Fix cardboard box becoming "invisible" in the inventory when used on a block that does not support it due to "failure" code only running on the server and not also running on the client
@@ -66,17 +66,19 @@ public class ItemBlockCardboardBox extends ItemBlockMekanism<BlockCardboardBox>
BlockPos pos = context.getPos();
if (getBlockData(stack) == null && !player.isSneaking() && !world.isAirBlock(pos)) {
BlockState state = world.getBlockState(pos);
- if (!world.isRemote && state.getBlockHardness(world, pos) != -1) {
+ if (state.getBlockHardness(world, pos) != -1) {
if (state.func_235714_a_(MekanismTags.Blocks.CARDBOARD_BLACKLIST) || MekanismConfig.general.cardboardModBlacklist.get().contains(state.getBlock().getRegistryName().getNamespace())) {
return ActionResultType.FAIL;
}
- BlockData data = new BlockData(state);
TileEntity tile = MekanismUtils.getTileEntity(world, pos);
- if (tile != null) {
- if (!SecurityUtils.canAccess(player, tile)) {
+ if (tile != null && !SecurityUtils.canAccess(player, tile)) {
//If the player cannot access the tile don't allow them to pick it up with a cardboard box
return ActionResultType.FAIL;
}
+ if (!world.isRemote) {
+ BlockData data = new BlockData(state);
+ if (tile != null) {
+ //Note: We check security access above
CompoundNBT tag = new CompoundNBT();
tile.write(tag);
data.tileTag = tag;
@@ -96,6 +98,7 @@ public class ItemBlockCardboardBox extends ItemBlockMekanism<BlockCardboardBox>
if (box != null) {
box.storedData = data;
}
+ }
return ActionResultType.SUCCESS;
}
}
