diff --git a/api/buildcraft/api/robots/ResourceId.java b/api/buildcraft/api/robots/ResourceId.java index 9bb6bd6e..8d795df1 100755 --- a/api/buildcraft/api/robots/ResourceId.java +++ b/api/buildcraft/api/robots/ResourceId.java @@ -24,7 +24,7 @@ public abstract class ResourceId { @Override public boolean equals(Object obj) { - if (obj.getClass() != getClass()) { + if (obj == null || obj.getClass() != getClass()) { return false; } diff --git a/common/buildcraft/builders/BlockMarker.java b/common/buildcraft/builders/BlockMarker.java index 84b46a0b..40d13e86 100644 --- a/common/buildcraft/builders/BlockMarker.java +++ b/common/buildcraft/builders/BlockMarker.java @@ -99,7 +99,7 @@ public class BlockMarker extends BlockBuildCraft { } TileEntity tile = world.getTileEntity(i, j, k); - if (tile instanceof TileMarker && !(tile instanceof TileConstructionMarker)) { + if (tile instanceof TileMarker) { ((TileMarker) tile).tryConnection(); return true; } diff --git a/common/buildcraft/builders/RenderArchitect.java b/common/buildcraft/builders/RenderArchitect.java index f5e8a83c..8fd653a0 100755 --- a/common/buildcraft/builders/RenderArchitect.java +++ b/common/buildcraft/builders/RenderArchitect.java @@ -26,32 +26,30 @@ public class RenderArchitect extends RenderBoxProvider { TileArchitect architect = (TileArchitect) tileentity; - if (architect != null) { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glTranslated(x, y, z); - GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); + GL11.glTranslated(x, y, z); + GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); - for (LaserData laser : architect.subLasers) { - if (laser != null) { - GL11.glPushMatrix(); - RenderLaser - .doRenderLaserWave( - TileEntityRendererDispatcher.instance.field_147553_e, - laser, EntityLaser.LASER_TEXTURES[3]); + for (LaserData laser : architect.subLasers) { + if (laser != null) { + GL11.glPushMatrix(); + RenderLaser + .doRenderLaserWave( + TileEntityRendererDispatcher.instance.field_147553_e, + laser, EntityLaser.LASER_TEXTURES[3]); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); } - - GL11.glPopAttrib(); - GL11.glPopMatrix(); } + + GL11.glPopAttrib(); + GL11.glPopMatrix(); } } diff --git a/common/buildcraft/builders/RenderConstructionMarker.java b/common/buildcraft/builders/RenderConstructionMarker.java index 59425f12..f8dc9c16 100755 --- a/common/buildcraft/builders/RenderConstructionMarker.java +++ b/common/buildcraft/builders/RenderConstructionMarker.java @@ -62,39 +62,37 @@ public class RenderConstructionMarker extends RenderBoxProvider { TileConstructionMarker marker = (TileConstructionMarker) tileentity; - if (marker != null) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + GL11.glTranslated(x, y, z); + GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); + + if (marker.laser != null) { GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - GL11.glTranslated(x, y, z); - GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); - - if (marker.laser != null) { - GL11.glPushMatrix(); - RenderLaser - .doRenderLaser( - TileEntityRendererDispatcher.instance.field_147553_e, - marker.laser, EntityLaser.LASER_TEXTURES[4]); - GL11.glPopMatrix(); - } - - if (marker.itemBlueprint != null) { - doRenderItem(marker.itemBlueprint, - marker.xCoord + 0.5F, - marker.yCoord + 0.2F, - marker.zCoord + 0.5F); - } - - //GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopAttrib(); + RenderLaser + .doRenderLaser( + TileEntityRendererDispatcher.instance.field_147553_e, + marker.laser, EntityLaser.LASER_TEXTURES[4]); GL11.glPopMatrix(); - - renderItems.render(tileentity, x, y, z); } + + if (marker.itemBlueprint != null) { + doRenderItem(marker.itemBlueprint, + marker.xCoord + 0.5F, + marker.yCoord + 0.2F, + marker.zCoord + 0.5F); + } + + //GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + + renderItems.render(tileentity, x, y, z); } public void doRenderItem(ItemStack stack, double x, double y, double z) { diff --git a/common/buildcraft/builders/TileBuilder.java b/common/buildcraft/builders/TileBuilder.java index 52fb04bc..1c62c497 100644 --- a/common/buildcraft/builders/TileBuilder.java +++ b/common/buildcraft/builders/TileBuilder.java @@ -662,11 +662,9 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid return new PacketCommand(this, "setItemRequirements", new CommandWriter() { public void write(ByteBuf data) { data.writeShort(items.size()); - if (items != null) { - for (ItemStack rb : items) { - NetworkUtils.writeStack(data, rb); - data.writeShort(rb.stackSize); - } + for (ItemStack rb : items) { + NetworkUtils.writeStack(data, rb); + data.writeShort(rb.stackSize); } } }); diff --git a/common/buildcraft/builders/TileQuarry.java b/common/buildcraft/builders/TileQuarry.java index ca3a215a..1d60796b 100644 --- a/common/buildcraft/builders/TileQuarry.java +++ b/common/buildcraft/builders/TileQuarry.java @@ -123,7 +123,7 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI } if (findTarget(false)) { - if (box != null && ((headPosX < box.xMin || headPosX > box.xMax) || (headPosZ < box.zMin || headPosZ > box.zMax))) { + if ((headPosX < box.xMin || headPosX > box.xMax) || (headPosZ < box.zMin || headPosZ > box.zMax)) { setHead(box.xMin + 1, yCoord + 2, box.zMin + 1); } } @@ -205,7 +205,7 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI // In this case, since idling() does it anyway, we should return. return; } else if (stage == Stage.MOVING) { - int energyUsed = this.getBattery().useEnergy(20, (int) Math.ceil(20 + getBattery().getEnergyStored() / 10), false); + int energyUsed = this.getBattery().useEnergy(20, (int) Math.ceil(20D + (double) getBattery().getEnergyStored() / 10), false); if (energyUsed >= 20) { diff --git a/common/buildcraft/core/blueprints/BptBuilderBase.java b/common/buildcraft/core/blueprints/BptBuilderBase.java index 9b3e73f7..77ac5c61 100644 --- a/common/buildcraft/core/blueprints/BptBuilderBase.java +++ b/common/buildcraft/core/blueprints/BptBuilderBase.java @@ -205,7 +205,7 @@ public abstract class BptBuilderBase implements IAreaProvider { } public void createDestroyItems(BuildingSlotBlock slot) { - int hardness = (int) Math.ceil(getBlockBreakEnergy(slot) / BuilderAPI.BREAK_ENERGY); + int hardness = (int) Math.ceil((double) getBlockBreakEnergy(slot) / BuilderAPI.BREAK_ENERGY); for (int i = 0; i < hardness; ++i) { slot.addStackConsumed(new ItemStack(BuildCraftCore.buildToolBlock)); @@ -217,8 +217,6 @@ public abstract class BptBuilderBase implements IAreaProvider { } public void saveBuildStateToNBT(NBTTagCompound nbt, IBuildingItemsProvider builder) { - NBTTagList clearList = new NBTTagList(); - nbt.setByteArray("usedLocationList", BitSetUtils.toByteArray(usedLocations)); NBTTagList buildingList = new NBTTagList(); diff --git a/common/buildcraft/core/blueprints/SchematicRegistry.java b/common/buildcraft/core/blueprints/SchematicRegistry.java index 13248484..4fb8aa1f 100644 --- a/common/buildcraft/core/blueprints/SchematicRegistry.java +++ b/common/buildcraft/core/blueprints/SchematicRegistry.java @@ -63,6 +63,9 @@ public final class SchematicRegistry implements ISchematicRegistry { } for (Constructor c : clazz.getConstructors()) { + if (c == null) { + continue; + } Class[] typesSignature = c.getParameterTypes(); if (typesSignature.length != params.length) { // non-matching constructor count arguments, skip @@ -87,7 +90,7 @@ public final class SchematicRegistry implements ISchematicRegistry { if (!valid) { continue; } - if (c != null && params.length == 0) { + if (params.length == 0) { emptyConstructorMap.put(clazz, c); } return c; diff --git a/common/buildcraft/core/config/ConfigManager.java b/common/buildcraft/core/config/ConfigManager.java index 690087bc..8c104cdc 100644 --- a/common/buildcraft/core/config/ConfigManager.java +++ b/common/buildcraft/core/config/ConfigManager.java @@ -37,7 +37,7 @@ public class ConfigManager implements IModGuiFactory { } public ConfigManager(Configuration c) { - this.config = c; + config = c; } public ConfigCategory getCat(String name) { diff --git a/common/buildcraft/core/lib/engines/TileEngineBase.java b/common/buildcraft/core/lib/engines/TileEngineBase.java index 6c496ef0..3c70466c 100644 --- a/common/buildcraft/core/lib/engines/TileEngineBase.java +++ b/common/buildcraft/core/lib/engines/TileEngineBase.java @@ -445,14 +445,10 @@ public abstract class TileEngineBase extends TileBuildCraft implements IPipeConn public void getGUINetworkData(int id, int value) { switch (id) { case 0: - int iEnergy = Math.round(energy); - iEnergy = (iEnergy & 0xffff0000) | (value & 0xffff); - energy = iEnergy; + energy = (energy & 0xffff0000) | (value & 0xffff); break; case 1: - iEnergy = Math.round(energy); - iEnergy = (iEnergy & 0xffff) | ((value & 0xffff) << 16); - energy = iEnergy; + energy = (energy & 0xffff) | ((value & 0xffff) << 16); break; case 2: currentOutput = value; @@ -464,9 +460,9 @@ public abstract class TileEngineBase extends TileBuildCraft implements IPipeConn } public void sendGUINetworkData(Container container, ICrafting iCrafting) { - iCrafting.sendProgressBarUpdate(container, 0, Math.round(energy) & 0xffff); - iCrafting.sendProgressBarUpdate(container, 1, (Math.round(energy) & 0xffff0000) >> 16); - iCrafting.sendProgressBarUpdate(container, 2, Math.round(currentOutput)); + iCrafting.sendProgressBarUpdate(container, 0, energy & 0xffff); + iCrafting.sendProgressBarUpdate(container, 1, (energy & 0xffff0000) >> 16); + iCrafting.sendProgressBarUpdate(container, 2, currentOutput); iCrafting.sendProgressBarUpdate(container, 3, Math.round(heat * 100)); } diff --git a/common/buildcraft/core/recipes/RefineryRecipeManager.java b/common/buildcraft/core/recipes/RefineryRecipeManager.java index 23d0ca19..4e94fbfc 100644 --- a/common/buildcraft/core/recipes/RefineryRecipeManager.java +++ b/common/buildcraft/core/recipes/RefineryRecipeManager.java @@ -42,7 +42,6 @@ public final class RefineryRecipeManager implements IRefineryRecipeManager { @Override public void addRecipe(String id, FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay) { - String name = result.getFluid().getName(); if (ingredient1 == null || ingredient2 == null || result == null) { BCLog.logger.warn("Rejected refinery recipe " + id + " due to a null FluidStack!"); diff --git a/common/buildcraft/core/render/RenderBuilder.java b/common/buildcraft/core/render/RenderBuilder.java index 627911f5..1308c074 100755 --- a/common/buildcraft/core/render/RenderBuilder.java +++ b/common/buildcraft/core/render/RenderBuilder.java @@ -26,36 +26,34 @@ public class RenderBuilder extends RenderBoxProvider { TileAbstractBuilder builder = (TileAbstractBuilder) tileentity; - if (builder != null) { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glTranslated(x, y, z); - GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); + GL11.glTranslated(x, y, z); + GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); - if (builder.getPathLaser() != null) { - for (LaserData laser : builder.getPathLaser()) { - if (laser != null) { - GL11.glPushMatrix(); - RenderLaser - .doRenderLaser( - TileEntityRendererDispatcher.instance.field_147553_e, - laser, EntityLaser.LASER_TEXTURES[4]); - GL11.glPopMatrix(); - } + if (builder.getPathLaser() != null) { + for (LaserData laser : builder.getPathLaser()) { + if (laser != null) { + GL11.glPushMatrix(); + RenderLaser + .doRenderLaser( + TileEntityRendererDispatcher.instance.field_147553_e, + laser, EntityLaser.LASER_TEXTURES[4]); + GL11.glPopMatrix(); } } - - //GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - - renderItems.render(tileentity, x, y, z); } + + //GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + + renderItems.render(tileentity, x, y, z); } } diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index b5a3cef8..98e52967 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -385,7 +385,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan return tankCoolant.fill(resource, doFill); } else if (BuildcraftFuelRegistry.fuel.getFuel(resource.getFluid()) != null) { int filled = tankFuel.fill(resource, doFill); - if (filled > 0 && tankFuel.getFluid() != null && tankFuel.getFluid().getFluid() != null && tankFuel.getFluid().getFluid() != currentFuel) { + if (filled > 0 && tankFuel.getFluid() != null && tankFuel.getFluid().getFluid() != null && (currentFuel == null || tankFuel.getFluid().getFluid() != currentFuel.getFluid())) { currentFuel = BuildcraftFuelRegistry.fuel.getFuel(tankFuel.getFluid().getFluid()); } return filled; diff --git a/common/buildcraft/robotics/EntityRobot.java b/common/buildcraft/robotics/EntityRobot.java index 380daacd..69b02054 100644 --- a/common/buildcraft/robotics/EntityRobot.java +++ b/common/buildcraft/robotics/EntityRobot.java @@ -1123,7 +1123,7 @@ public class EntityRobot extends EntityRobotBase implements && !StringUtils.isNullOrEmpty(nbttagcompound.getString("SkullOwner"))) { gameProfile = new GameProfile((UUID) null, nbttagcompound.getString("SkullOwner")); } - if (!StringUtils.isNullOrEmpty(gameProfile.getName())) { + if (gameProfile != null && !StringUtils.isNullOrEmpty(gameProfile.getName())) { if (!gameProfile.isComplete() || !gameProfile.getProperties().containsKey("textures")) { gameProfile = MinecraftServer.getServer().func_152358_ax() diff --git a/common/buildcraft/robotics/StationIndex.java b/common/buildcraft/robotics/StationIndex.java index 3ad58aed..0dd3b4bc 100755 --- a/common/buildcraft/robotics/StationIndex.java +++ b/common/buildcraft/robotics/StationIndex.java @@ -34,7 +34,7 @@ public class StationIndex { @Override public boolean equals(Object obj) { - if (obj.getClass() != getClass()) { + if (obj == null || obj.getClass() != getClass()) { return false; } diff --git a/common/buildcraft/silicon/TileLaser.java b/common/buildcraft/silicon/TileLaser.java index 671b0d1a..793ec8c8 100644 --- a/common/buildcraft/silicon/TileLaser.java +++ b/common/buildcraft/silicon/TileLaser.java @@ -100,13 +100,16 @@ public class TileLaser extends TileBuildCraft implements IHasWork, IControllable return; } - // We have a table and can work, so we create a laser if - // necessary. - laser.isVisible = true; + // We have a laser + if (laser != null) { + // We have a table and can work, so we create a laser if + // necessary. + laser.isVisible = true; - // We have a laser and may update it - if (laser != null && canUpdateLaser()) { - updateLaser(); + // We may update laser + if (canUpdateLaser()) { + updateLaser(); + } } // Consume power and transfer it to the table. diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 1e440a1f..dca01052 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -415,10 +415,8 @@ public class BlockGenericPipe extends BlockBuildCraft implements IColorRemovable pipeRemoved.clear(); } - if (pipe != null) { - pipeRemoved.put(new BlockIndex(x, y, z), pipe); - updateNeighbourSignalState(pipe); - } + pipeRemoved.put(new BlockIndex(x, y, z), pipe); + updateNeighbourSignalState(pipe); world.removeTileEntity(x, y, z); } diff --git a/common/buildcraft/transport/PipeTransportFluids.java b/common/buildcraft/transport/PipeTransportFluids.java index d0aa7c9d..390f359e 100644 --- a/common/buildcraft/transport/PipeTransportFluids.java +++ b/common/buildcraft/transport/PipeTransportFluids.java @@ -181,7 +181,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler public void initFromPipe(Class pipeClass) { capacity = LIQUID_IN_PIPE; flowRate = fluidCapacities.get(pipeClass); - travelDelay = MathUtils.clamp(Math.round(16 / (flowRate / 10)), 1, MAX_TRAVEL_DELAY); + travelDelay = MathUtils.clamp(Math.round(16F / (flowRate / 10)), 1, MAX_TRAVEL_DELAY); } @Override diff --git a/common/buildcraft/transport/pipes/PipeFluidsWood.java b/common/buildcraft/transport/pipes/PipeFluidsWood.java index 0ad797ea..b2c6d2fe 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsWood.java +++ b/common/buildcraft/transport/pipes/PipeFluidsWood.java @@ -108,7 +108,7 @@ public class PipeFluidsWood extends Pipe implements IEnergy FluidTankInfo tankInfo = transport.getTankInfo(side)[0]; FluidStack extracted; - if (tankInfo.fluid != null && tankInfo.fluid != null) { + if (tankInfo.fluid != null) { extracted = fluidHandler.drain(side.getOpposite(), new FluidStack(tankInfo.fluid, amount), false); } else { extracted = fluidHandler.drain(side.getOpposite(), amount, false); diff --git a/common/buildcraft/transport/pipes/PipePowerEmerald.java b/common/buildcraft/transport/pipes/PipePowerEmerald.java index d24b2350..cf9d29a2 100644 --- a/common/buildcraft/transport/pipes/PipePowerEmerald.java +++ b/common/buildcraft/transport/pipes/PipePowerEmerald.java @@ -12,12 +12,13 @@ import buildcraft.transport.PipeIconProvider; public class PipePowerEmerald extends PipePowerWood { - protected int standardIconIndex = PipeIconProvider.TYPE.PipePowerEmerald_Standard.ordinal(); - protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllEmerald_Solid.ordinal(); - public PipePowerEmerald(Item item) { super(item); + standardIconIndex = PipeIconProvider.TYPE.PipePowerEmerald_Standard.ordinal(); + + solidIconIndex = PipeIconProvider.TYPE.PipeAllEmerald_Solid.ordinal(); + battery = new RFBattery(2560 * 50, 2560, 0); transport.initFromPipe(this.getClass()); diff --git a/common/buildcraft/transport/pipes/PipePowerWood.java b/common/buildcraft/transport/pipes/PipePowerWood.java index 30707b60..4d8fbd3a 100644 --- a/common/buildcraft/transport/pipes/PipePowerWood.java +++ b/common/buildcraft/transport/pipes/PipePowerWood.java @@ -103,10 +103,6 @@ public class PipePowerWood extends Pipe implements IPipeTran return; } - if (sources == 0) { - return; - } - if (allowExtraction) { allowExtraction = false;