diff --git a/common/biomesoplenty/BiomesOPlenty.java b/common/biomesoplenty/BiomesOPlenty.java index 8f97844d8..f3d5bd051 100644 --- a/common/biomesoplenty/BiomesOPlenty.java +++ b/common/biomesoplenty/BiomesOPlenty.java @@ -16,6 +16,7 @@ import biomesoplenty.handlers.BOPCraftHandler; import biomesoplenty.handlers.BonemealHandler; import biomesoplenty.handlers.BreakSpeedHandler; import biomesoplenty.handlers.EntityEventHandler; +import biomesoplenty.handlers.FlipperMovementEventHandler; import biomesoplenty.handlers.FluidEventHandler; import biomesoplenty.handlers.MovementHandler; import biomesoplenty.handlers.SoundHandler; @@ -104,6 +105,7 @@ public class BiomesOPlenty MinecraftForge.EVENT_BUS.register(new FluidEventHandler()); MinecraftForge.EVENT_BUS.register(new BreakSpeedHandler()); MinecraftForge.EVENT_BUS.register(new MovementHandler()); + MinecraftForge.EVENT_BUS.register(new FlipperMovementEventHandler()); //MinecraftForge.EVENT_BUS.register(new AxeChopHandler()); proxy.registerRenderers(); diff --git a/common/biomesoplenty/handlers/FlipperMovementEventHandler.java b/common/biomesoplenty/handlers/FlipperMovementEventHandler.java new file mode 100644 index 000000000..755d69dd8 --- /dev/null +++ b/common/biomesoplenty/handlers/FlipperMovementEventHandler.java @@ -0,0 +1,48 @@ +package biomesoplenty.handlers; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import biomesoplenty.api.Items; + +public class FlipperMovementEventHandler +{ + @ForgeSubscribe + public void onLivingUpdate(LivingUpdateEvent event) + { + if (event.entity instanceof EntityLiving) + { + EntityLiving entity = (EntityLiving)event.entity; + + ItemStack itemstack = entity.getCurrentItemOrArmor(1); + + if (entity.isInWater()) + { + if (itemstack != null && itemstack.itemID == Items.flippers.get().itemID) + { + entity.motionX *= 1.1D; + entity.motionZ *= 1.1D; + } + } + } + + if (event.entity instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer)event.entity; + + InventoryPlayer inventory = player.inventory; + + if (player.isInWater()) + { + if (inventory.armorInventory[0] != null && inventory.armorInventory[0].itemID == Items.flippers.get().itemID) + { + player.motionX *= 1.1D; + player.motionZ *= 1.1D; + } + } + } + } +}