- Changed the recipe of the Acceleration rune so that it is a T4 rune.

- Added the Charging rune, which accumulates charge by using the LP from the Blood Altar (1 charge = 1 LP always). If enough charge is stored when crafting, the crafting occurs instantly.
This commit is contained in:
WayofTime 2016-09-22 14:20:05 -04:00
parent dade5f0837
commit ca96afa375
13 changed files with 699 additions and 12 deletions

View file

@ -0,0 +1,170 @@
package WayofTime.bloodmagic.entity.ai;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.pathfinding.Path;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
public class EntityAIPickUpAlly extends EntityAIBase
{
World worldObj;
protected EntityAspectedDemonBase entity;
/**
* An amount of decrementing ticks that allows the entity to attack once the
* tick reaches 0.
*/
protected int attackTick;
/** The speed with which the mob will approach the target */
double speedTowardsTarget;
/**
* When true, the mob will continue chasing its target, even if it can't
* find a path to them right now.
*/
boolean longMemory;
/** The PathEntity of our entity. */
Path entityPathEntity;
private int delayCounter;
private double targetX;
private double targetY;
private double targetZ;
protected final int attackInterval = 20;
private int failedPathFindingPenalty = 0;
private boolean canPenalize = false;
private EntityLivingBase pickupTarget = null;
public EntityAIPickUpAlly(EntityAspectedDemonBase creature, double speedIn, boolean useLongMemory)
{
this.entity = creature;
this.worldObj = creature.worldObj;
this.speedTowardsTarget = speedIn;
this.longMemory = useLongMemory;
this.setMutexBits(3);
}
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (this.entity.getRidingEntity() != null)
{
return false;
}
AxisAlignedBB bb = new AxisAlignedBB(entity.posX - 0.5, entity.posY - 0.5, entity.posZ - 0.5, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5).expandXyz(5);
List<EntityLivingBase> list = this.entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType()));
for (EntityLivingBase testEntity : list)
{
if (testEntity != this.entity)
{
Path path = this.entity.getNavigator().getPathToEntityLiving(testEntity);
if (path != null)
{
this.entityPathEntity = path;
this.pickupTarget = testEntity;
return true;
}
}
}
return false;
}
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
return this.entity.getRidingEntity() != null;
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
this.entity.getNavigator().setPath(this.entityPathEntity, this.speedTowardsTarget);
this.delayCounter = 0;
}
/**
* Resets the task
*/
public void resetTask()
{
this.entity.getNavigator().clearPathEntity();
this.pickupTarget = null;
}
/**
* Updates the task
*/
public void updateTask()
{
EntityLivingBase entitylivingbase = this.pickupTarget;
this.entity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
double d0 = this.entity.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
--this.delayCounter;
if ((this.longMemory || this.entity.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.entity.getRNG().nextFloat() < 0.05F))
{
this.targetX = entitylivingbase.posX;
this.targetY = entitylivingbase.getEntityBoundingBox().minY;
this.targetZ = entitylivingbase.posZ;
this.delayCounter = 4 + this.entity.getRNG().nextInt(7);
if (this.canPenalize)
{
this.delayCounter += failedPathFindingPenalty;
if (this.entity.getNavigator().getPath() != null)
{
net.minecraft.pathfinding.PathPoint finalPathPoint = this.entity.getNavigator().getPath().getFinalPathPoint();
if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.xCoord, finalPathPoint.yCoord, finalPathPoint.zCoord) < 1)
failedPathFindingPenalty = 0;
else
failedPathFindingPenalty += 10;
} else
{
failedPathFindingPenalty += 10;
}
}
if (d0 > 1024.0D)
{
this.delayCounter += 10;
} else if (d0 > 256.0D)
{
this.delayCounter += 5;
}
if (!this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget))
{
this.delayCounter += 15;
}
}
this.attackTick = Math.max(this.attackTick - 1, 0);
this.pickUpEntity(entitylivingbase, d0);
}
protected void pickUpEntity(EntityLivingBase potentialPickup, double distance)
{
double d0 = this.getAttackReachSqr(potentialPickup);
if (distance <= d0 && this.attackTick <= 0 && !potentialPickup.isRiding())
{
System.out.println("Hai!");
potentialPickup.startRiding(this.entity, true);
}
}
protected double getAttackReachSqr(EntityLivingBase attackTarget)
{
return (double) (this.entity.width * 2.0F * this.entity.width * 2.0F + attackTarget.width);
}
}

View file

