Compare commits

...

1 Commits

Author SHA1 Message Date
malte0811 7bf9561534 Disabled single component panels for non-creative-mode players for BTMMoon 2017-11-17 14:59:02 +01:00
1 changed files with 17 additions and 13 deletions

View File

@ -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();
}
}