From 73bc357197095e910a3249a5b2f7b99a63a0c26c Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Tue, 29 Aug 2017 23:29:33 +1000 Subject: $ Fixed LFTR tooltip not mentioning which casings to use. % More messing around with entity rendering and some custom mobs. --- .../core/entity/monster/EntitySickBlaze.java | 9 +- .../entity/monster/EntityStaballoyConstruct.java | 279 ++++++++++++++++++++ .../entity/monster/EntityStaballoyWarrior.java | 283 --------------------- 3 files changed, 284 insertions(+), 287 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java delete mode 100644 src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyWarrior.java (limited to 'src/Java/gtPlusPlus/core/entity') diff --git a/src/Java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java b/src/Java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java index 4d46c0a5ca..0c650ed3f2 100644 --- a/src/Java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java +++ b/src/Java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java @@ -19,6 +19,7 @@ public class EntitySickBlaze extends EntityBlaze { /** ticks until heightOffset is randomized */ private int heightOffsetUpdateTime; private int field_70846_g; + private final int mDataWatcherID = 30; public EntitySickBlaze(World p_i1731_1_) { super(p_i1731_1_); @@ -35,7 +36,7 @@ public class EntitySickBlaze extends EntityBlaze { @Override protected void entityInit() { super.entityInit(); - this.dataWatcher.addObject(16, new Byte((byte) 0)); + this.dataWatcher.addObject(mDataWatcherID, new Byte((byte) 0)); } /** @@ -209,12 +210,12 @@ public class EntitySickBlaze extends EntityBlaze { @Override public boolean func_70845_n() { - return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + return (this.dataWatcher.getWatchableObjectByte(mDataWatcherID) & 1) != 0; } @Override public void func_70844_e(boolean p_70844_1_) { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); + byte b0 = this.dataWatcher.getWatchableObjectByte(mDataWatcherID); if (p_70844_1_) { b0 = (byte) (b0 | 1); @@ -223,7 +224,7 @@ public class EntitySickBlaze extends EntityBlaze { b0 &= -2; } - this.dataWatcher.updateObject(16, Byte.valueOf(b0)); + this.dataWatcher.updateObject(mDataWatcherID, Byte.valueOf(b0)); } /** diff --git a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java new file mode 100644 index 0000000000..0006cae8af --- /dev/null +++ b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java @@ -0,0 +1,279 @@ +package gtPlusPlus.core.entity.monster; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.*; +import net.minecraft.entity.ai.*; +import net.minecraft.entity.monster.EntityGolem; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.*; +import net.minecraft.village.Village; +import net.minecraft.world.World; + +public class EntityStaballoyConstruct extends EntityGolem { + /** deincrements, and a distance-to-home check is done at 0 */ + private int homeCheckTimer; + Village villageObj; + private int attackTimer; + private int holdRoseTick; + + public EntityStaballoyConstruct(World world) { + super(world); + this.setSize(1.4F, 2.9F); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true)); + this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); + this.tasks.addTask(3, new EntityAIMoveThroughVillage(this, 0.6D, true)); + this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D)); + this.tasks.addTask(5, new EntityAIWander(this, 0.6D)); + this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(7, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask(2, + new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, IMob.mobSelector)); + } + + @Override + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(16, Byte.valueOf((byte) 0)); + } + + /** + * Returns true if the newer Entity AI code should be run + */ + @Override + public boolean isAIEnabled() { + return true; + } + + /** + * main AI tick function, replaces updateEntityActionState + */ + @Override + protected void updateAITick() { + if (--this.homeCheckTimer <= 0) { + this.homeCheckTimer = 70 + this.rand.nextInt(50); + this.villageObj = this.worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(this.posX), + MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 32); + + if (this.villageObj == null) { + this.detachHome(); + } + else { + ChunkCoordinates chunkcoordinates = this.villageObj.getCenter(); + this.setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, + (int) (this.villageObj.getVillageRadius() * 0.6F)); + } + } + + super.updateAITick(); + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); + } + + /** + * Decrements the entity's air supply when underwater + */ + @Override + protected int decreaseAirSupply(int p_70682_1_) { + return p_70682_1_; + } + + @Override + protected void collideWithEntity(Entity p_82167_1_) { + if (p_82167_1_ instanceof IMob && this.getRNG().nextInt(20) == 0) { + this.setAttackTarget((EntityLivingBase) p_82167_1_); + } + + super.collideWithEntity(p_82167_1_); + } + + /** + * Called frequently so the entity can update its state every tick as + * required. For example, zombies and skeletons use this to react to + * sunlight and start to burn. + */ + @Override + public void onLivingUpdate() { + super.onLivingUpdate(); + + if (this.attackTimer > 0) { + --this.attackTimer; + } + + if (this.holdRoseTick > 0) { + --this.holdRoseTick; + } + + if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D + && this.rand.nextInt(5) == 0) { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY - 0.20000000298023224D - this.yOffset); + int k = MathHelper.floor_double(this.posZ); + Block block = this.worldObj.getBlock(i, j, k); + + if (block.getMaterial() != Material.air) { + this.worldObj.spawnParticle( + "blockcrack_" + Block.getIdFromBlock(block) + "_" + this.worldObj.getBlockMetadata(i, j, k), + this.posX + (this.rand.nextFloat() - 0.5D) * this.width, + this.boundingBox.minY + 0.1D, + this.posZ + (this.rand.nextFloat() - 0.5D) * this.width, + 4.0D * (this.rand.nextFloat() - 0.5D), 0.5D, + (this.rand.nextFloat() - 0.5D) * 4.0D); + } + } + } + + /** + * Returns true if this entity can attack entities of the specified class. + */ + @Override + public boolean canAttackClass(Class p_70686_1_) { + return this.isPlayerCreated() && EntityPlayer.class.isAssignableFrom(p_70686_1_) ? false + : super.canAttackClass(p_70686_1_); + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + public void writeEntityToNBT(NBTTagCompound p_70014_1_) { + super.writeEntityToNBT(p_70014_1_); + p_70014_1_.setBoolean("PlayerCreated", this.isPlayerCreated()); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + public void readEntityFromNBT(NBTTagCompound p_70037_1_) { + super.readEntityFromNBT(p_70037_1_); + this.setPlayerCreated(p_70037_1_.getBoolean("PlayerCreated")); + } + + @Override + public boolean attackEntityAsMob(Entity p_70652_1_) { + this.attackTimer = 10; + this.worldObj.setEntityState(this, (byte) 4); + boolean flag = p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), + 7 + this.rand.nextInt(15)); + + if (flag) { + p_70652_1_.motionY += 0.4000000059604645D; + } + + this.playSound("mob.irongolem.throw", 1.0F, 1.0F); + return flag; + } + + @Override + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte p_70103_1_) { + if (p_70103_1_ == 4) { + this.attackTimer = 10; + this.playSound("mob.irongolem.throw", 1.0F, 1.0F); + } + else if (p_70103_1_ == 11) { + this.holdRoseTick = 400; + } + else { + super.handleHealthUpdate(p_70103_1_); + } + } + + public Village getVillage() { + return this.villageObj; + } + + @SideOnly(Side.CLIENT) + public int getAttackTimer() { + return this.attackTimer; + } + + public void setHoldingRose(boolean p_70851_1_) { + this.holdRoseTick = p_70851_1_ ? 400 : 0; + this.worldObj.setEntityState(this, (byte) 11); + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + @Override + protected String getHurtSound() { + return "mob.irongolem.hit"; + } + + /** + * Returns the sound this mob makes on death. + */ + @Override + protected String getDeathSound() { + return "mob.irongolem.death"; + } + + @Override + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { + this.playSound("mob.irongolem.walk", 1.0F, 1.0F); + } + + /** + * Drop 0-2 items of this living's type. @param par1 - Whether this entity + * has recently been hit by a player. @param par2 - Level of Looting used to + * kill this mob. + */ + @Override + protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { + int j = this.rand.nextInt(3); + int k; + + for (k = 0; k < j; ++k) { + this.func_145778_a(Item.getItemFromBlock(Blocks.red_flower), 1, 0.0F); + } + + k = 3 + this.rand.nextInt(3); + + for (int l = 0; l < k; ++l) { + this.dropItem(Items.iron_ingot, 1); + } + } + + public int getHoldRoseTick() { + return this.holdRoseTick; + } + + public boolean isPlayerCreated() { + return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + } + + public void setPlayerCreated(boolean p_70849_1_) { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (p_70849_1_) { + this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 1))); + } + else { + this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -2))); + } + } + + /** + * Called when the mob's health reaches 0. + */ + @Override + public void onDeath(DamageSource p_70645_1_) { + super.onDeath(p_70645_1_); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyWarrior.java b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyWarrior.java deleted file mode 100644 index b6829f6985..0000000000 --- a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyWarrior.java +++ /dev/null @@ -1,283 +0,0 @@ -package gtPlusPlus.core.entity.monster; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.*; -import net.minecraft.entity.ai.*; -import net.minecraft.entity.monster.EntityGolem; -import net.minecraft.entity.monster.IMob; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.*; -import net.minecraft.village.Village; -import net.minecraft.world.World; - -public class EntityStaballoyWarrior extends EntityGolem { - /** deincrements, and a distance-to-home check is done at 0 */ - private int homeCheckTimer; - Village villageObj; - private int attackTimer; - private int holdRoseTick; - - public EntityStaballoyWarrior(World world) { - super(world); - this.setSize(1.4F, 2.9F); - this.getNavigator().setAvoidsWater(true); - this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true)); - this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); - this.tasks.addTask(3, new EntityAIMoveThroughVillage(this, 0.6D, true)); - this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D)); - this.tasks.addTask(5, new EntityAIWander(this, 0.6D)); - this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); - this.tasks.addTask(7, new EntityAILookIdle(this)); - this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); - this.targetTasks.addTask(2, - new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, IMob.mobSelector)); - } - - @Override - protected void entityInit() { - super.entityInit(); - this.dataWatcher.addObject(16, Byte.valueOf((byte) 0)); - } - - /** - * Returns true if the newer Entity AI code should be run - */ - @Override - public boolean isAIEnabled() { - return true; - } - - /** - * main AI tick function, replaces updateEntityActionState - */ - @Override - protected void updateAITick() { - if (--this.homeCheckTimer <= 0) { - this.homeCheckTimer = 70 + this.rand.nextInt(50); - this.villageObj = this.worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(this.posX), - MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 32); - - if (this.villageObj == null) { - this.detachHome(); - } - else { - ChunkCoordinates chunkcoordinates = this.villageObj.getCenter(); - this.setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, - (int) (this.villageObj.getVillageRadius() * 0.6F)); - } - } - - super.updateAITick(); - } - - @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); - } - - /** - * Decrements the entity's air supply when underwater - */ - @Override - protected int decreaseAirSupply(int p_70682_1_) { - return p_70682_1_; - } - - @Override - protected void collideWithEntity(Entity p_82167_1_) { - if (p_82167_1_ instanceof IMob && this.getRNG().nextInt(20) == 0) { - this.setAttackTarget((EntityLivingBase) p_82167_1_); - } - - super.collideWithEntity(p_82167_1_); - } - - /** - * Called frequently so the entity can update its state every tick as - * required. For example, zombies and skeletons use this to react to - * sunlight and start to burn. - */ - @Override - public void onLivingUpdate() { - super.onLivingUpdate(); - - if (this.attackTimer > 0) { - --this.attackTimer; - } - - if (this.holdRoseTick > 0) { - --this.holdRoseTick; - } - - if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D - && this.rand.nextInt(5) == 0) { - int i = MathHelper.floor_double(this.posX); - int j = MathHelper.floor_double(this.posY - 0.20000000298023224D - this.yOffset); - int k = MathHelper.floor_double(this.posZ); - Block block = this.worldObj.getBlock(i, j, k); - - if (block.getMaterial() != Material.air) { - this.worldObj.spawnParticle( - "blockcrack_" + Block.getIdFromBlock(block) + "_" + this.worldObj.getBlockMetadata(i, j, k), - this.posX + (this.rand.nextFloat() - 0.5D) * this.width, - this.boundingBox.minY + 0.1D, - this.posZ + (this.rand.nextFloat() - 0.5D) * this.width, - 4.0D * (this.rand.nextFloat() - 0.5D), 0.5D, - (this.rand.nextFloat() - 0.5D) * 4.0D); - } - } - } - - /** - * Returns true if this entity can attack entities of the specified class. - */ - @Override - public boolean canAttackClass(Class p_70686_1_) { - return this.isPlayerCreated() && EntityPlayer.class.isAssignableFrom(p_70686_1_) ? false - : super.canAttackClass(p_70686_1_); - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - public void writeEntityToNBT(NBTTagCompound p_70014_1_) { - super.writeEntityToNBT(p_70014_1_); - p_70014_1_.setBoolean("PlayerCreated", this.isPlayerCreated()); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - public void readEntityFromNBT(NBTTagCompound p_70037_1_) { - super.readEntityFromNBT(p_70037_1_); - this.setPlayerCreated(p_70037_1_.getBoolean("PlayerCreated")); - } - - @Override - public boolean attackEntityAsMob(Entity p_70652_1_) { - this.attackTimer = 10; - this.worldObj.setEntityState(this, (byte) 4); - boolean flag = p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), - 7 + this.rand.nextInt(15)); - - if (flag) { - p_70652_1_.motionY += 0.4000000059604645D; - } - - this.playSound("mob.irongolem.throw", 1.0F, 1.0F); - return flag; - } - - @Override - @SideOnly(Side.CLIENT) - public void handleHealthUpdate(byte p_70103_1_) { - if (p_70103_1_ == 4) { - this.attackTimer = 10; - this.playSound("mob.irongolem.throw", 1.0F, 1.0F); - } - else if (p_70103_1_ == 11) { - this.holdRoseTick = 400; - } - else { - super.handleHealthUpdate(p_70103_1_); - } - } - - public Village getVillage() { - return this.villageObj; - } - - @SideOnly(Side.CLIENT) - public int getAttackTimer() { - return this.attackTimer; - } - - public void setHoldingRose(boolean p_70851_1_) { - this.holdRoseTick = p_70851_1_ ? 400 : 0; - this.worldObj.setEntityState(this, (byte) 11); - } - - /** - * Returns the sound this mob makes when it is hurt. - */ - @Override - protected String getHurtSound() { - return "mob.irongolem.hit"; - } - - /** - * Returns the sound this mob makes on death. - */ - @Override - protected String getDeathSound() { - return "mob.irongolem.death"; - } - - @Override - protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { - this.playSound("mob.irongolem.walk", 1.0F, 1.0F); - } - - /** - * Drop 0-2 items of this living's type. @param par1 - Whether this entity - * has recently been hit by a player. @param par2 - Level of Looting used to - * kill this mob. - */ - @Override - protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { - int j = this.rand.nextInt(3); - int k; - - for (k = 0; k < j; ++k) { - this.func_145778_a(Item.getItemFromBlock(Blocks.red_flower), 1, 0.0F); - } - - k = 3 + this.rand.nextInt(3); - - for (int l = 0; l < k; ++l) { - this.dropItem(Items.iron_ingot, 1); - } - } - - public int getHoldRoseTick() { - return this.holdRoseTick; - } - - public boolean isPlayerCreated() { - return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; - } - - public void setPlayerCreated(boolean p_70849_1_) { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (p_70849_1_) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 1))); - } - else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -2))); - } - } - - /** - * Called when the mob's health reaches 0. - */ - @Override - public void onDeath(DamageSource p_70645_1_) { - if (!this.isPlayerCreated() && this.attackingPlayer != null && this.villageObj != null) { - this.villageObj.setReputationForPlayer(this.attackingPlayer.getCommandSenderName(), -5); - } - - super.onDeath(p_70645_1_); - } -} \ No newline at end of file -- cgit