From b1b9d8a51b60034a1475e6cdbef147b6ff981ba0 Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Wed, 30 Oct 2013 11:19:44 +0800 Subject: [PATCH] #232 Fixed --- .../machine/hypercube/BlockHyperCube.java | 54 +++++++++---------- .../machine/hypercube/TileHyperCube.java | 2 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/common/crazypants/enderio/machine/hypercube/BlockHyperCube.java b/common/crazypants/enderio/machine/hypercube/BlockHyperCube.java index dc62fe3f..6dd6e586 100644 --- a/common/crazypants/enderio/machine/hypercube/BlockHyperCube.java +++ b/common/crazypants/enderio/machine/hypercube/BlockHyperCube.java @@ -108,7 +108,7 @@ public class BlockHyperCube extends Block implements ITileEntityProvider, IGuiHa @Override public void onBlockAdded(World world, int x, int y, int z) { - if (world.isRemote) { + if(world.isRemote) { return; } TileHyperCube tr = (TileHyperCube) world.getBlockTileEntity(x, y, z); @@ -117,7 +117,7 @@ public class BlockHyperCube extends Block implements ITileEntityProvider, IGuiHa @Override public void onNeighborBlockChange(World world, int x, int y, int z, int blockId) { - if (world.isRemote) { + if(world.isRemote) { return; } TileHyperCube te = (TileHyperCube) world.getBlockTileEntity(x, y, z); @@ -127,9 +127,9 @@ public class BlockHyperCube extends Block implements ITileEntityProvider, IGuiHa @Override public ArrayList getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) { ArrayList ret = new ArrayList(); - if (!world.isRemote) { + if(!world.isRemote) { TileEntity te = world.getBlockTileEntity(x, y, z); - if (te instanceof TileHyperCube) { + if(te instanceof TileHyperCube) { TileHyperCube hc = (TileHyperCube) te; hc.onBreakBlock(); ItemStack itemStack = new ItemStack(this); @@ -143,9 +143,9 @@ public class BlockHyperCube extends Block implements ITileEntityProvider, IGuiHa private void setChannelOnItem(TileHyperCube hc, ItemStack itemStack) { Channel chan = hc.getChannel(); - if (chan != null) { + if(chan != null) { NBTTagCompound tag = itemStack.getTagCompound(); - if (tag == null) { + if(tag == null) { tag = new NBTTagCompound(); itemStack.setTagCompound(tag); } @@ -153,34 +153,34 @@ public class BlockHyperCube extends Block implements ITileEntityProvider, IGuiHa tag.setBoolean("channelIsPublic", chan.isPublic()); if(!chan.isPublic()) { tag.setString("channelUser", chan.user); - } + } } } - + private Channel getChannelFromItem(ItemStack itemStack) { NBTTagCompound tag = itemStack.getTagCompound(); if(tag == null) { - return null; - } - - String channelName = tag.getString("channelName"); - if(channelName == null) { return null; } - + + String channelName = tag.getString("channelName"); + if(channelName == null || channelName.trim().isEmpty()) { + return null; + } + String user = null; if(!tag.getBoolean("channelIsPublic")) { user = tag.getString("channelUser"); } return new Channel(channelName, user); - + } @Override public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) { - if (!world.isRemote) { + if(!world.isRemote) { TileEntity te = world.getBlockTileEntity(x, y, z); - if (te instanceof TileHyperCube) { + if(te instanceof TileHyperCube) { TileHyperCube hc = (TileHyperCube) te; hc.onBreakBlock(); ItemStack itemStack = new ItemStack(this); @@ -200,14 +200,14 @@ public class BlockHyperCube extends Block implements ITileEntityProvider, IGuiHa @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { - if (world.isRemote) { + if(world.isRemote) { return; } TileEntity te = world.getBlockTileEntity(x, y, z); - if (te instanceof TileHyperCube) { + if(te instanceof TileHyperCube) { TileHyperCube cb = (TileHyperCube) te; cb.getInternalPowerHandler().setEnergy(PowerHandlerUtil.getStoredEnergyForItem(stack)); - if (player instanceof EntityPlayerMP) { + if(player instanceof EntityPlayerMP) { cb.setOwner(((EntityPlayerMP) player).username); } cb.setChannel(getChannelFromItem(stack)); @@ -228,23 +228,23 @@ public class BlockHyperCube extends Block implements ITileEntityProvider, IGuiHa @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { - if (ConduitUtil.isToolEquipped(entityPlayer) && entityPlayer.isSneaking()) { - if (entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) { + if(ConduitUtil.isToolEquipped(entityPlayer) && entityPlayer.isSneaking()) { + if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) { IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem(); - if (wrench.canWrench(entityPlayer, x, y, z)) { + if(wrench.canWrench(entityPlayer, x, y, z)) { removeBlockByPlayer(world, entityPlayer, x, y, z); - if (entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) { + if(entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) { ((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityPlayer, x, y, z); } return true; } } } - if (entityPlayer.isSneaking()) { + if(entityPlayer.isSneaking()) { return false; } TileEntity te = world.getBlockTileEntity(x, y, z); - if (!(te instanceof TileHyperCube)) { + if(!(te instanceof TileHyperCube)) { return false; } entityPlayer.openGui(EnderIO.instance, GuiHandler.GUI_ID_HYPER_CUBE, world, x, y, z); @@ -259,7 +259,7 @@ public class BlockHyperCube extends Block implements ITileEntityProvider, IGuiHa @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity te = world.getBlockTileEntity(x, y, z); - if (te instanceof TileHyperCube) { + if(te instanceof TileHyperCube) { TileHyperCube hc = (TileHyperCube) te; return new GuiHyperCube(hc); } diff --git a/common/crazypants/enderio/machine/hypercube/TileHyperCube.java b/common/crazypants/enderio/machine/hypercube/TileHyperCube.java index 48d10270..ed0c36b4 100644 --- a/common/crazypants/enderio/machine/hypercube/TileHyperCube.java +++ b/common/crazypants/enderio/machine/hypercube/TileHyperCube.java @@ -218,7 +218,7 @@ public class TileHyperCube extends TileEntity implements IInternalPowerReceptor, registeredChannel = channel; } - boolean requiresClientSync = wasConnected == stillConnected; + boolean requiresClientSync = wasConnected != stillConnected; float storedEnergy = powerHandler.getEnergyStored(); // Update if our power has changed by more than 0.5%