@ -120,7 +120,7 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
@Override
public double getBaseKnockbackResist(EnumDemonWillType type)
{
return super.getBaseKnockbackResist(type) + 0.2;
return super.getBaseKnockbackResist(type);
}
@Override
@ -187,6 +187,12 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
return SoundEvents.ENTITY_CHICKEN_DEATH;
}
@Override
protected float getSoundPitch()
{
return super.getSoundPitch() * 0.5f;
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{

View file

@ -0,0 +1,246 @@
package WayofTime.bloodmagic.entity.mob;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILeapAtTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.pathfinding.PathNavigateClimber;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIPickUpAlly;
public class EntityCorruptedSpider extends EntityAspectedDemonBase
{
private static final DataParameter<Byte> CLIMBING = EntityDataManager.<Byte>createKey(EntityCorruptedSpider.class, DataSerializers.BYTE);
public EntityCorruptedSpider(World world)
{
this(world, EnumDemonWillType.DEFAULT);
}
public EntityCorruptedSpider(World world, EnumDemonWillType type)
{
super(world);
this.setSize(1.4F, 0.9F);
this.setType(type);
}
protected void initEntityAI()
{
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
this.tasks.addTask(3, new EntityAIPickUpAlly(this, 1, true));
this.tasks.addTask(4, new EntityCorruptedSpider.AISpiderAttack(this));
this.tasks.addTask(5, new EntityAIWander(this, 0.8D));
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(6, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<EntityPlayer>(this, EntityPlayer.class, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityLivingBase>(this, EntityLivingBase.class, 10, true, false, new EntityAspectedDemonBase.TeamAttackPredicate(this)));
}
@Override
public double getBaseHP(EnumDemonWillType type)
{
return super.getBaseHP(type);
}
@Override
public double getBaseMeleeDamage(EnumDemonWillType type)
{
return super.getBaseMeleeDamage(type);
}
@Override
public double getBaseSpeed(EnumDemonWillType type)
{
return super.getBaseSpeed(type);
}
@Override
public double getBaseSprintModifier(EnumDemonWillType type)
{
return super.getBaseSprintModifier(type);
}
@Override
public double getBaseKnockbackResist(EnumDemonWillType type)
{
return super.getBaseKnockbackResist(type);
}
@Override
public double getMountedYOffset()
{
return (double) (this.height * 0.5F);
}
@Override
protected PathNavigate getNewNavigator(World worldIn)
{
return new PathNavigateClimber(this, worldIn);
}
@Override
protected void entityInit()
{
super.entityInit();
this.dataManager.register(CLIMBING, Byte.valueOf((byte) 0));
}
@Override
public void onUpdate()
{
super.onUpdate();
if (!this.worldObj.isRemote)
{
this.setBesideClimbableBlock(this.isCollidedHorizontally);
}
}
@Override
protected SoundEvent getAmbientSound()
{
return SoundEvents.ENTITY_SPIDER_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
return SoundEvents.ENTITY_SPIDER_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
return SoundEvents.ENTITY_SPIDER_DEATH;
}
@Override
protected float getSoundPitch()
{
return super.getSoundPitch() * 0.5f;
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{
this.playSound(SoundEvents.ENTITY_SPIDER_STEP, 0.15F, 1.0F);
}
@Override
public boolean isOnLadder()
{
return this.isBesideClimbableBlock();
}
@Override
public void setInWeb()
{
}
@Override
public EnumCreatureAttribute getCreatureAttribute()
{
return EnumCreatureAttribute.ARTHROPOD;
}
@Override
public boolean isPotionApplicable(PotionEffect potioneffectIn)
{
return potioneffectIn.getPotion() == MobEffects.POISON ? false : super.isPotionApplicable(potioneffectIn);
}
public boolean isBesideClimbableBlock()
{
return (((Byte) this.dataManager.get(CLIMBING)).byteValue() & 1) != 0;
}
public void setBesideClimbableBlock(boolean climbing)
{
byte b0 = ((Byte) this.dataManager.get(CLIMBING)).byteValue();
if (climbing)
{
b0 = (byte) (b0 | 1);
} else
{
b0 = (byte) (b0 & -2);
}
this.dataManager.set(CLIMBING, Byte.valueOf(b0));
}
@Override
public float getEyeHeight()
{
return 0.65F;
}
static class AISpiderAttack extends EntityAIAttackMelee
{
public AISpiderAttack(EntityCorruptedSpider spider)
{
super(spider, 1.0D, true);
}
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
float f = this.attacker.getBrightness(1.0F);
if (f >= 0.5F && this.attacker.getRNG().nextInt(100) == 0)
{
this.attacker.setAttackTarget((EntityLivingBase) null);
return false;
} else
{
return super.continueExecuting();
}
}
protected double getAttackReachSqr(EntityLivingBase attackTarget)
{
return (double) (4.0F + attackTarget.width);
}
}
static class AISpiderTarget<T extends EntityLivingBase> extends EntityAINearestAttackableTarget<T>
{
public AISpiderTarget(EntityCorruptedSpider spider, Class<T> classTarget)
{
super(spider, classTarget, true);
}
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
float f = this.taskOwner.getBrightness(1.0F);
return f >= 0.5F ? false : super.shouldExecute();
}
}
}