|
24 | 24 | import net.minecraft.init.Blocks; |
25 | 25 | import net.minecraft.init.Items; |
26 | 26 | import net.minecraft.item.Item; |
27 | | -import net.minecraft.item.ItemAxe; |
28 | 27 | import net.minecraft.item.ItemStack; |
29 | 28 | import net.minecraft.pathfinding.Path; |
30 | 29 | import net.minecraft.util.DamageSource; |
@@ -89,15 +88,14 @@ protected int getExperiencePoints(EntityPlayer player) { |
89 | 88 |
|
90 | 89 | @Override |
91 | 90 | public boolean attackEntityFrom(DamageSource damagesource, float i) { |
92 | | - if (damagesource.getTrueSource() != null && damagesource.getTrueSource() instanceof EntityPlayer) { |
93 | | - EntityPlayer ep = (EntityPlayer) damagesource.getTrueSource(); |
94 | | - ItemStack currentItem = ep.inventory.getCurrentItem(); |
95 | | - Item itemheld = currentItem.getItem(); |
96 | | - if (itemheld instanceof ItemAxe) { |
| 91 | + if (damagesource.getTrueSource() instanceof EntityPlayer) { |
| 92 | + EntityPlayer player = (EntityPlayer) damagesource.getTrueSource(); |
| 93 | + ItemStack heldStack = player.inventory.getCurrentItem(); |
| 94 | + Item heldItem = heldStack.getItem(); |
| 95 | + if (heldItem.getHarvestLevel(heldStack, "axe", player, null) >= 0) { |
97 | 96 | this.world.getDifficulty(); |
98 | 97 | if (super.shouldAttackPlayers()) { |
99 | | - setAttackTarget(ep); |
100 | | - |
| 98 | + setAttackTarget(player); |
101 | 99 | } |
102 | 100 | return super.attackEntityFrom(damagesource, i); |
103 | 101 | } |
@@ -191,9 +189,7 @@ private void plantOnFertileGround() { |
191 | 189 | Block block = Blocks.GRASS; |
192 | 190 | BlockEvent.BreakEvent event = null; |
193 | 191 | if (!this.world.isRemote) { |
194 | | - event = |
195 | | - new BlockEvent.BreakEvent(this.world, pos, block.getDefaultState(), FakePlayerFactory.get((WorldServer) this.world, |
196 | | - MoCreatures.MOCFAKEPLAYER)); |
| 192 | + event = new BlockEvent.BreakEvent(this.world, pos, block.getDefaultState(), FakePlayerFactory.get((WorldServer) this.world, MoCreatures.MOCFAKEPLAYER)); |
197 | 193 | } |
198 | 194 | if (event != null && !event.isCanceled()) { |
199 | 195 | this.world.setBlockState(pos.down(), block.getDefaultState(), 3); |
|
0 commit comments