From f0bcfd48b4e1bd1024fea106bffc2c51d9aae90a Mon Sep 17 00:00:00 2001 From: LemADEC Date: Wed, 6 Jan 2016 03:57:39 +0100 Subject: [PATCH] Fixed block interaction internal logic --- .../block/BlockAbstractContainer.java | 30 ++++++------- .../warpdrive/block/BlockAirGenerator.java | 26 ++++++------ .../java/cr0s/warpdrive/block/BlockLaser.java | 14 +++---- .../warpdrive/block/BlockLaserMedium.java | 9 ++-- .../block/building/BlockShipScanner.java | 16 +++---- .../block/collection/BlockLaserTreeFarm.java | 16 +++---- .../block/collection/BlockMiningLaser.java | 16 +++---- .../block/detection/BlockCamera.java | 16 +++---- .../block/detection/BlockCloakingCore.java | 16 +++---- .../block/detection/BlockMonitor.java | 42 +++++++++---------- .../warpdrive/block/detection/BlockRadar.java | 14 +++---- .../block/energy/BlockEnergyBank.java | 14 +++---- .../energy/BlockIC2reactorLaserMonitor.java | 9 ++-- .../warpdrive/block/movement/BlockLift.java | 18 ++++---- .../block/movement/BlockShipController.java | 20 ++++----- .../block/movement/BlockShipCore.java | 7 ++-- .../block/movement/BlockTransporter.java | 5 +-- .../block/weapon/BlockLaserCamera.java | 14 +++---- 18 files changed, 149 insertions(+), 153 deletions(-) diff --git a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java index 73e38b7c..7ff1aa86 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java +++ b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java @@ -26,27 +26,27 @@ public abstract class BlockAbstractContainer extends BlockContainer { } // FIXME untested - /* + /* @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + if (world.isRemote) { return false; } - + boolean hasResponse = false; - TileEntity te = world.getBlockTileEntity(x, y, z); - if (te != null && te instanceof IUpgradable) { - IUpgradable upgradable = (IUpgradable) te; - ItemStack is = player.inventory.getCurrentItem(); - if (is != null) { - Item i = is.getItem(); + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof IUpgradable) { + IUpgradable upgradable = (IUpgradable) tileEntity; + ItemStack itemStack = entityPlayer.inventory.getCurrentItem(); + if (itemStack != null) { + Item i = itemStack.getItem(); if (i instanceof ItemWarpUpgrade) { - if (upgradable.takeUpgrade(EnumUpgradeTypes.values()[is.getItemDamage()], false)) { - if (!player.capabilities.isCreativeMode) - player.inventory.decrStackSize(player.inventory.currentItem, 1); - player.addChatMessage("Upgrade accepted"); + if (upgradable.takeUpgrade(EnumUpgradeTypes.values()[itemStack.getItemDamage()], false)) { + if (!entityPlayer.capabilities.isCreativeMode) + entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1); + entityPlayer.addChatMessage("Upgrade accepted"); } else { - player.addChatMessage("Upgrade declined"); + entityPlayer.addChatMessage("Upgrade declined"); } hasResponse = true; } diff --git a/src/main/java/cr0s/warpdrive/block/BlockAirGenerator.java b/src/main/java/cr0s/warpdrive/block/BlockAirGenerator.java index 9306c7ef..e5e28dd7 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockAirGenerator.java +++ b/src/main/java/cr0s/warpdrive/block/BlockAirGenerator.java @@ -13,7 +13,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.api.IAirCanister; import cr0s.warpdrive.config.WarpDriveConfig; @@ -82,30 +81,31 @@ public class BlockAirGenerator extends BlockContainer { } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + if (world.isRemote) { return false; } - TileEntityAbstractEnergy tileEntity = (TileEntityAbstractEnergy) world.getTileEntity(x, y, z); - if (tileEntity != null) { - ItemStack heldItemStack = player.getHeldItem(); + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityAirGenerator) { + TileEntityAirGenerator airGenerator = (TileEntityAirGenerator)tileEntity; + ItemStack heldItemStack = entityPlayer.getHeldItem(); if (heldItemStack == null) { - WarpDrive.addChatMessage(player, tileEntity.getStatus()); + WarpDrive.addChatMessage(entityPlayer, airGenerator.getStatus()); return true; } else { Item heldItem = heldItemStack.getItem(); if (heldItem != null && (heldItem instanceof IAirCanister)) { IAirCanister airCanister = (IAirCanister) heldItem; - if (airCanister.canContainAir(heldItemStack) && tileEntity.consumeEnergy(WarpDriveConfig.AIRGEN_ENERGY_PER_CANISTER, true)) { - player.inventory.decrStackSize(player.inventory.currentItem, 1); + if (airCanister.canContainAir(heldItemStack) && airGenerator.consumeEnergy(WarpDriveConfig.AIRGEN_ENERGY_PER_CANISTER, true)) { + entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1); ItemStack toAdd = airCanister.fullDrop(heldItemStack); if (toAdd != null) { - if (!player.inventory.addItemStackToInventory(toAdd)) { - EntityItem ie = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, toAdd); - player.worldObj.spawnEntityInWorld(ie); + if (!entityPlayer.inventory.addItemStackToInventory(toAdd)) { + EntityItem ie = new EntityItem(entityPlayer.worldObj, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, toAdd); + entityPlayer.worldObj.spawnEntityInWorld(ie); } - tileEntity.consumeEnergy(WarpDriveConfig.AIRGEN_ENERGY_PER_CANISTER, false); + airGenerator.consumeEnergy(WarpDriveConfig.AIRGEN_ENERGY_PER_CANISTER, false); } } } diff --git a/src/main/java/cr0s/warpdrive/block/BlockLaser.java b/src/main/java/cr0s/warpdrive/block/BlockLaser.java index ae711b6c..2adf8ee3 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockLaser.java +++ b/src/main/java/cr0s/warpdrive/block/BlockLaser.java @@ -2,7 +2,6 @@ package cr0s.warpdrive.block; import java.util.Random; -import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -65,15 +64,16 @@ public class BlockLaser extends BlockContainer { */ @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + if (world.isRemote) { return false; } - // Report status - TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity != null && tileEntity instanceof TileEntityLaser && (entityPlayer.getHeldItem() == null)) { - WarpDrive.addChatMessage(entityPlayer, ((TileEntityLaser)tileEntity).getStatus()); - return true; + if (entityPlayer.getHeldItem() == null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityLaser) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityLaser)tileEntity).getStatus()); + return true; + } } return false; diff --git a/src/main/java/cr0s/warpdrive/block/BlockLaserMedium.java b/src/main/java/cr0s/warpdrive/block/BlockLaserMedium.java index c0d02393..462b7059 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockLaserMedium.java +++ b/src/main/java/cr0s/warpdrive/block/BlockLaserMedium.java @@ -8,7 +8,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; public class BlockLaserMedium extends BlockContainer { @@ -54,15 +53,15 @@ public class BlockLaserMedium extends BlockContainer { * Called upon block activation (right click on the block.) */ @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + if (world.isRemote) { return false; } if (entityPlayer.getHeldItem() == null) { TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity != null && tileEntity instanceof TileEntityAbstractEnergy) { - WarpDrive.addChatMessage(entityPlayer, ((TileEntityAbstractEnergy) tileEntity).getStatus()); + if (tileEntity instanceof TileEntityLaserMedium) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityLaserMedium) tileEntity).getStatus()); return true; } } diff --git a/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java b/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java index 1346f7f3..f7e6b0df 100644 --- a/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java +++ b/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java @@ -11,9 +11,7 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; -import cr0s.warpdrive.block.TileEntityAbstractEnergy; public class BlockShipScanner extends BlockContainer { private IIcon[] iconBuffer; @@ -68,15 +66,17 @@ public class BlockShipScanner extends BlockContainer { } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + if (world.isRemote) { return false; } - TileEntityAbstractEnergy abstractEnergy = (TileEntityAbstractEnergy)world.getTileEntity(x, y, z); - if (abstractEnergy != null && (entityPlayer.getHeldItem() == null)) { - WarpDrive.addChatMessage(entityPlayer, abstractEnergy.getStatus()); - return true; + if (entityPlayer.getHeldItem() == null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityShipScanner) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityShipScanner)tileEntity).getStatus()); + return true; + } } return false; diff --git a/src/main/java/cr0s/warpdrive/block/collection/BlockLaserTreeFarm.java b/src/main/java/cr0s/warpdrive/block/collection/BlockLaserTreeFarm.java index c1eb1ed8..9e2e0ff4 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/BlockLaserTreeFarm.java +++ b/src/main/java/cr0s/warpdrive/block/collection/BlockLaserTreeFarm.java @@ -2,7 +2,6 @@ package cr0s.warpdrive.block.collection; import java.util.Random; -import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -81,16 +80,17 @@ public class BlockLaserTreeFarm extends BlockContainer { } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + if (world.isRemote) { return false; } - TileEntityLaserTreeFarm treeFarm = (TileEntityLaserTreeFarm)world.getTileEntity(x, y, z); - - if (treeFarm != null && (entityPlayer.getHeldItem() == null)) { - WarpDrive.addChatMessage(entityPlayer, treeFarm.getStatus()); - return true; + if (entityPlayer.getHeldItem() == null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityLaserTreeFarm) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityLaserTreeFarm)tileEntity).getStatus()); + return true; + } } return false; diff --git a/src/main/java/cr0s/warpdrive/block/collection/BlockMiningLaser.java b/src/main/java/cr0s/warpdrive/block/collection/BlockMiningLaser.java index 4bf1fc5f..3a6fd22a 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/BlockMiningLaser.java +++ b/src/main/java/cr0s/warpdrive/block/collection/BlockMiningLaser.java @@ -11,7 +11,6 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; public class BlockMiningLaser extends BlockContainer { @@ -77,16 +76,17 @@ public class BlockMiningLaser extends BlockContainer { } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + if (world.isRemote) { return false; } - TileEntityMiningLaser miningLaser = (TileEntityMiningLaser)world.getTileEntity(x, y, z); - - if (miningLaser != null && (entityPlayer.getHeldItem() == null)) { - WarpDrive.addChatMessage(entityPlayer, miningLaser.getStatus()); - return true; + if (entityPlayer.getHeldItem() == null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityMiningLaser) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityMiningLaser)tileEntity).getStatus()); + return true; + } } return false; diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockCamera.java b/src/main/java/cr0s/warpdrive/block/detection/BlockCamera.java index cc1f7513..8dba3bcd 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockCamera.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockCamera.java @@ -11,7 +11,6 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; public class BlockCamera extends BlockContainer { @@ -55,16 +54,17 @@ public class BlockCamera extends BlockContainer { } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + if (world.isRemote) { return false; } - // Get camera frequency - TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity != null && tileEntity instanceof TileEntityCamera && (entityPlayer.getHeldItem() == null)) { - WarpDrive.addChatMessage(entityPlayer, ((TileEntityCamera)tileEntity).getStatus()); - return true; + if (entityPlayer.getHeldItem() == null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityCamera) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityCamera)tileEntity).getStatus()); + return true; + } } return false; diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java b/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java index cc2bb997..ce474fe1 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java @@ -12,7 +12,6 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; public class BlockCloakingCore extends BlockContainer { @@ -64,13 +63,14 @@ public class BlockCloakingCore extends BlockContainer { } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + if (world.isRemote) { return false; } - TileEntityCloakingCore cloakingCore = (TileEntityCloakingCore)world.getTileEntity(x, y, z); - if (cloakingCore != null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityCloakingCore) { + TileEntityCloakingCore cloakingCore = (TileEntityCloakingCore)tileEntity; if (entityPlayer.getHeldItem() == null) { WarpDrive.addChatMessage(entityPlayer, cloakingCore.getStatus()); // + " isInvalid? " + te.isInvalid() + " Valid? " + te.isValid + " Cloaking? " + te.isCloaking + " Enabled? " + te.isEnabled @@ -79,9 +79,9 @@ public class BlockCloakingCore extends BlockContainer { cloakingCore.isEnabled = !cloakingCore.isEnabled; WarpDrive.addChatMessage(entityPlayer, cloakingCore.getStatus()); return true; - } else if (false) {// TODO if player has advanced tool - WarpDrive.addChatMessage(entityPlayer, cloakingCore.getStatus() + "\n" + cloakingCore.getEnergyStatus()); - return true; + // } else if (xxx) {// TODO if player has advanced tool + // WarpDrive.addChatMessage(entityPlayer, cloakingCore.getStatus() + "\n" + cloakingCore.getEnergyStatus()); + // return true; } } diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java b/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java index eb4fdc0f..57026f08 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java @@ -11,7 +11,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.data.CameraRegistryItem; import cr0s.warpdrive.render.ClientCameraHandler; @@ -53,29 +52,30 @@ public class BlockMonitor extends BlockContainer { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { // Monitor is only reacting client side - if (!FMLCommonHandler.instance().getEffectiveSide().isClient()) { + if (!world.isRemote) { return false; } - // Get camera frequency - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if (tileEntity != null && tileEntity instanceof TileEntityMonitor && (entityPlayer.getHeldItem() == null)) { - int videoChannel = ((TileEntityMonitor)tileEntity).getVideoChannel(); - CameraRegistryItem camera = WarpDrive.instance.cameras.getCameraByFrequency(world, videoChannel); - if (camera == null || entityPlayer.isSneaking()) { - WarpDrive.addChatMessage(entityPlayer, ((TileEntityMonitor)tileEntity).getStatus()); - return true; - } else { - WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.monitor.viewingCamera", - videoChannel, - camera.position.chunkPosX, - camera.position.chunkPosY, - camera.position.chunkPosZ )); - ClientCameraHandler.setupViewpoint( - camera.type, entityPlayer, entityPlayer.rotationYaw, entityPlayer.rotationPitch, - x, y, z, this, - camera.position.chunkPosX, camera.position.chunkPosY, camera.position.chunkPosZ, world.getBlock(camera.position.chunkPosX, camera.position.chunkPosY, camera.position.chunkPosZ)); + if (entityPlayer.getHeldItem() == null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (tileEntity instanceof TileEntityMonitor) { + int videoChannel = ((TileEntityMonitor)tileEntity).getVideoChannel(); + CameraRegistryItem camera = WarpDrive.instance.cameras.getCameraByFrequency(world, videoChannel); + if (camera == null || entityPlayer.isSneaking()) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityMonitor)tileEntity).getStatus()); + return true; + } else { + WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.monitor.viewingCamera", + videoChannel, + camera.position.chunkPosX, + camera.position.chunkPosY, + camera.position.chunkPosZ )); + ClientCameraHandler.setupViewpoint( + camera.type, entityPlayer, entityPlayer.rotationYaw, entityPlayer.rotationPitch, + x, y, z, this, + camera.position.chunkPosX, camera.position.chunkPosY, camera.position.chunkPosZ, world.getBlock(camera.position.chunkPosX, camera.position.chunkPosY, camera.position.chunkPosZ)); + } } } diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockRadar.java b/src/main/java/cr0s/warpdrive/block/detection/BlockRadar.java index 2c3f0a2d..07fd5c38 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockRadar.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockRadar.java @@ -11,9 +11,7 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; -import cr0s.warpdrive.block.TileEntityAbstractEnergy; public class BlockRadar extends BlockContainer { private IIcon[] iconBuffer; @@ -84,14 +82,16 @@ public class BlockRadar extends BlockContainer { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + if (world.isRemote) { return false; } - TileEntityAbstractEnergy abstractEnergy = (TileEntityAbstractEnergy) world.getTileEntity(x, y, z); - if (abstractEnergy != null && (entityPlayer.getHeldItem() == null)) { - WarpDrive.addChatMessage(entityPlayer, abstractEnergy.getStatus()); - return true; + if (entityPlayer.getHeldItem() == null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityRadar) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityRadar)tileEntity).getStatus()); + return true; + } } return false; diff --git a/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java b/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java index e0a50c09..7fbef2d4 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java +++ b/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java @@ -6,10 +6,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.block.BlockAbstractContainer; -import cr0s.warpdrive.block.TileEntityAbstractEnergy; public class BlockEnergyBank extends BlockAbstractContainer { private IIcon iconBuffer; @@ -36,14 +34,16 @@ public class BlockEnergyBank extends BlockAbstractContainer { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + if (world.isRemote) { return false; } - TileEntityAbstractEnergy abstractEnergy = (TileEntityAbstractEnergy) world.getTileEntity(x, y, z); - if (abstractEnergy != null && (entityPlayer.getHeldItem() == null)) { - WarpDrive.addChatMessage(entityPlayer, abstractEnergy.getStatus()); - return true; + if (entityPlayer.getHeldItem() == null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityEnergyBank) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityEnergyBank) tileEntity).getStatus()); + return true; + } } return false; diff --git a/src/main/java/cr0s/warpdrive/block/energy/BlockIC2reactorLaserMonitor.java b/src/main/java/cr0s/warpdrive/block/energy/BlockIC2reactorLaserMonitor.java index 68016128..1ba23af1 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/BlockIC2reactorLaserMonitor.java +++ b/src/main/java/cr0s/warpdrive/block/energy/BlockIC2reactorLaserMonitor.java @@ -1,6 +1,5 @@ package cr0s.warpdrive.block.energy; -import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -59,14 +58,14 @@ public class BlockIC2reactorLaserMonitor extends BlockAbstractContainer {// TODO * 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) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + if (world.isRemote) { return false; } if (entityPlayer.getHeldItem() == null) { - TileEntity tileEntity = par1World.getTileEntity(x, y, z); - if (tileEntity != null && tileEntity instanceof TileEntityIC2reactorLaserMonitor) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityIC2reactorLaserMonitor) { WarpDrive.addChatMessage(entityPlayer, ((TileEntityIC2reactorLaserMonitor) tileEntity).getStatus()); return true; } diff --git a/src/main/java/cr0s/warpdrive/block/movement/BlockLift.java b/src/main/java/cr0s/warpdrive/block/movement/BlockLift.java index 453cbe99..701234b9 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/BlockLift.java +++ b/src/main/java/cr0s/warpdrive/block/movement/BlockLift.java @@ -11,9 +11,7 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; -import cr0s.warpdrive.block.TileEntityAbstractEnergy; public class BlockLift extends BlockContainer { @@ -82,16 +80,18 @@ public class BlockLift extends BlockContainer */ @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + if (world.isRemote) { return false; } - - TileEntityAbstractEnergy abstractEnergy = (TileEntityAbstractEnergy)world.getTileEntity(x, y, z); - if (abstractEnergy != null && (entityPlayer.getHeldItem() == null)) { - WarpDrive.addChatMessage(entityPlayer, abstractEnergy.getStatus()); - return true; + + if (entityPlayer.getHeldItem() == null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityLift) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityLift)tileEntity).getStatus()); + return true; + } } - + return false; } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/block/movement/BlockShipController.java b/src/main/java/cr0s/warpdrive/block/movement/BlockShipController.java index f05544a4..1edc3e60 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/BlockShipController.java +++ b/src/main/java/cr0s/warpdrive/block/movement/BlockShipController.java @@ -11,7 +11,6 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import cr0s.warpdrive.WarpDrive; @@ -89,19 +88,20 @@ public class BlockShipController extends BlockContainer { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + if (world.isRemote) { return false; } - // Report status - TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity != null && tileEntity instanceof TileEntityShipController && (entityPlayer.getHeldItem() == null)) { - if (entityPlayer.isSneaking()) { - WarpDrive.addChatMessage(entityPlayer, ((TileEntityShipController)tileEntity).getStatus()); - } else { - WarpDrive.addChatMessage(entityPlayer, ((TileEntityShipController)tileEntity).attachPlayer(entityPlayer)); + if (entityPlayer.getHeldItem() == null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityShipController) { + if (entityPlayer.isSneaking()) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityShipController)tileEntity).getStatus()); + } else { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityShipController)tileEntity).attachPlayer(entityPlayer)); + } + return true; } - return true; } return false; diff --git a/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java b/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java index 8fdcc0e0..75fe3ef5 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java +++ b/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java @@ -11,7 +11,6 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; public class BlockShipCore extends BlockContainer { @@ -81,14 +80,14 @@ public class BlockShipCore extends BlockContainer { * Called upon block activation (right click on the block.) */ @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + if (world.isRemote) { return false; } if (entityPlayer.getHeldItem() == null) { TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity != null && tileEntity instanceof TileEntityShipCore) { + if (tileEntity instanceof TileEntityShipCore) { WarpDrive.addChatMessage(entityPlayer, ((TileEntityShipCore)tileEntity).getStatus()); return true; } diff --git a/src/main/java/cr0s/warpdrive/block/movement/BlockTransporter.java b/src/main/java/cr0s/warpdrive/block/movement/BlockTransporter.java index 3fa95db8..c9eb386e 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/BlockTransporter.java +++ b/src/main/java/cr0s/warpdrive/block/movement/BlockTransporter.java @@ -1,6 +1,5 @@ package cr0s.warpdrive.block.movement; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.block.BlockAbstractContainer; import net.minecraft.block.material.Material; @@ -48,13 +47,13 @@ public class BlockTransporter extends BlockAbstractContainer { */ @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + if (world.isRemote) { return false; } if (entityPlayer.getHeldItem() == null) { TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity != null && tileEntity instanceof TileEntityTransporter) { + if (tileEntity instanceof TileEntityTransporter) { WarpDrive.addChatMessage(entityPlayer, ((TileEntityTransporter)tileEntity).getStatus()); return true; } diff --git a/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java b/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java index c848983e..00ef75af 100644 --- a/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java +++ b/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java @@ -9,7 +9,6 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.block.BlockAbstractContainer; import cr0s.warpdrive.block.TileEntityLaser; @@ -63,15 +62,16 @@ public class BlockLaserCamera extends BlockAbstractContainer { */ @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + if (world.isRemote) { return false; } - // Report status - TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!ClientCameraHandler.isOverlayEnabled && tileEntity != null && tileEntity instanceof TileEntityLaser && (entityPlayer.getHeldItem() == null)) { - WarpDrive.addChatMessage(entityPlayer, ((TileEntityLaser)tileEntity).getStatus()); - return true; + if (entityPlayer.getHeldItem() == null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof TileEntityLaser && !ClientCameraHandler.isOverlayEnabled) { + WarpDrive.addChatMessage(entityPlayer, ((TileEntityLaser) tileEntity).getStatus()); + return true; + } } return false;