From d292c5e8f57d5648a9998130513b649bcf3875a9 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Fri, 13 Nov 2015 21:55:51 +0100 Subject: [PATCH] Code cleanup --- .../block/detection/BlockMonitor.java | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java b/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java index 061bdb2b..e225985d 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java @@ -17,8 +17,8 @@ import cr0s.warpdrive.render.ClientCameraHandler; public class BlockMonitor extends BlockContainer { private IIcon iconFront; - private IIcon iconBlock; - + private IIcon iconSide; + public BlockMonitor() { super(Material.iron); setHardness(0.5F); @@ -26,49 +26,39 @@ public class BlockMonitor extends BlockContainer { setCreativeTab(WarpDrive.creativeTabWarpDrive); setBlockName("warpdrive.detection.Monitor"); } - + @Override - - /** - * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata - */ public IIcon getIcon(int side, int parMetadata) { int meta = parMetadata & 3; - return side == 2 ? (meta == 0 ? this.iconFront : this.iconBlock) : (side == 3 ? (meta == 2 ? this.iconFront : this.iconBlock) : (side == 4 ? (meta == 3 ? this.iconFront : this.iconBlock) : (side == 5 ? (meta == 1 ? this.iconFront : this.iconBlock) : this.iconBlock))); + return side == 2 ? (meta == 0 ? iconFront : iconSide) : (side == 3 ? (meta == 2 ? iconFront : iconSide) : (side == 4 ? (meta == 3 ? iconFront : iconSide) : (side == 5 ? (meta == 1 ? iconFront : iconSide) : iconSide))); } - + /** * When this method is called, your block should register all the icons it needs with the given IconRegister. This * is the only chance you get to register icons. */ @Override public void registerBlockIcons(IIconRegister reg) { - this.iconFront = reg.registerIcon("warpdrive:detection/monitorFront"); - this.iconBlock = reg.registerIcon("warpdrive:detection/monitorSide"); + iconFront = reg.registerIcon("warpdrive:detection/monitorFront"); + iconSide = reg.registerIcon("warpdrive:detection/monitorSide"); } - - /** - * Called when the block is placed in the world. - */ + @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) { int dir = Math.round(entityliving.rotationYaw / 90.0F) & 3; world.setBlockMetadataWithNotify(x, y, z, dir, 3); } - - /** - * Called upon block activation (right click on the block.) - */ + @Override public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { // Monitor is only reacting client side if (!FMLCommonHandler.instance().getEffectiveSide().isClient()) { return false; } - + // Get camera frequency TileEntity tileEntity = par1World.getTileEntity(x, y, z); - + if (tileEntity != null && tileEntity instanceof TileEntityMonitor && (entityPlayer.getHeldItem() == null)) { int frequency = ((TileEntityMonitor)tileEntity).getVideoChannel(); CameraRegistryItem cam = WarpDrive.instance.cameras.getCameraByFrequency(par1World, frequency); @@ -83,10 +73,10 @@ public class BlockMonitor extends BlockContainer { cam.position.chunkPosX, cam.position.chunkPosY, cam.position.chunkPosZ, par1World.getBlock(cam.position.chunkPosX, cam.position.chunkPosY, cam.position.chunkPosZ)); } } - + return false; } - + @Override public TileEntity createNewTileEntity(World world, int i) { return new TileEntityMonitor();