From 3580d4b34aede68f50f8dcdd91b0f2f21a145ed6 Mon Sep 17 00:00:00 2001 From: SpaceToad Date: Tue, 11 Feb 2014 21:11:06 +0100 Subject: [PATCH] fixed quarry placement and various minors twearks --- common/buildcraft/BuildCraftEnergy.java | 8 +++-- common/buildcraft/api/core/StackWrapper.java | 8 +++-- common/buildcraft/energy/TileEngine.java | 2 +- common/buildcraft/factory/BlockTank.java | 24 ++++++++------- common/buildcraft/factory/TileQuarry.java | 31 +++++++++----------- 5 files changed, 38 insertions(+), 35 deletions(-) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 100e7333..be7ea384 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -188,9 +188,11 @@ public class BuildCraftEnergy extends BuildCraftMod { FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("fuel", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketFuel), new ItemStack(Items.bucket)); } - BucketHandler.INSTANCE.buckets.put(blockOil, bucketOil); - BucketHandler.INSTANCE.buckets.put(blockFuel, bucketFuel); - MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE); + // TODO: Are these still really necessary? If not, remove the + // BucketHandler class as well. + //BucketHandler.INSTANCE.buckets.put(blockOil, bucketOil); + //BucketHandler.INSTANCE.buckets.put(blockFuel, bucketFuel); + //MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE); BuildcraftRecipes.refinery.addRecipe(new FluidStack(fluidOil, 1), new FluidStack(fluidFuel, 1), 12, 1); diff --git a/common/buildcraft/api/core/StackWrapper.java b/common/buildcraft/api/core/StackWrapper.java index 3da94754..2cc81ab7 100644 --- a/common/buildcraft/api/core/StackWrapper.java +++ b/common/buildcraft/api/core/StackWrapper.java @@ -27,12 +27,14 @@ public class StackWrapper { public int hashCode() { int hash = 5; - // TODO: this may have a speed impact. To be checked. - hash = 67 * hash + Item.itemRegistry.getIDForObject(stack.getItem()); + hash = 67 * hash + stack.getItem().hashCode(); hash = 67 * hash + stack.getItemDamage(); - if (stack.stackTagCompound != null) + + if (stack.stackTagCompound != null) { hash = 67 * hash + stack.stackTagCompound.hashCode(); + } + return hash; } diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index 30439bc1..632b1c7f 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -488,7 +488,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with) { if (type == PipeType.POWER) { return ConnectOverride.DEFAULT; - } else if (with == orientation) { + } else if (with == orientation) { return ConnectOverride.DISCONNECT; } else { return ConnectOverride.DEFAULT; diff --git a/common/buildcraft/factory/BlockTank.java b/common/buildcraft/factory/BlockTank.java index 18fba0c0..ac9b38a7 100644 --- a/common/buildcraft/factory/BlockTank.java +++ b/common/buildcraft/factory/BlockTank.java @@ -51,10 +51,6 @@ public class BlockTank extends BlockContainer { return false; } - public boolean isACube() { - return false; - } - @Override public TileEntity createNewTileEntity(World world, int metadata) { return new TileTank(); @@ -80,19 +76,19 @@ public class BlockTank extends BlockContainer { case 1: return textureTop; default: - if (iblockaccess.getBlock(i, j - 1, k) == this) + if (iblockaccess.getBlock(i, j - 1, k) == this) { return textureStackedSide; - else + } else { return textureBottomSide; + } } } @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { - + System.out.println ("ACTIVATED"); ItemStack current = entityplayer.inventory.getCurrentItem(); if (current != null) { - FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current); TileTank tank = (TileTank) world.getTileEntity(i, j, k); @@ -109,8 +105,8 @@ public class BlockTank extends BlockContainer { // Handle empty containers } else { - FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid; + if (available != null) { ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current); @@ -129,7 +125,9 @@ public class BlockTank extends BlockContainer { entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, filled); } } + tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true); + return true; } } @@ -141,9 +139,11 @@ public class BlockTank extends BlockContainer { @Override public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { - if (side <= 1) + if (side <= 1) { return world.getBlock(x, y, z) != this; - return super.shouldSideBeRendered(world, x, y, z, side); + } else { + return super.shouldSideBeRendered(world, x, y, z, side); + } } @Override @@ -157,10 +157,12 @@ public class BlockTank extends BlockContainer { @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileTank) { TileTank tank = (TileTank) tile; return tank.getFluidLightLevel(); } + return super.getLightValue(world, x, y, z); } } diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index 02559ddb..1bb68d4e 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -531,11 +531,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept if (chunkTicket == null) { isAlive = false; if (placedBy != null && !worldObj.isRemote) { - ((EntityPlayerMP) placedBy) - .addChatMessage(new ChatComponentText( - String.format( - "[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available", - xCoord, yCoord, zCoord))); + placedBy.addChatMessage(new ChatComponentText( + String.format( + "[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available", + xCoord, yCoord, zCoord))); } sendNetworkUpdate(); return; @@ -561,13 +560,12 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept int zSize = a.zMax() - a.zMin() + 1; if (xSize < 3 || zSize < 3 || ((xSize * zSize) >> 8) >= chunkTicket.getMaxChunkListDepth()) { - if (placedBy != null) { - ((EntityPlayerMP) placedBy) - .addChatMessage(new ChatComponentText( - String.format( - "Quarry size is outside of chunkloading bounds or too small %d %d (%d)", - xSize, zSize, - chunkTicket.getMaxChunkListDepth()))); + if (placedBy != null) { + placedBy.addChatMessage(new ChatComponentText( + String.format( + "Quarry size is outside of chunkloading bounds or too small %d %d (%d)", + xSize, zSize, + chunkTicket.getMaxChunkListDepth()))); } a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10); @@ -857,11 +855,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } if (placedBy != null) { - ((EntityPlayerMP) placedBy) - .addChatMessage(new ChatComponentText( - String.format( - "[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded", - xCoord, yCoord, zCoord, chunks.size()))); + placedBy.addChatMessage(new ChatComponentText( + String.format( + "[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded", + xCoord, yCoord, zCoord, chunks.size()))); } sendNetworkUpdate();