From 7bf9561534fa54b3c629124f9d118a336c53ca26 Mon Sep 17 00:00:00 2001 From: malte0811 Date: Fri, 17 Nov 2017 14:59:02 +0100 Subject: [PATCH] Disabled single component panels for non-creative-mode players for BTMMoon --- .../items/ItemPanelComponent.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/java/malte0811/industrialWires/items/ItemPanelComponent.java b/src/main/java/malte0811/industrialWires/items/ItemPanelComponent.java index ce0b867..4aa723f 100644 --- a/src/main/java/malte0811/industrialWires/items/ItemPanelComponent.java +++ b/src/main/java/malte0811/industrialWires/items/ItemPanelComponent.java @@ -180,24 +180,28 @@ public class ItemPanelComponent extends Item implements INetGUIItem { */ @Nonnull public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - IBlockState iblockstate = worldIn.getBlockState(pos); - Block block = iblockstate.getBlock(); + if (player.isCreative()&&player.isSneaking()) { + IBlockState iblockstate = worldIn.getBlockState(pos); + Block block = iblockstate.getBlock(); - if (!block.isReplaceable(worldIn, pos)) { - pos = pos.offset(facing); - } + if (!block.isReplaceable(worldIn, pos)) { + pos = pos.offset(facing); + } - ItemStack itemstack = player.getHeldItem(hand); + ItemStack itemstack = player.getHeldItem(hand); - if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(IndustrialWires.panel, pos, false, facing, (Entity) null)) { - placeBlockAt(itemstack, player, worldIn, pos, facing, hitX, hitY, hitZ); - SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, player); - worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); - itemstack.shrink(1); + if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(IndustrialWires.panel, pos, false, facing, (Entity) null)) { + placeBlockAt(itemstack, player, worldIn, pos, facing, hitX, hitY, hitZ); + SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, player); + worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); + itemstack.shrink(1); - return EnumActionResult.SUCCESS; + return EnumActionResult.SUCCESS; + } else { + return EnumActionResult.FAIL; + } } else { - return EnumActionResult.FAIL; + return onItemRightClick(worldIn, player, hand).getType(); } }