From f53543d78ae2a0dea65fff0d46df32b84b4d20fb Mon Sep 17 00:00:00 2001 From: Mitchell Petrie Date: Sat, 28 Mar 2015 12:43:59 -0400 Subject: [PATCH] Right-clicking on Slimelings will initiate hatching. Fixes #1354 --- .../mars/blocks/BlockSlimelingEgg.java | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/main/java/micdoodle8/mods/galacticraft/planets/mars/blocks/BlockSlimelingEgg.java b/src/main/java/micdoodle8/mods/galacticraft/planets/mars/blocks/BlockSlimelingEgg.java index e873792849..11723a3a1d 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/planets/mars/blocks/BlockSlimelingEgg.java +++ b/src/main/java/micdoodle8/mods/galacticraft/planets/mars/blocks/BlockSlimelingEgg.java @@ -68,22 +68,12 @@ public boolean canBlockStay(World par1World, int par2, int par3, int par4) Block block = par1World.getBlock(par2, par3 - 1, par4); return block.isSideSolid(par1World, par2, par3, par4, ForgeDirection.UP); } - - @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) + + private boolean beginHatch(World world, int x, int y, int z, EntityPlayer player) { - ItemStack currentStack = player.getCurrentEquippedItem(); int l = world.getBlockMetadata(x, y, z); - if (currentStack != null && currentStack.getItem() instanceof ItemPickaxe) - { - return world.setBlockToAir(x, y, z); - } - else if (player.capabilities.isCreativeMode) - { - return world.setBlockToAir(x, y, z); - } - else if (l < 3) + if (l < 3) { world.setBlockMetadataWithNotify(x, y, z, l + 3, 2); @@ -96,7 +86,7 @@ else if (l < 3) ((TileEntitySlimelingEgg) tile).lastTouchedPlayerName = player.getCommandSenderName(); } - return false; + return true; } else { @@ -104,6 +94,30 @@ else if (l < 3) } } + @Override + public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) + { + ItemStack currentStack = player.getCurrentEquippedItem(); + if (currentStack != null && currentStack.getItem() instanceof ItemPickaxe) + { + return world.setBlockToAir(x, y, z); + } + else if (player.capabilities.isCreativeMode) + { + return world.setBlockToAir(x, y, z); + } + else + { + beginHatch(world, x, y, z, player); + return false; + } + } + + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) + { + return beginHatch(world, x, y, z, player); + } + @Override public void harvestBlock(World world, EntityPlayer par2EntityPlayer, int x, int y, int z, int par6) {