Run formatter

This commit is contained in:
Nicholas Ignoffo 2017-08-15 21:30:48 -07:00
parent 61c44a831b
commit 08258fd6ef
606 changed files with 13464 additions and 22975 deletions

View file

@ -1,25 +1,23 @@
package WayofTime.bloodmagic.entity.ai;
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.item.ItemBow;
import net.minecraft.util.EnumHand;
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
public class EntityAIAttackRangedBow extends EntityAIBase
{
public class EntityAIAttackRangedBow extends EntityAIBase {
private final EntityDemonBase entity;
private final double moveSpeedAmp;
private int attackCooldown;
private final float maxAttackDistance;
private int attackCooldown;
private int attackTime = -1;
private int seeTime;
private boolean strafingClockwise;
private boolean strafingBackwards;
private int strafingTime = -1;
public EntityAIAttackRangedBow(EntityDemonBase entityDemonBase, double speedAmplifier, int delay, float maxDistance)
{
public EntityAIAttackRangedBow(EntityDemonBase entityDemonBase, double speedAmplifier, int delay, float maxDistance) {
this.entity = entityDemonBase;
this.moveSpeedAmp = speedAmplifier;
this.attackCooldown = delay;
@ -27,45 +25,39 @@ public class EntityAIAttackRangedBow extends EntityAIBase
this.setMutexBits(3);
}
public void setAttackCooldown(int p_189428_1_)
{
public void setAttackCooldown(int p_189428_1_) {
this.attackCooldown = p_189428_1_;
}
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
public boolean shouldExecute() {
return this.entity.getAttackTarget() != null && this.isBowInMainhand();
}
protected boolean isBowInMainhand()
{
protected boolean isBowInMainhand() {
return this.entity.getHeldItemMainhand().getItem() instanceof ItemBow;
}
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
public boolean continueExecuting() {
return (this.shouldExecute() || !this.entity.getNavigator().noPath()) && this.isBowInMainhand();
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
super.startExecuting();
}
/**
* Resets the task
*/
public void resetTask()
{
public void resetTask() {
super.startExecuting();
this.seeTime = 0;
this.attackTime = -1;
@ -75,89 +67,70 @@ public class EntityAIAttackRangedBow extends EntityAIBase
/**
* Updates the task
*/
public void updateTask()
{
public void updateTask() {
EntityLivingBase entitylivingbase = this.entity.getAttackTarget();
if (entitylivingbase != null)
{
if (entitylivingbase != null) {
double d0 = this.entity.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
boolean flag = this.entity.getEntitySenses().canSee(entitylivingbase);
boolean flag1 = this.seeTime > 0;
if (flag != flag1)
{
if (flag != flag1) {
this.seeTime = 0;
}
if (flag)
{
if (flag) {
++this.seeTime;
} else
{
} else {
--this.seeTime;
}
if (d0 <= (double) this.maxAttackDistance && this.seeTime >= 20)
{
if (d0 <= (double) this.maxAttackDistance && this.seeTime >= 20) {
this.entity.getNavigator().clearPathEntity();
++this.strafingTime;
} else
{
} else {
this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.moveSpeedAmp);
this.strafingTime = -1;
}
if (this.strafingTime >= 20)
{
if ((double) this.entity.getRNG().nextFloat() < 0.3D)
{
if (this.strafingTime >= 20) {
if ((double) this.entity.getRNG().nextFloat() < 0.3D) {
this.strafingClockwise = !this.strafingClockwise;
}
if ((double) this.entity.getRNG().nextFloat() < 0.3D)
{
if ((double) this.entity.getRNG().nextFloat() < 0.3D) {
this.strafingBackwards = !this.strafingBackwards;
}
this.strafingTime = 0;
}
if (this.strafingTime > -1)
{
if (d0 > (double) (this.maxAttackDistance * 0.75F))
{
if (this.strafingTime > -1) {
if (d0 > (double) (this.maxAttackDistance * 0.75F)) {
this.strafingBackwards = false;
} else if (d0 < (double) (this.maxAttackDistance * 0.25F))
{
} else if (d0 < (double) (this.maxAttackDistance * 0.25F)) {
this.strafingBackwards = true;
}
this.entity.getMoveHelper().strafe(this.strafingBackwards ? -0.5F : 0.5F, this.strafingClockwise ? 0.5F : -0.5F);
this.entity.faceEntity(entitylivingbase, 30.0F, 30.0F);
} else
{
} else {
this.entity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
}
if (this.entity.isHandActive())
{
if (!flag && this.seeTime < -60)
{
if (this.entity.isHandActive()) {
if (!flag && this.seeTime < -60) {
this.entity.resetActiveHand();
} else if (flag)
{
} else if (flag) {
int i = this.entity.getItemInUseMaxCount();
if (i >= 20)
{
if (i >= 20) {
this.entity.resetActiveHand();
this.entity.attackEntityWithRangedAttack(entitylivingbase, ItemBow.getArrowVelocity(i));
this.attackTime = this.attackCooldown;
}
}
} else if (--this.attackTime <= 0 && this.seeTime >= -60)
{
} else if (--this.attackTime <= 0 && this.seeTime >= -60) {
this.entity.setActiveHand(EnumHand.MAIN_HAND);
}
}

View file

@ -1,41 +1,42 @@
package WayofTime.bloodmagic.entity.ai;
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.pathfinding.Path;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
public class EntityAIAttackStealthMelee extends EntityAIBase
{
public class EntityAIAttackStealthMelee extends EntityAIBase {
protected final int attackInterval = 20;
protected EntityCorruptedChicken chicken;
World worldObj;
/**
* 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 */
World worldObj;
/**
* 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. */
/**
* 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;
public EntityAIAttackStealthMelee(EntityCorruptedChicken creature, double speedIn, boolean useLongMemory)
{
public EntityAIAttackStealthMelee(EntityCorruptedChicken creature, double speedIn, boolean useLongMemory) {
this.chicken = creature;
this.worldObj = creature.getEntityWorld();
this.speedTowardsTarget = speedIn;
@ -44,32 +45,24 @@ public class EntityAIAttackStealthMelee extends EntityAIBase
}
@Override
public boolean shouldExecute()
{
if (chicken.attackStateMachine != 1)
{
public boolean shouldExecute() {
if (chicken.attackStateMachine != 1) {
return false;
}
EntityLivingBase entitylivingbase = this.chicken.getAttackTarget();
if (entitylivingbase == null)
{
if (entitylivingbase == null) {
return false;
} else if (!entitylivingbase.isEntityAlive())
{
} else if (!entitylivingbase.isEntityAlive()) {
return false;
} else
{
if (canPenalize)
{
if (--this.delayCounter <= 0)
{
} else {
if (canPenalize) {
if (--this.delayCounter <= 0) {
this.entityPathEntity = this.chicken.getNavigator().getPathToEntityLiving(entitylivingbase);
this.delayCounter = 4 + this.chicken.getRNG().nextInt(7);
return this.entityPathEntity != null;
} else
{
} else {
return true;
}
}
@ -79,61 +72,50 @@ public class EntityAIAttackStealthMelee extends EntityAIBase
}
@Override
public boolean shouldContinueExecuting()
{
public boolean shouldContinueExecuting() {
return chicken.attackStateMachine == 1 && super.shouldContinueExecuting();
}
@Override
public void resetTask()
{
if (chicken.attackStateMachine == 1)
{
public void resetTask() {
if (chicken.attackStateMachine == 1) {
chicken.attackStateMachine = 0;
}
}
@Override
public void updateTask()
{
public void updateTask() {
EntityLivingBase entitylivingbase = this.chicken.getAttackTarget();
this.chicken.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
double d0 = this.chicken.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
--this.delayCounter;
if ((this.longMemory || this.chicken.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.chicken.getRNG().nextFloat() < 0.05F))
{
if ((this.longMemory || this.chicken.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.chicken.getRNG().nextFloat() < 0.05F)) {
this.targetX = entitylivingbase.posX;
this.targetY = entitylivingbase.getEntityBoundingBox().minY;
this.targetZ = entitylivingbase.posZ;
this.delayCounter = 4 + this.chicken.getRNG().nextInt(7);
if (this.canPenalize)
{
if (this.canPenalize) {
this.delayCounter += failedPathFindingPenalty;
if (this.chicken.getNavigator().getPath() != null)
{
if (this.chicken.getNavigator().getPath() != null) {
net.minecraft.pathfinding.PathPoint finalPathPoint = this.chicken.getNavigator().getPath().getFinalPathPoint();
if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z) < 1)
failedPathFindingPenalty = 0;
else
failedPathFindingPenalty += 10;
} else
{
} else {
failedPathFindingPenalty += 10;
}
}
if (d0 > 1024.0D)
{
if (d0 > 1024.0D) {
this.delayCounter += 10;
} else if (d0 > 256.0D)
{
} else if (d0 > 256.0D) {
this.delayCounter += 5;
}
if (!this.chicken.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget))
{
if (!this.chicken.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) {
this.delayCounter += 15;
}
}
@ -142,12 +124,10 @@ public class EntityAIAttackStealthMelee extends EntityAIBase
this.attackEntity(entitylivingbase, d0);
}
protected void attackEntity(EntityLivingBase attacked, double distance)
{
protected void attackEntity(EntityLivingBase attacked, double distance) {
double d0 = this.getAttackReachSqr(attacked);
if (distance <= d0 && this.attackTick <= 0)
{
if (distance <= d0 && this.attackTick <= 0) {
this.attackTick = 20;
this.chicken.swingArm(EnumHand.MAIN_HAND);
this.chicken.attackEntityAsMob(attacked);
@ -156,8 +136,7 @@ public class EntityAIAttackStealthMelee extends EntityAIBase
}
}
protected double getAttackReachSqr(EntityLivingBase attackTarget)
{
protected double getAttackReachSqr(EntityLivingBase attackTarget) {
return (double) (this.chicken.width * 2.0F * this.chicken.width * 2.0F + attackTarget.width);
}
}

View file

@ -1,24 +1,28 @@
package WayofTime.bloodmagic.entity.ai;
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
import WayofTime.bloodmagic.inversion.CorruptionHandler;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
import WayofTime.bloodmagic.inversion.CorruptionHandler;
public class EntityAIEatAndCorruptBlock extends EntityAIBase
{
/** The entity owner of this AITask */
public class EntityAIEatAndCorruptBlock extends EntityAIBase {
/**
* The entity owner of this AITask
*/
private final EntityAspectedDemonBase grassEaterEntity;
/** The world the grass eater entity is eating from */
/**
* The world the grass eater entity is eating from
*/
private final World world;
/** Number of ticks since the entity started to eat grass */
/**
* Number of ticks since the entity started to eat grass
*/
int eatingGrassTimer;
public EntityAIEatAndCorruptBlock(EntityAspectedDemonBase entity)
{
public EntityAIEatAndCorruptBlock(EntityAspectedDemonBase entity) {
this.grassEaterEntity = entity;
this.world = entity.getEntityWorld();
this.setMutexBits(7);
@ -27,13 +31,10 @@ public class EntityAIEatAndCorruptBlock extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (this.grassEaterEntity.getRNG().nextInt(50) != 0)
{
public boolean shouldExecute() {
if (this.grassEaterEntity.getRNG().nextInt(50) != 0) {
return false;
} else
{
} else {
BlockPos pos = new BlockPos(this.grassEaterEntity.posX, this.grassEaterEntity.posY, this.grassEaterEntity.posZ).down();
IBlockState offsetState = world.getBlockState(pos);
Block offsetBlock = offsetState.getBlock();
@ -44,8 +45,7 @@ public class EntityAIEatAndCorruptBlock extends EntityAIBase
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.eatingGrassTimer = 40;
this.world.setEntityState(this.grassEaterEntity, (byte) 10);
this.grassEaterEntity.getNavigator().clearPathEntity();
@ -54,44 +54,38 @@ public class EntityAIEatAndCorruptBlock extends EntityAIBase
/**
* Resets the task
*/
public void resetTask()
{
public void resetTask() {
this.eatingGrassTimer = 0;
}
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
public boolean continueExecuting() {
return this.eatingGrassTimer > 0;
}
/**
* Number of ticks since the entity started to eat grass
*/
public int getEatingGrassTimer()
{
public int getEatingGrassTimer() {
return this.eatingGrassTimer;
}
/**
* Updates the task
*/
public void updateTask()
{
public void updateTask() {
this.eatingGrassTimer = Math.max(0, this.eatingGrassTimer - 1);
if (this.eatingGrassTimer == 4)
{
if (this.eatingGrassTimer == 4) {
BlockPos blockpos = new BlockPos(this.grassEaterEntity.posX, this.grassEaterEntity.posY, this.grassEaterEntity.posZ);
BlockPos offsetPos = blockpos.down();
IBlockState offsetState = world.getBlockState(offsetPos);
Block offsetBlock = offsetState.getBlock();
if (CorruptionHandler.isBlockCorruptible(world, grassEaterEntity.getType(), offsetPos, offsetState, offsetBlock))
{
if (CorruptionHandler.isBlockCorruptible(world, grassEaterEntity.getType(), offsetPos, offsetState, offsetBlock)) {
// if (this.world.getGameRules().getBoolean("mobGriefing"))
{
this.world.playEvent(2001, offsetPos, Block.getIdFromBlock(offsetBlock));

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.entity.ai;
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
@ -12,22 +13,19 @@ import net.minecraft.pathfinding.PathNodeType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
public class EntityAIFollowOwner extends EntityAIBase
{
public class EntityAIFollowOwner extends EntityAIBase {
World theWorld;
float maxDist;
float minDist;
private EntityDemonBase thePet;
private EntityLivingBase theOwner;
World theWorld;
private double followSpeed;
private PathNavigate petPathfinder;
private int timeToRecalcPath;
float maxDist;
float minDist;
private float oldWaterCost;
public EntityAIFollowOwner(EntityDemonBase thePetIn, double followSpeedIn, float minDistIn, float maxDistIn)
{
public EntityAIFollowOwner(EntityDemonBase thePetIn, double followSpeedIn, float minDistIn, float maxDistIn) {
this.thePet = thePetIn;
this.theWorld = thePetIn.getEntityWorld();
this.followSpeed = followSpeedIn;
@ -36,8 +34,7 @@ public class EntityAIFollowOwner extends EntityAIBase
this.maxDist = maxDistIn;
this.setMutexBits(3);
if (!(thePetIn.getNavigator() instanceof PathNavigateGround))
{
if (!(thePetIn.getNavigator() instanceof PathNavigateGround)) {
throw new IllegalArgumentException("Unsupported mob type for FollowOwnerGoal");
}
}
@ -45,24 +42,18 @@ public class EntityAIFollowOwner extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
public boolean shouldExecute() {
EntityLivingBase entitylivingbase = this.thePet.getOwner();
if (entitylivingbase == null)
{
if (entitylivingbase == null) {
return false;
} else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator())
{
} else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator()) {
return false;
} else if (this.thePet.isStationary())
{
} else if (this.thePet.isStationary()) {
return false;
} else if (this.thePet.getDistanceSqToEntity(entitylivingbase) < (double) (this.minDist * this.minDist))
{
} else if (this.thePet.getDistanceSqToEntity(entitylivingbase) < (double) (this.minDist * this.minDist)) {
return false;
} else
{
} else {
this.theOwner = entitylivingbase;
return true;
}
@ -71,16 +62,14 @@ public class EntityAIFollowOwner extends EntityAIBase
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
public boolean continueExecuting() {
return !this.petPathfinder.noPath() && this.thePet.getDistanceSqToEntity(this.theOwner) > (double) (this.maxDist * this.maxDist) && !this.thePet.isStationary();
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.timeToRecalcPath = 0;
this.oldWaterCost = this.thePet.getPathPriority(PathNodeType.WATER);
this.thePet.setPathPriority(PathNodeType.WATER, 0.0F);
@ -89,15 +78,13 @@ public class EntityAIFollowOwner extends EntityAIBase
/**
* Resets the task
*/
public void resetTask()
{
public void resetTask() {
this.theOwner = null;
this.petPathfinder.clearPathEntity();
this.thePet.setPathPriority(PathNodeType.WATER, this.oldWaterCost);
}
private boolean isEmptyBlock(BlockPos pos)
{
private boolean isEmptyBlock(BlockPos pos) {
IBlockState iblockstate = this.theWorld.getBlockState(pos);
Block block = iblockstate.getBlock();
return block == Blocks.AIR || !iblockstate.isFullCube();
@ -106,32 +93,23 @@ public class EntityAIFollowOwner extends EntityAIBase
/**
* Updates the task
*/
public void updateTask()
{
public void updateTask() {
this.thePet.getLookHelper().setLookPositionWithEntity(this.theOwner, 10.0F, (float) this.thePet.getVerticalFaceSpeed());
if (!this.thePet.isStationary())
{
if (--this.timeToRecalcPath <= 0)
{
if (!this.thePet.isStationary()) {
if (--this.timeToRecalcPath <= 0) {
this.timeToRecalcPath = 10;
if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed))
{
if (!this.thePet.getLeashed())
{
if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D)
{
if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed)) {
if (!this.thePet.getLeashed()) {
if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D) {
int i = MathHelper.floor(this.theOwner.posX) - 2;
int j = MathHelper.floor(this.theOwner.posZ) - 2;
int k = MathHelper.floor(this.theOwner.getEntityBoundingBox().minY);
for (int l = 0; l <= 4; ++l)
{
for (int i1 = 0; i1 <= 4; ++i1)
{
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1)))
{
for (int l = 0; l <= 4; ++l) {
for (int i1 = 0; i1 <= 4; ++i1) {
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1))) {
this.thePet.setLocationAndAngles((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.thePet.rotationYaw, this.thePet.rotationPitch);
this.petPathfinder.clearPathEntity();
return;

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.entity.ai;
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
@ -12,25 +13,22 @@ import net.minecraft.pathfinding.PathNodeType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
public class EntityAIGrabEffectsFromOwner extends EntityAIBase
{
public class EntityAIGrabEffectsFromOwner extends EntityAIBase {
World theWorld;
float minDist;
private EntitySentientSpecter thePet;
private EntityLivingBase theOwner;
World theWorld;
private double followSpeed;
private PathNavigate petPathfinder;
private int timeToRecalcPath;
float minDist;
private float oldWaterCost;
/**
* In order to steal effects from the owner, the mob has to be close to the
* owner.
*/
public EntityAIGrabEffectsFromOwner(EntitySentientSpecter thePetIn, double followSpeedIn, float minDistIn)
{
public EntityAIGrabEffectsFromOwner(EntitySentientSpecter thePetIn, double followSpeedIn, float minDistIn) {
this.thePet = thePetIn;
this.theWorld = thePetIn.getEntityWorld();
this.followSpeed = followSpeedIn;
@ -38,8 +36,7 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase
this.minDist = minDistIn;
this.setMutexBits(3);
if (!(thePetIn.getNavigator() instanceof PathNavigateGround))
{
if (!(thePetIn.getNavigator() instanceof PathNavigateGround)) {
throw new IllegalArgumentException("Unsupported mob type for FollowOwnerGoal");
}
}
@ -47,27 +44,21 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
public boolean shouldExecute() {
EntityLivingBase entitylivingbase = this.thePet.getOwner();
if (entitylivingbase == null)
{
if (entitylivingbase == null) {
return false;
} else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator())
{
} else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator()) {
return false;
} else if (this.thePet.isStationary())
{
} else if (this.thePet.isStationary()) {
return false;
// } else if (this.thePet.getDistanceSqToEntity(entitylivingbase) < (double) (this.minDist * this.minDist))
// {
// return false;
} else if (!this.thePet.canStealEffectFromOwner(entitylivingbase))
{
} else if (!this.thePet.canStealEffectFromOwner(entitylivingbase)) {
return false;
} else
{
} else {
this.theOwner = entitylivingbase;
return true;
}
@ -76,16 +67,14 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
public boolean continueExecuting() {
return this.thePet.canStealEffectFromOwner(theOwner);// || !this.petPathfinder.noPath() && this.thePet.getDistanceSqToEntity(this.theOwner) > (double) (this.minDist * this.minDist) && !this.thePet.isStationary();
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.timeToRecalcPath = 0;
this.oldWaterCost = this.thePet.getPathPriority(PathNodeType.WATER);
this.thePet.setPathPriority(PathNodeType.WATER, 0.0F);
@ -94,15 +83,13 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase
/**
* Resets the task
*/
public void resetTask()
{
public void resetTask() {
this.theOwner = null;
this.petPathfinder.clearPathEntity();
this.thePet.setPathPriority(PathNodeType.WATER, this.oldWaterCost);
}
private boolean isEmptyBlock(BlockPos pos)
{
private boolean isEmptyBlock(BlockPos pos) {
IBlockState iblockstate = this.theWorld.getBlockState(pos);
Block block = iblockstate.getBlock();
return block == Blocks.AIR || !iblockstate.isFullCube();
@ -111,40 +98,29 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase
/**
* Updates the task
*/
public void updateTask()
{
public void updateTask() {
this.thePet.getLookHelper().setLookPositionWithEntity(this.theOwner, 10.0F, (float) this.thePet.getVerticalFaceSpeed());
if (this.thePet.getDistanceSqToEntity(theOwner) < this.minDist * this.minDist)
{
if (this.thePet.stealEffectsFromOwner(theOwner))
{
if (this.thePet.getDistanceSqToEntity(theOwner) < this.minDist * this.minDist) {
if (this.thePet.stealEffectsFromOwner(theOwner)) {
return;
}
}
if (!this.thePet.isStationary())
{
if (--this.timeToRecalcPath <= 0)
{
if (!this.thePet.isStationary()) {
if (--this.timeToRecalcPath <= 0) {
this.timeToRecalcPath = 10;
if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed))
{
if (!this.thePet.getLeashed())
{
if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D)
{
if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed)) {
if (!this.thePet.getLeashed()) {
if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D) {
int i = MathHelper.floor(this.theOwner.posX) - 2;
int j = MathHelper.floor(this.theOwner.posZ) - 2;
int k = MathHelper.floor(this.theOwner.getEntityBoundingBox().minY);
for (int l = 0; l <= 4; ++l)
{
for (int i1 = 0; i1 <= 4; ++i1)
{
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1)))
{
for (int l = 0; l <= 4; ++l) {
for (int i1 = 0; i1 <= 4; ++i1) {
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1))) {
this.thePet.setLocationAndAngles((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.thePet.rotationYaw, this.thePet.rotationPitch);
this.petPathfinder.clearPathEntity();
return;

View file

@ -1,28 +1,23 @@
package WayofTime.bloodmagic.entity.ai;
import java.util.UUID;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityOwnable;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
public class EntityAIHurtByTargetIgnoreTamed extends EntityAIHurtByTarget
{
public EntityAIHurtByTargetIgnoreTamed(EntityCreature creatureIn, boolean entityCallsForHelpIn, Class<?>... targetClassesIn)
{
import java.util.UUID;
public class EntityAIHurtByTargetIgnoreTamed extends EntityAIHurtByTarget {
public EntityAIHurtByTargetIgnoreTamed(EntityCreature creatureIn, boolean entityCallsForHelpIn, Class<?>... targetClassesIn) {
super(creatureIn, true, targetClassesIn);
}
@Override
public boolean isSuitableTarget(EntityLivingBase target, boolean includeInvincibles)
{
if (this.taskOwner instanceof IEntityOwnable && target instanceof IEntityOwnable)
{
public boolean isSuitableTarget(EntityLivingBase target, boolean includeInvincibles) {
if (this.taskOwner instanceof IEntityOwnable && target instanceof IEntityOwnable) {
UUID thisId = ((IEntityOwnable) this.taskOwner).getOwnerId();
UUID targetId = ((IEntityOwnable) target).getOwnerId();
if (thisId != null && targetId != null && thisId.equals(targetId))
{
if (thisId != null && targetId != null && thisId.equals(targetId)) {
return false;
}
}

View file

@ -1,31 +1,26 @@
package WayofTime.bloodmagic.entity.ai;
import WayofTime.bloodmagic.entity.mob.EntityMimic;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.util.math.BlockPos;
import WayofTime.bloodmagic.entity.mob.EntityMimic;
public class EntityAIMimicReform extends EntityAIBase
{
public class EntityAIMimicReform extends EntityAIBase {
private final EntityMimic theEntity;
public EntityAIMimicReform(EntityMimic creatureIn)
{
public EntityAIMimicReform(EntityMimic creatureIn) {
this.theEntity = creatureIn;
this.setMutexBits(2);
}
@Override
public boolean shouldExecute()
{
public boolean shouldExecute() {
return this.theEntity.ticksExisted > 100 && this.theEntity.hasHome() && this.theEntity.isWithinHomeDistanceCurrentPosition();
}
@Override
public void startExecuting()
{
public void startExecuting() {
BlockPos homePos = this.theEntity.getHomePosition();
if (theEntity.reformIntoMimicBlock(homePos))
{
if (theEntity.reformIntoMimicBlock(homePos)) {
this.theEntity.setDead();
}
}

View file

@ -1,17 +1,15 @@
package WayofTime.bloodmagic.entity.ai;
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAITarget;
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
public class EntityAIOwnerHurtByTarget extends EntityAITarget
{
public class EntityAIOwnerHurtByTarget extends EntityAITarget {
EntityDemonBase theDefendingTameable;
EntityLivingBase theOwnerAttacker;
private int timestamp;
public EntityAIOwnerHurtByTarget(EntityDemonBase theDefendingTameableIn)
{
public EntityAIOwnerHurtByTarget(EntityDemonBase theDefendingTameableIn) {
super(theDefendingTameableIn, false);
this.theDefendingTameable = theDefendingTameableIn;
this.setMutexBits(1);
@ -20,20 +18,15 @@ public class EntityAIOwnerHurtByTarget extends EntityAITarget
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (!this.theDefendingTameable.isTamed())
{
public boolean shouldExecute() {
if (!this.theDefendingTameable.isTamed()) {
return false;
} else
{
} else {
EntityLivingBase owner = this.theDefendingTameable.getOwner();
if (owner == null)
{
if (owner == null) {
return false;
} else
{
} else {
this.theOwnerAttacker = owner.getRevengeTarget();
int i = owner.getRevengeTimer();
return i != this.timestamp && this.isSuitableTarget(this.theOwnerAttacker, false) && this.theDefendingTameable.shouldAttackEntity(this.theOwnerAttacker, owner);
@ -44,13 +37,11 @@ public class EntityAIOwnerHurtByTarget extends EntityAITarget
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.taskOwner.setAttackTarget(this.theOwnerAttacker);
EntityLivingBase owner = this.theDefendingTameable.getOwner();
if (owner != null)
{
if (owner != null) {
this.timestamp = owner.getRevengeTimer();
}

View file

@ -1,17 +1,15 @@
package WayofTime.bloodmagic.entity.ai;
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAITarget;
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
public class EntityAIOwnerHurtTarget extends EntityAITarget
{
public class EntityAIOwnerHurtTarget extends EntityAITarget {
EntityDemonBase theEntityDemonBase;
EntityLivingBase theTarget;
private int timestamp;
public EntityAIOwnerHurtTarget(EntityDemonBase theEntityDemonBaseIn)
{
public EntityAIOwnerHurtTarget(EntityDemonBase theEntityDemonBaseIn) {
super(theEntityDemonBaseIn, false);
this.theEntityDemonBase = theEntityDemonBaseIn;
this.setMutexBits(1);
@ -20,20 +18,15 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (!this.theEntityDemonBase.isTamed())
{
public boolean shouldExecute() {
if (!this.theEntityDemonBase.isTamed()) {
return false;
} else
{
} else {
EntityLivingBase entitylivingbase = this.theEntityDemonBase.getOwner();
if (entitylivingbase == null)
{
if (entitylivingbase == null) {
return false;
} else
{
} else {
this.theTarget = entitylivingbase.getLastAttackedEntity();
int i = entitylivingbase.getLastAttackedEntityTime();
return i != this.timestamp && this.isSuitableTarget(this.theTarget, false) && this.theEntityDemonBase.shouldAttackEntity(this.theTarget, entitylivingbase);
@ -44,13 +37,11 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.taskOwner.setAttackTarget(this.theTarget);
EntityLivingBase entitylivingbase = this.theEntityDemonBase.getOwner();
if (entitylivingbase != null)
{
if (entitylivingbase != null) {
this.timestamp = entitylivingbase.getLastAttackedEntityTime();
}

View file

@ -1,44 +1,46 @@
package WayofTime.bloodmagic.entity.ai;
import java.util.List;
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
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;
import java.util.List;
public class EntityAIPickUpAlly extends EntityAIBase {
protected final int attackInterval = 20;
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 */
World worldObj;
/**
* 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. */
/**
* 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)
{
public EntityAIPickUpAlly(EntityAspectedDemonBase creature, double speedIn, boolean useLongMemory) {
this.entity = creature;
this.worldObj = creature.getEntityWorld();
this.speedTowardsTarget = speedIn;
@ -49,22 +51,17 @@ public class EntityAIPickUpAlly extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (this.entity.getRidingEntity() != null)
{
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).grow(5);
List<EntityLivingBase> list = this.entity.getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType()));
for (EntityLivingBase testEntity : list)
{
if (testEntity != this.entity)
{
for (EntityLivingBase testEntity : list) {
if (testEntity != this.entity) {
Path path = this.entity.getNavigator().getPathToEntityLiving(testEntity);
if (path != null)
{
if (path != null) {
this.entityPathEntity = path;
this.pickupTarget = testEntity;
return true;
@ -78,16 +75,14 @@ public class EntityAIPickUpAlly extends EntityAIBase
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
public boolean continueExecuting() {
return this.entity.getRidingEntity() != null;
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.entity.getNavigator().setPath(this.entityPathEntity, this.speedTowardsTarget);
this.delayCounter = 0;
}
@ -95,8 +90,7 @@ public class EntityAIPickUpAlly extends EntityAIBase
/**
* Resets the task
*/
public void resetTask()
{
public void resetTask() {
this.entity.getNavigator().clearPathEntity();
this.pickupTarget = null;
}
@ -104,46 +98,38 @@ public class EntityAIPickUpAlly extends EntityAIBase
/**
* Updates the task
*/
public void updateTask()
{
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))
{
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)
{
if (this.canPenalize) {
this.delayCounter += failedPathFindingPenalty;
if (this.entity.getNavigator().getPath() != null)
{
if (this.entity.getNavigator().getPath() != null) {
net.minecraft.pathfinding.PathPoint finalPathPoint = this.entity.getNavigator().getPath().getFinalPathPoint();
if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z) < 1)
failedPathFindingPenalty = 0;
else
failedPathFindingPenalty += 10;
} else
{
} else {
failedPathFindingPenalty += 10;
}
}
if (d0 > 1024.0D)
{
if (d0 > 1024.0D) {
this.delayCounter += 10;
} else if (d0 > 256.0D)
{
} else if (d0 > 256.0D) {
this.delayCounter += 5;
}
if (!this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget))
{
if (!this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) {
this.delayCounter += 15;
}
}
@ -152,19 +138,16 @@ public class EntityAIPickUpAlly extends EntityAIBase
this.pickUpEntity(entitylivingbase, d0);
}
protected void pickUpEntity(EntityLivingBase potentialPickup, double distance)
{
protected void pickUpEntity(EntityLivingBase potentialPickup, double distance) {
double d0 = this.getAttackReachSqr(potentialPickup);
if (distance <= d0 && this.attackTick <= 0 && !potentialPickup.isRiding())
{
if (distance <= d0 && this.attackTick <= 0 && !potentialPickup.isRiding()) {
System.out.println("Hai!");
potentialPickup.startRiding(this.entity, true);
}
}
protected double getAttackReachSqr(EntityLivingBase attackTarget)
{
protected double getAttackReachSqr(EntityLivingBase attackTarget) {
return (double) (this.entity.width * 2.0F * this.entity.width * 2.0F + attackTarget.width);
}
}

View file

@ -1,32 +1,35 @@
package WayofTime.bloodmagic.entity.ai;
import java.util.List;
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
public class EntityAIProtectAlly extends EntityAIBase
{
/** The entity owner of this AITask */
import java.util.List;
public class EntityAIProtectAlly extends EntityAIBase {
/**
* The entity owner of this AITask
*/
private final EntityCorruptedSheep entity;
/** The world the grass eater entity is eating from */
/**
* The world the grass eater entity is eating from
*/
private final World world;
/** Number of ticks since the entity started to eat grass */
/**
* Number of ticks since the entity started to eat grass
*/
int castTimer;
public EntityAIProtectAlly(EntityCorruptedSheep entity)
{
public EntityAIProtectAlly(EntityCorruptedSheep entity) {
this.entity = entity;
this.world = entity.getEntityWorld();
this.setMutexBits(7);
}
public int getCastTimer()
{
public int getCastTimer() {
return this.castTimer;
}
@ -34,16 +37,12 @@ public class EntityAIProtectAlly extends EntityAIBase
* Returns whether the EntityAIBase should begin execution.
*/
@Override
public boolean shouldExecute()
{
public boolean shouldExecute() {
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).grow(5);
List<EntityLivingBase> list = world.getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType()));
for (EntityLivingBase testEntity : list)
{
if (testEntity != this.entity)
{
if (this.entity.canProtectAlly(testEntity))
{
for (EntityLivingBase testEntity : list) {
if (testEntity != this.entity) {
if (this.entity.canProtectAlly(testEntity)) {
return true;
}
}
@ -56,8 +55,7 @@ public class EntityAIProtectAlly extends EntityAIBase
* Execute a one shot task or start executing a continuous task
*/
@Override
public void startExecuting()
{
public void startExecuting() {
this.castTimer = 100;
this.world.setEntityState(this.entity, (byte) 53);
this.entity.getNavigator().clearPathEntity();
@ -67,8 +65,7 @@ public class EntityAIProtectAlly extends EntityAIBase
* Resets the task
*/
@Override
public void resetTask()
{
public void resetTask() {
this.castTimer = 0;
}
@ -76,8 +73,7 @@ public class EntityAIProtectAlly extends EntityAIBase
* Returns whether an in-progress EntityAIBase should continue executing
*/
@Override
public boolean shouldContinueExecuting()
{
public boolean shouldContinueExecuting() {
return castTimer > 0;
}
@ -85,19 +81,14 @@ public class EntityAIProtectAlly extends EntityAIBase
* Updates the task
*/
@Override
public void updateTask()
{
public void updateTask() {
this.castTimer = Math.max(0, this.castTimer - 1);
if (castTimer == 0)
{
if (castTimer == 0) {
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).grow(5);
List<EntityLivingBase> list = world.getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType()));
for (EntityLivingBase testEntity : list)
{
if (testEntity != this.entity)
{
if (this.entity.applyProtectionToAlly(testEntity))
{
for (EntityLivingBase testEntity : list) {
if (testEntity != this.entity) {
if (this.entity.applyProtectionToAlly(testEntity)) {
return;
}
}

View file

@ -1,9 +1,8 @@
package WayofTime.bloodmagic.entity.ai;
import java.util.List;
import javax.annotation.Nullable;
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.RandomPositionGenerator;
@ -11,35 +10,36 @@ import net.minecraft.pathfinding.Path;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.util.EntitySelectors;
import net.minecraft.util.math.Vec3d;
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import java.util.List;
public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
{
public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase {
private final Predicate<Entity> canBeSeenSelector;
/** The entity we are attached to */
/**
* The entity we are attached to
*/
protected EntityDemonBase theEntity;
protected T closestLivingEntity;
private double farSpeed;
private double nearSpeed;
private double safeHealDistance = 3;
protected T closestLivingEntity;
private float avoidDistance;
/** The PathEntity of our entity */
/**
* The PathEntity of our entity
*/
private Path entityPathEntity;
/** The PathNavigate of our entity */
/**
* The PathNavigate of our entity
*/
private PathNavigate entityPathNavigate;
private Class<T> classToAvoid;
private Predicate<? super T> avoidTargetSelector;
public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class<T> classToAvoidIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn)
{
public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class<T> classToAvoidIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) {
this(theEntityIn, classToAvoidIn, Predicates.<T>alwaysTrue(), avoidDistanceIn, farSpeedIn, nearSpeedIn);
}
public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class<T> classToAvoidIn, Predicate<? super T> avoidTargetSelectorIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn)
{
public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class<T> classToAvoidIn, Predicate<? super T> avoidTargetSelectorIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) {
this.canBeSeenSelector = p_apply_1_ -> p_apply_1_.isEntityAlive() && EntityAIRetreatToHeal.this.theEntity.getEntitySenses().canSee(p_apply_1_);
this.theEntity = theEntityIn;
this.classToAvoid = classToAvoidIn;
@ -55,32 +55,25 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
* Returns whether the EntityAIBase should begin execution.
*/
@Override
public boolean shouldExecute()
{
if (!this.theEntity.shouldEmergencyHeal())
{
public boolean shouldExecute() {
if (!this.theEntity.shouldEmergencyHeal()) {
return false;
}
//This part almost doesn't matter
List<T> list = this.theEntity.getEntityWorld().getEntitiesWithinAABB(this.classToAvoid, this.theEntity.getEntityBoundingBox().expand((double) this.avoidDistance, 3.0D, (double) this.avoidDistance), Predicates.and(EntitySelectors.CAN_AI_TARGET, this.canBeSeenSelector, this.avoidTargetSelector));
if (list.isEmpty())
{
if (list.isEmpty()) {
return true; //No entities nearby, so I can freely heal
} else
{
} else {
this.closestLivingEntity = list.get(0);
Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, new Vec3d(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ));
if (vec3d == null)
{
if (vec3d == null) {
return false; //Nowhere to run, gotta fight!
} else if (this.closestLivingEntity.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity))
{
} else if (this.closestLivingEntity.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity)) {
return false; //I'll be headed off if I choose this direction.
} else
{
} else {
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3d.x, vec3d.y, vec3d.z);
return this.entityPathEntity != null;
}
@ -91,8 +84,7 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
* Returns whether an in-progress EntityAIBase should continue executing
*/
@Override
public boolean shouldContinueExecuting()
{
public boolean shouldContinueExecuting() {
return this.theEntity.shouldEmergencyHeal();//!this.entityPathNavigate.noPath();
}
@ -100,10 +92,8 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
* Execute a one shot task or start executing a continuous task
*/
@Override
public void startExecuting()
{
if (this.entityPathEntity != null)
{
public void startExecuting() {
if (this.entityPathEntity != null) {
this.entityPathNavigate.setPath(this.entityPathEntity, this.farSpeed);
}
}
@ -112,8 +102,7 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
* Resets the task
*/
@Override
public void resetTask()
{
public void resetTask() {
this.closestLivingEntity = null;
}
@ -121,33 +110,26 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
* Updates the task
*/
@Override
public void updateTask()
{
if (this.closestLivingEntity != null)
{
if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D)
{
public void updateTask() {
if (this.closestLivingEntity != null) {
if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D) {
this.theEntity.getNavigator().setSpeed(this.nearSpeed);
} else
{
} else {
this.theEntity.getNavigator().setSpeed(this.farSpeed);
}
if (this.theEntity.ticksExisted % 20 == 0 && this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) >= safeHealDistance * safeHealDistance)
{
if (this.theEntity.ticksExisted % 20 == 0 && this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) >= safeHealDistance * safeHealDistance) {
healEntity();
return;
}
}
if (this.theEntity.ticksExisted % 20 == 0)
{
if (this.theEntity.ticksExisted % 20 == 0) {
healEntity();
}
}
public void healEntity()
{
public void healEntity() {
this.theEntity.performEmergencyHeal(2);
}
}

View file

@ -1,29 +1,32 @@
package WayofTime.bloodmagic.entity.ai;
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.RandomPositionGenerator;
import net.minecraft.pathfinding.Path;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.util.math.Vec3d;
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
public class EntityAIStealthRetreat extends EntityAIBase
{
/** The entity we are attached to */
protected EntityCorruptedChicken entity;
public class EntityAIStealthRetreat extends EntityAIBase {
private final double farSpeed;
private final double nearSpeed;
private final float avoidDistance;
/** The PathEntity of our entity */
private Path entityPathEntity;
/** The PathNavigate of our entity */
/**
* The PathNavigate of our entity
*/
private final PathNavigate entityPathNavigate;
/**
* The entity we are attached to
*/
protected EntityCorruptedChicken entity;
/**
* The PathEntity of our entity
*/
private Path entityPathEntity;
private int ticksLeft = 0;
public EntityAIStealthRetreat(EntityCorruptedChicken theEntityIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn)
{
public EntityAIStealthRetreat(EntityCorruptedChicken theEntityIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) {
this.entity = theEntityIn;
this.avoidDistance = avoidDistanceIn;
this.farSpeed = farSpeedIn;
@ -33,26 +36,20 @@ public class EntityAIStealthRetreat extends EntityAIBase
}
@Override
public boolean shouldExecute()
{
if (this.entity.attackStateMachine == 2)
{
public boolean shouldExecute() {
if (this.entity.attackStateMachine == 2) {
EntityLivingBase attacked = this.entity.getAttackTarget();
if (attacked == null)
{
if (attacked == null) {
return false;
}
Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.entity, 16, 7, new Vec3d(attacked.posX, attacked.posY, attacked.posZ));
if (vec3d == null)
{
if (vec3d == null) {
return false;
} else if (attacked.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < attacked.getDistanceSqToEntity(this.entity))
{
} else if (attacked.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < attacked.getDistanceSqToEntity(this.entity)) {
return false;
} else
{
} else {
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3d.x, vec3d.y, vec3d.z);
return this.entityPathEntity != null;
}
@ -62,10 +59,8 @@ public class EntityAIStealthRetreat extends EntityAIBase
}
@Override
public boolean shouldContinueExecuting()
{
if (this.entityPathNavigate.noPath())
{
public boolean shouldContinueExecuting() {
if (this.entityPathNavigate.noPath()) {
this.entity.attackStateMachine = 0;
return false;
}
@ -74,33 +69,27 @@ public class EntityAIStealthRetreat extends EntityAIBase
}
@Override
public void resetTask()
{
public void resetTask() {
ticksLeft = 0;
}
@Override
public void startExecuting()
{
public void startExecuting() {
ticksLeft = this.entity.getEntityWorld().rand.nextInt(100) + 100;
this.entityPathNavigate.setPath(this.entityPathEntity, this.farSpeed);
}
@Override
public void updateTask()
{
public void updateTask() {
ticksLeft--;
if (ticksLeft <= 0 || this.entity.getAttackTarget() == null)
{
if (ticksLeft <= 0 || this.entity.getAttackTarget() == null) {
this.entity.attackStateMachine = 0;
return;
}
if (this.entity.getDistanceSqToEntity(this.entity.getAttackTarget()) < 49.0D)
{
if (this.entity.getDistanceSqToEntity(this.entity.getAttackTarget()) < 49.0D) {
this.entity.getNavigator().setSpeed(this.nearSpeed);
} else
{
} else {
this.entity.getNavigator().setSpeed(this.farSpeed);
}
}

View file

@ -1,52 +1,43 @@
package WayofTime.bloodmagic.entity.ai;
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.RandomPositionGenerator;
import net.minecraft.util.math.Vec3d;
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
public class EntityAIStealthTowardsTarget extends EntityAIBase
{
public class EntityAIStealthTowardsTarget extends EntityAIBase {
private final EntityCorruptedChicken entity;
private final double speed;
private double xPosition;
private double yPosition;
private double zPosition;
private final double speed;
private int ticksLeft = 0;
public EntityAIStealthTowardsTarget(EntityCorruptedChicken creatureIn, double speedIn)
{
public EntityAIStealthTowardsTarget(EntityCorruptedChicken creatureIn, double speedIn) {
this.entity = creatureIn;
this.speed = speedIn;
this.setMutexBits(1);
}
@Override
public boolean shouldExecute()
{
if (this.entity.attackStateMachine != 0 || this.entity.getAttackTarget() == null)
{
public boolean shouldExecute() {
if (this.entity.attackStateMachine != 0 || this.entity.getAttackTarget() == null) {
return false;
}
EntityLivingBase target = this.entity.getAttackTarget();
Vec3d vec3d = null;
if (target instanceof EntityCreature)
{
if (target instanceof EntityCreature) {
vec3d = RandomPositionGenerator.findRandomTarget((EntityCreature) target, 10, 7);
} else
{
} else {
vec3d = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7);
}
if (vec3d == null)
{
if (vec3d == null) {
return false;
} else
{
} else {
ticksLeft = this.entity.getEntityWorld().rand.nextInt(200) + 100;
this.xPosition = vec3d.x;
this.yPosition = vec3d.y;
@ -56,36 +47,29 @@ public class EntityAIStealthTowardsTarget extends EntityAIBase
}
@Override
public void resetTask()
{
public void resetTask() {
ticksLeft = 0;
}
@Override
public boolean shouldContinueExecuting()
{
public boolean shouldContinueExecuting() {
ticksLeft--;
if (ticksLeft <= 0)
{
if (ticksLeft <= 0) {
this.entity.attackStateMachine = 1;
}
this.entity.cloak();
if (this.entity.getNavigator().noPath())
{
if (this.entity.getNavigator().noPath()) {
EntityLivingBase target = this.entity.getAttackTarget();
Vec3d vec3d;
if (target instanceof EntityCreature)
{
if (target instanceof EntityCreature) {
vec3d = RandomPositionGenerator.findRandomTarget((EntityCreature) target, 10, 7);
} else
{
} else {
vec3d = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7);
}
if (vec3d != null)
{
if (vec3d != null) {
this.xPosition = vec3d.x;
this.yPosition = vec3d.y;
this.zPosition = vec3d.z;
@ -97,8 +81,7 @@ public class EntityAIStealthTowardsTarget extends EntityAIBase
}
@Override
public void startExecuting()
{
public void startExecuting() {
this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, this.speed);
}
}

View file

@ -1,5 +1,9 @@
package WayofTime.bloodmagic.entity.mob;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.gson.Serializers;
import com.google.common.base.Predicate;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.nbt.NBTTagCompound;
@ -8,161 +12,139 @@ import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.gson.Serializers;
import com.google.common.base.Predicate;
import java.util.Locale;
public abstract class EntityAspectedDemonBase extends EntityDemonBase
{
public abstract class EntityAspectedDemonBase extends EntityDemonBase {
protected static final DataParameter<EnumDemonWillType> TYPE = EntityDataManager.<EnumDemonWillType>createKey(EntityAspectedDemonBase.class, Serializers.WILL_TYPE_SERIALIZER);
public EntityAspectedDemonBase(World worldIn)
{
public EntityAspectedDemonBase(World worldIn) {
super(worldIn);
}
@Override
protected void entityInit()
{
protected void entityInit() {
super.entityInit();
this.dataManager.register(TYPE, EnumDemonWillType.DEFAULT);
}
public double getMeleeResist()
{
public double getMeleeResist() {
return 0;
}
public double getProjectileResist()
{
public double getProjectileResist() {
return 0;
}
public double getMagicResist()
{
public double getMagicResist() {
return 0;
}
public double getBaseHP(EnumDemonWillType type)
{
public double getBaseHP(EnumDemonWillType type) {
double baseHP = 40;
switch (type)
{
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseHP *= 0.8;
break;
case STEADFAST:
baseHP *= 1.25;
break;
switch (type) {
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseHP *= 0.8;
break;
case STEADFAST:
baseHP *= 1.25;
break;
}
return baseHP;
}
public double getBaseMeleeDamage(EnumDemonWillType type)
{
public double getBaseMeleeDamage(EnumDemonWillType type) {
double baseDamage = 8;
switch (type)
{
case DEFAULT:
break;
case CORROSIVE:
baseDamage *= 0.8;
break;
case DESTRUCTIVE:
baseDamage *= 1.5;
break;
case VENGEFUL:
baseDamage *= 0.8;
break;
case STEADFAST:
baseDamage *= 0.6;
break;
switch (type) {
case DEFAULT:
break;
case CORROSIVE:
baseDamage *= 0.8;
break;
case DESTRUCTIVE:
baseDamage *= 1.5;
break;
case VENGEFUL:
baseDamage *= 0.8;
break;
case STEADFAST:
baseDamage *= 0.6;
break;
}
return baseDamage;
}
public double getBaseSpeed(EnumDemonWillType type)
{
public double getBaseSpeed(EnumDemonWillType type) {
double baseSpeed = 0.27;
switch (type)
{
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseSpeed *= 1.3;
break;
case STEADFAST:
break;
switch (type) {
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseSpeed *= 1.3;
break;
case STEADFAST:
break;
}
return baseSpeed;
}
public double getBaseSprintModifier(EnumDemonWillType type)
{
public double getBaseSprintModifier(EnumDemonWillType type) {
double baseSprint = 1;
switch (type)
{
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseSprint *= 1.2;
break;
case STEADFAST:
break;
switch (type) {
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
baseSprint *= 1.2;
break;
case STEADFAST:
break;
}
return baseSprint;
}
public double getBaseKnockbackResist(EnumDemonWillType type)
{
public double getBaseKnockbackResist(EnumDemonWillType type) {
double baseKnockback = 0;
switch (type)
{
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
break;
case STEADFAST:
baseKnockback += 0.35;
break;
switch (type) {
case DEFAULT:
break;
case CORROSIVE:
break;
case DESTRUCTIVE:
break;
case VENGEFUL:
break;
case STEADFAST:
baseKnockback += 0.35;
break;
}
return baseKnockback;
}
public void applyEntityAttributes(EnumDemonWillType type)
{
public void applyEntityAttributes(EnumDemonWillType type) {
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(this.getBaseHP(type));
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(this.getBaseSpeed(type));
this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(this.getBaseMeleeDamage(type));
@ -170,24 +152,18 @@ public abstract class EntityAspectedDemonBase extends EntityDemonBase
}
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (this.isEntityInvulnerable(source))
{
public boolean attackEntityFrom(DamageSource source, float amount) {
if (this.isEntityInvulnerable(source)) {
return false;
} else
{
} else {
float newAmount = amount;
if (source.isProjectile())
{
if (source.isProjectile()) {
newAmount *= MathHelper.clamp(1 - getProjectileResist(), 0, 1);
} else
{
} else {
newAmount *= MathHelper.clamp(1 - getMeleeResist(), 0, 1);
}
if (source.isMagicDamage())
{
if (source.isMagicDamage()) {
newAmount *= MathHelper.clamp(1 - getMagicResist(), 0, 1);
}
@ -195,83 +171,47 @@ public abstract class EntityAspectedDemonBase extends EntityDemonBase
}
}
public EnumDemonWillType getType()
{
public EnumDemonWillType getType() {
return this.dataManager.get(TYPE);
}
public void setType(EnumDemonWillType type)
{
public void setType(EnumDemonWillType type) {
this.dataManager.set(TYPE, type);
this.applyEntityAttributes(type);
this.setCombatTask();
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
tag.setString(Constants.NBT.WILL_TYPE, this.getType().toString());
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
public void readEntityFromNBT(NBTTagCompound tag) {
super.readEntityFromNBT(tag);
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
{
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
setType(EnumDemonWillType.DEFAULT);
} else
{
} else {
setType(EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)));
}
}
public class TeamAttackPredicate implements Predicate<EntityLivingBase>
{
private final EntityAspectedDemonBase demon;
public TeamAttackPredicate(EntityAspectedDemonBase demon)
{
this.demon = demon;
}
//Returns true if this mob can attack the inputted mob.
@Override
public boolean apply(EntityLivingBase input)
{
if (input instanceof EntityAspectedDemonBase)
{
if (((EntityAspectedDemonBase) input).getType() == demon.getType())
{
return false;
}
}
return input != null;
}
}
//Returns true if the inputted mob is on the same team.
public static class WillTypePredicate implements Predicate<EntityLivingBase>
{
public static class WillTypePredicate implements Predicate<EntityLivingBase> {
private final EnumDemonWillType type;
public WillTypePredicate(EnumDemonWillType type)
{
public WillTypePredicate(EnumDemonWillType type) {
this.type = type;
}
//Returns true if this mob is the same type.
@Override
public boolean apply(EntityLivingBase input)
{
if (input instanceof EntityAspectedDemonBase)
{
if (((EntityAspectedDemonBase) input).getType() == type)
{
public boolean apply(EntityLivingBase input) {
if (input instanceof EntityAspectedDemonBase) {
if (((EntityAspectedDemonBase) input).getType() == type) {
return true;
}
}
@ -279,4 +219,24 @@ public abstract class EntityAspectedDemonBase extends EntityDemonBase
return false;
}
}
public class TeamAttackPredicate implements Predicate<EntityLivingBase> {
private final EntityAspectedDemonBase demon;
public TeamAttackPredicate(EntityAspectedDemonBase demon) {
this.demon = demon;
}
//Returns true if this mob can attack the inputted mob.
@Override
public boolean apply(EntityLivingBase input) {
if (input instanceof EntityAspectedDemonBase) {
if (((EntityAspectedDemonBase) input).getType() == demon.getType()) {
return false;
}
}
return input != null;
}
}
}

View file

@ -1,13 +1,13 @@
package WayofTime.bloodmagic.entity.mob;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackStealthMelee;
import WayofTime.bloodmagic.entity.ai.EntityAIStealthRetreat;
import WayofTime.bloodmagic.entity.ai.EntityAIStealthTowardsTarget;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
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.ai.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
@ -19,24 +19,18 @@ import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackStealthMelee;
import WayofTime.bloodmagic.entity.ai.EntityAIStealthRetreat;
import WayofTime.bloodmagic.entity.ai.EntityAIStealthTowardsTarget;
public class EntityCorruptedChicken extends EntityAspectedDemonBase
{
private EntityAIAttackStealthMelee aiAttackOnCollide;
public class EntityCorruptedChicken extends EntityAspectedDemonBase {
private final int attackPriority = 3;
public float wingRotation;
public float destPos;
public float oFlapSpeed;
public float oFlap;
public float wingRotDelta = 1.0F;
/** The time until the next egg is spawned. */
/**
* The time until the next egg is spawned.
*/
public int timeUntilNextEgg;
/*
* 0 means the chicken is casting stealth on itself when targeted, running
* to a random location near the target. 1 means the chicken is running
@ -45,14 +39,13 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
* state 0.
*/
public int attackStateMachine = 0;
private EntityAIAttackStealthMelee aiAttackOnCollide;
public EntityCorruptedChicken(World world)
{
public EntityCorruptedChicken(World world) {
this(world, EnumDemonWillType.DEFAULT);
}
public EntityCorruptedChicken(World world, EnumDemonWillType type)
{
public EntityCorruptedChicken(World world, EnumDemonWillType type) {
super(world);
this.setSize(0.4F, 0.7F);
this.timeUntilNextEgg = this.rand.nextInt(600) + 600;
@ -61,8 +54,7 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
this.setType(type);
}
protected void initEntityAI()
{
protected void initEntityAI() {
this.tasks.addTask(0, new EntityAISwimming(this));
// this.tasks.addTask(1, new EntityAIPanic(this, 1.4D));
this.tasks.addTask(attackPriority, new EntityAIStealthTowardsTarget(this, 1));
@ -76,10 +68,8 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
}
@Override
public void setCombatTask()
{
if (aiAttackOnCollide != null)
{
public void setCombatTask() {
if (aiAttackOnCollide != null) {
this.tasks.removeTask(aiAttackOnCollide);
}
@ -87,50 +77,42 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
this.tasks.addTask(attackPriority, aiAttackOnCollide);
}
public void cloak()
{
public void cloak() {
this.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 50, 0, false, false));
}
@Override
public double getBaseHP(EnumDemonWillType type)
{
public double getBaseHP(EnumDemonWillType type) {
return super.getBaseHP(type) * 0.5;
}
@Override
public double getBaseMeleeDamage(EnumDemonWillType type)
{
public double getBaseMeleeDamage(EnumDemonWillType type) {
return super.getBaseMeleeDamage(type) * 2.5;
}
@Override
public double getBaseSpeed(EnumDemonWillType type)
{
public double getBaseSpeed(EnumDemonWillType type) {
return super.getBaseSpeed(type);
}
@Override
public double getBaseSprintModifier(EnumDemonWillType type)
{
public double getBaseSprintModifier(EnumDemonWillType type) {
return super.getBaseSprintModifier(type);
}
@Override
public double getBaseKnockbackResist(EnumDemonWillType type)
{
public double getBaseKnockbackResist(EnumDemonWillType type) {
return super.getBaseKnockbackResist(type);
}
@Override
public float getEyeHeight()
{
public float getEyeHeight() {
return this.height;
}
@Override
public void onLivingUpdate()
{
public void onLivingUpdate() {
super.onLivingUpdate();
// if (!worldObj.isRemote)
@ -141,22 +123,19 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
this.destPos = (float) ((double) this.destPos + (double) (this.onGround ? -1 : 4) * 0.3D);
this.destPos = MathHelper.clamp(this.destPos, 0.0F, 1.0F);
if (!this.onGround && this.wingRotDelta < 1.0F)
{
if (!this.onGround && this.wingRotDelta < 1.0F) {
this.wingRotDelta = 1.0F;
}
this.wingRotDelta = (float) ((double) this.wingRotDelta * 0.9D);
if (!this.onGround && this.motionY < 0.0D)
{
if (!this.onGround && this.motionY < 0.0D) {
this.motionY *= 0.6D;
}
this.wingRotation += this.wingRotDelta * 2.0F;
if (!this.getEntityWorld().isRemote && !this.isChild() && --this.timeUntilNextEgg <= 0)
{
if (!this.getEntityWorld().isRemote && !this.isChild() && --this.timeUntilNextEgg <= 0) {
this.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
this.dropItem(Items.EGG, 1);
this.timeUntilNextEgg = this.rand.nextInt(600) + 600;
@ -164,61 +143,51 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
}
@Override
public void fall(float distance, float damageMultiplier)
{
public void fall(float distance, float damageMultiplier) {
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_CHICKEN_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_CHICKEN_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_CHICKEN_DEATH;
}
@Override
protected float getSoundPitch()
{
protected float getSoundPitch() {
return super.getSoundPitch() * 0.5f;
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{
protected void playStepSound(BlockPos pos, Block blockIn) {
this.playSound(SoundEvents.ENTITY_CHICKEN_STEP, 0.15F, 1.0F);
}
@Override
public void readEntityFromNBT(NBTTagCompound compound)
{
public void readEntityFromNBT(NBTTagCompound compound) {
super.readEntityFromNBT(compound);
if (compound.hasKey("EggLayTime"))
{
if (compound.hasKey("EggLayTime")) {
this.timeUntilNextEgg = compound.getInteger("EggLayTime");
}
}
@Override
public void writeEntityToNBT(NBTTagCompound compound)
{
public void writeEntityToNBT(NBTTagCompound compound) {
super.writeEntityToNBT(compound);
compound.setInteger("EggLayTime", this.timeUntilNextEgg);
}
@Override
public void updatePassenger(Entity passenger)
{
public void updatePassenger(Entity passenger) {
super.updatePassenger(passenger);
float f = MathHelper.sin(this.renderYawOffset * 0.017453292F);
float f1 = MathHelper.cos(this.renderYawOffset * 0.017453292F);
@ -226,8 +195,7 @@ public class EntityCorruptedChicken extends EntityAspectedDemonBase
float f3 = 0.0F;
passenger.setPosition(this.posX + (double) (0.1F * f), this.posY + (double) (this.height * 0.5F) + passenger.getYOffset() + 0.0D, this.posZ - (double) (0.1F * f1));
if (passenger instanceof EntityLivingBase)
{
if (passenger instanceof EntityLivingBase) {
((EntityLivingBase) passenger).renderYawOffset = this.renderYawOffset;
}
}

View file

@ -1,20 +1,13 @@
package WayofTime.bloodmagic.entity.mob;
import java.util.List;
import java.util.Map;
import java.util.Random;
import javax.annotation.Nullable;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIEatAndCorruptBlock;
import WayofTime.bloodmagic.entity.ai.EntityAIProtectAlly;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.ai.EntityAIAttackMelee;
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.ai.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.MobEffects;
@ -35,53 +28,61 @@ import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIEatAndCorruptBlock;
import WayofTime.bloodmagic.entity.ai.EntityAIProtectAlly;
import com.google.common.collect.Maps;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class EntityCorruptedSheep extends EntityAspectedDemonBase implements IShearable
{
public class EntityCorruptedSheep extends EntityAspectedDemonBase implements IShearable {
private static final DataParameter<Byte> DYE_COLOR = EntityDataManager.<Byte>createKey(EntityCorruptedSheep.class, DataSerializers.BYTE);
private static final Map<EnumDyeColor, float[]> DYE_TO_RGB = Maps.newEnumMap(EnumDyeColor.class);
public static int maxProtectionCooldown = 90 * 20; //90 second cooldown
static {
DYE_TO_RGB.put(EnumDyeColor.WHITE, new float[]{1.0F, 1.0F, 1.0F});
DYE_TO_RGB.put(EnumDyeColor.ORANGE, new float[]{0.85F, 0.5F, 0.2F});
DYE_TO_RGB.put(EnumDyeColor.MAGENTA, new float[]{0.7F, 0.3F, 0.85F});
DYE_TO_RGB.put(EnumDyeColor.LIGHT_BLUE, new float[]{0.4F, 0.6F, 0.85F});
DYE_TO_RGB.put(EnumDyeColor.YELLOW, new float[]{0.9F, 0.9F, 0.2F});
DYE_TO_RGB.put(EnumDyeColor.LIME, new float[]{0.5F, 0.8F, 0.1F});
DYE_TO_RGB.put(EnumDyeColor.PINK, new float[]{0.95F, 0.5F, 0.65F});
DYE_TO_RGB.put(EnumDyeColor.GRAY, new float[]{0.3F, 0.3F, 0.3F});
DYE_TO_RGB.put(EnumDyeColor.SILVER, new float[]{0.6F, 0.6F, 0.6F});
DYE_TO_RGB.put(EnumDyeColor.CYAN, new float[]{0.3F, 0.5F, 0.6F});
DYE_TO_RGB.put(EnumDyeColor.PURPLE, new float[]{0.5F, 0.25F, 0.7F});
DYE_TO_RGB.put(EnumDyeColor.BLUE, new float[]{0.2F, 0.3F, 0.7F});
DYE_TO_RGB.put(EnumDyeColor.BROWN, new float[]{0.4F, 0.3F, 0.2F});
DYE_TO_RGB.put(EnumDyeColor.GREEN, new float[]{0.4F, 0.5F, 0.2F});
DYE_TO_RGB.put(EnumDyeColor.RED, new float[]{0.6F, 0.2F, 0.2F});
DYE_TO_RGB.put(EnumDyeColor.BLACK, new float[]{0.1F, 0.1F, 0.1F});
}
private final int attackPriority = 3;
public int protectionCooldown = 0;
/**
* Used to control movement as well as wool regrowth. Set to 40 on
* handleHealthUpdate and counts down with each tick.
*/
private int sheepTimer;
private int castTimer = 0;
private EntityAIEatAndCorruptBlock entityAIEatGrass;
private EntityAIProtectAlly entityAIProtectAlly;
private EntityAIAttackMelee aiAttackOnCollide;
private final int attackPriority = 3;
public int protectionCooldown = 0;
public static int maxProtectionCooldown = 90 * 20; //90 second cooldown
public static float[] getDyeRgb(EnumDyeColor dyeColor)
{
return DYE_TO_RGB.get(dyeColor);
}
public EntityCorruptedSheep(World world)
{
public EntityCorruptedSheep(World world) {
this(world, EnumDemonWillType.DEFAULT);
}
public EntityCorruptedSheep(World world, EnumDemonWillType type)
{
public EntityCorruptedSheep(World world, EnumDemonWillType type) {
super(world);
this.setSize(0.9F, 1.3F);
this.setType(type);
}
protected void initEntityAI()
{
protected void initEntityAI() {
this.entityAIEatGrass = new EntityAIEatAndCorruptBlock(this);
this.entityAIProtectAlly = new EntityAIProtectAlly(this);
@ -97,10 +98,8 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
}
@Override
public void setCombatTask()
{
if (aiAttackOnCollide != null)
{
public void setCombatTask() {
if (aiAttackOnCollide != null) {
this.tasks.removeTask(aiAttackOnCollide);
}
@ -109,22 +108,18 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
}
@Override
protected void updateAITasks()
{
protected void updateAITasks() {
this.sheepTimer = this.entityAIEatGrass.getEatingGrassTimer();
this.castTimer = this.entityAIProtectAlly.getCastTimer();
super.updateAITasks();
}
@Override
public void onLivingUpdate()
{
if (this.getEntityWorld().isRemote)
{
public void onLivingUpdate() {
if (this.getEntityWorld().isRemote) {
this.sheepTimer = Math.max(0, this.sheepTimer - 1);
this.castTimer = Math.max(0, castTimer - 1);
if (this.castTimer == 70)
{
if (this.castTimer == 70) {
this.playSound(this.getHurtSound(), this.getSoundVolume() * 2, this.getSoundPitch());
}
}
@ -134,15 +129,12 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
super.onLivingUpdate();
}
public boolean canProtectAlly(EntityLivingBase entity)
{
public boolean canProtectAlly(EntityLivingBase entity) {
return this.protectionCooldown <= 0 && entity.getHealth() < entity.getMaxHealth() && !entity.isPotionActive(MobEffects.RESISTANCE);
}
public boolean applyProtectionToAlly(EntityLivingBase entity)
{
if (canProtectAlly(entity))
{
public boolean applyProtectionToAlly(EntityLivingBase entity) {
if (canProtectAlly(entity)) {
entity.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 20 * 20, 3));
this.protectionCooldown = maxProtectionCooldown;
}
@ -151,92 +143,75 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
}
@Override
public double getBaseHP(EnumDemonWillType type)
{
public double getBaseHP(EnumDemonWillType type) {
return super.getBaseHP(type) * 0.75;
}
@Override
public double getBaseMeleeDamage(EnumDemonWillType type)
{
public double getBaseMeleeDamage(EnumDemonWillType type) {
return super.getBaseMeleeDamage(type) * 0.75;
}
@Override
public double getBaseSpeed(EnumDemonWillType type)
{
public double getBaseSpeed(EnumDemonWillType type) {
return super.getBaseSpeed(type);
}
@Override
public double getBaseSprintModifier(EnumDemonWillType type)
{
public double getBaseSprintModifier(EnumDemonWillType type) {
return super.getBaseSprintModifier(type);
}
@Override
public double getBaseKnockbackResist(EnumDemonWillType type)
{
public double getBaseKnockbackResist(EnumDemonWillType type) {
return super.getBaseKnockbackResist(type) + 0.2;
}
@Override
public double getMeleeResist()
{
public double getMeleeResist() {
return 0.2;
}
@Override
public double getProjectileResist()
{
public double getProjectileResist() {
return 0.6;
}
@Override
protected void entityInit()
{
protected void entityInit() {
super.entityInit();
this.dataManager.register(DYE_COLOR, Byte.valueOf((byte) 0));
}
@Override
@SideOnly(Side.CLIENT)
public void handleStatusUpdate(byte id)
{
if (id == 10)
{
public void handleStatusUpdate(byte id) {
if (id == 10) {
this.sheepTimer = 40;
} else if (id == 53)
{
} else if (id == 53) {
this.castTimer = 100;
} else
{
} else {
super.handleStatusUpdate(id);
}
}
@SideOnly(Side.CLIENT)
public float getHeadRotationPointY(float partialTick)
{
public float getHeadRotationPointY(float partialTick) {
return this.sheepTimer <= 0 ? 0.0F : (this.sheepTimer >= 4 && this.sheepTimer <= 36 ? 1.0F : (this.sheepTimer < 4 ? ((float) this.sheepTimer - partialTick) / 4.0F : -((float) (this.sheepTimer - 40) - partialTick) / 4.0F));
}
@SideOnly(Side.CLIENT)
public float getHeadRotationAngleX(float partialTick)
{
if (this.sheepTimer > 4 && this.sheepTimer <= 36)
{
public float getHeadRotationAngleX(float partialTick) {
if (this.sheepTimer > 4 && this.sheepTimer <= 36) {
float f = ((float) (this.sheepTimer - 4) - partialTick) / 32.0F;
return ((float) Math.PI / 5F) + ((float) Math.PI * 7F / 100F) * MathHelper.sin(f * 28.7F);
} else
{
} else {
return this.sheepTimer > 0 ? ((float) Math.PI / 5F) : this.rotationPitch * 0.017453292F;
}
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
tag.setBoolean("Sheared", this.getSheared());
tag.setByte("Color", (byte) this.getFleeceColor().getMetadata());
@ -244,8 +219,7 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
public void readEntityFromNBT(NBTTagCompound tag) {
super.readEntityFromNBT(tag);
this.setSheared(tag.getBoolean("Sheared"));
this.setFleeceColor(EnumDyeColor.byMetadata(tag.getByte("Color")));
@ -253,48 +227,41 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_SHEEP_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_SHEEP_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_SHEEP_DEATH;
}
@Override
protected float getSoundPitch()
{
protected float getSoundPitch() {
return super.getSoundPitch() * 0.5f;
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{
protected void playStepSound(BlockPos pos, Block blockIn) {
this.playSound(SoundEvents.ENTITY_SHEEP_STEP, 0.15F, 1.0F);
}
/**
* Gets the wool color of this sheep.
*/
public EnumDyeColor getFleeceColor()
{
public EnumDyeColor getFleeceColor() {
return EnumDyeColor.byMetadata(this.dataManager.get(DYE_COLOR).byteValue() & 15);
}
/**
* Sets the wool color of this sheep
*/
public void setFleeceColor(EnumDyeColor color)
{
public void setFleeceColor(EnumDyeColor color) {
byte b0 = this.dataManager.get(DYE_COLOR).byteValue();
this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 & 240 | color.getMetadata() & 15)));
}
@ -302,48 +269,33 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
/**
* returns true if a sheeps wool has been sheared
*/
public boolean getSheared()
{
public boolean getSheared() {
return (this.dataManager.get(DYE_COLOR).byteValue() & 16) != 0;
}
/**
* make a sheep sheared if set to true
*/
public void setSheared(boolean sheared)
{
public void setSheared(boolean sheared) {
byte b0 = this.dataManager.get(DYE_COLOR).byteValue();
if (sheared)
{
if (sheared) {
this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 | 16)));
} else
{
} else {
this.dataManager.set(DYE_COLOR, Byte.valueOf((byte) (b0 & -17)));
}
}
/**
* Chooses a "vanilla" sheep color based on the provided random.
*/
public static EnumDyeColor getRandomSheepColor(Random random)
{
int i = random.nextInt(100);
return i < 5 ? EnumDyeColor.BLACK : (i < 10 ? EnumDyeColor.GRAY : (i < 15 ? EnumDyeColor.SILVER : (i < 18 ? EnumDyeColor.BROWN : (random.nextInt(500) == 0 ? EnumDyeColor.PINK : EnumDyeColor.WHITE))));
}
/**
* This function applies the benefits of growing back wool and faster
* growing up to the acting entity. (This function is used in the
* AIEatGrass)
*/
@Override
public void eatGrassBonus()
{
public void eatGrassBonus() {
this.setSheared(false);
if (this.isChild())
{
if (this.isChild()) {
this.heal(3);
}
}
@ -354,48 +306,24 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
* from nbt. Mainly used for initializing attributes and inventory
*/
@Override
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
{
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) {
livingdata = super.onInitialSpawn(difficulty, livingdata);
this.setFleeceColor(getRandomSheepColor(this.getEntityWorld().rand));
return livingdata;
}
@Override
public float getEyeHeight()
{
public float getEyeHeight() {
return 0.95F * this.height;
}
static
{
DYE_TO_RGB.put(EnumDyeColor.WHITE, new float[] { 1.0F, 1.0F, 1.0F });
DYE_TO_RGB.put(EnumDyeColor.ORANGE, new float[] { 0.85F, 0.5F, 0.2F });
DYE_TO_RGB.put(EnumDyeColor.MAGENTA, new float[] { 0.7F, 0.3F, 0.85F });
DYE_TO_RGB.put(EnumDyeColor.LIGHT_BLUE, new float[] { 0.4F, 0.6F, 0.85F });
DYE_TO_RGB.put(EnumDyeColor.YELLOW, new float[] { 0.9F, 0.9F, 0.2F });
DYE_TO_RGB.put(EnumDyeColor.LIME, new float[] { 0.5F, 0.8F, 0.1F });
DYE_TO_RGB.put(EnumDyeColor.PINK, new float[] { 0.95F, 0.5F, 0.65F });
DYE_TO_RGB.put(EnumDyeColor.GRAY, new float[] { 0.3F, 0.3F, 0.3F });
DYE_TO_RGB.put(EnumDyeColor.SILVER, new float[] { 0.6F, 0.6F, 0.6F });
DYE_TO_RGB.put(EnumDyeColor.CYAN, new float[] { 0.3F, 0.5F, 0.6F });
DYE_TO_RGB.put(EnumDyeColor.PURPLE, new float[] { 0.5F, 0.25F, 0.7F });
DYE_TO_RGB.put(EnumDyeColor.BLUE, new float[] { 0.2F, 0.3F, 0.7F });
DYE_TO_RGB.put(EnumDyeColor.BROWN, new float[] { 0.4F, 0.3F, 0.2F });
DYE_TO_RGB.put(EnumDyeColor.GREEN, new float[] { 0.4F, 0.5F, 0.2F });
DYE_TO_RGB.put(EnumDyeColor.RED, new float[] { 0.6F, 0.2F, 0.2F });
DYE_TO_RGB.put(EnumDyeColor.BLACK, new float[] { 0.1F, 0.1F, 0.1F });
}
@Override
public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos)
{
public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos) {
return !this.getSheared() && !this.isChild();
}
@Override
public List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune)
{
public List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) {
this.setSheared(true);
int i = 1 + this.rand.nextInt(3);
@ -410,4 +338,16 @@ public class EntityCorruptedSheep extends EntityAspectedDemonBase implements ISh
public int getCastTimer() {
return castTimer;
}
public static float[] getDyeRgb(EnumDyeColor dyeColor) {
return DYE_TO_RGB.get(dyeColor);
}
/**
* Chooses a "vanilla" sheep color based on the provided random.
*/
public static EnumDyeColor getRandomSheepColor(Random random) {
int i = random.nextInt(100);
return i < 5 ? EnumDyeColor.BLACK : (i < 10 ? EnumDyeColor.GRAY : (i < 15 ? EnumDyeColor.SILVER : (i < 18 ? EnumDyeColor.BROWN : (random.nextInt(500) == 0 ? EnumDyeColor.PINK : EnumDyeColor.WHITE))));
}
}

View file

@ -1,16 +1,11 @@
package WayofTime.bloodmagic.entity.mob;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.entity.ai.EntityAIPickUpAlly;
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.ai.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
@ -23,28 +18,22 @@ 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
{
public class EntityCorruptedSpider extends EntityAspectedDemonBase {
private static final DataParameter<Byte> CLIMBING = EntityDataManager.<Byte>createKey(EntityCorruptedSpider.class, DataSerializers.BYTE);
public EntityCorruptedSpider(World world)
{
public EntityCorruptedSpider(World world) {
this(world, EnumDemonWillType.DEFAULT);
}
public EntityCorruptedSpider(World world, EnumDemonWillType type)
{
public EntityCorruptedSpider(World world, EnumDemonWillType type) {
super(world);
this.setSize(1.4F, 0.9F);
this.setType(type);
}
protected void initEntityAI()
{
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));
@ -59,132 +48,109 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase
}
@Override
public double getBaseHP(EnumDemonWillType type)
{
public double getBaseHP(EnumDemonWillType type) {
return super.getBaseHP(type);
}
@Override
public double getBaseMeleeDamage(EnumDemonWillType type)
{
public double getBaseMeleeDamage(EnumDemonWillType type) {
return super.getBaseMeleeDamage(type);
}
@Override
public double getBaseSpeed(EnumDemonWillType type)
{
public double getBaseSpeed(EnumDemonWillType type) {
return super.getBaseSpeed(type);
}
@Override
public double getBaseSprintModifier(EnumDemonWillType type)
{
public double getBaseSprintModifier(EnumDemonWillType type) {
return super.getBaseSprintModifier(type);
}
@Override
public double getBaseKnockbackResist(EnumDemonWillType type)
{
public double getBaseKnockbackResist(EnumDemonWillType type) {
return super.getBaseKnockbackResist(type);
}
@Override
public double getMountedYOffset()
{
public double getMountedYOffset() {
return (double) (this.height * 0.5F);
}
@Override
protected PathNavigate createNavigator(World worldIn)
{
protected PathNavigate createNavigator(World worldIn) {
return new PathNavigateClimber(this, worldIn);
}
@Override
protected void entityInit()
{
protected void entityInit() {
super.entityInit();
this.dataManager.register(CLIMBING, (byte) 0);
}
@Override
public void onUpdate()
{
public void onUpdate() {
super.onUpdate();
if (!this.getEntityWorld().isRemote)
{
if (!this.getEntityWorld().isRemote) {
this.setBesideClimbableBlock(this.isCollidedHorizontally);
}
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_SPIDER_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_SPIDER_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_SPIDER_DEATH;
}
@Override
protected float getSoundPitch()
{
protected float getSoundPitch() {
return super.getSoundPitch() * 0.5f;
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{
protected void playStepSound(BlockPos pos, Block blockIn) {
this.playSound(SoundEvents.ENTITY_SPIDER_STEP, 0.15F, 1.0F);
}
@Override
public boolean isOnLadder()
{
public boolean isOnLadder() {
return this.isBesideClimbableBlock();
}
@Override
public void setInWeb()
{
public void setInWeb() {
}
@Override
public EnumCreatureAttribute getCreatureAttribute()
{
public EnumCreatureAttribute getCreatureAttribute() {
return EnumCreatureAttribute.ARTHROPOD;
}
@Override
public boolean isPotionApplicable(PotionEffect potioneffectIn)
{
public boolean isPotionApplicable(PotionEffect potioneffectIn) {
return potioneffectIn.getPotion() != MobEffects.POISON && super.isPotionApplicable(potioneffectIn);
}
public boolean isBesideClimbableBlock()
{
public boolean isBesideClimbableBlock() {
return (this.dataManager.get(CLIMBING) & 1) != 0;
}
public void setBesideClimbableBlock(boolean climbing)
{
public void setBesideClimbableBlock(boolean climbing) {
byte b0 = this.dataManager.get(CLIMBING);
if (climbing)
{
if (climbing) {
b0 = (byte) (b0 | 1);
} else
{
} else {
b0 = (byte) (b0 & -2);
}
@ -192,53 +158,43 @@ public class EntityCorruptedSpider extends EntityAspectedDemonBase
}
@Override
public float getEyeHeight()
{
public float getEyeHeight() {
return 0.65F;
}
static class AISpiderAttack extends EntityAIAttackMelee
{
public AISpiderAttack(EntityCorruptedSpider spider)
{
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 shouldContinueExecuting()
{
public boolean shouldContinueExecuting() {
float f = this.attacker.getBrightness();
if (f >= 0.5F && this.attacker.getRNG().nextInt(100) == 0)
{
if (f >= 0.5F && this.attacker.getRNG().nextInt(100) == 0) {
this.attacker.setAttackTarget(null);
return false;
} else
{
} else {
return super.shouldContinueExecuting();
}
}
protected double getAttackReachSqr(EntityLivingBase attackTarget)
{
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)
{
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()
{
public boolean shouldExecute() {
float f = this.taskOwner.getBrightness();
return !(f >= 0.5F) && super.shouldExecute();
}

View file

@ -1,18 +1,12 @@
package WayofTime.bloodmagic.entity.mob;
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
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.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityIronGolem;
@ -27,18 +21,14 @@ import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow;
public class EntityCorruptedZombie extends EntityAspectedDemonBase
{
public class EntityCorruptedZombie extends EntityAspectedDemonBase {
private final EntityAIAttackRangedBow aiArrowAttack = new EntityAIAttackRangedBow(this, 1.0D, 20, 15.0F);
private final EntityAIAttackMelee aiAttackOnCollide = new EntityAIAttackMelee(this, 1.0D, false);
private final int attackPriority = 3;
public EntityCorruptedZombie(World worldIn)
{
public EntityCorruptedZombie(World worldIn) {
super(worldIn);
this.setSize(0.6F, 1.95F);
// ((PathNavigateGround) getNavigator()).setCanSwim(false);
@ -60,8 +50,7 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
}
@Override
protected void applyEntityAttributes()
{
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0D);
getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(40.0D);
@ -71,35 +60,29 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
}
@Override
public void setCombatTask()
{
if (!this.getEntityWorld().isRemote)
{
public void setCombatTask() {
if (!this.getEntityWorld().isRemote) {
this.tasks.removeTask(this.aiAttackOnCollide);
this.tasks.removeTask(this.aiArrowAttack);
ItemStack itemstack = this.getHeldItemMainhand();
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow)
{
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) {
int i = 20;
if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD)
{
if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) {
i = 40;
}
this.aiArrowAttack.setAttackCooldown(i);
this.tasks.addTask(attackPriority, this.aiArrowAttack);
} else
{
} else {
this.tasks.addTask(attackPriority, this.aiAttackOnCollide);
}
}
}
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
public boolean attackEntityFrom(DamageSource source, float amount) {
return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount);
}
@ -107,17 +90,14 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
* Redone from EntityMob to prevent despawning on peaceful.
*/
@Override
public boolean attackEntityAsMob(Entity attackedEntity)
{
public boolean attackEntityAsMob(Entity attackedEntity) {
boolean flag = super.attackEntityAsMob(attackedEntity);
if (flag)
{
if (flag) {
//EMPTY
return true;
} else
{
} else {
return false;
}
}
@ -126,24 +106,20 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
* @param toHeal
* @return Amount of Will consumed from the Aura to heal
*/
public double absorbWillFromAuraToHeal(double toHeal)
{
if (getEntityWorld().isRemote)
{
public double absorbWillFromAuraToHeal(double toHeal) {
if (getEntityWorld().isRemote) {
return 0;
}
double healthMissing = this.getMaxHealth() - this.getHealth();
if (healthMissing <= 0)
{
if (healthMissing <= 0) {
return 0;
}
double will = WorldDemonWillHandler.getCurrentWill(getEntityWorld(), getPosition(), getType());
toHeal = Math.min(healthMissing, Math.min(toHeal, will / getWillToHealth()));
if (toHeal > 0)
{
if (toHeal > 0) {
this.heal((float) toHeal);
return WorldDemonWillHandler.drainWill(getEntityWorld(), getPosition(), getType(), toHeal * getWillToHealth(), true);
}
@ -151,21 +127,17 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
return 0;
}
public double getWillToHealth()
{
public double getWillToHealth() {
return 2;
}
@Override
protected boolean canDespawn()
{
protected boolean canDespawn() {
return !this.isTamed() && super.canDespawn();
}
public void onUpdate()
{
if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0)
{
public void onUpdate() {
if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0) {
absorbWillFromAuraToHeal(2);
}
@ -179,32 +151,27 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
}
@Override
protected float getSoundPitch()
{
protected float getSoundPitch() {
return super.getSoundPitch() * 0.5f;
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_ZOMBIE_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_ZOMBIE_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_ZOMBIE_DEATH;
}
@Override
protected void playStepSound(BlockPos pos, Block block)
{
protected void playStepSound(BlockPos pos, Block block) {
this.playSound(SoundEvents.ENTITY_ZOMBIE_STEP, 0.15F, 1.0F);
}
@ -212,8 +179,7 @@ public class EntityCorruptedZombie extends EntityAspectedDemonBase
* Returns the volume for the sounds this mob makes.
*/
@Override
protected float getSoundVolume()
{
protected float getSoundVolume() {
return 0.4F;
}
}

View file

@ -1,14 +1,10 @@
package WayofTime.bloodmagic.entity.mob;
import java.util.UUID;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityOwnable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityMob;
@ -34,58 +30,48 @@ import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import javax.annotation.Nullable;
import java.util.UUID;
public class EntityDemonBase extends EntityCreature implements IEntityOwnable
{
public class EntityDemonBase extends EntityCreature implements IEntityOwnable {
protected static final DataParameter<Byte> TAMED = EntityDataManager.createKey(EntityDemonBase.class, DataSerializers.BYTE);
protected static final DataParameter<Optional<UUID>> OWNER_UNIQUE_ID = EntityDataManager.createKey(EntityDemonBase.class, DataSerializers.OPTIONAL_UNIQUE_ID);
public EntityDemonBase(World worldIn)
{
public EntityDemonBase(World worldIn) {
super(worldIn);
}
@Override
protected void entityInit()
{
protected void entityInit() {
super.entityInit();
this.dataManager.register(TAMED, (byte) 0);
this.dataManager.register(OWNER_UNIQUE_ID, Optional.<UUID>absent());
}
@Override
protected void applyEntityAttributes()
{
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);
}
public void setCombatTask()
{
public void setCombatTask() {
}
@Override
public boolean isPotionApplicable(PotionEffect effect)
{
public boolean isPotionApplicable(PotionEffect effect) {
return super.isPotionApplicable(effect);
}
@Override
public void onLivingUpdate()
{
public void onLivingUpdate() {
this.updateArmSwingProgress();
super.onLivingUpdate();
}
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
public boolean attackEntityFrom(DamageSource source, float amount) {
return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount);
}
@ -93,23 +79,19 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
* Redone from EntityMob to prevent despawning on peaceful.
*/
@Override
public boolean attackEntityAsMob(Entity attackedEntity)
{
public boolean attackEntityAsMob(Entity attackedEntity) {
float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
int i = 0;
if (attackedEntity instanceof EntityLivingBase)
{
if (attackedEntity instanceof EntityLivingBase) {
f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase) attackedEntity).getCreatureAttribute());
i += EnchantmentHelper.getKnockbackModifier(this);
}
boolean flag = attackedEntity.attackEntityFrom(DamageSource.causeMobDamage(this), f);
if (flag)
{
if (i > 0)
{
if (flag) {
if (i > 0) {
((EntityLivingBase) attackedEntity).knockBack(this, (float) i * 0.5F, (double) MathHelper.sin(this.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(this.rotationYaw * 0.017453292F)));
this.motionX *= 0.6D;
this.motionZ *= 0.6D;
@ -117,23 +99,19 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
int j = EnchantmentHelper.getFireAspectModifier(this);
if (j > 0)
{
if (j > 0) {
attackedEntity.setFire(j * 4);
}
if (attackedEntity instanceof EntityPlayer)
{
if (attackedEntity instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) attackedEntity;
ItemStack itemstack = this.getHeldItemMainhand();
ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.EMPTY;
if (!itemstack.isEmpty() && !itemstack1.isEmpty() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD)
{
if (!itemstack.isEmpty() && !itemstack1.isEmpty() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD) {
float f1 = 0.25F + (float) EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;
if (this.rand.nextFloat() < f1)
{
if (this.rand.nextFloat() < f1) {
entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
this.getEntityWorld().setEntityState(entityplayer, (byte) 30);
}
@ -147,87 +125,70 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
}
@Override
public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack)
{
public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack) {
super.setItemStackToSlot(slotIn, stack);
if (!this.getEntityWorld().isRemote && slotIn == EntityEquipmentSlot.MAINHAND)
{
if (!this.getEntityWorld().isRemote && slotIn == EntityEquipmentSlot.MAINHAND) {
this.setCombatTask();
}
}
public boolean isStationary()
{
public boolean isStationary() {
return false;
}
public boolean absorbExplosion(Explosion explosion)
{
public boolean absorbExplosion(Explosion explosion) {
return false;
}
public void performEmergencyHeal(double toHeal)
{
public void performEmergencyHeal(double toHeal) {
this.heal((float) toHeal);
if (getEntityWorld() instanceof WorldServer)
{
if (getEntityWorld() instanceof WorldServer) {
WorldServer server = (WorldServer) getEntityWorld();
server.spawnParticle(EnumParticleTypes.HEART, this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, 7, 0.2, 0.2, 0.2, 0);
}
}
public boolean shouldEmergencyHeal()
{
public boolean shouldEmergencyHeal() {
return this.getHealth() < this.getMaxHealth() * 0.5;
}
@Override
protected boolean canDespawn()
{
protected boolean canDespawn() {
return !this.isTamed() && super.canDespawn();
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
if (this.getOwnerId() == null)
{
if (this.getOwnerId() == null) {
tag.setString("OwnerUUID", "");
} else
{
} else {
tag.setString("OwnerUUID", this.getOwnerId().toString());
}
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
public void readEntityFromNBT(NBTTagCompound tag) {
super.readEntityFromNBT(tag);
String s;
if (tag.hasKey("OwnerUUID", 8))
{
if (tag.hasKey("OwnerUUID", 8)) {
s = tag.getString("OwnerUUID");
} else
{
} else {
String s1 = tag.getString("Owner");
s = PreYggdrasilConverter.convertMobOwnerIfNeeded(this.getServer(), s1);
}
if (!s.isEmpty())
{
try
{
if (!s.isEmpty()) {
try {
this.setOwnerId(UUID.fromString(s));
this.setTamed(true);
} catch (Throwable var4)
{
} catch (Throwable var4) {
this.setTamed(false);
}
}
@ -236,46 +197,36 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
}
//TODO: Change to fit the given AI
public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner)
{
if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast))
{
if (attacker instanceof IEntityOwnable)
{
public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner) {
if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast)) {
if (attacker instanceof IEntityOwnable) {
IEntityOwnable entityOwnable = (IEntityOwnable) attacker;
if (entityOwnable.getOwner() == owner)
{
if (entityOwnable.getOwner() == owner) {
return false;
}
}
return !(attacker instanceof EntityPlayer && owner instanceof EntityPlayer && !((EntityPlayer) owner).canAttackPlayer((EntityPlayer) attacker)) && (!(attacker instanceof EntityHorse) || !((EntityHorse) attacker).isTame());
} else
{
} else {
return false;
}
}
public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity)
{
public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity) {
}
public boolean isTamed()
{
public boolean isTamed() {
return (this.dataManager.get(TAMED) & 4) != 0;
}
public void setTamed(boolean tamed)
{
public void setTamed(boolean tamed) {
byte b0 = this.dataManager.get(TAMED);
if (tamed)
{
if (tamed) {
this.dataManager.set(TAMED, (byte) (b0 | 4));
} else
{
} else {
this.dataManager.set(TAMED, (byte) (b0 & -5));
}
@ -283,8 +234,7 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_COW_AMBIENT;
}
@ -294,20 +244,17 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
return getHurtSound();
}
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_COW_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_COW_DEATH;
}
@Override
protected void playStepSound(BlockPos pos, Block block)
{
protected void playStepSound(BlockPos pos, Block block) {
this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F);
}
@ -315,52 +262,42 @@ public class EntityDemonBase extends EntityCreature implements IEntityOwnable
* Returns the volume for the sounds this mob makes.
*/
@Override
protected float getSoundVolume()
{
protected float getSoundVolume() {
return 0.4F;
}
@Override
public UUID getOwnerId()
{
public UUID getOwnerId() {
return (this.dataManager.get(OWNER_UNIQUE_ID)).orNull();
}
public void setOwnerId(UUID uuid)
{
public void setOwnerId(UUID uuid) {
this.dataManager.set(OWNER_UNIQUE_ID, Optional.fromNullable(uuid));
}
@Override
public EntityLivingBase getOwner()
{
try
{
public EntityLivingBase getOwner() {
try {
UUID uuid = this.getOwnerId();
return uuid == null ? null : this.getEntityWorld().getPlayerEntityByUUID(uuid);
} catch (IllegalArgumentException var2)
{
} catch (IllegalArgumentException var2) {
return null;
}
}
public void setOwner(EntityPlayer player)
{
public void setOwner(EntityPlayer player) {
setOwnerId(player.getUniqueID());
}
public class TargetPredicate implements Predicate<EntityMob>
{
public class TargetPredicate implements Predicate<EntityMob> {
EntityDemonBase entity;
public TargetPredicate(EntityDemonBase entity)
{
public TargetPredicate(EntityDemonBase entity) {
this.entity = entity;
}
@Override
public boolean apply(EntityMob input)
{
public boolean apply(EntityMob input) {
return entity.shouldAttackEntity(input, this.entity.getOwner());
}
}

View file

@ -1,19 +1,15 @@
package WayofTime.bloodmagic.entity.mob;
import WayofTime.bloodmagic.block.BlockMimic;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.entity.ai.EntityAIMimicReform;
import WayofTime.bloodmagic.tile.TileMimic;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.SharedMonsterAttributes;
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.EntityAIMoveTowardsRestriction;
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.ai.*;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
@ -33,13 +29,8 @@ import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import WayofTime.bloodmagic.block.BlockMimic;
import WayofTime.bloodmagic.entity.ai.EntityAIMimicReform;
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.tile.TileMimic;
public class EntityMimic extends EntityDemonBase
{
public class EntityMimic extends EntityDemonBase {
/**
* Copy of EntitySpider's AI (should be pretty evident...)
*/
@ -50,8 +41,7 @@ public class EntityMimic extends EntityDemonBase
public int metaOfReplacedBlock = 0;
public int playerCheckRadius = 5;
public EntityMimic(World worldIn)
{
public EntityMimic(World worldIn) {
super(worldIn);
this.setSize(0.9F, 0.9F);
@ -70,8 +60,7 @@ public class EntityMimic extends EntityDemonBase
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
tag.setBoolean("dropItemsOnBreak", dropItemsOnBreak);
@ -81,8 +70,7 @@ public class EntityMimic extends EntityDemonBase
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
public void readEntityFromNBT(NBTTagCompound tag) {
super.readEntityFromNBT(tag);
dropItemsOnBreak = tag.getBoolean("dropItemsOnBreak");
@ -91,30 +79,24 @@ public class EntityMimic extends EntityDemonBase
playerCheckRadius = tag.getInteger("playerCheckRadius");
}
public ItemStack getMimicItemStack()
{
public ItemStack getMimicItemStack() {
return this.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
}
public void setMimicItemStack(ItemStack stack)
{
public void setMimicItemStack(ItemStack stack) {
this.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
}
public boolean spawnHeldBlockOnDeath(World world, BlockPos pos)
{
public boolean spawnHeldBlockOnDeath(World world, BlockPos pos) {
return world.isAirBlock(pos) && TileMimic.replaceMimicWithBlockActual(world, pos, getMimicItemStack(), tileTag, metaOfReplacedBlock);
}
public boolean spawnMimicBlockAtPosition(World world, BlockPos pos)
{
if (world.isAirBlock(pos))
{
public boolean spawnMimicBlockAtPosition(World world, BlockPos pos) {
if (world.isAirBlock(pos)) {
IBlockState mimicState = RegistrarBloodMagicBlocks.MIMIC.getStateFromMeta(BlockMimic.sentientMimicMeta);
world.setBlockState(pos, mimicState, 3);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileMimic)
{
if (tile instanceof TileMimic) {
TileMimic mimic = (TileMimic) tile;
mimic.metaOfReplacedBlock = metaOfReplacedBlock;
mimic.tileTag = tileTag;
@ -129,8 +111,7 @@ public class EntityMimic extends EntityDemonBase
return false;
}
public void initializeMimic(ItemStack heldStack, NBTTagCompound tileTag, boolean dropItemsOnBreak, int metaOfReplacedBlock, int playerCheckRadius, BlockPos homePosition)
{
public void initializeMimic(ItemStack heldStack, NBTTagCompound tileTag, boolean dropItemsOnBreak, int metaOfReplacedBlock, int playerCheckRadius, BlockPos homePosition) {
this.setMimicItemStack(heldStack);
this.tileTag = tileTag;
this.dropItemsOnBreak = dropItemsOnBreak;
@ -139,29 +120,21 @@ public class EntityMimic extends EntityDemonBase
this.setHomePosAndDistance(homePosition, 2); //TODO: Save this.
}
public boolean reformIntoMimicBlock(BlockPos centerPos)
{
public boolean reformIntoMimicBlock(BlockPos centerPos) {
int horizontalRadius = 1;
int verticalRadius = 1;
for (int hR = 0; hR <= horizontalRadius; hR++)
{
for (int vR = 0; vR <= verticalRadius; vR++)
{
for (int i = -hR; i <= hR; i++)
{
for (int k = -hR; k <= hR; k++)
{
for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1))
{
if (!(Math.abs(i) == hR || Math.abs(k) == hR))
{
for (int hR = 0; hR <= horizontalRadius; hR++) {
for (int vR = 0; vR <= verticalRadius; vR++) {
for (int i = -hR; i <= hR; i++) {
for (int k = -hR; k <= hR; k++) {
for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1)) {
if (!(Math.abs(i) == hR || Math.abs(k) == hR)) {
continue;
}
BlockPos newPos = centerPos.add(i, j, k);
if (spawnMimicBlockAtPosition(getEntityWorld(), newPos))
{
if (spawnMimicBlockAtPosition(getEntityWorld(), newPos)) {
return true;
}
}
@ -174,35 +147,26 @@ public class EntityMimic extends EntityDemonBase
}
@Override
public void onDeath(DamageSource cause)
{
public void onDeath(DamageSource cause) {
super.onDeath(cause);
if (!getEntityWorld().isRemote)
{
if (!getEntityWorld().isRemote) {
BlockPos centerPos = this.getPosition();
int horizontalRadius = 1;
int verticalRadius = 1;
for (int hR = 0; hR <= horizontalRadius; hR++)
{
for (int vR = 0; vR <= verticalRadius; vR++)
{
for (int i = -hR; i <= hR; i++)
{
for (int k = -hR; k <= hR; k++)
{
for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1))
{
if (!(Math.abs(i) == hR || Math.abs(k) == hR))
{
for (int hR = 0; hR <= horizontalRadius; hR++) {
for (int vR = 0; vR <= verticalRadius; vR++) {
for (int i = -hR; i <= hR; i++) {
for (int k = -hR; k <= hR; k++) {
for (int j = -vR; j <= vR; j += 2 * vR + (vR > 0 ? 0 : 1)) {
if (!(Math.abs(i) == hR || Math.abs(k) == hR)) {
continue;
}
BlockPos newPos = centerPos.add(i, j, k);
if (spawnHeldBlockOnDeath(getEntityWorld(), newPos))
{
if (spawnHeldBlockOnDeath(getEntityWorld(), newPos)) {
return;
}
}
@ -218,8 +182,7 @@ public class EntityMimic extends EntityDemonBase
* this one.
*/
@Override
public double getMountedYOffset()
{
public double getMountedYOffset() {
return (double) (this.height * 0.5F);
}
@ -227,14 +190,12 @@ public class EntityMimic extends EntityDemonBase
* Returns new PathNavigateGround instance
*/
@Override
protected PathNavigate createNavigator(World worldIn)
{
protected PathNavigate createNavigator(World worldIn) {
return new PathNavigateClimber(this, worldIn);
}
@Override
protected void entityInit()
{
protected void entityInit() {
super.entityInit();
this.dataManager.register(CLIMBING, (byte) 0);
// this.dataManager.register(ITEMSTACK, null);
@ -244,53 +205,44 @@ public class EntityMimic extends EntityDemonBase
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
if (!this.getEntityWorld().isRemote && this.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL)
{
if (reformIntoMimicBlock(this.getPosition()))
{
public void onUpdate() {
if (!this.getEntityWorld().isRemote && this.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL) {
if (reformIntoMimicBlock(this.getPosition())) {
this.setDead();
}
}
super.onUpdate();
if (!this.getEntityWorld().isRemote)
{
if (!this.getEntityWorld().isRemote) {
this.setBesideClimbableBlock(this.isCollidedHorizontally);
}
}
@Override
protected void applyEntityAttributes()
{
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D);
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3D);
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_SPIDER_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_SPIDER_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_SPIDER_DEATH;
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{
protected void playStepSound(BlockPos pos, Block blockIn) {
this.playSound(SoundEvents.ENTITY_SPIDER_STEP, 0.15F, 1.0F);
}
@ -298,8 +250,7 @@ public class EntityMimic extends EntityDemonBase
* returns true if this entity is by a ladder, false otherwise
*/
@Override
public boolean isOnLadder()
{
public boolean isOnLadder() {
return this.isBesideClimbableBlock();
}
@ -307,8 +258,7 @@ public class EntityMimic extends EntityDemonBase
* Sets the Entity inside a web block.
*/
@Override
public void setInWeb()
{
public void setInWeb() {
}
@ -316,14 +266,12 @@ public class EntityMimic extends EntityDemonBase
* Get this Entity's EnumCreatureAttribute
*/
@Override
public EnumCreatureAttribute getCreatureAttribute()
{
public EnumCreatureAttribute getCreatureAttribute() {
return EnumCreatureAttribute.ARTHROPOD;
}
@Override
public boolean isPotionApplicable(PotionEffect potioneffectIn)
{
public boolean isPotionApplicable(PotionEffect potioneffectIn) {
return potioneffectIn.getPotion() != MobEffects.POISON && super.isPotionApplicable(potioneffectIn);
}
@ -331,8 +279,7 @@ public class EntityMimic extends EntityDemonBase
* Returns true if the WatchableObject (Byte) is 0x01 otherwise returns
* false. The WatchableObject is updated using setBesideClimableBlock.
*/
public boolean isBesideClimbableBlock()
{
public boolean isBesideClimbableBlock() {
return (this.dataManager.get(CLIMBING) & 1) != 0;
}
@ -340,44 +287,35 @@ public class EntityMimic extends EntityDemonBase
* Updates the WatchableObject (Byte) created in entityInit(), setting it to
* 0x01 if par1 is true or 0x00 if it is false.
*/
public void setBesideClimbableBlock(boolean climbing)
{
public void setBesideClimbableBlock(boolean climbing) {
byte b0 = this.dataManager.get(CLIMBING);
if (climbing)
{
if (climbing) {
b0 = (byte) (b0 | 1);
} else
{
} else {
b0 = (byte) (b0 & -2);
}
this.dataManager.set(CLIMBING, b0);
}
public float getEyeHeight()
{
public float getEyeHeight() {
return 0.65F;
}
static class AISpiderAttack extends EntityAIAttackMelee
{
public AISpiderAttack(EntityMimic spider)
{
static class AISpiderAttack extends EntityAIAttackMelee {
public AISpiderAttack(EntityMimic spider) {
super(spider, 1.0D, true);
}
@Override
protected double getAttackReachSqr(EntityLivingBase attackTarget)
{
protected double getAttackReachSqr(EntityLivingBase attackTarget) {
return (double) (4.0F + attackTarget.width);
}
}
static class AISpiderTarget<T extends EntityLivingBase> extends EntityAINearestAttackableTarget<T>
{
public AISpiderTarget(EntityMimic spider, Class<T> classTarget)
{
static class AISpiderTarget<T extends EntityLivingBase> extends EntityAINearestAttackableTarget<T> {
public AISpiderTarget(EntityMimic spider, Class<T> classTarget) {
super(spider, classTarget, true);
}
}

View file

@ -1,21 +1,22 @@
package WayofTime.bloodmagic.entity.mob;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow;
import WayofTime.bloodmagic.entity.ai.EntityAIFollowOwner;
import WayofTime.bloodmagic.entity.ai.*;
import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtByTarget;
import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtTarget;
import WayofTime.bloodmagic.item.soul.ItemSentientBow;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
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.ai.*;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.player.EntityPlayer;
@ -39,31 +40,19 @@ import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow;
import WayofTime.bloodmagic.entity.ai.EntityAIFollowOwner;
import WayofTime.bloodmagic.entity.ai.EntityAIGrabEffectsFromOwner;
import WayofTime.bloodmagic.entity.ai.EntityAIHurtByTargetIgnoreTamed;
import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtByTarget;
import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtTarget;
import WayofTime.bloodmagic.entity.ai.EntityAIRetreatToHeal;
import WayofTime.bloodmagic.item.soul.ItemSentientBow;
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
public class EntitySentientSpecter extends EntityDemonBase
{
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class EntitySentientSpecter extends EntityDemonBase {
private final EntityAIAttackRangedBow aiArrowAttack = new EntityAIAttackRangedBow(this, 1.0D, 20, 15.0F);
private final EntityAIAttackMelee aiAttackOnCollide = new EntityAIAttackMelee(this, 1.0D, false);
private final int attackPriority = 3;
protected EnumDemonWillType type = EnumDemonWillType.DESTRUCTIVE;
protected boolean wasGivenSentientArmour = false;
private final EntityAIAttackRangedBow aiArrowAttack = new EntityAIAttackRangedBow(this, 1.0D, 20, 15.0F);
private final EntityAIAttackMelee aiAttackOnCollide = new EntityAIAttackMelee(this, 1.0D, false);
private final int attackPriority = 3;
public EntitySentientSpecter(World worldIn)
{
public EntitySentientSpecter(World worldIn) {
super(worldIn);
this.setSize(0.6F, 1.95F);
// ((PathNavigateGround) getNavigator()).setCanSwim(false);
@ -87,8 +76,7 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
protected void applyEntityAttributes()
{
protected void applyEntityAttributes() {
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(40.0D);
getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D);
@ -96,27 +84,22 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
public void setCombatTask()
{
if (!this.getEntityWorld().isRemote)
{
public void setCombatTask() {
if (!this.getEntityWorld().isRemote) {
this.tasks.removeTask(this.aiAttackOnCollide);
this.tasks.removeTask(this.aiArrowAttack);
ItemStack itemstack = this.getHeldItemMainhand();
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow)
{
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) {
int i = 20;
if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD)
{
if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) {
i = 40;
}
this.aiArrowAttack.setAttackCooldown(i);
this.tasks.addTask(attackPriority, this.aiArrowAttack);
} else
{
} else {
this.tasks.addTask(attackPriority, this.aiAttackOnCollide);
}
}
@ -130,22 +113,17 @@ public class EntitySentientSpecter extends EntityDemonBase
return !(potion == MobEffects.REGENERATION || potion == MobEffects.INSTANT_HEALTH) && super.isPotionApplicable(effect);
}
public boolean canStealEffectFromOwner(EntityLivingBase owner, PotionEffect effect)
{
public boolean canStealEffectFromOwner(EntityLivingBase owner, PotionEffect effect) {
return effect.getPotion().isBadEffect() && this.type == EnumDemonWillType.CORROSIVE;
}
public boolean canStealEffectFromOwner(EntityLivingBase owner)
{
if (this.type != EnumDemonWillType.CORROSIVE)
{
public boolean canStealEffectFromOwner(EntityLivingBase owner) {
if (this.type != EnumDemonWillType.CORROSIVE) {
return false;
}
for (PotionEffect eff : owner.getActivePotionEffects())
{
if (canStealEffectFromOwner(owner, eff))
{
for (PotionEffect eff : owner.getActivePotionEffects()) {
if (canStealEffectFromOwner(owner, eff)) {
return true;
}
}
@ -153,10 +131,8 @@ public class EntitySentientSpecter extends EntityDemonBase
return false;
}
public boolean stealEffectsFromOwner(EntityLivingBase owner)
{
if (this.type != EnumDemonWillType.CORROSIVE)
{
public boolean stealEffectsFromOwner(EntityLivingBase owner) {
if (this.type != EnumDemonWillType.CORROSIVE) {
return false;
}
@ -164,17 +140,14 @@ public class EntitySentientSpecter extends EntityDemonBase
List<PotionEffect> removedEffects = new ArrayList<PotionEffect>();
for (PotionEffect eff : owner.getActivePotionEffects())
{
if (canStealEffectFromOwner(owner, eff))
{
for (PotionEffect eff : owner.getActivePotionEffects()) {
if (canStealEffectFromOwner(owner, eff)) {
removedEffects.add(eff);
hasStolenEffect = true;
}
}
for (PotionEffect eff : removedEffects)
{
for (PotionEffect eff : removedEffects) {
owner.removePotionEffect(eff.getPotion());
this.addPotionEffect(eff);
}
@ -182,23 +155,17 @@ public class EntitySentientSpecter extends EntityDemonBase
return hasStolenEffect;
}
public boolean applyNegativeEffectsToAttacked(EntityLivingBase attackedEntity, float percentTransmitted)
{
public boolean applyNegativeEffectsToAttacked(EntityLivingBase attackedEntity, float percentTransmitted) {
boolean hasProvidedEffect = false;
List<PotionEffect> removedEffects = new ArrayList<PotionEffect>();
for (PotionEffect eff : this.getActivePotionEffects())
{
if (eff.getPotion().isBadEffect() && attackedEntity.isPotionApplicable(eff))
{
if (!attackedEntity.isPotionActive(eff.getPotion()))
{
for (PotionEffect eff : this.getActivePotionEffects()) {
if (eff.getPotion().isBadEffect() && attackedEntity.isPotionApplicable(eff)) {
if (!attackedEntity.isPotionActive(eff.getPotion())) {
removedEffects.add(eff);
hasProvidedEffect = true;
} else
{
} else {
PotionEffect activeEffect = attackedEntity.getActivePotionEffect(eff.getPotion());
if (activeEffect.getAmplifier() < eff.getAmplifier() || activeEffect.getDuration() < eff.getDuration() * percentTransmitted)
{
if (activeEffect.getAmplifier() < eff.getAmplifier() || activeEffect.getDuration() < eff.getDuration() * percentTransmitted) {
removedEffects.add(eff);
hasProvidedEffect = true;
}
@ -206,18 +173,15 @@ public class EntitySentientSpecter extends EntityDemonBase
}
}
for (PotionEffect eff : removedEffects)
{
if (!attackedEntity.isPotionActive(eff.getPotion()))
{
for (PotionEffect eff : removedEffects) {
if (!attackedEntity.isPotionActive(eff.getPotion())) {
PotionEffect newEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * percentTransmitted), eff.getAmplifier(), eff.getIsAmbient(), eff.doesShowParticles());
attackedEntity.addPotionEffect(newEffect);
PotionEffect newSentientEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * (1 - percentTransmitted)), eff.getAmplifier(), eff.getIsAmbient(), eff.doesShowParticles());
this.removePotionEffect(eff.getPotion());
this.addPotionEffect(newSentientEffect);
} else
{
} else {
PotionEffect activeEffect = attackedEntity.getActivePotionEffect(eff.getPotion());
PotionEffect newEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * percentTransmitted), eff.getAmplifier(), activeEffect.getIsAmbient(), activeEffect.doesShowParticles());
@ -232,26 +196,21 @@ public class EntitySentientSpecter extends EntityDemonBase
return hasProvidedEffect;
}
public List<PotionEffect> getPotionEffectsForArrowRemovingDuration(float percentTransmitted)
{
public List<PotionEffect> getPotionEffectsForArrowRemovingDuration(float percentTransmitted) {
List<PotionEffect> arrowEffects = new ArrayList<PotionEffect>();
if (type != EnumDemonWillType.CORROSIVE)
{
if (type != EnumDemonWillType.CORROSIVE) {
return arrowEffects;
}
List<PotionEffect> removedEffects = new ArrayList<PotionEffect>();
for (PotionEffect eff : this.getActivePotionEffects())
{
if (eff.getPotion().isBadEffect())
{
for (PotionEffect eff : this.getActivePotionEffects()) {
if (eff.getPotion().isBadEffect()) {
removedEffects.add(eff);
}
}
for (PotionEffect eff : removedEffects)
{
for (PotionEffect eff : removedEffects) {
PotionEffect newEffect = new PotionEffect(eff.getPotion(), (int) (eff.getDuration() * percentTransmitted), eff.getAmplifier(), eff.getIsAmbient(), eff.doesShowParticles());
arrowEffects.add(newEffect);
@ -264,8 +223,7 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
public boolean attackEntityFrom(DamageSource source, float amount) {
return !this.isEntityInvulnerable(source) && super.attackEntityFrom(source, amount);
}
@ -273,47 +231,38 @@ public class EntitySentientSpecter extends EntityDemonBase
* Redone from EntityMob to prevent despawning on peaceful.
*/
@Override
public boolean attackEntityAsMob(Entity attackedEntity)
{
public boolean attackEntityAsMob(Entity attackedEntity) {
boolean flag = super.attackEntityAsMob(attackedEntity);
if (flag)
{
if (this.type == EnumDemonWillType.CORROSIVE && attackedEntity instanceof EntityLivingBase)
{
if (flag) {
if (this.type == EnumDemonWillType.CORROSIVE && attackedEntity instanceof EntityLivingBase) {
// ((EntityLivingBase) attackedEntity).addPotionEffect(new PotionEffect(MobEffects.WITHER, 200));
applyNegativeEffectsToAttacked((EntityLivingBase) attackedEntity, 1);
}
return true;
} else
{
} else {
return false;
}
}
@Override
public void onDeath(DamageSource cause)
{
public void onDeath(DamageSource cause) {
super.onDeath(cause);
if (!getEntityWorld().isRemote && !getHeldItemMainhand().isEmpty())
{
if (!getEntityWorld().isRemote && !getHeldItemMainhand().isEmpty()) {
this.entityDropItem(getHeldItemMainhand(), 0);
}
}
@Override
public boolean isStationary()
{
public boolean isStationary() {
return false;
}
@Override
public boolean absorbExplosion(Explosion explosion)
{
if (this.type == EnumDemonWillType.DESTRUCTIVE)
{
public boolean absorbExplosion(Explosion explosion) {
if (this.type == EnumDemonWillType.DESTRUCTIVE) {
this.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 600, 1));
explosion.doExplosionB(true);
@ -325,27 +274,21 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
public boolean processInteract(EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (this.isTamed() && player.equals(this.getOwner()) && hand == EnumHand.MAIN_HAND)
{
if (this.isTamed() && player.equals(this.getOwner()) && hand == EnumHand.MAIN_HAND) {
if (stack.isEmpty() && player.isSneaking()) //Should return to the entity
{
if (!getEntityWorld().isRemote)
{
if (!getHeldItemMainhand().isEmpty())
{
if (!getEntityWorld().isRemote) {
if (!getHeldItemMainhand().isEmpty()) {
this.entityDropItem(getHeldItemMainhand(), 0);
}
if (!getHeldItemOffhand().isEmpty())
{
if (!getHeldItemOffhand().isEmpty()) {
this.entityDropItem(getHeldItemOffhand(), 0);
}
if (wasGivenSentientArmour)
{
if (wasGivenSentientArmour) {
this.entityDropItem(new ItemStack(RegistrarBloodMagicItems.SENTIENT_ARMOUR_GEM), 0);
}
@ -357,46 +300,38 @@ public class EntitySentientSpecter extends EntityDemonBase
return super.processInteract(player, hand);
}
public boolean isEntityInvulnerable(DamageSource source)
{
public boolean isEntityInvulnerable(DamageSource source) {
return super.isEntityInvulnerable(source) && (this.type == EnumDemonWillType.DESTRUCTIVE && source.isExplosion());
}
@Override
public void performEmergencyHeal(double toHeal)
{
public void performEmergencyHeal(double toHeal) {
this.heal((float) toHeal);
if (getEntityWorld() instanceof WorldServer)
{
if (getEntityWorld() instanceof WorldServer) {
WorldServer server = (WorldServer) getEntityWorld();
server.spawnParticle(EnumParticleTypes.HEART, this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, 7, 0.2, 0.2, 0.2, 0, new int[0]);
}
}
/**
*
* @param toHeal
* @return Amount of Will consumed from the Aura to heal
*/
public double absorbWillFromAuraToHeal(double toHeal)
{
if (getEntityWorld().isRemote)
{
public double absorbWillFromAuraToHeal(double toHeal) {
if (getEntityWorld().isRemote) {
return 0;
}
double healthMissing = this.getMaxHealth() - this.getHealth();
if (healthMissing <= 0)
{
if (healthMissing <= 0) {
return 0;
}
double will = WorldDemonWillHandler.getCurrentWill(getEntityWorld(), getPosition(), getType());
toHeal = Math.min(healthMissing, Math.min(toHeal, will / getWillToHealth()));
if (toHeal > 0)
{
if (toHeal > 0) {
this.heal((float) toHeal);
return WorldDemonWillHandler.drainWill(getEntityWorld(), getPosition(), getType(), toHeal * getWillToHealth(), true);
}
@ -404,21 +339,17 @@ public class EntitySentientSpecter extends EntityDemonBase
return 0;
}
public double getWillToHealth()
{
public double getWillToHealth() {
return 2;
}
@Override
protected boolean canDespawn()
{
protected boolean canDespawn() {
return !this.isTamed() && super.canDespawn();
}
public void onUpdate()
{
if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0)
{
public void onUpdate() {
if (!this.getEntityWorld().isRemote && this.ticksExisted % 20 == 0) {
absorbWillFromAuraToHeal(2);
}
@ -426,8 +357,7 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
@ -436,15 +366,12 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
public void readEntityFromNBT(NBTTagCompound tag) {
super.readEntityFromNBT(tag);
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
{
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
type = EnumDemonWillType.DEFAULT;
} else
{
} else {
type = EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
}
@ -455,37 +382,29 @@ public class EntitySentientSpecter extends EntityDemonBase
//TODO: Change to fit the given AI
@Override
public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner)
{
if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast))
{
public boolean shouldAttackEntity(EntityLivingBase attacker, EntityLivingBase owner) {
if (!(attacker instanceof EntityCreeper) && !(attacker instanceof EntityGhast)) {
return super.shouldAttackEntity(attacker, owner);
} else
{
} else {
return false;
}
}
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity)
{
public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity) {
ItemStack heldStack = this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
if (!heldStack.isEmpty() && heldStack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW)
{
if (!heldStack.isEmpty() && heldStack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW) {
EntityTippedArrow arrowEntity = ((ItemSentientBow) heldStack.getItem()).getArrowEntity(getEntityWorld(), heldStack, target, this, velocity);
if (arrowEntity != null)
{
if (arrowEntity != null) {
List<PotionEffect> effects = getPotionEffectsForArrowRemovingDuration(0.2f);
for (PotionEffect eff : effects)
{
for (PotionEffect eff : effects) {
arrowEntity.addEffect(eff);
}
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.getEntityWorld().spawnEntity(arrowEntity);
}
} else
{
} else {
EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.getEntityWorld(), this); //TODO: Change to an arrow created by the Sentient Bow
double d0 = target.posX - this.posX;
double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entitytippedarrow.posY;
@ -496,21 +415,18 @@ public class EntitySentientSpecter extends EntityDemonBase
int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
entitytippedarrow.setDamage((double) (velocity * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.getEntityWorld().getDifficulty().getDifficultyId() * 0.11F));
if (i > 0)
{
if (i > 0) {
entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double) i * 0.5D + 0.5D);
}
if (j > 0)
{
if (j > 0) {
entitytippedarrow.setKnockbackStrength(j);
}
boolean burning = this.isBurning();
burning = burning || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0;
if (burning)
{
if (burning) {
entitytippedarrow.setFire(100);
}
@ -525,26 +441,22 @@ public class EntitySentientSpecter extends EntityDemonBase
}
@Override
protected SoundEvent getAmbientSound()
{
protected SoundEvent getAmbientSound() {
return SoundEvents.ENTITY_COW_AMBIENT;
}
@Override
protected SoundEvent getHurtSound()
{
protected SoundEvent getHurtSound() {
return SoundEvents.ENTITY_COW_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
protected SoundEvent getDeathSound() {
return SoundEvents.ENTITY_COW_DEATH;
}
@Override
protected void playStepSound(BlockPos pos, Block block)
{
protected void playStepSound(BlockPos pos, Block block) {
this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F);
}
@ -552,8 +464,7 @@ public class EntitySentientSpecter extends EntityDemonBase
* Returns the volume for the sounds this mob makes.
*/
@Override
protected float getSoundVolume()
{
protected float getSoundVolume() {
return 0.4F;
}

View file

@ -8,7 +8,8 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
@ -16,27 +17,23 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fml.common.registry.IThrowableEntity;
public class EntityBloodLight extends EntityThrowable implements IThrowableEntity, IEntityAdditionalSpawnData
{
public class EntityBloodLight extends EntityThrowable implements IThrowableEntity, IEntityAdditionalSpawnData {
public EntityLivingBase shootingEntity;
protected int ticksInAir = 0;
protected int maxTicksInAir = 600;
public EntityBloodLight(World world)
{
public EntityBloodLight(World world) {
super(world);
this.setSize(0.5F, 0.5F);
}
public EntityBloodLight(World world, double x, double y, double z)
{
public EntityBloodLight(World world, double x, double y, double z) {
super(world);
this.setSize(0.5F, 0.5F);
this.setPosition(x, y, z);
}
public EntityBloodLight(World world, EntityLivingBase player)
{
public EntityBloodLight(World world, EntityLivingBase player) {
super(world, player);
shootingEntity = player;
float par3 = 0.8F;
@ -53,14 +50,12 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit
}
@Override
protected float getGravityVelocity()
{
protected float getGravityVelocity() {
return 0F;
}
@Override
public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8)
{
public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) {
float var9 = MathHelper.sqrt(var1 * var1 + var3 * var3 + var5 * var5);
var1 /= var9;
var3 /= var9;
@ -80,33 +75,26 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit
}
@Override
public void onUpdate()
{
public void onUpdate() {
super.onUpdate();
if (this.ticksExisted > this.maxTicksInAir)
{
if (this.ticksExisted > this.maxTicksInAir) {
setDead();
}
}
@Override
protected void onImpact(RayTraceResult mop)
{
if (mop.typeOfHit == RayTraceResult.Type.ENTITY && mop.entityHit != null)
{
if (mop.entityHit == shootingEntity)
{
protected void onImpact(RayTraceResult mop) {
if (mop.typeOfHit == RayTraceResult.Type.ENTITY && mop.entityHit != null) {
if (mop.entityHit == shootingEntity) {
return;
}
this.onImpact(mop.entityHit);
} else if (mop.typeOfHit == RayTraceResult.Type.BLOCK)
{
} else if (mop.typeOfHit == RayTraceResult.Type.BLOCK) {
EnumFacing sideHit = mop.sideHit;
BlockPos blockPos = mop.getBlockPos().offset(sideHit);
if (getEntityWorld().isAirBlock(blockPos))
{
if (getEntityWorld().isAirBlock(blockPos)) {
getEntityWorld().setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState());
}
}
@ -114,23 +102,18 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit
this.setDead();
}
protected void onImpact(Entity mop)
{
if (mop == shootingEntity && ticksInAir > 3)
{
protected void onImpact(Entity mop) {
if (mop == shootingEntity && ticksInAir > 3) {
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
this.setDead();
} else
{
if (mop instanceof EntityLivingBase)
{
} else {
if (mop instanceof EntityLivingBase) {
((EntityLivingBase) mop).setRevengeTarget(shootingEntity);
doDamage(1, mop);
}
}
if (getEntityWorld().isAirBlock(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ)))
{
if (getEntityWorld().isAirBlock(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ))) {
getEntityWorld().setBlockState(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ), Blocks.FIRE.getDefaultState());
}
@ -138,59 +121,50 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit
this.setDead();
}
protected void doDamage(int i, Entity mop)
{
protected void doDamage(int i, Entity mop) {
mop.attackEntityFrom(this.getDamageSource(), i);
}
public DamageSource getDamageSource()
{
public DamageSource getDamageSource() {
return DamageSource.causeMobDamage(shootingEntity);
}
@Override
public void writeSpawnData(ByteBuf data)
{
public void writeSpawnData(ByteBuf data) {
data.writeByte(this.ticksInAir);
}
@Override
public void readSpawnData(ByteBuf data)
{
public void readSpawnData(ByteBuf data) {
this.ticksInAir = data.readByte();
}
@Override
public void writeEntityToNBT(NBTTagCompound nbt)
{
public void writeEntityToNBT(NBTTagCompound nbt) {
super.writeEntityToNBT(nbt);
nbt.setInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR, ticksInAir);
nbt.setInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR, maxTicksInAir);
}
@Override
public void readEntityFromNBT(NBTTagCompound nbt)
{
public void readEntityFromNBT(NBTTagCompound nbt) {
super.readEntityFromNBT(nbt);
ticksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR);
maxTicksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR);
}
@Override
protected boolean canTriggerWalking()
{
protected boolean canTriggerWalking() {
return false;
}
@Override
public boolean canBeCollidedWith()
{
public boolean canBeCollidedWith() {
return false;
}
@Override
public void setThrower(Entity entity)
{
public void setThrower(Entity entity) {
if (entity instanceof EntityLivingBase)
this.shootingEntity = (EntityLivingBase) entity;
}

View file

@ -1,5 +1,7 @@
package WayofTime.bloodmagic.entity.projectile;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.meteor.MeteorRegistry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
@ -11,27 +13,20 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.IThrowableEntity;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.meteor.MeteorRegistry;
public class EntityMeteor extends EntityThrowable implements IThrowableEntity
{
public class EntityMeteor extends EntityThrowable implements IThrowableEntity {
public ItemStack meteorStack = ItemStack.EMPTY;
protected int ticksInAir = 0;
protected int maxTicksInAir = 600;
protected double radiusModifier = 1;
protected double explosionModifier = 1;
protected double fillerChance = 0;
public ItemStack meteorStack = ItemStack.EMPTY;
public EntityMeteor(World world)
{
public EntityMeteor(World world) {
super(world);
}
public EntityMeteor(World world, double x, double y, double z, double velX, double velY, double velZ, double radiusModifier, double explosionModifier, double fillerChance)
{
public EntityMeteor(World world, double x, double y, double z, double velX, double velY, double velZ, double radiusModifier, double explosionModifier, double fillerChance) {
super(world);
this.setSize(1F, 1F);
this.setPosition(x, y, z);
@ -44,39 +39,31 @@ public class EntityMeteor extends EntityThrowable implements IThrowableEntity
}
@Override
protected float getGravityVelocity()
{
protected float getGravityVelocity() {
return 0.03F;
}
@Override
public void onUpdate()
{
public void onUpdate() {
super.onUpdate();
if (this.ticksExisted > this.maxTicksInAir)
{
if (this.ticksExisted > this.maxTicksInAir) {
setDead();
}
}
@Override
protected void onImpact(RayTraceResult mop)
{
if (mop.typeOfHit == RayTraceResult.Type.ENTITY && mop.entityHit != null)
{
protected void onImpact(RayTraceResult mop) {
if (mop.typeOfHit == RayTraceResult.Type.ENTITY && mop.entityHit != null) {
this.onImpact(mop.entityHit);
} else if (mop.typeOfHit == RayTraceResult.Type.BLOCK)
{
} else if (mop.typeOfHit == RayTraceResult.Type.BLOCK) {
generateMeteor(mop.getBlockPos());
}
this.setDead();
}
protected void onImpact(Entity mop)
{
if (mop instanceof EntityLivingBase)
{
protected void onImpact(Entity mop) {
if (mop instanceof EntityLivingBase) {
doDamage(100, mop);
}
@ -86,24 +73,20 @@ public class EntityMeteor extends EntityThrowable implements IThrowableEntity
this.setDead();
}
protected void doDamage(int i, Entity mop)
{
protected void doDamage(int i, Entity mop) {
mop.attackEntityFrom(this.getDamageSource(), i);
}
public void generateMeteor(BlockPos pos)
{
public void generateMeteor(BlockPos pos) {
MeteorRegistry.generateMeteorForItem(meteorStack, getEntityWorld(), pos, Blocks.STONE.getDefaultState(), radiusModifier, explosionModifier, fillerChance);
}
public DamageSource getDamageSource()
{
public DamageSource getDamageSource() {
return DamageSource.ANVIL;
}
@Override
public void writeEntityToNBT(NBTTagCompound nbt)
{
public void writeEntityToNBT(NBTTagCompound nbt) {
super.writeEntityToNBT(nbt);
nbt.setInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR, ticksInAir);
nbt.setInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR, maxTicksInAir);
@ -117,8 +100,7 @@ public class EntityMeteor extends EntityThrowable implements IThrowableEntity
}
@Override
public void readEntityFromNBT(NBTTagCompound nbt)
{
public void readEntityFromNBT(NBTTagCompound nbt) {
super.readEntityFromNBT(nbt);
ticksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR);
maxTicksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR);
@ -132,20 +114,17 @@ public class EntityMeteor extends EntityThrowable implements IThrowableEntity
}
@Override
protected boolean canTriggerWalking()
{
protected boolean canTriggerWalking() {
return false;
}
@Override
public boolean canBeCollidedWith()
{
public boolean canBeCollidedWith() {
return false;
}
@Override
public void setThrower(Entity entity)
{
public void setThrower(Entity entity) {
}

View file

@ -1,5 +1,8 @@
package WayofTime.bloodmagic.entity.projectile;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
@ -9,40 +12,30 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
import java.util.Locale;
public class EntitySentientArrow extends EntityTippedArrow
{
public class EntitySentientArrow extends EntityTippedArrow {
public double reimbursedAmountOnHit = 0;
public EnumDemonWillType type = EnumDemonWillType.DEFAULT;
public EntitySentientArrow(World worldIn)
{
public EntitySentientArrow(World worldIn) {
super(worldIn);
}
public EntitySentientArrow(World worldIn, double x, double y, double z)
{
public EntitySentientArrow(World worldIn, double x, double y, double z) {
super(worldIn, x, y, z);
}
public EntitySentientArrow(World worldIn, EntityLivingBase shooter, EnumDemonWillType type, double reinburseAmount)
{
public EntitySentientArrow(World worldIn, EntityLivingBase shooter, EnumDemonWillType type, double reinburseAmount) {
super(worldIn, shooter);
this.reimbursedAmountOnHit = reinburseAmount;
this.type = type;
}
public void reimbursePlayer(EntityLivingBase hitEntity, float damage)
{
if (this.shootingEntity instanceof EntityPlayer)
{
if (hitEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob))
{
public void reimbursePlayer(EntityLivingBase hitEntity, float damage) {
if (this.shootingEntity instanceof EntityPlayer) {
if (hitEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob)) {
return;
}
@ -51,8 +44,7 @@ public class EntitySentientArrow extends EntityTippedArrow
}
@Override
public void writeEntityToNBT(NBTTagCompound tag)
{
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
tag.setDouble("reimbursement", reimbursedAmountOnHit);
@ -60,8 +52,7 @@ public class EntitySentientArrow extends EntityTippedArrow
}
@Override
public void readEntityFromNBT(NBTTagCompound tag)
{
public void readEntityFromNBT(NBTTagCompound tag) {
super.readEntityFromNBT(tag);
reimbursedAmountOnHit = tag.getDouble("reimbursement");
@ -69,8 +60,7 @@ public class EntitySentientArrow extends EntityTippedArrow
}
@Override
protected ItemStack getArrowStack()
{
protected ItemStack getArrowStack() {
return new ItemStack(Items.ARROW);
}
}

View file

@ -9,20 +9,16 @@ import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
public class EntitySoulSnare extends EntityThrowable
{
public EntitySoulSnare(World worldIn)
{
public class EntitySoulSnare extends EntityThrowable {
public EntitySoulSnare(World worldIn) {
super(worldIn);
}
public EntitySoulSnare(World worldIn, EntityLivingBase throwerIn)
{
public EntitySoulSnare(World worldIn, EntityLivingBase throwerIn) {
super(worldIn, throwerIn);
}
public EntitySoulSnare(World worldIn, double x, double y, double z)
{
public EntitySoulSnare(World worldIn, double x, double y, double z) {
super(worldIn, x, y, z);
}
@ -30,30 +26,24 @@ public class EntitySoulSnare extends EntityThrowable
* Called when this EntityThrowable hits a block or entity.
*/
@Override
protected void onImpact(RayTraceResult result)
{
if (result.entityHit == this.getThrower() && this.ticksExisted < 20)
{
protected void onImpact(RayTraceResult result) {
if (result.entityHit == this.getThrower() && this.ticksExisted < 20) {
return;
}
if (result.entityHit != null && result.entityHit != this.getThrower())
{
if (result.entityHit instanceof EntityLivingBase && result.entityHit.getEntityWorld().rand.nextDouble() < 0.25)
{
if (result.entityHit != null && result.entityHit != this.getThrower()) {
if (result.entityHit instanceof EntityLivingBase && result.entityHit.getEntityWorld().rand.nextDouble() < 0.25) {
((EntityLivingBase) result.entityHit).addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_SNARE, 300, 0));
}
result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) 0);
}
for (int j = 0; j < 8; ++j)
{
for (int j = 0; j < 8; ++j) {
this.getEntityWorld().spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
}
if (!this.getEntityWorld().isRemote)
{
if (!this.getEntityWorld().isRemote) {
this.setDead();
}
}