From 80af2463b3dbca855815482f2fe37ebad0254b17 Mon Sep 17 00:00:00 2001 From: Nicholas Ignoffo Date: Thu, 15 Sep 2016 06:54:00 -0700 Subject: [PATCH] Temporary fix for obtaining bedrock in Survival (#919) This stops the mimic from being placed inside of any block marked as unbreakable. This should be expanded to a blacklist when I'm not late for work. --- .../bloodmagic/item/block/ItemBlockMimic.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockMimic.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockMimic.java index dc3c04a4..fff89c1c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockMimic.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockMimic.java @@ -48,6 +48,12 @@ public class ItemBlockMimic extends ItemBlock int i = this.getMetadata(stack.getMetadata()); IBlockState iblockstate1 = this.block.onBlockPlaced(world, pos, facing, hitX, hitY, hitZ, i, player); + IBlockState blockReplaced = world.getBlockState(pos); + if (!canReplaceBlock(world, pos, blockReplaced)) + { + return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ); + } + TileEntity tileReplaced = world.getTileEntity(pos); if (!canReplaceTile(i, tileReplaced)) { @@ -109,6 +115,10 @@ public class ItemBlockMimic extends ItemBlock return tile == null; } + public boolean canReplaceBlock(World world, BlockPos pos, IBlockState state) { + return state.getBlockHardness(world, pos) != -1.0F; + } + public NBTTagCompound getTagFromTileEntity(TileEntity tile) { NBTTagCompound tag = new NBTTagCompound();