Code cleanup

This commit is contained in:
LemADEC 2015-11-13 21:55:51 +01:00
parent baf8a25057
commit d292c5e8f5

View file

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