From 88cee1494887d30c9863fe262fb40cb9ddd53035 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 21 Aug 2013 15:08:02 -0700 Subject: [PATCH 001/121] Halve Laser Power Perdition --- common/buildcraft/silicon/TileLaser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/buildcraft/silicon/TileLaser.java b/common/buildcraft/silicon/TileLaser.java index fd73b00c..bf350abc 100644 --- a/common/buildcraft/silicon/TileLaser.java +++ b/common/buildcraft/silicon/TileLaser.java @@ -39,6 +39,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction private int nextLaserUpdate = 10; private int nextLaserSearch = 100; private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown; + private static final PowerHandler.PerditionCalculator PERDITION = new PowerHandler.PerditionCalculator(0.5F); public TileLaser() { powerHandler = new PowerHandler(this, Type.MACHINE); @@ -47,7 +48,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction private void initPowerProvider() { powerHandler.configure(25, 150, 25, 1000); - powerHandler.configurePowerPerdition(1, 1); + powerHandler.setPerdition(PERDITION); } @Override From 4172ba2ebcfd9424a6f3734d14df14eb2d7e27e8 Mon Sep 17 00:00:00 2001 From: Roman Sandu Date: Thu, 22 Aug 2013 18:05:12 +0400 Subject: [PATCH 002/121] Got rid of Z-fighting of hollow facades with pipes inside them. --- common/buildcraft/transport/render/PipeWorldRenderer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/buildcraft/transport/render/PipeWorldRenderer.java b/common/buildcraft/transport/render/PipeWorldRenderer.java index b4487001..cb9e2210 100644 --- a/common/buildcraft/transport/render/PipeWorldRenderer.java +++ b/common/buildcraft/transport/render/PipeWorldRenderer.java @@ -270,14 +270,14 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler { if (state.pipeConnectionMatrix.isConnected(direction)) { float[][] rotated = deepClone(zeroState); rotated[2][0] = 0.0F; - rotated[2][1] = Utils.pipeMinPos; + rotated[2][1] = Utils.pipeMinPos - zFightOffset; rotated[1][0] -= zFightOffset / 2; transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); rotated = deepClone(zeroState); - rotated[2][0] = Utils.pipeMaxPos; + rotated[2][0] = Utils.pipeMaxPos + zFightOffset; rotated[1][0] -= zFightOffset / 2; transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); @@ -285,14 +285,14 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler { rotated = deepClone(zeroState); rotated[0][0] = 0.0F; - rotated[0][1] = Utils.pipeMinPos; + rotated[0][1] = Utils.pipeMinPos - zFightOffset; rotated[1][1] -= zFightOffset; transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); rotated = deepClone(zeroState); - rotated[0][0] = Utils.pipeMaxPos; + rotated[0][0] = Utils.pipeMaxPos + zFightOffset; rotated[0][1] = 1F; rotated[1][1] -= zFightOffset; transform(rotated, direction); From c7b00eb4e570f8cfdde340b1c31397131d7adfff Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 23 Aug 2013 03:05:44 -0700 Subject: [PATCH 003/121] Null check properly --- common/buildcraft/factory/TileTank.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/buildcraft/factory/TileTank.java b/common/buildcraft/factory/TileTank.java index 9d36643d..b90ceb56 100644 --- a/common/buildcraft/factory/TileTank.java +++ b/common/buildcraft/factory/TileTank.java @@ -191,7 +191,9 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - if (resource != null && !resource.isFluidEqual(tank.getFluid())) + if (resource == null) + return null; + if (!resource.isFluidEqual(tank.getFluid())) return null; return drain(from, resource.amount, doDrain); } From 81cf01f3d0b83c57348dfa426f58864b43e8b270 Mon Sep 17 00:00:00 2001 From: robin Date: Fri, 23 Aug 2013 14:04:09 +0200 Subject: [PATCH 004/121] Fix oil and fuel name in en_US --- buildcraft_resources/lang/buildcraft/en_US.properties | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index 4a7375d6..5d9244b6 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -33,7 +33,6 @@ item.goldGearItem=Gold Gear item.diamondGearItem=Diamond Gear item.templateItem=Template item.wrenchItem=Wrench -item.fuel=Fuel item.pipeWaterproof=Pipe Sealant item.pipeGate.0=Gate item.pipeGate.1=Iron AND Gate @@ -112,8 +111,8 @@ tile.floodGateBlock=Flood Gate tile.engineWood=Redstone Engine tile.engineStone=Stirling Engine tile.engineIron=Combustion Engine -tile.oilStill=Oil +tile.blockOil=Oil +tile.blockFuel=Fuel tile.spring.water=Water Spring tile.spring.oil=Oil Spring -tile.oilMoving=Oil tile.filteredBufferBlock=Filtered Buffer From f88155ef0e89693a1a799dc667ea82d71485f196 Mon Sep 17 00:00:00 2001 From: ganymedes01 Date: Fri, 23 Aug 2013 13:43:18 +0100 Subject: [PATCH 005/121] Better handling for ISidedInventory tile entities The pipe shouldn't connect to an inventory that isn't available from a certain side. With this it would be easier to manage what sides the pipe connects to without having to implement IPipeConnection. And also get rid of unnecessary connections. --- common/buildcraft/transport/PipeTransportItems.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index 5fe69429..4a7d611a 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -572,7 +572,9 @@ public class PipeTransportItems extends PipeTransport { if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportItems)) return false; } - + + if(tile instanceof ISidedInventory) + return ((ISidedInventory)tile).getAccessibleSlotsFromSide(side.getOpposite().ordinal()).length > 0; return tile instanceof TileGenericPipe || tile instanceof ISpecialInventory || (tile instanceof IInventory && ((IInventory) tile).getSizeInventory() > 0) || (tile instanceof IMachine && ((IMachine) tile).manageSolids()); } From 0b91ef14676380c37d8b58745c5ce8ae704282d9 Mon Sep 17 00:00:00 2001 From: ganymedes01 Date: Fri, 23 Aug 2013 15:45:49 +0100 Subject: [PATCH 006/121] Import ISidedInventort... Sorry about that... Massive derp --- common/buildcraft/transport/PipeTransportItems.java | 1 + 1 file changed, 1 insertion(+) diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index 4a7d611a..69ffe5f6 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -40,6 +40,7 @@ import java.util.logging.Level; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; From 8d1c6dc936a85fb565ca5a2382df0cfc507a62f2 Mon Sep 17 00:00:00 2001 From: Krapht Date: Fri, 23 Aug 2013 21:41:41 +0200 Subject: [PATCH 007/121] Fix engine not working if doDaylightCycle is set to false. Fixes #1148 --- common/buildcraft/energy/TileEngineWood.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/energy/TileEngineWood.java b/common/buildcraft/energy/TileEngineWood.java index f1c0f9da..df753a29 100644 --- a/common/buildcraft/energy/TileEngineWood.java +++ b/common/buildcraft/energy/TileEngineWood.java @@ -7,10 +7,10 @@ */ package buildcraft.energy; -import buildcraft.api.transport.IPipeTile.PipeType; -import buildcraft.core.proxy.CoreProxy; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeDirection; +import buildcraft.api.transport.IPipeTile.PipeType; +import buildcraft.core.proxy.CoreProxy; public class TileEngineWood extends TileEngine { @@ -76,7 +76,7 @@ public class TileEngineWood extends TileEngine { super.engineUpdate(); if (isRedstonePowered) - if (worldObj.getWorldTime() % 20 == 0) + if (worldObj.getTotalWorldTime() % 20 == 0) addEnergy(1); } From 4f21d4f8d845533fbfbbb5a015262e6fc507f643 Mon Sep 17 00:00:00 2001 From: Krapht Date: Fri, 23 Aug 2013 21:46:51 +0200 Subject: [PATCH 008/121] Fix chute either working twice as fast or not at all depending on when you set doDaylightCycle to false --- common/buildcraft/factory/TileHopper.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/buildcraft/factory/TileHopper.java b/common/buildcraft/factory/TileHopper.java index 74cec761..c375bd06 100644 --- a/common/buildcraft/factory/TileHopper.java +++ b/common/buildcraft/factory/TileHopper.java @@ -1,16 +1,16 @@ package buildcraft.factory; -import buildcraft.core.TileBuildCraft; -import buildcraft.core.inventory.ITransactor; -import buildcraft.core.inventory.SimpleInventory; -import buildcraft.core.inventory.Transactor; -import buildcraft.core.proxy.CoreProxy; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; +import buildcraft.core.TileBuildCraft; +import buildcraft.core.inventory.ITransactor; +import buildcraft.core.inventory.SimpleInventory; +import buildcraft.core.inventory.Transactor; +import buildcraft.core.proxy.CoreProxy; public class TileHopper extends TileBuildCraft implements IInventory { @@ -34,7 +34,7 @@ public class TileHopper extends TileBuildCraft implements IInventory { @Override public void updateEntity() { super.updateEntity(); - if (CoreProxy.proxy.isRenderWorld(worldObj) || worldObj.getWorldTime() % 2 != 0) + if (CoreProxy.proxy.isRenderWorld(worldObj) || worldObj.getTotalWorldTime() % 2 != 0) return; TileEntity tile = this.worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord); From 4ae2380d579591533fc0b5599ce2ef24b895deea Mon Sep 17 00:00:00 2001 From: Krapht Date: Fri, 23 Aug 2013 21:55:19 +0200 Subject: [PATCH 009/121] Probably fixes #991 --- .../transport/PipeTransportFluids.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/common/buildcraft/transport/PipeTransportFluids.java b/common/buildcraft/transport/PipeTransportFluids.java index 51b523e8..4704124e 100644 --- a/common/buildcraft/transport/PipeTransportFluids.java +++ b/common/buildcraft/transport/PipeTransportFluids.java @@ -7,16 +7,8 @@ */ package buildcraft.transport; -import buildcraft.BuildCraftCore; -import buildcraft.api.core.SafeTimeTracker; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.transport.IPipeTile.PipeType; -import buildcraft.core.DefaultProps; -import buildcraft.core.IMachine; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.utils.Utils; -import buildcraft.transport.network.PacketFluidUpdate; import java.util.BitSet; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -28,6 +20,14 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; +import buildcraft.BuildCraftCore; +import buildcraft.api.core.SafeTimeTracker; +import buildcraft.api.gates.ITrigger; +import buildcraft.api.transport.IPipeTile.PipeType; +import buildcraft.core.DefaultProps; +import buildcraft.core.IMachine; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.transport.network.PacketFluidUpdate; public class PipeTransportFluids extends PipeTransport implements IFluidHandler { @@ -330,7 +330,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler } private void moveFluids() { - short newTimeSlot = (short) (container.worldObj.getWorldTime() % travelDelay); + short newTimeSlot = (short) (container.worldObj.getTotalWorldTime() % travelDelay); short outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot); moveFromPipe(outputCount); From fac6e9236ecacae55e88f20f45a515c727bf4878 Mon Sep 17 00:00:00 2001 From: Krapht Date: Fri, 23 Aug 2013 21:57:34 +0200 Subject: [PATCH 010/121] Replace getWorldTime() with getTotalWorldTime --- .../transport/BlockGenericPipe.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index f4587597..a9a5f944 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -7,24 +7,13 @@ */ package buildcraft.transport; -import buildcraft.BuildCraftCore; -import buildcraft.BuildCraftTransport; -import buildcraft.api.tools.IToolWrench; -import buildcraft.api.transport.IPipe; -import buildcraft.api.transport.ISolidSideTile; -import buildcraft.core.BlockIndex; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.utils.Utils; -import buildcraft.transport.render.PipeWorldRenderer; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -45,6 +34,18 @@ import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; +import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftTransport; +import buildcraft.api.tools.IToolWrench; +import buildcraft.api.transport.IPipe; +import buildcraft.api.transport.ISolidSideTile; +import buildcraft.core.BlockIndex; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.Utils; +import buildcraft.transport.render.PipeWorldRenderer; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockGenericPipe extends BlockContainer { @@ -482,8 +483,8 @@ public class BlockGenericPipe extends BlockContainer { int y = pipe.container.yCoord; int z = pipe.container.zCoord; - if (lastRemovedDate != world.getWorldTime()) { - lastRemovedDate = world.getWorldTime(); + if (lastRemovedDate != world.getTotalWorldTime()) { + lastRemovedDate = world.getTotalWorldTime(); pipeRemoved.clear(); } From 67772a9c599c63744ccbde6015ff26cb4b1760d5 Mon Sep 17 00:00:00 2001 From: Krapht Date: Fri, 23 Aug 2013 22:03:25 +0200 Subject: [PATCH 011/121] Fix kinisis pipes when doDaylightCycle is set to false. Fixes #1152 --- .../transport/PipeTransportPower.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index bf5e4ea8..13d59ed9 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -7,6 +7,13 @@ */ package buildcraft.transport; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; import buildcraft.BuildCraftCore; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.gates.ITrigger; @@ -17,7 +24,6 @@ import buildcraft.api.power.PowerHandler.Type; import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.core.DefaultProps; import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.utils.Utils; import buildcraft.transport.network.PacketPowerUpdate; import buildcraft.transport.pipes.PipePowerCobblestone; import buildcraft.transport.pipes.PipePowerDiamond; @@ -25,12 +31,6 @@ import buildcraft.transport.pipes.PipePowerGold; import buildcraft.transport.pipes.PipePowerQuartz; import buildcraft.transport.pipes.PipePowerStone; import buildcraft.transport.pipes.PipePowerWood; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; public class PipeTransportPower extends PipeTransport { @@ -278,8 +278,8 @@ public class PipeTransportPower extends PipeTransport { } private void step() { - if (currentDate != container.worldObj.getWorldTime()) { - currentDate = container.worldObj.getWorldTime(); + if (currentDate != container.worldObj.getTotalWorldTime()) { + currentDate = container.worldObj.getTotalWorldTime(); powerQuery = nextPowerQuery; nextPowerQuery = new int[6]; @@ -344,7 +344,7 @@ public class PipeTransportPower extends PipeTransport { @Override public void initialize() { - currentDate = container.worldObj.getWorldTime(); + currentDate = container.worldObj.getTotalWorldTime(); } @Override From 23ed609a53f2f666357b5dcfe50126e2ce9d8dee Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 23 Aug 2013 16:29:35 -0700 Subject: [PATCH 012/121] Limit Buildcraft to current MC ver --- common/buildcraft/BuildCraftCore.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 36dc487c..67398583 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -77,7 +77,7 @@ import net.minecraftforge.common.Property; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.fluids.IFluidBlock; -@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", dependencies = "required-after:Forge@[9.10.0.800,)") +@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6,1.7)", dependencies = "required-after:Forge@[9.10.0.800,)") @NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true) public class BuildCraftCore { public static enum RenderMode { From f8c52932a209b81f18f04f0776f7936f371e9a47 Mon Sep 17 00:00:00 2001 From: Jason Penini Date: Sat, 24 Aug 2013 15:46:43 -0700 Subject: [PATCH 013/121] Fixed the logo in the mods list. Refresh you eclipse before you say it dosen't work. --- buildcraft_resources/mcmod.info | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/buildcraft_resources/mcmod.info b/buildcraft_resources/mcmod.info index a11c4a8f..45cce29e 100644 --- a/buildcraft_resources/mcmod.info +++ b/buildcraft_resources/mcmod.info @@ -6,7 +6,7 @@ "mcversion": "", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more!", "credits": "Created by SpaceToad", - "logoFile": "/gfx/buildcraft/logo.png", + "logoFile": "/assets/buildcraft/logo.png", "url": "http://www.mod-buildcraft.com/", "updateUrl": "", "authors": [ "SpaceToad", "BuildCraft Team" ], @@ -23,7 +23,7 @@ "mcversion": "", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Builders Component)", "credits": "Created by SpaceToad", - "logoFile": "/gfx/buildcraft/logo.png", + "logoFile": "/assets/buildcraft/logo.png", "url": "http://www.mod-buildcraft.com/", "updateUrl": "", "authors": [ "SpaceToad", "BuildCraft Team" ], @@ -40,7 +40,7 @@ "mcversion": "", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Energy Component)", "credits": "Created by SpaceToad", - "logoFile": "/gfx/buildcraft/logo.png", + "logoFile": "/assets/buildcraft/logo.png", "url": "http://www.mod-buildcraft.com/", "updateUrl": "", "authors": [ "SpaceToad", "BuildCraft Team" ], @@ -57,7 +57,7 @@ "mcversion": "", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Factory Component)", "credits": "Created by SpaceToad", - "logoFile": "/gfx/buildcraft/logo.png", + "logoFile": "/assets/buildcraft/logo.png", "url": "http://www.mod-buildcraft.com/", "updateUrl": "", "authors": [ "SpaceToad", "BuildCraft Team" ], @@ -74,7 +74,7 @@ "mcversion": "", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Silicon Component)", "credits": "Created by SpaceToad", - "logoFile": "/gfx/buildcraft/logo.png", + "logoFile": "/assets/buildcraft/logo.png", "url": "http://www.mod-buildcraft.com/", "updateUrl": "", "authors": [ "SpaceToad", "BuildCraft Team" ], @@ -91,7 +91,7 @@ "mcversion": "", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Transport Component)", "credits": "Created by SpaceToad", - "logoFile": "/gfx/buildcraft/logo.png", + "logoFile": "/assets/buildcraft/logo.png", "url": "http://www.mod-buildcraft.com/", "updateUrl": "", "authors": [ "SpaceToad", "BuildCraft Team" ], From c625b5484c69ac3f91743332047fb5e64c0ddeae Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 24 Aug 2013 17:26:38 -0700 Subject: [PATCH 014/121] Add Chests to rotations requiring sneaking --- common/buildcraft/core/ItemWrench.java | 2 ++ common/buildcraft/factory/BlockTank.java | 1 + 2 files changed, 3 insertions(+) diff --git a/common/buildcraft/core/ItemWrench.java b/common/buildcraft/core/ItemWrench.java index b4427ae2..da8c2747 100644 --- a/common/buildcraft/core/ItemWrench.java +++ b/common/buildcraft/core/ItemWrench.java @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.Set; import net.minecraft.block.Block; import net.minecraft.block.BlockButton; +import net.minecraft.block.BlockChest; import net.minecraft.block.BlockLever; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -20,6 +21,7 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench { setFull3D(); shiftRotations.add(BlockLever.class); shiftRotations.add(BlockButton.class); + shiftRotations.add(BlockChest.class); } private boolean isShiftRotation(Class cls) { diff --git a/common/buildcraft/factory/BlockTank.java b/common/buildcraft/factory/BlockTank.java index ad1266e7..a23256cc 100644 --- a/common/buildcraft/factory/BlockTank.java +++ b/common/buildcraft/factory/BlockTank.java @@ -71,6 +71,7 @@ public class BlockTank extends BlockContainer { } @SuppressWarnings({"all"}) + @Override public Icon getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) { switch (l) { case 0: From 4609d74a8e0b189f375ff8d67d779950d671f869 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 25 Aug 2013 12:59:59 -0700 Subject: [PATCH 015/121] Fix Refinery Filters --- common/buildcraft/core/fluids/SingleUseTank.java | 10 ++++------ common/buildcraft/core/fluids/Tank.java | 12 ++++++++++-- common/buildcraft/factory/TileRefinery.java | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/common/buildcraft/core/fluids/SingleUseTank.java b/common/buildcraft/core/fluids/SingleUseTank.java index 9b2c4f0d..71f6d1ef 100644 --- a/common/buildcraft/core/fluids/SingleUseTank.java +++ b/common/buildcraft/core/fluids/SingleUseTank.java @@ -50,17 +50,15 @@ public class SingleUseTank extends Tank { } @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - super.writeToNBT(nbt); + public void writeTankToNBT(NBTTagCompound nbt) { + super.writeTankToNBT(nbt); if (acceptedFluid != null) nbt.setString("acceptedFluid", acceptedFluid.getName()); - return nbt; } @Override - public FluidTank readFromNBT(NBTTagCompound nbt) { - super.readFromNBT(nbt); + public void readTankFromNBT(NBTTagCompound nbt) { + super.readTankFromNBT(nbt); acceptedFluid = FluidRegistry.getFluid(nbt.getString("acceptedFluid")); - return this; } } diff --git a/common/buildcraft/core/fluids/Tank.java b/common/buildcraft/core/fluids/Tank.java index 9db95505..6ec56082 100644 --- a/common/buildcraft/core/fluids/Tank.java +++ b/common/buildcraft/core/fluids/Tank.java @@ -41,22 +41,30 @@ public class Tank extends FluidTank { } @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + public final NBTTagCompound writeToNBT(NBTTagCompound nbt) { NBTTagCompound tankData = new NBTTagCompound(); super.writeToNBT(tankData); + writeTankToNBT(tankData); nbt.setCompoundTag(name, tankData); return nbt; } @Override - public FluidTank readFromNBT(NBTTagCompound nbt) { + public final FluidTank readFromNBT(NBTTagCompound nbt) { if (nbt.hasKey(name)) { NBTTagCompound tankData = nbt.getCompoundTag(name); super.readFromNBT(tankData); + readTankFromNBT(tankData); } return this; } + public void writeTankToNBT(NBTTagCompound nbt) { + } + + public void readTankFromNBT(NBTTagCompound nbt) { + } + public ToolTip getToolTip() { return toolTip; } diff --git a/common/buildcraft/factory/TileRefinery.java b/common/buildcraft/factory/TileRefinery.java index b931a736..cd8408cb 100644 --- a/common/buildcraft/factory/TileRefinery.java +++ b/common/buildcraft/factory/TileRefinery.java @@ -62,7 +62,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe } private void initPowerProvider() { - powerHandler.configure(25, 100, 25, 1000); + powerHandler.configure(50, 150, 25, 1000); powerHandler.configurePowerPerdition(1, 1); } From 5cd49d2f8c38222f29e079b5e160e1c2c19ab505 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 26 Aug 2013 18:34:30 -0700 Subject: [PATCH 016/121] Update pipe contents localization --- buildcraft_resources/lang/buildcraft/en_US.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index 5d9244b6..a04db9f9 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -2,7 +2,7 @@ gate.pipe.empty=Pipe Empty gate.pipe.containsItems=Items Traversing -gate.pipe.containsLiquids=Liquid Traversing +gate.pipe.containsFluids=Fluid Traversing gate.pipe.containsEnergy=Power Traversing gate.pipe.requestsEnergy=Power Requested gate.pipe.tooMuchEnergy=Power Overloaded From cfd89df7b9c04c8febd89b42b57704df82298df9 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 28 Aug 2013 19:36:59 -0700 Subject: [PATCH 017/121] Make Plugs more visible in hand --- .../transport/render/PlugItemRenderer.java | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/common/buildcraft/transport/render/PlugItemRenderer.java b/common/buildcraft/transport/render/PlugItemRenderer.java index d30a9f40..88602f67 100644 --- a/common/buildcraft/transport/render/PlugItemRenderer.java +++ b/common/buildcraft/transport/render/PlugItemRenderer.java @@ -8,15 +8,16 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraftforge.client.IItemRenderer; +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON; import org.lwjgl.opengl.GL11; -public class PlugItemRenderer implements IItemRenderer{ +public class PlugItemRenderer implements IItemRenderer { private void renderPlugItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) { // Render StructurePipe Block block = BuildCraftTransport.genericPipeBlock; Tessellator tessellator = Tessellator.instance; - + block = BuildCraftTransport.genericPipeBlock; Icon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe @@ -29,67 +30,74 @@ public class PlugItemRenderer implements IItemRenderer{ tessellator.setNormal(0.0F, -0F, 0.0F); render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, textureID); tessellator.draw(); - + tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, textureID); tessellator.draw(); - + tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1F); render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, textureID); tessellator.draw(); - + tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, textureID); tessellator.draw(); - + tessellator.startDrawingQuads(); tessellator.setNormal(-1F, 0.0F, 0.0F); render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, textureID); tessellator.draw(); - + tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, textureID); tessellator.draw(); } - + @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { switch (type) { - case ENTITY: - return true; - case EQUIPPED: - return true; - case INVENTORY: - return true; - default: - return false; + case ENTITY: + return true; + case EQUIPPED: + return true; + case EQUIPPED_FIRST_PERSON: + return true; + case INVENTORY: + return true; + default: + return false; } } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return true; + return helper != ItemRendererHelper.BLOCK_3D; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { - case ENTITY: - GL11.glScalef(0.50F, 0.50F, 0.50F); - renderPlugItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F); - break; - case EQUIPPED: - renderPlugItem((RenderBlocks) data[0], item, 0F, 0F, 0f); - break; - case INVENTORY: - GL11.glScalef(1.1F, 1.1F, 1.1F); - renderPlugItem((RenderBlocks) data[0], item, -0.3f, -0.35f, -0.7f); - break; - default: + case ENTITY: + GL11.glScalef(0.50F, 0.50F, 0.50F); + renderPlugItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F); + break; + case EQUIPPED: + case EQUIPPED_FIRST_PERSON: + GL11.glRotatef(70, 0, 0, 1F); + GL11.glRotatef(-55, 1, 0, 0); + GL11.glScalef(2F, 2F, 2F); + GL11.glTranslatef(0, -0.6F, -0.4F); + renderPlugItem((RenderBlocks) data[0], item, 0F, 0F, 0f); + break; + case INVENTORY: + GL11.glScalef(1.1F, 1.1F, 1.1F); + renderPlugItem((RenderBlocks) data[0], item, -0.3f, -0.35f, -0.7f); + break; + default: } } } From 54e7e372eca3be15cb1efd150b767978399ec6ce Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 28 Aug 2013 19:37:56 -0700 Subject: [PATCH 018/121] Make pipes with solid end consistant --- common/buildcraft/transport/pipes/PipeFluidsIron.java | 10 +++------- .../buildcraft/transport/pipes/PipeItemsDaizuli.java | 6 ++++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/common/buildcraft/transport/pipes/PipeFluidsIron.java b/common/buildcraft/transport/pipes/PipeFluidsIron.java index 3698a398..dafe22b5 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsIron.java +++ b/common/buildcraft/transport/pipes/PipeFluidsIron.java @@ -83,14 +83,10 @@ public class PipeFluidsIron extends Pipe { public int getIconIndex(ForgeDirection direction) { if (direction == ForgeDirection.UNKNOWN) return standardIconIndex; - else { - int metadata = container.getBlockMetadata(); + if (container != null && container.getBlockMetadata() == direction.ordinal()) + return standardIconIndex; + return solidIconIndex; - if (metadata == direction.ordinal()) - return solidIconIndex; - else - return standardIconIndex; - } } @Override diff --git a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java index 6cad55c5..7c030ef6 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java @@ -102,9 +102,11 @@ public class PipeItemsDaizuli extends Pipe implements IPipeT @Override public int getIconIndex(ForgeDirection direction) { + if (direction == ForgeDirection.UNKNOWN) + return standardIconIndex + color; if (container != null && container.getBlockMetadata() == direction.ordinal()) - return solidIconIndex; - return standardIconIndex + color; + return standardIconIndex + color; + return solidIconIndex; } @Override From 45e73c28b1db479ce344c78862ebde80ba0e47de Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 29 Aug 2013 04:51:28 -0700 Subject: [PATCH 019/121] Fix Laser's hasWork trigger --- common/buildcraft/silicon/TileLaser.java | 25 ++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/common/buildcraft/silicon/TileLaser.java b/common/buildcraft/silicon/TileLaser.java index bf350abc..c85b983c 100644 --- a/common/buildcraft/silicon/TileLaser.java +++ b/common/buildcraft/silicon/TileLaser.java @@ -23,6 +23,7 @@ import buildcraft.core.TileBuildCraft; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.triggers.ActionMachineControl; import java.util.LinkedList; +import java.util.List; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -58,12 +59,6 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction if (!CoreProxy.proxy.isSimulating(worldObj)) return; - // Disable the laser and do nothing if no energy is available. - if (powerHandler.getEnergyStored() == 0) { - removeLaser(); - return; - } - // If a gate disabled us, remove laser and do nothing. if (lastMode == ActionMachineControl.Mode.Off) { removeLaser(); @@ -83,6 +78,12 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction return; } + // Disable the laser and do nothing if no energy is available. + if (powerHandler.getEnergyStored() == 0) { + removeLaser(); + return; + } + // We have a table and can work, so we create a laser if // necessary. if (laser == null) { @@ -101,19 +102,19 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction if (laser != null) { laser.pushPower(power); } - + onPowerSent(power); sendNetworkUpdate(); } - protected float getMaxPowerSent(){ + protected float getMaxPowerSent() { return 4; } protected void onPowerSent(float power) { } - + protected boolean canFindTable() { return searchTracker.markTimeIfDelay(worldObj, nextLaserSearch); } @@ -162,7 +163,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction break; } - LinkedList targets = new LinkedList(); + List targets = new LinkedList(); for (int x = minX; x <= maxX; ++x) { for (int y = minY; y <= maxY; ++y) { @@ -181,7 +182,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction } } - if (targets.size() == 0) + if (targets.isEmpty()) return; BlockIndex b = targets.get(worldObj.rand.nextInt(targets.size())); @@ -280,7 +281,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction @Override public boolean isActive() { - return laser != null; + return isValidTable(); } @Override From 48daafae3523ed7e1ff12531d4a7955e858d0fde Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 29 Aug 2013 07:07:11 -0700 Subject: [PATCH 020/121] Reworked Iron Engine Heat Mechanics They cool down much faster, but use Coolant while doing so. Additionally, they are affected by Biome temperature. Expect to need more water/better Coolant in a desert for optimal operation. Ice Blocks are also recommended. --- common/buildcraft/BuildCraftEnergy.java | 2 +- common/buildcraft/energy/TileEngineIron.java | 80 +++++++++++++------- 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 6e8fe47d..cb7b3ca2 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -202,7 +202,7 @@ public class BuildCraftEnergy { RefineryRecipes.addRecipe(new FluidStack(fluidOil, 1), new FluidStack(fluidFuel, 1), 12, 1); // Iron Engine Fuels - IronEngineFuel.addFuel("lava", 1, 20000); +// IronEngineFuel.addFuel("lava", 1, 20000); IronEngineFuel.addFuel("oil", 3, 20000); IronEngineFuel.addFuel("fuel", 6, 100000); diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index c6b2cdae..392793fd 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -21,6 +21,7 @@ import buildcraft.core.fluids.Tank; import buildcraft.core.fluids.TankManager; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; +import static buildcraft.energy.TileEngine.MIN_HEAT; import buildcraft.energy.gui.ContainerEngine; import java.util.LinkedList; import net.minecraft.entity.player.EntityPlayer; @@ -29,6 +30,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; +import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -40,7 +42,8 @@ public class TileEngineIron extends TileEngine implements IFluidHandler { public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 10; public static float HEAT_PER_MJ = 0.0023F; - public static float COOLDOWN_RATE = 0.01F; + public static float COOLDOWN_RATE = 0.05F; + public static float MAX_COOLING = 0.1F; int burnTime = 0; private Tank tankFuel; private Tank tankCoolant; @@ -48,11 +51,12 @@ public class TileEngineIron extends TileEngine implements IFluidHandler { private Fuel currentFuel = null; public int penaltyCooling = 0; boolean lastPowered = false; + private BiomeGenBase biomeCache; public TileEngineIron() { super(1); tankFuel = new Tank("tankFuel", MAX_LIQUID); - tankCoolant = new Tank("tankCoolant",MAX_LIQUID); + tankCoolant = new Tank("tankCoolant", MAX_LIQUID); tankManager.add(tankFuel); tankManager.add(tankCoolant); } @@ -111,6 +115,21 @@ public class TileEngineIron extends TileEngine implements IFluidHandler { } } + private float getBiomeTempScalar() { + if (biomeCache == null) + biomeCache = worldObj.getBiomeGenForCoords(xCoord, zCoord); + float tempScalar = biomeCache.temperature - 1.0F; + tempScalar *= 0.5F; + tempScalar += 1.0F; + return tempScalar; + } + + @Override + public void invalidate() { + super.invalidate(); + biomeCache = null; + } + @Override public boolean isBurning() { FluidStack fuel = tankFuel.getFluid(); @@ -148,13 +167,13 @@ public class TileEngineIron extends TileEngine implements IFluidHandler { } currentOutput = currentFuel.powerPerCycle; // Comment out for constant power addEnergy(currentFuel.powerPerCycle); - heat += currentFuel.powerPerCycle * HEAT_PER_MJ; + heat += currentFuel.powerPerCycle * HEAT_PER_MJ * getBiomeTempScalar(); } } else if (penaltyCooling <= 0) { if (lastPowered) { lastPowered = false; - penaltyCooling = 30 * 20; - // 30 sec of penalty on top of the cooling + penaltyCooling = 10; + // 10 tick of penalty on top of the cooling } } } @@ -169,7 +188,7 @@ public class TileEngineIron extends TileEngine implements IFluidHandler { final ItemStack stack = getStackInSlot(0); if (stack != null) { FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack); - if (liquid == null && heat > IDEAL_HEAT) { + if (liquid == null && heat > MIN_HEAT * 2) { liquid = IronEngineCoolant.getFluidCoolant(stack); } @@ -181,34 +200,37 @@ public class TileEngineIron extends TileEngine implements IFluidHandler { } } - if (heat > IDEAL_HEAT) { - float extraHeat = heat - IDEAL_HEAT; - - FluidStack coolant = this.tankCoolant.getFluid(); - Coolant currentCoolant = IronEngineCoolant.getCoolant(coolant); - if (currentCoolant != null) { - float cooling = currentCoolant.getDegreesCoolingPerMB(heat); - if (coolant.amount * cooling > extraHeat) { - coolant.amount -= Math.round(extraHeat / cooling); - heat = IDEAL_HEAT; - } else { - heat -= coolant.amount * cooling; - tankCoolant.setFluid(null); - } - } - } - if (heat > MIN_HEAT && (penaltyCooling > 0 || !isRedstonePowered)) { heat -= COOLDOWN_RATE; - + coolEngine(MIN_HEAT); + getEnergyStage(); + } else if (heat > IDEAL_HEAT) { + coolEngine(IDEAL_HEAT); } - if (heat <= MIN_HEAT) { - heat = MIN_HEAT; - } - - if (heat <= MIN_HEAT && penaltyCooling > 0) { + if (heat <= MIN_HEAT && penaltyCooling > 0) penaltyCooling--; + + if (heat <= MIN_HEAT) + heat = MIN_HEAT; + } + + private void coolEngine(float idealHeat) { + float extraHeat = heat - idealHeat; + extraHeat = Math.min(MAX_COOLING, extraHeat); + + FluidStack coolant = this.tankCoolant.getFluid(); + Coolant currentCoolant = IronEngineCoolant.getCoolant(coolant); + if (currentCoolant != null) { + float cooling = currentCoolant.getDegreesCoolingPerMB(heat); + cooling /= getBiomeTempScalar(); + if (coolant.amount * cooling > extraHeat) { + coolant.amount -= Math.round(extraHeat / cooling); + heat -= extraHeat; + } else { + heat -= coolant.amount * cooling; + tankCoolant.setFluid(null); + } } } From f2f182838666b3a26df90de35f15cc46b42e6250 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 29 Aug 2013 07:27:56 -0700 Subject: [PATCH 021/121] Limit Coolant per tick rather Cooling per tick Makes better Coolants more desirable because they can cool faster. --- common/buildcraft/energy/TileEngineIron.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index 392793fd..c87229fc 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -43,7 +43,7 @@ public class TileEngineIron extends TileEngine implements IFluidHandler { public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 10; public static float HEAT_PER_MJ = 0.0023F; public static float COOLDOWN_RATE = 0.05F; - public static float MAX_COOLING = 0.1F; + public static int MAX_COOLANT_PER_TICK = 40; int burnTime = 0; private Tank tankFuel; private Tank tankCoolant; @@ -217,19 +217,22 @@ public class TileEngineIron extends TileEngine implements IFluidHandler { private void coolEngine(float idealHeat) { float extraHeat = heat - idealHeat; - extraHeat = Math.min(MAX_COOLING, extraHeat); FluidStack coolant = this.tankCoolant.getFluid(); + if (coolant == null) + return; + + int coolantAmount = Math.min(MAX_COOLANT_PER_TICK, coolant.amount); Coolant currentCoolant = IronEngineCoolant.getCoolant(coolant); if (currentCoolant != null) { float cooling = currentCoolant.getDegreesCoolingPerMB(heat); cooling /= getBiomeTempScalar(); - if (coolant.amount * cooling > extraHeat) { - coolant.amount -= Math.round(extraHeat / cooling); + if (coolantAmount * cooling > extraHeat) { + tankCoolant.drain(Math.round(extraHeat / cooling), true); heat -= extraHeat; } else { - heat -= coolant.amount * cooling; - tankCoolant.setFluid(null); + tankCoolant.drain(coolantAmount, true); + heat -= coolantAmount * cooling; } } } From f02295bac4457fac48eeedded8fc6dbac8d9c178 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 29 Aug 2013 10:38:08 -0700 Subject: [PATCH 022/121] Flood Gate shouldn't put water in the Nether --- common/buildcraft/factory/TileFloodGate.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/factory/TileFloodGate.java b/common/buildcraft/factory/TileFloodGate.java index 3593b8a7..07c27d02 100644 --- a/common/buildcraft/factory/TileFloodGate.java +++ b/common/buildcraft/factory/TileFloodGate.java @@ -24,6 +24,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; @@ -68,7 +69,16 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { tick++; if (tick % 16 == 0) { FluidStack fluidtoFill = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false); - if (fluidtoFill != null && fluidtoFill.amount == FluidContainerRegistry.BUCKET_VOLUME && fluidtoFill.getFluid() != null && fluidtoFill.getFluid().canBePlacedInWorld()) { + if (fluidtoFill != null && fluidtoFill.amount == FluidContainerRegistry.BUCKET_VOLUME) { + Fluid fluid = fluidtoFill.getFluid(); + if (fluid == null || !fluid.canBePlacedInWorld()) + return; + + if (fluid == FluidRegistry.WATER && worldObj.provider.dimensionId == -1) { + tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); + return; + } + if (tick % REBUILD_DELAY[rebuildDelay] == 0) { rebuildDelay++; if (rebuildDelay >= REBUILD_DELAY.length) @@ -77,7 +87,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { } BlockIndex index = getNextIndexToFill(true); - if (index != null && placeFluid(index.x, index.y, index.z, fluidtoFill.getFluid())) { + if (index != null && placeFluid(index.x, index.y, index.z, fluid)) { tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); rebuildDelay = 0; } From f6b0f8a1f24cc9aed65cd4329bdf1cee0cbefce0 Mon Sep 17 00:00:00 2001 From: Krapht Date: Sat, 31 Aug 2013 19:01:31 +0200 Subject: [PATCH 023/121] Added a BuildCraftCore config option for color-blind mode. Added alternate textures for Diamond pipe interface and the green side of diamond --- .../blocks/pipeItemsDiamond_west_cb.png | Bin 0 -> 238 bytes .../buildcraft/textures/gui/filter_cb.png | Bin 0 -> 1284 bytes common/buildcraft/BuildCraftCore.java | 38 ++++++++++-------- .../transport/PipeIconProvider.java | 17 +++++--- .../transport/gui/GuiDiamondPipe.java | 19 +++++++-- .../transport/pipes/PipeItemsDiamond.java | 23 ++++++----- 6 files changed, 61 insertions(+), 36 deletions(-) create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_west_cb.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/gui/filter_cb.png diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_west_cb.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_west_cb.png new file mode 100644 index 0000000000000000000000000000000000000000..aae93acbe33ca63d91fab9edf68543980ce047f3 GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE({Go7K6u9?zcdSv%n*= zn1O*?7=#%aX3dcR3bL1Y`ns~;<&YOJHksT$dks*i+SA1`#NzbY$&P#t3Op?BZS95M z_u4)_|H{{Q>Mb=sb*F^}(g%#M?&$wrv+Cz3KNsd32d=4Zin%$Jr*>!Mk-6)=_w8BT zCN3uXf>m0rKU@4|)Oxhaz e-{;)7F6R9*p_%J{Moj`bgTd3)&t;ucLK6TV9aPu= literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/filter_cb.png b/buildcraft_resources/assets/buildcraft/textures/gui/filter_cb.png new file mode 100644 index 0000000000000000000000000000000000000000..cc76dfe9bf7132342db82ab33164ecd737580c5d GIT binary patch literal 1284 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6&6+N0NyjuYx4HsW) zRdaD^JDj?3W><^P1e-Ne-W}lHI5pK`!^E7&r2>(m9V~0-bN2s`(VYA*W;@$Hsqi}? zAH%tJ@JlVMSEH(b^V4Hl`PwQjE^ZUw zhi~7)uFSdgFRu7+<-X4{dds`MFXa~e`15x2ZH^Q_&f-3ErmeZsf`YNvd(S886|xEl zZoHYZiSL4m@0Z&AKFi6^W&R&-sb*+kU|?e4U{F9~z{R)=%9H~xo7`kKJT7x8MR|hd z(eoPxUvx3vkl~ADukh0hTRqkCna{l9KYK(NzGH+3G=$)RCHCNt+k(G#zZIU%aGsgN zVzm5+r5RJKAw&CNwbu-qw#T!!8Xcc=vN(sOh#zbC!pu9M35)`<7jJ-u?K^4LVfidT zO}g=nW?f&eLpaZY#NrcH4pn~dXD6O9On)RJ-FSx?8ng{I<&*2KzyJTIu=vc*BQi0J z2+uD+`+Gmbvl*YK78kI>0_6V_pmWpa*9sJ$S?FWNG&A@Q(6Dt94e|D$&34(??agm9 zJU(Y7Db78+np(zWuc2PC*VY zU~+>7k5ADjwFPSrJey+hyh7U`UZmk8PDfM*qb6Mw<&;$S?ftu9- literal 0 HcmV?d00001 diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 67398583..4fa93c6b 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -9,6 +9,23 @@ package buildcraft; +import java.io.File; +import java.util.TreeMap; +import java.util.logging.Logger; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFluid; +import net.minecraft.entity.EntityList; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.common.Configuration; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.Property; +import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.fluids.IFluidBlock; import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.IIconProvider; import buildcraft.api.gates.ActionManager; @@ -60,22 +77,6 @@ import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.io.File; -import java.util.TreeMap; -import java.util.logging.Logger; -import net.minecraft.block.Block; -import net.minecraft.block.BlockFluid; -import net.minecraft.entity.EntityList; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; -import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.common.Configuration; -import net.minecraftforge.common.IPlantable; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.Property; -import net.minecraftforge.event.ForgeSubscribe; -import net.minecraftforge.fluids.IFluidBlock; @Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6,1.7)", dependencies = "required-after:Forge@[9.10.0.800,)") @NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true) @@ -89,6 +90,7 @@ public class BuildCraftCore { public static boolean debugMode = false; public static boolean modifyWorld = false; public static boolean trackNetworkUsage = false; + public static boolean colorBlindMode = false; public static boolean dropBrokenBlocks = true; // Set to false to prevent the filler from dropping broken blocks. @@ -251,6 +253,10 @@ public class BuildCraftCore { LanguageRegistry.addName(diamondGearItem, "Diamond Gear"); CoreProxy.proxy.registerItem(diamondGearItem); + Property colorBlindProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "client.colorblindmode", false); + colorBlindProp.comment = "Set to true to enable alternate textures"; + colorBlindMode = colorBlindProp.getBoolean(false); + MinecraftForge.EVENT_BUS.register(this); } finally { diff --git a/common/buildcraft/transport/PipeIconProvider.java b/common/buildcraft/transport/PipeIconProvider.java index 1f1714ec..ba487572 100644 --- a/common/buildcraft/transport/PipeIconProvider.java +++ b/common/buildcraft/transport/PipeIconProvider.java @@ -1,10 +1,11 @@ package buildcraft.transport; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.util.Icon; +import buildcraft.BuildCraftCore; import buildcraft.api.core.IIconProvider; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; public class PipeIconProvider implements IIconProvider { @@ -19,7 +20,7 @@ public class PipeIconProvider implements IIconProvider { PipeItemsDiamond_Up("pipeItemsDiamond_up"), PipeItemsDiamond_North("pipeItemsDiamond_north"), PipeItemsDiamond_South("pipeItemsDiamond_south"), - PipeItemsDiamond_West("pipeItemsDiamond_west"), + PipeItemsDiamond_West("pipeItemsDiamond_west", "pipeItemsDiamond_west_cb"), PipeItemsDiamond_East("pipeItemsDiamond_east"), // PipeItemsLapis_Black("pipeItemsLapis_black"), @@ -97,14 +98,20 @@ public class PipeIconProvider implements IIconProvider { ItemBox("itemBox"); public static final TYPE[] VALUES = values(); private final String iconTag; + private final String iconTagColorBlind; private Icon icon; - private TYPE(String iconTag) { + private TYPE(String iconTag, String IconTagColorBlind){ this.iconTag = iconTag; + this.iconTagColorBlind = IconTagColorBlind; + } + + private TYPE(String iconTag) { + this(iconTag, iconTag); } private void registerIcon(IconRegister iconRegister) { - icon = iconRegister.registerIcon("buildcraft:" + iconTag); + icon = iconRegister.registerIcon("buildcraft:" + (BuildCraftCore.colorBlindMode ? iconTagColorBlind : iconTag)); } public Icon getIcon() { diff --git a/common/buildcraft/transport/gui/GuiDiamondPipe.java b/common/buildcraft/transport/gui/GuiDiamondPipe.java index c402b509..d8a8c7a5 100644 --- a/common/buildcraft/transport/gui/GuiDiamondPipe.java +++ b/common/buildcraft/transport/gui/GuiDiamondPipe.java @@ -7,20 +7,31 @@ */ package buildcraft.transport.gui; +import net.minecraft.inventory.IInventory; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import buildcraft.BuildCraftCore; import buildcraft.core.DefaultProps; import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.utils.StringUtils; import buildcraft.transport.pipes.PipeItemsDiamond; -import net.minecraft.inventory.IInventory; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; public class GuiDiamondPipe extends GuiBuildCraft { - private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter.png"); + private static final ResourceLocation TEXTURE; IInventory playerInventory; IInventory filterInventory; + static { + if (!BuildCraftCore.colorBlindMode){ + TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter.png"); + } else { + TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter_cb.png"); + } + } + public GuiDiamondPipe(IInventory playerInventory, PipeItemsDiamond pipe) { super(new ContainerDiamondPipe(playerInventory, pipe), pipe.getFilters()); this.playerInventory = playerInventory; diff --git a/common/buildcraft/transport/pipes/PipeItemsDiamond.java b/common/buildcraft/transport/pipes/PipeItemsDiamond.java index c8c831ba..0ea40d90 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDiamond.java +++ b/common/buildcraft/transport/pipes/PipeItemsDiamond.java @@ -7,6 +7,18 @@ */ package buildcraft.transport.pipes; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.LinkedList; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.Position; @@ -23,17 +35,6 @@ import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TravelingItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.LinkedList; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.ForgeDirection; public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook, IClientState { From c6ca3b28e7e17af157b6e2cb87dabf3d09a65a22 Mon Sep 17 00:00:00 2001 From: Krapht Date: Sat, 31 Aug 2013 22:17:50 +0200 Subject: [PATCH 024/121] Move implementation of IInventory from TileEngine to new abstract class TileEngineWithInventory. This will effectivly remove IInventory from redstone engines. Fixes #1180 --- common/buildcraft/energy/GuiHandler.java | 14 +-- common/buildcraft/energy/TileEngine.java | 90 +++--------------- common/buildcraft/energy/TileEngineIron.java | 32 +++---- .../buildcraft/energy/TileEngineLegacy.java | 5 - common/buildcraft/energy/TileEngineStone.java | 17 ++-- .../energy/TileEngineWithInventory.java | 91 +++++++++++++++++++ common/buildcraft/energy/TileEngineWood.java | 4 - .../energy/gui/ContainerEngine.java | 10 +- .../energy/gui/GuiCombustionEngine.java | 12 ++- .../buildcraft/energy/gui/GuiStoneEngine.java | 11 ++- 10 files changed, 157 insertions(+), 129 deletions(-) create mode 100644 common/buildcraft/energy/TileEngineWithInventory.java diff --git a/common/buildcraft/energy/GuiHandler.java b/common/buildcraft/energy/GuiHandler.java index 1e084b0f..580a9867 100644 --- a/common/buildcraft/energy/GuiHandler.java +++ b/common/buildcraft/energy/GuiHandler.java @@ -1,13 +1,13 @@ package buildcraft.energy; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; import buildcraft.core.GuiIds; import buildcraft.energy.gui.ContainerEngine; import buildcraft.energy.gui.GuiCombustionEngine; import buildcraft.energy.gui.GuiStoneEngine; import cpw.mods.fml.common.network.IGuiHandler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; public class GuiHandler implements IGuiHandler { @@ -18,10 +18,10 @@ public class GuiHandler implements IGuiHandler { return null; TileEntity tile = world.getBlockTileEntity(x, y, z); - if (!(tile instanceof TileEngine)) + if (!(tile instanceof TileEngineWithInventory)) return null; - TileEngine engine = (TileEngine) tile; + TileEngineWithInventory engine = (TileEngineWithInventory) tile; switch (ID) { @@ -43,10 +43,10 @@ public class GuiHandler implements IGuiHandler { return null; TileEntity tile = world.getBlockTileEntity(x, y, z); - if (!(tile instanceof TileEngine)) + if (!(tile instanceof TileEngineWithInventory)) return null; - TileEngine engine = (TileEngine) tile; + TileEngineWithInventory engine = (TileEngineWithInventory) tile; switch (ID) { diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index 2013c9ae..bc8b5da1 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -7,6 +7,16 @@ */ package buildcraft.energy; +import java.util.LinkedList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.ForgeDirection; import buildcraft.BuildCraftEnergy; import buildcraft.api.core.Position; import buildcraft.api.gates.IOverrideDefaultTriggers; @@ -21,24 +31,11 @@ import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.core.DefaultProps; import buildcraft.core.TileBuffer; import buildcraft.core.TileBuildCraft; -import buildcraft.core.inventory.InvUtils; -import buildcraft.core.inventory.SimpleInventory; import buildcraft.core.network.TileNetworkData; import buildcraft.core.proxy.CoreProxy; import buildcraft.energy.gui.ContainerEngine; -import java.util.LinkedList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagFloat; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.ForgeDirection; -public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter, IInventory, IOverrideDefaultTriggers, IPipeConnection { +public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter, IOverrideDefaultTriggers, IPipeConnection { public static final ResourceLocation WOOD_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png"); public static final ResourceLocation STONE_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_stone.png"); @@ -60,7 +57,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public float progress; public float energy; public float heat = MIN_HEAT; - private final SimpleInventory inv; + // public @TileNetworkData EnergyStage energyStage = EnergyStage.BLUE; @@ -69,13 +66,11 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public @TileNetworkData boolean isPumping = false; // Used for SMP synch - public TileEngine(int invSize) { + public TileEngine(){ powerHandler = new PowerHandler(this, Type.ENGINE); powerHandler.configurePowerPerdition(1, 100); - - inv = new SimpleInventory(invSize, "Engine", 64); } - + @Override public void initialize() { if (!CoreProxy.proxy.isRenderWorld(worldObj)) { @@ -287,7 +282,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto NBTBase tag = data.getTag("heat"); if (tag instanceof NBTTagFloat) heat = data.getFloat("heat"); - inv.readFromNBT(data); } @Override @@ -297,7 +291,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto data.setFloat("progress", progress); data.setFloat("energyF", energy); data.setFloat("heat", heat); - inv.writeToNBT(data); } public void getGUINetworkData(int id, int value) { @@ -327,55 +320,10 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto iCrafting.sendProgressBarUpdate(containerEngine, 2, Math.round(currentOutput * 10)); iCrafting.sendProgressBarUpdate(containerEngine, 3, Math.round(heat * 100)); } - /* IINVENTORY IMPLEMENTATION */ - - @Override - public int getSizeInventory() { - return inv.getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int slot) { - return inv.getStackInSlot(slot); - } - - @Override - public ItemStack decrStackSize(int slot, int amount) { - return inv.decrStackSize(slot, amount); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return inv.getStackInSlotOnClosing(slot); - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemstack) { - inv.setInventorySlotContents(slot, itemstack); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } + public void delete() { - InvUtils.dropItems(worldObj, inv, xCoord, yCoord, zCoord); - } - @Override - public String getInvName() { - return "Engine"; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; } /* STATE INFORMATION */ @@ -444,14 +392,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto return false; } - @Override - public void openChest() { - } - - @Override - public void closeChest() { - } - public abstract float getMaxEnergy(); public float minEnergyReceived() { diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index c87229fc..c0b31023 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -7,6 +7,21 @@ */ package buildcraft.energy; +import java.util.LinkedList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; import buildcraft.api.fuels.IronEngineCoolant; @@ -21,24 +36,9 @@ import buildcraft.core.fluids.Tank; import buildcraft.core.fluids.TankManager; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; -import static buildcraft.energy.TileEngine.MIN_HEAT; import buildcraft.energy.gui.ContainerEngine; -import java.util.LinkedList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; -public class TileEngineIron extends TileEngine implements IFluidHandler { +public class TileEngineIron extends TileEngineWithInventory implements IFluidHandler { public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 10; public static float HEAT_PER_MJ = 0.0023F; diff --git a/common/buildcraft/energy/TileEngineLegacy.java b/common/buildcraft/energy/TileEngineLegacy.java index c33dfa4b..10364828 100644 --- a/common/buildcraft/energy/TileEngineLegacy.java +++ b/common/buildcraft/energy/TileEngineLegacy.java @@ -7,7 +7,6 @@ */ package buildcraft.energy; -import buildcraft.core.DefaultProps; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; @@ -23,10 +22,6 @@ public class TileEngineLegacy extends TileEngine { private NBTTagCompound nbt; - public TileEngineLegacy() { - super(0); - } - @Override public void updateEntity() { worldObj.removeBlockTileEntity(xCoord, yCoord, zCoord); diff --git a/common/buildcraft/energy/TileEngineStone.java b/common/buildcraft/energy/TileEngineStone.java index e5d53c1f..6f385d79 100644 --- a/common/buildcraft/energy/TileEngineStone.java +++ b/common/buildcraft/energy/TileEngineStone.java @@ -7,14 +7,8 @@ */ package buildcraft.energy; -import buildcraft.BuildCraftCore; -import buildcraft.BuildCraftEnergy; -import buildcraft.api.gates.ITrigger; -import buildcraft.core.GuiIds; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.utils.Utils; -import buildcraft.energy.gui.ContainerEngine; import java.util.LinkedList; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.item.ItemStack; @@ -22,8 +16,15 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeDirection; +import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftEnergy; +import buildcraft.api.gates.ITrigger; +import buildcraft.core.GuiIds; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.Utils; +import buildcraft.energy.gui.ContainerEngine; -public class TileEngineStone extends TileEngine { +public class TileEngineStone extends TileEngineWithInventory { final float MAX_OUTPUT = 1f; final float MIN_OUTPUT = MAX_OUTPUT / 3; diff --git a/common/buildcraft/energy/TileEngineWithInventory.java b/common/buildcraft/energy/TileEngineWithInventory.java new file mode 100644 index 00000000..1eba264f --- /dev/null +++ b/common/buildcraft/energy/TileEngineWithInventory.java @@ -0,0 +1,91 @@ +package buildcraft.energy; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import buildcraft.core.inventory.InvUtils; +import buildcraft.core.inventory.SimpleInventory; + +public abstract class TileEngineWithInventory extends TileEngine implements IInventory{ + + private final SimpleInventory inv; + + public TileEngineWithInventory(int invSize) { + inv = new SimpleInventory(invSize, "Engine", 64); + } + + /* IINVENTORY IMPLEMENTATION */ + + @Override + public int getSizeInventory() { + return inv.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inv.getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + return inv.decrStackSize(slot, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inv.getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack itemstack) { + inv.setInventorySlotContents(slot, itemstack); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } + + @Override + public String getInvName() { + return "Engine"; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; + } + + @Override + public void openChest() { + } + + @Override + public void closeChest() { + } + + @Override + public void readFromNBT(NBTTagCompound data) { + super.readFromNBT(data); + inv.readFromNBT(data); + } + + @Override + public void writeToNBT(NBTTagCompound data) { + super.writeToNBT(data); + inv.writeToNBT(data); + } + + @Override + public void delete() { + super.delete(); + InvUtils.dropItems(worldObj, inv, xCoord, yCoord, zCoord); + } + +} \ No newline at end of file diff --git a/common/buildcraft/energy/TileEngineWood.java b/common/buildcraft/energy/TileEngineWood.java index df753a29..19fa9b4f 100644 --- a/common/buildcraft/energy/TileEngineWood.java +++ b/common/buildcraft/energy/TileEngineWood.java @@ -16,10 +16,6 @@ public class TileEngineWood extends TileEngine { public static final float OUTPUT = 0.05F; - public TileEngineWood() { - super(0); - } - @Override public ResourceLocation getTextureFile() { return WOOD_TEXTURE; diff --git a/common/buildcraft/energy/gui/ContainerEngine.java b/common/buildcraft/energy/gui/ContainerEngine.java index 9c90557d..5b8d017a 100644 --- a/common/buildcraft/energy/gui/ContainerEngine.java +++ b/common/buildcraft/energy/gui/ContainerEngine.java @@ -7,19 +7,19 @@ */ package buildcraft.energy.gui; -import buildcraft.core.gui.BuildCraftContainer; -import buildcraft.energy.TileEngine; -import buildcraft.energy.TileEngineStone; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; +import buildcraft.core.gui.BuildCraftContainer; +import buildcraft.energy.TileEngineStone; +import buildcraft.energy.TileEngineWithInventory; public class ContainerEngine extends BuildCraftContainer { - protected TileEngine engine; + protected TileEngineWithInventory engine; - public ContainerEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) { + public ContainerEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) { super(tileEngine.getSizeInventory()); engine = tileEngine; diff --git a/common/buildcraft/energy/gui/GuiCombustionEngine.java b/common/buildcraft/energy/gui/GuiCombustionEngine.java index a76ae901..c29a4c0a 100644 --- a/common/buildcraft/energy/gui/GuiCombustionEngine.java +++ b/common/buildcraft/energy/gui/GuiCombustionEngine.java @@ -7,24 +7,26 @@ */ package buildcraft.energy.gui; -import buildcraft.core.DefaultProps; -import buildcraft.core.utils.StringUtils; -import buildcraft.energy.TileEngine; -import buildcraft.energy.TileEngineIron; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.Icon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; + import org.lwjgl.opengl.GL11; +import buildcraft.core.DefaultProps; +import buildcraft.core.utils.StringUtils; +import buildcraft.energy.TileEngineIron; +import buildcraft.energy.TileEngineWithInventory; + public class GuiCombustionEngine extends GuiEngine { private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/combustion_engine_gui.png"); private static final ResourceLocation BLOCK_TEXTURE = TextureMap.field_110575_b; - public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) { + public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) { super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine); } diff --git a/common/buildcraft/energy/gui/GuiStoneEngine.java b/common/buildcraft/energy/gui/GuiStoneEngine.java index dee51ab7..12209ac5 100644 --- a/common/buildcraft/energy/gui/GuiStoneEngine.java +++ b/common/buildcraft/energy/gui/GuiStoneEngine.java @@ -7,18 +7,21 @@ */ package buildcraft.energy.gui; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + import buildcraft.core.DefaultProps; import buildcraft.core.utils.StringUtils; import buildcraft.energy.TileEngine; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; +import buildcraft.energy.TileEngineWithInventory; public class GuiStoneEngine extends GuiEngine { private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/steam_engine_gui.png"); - public GuiStoneEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) { + public GuiStoneEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) { super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine); } From 57c58036b760c5b3919f8e6207988f43691de3ab Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 31 Aug 2013 18:31:15 -0700 Subject: [PATCH 025/121] Working out the kinks --- common/buildcraft/transport/pipes/PipePowerWood.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/transport/pipes/PipePowerWood.java b/common/buildcraft/transport/pipes/PipePowerWood.java index ca1d1cfb..d1329b16 100644 --- a/common/buildcraft/transport/pipes/PipePowerWood.java +++ b/common/buildcraft/transport/pipes/PipePowerWood.java @@ -39,7 +39,7 @@ public class PipePowerWood extends Pipe implements IPowerRec } private void initPowerProvider() { - powerHandler.configure(2, 250, 1, 1500); + powerHandler.configure(2, 300, 1, 1500); powerHandler.configurePowerPerdition(1, 10); } From ddc203fe592ca523634de7f2e7640203078bd1ef Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 1 Sep 2013 04:51:50 -0700 Subject: [PATCH 026/121] Possible fix for #1182 --- common/buildcraft/transport/PipeTransportItems.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index 69ffe5f6..52ddb4fb 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -573,9 +573,12 @@ public class PipeTransportItems extends PipeTransport { if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportItems)) return false; } - - if(tile instanceof ISidedInventory) - return ((ISidedInventory)tile).getAccessibleSlotsFromSide(side.getOpposite().ordinal()).length > 0; + + if (tile instanceof ISidedInventory) { + int[] slots = ((ISidedInventory) tile).getAccessibleSlotsFromSide(side.getOpposite().ordinal()); + return slots != null && slots.length > 0; + } + return tile instanceof TileGenericPipe || tile instanceof ISpecialInventory || (tile instanceof IInventory && ((IInventory) tile).getSizeInventory() > 0) || (tile instanceof IMachine && ((IMachine) tile).manageSolids()); } From ae77912afdd99687e841d74292d4d55da40a8497 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 3 Sep 2013 02:11:14 -0700 Subject: [PATCH 027/121] Make Tanks emit light if the Fluid glows --- common/buildcraft/factory/BlockTank.java | 11 +++++++++++ common/buildcraft/factory/TileTank.java | 19 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/factory/BlockTank.java b/common/buildcraft/factory/BlockTank.java index a23256cc..8ab8840a 100644 --- a/common/buildcraft/factory/BlockTank.java +++ b/common/buildcraft/factory/BlockTank.java @@ -23,6 +23,7 @@ import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; @@ -157,4 +158,14 @@ public class BlockTank extends BlockContainer { textureBottomSide = par1IconRegister.registerIcon("buildcraft:tank_bottom_side"); textureTop = par1IconRegister.registerIcon("buildcraft:tank_top"); } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + TileEntity tile = world.getBlockTileEntity(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/TileTank.java b/common/buildcraft/factory/TileTank.java index b90ceb56..43cc1d12 100644 --- a/common/buildcraft/factory/TileTank.java +++ b/common/buildcraft/factory/TileTank.java @@ -21,6 +21,7 @@ import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.EnumSkyBlock; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -35,18 +36,25 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { public final TankManager tankManager = new TankManager(tank); public boolean hasUpdate = false; public SafeTimeTracker tracker = new SafeTimeTracker(); + private int prevLightValue = 0; /* UPDATING */ @Override public void updateEntity() { - if (CoreProxy.proxy.isRenderWorld(worldObj)) + if (CoreProxy.proxy.isRenderWorld(worldObj)) { + int lightValue = getFluidLightLevel(); + if (prevLightValue != lightValue) { + prevLightValue = lightValue; + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); + } return; - + } + // Have liquid flow down into tanks below if any. if (tank.getFluid() != null) { moveFluidBelow(); } - + if (hasUpdate && tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)) { sendNetworkUpdate(); hasUpdate = false; @@ -242,4 +250,9 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { public boolean canDrain(ForgeDirection from, Fluid fluid) { return false; } + + public int getFluidLightLevel() { + FluidStack tankFluid = tank.getFluid(); + return tankFluid == null ? 0 : tankFluid.getFluid().getLuminosity(tankFluid); + } } From 158c79c301f0271ba7a1dbae03ecd6809aca1519 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 3 Sep 2013 02:12:13 -0700 Subject: [PATCH 028/121] Clean up Obsidian Pipe code --- .../transport/pipes/PipeItemsObsidian.java | 86 +++++++------------ .../transport/pipes/PipePowerWood.java | 2 +- .../transport/render/PipeWorldRenderer.java | 23 ++++- 3 files changed, 55 insertions(+), 56 deletions(-) diff --git a/common/buildcraft/transport/pipes/PipeItemsObsidian.java b/common/buildcraft/transport/pipes/PipeItemsObsidian.java index cc88e9e5..67dde61b 100644 --- a/common/buildcraft/transport/pipes/PipeItemsObsidian.java +++ b/common/buildcraft/transport/pipes/PipeItemsObsidian.java @@ -14,6 +14,9 @@ import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.Type; +import buildcraft.core.inventory.ITransactor; +import buildcraft.core.inventory.Transactor; +import buildcraft.core.inventory.filters.StackFilter; import buildcraft.transport.TravelingItem; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; @@ -22,12 +25,12 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.Arrays; import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityMinecartChest; import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; @@ -35,6 +38,7 @@ import net.minecraftforge.common.ForgeDirection; public class PipeItemsObsidian extends Pipe implements IPowerReceptor { + private static final PowerHandler.PerditionCalculator PERDITION = new PowerHandler.PerditionCalculator(0.5F); private PowerHandler powerHandler; private int[] entitiesDropped; private int entitiesDroppedIndex = 0; @@ -43,14 +47,11 @@ public class PipeItemsObsidian extends Pipe implements IPowe super(new PipeTransportItems(), itemID); entitiesDropped = new int[32]; - - for (int i = 0; i < entitiesDropped.length; ++i) { - entitiesDropped[i] = -1; - } + Arrays.fill(entitiesDropped, -1); powerHandler = new PowerHandler(this, Type.MACHINE); powerHandler.configure(1, 64, 1, 256); - powerHandler.configurePowerPerdition(1, 1); + powerHandler.setPerdition(PERDITION); } @Override @@ -138,48 +139,45 @@ public class PipeItemsObsidian extends Pipe implements IPowe Position min = p1.min(p2); Position max = p1.max(p2); - return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z); + return AxisAlignedBB.getAABBPool().getAABB(min.x, min.y, min.z, max.x, max.y, max.z); } @Override public void doWork(PowerHandler workProvider) { for (int j = 1; j < 5; ++j) { - if (trySucc(j)) + if (suckItem(j)) return; } - - powerHandler.useEnergy(1, 1, true); } - private boolean trySucc(int distance) { + private boolean suckItem(int distance) { AxisAlignedBB box = getSuckingBox(getOpenOrientation(), distance); if (box == null) return false; @SuppressWarnings("rawtypes") - List list = container.worldObj.getEntitiesWithinAABB(Entity.class, box); + List discoveredEntities = (List) container.worldObj.getEntitiesWithinAABB(Entity.class, box); - for (int g = 0; g < list.size(); g++) { - if (list.get(g) instanceof Entity) { - Entity entity = (Entity) list.get(g); + for (Entity entity : discoveredEntities) { + if (canSuck(entity, distance)) { + pullItemIntoPipe(entity, distance); + return true; + } - if (canSuck(entity, distance)) { - pullItemIntoPipe(entity, distance); - return true; - } - - if (distance == 1 && list.get(g) instanceof EntityMinecartChest) { - EntityMinecartChest cart = (EntityMinecartChest) list.get(g); - if (!cart.isDead) { - ItemStack stack = checkExtractGeneric(cart, true, getOpenOrientation()); - if (stack != null && powerHandler.useEnergy(1, 1, true) == 1) { - EntityItem entityitem = new EntityItem(container.worldObj, cart.posX, cart.posY + 0.3F, cart.posZ, stack); - entityitem.delayBeforeCanPickup = 10; - container.worldObj.spawnEntityInWorld(entityitem); - pullItemIntoPipe(entityitem, 1); - return true; - } + if (distance == 1 && entity instanceof EntityMinecartChest) { + EntityMinecartChest cart = (EntityMinecartChest) entity; + if (!cart.isDead) { + ITransactor trans = Transactor.getTransactorFor(cart); + ForgeDirection openOrientation = getOpenOrientation(); + ItemStack stack = trans.remove(StackFilter.ALL, openOrientation, false); + if (stack != null && powerHandler.useEnergy(1, 1, true) == 1) { + trans.remove(StackFilter.ALL, openOrientation, true); + EntityItem entityitem = new EntityItem(container.worldObj, cart.posX, cart.posY + 0.3F, cart.posZ, stack); + entityitem.delayBeforeCanPickup = 10; + container.worldObj.spawnEntityInWorld(entityitem); + pullItemIntoPipe(entityitem, 1); + return true; } } } @@ -188,23 +186,6 @@ public class PipeItemsObsidian extends Pipe implements IPowe return false; } - public ItemStack checkExtractGeneric(IInventory inventory, boolean doRemove, ForgeDirection from) { - for (int k = 0; k < inventory.getSizeInventory(); ++k) { - if (inventory.getStackInSlot(k) != null && inventory.getStackInSlot(k).stackSize > 0) { - - ItemStack slot = inventory.getStackInSlot(k); - - if (slot != null && slot.stackSize > 0) - if (doRemove) - return inventory.decrStackSize(k, 1); - else - return slot; - } - } - - return null; - } - public void pullItemIntoPipe(Entity entity, int distance) { if (CoreProxy.proxy.isRenderWorld(container.worldObj)) return; @@ -281,12 +262,9 @@ public class PipeItemsObsidian extends Pipe implements IPowe return powerHandler.useEnergy(1, distance, false) >= distance; } else if (entity instanceof EntityArrow) { EntityArrow arrow = (EntityArrow) entity; - if (arrow.canBePickedUp == 1) - return powerHandler.useEnergy(1, distance, false) >= distance; - else - return false; - } else - return false; + return arrow.canBePickedUp == 1 && powerHandler.useEnergy(1, distance, false) >= distance; + } + return false; } @Override diff --git a/common/buildcraft/transport/pipes/PipePowerWood.java b/common/buildcraft/transport/pipes/PipePowerWood.java index d1329b16..c9aa769b 100644 --- a/common/buildcraft/transport/pipes/PipePowerWood.java +++ b/common/buildcraft/transport/pipes/PipePowerWood.java @@ -39,7 +39,7 @@ public class PipePowerWood extends Pipe implements IPowerRec } private void initPowerProvider() { - powerHandler.configure(2, 300, 1, 1500); + powerHandler.configure(2, 500, 1, 1500); powerHandler.configurePowerPerdition(1, 10); } diff --git a/common/buildcraft/transport/render/PipeWorldRenderer.java b/common/buildcraft/transport/render/PipeWorldRenderer.java index cb9e2210..31983f43 100644 --- a/common/buildcraft/transport/render/PipeWorldRenderer.java +++ b/common/buildcraft/transport/render/PipeWorldRenderer.java @@ -552,7 +552,28 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler { } private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) { - return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) == 0 && !state.plugMatrix.isConnected(direction); + return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) == 0 && !state.plugMatrix.isConnected(direction) && !isOpenOrientation(state, direction); + } + + public boolean isOpenOrientation(PipeRenderState state, ForgeDirection direction) { + int connections = 0; + + ForgeDirection targetOrientation = ForgeDirection.UNKNOWN; + + for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { + if (state.pipeConnectionMatrix.isConnected(o)) { + + connections++; + + if (connections == 1) + targetOrientation = o; + } + } + + if (connections > 1 || connections == 0) + return false; + + return targetOrientation.getOpposite() == direction; } @Override From 730a0ac4a7c32d8437c9c8b7abc238427b7c5b7a Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 3 Sep 2013 15:52:19 -0400 Subject: [PATCH 029/121] Fix for updated MCP names --- .../buildcraft/builders/gui/GuiBlueprintLibrary.java | 2 +- common/buildcraft/builders/gui/GuiBuilder.java | 4 ++-- common/buildcraft/builders/gui/GuiFiller.java | 6 +++--- common/buildcraft/builders/gui/GuiTemplate.java | 2 +- common/buildcraft/core/CommandBuildCraft.java | 10 +++++----- common/buildcraft/core/gui/GuiAdvancedInterface.java | 4 ++-- common/buildcraft/core/gui/GuiBuildCraft.java | 2 +- .../buildcraft/core/gui/buttons/GuiBetterButton.java | 2 +- common/buildcraft/core/proxy/CoreProxyClient.java | 2 +- common/buildcraft/core/render/FluidRenderer.java | 4 ++-- common/buildcraft/core/render/RenderEntityBlock.java | 4 ++-- common/buildcraft/core/render/RenderLaser.java | 4 ++-- common/buildcraft/core/render/RenderRobot.java | 4 ++-- common/buildcraft/core/render/RenderVoid.java | 2 +- .../buildcraft/core/render/RenderingEntityBlocks.java | 4 ++-- common/buildcraft/energy/gui/GuiCombustionEngine.java | 8 ++++---- common/buildcraft/energy/gui/GuiEngine.java | 4 ++-- common/buildcraft/energy/gui/GuiStoneEngine.java | 2 +- common/buildcraft/energy/render/RenderEngine.java | 6 +++--- common/buildcraft/factory/TileQuarry.java | 6 +++--- common/buildcraft/factory/gui/GuiAutoCrafting.java | 2 +- common/buildcraft/factory/gui/GuiHopper.java | 2 +- common/buildcraft/factory/gui/GuiRefinery.java | 2 +- common/buildcraft/factory/render/RenderHopper.java | 4 ++-- common/buildcraft/factory/render/RenderRefinery.java | 8 ++++---- common/buildcraft/factory/render/RenderTank.java | 2 +- .../silicon/gui/GuiAdvancedCraftingTable.java | 4 ++-- common/buildcraft/silicon/gui/GuiAssemblyTable.java | 4 ++-- common/buildcraft/transport/BlockGenericPipe.java | 4 ++-- common/buildcraft/transport/ItemFacade.java | 2 +- common/buildcraft/transport/gui/GuiDiamondPipe.java | 2 +- common/buildcraft/transport/gui/GuiEmeraldPipe.java | 2 +- common/buildcraft/transport/gui/GuiFilteredBuffer.java | 2 +- common/buildcraft/transport/gui/GuiGateInterface.java | 8 ++++---- .../buildcraft/transport/render/PipeItemRenderer.java | 2 +- common/buildcraft/transport/render/RenderPipe.java | 8 ++++---- 36 files changed, 70 insertions(+), 70 deletions(-) diff --git a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java index 43b19929..68284f29 100644 --- a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java +++ b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java @@ -106,7 +106,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft { @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); int j = (width - xSize) / 2; int k = (height - ySize) / 2; diff --git a/common/buildcraft/builders/gui/GuiBuilder.java b/common/buildcraft/builders/gui/GuiBuilder.java index 01c0a7d6..a3bd533d 100644 --- a/common/buildcraft/builders/gui/GuiBuilder.java +++ b/common/buildcraft/builders/gui/GuiBuilder.java @@ -64,10 +64,10 @@ public class GuiBuilder extends GuiAdvancedInterface { int realXSize = 0; if (builder.isBuildingBlueprint()) { - mc.renderEngine.func_110577_a(BLUEPRINT_TEXTURE); + mc.renderEngine.bindTexture(BLUEPRINT_TEXTURE); realXSize = 256; } else { - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); realXSize = 176; } diff --git a/common/buildcraft/builders/gui/GuiFiller.java b/common/buildcraft/builders/gui/GuiFiller.java index 6a881622..7c17b209 100644 --- a/common/buildcraft/builders/gui/GuiFiller.java +++ b/common/buildcraft/builders/gui/GuiFiller.java @@ -19,7 +19,7 @@ import org.lwjgl.opengl.GL11; public class GuiFiller extends GuiBuildCraft { private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filler.png"); - private static final ResourceLocation BLOCK_TEXTURE = TextureMap.field_110575_b; + private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; IInventory playerInventory; TileFiller filler; @@ -47,12 +47,12 @@ public class GuiFiller extends GuiBuildCraft { protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); if (filler.currentPattern != null) { - mc.renderEngine.func_110577_a(BLOCK_TEXTURE); + mc.renderEngine.bindTexture(BLOCK_TEXTURE); drawTexturedModelRectFromIcon(guiLeft + patternSymbolX, guiTop + patternSymbolY, filler.currentPattern.getTexture(), 16, 16); } diff --git a/common/buildcraft/builders/gui/GuiTemplate.java b/common/buildcraft/builders/gui/GuiTemplate.java index aee74cfb..fccefd98 100644 --- a/common/buildcraft/builders/gui/GuiTemplate.java +++ b/common/buildcraft/builders/gui/GuiTemplate.java @@ -52,7 +52,7 @@ public class GuiTemplate extends GuiBuildCraft { @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); int j = (width - xSize) / 2; int k = (height - ySize) / 2; drawTexturedModalRect(j, k, 0, 0, xSize, ySize); diff --git a/common/buildcraft/core/CommandBuildCraft.java b/common/buildcraft/core/CommandBuildCraft.java index f55b391f..6aa5b796 100644 --- a/common/buildcraft/core/CommandBuildCraft.java +++ b/common/buildcraft/core/CommandBuildCraft.java @@ -46,9 +46,9 @@ public class CommandBuildCraft extends CommandBase { commandVersion(sender, arguments); return; } else if (arguments[0].matches("help")) { - sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Format: '" + this.getCommandName() + " '")); - sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Available commands:")); - sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("- version : Version information.")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText("Format: '" + this.getCommandName() + " '")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText("Available commands:")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText("- version : Version information.")); return; } @@ -58,11 +58,11 @@ public class CommandBuildCraft extends CommandBase { private void commandVersion(ICommandSender sender, String[] arguments) { String colour = Version.isOutdated() ? "\u00A7c" : "\u00A7a"; - sender.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(colour + "BuildCraft %s for Minecraft %s (Latest: %s).", Version.getVersion(), + sender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format(colour + "BuildCraft %s for Minecraft %s (Latest: %s).", Version.getVersion(), CoreProxy.proxy.getMinecraftVersion(), Version.getRecommendedVersion()))); if (Version.isOutdated()) { for (String updateLine : Version.getChangelog()) { - sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("\u00A79" + updateLine)); + sender.sendChatToPlayer(ChatMessageComponent.createFromText("\u00A79" + updateLine)); } } } diff --git a/common/buildcraft/core/gui/GuiAdvancedInterface.java b/common/buildcraft/core/gui/GuiAdvancedInterface.java index d9108443..bbcf04c3 100644 --- a/common/buildcraft/core/gui/GuiAdvancedInterface.java +++ b/common/buildcraft/core/gui/GuiAdvancedInterface.java @@ -36,7 +36,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { } public ResourceLocation getTexture() { - return TextureMap.field_110576_c; + return TextureMap.locationItemsTexture; } public ItemStack getItemStack() { @@ -54,7 +54,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { if (getItemStack() != null) { drawStack(getItemStack()); } else if (getIcon() != null) { - mc.renderEngine.func_110577_a(getTexture()); + mc.renderEngine.bindTexture(getTexture()); //System.out.printf("Drawing advanced sprite %s (%d,%d) at %d %d\n", getIcon().getIconName(), getIcon().getOriginX(),getIcon().getOriginY(),cornerX + x, cornerY + y); drawTexturedModelRectFromIcon(cornerX + x, cornerY + y, getIcon(), 16, 16); } diff --git a/common/buildcraft/core/gui/GuiBuildCraft.java b/common/buildcraft/core/gui/GuiBuildCraft.java index 86baf703..e292bbae 100644 --- a/common/buildcraft/core/gui/GuiBuildCraft.java +++ b/common/buildcraft/core/gui/GuiBuildCraft.java @@ -209,7 +209,7 @@ public abstract class GuiBuildCraft extends GuiContainer { GL11.glColor4f(colorR, colorG, colorB, 1.0F); - mc.renderEngine.func_110577_a(LEDGER_TEXTURE); + mc.renderEngine.bindTexture(LEDGER_TEXTURE); drawTexturedModalRect(x, y, 0, 256 - currentHeight, 4, currentHeight); drawTexturedModalRect(x + 4, y, 256 - currentWidth + 4, 0, currentWidth - 4, 4); // Add in top left corner again diff --git a/common/buildcraft/core/gui/buttons/GuiBetterButton.java b/common/buildcraft/core/gui/buttons/GuiBetterButton.java index 7b24f659..5fbcaa91 100644 --- a/common/buildcraft/core/gui/buttons/GuiBetterButton.java +++ b/common/buildcraft/core/gui/buttons/GuiBetterButton.java @@ -57,7 +57,7 @@ public class GuiBetterButton extends GuiButton { } protected void bindButtonTextures(Minecraft minecraft) { - minecraft.renderEngine.func_110577_a(BUTTON_TEXTURES); + minecraft.renderEngine.bindTexture(BUTTON_TEXTURES); } @Override diff --git a/common/buildcraft/core/proxy/CoreProxyClient.java b/common/buildcraft/core/proxy/CoreProxyClient.java index c30dedca..ebbde727 100644 --- a/common/buildcraft/core/proxy/CoreProxyClient.java +++ b/common/buildcraft/core/proxy/CoreProxyClient.java @@ -79,7 +79,7 @@ public class CoreProxyClient extends CoreProxy { /* LOCALIZATION */ @Override public String getCurrentLanguage() { - return Minecraft.getMinecraft().func_135016_M().func_135041_c().func_135034_a(); + return Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode(); } @Override diff --git a/common/buildcraft/core/render/FluidRenderer.java b/common/buildcraft/core/render/FluidRenderer.java index dd76870a..905be09f 100644 --- a/common/buildcraft/core/render/FluidRenderer.java +++ b/common/buildcraft/core/render/FluidRenderer.java @@ -27,7 +27,7 @@ import org.lwjgl.opengl.GL11; */ public class FluidRenderer { - private static final ResourceLocation BLOCK_TEXTURE = TextureMap.field_110575_b; + private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; private static Map flowingRenderCache = new HashMap(); private static Map stillRenderCache = new HashMap(); public static final int DISPLAY_STAGES = 100; @@ -46,7 +46,7 @@ public class FluidRenderer { } Icon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon(); if (icon == null) { - icon = ((TextureMap) Minecraft.getMinecraft().func_110434_K().func_110581_b(TextureMap.field_110575_b)).func_110572_b("missingno"); + icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); } return icon; } diff --git a/common/buildcraft/core/render/RenderEntityBlock.java b/common/buildcraft/core/render/RenderEntityBlock.java index 6c967381..cfb5089b 100644 --- a/common/buildcraft/core/render/RenderEntityBlock.java +++ b/common/buildcraft/core/render/RenderEntityBlock.java @@ -24,7 +24,7 @@ public class RenderEntityBlock extends Render { public static RenderEntityBlock INSTANCE = new RenderEntityBlock(); @Override - protected ResourceLocation func_110775_a(Entity entity) { + protected ResourceLocation getEntityTexture(Entity entity) { throw new UnsupportedOperationException("Not supported yet."); } @@ -67,7 +67,7 @@ public class RenderEntityBlock extends Render { World world = entity.worldObj; BlockInterface util = new BlockInterface(); util.texture = entity.texture; - func_110776_a(TextureMap.field_110575_b); + bindTexture(TextureMap.locationBlocksTexture); for (int iBase = 0; iBase < entity.iSize; ++iBase) { for (int jBase = 0; jBase < entity.jSize; ++jBase) { diff --git a/common/buildcraft/core/render/RenderLaser.java b/common/buildcraft/core/render/RenderLaser.java index b74ae911..dc5b859a 100644 --- a/common/buildcraft/core/render/RenderLaser.java +++ b/common/buildcraft/core/render/RenderLaser.java @@ -46,7 +46,7 @@ public class RenderLaser extends Render { GL11.glRotatef((float) laser.angleZ, 0, 1, 0); GL11.glRotatef((float) laser.angleY, 0, 0, 1); - renderManager.renderEngine.func_110577_a(laser.getTexture()); + renderManager.renderEngine.bindTexture(laser.getTexture()); float factor = (float) (1.0 / 16.0); @@ -78,7 +78,7 @@ public class RenderLaser extends Render { } @Override - protected ResourceLocation func_110775_a(Entity entity) { + protected ResourceLocation getEntityTexture(Entity entity) { return ((EntityLaser) entity).getTexture(); } } diff --git a/common/buildcraft/core/render/RenderRobot.java b/common/buildcraft/core/render/RenderRobot.java index 1aae2e11..6af671a5 100644 --- a/common/buildcraft/core/render/RenderRobot.java +++ b/common/buildcraft/core/render/RenderRobot.java @@ -35,7 +35,7 @@ public class RenderRobot extends Render { GL11.glDisable(2896 /* GL_LIGHTING */); GL11.glTranslated(x, y, z); - renderManager.renderEngine.func_110577_a(TEXTURE); + renderManager.renderEngine.bindTexture(TEXTURE); float factor = (float) (1.0 / 16.0); @@ -47,7 +47,7 @@ public class RenderRobot extends Render { } @Override - protected ResourceLocation func_110775_a(Entity entity) { + protected ResourceLocation getEntityTexture(Entity entity) { return TEXTURE; } } diff --git a/common/buildcraft/core/render/RenderVoid.java b/common/buildcraft/core/render/RenderVoid.java index 155e23b7..842ed879 100644 --- a/common/buildcraft/core/render/RenderVoid.java +++ b/common/buildcraft/core/render/RenderVoid.java @@ -22,7 +22,7 @@ public class RenderVoid extends Render { } @Override - protected ResourceLocation func_110775_a(Entity entity) { + protected ResourceLocation getEntityTexture(Entity entity) { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/common/buildcraft/core/render/RenderingEntityBlocks.java b/common/buildcraft/core/render/RenderingEntityBlocks.java index 157c07a2..cf217e0f 100644 --- a/common/buildcraft/core/render/RenderingEntityBlocks.java +++ b/common/buildcraft/core/render/RenderingEntityBlocks.java @@ -16,7 +16,7 @@ import org.lwjgl.opengl.GL11; public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler { - private static final ResourceLocation BLOCK_TEXTURE = TextureMap.field_110575_b; + private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; public static class EntityRenderIndex { @@ -96,7 +96,7 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler { if (block.getRenderType() == BuildCraftCore.blockByEntityModel) { // renderblocks.renderStandardBlock(block, i, j, k); } else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) { - Minecraft.getMinecraft().renderEngine.func_110577_a(BLOCK_TEXTURE); + Minecraft.getMinecraft().renderEngine.bindTexture(BLOCK_TEXTURE); legacyPipeRender(renderer, world, x, y, z, block, modelId); } diff --git a/common/buildcraft/energy/gui/GuiCombustionEngine.java b/common/buildcraft/energy/gui/GuiCombustionEngine.java index c29a4c0a..a2074c57 100644 --- a/common/buildcraft/energy/gui/GuiCombustionEngine.java +++ b/common/buildcraft/energy/gui/GuiCombustionEngine.java @@ -24,7 +24,7 @@ import buildcraft.energy.TileEngineWithInventory; public class GuiCombustionEngine extends GuiEngine { private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/combustion_engine_gui.png"); - private static final ResourceLocation BLOCK_TEXTURE = TextureMap.field_110575_b; + private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) { super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine); @@ -41,7 +41,7 @@ public class GuiCombustionEngine extends GuiEngine { @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); int j = (width - xSize) / 2; int k = (height - ySize) / 2; drawTexturedModalRect(j, k, 0, 0, xSize, ySize); @@ -68,7 +68,7 @@ public class GuiCombustionEngine extends GuiEngine { if (fluid != null && fluid.getStillIcon() != null) { liquidIcon = fluid.getStillIcon(); } - mc.renderEngine.func_110577_a(BLOCK_TEXTURE); + mc.renderEngine.bindTexture(BLOCK_TEXTURE); if (liquidIcon != null) { while (true) { @@ -91,7 +91,7 @@ public class GuiCombustionEngine extends GuiEngine { } } - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60); } } diff --git a/common/buildcraft/energy/gui/GuiEngine.java b/common/buildcraft/energy/gui/GuiEngine.java index 2012d034..5624fb33 100644 --- a/common/buildcraft/energy/gui/GuiEngine.java +++ b/common/buildcraft/energy/gui/GuiEngine.java @@ -13,7 +13,7 @@ import net.minecraft.util.ResourceLocation; public abstract class GuiEngine extends GuiBuildCraft { - private static final ResourceLocation ITEM_TEXTURE = TextureMap.field_110576_c; + private static final ResourceLocation ITEM_TEXTURE = TextureMap.locationItemsTexture; protected class EngineLedger extends Ledger { @@ -35,7 +35,7 @@ public abstract class GuiEngine extends GuiBuildCraft { drawBackground(x, y); // Draw icon - Minecraft.getMinecraft().renderEngine.func_110577_a(ITEM_TEXTURE); + Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE); drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4); if (!isFullyOpened()) diff --git a/common/buildcraft/energy/gui/GuiStoneEngine.java b/common/buildcraft/energy/gui/GuiStoneEngine.java index 12209ac5..0972f73c 100644 --- a/common/buildcraft/energy/gui/GuiStoneEngine.java +++ b/common/buildcraft/energy/gui/GuiStoneEngine.java @@ -36,7 +36,7 @@ public class GuiStoneEngine extends GuiEngine { @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); int j = (width - xSize) / 2; int k = (height - ySize) / 2; drawTexturedModalRect(j, k, 0, 0, xSize, ySize); diff --git a/common/buildcraft/energy/render/RenderEngine.java b/common/buildcraft/energy/render/RenderEngine.java index 1326ec7f..a72a96c8 100644 --- a/common/buildcraft/energy/render/RenderEngine.java +++ b/common/buildcraft/energy/render/RenderEngine.java @@ -161,7 +161,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor float factor = (float) (1.0 / 16.0); - func_110628_a(baseTexture); + bindTexture(baseTexture); box.render(factor); @@ -169,7 +169,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor movingBox.render(factor); GL11.glTranslatef(-translate[0] * translatefact, -translate[1] * translatefact, -translate[2] * translatefact); - func_110628_a(CHAMBER_TEXTURE); + bindTexture(CHAMBER_TEXTURE); float chamberf = 2F / 16F; @@ -199,7 +199,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor break; } - func_110628_a(texture); + bindTexture(texture); trunk.render(factor); diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index e998910b..d3bd38d6 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -513,7 +513,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept isAlive = false; if (placedBy != null && CoreProxy.proxy.isSimulating(worldObj)) { PacketDispatcher.sendPacketToPlayer( - new Packet3Chat(ChatMessageComponent.func_111066_d(String.format("[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available", + new Packet3Chat(ChatMessageComponent.createFromText(String.format("[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available", xCoord, yCoord, zCoord))), (Player) placedBy); } sendNetworkUpdate(); @@ -542,7 +542,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept if (xSize < 3 || zSize < 3 || ((xSize * zSize) >> 8) >= chunkTicket.getMaxChunkListDepth()) { if (placedBy != null) { PacketDispatcher.sendPacketToPlayer( - new Packet3Chat(ChatMessageComponent.func_111066_d(String.format("Quarry size is outside of chunkloading bounds or too small %d %d (%d)", xSize, zSize, + new Packet3Chat(ChatMessageComponent.createFromText(String.format("Quarry size is outside of chunkloading bounds or too small %d %d (%d)", xSize, zSize, chunkTicket.getMaxChunkListDepth()))), (Player) placedBy); } a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10); @@ -832,7 +832,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } if (placedBy != null) { PacketDispatcher.sendPacketToPlayer( - new Packet3Chat(ChatMessageComponent.func_111066_d(String.format("[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded", xCoord, yCoord, zCoord, chunks.size()))), + new Packet3Chat(ChatMessageComponent.createFromText(String.format("[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded", xCoord, yCoord, zCoord, chunks.size()))), (Player) placedBy); } sendNetworkUpdate(); diff --git a/common/buildcraft/factory/gui/GuiAutoCrafting.java b/common/buildcraft/factory/gui/GuiAutoCrafting.java index 8aa44f89..76293ae9 100644 --- a/common/buildcraft/factory/gui/GuiAutoCrafting.java +++ b/common/buildcraft/factory/gui/GuiAutoCrafting.java @@ -44,7 +44,7 @@ public class GuiAutoCrafting extends GuiBuildCraft { @Override protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(gui); + mc.renderEngine.bindTexture(gui); int x = (width - xSize) / 2; int y = (height - ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, ySize); diff --git a/common/buildcraft/factory/gui/GuiHopper.java b/common/buildcraft/factory/gui/GuiHopper.java index 5ab38dc3..2ab5c7c5 100644 --- a/common/buildcraft/factory/gui/GuiHopper.java +++ b/common/buildcraft/factory/gui/GuiHopper.java @@ -19,7 +19,7 @@ public class GuiHopper extends GuiContainer { @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); int j = (width - xSize) / 2; int k = (height - ySize) / 2; drawTexturedModalRect(j, k, 0, 0, xSize, ySize); diff --git a/common/buildcraft/factory/gui/GuiRefinery.java b/common/buildcraft/factory/gui/GuiRefinery.java index ab5486c0..1b36648c 100644 --- a/common/buildcraft/factory/gui/GuiRefinery.java +++ b/common/buildcraft/factory/gui/GuiRefinery.java @@ -56,7 +56,7 @@ public class GuiRefinery extends GuiAdvancedInterface { @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); int j = (width - xSize) / 2; int k = (height - ySize) / 2; drawTexturedModalRect(j, k, 0, 0, xSize, ySize); diff --git a/common/buildcraft/factory/render/RenderHopper.java b/common/buildcraft/factory/render/RenderHopper.java index 46e519fd..12f5a64c 100644 --- a/common/buildcraft/factory/render/RenderHopper.java +++ b/common/buildcraft/factory/render/RenderHopper.java @@ -56,10 +56,10 @@ public class RenderHopper extends TileEntitySpecialRenderer implements IInventor GL11.glDisable(GL11.GL_LIGHTING); GL11.glTranslated(x, y, z); - func_110628_a(HOPPER_TEXTURE); + bindTexture(HOPPER_TEXTURE); top.render((float) (1.0 / 16.0)); bottom.render((float) (1.0 / 16.0)); - func_110628_a(HOPPER_MIDDLE_TEXTURE); + bindTexture(HOPPER_MIDDLE_TEXTURE); middle.render(Tessellator.instance, 1F / 16F); GL11.glEnable(GL11.GL_LIGHTING); diff --git a/common/buildcraft/factory/render/RenderRefinery.java b/common/buildcraft/factory/render/RenderRefinery.java index 89ee424f..4f2a19ba 100644 --- a/common/buildcraft/factory/render/RenderRefinery.java +++ b/common/buildcraft/factory/render/RenderRefinery.java @@ -126,7 +126,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent GL11.glRotatef(angle, 0, 1, 0); - func_110628_a(TEXTURE); + bindTexture(TEXTURE); GL11.glPushMatrix(); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); @@ -182,7 +182,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent int[] list1 = FluidRenderer.getFluidDisplayLists(liquid1, tile.worldObj, false); if (list1 != null) { - func_110628_a(FluidRenderer.getFluidSheet(liquid1)); + bindTexture(FluidRenderer.getFluidSheet(liquid1)); FluidRenderer.setColorForFluidStack(liquid1); GL11.glCallList(list1[getDisplayListIndex(tile.tank1)]); } @@ -194,7 +194,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent if (list2 != null) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0, 1); - func_110628_a(FluidRenderer.getFluidSheet(liquid2)); + bindTexture(FluidRenderer.getFluidSheet(liquid2)); FluidRenderer.setColorForFluidStack(liquid2); GL11.glCallList(list2[getDisplayListIndex(tile.tank2)]); GL11.glPopMatrix(); @@ -208,7 +208,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent if (list3 != null) { GL11.glPushMatrix(); GL11.glTranslatef(1, 0, 0.5F); - func_110628_a(FluidRenderer.getFluidSheet(liquidResult)); + bindTexture(FluidRenderer.getFluidSheet(liquidResult)); FluidRenderer.setColorForFluidStack(liquidResult); GL11.glCallList(list3[getDisplayListIndex(tile.result)]); GL11.glPopMatrix(); diff --git a/common/buildcraft/factory/render/RenderTank.java b/common/buildcraft/factory/render/RenderTank.java index 579c961a..487f9531 100644 --- a/common/buildcraft/factory/render/RenderTank.java +++ b/common/buildcraft/factory/render/RenderTank.java @@ -38,7 +38,7 @@ public class RenderTank extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - func_110628_a(FluidRenderer.getFluidSheet(liquid)); + bindTexture(FluidRenderer.getFluidSheet(liquid)); FluidRenderer.setColorForFluidStack(liquid); GL11.glTranslatef((float) x + 0.125F, (float) y, (float) z + 0.125F); diff --git a/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java b/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java index 2b188f88..f74233f4 100644 --- a/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java @@ -35,7 +35,7 @@ public class GuiAdvancedCraftingTable extends GuiBuildCraft { drawBackground(x, y); // Draw icon - Minecraft.getMinecraft().renderEngine.func_110577_a(TextureMap.field_110576_c); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4); if (!isFullyOpened()) @@ -76,7 +76,7 @@ public class GuiAdvancedCraftingTable extends GuiBuildCraft { @Override protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(gui); + mc.renderEngine.bindTexture(gui); int cornerX = (width - xSize) / 2; int cornerY = (height - ySize) / 2; drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); diff --git a/common/buildcraft/silicon/gui/GuiAssemblyTable.java b/common/buildcraft/silicon/gui/GuiAssemblyTable.java index 48108ccf..d9c04d88 100644 --- a/common/buildcraft/silicon/gui/GuiAssemblyTable.java +++ b/common/buildcraft/silicon/gui/GuiAssemblyTable.java @@ -50,7 +50,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { drawBackground(x, y); // Draw icon - mc.renderEngine.func_110577_a(TextureMap.field_110576_c); + mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4); if (!isFullyOpened()) @@ -141,7 +141,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); int cornerX = (width - xSize) / 2; int cornerY = (height - ySize) / 2; drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index a9a5f944..fec55a41 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -998,7 +998,7 @@ public class BlockGenericPipe extends BlockContainer { } EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, worldObj.getBlockMetadata(x, y, z)); - fx.func_110125_a(icon); + fx.setParticleIcon(icon); effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); return true; } @@ -1035,7 +1035,7 @@ public class BlockGenericPipe extends BlockContainer { double pz = z + (k + 0.5D) / (double) its; int random = rand.nextInt(6); EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, BuildCraftTransport.genericPipeBlock, random, meta); - fx.func_110125_a(icon); + fx.setParticleIcon(icon); effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z)); } } diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index 7dd4553b..e74b70ca 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -126,7 +126,7 @@ public class ItemFacade extends ItemBuildCraft { Set names = Sets.newHashSet(); for (int meta = 0; meta <= 15; meta++) { ItemStack is = new ItemStack(b, 1, meta); - if (!Strings.isNullOrEmpty(is.getItemName()) && names.add(is.getItemName())) { + if (!Strings.isNullOrEmpty(is.getUnlocalizedName()) && names.add(is.getUnlocalizedName())) { ItemFacade.addFacade(is); } } diff --git a/common/buildcraft/transport/gui/GuiDiamondPipe.java b/common/buildcraft/transport/gui/GuiDiamondPipe.java index d8a8c7a5..91b97ec4 100644 --- a/common/buildcraft/transport/gui/GuiDiamondPipe.java +++ b/common/buildcraft/transport/gui/GuiDiamondPipe.java @@ -49,7 +49,7 @@ public class GuiDiamondPipe extends GuiBuildCraft { @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); int j = (width - xSize) / 2; int k = (height - ySize) / 2; drawTexturedModalRect(j, k, 0, 0, xSize, ySize); diff --git a/common/buildcraft/transport/gui/GuiEmeraldPipe.java b/common/buildcraft/transport/gui/GuiEmeraldPipe.java index b70a423f..89fcfe15 100644 --- a/common/buildcraft/transport/gui/GuiEmeraldPipe.java +++ b/common/buildcraft/transport/gui/GuiEmeraldPipe.java @@ -38,7 +38,7 @@ public class GuiEmeraldPipe extends GuiBuildCraft { @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); int j = (width - xSize) / 2; int k = (height - ySize) / 2; drawTexturedModalRect(j, k, 0, 0, xSize, ySize); diff --git a/common/buildcraft/transport/gui/GuiFilteredBuffer.java b/common/buildcraft/transport/gui/GuiFilteredBuffer.java index 617dce39..ec2356f4 100644 --- a/common/buildcraft/transport/gui/GuiFilteredBuffer.java +++ b/common/buildcraft/transport/gui/GuiFilteredBuffer.java @@ -39,7 +39,7 @@ public class GuiFilteredBuffer extends GuiContainer { protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); int cornerX = (width - xSize) / 2; int cornerY = (height - ySize) / 2; diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java index a24883f6..82091ef4 100644 --- a/common/buildcraft/transport/gui/GuiGateInterface.java +++ b/common/buildcraft/transport/gui/GuiGateInterface.java @@ -239,7 +239,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { ResourceLocation texture = _container.getGateGuiFile(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.func_110577_a(texture); + mc.renderEngine.bindTexture(texture); int cornerX = (width - xSize) / 2; int cornerY = (height - ySize) / 2; @@ -255,18 +255,18 @@ public class GuiGateInterface extends GuiAdvancedInterface { if (_container.getGateOrdinal() >= GateKind.AND_3.ordinal()) { if (_container.triggerState[triggerTracker++]) { - mc.renderEngine.func_110577_a(texture); + mc.renderEngine.bindTexture(texture); drawTexturedModalRect(cornerX + slot.x + 35, cornerY + slot.y + 6, 176, 18, 18, 4); } if (trigger == null || !trigger.hasParameter()) { - mc.renderEngine.func_110577_a(texture); + mc.renderEngine.bindTexture(texture); drawTexturedModalRect(cornerX + slot.x + 17, cornerY + slot.y - 1, 176, 0, 18, 18); } } else if (_container.triggerState[triggerTracker++]) { - mc.renderEngine.func_110577_a(texture); + mc.renderEngine.bindTexture(texture); drawTexturedModalRect(cornerX + slot.x + 17, cornerY + slot.y + 6, 176, 18, 18, 4); } diff --git a/common/buildcraft/transport/render/PipeItemRenderer.java b/common/buildcraft/transport/render/PipeItemRenderer.java index a0ce62a1..29a07364 100644 --- a/common/buildcraft/transport/render/PipeItemRenderer.java +++ b/common/buildcraft/transport/render/PipeItemRenderer.java @@ -25,7 +25,7 @@ public class PipeItemRenderer implements IItemRenderer { Icon icon = ((ItemPipe) Item.itemsList[item.itemID]).getIconFromDamage(0); if (icon == null) - icon = ((TextureMap) Minecraft.getMinecraft().func_110434_K().func_110581_b(TextureMap.field_110575_b)).func_110572_b("missingno"); + icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); block.setBlockBoundsForItemRender(); diff --git a/common/buildcraft/transport/render/RenderPipe.java b/common/buildcraft/transport/render/RenderPipe.java index 2319f511..7c708e5e 100644 --- a/common/buildcraft/transport/render/RenderPipe.java +++ b/common/buildcraft/transport/render/RenderPipe.java @@ -273,7 +273,7 @@ public class RenderPipe extends TileEntitySpecialRenderer { GL11.glTranslatef((float) x, (float) y, (float) z); - func_110628_a(TextureMap.field_110575_b); + bindTexture(TextureMap.locationBlocksTexture); int[] displayList = pow.overload > 0 ? displayPowerListOverload : displayPowerList; @@ -368,7 +368,7 @@ public class RenderPipe extends TileEntitySpecialRenderer { break; default: } - func_110628_a(TextureMap.field_110575_b); + bindTexture(TextureMap.locationBlocksTexture); FluidRenderer.setColorForFluidStack(fluidStack); GL11.glCallList(list); GL11.glPopMatrix(); @@ -383,7 +383,7 @@ public class RenderPipe extends TileEntitySpecialRenderer { if (d != null) { int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1)); - func_110628_a(TextureMap.field_110575_b); + bindTexture(TextureMap.locationBlocksTexture); FluidRenderer.setColorForFluidStack(fluidStack); if (above) { @@ -445,7 +445,7 @@ public class RenderPipe extends TileEntitySpecialRenderer { dummyEntityItem.setEntityItemStack(itemstack); customRenderItem.doRenderItem(dummyEntityItem, 0, 0, 0, 0, 0); if (color != null) { - func_110628_a(TextureMap.field_110575_b); + bindTexture(TextureMap.locationBlocksTexture); BlockInterface block = new BlockInterface(); block.texture = PipeIconProvider.TYPE.ItemBox.getIcon(); From 1253534535a91bdf2cc9d077016a5e22c746dc79 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 6 Sep 2013 15:49:52 -0700 Subject: [PATCH 030/121] Add tooltips to all the Pipes --- build.xml | 2 +- .../lang/buildcraft/en_US.properties | 23 ++++++++++ common/buildcraft/transport/ItemPipe.java | 10 +++-- .../transport/PipeToolTipManager.java | 42 +++++++++++++++++++ 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 common/buildcraft/transport/PipeToolTipManager.java diff --git a/build.xml b/build.xml index c21fb782..e8b38eab 100644 --- a/build.xml +++ b/build.xml @@ -19,7 +19,7 @@ - + diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index a04db9f9..b9cc90b2 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -116,3 +116,26 @@ tile.blockFuel=Fuel tile.spring.water=Water Spring tile.spring.oil=Oil Spring tile.filteredBufferBlock=Filtered Buffer + +tip.PipeFluidsCobblestone=Basic pipe, 10 mB/t\nWon't connect to Stone +tip.PipeFluidsEmerald=Extraction pipe, 40 mB/t +tip.PipeFluidsGold=Basic pipe, 40 mB/t +tip.PipeFluidsIron=Valve pipe, 10 mB/t +tip.PipeFluidsSandstone=Only connects to other pipes, 10 mB/t +tip.PipeFluidsStone=Basic pipe, 10 mB/t\nWon't connect to Cobblestone +tip.PipeFluidsVoid=Destroys fluids, 10 mB/t +tip.PipeFluidsWood=Extraction pipe, 10 mB/t +tip.PipeItemsCobblestone=Basic pipe, high drag\nWon't connect to Stone or Quartz +tip.PipeItemsDaizuli=Routes painted items +tip.PipeItemsDiamond=Sorts items +tip.PipeItemsEmerald=Round-robin extraction pipe +tip.PipeItemsGold=Speeds up items +tip.PipeItemsIron=Routes items +tip.PipeItemsLapis=Paints items +tip.PipeItemsObsidian=Sucks up items +tip.PipeItemsQuartz=Basic pipe, low drag\nWon't connect to Cobblestone or Stone +tip.PipeItemsSandstone=Only connects to other pipes +tip.PipeItemsStone=Basic pipe, medium drag\nWon't connect to Cobblestone or Quartz +tip.PipeItemsVoid=Destroys items +tip.PipeItemsWood=Extraction pipe +tip.PipeStructureCobblestone=Support pipe diff --git a/common/buildcraft/transport/ItemPipe.java b/common/buildcraft/transport/ItemPipe.java index 9eafad8b..fa6e4b80 100644 --- a/common/buildcraft/transport/ItemPipe.java +++ b/common/buildcraft/transport/ItemPipe.java @@ -121,12 +121,16 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { } @Override + @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) { super.addInformation(stack, player, list, advanced); Class pipe = BlockGenericPipe.pipes.get(itemID); - Integer capacity = PipeTransportPower.powerCapacities.get(pipe); - if (capacity != null) { - list.add(String.format("%d MJ/t", capacity)); + String toolTip = PipeToolTipManager.getToolTip(pipe); + if (toolTip != null) { + String[] tips = toolTip.split("\\n"); + for (String tip : tips) { + list.add(tip); + } } } } diff --git a/common/buildcraft/transport/PipeToolTipManager.java b/common/buildcraft/transport/PipeToolTipManager.java new file mode 100644 index 00000000..6b99cc43 --- /dev/null +++ b/common/buildcraft/transport/PipeToolTipManager.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport; + +import buildcraft.core.utils.StringUtils; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author CovertJaguar + */ +@SideOnly(Side.CLIENT) +public class PipeToolTipManager { + + private static final Map, String> toolTips = new HashMap, String>(); + + static { + for (Map.Entry, Integer> pipe : PipeTransportPower.powerCapacities.entrySet()) { + PipeToolTipManager.addToolTip(pipe.getKey(), String.format("%d MJ/t", pipe.getValue())); + } + } + + public static void addToolTip(Class pipe, String toolTip) { + toolTips.put(pipe, toolTip); + } + + public static String getToolTip(Class pipe) { + String tip = toolTips.get(pipe); + if (tip != null) + return tip; + return StringUtils.localize("tip." + pipe.getSimpleName()); + } +} From 87bb24e26372697e11c2defb842d843068d79c2e Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 8 Sep 2013 06:51:21 -0700 Subject: [PATCH 031/121] Fix possible NPE in TankManager --- common/buildcraft/core/fluids/TankManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/core/fluids/TankManager.java b/common/buildcraft/core/fluids/TankManager.java index 25633d1f..0b14f078 100644 --- a/common/buildcraft/core/fluids/TankManager.java +++ b/common/buildcraft/core/fluids/TankManager.java @@ -112,7 +112,7 @@ public class TankManager extends ForwardingList implements IF public void writeData(DataOutputStream data) throws IOException { for (Tank tank : tanks) { FluidStack fluidStack = tank.getFluid(); - if (fluidStack != null) { + if (fluidStack != null && fluidStack.getFluid() != null) { data.writeShort(fluidStack.getFluid().getID()); data.writeInt(fluidStack.amount); } else { From 5e786d8902066f2d208673106f9ba9261c62e2cd Mon Sep 17 00:00:00 2001 From: ddoggy99 Date: Thu, 12 Sep 2013 23:27:11 +1000 Subject: [PATCH 032/121] Cleaned up IMC code --- common/buildcraft/BuildCraftBuilders.java | 7 ++ common/buildcraft/BuildCraftCore.java | 7 ++ common/buildcraft/BuildCraftEnergy.java | 39 +--------- common/buildcraft/BuildCraftFactory.java | 7 ++ common/buildcraft/BuildCraftSilicon.java | 7 ++ common/buildcraft/BuildCraftTransport.java | 25 +------ common/buildcraft/core/InterModComms.java | 87 ++++++++++++++++++++++ 7 files changed, 123 insertions(+), 56 deletions(-) create mode 100644 common/buildcraft/core/InterModComms.java diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index b18cb4a6..0c685382 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -56,6 +56,7 @@ import buildcraft.builders.TileMarker; import buildcraft.builders.TilePathMarker; import buildcraft.builders.network.PacketHandlerBuilders; import buildcraft.core.DefaultProps; +import buildcraft.core.InterModComms; import buildcraft.core.Version; import buildcraft.core.blueprints.BptPlayerIndex; import buildcraft.core.blueprints.BptRootIndex; @@ -64,6 +65,7 @@ import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent; import cpw.mods.fml.common.network.NetworkMod; @@ -331,6 +333,11 @@ public class BuildCraftBuilders { FillerManager.registry.addRecipe(new FillerFillPyramid(), new Object[]{" ", " b ", "bbb", 'g', Block.glass, 'b', Block.brick}); FillerManager.registry.addRecipe(new FillerFillStairs(), new Object[]{" b", " bb", "bbb", 'g', Block.glass, 'b', Block.brick}); } + + @EventHandler + public void processIMCRequests(FMLInterModComms.IMCEvent event) { + InterModComms.processIMC(event); + } public static BptPlayerIndex getPlayerIndex(String name) { BptRootIndex rootIndex = getBptRootIndex(); diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 4fa93c6b..5d8e1da4 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -38,6 +38,7 @@ import buildcraft.core.DefaultProps; import buildcraft.core.EntityEnergyLaser; import buildcraft.core.EntityPowerLaser; import buildcraft.core.EntityRobot; +import buildcraft.core.InterModComms; import buildcraft.core.ItemBuildCraft; import buildcraft.core.ItemSpring; import buildcraft.core.ItemWrench; @@ -67,6 +68,7 @@ import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; @@ -341,4 +343,9 @@ public class BuildCraftCore { GameRegistry.addRecipe(new ItemStack(goldGearItem), " I ", "IGI", " I ", Character.valueOf('I'), Item.ingotGold, Character.valueOf('G'), ironGearItem); GameRegistry.addRecipe(new ItemStack(diamondGearItem), " I ", "IGI", " I ", Character.valueOf('I'), Item.diamond, Character.valueOf('G'), goldGearItem); } + + @EventHandler + public void processIMCRequests(FMLInterModComms.IMCEvent event) { + InterModComms.processIMC(event); + } } diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index cb7b3ca2..872b88d8 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -13,6 +13,7 @@ import buildcraft.api.recipes.RefineryRecipes; import buildcraft.core.BlockIndex; import buildcraft.core.BlockSpring; import buildcraft.core.DefaultProps; +import buildcraft.core.InterModComms; import buildcraft.core.Version; import buildcraft.core.network.PacketHandler; import buildcraft.core.proxy.CoreProxy; @@ -44,8 +45,6 @@ import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.TreeMap; -import java.util.logging.Level; -import java.util.logging.Logger; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.Item; @@ -253,40 +252,10 @@ public class BuildCraftEnergy { Character.valueOf('g'), Block.glass, Character.valueOf('G'), BuildCraftCore.ironGearItem, Character.valueOf('p'), Block.pistonBase}); } - @Mod.IMCCallback + @EventHandler public void processIMCRequests(FMLInterModComms.IMCEvent event) { - for (FMLInterModComms.IMCMessage m : event.getMessages()) { - if (m.key.equals("oil-lake-biome")) { - try { - String biomeID = m.getStringValue().trim(); - int id = Integer.valueOf(biomeID); - if (id >= BiomeGenBase.biomeList.length) { - throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length); - } - OilPopulate.INSTANCE.surfaceDepositBiomes.add(id); - } catch (Exception ex) { - Logger.getLogger("Buildcraft").log(Level.WARNING, - String.format("Received an invalid oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender())); - } - Logger.getLogger("Buildcraft").log(Level.INFO, - String.format("Received an successfull oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender())); - } else if (m.key.equals("oil-gen-exclude")) { - try { - String biomeID = m.getStringValue().trim(); - int id = Integer.valueOf(biomeID); - if (id >= BiomeGenBase.biomeList.length) { - throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length); - } - OilPopulate.INSTANCE.excludedBiomes.add(id); - } catch (Exception ex) { - Logger.getLogger("Buildcraft").log(Level.WARNING, - String.format("Received an invalid oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender())); - } - Logger.getLogger("Buildcraft").log(Level.INFO, - String.format("Received an successfull oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender())); - } - } - } + InterModComms.processIMC(event); + } // public static int createPollution (World world, int i, int j, int k, int // saturation) { // int remainingSaturation = saturation; diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index b5370298..3d75bc94 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -8,6 +8,7 @@ package buildcraft; import buildcraft.core.DefaultProps; +import buildcraft.core.InterModComms; import buildcraft.core.Version; import buildcraft.core.proxy.CoreProxy; import buildcraft.factory.BlockAutoWorkbench; @@ -42,6 +43,7 @@ import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; @@ -317,6 +319,11 @@ public class BuildCraftFactory { 'G', BuildCraftCore.ironGearItem, 'F', new ItemStack(Block.fenceIron)); } + + @EventHandler + public void processIMCRequests(FMLInterModComms.IMCEvent event) { + InterModComms.processIMC(event); + } @ForgeSubscribe @SideOnly(Side.CLIENT) diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 39e0d326..735d164e 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -11,6 +11,7 @@ import buildcraft.api.bptblocks.BptBlockInventory; import buildcraft.api.bptblocks.BptBlockRotateMeta; import buildcraft.api.recipes.AssemblyRecipe; import buildcraft.core.DefaultProps; +import buildcraft.core.InterModComms; import buildcraft.core.ItemRedstoneChipset; import buildcraft.core.Version; import buildcraft.core.proxy.CoreProxy; @@ -27,6 +28,7 @@ import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; @@ -224,4 +226,9 @@ public class BuildCraftSilicon { CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6), "Autarchic Diamond OR Gate"); } + + @EventHandler + public void processIMCRequests(FMLInterModComms.IMCEvent event) { + InterModComms.processIMC(event); + } } diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index e5345e60..9787d97e 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -15,6 +15,7 @@ import buildcraft.api.transport.IPipe; import buildcraft.api.transport.PipeManager; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.DefaultProps; +import buildcraft.core.InterModComms; import buildcraft.core.ItemBuildCraft; import buildcraft.core.Version; import buildcraft.core.proxy.CoreProxy; @@ -84,7 +85,7 @@ import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; @@ -443,26 +444,8 @@ public class BuildCraftTransport { } @EventHandler - public void processIMCRequests(FMLInterModComms.IMCEvent event) { - Splitter splitter = Splitter.on("@").trimResults(); - for (IMCMessage m : event.getMessages()) { - if ("add-facade".equals(m.key)) { - String[] array = Iterables.toArray(splitter.split(m.getStringValue()), String.class); - if (array.length != 2) { - Logger.getLogger("Buildcraft").log(Level.INFO, - String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender())); - continue; - } - Integer blId = Ints.tryParse(array[0]); - Integer metaId = Ints.tryParse(array[1]); - if (blId == null || metaId == null) { - Logger.getLogger("Buildcraft").log(Level.INFO, - String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender())); - continue; - } - ItemFacade.addFacade(new ItemStack(blId, 1, metaId)); - } - } + public void processIMCRequests(IMCEvent event) { + InterModComms.processIMC(event); } public static Item buildPipe(int defaultID, Class clas, String descr, Object... ingredients) { diff --git a/common/buildcraft/core/InterModComms.java b/common/buildcraft/core/InterModComms.java new file mode 100644 index 00000000..e4a56ece --- /dev/null +++ b/common/buildcraft/core/InterModComms.java @@ -0,0 +1,87 @@ +/** + * BuildCraft is open-source. It is distributed under the terms of the + * BuildCraft Open Source License. It grants rights to read, modify, compile or + * run the code. It does *NOT* grant the right to redistribute this software or + * its modifications in any form, binary or source, except if expressively + * granted by the copyright holder. + */ +package buildcraft.core; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.biome.BiomeGenBase; +import buildcraft.energy.worldgen.OilPopulate; +import buildcraft.transport.ItemFacade; + +import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; +import com.google.common.primitives.Ints; + +import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + +public class InterModComms { + + public static void processIMC(IMCEvent event) { + for (IMCMessage m : event.getMessages()) { + if ("add-facade".equals(m.key)) { + processFacadeIMC(event, m); + } else if (m.key.equals("oil-lake-biome")) { + processOilLakeBiomeIMC(event, m); + } else if (m.key.equals("oil-gen-exclude")) { + processOilGenExcludeIMC(event, m); + } + } + } + + public static void processFacadeIMC(IMCEvent event, IMCMessage m) { + try { + Splitter splitter = Splitter.on("@").trimResults(); + + String[] array = Iterables.toArray(splitter.split(m.getStringValue()), String.class); + if (array.length != 2) { + Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender())); + } else { + Integer blId = Ints.tryParse(array[0]); + Integer metaId = Ints.tryParse(array[1]); + if (blId == null || metaId == null) { + Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender())); + } else { + ItemFacade.addFacade(new ItemStack(blId, 1, metaId)); + } + } + } catch (Exception ex) { + + } + } + + public static void processOilLakeBiomeIMC(IMCEvent event, IMCMessage m) { + try { + String biomeID = m.getStringValue().trim(); + int id = Integer.valueOf(biomeID); + if (id >= BiomeGenBase.biomeList.length) { + throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length); + } + OilPopulate.INSTANCE.surfaceDepositBiomes.add(id); + } catch (Exception ex) { + Logger.getLogger("Buildcraft").log(Level.WARNING, String.format("Received an invalid oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender())); + } + Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an successfull oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender())); + } + + public static void processOilGenExcludeIMC(IMCEvent event, IMCMessage m) { + try { + String biomeID = m.getStringValue().trim(); + int id = Integer.valueOf(biomeID); + if (id >= BiomeGenBase.biomeList.length) { + throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length); + } + OilPopulate.INSTANCE.excludedBiomes.add(id); + } catch (Exception ex) { + Logger.getLogger("Buildcraft").log(Level.WARNING, String.format("Received an invalid oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender())); + } + Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an successfull oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender())); + } +} From 880fd64e271eb95d32b4392113b26a915d4f18a5 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 12 Sep 2013 10:57:20 -0700 Subject: [PATCH 033/121] Engines should prefer facing pipes on placement --- common/buildcraft/energy/BlockEngine.java | 5 +++-- common/buildcraft/energy/TileEngine.java | 26 +++++++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/common/buildcraft/energy/BlockEngine.java b/common/buildcraft/energy/BlockEngine.java index 7b76c692..468f86e0 100644 --- a/common/buildcraft/energy/BlockEngine.java +++ b/common/buildcraft/energy/BlockEngine.java @@ -95,7 +95,7 @@ public class BlockEngine extends BlockContainer { public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { TileEntity tile = world.getBlockTileEntity(x, y, z); if (tile instanceof TileEngine) { - return ((TileEngine) tile).switchOrientation(); + return ((TileEngine) tile).switchOrientation(false); } return false; } @@ -127,7 +127,8 @@ public class BlockEngine extends BlockContainer { public void onPostBlockPlaced(World world, int x, int y, int z, int par5) { TileEngine tile = (TileEngine) world.getBlockTileEntity(x, y, z); tile.orientation = ForgeDirection.UP; - tile.switchOrientation(); + if (!tile.isOrientationValid()) + tile.switchOrientation(true); } @Override diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index bc8b5da1..bf247954 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -27,6 +27,7 @@ import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.Type; import buildcraft.api.transport.IPipeConnection; +import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.core.DefaultProps; import buildcraft.core.TileBuffer; @@ -57,7 +58,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public float progress; public float energy; public float heat = MIN_HEAT; - // public @TileNetworkData EnergyStage energyStage = EnergyStage.BLUE; @@ -66,11 +66,11 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public @TileNetworkData boolean isPumping = false; // Used for SMP synch - public TileEngine(){ + public TileEngine() { powerHandler = new PowerHandler(this, Type.ENGINE); powerHandler.configurePowerPerdition(1, 100); } - + @Override public void initialize() { if (!CoreProxy.proxy.isRenderWorld(worldObj)) { @@ -254,7 +254,21 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto sendNetworkUpdate(); } - public boolean switchOrientation() { + public boolean isOrientationValid() { + Position pos = new Position(xCoord, yCoord, zCoord, orientation); + pos.moveForwards(1); + TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z); + + return isPoweredTile(tile, orientation); + } + + public boolean switchOrientation(boolean preferPipe) { + if (preferPipe && switchOrientation_do(true)) + return true; + return switchOrientation_do(false); + } + + private boolean switchOrientation_do(boolean pipesOnly) { for (int i = orientation.ordinal() + 1; i <= orientation.ordinal() + 6; ++i) { ForgeDirection o = ForgeDirection.VALID_DIRECTIONS[i % 6]; @@ -262,7 +276,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto pos.moveForwards(1); TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z); - if (isPoweredTile(tile, o)) { + if ((!pipesOnly || tile instanceof IPipeTile) && isPoweredTile(tile, o)) { orientation = o; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord)); @@ -320,10 +334,8 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto iCrafting.sendProgressBarUpdate(containerEngine, 2, Math.round(currentOutput * 10)); iCrafting.sendProgressBarUpdate(containerEngine, 3, Math.round(heat * 100)); } - public void delete() { - } /* STATE INFORMATION */ From 74fd4093300ae219542daea46cc51fef233639fa Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 12 Sep 2013 11:03:00 -0700 Subject: [PATCH 034/121] Added Mining Config Options Config options added: * Mining Cost Multiplier, scales power usage of both Quarry and Mining Well * Max Depth, limited Quarry/Well to a certain depth below the block * One Time Use Quarries, Quarry doesn't drop an item when broken, get it right the first time (defaults to false) --- common/buildcraft/BuildCraftFactory.java | 26 ++-- common/buildcraft/api/power/PowerHandler.java | 14 ++- common/buildcraft/core/utils/ConfigUtils.java | 115 ++++++++++++++++++ common/buildcraft/factory/BlockQuarry.java | 69 ++++++----- .../factory/FactoryProxyClient.java | 52 ++++---- common/buildcraft/factory/TileMiningWell.java | 9 +- common/buildcraft/factory/TileQuarry.java | 20 +-- 7 files changed, 229 insertions(+), 76 deletions(-) create mode 100644 common/buildcraft/core/utils/ConfigUtils.java diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index 3d75bc94..f79138aa 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -11,6 +11,7 @@ import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.Version; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.ConfigUtils; import buildcraft.factory.BlockAutoWorkbench; import buildcraft.factory.BlockFloodGate; import buildcraft.factory.BlockFrame; @@ -61,12 +62,14 @@ import net.minecraftforge.common.Configuration; import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.Property; import net.minecraftforge.event.ForgeSubscribe; @Mod(name = "BuildCraft Factory", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Factory", dependencies = DefaultProps.DEPENDENCY_CORE) @NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerFactory.class, clientSideRequired = true, serverSideRequired = true) public class BuildCraftFactory { + public static final int MINING_MJ_COST_PER_BLOCK = 64; public static BlockQuarry quarryBlock; public static BlockMiningWell miningWellBlock; public static BlockAutoWorkbench autoWorkbenchBlock; @@ -77,8 +80,10 @@ public class BuildCraftFactory { public static BlockTank tankBlock; public static BlockRefinery refineryBlock; public static BlockHopper hopperBlock; - public static boolean hopperDisabled; public static boolean allowMining = true; + public static boolean quarryOneTimeUse = false; + public static float miningMultiplier = 1; + public static int miningDepth = 256; public static PumpDimensionList pumpDimensionList; @Instance("BuildCraft|Factory") public static BuildCraftFactory instance; @@ -133,10 +138,7 @@ public class BuildCraftFactory { CoreProxy.proxy.registerTileEntity(TileFloodGate.class, "net.minecraft.src.buildcraft.factory.TileFloodGate"); CoreProxy.proxy.registerTileEntity(TileTank.class, "net.minecraft.src.buildcraft.factory.TileTank"); CoreProxy.proxy.registerTileEntity(TileRefinery.class, "net.minecraft.src.buildcraft.factory.Refinery"); - - if (!hopperDisabled) { - CoreProxy.proxy.registerTileEntity(TileHopper.class, "net.minecraft.src.buildcraft.factory.TileHopper"); - } + CoreProxy.proxy.registerTileEntity(TileHopper.class, "net.minecraft.src.buildcraft.factory.TileHopper"); FactoryProxy.proxy.initializeTileEntities(); @@ -152,9 +154,19 @@ public class BuildCraftFactory { @EventHandler public void initialize(FMLPreInitializationEvent evt) { - allowMining = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "mining.enabled", true).getBoolean(true); + ConfigUtils genCat = new ConfigUtils(BuildCraftCore.mainConfiguration, Configuration.CATEGORY_GENERAL); - pumpDimensionList = new PumpDimensionList(BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pumping.controlList", DefaultProps.PUMP_DIMENSION_LIST).getString()); + allowMining = genCat.get("mining.enabled", true, "disables the recipes for automated mining machines"); + quarryOneTimeUse = genCat.get("quarry.one.time.use", false, "Quarry cannot be picked back up after placement"); + miningMultiplier = genCat.get("mining.cost.multipler", 1F, 1F, 10F, "cost multiplier for mining operations, range (1.0 - 10.0)\nhigh values may render engines incapable of powering machines directly"); + miningDepth = genCat.get("mining.depth", 2, 256, 256, "how far below the machine can mining machines dig, range (2 - 256), default 256"); + + Property pumpList = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pumping.controlList", DefaultProps.PUMP_DIMENSION_LIST); + pumpList.comment = "Allows admins to whitelist or blacklist pumping of specific fluids in specific dimensions.\n" + + "Eg. \"-/-1/Lava\" will disable lava in the nether. \"-/*/Lava\" will disable lava in any dimension. \"+/0/*\" will enable any fluid in the overworld.\n" + + "Entries are comma seperated, banned fluids have precedence over allowed ones." + + "Default is \"+/*/*,+/-1/Lava\" - the second redundant entry (\"+/-1/Lava\") is there to show the format."; + pumpDimensionList = new PumpDimensionList(pumpList.getString()); int miningWellId = BuildCraftCore.mainConfiguration.getBlock("miningWell.id", DefaultProps.MINING_WELL_ID).getInt(DefaultProps.MINING_WELL_ID); int plainPipeId = BuildCraftCore.mainConfiguration.getBlock("drill.id", DefaultProps.DRILL_ID).getInt(DefaultProps.DRILL_ID); diff --git a/common/buildcraft/api/power/PowerHandler.java b/common/buildcraft/api/power/PowerHandler.java index bc23ebda..6965122b 100644 --- a/common/buildcraft/api/power/PowerHandler.java +++ b/common/buildcraft/api/power/PowerHandler.java @@ -23,7 +23,7 @@ public final class PowerHandler { case STORAGE: return true; default: - return false; + return false; } } @@ -33,11 +33,16 @@ public final class PowerHandler { case STORAGE: return true; default: - return false; + return false; } } } + /** + * Extend this class to create custom Perdition algorithms (its not final). + * + * NOTE: It is not possible to create a Zero perdition algorithm. + */ public static class PerditionCalculator { public static final float DEFAULT_POWERLOSS = 1F; @@ -48,6 +53,11 @@ public final class PowerHandler { powerLoss = DEFAULT_POWERLOSS; } + /** + * Simple constructor for simple Perdition per tick. + * + * @param powerLoss power loss per tick + */ public PerditionCalculator(float powerLoss) { if (powerLoss < MIN_POWERLOSS) { powerLoss = MIN_POWERLOSS; diff --git a/common/buildcraft/core/utils/ConfigUtils.java b/common/buildcraft/core/utils/ConfigUtils.java new file mode 100644 index 00000000..df4cfde7 --- /dev/null +++ b/common/buildcraft/core/utils/ConfigUtils.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.utils; + +import buildcraft.BuildCraftCore; +import java.util.logging.Level; +import net.minecraftforge.common.Configuration; +import net.minecraftforge.common.Property; + +/** + * + * @author CovertJaguar + */ +public class ConfigUtils { + + private static final String COMMENT_PREFIX = ""; + private static final String COMMENT_SUFFIX = ""; + private final Configuration config; + private final String cat; + + public ConfigUtils(Configuration config, String cat) { + this.config = config; + this.cat = cat; + } + + public boolean get(String tag, boolean defaultValue, String comment) { + return get(tag, defaultValue, false, comment); + } + + public boolean get(String tag, boolean defaultValue, boolean reset, String comment) { + comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; + Property prop = config.get(cat, tag, defaultValue); + prop.comment = comment; + boolean ret = parseBoolean(prop, defaultValue); + if (reset) + prop.set(defaultValue); + return ret; + } + + public int get(String tag, int defaultValue, String comment) { + comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; + Property prop = config.get(cat, tag, defaultValue); + prop.comment = comment; + return parseInteger(prop, defaultValue); + } + + public int get(String tag, int min, int defaultValue, int max, String comment) { + comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; + Property prop = config.get(cat, tag, defaultValue); + prop.comment = comment; + int parsed = parseInteger(prop, defaultValue); + int clamped = Math.max(parsed, min); + clamped = Math.min(clamped, max); + if (clamped != parsed) + prop.set(clamped); + return clamped; + } + + public float get(String tag, float min, float defaultValue, float max, String comment) { + comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX; + Property prop = config.get(cat, tag, defaultValue); + prop.comment = comment; + double parsed = parseDouble(prop, defaultValue); + double clamped = Math.max(parsed, min); + clamped = Math.min(clamped, max); + if (clamped != parsed) + prop.set(clamped); + return (float) clamped; + } + + private boolean parseBoolean(Property prop, boolean defaultValue) { + String value = prop.getString(); + boolean parsed; + try { + parsed = Boolean.parseBoolean(value); + } catch (NumberFormatException ex) { + BuildCraftCore.bcLog.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex); + prop.set(defaultValue); + return defaultValue; + } + return parsed; + } + + private int parseInteger(Property prop, int defaultValue) { + String value = prop.getString(); + int parsed; + try { + parsed = Integer.parseInt(value); + } catch (NumberFormatException ex) { + BuildCraftCore.bcLog.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex); + prop.set(defaultValue); + return defaultValue; + } + return parsed; + } + + private double parseDouble(Property prop, double defaultValue) { + String value = prop.getString(); + double parsed; + try { + parsed = Double.parseDouble(value); + } catch (NumberFormatException ex) { + BuildCraftCore.bcLog.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex); + prop.set(defaultValue); + return defaultValue; + } + return parsed; + } +} diff --git a/common/buildcraft/factory/BlockQuarry.java b/common/buildcraft/factory/BlockQuarry.java index ecee8fbd..d5e15f03 100644 --- a/common/buildcraft/factory/BlockQuarry.java +++ b/common/buildcraft/factory/BlockQuarry.java @@ -1,12 +1,10 @@ /** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com + * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public License + * 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.factory; import buildcraft.BuildCraftFactory; @@ -49,7 +47,7 @@ public class BlockQuarry extends BlockMachineRoot { ForgeDirection orientation = Utils.get2dOrientation(new Position(entityliving.posX, entityliving.posY, entityliving.posZ), new Position(i, j, k)); - world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(),1); + world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1); if (entityliving instanceof EntityPlayer) { TileQuarry tq = (TileQuarry) world.getBlockTileEntity(i, j, k); tq.placedBy = (EntityPlayer) entityliving; @@ -62,14 +60,14 @@ public class BlockQuarry extends BlockMachineRoot { if (j == 0 && i == 3) return textureFront; - if (i == j && i>1) // Front can't be top or bottom. + if (i == j && i > 1) // Front can't be top or bottom. return textureFront; switch (i) { - case 1: - return textureTop; - default: - return textureSide; + case 1: + return textureTop; + default: + return textureSide; } } @@ -91,25 +89,25 @@ public class BlockQuarry extends BlockMachineRoot { int meta = world.getBlockMetadata(i, j, k); if ((meta & 8) == 0) { - world.setBlockMetadataWithNotify(i, j, k, meta | 8,0); + world.setBlockMetadataWithNotify(i, j, k, meta | 8, 0); ForgeDirection[] dirs = ForgeDirection.VALID_DIRECTIONS; for (ForgeDirection dir : dirs) { switch (dir) { - case UP: - searchFrames(world, i, j + 1, k); - case DOWN: - searchFrames(world, i, j - 1, k); - case SOUTH: - searchFrames(world, i, j, k + 1); - case NORTH: - searchFrames(world, i, j, k - 1); - case EAST: - searchFrames(world, i + 1, j, k); - case WEST: - default: - searchFrames(world, i - 1, j, k); + case UP: + searchFrames(world, i, j + 1, k); + case DOWN: + searchFrames(world, i, j - 1, k); + case SOUTH: + searchFrames(world, i, j, k + 1); + case NORTH: + searchFrames(world, i, j, k - 1); + case EAST: + searchFrames(world, i + 1, j, k); + case WEST: + default: + searchFrames(world, i - 1, j, k); } } } @@ -117,10 +115,18 @@ public class BlockQuarry extends BlockMachineRoot { private void markFrameForDecay(World world, int x, int y, int z) { if (world.getBlockId(x, y, z) == BuildCraftFactory.frameBlock.blockID) { - world.setBlockMetadataWithNotify(x, y, z, 1,0); + world.setBlockMetadataWithNotify(x, y, z, 1, 0); } } + @Override + public ArrayList getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) { + if (BuildCraftFactory.quarryOneTimeUse) { + return new ArrayList(); + } + return super.getBlockDropped(world, x, y, z, metadata, fortune); + } + @Override public void breakBlock(World world, int i, int j, int k, int par5, int par6) { @@ -214,7 +220,7 @@ public class BlockQuarry extends BlockMachineRoot { return false; } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) @Override public void addCreativeItems(ArrayList itemList) { itemList.add(new ItemStack(this)); @@ -222,10 +228,9 @@ public class BlockQuarry extends BlockMachineRoot { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) - { - textureSide = par1IconRegister.registerIcon("buildcraft:quarry_side"); - textureTop = par1IconRegister.registerIcon("buildcraft:quarry_top"); - textureFront = par1IconRegister.registerIcon("buildcraft:quarry_front"); + public void registerIcons(IconRegister par1IconRegister) { + textureSide = par1IconRegister.registerIcon("buildcraft:quarry_side"); + textureTop = par1IconRegister.registerIcon("buildcraft:quarry_top"); + textureFront = par1IconRegister.registerIcon("buildcraft:quarry_front"); } } diff --git a/common/buildcraft/factory/FactoryProxyClient.java b/common/buildcraft/factory/FactoryProxyClient.java index daebdc08..11ef2cd8 100644 --- a/common/buildcraft/factory/FactoryProxyClient.java +++ b/common/buildcraft/factory/FactoryProxyClient.java @@ -17,18 +17,25 @@ import net.minecraft.util.Icon; import net.minecraft.world.World; public class FactoryProxyClient extends FactoryProxy { - public static Icon pumpTexture; - public static Icon drillTexture; - public static Icon drillHeadTexture; - @Override + public static Icon pumpTexture; + public static Icon drillTexture; + public static Icon drillHeadTexture; + + @Override public void initializeTileEntities() { super.initializeTileEntities(); - ClientRegistry.bindTileEntitySpecialRenderer(TileTank.class, new RenderTank()); - ClientRegistry.bindTileEntitySpecialRenderer(TileRefinery.class, new RenderRefinery()); - RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftFactory.refineryBlock, 0), new RenderRefinery()); - if (!BuildCraftFactory.hopperDisabled) { + if (BuildCraftFactory.tankBlock != null) { + ClientRegistry.bindTileEntitySpecialRenderer(TileTank.class, new RenderTank()); + } + + if (BuildCraftFactory.refineryBlock != null) { + ClientRegistry.bindTileEntitySpecialRenderer(TileRefinery.class, new RenderRefinery()); + RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftFactory.refineryBlock, 0), new RenderRefinery()); + } + + if (BuildCraftFactory.hopperBlock != null) { ClientRegistry.bindTileEntitySpecialRenderer(TileHopper.class, new RenderHopper()); RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftFactory.hopperBlock, 0), new RenderHopper()); } @@ -53,26 +60,23 @@ public class FactoryProxyClient extends FactoryProxy { } @Override - public EntityBlock newPumpTube(World w) - { - EntityBlock eb = super.newPumpTube(w); - eb.texture = pumpTexture; - return eb; + public EntityBlock newPumpTube(World w) { + EntityBlock eb = super.newPumpTube(w); + eb.texture = pumpTexture; + return eb; } @Override - public EntityBlock newDrill(World w, double i, double j, double k, double l, double d, double e) - { - EntityBlock eb = super.newDrill(w, i, j, k, l, d, e); - eb.texture = drillTexture; - return eb; + public EntityBlock newDrill(World w, double i, double j, double k, double l, double d, double e) { + EntityBlock eb = super.newDrill(w, i, j, k, l, d, e); + eb.texture = drillTexture; + return eb; } @Override - public EntityBlock newDrillHead(World w, double i, double j, double k, double l, double d, double e) - { - EntityBlock eb = super.newDrillHead(w, i, j, k, l, d, e); - eb.texture = drillHeadTexture; - return eb; - } + public EntityBlock newDrillHead(World w, double i, double j, double k, double l, double d, double e) { + EntityBlock eb = super.newDrillHead(w, i, j, k, l, d, e); + eb.texture = drillHeadTexture; + return eb; + } } diff --git a/common/buildcraft/factory/TileMiningWell.java b/common/buildcraft/factory/TileMiningWell.java index ba4d5257..03c8b3fd 100644 --- a/common/buildcraft/factory/TileMiningWell.java +++ b/common/buildcraft/factory/TileMiningWell.java @@ -31,7 +31,9 @@ public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerRe public TileMiningWell() { powerHandler = new PowerHandler(this, Type.MACHINE); - powerHandler.configure(100, 100, 60, 1000); + + float mj = BuildCraftFactory.MINING_MJ_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier; + powerHandler.configure(100 * BuildCraftFactory.miningMultiplier, 100 * BuildCraftFactory.miningMultiplier, mj, 1000 * BuildCraftFactory.miningMultiplier); powerHandler.configurePowerPerdition(1, 1); } @@ -41,7 +43,8 @@ public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerRe */ @Override public void doWork(PowerHandler workProvider) { - if (powerHandler.useEnergy(60, 60, true) != 60) + float mj = BuildCraftFactory.MINING_MJ_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier; + if (powerHandler.useEnergy(mj, mj, true) != mj) return; World world = worldObj; @@ -52,7 +55,7 @@ public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerRe depth = depth - 1; } - if (depth < 1 || !BlockUtil.canChangeBlock(world, xCoord, depth, zCoord)) { + if (depth < 1 || depth < yCoord - BuildCraftFactory.miningDepth || !BlockUtil.canChangeBlock(world, xCoord, depth, zCoord)) { isDigging = false; return; } diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index d3bd38d6..5fb97dbc 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -72,6 +72,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept public PowerHandler powerHandler; boolean isDigging = false; public static final int MAX_ENERGY = 15000; + private static final PowerHandler.PerditionCalculator PERDITION = new PowerHandler.PerditionCalculator(2 * BuildCraftFactory.miningMultiplier); public TileQuarry() { powerHandler = new PowerHandler(this, PowerHandler.Type.MACHINE); @@ -79,8 +80,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } private void initPowerProvider() { - powerHandler.configure(50, 100, 25, MAX_ENERGY); - powerHandler.configurePowerPerdition(2, 1); + float mj = 25 * BuildCraftFactory.miningMultiplier; + powerHandler.configure(50 * BuildCraftFactory.miningMultiplier, 100 * BuildCraftFactory.miningMultiplier, mj, MAX_ENERGY * BuildCraftFactory.miningMultiplier); + powerHandler.setPerdition(PERDITION); } public void createUtilsIfNeeded() { @@ -194,9 +196,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } protected void buildFrame() { - - powerHandler.configure(50, 100, 25, MAX_ENERGY); - if (powerHandler.useEnergy(25, 25, true) != 25) + float mj = 25 * BuildCraftFactory.miningMultiplier; + powerHandler.configure(50 * BuildCraftFactory.miningMultiplier, 100 * BuildCraftFactory.miningMultiplier, mj, MAX_ENERGY * BuildCraftFactory.miningMultiplier); + if (powerHandler.useEnergy(mj, mj, true) != mj) return; if (builder == null) { @@ -210,8 +212,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } protected void dig() { - powerHandler.configure(100, 500, 60, MAX_ENERGY); - if (powerHandler.useEnergy(60, 60, true) != 60) + powerHandler.configure(100 * BuildCraftFactory.miningMultiplier, 500 * BuildCraftFactory.miningMultiplier, BuildCraftFactory.MINING_MJ_COST_PER_BLOCK, MAX_ENERGY * BuildCraftFactory.miningMultiplier); + + float mj = BuildCraftFactory.MINING_MJ_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier; + if (powerHandler.useEnergy(mj, mj, true) != mj) return; if (!findTarget(true)) { @@ -278,7 +282,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept Integer[][] columnHeights = new Integer[bluePrintBuilder.bluePrint.sizeX - 2][bluePrintBuilder.bluePrint.sizeZ - 2]; boolean[][] blockedColumns = new boolean[bluePrintBuilder.bluePrint.sizeX - 2][bluePrintBuilder.bluePrint.sizeZ - 2]; - for (int searchY = yCoord + 3; searchY >= 0; --searchY) { + for (int searchY = yCoord + 3; searchY >= 1 && searchY >= yCoord - BuildCraftFactory.miningDepth; --searchY) { int startX, endX, incX; if (searchY % 2 == 0) { From f0c1e7467f94efb75763941a59e7b6a529f91650 Mon Sep 17 00:00:00 2001 From: SirSengir Date: Fri, 13 Sep 2013 10:00:45 +0200 Subject: [PATCH 035/121] Clarify handling of code cleanup/formatting PRs. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d137b77b..cb3bf9b7 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ If you wish to submit a pull request to fix bugs or broken behaviour feel free to do so. If you would like to add features or change existing behaviour or balance, please discuss it with Sengir or Krapht before submiting the pull request. +Do not submit pull requests which solely "fix" formatting. As these kinds of changes are usually very intrusive in commit history and everyone has their own idea what "proper formatting" is, they should be done by one of the main contributors. +Please only submit "code cleanup", if the changes actually have a substantial impact on readability. + ### Reporting issues * Before reporting an issue, please check that it has not been reported before. * Issues are for bugs/crashes, please do not use them to ask general questions. From 56d46de1beb18545a55b8fefbf154cf20e9b05f0 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 13 Sep 2013 20:46:51 -0700 Subject: [PATCH 036/121] Wooden Power Pipes can no longer output power Prevents power loops when a machine both emits and accepts power. Closes #1202 --- .../transport/IPipeTransportPowerHook.java | 8 +++++++ .../transport/PipeTransportPower.java | 15 ++++++------ .../transport/pipes/PipePowerWood.java | 24 +++++++++++++++---- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/common/buildcraft/transport/IPipeTransportPowerHook.java b/common/buildcraft/transport/IPipeTransportPowerHook.java index 28cc3450..898019ca 100644 --- a/common/buildcraft/transport/IPipeTransportPowerHook.java +++ b/common/buildcraft/transport/IPipeTransportPowerHook.java @@ -13,7 +13,15 @@ import net.minecraftforge.common.ForgeDirection; public interface IPipeTransportPowerHook { + /** + * Override default behavior on receiving energy into the pipe. + * + * @return The amount of power used, or -1 for default behavior. + */ public float receiveEnergy(ForgeDirection from, float val); + /** + * Override default requested power. + */ public float requestEnergy(ForgeDirection from, float amount); } diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index 13d59ed9..0f2937d7 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -321,14 +321,15 @@ public class PipeTransportPower extends PipeTransport { step(); if (this.container.pipe instanceof IPipeTransportPowerHook) { - return ((IPipeTransportPowerHook) this.container.pipe).receiveEnergy(from, val); - } else { - internalNextPower[from.ordinal()] += val; + float ret = ((IPipeTransportPowerHook) this.container.pipe).receiveEnergy(from, val); + if (ret >= 0) + return ret; + } + internalNextPower[from.ordinal()] += val; - if (internalNextPower[from.ordinal()] > maxPower) { - val -= internalNextPower[from.ordinal()] - maxPower; - internalNextPower[from.ordinal()] = maxPower; - } + if (internalNextPower[from.ordinal()] > maxPower) { + val -= internalNextPower[from.ordinal()] - maxPower; + internalNextPower[from.ordinal()] = maxPower; } return val; } diff --git a/common/buildcraft/transport/pipes/PipePowerWood.java b/common/buildcraft/transport/pipes/PipePowerWood.java index c9aa769b..433224d3 100644 --- a/common/buildcraft/transport/pipes/PipePowerWood.java +++ b/common/buildcraft/transport/pipes/PipePowerWood.java @@ -13,6 +13,8 @@ import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.Type; +import buildcraft.api.transport.IPipeTile; +import buildcraft.transport.IPipeTransportPowerHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; @@ -21,8 +23,7 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.ForgeDirection; - -public class PipePowerWood extends Pipe implements IPowerReceptor { +public class PipePowerWood extends Pipe implements IPowerReceptor, IPipeTransportPowerHook { private PowerHandler powerHandler; protected int standardIconIndex = PipeIconProvider.TYPE.PipePowerWood_Standard.ordinal(); @@ -108,9 +109,9 @@ public class PipePowerWood extends Pipe implements IPowerRec float energyUsable = powerHandler.useEnergy(0, energyToRemove, false); - float energySend = transport.receiveEnergy(o, energyUsable); - if (energySend > 0) { - powerHandler.useEnergy(0, energySend, true); + float energySent = transport.receiveEnergy(o, energyUsable); + if (energySent > 0) { + powerHandler.useEnergy(0, energySent, true); } } } @@ -145,4 +146,17 @@ public class PipePowerWood extends Pipe implements IPowerRec powerSources[i] = data.getBoolean("powerSources[" + i + "]"); } } + + @Override + public float receiveEnergy(ForgeDirection from, float val) { + return -1; + } + + @Override + public float requestEnergy(ForgeDirection from, float amount) { + if (container.getTile(from) instanceof IPipeTile) { + return amount; + } + return 0; + } } From 2d651297221a50afe0697d9eb31ad48e0fa039b0 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 15 Sep 2013 00:38:55 -0700 Subject: [PATCH 037/121] More tweaks to improve mobility of blocks --- common/buildcraft/energy/TileEngine.java | 38 +++++++++++++------ .../buildcraft/transport/TileGenericPipe.java | 2 +- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index bf247954..4e89fe32 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -54,7 +54,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto protected PowerHandler powerHandler; public float currentOutput = 0; public boolean isRedstonePowered = false; - public TileBuffer[] tileCache; + private TileBuffer[] tileCache; public float progress; public float energy; public float heat = MIN_HEAT; @@ -74,7 +74,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto @Override public void initialize() { if (!CoreProxy.proxy.isRenderWorld(worldObj)) { - tileCache = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, true); powerHandler.configure(minEnergyReceived(), maxEnergyReceived(), 1, getMaxEnergy()); checkRedstonePower(); } @@ -173,7 +172,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto updateHeatLevel(); engineUpdate(); - TileEntity tile = tileCache[orientation.ordinal()].getTile(); + TileEntity tile = getTileBuffer(orientation).getTile(); if (progressPart != 0) { progress += getPistonSpeed(); @@ -206,14 +205,14 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto } private float getPowerToExtract() { - TileEntity tile = tileCache[orientation.ordinal()].getTile(); + TileEntity tile = getTileBuffer(orientation).getTile(); PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite()); return extractEnergy(receptor.getMinEnergyReceived(), receptor.getMaxEnergyReceived(), false); // Comment out for constant power // return extractEnergy(0, getActualOutput(), false); // Uncomment for constant power } private void sendPower() { - TileEntity tile = tileCache[orientation.ordinal()].getTile(); + TileEntity tile = getTileBuffer(orientation).getTile(); if (isPoweredTile(tile, orientation)) { PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite()); @@ -255,10 +254,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto } public boolean isOrientationValid() { - Position pos = new Position(xCoord, yCoord, zCoord, orientation); - pos.moveForwards(1); - TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z); - + TileEntity tile = getTileBuffer(orientation).getTile(); return isPoweredTile(tile, orientation); } @@ -272,9 +268,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto for (int i = orientation.ordinal() + 1; i <= orientation.ordinal() + 6; ++i) { ForgeDirection o = ForgeDirection.VALID_DIRECTIONS[i % 6]; - Position pos = new Position(xCoord, yCoord, zCoord, o); - pos.moveForwards(1); - TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z); + TileEntity tile = getTileBuffer(o).getTile(); if ((!pipesOnly || tile instanceof IPipeTile) && isPoweredTile(tile, o)) { orientation = o; @@ -287,6 +281,26 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto return false; } + public TileBuffer getTileBuffer(ForgeDirection side) { + if (tileCache == null) + tileCache = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, false); + return tileCache[side.ordinal()]; + } + + @Override + public void invalidate() { + super.invalidate(); + tileCache = null; + } + + @Override + public void validate() { + super.validate(); + tileCache = null; + if (!isOrientationValid()) + switchOrientation(true); + } + @Override public void readFromNBT(NBTTagCompound data) { super.readFromNBT(data); diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 14a13bf5..591102fb 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -35,7 +35,6 @@ import cpw.mods.fml.relauncher.SideOnly; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.util.Arrays; import java.util.LinkedList; import java.util.logging.Level; import net.minecraft.block.Block; @@ -140,6 +139,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui @Override public void validate() { super.validate(); + initialized = false; tileBuffer = null; bindPipe(); if (pipe != null) From 08c4bc3f47b99db845ad8da04ce54ddda2f99a92 Mon Sep 17 00:00:00 2001 From: ganymedes01 Date: Sun, 15 Sep 2013 21:40:27 +0100 Subject: [PATCH 038/121] Fix for sandstone pipes --- .../transport/IPipeConnectionForced.java | 14 ++++++ .../buildcraft/transport/TileGenericPipe.java | 47 ++++++++++--------- .../transport/pipes/PipeFluidsSandstone.java | 14 ++++-- .../transport/pipes/PipeItemsSandstone.java | 12 +++-- 4 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 common/buildcraft/transport/IPipeConnectionForced.java diff --git a/common/buildcraft/transport/IPipeConnectionForced.java b/common/buildcraft/transport/IPipeConnectionForced.java new file mode 100644 index 00000000..209e5c31 --- /dev/null +++ b/common/buildcraft/transport/IPipeConnectionForced.java @@ -0,0 +1,14 @@ +package buildcraft.transport; + +import net.minecraftforge.common.ForgeDirection; + +public interface IPipeConnectionForced { + + /** + * Allows you to block connection overrides. + * + * @param with + * @return TRUE to block an override. FALSE to allow overrides. + */ + public boolean ignoreConnectionOverrides(ForgeDirection with); +} diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 591102fb..5ae87c2e 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -7,6 +7,24 @@ */ package buildcraft.transport; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.LinkedList; +import java.util.logging.Level; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.packet.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; @@ -17,6 +35,7 @@ import buildcraft.api.gates.ITrigger; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; +import buildcraft.transport.IPipeConnectionForced; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipeConnection; import buildcraft.api.transport.IPipeTile; @@ -32,23 +51,6 @@ import buildcraft.core.network.PacketTileState; import buildcraft.transport.Gate.GateKind; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.LinkedList; -import java.util.logging.Level; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.packet.Packet; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFluidHandler, IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, IDropControlInventory, IPipeRenderState, ISyncedTile, ISolidSideTile { @@ -425,11 +427,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui if (!BlockGenericPipe.isValid(pipe)) return false; - if (with instanceof IPipeConnection) { - IPipeConnection.ConnectOverride override = ((IPipeConnection) with).overridePipeConnection(pipe.transport.getPipeType(), side.getOpposite()); - if (override != IPipeConnection.ConnectOverride.DEFAULT) - return override == IPipeConnection.ConnectOverride.CONNECT ? true : false; - } + if(!(pipe instanceof IPipeConnectionForced) || !((IPipeConnectionForced) pipe).ignoreConnectionOverrides(side)) + if (with instanceof IPipeConnection) { + IPipeConnection.ConnectOverride override = ((IPipeConnection) with).overridePipeConnection(pipe.transport.getPipeType(), side.getOpposite()); + if (override != IPipeConnection.ConnectOverride.DEFAULT) + return override == IPipeConnection.ConnectOverride.CONNECT ? true : false; + } if (with instanceof TileGenericPipe) { if (((TileGenericPipe) with).hasPlug(side.getOpposite())) diff --git a/common/buildcraft/transport/pipes/PipeFluidsSandstone.java b/common/buildcraft/transport/pipes/PipeFluidsSandstone.java index 70b9c63b..1483426c 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsSandstone.java +++ b/common/buildcraft/transport/pipes/PipeFluidsSandstone.java @@ -7,8 +7,12 @@ */ package buildcraft.transport.pipes; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; +import buildcraft.transport.IPipeConnectionForced; import buildcraft.transport.IPipeTransportFluidsHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; @@ -16,11 +20,8 @@ import buildcraft.transport.PipeTransportFluids; import buildcraft.transport.TileGenericPipe; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -public class PipeFluidsSandstone extends Pipe implements IPipeTransportFluidsHook { +public class PipeFluidsSandstone extends Pipe implements IPipeTransportFluidsHook, IPipeConnectionForced { public PipeFluidsSandstone(int itemID) { super(new PipeTransportFluids(), itemID); @@ -49,4 +50,9 @@ public class PipeFluidsSandstone extends Pipe implements IP public boolean canPipeConnect(TileEntity tile, ForgeDirection side) { return (tile instanceof TileGenericPipe) && super.canPipeConnect(tile, side); } + + @Override + public boolean ignoreConnectionOverrides(ForgeDirection with) { + return true; + } } diff --git a/common/buildcraft/transport/pipes/PipeItemsSandstone.java b/common/buildcraft/transport/pipes/PipeItemsSandstone.java index fe53d0c8..6e23d15a 100644 --- a/common/buildcraft/transport/pipes/PipeItemsSandstone.java +++ b/common/buildcraft/transport/pipes/PipeItemsSandstone.java @@ -7,18 +7,19 @@ */ package buildcraft.transport.pipes; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; +import buildcraft.transport.IPipeConnectionForced; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TileGenericPipe; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; -public class PipeItemsSandstone extends Pipe { +public class PipeItemsSandstone extends Pipe implements IPipeConnectionForced { public PipeItemsSandstone(int itemID) { super(new PipeTransportItems(), itemID); @@ -39,4 +40,9 @@ public class PipeItemsSandstone extends Pipe { public boolean canPipeConnect(TileEntity tile, ForgeDirection side) { return (tile instanceof TileGenericPipe) && super.canPipeConnect(tile, side); } + + @Override + public boolean ignoreConnectionOverrides(ForgeDirection with) { + return true; + } } From 1aaa35c5b10c8b9d9f2801194a44cfa8aebd0007 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 15 Sep 2013 23:18:14 -0700 Subject: [PATCH 039/121] Increase hardness of blocks --- common/buildcraft/builders/BlockArchitect.java | 2 +- common/buildcraft/builders/BlockBlueprintLibrary.java | 2 +- common/buildcraft/builders/BlockBuilder.java | 2 +- common/buildcraft/builders/BlockFiller.java | 2 +- common/buildcraft/energy/BlockEngine.java | 2 +- common/buildcraft/factory/BlockAutoWorkbench.java | 2 +- common/buildcraft/factory/BlockMachineRoot.java | 1 + common/buildcraft/factory/BlockMiningWell.java | 2 +- common/buildcraft/factory/BlockQuarry.java | 2 +- common/buildcraft/factory/BlockRefinery.java | 2 +- common/buildcraft/silicon/BlockLaser.java | 2 +- common/buildcraft/silicon/BlockLaserTable.java | 2 +- 12 files changed, 12 insertions(+), 11 deletions(-) diff --git a/common/buildcraft/builders/BlockArchitect.java b/common/buildcraft/builders/BlockArchitect.java index 06f9c3f4..b9c29da9 100644 --- a/common/buildcraft/builders/BlockArchitect.java +++ b/common/buildcraft/builders/BlockArchitect.java @@ -41,7 +41,7 @@ public class BlockArchitect extends BlockContainer { public BlockArchitect(int i) { super(i, Material.iron); - setHardness(0.5F); + setHardness(5F); //setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); } diff --git a/common/buildcraft/builders/BlockBlueprintLibrary.java b/common/buildcraft/builders/BlockBlueprintLibrary.java index 7ccf77d0..31026b61 100644 --- a/common/buildcraft/builders/BlockBlueprintLibrary.java +++ b/common/buildcraft/builders/BlockBlueprintLibrary.java @@ -33,7 +33,7 @@ public class BlockBlueprintLibrary extends BlockContainer { public BlockBlueprintLibrary(int i) { super(i, Material.wood); //setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); - setHardness(0.7F); + setHardness(5F); } @Override diff --git a/common/buildcraft/builders/BlockBuilder.java b/common/buildcraft/builders/BlockBuilder.java index 5eae766c..bdf20b08 100644 --- a/common/buildcraft/builders/BlockBuilder.java +++ b/common/buildcraft/builders/BlockBuilder.java @@ -37,7 +37,7 @@ public class BlockBuilder extends BlockContainer { public BlockBuilder(int i) { super(i, Material.iron); - setHardness(0.7F); + setHardness(5F); setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); } diff --git a/common/buildcraft/builders/BlockFiller.java b/common/buildcraft/builders/BlockFiller.java index 0c223c17..32c7aae7 100644 --- a/common/buildcraft/builders/BlockFiller.java +++ b/common/buildcraft/builders/BlockFiller.java @@ -38,7 +38,7 @@ public class BlockFiller extends BlockContainer { public BlockFiller(int i) { super(i, Material.iron); - setHardness(0.5F); + setHardness(5F); setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); } diff --git a/common/buildcraft/energy/BlockEngine.java b/common/buildcraft/energy/BlockEngine.java index 468f86e0..f5275da1 100644 --- a/common/buildcraft/energy/BlockEngine.java +++ b/common/buildcraft/energy/BlockEngine.java @@ -34,7 +34,7 @@ public class BlockEngine extends BlockContainer { public BlockEngine(int i) { super(i, Material.iron); - setHardness(0.5F); + setHardness(5F); setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); setUnlocalizedName("engineBlock"); } diff --git a/common/buildcraft/factory/BlockAutoWorkbench.java b/common/buildcraft/factory/BlockAutoWorkbench.java index 83a7b4a4..45e1e90e 100644 --- a/common/buildcraft/factory/BlockAutoWorkbench.java +++ b/common/buildcraft/factory/BlockAutoWorkbench.java @@ -32,7 +32,7 @@ public class BlockAutoWorkbench extends BlockBuildCraft { public BlockAutoWorkbench(int i) { super(i, Material.wood); - setHardness(1.0F); + setHardness(3.0F); } @Override diff --git a/common/buildcraft/factory/BlockMachineRoot.java b/common/buildcraft/factory/BlockMachineRoot.java index 843301e7..31f337d7 100644 --- a/common/buildcraft/factory/BlockMachineRoot.java +++ b/common/buildcraft/factory/BlockMachineRoot.java @@ -21,6 +21,7 @@ public abstract class BlockMachineRoot extends BlockContainer { protected BlockMachineRoot(int i, Material material) { super(i, material); setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setHardness(5F); } @Override diff --git a/common/buildcraft/factory/BlockMiningWell.java b/common/buildcraft/factory/BlockMiningWell.java index 85712ae5..44899641 100644 --- a/common/buildcraft/factory/BlockMiningWell.java +++ b/common/buildcraft/factory/BlockMiningWell.java @@ -31,7 +31,7 @@ public class BlockMiningWell extends BlockMachineRoot { public BlockMiningWell(int i) { super(i, Material.ground); - setHardness(1.5F); + setHardness(5F); setResistance(10F); setStepSound(soundStoneFootstep); } diff --git a/common/buildcraft/factory/BlockQuarry.java b/common/buildcraft/factory/BlockQuarry.java index d5e15f03..fa9d3576 100644 --- a/common/buildcraft/factory/BlockQuarry.java +++ b/common/buildcraft/factory/BlockQuarry.java @@ -36,7 +36,7 @@ public class BlockQuarry extends BlockMachineRoot { public BlockQuarry(int i) { super(i, Material.iron); - setHardness(1.5F); + setHardness(10F); setResistance(10F); setStepSound(soundStoneFootstep); } diff --git a/common/buildcraft/factory/BlockRefinery.java b/common/buildcraft/factory/BlockRefinery.java index 6f91e3c0..3417eac1 100644 --- a/common/buildcraft/factory/BlockRefinery.java +++ b/common/buildcraft/factory/BlockRefinery.java @@ -42,7 +42,7 @@ public class BlockRefinery extends BlockContainer { public BlockRefinery(int i) { super(i, Material.iron); - setHardness(0.5F); + setHardness(5F); setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); } diff --git a/common/buildcraft/silicon/BlockLaser.java b/common/buildcraft/silicon/BlockLaser.java index 0d25f117..95b080a7 100644 --- a/common/buildcraft/silicon/BlockLaser.java +++ b/common/buildcraft/silicon/BlockLaser.java @@ -27,7 +27,7 @@ public class BlockLaser extends BlockContainer { public BlockLaser(int i) { super(i, Material.iron); - setHardness(0.5F); + setHardness(10F); setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); } diff --git a/common/buildcraft/silicon/BlockLaserTable.java b/common/buildcraft/silicon/BlockLaserTable.java index 2ae0d3b0..65f5a54c 100644 --- a/common/buildcraft/silicon/BlockLaserTable.java +++ b/common/buildcraft/silicon/BlockLaserTable.java @@ -26,7 +26,7 @@ public class BlockLaserTable extends BlockContainer { super(i, Material.iron); setBlockBounds(0, 0, 0, 1, 9F / 16F, 1); - setHardness(0.5F); + setHardness(10F); setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); } From cde67912f66fe5834daa3e83c3d1e93630499e1a Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 15 Sep 2013 23:18:36 -0700 Subject: [PATCH 040/121] Fix loop in TileEngine --- common/buildcraft/energy/TileEngine.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index 4e89fe32..d76a8432 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -54,6 +54,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto protected PowerHandler powerHandler; public float currentOutput = 0; public boolean isRedstonePowered = false; + private boolean checkOrienation = false; private TileBuffer[] tileCache; public float progress; public float energy; @@ -169,6 +170,12 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto return; } + if (checkOrienation) { + checkOrienation = false; + if (!isOrientationValid()) + switchOrientation(true); + } + updateHeatLevel(); engineUpdate(); @@ -291,14 +298,14 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public void invalidate() { super.invalidate(); tileCache = null; + checkOrienation = true; } @Override public void validate() { super.validate(); tileCache = null; - if (!isOrientationValid()) - switchOrientation(true); + checkOrienation = true; } @Override From 5b4d661543fe78aeb5defb64e9be51dcf39221ae Mon Sep 17 00:00:00 2001 From: Flow86 Date: Tue, 17 Sep 2013 08:49:06 +0200 Subject: [PATCH 041/121] Update Pipe.java fix NPE. (see RS485/LogisticsPipes-Dev#182) --- common/buildcraft/transport/Pipe.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index e3d0f05e..6fd1043a 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -86,6 +86,10 @@ public abstract class Pipe implements IPipe, IDropContr Pipe otherPipe; if (tile instanceof TileGenericPipe) { otherPipe = ((TileGenericPipe) tile).pipe; + + if (!BlockGenericPipe.isFullyDefined(otherPipe)) + return false; + if (!PipeConnectionBans.canPipesConnect(getClass(), otherPipe.getClass())) return false; } From bb7aa41b4823711241f122e9ed62ce8cbddced23 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 18 Sep 2013 09:56:31 -0400 Subject: [PATCH 042/121] Fix Quarry in the nether. Closes a bunch of bug reports no doubt. --- .project | 7 ++++++ common/buildcraft/core/utils/BlockUtil.java | 8 ++++++ common/buildcraft/factory/TileQuarry.java | 27 ++++++++++++++++----- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/.project b/.project index c4146540..d2bbeb49 100644 --- a/.project +++ b/.project @@ -14,4 +14,11 @@ org.eclipse.jdt.core.javanature + + + common/assets + 2 + PROJECT_LOC/buildcraft_resources/assets + + diff --git a/common/buildcraft/core/utils/BlockUtil.java b/common/buildcraft/core/utils/BlockUtil.java index d1ddfac7..fa95412f 100644 --- a/common/buildcraft/core/utils/BlockUtil.java +++ b/common/buildcraft/core/utils/BlockUtil.java @@ -74,6 +74,14 @@ public class BlockUtil { return canChangeBlock(world.getBlockId(x, y, z), world, x, y, z); } + public static boolean isAnObstructingBlock(int blockID, World world, int x, int y, int z) + { + Block block = Block.blocksList[blockID]; + + if (blockID == 0 || block == null || block.isAirBlock(world, x, y, z)) + return false; + return true; + } public static boolean canChangeBlock(int blockID, World world, int x, int y, int z) { Block block = Block.blocksList[blockID]; diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index 5fb97dbc..d33ca246 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -11,6 +11,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; +import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -259,15 +260,22 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept if (!columnVisitListIsUpdated) { // nextTarget may not be accurate, at least search the target column for changes for (int y = nextTarget[1] + 1; y < yCoord + 3; y++) { int blockID = worldObj.getBlockId(nextTarget[0], y, nextTarget[2]); - - if (BlockUtil.canChangeBlock(blockID, worldObj, nextTarget[0], y, nextTarget[2]) && !BlockUtil.isSoftBlock(blockID, worldObj, nextTarget[0], y, nextTarget[2])) { + if (BlockUtil.isAnObstructingBlock(blockID, worldObj, nextTarget[0], y, nextTarget[2]) || !BlockUtil.isSoftBlock(blockID, worldObj, nextTarget[0], y, nextTarget[2])) { createColumnVisitList(); - nextTarget = visitList.removeFirst(); - + columnVisitListIsUpdated = true; + nextTarget = null; break; } } } + if (columnVisitListIsUpdated && nextTarget == null && !visitList.isEmpty()) + { + nextTarget = visitList.removeFirst(); + } + else if (columnVisitListIsUpdated && nextTarget == null) + { + return false; + } setTarget(nextTarget[0], nextTarget[1] + 1, nextTarget[2]); @@ -316,8 +324,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept if (height == null) columnHeights[searchX][searchZ] = height = worldObj.getHeightValue(bx, bz); - if (height < by) - continue; + if (height > 0 && height < by && worldObj.provider.dimensionId != -1) + { + continue; + } int blockID = worldObj.getBlockId(bx, by, bz); @@ -326,6 +336,11 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } else if (!BlockUtil.isSoftBlock(blockID, worldObj, bx, by, bz)) { visitList.add(new int[]{bx, by, bz}); } + if (height == 0 && !worldObj.isAirBlock(bx, by, bz)) + { + columnHeights[searchX][searchZ] = by; + } + // Stop at two planes - generally any obstructions will have been found and will force a recompute prior to this if (visitList.size() > bluePrintBuilder.bluePrint.sizeZ * bluePrintBuilder.bluePrint.sizeX * 2) return; From dcc8e48325046be984c77adaee91a6302a8fd8c5 Mon Sep 17 00:00:00 2001 From: pahimar Date: Wed, 18 Sep 2013 22:12:47 -0400 Subject: [PATCH 043/121] Use the buildcraft_resources directory as a source directory so that when running inside of Eclipse we map textures properly and get way less spammy spam --- .classpath | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.classpath b/.classpath index 9d71da7e..e4623235 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,12 @@ - + + + + + + - + From 378e6fd3bf6e7e54713795b0b77600f5b5bbbdf3 Mon Sep 17 00:00:00 2001 From: pahimar Date: Wed, 18 Sep 2013 22:16:22 -0400 Subject: [PATCH 044/121] Taking out some of my personal configurations, so that my net diff tonight is only adding the resources directory as a source directory for the eclipse project files --- .classpath | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.classpath b/.classpath index e4623235..2af1d2f7 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,8 @@ - - - - - + - + From 14db1ed0ebcdd75be50a7527143319d87475260e Mon Sep 17 00:00:00 2001 From: Flow86 Date: Thu, 19 Sep 2013 12:36:52 +0200 Subject: [PATCH 045/121] fix GuiMultiButton Tooltip handling --- .../core/gui/buttons/GuiMultiButton.java | 18 +++++++++++++++--- .../core/gui/buttons/IMultiButtonState.java | 6 +++++- .../core/gui/buttons/LockButtonState.java | 12 +++++++++--- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/common/buildcraft/core/gui/buttons/GuiMultiButton.java b/common/buildcraft/core/gui/buttons/GuiMultiButton.java index d5928ff2..3bc4ea36 100644 --- a/common/buildcraft/core/gui/buttons/GuiMultiButton.java +++ b/common/buildcraft/core/gui/buttons/GuiMultiButton.java @@ -1,13 +1,16 @@ package buildcraft.core.gui.buttons; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; + import org.lwjgl.opengl.GL11; +import buildcraft.core.gui.tooltips.ToolTip; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** - * + * * @author CovertJaguar */ @SideOnly(Side.CLIENT) @@ -68,4 +71,13 @@ public class GuiMultiButton extends GuiBetterButton { public MultiButtonController getController() { return control; } + + @Override + public ToolTip getToolTip() { + ToolTip tip = this.control.getButtonState().getToolTip(); + if (tip != null) { + return tip; + } + return super.getToolTip(); + } } diff --git a/common/buildcraft/core/gui/buttons/IMultiButtonState.java b/common/buildcraft/core/gui/buttons/IMultiButtonState.java index 92879613..33deca20 100644 --- a/common/buildcraft/core/gui/buttons/IMultiButtonState.java +++ b/common/buildcraft/core/gui/buttons/IMultiButtonState.java @@ -1,7 +1,9 @@ package buildcraft.core.gui.buttons; +import buildcraft.core.gui.tooltips.ToolTip; + /** - * + * * @author CovertJaguar */ public interface IMultiButtonState { @@ -11,4 +13,6 @@ public interface IMultiButtonState { public String name(); public IButtonTextureSet getTextureSet(); + + public ToolTip getToolTip(); } diff --git a/common/buildcraft/core/gui/buttons/LockButtonState.java b/common/buildcraft/core/gui/buttons/LockButtonState.java index 88686b34..db86bed9 100644 --- a/common/buildcraft/core/gui/buttons/LockButtonState.java +++ b/common/buildcraft/core/gui/buttons/LockButtonState.java @@ -1,13 +1,14 @@ package buildcraft.core.gui.buttons; +import buildcraft.core.gui.tooltips.ToolTip; + /** - * + * * @author CovertJaguar */ public enum LockButtonState implements IMultiButtonState { - UNLOCKED(new ButtonTextureSet(224, 0, 16, 16)), - LOCKED(new ButtonTextureSet(240, 0, 16, 16)); + UNLOCKED(new ButtonTextureSet(224, 0, 16, 16)), LOCKED(new ButtonTextureSet(240, 0, 16, 16)); public static final LockButtonState[] VALUES = values(); private final IButtonTextureSet texture; @@ -24,4 +25,9 @@ public enum LockButtonState implements IMultiButtonState { public IButtonTextureSet getTextureSet() { return texture; } + + @Override + public ToolTip getToolTip() { + return null; + } } From 74d2239dc740f75e5355059e35715a3f263959d4 Mon Sep 17 00:00:00 2001 From: Flow86 Date: Thu, 19 Sep 2013 12:45:17 +0200 Subject: [PATCH 046/121] added non blocking mode to emerald pipe implements/closes #1195 --- .../lang/buildcraft/en_US.properties | 4 + .../core/network/IGuiReturnHandler.java | 20 ++++ .../core/network/PacketGuiReturn.java | 89 +++++++++++++++++ .../core/network/PacketHandler.java | 18 +++- common/buildcraft/core/network/PacketIds.java | 13 ++- .../buildcraft/transport/TileGenericPipe.java | 15 ++- .../transport/gui/GuiEmeraldPipe.java | 39 +++++++- .../transport/pipes/PipeItemsEmerald.java | 96 ++++++++++++++++--- 8 files changed, 268 insertions(+), 26 deletions(-) create mode 100644 common/buildcraft/core/network/IGuiReturnHandler.java create mode 100644 common/buildcraft/core/network/PacketGuiReturn.java diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index b9cc90b2..1d897c4a 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -24,6 +24,10 @@ gui.heat=Heat gui.assemblyRate=Energy Rate gui.assemblyCurrentRequired=Energy Required gui.clickcraft=-Click to Craft- +gui.pipes.emerald.blocking=Blocking +gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing +gui.pipes.emerald.nonblocking=Non Blocking +gui.pipes.emerald.nonblocking.tip=Extraction continues with the next filter in list if element is missing item.bucketFuel=Fuel Bucket item.bucketOil=Oil Bucket item.woodenGearItem=Wood Gear diff --git a/common/buildcraft/core/network/IGuiReturnHandler.java b/common/buildcraft/core/network/IGuiReturnHandler.java new file mode 100644 index 00000000..25b1a63b --- /dev/null +++ b/common/buildcraft/core/network/IGuiReturnHandler.java @@ -0,0 +1,20 @@ +package buildcraft.core.network; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +/** + * + * @author CovertJaguar + */ +public abstract interface IGuiReturnHandler { + public World getWorld(); + + public void writeGuiData(DataOutputStream paramDataOutputStream) throws IOException; + + public void readGuiData(DataInputStream paramDataInputStream, EntityPlayer paramEntityPlayer) throws IOException; +} diff --git a/common/buildcraft/core/network/PacketGuiReturn.java b/common/buildcraft/core/network/PacketGuiReturn.java new file mode 100644 index 00000000..e559b24b --- /dev/null +++ b/common/buildcraft/core/network/PacketGuiReturn.java @@ -0,0 +1,89 @@ +package buildcraft.core.network; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; +import cpw.mods.fml.common.network.PacketDispatcher; + +/** + * + * @author CovertJaguar + */ +public class PacketGuiReturn extends BuildCraftPacket { + private EntityPlayer sender; + private IGuiReturnHandler obj; + private byte[] extraData; + + public PacketGuiReturn(EntityPlayer sender) { + this.sender = sender; + } + + public PacketGuiReturn(IGuiReturnHandler obj) { + this.obj = obj; + this.extraData = null; + } + + public PacketGuiReturn(IGuiReturnHandler obj, byte[] extraData) { + this.obj = obj; + this.extraData = extraData; + } + + @Override + public void writeData(DataOutputStream data) throws IOException { + data.writeInt(obj.getWorld().provider.dimensionId); + if (obj instanceof TileEntity) { + TileEntity tile = (TileEntity) obj; + data.writeBoolean(true); + data.writeInt(tile.xCoord); + data.writeInt(tile.yCoord); + data.writeInt(tile.zCoord); + } else if (obj instanceof Entity) { + Entity entity = (Entity) obj; + data.writeBoolean(false); + data.writeInt(entity.entityId); + } else + return; + obj.writeGuiData(data); + if (extraData != null) + data.write(extraData); + } + + @Override + public void readData(DataInputStream data) throws IOException { + int dim = data.readInt(); + World world = DimensionManager.getWorld(dim); + boolean tileReturn = data.readBoolean(); + if (tileReturn) { + int x = data.readInt(); + int y = data.readInt(); + int z = data.readInt(); + + TileEntity t = world.getBlockTileEntity(x, y, z); + + if (t instanceof IGuiReturnHandler) + ((IGuiReturnHandler) t).readGuiData(data, sender); + + } else { + int entityId = data.readInt(); + Entity entity = world.getEntityByID(entityId); + + if (entity instanceof IGuiReturnHandler) + ((IGuiReturnHandler) entity).readGuiData(data, sender); + } + } + + public void sendPacket() { + PacketDispatcher.sendPacketToServer(getPacket()); + } + + @Override + public int getID() { + return PacketIds.GUI_RETURN; + } +} \ No newline at end of file diff --git a/common/buildcraft/core/network/PacketHandler.java b/common/buildcraft/core/network/PacketHandler.java index bac2e773..a999117e 100644 --- a/common/buildcraft/core/network/PacketHandler.java +++ b/common/buildcraft/core/network/PacketHandler.java @@ -1,15 +1,16 @@ package buildcraft.core.network; -import cpw.mods.fml.common.network.IPacketHandler; -import cpw.mods.fml.common.network.Player; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import cpw.mods.fml.common.network.IPacketHandler; +import cpw.mods.fml.common.network.Player; public class PacketHandler implements IPacketHandler { @@ -35,13 +36,14 @@ public class PacketHandler implements IPacketHandler { int packetID = data.read(); switch (packetID) { - case PacketIds.TILE_UPDATE: + case PacketIds.TILE_UPDATE: { PacketTileUpdate packetT = new PacketTileUpdate(); packetT.readData(data); onTileUpdate((EntityPlayer) player, packetT); break; + } - case PacketIds.STATE_UPDATE: + case PacketIds.STATE_UPDATE: { PacketTileState inPacket = new PacketTileState(); inPacket.readData(data); World world = ((EntityPlayer) player).worldObj; @@ -50,6 +52,14 @@ public class PacketHandler implements IPacketHandler { inPacket.applyStates(data, (ISyncedTile) tile); } break; + } + + case PacketIds.GUI_RETURN: { + PacketGuiReturn packet1 = new PacketGuiReturn((EntityPlayer) player); + packet1.readData(data); + // onGuiReturn((EntityPlayer) player, packet1); + break; + } } } catch (Exception ex) { ex.printStackTrace(); diff --git a/common/buildcraft/core/network/PacketIds.java b/common/buildcraft/core/network/PacketIds.java index a60e97c4..34af2c6f 100644 --- a/common/buildcraft/core/network/PacketIds.java +++ b/common/buildcraft/core/network/PacketIds.java @@ -3,32 +3,39 @@ package buildcraft.core.network; public class PacketIds { public static final int TILE_UPDATE = 0; -// public static final int PIPE_DESCRIPTION = 1; + // public static final int PIPE_DESCRIPTION = 1; public static final int PIPE_CONTENTS = 2; public static final int PIPE_LIQUID = 3; public static final int PIPE_POWER = 4; public static final int REQUEST_ITEM_NBT = 5; public static final int PIPE_ITEM_NBT = 6; + public static final int SELECTION_ASSEMBLY_GET = 20; /** Packet sent to server when a recipe is clicked on in the assembly table */ public static final int SELECTION_ASSEMBLY = 21; /** Packet to send recipes to client */ public static final int SELECTION_ASSEMBLY_SEND = 22; + public static final int DIAMOND_PIPE_SELECT = 31; public static final int EMERALD_PIPE_SELECT = 32; + public static final int GATE_ACTIONS = 40; public static final int GATE_REQUEST_INIT = 41; public static final int GATE_REQUEST_SELECTION = 42; public static final int GATE_SELECTION = 43; public static final int GATE_SELECTION_CHANGE = 44; public static final int GATE_TRIGGERS = 45; + public static final int REFINERY_FILTER_SET = 50; + public static final int ARCHITECT_NAME = 60; public static final int LIBRARY_ACTION = 61; public static final int LIBRARY_SELECT = 62; - public static final int STATE_UPDATE = 100; - public static final int ADVANCED_WORKBENCH_SETSLOT = 70; public static final int SELECTION_ADVANCED_WORKBENCH = 71; + + public static final int GUI_RETURN = 80; + + public static final int STATE_UPDATE = 100; } diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 5ae87c2e..e9e38d46 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -46,6 +46,7 @@ import buildcraft.core.ITileBufferHolder; import buildcraft.core.TileBuffer; import buildcraft.core.inventory.InvUtils; import buildcraft.core.network.IClientState; +import buildcraft.core.network.IGuiReturnHandler; import buildcraft.core.network.ISyncedTile; import buildcraft.core.network.PacketTileState; import buildcraft.transport.Gate.GateKind; @@ -53,7 +54,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFluidHandler, IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, - IDropControlInventory, IPipeRenderState, ISyncedTile, ISolidSideTile { + IDropControlInventory, IPipeRenderState, ISyncedTile, ISolidSideTile, IGuiReturnHandler { private class CoreState implements IClientState { @@ -693,4 +694,16 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui public void markBlockForUpdate() { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } + + @Override + public void writeGuiData(DataOutputStream data) throws IOException { + if (BlockGenericPipe.isValid(pipe) && pipe instanceof IGuiReturnHandler) + ((IGuiReturnHandler) pipe).writeGuiData(data); + } + + @Override + public void readGuiData(DataInputStream data, EntityPlayer sender) throws IOException { + if (BlockGenericPipe.isValid(pipe) && pipe instanceof IGuiReturnHandler) + ((IGuiReturnHandler) pipe).readGuiData(data, sender); + } } diff --git a/common/buildcraft/transport/gui/GuiEmeraldPipe.java b/common/buildcraft/transport/gui/GuiEmeraldPipe.java index 89fcfe15..2134124c 100644 --- a/common/buildcraft/transport/gui/GuiEmeraldPipe.java +++ b/common/buildcraft/transport/gui/GuiEmeraldPipe.java @@ -7,28 +7,59 @@ */ package buildcraft.transport.gui; -import buildcraft.core.DefaultProps; -import buildcraft.core.gui.GuiBuildCraft; -import buildcraft.core.utils.StringUtils; -import buildcraft.transport.pipes.PipeItemsEmerald; import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; +import buildcraft.core.DefaultProps; +import buildcraft.core.gui.GuiBuildCraft; +import buildcraft.core.gui.buttons.GuiMultiButton; +import buildcraft.core.network.PacketGuiReturn; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.StringUtils; +import buildcraft.transport.pipes.PipeItemsEmerald; + public class GuiEmeraldPipe extends GuiBuildCraft { private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter_2.png"); + private GuiMultiButton button; + IInventory playerInventory; IInventory filterInventory; + PipeItemsEmerald pipe; public GuiEmeraldPipe(IInventory playerInventory, PipeItemsEmerald pipe) { super(new ContainerEmeraldPipe(playerInventory, pipe), pipe.getFilters()); + + this.pipe = pipe; this.playerInventory = playerInventory; this.filterInventory = pipe.getFilters(); + xSize = 175; ySize = 132; } + @Override + public void initGui() { + super.initGui(); + + this.buttonList.clear(); + this.button = new GuiMultiButton(0, this.guiLeft + this.xSize - (80 + 4), this.guiTop + 2, 80, this.pipe.getStateController().copy()); + this.buttonList.add(this.button); + } + + @Override + public void onGuiClosed() { + if (CoreProxy.proxy.isRenderWorld(pipe.getWorld())) { + pipe.getStateController().setCurrentState(button.getController().getCurrentState()); + PacketGuiReturn pkt = new PacketGuiReturn(pipe.getContainer()); + pkt.sendPacket(); + } + + super.onGuiClosed(); + } + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { fontRenderer.drawString(filterInventory.getInvName(), getCenteredOffset(filterInventory.getInvName()), 6, 0x404040); diff --git a/common/buildcraft/transport/pipes/PipeItemsEmerald.java b/common/buildcraft/transport/pipes/PipeItemsEmerald.java index 475aaf5a..dcc7fb20 100644 --- a/common/buildcraft/transport/pipes/PipeItemsEmerald.java +++ b/common/buildcraft/transport/pipes/PipeItemsEmerald.java @@ -7,19 +7,10 @@ */ package buildcraft.transport.pipes; -import buildcraft.BuildCraftTransport; -import buildcraft.api.inventory.ISelectiveInventory; -import buildcraft.api.inventory.ISpecialInventory; -import buildcraft.core.GuiIds; -import buildcraft.core.inventory.SimpleInventory; -import buildcraft.core.network.IClientState; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.utils.Utils; -import buildcraft.transport.BlockGenericPipe; -import buildcraft.transport.PipeIconProvider; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -27,10 +18,57 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.ForgeDirection; +import buildcraft.BuildCraftTransport; +import buildcraft.api.inventory.ISelectiveInventory; +import buildcraft.api.inventory.ISpecialInventory; +import buildcraft.core.GuiIds; +import buildcraft.core.gui.buttons.IButtonTextureSet; +import buildcraft.core.gui.buttons.IMultiButtonState; +import buildcraft.core.gui.buttons.MultiButtonController; +import buildcraft.core.gui.buttons.StandardButtonTextureSets; +import buildcraft.core.gui.tooltips.ToolTip; +import buildcraft.core.gui.tooltips.ToolTipLine; +import buildcraft.core.inventory.SimpleInventory; +import buildcraft.core.network.IClientState; +import buildcraft.core.network.IGuiReturnHandler; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.StringUtils; +import buildcraft.core.utils.Utils; +import buildcraft.transport.BlockGenericPipe; +import buildcraft.transport.PipeIconProvider; -public class PipeItemsEmerald extends PipeItemsWood implements IClientState { +public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGuiReturnHandler { - private SimpleInventory filters = new SimpleInventory(9, "Filters", 1); + public static enum ButtonState implements IMultiButtonState { + BLOCKING("gui.pipes.emerald.blocking"), NONBLOCKING("gui.pipes.emerald.nonblocking"); + + private final String label; + private final ToolTip tip; + + private ButtonState(String label) { + this.label = label; + tip = new ToolTip(); + tip.add(new ToolTipLine(label + ".tip")); + } + + @Override + public String getLabel() { + return StringUtils.localize(this.label); + } + + @Override + public IButtonTextureSet getTextureSet() { + return StandardButtonTextureSets.SMALL_BUTTON; + } + + @Override + public ToolTip getToolTip() { + return this.tip; + } + } + + private final MultiButtonController stateController = MultiButtonController.getController(ButtonState.BLOCKING.ordinal(), ButtonState.values()); + private final SimpleInventory filters = new SimpleInventory(9, "Filters", 1); private int currentFilter = 0; public PipeItemsEmerald(int itemID) { @@ -68,8 +106,9 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState { public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) { /* ISELECTIVEINVENTORY */ + // non blocking mode is not implemented for ISelectiveInventory yet if (inventory instanceof ISelectiveInventory) { - ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[]{getCurrentFilter()}, false, doRemove, from, (int) powerHandler.getEnergyStored()); + ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[] { getCurrentFilter() }, false, doRemove, from, (int) powerHandler.getEnergyStored()); if (doRemove) { for (ItemStack stack : stacks) { if (stack != null) { @@ -81,6 +120,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState { return stacks; /* ISPECIALINVENTORY */ + // non blocking mode is not needed for ISpecialInventory since its not round robin anyway } else if (inventory instanceof ISpecialInventory) { ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(false, from, (int) powerHandler.getEnergyStored()); if (stacks != null) { @@ -117,8 +157,18 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState { IInventory inv = Utils.getInventory(inventory); ItemStack result = checkExtractGeneric(inv, doRemove, from); + // check through every filter once if non-blocking + if (doRemove && stateController.getButtonState() == ButtonState.NONBLOCKING && result == null) { + int count = 1; + while (result == null && count < filters.getSizeInventory()) { + incrementFilter(); + result = checkExtractGeneric(inv, doRemove, from); + count++; + } + } + if (result != null) { - return new ItemStack[]{result}; + return new ItemStack[] { result }; } } @@ -176,6 +226,8 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState { super.readFromNBT(nbt); filters.readFromNBT(nbt); currentFilter = nbt.getInteger("currentFilter"); + + stateController.readFromNBT(nbt, "state"); } @Override @@ -183,6 +235,8 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState { super.writeToNBT(nbt); filters.writeToNBT(nbt); nbt.setInteger("currentFilter", currentFilter); + + stateController.writeToNBT(nbt, "state"); } // ICLIENTSTATE @@ -204,4 +258,18 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState { public IInventory getFilters() { return filters; } + + public MultiButtonController getStateController() { + return stateController; + } + + @Override + public void writeGuiData(DataOutputStream data) throws IOException { + data.writeByte(stateController.getCurrentState()); + } + + @Override + public void readGuiData(DataInputStream data, EntityPlayer sender) throws IOException { + stateController.setCurrentState(data.readByte()); + } } From b7f173b7f2cc54ed04001f2b1ccd4061935b7e21 Mon Sep 17 00:00:00 2001 From: Flow86 Date: Thu, 19 Sep 2013 12:51:40 +0200 Subject: [PATCH 047/121] place button in emerald pipe a bit better (ideas for better placement are welcome) --- common/buildcraft/transport/gui/GuiEmeraldPipe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/transport/gui/GuiEmeraldPipe.java b/common/buildcraft/transport/gui/GuiEmeraldPipe.java index 2134124c..c3e69d0f 100644 --- a/common/buildcraft/transport/gui/GuiEmeraldPipe.java +++ b/common/buildcraft/transport/gui/GuiEmeraldPipe.java @@ -45,7 +45,7 @@ public class GuiEmeraldPipe extends GuiBuildCraft { super.initGui(); this.buttonList.clear(); - this.button = new GuiMultiButton(0, this.guiLeft + this.xSize - (80 + 4), this.guiTop + 2, 80, this.pipe.getStateController().copy()); + this.button = new GuiMultiButton(0, this.guiLeft + this.xSize - (80 + 6), this.guiTop + 34, 80, this.pipe.getStateController().copy()); this.buttonList.add(this.button); } From 11ed5b16dd2b7ab6e5050d92a0f8e8bc2dd303b2 Mon Sep 17 00:00:00 2001 From: Vexatos Date: Fri, 20 Sep 2013 10:22:40 +0200 Subject: [PATCH 048/121] Update en_US.properties I think this sounds better. Please tell me your opinion about it. --- buildcraft_resources/lang/buildcraft/en_US.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index 1d897c4a..fee36ca3 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -27,7 +27,7 @@ gui.clickcraft=-Click to Craft- gui.pipes.emerald.blocking=Blocking gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing gui.pipes.emerald.nonblocking=Non Blocking -gui.pipes.emerald.nonblocking.tip=Extraction continues with the next filter in list if element is missing +gui.pipes.emerald.nonblocking.tip=Extraction continues with the next element in filter if one element is missing item.bucketFuel=Fuel Bucket item.bucketOil=Oil Bucket item.woodenGearItem=Wood Gear From 5f4d4c1008a7a5941f6ad4018f2dabcc5c55e06e Mon Sep 17 00:00:00 2001 From: Jaroslaw Szczesniewski Date: Sun, 22 Sep 2013 01:24:51 +0200 Subject: [PATCH 049/121] Fix for kinesis pipes content triggers Due to smoothing s>0 will always be true. All float values higher than 0 will work, however the lower the value, the longer the delay. Tested with 1 stirling engine powering 16 pumps, s>0.001 caused flickering in this case. --- common/buildcraft/transport/triggers/TriggerPipeContents.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/transport/triggers/TriggerPipeContents.java b/common/buildcraft/transport/triggers/TriggerPipeContents.java index 4b4bce49..1e8fa321 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeContents.java +++ b/common/buildcraft/transport/triggers/TriggerPipeContents.java @@ -129,14 +129,14 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe { switch (kind) { case Empty: for (double s : transportPower.displayPower) { - if (s > 0) + if (s > 1e-4) return false; } return true; case ContainsEnergy: for (double s : transportPower.displayPower) { - if (s > 0) + if (s > 1e-4) return true; } From 4a017f355e21ac56886cef173a952a38574f2bc8 Mon Sep 17 00:00:00 2001 From: Gordon H Date: Sun, 22 Sep 2013 09:48:25 -0400 Subject: [PATCH 050/121] Added oil well generation probability scalar to config file --- common/buildcraft/BuildCraftEnergy.java | 2 ++ common/buildcraft/energy/worldgen/OilPopulate.java | 1 + 2 files changed, 3 insertions(+) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 872b88d8..361b152f 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -80,6 +80,7 @@ public class BuildCraftEnergy { public static Item bucketFuel; public static Item fuel; public static boolean canOilBurn; + public static double oilWellScalar; public static TreeMap saturationStored = new TreeMap(); public static BCTrigger triggerBlueEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_BLUE_ENGINE_HEAT, EnergyStage.BLUE, "buildcraft.engine.stage.blue"); public static BCTrigger triggerGreenEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_GREEN_ENGINE_HEAT, EnergyStage.GREEN, "buildcraft.engine.stage.green"); @@ -106,6 +107,7 @@ public class BuildCraftEnergy { int oilDesertBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilDesert", DefaultProps.BIOME_OIL_DESERT).getInt(DefaultProps.BIOME_OIL_DESERT); int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN); canOilBurn = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "burnOil", true, "Can oil burn?").getBoolean(true); + oilWellScalar = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilWellGenerationRate", 1.0, "Probability of oil well generation").getDouble(1.0); BuildCraftCore.mainConfiguration.save(); class BiomeIdException extends RuntimeException { diff --git a/common/buildcraft/energy/worldgen/OilPopulate.java b/common/buildcraft/energy/worldgen/OilPopulate.java index bfc1bf4a..1846e891 100644 --- a/common/buildcraft/energy/worldgen/OilPopulate.java +++ b/common/buildcraft/energy/worldgen/OilPopulate.java @@ -87,6 +87,7 @@ public class OilPopulate { || (BiomeDictionary.isBiomeOfType(biome, FOREST) && BiomeDictionary.isBiomeOfType(biome, FROZEN)); double bonus = oilBiome ? 3.0 : 1.0; + bonus *= BuildCraftEnergy.oilWellScalar; if (excessiveBiomes.contains(biome.biomeID)) { bonus *= 30.0; } else if (BuildCraftCore.debugMode) { From 83298c9b944f4e4b3e323340119dc7a718c204d8 Mon Sep 17 00:00:00 2001 From: Sergey Shatunov Date: Mon, 23 Sep 2013 22:21:24 +0800 Subject: [PATCH 051/121] Add a config property for update check --- common/buildcraft/BuildCraftCore.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 5d8e1da4..bff23b3a 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -168,8 +168,6 @@ public class BuildCraftCore { @EventHandler public void loadConfiguration(FMLPreInitializationEvent evt) { - Version.check(); - bcLog.setParent(FMLLog.getLogger()); bcLog.info("Starting BuildCraft " + Version.getVersion()); bcLog.info("Copyright (c) SpaceToad, 2011"); @@ -178,6 +176,12 @@ public class BuildCraftCore { mainConfiguration = new BuildCraftConfiguration(new File(evt.getModConfigurationDirectory(), "buildcraft/main.conf")); try { mainConfiguration.load(); + + Property updateCheck = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "update.check", true); + updateCheck.comment = "set to true for version check on startup"; + if (updateCheck.getBoolean(true)) { + Version.check(); + } Property continuousCurrent = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "current.continuous", DefaultProps.CURRENT_CONTINUOUS); From 6c76a9a8d655bd5276a8b5619b16d4339dfafc91 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 24 Sep 2013 08:49:48 -0700 Subject: [PATCH 052/121] Add flat taxing to PowerHandler for King Lemming This should be a non-breaking API change. --- common/buildcraft/api/power/PowerHandler.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/buildcraft/api/power/PowerHandler.java b/common/buildcraft/api/power/PowerHandler.java index 6965122b..0b8778fc 100644 --- a/common/buildcraft/api/power/PowerHandler.java +++ b/common/buildcraft/api/power/PowerHandler.java @@ -82,6 +82,17 @@ public final class PowerHandler { } return current; } + + /** + * Taxes a flat rate on all incoming power. + * + * Defaults to 0% tax rate. + * + * @return percent of input to tax + */ + public float getTaxPercent() { + return 0; + } } public static final PerditionCalculator DEFAULT_PERDITION = new PerditionCalculator(); private float minEnergyReceived; @@ -347,6 +358,8 @@ public final class PowerHandler { } updateSources(from); + + used -= used * getPerdition().getTaxPercent(); used = addEnergy(used); From 3c84c34bd94a81fc5db45c14b7b78f75c8cb2c20 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 24 Sep 2013 10:17:21 -0700 Subject: [PATCH 053/121] Wooden Pipes shouldn't orient to pipes Closes #1218 --- common/buildcraft/transport/pipes/PipeFluidsWood.java | 4 +++- common/buildcraft/transport/pipes/PipeItemsWood.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/transport/pipes/PipeFluidsWood.java b/common/buildcraft/transport/pipes/PipeFluidsWood.java index 7896d110..22792a15 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsWood.java +++ b/common/buildcraft/transport/pipes/PipeFluidsWood.java @@ -13,8 +13,8 @@ import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.Type; +import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.PipeManager; -import buildcraft.core.TileBuffer; import buildcraft.core.network.TileNetworkData; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; @@ -41,6 +41,8 @@ public class PipeFluidsWood extends Pipe implements IPowerR private PipeLogicWood logic = new PipeLogicWood(this) { @Override protected boolean isValidConnectingTile(TileEntity tile) { + if(tile instanceof IPipeTile) + return false; if (!(tile instanceof IFluidHandler)) return false; if (!PipeManager.canExtractFluids(pipe, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord)) diff --git a/common/buildcraft/transport/pipes/PipeItemsWood.java b/common/buildcraft/transport/pipes/PipeItemsWood.java index 70c850e0..e548eec6 100644 --- a/common/buildcraft/transport/pipes/PipeItemsWood.java +++ b/common/buildcraft/transport/pipes/PipeItemsWood.java @@ -15,8 +15,8 @@ import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.Type; +import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.PipeManager; -import buildcraft.core.TileBuffer; import buildcraft.transport.TravelingItem; import buildcraft.core.inventory.InventoryWrapper; import buildcraft.core.utils.Utils; @@ -40,6 +40,8 @@ public class PipeItemsWood extends Pipe implements IPowerRec private PipeLogicWood logic = new PipeLogicWood(this) { @Override protected boolean isValidConnectingTile(TileEntity tile) { + if (tile instanceof IPipeTile) + return false; if (!(tile instanceof IInventory)) return false; if (!PipeManager.canExtractItems(pipe, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord)) From 8782d5125ab0b5c79796530b3523f58b313be5d8 Mon Sep 17 00:00:00 2001 From: Captain Shadows Date: Wed, 25 Sep 2013 16:07:49 -0400 Subject: [PATCH 054/121] Ore Dictionary compatibility Changed some recipes to use the Ore Dictionary. Made shapeless recipes use the Ore Dictionary. Also implemented the changes that CJ asked for. If there was another PR like this one(Not counting #1227, #1232, and #1234), I would like to know why not? --- common/buildcraft/BuildCraftBuilders.java | 38 ++++++++++----------- common/buildcraft/BuildCraftCore.java | 12 +++---- common/buildcraft/BuildCraftEnergy.java | 12 +++---- common/buildcraft/BuildCraftSilicon.java | 10 +++--- common/buildcraft/BuildCraftTransport.java | 12 +++---- common/buildcraft/core/proxy/CoreProxy.java | 4 ++- 6 files changed, 45 insertions(+), 43 deletions(-) diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index 0c685382..c72cd496 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -295,33 +295,33 @@ public class BuildCraftBuilders { public static void loadRecipes() { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(templateItem, 1), new Object[]{"ppp", "pip", "ppp", Character.valueOf('i'), - new ItemStack(Item.dyePowder, 1, 0), Character.valueOf('p'), Item.paper}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(templateItem, 1), new Object[]{"ppp", "pip", "ppp", 'i', + new ItemStack(Item.dyePowder, 1, 0), 'p', Item.paper}); -// CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), new Object[]{"ppp", "pip", "ppp", Character.valueOf('i'), -// new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('p'), Item.paper}); +// CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), new Object[]{"ppp", "pip", "ppp", 'i', +// new ItemStack(Item.dyePowder, 1, 4), 'p', Item.paper}); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(markerBlock, 1), new Object[]{"l ", "r ", Character.valueOf('l'), - new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('r'), Block.torchRedstoneActive}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(markerBlock, 1), new Object[]{"l ", "r ", 'l', + new ItemStack(Item.dyePowder, 1, 4), 'r', Block.torchRedstoneActive}); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(pathMarkerBlock, 1), new Object[]{"l ", "r ", Character.valueOf('l'), - new ItemStack(Item.dyePowder, 1, 2), Character.valueOf('r'), Block.torchRedstoneActive}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(pathMarkerBlock, 1), new Object[]{"l ", "r ", 'l', + new ItemStack(Item.dyePowder, 1, 2), 'r', Block.torchRedstoneActive}); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(fillerBlock, 1), new Object[]{"btb", "ycy", "gCg", Character.valueOf('b'), - new ItemStack(Item.dyePowder, 1, 0), Character.valueOf('t'), markerBlock, Character.valueOf('y'), new ItemStack(Item.dyePowder, 1, 11), - Character.valueOf('c'), Block.workbench, Character.valueOf('g'), BuildCraftCore.goldGearItem, Character.valueOf('C'), Block.chest}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(fillerBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b', + new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11), + 'c', Block.workbench, 'g', BuildCraftCore.goldGearItem, 'C', Block.chest}); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(builderBlock, 1), new Object[]{"btb", "ycy", "gCg", Character.valueOf('b'), - new ItemStack(Item.dyePowder, 1, 0), Character.valueOf('t'), markerBlock, Character.valueOf('y'), new ItemStack(Item.dyePowder, 1, 11), - Character.valueOf('c'), Block.workbench, Character.valueOf('g'), BuildCraftCore.diamondGearItem, Character.valueOf('C'), Block.chest}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(builderBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b', + new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11), + 'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C', Block.chest}); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(architectBlock, 1), new Object[]{"btb", "ycy", "gCg", Character.valueOf('b'), - new ItemStack(Item.dyePowder, 1, 0), Character.valueOf('t'), markerBlock, Character.valueOf('y'), new ItemStack(Item.dyePowder, 1, 11), - Character.valueOf('c'), Block.workbench, Character.valueOf('g'), BuildCraftCore.diamondGearItem, Character.valueOf('C'), + CoreProxy.proxy.addCraftingRecipe(new ItemStack(architectBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b', + new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11), + 'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C', new ItemStack(templateItem, 1)}); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(libraryBlock, 1), new Object[]{"bbb", "bBb", "bbb", Character.valueOf('b'), - new ItemStack(blueprintItem), Character.valueOf('B'), Block.bookShelf}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(libraryBlock, 1), new Object[]{"bbb", "bBb", "bbb", 'b', + new ItemStack(blueprintItem), 'B', Block.bookShelf}); // / INIT FILLER PATTERNS diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index bff23b3a..76bec134 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -339,13 +339,13 @@ public class BuildCraftCore { } public void loadRecipes() { - GameRegistry.addRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", Character.valueOf('I'), Item.ingotIron, Character.valueOf('G'), stoneGearItem); - GameRegistry.addRecipe(new ItemStack(woodenGearItem), " S ", "S S", " S ", Character.valueOf('S'), Item.stick); - GameRegistry.addRecipe(new ItemStack(stoneGearItem), " I ", "IGI", " I ", Character.valueOf('I'), Block.cobblestone, Character.valueOf('G'), + CoreProxy.proxy.addCraftingRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", 'I', Item.ingotIron, 'G', stoneGearItem); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(woodenGearItem), " S ", "S S", " S ", 'S', "stickWood"); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(stoneGearItem), " I ", "IGI", " I ", 'I', "cobblestone", 'G', woodenGearItem); - GameRegistry.addRecipe(new ItemStack(ironGearItem), " I ", "IGI", " I ", Character.valueOf('I'), Item.ingotIron, Character.valueOf('G'), stoneGearItem); - GameRegistry.addRecipe(new ItemStack(goldGearItem), " I ", "IGI", " I ", Character.valueOf('I'), Item.ingotGold, Character.valueOf('G'), ironGearItem); - GameRegistry.addRecipe(new ItemStack(diamondGearItem), " I ", "IGI", " I ", Character.valueOf('I'), Item.diamond, Character.valueOf('G'), goldGearItem); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(ironGearItem), " I ", "IGI", " I ", 'I', Item.ingotIron, 'G', stoneGearItem); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(goldGearItem), " I ", "IGI", " I ", 'I', Item.ingotGold, 'G', ironGearItem); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(diamondGearItem), " I ", "IGI", " I ", 'I', Item.diamond, 'G', goldGearItem); } @EventHandler diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 361b152f..bc7f5882 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -246,12 +246,12 @@ public class BuildCraftEnergy { public static void loadRecipes() { CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 0), - new Object[]{"www", " g ", "GpG", Character.valueOf('w'), "plankWood", Character.valueOf('g'), Block.glass, Character.valueOf('G'), - BuildCraftCore.woodenGearItem, Character.valueOf('p'), Block.pistonBase}); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 1), new Object[]{"www", " g ", "GpG", Character.valueOf('w'), Block.cobblestone, - Character.valueOf('g'), Block.glass, Character.valueOf('G'), BuildCraftCore.stoneGearItem, Character.valueOf('p'), Block.pistonBase}); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 2), new Object[]{"www", " g ", "GpG", Character.valueOf('w'), Item.ingotIron, - Character.valueOf('g'), Block.glass, Character.valueOf('G'), BuildCraftCore.ironGearItem, Character.valueOf('p'), Block.pistonBase}); + new Object[]{"www", " g ", "GpG", 'w', "plankWood", 'g', Block.glass, 'G', + BuildCraftCore.woodenGearItem, 'p', Block.pistonBase}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 1), new Object[]{"www", " g ", "GpG", 'w', "cobblestone", + 'g', Block.glass, 'G', BuildCraftCore.stoneGearItem, 'p', Block.pistonBase}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 2), new Object[]{"www", " g ", "GpG", 'w', Item.ingotIron, + 'g', Block.glass, 'G', BuildCraftCore.ironGearItem, 'p', Block.pistonBase}); } @EventHandler diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 735d164e..3d1a2433 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -93,14 +93,14 @@ public class BuildCraftSilicon { public static void loadRecipes() { CoreProxy.proxy.addCraftingRecipe(new ItemStack(laserBlock), - new Object[]{"ORR", "DDR", "ORR", Character.valueOf('O'), Block.obsidian, Character.valueOf('R'), Item.redstone, Character.valueOf('D'), + new Object[]{"ORR", "DDR", "ORR", 'O', Block.obsidian, 'R', Item.redstone, 'D', Item.diamond,}); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 0), new Object[]{"ORO", "ODO", "OGO", Character.valueOf('O'), Block.obsidian, - Character.valueOf('R'), Item.redstone, Character.valueOf('D'), Item.diamond, Character.valueOf('G'), BuildCraftCore.diamondGearItem,}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 0), new Object[]{"ORO", "ODO", "OGO", 'O', Block.obsidian, + 'R', Item.redstone, 'D', Item.diamond, 'G', BuildCraftCore.diamondGearItem,}); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 1), new Object[]{"OWO", "OCO", "ORO", Character.valueOf('O'), Block.obsidian, - Character.valueOf('W'), Block.workbench, Character.valueOf('C'), Block.chest, Character.valueOf('R'), new ItemStack(redstoneChipset, 1, 0),}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 1), new Object[]{"OWO", "OCO", "ORO", 'O', Block.obsidian, + 'W', Block.workbench, 'C', Block.chest, 'R', new ItemStack(redstoneChipset, 1, 0),}); // Add reverse recipies for all gates // Iron diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 9787d97e..74c6787f 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -278,8 +278,8 @@ public class BuildCraftTransport { // Fixing retro-compatiblity pipeItemsWood = buildPipe(DefaultProps.PIPE_ITEMS_WOOD_ID, PipeItemsWood.class, "Wooden Transport Pipe", "plankWood", Block.glass, "plankWood"); pipeItemsEmerald = buildPipe(DefaultProps.PIPE_ITEMS_EMERALD_ID, PipeItemsEmerald.class, "Emerald Transport Pipe", Item.emerald, Block.glass, Item.emerald); - pipeItemsCobblestone = buildPipe(DefaultProps.PIPE_ITEMS_COBBLESTONE_ID, PipeItemsCobblestone.class, "Cobblestone Transport Pipe", Block.cobblestone, Block.glass, Block.cobblestone); - pipeItemsStone = buildPipe(DefaultProps.PIPE_ITEMS_STONE_ID, PipeItemsStone.class, "Stone Transport Pipe", Block.stone, Block.glass, Block.stone); + pipeItemsCobblestone = buildPipe(DefaultProps.PIPE_ITEMS_COBBLESTONE_ID, PipeItemsCobblestone.class, "Cobblestone Transport Pipe", "cobblestone", Block.glass, "cobblestone"); + pipeItemsStone = buildPipe(DefaultProps.PIPE_ITEMS_STONE_ID, PipeItemsStone.class, "Stone Transport Pipe", "stone", Block.glass, "stone"); pipeItemsQuartz = buildPipe(DefaultProps.PIPE_ITEMS_QUARTZ_ID, PipeItemsQuartz.class, "Quartz Transport Pipe", Block.blockNetherQuartz, Block.glass, Block.blockNetherQuartz); pipeItemsIron = buildPipe(DefaultProps.PIPE_ITEMS_IRON_ID, PipeItemsIron.class, "Iron Transport Pipe", Item.ingotIron, Block.glass, Item.ingotIron); pipeItemsGold = buildPipe(DefaultProps.PIPE_ITEMS_GOLD_ID, PipeItemsGold.class, "Golden Transport Pipe", Item.ingotGold, Block.glass, Item.ingotGold); @@ -428,15 +428,15 @@ public class BuildCraftTransport { // Add pipe recipes for (PipeRecipe pipe : pipeRecipes) { if (pipe.isShapeless) { - GameRegistry.addShapelessRecipe(pipe.result, pipe.input); + CoreProxy.proxy.addShapelessRecipe(pipe.result, pipe.input); } else { CoreProxy.proxy.addCraftingRecipe(pipe.result, pipe.input); } } CoreProxy.proxy.addCraftingRecipe(new ItemStack(filteredBufferBlock, 1), - new Object[]{"wdw", "wcw", "wpw", Character.valueOf('w'), "plankWood", Character.valueOf('d'), - BuildCraftTransport.pipeItemsDiamond, Character.valueOf('c'), Block.chest, Character.valueOf('p'), + new Object[]{"wdw", "wcw", "wpw", 'w', "plankWood", 'd', + BuildCraftTransport.pipeItemsDiamond, 'c', Block.chest, 'p', Block.pistonBase}); //Facade turning helper @@ -463,7 +463,7 @@ public class BuildCraftTransport { if (ingredients.length == 3) { recipe.result = new ItemStack(res, 8); - recipe.input = new Object[]{"ABC", Character.valueOf('A'), ingredients[0], Character.valueOf('B'), ingredients[1], Character.valueOf('C'), ingredients[2]}; + recipe.input = new Object[]{"ABC", 'A', ingredients[0], 'B', ingredients[1], 'C', ingredients[2]}; pipeRecipes.add(recipe); } else if (ingredients.length == 2) { diff --git a/common/buildcraft/core/proxy/CoreProxy.java b/common/buildcraft/core/proxy/CoreProxy.java index ed15fa5a..14ea71c5 100644 --- a/common/buildcraft/core/proxy/CoreProxy.java +++ b/common/buildcraft/core/proxy/CoreProxy.java @@ -34,6 +34,7 @@ import net.minecraft.util.ChatMessageComponent; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; public class CoreProxy { @@ -126,7 +127,8 @@ public class CoreProxy { } public void addShapelessRecipe(ItemStack result, Object... recipe) { - GameRegistry.addShapelessRecipe(result, recipe); + CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(result, recipe)); + //GameRegistry.addShapelessRecipe(result, recipe); } public void sendToPlayers(Packet packet, World world, int x, int y, int z, int maxDistance) { From daf79abda5f34802938f33fcad453d9222f885ac Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 25 Sep 2013 17:48:39 -0700 Subject: [PATCH 055/121] Fix for Pumps Closes #1224 --- common/buildcraft/factory/TilePump.java | 24 ++-- .../transport/pipes/PipePowerIron.java | 107 ++++++++++++++++++ .../triggers/ActionPowerLimiter.java | 41 +++++++ 3 files changed, 164 insertions(+), 8 deletions(-) create mode 100644 common/buildcraft/transport/pipes/PipePowerIron.java create mode 100644 common/buildcraft/transport/triggers/ActionPowerLimiter.java diff --git a/common/buildcraft/factory/TilePump.java b/common/buildcraft/factory/TilePump.java index 5285ef1e..04d96439 100644 --- a/common/buildcraft/factory/TilePump.java +++ b/common/buildcraft/factory/TilePump.java @@ -36,6 +36,7 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.Set; import java.util.TreeMap; +import net.minecraft.block.material.Material; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -59,7 +60,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor private TileBuffer[] tileBuffer = null; private SafeTimeTracker timer = new SafeTimeTracker(); private int tick = Utils.RANDOM.nextInt(); - private int numFluidBlocksFound = 0; + private int numFluidBlocksFound = 0; public TilePump() { powerHandler = new PowerHandler(this, Type.MACHINE); @@ -82,8 +83,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor if (CoreProxy.proxy.isRenderWorld(worldObj)) - return; - + return; + pushToConsumers(); if (tube.posY - aimY > 0.01) { @@ -124,7 +125,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor if (isPumpableFluid(xCoord, y, zCoord)) { aimY = y; return; - } else if (!worldObj.isAirBlock(xCoord, y, zCoord)) { + } else if (isBlocked(xCoord, y, zCoord)) { return; } } @@ -133,8 +134,13 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor } } + private boolean isBlocked(int x, int y, int z) { + Material mat = worldObj.getBlockMaterial(x, y, z); + return mat.blocksMovement(); + } + private void pushToConsumers() { - if(tileBuffer == null) + if (tileBuffer == null) tileBuffer = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, false); FluidUtils.pushFluidToConsumers(tank, 400, tileBuffer); } @@ -232,7 +238,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor queueForPumping(index.x - 1, index.y, index.z, visitedBlocks, fluidsFound, pumpingFluid); queueForPumping(index.x, index.y, index.z + 1, visitedBlocks, fluidsFound, pumpingFluid); queueForPumping(index.x, index.y, index.z - 1, visitedBlocks, fluidsFound, pumpingFluid); - + if (pumpingFluid == FluidRegistry.WATER && !BuildCraftCore.consumeWaterSources && numFluidBlocksFound >= 9) return; @@ -265,6 +271,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor return false; if (!isFluidAllowed(fluid)) return false; + if (tank.getAcceptedFluid() != null && tank.getAcceptedFluid() != fluid) + return false; return true; } @@ -315,11 +323,11 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor @Override public boolean isActive() { BlockIndex next = getNextIndexToPump(false); - + if (next != null) { return isPumpableFluid(next.x, next.y, next.z); } - + return false; } diff --git a/common/buildcraft/transport/pipes/PipePowerIron.java b/common/buildcraft/transport/pipes/PipePowerIron.java new file mode 100644 index 00000000..76ce44e8 --- /dev/null +++ b/common/buildcraft/transport/pipes/PipePowerIron.java @@ -0,0 +1,107 @@ +/** + * BuildCraft is open-source. It is distributed under the terms of the + * BuildCraft Open Source License. It grants rights to read, modify, compile or + * run the code. It does *NOT* grant the right to redistribute this software or + * its modifications in any form, binary or source, except if expressively + * granted by the copyright holder. + */ +package buildcraft.transport.pipes; + +import buildcraft.BuildCraftTransport; +import buildcraft.api.core.IIconProvider; +import buildcraft.api.tools.IToolWrench; +import buildcraft.core.utils.StringUtils; +import buildcraft.transport.Pipe; +import buildcraft.transport.PipeIconProvider; +import buildcraft.transport.PipeTransportPower; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.util.ChatMessageComponent; +import net.minecraftforge.common.ForgeDirection; + +public class PipePowerIron extends Pipe { + + public static enum PowerMode { + + M2(2), M4(4), M8(8), M16(16), M32(32), M64(64), M128(128); + public static final PowerMode[] VALUES = values(); + private final int maxPower; + + private PowerMode(int max) { + this.maxPower = max; + } + + public PowerMode getNext() { + PowerMode next = VALUES[(ordinal() + 1) % (VALUES.length - 1)]; + return next; + } + + public PowerMode getPrevious() { + PowerMode previous = VALUES[(ordinal() + VALUES.length - 2) % (VALUES.length - 1)]; + return previous; + } + + public static PowerMode fromId(int id) { + if (id < 0 || id >= VALUES.length) { + return M128; + } + return VALUES[id]; + } + } + + public PipePowerIron(int itemID) { + super(new PipeTransportPower(), itemID); + transport.initFromPipe(getClass()); + } + + @Override + public int getIconIndex(ForgeDirection direction) { + if (container == null) + return PipeIconProvider.TYPE.PipePowerIronM128.ordinal(); + return PipeIconProvider.TYPE.PipePowerIronM2.ordinal() + container.getBlockMetadata(); + } + + @Override + public boolean blockActivated(EntityPlayer player) { + Item equipped = player.getCurrentEquippedItem() != null ? player.getCurrentEquippedItem().getItem() : null; + if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(player, container.xCoord, container.yCoord, container.zCoord)) { + if (player.isSneaking()) { + setMode(getMode().getPrevious()); + } else { + setMode(getMode().getNext()); + } + player.addChatMessage(String.format(StringUtils.localize("chat.pipe.power.iron.mode"), getMode().maxPower)); + + ((IToolWrench) equipped).wrenchUsed(player, container.xCoord, container.yCoord, container.zCoord); + return true; + } + + return false; + } + + @Override + public void updateEntity() { + super.updateEntity(); + transport.maxPower = getMode().maxPower; + } + + public PowerMode getMode() { + return PowerMode.fromId(container.getBlockMetadata()); + } + + public void setMode(PowerMode mode) { + if (mode.ordinal() != container.getBlockMetadata()) { + container.worldObj.setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, mode.ordinal(), 3); + container.scheduleRenderUpdate(); + container.markBlockForUpdate(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIconProvider getIconProvider() { + return BuildCraftTransport.instance.pipeIconProvider; + } +} diff --git a/common/buildcraft/transport/triggers/ActionPowerLimiter.java b/common/buildcraft/transport/triggers/ActionPowerLimiter.java new file mode 100644 index 00000000..0b9da043 --- /dev/null +++ b/common/buildcraft/transport/triggers/ActionPowerLimiter.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public License + * 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport.triggers; + +import buildcraft.core.triggers.BCAction; +import java.util.Locale; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.util.Icon; +import net.minecraftforge.common.ForgeDirection; + +public class ActionPipeDirection extends BCAction { + + private Icon icon; + public final ForgeDirection direction; + + public ActionPipeDirection(int id, ForgeDirection direction) { + super(id, "buildcraft.pipe.dir." + direction.name().toLowerCase(Locale.ENGLISH)); + + this.direction = direction; + } + + @Override + public String getDescription() { + return direction.name().substring(0, 1) + direction.name().substring(1).toLowerCase(Locale.ENGLISH) + " Pipe Direction"; + } + + @Override + public Icon getIcon() { + return icon; + } + + @Override + public void registerIcons(IconRegister iconRegister) { + icon = iconRegister.registerIcon("buildcraft:triggers/trigger_dir_" + direction.name().toLowerCase(Locale.ENGLISH)); + } +} From 68b5c5267d8b5604789ea666ffa39fb1fdac5988 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 25 Sep 2013 18:16:59 -0700 Subject: [PATCH 056/121] Added Iron Kinesis Pipe The Iron Kinesis Pipe allows you select its throughput limiter via Wrench or Gate Action. The possible values are: 2, 4, 8, 16, 32 , 64, and 128 MJ/t --- build.xml | 4 +- .../textures/blocks/pipePowerIronM128.png | Bin 0 -> 265 bytes .../textures/blocks/pipePowerIronM16.png | Bin 0 -> 280 bytes .../textures/blocks/pipePowerIronM2.png | Bin 0 -> 283 bytes .../textures/blocks/pipePowerIronM32.png | Bin 0 -> 287 bytes .../textures/blocks/pipePowerIronM4.png | Bin 0 -> 290 bytes .../textures/blocks/pipePowerIronM64.png | Bin 0 -> 284 bytes .../textures/blocks/pipePowerIronM8.png | Bin 0 -> 285 bytes .../items/triggers/trigger_limiter_m128.png | Bin 0 -> 249 bytes .../items/triggers/trigger_limiter_m16.png | Bin 0 -> 257 bytes .../items/triggers/trigger_limiter_m2.png | Bin 0 -> 256 bytes .../items/triggers/trigger_limiter_m32.png | Bin 0 -> 256 bytes .../items/triggers/trigger_limiter_m4.png | Bin 0 -> 257 bytes .../items/triggers/trigger_limiter_m64.png | Bin 0 -> 254 bytes .../items/triggers/trigger_limiter_m8.png | Bin 0 -> 258 bytes .../lang/buildcraft/en_US.properties | 5 +++ common/buildcraft/BuildCraftTransport.java | 28 ++++++++------ common/buildcraft/core/utils/EnumColor.java | 4 +- .../buildcraft/core/utils/Localization.java | 16 ++++++++ common/buildcraft/transport/ItemPipe.java | 9 +---- .../transport/PipeIconProvider.java | 12 +++++- .../transport/PipeToolTipManager.java | 20 ++++++++-- .../transport/PipeTransportPower.java | 16 ++++++-- .../transport/TransportProxyClient.java | 1 + .../transport/pipes/PipePowerIron.java | 35 +++++++++++++++--- .../triggers/ActionPowerLimiter.java | 16 ++++---- 26 files changed, 120 insertions(+), 46 deletions(-) create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM128.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM16.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM2.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM32.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM4.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM64.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM8.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m128.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m16.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m2.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m32.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m4.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m64.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m8.png diff --git a/build.xml b/build.xml index e8b38eab..a82dea32 100644 --- a/build.xml +++ b/build.xml @@ -18,8 +18,8 @@ - - + + diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM128.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM128.png new file mode 100644 index 0000000000000000000000000000000000000000..874cddaa1f1fe5ec1e29ebbbfff6657313fb8b01 GIT binary patch literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsH)Y| z#WBRf|7c$zUxNXM^UnXaW#=*@9m8V39L`9VT>Qf*c%^wya_RFQa7IQ$63NEQiLJy`YMJwTmQ2f%qomyIAgZ0G<4OxtP71m2QhfM`njxg HN@xNAQ<-60 literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM16.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM16.png new file mode 100644 index 0000000000000000000000000000000000000000..a354a891241e853097309ff86543eb2d762e55c7 GIT binary patch literal 280 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsA`I* zi(`m||Jn)Md<_O1&O3K5ziIhA%1-I#B0aM*gD!oym04@Q>KVz|-pF`+;?1rw#yh{x zHzbEh{1sEk<~*?B*7W&l1}BZB?L&&cTfA4hD&oCtPV0|H8b2Z>9~hsj+{<8h_@95n zlRqe+F$mx^UKR&$VtJ(%7W`3$>|;TOL@Ko!ao<!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsA{^W zi(`m||I!JJd`A^HoOk~8du;hvEb4eiTKE1)SIvDoQK8vu%Qt^K`e^nFS;_wD)B~og zzO8U)koc|aa80ZsZEM^8stuFF)#_J0`xG(1Oskb~FXNQWn)^>2cv%_&wM9( z*Ej6&awz-f%lqlaiDh#(8a!S(>$Klmw+~C%C)acPs*7_TcpN7=LH+|r!!LaWvp{i% a&GJ60y;iM^33&%}B7>)^pUXO@geCw`7if!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsA{&S zi(`m||I!JKd`A>GoPU1)Ew%sh<{L_rX70{CyDH$uX`|IyYrp21&8w_1eBUQ|dox$U z>U?Iqe8xz3hC^Ap|4${T$Itu|F!%K1J8wg@rme8y{@ERKh9UK*d)6|Z-xjqu4+o|@ z=v3`yI3=cFS-(u|X5Qur(^gsXUETTSN*2$*lL?=u3s~*+VAz(P%8>WR<7z*{&N`+U dNB8J6q{Yvi9keRA_$A2W44$rjF6*2UngGh=YmEQ^ literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM4.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM4.png new file mode 100644 index 0000000000000000000000000000000000000000..bfddb9050530a88a032790ff54e9f824368061b1 GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsA`_4 zi(`m||I!JJe1{cym_L8s+g2X*=7^5V0^cjEI4vHAB!;ftdhhJ9=iKIT)>VZz+RS!~ zv-+!88#eA|N|9ycSZ(@8yV>)e<&WU4`u(M*D;0TO@GiJB`_WN}GYqy0pA%EIwpTJ0 zEl}Jta^#YS(R2*c^pKAEi5YBLA gJH!2oy9{UK!aTiK{oQj+7U)t2Pgg&ebxsLQ03H)-WB>pF literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM64.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM64.png new file mode 100644 index 0000000000000000000000000000000000000000..4503f6b776ffef3678ab03a56a547c76a6ae5403 GIT binary patch literal 284 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsA`6% zi(`m||I!KEe1{DC%k_dazi&OHqbx1QRis&(G!pOUz-f|1nBv|l@KxPMLMcdus` zuzdaK&&;SNr88T%gq$s0aV~XvSaN}S^U4353nzE8JovhX=RoKD)&E2lzUMP+p81?D b;T!8>%ivXJK5JJ4-N@kS>gTe~DWM4fB2;OB literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM8.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM8.png new file mode 100644 index 0000000000000000000000000000000000000000..4d83d7ef114e64eadceff03a2ce58c8fc0a602ff GIT binary patch literal 285 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsA{IC zi(`m||J(`Oe1{DAmH>w|XDV=i&Po&e3~kN<+omqYV2FC^M+NS7(T? cv14%2D^~VfmAC$LG|-U@p00i_>zopr0L>k0-T(jq literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m128.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m128.png new file mode 100644 index 0000000000000000000000000000000000000000..2ea44f1dba70a4ef8cb426687dc5d03059a39681 GIT binary patch literal 249 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0gN_s>q|Kvfx@E{-7<{!33AavgDCIDFvG|I5Zog literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m16.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m16.png new file mode 100644 index 0000000000000000000000000000000000000000..2a8224270c361f539baf8968710f88a5b90949d5 GIT binary patch literal 257 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0gN_s>q|Kve~vE{-7<{!33A@-;Z{Fgw3Xgb eGJ1En7u%|wn_gU9c;Xt+ZU#?RKbLh*2~7YS;aOt< literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m2.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m2.png new file mode 100644 index 0000000000000000000000000000000000000000..5b066173f69c9c3456e3d4eb68c8610bf5bc3d07 GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0gN_s>q|KvnskE{-7<{!33A@*N5ga6Wiv&fx~Z2ao;ZpDErwepYz+sW2i8|GmsJLDYqZnl=q gr;m^K-9Pu0O|P`Im@`F;8)!9yr>mdKI;Vst0Gpayod5s; literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m32.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m32.png new file mode 100644 index 0000000000000000000000000000000000000000..b4136883df4000f8abece9faac16d90db771c5bf GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0gN_s>q|KvnskE{-7<{!33A@-;Z{Fgw$!ldZ8SA?ZguAZts+PGI4IPMAdRzpw$eXu6{1- HoD!M<q|Kve~vE{-7<{!33A@*ObXIeg&X9)JI{43b`%npShz5AC`Zwg1Ww*WT|> zj@5TGn6>>EV9e$DugG*u;-53i7Q;X792vE(2q|KvlV(E{-7<{!33A@-;Z{Fgw?p7dQFd%UId;(Qr%1!5bVCj7+NNnq$UA$B_Vh1Y%607cg&@|) g$!N;n-rgyq|KvjjFE{-7<{!33A@-aK|96s>7a^5~e-kicIvlNc*P+0SP&gbb;^?{Gm ziyqs%I7lC^?`SY<`!B$l%ky86>6XMlXO=C7f7&@Rl7H|EUO4taUP-6O__~q~|N5O` xiIo*+w{o05oW0I9LN2aY_t2*gvwoM&(=XJVSS+{e@^hf&44$rjF6*2UngH#0Spon6 literal 0 HcmV?d00001 diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index fee36ca3..8c9358f8 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -1,5 +1,7 @@ # Master language file +chat.pipe.power.iron.mode=Switched to %d MJ/t limit + gate.pipe.empty=Pipe Empty gate.pipe.containsItems=Items Traversing gate.pipe.containsFluids=Fluid Traversing @@ -83,6 +85,7 @@ item.PipePowerWood=Wooden Kinesis Pipe item.PipePowerCobblestone=Cobblestone Kinesis Pipe item.PipePowerStone=Stone Kinesis Pipe item.PipePowerQuartz=Quartz Kinesis Pipe +item.PipePowerIron=Iron Kinesis Pipe item.PipePowerGold=Golden Kinesis Pipe item.PipePowerDiamond=Diamond Kinesis Pipe item.PipeItemsStripes=Stripes Transport Pipe @@ -142,4 +145,6 @@ tip.PipeItemsSandstone=Only connects to other pipes tip.PipeItemsStone=Basic pipe, medium drag\nWon't connect to Cobblestone or Quartz tip.PipeItemsVoid=Destroys items tip.PipeItemsWood=Extraction pipe +tip.PipePowerWood=Power Input Pipe +tip.PipePowerIron=Selectable Limiter Pipe tip.PipeStructureCobblestone=Support pipe diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 74c6787f..026a147b 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -65,6 +65,8 @@ import buildcraft.transport.pipes.PipeItemsWood; import buildcraft.transport.pipes.PipePowerCobblestone; import buildcraft.transport.pipes.PipePowerDiamond; import buildcraft.transport.pipes.PipePowerGold; +import buildcraft.transport.pipes.PipePowerIron; +import buildcraft.transport.pipes.PipePowerIron.PowerMode; import buildcraft.transport.pipes.PipePowerQuartz; import buildcraft.transport.pipes.PipePowerStone; import buildcraft.transport.pipes.PipePowerWood; @@ -72,21 +74,18 @@ import buildcraft.transport.pipes.PipeStructureCobblestone; import buildcraft.transport.triggers.ActionEnergyPulser; import buildcraft.transport.triggers.ActionPipeColor; import buildcraft.transport.triggers.ActionPipeDirection; +import buildcraft.transport.triggers.ActionPowerLimiter; import buildcraft.transport.triggers.ActionSignalOutput; import buildcraft.transport.triggers.ActionSingleEnergyPulse; import buildcraft.transport.triggers.TriggerFilteredBufferInventoryLevel; import buildcraft.transport.triggers.TriggerPipeContents; import buildcraft.transport.triggers.TriggerPipeContents.Kind; import buildcraft.transport.triggers.TriggerPipeSignal; -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; -import com.google.common.primitives.Ints; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; -import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; @@ -94,8 +93,6 @@ import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import java.util.LinkedList; -import java.util.logging.Level; -import java.util.logging.Logger; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; @@ -143,6 +140,7 @@ public class BuildCraftTransport { public static Item pipePowerCobblestone; public static Item pipePowerStone; public static Item pipePowerQuartz; + public static Item pipePowerIron; public static Item pipePowerGold; public static Item pipePowerDiamond; public static ItemFacade facadeItem; @@ -176,6 +174,7 @@ public class BuildCraftTransport { public static BCAction actionSingleEnergyPulse = new ActionSingleEnergyPulse(DefaultProps.ACTION_SINGLE_ENERGY_PULSE); public static BCAction[] actionPipeColor = new BCAction[16]; public static BCAction[] actionPipeDirection = new BCAction[16]; + public static BCAction[] actionPowerLimiter = new BCAction[7]; @Instance("BuildCraft|Transport") public static BuildCraftTransport instance; public IIconProvider pipeIconProvider = new PipeIconProvider(); @@ -299,12 +298,13 @@ public class BuildCraftTransport { pipeFluidsSandstone = buildPipe(DefaultProps.PIPE_LIQUIDS_SANDSTONE_ID, PipeFluidsSandstone.class, "Sandstone Waterproof Pipe", pipeWaterproof, pipeItemsSandstone); pipeFluidsVoid = buildPipe(DefaultProps.PIPE_LIQUIDS_VOID_ID, PipeFluidsVoid.class, "Void Waterproof Pipe", pipeWaterproof, pipeItemsVoid); - pipePowerWood = buildPipe(DefaultProps.PIPE_POWER_WOOD_ID, PipePowerWood.class, "Wooden Conductive Pipe", Item.redstone, pipeItemsWood); - pipePowerCobblestone = buildPipe(DefaultProps.PIPE_POWER_COBBLESTONE_ID, PipePowerCobblestone.class, "Cobblestone Conductive Pipe", Item.redstone, pipeItemsCobblestone); - pipePowerStone = buildPipe(DefaultProps.PIPE_POWER_STONE_ID, PipePowerStone.class, "Stone Conductive Pipe", Item.redstone, pipeItemsStone); - pipePowerQuartz = buildPipe(DefaultProps.PIPE_POWER_QUARTZ_ID, PipePowerQuartz.class, "Quartz Conductive Pipe", Item.redstone, pipeItemsQuartz); - pipePowerGold = buildPipe(DefaultProps.PIPE_POWER_GOLD_ID, PipePowerGold.class, "Golden Conductive Pipe", Item.redstone, pipeItemsGold); - pipePowerDiamond = buildPipe(DefaultProps.PIPE_POWER_DIAMOND_ID, PipePowerDiamond.class, "Diamond Conductive Pipe", Item.redstone, pipeItemsDiamond); + pipePowerWood = buildPipe(DefaultProps.PIPE_POWER_WOOD_ID, PipePowerWood.class, "Wooden Kinesis Pipe", Item.redstone, pipeItemsWood); + pipePowerCobblestone = buildPipe(DefaultProps.PIPE_POWER_COBBLESTONE_ID, PipePowerCobblestone.class, "Cobblestone Kinesis Pipe", Item.redstone, pipeItemsCobblestone); + pipePowerStone = buildPipe(DefaultProps.PIPE_POWER_STONE_ID, PipePowerStone.class, "Stone Kinesis Pipe", Item.redstone, pipeItemsStone); + pipePowerQuartz = buildPipe(DefaultProps.PIPE_POWER_QUARTZ_ID, PipePowerQuartz.class, "Quartz Kinesis Pipe", Item.redstone, pipeItemsQuartz); + pipePowerIron = buildPipe(DefaultProps.PIPE_POWER_IRON_ID, PipePowerIron.class, "Iron Kinesis Pipe", Item.redstone, pipeItemsIron); + pipePowerGold = buildPipe(DefaultProps.PIPE_POWER_GOLD_ID, PipePowerGold.class, "Golden Kinesis Pipe", Item.redstone, pipeItemsGold); + pipePowerDiamond = buildPipe(DefaultProps.PIPE_POWER_DIAMOND_ID, PipePowerDiamond.class, "Diamond Kinesis Pipe", Item.redstone, pipeItemsDiamond); pipeStructureCobblestone = buildPipe(DefaultProps.PIPE_STRUCTURE_COBBLESTONE_ID, PipeStructureCobblestone.class, "Cobblestone Structure Pipe", Block.gravel, pipeItemsCobblestone); @@ -418,6 +418,10 @@ public class BuildCraftTransport { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { actionPipeDirection[direction.ordinal()] = new ActionPipeDirection(-1, direction); } + + for (PowerMode limit : PowerMode.VALUES) { + actionPowerLimiter[limit.ordinal()] = new ActionPowerLimiter(-1, limit); + } } public void loadRecipes() { diff --git a/common/buildcraft/core/utils/EnumColor.java b/common/buildcraft/core/utils/EnumColor.java index dcbc39a8..426f3a15 100644 --- a/common/buildcraft/core/utils/EnumColor.java +++ b/common/buildcraft/core/utils/EnumColor.java @@ -132,12 +132,12 @@ public enum EnumColor { } public EnumColor getNext() { - EnumColor next = VALUES[(ordinal() + 1) % (VALUES.length - 1)]; + EnumColor next = VALUES[(ordinal() + 1) % VALUES.length]; return next; } public EnumColor getPrevious() { - EnumColor previous = VALUES[(ordinal() + VALUES.length - 2) % (VALUES.length - 1)]; + EnumColor previous = VALUES[(ordinal() + VALUES.length - 1) % VALUES.length]; return previous; } diff --git a/common/buildcraft/core/utils/Localization.java b/common/buildcraft/core/utils/Localization.java index 34fc65c8..9ec1fa45 100644 --- a/common/buildcraft/core/utils/Localization.java +++ b/common/buildcraft/core/utils/Localization.java @@ -64,6 +64,22 @@ public class Localization { return mappings.getProperty(key, defaultMappings.getProperty(key, key)); } + + public static synchronized boolean hasKey(String key) { + if (getCurrentLanguage() == null) { + return false; + } + if (!getCurrentLanguage().equals(loadedLanguage)) { + defaultMappings.clear(); + mappings.clear(); + for (modInfo mInfo : mods) { + load(mInfo.modName, mInfo.defaultLanguage); + } + loadedLanguage = getCurrentLanguage(); + } + + return mappings.getProperty(key, defaultMappings.getProperty(key)) != null; + } private static void load(String path, String default_language) { InputStream langStream = null; diff --git a/common/buildcraft/transport/ItemPipe.java b/common/buildcraft/transport/ItemPipe.java index fa6e4b80..6f655718 100644 --- a/common/buildcraft/transport/ItemPipe.java +++ b/common/buildcraft/transport/ItemPipe.java @@ -125,12 +125,7 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) { super.addInformation(stack, player, list, advanced); Class pipe = BlockGenericPipe.pipes.get(itemID); - String toolTip = PipeToolTipManager.getToolTip(pipe); - if (toolTip != null) { - String[] tips = toolTip.split("\\n"); - for (String tip : tips) { - list.add(tip); - } - } + List toolTip = PipeToolTipManager.getToolTip(pipe); + list.addAll(toolTip); } } diff --git a/common/buildcraft/transport/PipeIconProvider.java b/common/buildcraft/transport/PipeIconProvider.java index ba487572..e9ba64f2 100644 --- a/common/buildcraft/transport/PipeIconProvider.java +++ b/common/buildcraft/transport/PipeIconProvider.java @@ -91,6 +91,14 @@ public class PipeIconProvider implements IIconProvider { PipePowerCobblestone("pipePowerCobblestone"), PipePowerWood_Standard("pipePowerWood_standard"), // + PipePowerIronM2("pipePowerIronM2"), + PipePowerIronM4("pipePowerIronM4"), + PipePowerIronM8("pipePowerIronM8"), + PipePowerIronM16("pipePowerIronM16"), + PipePowerIronM32("pipePowerIronM32"), + PipePowerIronM64("pipePowerIronM64"), + PipePowerIronM128("pipePowerIronM128"), + // Power_Normal("texture_cyan"), Power_Overload("texture_red_lit"), Stripes("pipeStripes"), @@ -101,11 +109,11 @@ public class PipeIconProvider implements IIconProvider { private final String iconTagColorBlind; private Icon icon; - private TYPE(String iconTag, String IconTagColorBlind){ + private TYPE(String iconTag, String IconTagColorBlind) { this.iconTag = iconTag; this.iconTagColorBlind = IconTagColorBlind; } - + private TYPE(String iconTag) { this(iconTag, iconTag); } diff --git a/common/buildcraft/transport/PipeToolTipManager.java b/common/buildcraft/transport/PipeToolTipManager.java index 6b99cc43..f7c22df1 100644 --- a/common/buildcraft/transport/PipeToolTipManager.java +++ b/common/buildcraft/transport/PipeToolTipManager.java @@ -8,10 +8,13 @@ */ package buildcraft.transport; -import buildcraft.core.utils.StringUtils; +import buildcraft.core.utils.Localization; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -33,10 +36,19 @@ public class PipeToolTipManager { toolTips.put(pipe, toolTip); } - public static String getToolTip(Class pipe) { + public static List getToolTip(Class pipe) { + List tips = new ArrayList(); + String tipTag = "tip." + pipe.getSimpleName(); + if (Localization.hasKey(tipTag)) { + String localized = Localization.get(tipTag); + if (localized != null) { + String[] lines = localized.split("\\n"); + tips.addAll(Arrays.asList(lines)); + } + } String tip = toolTips.get(pipe); if (tip != null) - return tip; - return StringUtils.localize("tip." + pipe.getSimpleName()); + tips.add(tip); + return tips; } } diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index 0f2937d7..e048132e 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -28,6 +28,7 @@ import buildcraft.transport.network.PacketPowerUpdate; import buildcraft.transport.pipes.PipePowerCobblestone; import buildcraft.transport.pipes.PipePowerDiamond; import buildcraft.transport.pipes.PipePowerGold; +import buildcraft.transport.pipes.PipePowerIron; import buildcraft.transport.pipes.PipePowerQuartz; import buildcraft.transport.pipes.PipePowerStone; import buildcraft.transport.pipes.PipePowerWood; @@ -44,6 +45,7 @@ public class PipeTransportPower extends PipeTransport { powerCapacities.put(PipePowerStone.class, 16); powerCapacities.put(PipePowerWood.class, 32); powerCapacities.put(PipePowerQuartz.class, 64); + powerCapacities.put(PipePowerIron.class, 128); powerCapacities.put(PipePowerGold.class, 256); powerCapacities.put(PipePowerDiamond.class, 1024); } @@ -325,11 +327,17 @@ public class PipeTransportPower extends PipeTransport { if (ret >= 0) return ret; } - internalNextPower[from.ordinal()] += val; + int side = from.ordinal(); + if (internalNextPower[side] > maxPower) + return 0; - if (internalNextPower[from.ordinal()] > maxPower) { - val -= internalNextPower[from.ordinal()] - maxPower; - internalNextPower[from.ordinal()] = maxPower; + internalNextPower[side] += val; + + if (internalNextPower[side] > maxPower) { + val -= internalNextPower[side] - maxPower; + internalNextPower[side] = maxPower; + if (val < 0) + val = 0; } return val; } diff --git a/common/buildcraft/transport/TransportProxyClient.java b/common/buildcraft/transport/TransportProxyClient.java index 7c3ea24b..d75da5f0 100644 --- a/common/buildcraft/transport/TransportProxyClient.java +++ b/common/buildcraft/transport/TransportProxyClient.java @@ -51,6 +51,7 @@ public class TransportProxyClient extends TransportProxy { MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerCobblestone.itemID, pipeItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerStone.itemID, pipeItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerQuartz.itemID, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerIron.itemID, pipeItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerGold.itemID, pipeItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerDiamond.itemID, pipeItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeStructureCobblestone.itemID, pipeItemRenderer); diff --git a/common/buildcraft/transport/pipes/PipePowerIron.java b/common/buildcraft/transport/pipes/PipePowerIron.java index 76ce44e8..dbf942f0 100644 --- a/common/buildcraft/transport/pipes/PipePowerIron.java +++ b/common/buildcraft/transport/pipes/PipePowerIron.java @@ -9,16 +9,19 @@ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; +import buildcraft.api.gates.IAction; import buildcraft.api.tools.IToolWrench; import buildcraft.core.utils.StringUtils; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; +import buildcraft.transport.triggers.ActionPowerLimiter; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.LinkedList; +import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; -import net.minecraft.util.ChatMessageComponent; import net.minecraftforge.common.ForgeDirection; public class PipePowerIron extends Pipe { @@ -27,19 +30,19 @@ public class PipePowerIron extends Pipe { M2(2), M4(4), M8(8), M16(16), M32(32), M64(64), M128(128); public static final PowerMode[] VALUES = values(); - private final int maxPower; + public final int maxPower; private PowerMode(int max) { this.maxPower = max; } public PowerMode getNext() { - PowerMode next = VALUES[(ordinal() + 1) % (VALUES.length - 1)]; + PowerMode next = VALUES[(ordinal() + 1) % VALUES.length]; return next; } public PowerMode getPrevious() { - PowerMode previous = VALUES[(ordinal() + VALUES.length - 2) % (VALUES.length - 1)]; + PowerMode previous = VALUES[(ordinal() + VALUES.length - 1) % VALUES.length]; return previous; } @@ -72,7 +75,8 @@ public class PipePowerIron extends Pipe { } else { setMode(getMode().getNext()); } - player.addChatMessage(String.format(StringUtils.localize("chat.pipe.power.iron.mode"), getMode().maxPower)); + if (getWorld().isRemote) + player.addChatMessage(String.format(StringUtils.localize("chat.pipe.power.iron.mode"), getMode().maxPower)); ((IToolWrench) equipped).wrenchUsed(player, container.xCoord, container.yCoord, container.zCoord); return true; @@ -104,4 +108,25 @@ public class PipePowerIron extends Pipe { public IIconProvider getIconProvider() { return BuildCraftTransport.instance.pipeIconProvider; } + + @Override + protected void actionsActivated(Map actions) { + super.actionsActivated(actions); + + for (Map.Entry action : actions.entrySet()) { + if (action.getKey() instanceof ActionPowerLimiter && action.getValue() == Boolean.TRUE) { + setMode(((ActionPowerLimiter) action.getKey()).limit); + break; + } + } + } + + @Override + public LinkedList getActions() { + LinkedList action = super.getActions(); + for (PowerMode mode : PowerMode.VALUES) { + action.add(BuildCraftTransport.actionPowerLimiter[mode.ordinal()]); + } + return action; + } } diff --git a/common/buildcraft/transport/triggers/ActionPowerLimiter.java b/common/buildcraft/transport/triggers/ActionPowerLimiter.java index 0b9da043..787cfea8 100644 --- a/common/buildcraft/transport/triggers/ActionPowerLimiter.java +++ b/common/buildcraft/transport/triggers/ActionPowerLimiter.java @@ -8,25 +8,25 @@ package buildcraft.transport.triggers; import buildcraft.core.triggers.BCAction; +import buildcraft.transport.pipes.PipePowerIron.PowerMode; import java.util.Locale; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.util.Icon; -import net.minecraftforge.common.ForgeDirection; -public class ActionPipeDirection extends BCAction { +public class ActionPowerLimiter extends BCAction { private Icon icon; - public final ForgeDirection direction; + public final PowerMode limit; - public ActionPipeDirection(int id, ForgeDirection direction) { - super(id, "buildcraft.pipe.dir." + direction.name().toLowerCase(Locale.ENGLISH)); + public ActionPowerLimiter(int id, PowerMode limit) { + super(id, "buildcraft.power.limiter." + limit.name().toLowerCase(Locale.ENGLISH)); - this.direction = direction; + this.limit = limit; } @Override public String getDescription() { - return direction.name().substring(0, 1) + direction.name().substring(1).toLowerCase(Locale.ENGLISH) + " Pipe Direction"; + return limit.maxPower + " MJ/t Limit"; } @Override @@ -36,6 +36,6 @@ public class ActionPipeDirection extends BCAction { @Override public void registerIcons(IconRegister iconRegister) { - icon = iconRegister.registerIcon("buildcraft:triggers/trigger_dir_" + direction.name().toLowerCase(Locale.ENGLISH)); + icon = iconRegister.registerIcon("buildcraft:triggers/trigger_limiter_" + limit.name().toLowerCase(Locale.ENGLISH)); } } From f35ea290e5ff8e3c3e7ef173fd0da48152ad01c0 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 26 Sep 2013 00:01:12 -0400 Subject: [PATCH 057/121] Fix single pulse : account for the baked in energy loss.. --- common/buildcraft/transport/EnergyPulser.java | 2 +- common/buildcraft/transport/pipes/PipeItemsWood.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/transport/EnergyPulser.java b/common/buildcraft/transport/EnergyPulser.java index 91c11140..53b7602f 100644 --- a/common/buildcraft/transport/EnergyPulser.java +++ b/common/buildcraft/transport/EnergyPulser.java @@ -27,7 +27,7 @@ public class EnergyPulser { return; if (!singlePulse || !hasPulsed) { - powerReceptor.getPowerReceiver(null).receiveEnergy(Type.GATE, Math.min(1 << (pulseCount - 1), 64), ForgeDirection.WEST); + powerReceptor.getPowerReceiver(null).receiveEnergy(Type.GATE, Math.min(1 << (pulseCount - 1), 64) *1.01f, ForgeDirection.WEST); hasPulsed = true; } } diff --git a/common/buildcraft/transport/pipes/PipeItemsWood.java b/common/buildcraft/transport/pipes/PipeItemsWood.java index e548eec6..c5aa8ae2 100644 --- a/common/buildcraft/transport/pipes/PipeItemsWood.java +++ b/common/buildcraft/transport/pipes/PipeItemsWood.java @@ -54,7 +54,7 @@ public class PipeItemsWood extends Pipe implements IPowerRec super(new PipeTransportItems(), itemID); powerHandler = new PowerHandler(this, Type.MACHINE); - powerHandler.configure(1, 64, 1, 64); + powerHandler.configure(1, 64.1f, 1, 64.1f); powerHandler.configurePowerPerdition(0, 0); } From 3e13bbb166568624cc918f8a9f916fa2062f6c37 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 25 Sep 2013 22:58:21 -0700 Subject: [PATCH 058/121] Version 4.1.0 --- buildcraft_resources/build.number | 4 ++-- buildcraft_resources/changelog/4.1.0 | 17 +++++++++++++++++ buildcraft_resources/mcmod.info | 12 ++++++------ 3 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 buildcraft_resources/changelog/4.1.0 diff --git a/buildcraft_resources/build.number b/buildcraft_resources/build.number index b13dc05d..600a792b 100644 --- a/buildcraft_resources/build.number +++ b/buildcraft_resources/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Fri Aug 09 09:44:46 CEST 2013 -build.number=39 +#Wed Sep 25 22:54:12 PDT 2013 +build.number=47 diff --git a/buildcraft_resources/changelog/4.1.0 b/buildcraft_resources/changelog/4.1.0 new file mode 100644 index 00000000..8de1a9b4 --- /dev/null +++ b/buildcraft_resources/changelog/4.1.0 @@ -0,0 +1,17 @@ + +#4.1.0 + +- New: Added Iron Kinesis Pipe. (CovertJaguar) +- New: Added Non-Round Robin mode to Emerald Item Pipe. (Flow86) +- New: Pipes have tool tips now. (CovertJaguar) +- New: Added config option for update check (Prototik) +- New: Added config option for Oil Well proclivity. (sadris) +- New: Added config options for various Quarry/Mining Well tweaks/nerfs. (CovertJaguar) +- New: Added config options for Colorblind mode. (Krapht) +- Change: Reworked Combustion Engine heat mechanics. (CovertJaguar) +- Fix: Fixed Quarries in the Nether (cpw) +- Fix: Autarchic Gate single pulses are now more reliable. (cpw) +- Fix: Laser's hadWork trigger should work correctly now. (CovertJaguar) +- Fix: Refineries no longer forget their filters. (CovertJaguar) +- Fix: Pumps can now pump Oil out of Oceans again. (CovertJaguar) +- And: Various other small fixes/tweaks. \ No newline at end of file diff --git a/buildcraft_resources/mcmod.info b/buildcraft_resources/mcmod.info index 45cce29e..b8f1fceb 100644 --- a/buildcraft_resources/mcmod.info +++ b/buildcraft_resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "BuildCraft|Core", "name": "BuildCraft", "version": "@VERSION@", - "mcversion": "", + "mcversion": "@MC_VERSION@", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more!", "credits": "Created by SpaceToad", "logoFile": "/assets/buildcraft/logo.png", @@ -20,7 +20,7 @@ "modid": "BuildCraft|Builders", "name": "BC Builders", "version": "@VERSION@", - "mcversion": "", + "mcversion": "@MC_VERSION@", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Builders Component)", "credits": "Created by SpaceToad", "logoFile": "/assets/buildcraft/logo.png", @@ -37,7 +37,7 @@ "modid": "BuildCraft|Energy", "name": "BC Energy", "version": "@VERSION@", - "mcversion": "", + "mcversion": "@MC_VERSION@", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Energy Component)", "credits": "Created by SpaceToad", "logoFile": "/assets/buildcraft/logo.png", @@ -54,7 +54,7 @@ "modid": "BuildCraft|Factory", "name": "BC Factory", "version": "@VERSION@", - "mcversion": "", + "mcversion": "@MC_VERSION@", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Factory Component)", "credits": "Created by SpaceToad", "logoFile": "/assets/buildcraft/logo.png", @@ -71,7 +71,7 @@ "modid": "BuildCraft|Silicon", "name": "BC Silicon", "version": "@VERSION@", - "mcversion": "", + "mcversion": "@MC_VERSION@", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Silicon Component)", "credits": "Created by SpaceToad", "logoFile": "/assets/buildcraft/logo.png", @@ -88,7 +88,7 @@ "modid": "BuildCraft|Transport", "name": "BC Transport", "version": "@VERSION@", - "mcversion": "", + "mcversion": "@MC_VERSION@", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Transport Component)", "credits": "Created by SpaceToad", "logoFile": "/assets/buildcraft/logo.png", From 1a639f7afb1587bc975a2debbf776a59926a83fc Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 27 Sep 2013 22:12:37 -0700 Subject: [PATCH 059/121] Remove some unneeded imports --- common/buildcraft/BuildCraftCore.java | 1 - common/buildcraft/transport/pipes/PipeItemsIron.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 76bec134..a5eac72c 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -74,7 +74,6 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.EntityRegistry; -import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; diff --git a/common/buildcraft/transport/pipes/PipeItemsIron.java b/common/buildcraft/transport/pipes/PipeItemsIron.java index 7df0178b..2b884897 100644 --- a/common/buildcraft/transport/pipes/PipeItemsIron.java +++ b/common/buildcraft/transport/pipes/PipeItemsIron.java @@ -14,11 +14,9 @@ import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TileGenericPipe; -import buildcraft.transport.triggers.ActionPipeColor; import buildcraft.transport.triggers.ActionPipeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.Arrays; import java.util.LinkedList; import java.util.Map; import net.minecraft.entity.player.EntityPlayer; From b6cb556274ffd7c448bda24e3b3d595963056257 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 27 Sep 2013 22:13:13 -0700 Subject: [PATCH 060/121] Fix version check --- common/buildcraft/core/Version.java | 93 ++++++++++++++--------------- 1 file changed, 45 insertions(+), 48 deletions(-) diff --git a/common/buildcraft/core/Version.java b/common/buildcraft/core/Version.java index 20150603..c6c35212 100644 --- a/common/buildcraft/core/Version.java +++ b/common/buildcraft/core/Version.java @@ -11,23 +11,20 @@ import net.minecraftforge.common.Property; public class Version implements Runnable { - private static Version instance = new Version(); + private static Version instance = new Version(); public enum EnumUpdateState { + CURRENT, OUTDATED, CONNECTION_ERROR } - public static final String VERSION = "@VERSION@"; public static final String BUILD_NUMBER = "@BUILD_NUMBER@"; private static final String REMOTE_VERSION_FILE = "http://bit.ly/buildcraftver"; private static final String REMOTE_CHANGELOG_ROOT = "https://dl.dropbox.com/u/44760587/buildcraft/changelog/"; - public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT; - public static final int FORGE_VERSION_MAJOR = 4; public static final int FORGE_VERSION_MINOR = 0; public static final int FORGE_VERSION_PATCH = 0; - private static String recommendedVersion; private static String[] cachedChangelog; @@ -62,30 +59,30 @@ public class Version implements Runnable { public static void versionCheck() { try { - if ("0.0.0".equals(VERSION)) return; - + if ("0.0.0".equals(VERSION)) + return; + String location = REMOTE_VERSION_FILE; HttpURLConnection conn = null; while (location != null && !location.isEmpty()) { URL url = new URL(location); - - if(conn != null) + + if (conn != null) conn.disconnect(); - + conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)"); conn.connect(); location = conn.getHeaderField("Location"); } - - if(conn == null) + + if (conn == null) throw new NullPointerException(); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); - conn.disconnect(); - String line = null; + String line; String mcVersion = CoreProxy.proxy.getMinecraftVersion(); while ((line = reader.readLine()) != null) { if (line.startsWith(mcVersion)) { @@ -95,7 +92,7 @@ public class Version implements Runnable { recommendedVersion = tokens[2]; if (line.endsWith(VERSION)) { - BuildCraftCore.bcLog.finer("Using the latest version [" + getVersion() + "] for Minecraft " + mcVersion); + BuildCraftCore.bcLog.finer("Using the latest version [" + getVersion() + "] for Minecraft " + mcVersion); currentVersion = EnumUpdateState.CURRENT; return; } @@ -107,6 +104,8 @@ public class Version implements Runnable { + ". Consider updating."); currentVersion = EnumUpdateState.OUTDATED; + conn.disconnect(); + reader.close(); } catch (Exception e) { BuildCraftCore.bcLog.warning("Unable to read from remote version authority."); BuildCraftCore.bcLog.warning(e.toString()); @@ -130,20 +129,20 @@ public class Version implements Runnable { HttpURLConnection conn = null; while (location != null && !location.isEmpty()) { URL url = new URL(location); - - if(conn != null) + + if (conn != null) conn.disconnect(); - + conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)"); conn.connect(); location = conn.getHeaderField("Location"); } - - if(conn == null) + + if (conn == null) throw new NullPointerException(); - + BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); conn.disconnect(); @@ -167,41 +166,39 @@ public class Version implements Runnable { BuildCraftCore.bcLog.warning("Unable to read changelog from remote site."); } - return new String[] { String.format("Unable to retrieve changelog for %s %s", DefaultProps.MOD, version) }; + return new String[]{String.format("Unable to retrieve changelog for %s %s", DefaultProps.MOD, version)}; } - @Override - public void run() { + @Override + public void run() { - int count = 0; - currentVersion = null; + int count = 0; + currentVersion = null; - BuildCraftCore.bcLog.info("Beginning version check"); + BuildCraftCore.bcLog.info("Beginning version check"); - try { - while ((count < 3) && ((currentVersion == null) || (currentVersion == EnumUpdateState.CONNECTION_ERROR))) { - versionCheck(); - count++; + try { + while ((count < 3) && ((currentVersion == null) || (currentVersion == EnumUpdateState.CONNECTION_ERROR))) { + versionCheck(); + count++; - if (currentVersion == EnumUpdateState.CONNECTION_ERROR) { - BuildCraftCore.bcLog.info("Version check attempt " + count + " failed, trying again in 10 seconds"); - Thread.sleep(10000); - } - } - } - catch (InterruptedException e) { - e.printStackTrace(); - } + if (currentVersion == EnumUpdateState.CONNECTION_ERROR) { + BuildCraftCore.bcLog.info("Version check attempt " + count + " failed, trying again in 10 seconds"); + Thread.sleep(10000); + } + } + } catch (InterruptedException e) { + e.printStackTrace(); + } - if (currentVersion == EnumUpdateState.CONNECTION_ERROR) { - BuildCraftCore.bcLog.info("Version check failed"); - } + if (currentVersion == EnumUpdateState.CONNECTION_ERROR) { + BuildCraftCore.bcLog.info("Version check failed"); + } - } + } - public static void check() { - - new Thread(instance).start(); - } + public static void check() { + new Thread(instance).start(); + } } From de8da4c008efb6a38283a0649b6a0d18d6c629d9 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 5 Oct 2013 06:18:01 -0700 Subject: [PATCH 061/121] Some minor cleanup --- common/buildcraft/core/EntityRobot.java | 4 ++-- common/buildcraft/core/utils/BlockUtil.java | 12 ++++++------ common/buildcraft/factory/TileQuarry.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/buildcraft/core/EntityRobot.java b/common/buildcraft/core/EntityRobot.java index 054f7e21..6a460050 100644 --- a/common/buildcraft/core/EntityRobot.java +++ b/common/buildcraft/core/EntityRobot.java @@ -213,12 +213,12 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData { if (target.mode == Mode.ClearIfInvalid) { if (!target.isValid(a.context)) { - worldObj.setBlock(target.x, target.y, target.z, 0, 0,3); + worldObj.setBlockToAir(target.x, target.y, target.z); } } else if (target.stackToUse != null) { - worldObj.setBlock(target.x, target.y, target.z, 0); + worldObj.setBlockToAir(target.x, target.y, target.z); throw new RuntimeException("NOT IMPLEMENTED"); // target.stackToUse.getItem().onItemUse(target.stackToUse, // CoreProxy.getBuildCraftPlayer(worldObj), worldObj, target.x, target.y - 1, diff --git a/common/buildcraft/core/utils/BlockUtil.java b/common/buildcraft/core/utils/BlockUtil.java index fa95412f..3b173e7b 100644 --- a/common/buildcraft/core/utils/BlockUtil.java +++ b/common/buildcraft/core/utils/BlockUtil.java @@ -74,14 +74,14 @@ public class BlockUtil { return canChangeBlock(world.getBlockId(x, y, z), world, x, y, z); } - public static boolean isAnObstructingBlock(int blockID, World world, int x, int y, int z) - { - Block block = Block.blocksList[blockID]; + public static boolean isAnObstructingBlock(int blockID, World world, int x, int y, int z) { + Block block = Block.blocksList[blockID]; - if (blockID == 0 || block == null || block.isAirBlock(world, x, y, z)) - return false; - return true; + if (blockID == 0 || block == null || block.isAirBlock(world, x, y, z)) + return false; + return true; } + public static boolean canChangeBlock(int blockID, World world, int x, int y, int z) { Block block = Block.blocksList[blockID]; diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index d33ca246..837f18b6 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -434,7 +434,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } worldObj.playAuxSFXAtEntity(null, 2001, i, j, k, blockId + (worldObj.getBlockMetadata(i, j, k) << 12)); - worldObj.setBlock(i, j, k, 0); + worldObj.setBlockToAir(i, j, k); } // Collect any lost items laying around From f76c684162b1a859a40059f47807f98ce5ba79a5 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 5 Oct 2013 06:19:54 -0700 Subject: [PATCH 062/121] Closes #1250 Don't know how it happened, but whatever. --- .../buildcraft/core/triggers/ActionTriggerIconProvider.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/common/buildcraft/core/triggers/ActionTriggerIconProvider.java b/common/buildcraft/core/triggers/ActionTriggerIconProvider.java index ad928323..c70aa07a 100644 --- a/common/buildcraft/core/triggers/ActionTriggerIconProvider.java +++ b/common/buildcraft/core/triggers/ActionTriggerIconProvider.java @@ -52,7 +52,7 @@ public class ActionTriggerIconProvider implements IIconProvider { @SideOnly(Side.CLIENT) - private Icon[] icons; + private final Icon[] icons = new Icon[MAX]; private ActionTriggerIconProvider(){} @@ -65,8 +65,6 @@ public class ActionTriggerIconProvider implements IIconProvider { @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { - icons = new Icon[MAX]; - icons[ActionTriggerIconProvider.Action_MachineControl_On] = iconRegister.registerIcon("buildcraft:triggers/action_machinecontrol_on"); icons[ActionTriggerIconProvider.Action_MachineControl_Off] = iconRegister.registerIcon("buildcraft:triggers/action_machinecontrol_off"); icons[ActionTriggerIconProvider.Action_MachineControl_Loop] = iconRegister.registerIcon("buildcraft:triggers/action_machinecontrol_loop"); From 782002b458db93bc25dcb87fe08983b357fc2e49 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 5 Oct 2013 07:24:54 -0700 Subject: [PATCH 063/121] Fix some texture fighting on Kinesis Pipes --- .../transport/render/RenderPipe.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/common/buildcraft/transport/render/RenderPipe.java b/common/buildcraft/transport/render/RenderPipe.java index 7c708e5e..859f40d1 100644 --- a/common/buildcraft/transport/render/RenderPipe.java +++ b/common/buildcraft/transport/render/RenderPipe.java @@ -269,7 +269,9 @@ public class RenderPipe extends TileEntitySpecialRenderer { PipeTransportPower pow = pipe.transport; GL11.glPushMatrix(); - GL11.glDisable(2896 /* GL_LIGHTING */); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glDisable(GL11.GL_LIGHTING); +// GL11.glEnable(GL11.GL_BLEND); GL11.glTranslatef((float) x, (float) y, (float) z); @@ -277,17 +279,18 @@ public class RenderPipe extends TileEntitySpecialRenderer { int[] displayList = pow.overload > 0 ? displayPowerListOverload : displayPowerList; - for (int i = 0; i < 6; ++i) { + for (int side = 0; side < 6; ++side) { GL11.glPushMatrix(); GL11.glTranslatef(0.5F, 0.5F, 0.5F); - GL11.glRotatef(angleY[i], 0, 1, 0); - GL11.glRotatef(angleZ[i], 0, 0, 1); + GL11.glRotatef(angleY[side], 0, 1, 0); + GL11.glRotatef(angleZ[side], 0, 0, 1); + float scale = 1.0F - side * 0.0001F; + GL11.glScalef(scale, scale, scale); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - if (pow.clientDisplayPower[i] >= 1.0) { - short stage = pow.clientDisplayPower[i]; - + short stage = pow.clientDisplayPower[side]; + if (stage >= 1) { if (stage < displayList.length) { GL11.glCallList(displayList[stage]); } else { @@ -298,7 +301,7 @@ public class RenderPipe extends TileEntitySpecialRenderer { GL11.glPopMatrix(); } - GL11.glEnable(2896 /* GL_LIGHTING */); + GL11.glPopAttrib(); GL11.glPopMatrix(); } @@ -385,7 +388,7 @@ public class RenderPipe extends TileEntitySpecialRenderer { bindTexture(TextureMap.locationBlocksTexture); FluidRenderer.setColorForFluidStack(fluidStack); - + if (above) { GL11.glCallList(d.centerVertical[stage]); } From 7bbb853aaef3ac2ae0bec7011e1d04fb63ab6c13 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 5 Oct 2013 07:46:47 -0700 Subject: [PATCH 064/121] Expand PowerHandler Javadocs some more --- common/buildcraft/api/power/PowerHandler.java | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/api/power/PowerHandler.java b/common/buildcraft/api/power/PowerHandler.java index 0b8778fc..5bd6fef2 100644 --- a/common/buildcraft/api/power/PowerHandler.java +++ b/common/buildcraft/api/power/PowerHandler.java @@ -11,6 +11,24 @@ import buildcraft.api.core.SafeTimeTracker; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.ForgeDirection; +/** + * The PowerHandler is similar to FluidTank in that it holds your power and + * allows standardized interaction between machines. + * + * To receive power to your machine you needs create an instance of PowerHandler + * and implement IPowerReceptor on the TileEntity. + * + * If you plan emit power, you need only implement IPowerEmitter. You do not + * need a PowerHandler. Engines have a PowerHandler because they can also + * receive power from other Engines. + * + * See TileRefinery for a simple example of a power using machine. + * + * @see IPowerReceptor + * @see IPowerEmitter + * + * @author CovertJaguar + */ public final class PowerHandler { public static enum Type { @@ -85,9 +103,9 @@ public final class PowerHandler { /** * Taxes a flat rate on all incoming power. - * + * * Defaults to 0% tax rate. - * + * * @return percent of input to tax */ public float getTaxPercent() { @@ -168,6 +186,16 @@ public final class PowerHandler { this.activationEnergy = activationEnergy; } + /** + * Allows you define perdition in terms of loss/ticks. + * + * This function is mostly for legacy implementations. See + * PerditionCalculator for more complex perdition formulas. + * + * @param powerLoss + * @param powerLossRegularity + * @see PerditionCalculator + */ public void configurePowerPerdition(int powerLoss, int powerLossRegularity) { if (powerLoss == 0 || powerLossRegularity == 0) { perdition = new PerditionCalculator(0); @@ -343,6 +371,8 @@ public final class PowerHandler { /** * Add power to the PowerReceiver from an external source. * + * IPowerEmitters are responsible for calling this themselves. + * * @param quantity * @param from * @return the amount of power used @@ -358,7 +388,7 @@ public final class PowerHandler { } updateSources(from); - + used -= used * getPerdition().getTaxPercent(); used = addEnergy(used); From 6eb39da66fac4ca7caa7420a358274dc1af7fb13 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 6 Oct 2013 15:26:35 -0700 Subject: [PATCH 065/121] Prevent Spring block updates on chunk gen --- common/buildcraft/core/BlockSpring.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/buildcraft/core/BlockSpring.java b/common/buildcraft/core/BlockSpring.java index d4e2115a..6fd5e1a8 100644 --- a/common/buildcraft/core/BlockSpring.java +++ b/common/buildcraft/core/BlockSpring.java @@ -92,6 +92,12 @@ public class BlockSpring extends Block { world.setBlock(x, y + 1, z, spring.liquidBlock.blockID); } + // Prevents updates on chunk generation + @Override + public boolean func_82506_l() { + return false; + } + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { From 2a38a58fbb24d5189fb9d8276becf54fba4fc4e8 Mon Sep 17 00:00:00 2001 From: Player Date: Mon, 7 Oct 2013 17:01:50 +0200 Subject: [PATCH 066/121] energy: nerf oil and fuel from 60k/600k to 15k/150k MJ/bucket. The power (3/6 MJ/t) is unchanged. This change reduces the mismatch between the liquid and solid fuel energy value. --- common/buildcraft/BuildCraftEnergy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index bc7f5882..28cda845 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -204,8 +204,8 @@ public class BuildCraftEnergy { // Iron Engine Fuels // IronEngineFuel.addFuel("lava", 1, 20000); - IronEngineFuel.addFuel("oil", 3, 20000); - IronEngineFuel.addFuel("fuel", 6, 100000); + IronEngineFuel.addFuel("oil", 3, 5000); + IronEngineFuel.addFuel("fuel", 6, 25000); // Iron Engine Coolants IronEngineCoolant.addCoolant(FluidRegistry.getFluid("water"), 0.0023F); From 0a004e4383285a2020d55d0cd8ba430406a534d5 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 7 Oct 2013 09:14:51 -0700 Subject: [PATCH 067/121] Add configs for fuel values --- common/buildcraft/BuildCraftEnergy.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 28cda845..eb84eb13 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -108,6 +108,9 @@ public class BuildCraftEnergy { int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN); canOilBurn = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "burnOil", true, "Can oil burn?").getBoolean(true); oilWellScalar = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilWellGenerationRate", 1.0, "Probability of oil well generation").getDouble(1.0); + + double fuelOilMultiplier = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.oil.combustion", 1.0F, "adjust energy value of Oil in Combustion Engines").getDouble(1.0F); + double fuelFuelMultiplier = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.fuel.combustion", 1.0F, "adjust energy value of Fuel in Combustion Engines").getDouble(1.0F); BuildCraftCore.mainConfiguration.save(); class BiomeIdException extends RuntimeException { @@ -204,8 +207,8 @@ public class BuildCraftEnergy { // Iron Engine Fuels // IronEngineFuel.addFuel("lava", 1, 20000); - IronEngineFuel.addFuel("oil", 3, 5000); - IronEngineFuel.addFuel("fuel", 6, 25000); + IronEngineFuel.addFuel("oil", 3, (int) (5000 * fuelOilMultiplier)); + IronEngineFuel.addFuel("fuel", 6, (int) (25000 * fuelFuelMultiplier)); // Iron Engine Coolants IronEngineCoolant.addCoolant(FluidRegistry.getFluid("water"), 0.0023F); @@ -256,8 +259,8 @@ public class BuildCraftEnergy { @EventHandler public void processIMCRequests(FMLInterModComms.IMCEvent event) { - InterModComms.processIMC(event); - } + InterModComms.processIMC(event); + } // public static int createPollution (World world, int i, int j, int k, int // saturation) { // int remainingSaturation = saturation; From fb0ee9118396f99cd63d783ff84d2f6c1b3a2be0 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 8 Oct 2013 11:02:14 -0700 Subject: [PATCH 068/121] Fix issues with Wooden Engine Closes #1253 --- common/buildcraft/energy/TileEngine.java | 1 - common/buildcraft/energy/TileEngineWood.java | 11 +++++------ .../render/{RenderPipe.java => PipeRendererTESR.java} | 0 ...{PipeWorldRenderer.java => PipeRendererWorld.java} | 0 4 files changed, 5 insertions(+), 7 deletions(-) rename common/buildcraft/transport/render/{RenderPipe.java => PipeRendererTESR.java} (100%) rename common/buildcraft/transport/render/{PipeWorldRenderer.java => PipeRendererWorld.java} (100%) diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index d76a8432..56f6e3ac 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -18,7 +18,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeDirection; import buildcraft.BuildCraftEnergy; -import buildcraft.api.core.Position; import buildcraft.api.gates.IOverrideDefaultTriggers; import buildcraft.api.gates.ITrigger; import buildcraft.api.power.IPowerEmitter; diff --git a/common/buildcraft/energy/TileEngineWood.java b/common/buildcraft/energy/TileEngineWood.java index 19fa9b4f..5791cd62 100644 --- a/common/buildcraft/energy/TileEngineWood.java +++ b/common/buildcraft/energy/TileEngineWood.java @@ -7,6 +7,7 @@ */ package buildcraft.energy; +import buildcraft.api.power.PowerHandler; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeDirection; import buildcraft.api.transport.IPipeTile.PipeType; @@ -52,10 +53,8 @@ public class TileEngineWood extends TileEngine { @Override public float getPistonSpeed() { if (CoreProxy.proxy.isSimulating(worldObj)) - return Math.max(0.8f * getHeatLevel(), 0.01f); + return Math.max(0.08f * getHeatLevel(), 0.01f); switch (getEnergyStage()) { - case BLUE: - return 0.01F; case GREEN: return 0.02F; case YELLOW: @@ -63,7 +62,7 @@ public class TileEngineWood extends TileEngine { case RED: return 0.08F; default: - return 0; + return 0.01F; } } @@ -72,7 +71,7 @@ public class TileEngineWood extends TileEngine { super.engineUpdate(); if (isRedstonePowered) - if (worldObj.getTotalWorldTime() % 20 == 0) + if (worldObj.getTotalWorldTime() % 16 == 0) addEnergy(1); } @@ -103,6 +102,6 @@ public class TileEngineWood extends TileEngine { @Override public float maxEnergyExtracted() { - return 1; + return 1 + PowerHandler.PerditionCalculator.MIN_POWERLOSS; } } diff --git a/common/buildcraft/transport/render/RenderPipe.java b/common/buildcraft/transport/render/PipeRendererTESR.java similarity index 100% rename from common/buildcraft/transport/render/RenderPipe.java rename to common/buildcraft/transport/render/PipeRendererTESR.java diff --git a/common/buildcraft/transport/render/PipeWorldRenderer.java b/common/buildcraft/transport/render/PipeRendererWorld.java similarity index 100% rename from common/buildcraft/transport/render/PipeWorldRenderer.java rename to common/buildcraft/transport/render/PipeRendererWorld.java From 3a39b289a2a973bca370270e105980025d92a53c Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 8 Oct 2013 11:13:40 -0700 Subject: [PATCH 069/121] Moved Pipe Gate/Wire rendering to the TESR Should greatly improve performance of wire/gate switching. --- .../buildcraft/core/render/FluidRenderer.java | 4 +- .../core/render/RenderEntityBlock.java | 290 +++++++++++++----- .../transport/BlockGenericPipe.java | 4 +- .../buildcraft/transport/PipeRenderState.java | 9 +- .../buildcraft/transport/TileGenericPipe.java | 40 ++- .../transport/TransportProxyClient.java | 8 +- .../transport/pipes/PipeItemsDaizuli.java | 1 - .../transport/pipes/PipeItemsLapis.java | 1 - .../transport/pipes/PipeLogicIron.java | 2 +- .../transport/pipes/PipePowerIron.java | 1 - .../transport/render/PipeRendererTESR.java | 266 +++++++++++++++- .../transport/render/PipeRendererWorld.java | 213 +------------ .../transport/utils/ConnectionMatrix.java | 12 +- .../transport/utils/FacadeMatrix.java | 36 ++- .../transport/utils/TextureMatrix.java | 7 +- 15 files changed, 556 insertions(+), 338 deletions(-) diff --git a/common/buildcraft/core/render/FluidRenderer.java b/common/buildcraft/core/render/FluidRenderer.java index 905be09f..e5c3836b 100644 --- a/common/buildcraft/core/render/FluidRenderer.java +++ b/common/buildcraft/core/render/FluidRenderer.java @@ -7,7 +7,7 @@ */ package buildcraft.core.render; -import buildcraft.core.render.RenderEntityBlock.BlockInterface; +import buildcraft.core.render.RenderEntityBlock.RenderInfo; import java.util.HashMap; import java.util.Map; import net.minecraft.block.Block; @@ -31,7 +31,7 @@ public class FluidRenderer { private static Map flowingRenderCache = new HashMap(); private static Map stillRenderCache = new HashMap(); public static final int DISPLAY_STAGES = 100; - private static final BlockInterface liquidBlock = new BlockInterface(); + private static final RenderInfo liquidBlock = new RenderInfo(); public static Icon getFluidTexture(FluidStack fluidStack, boolean flowing) { if (fluidStack == null) { diff --git a/common/buildcraft/core/render/RenderEntityBlock.java b/common/buildcraft/core/render/RenderEntityBlock.java index cfb5089b..624e541c 100644 --- a/common/buildcraft/core/render/RenderEntityBlock.java +++ b/common/buildcraft/core/render/RenderEntityBlock.java @@ -8,6 +8,7 @@ package buildcraft.core.render; import buildcraft.core.EntityBlock; +import java.util.Arrays; import net.minecraft.block.Block; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; @@ -20,7 +21,7 @@ import net.minecraft.world.World; import org.lwjgl.opengl.GL11; public class RenderEntityBlock extends Render { - + public static RenderEntityBlock INSTANCE = new RenderEntityBlock(); @Override @@ -28,7 +29,7 @@ public class RenderEntityBlock extends Render { throw new UnsupportedOperationException("Not supported yet."); } - public static class BlockInterface { + public static class RenderInfo { public double minX; public double minY; @@ -38,17 +39,81 @@ public class RenderEntityBlock extends Render { public double maxZ; public Block baseBlock = Block.sand; public Icon texture = null; + public Icon[] textureArray = null; + public boolean[] renderSide = new boolean[6]; + public float light = -1f; + public int brightness = -1; - public Icon getBlockTextureFromSide(int i) { - if (texture == null) - return baseBlock.getBlockTextureFromSide(i); - else - return texture; + public RenderInfo() { + setRenderAllSides(); + } + + public RenderInfo(Block template, Icon[] texture) { + this(); + this.baseBlock = template; + this.textureArray = texture; + } + + public RenderInfo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) { + this(); + setBounds(minX, minY, minZ, maxX, maxY, maxZ); } public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k) { return baseBlock.getBlockBrightness(iblockaccess, i, j, k); } + + public final void setBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { + this.minX = minX; + this.minY = minY; + this.minZ = minZ; + this.maxX = maxX; + this.maxY = maxY; + this.maxZ = maxZ; + } + + public final void setRenderSingleSide(int side) { + Arrays.fill(renderSide, false); + renderSide[side] = true; + } + + public final void setRenderAllSides() { + Arrays.fill(renderSide, true); + } + + public void rotate() { + double temp = minX; + minX = minZ; + minZ = temp; + + temp = maxX; + maxX = maxZ; + maxZ = temp; + } + + public void reverseX() { + double temp = minX; + minX = 1 - maxX; + maxX = 1 - temp; + } + + public void reverseZ() { + double temp = minZ; + minZ = 1 - maxZ; + maxZ = 1 - temp; + } + + public Icon getBlockTextureFromSide(int i) { + if (texture != null) + return texture; + if (textureArray == null || textureArray.length == 0) + return baseBlock.getBlockTextureFromSide(i); + else { + if (i >= textureArray.length) + i = 0; + return textureArray[i]; + } + } } private RenderEntityBlock() { @@ -65,7 +130,7 @@ public class RenderEntityBlock extends Render { shadowSize = entity.shadowSize; World world = entity.worldObj; - BlockInterface util = new BlockInterface(); + RenderInfo util = new RenderInfo(); util.texture = entity.texture; bindTexture(TextureMap.locationBlocksTexture); @@ -108,92 +173,169 @@ public class RenderEntityBlock extends Render { } } - public void renderBlock(BlockInterface block, IBlockAccess blockAccess, int i, int j, int k, boolean doLight, boolean doTessellating) { - float f = 0.5F; - float f1 = 1.0F; - float f2 = 0.8F; - float f3 = 0.6F; - - renderBlocks.renderMaxX = block.maxX; - renderBlocks.renderMinX = block.minX; - renderBlocks.renderMaxY = block.maxY; - renderBlocks.renderMinY = block.minY; - renderBlocks.renderMaxZ = block.maxZ; - renderBlocks.renderMinZ = block.minZ; - renderBlocks.enableAO = false; + public void renderBlock(RenderInfo info, IBlockAccess blockAccess, int x, int y, int z, boolean doLight, boolean doTessellating) { + renderBlock(info, blockAccess, x, y, z, x, y, z, doLight, doTessellating); + } + public void renderBlock(RenderInfo info, IBlockAccess blockAccess, double x, double y, double z, int lightX, int lightY, int lightZ, boolean doLight, boolean doTessellating) { + float lightBottom = 0.5F; + float lightTop = 1.0F; + float lightEastWest = 0.8F; + float lightNorthSouth = 0.6F; Tessellator tessellator = Tessellator.instance; - if (doTessellating) { + if (blockAccess == null) + doLight = false; + + if (doTessellating && !tessellator.isDrawing) tessellator.startDrawingQuads(); - } - - float f4 = 0, f5 = 0; + float light = 0; if (doLight) { - f4 = block.getBlockBrightness(blockAccess, i, j, k); - f5 = block.getBlockBrightness(blockAccess, i, j, k); - if (f5 < f4) { - f5 = f4; - } - tessellator.setColorOpaque_F(f * f5, f * f5, f * f5); + if (info.light < 0) { + light = info.baseBlock.getBlockBrightness(blockAccess, (int) lightX, (int) lightY, (int) lightZ); + light = light + ((1.0f - light) * 0.4f); + } else + light = info.light; + int brightness = 0; + if (info.brightness < 0) + brightness = info.baseBlock.getMixedBrightnessForBlock(blockAccess, lightX, lightY, lightZ); + else + brightness = info.brightness; + tessellator.setBrightness(brightness); + tessellator.setColorOpaque_F(lightBottom * light, lightBottom * light, lightBottom * light); + } else { + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + if (info.brightness >= 0) + tessellator.setBrightness(info.brightness); } - renderBlocks.renderFaceYNeg(null, 0, 0, 0, block.getBlockTextureFromSide(0)); + renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ); - if (doLight) { - f5 = block.getBlockBrightness(blockAccess, i, j, k); - if (f5 < f4) { - f5 = f4; - } - tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5); - } + if (info.renderSide[0]) + renderBlocks.renderFaceYNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(0)); - renderBlocks.renderFaceYPos(null, 0, 0, 0, block.getBlockTextureFromSide(1)); + if (doLight) + tessellator.setColorOpaque_F(lightTop * light, lightTop * light, lightTop * light); - if (doLight) { - f5 = block.getBlockBrightness(blockAccess, i, j, k); - if (f5 < f4) { - f5 = f4; - } - tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5); - } + if (info.renderSide[1]) + renderBlocks.renderFaceYPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(1)); - renderBlocks.renderFaceZNeg(null, 0, 0, 0, block.getBlockTextureFromSide(2)); + if (doLight) + tessellator.setColorOpaque_F(lightEastWest * light, lightEastWest * light, lightEastWest * light); - if (doLight) { - f5 = block.getBlockBrightness(blockAccess, i, j, k); - if (f5 < f4) { - f5 = f4; - } - tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5); - } + if (info.renderSide[2]) + renderBlocks.renderFaceZNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(2)); - renderBlocks.renderFaceZPos(null, 0, 0, 0, block.getBlockTextureFromSide(3)); + if (doLight) + tessellator.setColorOpaque_F(lightEastWest * light, lightEastWest * light, lightEastWest * light); - if (doLight) { - f5 = block.getBlockBrightness(blockAccess, i, j, k); - if (f5 < f4) { - f5 = f4; - } - tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5); - } + if (info.renderSide[3]) + renderBlocks.renderFaceZPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(3)); - renderBlocks.renderFaceXNeg(null, 0, 0, 0, block.getBlockTextureFromSide(4)); + if (doLight) + tessellator.setColorOpaque_F(lightNorthSouth * light, lightNorthSouth * light, lightNorthSouth * light); - if (doLight) { - f5 = block.getBlockBrightness(blockAccess, i, j, k); - if (f5 < f4) { - f5 = f4; - } - tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5); - } + if (info.renderSide[4]) + renderBlocks.renderFaceXNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(4)); - renderBlocks.renderFaceXPos(null, 0, 0, 0, block.getBlockTextureFromSide(5)); + if (doLight) + tessellator.setColorOpaque_F(lightNorthSouth * light, lightNorthSouth * light, lightNorthSouth * light); - if (doTessellating) { + if (info.renderSide[5]) + renderBlocks.renderFaceXPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(5)); + + if (doTessellating && tessellator.isDrawing) tessellator.draw(); - } } +// +// public void renderBlock(RenderInfo block, IBlockAccess blockAccess, int i, int j, int k, boolean doLight, boolean doTessellating) { +// float f = 0.5F; +// float f1 = 1.0F; +// float f2 = 0.8F; +// float f3 = 0.6F; +// +// renderBlocks.renderMaxX = block.maxX; +// renderBlocks.renderMinX = block.minX; +// renderBlocks.renderMaxY = block.maxY; +// renderBlocks.renderMinY = block.minY; +// renderBlocks.renderMaxZ = block.maxZ; +// renderBlocks.renderMinZ = block.minZ; +// renderBlocks.enableAO = false; +// +// +// Tessellator tessellator = Tessellator.instance; +// +// if (doTessellating) { +// tessellator.startDrawingQuads(); +// } +// +// float f4 = 0, f5 = 0; +// +// if (doLight) { +// f4 = block.getBlockBrightness(blockAccess, i, j, k); +// f5 = block.getBlockBrightness(blockAccess, i, j, k); +// if (f5 < f4) { +// f5 = f4; +// } +// tessellator.setColorOpaque_F(f * f5, f * f5, f * f5); +// } +// +// renderBlocks.renderFaceYNeg(null, 0, 0, 0, block.getBlockTextureFromSide(0)); +// +// if (doLight) { +// f5 = block.getBlockBrightness(blockAccess, i, j, k); +// if (f5 < f4) { +// f5 = f4; +// } +// tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5); +// } +// +// renderBlocks.renderFaceYPos(null, 0, 0, 0, block.getBlockTextureFromSide(1)); +// +// if (doLight) { +// f5 = block.getBlockBrightness(blockAccess, i, j, k); +// if (f5 < f4) { +// f5 = f4; +// } +// tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5); +// } +// +// renderBlocks.renderFaceZNeg(null, 0, 0, 0, block.getBlockTextureFromSide(2)); +// +// if (doLight) { +// f5 = block.getBlockBrightness(blockAccess, i, j, k); +// if (f5 < f4) { +// f5 = f4; +// } +// tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5); +// } +// +// renderBlocks.renderFaceZPos(null, 0, 0, 0, block.getBlockTextureFromSide(3)); +// +// if (doLight) { +// f5 = block.getBlockBrightness(blockAccess, i, j, k); +// if (f5 < f4) { +// f5 = f4; +// } +// tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5); +// } +// +// renderBlocks.renderFaceXNeg(null, 0, 0, 0, block.getBlockTextureFromSide(4)); +// +// if (doLight) { +// f5 = block.getBlockBrightness(blockAccess, i, j, k); +// if (f5 < f4) { +// f5 = f4; +// } +// tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5); +// } +// +// renderBlocks.renderFaceXPos(null, 0, 0, 0, block.getBlockTextureFromSide(5)); +// +// if (doTessellating) { +// tessellator.draw(); +// } +// } } diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index fec55a41..15d05963 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -42,7 +42,7 @@ import buildcraft.api.transport.ISolidSideTile; import buildcraft.core.BlockIndex; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; -import buildcraft.transport.render.PipeWorldRenderer; +import buildcraft.transport.render.PipeRendererWorld; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -167,7 +167,7 @@ public class BlockGenericPipe extends BlockContainer { super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } - float facadeThickness = PipeWorldRenderer.facadeThickness; + float facadeThickness = PipeRendererWorld.facadeThickness; if (tileG.hasFacade(ForgeDirection.EAST)) { setBlockBounds(1 - facadeThickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); diff --git a/common/buildcraft/transport/PipeRenderState.java b/common/buildcraft/transport/PipeRenderState.java index 7448d50c..8f25c942 100644 --- a/common/buildcraft/transport/PipeRenderState.java +++ b/common/buildcraft/transport/PipeRenderState.java @@ -16,14 +16,11 @@ public class PipeRenderState implements IClientState { private boolean hasGate = false; private int gateIconIndex = 0; - public final ConnectionMatrix pipeConnectionMatrix = new ConnectionMatrix(); public final TextureMatrix textureMatrix = new TextureMatrix(); public final WireMatrix wireMatrix = new WireMatrix(); public final ConnectionMatrix plugMatrix = new ConnectionMatrix(); - public final FacadeMatrix facadeMatrix = new FacadeMatrix(); - private boolean dirty = true; /* @@ -58,14 +55,18 @@ public class PipeRenderState implements IClientState { dirty = false; pipeConnectionMatrix.clean(); textureMatrix.clean(); - wireMatrix.clean(); facadeMatrix.clean(); + wireMatrix.clean(); } public boolean isDirty() { return dirty || pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || wireMatrix.isDirty() || facadeMatrix.isDirty() || plugMatrix.isDirty(); } + public boolean needsRenderUpdate() { + return pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || facadeMatrix.isDirty() || plugMatrix.isDirty(); + } + @Override public void writeData(DataOutputStream data) throws IOException { data.writeBoolean(hasGate); diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index e9e38d46..4a94280e 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -35,7 +35,6 @@ import buildcraft.api.gates.ITrigger; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; -import buildcraft.transport.IPipeConnectionForced; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipeConnection; import buildcraft.api.transport.IPipeTile; @@ -52,6 +51,8 @@ import buildcraft.core.network.PacketTileState; import buildcraft.transport.Gate.GateKind; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.server.management.PlayerInstance; +import net.minecraft.world.WorldServer; public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFluidHandler, IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, IDropControlInventory, IPipeRenderState, ISyncedTile, ISolidSideTile, IGuiReturnHandler { @@ -80,6 +81,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui public boolean[] pipeConnectionsBuffer = new boolean[6]; public SafeTimeTracker networkSyncTracker = new SafeTimeTracker(); public Pipe pipe; + private boolean sendClientUpdate = false; private boolean blockNeighborChange = false; private boolean refreshRenderState = false; private boolean pipeBound = false; @@ -186,6 +188,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui PowerReceiver provider = getPowerReceiver(null); if (provider != null) provider.update(); + + if (sendClientUpdate) { + sendClientUpdate = false; + if (worldObj instanceof WorldServer) { + WorldServer world = (WorldServer) worldObj; + PlayerInstance playerInstance = world.getPlayerManager().getOrCreateChunkWatcher(xCoord >> 4, zCoord >> 4, false); + if (playerInstance != null) { + playerInstance.sendToAllPlayersWatchingChunk(getDescriptionPacket()); + } + } + } } // PRECONDITION: worldObj must not be null @@ -244,8 +257,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } if (renderState.isDirty()) { - markBlockForUpdate(); renderState.clean(); + sendUpdateToClient(); } } @@ -363,6 +376,10 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui return packet.getPacket(); } + public void sendUpdateToClient() { + sendClientUpdate = true; + } + @Override public LinkedList getTriggers() { LinkedList result = new LinkedList(); @@ -428,12 +445,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui if (!BlockGenericPipe.isValid(pipe)) return false; - if(!(pipe instanceof IPipeConnectionForced) || !((IPipeConnectionForced) pipe).ignoreConnectionOverrides(side)) + if (!(pipe instanceof IPipeConnectionForced) || !((IPipeConnectionForced) pipe).ignoreConnectionOverrides(side)) if (with instanceof IPipeConnection) { IPipeConnection.ConnectOverride override = ((IPipeConnection) with).overridePipeConnection(pipe.transport.getPipeType(), side.getOpposite()); if (override != IPipeConnection.ConnectOverride.DEFAULT) return override == IPipeConnection.ConnectOverride.CONNECT ? true : false; - } + } if (with instanceof TileGenericPipe) { if (((TileGenericPipe) with).hasPlug(side.getOpposite())) @@ -618,9 +635,16 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui pipe.gate = new GateVanilla(pipe); pipe.gate.kind = GateKind.values()[coreState.gateKind]; } + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); break; + case 1: { + if (renderState.needsRenderUpdate()) { + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + renderState.clean(); + } + break; + } } - worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } @Override @@ -690,11 +714,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; } - - public void markBlockForUpdate() { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - + @Override public void writeGuiData(DataOutputStream data) throws IOException { if (BlockGenericPipe.isValid(pipe) && pipe instanceof IGuiReturnHandler) diff --git a/common/buildcraft/transport/TransportProxyClient.java b/common/buildcraft/transport/TransportProxyClient.java index d75da5f0..b654f44d 100644 --- a/common/buildcraft/transport/TransportProxyClient.java +++ b/common/buildcraft/transport/TransportProxyClient.java @@ -3,23 +3,23 @@ package buildcraft.transport; import buildcraft.BuildCraftTransport; import buildcraft.transport.render.FacadeItemRenderer; import buildcraft.transport.render.PipeItemRenderer; -import buildcraft.transport.render.PipeWorldRenderer; +import buildcraft.transport.render.PipeRendererWorld; import buildcraft.transport.render.PlugItemRenderer; -import buildcraft.transport.render.RenderPipe; +import buildcraft.transport.render.PipeRendererTESR; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import net.minecraftforge.client.MinecraftForgeClient; public class TransportProxyClient extends TransportProxy { public final static PipeItemRenderer pipeItemRenderer = new PipeItemRenderer(); - public final static PipeWorldRenderer pipeWorldRenderer = new PipeWorldRenderer(); + public final static PipeRendererWorld pipeWorldRenderer = new PipeRendererWorld(); public final static FacadeItemRenderer facadeItemRenderer = new FacadeItemRenderer(); public final static PlugItemRenderer plugItemRenderer = new PlugItemRenderer(); @Override public void registerTileEntities() { super.registerTileEntities(); - RenderPipe rp = new RenderPipe(); + PipeRendererTESR rp = new PipeRendererTESR(); ClientRegistry.bindTileEntitySpecialRenderer(TileDummyGenericPipe.class, rp); ClientRegistry.bindTileEntitySpecialRenderer(TileDummyGenericPipe2.class, rp); ClientRegistry.bindTileEntitySpecialRenderer(TileGenericPipe.class, rp); diff --git a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java index 7c030ef6..2d631529 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java @@ -72,7 +72,6 @@ public class PipeItemsDaizuli extends Pipe implements IPipeT if (color != c.ordinal()) { this.color = c.ordinal(); container.scheduleRenderUpdate(); - container.markBlockForUpdate(); } } diff --git a/common/buildcraft/transport/pipes/PipeItemsLapis.java b/common/buildcraft/transport/pipes/PipeItemsLapis.java index 10d83ff8..3966a23e 100644 --- a/common/buildcraft/transport/pipes/PipeItemsLapis.java +++ b/common/buildcraft/transport/pipes/PipeItemsLapis.java @@ -77,7 +77,6 @@ public class PipeItemsLapis extends Pipe implements IItemTra if (color.ordinal() != container.getBlockMetadata()) { container.worldObj.setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, color.ordinal(), 3); container.scheduleRenderUpdate(); - container.markBlockForUpdate(); } } diff --git a/common/buildcraft/transport/pipes/PipeLogicIron.java b/common/buildcraft/transport/pipes/PipeLogicIron.java index 9bce940a..486cdb0b 100644 --- a/common/buildcraft/transport/pipes/PipeLogicIron.java +++ b/common/buildcraft/transport/pipes/PipeLogicIron.java @@ -82,7 +82,7 @@ public abstract class PipeLogicIron { Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null; if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord)) { switchPosition(); - pipe.container.worldObj.markBlockForUpdate(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); + pipe.container.scheduleRenderUpdate(); ((IToolWrench) equipped).wrenchUsed(entityplayer, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); return true; diff --git a/common/buildcraft/transport/pipes/PipePowerIron.java b/common/buildcraft/transport/pipes/PipePowerIron.java index dbf942f0..2a6b30bd 100644 --- a/common/buildcraft/transport/pipes/PipePowerIron.java +++ b/common/buildcraft/transport/pipes/PipePowerIron.java @@ -99,7 +99,6 @@ public class PipePowerIron extends Pipe { if (mode.ordinal() != container.getBlockMetadata()) { container.worldObj.setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, mode.ordinal(), 3); container.scheduleRenderUpdate(); - container.markBlockForUpdate(); } } diff --git a/common/buildcraft/transport/render/PipeRendererTESR.java b/common/buildcraft/transport/render/PipeRendererTESR.java index 859f40d1..425cfde7 100644 --- a/common/buildcraft/transport/render/PipeRendererTESR.java +++ b/common/buildcraft/transport/render/PipeRendererTESR.java @@ -10,13 +10,16 @@ package buildcraft.transport.render; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore.RenderMode; import buildcraft.BuildCraftTransport; +import buildcraft.api.transport.IPipe; +import buildcraft.api.transport.IPipe.WireColor; import buildcraft.core.render.FluidRenderer; import buildcraft.core.render.RenderEntityBlock; -import buildcraft.core.render.RenderEntityBlock.BlockInterface; +import buildcraft.core.render.RenderEntityBlock.RenderInfo; import buildcraft.core.utils.EnumColor; import buildcraft.core.utils.Utils; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; +import buildcraft.transport.PipeRenderState; import buildcraft.transport.PipeTransportFluids; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.PipeTransportPower; @@ -26,6 +29,7 @@ import com.google.common.collect.Maps; import java.util.HashMap; import net.minecraft.block.Block; import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureMap; @@ -40,7 +44,7 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; -public class RenderPipe extends TileEntitySpecialRenderer { +public class PipeRendererTESR extends TileEntitySpecialRenderer { final static private int LIQUID_STAGES = 40; final static private int MAX_ITEMS_TO_RENDER = 10; @@ -61,7 +65,7 @@ public class RenderPipe extends TileEntitySpecialRenderer { public int[] displayPowerList = new int[POWER_STAGES]; public int[] displayPowerListOverload = new int[POWER_STAGES]; - public RenderPipe() { + public PipeRendererTESR() { customRenderItem = new RenderItem() { @Override public boolean shouldBob() { @@ -84,7 +88,7 @@ public class RenderPipe extends TileEntitySpecialRenderer { DisplayFluidList d = new DisplayFluidList(); displayFluidLists.put(liquidId, d); - BlockInterface block = new BlockInterface(); + RenderInfo block = new RenderInfo(); Fluid fluid = FluidRegistry.getFluid(liquidId); if (fluid.getBlockID() > 0) { @@ -185,7 +189,7 @@ public class RenderPipe extends TileEntitySpecialRenderer { initialized = true; - BlockInterface block = new BlockInterface(); + RenderInfo block = new RenderInfo(); block.texture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Power_Normal.ordinal()); float size = Utils.pipeMaxPos - Utils.pipeMinPos; @@ -250,6 +254,8 @@ public class RenderPipe extends TileEntitySpecialRenderer { if (pipe.pipe == null) return; + renderGatesWires(pipe, x, y, z); + switch (pipe.getPipeType()) { case ITEM: renderSolids(pipe.pipe, x, y, z); @@ -263,6 +269,254 @@ public class RenderPipe extends TileEntitySpecialRenderer { } } + private void renderGatesWires(TileGenericPipe pipe, double x, double y, double z) { + PipeRenderState state = pipe.getRenderState(); + + if (state.wireMatrix.hasWire(WireColor.Red)) { + pipeWireRender(pipe, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMinPos, IPipe.WireColor.Red, x, y, z); + } + + if (state.wireMatrix.hasWire(WireColor.Blue)) { + pipeWireRender(pipe, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos, IPipe.WireColor.Blue, x, y, z); + } + + if (state.wireMatrix.hasWire(WireColor.Green)) { + pipeWireRender(pipe, Utils.pipeMaxPos, Utils.pipeMinPos, Utils.pipeMinPos, IPipe.WireColor.Green, x, y, z); + } + + if (state.wireMatrix.hasWire(WireColor.Yellow)) { + pipeWireRender(pipe, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, IPipe.WireColor.Yellow, x, y, z); + } + + if (state.hasGate()) { + pipeGateRender(pipe, x, y, z); + } + } + + private void pipeWireRender(TileGenericPipe pipe, float cx, float cy, float cz, IPipe.WireColor color, double x, double y, double z) { + + PipeRenderState state = pipe.getRenderState(); + + float minX = Utils.pipeMinPos; + float minY = Utils.pipeMinPos; + float minZ = Utils.pipeMinPos; + + float maxX = Utils.pipeMaxPos; + float maxY = Utils.pipeMaxPos; + float maxZ = Utils.pipeMaxPos; + + boolean foundX = false, foundY = false, foundZ = false; + + if (state.wireMatrix.isWireConnected(color, ForgeDirection.WEST)) { + minX = 0; + foundX = true; + } + + if (state.wireMatrix.isWireConnected(color, ForgeDirection.EAST)) { + maxX = 1; + foundX = true; + } + + if (state.wireMatrix.isWireConnected(color, ForgeDirection.DOWN)) { + minY = 0; + foundY = true; + } + + if (state.wireMatrix.isWireConnected(color, ForgeDirection.UP)) { + maxY = 1; + foundY = true; + } + + if (state.wireMatrix.isWireConnected(color, ForgeDirection.NORTH)) { + minZ = 0; + foundZ = true; + } + + if (state.wireMatrix.isWireConnected(color, ForgeDirection.SOUTH)) { + maxZ = 1; + foundZ = true; + } + + boolean center = false; + + if (minX == 0 && maxX != 1 && (foundY || foundZ)) + if (cx == Utils.pipeMinPos) { + maxX = Utils.pipeMinPos; + } else { + center = true; + } + + if (minX != 0 && maxX == 1 && (foundY || foundZ)) + if (cx == Utils.pipeMaxPos) { + minX = Utils.pipeMaxPos; + } else { + center = true; + } + + if (minY == 0 && maxY != 1 && (foundX || foundZ)) + if (cy == Utils.pipeMinPos) { + maxY = Utils.pipeMinPos; + } else { + center = true; + } + + if (minY != 0 && maxY == 1 && (foundX || foundZ)) + if (cy == Utils.pipeMaxPos) { + minY = Utils.pipeMaxPos; + } else { + center = true; + } + + if (minZ == 0 && maxZ != 1 && (foundX || foundY)) + if (cz == Utils.pipeMinPos) { + maxZ = Utils.pipeMinPos; + } else { + center = true; + } + + if (minZ != 0 && maxZ == 1 && (foundX || foundY)) + if (cz == Utils.pipeMaxPos) { + minZ = Utils.pipeMaxPos; + } else { + center = true; + } + + boolean found = foundX || foundY || foundZ; + + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_CULL_FACE); + RenderHelper.disableStandardItemLighting(); + + GL11.glColor3f(1, 1, 1); + GL11.glTranslatef((float) x, (float) y, (float) z); + + bindTexture(TextureMap.locationBlocksTexture); + + RenderInfo box = new RenderInfo(); + box.texture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(color)); + + // Z render + + if (minZ != Utils.pipeMinPos || maxZ != Utils.pipeMaxPos || !found) { + box.setBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, minZ, cx == Utils.pipeMinPos ? cx + : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, maxZ); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + } + + // X render + + if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) { + box.setBounds(minX, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, maxX, cy == Utils.pipeMinPos ? cy + : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + } + + // Y render + + if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) { + box.setBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, minY, cz == Utils.pipeMinPos ? cz - 0.05F : cz, cx == Utils.pipeMinPos ? cx + : cx + 0.05F, maxY, cz == Utils.pipeMinPos ? cz : cz + 0.05F); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + } + + if (center || !found) { + box.setBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, + cx == Utils.pipeMinPos ? cx : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + } + + RenderHelper.enableStandardItemLighting(); + + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + + private void pipeGateRender(TileGenericPipe pipe, double x, double y, double z) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); +// GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_CULL_FACE); +// GL11.glDisable(GL11.GL_TEXTURE_2D); + RenderHelper.disableStandardItemLighting(); + + GL11.glColor3f(1, 1, 1); + GL11.glTranslatef((float) x, (float) y, (float) z); + + bindTexture(TextureMap.locationBlocksTexture); + + PipeRenderState state = pipe.getRenderState(); + + float min = Utils.pipeMinPos + 0.05F; + float max = Utils.pipeMaxPos - 0.05F; + + RenderInfo box = new RenderInfo(); + box.texture = BuildCraftTransport.instance.gateIconProvider.getIcon(state.getGateIconIndex()); + + if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) { + box.setBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos + 0.001F, max, max); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + } + + if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) { + box.setBounds(Utils.pipeMaxPos + 0.001F, min, min, Utils.pipeMaxPos + 0.10F, max, max); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + } + + if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) { + box.setBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos + 0.001F, max); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + } + + if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) { + box.setBounds(min, Utils.pipeMaxPos + 0.001F, min, max, Utils.pipeMaxPos + 0.10F, max); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + } + + if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) { + box.setBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos + 0.001F); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + } + + if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) { + box.setBounds(min, min, Utils.pipeMaxPos + 0.001F, max, max, Utils.pipeMaxPos + 0.10F); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + } + + RenderHelper.enableStandardItemLighting(); + + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + + private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) { + return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) == 0 && !state.plugMatrix.isConnected(direction) && !isOpenOrientation(state, direction); + } + + public boolean isOpenOrientation(PipeRenderState state, ForgeDirection direction) { + int connections = 0; + + ForgeDirection targetOrientation = ForgeDirection.UNKNOWN; + + for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { + if (state.pipeConnectionMatrix.isConnected(o)) { + + connections++; + + if (connections == 1) + targetOrientation = o; + } + } + + if (connections > 1 || connections == 0) + return false; + + return targetOrientation.getOpposite() == direction; + } + private void renderPower(Pipe pipe, double x, double y, double z) { initializeDisplayPowerList(pipe.container.worldObj); @@ -449,7 +703,7 @@ public class RenderPipe extends TileEntitySpecialRenderer { customRenderItem.doRenderItem(dummyEntityItem, 0, 0, 0, 0, 0); if (color != null) { bindTexture(TextureMap.locationBlocksTexture); - BlockInterface block = new BlockInterface(); + RenderInfo block = new RenderInfo(); block.texture = PipeIconProvider.TYPE.ItemBox.getIcon(); diff --git a/common/buildcraft/transport/render/PipeRendererWorld.java b/common/buildcraft/transport/render/PipeRendererWorld.java index 31983f43..5cc1baef 100644 --- a/common/buildcraft/transport/render/PipeRendererWorld.java +++ b/common/buildcraft/transport/render/PipeRendererWorld.java @@ -2,8 +2,6 @@ package buildcraft.transport.render; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.api.transport.IPipe; -import buildcraft.api.transport.IPipe.WireColor; import buildcraft.core.utils.Utils; import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.IPipeRenderState; @@ -20,7 +18,7 @@ import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.ForgeDirection; -public class PipeWorldRenderer implements ISimpleBlockRenderingHandler { +public class PipeRendererWorld implements ISimpleBlockRenderingHandler { public static final float facadeThickness = 1F / 16F; @@ -197,31 +195,6 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler { renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - if (state.wireMatrix.hasWire(WireColor.Red)) { - state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Red)); - - pipeWireRender(renderblocks, block, state, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMinPos, IPipe.WireColor.Red, x, y, z); - } - - if (state.wireMatrix.hasWire(WireColor.Blue)) { - state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Blue)); - pipeWireRender(renderblocks, block, state, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos, IPipe.WireColor.Blue, x, y, z); - } - - if (state.wireMatrix.hasWire(WireColor.Green)) { - state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Green)); - pipeWireRender(renderblocks, block, state, Utils.pipeMaxPos, Utils.pipeMinPos, Utils.pipeMinPos, IPipe.WireColor.Green, x, y, z); - } - - if (state.wireMatrix.hasWire(WireColor.Yellow)) { - state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Yellow)); - pipeWireRender(renderblocks, block, state, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, IPipe.WireColor.Yellow, x, y, z); - } - - if (state.hasGate()) { - pipeGateRender(renderblocks, block, state, x, y, z); - } - pipeFacadeRenderer(renderblocks, block, state, x, y, z); pipePlugRenderer(renderblocks, block, state, x, y, z); @@ -392,190 +365,6 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler { } - private void pipeWireRender(RenderBlocks renderblocks, Block block, PipeRenderState state, float cx, float cy, float cz, IPipe.WireColor color, int x, - int y, int z) { - - float minX = Utils.pipeMinPos; - float minY = Utils.pipeMinPos; - float minZ = Utils.pipeMinPos; - - float maxX = Utils.pipeMaxPos; - float maxY = Utils.pipeMaxPos; - float maxZ = Utils.pipeMaxPos; - - boolean foundX = false, foundY = false, foundZ = false; - - if (state.wireMatrix.isWireConnected(color, ForgeDirection.WEST)) { - minX = 0; - foundX = true; - } - - if (state.wireMatrix.isWireConnected(color, ForgeDirection.EAST)) { - maxX = 1; - foundX = true; - } - - if (state.wireMatrix.isWireConnected(color, ForgeDirection.DOWN)) { - minY = 0; - foundY = true; - } - - if (state.wireMatrix.isWireConnected(color, ForgeDirection.UP)) { - maxY = 1; - foundY = true; - } - - if (state.wireMatrix.isWireConnected(color, ForgeDirection.NORTH)) { - minZ = 0; - foundZ = true; - } - - if (state.wireMatrix.isWireConnected(color, ForgeDirection.SOUTH)) { - maxZ = 1; - foundZ = true; - } - - boolean center = false; - - if (minX == 0 && maxX != 1 && (foundY || foundZ)) - if (cx == Utils.pipeMinPos) { - maxX = Utils.pipeMinPos; - } else { - center = true; - } - - if (minX != 0 && maxX == 1 && (foundY || foundZ)) - if (cx == Utils.pipeMaxPos) { - minX = Utils.pipeMaxPos; - } else { - center = true; - } - - if (minY == 0 && maxY != 1 && (foundX || foundZ)) - if (cy == Utils.pipeMinPos) { - maxY = Utils.pipeMinPos; - } else { - center = true; - } - - if (minY != 0 && maxY == 1 && (foundX || foundZ)) - if (cy == Utils.pipeMaxPos) { - minY = Utils.pipeMaxPos; - } else { - center = true; - } - - if (minZ == 0 && maxZ != 1 && (foundX || foundY)) - if (cz == Utils.pipeMinPos) { - maxZ = Utils.pipeMinPos; - } else { - center = true; - } - - if (minZ != 0 && maxZ == 1 && (foundX || foundY)) - if (cz == Utils.pipeMaxPos) { - minZ = Utils.pipeMaxPos; - } else { - center = true; - } - - boolean found = foundX || foundY || foundZ; - - // Z render - - if (minZ != Utils.pipeMinPos || maxZ != Utils.pipeMaxPos || !found) { - renderblocks.setRenderBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, minZ, cx == Utils.pipeMinPos ? cx - : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, maxZ); - renderblocks.renderStandardBlock(block, x, y, z); - } - - // X render - - if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) { - renderblocks.setRenderBounds(minX, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, maxX, cy == Utils.pipeMinPos ? cy - : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F); - renderblocks.renderStandardBlock(block, x, y, z); - } - - // Y render - - if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) { - renderblocks.setRenderBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, minY, cz == Utils.pipeMinPos ? cz - 0.05F : cz, cx == Utils.pipeMinPos ? cx - : cx + 0.05F, maxY, cz == Utils.pipeMinPos ? cz : cz + 0.05F); - renderblocks.renderStandardBlock(block, x, y, z); - } - - if (center || !found) { - renderblocks.setRenderBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, - cx == Utils.pipeMinPos ? cx : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F); - renderblocks.renderStandardBlock(block, x, y, z); - } - - } - - private void pipeGateRender(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) { - - state.currentTexture = BuildCraftTransport.instance.gateIconProvider.getIcon(state.getGateIconIndex()); - - float min = Utils.pipeMinPos + 0.05F; - float max = Utils.pipeMaxPos - 0.05F; - - if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) { - renderblocks.setRenderBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos + 0.001F, max, max); - renderblocks.renderStandardBlock(block, x, y, z); - } - - if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) { - renderblocks.setRenderBounds(Utils.pipeMaxPos + 0.001F, min, min, Utils.pipeMaxPos + 0.10F, max, max); - renderblocks.renderStandardBlock(block, x, y, z); - } - - if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) { - renderblocks.setRenderBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos + 0.001F, max); - renderblocks.renderStandardBlock(block, x, y, z); - } - - if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) { - renderblocks.setRenderBounds(min, Utils.pipeMaxPos + 0.001F, min, max, Utils.pipeMaxPos + 0.10F, max); - renderblocks.renderStandardBlock(block, x, y, z); - } - - if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) { - renderblocks.setRenderBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos + 0.001F); - renderblocks.renderStandardBlock(block, x, y, z); - } - - if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) { - renderblocks.setRenderBounds(min, min, Utils.pipeMaxPos + 0.001F, max, max, Utils.pipeMaxPos + 0.10F); - renderblocks.renderStandardBlock(block, x, y, z); - } - } - - private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) { - return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) == 0 && !state.plugMatrix.isConnected(direction) && !isOpenOrientation(state, direction); - } - - public boolean isOpenOrientation(PipeRenderState state, ForgeDirection direction) { - int connections = 0; - - ForgeDirection targetOrientation = ForgeDirection.UNKNOWN; - - for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { - if (state.pipeConnectionMatrix.isConnected(o)) { - - connections++; - - if (connections == 1) - targetOrientation = o; - } - } - - if (connections > 1 || connections == 0) - return false; - - return targetOrientation.getOpposite() == direction; - } - @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { // TODO Auto-generated method stub diff --git a/common/buildcraft/transport/utils/ConnectionMatrix.java b/common/buildcraft/transport/utils/ConnectionMatrix.java index 778e7ba7..93acc280 100644 --- a/common/buildcraft/transport/utils/ConnectionMatrix.java +++ b/common/buildcraft/transport/utils/ConnectionMatrix.java @@ -8,9 +8,8 @@ import net.minecraftforge.common.ForgeDirection; public class ConnectionMatrix { - private final BitSet _connected = new BitSet(ForgeDirection.VALID_DIRECTIONS.length); + private BitSet _connected = new BitSet(ForgeDirection.VALID_DIRECTIONS.length); private final BitSetCodec _bitSetCodec = new BitSetCodec(); - private boolean dirty = false; public boolean isConnected(ForgeDirection direction) { @@ -18,7 +17,7 @@ public class ConnectionMatrix { } public void setConnected(ForgeDirection direction, boolean value) { - if (_connected.get(direction.ordinal()) != value){ + if (_connected.get(direction.ordinal()) != value) { _connected.set(direction.ordinal(), value); dirty = true; } @@ -37,6 +36,11 @@ public class ConnectionMatrix { } public void readData(DataInputStream data) throws IOException { - _bitSetCodec.decode(data.readByte(), _connected); + BitSet connection = new BitSet(ForgeDirection.VALID_DIRECTIONS.length); + _bitSetCodec.decode(data.readByte(), connection); + if (!_connected.equals(connection)) { + _connected = connection; + dirty = true; + } } } diff --git a/common/buildcraft/transport/utils/FacadeMatrix.java b/common/buildcraft/transport/utils/FacadeMatrix.java index 086eecc5..b4ce11d4 100644 --- a/common/buildcraft/transport/utils/FacadeMatrix.java +++ b/common/buildcraft/transport/utils/FacadeMatrix.java @@ -6,27 +6,27 @@ import java.io.IOException; import net.minecraftforge.common.ForgeDirection; public class FacadeMatrix { + private final int[] _blockIds = new int[ForgeDirection.VALID_DIRECTIONS.length]; private final int[] _blockMetas = new int[ForgeDirection.VALID_DIRECTIONS.length]; - private boolean dirty = false; public FacadeMatrix() { } - public void setFacade(ForgeDirection direction, int blockId, int blockMeta){ - if (_blockIds[direction.ordinal()] != blockId || _blockMetas[direction.ordinal()] != blockMeta){ + public void setFacade(ForgeDirection direction, int blockId, int blockMeta) { + if (_blockIds[direction.ordinal()] != blockId || _blockMetas[direction.ordinal()] != blockMeta) { _blockIds[direction.ordinal()] = blockId; _blockMetas[direction.ordinal()] = blockMeta; dirty = true; } } - - public int getFacadeBlockId(ForgeDirection direction){ + + public int getFacadeBlockId(ForgeDirection direction) { return _blockIds[direction.ordinal()]; } - - public int getFacadeMetaId(ForgeDirection direction){ + + public int getFacadeMetaId(ForgeDirection direction) { return _blockMetas[direction.ordinal()]; } @@ -38,17 +38,25 @@ public class FacadeMatrix { dirty = false; } - public void readData(DataInputStream data) throws IOException { - for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { - _blockIds[i] = data.readShort(); - _blockMetas[i] = data.readByte(); - } - } - public void writeData(DataOutputStream data) throws IOException { for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { data.writeShort(_blockIds[i]); data.writeByte(_blockMetas[i]); } } + + public void readData(DataInputStream data) throws IOException { + for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { + short id = data.readShort(); + if (_blockIds[i] != id) { + _blockIds[i] = id; + dirty = true; + } + byte meta = data.readByte(); + if (_blockMetas[i] != meta) { + _blockMetas[i] = meta; + dirty = true; + } + } + } } diff --git a/common/buildcraft/transport/utils/TextureMatrix.java b/common/buildcraft/transport/utils/TextureMatrix.java index eb535a9b..2da1e5d7 100644 --- a/common/buildcraft/transport/utils/TextureMatrix.java +++ b/common/buildcraft/transport/utils/TextureMatrix.java @@ -8,7 +8,6 @@ import net.minecraftforge.common.ForgeDirection; public class TextureMatrix { private final int[] _iconIndexes = new int[7]; - private boolean dirty = false; public int getTextureIndex(ForgeDirection direction) { @@ -38,7 +37,11 @@ public class TextureMatrix { public void readData(DataInputStream data) throws IOException { for (int i = 0; i < _iconIndexes.length; i++) { - _iconIndexes[i] = data.readByte(); + int icon = data.readByte(); + if (_iconIndexes[i] != icon) { + _iconIndexes[i] = icon; + dirty = true; + } } } } From 11c96949ec7dedb4f439369b415aa8170eead8da Mon Sep 17 00:00:00 2001 From: viliml Date: Wed, 9 Oct 2013 19:19:39 +0200 Subject: [PATCH 070/121] Fix Forge ore dictionary support for the Assembly Table Fixes https://github.com/BuildCraft/BuildCraft/issues/531 . Don't worry, I checked it and it has no errors and works as intended :D --- common/buildcraft/api/recipes/AssemblyRecipe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/api/recipes/AssemblyRecipe.java b/common/buildcraft/api/recipes/AssemblyRecipe.java index 573db282..c9ace7fc 100644 --- a/common/buildcraft/api/recipes/AssemblyRecipe.java +++ b/common/buildcraft/api/recipes/AssemblyRecipe.java @@ -32,7 +32,7 @@ public class AssemblyRecipe { continue; } - if (item.isItemEqual(in)) { + if (StackHelper.instance().isCraftingEquivalent(in, item, true)) { found += item.stackSize; // Adds quantity of stack to amount // found } From 16a577e1ebf4378864997dd4bee0c085f0db7acf Mon Sep 17 00:00:00 2001 From: Reika Date: Thu, 10 Oct 2013 00:37:31 -0400 Subject: [PATCH 071/121] Bugfix for non-world liquids --- common/buildcraft/core/render/FluidRenderer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/buildcraft/core/render/FluidRenderer.java b/common/buildcraft/core/render/FluidRenderer.java index e5c3836b..5ce8c4c2 100644 --- a/common/buildcraft/core/render/FluidRenderer.java +++ b/common/buildcraft/core/render/FluidRenderer.java @@ -28,6 +28,7 @@ import org.lwjgl.opengl.GL11; public class FluidRenderer { private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; + private static final ResourceLocation ITEM_TEXTURE = TextureMap.locationItemsTexture; private static Map flowingRenderCache = new HashMap(); private static Map stillRenderCache = new HashMap(); public static final int DISPLAY_STAGES = 100; @@ -58,7 +59,10 @@ public class FluidRenderer { } public static ResourceLocation getFluidSheet(Fluid liquid) { + if (liquid.canBePlacedInWorld()) return BLOCK_TEXTURE; + else + return ITEM_TEXTURE; } public static void setColorForFluidStack(FluidStack fluidstack) { From 16a6d768dbf42a75a27c49f6d5fbcd9abdef5452 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 10 Oct 2013 03:45:00 -0700 Subject: [PATCH 072/121] Revert "Bugfix for non-world liquids" This reverts commit 16a577e1ebf4378864997dd4bee0c085f0db7acf. --- common/buildcraft/core/render/FluidRenderer.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/common/buildcraft/core/render/FluidRenderer.java b/common/buildcraft/core/render/FluidRenderer.java index 5ce8c4c2..e5c3836b 100644 --- a/common/buildcraft/core/render/FluidRenderer.java +++ b/common/buildcraft/core/render/FluidRenderer.java @@ -28,7 +28,6 @@ import org.lwjgl.opengl.GL11; public class FluidRenderer { private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; - private static final ResourceLocation ITEM_TEXTURE = TextureMap.locationItemsTexture; private static Map flowingRenderCache = new HashMap(); private static Map stillRenderCache = new HashMap(); public static final int DISPLAY_STAGES = 100; @@ -59,10 +58,7 @@ public class FluidRenderer { } public static ResourceLocation getFluidSheet(Fluid liquid) { - if (liquid.canBePlacedInWorld()) return BLOCK_TEXTURE; - else - return ITEM_TEXTURE; } public static void setColorForFluidStack(FluidStack fluidstack) { From 62f2ac032ccda4b4cdcec8284a274bb9276556b7 Mon Sep 17 00:00:00 2001 From: Matthew Prenger Date: Thu, 10 Oct 2013 18:48:32 -0500 Subject: [PATCH 073/121] Fixed missing import --- common/buildcraft/api/recipes/AssemblyRecipe.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/buildcraft/api/recipes/AssemblyRecipe.java b/common/buildcraft/api/recipes/AssemblyRecipe.java index c9ace7fc..f9db4ce9 100644 --- a/common/buildcraft/api/recipes/AssemblyRecipe.java +++ b/common/buildcraft/api/recipes/AssemblyRecipe.java @@ -1,6 +1,8 @@ package buildcraft.api.recipes; import java.util.LinkedList; + +import buildcraft.core.inventory.StackHelper; import net.minecraft.item.ItemStack; public class AssemblyRecipe { From 7daea136eac3fbdcf3bb2182b53fac21a25b038b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 11 Oct 2013 06:02:22 -0700 Subject: [PATCH 074/121] Revert "Fix Forge ore dictionary support for the Assembly Table" This reverts commit 11c96949ec7dedb4f439369b415aa8170eead8da. --- common/buildcraft/api/recipes/AssemblyRecipe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/api/recipes/AssemblyRecipe.java b/common/buildcraft/api/recipes/AssemblyRecipe.java index c9ace7fc..573db282 100644 --- a/common/buildcraft/api/recipes/AssemblyRecipe.java +++ b/common/buildcraft/api/recipes/AssemblyRecipe.java @@ -32,7 +32,7 @@ public class AssemblyRecipe { continue; } - if (StackHelper.instance().isCraftingEquivalent(in, item, true)) { + if (item.isItemEqual(in)) { found += item.stackSize; // Adds quantity of stack to amount // found } From 54b2e5de8809b21dc606463cd023b35635776369 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 11 Oct 2013 06:02:57 -0700 Subject: [PATCH 075/121] Revert "Fixed missing import" This reverts commit 62f2ac032ccda4b4cdcec8284a274bb9276556b7. --- common/buildcraft/api/recipes/AssemblyRecipe.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/buildcraft/api/recipes/AssemblyRecipe.java b/common/buildcraft/api/recipes/AssemblyRecipe.java index a384f712..573db282 100644 --- a/common/buildcraft/api/recipes/AssemblyRecipe.java +++ b/common/buildcraft/api/recipes/AssemblyRecipe.java @@ -1,8 +1,6 @@ package buildcraft.api.recipes; import java.util.LinkedList; - -import buildcraft.core.inventory.StackHelper; import net.minecraft.item.ItemStack; public class AssemblyRecipe { From 9cb53f940572ed9f7670aeebafc26d90dd45a99e Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 11 Oct 2013 06:06:11 -0700 Subject: [PATCH 076/121] Fix NPE in ACT Closes #1270 --- common/buildcraft/silicon/TileAdvancedCraftingTable.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/silicon/TileAdvancedCraftingTable.java b/common/buildcraft/silicon/TileAdvancedCraftingTable.java index 42ea6138..8fd35a15 100644 --- a/common/buildcraft/silicon/TileAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/TileAdvancedCraftingTable.java @@ -72,7 +72,6 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory, if (useRecipeStack || tempStacks == null) { return craftingSlots.getStackInSlot(slot); } else { - if (bindings[slot] >= 0) { return tempStacks[bindings[slot]]; } @@ -85,14 +84,14 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory, @Override public void setInventorySlotContents(int slot, ItemStack par2ItemStack) { - if (tempStacks != null && slot >= 0 && slot < 9) { + if (tempStacks != null && slot >= 0 && slot < 9 && bindings[slot] >= 0) { tempStacks[bindings[slot]] = par2ItemStack; } } @Override public ItemStack decrStackSize(int slot, int amount) { - if (tempStacks != null && slot >= 0 && slot < 9) { + if (tempStacks != null && slot >= 0 && slot < 9 && bindings[slot] >= 0) { if (tempStacks[bindings[slot]].stackSize <= amount) { ItemStack result = tempStacks[bindings[slot]]; tempStacks[bindings[slot]] = null; From 99fca02856cf0b297b02417f4fc7a7037a3cd91f Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 11 Oct 2013 19:16:57 -0700 Subject: [PATCH 077/121] Fix Pipe Raytracing + Improve Pipe interactions Closes #1246 Its now much easier and more consistent to remove specific addons from a pipe. Sneak-click with a gate to remove a gate, sneak-click with a Yellow Wire to remove a Yellow Wire, etc... Plugs can now be placed easily and simply on any side of the pipe in any configuration. Selection Box now highlights the part of the pipe you are pointing at. --- common/buildcraft/BuildCraftTransport.java | 8 +- common/buildcraft/core/CoreConstants.java | 19 + common/buildcraft/core/ItemBuildCraft.java | 30 +- .../core/render/RenderingEntityBlocks.java | 7 +- .../core/utils/MatrixTranformations.java | 73 +++ common/buildcraft/core/utils/Utils.java | 13 +- common/buildcraft/factory/BlockFrame.java | 19 +- common/buildcraft/factory/BlockPlainPipe.java | 10 +- common/buildcraft/factory/TilePump.java | 7 +- common/buildcraft/factory/TileQuarry.java | 8 +- .../silicon/SiliconRenderBlock.java | 4 +- .../transport/BlockGenericPipe.java | 576 ++++++++++-------- common/buildcraft/transport/ItemFacade.java | 48 +- common/buildcraft/transport/ItemGate.java | 1 + common/buildcraft/transport/ItemPlug.java | 48 +- common/buildcraft/transport/Pipe.java | 24 + .../transport/PipeTransportItems.java | 16 +- .../buildcraft/transport/TileGenericPipe.java | 41 +- .../transport/TransportConstants.java | 21 + .../transport/pipes/PipeItemsDaizuli.java | 10 +- .../transport/pipes/PipeItemsGold.java | 4 +- .../transport/pipes/PipeItemsLapis.java | 10 +- .../transport/pipes/PipeItemsObsidian.java | 4 +- .../transport/pipes/PipeItemsQuartz.java | 10 +- .../transport/pipes/PipeItemsStone.java | 10 +- .../transport/render/FacadeItemRenderer.java | 8 +- .../transport/render/PipeItemRenderer.java | 4 +- .../transport/render/PipeRendererTESR.java | 126 ++-- .../transport/render/PipeRendererWorld.java | 116 +--- .../transport/render/TileEntityPickupFX.java | 4 +- .../transport/utils/TransportUtils.java | 27 + 31 files changed, 763 insertions(+), 543 deletions(-) create mode 100644 common/buildcraft/core/CoreConstants.java create mode 100644 common/buildcraft/core/utils/MatrixTranformations.java create mode 100644 common/buildcraft/transport/TransportConstants.java create mode 100644 common/buildcraft/transport/utils/TransportUtils.java diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 026a147b..6d3edfe7 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -313,28 +313,28 @@ public class BuildCraftTransport { // 1, 0), Block.glass, new ItemStack(Item.dyePowder, 1, 11)); Property redPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "redPipeWire.id", DefaultProps.RED_PIPE_WIRE); - redPipeWire = new ItemBuildCraft(redPipeWireId.getInt()); + redPipeWire = new ItemBuildCraft(redPipeWireId.getInt()).setPassSneakClick(true); redPipeWire.setUnlocalizedName("redPipeWire"); LanguageRegistry.addName(redPipeWire, "Red Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 1), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(redPipeWire, 8))); Property bluePipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "bluePipeWire.id", DefaultProps.BLUE_PIPE_WIRE); - bluePipeWire = new ItemBuildCraft(bluePipeWireId.getInt()); + bluePipeWire = new ItemBuildCraft(bluePipeWireId.getInt()).setPassSneakClick(true); bluePipeWire.setUnlocalizedName("bluePipeWire"); LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 4), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(bluePipeWire, 8))); Property greenPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "greenPipeWire.id", DefaultProps.GREEN_PIPE_WIRE); - greenPipeWire = new ItemBuildCraft(greenPipeWireId.getInt()); + greenPipeWire = new ItemBuildCraft(greenPipeWireId.getInt()).setPassSneakClick(true); greenPipeWire.setUnlocalizedName("greenPipeWire"); LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 2), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(greenPipeWire, 8))); Property yellowPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "yellowPipeWire.id", DefaultProps.YELLOW_PIPE_WIRE); - yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()); + yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()).setPassSneakClick(true); yellowPipeWire.setUnlocalizedName("yellowPipeWire"); LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 11), new ItemStack(Item.redstone, 1), diff --git a/common/buildcraft/core/CoreConstants.java b/common/buildcraft/core/CoreConstants.java new file mode 100644 index 00000000..eb9ab89d --- /dev/null +++ b/common/buildcraft/core/CoreConstants.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core; + +/** + * + * @author CovertJaguar + */ +public class CoreConstants { + + public static final float PIPE_MIN_POS = 0.25F; + public static final float PIPE_MAX_POS = 0.75F; +} diff --git a/common/buildcraft/core/ItemBuildCraft.java b/common/buildcraft/core/ItemBuildCraft.java index 42a8467b..57baa729 100644 --- a/common/buildcraft/core/ItemBuildCraft.java +++ b/common/buildcraft/core/ItemBuildCraft.java @@ -1,12 +1,10 @@ /** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com + * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public License + * 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core; import buildcraft.core.utils.StringUtils; @@ -15,10 +13,13 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class ItemBuildCraft extends Item { private String iconName; + private boolean passSneakClick = false; + public ItemBuildCraft(int i) { super(i); setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); @@ -36,9 +37,18 @@ public class ItemBuildCraft extends Item { } @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) - { - this.itemIcon = par1IconRegister.registerIcon("buildcraft:" + iconName); - } + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister par1IconRegister) { + this.itemIcon = par1IconRegister.registerIcon("buildcraft:" + iconName); + } + + public Item setPassSneakClick(boolean passClick) { + this.passSneakClick = passClick; + return this; + } + + @Override + public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6) { + return passSneakClick; + } } diff --git a/common/buildcraft/core/render/RenderingEntityBlocks.java b/common/buildcraft/core/render/RenderingEntityBlocks.java index cf217e0f..cc4a8bc2 100644 --- a/common/buildcraft/core/render/RenderingEntityBlocks.java +++ b/common/buildcraft/core/render/RenderingEntityBlocks.java @@ -1,6 +1,7 @@ package buildcraft.core.render; import buildcraft.BuildCraftCore; +import buildcraft.core.CoreConstants; import buildcraft.core.IInventoryRenderer; import buildcraft.core.utils.Utils; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; @@ -57,7 +58,7 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler { } else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) { Tessellator tessellator = Tessellator.instance; - block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); + block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS); renderer.setRenderBoundsFromBlock(block); block.setBlockBoundsForItemRender(); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); @@ -116,8 +117,8 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler { /* LEGACY PIPE RENDERING and quarry frames! */ private void legacyPipeRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l) { - float minSize = Utils.pipeMinPos; - float maxSize = Utils.pipeMaxPos; + float minSize = CoreConstants.PIPE_MIN_POS; + float maxSize = CoreConstants.PIPE_MAX_POS; block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize); renderblocks.setRenderBoundsFromBlock(block); diff --git a/common/buildcraft/core/utils/MatrixTranformations.java b/common/buildcraft/core/utils/MatrixTranformations.java new file mode 100644 index 00000000..c5eae1a4 --- /dev/null +++ b/common/buildcraft/core/utils/MatrixTranformations.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.utils; + +import net.minecraftforge.common.ForgeDirection; + +/** + * + * @author Krapht + */ +public class MatrixTranformations { + + /** + * Mirrors the array on the Y axis by calculating offsets from 0.5F + * + * @param targetArray + */ + public static void mirrorY(float[][] targetArray) { + float temp = targetArray[1][0]; + targetArray[1][0] = (targetArray[1][1] - 0.5F) * -1F + 0.5F; // 1 -> 0.5F -> -0.5F -> 0F + targetArray[1][1] = (temp - 0.5F) * -1F + 0.5F; // 0 -> -0.5F -> 0.5F -> 1F + } + + /** + * Shifts the coordinates around effectively rotating something. Zero state + * is DOWN then -> NORTH -> WEST Note - To obtain Position, do a mirrorY() before + * rotating + * + * @param targetArray the array that should be rotated + */ + public static void rotate(float[][] targetArray) { + for (int i = 0; i < 2; i++) { + float temp = targetArray[2][i]; + targetArray[2][i] = targetArray[1][i]; + targetArray[1][i] = targetArray[0][i]; + targetArray[0][i] = temp; + } + } + + /** + * @param targetArray the array that should be transformed + * @param direction + */ + public static void transform(float[][] targetArray, ForgeDirection direction) { + if ((direction.ordinal() & 0x1) == 1) { + mirrorY(targetArray); + } + + for (int i = 0; i < (direction.ordinal() >> 1); i++) { + rotate(targetArray); + } + } + + /** + * Clones both dimensions of a float[][] + * + * @param source the float[][] to deepClone + * @return + */ + public static float[][] deepClone(float[][] source) { + float[][] target = source.clone(); + for (int i = 0; i < target.length; i++) { + target[i] = source[i].clone(); + } + return target; + } +} diff --git a/common/buildcraft/core/utils/Utils.java b/common/buildcraft/core/utils/Utils.java index c4435fcb..435170de 100644 --- a/common/buildcraft/core/utils/Utils.java +++ b/common/buildcraft/core/utils/Utils.java @@ -47,9 +47,6 @@ import net.minecraftforge.common.ForgeDirection; public class Utils { public static final Random RANDOM = new Random(); - public static final float pipeMinPos = 0.25F; - public static final float pipeMaxPos = 0.75F; - public static float pipeNormalSpeed = 0.01F; private static final List directions = new ArrayList(Arrays.asList(ForgeDirection.VALID_DIRECTIONS)); /* IINVENTORY HELPERS */ @@ -80,14 +77,6 @@ public class Utils { } - /** - * Depending on the kind of item in the pipe, set the floor at a different - * level to optimize graphical aspect. - */ - public static float getPipeFloorOf(ItemStack item) { - return pipeMinPos; - } - public static ForgeDirection get2dOrientation(Position pos1, Position pos2) { double Dx = pos1.x - pos2.x; double Dz = pos1.z - pos2.z; @@ -338,7 +327,7 @@ public class Utils { if (tile instanceof IInventory && !CoreProxy.proxy.isRenderWorld(world)) { if (!(tile instanceof IDropControlInventory) || ((IDropControlInventory) tile).doDrop()) { InvUtils.dropItems(world, (IInventory) tile, i, j, k); - InvUtils.wipeInventory((IInventory)tile); + InvUtils.wipeInventory((IInventory) tile); } } diff --git a/common/buildcraft/factory/BlockFrame.java b/common/buildcraft/factory/BlockFrame.java index a6a155db..fa063b39 100644 --- a/common/buildcraft/factory/BlockFrame.java +++ b/common/buildcraft/factory/BlockFrame.java @@ -10,6 +10,7 @@ package buildcraft.factory; import buildcraft.BuildCraftCore; +import buildcraft.core.CoreConstants; import buildcraft.core.IFramePipeConnection; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; @@ -69,7 +70,7 @@ public class BlockFrame extends Block implements IFramePipeConnection { @Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) { - float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos; + float xMin = CoreConstants.PIPE_MIN_POS, xMax = CoreConstants.PIPE_MAX_POS, yMin = CoreConstants.PIPE_MIN_POS, yMax = CoreConstants.PIPE_MAX_POS, zMin = CoreConstants.PIPE_MIN_POS, zMax = CoreConstants.PIPE_MAX_POS; if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) { xMin = 0.0F; @@ -107,36 +108,36 @@ public class BlockFrame extends Block implements IFramePipeConnection { @SuppressWarnings("rawtypes") @Override public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List arraylist, Entity par7Entity) { - setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); + setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) { - setBlockBounds(0.0F, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); + setBlockBounds(0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } if (Utils.checkLegacyPipesConnections(world, i, j, k, i + 1, j, k)) { - setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, 1.0F, Utils.pipeMaxPos, Utils.pipeMaxPos); + setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 1.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j - 1, k)) { - setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); + setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j + 1, k)) { - setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); + setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j, k - 1)) { - setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, 0.0F, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); + setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j, k + 1)) { - setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, 1.0F); + setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, 1.0F); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } @@ -145,7 +146,7 @@ public class BlockFrame extends Block implements IFramePipeConnection { @Override public MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3 vec3d, Vec3 vec3d1) { - float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos; + float xMin = CoreConstants.PIPE_MIN_POS, xMax = CoreConstants.PIPE_MAX_POS, yMin = CoreConstants.PIPE_MIN_POS, yMax = CoreConstants.PIPE_MAX_POS, zMin = CoreConstants.PIPE_MIN_POS, zMax = CoreConstants.PIPE_MAX_POS; if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) { xMin = 0.0F; diff --git a/common/buildcraft/factory/BlockPlainPipe.java b/common/buildcraft/factory/BlockPlainPipe.java index 13a0f444..bba34558 100644 --- a/common/buildcraft/factory/BlockPlainPipe.java +++ b/common/buildcraft/factory/BlockPlainPipe.java @@ -9,8 +9,8 @@ package buildcraft.factory; +import buildcraft.core.CoreConstants; import buildcraft.core.IFramePipeConnection; -import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; @@ -26,13 +26,13 @@ public class BlockPlainPipe extends Block implements IFramePipeConnection { public BlockPlainPipe(int i) { super(i, Material.glass); - minX = Utils.pipeMinPos; + minX = CoreConstants.PIPE_MIN_POS; minY = 0.0; - minZ = Utils.pipeMinPos; + minZ = CoreConstants.PIPE_MIN_POS; - maxX = Utils.pipeMaxPos; + maxX = CoreConstants.PIPE_MAX_POS; maxY = 1.0; - maxZ = Utils.pipeMaxPos; + maxZ = CoreConstants.PIPE_MAX_POS; } @Override diff --git a/common/buildcraft/factory/TilePump.java b/common/buildcraft/factory/TilePump.java index 04d96439..87a1b948 100644 --- a/common/buildcraft/factory/TilePump.java +++ b/common/buildcraft/factory/TilePump.java @@ -16,6 +16,7 @@ import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.Type; import buildcraft.core.BlockIndex; +import buildcraft.core.CoreConstants; import buildcraft.core.EntityBlock; import buildcraft.core.IMachine; import buildcraft.core.TileBuffer; @@ -370,11 +371,11 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor private void setTubePosition() { if (tube != null) { - tube.iSize = Utils.pipeMaxPos - Utils.pipeMinPos; - tube.kSize = Utils.pipeMaxPos - Utils.pipeMinPos; + tube.iSize = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS; + tube.kSize = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS; tube.jSize = yCoord - tube.posY; - tube.setPosition(xCoord + Utils.pipeMinPos, tubeY, zCoord + Utils.pipeMinPos); + tube.setPosition(xCoord + CoreConstants.PIPE_MIN_POS, tubeY, zCoord + CoreConstants.PIPE_MIN_POS); } } diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index 837f18b6..a995dc71 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -11,7 +11,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; -import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -33,6 +32,7 @@ import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.core.Box; +import buildcraft.core.CoreConstants; import buildcraft.core.DefaultAreaProvider; import buildcraft.core.EntityRobot; import buildcraft.core.IBuilderInventory; @@ -128,9 +128,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept private void createArm() { - worldObj.spawnEntityInWorld(new EntityMechanicalArm(worldObj, box.xMin + Utils.pipeMaxPos, yCoord + bluePrintBuilder.bluePrint.sizeY - 1 - + Utils.pipeMinPos, box.zMin + Utils.pipeMaxPos, bluePrintBuilder.bluePrint.sizeX - 2 + Utils.pipeMinPos * 2, bluePrintBuilder.bluePrint.sizeZ - - 2 + Utils.pipeMinPos * 2, this)); + worldObj.spawnEntityInWorld(new EntityMechanicalArm(worldObj, box.xMin + CoreConstants.PIPE_MAX_POS, yCoord + bluePrintBuilder.bluePrint.sizeY - 1 + + CoreConstants.PIPE_MIN_POS, box.zMin + CoreConstants.PIPE_MAX_POS, bluePrintBuilder.bluePrint.sizeX - 2 + CoreConstants.PIPE_MIN_POS * 2, bluePrintBuilder.bluePrint.sizeZ + - 2 + CoreConstants.PIPE_MIN_POS * 2, this)); } // Callback from the arm once it's created diff --git a/common/buildcraft/silicon/SiliconRenderBlock.java b/common/buildcraft/silicon/SiliconRenderBlock.java index 0732e9e6..fcb1f0f8 100644 --- a/common/buildcraft/silicon/SiliconRenderBlock.java +++ b/common/buildcraft/silicon/SiliconRenderBlock.java @@ -9,7 +9,7 @@ package buildcraft.silicon; -import buildcraft.core.utils.Utils; +import buildcraft.core.CoreConstants; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; @@ -121,7 +121,7 @@ public class SiliconRenderBlock implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int i, int j, RenderBlocks renderblocks) { - block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); + block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); block.setBlockBounds(0.0F, 0.0F, 0.0F, 1, 4F / 16F, 1); diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 15d05963..f1e6d8ee 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -40,30 +40,45 @@ import buildcraft.api.tools.IToolWrench; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.ISolidSideTile; import buildcraft.core.BlockIndex; +import buildcraft.core.CoreConstants; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; -import buildcraft.transport.render.PipeRendererWorld; +import buildcraft.core.utils.MatrixTranformations; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.Arrays; +import net.minecraft.client.Minecraft; public class BlockGenericPipe extends BlockContainer { static enum Part { Pipe, - Gate + Gate, + Facade, + Plug } static class RaytraceResult { - RaytraceResult(Part hitPart, MovingObjectPosition movingObjectPosition) { + RaytraceResult(Part hitPart, MovingObjectPosition movingObjectPosition, AxisAlignedBB boundingBox, ForgeDirection side) { this.hitPart = hitPart; this.movingObjectPosition = movingObjectPosition; + this.boundingBox = boundingBox; + this.sideHit = side; + } + public final Part hitPart; + public final MovingObjectPosition movingObjectPosition; + public final AxisAlignedBB boundingBox; + public final ForgeDirection sideHit; + + @Override + public String toString() { + return String.format("RayTraceResult: %s, %s", hitPart == null ? "null" : hitPart.name(), boundingBox == null ? "null" : boundingBox.toString()); } - public Part hitPart; - public MovingObjectPosition movingObjectPosition; } + private static final ForgeDirection[] DIR_VALUES = ForgeDirection.values(); private static Random rand = new Random(); private boolean skippedFirstIconRegister; private char renderAxis = 'a'; @@ -130,7 +145,7 @@ public class BlockGenericPipe extends BlockContainer { @SuppressWarnings("rawtypes") @Override public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List arraylist, Entity par7Entity) { - setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); + setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); TileEntity tile1 = world.getBlockTileEntity(i, j, k); @@ -138,36 +153,36 @@ public class BlockGenericPipe extends BlockContainer { TileGenericPipe tileG = (TileGenericPipe) tile1; if (tileG.isPipeConnected(ForgeDirection.WEST)) { - setBlockBounds(0.0F, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); + setBlockBounds(0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } if (tileG.isPipeConnected(ForgeDirection.EAST)) { - setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, 1.0F, Utils.pipeMaxPos, Utils.pipeMaxPos); + setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 1.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } if (tileG.isPipeConnected(ForgeDirection.DOWN)) { - setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); + setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } if (tileG.isPipeConnected(ForgeDirection.UP)) { - setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); + setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } if (tileG.isPipeConnected(ForgeDirection.NORTH)) { - setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, 0.0F, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); + setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } if (tileG.isPipeConnected(ForgeDirection.SOUTH)) { - setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, 1.0F); + setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, 1.0F); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); } - float facadeThickness = PipeRendererWorld.facadeThickness; + float facadeThickness = TransportConstants.FACADE_THICKNESS; if (tileG.hasFacade(ForgeDirection.EAST)) { setBlockBounds(1 - facadeThickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); @@ -202,61 +217,29 @@ public class BlockGenericPipe extends BlockContainer { setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } + @SideOnly(Side.CLIENT) @Override - public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) { - float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos; + public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { + RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, Minecraft.getMinecraft().thePlayer); - TileEntity tile1 = world.getBlockTileEntity(i, j, k); - - if (tile1 instanceof TileGenericPipe) { - TileGenericPipe tileG = (TileGenericPipe) tile1; - if (tileG.isPipeConnected(ForgeDirection.WEST) || tileG.hasFacade(ForgeDirection.WEST)) { - xMin = 0.0F; - } - - if (tileG.isPipeConnected(ForgeDirection.EAST) || tileG.hasFacade(ForgeDirection.EAST)) { - xMax = 1.0F; - } - - if (tileG.isPipeConnected(ForgeDirection.DOWN) || tileG.hasFacade(ForgeDirection.DOWN)) { - yMin = 0.0F; - } - - if (tileG.isPipeConnected(ForgeDirection.UP) || tileG.hasFacade(ForgeDirection.UP)) { - yMax = 1.0F; - } - - if (tileG.isPipeConnected(ForgeDirection.NORTH) || tileG.hasFacade(ForgeDirection.NORTH)) { - zMin = 0.0F; - } - - if (tileG.isPipeConnected(ForgeDirection.SOUTH) || tileG.hasFacade(ForgeDirection.SOUTH)) { - zMax = 1.0F; - } - - if (tileG.hasFacade(ForgeDirection.EAST) || tileG.hasFacade(ForgeDirection.WEST)) { - yMin = 0.0F; - yMax = 1.0F; - zMin = 0.0F; - zMax = 1.0F; - } - - if (tileG.hasFacade(ForgeDirection.UP) || tileG.hasFacade(ForgeDirection.DOWN)) { - xMin = 0.0F; - xMax = 1.0F; - zMin = 0.0F; - zMax = 1.0F; - } - - if (tileG.hasFacade(ForgeDirection.SOUTH) || tileG.hasFacade(ForgeDirection.NORTH)) { - xMin = 0.0F; - xMax = 1.0F; - yMin = 0.0F; - yMax = 1.0F; + if (rayTraceResult != null && rayTraceResult.boundingBox != null) { + AxisAlignedBB box = rayTraceResult.boundingBox; + switch (rayTraceResult.hitPart) { + case Gate: + case Plug: { + float scale = 0.001F; + box = box.expand(scale, scale, scale); + break; + } + case Pipe: { + float scale = 0.08F; + box = box.expand(scale, scale, scale); + break; + } } + return box.getOffsetBoundingBox(x, y, z); } - - return AxisAlignedBB.getBoundingBox((double) i + xMin, (double) j + yMin, (double) k + zMin, (double) i + xMax, (double) j + yMax, (double) k + zMax); + return super.getSelectedBoundingBoxFromPool(world, x, y, z).expand(-0.85F, -0.85F, -0.85F); } @Override @@ -291,8 +274,6 @@ public class BlockGenericPipe extends BlockContainer { } private RaytraceResult doRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) { - float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos; - TileEntity pipeTileEntity = world.getBlockTileEntity(x, y, z); TileGenericPipe tileG = null; @@ -311,96 +292,60 @@ public class BlockGenericPipe extends BlockContainer { * pipe hits along x, y, and z axis, gate (all 6 sides) [and * wires+facades] */ - MovingObjectPosition[] hits = new MovingObjectPosition[9]; + MovingObjectPosition[] hits = new MovingObjectPosition[25]; + AxisAlignedBB[] boxes = new AxisAlignedBB[25]; + ForgeDirection[] sideHit = new ForgeDirection[25]; + Arrays.fill(sideHit, ForgeDirection.UNKNOWN); - boolean needAxisCheck = false; - boolean needCenterCheck = true; + // pipe - // check along the x axis - - if (tileG.isPipeConnected(ForgeDirection.WEST)) { - xMin = 0.0F; - needAxisCheck = true; - } - - if (tileG.isPipeConnected(ForgeDirection.WEST)) { - xMax = 1.0F; - needAxisCheck = true; - } - - if (needAxisCheck) { - setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax); - - hits[0] = super.collisionRayTrace(world, x, y, z, origin, direction); - xMin = Utils.pipeMinPos; - xMax = Utils.pipeMaxPos; - needAxisCheck = false; - needCenterCheck = false; // center already checked through this axis - } - - // check along the y axis - - if (tileG.isPipeConnected(ForgeDirection.DOWN)) { - yMin = 0.0F; - needAxisCheck = true; - } - - if (tileG.isPipeConnected(ForgeDirection.UP)) { - yMax = 1.0F; - needAxisCheck = true; - } - - if (needAxisCheck) { - setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax); - - hits[1] = super.collisionRayTrace(world, x, y, z, origin, direction); - yMin = Utils.pipeMinPos; - yMax = Utils.pipeMaxPos; - needAxisCheck = false; - needCenterCheck = false; // center already checked through this axis - } - - // check along the z axis - - if (tileG.isPipeConnected(ForgeDirection.NORTH)) { - zMin = 0.0F; - needAxisCheck = true; - } - - if (tileG.isPipeConnected(ForgeDirection.SOUTH)) { - zMax = 1.0F; - needAxisCheck = true; - } - - if (needAxisCheck) { - setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax); - - hits[2] = super.collisionRayTrace(world, x, y, z, origin, direction); - zMin = Utils.pipeMinPos; - zMax = Utils.pipeMaxPos; - needAxisCheck = false; - needCenterCheck = false; // center already checked through this axis - } - - // check center (only if no axis were checked/the pipe has no connections) - - if (needCenterCheck) { - setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax); - - hits[0] = super.collisionRayTrace(world, x, y, z, origin, direction); + for (ForgeDirection side : DIR_VALUES) { + if (side == ForgeDirection.UNKNOWN || tileG.isPipeConnected(side)) { + AxisAlignedBB bb = getPipeBoundingBox(side); + setBlockBounds(bb); + boxes[side.ordinal()] = bb; + hits[side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction); + sideHit[side.ordinal()] = side; + } } // gates - if (pipe.hasGate()) { - for (int side = 0; side < 6; side++) { - setBlockBoundsToGate(ForgeDirection.VALID_DIRECTIONS[side]); - - hits[3 + side] = super.collisionRayTrace(world, x, y, z, origin, direction); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (pipe.hasGate(side)) { + AxisAlignedBB bb = getGateBoundingBox(side); + setBlockBounds(bb); + boxes[7 + side.ordinal()] = bb; + hits[7 + side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction); + sideHit[7 + side.ordinal()] = side; } } - // TODO: check wires, facades + // facades + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (tileG.hasFacade(side)) { + AxisAlignedBB bb = getFacadeBoundingBox(side); + setBlockBounds(bb); + boxes[13 + side.ordinal()] = bb; + hits[13 + side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction); + sideHit[13 + side.ordinal()] = side; + } + } + + // plugs + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (tileG.hasPlug(side)) { + AxisAlignedBB bb = getPlugBoundingBox(side); + setBlockBounds(bb); + boxes[19 + side.ordinal()] = bb; + hits[19 + side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction); + sideHit[19 + side.ordinal()] = side; + } + } + + // TODO: check wires // get closest hit @@ -429,41 +374,96 @@ public class BlockGenericPipe extends BlockContainer { } else { Part hitPart; - if (minIndex < 3) { + if (minIndex < 7) { hitPart = Part.Pipe; - } else { + } else if (minIndex < 13) { hitPart = Part.Gate; + } else if (minIndex < 19) { + hitPart = Part.Facade; + } else { + hitPart = Part.Plug; } - return new RaytraceResult(hitPart, hits[minIndex]); + return new RaytraceResult(hitPart, hits[minIndex], boxes[minIndex], sideHit[minIndex]); } } - private void setBlockBoundsToGate(ForgeDirection dir) { - float min = Utils.pipeMinPos + 0.05F; - float max = Utils.pipeMaxPos - 0.05F; + private void setBlockBounds(AxisAlignedBB bb) { + setBlockBounds((float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ); + } - switch (dir) { - case DOWN: - setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos, max); - break; - case UP: - setBlockBounds(min, Utils.pipeMaxPos, min, max, Utils.pipeMaxPos + 0.10F, max); - break; - case NORTH: - setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos); - break; - case SOUTH: - setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F); - break; - case WEST: - setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos, max, max); - break; - default: - case EAST: - setBlockBounds(Utils.pipeMaxPos, min, min, Utils.pipeMaxPos + 0.10F, max, max); - break; + private AxisAlignedBB getGateBoundingBox(ForgeDirection side) { + float min = CoreConstants.PIPE_MIN_POS + 0.05F; + float max = CoreConstants.PIPE_MAX_POS - 0.05F; + + float[][] bounds = new float[3][2]; + // X START - END + bounds[0][0] = min; + bounds[0][1] = max; + // Y START - END + bounds[1][0] = CoreConstants.PIPE_MIN_POS - 0.10F; + bounds[1][1] = CoreConstants.PIPE_MIN_POS; + // Z START - END + bounds[2][0] = min; + bounds[2][1] = max; + + MatrixTranformations.transform(bounds, side); + return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]); + } + + private AxisAlignedBB getFacadeBoundingBox(ForgeDirection side) { + float[][] bounds = new float[3][2]; + // X START - END + bounds[0][0] = 0.0F; + bounds[0][1] = 1.0F; + // Y START - END + bounds[1][0] = 0.0F; + bounds[1][1] = TransportConstants.FACADE_THICKNESS; + // Z START - END + bounds[2][0] = 0.0F; + bounds[2][1] = 1.0F; + + MatrixTranformations.transform(bounds, side); + return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]); + } + + private AxisAlignedBB getPlugBoundingBox(ForgeDirection side) { + float[][] bounds = new float[3][2]; + // X START - END + bounds[0][0] = 0.25F; + bounds[0][1] = 0.75F; + // Y START - END + bounds[1][0] = 0.125F; + bounds[1][1] = 0.251F; + // Z START - END + bounds[2][0] = 0.25F; + bounds[2][1] = 0.75F; + + MatrixTranformations.transform(bounds, side); + return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]); + } + + private AxisAlignedBB getPipeBoundingBox(ForgeDirection side) { + float min = CoreConstants.PIPE_MIN_POS; + float max = CoreConstants.PIPE_MAX_POS; + + if (side == ForgeDirection.UNKNOWN) { + return AxisAlignedBB.getAABBPool().getAABB(min, min, min, max, max, max); } + + float[][] bounds = new float[3][2]; + // X START - END + bounds[0][0] = min; + bounds[0][1] = max; + // Y START - END + bounds[1][0] = 0; + bounds[1][1] = min; + // Z START - END + bounds[2][0] = min; + bounds[2][1] = max; + + MatrixTranformations.transform(bounds, side); + return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]); } public static void removePipe(Pipe pipe) { @@ -619,91 +619,65 @@ public class BlockGenericPipe extends BlockContainer { Pipe pipe = getPipe(world, x, y, z); if (isValid(pipe)) { + ItemStack currentItem = player.getCurrentEquippedItem(); - // / Right click while sneaking without wrench to strip equipment + // Right click while sneaking with empty hand to strip equipment // from the pipe. - if (player.isSneaking() - && (player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof IToolWrench))) { - - if (pipe.hasGate() || pipe.isWired()) - return stripEquipment(pipe); - - } else if (player.getCurrentEquippedItem() == null) { + if (player.isSneaking() && currentItem == null) { + if (stripEquipment(world, x, y, z, player, pipe)) + return true; + } else if (currentItem == null) { // Fall through the end of the test - } else if (player.getCurrentEquippedItem().itemID == Item.sign.itemID) + } else if (currentItem.itemID == Item.sign.itemID) // Sign will be placed anyway, so lets show the sign gui return false; - else if (player.getCurrentEquippedItem().getItem() instanceof ItemPipe) + else if (currentItem.getItem() instanceof ItemPipe) return false; - else if (player.getCurrentEquippedItem().getItem() instanceof IToolWrench) + else if (currentItem.getItem() instanceof IToolWrench) // Only check the instance at this point. Call the IToolWrench // interface callbacks for the individual pipe/logic calls return pipe.blockActivated(player); - else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.redPipeWire) { - if (!pipe.wireSet[IPipe.WireColor.Red.ordinal()]) { - pipe.wireSet[IPipe.WireColor.Red.ordinal()] = true; - if (!player.capabilities.isCreativeMode) { - player.getCurrentEquippedItem().splitStack(1); - } - pipe.signalStrength[IPipe.WireColor.Red.ordinal()] = 0; - pipe.container.scheduleNeighborChange(); + else if (currentItem.getItem() == BuildCraftTransport.redPipeWire) { + if (addOrStripWire(player, pipe, IPipe.WireColor.Red)) { return true; } - } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.bluePipeWire) { - if (!pipe.wireSet[IPipe.WireColor.Blue.ordinal()]) { - pipe.wireSet[IPipe.WireColor.Blue.ordinal()] = true; - if (!player.capabilities.isCreativeMode) { - player.getCurrentEquippedItem().splitStack(1); - } - pipe.signalStrength[IPipe.WireColor.Blue.ordinal()] = 0; - pipe.container.scheduleNeighborChange(); + } else if (currentItem.getItem() == BuildCraftTransport.bluePipeWire) { + if (addOrStripWire(player, pipe, IPipe.WireColor.Blue)) { return true; } - } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.greenPipeWire) { - if (!pipe.wireSet[IPipe.WireColor.Green.ordinal()]) { - pipe.wireSet[IPipe.WireColor.Green.ordinal()] = true; - if (!player.capabilities.isCreativeMode) { - player.getCurrentEquippedItem().splitStack(1); - } - pipe.signalStrength[IPipe.WireColor.Green.ordinal()] = 0; - pipe.container.scheduleNeighborChange(); + } else if (currentItem.getItem() == BuildCraftTransport.greenPipeWire) { + if (addOrStripWire(player, pipe, IPipe.WireColor.Green)) { return true; } - } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.yellowPipeWire) { - if (!pipe.wireSet[IPipe.WireColor.Yellow.ordinal()]) { - pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] = true; - if (!player.capabilities.isCreativeMode) { - player.getCurrentEquippedItem().splitStack(1); - } - pipe.signalStrength[IPipe.WireColor.Yellow.ordinal()] = 0; - pipe.container.scheduleNeighborChange(); + } else if (currentItem.getItem() == BuildCraftTransport.yellowPipeWire) { + if (addOrStripWire(player, pipe, IPipe.WireColor.Yellow)) { return true; } - } else if (player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGate.itemID - || player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGateAutarchic.itemID) - if (!pipe.hasGate()) { - - pipe.gate = Gate.makeGate(pipe, player.getCurrentEquippedItem()); - if (!player.capabilities.isCreativeMode) { - player.getCurrentEquippedItem().splitStack(1); - } - pipe.container.scheduleRenderUpdate(); + } else if (currentItem.getItem() instanceof ItemGate) { + if (addOrStripGate(world, x, y, z, player, pipe)) { + return true; + } + } else if (currentItem.getItem() instanceof ItemPlug) { + if (addOrStripPlug(world, x, y, z, player, ForgeDirection.getOrientation(side), pipe)) { + return true; + } + } else if (currentItem.getItem() instanceof ItemFacade) + if (addOrStripFacade(world, x, y, z, player, ForgeDirection.getOrientation(side), pipe)) { return true; } - boolean openGateGui = false; + boolean clickedOnGate = false; if (pipe.hasGate()) { RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); if (rayTraceResult != null && rayTraceResult.hitPart == Part.Gate) { - openGateGui = true; + clickedOnGate = true; } } - if (openGateGui) { + if (clickedOnGate) { pipe.gate.openGui(player); - return true; } else return pipe.blockActivated(player); @@ -712,22 +686,32 @@ public class BlockGenericPipe extends BlockContainer { return false; } - private boolean stripEquipment(Pipe pipe) { - - // Try to strip wires first, starting with yellow. - for (IPipe.WireColor color : IPipe.WireColor.values()) { - if (pipe.wireSet[color.reverse().ordinal()]) { - if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { - dropWire(color.reverse(), pipe); - } - pipe.wireSet[color.reverse().ordinal()] = false; - // pipe.worldObj.markBlockNeedsUpdate(pipe.xCoord, pipe.yCoord, pipe.zCoord); - pipe.container.scheduleRenderUpdate(); - return true; + private boolean addOrStripGate(World world, int x, int y, int z, EntityPlayer player, Pipe pipe) { + if (addGate(player, pipe)) + return true; + if (player.isSneaking()) { + RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); + if (rayTraceResult != null && rayTraceResult.hitPart == Part.Facade) { + if (stripGate(pipe)) + return true; } } + return false; + } - // Try to strip gate next + private boolean addGate(EntityPlayer player, Pipe pipe) { + if (!pipe.hasGate()) { + pipe.gate = Gate.makeGate(pipe, player.getCurrentEquippedItem()); + if (!player.capabilities.isCreativeMode) { + player.getCurrentEquippedItem().splitStack(1); + } + pipe.container.scheduleRenderUpdate(); + return true; + } + return false; + } + + private boolean stripGate(Pipe pipe) { if (pipe.hasGate()) { if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { pipe.gate.dropGate(); @@ -735,10 +719,116 @@ public class BlockGenericPipe extends BlockContainer { pipe.resetGate(); return true; } - return false; } + private boolean addOrStripWire(EntityPlayer player, Pipe pipe, IPipe.WireColor color) { + if (addWire(pipe, color)) { + if (!player.capabilities.isCreativeMode) { + player.getCurrentEquippedItem().splitStack(1); + } + return true; + } + return player.isSneaking() && stripWire(pipe, color); + } + + private boolean addWire(Pipe pipe, IPipe.WireColor color) { + if (!pipe.wireSet[color.ordinal()]) { + pipe.wireSet[color.ordinal()] = true; + pipe.signalStrength[color.ordinal()] = 0; + pipe.container.scheduleNeighborChange(); + return true; + } + return false; + } + + private boolean stripWire(Pipe pipe, IPipe.WireColor color) { + if (pipe.wireSet[color.ordinal()]) { + if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { + dropWire(color, pipe); + } + pipe.wireSet[color.ordinal()] = false; + pipe.container.scheduleRenderUpdate(); + return true; + } + return false; + } + + private boolean addOrStripFacade(World world, int x, int y, int z, EntityPlayer player, ForgeDirection side, Pipe pipe) { + if (player.isSneaking()) { + RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); + if (rayTraceResult != null && rayTraceResult.hitPart == Part.Facade) { + if (stripFacade(pipe, rayTraceResult.sideHit)) + return true; + } + } + if (addFacade(player, pipe, side)) + return true; + return false; + } + + private boolean addFacade(EntityPlayer player, Pipe pipe, ForgeDirection side) { + ItemStack stack = player.getCurrentEquippedItem(); + if (pipe.container.addFacade(side, ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) { + if (!player.capabilities.isCreativeMode) { + stack.stackSize--; + } + return true; + } + return false; + } + + private boolean stripFacade(Pipe pipe, ForgeDirection side) { + return pipe.container.dropFacade(side); + } + + private boolean addOrStripPlug(World world, int x, int y, int z, EntityPlayer player, ForgeDirection side, Pipe pipe) { + RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); + if (player.isSneaking()) { + if (rayTraceResult != null && rayTraceResult.hitPart == Part.Plug) { + if (stripPlug(pipe, rayTraceResult.sideHit)) + return true; + } + } + if (rayTraceResult != null && rayTraceResult.hitPart == Part.Pipe) { + if (addPlug(player, pipe, rayTraceResult.sideHit != null && rayTraceResult.sideHit != ForgeDirection.UNKNOWN ? rayTraceResult.sideHit : side)) + return true; + } + return false; + } + + private boolean addPlug(EntityPlayer player, Pipe pipe, ForgeDirection side) { + ItemStack stack = player.getCurrentEquippedItem(); + if (pipe.container.addPlug(side)) { + if (!player.capabilities.isCreativeMode) { + stack.stackSize--; + } + return true; + } + return false; + } + + private boolean stripPlug(Pipe pipe, ForgeDirection side) { + return pipe.container.removeAndDropPlug(side); + } + + private boolean stripEquipment(World world, int x, int y, int z, EntityPlayer player, Pipe pipe) { + // Try to strip facades first + RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); + if (rayTraceResult != null && rayTraceResult.hitPart == Part.Facade) { + if (stripFacade(pipe, rayTraceResult.sideHit)) + return true; + } + + // Try to strip wires second, starting with yellow. + for (IPipe.WireColor color : IPipe.WireColor.values()) { + if (stripWire(pipe, color)) + return true; + } + + return stripGate(pipe); + } + /** * Drops a pipe wire item of the passed color. * diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index e74b70ca..67ecc66a 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -71,30 +71,30 @@ public class ItemFacade extends ItemBuildCraft { } } - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - if (worldObj.isRemote) - return false; - TileEntity tile = worldObj.getBlockTileEntity(x, y, z); - if (!(tile instanceof TileGenericPipe)) - return false; - TileGenericPipe pipeTile = (TileGenericPipe) tile; - - if (player.isSneaking()) { // Strip facade - if (!pipeTile.hasFacade(ForgeDirection.VALID_DIRECTIONS[side])) - return false; - pipeTile.dropFacade(ForgeDirection.VALID_DIRECTIONS[side]); - return true; - } else { - if (((TileGenericPipe) tile).addFacade(ForgeDirection.values()[side], ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) { - if (!player.capabilities.isCreativeMode) { - stack.stackSize--; - } - return true; - } - return false; - } - } +// @Override +// public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { +// if (worldObj.isRemote) +// return false; +// TileEntity tile = worldObj.getBlockTileEntity(x, y, z); +// if (!(tile instanceof TileGenericPipe)) +// return false; +// TileGenericPipe pipeTile = (TileGenericPipe) tile; +// +// if (player.isSneaking()) { // Strip facade +// if (!pipeTile.hasFacade(ForgeDirection.VALID_DIRECTIONS[side])) +// return false; +// pipeTile.dropFacade(ForgeDirection.VALID_DIRECTIONS[side]); +// return true; +// } else { +// if (((TileGenericPipe) tile).addFacade(ForgeDirection.values()[side], ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) { +// if (!player.capabilities.isCreativeMode) { +// stack.stackSize--; +// } +// return true; +// } +// return false; +// } +// } public static void initialize() { for (Field f : Block.class.getDeclaredFields()) { diff --git a/common/buildcraft/transport/ItemGate.java b/common/buildcraft/transport/ItemGate.java index 43c0ba7e..62ef67f7 100644 --- a/common/buildcraft/transport/ItemGate.java +++ b/common/buildcraft/transport/ItemGate.java @@ -46,6 +46,7 @@ public class ItemGate extends ItemBuildCraft { setHasSubtypes(true); setMaxDamage(0); setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setPassSneakClick(true); } @SuppressWarnings({ "all" }) diff --git a/common/buildcraft/transport/ItemPlug.java b/common/buildcraft/transport/ItemPlug.java index f819d006..46498201 100644 --- a/common/buildcraft/transport/ItemPlug.java +++ b/common/buildcraft/transport/ItemPlug.java @@ -23,30 +23,30 @@ public class ItemPlug extends ItemBuildCraft { return "item.PipePlug"; } - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - if (worldObj.isRemote) - return false; - TileEntity tile = worldObj.getBlockTileEntity(x, y, z); - if (!(tile instanceof TileGenericPipe)) - return false; - TileGenericPipe pipeTile = (TileGenericPipe) tile; - - if (player.isSneaking()) { // Strip plug - if (!pipeTile.hasPlug(ForgeDirection.VALID_DIRECTIONS[side])) - return false; - pipeTile.removeAndDropPlug(ForgeDirection.VALID_DIRECTIONS[side]); - return true; - } else { - if (((TileGenericPipe) tile).addPlug(ForgeDirection.VALID_DIRECTIONS[side])){ - if (!player.capabilities.isCreativeMode) { - stack.stackSize--; - } - return true; - } - return false; - } - } +// @Override +// public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { +// if (worldObj.isRemote) +// return false; +// TileEntity tile = worldObj.getBlockTileEntity(x, y, z); +// if (!(tile instanceof TileGenericPipe)) +// return false; +// TileGenericPipe pipeTile = (TileGenericPipe) tile; +// +// if (player.isSneaking()) { // Strip plug +// if (!pipeTile.hasPlug(ForgeDirection.VALID_DIRECTIONS[side])) +// return false; +// pipeTile.removeAndDropPlug(ForgeDirection.VALID_DIRECTIONS[side]); +// return true; +// } else { +// if (((TileGenericPipe) tile).addPlug(ForgeDirection.VALID_DIRECTIONS[side])){ +// if (!player.capabilities.isCreativeMode) { +// stack.stackSize--; +// } +// return true; +// } +// return false; +// } +// } @Override public boolean shouldPassSneakingClickToBlock(World worldObj, int x, int y, int z ) { diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index 6fd1043a..bfdf4955 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -365,6 +365,30 @@ public abstract class Pipe implements IPipe, IDropContr return gate != null; } + public boolean hasGate(ForgeDirection side) { + if (!hasGate()) + return false; + if (container.hasFacade(side)) + return false; + if (container.hasPlug(side)) + return false; + + int connections = 0; + ForgeDirection targetOrientation = ForgeDirection.UNKNOWN; + for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { + if (container.isPipeConnected(o)) { + connections++; + if (connections == 1) + targetOrientation = o; + } + } + + if (connections > 1 || connections == 0) + return true; + + return targetOrientation.getOpposite() != side; + } + protected void notifyBlocksOfNeighborChange(ForgeDirection side) { container.worldObj.notifyBlocksOfNeighborChange(container.xCoord + side.offsetX, container.yCoord + side.offsetY, container.zCoord + side.offsetZ, BuildCraftTransport.genericPipeBlock.blockID); } diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index 52ddb4fb..cc39547e 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -19,10 +19,10 @@ import buildcraft.core.inventory.Transactor; import buildcraft.core.network.PacketIds; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.BlockUtil; -import buildcraft.core.utils.Utils; import buildcraft.transport.network.PacketPipeTransportContent; import buildcraft.transport.network.PacketPipeTransportNBT; import buildcraft.transport.network.PacketSimpleId; +import buildcraft.transport.utils.TransportUtils; import com.google.common.collect.BiMap; import com.google.common.collect.ForwardingSet; import com.google.common.collect.HashBiMap; @@ -134,12 +134,12 @@ public class PipeTransportItems extends PipeTransport { public void defaultReajustSpeed(TravelingItem item) { float speed = item.getSpeed(); - if (speed > Utils.pipeNormalSpeed) { - speed -= Utils.pipeNormalSpeed; + if (speed > TransportConstants.PIPE_NORMAL_SPEED) { + speed -= TransportConstants.PIPE_NORMAL_SPEED; } - if (speed < Utils.pipeNormalSpeed) { - speed = Utils.pipeNormalSpeed; + if (speed < TransportConstants.PIPE_NORMAL_SPEED) { + speed = TransportConstants.PIPE_NORMAL_SPEED; } item.setSpeed(speed); @@ -159,7 +159,7 @@ public class PipeTransportItems extends PipeTransport { z = Math.min(z, container.zCoord + 0.99); if (item.input != ForgeDirection.UP && item.input != ForgeDirection.DOWN) { - y = container.yCoord + Utils.getPipeFloorOf(item.getItemStack()); + y = container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()); } item.setPosition(x, y, z); @@ -338,7 +338,7 @@ public class PipeTransportItems extends PipeTransport { item.toCenter = false; // Reajusting to the middle - item.setPosition(container.xCoord + 0.5, container.yCoord + Utils.getPipeFloorOf(item.getItemStack()), container.zCoord + 0.5); + item.setPosition(container.xCoord + 0.5, container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()), container.zCoord + 0.5); if (item.output == ForgeDirection.UNKNOWN) { if (travelHook != null) { @@ -421,7 +421,7 @@ public class PipeTransportItems extends PipeTransport { protected boolean middleReached(TravelingItem item) { float middleLimit = item.getSpeed() * 1.01F; - return (Math.abs(container.xCoord + 0.5 - item.xCoord) < middleLimit && Math.abs(container.yCoord + Utils.getPipeFloorOf(item.getItemStack()) - item.yCoord) < middleLimit && Math + return (Math.abs(container.xCoord + 0.5 - item.xCoord) < middleLimit && Math.abs(container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()) - item.yCoord) < middleLimit && Math .abs(container.zCoord + 0.5 - item.zCoord) < middleLimit); } diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 4a94280e..429bab14 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -570,6 +570,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } public boolean hasFacade(ForgeDirection direction) { + if (direction == null || direction == ForgeDirection.UNKNOWN) + return false; if (this.worldObj.isRemote) return renderState.facadeMatrix.getFacadeBlockId(direction) != 0; return (this.facadeBlocks[direction.ordinal()] != 0); @@ -579,16 +581,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui InvUtils.dropItems(worldObj, ItemFacade.getStack(this.facadeBlocks[direction.ordinal()], this.facadeMeta[direction.ordinal()]), this.xCoord, this.yCoord, this.zCoord); } - public void dropFacade(ForgeDirection direction) { - if (this.worldObj.isRemote) - return; + public boolean dropFacade(ForgeDirection direction) { if (!hasFacade(direction)) - return; - dropFacadeItem(direction); - this.facadeBlocks[direction.ordinal()] = 0; - this.facadeMeta[direction.ordinal()] = 0; - worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); - scheduleRenderUpdate(); + return false; + if (!worldObj.isRemote) { + dropFacadeItem(direction); + this.facadeBlocks[direction.ordinal()] = 0; + this.facadeMeta[direction.ordinal()] = 0; + worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); + scheduleRenderUpdate(); + } + return true; } /** @@ -677,15 +680,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui return plugs[side.ordinal()]; } - public void removeAndDropPlug(ForgeDirection side) { + public boolean removeAndDropPlug(ForgeDirection side) { if (!hasPlug(side)) - return; - - plugs[side.ordinal()] = false; - InvUtils.dropItems(worldObj, new ItemStack(BuildCraftTransport.plugItem), this.xCoord, this.yCoord, this.zCoord); - worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); - scheduleNeighborChange(); //To force recalculation of connections - scheduleRenderUpdate(); + return false; + if (!worldObj.isRemote) { + plugs[side.ordinal()] = false; + InvUtils.dropItems(worldObj, new ItemStack(BuildCraftTransport.plugItem), this.xCoord, this.yCoord, this.zCoord); + worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); + scheduleNeighborChange(); //To force recalculation of connections + scheduleRenderUpdate(); + } + return true; } public boolean addPlug(ForgeDirection forgeDirection) { @@ -714,7 +719,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; } - + @Override public void writeGuiData(DataOutputStream data) throws IOException { if (BlockGenericPipe.isValid(pipe) && pipe instanceof IGuiReturnHandler) diff --git a/common/buildcraft/transport/TransportConstants.java b/common/buildcraft/transport/TransportConstants.java new file mode 100644 index 00000000..10a2eaf8 --- /dev/null +++ b/common/buildcraft/transport/TransportConstants.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport; + +import net.minecraft.item.ItemStack; + +/** + * + * @author CovertJaguar + */ +public class TransportConstants { + + public static final float FACADE_THICKNESS = 1F / 16F; + public static final float PIPE_NORMAL_SPEED = 0.01F; +} diff --git a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java index 2d631529..cad1b80e 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java @@ -14,12 +14,12 @@ import buildcraft.api.gates.IAction; import buildcraft.api.tools.IToolWrench; import buildcraft.core.network.TileNetworkData; import buildcraft.core.utils.EnumColor; -import buildcraft.core.utils.Utils; import buildcraft.transport.IPipeTransportItemsHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TileGenericPipe; +import buildcraft.transport.TransportConstants; import buildcraft.transport.TravelingItem; import buildcraft.transport.triggers.ActionPipeColor; import buildcraft.transport.triggers.ActionPipeDirection; @@ -140,12 +140,12 @@ public class PipeItemsDaizuli extends Pipe implements IPipeT @Override public void readjustSpeed(TravelingItem item) { - if (item.getSpeed() > Utils.pipeNormalSpeed) - item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F); + if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) + item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F); - if (item.getSpeed() < Utils.pipeNormalSpeed) - item.setSpeed(Utils.pipeNormalSpeed); + if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) + item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED); } @Override diff --git a/common/buildcraft/transport/pipes/PipeItemsGold.java b/common/buildcraft/transport/pipes/PipeItemsGold.java index 13ec571b..cc35cc5c 100644 --- a/common/buildcraft/transport/pipes/PipeItemsGold.java +++ b/common/buildcraft/transport/pipes/PipeItemsGold.java @@ -10,11 +10,11 @@ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.Position; -import buildcraft.core.utils.Utils; import buildcraft.transport.IPipeTransportItemsHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; +import buildcraft.transport.TransportConstants; import buildcraft.transport.TravelingItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -50,6 +50,6 @@ public class PipeItemsGold extends Pipe implements IPipeTransportItemsHook { @Override public void readjustSpeed(TravelingItem item) { - item.setSpeed(Math.min(Math.max(Utils.pipeNormalSpeed, item.getSpeed()) * 2f, Utils.pipeNormalSpeed * 20F)); + item.setSpeed(Math.min(Math.max(TransportConstants.PIPE_NORMAL_SPEED, item.getSpeed()) * 2f, TransportConstants.PIPE_NORMAL_SPEED * 20F)); } } diff --git a/common/buildcraft/transport/pipes/PipeItemsLapis.java b/common/buildcraft/transport/pipes/PipeItemsLapis.java index 3966a23e..4df7a8f6 100644 --- a/common/buildcraft/transport/pipes/PipeItemsLapis.java +++ b/common/buildcraft/transport/pipes/PipeItemsLapis.java @@ -13,12 +13,12 @@ import buildcraft.api.core.Position; import buildcraft.api.gates.IAction; import buildcraft.api.tools.IToolWrench; import buildcraft.core.utils.EnumColor; -import buildcraft.core.utils.Utils; import buildcraft.transport.IItemTravelingHook; import buildcraft.transport.IPipeTransportItemsHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; +import buildcraft.transport.TransportConstants; import buildcraft.transport.TravelingItem; import buildcraft.transport.triggers.ActionPipeColor; import cpw.mods.fml.relauncher.Side; @@ -96,12 +96,12 @@ public class PipeItemsLapis extends Pipe implements IItemTra @Override public void readjustSpeed(TravelingItem item) { - if (item.getSpeed() > Utils.pipeNormalSpeed) { - item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F); + if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) { + item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F); } - if (item.getSpeed() < Utils.pipeNormalSpeed) { - item.setSpeed(Utils.pipeNormalSpeed); + if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) { + item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED); } } diff --git a/common/buildcraft/transport/pipes/PipeItemsObsidian.java b/common/buildcraft/transport/pipes/PipeItemsObsidian.java index 67dde61b..eff8cfb3 100644 --- a/common/buildcraft/transport/pipes/PipeItemsObsidian.java +++ b/common/buildcraft/transport/pipes/PipeItemsObsidian.java @@ -19,10 +19,10 @@ import buildcraft.core.inventory.Transactor; import buildcraft.core.inventory.filters.StackFilter; import buildcraft.transport.TravelingItem; import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.utils.Utils; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; +import buildcraft.transport.utils.TransportUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.Arrays; @@ -226,7 +226,7 @@ public class PipeItemsObsidian extends Pipe implements IPowe CoreProxy.proxy.removeEntity(entity); } - TravelingItem passive = new TravelingItem(container.xCoord + 0.5, container.yCoord + Utils.getPipeFloorOf(stack), container.zCoord + 0.5, stack); + TravelingItem passive = new TravelingItem(container.xCoord + 0.5, container.yCoord + TransportUtils.getPipeFloorOf(stack), container.zCoord + 0.5, stack); passive.setSpeed((float) speed); diff --git a/common/buildcraft/transport/pipes/PipeItemsQuartz.java b/common/buildcraft/transport/pipes/PipeItemsQuartz.java index 384c21e0..13c6a0d5 100644 --- a/common/buildcraft/transport/pipes/PipeItemsQuartz.java +++ b/common/buildcraft/transport/pipes/PipeItemsQuartz.java @@ -10,11 +10,11 @@ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.Position; -import buildcraft.core.utils.Utils; import buildcraft.transport.IPipeTransportItemsHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; +import buildcraft.transport.TransportConstants; import buildcraft.transport.TravelingItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -41,12 +41,12 @@ public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook { @Override public void readjustSpeed(TravelingItem item) { - if (item.getSpeed() > Utils.pipeNormalSpeed) { - item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F); + if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) { + item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F); } - if (item.getSpeed() < Utils.pipeNormalSpeed) { - item.setSpeed(Utils.pipeNormalSpeed); + if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) { + item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED); } } diff --git a/common/buildcraft/transport/pipes/PipeItemsStone.java b/common/buildcraft/transport/pipes/PipeItemsStone.java index 6199c8ea..415e5dd2 100644 --- a/common/buildcraft/transport/pipes/PipeItemsStone.java +++ b/common/buildcraft/transport/pipes/PipeItemsStone.java @@ -10,11 +10,11 @@ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.Position; -import buildcraft.core.utils.Utils; import buildcraft.transport.IPipeTransportItemsHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; +import buildcraft.transport.TransportConstants; import buildcraft.transport.TravelingItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -40,12 +40,12 @@ public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook { @Override public void readjustSpeed(TravelingItem item) { - if (item.getSpeed() > Utils.pipeNormalSpeed) { - item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 2.0F); + if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) { + item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 2.0F); } - if (item.getSpeed() < Utils.pipeNormalSpeed) { - item.setSpeed(Utils.pipeNormalSpeed); + if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) { + item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED); } } diff --git a/common/buildcraft/transport/render/FacadeItemRenderer.java b/common/buildcraft/transport/render/FacadeItemRenderer.java index 56e98d1d..2572ae6e 100644 --- a/common/buildcraft/transport/render/FacadeItemRenderer.java +++ b/common/buildcraft/transport/render/FacadeItemRenderer.java @@ -1,7 +1,7 @@ package buildcraft.transport.render; import buildcraft.BuildCraftTransport; -import buildcraft.core.utils.Utils; +import buildcraft.core.CoreConstants; import buildcraft.transport.ItemFacade; import buildcraft.transport.PipeIconProvider; import net.minecraft.block.Block; @@ -11,6 +11,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraftforge.client.IItemRenderer; +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON; import org.lwjgl.opengl.GL11; public class FacadeItemRenderer implements IItemRenderer { @@ -72,7 +73,7 @@ public class FacadeItemRenderer implements IItemRenderer { block = BuildCraftTransport.genericPipeBlock; Icon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe - block.setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos - 1F / 16F); + block.setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS - 1F / 16F); block.setBlockBoundsForItemRender(); render.setRenderBoundsFromBlock(block); GL11.glTranslatef(translateX, translateY, translateZ + 0.25F); @@ -112,6 +113,8 @@ public class FacadeItemRenderer implements IItemRenderer { return true; case EQUIPPED: return true; + case EQUIPPED_FIRST_PERSON: + return true; case INVENTORY: return true; default: @@ -133,6 +136,7 @@ public class FacadeItemRenderer implements IItemRenderer { renderFacadeItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F); break; case EQUIPPED: + case EQUIPPED_FIRST_PERSON: renderFacadeItem((RenderBlocks) data[0], item, 0F, 0F, 0f); break; case INVENTORY: diff --git a/common/buildcraft/transport/render/PipeItemRenderer.java b/common/buildcraft/transport/render/PipeItemRenderer.java index 29a07364..7d8f39e3 100644 --- a/common/buildcraft/transport/render/PipeItemRenderer.java +++ b/common/buildcraft/transport/render/PipeItemRenderer.java @@ -1,7 +1,7 @@ package buildcraft.transport.render; import buildcraft.BuildCraftTransport; -import buildcraft.core.utils.Utils; +import buildcraft.core.CoreConstants; import buildcraft.transport.ItemPipe; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -27,7 +27,7 @@ public class PipeItemRenderer implements IItemRenderer { if (icon == null) icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); - block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); + block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS); block.setBlockBoundsForItemRender(); render.setRenderBoundsFromBlock(block); diff --git a/common/buildcraft/transport/render/PipeRendererTESR.java b/common/buildcraft/transport/render/PipeRendererTESR.java index 425cfde7..128fad2d 100644 --- a/common/buildcraft/transport/render/PipeRendererTESR.java +++ b/common/buildcraft/transport/render/PipeRendererTESR.java @@ -12,11 +12,11 @@ import buildcraft.BuildCraftCore.RenderMode; import buildcraft.BuildCraftTransport; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipe.WireColor; +import buildcraft.core.CoreConstants; import buildcraft.core.render.FluidRenderer; import buildcraft.core.render.RenderEntityBlock; import buildcraft.core.render.RenderEntityBlock.RenderInfo; import buildcraft.core.utils.EnumColor; -import buildcraft.core.utils.Utils; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeRenderState; @@ -98,7 +98,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { } block.texture = fluid.getStillIcon(); - float size = Utils.pipeMaxPos - Utils.pipeMinPos; + float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS; // render size @@ -111,12 +111,12 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { GL11.glNewList(d.sideHorizontal[s], 4864 /* GL_COMPILE */); block.minX = 0.0F; - block.minZ = Utils.pipeMinPos + 0.01F; + block.minZ = CoreConstants.PIPE_MIN_POS + 0.01F; block.maxX = block.minX + size / 2F + 0.01F; block.maxZ = block.minZ + size - 0.02F; - block.minY = Utils.pipeMinPos + 0.01F; + block.minY = CoreConstants.PIPE_MIN_POS + 0.01F; block.maxY = block.minY + (size - 0.02F) * ratio; RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true); @@ -128,7 +128,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { d.sideVertical[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.sideVertical[s], 4864 /* GL_COMPILE */); - block.minY = Utils.pipeMaxPos - 0.01; + block.minY = CoreConstants.PIPE_MAX_POS - 0.01; block.maxY = 1; block.minX = 0.5 - (size / 2 - 0.01) * ratio; @@ -146,13 +146,13 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { d.centerHorizontal[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.centerHorizontal[s], 4864 /* GL_COMPILE */); - block.minX = Utils.pipeMinPos + 0.01; - block.minZ = Utils.pipeMinPos + 0.01; + block.minX = CoreConstants.PIPE_MIN_POS + 0.01; + block.minZ = CoreConstants.PIPE_MIN_POS + 0.01; block.maxX = block.minX + size - 0.02; block.maxZ = block.minZ + size - 0.02; - block.minY = Utils.pipeMinPos + 0.01; + block.minY = CoreConstants.PIPE_MIN_POS + 0.01; block.maxY = block.minY + (size - 0.02F) * ratio; RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true); @@ -164,8 +164,8 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { d.centerVertical[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.centerVertical[s], 4864 /* GL_COMPILE */); - block.minY = Utils.pipeMinPos + 0.01; - block.maxY = Utils.pipeMaxPos - 0.01; + block.minY = CoreConstants.PIPE_MIN_POS + 0.01; + block.maxY = CoreConstants.PIPE_MAX_POS - 0.01; block.minX = 0.5 - (size / 2 - 0.02) * ratio; block.maxX = 0.5 + (size / 2 - 0.02) * ratio; @@ -192,7 +192,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { RenderInfo block = new RenderInfo(); block.texture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Power_Normal.ordinal()); - float size = Utils.pipeMaxPos - Utils.pipeMinPos; + float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS; for (int s = 0; s < POWER_STAGES; ++s) { displayPowerList[s] = GLAllocation.generateDisplayLists(1); @@ -218,7 +218,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { block.texture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Power_Overload.ordinal()); - size = Utils.pipeMaxPos - Utils.pipeMinPos; + size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS; for (int s = 0; s < POWER_STAGES; ++s) { displayPowerListOverload[s] = GLAllocation.generateDisplayLists(1); @@ -273,19 +273,19 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { PipeRenderState state = pipe.getRenderState(); if (state.wireMatrix.hasWire(WireColor.Red)) { - pipeWireRender(pipe, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMinPos, IPipe.WireColor.Red, x, y, z); + pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MIN_POS, IPipe.WireColor.Red, x, y, z); } if (state.wireMatrix.hasWire(WireColor.Blue)) { - pipeWireRender(pipe, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos, IPipe.WireColor.Blue, x, y, z); + pipeWireRender(pipe, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, IPipe.WireColor.Blue, x, y, z); } if (state.wireMatrix.hasWire(WireColor.Green)) { - pipeWireRender(pipe, Utils.pipeMaxPos, Utils.pipeMinPos, Utils.pipeMinPos, IPipe.WireColor.Green, x, y, z); + pipeWireRender(pipe, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, IPipe.WireColor.Green, x, y, z); } if (state.wireMatrix.hasWire(WireColor.Yellow)) { - pipeWireRender(pipe, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, IPipe.WireColor.Yellow, x, y, z); + pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, IPipe.WireColor.Yellow, x, y, z); } if (state.hasGate()) { @@ -297,13 +297,13 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { PipeRenderState state = pipe.getRenderState(); - float minX = Utils.pipeMinPos; - float minY = Utils.pipeMinPos; - float minZ = Utils.pipeMinPos; + float minX = CoreConstants.PIPE_MIN_POS; + float minY = CoreConstants.PIPE_MIN_POS; + float minZ = CoreConstants.PIPE_MIN_POS; - float maxX = Utils.pipeMaxPos; - float maxY = Utils.pipeMaxPos; - float maxZ = Utils.pipeMaxPos; + float maxX = CoreConstants.PIPE_MAX_POS; + float maxY = CoreConstants.PIPE_MAX_POS; + float maxZ = CoreConstants.PIPE_MAX_POS; boolean foundX = false, foundY = false, foundZ = false; @@ -340,43 +340,43 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { boolean center = false; if (minX == 0 && maxX != 1 && (foundY || foundZ)) - if (cx == Utils.pipeMinPos) { - maxX = Utils.pipeMinPos; + if (cx == CoreConstants.PIPE_MIN_POS) { + maxX = CoreConstants.PIPE_MIN_POS; } else { center = true; } if (minX != 0 && maxX == 1 && (foundY || foundZ)) - if (cx == Utils.pipeMaxPos) { - minX = Utils.pipeMaxPos; + if (cx == CoreConstants.PIPE_MAX_POS) { + minX = CoreConstants.PIPE_MAX_POS; } else { center = true; } if (minY == 0 && maxY != 1 && (foundX || foundZ)) - if (cy == Utils.pipeMinPos) { - maxY = Utils.pipeMinPos; + if (cy == CoreConstants.PIPE_MIN_POS) { + maxY = CoreConstants.PIPE_MIN_POS; } else { center = true; } if (minY != 0 && maxY == 1 && (foundX || foundZ)) - if (cy == Utils.pipeMaxPos) { - minY = Utils.pipeMaxPos; + if (cy == CoreConstants.PIPE_MAX_POS) { + minY = CoreConstants.PIPE_MAX_POS; } else { center = true; } if (minZ == 0 && maxZ != 1 && (foundX || foundY)) - if (cz == Utils.pipeMinPos) { - maxZ = Utils.pipeMinPos; + if (cz == CoreConstants.PIPE_MIN_POS) { + maxZ = CoreConstants.PIPE_MIN_POS; } else { center = true; } if (minZ != 0 && maxZ == 1 && (foundX || foundY)) - if (cz == Utils.pipeMaxPos) { - minZ = Utils.pipeMaxPos; + if (cz == CoreConstants.PIPE_MAX_POS) { + minZ = CoreConstants.PIPE_MAX_POS; } else { center = true; } @@ -389,10 +389,16 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_CULL_FACE); RenderHelper.disableStandardItemLighting(); - + GL11.glColor3f(1, 1, 1); - GL11.glTranslatef((float) x, (float) y, (float) z); - + GL11.glTranslatef((float) x, (float) y, (float) z); + + float scale = 1.001f; + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glScalef(scale, scale, scale); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + + bindTexture(TextureMap.locationBlocksTexture); RenderInfo box = new RenderInfo(); @@ -400,36 +406,36 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { // Z render - if (minZ != Utils.pipeMinPos || maxZ != Utils.pipeMaxPos || !found) { - box.setBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, minZ, cx == Utils.pipeMinPos ? cx - : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, maxZ); + if (minZ != CoreConstants.PIPE_MIN_POS || maxZ != CoreConstants.PIPE_MAX_POS || !found) { + box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, minZ, cx == CoreConstants.PIPE_MIN_POS ? cx + : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, maxZ); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } // X render - if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) { - box.setBounds(minX, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, maxX, cy == Utils.pipeMinPos ? cy - : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F); + if (minX != CoreConstants.PIPE_MIN_POS || maxX != CoreConstants.PIPE_MAX_POS || !found) { + box.setBounds(minX, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, maxX, cy == CoreConstants.PIPE_MIN_POS ? cy + : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } // Y render - if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) { - box.setBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, minY, cz == Utils.pipeMinPos ? cz - 0.05F : cz, cx == Utils.pipeMinPos ? cx - : cx + 0.05F, maxY, cz == Utils.pipeMinPos ? cz : cz + 0.05F); + if (minY != CoreConstants.PIPE_MIN_POS || maxY != CoreConstants.PIPE_MAX_POS || !found) { + box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, minY, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, cx == CoreConstants.PIPE_MIN_POS ? cx + : cx + 0.05F, maxY, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } if (center || !found) { - box.setBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, - cx == Utils.pipeMinPos ? cx : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F); + box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, + cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } - + RenderHelper.enableStandardItemLighting(); - + GL11.glPopAttrib(); GL11.glPopMatrix(); } @@ -442,7 +448,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_CULL_FACE); // GL11.glDisable(GL11.GL_TEXTURE_2D); RenderHelper.disableStandardItemLighting(); - + GL11.glColor3f(1, 1, 1); GL11.glTranslatef((float) x, (float) y, (float) z); @@ -450,42 +456,42 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { PipeRenderState state = pipe.getRenderState(); - float min = Utils.pipeMinPos + 0.05F; - float max = Utils.pipeMaxPos - 0.05F; + float min = CoreConstants.PIPE_MIN_POS + 0.05F; + float max = CoreConstants.PIPE_MAX_POS - 0.05F; RenderInfo box = new RenderInfo(); box.texture = BuildCraftTransport.instance.gateIconProvider.getIcon(state.getGateIconIndex()); if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) { - box.setBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos + 0.001F, max, max); + box.setBounds(CoreConstants.PIPE_MIN_POS - 0.10F, min, min, CoreConstants.PIPE_MIN_POS + 0.001F, max, max); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) { - box.setBounds(Utils.pipeMaxPos + 0.001F, min, min, Utils.pipeMaxPos + 0.10F, max, max); + box.setBounds(CoreConstants.PIPE_MAX_POS + 0.001F, min, min, CoreConstants.PIPE_MAX_POS + 0.10F, max, max); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) { - box.setBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos + 0.001F, max); + box.setBounds(min, CoreConstants.PIPE_MIN_POS - 0.10F, min, max, CoreConstants.PIPE_MIN_POS + 0.001F, max); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) { - box.setBounds(min, Utils.pipeMaxPos + 0.001F, min, max, Utils.pipeMaxPos + 0.10F, max); + box.setBounds(min, CoreConstants.PIPE_MAX_POS + 0.001F, min, max, CoreConstants.PIPE_MAX_POS + 0.10F, max); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) { - box.setBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos + 0.001F); + box.setBounds(min, min, CoreConstants.PIPE_MIN_POS - 0.10F, max, max, CoreConstants.PIPE_MIN_POS + 0.001F); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) { - box.setBounds(min, min, Utils.pipeMaxPos + 0.001F, max, max, Utils.pipeMaxPos + 0.10F); + box.setBounds(min, min, CoreConstants.PIPE_MAX_POS + 0.001F, max, max, CoreConstants.PIPE_MAX_POS + 0.10F); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } - + RenderHelper.enableStandardItemLighting(); GL11.glPopAttrib(); diff --git a/common/buildcraft/transport/render/PipeRendererWorld.java b/common/buildcraft/transport/render/PipeRendererWorld.java index 5cc1baef..77f8f4a8 100644 --- a/common/buildcraft/transport/render/PipeRendererWorld.java +++ b/common/buildcraft/transport/render/PipeRendererWorld.java @@ -2,12 +2,14 @@ package buildcraft.transport.render; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.core.utils.Utils; +import buildcraft.core.CoreConstants; import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.IPipeRenderState; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeRenderState; +import buildcraft.transport.TransportConstants; import buildcraft.transport.TransportProxy; +import buildcraft.core.utils.MatrixTranformations; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; @@ -20,62 +22,8 @@ import net.minecraftforge.common.ForgeDirection; public class PipeRendererWorld implements ISimpleBlockRenderingHandler { - public static final float facadeThickness = 1F / 16F; - /** - * Mirrors the array on the Y axis by calculating offsets from 0.5F - * - * @param targetArray - */ - private void mirrorY(float[][] targetArray) { - float temp = targetArray[1][0]; - targetArray[1][0] = (targetArray[1][1] - 0.5F) * -1F + 0.5F; // 1 -> 0.5F -> -0.5F -> 0F - targetArray[1][1] = (temp - 0.5F) * -1F + 0.5F; // 0 -> -0.5F -> 0.5F -> 1F - } - /** - * Shifts the coordinates around effectivly rotating something. Zero state - * is DOWN then -> NORTH -> WEST Note - To obtain Pos, do a mirrorY() before - * rotating - * - * @param targetArray the array that should be rotated - */ - private void rotate(float[][] targetArray) { - for (int i = 0; i < 2; i++) { - float temp = targetArray[2][i]; - targetArray[2][i] = targetArray[1][i]; - targetArray[1][i] = targetArray[0][i]; - targetArray[0][i] = temp; - } - } - - /** - * @param targetArray the array that should be transformed - * @param direction - */ - private void transform(float[][] targetArray, ForgeDirection direction) { - if ((direction.ordinal() & 0x1) == 1) { - mirrorY(targetArray); - } - - for (int i = 0; i < (direction.ordinal() >> 1); i++) { - rotate(targetArray); - } - } - - /** - * Clones both dimensions of a float[][] - * - * @param source the float[][] to deepClone - * @return - */ - private float[][] deepClone(float[][] source) { - float[][] target = source.clone(); - for (int i = 0; i < target.length; i++) { - target[i] = source[i].clone(); - } - return target; - } private void renderAllFaceExeptAxe(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int x, int y, int z, char axe) { float minX = (float) renderblocks.renderMinX; @@ -121,8 +69,8 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, BlockGenericPipe block, IPipeRenderState renderState, int x, int y, int z) { - float minSize = Utils.pipeMinPos; - float maxSize = Utils.pipeMaxPos; + float minSize = CoreConstants.PIPE_MIN_POS; + float maxSize = CoreConstants.PIPE_MAX_POS; PipeRenderState state = renderState.getRenderState(); IIconProvider icons = renderState.getPipeIcons(); @@ -210,7 +158,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { zeroState[0][1] = 1.0F + zFightOffset / 2; // Y START - END zeroState[1][0] = 0.0F - zFightOffset; - zeroState[1][1] = facadeThickness; + zeroState[1][1] = TransportConstants.FACADE_THICKNESS; // Z START - END zeroState[2][0] = 0.0F; zeroState[2][1] = 1.0F; @@ -241,39 +189,39 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { // Hollow facade if (state.pipeConnectionMatrix.isConnected(direction)) { - float[][] rotated = deepClone(zeroState); + float[][] rotated = MatrixTranformations.deepClone(zeroState); rotated[2][0] = 0.0F; - rotated[2][1] = Utils.pipeMinPos - zFightOffset; + rotated[2][1] = CoreConstants.PIPE_MIN_POS - zFightOffset; rotated[1][0] -= zFightOffset / 2; - transform(rotated, direction); + MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); - rotated = deepClone(zeroState); - rotated[2][0] = Utils.pipeMaxPos + zFightOffset; + rotated = MatrixTranformations.deepClone(zeroState); + rotated[2][0] = CoreConstants.PIPE_MAX_POS + zFightOffset; rotated[1][0] -= zFightOffset / 2; - transform(rotated, direction); + MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); - rotated = deepClone(zeroState); + rotated = MatrixTranformations.deepClone(zeroState); rotated[0][0] = 0.0F; - rotated[0][1] = Utils.pipeMinPos - zFightOffset; + rotated[0][1] = CoreConstants.PIPE_MIN_POS - zFightOffset; rotated[1][1] -= zFightOffset; - transform(rotated, direction); + MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); - rotated = deepClone(zeroState); - rotated[0][0] = Utils.pipeMaxPos + zFightOffset; + rotated = MatrixTranformations.deepClone(zeroState); + rotated[0][0] = CoreConstants.PIPE_MAX_POS + zFightOffset; rotated[0][1] = 1F; rotated[1][1] -= zFightOffset; - transform(rotated, direction); + MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); } else { // Solid facade - float[][] rotated = deepClone(zeroState); - transform(rotated, direction); + float[][] rotated = MatrixTranformations.deepClone(zeroState); + MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); } @@ -292,21 +240,21 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { } // X START - END - zeroState[0][0] = Utils.pipeMinPos; - zeroState[0][1] = Utils.pipeMaxPos; + zeroState[0][0] = CoreConstants.PIPE_MIN_POS; + zeroState[0][1] = CoreConstants.PIPE_MAX_POS; // Y START - END - zeroState[1][0] = facadeThickness; - zeroState[1][1] = Utils.pipeMinPos; + zeroState[1][0] = TransportConstants.FACADE_THICKNESS; + zeroState[1][1] = CoreConstants.PIPE_MIN_POS; // Z START - END - zeroState[2][0] = Utils.pipeMinPos; - zeroState[2][1] = Utils.pipeMaxPos; + zeroState[2][0] = CoreConstants.PIPE_MIN_POS; + zeroState[2][1] = CoreConstants.PIPE_MAX_POS; state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (state.facadeMatrix.getFacadeBlockId(direction) != 0 && !state.pipeConnectionMatrix.isConnected(direction)) { - float[][] rotated = deepClone(zeroState); - transform(rotated, direction); + float[][] rotated = MatrixTranformations.deepClone(zeroState); + MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); @@ -333,8 +281,8 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (state.plugMatrix.isConnected(direction)) { - float[][] rotated = deepClone(zeroState); - transform(rotated, direction); + float[][] rotated = MatrixTranformations.deepClone(zeroState); + MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); @@ -355,8 +303,8 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (state.plugMatrix.isConnected(direction)) { - float[][] rotated = deepClone(zeroState); - transform(rotated, direction); + float[][] rotated = MatrixTranformations.deepClone(zeroState); + MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); diff --git a/common/buildcraft/transport/render/TileEntityPickupFX.java b/common/buildcraft/transport/render/TileEntityPickupFX.java index 3a525cbd..d5ac1411 100644 --- a/common/buildcraft/transport/render/TileEntityPickupFX.java +++ b/common/buildcraft/transport/render/TileEntityPickupFX.java @@ -11,7 +11,7 @@ */ package buildcraft.transport.render; -import buildcraft.core.utils.Utils; +import buildcraft.transport.utils.TransportUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.particle.EntityFX; @@ -42,7 +42,7 @@ public class TileEntityPickupFX extends EntityFX this.entityToPickUp = par2Entity; this.entityPickingUp = par3Entity; this.maxAge = 3; - this.yOffs = Utils.getPipeFloorOf(par2Entity.getEntityItem()); + this.yOffs = TransportUtils.getPipeFloorOf(par2Entity.getEntityItem()); } @Override diff --git a/common/buildcraft/transport/utils/TransportUtils.java b/common/buildcraft/transport/utils/TransportUtils.java new file mode 100644 index 00000000..fb601108 --- /dev/null +++ b/common/buildcraft/transport/utils/TransportUtils.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport.utils; + +import buildcraft.core.CoreConstants; +import net.minecraft.item.ItemStack; + +/** + * + * @author CovertJaguar + */ +public class TransportUtils { + + /** + * Depending on the kind of item in the pipe, set the floor at a different + * level to optimize graphical aspect. + */ + public static float getPipeFloorOf(ItemStack item) { + return CoreConstants.PIPE_MIN_POS; + } +} From ef2eace03cbbfba838e32d843727c6584a617c8b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 12 Oct 2013 17:13:40 -0700 Subject: [PATCH 078/121] Add Tank tiles --- common/buildcraft/core/fluids/RestrictedTank.java | 5 +++-- common/buildcraft/core/fluids/SingleUseTank.java | 6 +++--- common/buildcraft/core/fluids/Tank.java | 4 +++- common/buildcraft/energy/TileEngineIron.java | 6 ++---- common/buildcraft/factory/TileFloodGate.java | 3 +-- common/buildcraft/factory/TilePump.java | 3 +-- common/buildcraft/factory/TileRefinery.java | 6 +++--- common/buildcraft/factory/TileTank.java | 2 +- 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/common/buildcraft/core/fluids/RestrictedTank.java b/common/buildcraft/core/fluids/RestrictedTank.java index b2f82b9a..40f92e11 100644 --- a/common/buildcraft/core/fluids/RestrictedTank.java +++ b/common/buildcraft/core/fluids/RestrictedTank.java @@ -8,6 +8,7 @@ */ package buildcraft.core.fluids; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -19,8 +20,8 @@ public class RestrictedTank extends Tank { private final Fluid[] acceptedFluids; - public RestrictedTank(String name, int capacity, Fluid... acceptedFluids) { - super(name, capacity); + public RestrictedTank(String name, int capacity, TileEntity tile, Fluid... acceptedFluids) { + super(name, capacity, tile); this.acceptedFluids = acceptedFluids; } diff --git a/common/buildcraft/core/fluids/SingleUseTank.java b/common/buildcraft/core/fluids/SingleUseTank.java index 71f6d1ef..2b18ba63 100644 --- a/common/buildcraft/core/fluids/SingleUseTank.java +++ b/common/buildcraft/core/fluids/SingleUseTank.java @@ -9,10 +9,10 @@ package buildcraft.core.fluids; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; /** * @@ -22,8 +22,8 @@ public class SingleUseTank extends Tank { private Fluid acceptedFluid; - public SingleUseTank(String name, int capacity) { - super(name, capacity); + public SingleUseTank(String name, int capacity, TileEntity tile) { + super(name, capacity, tile); } @Override diff --git a/common/buildcraft/core/fluids/Tank.java b/common/buildcraft/core/fluids/Tank.java index 6ec56082..1922e79a 100644 --- a/common/buildcraft/core/fluids/Tank.java +++ b/common/buildcraft/core/fluids/Tank.java @@ -12,6 +12,7 @@ import buildcraft.core.gui.tooltips.ToolTip; import buildcraft.core.gui.tooltips.ToolTipLine; import java.util.Locale; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidTank; @@ -23,9 +24,10 @@ public class Tank extends FluidTank { private final String name; - public Tank(String name, int capacity) { + public Tank(String name, int capacity, TileEntity tile) { super(capacity); this.name = name; + this.tile = tile; } public boolean isEmpty() { diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index c0b31023..a98a88b2 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -45,8 +45,8 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan public static float COOLDOWN_RATE = 0.05F; public static int MAX_COOLANT_PER_TICK = 40; int burnTime = 0; - private Tank tankFuel; - private Tank tankCoolant; + private Tank tankFuel = new Tank("tankFuel", MAX_LIQUID, this); + private Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this); private TankManager tankManager = new TankManager(); private Fuel currentFuel = null; public int penaltyCooling = 0; @@ -55,8 +55,6 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan public TileEngineIron() { super(1); - tankFuel = new Tank("tankFuel", MAX_LIQUID); - tankCoolant = new Tank("tankCoolant", MAX_LIQUID); tankManager.add(tankFuel); tankManager.add(tankCoolant); } diff --git a/common/buildcraft/factory/TileFloodGate.java b/common/buildcraft/factory/TileFloodGate.java index 07c27d02..7cb99338 100644 --- a/common/buildcraft/factory/TileFloodGate.java +++ b/common/buildcraft/factory/TileFloodGate.java @@ -36,7 +36,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { private final TreeMap> pumpLayerQueues = new TreeMap>(); private final Set visitedBlocks = new HashSet(); private Deque fluidsFound = new LinkedList(); - private final Tank tank; + private final Tank tank = new Tank("tank", MAX_LIQUID, this); private int rebuildDelay; private int tick = Utils.RANDOM.nextInt(); private boolean powered = false; @@ -53,7 +53,6 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { } public TileFloodGate() { - tank = new Tank("tank", MAX_LIQUID); } @Override diff --git a/common/buildcraft/factory/TilePump.java b/common/buildcraft/factory/TilePump.java index 87a1b948..e6e419d3 100644 --- a/common/buildcraft/factory/TilePump.java +++ b/common/buildcraft/factory/TilePump.java @@ -54,7 +54,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 16; EntityBlock tube; private TreeMap> pumpLayerQueues = new TreeMap>(); - SingleUseTank tank; + SingleUseTank tank = new SingleUseTank("tank", MAX_LIQUID, this); double tubeY = Double.NaN; int aimY = 0; private PowerHandler powerHandler; @@ -66,7 +66,6 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor public TilePump() { powerHandler = new PowerHandler(this, Type.MACHINE); initPowerProvider(); - tank = new SingleUseTank("tank", MAX_LIQUID); } private void initPowerProvider() { diff --git a/common/buildcraft/factory/TileRefinery.java b/common/buildcraft/factory/TileRefinery.java index cd8408cb..47bd3236 100644 --- a/common/buildcraft/factory/TileRefinery.java +++ b/common/buildcraft/factory/TileRefinery.java @@ -45,9 +45,9 @@ import net.minecraftforge.fluids.IFluidHandler; public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowerReceptor, IInventory, IMachine { public static int LIQUID_PER_SLOT = FluidContainerRegistry.BUCKET_VOLUME * 4; - public SingleUseTank tank1 = new SingleUseTank("tank1", LIQUID_PER_SLOT); - public SingleUseTank tank2 = new SingleUseTank("tank2", LIQUID_PER_SLOT); - public SingleUseTank result = new SingleUseTank("result", LIQUID_PER_SLOT); + public SingleUseTank tank1 = new SingleUseTank("tank1", LIQUID_PER_SLOT, this); + public SingleUseTank tank2 = new SingleUseTank("tank2", LIQUID_PER_SLOT, this); + public SingleUseTank result = new SingleUseTank("result", LIQUID_PER_SLOT, this); public TankManager tankManager = new TankManager(tank1, tank2, result); public float animationSpeed = 1; private int animationStage = 0; diff --git a/common/buildcraft/factory/TileTank.java b/common/buildcraft/factory/TileTank.java index 43cc1d12..ffc08e27 100644 --- a/common/buildcraft/factory/TileTank.java +++ b/common/buildcraft/factory/TileTank.java @@ -32,7 +32,7 @@ import net.minecraftforge.fluids.IFluidHandler; public class TileTank extends TileBuildCraft implements IFluidHandler { - public final Tank tank = new Tank("tank", FluidContainerRegistry.BUCKET_VOLUME * 16); + public final Tank tank = new Tank("tank", FluidContainerRegistry.BUCKET_VOLUME * 16, this); public final TankManager tankManager = new TankManager(tank); public boolean hasUpdate = false; public SafeTimeTracker tracker = new SafeTimeTracker(); From 925a14476b57547ce776acbd0ce342b9f43f15fa Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 12 Oct 2013 17:23:00 -0700 Subject: [PATCH 079/121] Mention Optifine in Issue reporting section --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cb3bf9b7..2ae94aed 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ If you don't, we might assume that you are using latest-greatest and waste a bun a problem that might have fixed been already. Such things makes for very grumpy devs. Grumpy devs spend less time coding and more time doing stuff that makes them less grumpy. * If the issues occurs on a server, be sure it's a vanilla forge server and not a mcpc+ server. +* Issues with any logs mentioning Optifine will be closed on sight! Remove Optifine before reporting any issue. #### Frequently reported * java.lang.AbstractMethodError - Incompatibility between BC/Forge/Mod using BC API. Usually not a BC issue From bab1e30d6ca1796458db5ca5ce0ad4f2f2b21a61 Mon Sep 17 00:00:00 2001 From: Eragonn1490 Date: Sun, 13 Oct 2013 00:49:37 -0400 Subject: [PATCH 080/121] Added Gears to Ore Dictionary Added Imports for OreDictionary Added all the gears to the OreDictionary --- common/buildcraft/BuildCraftCore.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index a5eac72c..e56bd62b 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -25,6 +25,7 @@ import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.Property; import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.fluids.IFluidBlock; import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.IIconProvider; @@ -241,22 +242,27 @@ public class BuildCraftCore { woodenGearItem = (new ItemBuildCraft(woodenGearId.getInt())).setUnlocalizedName("woodenGearItem"); LanguageRegistry.addName(woodenGearItem, "Wooden Gear"); CoreProxy.proxy.registerItem(woodenGearItem); + OreDictionary.registerOre("gearWooden", new ItemStack(woodenGearItem,1,0)); stoneGearItem = (new ItemBuildCraft(stoneGearId.getInt())).setUnlocalizedName("stoneGearItem"); LanguageRegistry.addName(stoneGearItem, "Stone Gear"); CoreProxy.proxy.registerItem(stoneGearItem); + OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem,1,0)); ironGearItem = (new ItemBuildCraft(ironGearId.getInt())).setUnlocalizedName("ironGearItem"); LanguageRegistry.addName(ironGearItem, "Iron Gear"); CoreProxy.proxy.registerItem(ironGearItem); - + OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem,1,0)); + goldGearItem = (new ItemBuildCraft(goldenGearId.getInt())).setUnlocalizedName("goldGearItem"); LanguageRegistry.addName(goldGearItem, "Gold Gear"); CoreProxy.proxy.registerItem(goldGearItem); + OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem,1,0)); diamondGearItem = (new ItemBuildCraft(diamondGearId.getInt())).setUnlocalizedName("diamondGearItem"); LanguageRegistry.addName(diamondGearItem, "Diamond Gear"); CoreProxy.proxy.registerItem(diamondGearItem); + OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem,1,0)); Property colorBlindProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "client.colorblindmode", false); colorBlindProp.comment = "Set to true to enable alternate textures"; From e4af7d00f6bc86bd05e50479df3b505576891b33 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 13 Oct 2013 08:22:31 -0700 Subject: [PATCH 081/121] Cleanup last commit --- common/buildcraft/BuildCraftCore.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index e56bd62b..58dcc0fd 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -242,27 +242,27 @@ public class BuildCraftCore { woodenGearItem = (new ItemBuildCraft(woodenGearId.getInt())).setUnlocalizedName("woodenGearItem"); LanguageRegistry.addName(woodenGearItem, "Wooden Gear"); CoreProxy.proxy.registerItem(woodenGearItem); - OreDictionary.registerOre("gearWooden", new ItemStack(woodenGearItem,1,0)); + OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem)); stoneGearItem = (new ItemBuildCraft(stoneGearId.getInt())).setUnlocalizedName("stoneGearItem"); LanguageRegistry.addName(stoneGearItem, "Stone Gear"); CoreProxy.proxy.registerItem(stoneGearItem); - OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem,1,0)); + OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem)); ironGearItem = (new ItemBuildCraft(ironGearId.getInt())).setUnlocalizedName("ironGearItem"); LanguageRegistry.addName(ironGearItem, "Iron Gear"); CoreProxy.proxy.registerItem(ironGearItem); - OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem,1,0)); + OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem)); goldGearItem = (new ItemBuildCraft(goldenGearId.getInt())).setUnlocalizedName("goldGearItem"); LanguageRegistry.addName(goldGearItem, "Gold Gear"); CoreProxy.proxy.registerItem(goldGearItem); - OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem,1,0)); + OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem)); diamondGearItem = (new ItemBuildCraft(diamondGearId.getInt())).setUnlocalizedName("diamondGearItem"); LanguageRegistry.addName(diamondGearItem, "Diamond Gear"); CoreProxy.proxy.registerItem(diamondGearItem); - OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem,1,0)); + OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem)); Property colorBlindProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "client.colorblindmode", false); colorBlindProp.comment = "Set to true to enable alternate textures"; From 4ee2d8bd078f1d8f2de81d344669440e7edafba2 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 14 Oct 2013 12:33:26 -0700 Subject: [PATCH 082/121] Remove depreciated addCreativeItems() function --- common/buildcraft/factory/BlockFrame.java | 6 +++--- common/buildcraft/factory/BlockPlainPipe.java | 20 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/common/buildcraft/factory/BlockFrame.java b/common/buildcraft/factory/BlockFrame.java index fa063b39..19a96c38 100644 --- a/common/buildcraft/factory/BlockFrame.java +++ b/common/buildcraft/factory/BlockFrame.java @@ -15,12 +15,12 @@ import buildcraft.core.IFramePipeConnection; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.ArrayList; import java.util.List; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; @@ -188,8 +188,8 @@ public class BlockFrame extends Block implements IFramePipeConnection { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); + public void getSubBlocks(int id, CreativeTabs tab, List list) { + list.add(new ItemStack(this)); } @Override diff --git a/common/buildcraft/factory/BlockPlainPipe.java b/common/buildcraft/factory/BlockPlainPipe.java index bba34558..5a3f9a85 100644 --- a/common/buildcraft/factory/BlockPlainPipe.java +++ b/common/buildcraft/factory/BlockPlainPipe.java @@ -1,12 +1,10 @@ /** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com + * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public License + * 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.factory; import buildcraft.core.CoreConstants; @@ -14,10 +12,12 @@ import buildcraft.core.IFramePipeConnection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; +import java.util.List; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; @@ -65,15 +65,13 @@ public class BlockPlainPipe extends Block implements IFramePipeConnection { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); + public void getSubBlocks(int id, CreativeTabs tab, List list) { + list.add(new ItemStack(this)); } - @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) - { - this.blockIcon = par1IconRegister.registerIcon("buildcraft:blockPlainPipe"); + public void registerIcons(IconRegister par1IconRegister) { + this.blockIcon = par1IconRegister.registerIcon("buildcraft:blockPlainPipe"); } } From 068066d9bdfe0e61d497281e4892e9c709663808 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 15 Oct 2013 09:15:28 -0700 Subject: [PATCH 083/121] Allows bouncing on Diazuli Pipe --- common/buildcraft/transport/PipeTransportItems.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index cc39547e..aca0a2ea 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -278,17 +278,17 @@ public class PipeTransportItems extends PipeTransport { result.add(o); } + if (this.container.pipe instanceof IPipeTransportItemsHook) { + Position pos = new Position(container.xCoord, container.yCoord, container.zCoord, item.input); + result = ((IPipeTransportItemsHook) this.container.pipe).filterPossibleMovements(result, pos, item); + } + if (allowBouncing && result.isEmpty()) { if (canReceivePipeObjects(item.input.getOpposite(), item)) { result.add(item.input.getOpposite()); } } - if (this.container.pipe instanceof IPipeTransportItemsHook) { - Position pos = new Position(container.xCoord, container.yCoord, container.zCoord, item.input); - result = ((IPipeTransportItemsHook) this.container.pipe).filterPossibleMovements(result, pos, item); - } - return result; } From 8b2093b7eadaf295bc79f8866942c74685e28bac Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 15 Oct 2013 09:53:20 -0700 Subject: [PATCH 084/121] Fix painted Item rendering --- common/buildcraft/core/render/RenderEntityBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/core/render/RenderEntityBlock.java b/common/buildcraft/core/render/RenderEntityBlock.java index 624e541c..f8ac4859 100644 --- a/common/buildcraft/core/render/RenderEntityBlock.java +++ b/common/buildcraft/core/render/RenderEntityBlock.java @@ -206,7 +206,7 @@ public class RenderEntityBlock extends Render { tessellator.setBrightness(brightness); tessellator.setColorOpaque_F(lightBottom * light, lightBottom * light, lightBottom * light); } else { - tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); +// tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); if (info.brightness >= 0) tessellator.setBrightness(info.brightness); } From 3438566406f7ce22b5570d3a27438a7098523815 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 15 Oct 2013 10:09:23 -0700 Subject: [PATCH 085/121] Fix marker rendering --- common/buildcraft/core/render/RenderEntityBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/core/render/RenderEntityBlock.java b/common/buildcraft/core/render/RenderEntityBlock.java index f8ac4859..11955ee3 100644 --- a/common/buildcraft/core/render/RenderEntityBlock.java +++ b/common/buildcraft/core/render/RenderEntityBlock.java @@ -164,7 +164,7 @@ public class RenderEntityBlock extends Render { lightZ = (int) (Math.floor(entity.posZ) + kBase); GL11.glDisable(2896 /* GL_LIGHTING */); - renderBlock(util, world, lightX, lightY, lightZ, false, true); + renderBlock(util, world, 0, 0, 0, lightX, lightY, lightZ, false, true); GL11.glEnable(2896 /* GL_LIGHTING */); GL11.glPopMatrix(); From 8e92d0494cdc7a72bbc4ba4754a2f68981056d36 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 15 Oct 2013 10:41:04 -0700 Subject: [PATCH 086/121] Fuel/Oil should explode when placed in the nether --- .../energy/BlockBuildcraftFluid.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/common/buildcraft/energy/BlockBuildcraftFluid.java b/common/buildcraft/energy/BlockBuildcraftFluid.java index 37fca7fc..b2fe7b3b 100644 --- a/common/buildcraft/energy/BlockBuildcraftFluid.java +++ b/common/buildcraft/energy/BlockBuildcraftFluid.java @@ -49,7 +49,16 @@ public class BlockBuildcraftFluid extends BlockFluidClassic { @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { - this.theIcon = new Icon[]{iconRegister.registerIcon("buildcraft:" + fluidName + "_still"), iconRegister.registerIcon("buildcraft:" + fluidName + "_flow")}; + this.theIcon = new Icon[] { iconRegister.registerIcon("buildcraft:" + fluidName + "_still"), iconRegister.registerIcon("buildcraft:" + fluidName + "_flow") }; + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, int blockId) { + super.onNeighborBlockChange(world, x, y, z, blockId); + if (flammable && world.provider.dimensionId == -1) { + world.newExplosion(null, x, y, z, 4F, true, true); + world.setBlockToAir(x, y, z); + } } public BlockBuildcraftFluid setFlammable(boolean flammable) { @@ -82,13 +91,13 @@ public class BlockBuildcraftFluid extends BlockFluidClassic { return flammable && flammability == 0; } - public BlockBuildcraftFluid setParticleColor(float particleRed, float particleGreen, float particleBlue){ + public BlockBuildcraftFluid setParticleColor(float particleRed, float particleGreen, float particleBlue) { this.particleRed = particleRed; this.particleGreen = particleGreen; this.particleBlue = particleBlue; return this; } - + @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random rand) { @@ -98,21 +107,23 @@ public class BlockBuildcraftFluid extends BlockFluidClassic { double px = (double) ((float) x + rand.nextFloat()); double py = (double) y - 1.05D; double pz = (double) ((float) z + rand.nextFloat()); - + EntityFX fx = new EntityDropParticleFX(world, px, py, pz, particleRed, particleGreen, particleBlue); FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx); } } - + @Override public boolean canDisplace(IBlockAccess world, int x, int y, int z) { - if (world.getBlockMaterial(x, y, z).isLiquid()) return false; + if (world.getBlockMaterial(x, y, z).isLiquid()) + return false; return super.canDisplace(world, x, y, z); } - + @Override public boolean displaceIfPossible(World world, int x, int y, int z) { - if (world.getBlockMaterial(x, y, z).isLiquid()) return false; + if (world.getBlockMaterial(x, y, z).isLiquid()) + return false; return super.displaceIfPossible(world, x, y, z); } } From e4cad84af6985befd63965d320893c78bcc50a0b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 15 Oct 2013 14:33:11 -0700 Subject: [PATCH 087/121] Fix Gate removal --- common/buildcraft/transport/BlockGenericPipe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index f1e6d8ee..3fba366e 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -691,7 +691,7 @@ public class BlockGenericPipe extends BlockContainer { return true; if (player.isSneaking()) { RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); - if (rayTraceResult != null && rayTraceResult.hitPart == Part.Facade) { + if (rayTraceResult != null && rayTraceResult.hitPart == Part.Gate) { if (stripGate(pipe)) return true; } From 6fdbd8c525758de8cae9ba08538dd7f464cc51cb Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 15 Oct 2013 16:37:17 -0700 Subject: [PATCH 088/121] Move Facades to own tab --- common/buildcraft/BuildCraftTransport.java | 1 - .../buildcraft/builders/BlockArchitect.java | 2 +- .../builders/BlockBlueprintLibrary.java | 2 +- common/buildcraft/builders/BlockBuilder.java | 2 +- common/buildcraft/builders/BlockFiller.java | 2 +- common/buildcraft/builders/BlockMarker.java | 2 +- common/buildcraft/builders/ItemBptBase.java | 2 +- common/buildcraft/core/BlockBuildCraft.java | 2 +- common/buildcraft/core/BlockSpring.java | 2 +- .../core/CreativeTabBuildCraft.java | 59 +++++++++++++++---- common/buildcraft/core/ItemBuildCraft.java | 2 +- common/buildcraft/energy/BlockEngine.java | 2 +- .../energy/ItemBucketBuildcraft.java | 2 +- common/buildcraft/factory/BlockFloodGate.java | 2 +- .../buildcraft/factory/BlockMachineRoot.java | 2 +- common/buildcraft/factory/BlockPump.java | 2 +- common/buildcraft/factory/BlockRefinery.java | 2 +- common/buildcraft/factory/BlockTank.java | 2 +- common/buildcraft/silicon/BlockLaser.java | 2 +- .../buildcraft/silicon/BlockLaserTable.java | 2 +- common/buildcraft/transport/ItemFacade.java | 5 +- common/buildcraft/transport/ItemGate.java | 2 - common/buildcraft/transport/ItemPipe.java | 2 - common/buildcraft/transport/ItemPlug.java | 5 -- 24 files changed, 66 insertions(+), 44 deletions(-) diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 6d3edfe7..b5d9ef8d 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -269,7 +269,6 @@ public class BuildCraftTransport { pipeWaterproof = new ItemBuildCraft(pipeWaterproofId.getInt()); pipeWaterproof.setUnlocalizedName("pipeWaterproof"); - pipeWaterproof.setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); LanguageRegistry.addName(pipeWaterproof, "Pipe Waterproof"); genericPipeBlock = new BlockGenericPipe(genericPipeId.getInt()); CoreProxy.proxy.registerBlock(genericPipeBlock.setUnlocalizedName("pipeBlock"), ItemBlock.class); diff --git a/common/buildcraft/builders/BlockArchitect.java b/common/buildcraft/builders/BlockArchitect.java index b9c29da9..c88b2bca 100644 --- a/common/buildcraft/builders/BlockArchitect.java +++ b/common/buildcraft/builders/BlockArchitect.java @@ -42,7 +42,7 @@ public class BlockArchitect extends BlockContainer { public BlockArchitect(int i) { super(i, Material.iron); setHardness(5F); - //setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + //setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/builders/BlockBlueprintLibrary.java b/common/buildcraft/builders/BlockBlueprintLibrary.java index 31026b61..10276562 100644 --- a/common/buildcraft/builders/BlockBlueprintLibrary.java +++ b/common/buildcraft/builders/BlockBlueprintLibrary.java @@ -32,7 +32,7 @@ public class BlockBlueprintLibrary extends BlockContainer { public BlockBlueprintLibrary(int i) { super(i, Material.wood); - //setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + //setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); setHardness(5F); } diff --git a/common/buildcraft/builders/BlockBuilder.java b/common/buildcraft/builders/BlockBuilder.java index bdf20b08..e4681785 100644 --- a/common/buildcraft/builders/BlockBuilder.java +++ b/common/buildcraft/builders/BlockBuilder.java @@ -38,7 +38,7 @@ public class BlockBuilder extends BlockContainer { public BlockBuilder(int i) { super(i, Material.iron); setHardness(5F); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/builders/BlockFiller.java b/common/buildcraft/builders/BlockFiller.java index 32c7aae7..9e052f9d 100644 --- a/common/buildcraft/builders/BlockFiller.java +++ b/common/buildcraft/builders/BlockFiller.java @@ -39,7 +39,7 @@ public class BlockFiller extends BlockContainer { super(i, Material.iron); setHardness(5F); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/builders/BlockMarker.java b/common/buildcraft/builders/BlockMarker.java index adfc49e7..f4001be8 100644 --- a/common/buildcraft/builders/BlockMarker.java +++ b/common/buildcraft/builders/BlockMarker.java @@ -31,7 +31,7 @@ public class BlockMarker extends BlockContainer { super(i, Material.circuits); setLightValue(0.5F); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } private AxisAlignedBB getBoundingBox(int meta) { diff --git a/common/buildcraft/builders/ItemBptBase.java b/common/buildcraft/builders/ItemBptBase.java index 4f623d20..040137ad 100644 --- a/common/buildcraft/builders/ItemBptBase.java +++ b/common/buildcraft/builders/ItemBptBase.java @@ -27,7 +27,7 @@ public abstract class ItemBptBase extends ItemBuildCraft { super(i); maxStackSize = 1; - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @SuppressWarnings({ "all" }) diff --git a/common/buildcraft/core/BlockBuildCraft.java b/common/buildcraft/core/BlockBuildCraft.java index 74e84669..5cb35417 100644 --- a/common/buildcraft/core/BlockBuildCraft.java +++ b/common/buildcraft/core/BlockBuildCraft.java @@ -14,7 +14,7 @@ public abstract class BlockBuildCraft extends BlockContainer { protected BlockBuildCraft(int id, Material material) { super(id, material); this.rand = new Random(); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/core/BlockSpring.java b/common/buildcraft/core/BlockSpring.java index 6fd5e1a8..b6a3e503 100644 --- a/common/buildcraft/core/BlockSpring.java +++ b/common/buildcraft/core/BlockSpring.java @@ -45,7 +45,7 @@ public class BlockSpring extends Block { setStepSound(soundStoneFootstep); disableStats(); setTickRandomly(true); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/core/CreativeTabBuildCraft.java b/common/buildcraft/core/CreativeTabBuildCraft.java index dcb77115..da3c6b07 100644 --- a/common/buildcraft/core/CreativeTabBuildCraft.java +++ b/common/buildcraft/core/CreativeTabBuildCraft.java @@ -1,24 +1,59 @@ package buildcraft.core; import buildcraft.BuildCraftCore; +import buildcraft.core.utils.Localization; +import buildcraft.transport.ItemFacade; +import java.util.Locale; +import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; -public class CreativeTabBuildCraft extends CreativeTabs { +public enum CreativeTabBuildCraft { - public static final CreativeTabs tabBuildCraft = new CreativeTabBuildCraft("buildcraft"); - - public CreativeTabBuildCraft(String label) { - super(label); + MACHINES, + FACADES; + private final CreativeTabs tab; + + private CreativeTabBuildCraft() { + tab = new Tab(); } - @Override - public ItemStack getIconItemStack() { - return new ItemStack(BuildCraftCore.diamondGearItem); + public CreativeTabs get() { + return tab; } - - @Override - public String getTranslatedTabLabel() { - return "BuildCraft"; + + private String getLabel() { + return "buildcraft." + name().toLowerCase(Locale.ENGLISH); + } + + private String translate() { + return Localization.get("tab." + name().toLowerCase(Locale.ENGLISH)); + } + + private ItemStack getItem() { + switch (this) { + case FACADES: + return ItemFacade.getStack(Block.stoneBrick, 0); + default: + return new ItemStack(BuildCraftCore.diamondGearItem); + } + + } + + private class Tab extends CreativeTabs { + + private Tab() { + super(getLabel()); + } + + @Override + public ItemStack getIconItemStack() { + return getItem(); + } + + @Override + public String getTranslatedTabLabel() { + return translate(); + } } } diff --git a/common/buildcraft/core/ItemBuildCraft.java b/common/buildcraft/core/ItemBuildCraft.java index 57baa729..8b4980bb 100644 --- a/common/buildcraft/core/ItemBuildCraft.java +++ b/common/buildcraft/core/ItemBuildCraft.java @@ -22,7 +22,7 @@ public class ItemBuildCraft extends Item { public ItemBuildCraft(int i) { super(i); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/energy/BlockEngine.java b/common/buildcraft/energy/BlockEngine.java index f5275da1..8382700d 100644 --- a/common/buildcraft/energy/BlockEngine.java +++ b/common/buildcraft/energy/BlockEngine.java @@ -35,7 +35,7 @@ public class BlockEngine extends BlockContainer { super(i, Material.iron); setHardness(5F); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); setUnlocalizedName("engineBlock"); } diff --git a/common/buildcraft/energy/ItemBucketBuildcraft.java b/common/buildcraft/energy/ItemBucketBuildcraft.java index b4a2ff46..8501e23d 100644 --- a/common/buildcraft/energy/ItemBucketBuildcraft.java +++ b/common/buildcraft/energy/ItemBucketBuildcraft.java @@ -22,7 +22,7 @@ public class ItemBucketBuildcraft extends ItemBucket { public ItemBucketBuildcraft(int i, int blockId) { super(i, blockId); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); setContainerItem(Item.bucketEmpty); } diff --git a/common/buildcraft/factory/BlockFloodGate.java b/common/buildcraft/factory/BlockFloodGate.java index cd123bd4..c0ce9c3d 100644 --- a/common/buildcraft/factory/BlockFloodGate.java +++ b/common/buildcraft/factory/BlockFloodGate.java @@ -32,7 +32,7 @@ public class BlockFloodGate extends BlockContainer { public BlockFloodGate(int i) { super(i, Material.iron); setHardness(5F); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/factory/BlockMachineRoot.java b/common/buildcraft/factory/BlockMachineRoot.java index 31f337d7..d98bc802 100644 --- a/common/buildcraft/factory/BlockMachineRoot.java +++ b/common/buildcraft/factory/BlockMachineRoot.java @@ -20,7 +20,7 @@ public abstract class BlockMachineRoot extends BlockContainer { protected BlockMachineRoot(int i, Material material) { super(i, material); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); setHardness(5F); } diff --git a/common/buildcraft/factory/BlockPump.java b/common/buildcraft/factory/BlockPump.java index ed30afe5..6dc5585f 100644 --- a/common/buildcraft/factory/BlockPump.java +++ b/common/buildcraft/factory/BlockPump.java @@ -32,7 +32,7 @@ public class BlockPump extends BlockContainer { public BlockPump(int i) { super(i, Material.iron); setHardness(5F); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/factory/BlockRefinery.java b/common/buildcraft/factory/BlockRefinery.java index 3417eac1..de22da93 100644 --- a/common/buildcraft/factory/BlockRefinery.java +++ b/common/buildcraft/factory/BlockRefinery.java @@ -43,7 +43,7 @@ public class BlockRefinery extends BlockContainer { super(i, Material.iron); setHardness(5F); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/factory/BlockTank.java b/common/buildcraft/factory/BlockTank.java index 8ab8840a..75bbc95c 100644 --- a/common/buildcraft/factory/BlockTank.java +++ b/common/buildcraft/factory/BlockTank.java @@ -37,7 +37,7 @@ public class BlockTank extends BlockContainer { super(i, Material.glass); setBlockBounds(0.125F, 0F, 0.125F, 0.875F, 1F, 0.875F); setHardness(0.5F); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/silicon/BlockLaser.java b/common/buildcraft/silicon/BlockLaser.java index 95b080a7..b0eb8320 100644 --- a/common/buildcraft/silicon/BlockLaser.java +++ b/common/buildcraft/silicon/BlockLaser.java @@ -28,7 +28,7 @@ public class BlockLaser extends BlockContainer { public BlockLaser(int i) { super(i, Material.iron); setHardness(10F); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/silicon/BlockLaserTable.java b/common/buildcraft/silicon/BlockLaserTable.java index 65f5a54c..4cd9204f 100644 --- a/common/buildcraft/silicon/BlockLaserTable.java +++ b/common/buildcraft/silicon/BlockLaserTable.java @@ -27,7 +27,7 @@ public class BlockLaserTable extends BlockContainer { setBlockBounds(0, 0, 0, 1, 9F / 16F, 1); setHardness(10F); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index 67ecc66a..d520c6bc 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -17,15 +17,12 @@ import java.util.Set; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; public class ItemFacade extends ItemBuildCraft { @@ -36,7 +33,7 @@ public class ItemFacade extends ItemBuildCraft { setHasSubtypes(true); setMaxDamage(0); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); + setCreativeTab(CreativeTabBuildCraft.FACADES.get()); } @Override diff --git a/common/buildcraft/transport/ItemGate.java b/common/buildcraft/transport/ItemGate.java index 62ef67f7..4e7286af 100644 --- a/common/buildcraft/transport/ItemGate.java +++ b/common/buildcraft/transport/ItemGate.java @@ -3,7 +3,6 @@ package buildcraft.transport; import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.IAction; import buildcraft.api.gates.ITrigger; -import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.ItemBuildCraft; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -45,7 +44,6 @@ public class ItemGate extends ItemBuildCraft { setHasSubtypes(true); setMaxDamage(0); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); setPassSneakClick(true); } diff --git a/common/buildcraft/transport/ItemPipe.java b/common/buildcraft/transport/ItemPipe.java index 6f655718..c286c6ef 100644 --- a/common/buildcraft/transport/ItemPipe.java +++ b/common/buildcraft/transport/ItemPipe.java @@ -10,7 +10,6 @@ package buildcraft.transport; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.IItemPipe; import buildcraft.core.ItemBuildCraft; import cpw.mods.fml.relauncher.Side; @@ -32,7 +31,6 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { protected ItemPipe(int i) { super(i); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); } @Override diff --git a/common/buildcraft/transport/ItemPlug.java b/common/buildcraft/transport/ItemPlug.java index 46498201..94b5fcbf 100644 --- a/common/buildcraft/transport/ItemPlug.java +++ b/common/buildcraft/transport/ItemPlug.java @@ -1,21 +1,16 @@ package buildcraft.transport; -import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.ItemBuildCraft; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; public class ItemPlug extends ItemBuildCraft { public ItemPlug(int i) { super(i); - setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); } @Override From 4a9eb69b912ab749ecce39ef391f329badc3c81d Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 15 Oct 2013 16:38:30 -0700 Subject: [PATCH 089/121] Attempt to make pickBlock supports Gate/Plugs Whether a Gate is an Autoarchic Gate or not is not sync to the client unfortunately. --- .../buildcraft/transport/BlockGenericPipe.java | 17 +++++++++++++++++ common/buildcraft/transport/Gate.java | 6 +++++- common/buildcraft/transport/GateVanilla.java | 4 ++-- common/buildcraft/transport/ItemFacade.java | 10 +++++++--- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 3fba366e..d33b9e4e 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -576,6 +576,23 @@ public class BlockGenericPipe extends BlockContainer { return pipe.itemID; } + @SideOnly(Side.CLIENT) + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, Minecraft.getMinecraft().thePlayer); + + if (rayTraceResult != null && rayTraceResult.boundingBox != null) { + switch (rayTraceResult.hitPart) { + case Gate: + Pipe pipe = getPipe(world, x, y, z); + return pipe.gate.getGateItem(); + case Plug: + return new ItemStack(BuildCraftTransport.plugItem); + } + } + return super.getPickBlock(target, world, x, y, z); + } + /* Wrappers ************************************************************ */ @Override public void onNeighborBlockChange(World world, int x, int y, int z, int id) { diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java index e5453285..2c356c31 100644 --- a/common/buildcraft/transport/Gate.java +++ b/common/buildcraft/transport/Gate.java @@ -153,7 +153,11 @@ public abstract class Gate { // / UPDATING public abstract void update(); - public abstract void dropGate(); + public abstract ItemStack getGateItem(); + + public void dropGate() { + pipe.dropItem(getGateItem()); + } public void resetGate() { if (broadcastRedstone) { diff --git a/common/buildcraft/transport/GateVanilla.java b/common/buildcraft/transport/GateVanilla.java index 8d0726e3..16958cf5 100644 --- a/common/buildcraft/transport/GateVanilla.java +++ b/common/buildcraft/transport/GateVanilla.java @@ -140,7 +140,7 @@ public class GateVanilla extends Gate { * @param k */ @Override - public void dropGate() { + public ItemStack getGateItem() { int gateDamage; switch (kind) { @@ -175,7 +175,7 @@ public class GateVanilla extends Gate { gateItem = BuildCraftTransport.pipeGate; } - pipe.dropItem(new ItemStack(gateItem, 1, gateDamage)); + return new ItemStack(gateItem, 1, gateDamage); } diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index d520c6bc..f76c96e3 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -216,13 +216,13 @@ public class ItemFacade extends ItemBuildCraft { Block bl = Block.blocksList[blockId]; // No Meta if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0xC) == 0) - return getStack(blockId, (blockMeta & 0x3) | 4); + return getStack(bl, (blockMeta & 0x3) | 4); // Meta | 4 = true if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x8) == 0) - return getStack(blockId, (blockMeta & 0x3) | 8); + return getStack(bl, (blockMeta & 0x3) | 8); // Meta | 8 = true if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x4) == 0) - return getStack(blockId, (blockMeta & 0x3)); + return getStack(bl, (blockMeta & 0x3)); } return null; } @@ -250,6 +250,10 @@ public class ItemFacade extends ItemBuildCraft { return 0; } + public static ItemStack getStack(Block block, int metadata) { + return getStack(block.blockID, metadata); + } + public static ItemStack getStack(int blockID, int metadata) { ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0); NBTTagCompound nbt = new NBTTagCompound("tag"); From 1e224ba4ef33c90c2fa4d4dfb15becf09e4eae21 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 15 Oct 2013 16:40:09 -0700 Subject: [PATCH 090/121] Add some commented out debug statements to PowerHandlers --- common/buildcraft/api/power/PowerHandler.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/common/buildcraft/api/power/PowerHandler.java b/common/buildcraft/api/power/PowerHandler.java index 5bd6fef2..5f405546 100644 --- a/common/buildcraft/api/power/PowerHandler.java +++ b/common/buildcraft/api/power/PowerHandler.java @@ -94,10 +94,12 @@ public final class PowerHandler { * @return */ public float applyPerdition(PowerHandler powerHandler, float current, long ticksPassed) { +// float prev = current; current -= powerLoss * ticksPassed; if (current < 0) { current = 0; } +// powerHandler.totalLostPower += prev - current; return current; } @@ -126,6 +128,11 @@ public final class PowerHandler { private PerditionCalculator perdition; private final PowerReceiver receiver; private final Type type; + // Debug +// private double totalLostPower = 0; +// private double totalReceivedPower = 0; +// private double totalUsedPower = 0; +// private long startTime = -1; public PowerHandler(IPowerReceptor receptor, Type type) { this.receptor = receptor; @@ -235,6 +242,13 @@ public final class PowerHandler { * design around this though if you are aware of the limitations. */ public void update() { +// if (startTime == -1) +// startTime = receptor.getWorld().getTotalWorldTime(); +// else { +// long duration = receptor.getWorld().getTotalWorldTime() - startTime; +// System.out.printf("Power Stats: %s - Stored: %.2f Gained: %.2f - %.2f/t Lost: %.2f - %.2f/t Used: %.2f - %.2f/t%n", receptor.getClass().getSimpleName(), energyStored, totalReceivedPower, totalReceivedPower / duration, totalLostPower, totalLostPower / duration, totalUsedPower, totalUsedPower / duration); +// } + applyPerdition(); applyWork(); validateEnergy(); @@ -303,6 +317,9 @@ public final class PowerHandler { validateEnergy(); +// if (doUse) +// totalUsedPower += result; + return result; } @@ -396,9 +413,11 @@ public final class PowerHandler { applyWork(); if (source == Type.ENGINE && type.eatsEngineExcess()) { - return Math.min(quantity, maxEnergyReceived); + used = Math.min(quantity, maxEnergyReceived); } +// totalReceivedPower += used; + return used; } } From 29e5657b0a1141165e0b265ddefaf6861ca25778 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 19 Oct 2013 04:22:50 -0700 Subject: [PATCH 091/121] Fix pumplist case confusion --- common/buildcraft/BuildCraftFactory.java | 2 +- common/buildcraft/factory/PumpDimensionList.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index f79138aa..4ed83863 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -165,7 +165,7 @@ public class BuildCraftFactory { pumpList.comment = "Allows admins to whitelist or blacklist pumping of specific fluids in specific dimensions.\n" + "Eg. \"-/-1/Lava\" will disable lava in the nether. \"-/*/Lava\" will disable lava in any dimension. \"+/0/*\" will enable any fluid in the overworld.\n" + "Entries are comma seperated, banned fluids have precedence over allowed ones." - + "Default is \"+/*/*,+/-1/Lava\" - the second redundant entry (\"+/-1/Lava\") is there to show the format."; + + "Default is \"+/*/*,+/-1/Lava\" - the second redundant entry (\"+/-1/lava\") is there to show the format."; pumpDimensionList = new PumpDimensionList(pumpList.getString()); int miningWellId = BuildCraftCore.mainConfiguration.getBlock("miningWell.id", DefaultProps.MINING_WELL_ID).getInt(DefaultProps.MINING_WELL_ID); diff --git a/common/buildcraft/factory/PumpDimensionList.java b/common/buildcraft/factory/PumpDimensionList.java index eca15387..d8e5da4d 100644 --- a/common/buildcraft/factory/PumpDimensionList.java +++ b/common/buildcraft/factory/PumpDimensionList.java @@ -3,6 +3,7 @@ package buildcraft.factory; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import net.minecraftforge.fluids.Fluid; public class PumpDimensionList { @@ -34,7 +35,7 @@ public class PumpDimensionList { else e.dimID = Integer.parseInt(dimIDString); - e.fluidName = entryString.substring(i + 1); + e.fluidName = entryString.substring(i + 1).toLowerCase(Locale.ENGLISH); if(e.fluidName.equals("*")) e.matchAnyFluid = true; From f84baecaed049fbf35dc7cad0f0025b312d12ef3 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 19 Oct 2013 12:50:20 -0700 Subject: [PATCH 092/121] Ban MFR/PowerCrystals Core --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2ae94aed..e0261ea7 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ a problem that might have fixed been already. Such things makes for very grumpy less time coding and more time doing stuff that makes them less grumpy. * If the issues occurs on a server, be sure it's a vanilla forge server and not a mcpc+ server. * Issues with any logs mentioning Optifine will be closed on sight! Remove Optifine before reporting any issue. +* Issues with any logs mentioning MineFactoryReloaded or PowerCrystalsCore will be closed on sight! The are modifying our code using core mods! #### Frequently reported * java.lang.AbstractMethodError - Incompatibility between BC/Forge/Mod using BC API. Usually not a BC issue From 81f78e5bf7bc4418abd78ca88883bd5e58b88600 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 19 Oct 2013 13:33:03 -0700 Subject: [PATCH 093/121] Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e0261ea7..28a79d58 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ a problem that might have fixed been already. Such things makes for very grumpy less time coding and more time doing stuff that makes them less grumpy. * If the issues occurs on a server, be sure it's a vanilla forge server and not a mcpc+ server. * Issues with any logs mentioning Optifine will be closed on sight! Remove Optifine before reporting any issue. -* Issues with any logs mentioning MineFactoryReloaded or PowerCrystalsCore will be closed on sight! The are modifying our code using core mods! +* Issues with any logs mentioning MineFactoryReloaded or PowerCrystalsCore will be closed on sight! They are modifying our code using core mods! #### Frequently reported * java.lang.AbstractMethodError - Incompatibility between BC/Forge/Mod using BC API. Usually not a BC issue From d6e0277b7da7f3593b01fb8f44056fff21486048 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 19 Oct 2013 16:51:43 -0700 Subject: [PATCH 094/121] Wood Item Pipes shouldn't never explode themselves --- .../buildcraft/transport/PipeTransportItems.java | 16 +++++++++++++--- .../transport/pipes/PipeItemsWood.java | 5 +++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index aca0a2ea..c16b9d48 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -272,7 +272,7 @@ public class PipeTransportItems extends PipeTransport { item.blacklist.add(item.input.getOpposite()); for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { - if(item.blacklist.contains(o)) + if (item.blacklist.contains(o)) continue; if (container.pipe.outputOpen(o) && canReceivePipeObjects(o, item)) result.add(o); @@ -282,7 +282,7 @@ public class PipeTransportItems extends PipeTransport { Position pos = new Position(container.xCoord, container.yCoord, container.zCoord, item.input); result = ((IPipeTransportItemsHook) this.container.pipe).filterPossibleMovements(result, pos, item); } - + if (allowBouncing && result.isEmpty()) { if (canReceivePipeObjects(item.input.getOpposite(), item)) { result.add(item.input.getOpposite()); @@ -555,10 +555,20 @@ public class PipeTransportItems extends PipeTransport { PacketDispatcher.sendPacketToAllAround(container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST, dimension, createItemPacket(data)); } - public int getNumberOfItems() { + public int getNumberOfStacks() { return items.size(); } + public int getNumberOfItems() { + int num = 0; + for (TravelingItem item : items) { + if (item.getItemStack() == null) + continue; + num += item.getItemStack().stackSize; + } + return num; + } + public void onDropped(EntityItem item) { this.container.pipe.onDropped(item); } diff --git a/common/buildcraft/transport/pipes/PipeItemsWood.java b/common/buildcraft/transport/pipes/PipeItemsWood.java index c5aa8ae2..e5746046 100644 --- a/common/buildcraft/transport/pipes/PipeItemsWood.java +++ b/common/buildcraft/transport/pipes/PipeItemsWood.java @@ -105,7 +105,8 @@ public class PipeItemsWood extends Pipe implements IPowerRec if (powerHandler.getEnergyStored() <= 0) return; - extractItems(); + if (transport.getNumberOfStacks() < PipeTransportItems.MAX_PIPE_STACKS) + extractItems(); powerHandler.setEnergy(0); } @@ -154,7 +155,7 @@ public class PipeItemsWood extends Pipe implements IPowerRec /* ISPECIALINVENTORY */ if (inventory instanceof ISpecialInventory) { - ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(doRemove, from, (int) powerHandler.getEnergyStored()); + ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(doRemove, from, Math.min((int) powerHandler.getEnergyStored(), PipeTransportItems.MAX_PIPE_ITEMS - transport.getNumberOfItems())); if (stacks != null && doRemove) { for (ItemStack stack : stacks) { if (stack != null) { From 93f9dceb902c07f3706f9f9ad179d96380650362 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 20 Oct 2013 00:36:37 -0700 Subject: [PATCH 095/121] Improve Facade Rendering + Interaction --- .../transport/BlockGenericPipe.java | 57 ++++++++++------ common/buildcraft/transport/ItemFacade.java | 50 +++++++------- .../buildcraft/transport/PipeRenderState.java | 2 + .../transport/TransportConstants.java | 4 +- .../transport/render/PipeRendererWorld.java | 66 +++++++++++++++---- 5 files changed, 119 insertions(+), 60 deletions(-) diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index d33b9e4e..414796f3 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -81,11 +81,12 @@ public class BlockGenericPipe extends BlockContainer { private static final ForgeDirection[] DIR_VALUES = ForgeDirection.values(); private static Random rand = new Random(); private boolean skippedFirstIconRegister; - private char renderAxis = 'a'; + private boolean[] renderSide = new boolean[6]; /* Defined subprograms ************************************************* */ public BlockGenericPipe(int i) { super(i, Material.glass); + setRenderAllSides(); } @Override @@ -114,19 +115,33 @@ public class BlockGenericPipe extends BlockContainer { } public void setRenderAxis(char axis) { - this.renderAxis = axis; + Arrays.fill(renderSide, false); + if (axis == 'x') { + renderSide[4] = true; + renderSide[5] = true; + } + if (axis == 'y') { + renderSide[0] = true; + renderSide[1] = true; + } + if (axis == 'z') { + renderSide[2] = true; + renderSide[3] = true; + } + } + + public final void setRenderAllSides() { + Arrays.fill(renderSide, true); + } + + public void setRenderSide(ForgeDirection side, boolean render) { + renderSide[side.ordinal()] = render; } @Override @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side) { - if (renderAxis == 'x') - return side == 4 || side == 5; - if (renderAxis == 'y') - return side == 0 || side == 1; - if (renderAxis == 'z') - return side == 2 || side == 3; - return true; + return renderSide[side]; } @Override @@ -583,11 +598,11 @@ public class BlockGenericPipe extends BlockContainer { if (rayTraceResult != null && rayTraceResult.boundingBox != null) { switch (rayTraceResult.hitPart) { - case Gate: - Pipe pipe = getPipe(world, x, y, z); - return pipe.gate.getGateItem(); - case Plug: - return new ItemStack(BuildCraftTransport.plugItem); + case Gate: + Pipe pipe = getPipe(world, x, y, z); + return pipe.gate.getGateItem(); + case Plug: + return new ItemStack(BuildCraftTransport.plugItem); } } return super.getPickBlock(target, world, x, y, z); @@ -772,15 +787,17 @@ public class BlockGenericPipe extends BlockContainer { } private boolean addOrStripFacade(World world, int x, int y, int z, EntityPlayer player, ForgeDirection side, Pipe pipe) { + RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); if (player.isSneaking()) { - RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); if (rayTraceResult != null && rayTraceResult.hitPart == Part.Facade) { if (stripFacade(pipe, rayTraceResult.sideHit)) return true; } } - if (addFacade(player, pipe, side)) - return true; + if (rayTraceResult != null && rayTraceResult.hitPart == Part.Pipe) { + if (addFacade(player, pipe, rayTraceResult.sideHit != null && rayTraceResult.sideHit != ForgeDirection.UNKNOWN ? rayTraceResult.sideHit : side)) + return true; + } return false; } @@ -874,11 +891,13 @@ public class BlockGenericPipe extends BlockContainer { @SuppressWarnings({"all"}) @SideOnly(Side.CLIENT) @Override - public Icon getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public Icon getBlockTexture(IBlockAccess iblockaccess, int x, int y, int z, int side) { - TileEntity tile = iblockaccess.getBlockTileEntity(i, j, k); + TileEntity tile = iblockaccess.getBlockTileEntity(x, y, z); if (!(tile instanceof IPipeRenderState)) return null; + if (((IPipeRenderState) tile).getRenderState().textureArray != null) + return ((IPipeRenderState) tile).getRenderState().textureArray[side]; return ((IPipeRenderState) tile).getRenderState().currentTexture; // Pipe pipe = getPipe(iblockaccess, i, j, k); diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index f76c96e3..eec7a89f 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -1,6 +1,7 @@ package buildcraft.transport; import buildcraft.BuildCraftTransport; +import buildcraft.api.core.Position; import buildcraft.api.recipes.AssemblyRecipe; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.ItemBuildCraft; @@ -17,12 +18,15 @@ import java.util.Set; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; public class ItemFacade extends ItemBuildCraft { @@ -68,30 +72,26 @@ public class ItemFacade extends ItemBuildCraft { } } -// @Override -// public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { -// if (worldObj.isRemote) -// return false; -// TileEntity tile = worldObj.getBlockTileEntity(x, y, z); -// if (!(tile instanceof TileGenericPipe)) -// return false; -// TileGenericPipe pipeTile = (TileGenericPipe) tile; -// -// if (player.isSneaking()) { // Strip facade -// if (!pipeTile.hasFacade(ForgeDirection.VALID_DIRECTIONS[side])) -// return false; -// pipeTile.dropFacade(ForgeDirection.VALID_DIRECTIONS[side]); -// return true; -// } else { -// if (((TileGenericPipe) tile).addFacade(ForgeDirection.values()[side], ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) { -// if (!player.capabilities.isCreativeMode) { -// stack.stackSize--; -// } -// return true; -// } -// return false; -// } -// } + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { + if (worldObj.isRemote) + return false; + Position pos = new Position(x, y, z, ForgeDirection.getOrientation(side)); + pos.moveForwards(1.0); + + TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z); + if (!(tile instanceof TileGenericPipe)) + return false; + TileGenericPipe pipeTile = (TileGenericPipe) tile; + + if (pipeTile.addFacade(ForgeDirection.getOrientation(side).getOpposite(), ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) { + if (!player.capabilities.isCreativeMode) { + stack.stackSize--; + } + return true; + } + return false; + } public static void initialize() { for (Field f : Block.class.getDeclaredFields()) { @@ -253,7 +253,7 @@ public class ItemFacade extends ItemBuildCraft { public static ItemStack getStack(Block block, int metadata) { return getStack(block.blockID, metadata); } - + public static ItemStack getStack(int blockID, int metadata) { ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0); NBTTagCompound nbt = new NBTTagCompound("tag"); diff --git a/common/buildcraft/transport/PipeRenderState.java b/common/buildcraft/transport/PipeRenderState.java index 8f25c942..200ea884 100644 --- a/common/buildcraft/transport/PipeRenderState.java +++ b/common/buildcraft/transport/PipeRenderState.java @@ -28,6 +28,8 @@ public class PipeRenderState implements IClientState { */ @SideOnly(Side.CLIENT) public Icon currentTexture; + @SideOnly(Side.CLIENT) + public Icon[] textureArray; public void setHasGate(boolean value) { if (hasGate != value) { diff --git a/common/buildcraft/transport/TransportConstants.java b/common/buildcraft/transport/TransportConstants.java index 10a2eaf8..e76ef048 100644 --- a/common/buildcraft/transport/TransportConstants.java +++ b/common/buildcraft/transport/TransportConstants.java @@ -8,14 +8,12 @@ */ package buildcraft.transport; -import net.minecraft.item.ItemStack; - /** * * @author CovertJaguar */ public class TransportConstants { - public static final float FACADE_THICKNESS = 1F / 16F; + public static final float FACADE_THICKNESS = 2F / 16F; public static final float PIPE_NORMAL_SPEED = 0.01F; } diff --git a/common/buildcraft/transport/render/PipeRendererWorld.java b/common/buildcraft/transport/render/PipeRendererWorld.java index 77f8f4a8..2a9db5f2 100644 --- a/common/buildcraft/transport/render/PipeRendererWorld.java +++ b/common/buildcraft/transport/render/PipeRendererWorld.java @@ -22,9 +22,6 @@ import net.minecraftforge.common.ForgeDirection; public class PipeRendererWorld implements ISimpleBlockRenderingHandler { - - - private void renderAllFaceExeptAxe(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int x, int y, int z, char axe) { float minX = (float) renderblocks.renderMinX; float minY = (float) renderblocks.renderMinY; @@ -148,27 +145,60 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { } - private void pipeFacadeRenderer(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) { + private void pipeFacadeRenderer(RenderBlocks renderblocks, BlockGenericPipe block, PipeRenderState state, int x, int y, int z) { float zFightOffset = 1F / 4096F; float[][] zeroState = new float[3][2]; // X START - END - zeroState[0][0] = 0.0F - zFightOffset / 2; - zeroState[0][1] = 1.0F + zFightOffset / 2; + zeroState[0][0] = 0.0F; + zeroState[0][1] = 1.0F; // Y START - END - zeroState[1][0] = 0.0F - zFightOffset; + zeroState[1][0] = 0.0F; zeroState[1][1] = TransportConstants.FACADE_THICKNESS; // Z START - END zeroState[2][0] = 0.0F; zeroState[2][1] = 1.0F; + float[] xOffsets = new float[6]; + xOffsets[0] = zFightOffset; + xOffsets[1] = zFightOffset; + xOffsets[2] = 0; + xOffsets[3] = 0; + xOffsets[4] = 0; + xOffsets[5] = 0; + + float[] yOffsets = new float[6]; + yOffsets[0] = 0; + yOffsets[1] = 0; + yOffsets[2] = zFightOffset; + yOffsets[3] = zFightOffset; + yOffsets[4] = 0; + yOffsets[5] = 0; + + float[] zOffsets = new float[6]; + zOffsets[0] = zFightOffset; + zOffsets[1] = zFightOffset; + zOffsets[2] = 0; + zOffsets[3] = 0; + zOffsets[4] = 0; + zOffsets[5] = 0; + + state.textureArray = new Icon[6]; + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { int facadeId = state.facadeMatrix.getFacadeBlockId(direction); if (facadeId != 0) { Block renderBlock = Block.blocksList[facadeId]; int renderMeta = state.facadeMatrix.getFacadeMetaId(direction); - state.currentTexture = renderBlock.getIcon(direction.ordinal(), renderMeta); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + state.textureArray[side.ordinal()] = renderBlock.getIcon(side.ordinal(), renderMeta); + if (side == direction || side == direction.getOpposite()) + block.setRenderSide(side, true); + else + block.setRenderSide(side, state.facadeMatrix.getFacadeBlockId(side) == 0); + } try { BlockGenericPipe.facadeRenderColor = Item.itemsList[state.facadeMatrix.getFacadeBlockId(direction)].getColorFromItemStack(new ItemStack(facadeId, 1, renderMeta), 0); @@ -190,16 +220,18 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { // Hollow facade if (state.pipeConnectionMatrix.isConnected(direction)) { float[][] rotated = MatrixTranformations.deepClone(zeroState); + rotated[0][0] = CoreConstants.PIPE_MIN_POS - zFightOffset; + rotated[0][1] = CoreConstants.PIPE_MAX_POS + zFightOffset; rotated[2][0] = 0.0F; rotated[2][1] = CoreConstants.PIPE_MIN_POS - zFightOffset; - rotated[1][0] -= zFightOffset / 2; MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); rotated = MatrixTranformations.deepClone(zeroState); + rotated[0][0] = CoreConstants.PIPE_MIN_POS - zFightOffset; + rotated[0][1] = CoreConstants.PIPE_MAX_POS + zFightOffset; rotated[2][0] = CoreConstants.PIPE_MAX_POS + zFightOffset; - rotated[1][0] -= zFightOffset / 2; MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); @@ -207,7 +239,6 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { rotated = MatrixTranformations.deepClone(zeroState); rotated[0][0] = 0.0F; rotated[0][1] = CoreConstants.PIPE_MIN_POS - zFightOffset; - rotated[1][1] -= zFightOffset; MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); @@ -215,14 +246,20 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { rotated = MatrixTranformations.deepClone(zeroState); rotated[0][0] = CoreConstants.PIPE_MAX_POS + zFightOffset; rotated[0][1] = 1F; - rotated[1][1] -= zFightOffset; MatrixTranformations.transform(rotated, direction); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.renderStandardBlock(block, x, y, z); } else { // Solid facade float[][] rotated = MatrixTranformations.deepClone(zeroState); MatrixTranformations.transform(rotated, direction); - renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); + + renderblocks.setRenderBounds( + rotated[0][0] + xOffsets[direction.ordinal()], + rotated[1][0] + yOffsets[direction.ordinal()], + rotated[2][0] + zOffsets[direction.ordinal()], + rotated[0][1] + xOffsets[direction.ordinal()], + rotated[1][1] + yOffsets[direction.ordinal()], + rotated[2][1] + zOffsets[direction.ordinal()]); renderblocks.renderStandardBlock(block, x, y, z); } @@ -239,6 +276,9 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { BlockGenericPipe.facadeRenderColor = -1; } + state.textureArray = null; + block.setRenderAllSides(); + // X START - END zeroState[0][0] = CoreConstants.PIPE_MIN_POS; zeroState[0][1] = CoreConstants.PIPE_MAX_POS; From aa67b6dd5aa90096f5607b0c8b246fed0c9c2a2b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 20 Oct 2013 11:49:38 -0700 Subject: [PATCH 096/121] More Facade Rendering tweaks No, this does not fix #1287, sorry. --- .../transport/render/FacadeRenderHelper.java | 203 ++++++++++++++++++ .../transport/render/PipeRendererWorld.java | 155 +------------ 2 files changed, 204 insertions(+), 154 deletions(-) create mode 100644 common/buildcraft/transport/render/FacadeRenderHelper.java diff --git a/common/buildcraft/transport/render/FacadeRenderHelper.java b/common/buildcraft/transport/render/FacadeRenderHelper.java new file mode 100644 index 00000000..39b48b4d --- /dev/null +++ b/common/buildcraft/transport/render/FacadeRenderHelper.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport.render; + +import buildcraft.BuildCraftTransport; +import buildcraft.core.CoreConstants; +import buildcraft.core.utils.MatrixTranformations; +import buildcraft.transport.BlockGenericPipe; +import buildcraft.transport.PipeIconProvider; +import buildcraft.transport.PipeRenderState; +import buildcraft.transport.TransportConstants; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraftforge.common.ForgeDirection; + +/** + * + * @author CovertJaguar + */ +public class FacadeRenderHelper { + + private static final float zFightOffset = 1F / 4096F; + private static final float[][] zeroStateFacade = new float[3][2]; + private static final float[][] zeroStateSupport = new float[3][2]; + private static final float[] xOffsets = new float[6]; + private static final float[] yOffsets = new float[6]; + private static final float[] zOffsets = new float[6]; + + static { + + // X START - END + zeroStateFacade[0][0] = 0.0F; + zeroStateFacade[0][1] = 1.0F; + // Y START - END + zeroStateFacade[1][0] = 0.0F; + zeroStateFacade[1][1] = TransportConstants.FACADE_THICKNESS; + // Z START - END + zeroStateFacade[2][0] = 0.0F; + zeroStateFacade[2][1] = 1.0F; + + // X START - END + zeroStateSupport[0][0] = CoreConstants.PIPE_MIN_POS; + zeroStateSupport[0][1] = CoreConstants.PIPE_MAX_POS; + // Y START - END + zeroStateSupport[1][0] = TransportConstants.FACADE_THICKNESS; + zeroStateSupport[1][1] = CoreConstants.PIPE_MIN_POS; + // Z START - END + zeroStateSupport[2][0] = CoreConstants.PIPE_MIN_POS; + zeroStateSupport[2][1] = CoreConstants.PIPE_MAX_POS; + + xOffsets[0] = zFightOffset; + xOffsets[1] = zFightOffset; + xOffsets[2] = 0; + xOffsets[3] = 0; + xOffsets[4] = 0; + xOffsets[5] = 0; + + yOffsets[0] = 0; + yOffsets[1] = 0; + yOffsets[2] = zFightOffset; + yOffsets[3] = zFightOffset; + yOffsets[4] = 0; + yOffsets[5] = 0; + + zOffsets[0] = zFightOffset; + zOffsets[1] = zFightOffset; + zOffsets[2] = 0; + zOffsets[3] = 0; + zOffsets[4] = 0; + zOffsets[5] = 0; + } + + private static void setRenderBounds(RenderBlocks renderblocks, float[][] rotated, ForgeDirection side) { + renderblocks.setRenderBounds( + rotated[0][0] + xOffsets[side.ordinal()], + rotated[1][0] + yOffsets[side.ordinal()], + rotated[2][0] + zOffsets[side.ordinal()], + rotated[0][1] - xOffsets[side.ordinal()], + rotated[1][1] - yOffsets[side.ordinal()], + rotated[2][1] - zOffsets[side.ordinal()]); + } + + private static void setRenderBoundsAlt(RenderBlocks renderblocks, float[][] rotated, ForgeDirection side) { + renderblocks.setRenderBounds( + rotated[0][0], + rotated[1][0] + yOffsets[side.ordinal()], + rotated[2][0], + rotated[0][1], + rotated[1][1] + yOffsets[side.ordinal()], + rotated[2][1]); + } + + public static void pipeFacadeRenderer(RenderBlocks renderblocks, BlockGenericPipe block, PipeRenderState state, int x, int y, int z) { + state.textureArray = new Icon[6]; + + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + int facadeId = state.facadeMatrix.getFacadeBlockId(direction); + if (facadeId != 0) { + Block renderBlock = Block.blocksList[facadeId]; + int renderMeta = state.facadeMatrix.getFacadeMetaId(direction); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + state.textureArray[side.ordinal()] = renderBlock.getIcon(side.ordinal(), renderMeta); + if (side == direction || side == direction.getOpposite()) + block.setRenderSide(side, true); + else + block.setRenderSide(side, state.facadeMatrix.getFacadeBlockId(side) == 0); + } + + try { + BlockGenericPipe.facadeRenderColor = Item.itemsList[state.facadeMatrix.getFacadeBlockId(direction)].getColorFromItemStack(new ItemStack(facadeId, 1, renderMeta), 0); + } catch (Throwable error) { + } + + if (renderBlock.getRenderType() == 31) { + if ((renderMeta & 12) == 4) { + renderblocks.uvRotateEast = 1; + renderblocks.uvRotateWest = 1; + renderblocks.uvRotateTop = 1; + renderblocks.uvRotateBottom = 1; + } else if ((renderMeta & 12) == 8) { + renderblocks.uvRotateSouth = 1; + renderblocks.uvRotateNorth = 1; + } + } + + // Hollow facade + if (state.pipeConnectionMatrix.isConnected(direction)) { + float[][] rotated = MatrixTranformations.deepClone(zeroStateFacade); + rotated[0][0] = CoreConstants.PIPE_MIN_POS - zFightOffset * 4; + rotated[0][1] = CoreConstants.PIPE_MAX_POS + zFightOffset * 4; + rotated[2][0] = 0.0F; + rotated[2][1] = CoreConstants.PIPE_MIN_POS - zFightOffset * 2; + MatrixTranformations.transform(rotated, direction); + setRenderBounds(renderblocks, rotated, direction); + renderblocks.renderStandardBlock(block, x, y, z); + + rotated = MatrixTranformations.deepClone(zeroStateFacade); + rotated[0][0] = CoreConstants.PIPE_MIN_POS - zFightOffset * 4; + rotated[0][1] = CoreConstants.PIPE_MAX_POS + zFightOffset * 4; + rotated[2][0] = CoreConstants.PIPE_MAX_POS + zFightOffset * 2; + MatrixTranformations.transform(rotated, direction); + setRenderBounds(renderblocks, rotated, direction); + renderblocks.renderStandardBlock(block, x, y, z); + + rotated = MatrixTranformations.deepClone(zeroStateFacade); + rotated[0][0] = 0.0F; + rotated[0][1] = CoreConstants.PIPE_MIN_POS - zFightOffset * 2; + MatrixTranformations.transform(rotated, direction); + setRenderBounds(renderblocks, rotated, direction); + renderblocks.renderStandardBlock(block, x, y, z); + + rotated = MatrixTranformations.deepClone(zeroStateFacade); + rotated[0][0] = CoreConstants.PIPE_MAX_POS + zFightOffset * 2; + rotated[0][1] = 1F; + MatrixTranformations.transform(rotated, direction); + setRenderBounds(renderblocks, rotated, direction); + renderblocks.renderStandardBlock(block, x, y, z); + } else { // Solid facade + float[][] rotated = MatrixTranformations.deepClone(zeroStateFacade); + MatrixTranformations.transform(rotated, direction); + setRenderBounds(renderblocks, rotated, direction); + renderblocks.renderStandardBlock(block, x, y, z); + } + + if (renderBlock.getRenderType() == 31) { + renderblocks.uvRotateSouth = 0; + renderblocks.uvRotateEast = 0; + renderblocks.uvRotateWest = 0; + renderblocks.uvRotateNorth = 0; + renderblocks.uvRotateTop = 0; + renderblocks.uvRotateBottom = 0; + } + } + + BlockGenericPipe.facadeRenderColor = -1; + } + + state.textureArray = null; + block.setRenderAllSides(); + + state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe + + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + if (state.facadeMatrix.getFacadeBlockId(direction) != 0 && !state.pipeConnectionMatrix.isConnected(direction)) { + float[][] rotated = MatrixTranformations.deepClone(zeroStateSupport); + MatrixTranformations.transform(rotated, direction); + + renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); + renderblocks.renderStandardBlock(block, x, y, z); + } + } + } +} diff --git a/common/buildcraft/transport/render/PipeRendererWorld.java b/common/buildcraft/transport/render/PipeRendererWorld.java index 2a9db5f2..5e70304a 100644 --- a/common/buildcraft/transport/render/PipeRendererWorld.java +++ b/common/buildcraft/transport/render/PipeRendererWorld.java @@ -146,160 +146,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { } private void pipeFacadeRenderer(RenderBlocks renderblocks, BlockGenericPipe block, PipeRenderState state, int x, int y, int z) { - - float zFightOffset = 1F / 4096F; - - float[][] zeroState = new float[3][2]; - // X START - END - zeroState[0][0] = 0.0F; - zeroState[0][1] = 1.0F; - // Y START - END - zeroState[1][0] = 0.0F; - zeroState[1][1] = TransportConstants.FACADE_THICKNESS; - // Z START - END - zeroState[2][0] = 0.0F; - zeroState[2][1] = 1.0F; - - float[] xOffsets = new float[6]; - xOffsets[0] = zFightOffset; - xOffsets[1] = zFightOffset; - xOffsets[2] = 0; - xOffsets[3] = 0; - xOffsets[4] = 0; - xOffsets[5] = 0; - - float[] yOffsets = new float[6]; - yOffsets[0] = 0; - yOffsets[1] = 0; - yOffsets[2] = zFightOffset; - yOffsets[3] = zFightOffset; - yOffsets[4] = 0; - yOffsets[5] = 0; - - float[] zOffsets = new float[6]; - zOffsets[0] = zFightOffset; - zOffsets[1] = zFightOffset; - zOffsets[2] = 0; - zOffsets[3] = 0; - zOffsets[4] = 0; - zOffsets[5] = 0; - - state.textureArray = new Icon[6]; - - for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - int facadeId = state.facadeMatrix.getFacadeBlockId(direction); - if (facadeId != 0) { - Block renderBlock = Block.blocksList[facadeId]; - int renderMeta = state.facadeMatrix.getFacadeMetaId(direction); - - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - state.textureArray[side.ordinal()] = renderBlock.getIcon(side.ordinal(), renderMeta); - if (side == direction || side == direction.getOpposite()) - block.setRenderSide(side, true); - else - block.setRenderSide(side, state.facadeMatrix.getFacadeBlockId(side) == 0); - } - - try { - BlockGenericPipe.facadeRenderColor = Item.itemsList[state.facadeMatrix.getFacadeBlockId(direction)].getColorFromItemStack(new ItemStack(facadeId, 1, renderMeta), 0); - } catch (Throwable error) { - } - - if (renderBlock.getRenderType() == 31) { - if ((renderMeta & 12) == 4) { - renderblocks.uvRotateEast = 1; - renderblocks.uvRotateWest = 1; - renderblocks.uvRotateTop = 1; - renderblocks.uvRotateBottom = 1; - } else if ((renderMeta & 12) == 8) { - renderblocks.uvRotateSouth = 1; - renderblocks.uvRotateNorth = 1; - } - } - - // Hollow facade - if (state.pipeConnectionMatrix.isConnected(direction)) { - float[][] rotated = MatrixTranformations.deepClone(zeroState); - rotated[0][0] = CoreConstants.PIPE_MIN_POS - zFightOffset; - rotated[0][1] = CoreConstants.PIPE_MAX_POS + zFightOffset; - rotated[2][0] = 0.0F; - rotated[2][1] = CoreConstants.PIPE_MIN_POS - zFightOffset; - MatrixTranformations.transform(rotated, direction); - renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); - renderblocks.renderStandardBlock(block, x, y, z); - - rotated = MatrixTranformations.deepClone(zeroState); - rotated[0][0] = CoreConstants.PIPE_MIN_POS - zFightOffset; - rotated[0][1] = CoreConstants.PIPE_MAX_POS + zFightOffset; - rotated[2][0] = CoreConstants.PIPE_MAX_POS + zFightOffset; - MatrixTranformations.transform(rotated, direction); - renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); - renderblocks.renderStandardBlock(block, x, y, z); - - rotated = MatrixTranformations.deepClone(zeroState); - rotated[0][0] = 0.0F; - rotated[0][1] = CoreConstants.PIPE_MIN_POS - zFightOffset; - MatrixTranformations.transform(rotated, direction); - renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); - renderblocks.renderStandardBlock(block, x, y, z); - - rotated = MatrixTranformations.deepClone(zeroState); - rotated[0][0] = CoreConstants.PIPE_MAX_POS + zFightOffset; - rotated[0][1] = 1F; - MatrixTranformations.transform(rotated, direction); - renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); - renderblocks.renderStandardBlock(block, x, y, z); - } else { // Solid facade - float[][] rotated = MatrixTranformations.deepClone(zeroState); - MatrixTranformations.transform(rotated, direction); - - renderblocks.setRenderBounds( - rotated[0][0] + xOffsets[direction.ordinal()], - rotated[1][0] + yOffsets[direction.ordinal()], - rotated[2][0] + zOffsets[direction.ordinal()], - rotated[0][1] + xOffsets[direction.ordinal()], - rotated[1][1] + yOffsets[direction.ordinal()], - rotated[2][1] + zOffsets[direction.ordinal()]); - renderblocks.renderStandardBlock(block, x, y, z); - } - - if (renderBlock.getRenderType() == 31) { - renderblocks.uvRotateSouth = 0; - renderblocks.uvRotateEast = 0; - renderblocks.uvRotateWest = 0; - renderblocks.uvRotateNorth = 0; - renderblocks.uvRotateTop = 0; - renderblocks.uvRotateBottom = 0; - } - } - - BlockGenericPipe.facadeRenderColor = -1; - } - - state.textureArray = null; - block.setRenderAllSides(); - - // X START - END - zeroState[0][0] = CoreConstants.PIPE_MIN_POS; - zeroState[0][1] = CoreConstants.PIPE_MAX_POS; - // Y START - END - zeroState[1][0] = TransportConstants.FACADE_THICKNESS; - zeroState[1][1] = CoreConstants.PIPE_MIN_POS; - // Z START - END - zeroState[2][0] = CoreConstants.PIPE_MIN_POS; - zeroState[2][1] = CoreConstants.PIPE_MAX_POS; - - state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe - - for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - if (state.facadeMatrix.getFacadeBlockId(direction) != 0 && !state.pipeConnectionMatrix.isConnected(direction)) { - float[][] rotated = MatrixTranformations.deepClone(zeroState); - MatrixTranformations.transform(rotated, direction); - - renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); - renderblocks.renderStandardBlock(block, x, y, z); - } - } + FacadeRenderHelper.pipeFacadeRenderer(renderblocks, block, state, x, y, z); } private void pipePlugRenderer(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) { From ce2efe13bb7b7c32ec2735e87b55de4e99691609 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 20 Oct 2013 11:50:40 -0700 Subject: [PATCH 097/121] Remove some dead code --- .../transport/render/FacadeRenderHelper.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/common/buildcraft/transport/render/FacadeRenderHelper.java b/common/buildcraft/transport/render/FacadeRenderHelper.java index 39b48b4d..6ff9e549 100644 --- a/common/buildcraft/transport/render/FacadeRenderHelper.java +++ b/common/buildcraft/transport/render/FacadeRenderHelper.java @@ -89,16 +89,6 @@ public class FacadeRenderHelper { rotated[2][1] - zOffsets[side.ordinal()]); } - private static void setRenderBoundsAlt(RenderBlocks renderblocks, float[][] rotated, ForgeDirection side) { - renderblocks.setRenderBounds( - rotated[0][0], - rotated[1][0] + yOffsets[side.ordinal()], - rotated[2][0], - rotated[0][1], - rotated[1][1] + yOffsets[side.ordinal()], - rotated[2][1]); - } - public static void pipeFacadeRenderer(RenderBlocks renderblocks, BlockGenericPipe block, PipeRenderState state, int x, int y, int z) { state.textureArray = new Icon[6]; From 8166cb0bd895607b7a8e7e2157842db0f423db85 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 22 Oct 2013 21:44:43 -0700 Subject: [PATCH 098/121] Fix slot click issue with Phantom Slots --- common/buildcraft/core/gui/GuiBuildCraft.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/buildcraft/core/gui/GuiBuildCraft.java b/common/buildcraft/core/gui/GuiBuildCraft.java index e292bbae..fab83ce5 100644 --- a/common/buildcraft/core/gui/GuiBuildCraft.java +++ b/common/buildcraft/core/gui/GuiBuildCraft.java @@ -2,7 +2,9 @@ package buildcraft.core.gui; import buildcraft.core.DefaultProps; import buildcraft.core.gui.buttons.GuiBetterButton; +import buildcraft.core.gui.slots.IPhantomSlot; import buildcraft.core.gui.slots.SlotBase; +import buildcraft.core.gui.slots.SlotPhantom; import buildcraft.core.gui.tooltips.ToolTip; import buildcraft.core.gui.tooltips.ToolTipLine; import buildcraft.core.utils.SessionVars; @@ -335,6 +337,23 @@ public abstract class GuiBuildCraft extends GuiContainer { ledgerManager.handleMouseClicked(par1, par2, mouseButton); } + @Override + protected void mouseClickMove(int x, int y, int mouseButton, long time) { + Slot slot = getSlotAtPosition(x, y); + if (mouseButton == 1 && slot instanceof IPhantomSlot) + return; + super.mouseClickMove(x, y, mouseButton, time); + } + + public Slot getSlotAtPosition(int x, int y) { + for (int slotIndex = 0; slotIndex < this.inventorySlots.inventorySlots.size(); ++slotIndex) { + Slot slot = (Slot) this.inventorySlots.inventorySlots.get(slotIndex); + if (isMouseOverSlot(slot, x, y)) + return slot; + } + return null; + } + private void drawToolTips(ToolTip toolTips, int mouseX, int mouseY) { if (toolTips.size() > 0) { int left = this.guiLeft; From c16a0266e8282a350fc55b85e7a4cb384f80db94 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 23 Oct 2013 13:21:24 -0700 Subject: [PATCH 099/121] Allow Facades and Plugs to be placed over Gates --- common/buildcraft/transport/BlockGenericPipe.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 414796f3..ce9c638d 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -794,7 +794,7 @@ public class BlockGenericPipe extends BlockContainer { return true; } } - if (rayTraceResult != null && rayTraceResult.hitPart == Part.Pipe) { + if (rayTraceResult != null && (rayTraceResult.hitPart == Part.Pipe || rayTraceResult.hitPart == Part.Gate)) { if (addFacade(player, pipe, rayTraceResult.sideHit != null && rayTraceResult.sideHit != ForgeDirection.UNKNOWN ? rayTraceResult.sideHit : side)) return true; } @@ -824,7 +824,7 @@ public class BlockGenericPipe extends BlockContainer { return true; } } - if (rayTraceResult != null && rayTraceResult.hitPart == Part.Pipe) { + if (rayTraceResult != null && (rayTraceResult.hitPart == Part.Pipe || rayTraceResult.hitPart == Part.Gate)) { if (addPlug(player, pipe, rayTraceResult.sideHit != null && rayTraceResult.sideHit != ForgeDirection.UNKNOWN ? rayTraceResult.sideHit : side)) return true; } From 12552b3b043ebfa0888d7c8e251dd2fbfbddd19b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 23 Oct 2013 13:30:15 -0700 Subject: [PATCH 100/121] Increase Gate respond time --- common/buildcraft/transport/Gate.java | 1 - common/buildcraft/transport/Pipe.java | 17 ++--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java index 2c356c31..275a1441 100644 --- a/common/buildcraft/transport/Gate.java +++ b/common/buildcraft/transport/Gate.java @@ -251,7 +251,6 @@ public abstract class Gate { for (int i = 0; i < oldBroadcastSignal.length; ++i) { if (oldBroadcastSignal[i] != broadcastSignal[i]) { - // worldObj.markBlockNeedsUpdate(container.xCoord, container.yCoord, zCoord); pipe.container.scheduleRenderUpdate(); pipe.updateSignalState(); break; diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index bfdf4955..fe0b9ebb 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -139,15 +139,11 @@ public abstract class Pipe implements IPipe, IDropContr if (container.worldObj.isRemote) return; - if (actionTracker.markTimeIfDelay(container.worldObj, 10)) { - resolveActions(); - } - // Update the gate if we have any if (gate != null) { + gate.resolveActions(); gate.update(); } - } private void internalUpdate() { @@ -297,9 +293,7 @@ public abstract class Pipe implements IPipe, IDropContr internalUpdateScheduled = true; if (oldSignal == 0) { - // worldObj.markBlockNeedsUpdate(container.xCoord, container.yCoord, zCoord); container.scheduleRenderUpdate(); - } return true; @@ -372,7 +366,7 @@ public abstract class Pipe implements IPipe, IDropContr return false; if (container.hasPlug(side)) return false; - + int connections = 0; ForgeDirection targetOrientation = ForgeDirection.UNKNOWN; for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { @@ -458,13 +452,6 @@ public abstract class Pipe implements IPipe, IDropContr container.scheduleRenderUpdate(); } - private void resolveActions() { - if (!hasGate()) - return; - - gate.resolveActions(); - } - protected void actionsActivated(Map actions) { } From f593cf7a206682d49d7a4d0880ef1e4a39ca2f01 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 23 Oct 2013 21:53:39 -0700 Subject: [PATCH 101/121] Version 4.1.1 --- buildcraft_resources/changelog/4.1.1 | 11 +++++++++++ common/buildcraft/core/Version.java | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 buildcraft_resources/changelog/4.1.1 diff --git a/buildcraft_resources/changelog/4.1.1 b/buildcraft_resources/changelog/4.1.1 new file mode 100644 index 00000000..2fe880cd --- /dev/null +++ b/buildcraft_resources/changelog/4.1.1 @@ -0,0 +1,11 @@ + +#4.1.1 + +- New: Massive rework of Pipe/Player interactions with improvements to selection, Gate/Wire/Facade/Plug placement and removal, Facade rendering and more. (CovertJaguar) +- New: Added config options for fluid fuel values. (CovertJaguar) +- Change: Move Gate/Wire rending to the Pipe TESR, should improve fps when lots of Gates are used. (CovertJaguar) +- Change: Reduce burn time of fluid fuels. (Player) +- Change: Fuel/Oil explode if placed in the Nether. (CovertJaguar) +- Fix: Fix version check so it isn't giving wrong results. (CovertJaguar) +- Fix: Add missing zero to Wooden Engine pump speed. (CovertJaguar) +- Fix: Increase Gate reponds time. (CovertJaguar) \ No newline at end of file diff --git a/common/buildcraft/core/Version.java b/common/buildcraft/core/Version.java index c6c35212..7b72babc 100644 --- a/common/buildcraft/core/Version.java +++ b/common/buildcraft/core/Version.java @@ -19,8 +19,8 @@ public class Version implements Runnable { } public static final String VERSION = "@VERSION@"; public static final String BUILD_NUMBER = "@BUILD_NUMBER@"; - private static final String REMOTE_VERSION_FILE = "http://bit.ly/buildcraftver"; - private static final String REMOTE_CHANGELOG_ROOT = "https://dl.dropbox.com/u/44760587/buildcraft/changelog/"; + private static final String REMOTE_VERSION_FILE = "http://bit.ly/buildcraftversion"; + private static final String REMOTE_CHANGELOG_ROOT = "https://dl.dropboxusercontent.com/u/38558957/Minecraft/Buildcraft/changelogs/"; public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT; public static final int FORGE_VERSION_MAJOR = 4; public static final int FORGE_VERSION_MINOR = 0; From 9b9f468dd50c4e900e0a46e4a7c9b290d80ade22 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 23 Oct 2013 22:15:20 -0700 Subject: [PATCH 102/121] Fixed typo --- buildcraft_resources/changelog/4.1.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildcraft_resources/changelog/4.1.1 b/buildcraft_resources/changelog/4.1.1 index 2fe880cd..65c05f30 100644 --- a/buildcraft_resources/changelog/4.1.1 +++ b/buildcraft_resources/changelog/4.1.1 @@ -8,4 +8,4 @@ - Change: Fuel/Oil explode if placed in the Nether. (CovertJaguar) - Fix: Fix version check so it isn't giving wrong results. (CovertJaguar) - Fix: Add missing zero to Wooden Engine pump speed. (CovertJaguar) -- Fix: Increase Gate reponds time. (CovertJaguar) \ No newline at end of file +- Fix: Increase Gate response time. (CovertJaguar) \ No newline at end of file From 4bdf0f22d5e674eb57d5c1d00b03bf580a1ae75f Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 24 Oct 2013 18:31:42 -0700 Subject: [PATCH 103/121] Buffer Triggers now apply to all Inventories Also adjusted inventory triggers to account for whether an item can be put in a slot when calculating if there is space in the inventory. --- common/buildcraft/BuildCraftCore.java | 5 + common/buildcraft/BuildCraftTransport.java | 5 - .../api/gates/ITriggerParameter.java | 1 + .../api/gates/TriggerParameter.java | 6 +- common/buildcraft/core/DefaultProps.java | 4 +- .../core/triggers/DefaultTriggerProvider.java | 3 + .../core/triggers/TriggerFluidContainer.java | 4 +- .../core/triggers/TriggerInventory.java | 42 +++---- .../core/triggers/TriggerInventoryLevel.java | 104 +++++++++++++++++ .../transport/TileFilteredBuffer.java | 17 +-- .../transport/gui/GuiGateInterface.java | 2 +- .../TriggerFilteredBufferInventoryLevel.java | 109 ------------------ .../triggers/TriggerPipeContents.java | 10 +- 13 files changed, 139 insertions(+), 173 deletions(-) create mode 100644 common/buildcraft/core/triggers/TriggerInventoryLevel.java delete mode 100644 common/buildcraft/transport/triggers/TriggerFilteredBufferInventoryLevel.java diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 58dcc0fd..c85ef338 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -61,6 +61,7 @@ import buildcraft.core.triggers.DefaultActionProvider; import buildcraft.core.triggers.DefaultTriggerProvider; import buildcraft.core.triggers.TriggerFluidContainer; import buildcraft.core.triggers.TriggerInventory; +import buildcraft.core.triggers.TriggerInventoryLevel; import buildcraft.core.triggers.TriggerMachine; import buildcraft.core.utils.Localization; import buildcraft.transport.triggers.TriggerRedstoneInput; @@ -148,6 +149,10 @@ public class BuildCraftCore { public static BCTrigger triggerFullFluid = new TriggerFluidContainer(DefaultProps.TRIGGER_FULL_LIQUID, TriggerFluidContainer.State.Full); public static BCTrigger triggerRedstoneActive = new TriggerRedstoneInput(DefaultProps.TRIGGER_REDSTONE_ACTIVE, true); public static BCTrigger triggerRedstoneInactive = new TriggerRedstoneInput(DefaultProps.TRIGGER_REDSTONE_INACTIVE, false); + + public static BCTrigger triggerInventoryBelow25 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_25); + public static BCTrigger triggerInventoryBelow50 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_50); + public static BCTrigger triggerInventoryBelow75 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_75); public static BCAction actionRedstone = new ActionRedstoneOutput(DefaultProps.ACTION_REDSTONE); public static BCAction actionOn = new ActionMachineControl(DefaultProps.ACTION_ON, Mode.On); diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index b5d9ef8d..71e12747 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -13,7 +13,6 @@ import buildcraft.api.recipes.AssemblyRecipe; import buildcraft.api.transport.IExtractionHandler; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.PipeManager; -import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.ItemBuildCraft; @@ -77,7 +76,6 @@ import buildcraft.transport.triggers.ActionPipeDirection; import buildcraft.transport.triggers.ActionPowerLimiter; import buildcraft.transport.triggers.ActionSignalOutput; import buildcraft.transport.triggers.ActionSingleEnergyPulse; -import buildcraft.transport.triggers.TriggerFilteredBufferInventoryLevel; import buildcraft.transport.triggers.TriggerPipeContents; import buildcraft.transport.triggers.TriggerPipeContents.Kind; import buildcraft.transport.triggers.TriggerPipeSignal; @@ -163,9 +161,6 @@ public class BuildCraftTransport { public static BCTrigger triggerGreenSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_GREEN_SIGNAL_INACTIVE, false, IPipe.WireColor.Green); public static BCTrigger triggerYellowSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_ACTIVE, true, IPipe.WireColor.Yellow); public static BCTrigger triggerYellowSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_INACTIVE, false, IPipe.WireColor.Yellow); - public static BCTrigger triggerInventoryBelow25 = new TriggerFilteredBufferInventoryLevel(DefaultProps.TRIGGER_INVENTORY_LEVEL_BELOW25, TriggerFilteredBufferInventoryLevel.State.Below25); - public static BCTrigger triggerInventoryBelow50 = new TriggerFilteredBufferInventoryLevel(DefaultProps.TRIGGER_INVENTORY_LEVEL_BELOW50, TriggerFilteredBufferInventoryLevel.State.Below50); - public static BCTrigger triggerInventoryBelow75 = new TriggerFilteredBufferInventoryLevel(DefaultProps.TRIGGER_INVENTORY_LEVEL_BELOW75, TriggerFilteredBufferInventoryLevel.State.Below75); public static BCAction actionRedSignal = new ActionSignalOutput(DefaultProps.ACTION_RED_SIGNAL, IPipe.WireColor.Red); public static BCAction actionBlueSignal = new ActionSignalOutput(DefaultProps.ACTION_BLUE_SIGNAL, IPipe.WireColor.Blue); public static BCAction actionGreenSignal = new ActionSignalOutput(DefaultProps.ACTION_GREEN_SIGNAL, IPipe.WireColor.Green); diff --git a/common/buildcraft/api/gates/ITriggerParameter.java b/common/buildcraft/api/gates/ITriggerParameter.java index cef436a6..b097667a 100644 --- a/common/buildcraft/api/gates/ITriggerParameter.java +++ b/common/buildcraft/api/gates/ITriggerParameter.java @@ -13,6 +13,7 @@ public interface ITriggerParameter { public abstract void readFromNBT(NBTTagCompound compound); + @Deprecated public abstract ItemStack getItem(); } diff --git a/common/buildcraft/api/gates/TriggerParameter.java b/common/buildcraft/api/gates/TriggerParameter.java index c76ce99a..0127bc85 100644 --- a/common/buildcraft/api/gates/TriggerParameter.java +++ b/common/buildcraft/api/gates/TriggerParameter.java @@ -66,12 +66,8 @@ public class TriggerParameter implements ITriggerParameter { } } - /* - * (non-Javadoc) - * - * @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#getItem() - */ @Override + @Deprecated public ItemStack getItem() { return stack; } diff --git a/common/buildcraft/core/DefaultProps.java b/common/buildcraft/core/DefaultProps.java index 32cfffd8..f55e6d37 100644 --- a/common/buildcraft/core/DefaultProps.java +++ b/common/buildcraft/core/DefaultProps.java @@ -127,6 +127,7 @@ public class DefaultProps { public static final int FILLER_LIFESPAN_TOUGH = 20; public static final int FILLER_LIFESPAN_NORMAL = 6000; + // These are only till here for Legacy support, new Triggers/Action don't need them public static int TRIGGER_REDSTONE_ACTIVE = 1; public static int TRIGGER_REDSTONE_INACTIVE = 2; public static int TRIGGER_MACHINE_ACTIVE = 3; @@ -157,9 +158,6 @@ public class DefaultProps { public static int TRIGGER_RED_ENGINE_HEAT = 28; public static int TRIGGER_PIPE_REQUESTS_ENERGY = 29; public static int TRIGGER_PIPE_TOO_MUCH_ENERGY = 30; - public static int TRIGGER_INVENTORY_LEVEL_BELOW25 = 31; - public static int TRIGGER_INVENTORY_LEVEL_BELOW50 = 32; - public static int TRIGGER_INVENTORY_LEVEL_BELOW75 = 33; public static int ACTION_REDSTONE = 1; public static int ACTION_RED_SIGNAL = 2; diff --git a/common/buildcraft/core/triggers/DefaultTriggerProvider.java b/common/buildcraft/core/triggers/DefaultTriggerProvider.java index 48c5e643..8f2392a1 100644 --- a/common/buildcraft/core/triggers/DefaultTriggerProvider.java +++ b/common/buildcraft/core/triggers/DefaultTriggerProvider.java @@ -29,6 +29,9 @@ public class DefaultTriggerProvider implements ITriggerProvider { res.add(BuildCraftCore.triggerContainsInventory); res.add(BuildCraftCore.triggerSpaceInventory); res.add(BuildCraftCore.triggerFullInventory); + res.add(BuildCraftCore.triggerInventoryBelow25); + res.add(BuildCraftCore.triggerInventoryBelow50); + res.add(BuildCraftCore.triggerInventoryBelow75); } if (tile instanceof IFluidHandler) { diff --git a/common/buildcraft/core/triggers/TriggerFluidContainer.java b/common/buildcraft/core/triggers/TriggerFluidContainer.java index 6754003a..0674876e 100644 --- a/common/buildcraft/core/triggers/TriggerFluidContainer.java +++ b/common/buildcraft/core/triggers/TriggerFluidContainer.java @@ -58,8 +58,8 @@ public class TriggerFluidContainer extends BCTrigger { FluidStack searchedFluid = null; - if (parameter != null && parameter.getItem() != null) { - searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItem()); + if (parameter != null && parameter.getItemStack() != null) { + searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack()); } if (searchedFluid != null) { diff --git a/common/buildcraft/core/triggers/TriggerInventory.java b/common/buildcraft/core/triggers/TriggerInventory.java index 294f596e..7a74d870 100644 --- a/common/buildcraft/core/triggers/TriggerInventory.java +++ b/common/buildcraft/core/triggers/TriggerInventory.java @@ -9,10 +9,11 @@ package buildcraft.core.triggers; import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.inventory.ISpecialInventory; -import buildcraft.core.inventory.InventoryWrapper; +import buildcraft.core.inventory.InventoryIterator; +import buildcraft.core.inventory.InventoryIterator.IInvSlot; +import buildcraft.core.inventory.StackHelper; import java.util.Locale; import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -58,7 +59,7 @@ public class TriggerInventory extends BCTrigger { ItemStack searchedStack = null; if (parameter != null) { - searchedStack = parameter.getItem(); + searchedStack = parameter.getItemStack(); } if (tile instanceof ISpecialInventory) { @@ -82,34 +83,21 @@ public class TriggerInventory extends BCTrigger { } if (tile instanceof IInventory) { - ISidedInventory inv = InventoryWrapper.getWrappedInventory(tile); - int invSize = inv.getSizeInventory(); - - if (invSize <= 0) - return false; - + boolean hasSlots = false; boolean foundItems = false; boolean foundSpace = false; - for (int i : inv.getAccessibleSlotsFromSide(side.ordinal())) { - ItemStack stack = inv.getStackInSlot(i); - - boolean slotEmpty = stack == null || stack.stackSize == 0; - - if (searchedStack == null) { - foundItems |= !slotEmpty; - } else if (!slotEmpty) { - foundItems |= stack.isItemEqual(searchedStack); - } - - if (slotEmpty) { - foundSpace = true; - } else if (searchedStack != null) { - if (stack.stackSize < stack.getMaxStackSize() && stack.isItemEqual(searchedStack)) { - foundSpace = true; - } - } + for (IInvSlot slot : InventoryIterator.getIterable((IInventory) tile, side)) { + hasSlots = true; + ItemStack stack = slot.getStackInSlot(); + + foundItems |= stack != null && (searchedStack == null || StackHelper.instance().canStacksMerge(stack, searchedStack)); + foundSpace |= (stack == null || (StackHelper.instance().canStacksMerge(stack, searchedStack) && stack.stackSize < stack.getMaxStackSize())) + && (searchedStack == null || slot.canPutStackInSlot(searchedStack)); } + + if(!hasSlots) + return false; switch (state) { case Empty: diff --git a/common/buildcraft/core/triggers/TriggerInventoryLevel.java b/common/buildcraft/core/triggers/TriggerInventoryLevel.java new file mode 100644 index 00000000..fa1432fa --- /dev/null +++ b/common/buildcraft/core/triggers/TriggerInventoryLevel.java @@ -0,0 +1,104 @@ +/** + * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public License + * 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.triggers; + +import buildcraft.api.gates.ActionManager; +import buildcraft.api.gates.ITriggerParameter; +import buildcraft.core.inventory.InventoryIterator; +import buildcraft.core.inventory.InventoryIterator.IInvSlot; +import buildcraft.core.inventory.StackHelper; +import java.util.Locale; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; + +public class TriggerInventoryLevel extends BCTrigger { + + public enum TriggerType { + + BELOW_25, BELOW_50, BELOW_75 + }; + public TriggerType type; + + public TriggerInventoryLevel(TriggerType type) { + super(0, "buildcraft.inventorylevel." + type.name().toLowerCase(Locale.ENGLISH)); + this.type = type; + + // Legacy migration code + ActionManager.triggers.put("buildcraft.filteredBuffer." + type.name().toLowerCase(Locale.ENGLISH), this); + } + + @Override + public boolean hasParameter() { + return true; + } + + @Override + public String getDescription() { + switch (type) { + case BELOW_25: + return "Contains < 25%"; + case BELOW_50: + return "Contains < 50%"; + default: + return "Contains < 75%"; + } + } + + @Override + public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) { + // A parameter is required + if (parameter == null) + return false; + + if (tile instanceof IInventory) { + ItemStack searchStack = parameter.getItemStack(); + + int stackSpace = 0; + int foundItems = 0; + for (IInvSlot slot : InventoryIterator.getIterable((IInventory) tile, side)) { + if (slot.canPutStackInSlot(searchStack)) { + ItemStack stackInSlot = slot.getStackInSlot(); + if (stackInSlot == null || StackHelper.instance().canStacksMerge(stackInSlot, searchStack)) { + stackSpace++; + foundItems += stackInSlot == null ? 0 : stackInSlot.stackSize; + } + } + } + + if (stackSpace > 0) { + float percentage = (float) foundItems / ((float) stackSpace * (float) searchStack.getMaxStackSize()); + + switch (type) { + case BELOW_25: + return percentage < 0.25f; + case BELOW_50: + return percentage < 0.5f; + default: + return percentage < 0.75f; + } + } + + } + + return false; + } + + @Override + public int getIconIndex() { + switch (type) { + case BELOW_25: + return ActionTriggerIconProvider.Trigger_Inventory_Below25; + case BELOW_50: + return ActionTriggerIconProvider.Trigger_Inventory_Below50; + default: + return ActionTriggerIconProvider.Trigger_Inventory_Below75; + } + } +} diff --git a/common/buildcraft/transport/TileFilteredBuffer.java b/common/buildcraft/transport/TileFilteredBuffer.java index dbb8c0b5..3101a9a4 100644 --- a/common/buildcraft/transport/TileFilteredBuffer.java +++ b/common/buildcraft/transport/TileFilteredBuffer.java @@ -1,18 +1,14 @@ package buildcraft.transport; -import buildcraft.BuildCraftTransport; -import buildcraft.api.gates.IOverrideDefaultTriggers; -import buildcraft.api.gates.ITrigger; import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.SimpleInventory; -import java.util.LinkedList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class TileFilteredBuffer extends TileBuildCraft implements IInventory, IOverrideDefaultTriggers { +public class TileFilteredBuffer extends TileBuildCraft implements IInventory { private final SimpleInventory inventoryFilters = new SimpleInventory(9, "FilteredBufferFilters", 1); private final SimpleInventory inventoryStorage = new SimpleInventory(9, "FilteredBufferStorage", 64); @@ -93,17 +89,6 @@ public class TileFilteredBuffer extends TileBuildCraft implements IInventory, IO return false; } - @Override - public LinkedList getTriggers() { - LinkedList result = new LinkedList(); - - result.add(BuildCraftTransport.triggerInventoryBelow25); - result.add(BuildCraftTransport.triggerInventoryBelow50); - result.add(BuildCraftTransport.triggerInventoryBelow75); - - return result; - } - @Override public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java index 82091ef4..5a537b20 100644 --- a/common/buildcraft/transport/gui/GuiGateInterface.java +++ b/common/buildcraft/transport/gui/GuiGateInterface.java @@ -136,7 +136,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { public ItemStack getItemStack() { ITriggerParameter parameter = pipe.gate.getTriggerParameter(slot); if (parameter != null) - return parameter.getItem(); + return parameter.getItemStack(); else return null; } diff --git a/common/buildcraft/transport/triggers/TriggerFilteredBufferInventoryLevel.java b/common/buildcraft/transport/triggers/TriggerFilteredBufferInventoryLevel.java deleted file mode 100644 index 7cb69aa7..00000000 --- a/common/buildcraft/transport/triggers/TriggerFilteredBufferInventoryLevel.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in - * http://www.mod-buildcraft.com/MMPL-1.0.txt - */ -package buildcraft.transport.triggers; - -import buildcraft.api.gates.ITriggerParameter; -import buildcraft.core.triggers.ActionTriggerIconProvider; -import buildcraft.core.triggers.BCTrigger; -import buildcraft.transport.TileFilteredBuffer; -import java.util.Locale; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; - -public class TriggerFilteredBufferInventoryLevel extends BCTrigger { - - public enum State { - - Below25, Below50, Below75 - }; - public State state; - - public TriggerFilteredBufferInventoryLevel(int legacyId, State state) { - super(legacyId, "buildcraft.filteredBuffer." + state.name().toLowerCase(Locale.ENGLISH)); - - this.state = state; - } - - @Override - public boolean hasParameter() { - return true; - } - - @Override - public String getDescription() { - switch (state) { - case Below25: - return "Contains < 25%"; - case Below50: - return "Contains < 50%"; - default: - return "Contains < 75%"; - } - } - - @Override - public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) { - if (tile instanceof TileFilteredBuffer) { - - // A parameter is required - if (parameter == null) { - return false; - } - - TileFilteredBuffer filteredBuffer = (TileFilteredBuffer) tile; - ItemStack searchStack = parameter.getItem(); - - int foundStackCount = 0; - int foundItemCount = 0; - - IInventory filters = filteredBuffer.getFilters(); - - for (int i = 0; i < filters.getSizeInventory(); i++) { - ItemStack filterStack = filters.getStackInSlot(i); - - if (filterStack != null && filterStack.isItemEqual(searchStack)) { - ItemStack foundStack = filteredBuffer.getStackInSlot(i); - - if (foundStack != null) - foundItemCount += foundStack.stackSize; - - foundStackCount++; - } - } - - if (foundStackCount > 0) { - float percentage = (float) foundItemCount / ((float) foundStackCount * (float) searchStack.getMaxStackSize()); - - switch (state) { - case Below25: - return percentage < 0.25f; - case Below50: - return percentage < 0.5f; - default: - return percentage < 0.75f; - } - } - } - - return false; - } - - @Override - public int getIconIndex() { - switch (state) { - case Below25: - return ActionTriggerIconProvider.Trigger_Inventory_Below25; - case Below50: - return ActionTriggerIconProvider.Trigger_Inventory_Below50; - default: - return ActionTriggerIconProvider.Trigger_Inventory_Below75; - } - } -} diff --git a/common/buildcraft/transport/triggers/TriggerPipeContents.java b/common/buildcraft/transport/triggers/TriggerPipeContents.java index 1e8fa321..afa4d353 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeContents.java +++ b/common/buildcraft/transport/triggers/TriggerPipeContents.java @@ -90,10 +90,10 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe { if (kind == Kind.Empty) return transportItems.items.isEmpty(); else if (kind == Kind.ContainsItems) - if (parameter != null && parameter.getItem() != null) { + if (parameter != null && parameter.getItemStack()!= null) { for (TravelingItem item : transportItems.items) { - if (item.getItemStack().itemID == parameter.getItem().itemID - && item.getItemStack().getItemDamage() == parameter.getItem().getItemDamage()) + if (item.getItemStack().itemID == parameter.getItemStack().itemID + && item.getItemStack().getItemDamage() == parameter.getItemStack().getItemDamage()) return true; } } else @@ -103,8 +103,8 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe { FluidStack searchedFluid = null; - if (parameter != null && parameter.getItem() != null) { - searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItem()); + if (parameter != null && parameter.getItemStack() != null) { + searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack()); } if (kind == Kind.Empty) { From d7739cc8cbccee50c0322f5c3fd9a68cb34e959f Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 25 Oct 2013 18:11:10 -0700 Subject: [PATCH 104/121] Triggers can now require a parameter.. ...and will not be show on gates that don't support parameters. Also moved logger to own class and added a API error function. --- common/buildcraft/BuildCraftCore.java | 8 +- .../buildcraft/api/gates/ActionManager.java | 25 ++++--- common/buildcraft/api/gates/ITrigger.java | 5 ++ common/buildcraft/core/EntityRobot.java | 4 +- common/buildcraft/core/Version.java | 17 +++-- .../buildcraft/core/blueprints/BptBase.java | 3 +- .../core/blueprints/BptBlueprint.java | 4 +- .../core/blueprints/BptBuilderBlueprint.java | 16 ++-- .../buildcraft/core/blueprints/BptError.java | 4 +- .../buildcraft/core/triggers/BCTrigger.java | 5 ++ .../core/triggers/TriggerInventoryLevel.java | 7 +- common/buildcraft/core/utils/BCLog.java | 45 +++++++++++ common/buildcraft/core/utils/ConfigUtils.java | 6 +- .../factory/FactoryProxyClient.java | 6 +- .../transport/BlockGenericPipe.java | 6 +- common/buildcraft/transport/GuiHandler.java | 6 +- common/buildcraft/transport/ItemPipe.java | 4 +- .../transport/PipeTransportItems.java | 6 +- .../buildcraft/transport/TileGenericPipe.java | 5 +- .../transport/gui/ContainerGateInterface.java | 74 ++++++++++++------- 20 files changed, 169 insertions(+), 87 deletions(-) create mode 100644 common/buildcraft/core/utils/BCLog.java diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index c85ef338..e79a6af5 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -63,6 +63,7 @@ import buildcraft.core.triggers.TriggerFluidContainer; import buildcraft.core.triggers.TriggerInventory; import buildcraft.core.triggers.TriggerInventoryLevel; import buildcraft.core.triggers.TriggerMachine; +import buildcraft.core.utils.BCLog; import buildcraft.core.utils.Localization; import buildcraft.transport.triggers.TriggerRedstoneInput; import cpw.mods.fml.common.FMLLog; @@ -165,18 +166,13 @@ public class BuildCraftCore { public static BptItem[] itemBptProps = new BptItem[Item.itemsList.length]; - public static final Logger bcLog = Logger.getLogger("Buildcraft"); - @Instance("BuildCraft|Core") public static BuildCraftCore instance; @EventHandler public void loadConfiguration(FMLPreInitializationEvent evt) { - bcLog.setParent(FMLLog.getLogger()); - bcLog.info("Starting BuildCraft " + Version.getVersion()); - bcLog.info("Copyright (c) SpaceToad, 2011"); - bcLog.info("http://www.mod-buildcraft.com"); + BCLog.initLog(); mainConfiguration = new BuildCraftConfiguration(new File(evt.getModConfigurationDirectory(), "buildcraft/main.conf")); try { diff --git a/common/buildcraft/api/gates/ActionManager.java b/common/buildcraft/api/gates/ActionManager.java index 26cfd2c7..919874e7 100644 --- a/common/buildcraft/api/gates/ActionManager.java +++ b/common/buildcraft/api/gates/ActionManager.java @@ -19,12 +19,12 @@ public class ActionManager { triggerProviders.add(provider); } } - - public static void registerTrigger(ITrigger trigger){ + + public static void registerTrigger(ITrigger trigger) { triggers.put(trigger.getUniqueTag(), trigger); } - - public static void registerAction(IAction action){ + + public static void registerAction(IAction action) { actions.put(action.getUniqueTag(), action); } @@ -52,6 +52,7 @@ public class ActionManager { } } + //TODO: Use sets not lists public static LinkedList getNeighborActions(Block block, TileEntity entity) { LinkedList actions = new LinkedList(); @@ -87,18 +88,18 @@ public class ActionManager { return triggers; } - - public static ITrigger getTriggerFromLegacyId(int legacyId){ - for(ITrigger trigger : triggers.values()){ - if(trigger.getLegacyId() == legacyId) + + public static ITrigger getTriggerFromLegacyId(int legacyId) { + for (ITrigger trigger : triggers.values()) { + if (trigger.getLegacyId() == legacyId) return trigger; } return null; } - - public static IAction getActionFromLegacyId(int legacyId){ - for(IAction action : actions.values()){ - if(action.getLegacyId() == legacyId) + + public static IAction getActionFromLegacyId(int legacyId) { + for (IAction action : actions.values()) { + if (action.getLegacyId() == legacyId) return action; } return null; diff --git a/common/buildcraft/api/gates/ITrigger.java b/common/buildcraft/api/gates/ITrigger.java index ab59616b..64851f56 100644 --- a/common/buildcraft/api/gates/ITrigger.java +++ b/common/buildcraft/api/gates/ITrigger.java @@ -28,6 +28,11 @@ public interface ITrigger { */ boolean hasParameter(); + /** + * Return true if this trigger requires a parameter + */ + boolean requiresParameter(); + /** * Return the trigger description in the UI */ diff --git a/common/buildcraft/core/EntityRobot.java b/common/buildcraft/core/EntityRobot.java index 6a460050..9e5bb507 100644 --- a/common/buildcraft/core/EntityRobot.java +++ b/common/buildcraft/core/EntityRobot.java @@ -16,7 +16,6 @@ import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import buildcraft.BuildCraftCore; import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.core.Position; import buildcraft.core.blueprints.BptBuilderBase; @@ -24,6 +23,7 @@ import buildcraft.core.blueprints.BptContext; import buildcraft.core.blueprints.BptSlot; import buildcraft.core.blueprints.BptSlot.Mode; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BlockUtil; import com.google.common.io.ByteArrayDataInput; @@ -230,7 +230,7 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData { } catch (Throwable t) { // Defensive code against errors in implementers t.printStackTrace(); - BuildCraftCore.bcLog.throwing("EntityRobot", "update", t); + BCLog.logger.throwing("EntityRobot", "update", t); } } } diff --git a/common/buildcraft/core/Version.java b/common/buildcraft/core/Version.java index 7b72babc..2a32bb95 100644 --- a/common/buildcraft/core/Version.java +++ b/common/buildcraft/core/Version.java @@ -2,6 +2,7 @@ package buildcraft.core; import buildcraft.BuildCraftCore; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.BCLog; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; @@ -92,7 +93,7 @@ public class Version implements Runnable { recommendedVersion = tokens[2]; if (line.endsWith(VERSION)) { - BuildCraftCore.bcLog.finer("Using the latest version [" + getVersion() + "] for Minecraft " + mcVersion); + BCLog.logger.finer("Using the latest version [" + getVersion() + "] for Minecraft " + mcVersion); currentVersion = EnumUpdateState.CURRENT; return; } @@ -100,15 +101,15 @@ public class Version implements Runnable { } } - BuildCraftCore.bcLog.warning("Using outdated version [" + VERSION + " (build:" + BUILD_NUMBER + ")] for Minecraft " + mcVersion + BCLog.logger.warning("Using outdated version [" + VERSION + " (build:" + BUILD_NUMBER + ")] for Minecraft " + mcVersion + ". Consider updating."); currentVersion = EnumUpdateState.OUTDATED; conn.disconnect(); reader.close(); } catch (Exception e) { - BuildCraftCore.bcLog.warning("Unable to read from remote version authority."); - BuildCraftCore.bcLog.warning(e.toString()); + BCLog.logger.warning("Unable to read from remote version authority."); + BCLog.logger.warning(e.toString()); currentVersion = EnumUpdateState.CONNECTION_ERROR; } } @@ -163,7 +164,7 @@ public class Version implements Runnable { } catch (Exception ex) { ex.printStackTrace(); - BuildCraftCore.bcLog.warning("Unable to read changelog from remote site."); + BCLog.logger.warning("Unable to read changelog from remote site."); } return new String[]{String.format("Unable to retrieve changelog for %s %s", DefaultProps.MOD, version)}; @@ -175,7 +176,7 @@ public class Version implements Runnable { int count = 0; currentVersion = null; - BuildCraftCore.bcLog.info("Beginning version check"); + BCLog.logger.info("Beginning version check"); try { while ((count < 3) && ((currentVersion == null) || (currentVersion == EnumUpdateState.CONNECTION_ERROR))) { @@ -183,7 +184,7 @@ public class Version implements Runnable { count++; if (currentVersion == EnumUpdateState.CONNECTION_ERROR) { - BuildCraftCore.bcLog.info("Version check attempt " + count + " failed, trying again in 10 seconds"); + BCLog.logger.info("Version check attempt " + count + " failed, trying again in 10 seconds"); Thread.sleep(10000); } } @@ -192,7 +193,7 @@ public class Version implements Runnable { } if (currentVersion == EnumUpdateState.CONNECTION_ERROR) { - BuildCraftCore.bcLog.info("Version check failed"); + BCLog.logger.info("Version check failed"); } } diff --git a/common/buildcraft/core/blueprints/BptBase.java b/common/buildcraft/core/blueprints/BptBase.java index 0f578278..819419d8 100644 --- a/common/buildcraft/core/blueprints/BptBase.java +++ b/common/buildcraft/core/blueprints/BptBase.java @@ -13,6 +13,7 @@ import buildcraft.BuildCraftCore; import buildcraft.core.Box; import buildcraft.core.Version; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.BCLog; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -81,7 +82,7 @@ public abstract class BptBase { } catch (Throwable t) { // Defensive code against errors in implementers t.printStackTrace(); - BuildCraftCore.bcLog.throwing("BptBase", "rotateLeft", t); + BCLog.logger.throwing("BptBase", "rotateLeft", t); } } } diff --git a/common/buildcraft/core/blueprints/BptBlueprint.java b/common/buildcraft/core/blueprints/BptBlueprint.java index e52aeeac..16cb545c 100644 --- a/common/buildcraft/core/blueprints/BptBlueprint.java +++ b/common/buildcraft/core/blueprints/BptBlueprint.java @@ -9,7 +9,6 @@ package buildcraft.core.blueprints; -import buildcraft.BuildCraftCore; import buildcraft.api.blueprints.BlockSignature; import buildcraft.api.blueprints.BlueprintManager; import buildcraft.api.blueprints.BptBlock; @@ -17,6 +16,7 @@ import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.ItemSignature; import buildcraft.core.IBptContributor; +import buildcraft.core.utils.BCLog; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; @@ -76,7 +76,7 @@ public class BptBlueprint extends BptBase { } catch (Throwable t) { // Defensive code against errors in implementers t.printStackTrace(); - BuildCraftCore.bcLog.throwing("BptBlueprint", "readFromWorld", t); + BCLog.logger.throwing("BptBlueprint", "readFromWorld", t); } } diff --git a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java index 9b888f5a..7ba5c0e3 100644 --- a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java +++ b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java @@ -9,9 +9,9 @@ package buildcraft.core.blueprints; -import buildcraft.BuildCraftCore; import buildcraft.core.IBuilderInventory; import buildcraft.core.blueprints.BptSlot.Mode; +import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BlockUtil; import java.util.Comparator; import java.util.LinkedList; @@ -186,7 +186,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { } catch (Throwable t) { // Defensive code against errors in implementers t.printStackTrace(); - BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "internalGetBlock", t); + BCLog.logger.throwing("BptBuilderBlueprint", "internalGetBlock", t); getNext = false; } @@ -232,7 +232,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { } catch (Throwable t) { // Defensive code against errors in implementers t.printStackTrace(); - BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "checkRequirements", t); + BCLog.logger.throwing("BptBuilderBlueprint", "checkRequirements", t); } int size = inv.getSizeInventory(); @@ -260,7 +260,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { } catch (Throwable t) { // Defensive code against errors in implementers t.printStackTrace(); - BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "checkRequirements", t); + BCLog.logger.throwing("BptBuilderBlueprint", "checkRequirements", t); } if (reqStk.stackSize == 0) { @@ -290,7 +290,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { } catch (Throwable t) { // Defensive code against errors in implementers t.printStackTrace(); - BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "useRequirements", t); + BCLog.logger.throwing("BptBuilderBlueprint", "useRequirements", t); } @@ -319,7 +319,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { } catch (Throwable t) { // Defensive code against errors in implementers t.printStackTrace(); - BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "useRequirements", t); + BCLog.logger.throwing("BptBuilderBlueprint", "useRequirements", t); } if (invStk.stackSize == 0) { @@ -373,7 +373,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { } catch (Throwable t) { // Defensive code against errors in implementers t.printStackTrace(); - BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "recomputeIfNeeded", t); + BCLog.logger.throwing("BptBuilderBlueprint", "recomputeIfNeeded", t); } for (ItemStack stack : stacks) { @@ -429,7 +429,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { } catch (Throwable t) { // Defensive code against errors in implementers t.printStackTrace(); - BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "postProcessing", t); + BCLog.logger.throwing("BptBuilderBlueprint", "postProcessing", t); } } } diff --git a/common/buildcraft/core/blueprints/BptError.java b/common/buildcraft/core/blueprints/BptError.java index 91492698..7a4fa0a5 100644 --- a/common/buildcraft/core/blueprints/BptError.java +++ b/common/buildcraft/core/blueprints/BptError.java @@ -9,7 +9,7 @@ package buildcraft.core.blueprints; -import buildcraft.BuildCraftCore; +import buildcraft.core.utils.BCLog; public class BptError extends Exception { @@ -21,7 +21,7 @@ public class BptError extends Exception { public BptError(String str) { super(str); - BuildCraftCore.bcLog.fine("BLUEPRINT ERROR:" + str); + BCLog.logger.fine("BLUEPRINT ERROR:" + str); } diff --git a/common/buildcraft/core/triggers/BCTrigger.java b/common/buildcraft/core/triggers/BCTrigger.java index ecaec208..e94aaeba 100644 --- a/common/buildcraft/core/triggers/BCTrigger.java +++ b/common/buildcraft/core/triggers/BCTrigger.java @@ -64,6 +64,11 @@ public abstract class BCTrigger implements ITrigger { return false; } + @Override + public boolean requiresParameter() { + return false; + } + @Override public String getDescription() { return ""; diff --git a/common/buildcraft/core/triggers/TriggerInventoryLevel.java b/common/buildcraft/core/triggers/TriggerInventoryLevel.java index fa1432fa..9dc2560d 100644 --- a/common/buildcraft/core/triggers/TriggerInventoryLevel.java +++ b/common/buildcraft/core/triggers/TriggerInventoryLevel.java @@ -29,7 +29,7 @@ public class TriggerInventoryLevel extends BCTrigger { public TriggerInventoryLevel(TriggerType type) { super(0, "buildcraft.inventorylevel." + type.name().toLowerCase(Locale.ENGLISH)); this.type = type; - + // Legacy migration code ActionManager.triggers.put("buildcraft.filteredBuffer." + type.name().toLowerCase(Locale.ENGLISH), this); } @@ -39,6 +39,11 @@ public class TriggerInventoryLevel extends BCTrigger { return true; } + @Override + public boolean requiresParameter() { + return true; + } + @Override public String getDescription() { switch (type) { diff --git a/common/buildcraft/core/utils/BCLog.java b/common/buildcraft/core/utils/BCLog.java new file mode 100644 index 00000000..e987345e --- /dev/null +++ b/common/buildcraft/core/utils/BCLog.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) SpaceToad, 2011-2012 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.utils; + +import buildcraft.core.Version; +import cpw.mods.fml.common.FMLLog; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author CovertJaguar + */ +public class BCLog { + + public static final Logger logger = Logger.getLogger("Buildcraft"); + + public static void initLog() { + logger.setParent(FMLLog.getLogger()); + logger.info("Starting BuildCraft " + Version.getVersion()); + logger.info("Copyright (c) SpaceToad, 2011"); + logger.info("http://www.mod-buildcraft.com"); + } + + public static void logErrorAPI(String mod, Throwable error, Class classFile) { + StringBuilder msg = new StringBuilder(mod); + msg.append(" API error, please update your mods. Error: ").append(error); + StackTraceElement[] stackTrace = error.getStackTrace(); + if (stackTrace.length > 0) + msg.append(", ").append(stackTrace[0]); + logger.log(Level.SEVERE, msg.toString()); + + if (classFile != null) { + msg = new StringBuilder(mod); + msg.append(" API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain().getCodeSource().getLocation()); + logger.log(Level.SEVERE, msg.toString()); + } + } +} diff --git a/common/buildcraft/core/utils/ConfigUtils.java b/common/buildcraft/core/utils/ConfigUtils.java index df4cfde7..cb439f66 100644 --- a/common/buildcraft/core/utils/ConfigUtils.java +++ b/common/buildcraft/core/utils/ConfigUtils.java @@ -80,7 +80,7 @@ public class ConfigUtils { try { parsed = Boolean.parseBoolean(value); } catch (NumberFormatException ex) { - BuildCraftCore.bcLog.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex); + BCLog.logger.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex); prop.set(defaultValue); return defaultValue; } @@ -93,7 +93,7 @@ public class ConfigUtils { try { parsed = Integer.parseInt(value); } catch (NumberFormatException ex) { - BuildCraftCore.bcLog.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex); + BCLog.logger.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex); prop.set(defaultValue); return defaultValue; } @@ -106,7 +106,7 @@ public class ConfigUtils { try { parsed = Double.parseDouble(value); } catch (NumberFormatException ex) { - BuildCraftCore.bcLog.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex); + BCLog.logger.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex); prop.set(defaultValue); return defaultValue; } diff --git a/common/buildcraft/factory/FactoryProxyClient.java b/common/buildcraft/factory/FactoryProxyClient.java index 11ef2cd8..a988c1f5 100644 --- a/common/buildcraft/factory/FactoryProxyClient.java +++ b/common/buildcraft/factory/FactoryProxyClient.java @@ -1,11 +1,11 @@ package buildcraft.factory; -import buildcraft.BuildCraftCore; import buildcraft.BuildCraftFactory; import buildcraft.core.EntityBlock; import buildcraft.core.render.RenderVoid; import buildcraft.core.render.RenderingEntityBlocks; import buildcraft.core.render.RenderingEntityBlocks.EntityRenderIndex; +import buildcraft.core.utils.BCLog; import buildcraft.factory.gui.GuiAutoCrafting; import buildcraft.factory.render.RenderHopper; import buildcraft.factory.render.RenderRefinery; @@ -53,9 +53,9 @@ public class FactoryProxyClient extends FactoryProxy { Class neiRenderer = Class.forName("codechicken.nei.DefaultOverlayRenderer"); Method method = neiRenderer.getMethod("registerGuiOverlay", Class.class, String.class, int.class, int.class); method.invoke(null, GuiAutoCrafting.class, "crafting", 5, 11); - BuildCraftCore.bcLog.fine("NEI detected, adding NEI overlay"); + BCLog.logger.fine("NEI detected, adding NEI overlay"); } catch (Exception e) { - BuildCraftCore.bcLog.fine("NEI not detected."); + BCLog.logger.fine("NEI not detected."); } } diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index ce9c638d..6ed8dc32 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -34,7 +34,6 @@ import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; -import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.tools.IToolWrench; import buildcraft.api.transport.IPipe; @@ -42,6 +41,7 @@ import buildcraft.api.transport.ISolidSideTile; import buildcraft.core.BlockIndex; import buildcraft.core.CoreConstants; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.BCLog; import buildcraft.core.utils.Utils; import buildcraft.core.utils.MatrixTranformations; import cpw.mods.fml.common.registry.GameRegistry; @@ -1001,11 +1001,11 @@ public class BlockGenericPipe extends BlockContainer { if (pipe != null) return pipe.getConstructor(int.class).newInstance(key); else { - BuildCraftCore.bcLog.warning("Detected pipe with unknown key (" + key + "). Did you remove a buildcraft addon?"); + BCLog.logger.warning("Detected pipe with unknown key (" + key + "). Did you remove a buildcraft addon?"); } } catch (Throwable t) { - BuildCraftCore.bcLog.warning("Failed to create pipe with (" + key + "). No valid constructor found. Possibly a item ID conflit."); + BCLog.logger.warning("Failed to create pipe with (" + key + "). No valid constructor found. Possibly a item ID conflit."); } return null; diff --git a/common/buildcraft/transport/GuiHandler.java b/common/buildcraft/transport/GuiHandler.java index 767dcd34..a268a9a6 100644 --- a/common/buildcraft/transport/GuiHandler.java +++ b/common/buildcraft/transport/GuiHandler.java @@ -1,7 +1,7 @@ package buildcraft.transport; -import buildcraft.BuildCraftCore; import buildcraft.core.GuiIds; +import buildcraft.core.utils.BCLog; import buildcraft.transport.gui.ContainerDiamondPipe; import buildcraft.transport.gui.ContainerEmeraldPipe; import buildcraft.transport.gui.ContainerFilteredBuffer; @@ -55,7 +55,7 @@ public class GuiHandler implements IGuiHandler { return null; } } catch (Exception ex) { - BuildCraftCore.bcLog.log(Level.SEVERE, "Failed to open GUI", ex); + BCLog.logger.log(Level.SEVERE, "Failed to open GUI", ex); } return null; } @@ -95,7 +95,7 @@ public class GuiHandler implements IGuiHandler { return null; } } catch (Exception ex) { - BuildCraftCore.bcLog.log(Level.SEVERE, "Failed to open GUI", ex); + BCLog.logger.log(Level.SEVERE, "Failed to open GUI", ex); } return null; } diff --git a/common/buildcraft/transport/ItemPipe.java b/common/buildcraft/transport/ItemPipe.java index c286c6ef..13893649 100644 --- a/common/buildcraft/transport/ItemPipe.java +++ b/common/buildcraft/transport/ItemPipe.java @@ -7,11 +7,11 @@ */ package buildcraft.transport; -import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.core.IItemPipe; import buildcraft.core.ItemBuildCraft; +import buildcraft.core.utils.BCLog; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; @@ -70,7 +70,7 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { Pipe pipe = BlockGenericPipe.createPipe(itemID); if (pipe == null) { - BuildCraftCore.bcLog.log(Level.WARNING, "Pipe failed to create during placement at {0},{1},{2}", new Object[]{i, j, k}); + BCLog.logger.log(Level.WARNING, "Pipe failed to create during placement at {0},{1},{2}", new Object[]{i, j, k}); return true; } if (BlockGenericPipe.placePipe(pipe, world, i, j, k, blockID, 0)) { diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index c16b9d48..13254ab4 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -7,7 +7,6 @@ */ package buildcraft.transport; -import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.Position; import buildcraft.api.gates.ITrigger; @@ -18,6 +17,7 @@ import buildcraft.core.IMachine; import buildcraft.core.inventory.Transactor; import buildcraft.core.network.PacketIds; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BlockUtil; import buildcraft.transport.network.PacketPipeTransportContent; import buildcraft.transport.network.PacketPipeTransportNBT; @@ -196,7 +196,7 @@ public class PipeTransportItems extends PipeTransport { } if (items.size() > MAX_PIPE_STACKS) { - BuildCraftCore.bcLog.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many stacks: %d", container.xCoord, container.yCoord, container.zCoord, items.size())); + BCLog.logger.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many stacks: %d", container.xCoord, container.yCoord, container.zCoord, items.size())); destroyPipe(); return; } @@ -209,7 +209,7 @@ public class PipeTransportItems extends PipeTransport { } if (numItems > MAX_PIPE_ITEMS) { - BuildCraftCore.bcLog.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many items: %d", container.xCoord, container.yCoord, container.zCoord, numItems)); + BCLog.logger.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many items: %d", container.xCoord, container.yCoord, container.zCoord, numItems)); destroyPipe(); } } diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 429bab14..9b02066c 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -48,6 +48,7 @@ import buildcraft.core.network.IClientState; import buildcraft.core.network.IGuiReturnHandler; import buildcraft.core.network.ISyncedTile; import buildcraft.core.network.PacketTileState; +import buildcraft.core.utils.BCLog; import buildcraft.transport.Gate.GateKind; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -120,7 +121,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui if (pipe != null) pipe.readFromNBT(nbt); else { - BuildCraftCore.bcLog.log(Level.WARNING, "Pipe failed to load from NBT at {0},{1},{2}", new Object[]{xCoord, yCoord, zCoord}); + BCLog.logger.log(Level.WARNING, "Pipe failed to load from NBT at {0},{1},{2}", new Object[]{xCoord, yCoord, zCoord}); deletePipe = true; } @@ -267,7 +268,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui this.blockType = getBlockType(); if (pipe == null) { - BuildCraftCore.bcLog.log(Level.WARNING, "Pipe failed to initialize at {0},{1},{2}, deleting", new Object[]{xCoord, yCoord, zCoord}); + BCLog.logger.log(Level.WARNING, "Pipe failed to initialize at {0},{1},{2}, deleting", new Object[]{xCoord, yCoord, zCoord}); worldObj.setBlockToAir(xCoord, yCoord, zCoord); return; } diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java index e728e2e8..5e57c676 100644 --- a/common/buildcraft/transport/gui/ContainerGateInterface.java +++ b/common/buildcraft/transport/gui/ContainerGateInterface.java @@ -7,7 +7,6 @@ */ package buildcraft.transport.gui; -import buildcraft.api.core.Position; import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IOverrideDefaultTriggers; @@ -21,9 +20,13 @@ import buildcraft.core.network.PacketPayload; import buildcraft.core.network.PacketPayloadArrays; import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.BCLog; +import buildcraft.transport.Gate; import buildcraft.transport.Pipe; +import java.util.Comparator; import java.util.Iterator; -import java.util.LinkedList; +import java.util.NavigableSet; +import java.util.TreeSet; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ICrafting; @@ -38,8 +41,18 @@ public class ContainerGateInterface extends BuildCraftContainer { IInventory playerIInventory; Pipe pipe; - private final LinkedList _potentialTriggers = new LinkedList(); - private final LinkedList _potentialActions = new LinkedList(); + private final NavigableSet _potentialTriggers = new TreeSet(new Comparator() { + @Override + public int compare(ITrigger o1, ITrigger o2) { + return o1.getUniqueTag().compareTo(o2.getUniqueTag()); + } + }); + private final NavigableSet _potentialActions = new TreeSet(new Comparator() { + @Override + public int compare(IAction o1, IAction o2) { + return o1.getUniqueTag().compareTo(o2.getUniqueTag()); + } + }); private boolean isSynchronized = false; private boolean isNetInitialized = false; public boolean[] triggerState = new boolean[8]; @@ -75,20 +88,19 @@ public class ContainerGateInterface extends BuildCraftContainer { TileEntity tile = pipe.container.getTile(o); int blockID = pipe.container.getBlockId(o); Block block = Block.blocksList[blockID]; + _potentialTriggers.addAll(ActionManager.getNeighborTriggers(block, tile)); + _potentialActions.addAll(ActionManager.getNeighborActions(block, tile)); + } - LinkedList nearbyTriggers = ActionManager.getNeighborTriggers(block, tile); - - for (ITrigger t : nearbyTriggers) { - if (!_potentialTriggers.contains(t)) { - _potentialTriggers.add(t); - } - } - - LinkedList nearbyActions = ActionManager.getNeighborActions(block, tile); - - for (IAction a : nearbyActions) { - if (!_potentialActions.contains(a)) { - _potentialActions.add(a); + if (getGateOrdinal() < Gate.GateKind.AND_3.ordinal()) { + Iterator it = _potentialTriggers.iterator(); + while (it.hasNext()) { + ITrigger trigger = it.next(); + try { + if (trigger.requiresParameter()) + it.remove(); + } catch (Throwable error) { + BCLog.logErrorAPI("Buildcraft", error, trigger.getClass()); } } } @@ -269,8 +281,9 @@ public class ContainerGateInterface extends BuildCraftContainer { PacketPayloadArrays payload = new PacketPayloadArrays(1, 0, length); payload.intPayload[0] = length; - for (int i = 0; i < length; i++) { - payload.stringPayload[i] = _potentialActions.get(i).getUniqueTag(); + int i = 0; + for (IAction action : _potentialActions) { + payload.stringPayload[i++] = action.getUniqueTag(); } PacketUpdate packet = new PacketUpdate(PacketIds.GATE_ACTIONS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload); @@ -291,8 +304,9 @@ public class ContainerGateInterface extends BuildCraftContainer { PacketPayloadArrays payload = new PacketPayloadArrays(1, 0, length); payload.intPayload[0] = length; - for (int i = 0; i < length; i++) { - payload.stringPayload[i] = _potentialTriggers.get(i).getUniqueTag(); + int i = 0; + for (ITrigger trigger : _potentialTriggers) { + payload.stringPayload[i++] = trigger.getUniqueTag(); } PacketUpdate packet = new PacketUpdate(PacketIds.GATE_TRIGGERS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload); @@ -344,11 +358,15 @@ public class ContainerGateInterface extends BuildCraftContainer { } public ITrigger getFirstTrigger() { - return _potentialTriggers.size() > 0 ? _potentialTriggers.getFirst() : null; + if (_potentialTriggers.isEmpty()) + return null; + return _potentialTriggers.first(); } public ITrigger getLastTrigger() { - return _potentialTriggers.size() > 0 ? _potentialTriggers.getLast() : null; + if (_potentialTriggers.isEmpty()) + return null; + return _potentialTriggers.last(); } public Iterator getTriggerIterator(boolean descending) { @@ -381,11 +399,15 @@ public class ContainerGateInterface extends BuildCraftContainer { } public IAction getFirstAction() { - return _potentialActions.peekFirst(); + if (_potentialActions.isEmpty()) + return null; + return _potentialActions.first(); } public IAction getLastAction() { - return _potentialActions.peekLast(); + if (_potentialActions.isEmpty()) + return null; + return _potentialActions.last(); } public Iterator getActionIterator(boolean descending) { @@ -406,7 +428,7 @@ public class ContainerGateInterface extends BuildCraftContainer { return pipe.gate.getGuiFile(); } - public int getGateOrdinal() { + public final int getGateOrdinal() { return pipe.gate.kind.ordinal(); } From c4d60c9230c982c096ea36e7bb45be314f3d84b7 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 25 Oct 2013 18:14:58 -0700 Subject: [PATCH 105/121] Add tab localization Closes #1298 --- buildcraft_resources/lang/buildcraft/en_US.properties | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index 8c9358f8..4512f796 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -96,6 +96,10 @@ item.PipeItemsSandstone=Sandstone Transport Pipe item.PipeFluidsSandstone=Sandstone Fluid Pipe item.Facade=Facade item.PipePlug=Pipe Plug + +tab.machines=Buildcraft Machines +tab.facades=Buildcraft Facades + tile.miningWellBlock=Mining Well tile.plainPipeBlock=Mining Pipe tile.autoWorkbenchBlock=Auto Workbench From 9074f10c1de2c3b78d1543bcf47bb3e09786a10c Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 26 Oct 2013 03:03:19 -0700 Subject: [PATCH 106/121] Register chipsets with FML --- common/buildcraft/BuildCraftSilicon.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 3d1a2433..5f763a41 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -32,6 +32,7 @@ import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -70,6 +71,7 @@ public class BuildCraftSilicon { redstoneChipset = new ItemRedstoneChipset(redstoneChipsetId.getInt()); redstoneChipset.setUnlocalizedName("redstoneChipset"); + CoreProxy.proxy.registerItem(redstoneChipset); } From bdf93e12ba4f64ef738a2641fc24f9262ced5ffd Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 26 Oct 2013 03:14:23 -0700 Subject: [PATCH 107/121] Register chipset stacks with FML for good measure --- common/buildcraft/BuildCraftSilicon.java | 5 ++- .../buildcraft/core/ItemRedstoneChipset.java | 32 +++++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 5f763a41..b15a4200 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -32,7 +32,6 @@ import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -43,7 +42,7 @@ import net.minecraftforge.common.Property; @NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerSilicon.class, clientSideRequired = true, serverSideRequired = true) public class BuildCraftSilicon { - public static Item redstoneChipset; + public static ItemRedstoneChipset redstoneChipset; public static BlockLaser laserBlock; public static BlockLaserTable assemblyTableBlock; @Instance("BuildCraft|Silicon") @@ -72,7 +71,7 @@ public class BuildCraftSilicon { redstoneChipset = new ItemRedstoneChipset(redstoneChipsetId.getInt()); redstoneChipset.setUnlocalizedName("redstoneChipset"); CoreProxy.proxy.registerItem(redstoneChipset); - + redstoneChipset.registerItemStacks(); } @EventHandler diff --git a/common/buildcraft/core/ItemRedstoneChipset.java b/common/buildcraft/core/ItemRedstoneChipset.java index ff3bd7e5..73f706bf 100644 --- a/common/buildcraft/core/ItemRedstoneChipset.java +++ b/common/buildcraft/core/ItemRedstoneChipset.java @@ -1,5 +1,6 @@ package buildcraft.core; +import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; @@ -10,8 +11,8 @@ import net.minecraft.util.Icon; public class ItemRedstoneChipset extends ItemBuildCraft { - @SideOnly(Side.CLIENT) - private Icon[] icons; + @SideOnly(Side.CLIENT) + private Icon[] icons; public ItemRedstoneChipset(int i) { super(i); @@ -20,10 +21,10 @@ public class ItemRedstoneChipset extends ItemBuildCraft { setMaxDamage(0); } - @SuppressWarnings({ "all" }) + @SuppressWarnings({"all"}) @Override public Icon getIconFromDamage(int i) { - return i < icons.length ? icons[i] : null; + return i < icons.length ? icons[i] : null; } @Override @@ -31,7 +32,7 @@ public class ItemRedstoneChipset extends ItemBuildCraft { return (new StringBuilder()).append(super.getUnlocalizedName()).append(".").append(itemstack.getItemDamage()).toString(); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override @SideOnly(Side.CLIENT) public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List itemList) { @@ -39,16 +40,21 @@ public class ItemRedstoneChipset extends ItemBuildCraft { itemList.add(new ItemStack(this, 1, i)); } } + private static String[] chipsetNames = {"redstone_red", "redstone_iron", "redstone_gold", "redstone_diamond", "redstone_pulsating"}; - private static String[] chipsetNames = { "redstone_red", "redstone_iron", "redstone_gold", "redstone_diamond", "redstone_pulsating" }; @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) - { - icons = new Icon[chipsetNames.length]; - int i = 0; - for (String csName : chipsetNames) { - icons[i++] = par1IconRegister.registerIcon("buildcraft:"+csName+"_chipset"); - } + public void registerIcons(IconRegister par1IconRegister) { + icons = new Icon[chipsetNames.length]; + int i = 0; + for (String csName : chipsetNames) { + icons[i++] = par1IconRegister.registerIcon("buildcraft:" + csName + "_chipset"); + } + } + + public void registerItemStacks() { + for (int i = 0; i < 5; i++) { + GameRegistry.registerCustomItemStack(chipsetNames[i] + "_chipset", new ItemStack(this, 1, i)); + } } } From 36da365ccb87c010d0712acd7e78536c768d6aec Mon Sep 17 00:00:00 2001 From: Player Date: Sun, 27 Oct 2013 12:14:14 +0100 Subject: [PATCH 108/121] pipes: improve render performance --- .../transport/BlockGenericPipe.java | 46 +++--- .../transport/render/PipeRendererWorld.java | 152 ++++++------------ .../transport/utils/ConnectionMatrix.java | 32 ++-- 3 files changed, 85 insertions(+), 145 deletions(-) diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 6ed8dc32..5ea3ff42 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -81,7 +81,7 @@ public class BlockGenericPipe extends BlockContainer { private static final ForgeDirection[] DIR_VALUES = ForgeDirection.values(); private static Random rand = new Random(); private boolean skippedFirstIconRegister; - private boolean[] renderSide = new boolean[6]; + private int renderMask = 0; /* Defined subprograms ************************************************* */ public BlockGenericPipe(int i) { @@ -114,34 +114,26 @@ public class BlockGenericPipe extends BlockContainer { return false; } - public void setRenderAxis(char axis) { - Arrays.fill(renderSide, false); - if (axis == 'x') { - renderSide[4] = true; - renderSide[5] = true; - } - if (axis == 'y') { - renderSide[0] = true; - renderSide[1] = true; - } - if (axis == 'z') { - renderSide[2] = true; - renderSide[3] = true; - } + public void setRenderMask(int mask) { + renderMask = mask; } public final void setRenderAllSides() { - Arrays.fill(renderSide, true); + renderMask = 0x3f; } public void setRenderSide(ForgeDirection side, boolean render) { - renderSide[side.ordinal()] = render; + if (render) { + renderMask |= 1 << side.ordinal(); + } else { + renderMask &= ~(1 << side.ordinal()); + } } @Override @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side) { - return renderSide[side]; + return (renderMask & (1 << side)) != 0; } @Override @@ -1100,27 +1092,27 @@ public class BlockGenericPipe extends BlockContainer { double pz = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (b * 2.0F)) + b + block.getBlockBoundsMinZ(); if (sideHit == 0) { - py = (double) y + block.getBlockBoundsMinY() - (double) b; + py = y + block.getBlockBoundsMinY() - b; } if (sideHit == 1) { - py = (double) y + block.getBlockBoundsMaxY() + (double) b; + py = y + block.getBlockBoundsMaxY() + b; } if (sideHit == 2) { - pz = (double) z + block.getBlockBoundsMinZ() - (double) b; + pz = z + block.getBlockBoundsMinZ() - b; } if (sideHit == 3) { - pz = (double) z + block.getBlockBoundsMaxZ() + (double) b; + pz = z + block.getBlockBoundsMaxZ() + b; } if (sideHit == 4) { - px = (double) x + block.getBlockBoundsMinX() - (double) b; + px = x + block.getBlockBoundsMinX() - b; } if (sideHit == 5) { - px = (double) x + block.getBlockBoundsMaxX() + (double) b; + px = x + block.getBlockBoundsMaxX() + b; } EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, worldObj.getBlockMetadata(x, y, z)); @@ -1156,9 +1148,9 @@ public class BlockGenericPipe extends BlockContainer { for (int i = 0; i < its; ++i) { for (int j = 0; j < its; ++j) { for (int k = 0; k < its; ++k) { - double px = x + (i + 0.5D) / (double) its; - double py = y + (j + 0.5D) / (double) its; - double pz = z + (k + 0.5D) / (double) its; + double px = x + (i + 0.5D) / its; + double py = y + (j + 0.5D) / its; + double pz = z + (k + 0.5D) / its; int random = rand.nextInt(6); EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, BuildCraftTransport.genericPipeBlock, random, meta); fx.setParticleIcon(icon); diff --git a/common/buildcraft/transport/render/PipeRendererWorld.java b/common/buildcraft/transport/render/PipeRendererWorld.java index 5e70304a..bddbb397 100644 --- a/common/buildcraft/transport/render/PipeRendererWorld.java +++ b/common/buildcraft/transport/render/PipeRendererWorld.java @@ -7,142 +7,82 @@ import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.IPipeRenderState; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeRenderState; -import buildcraft.transport.TransportConstants; import buildcraft.transport.TransportProxy; import buildcraft.core.utils.MatrixTranformations; + import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; + import net.minecraftforge.common.ForgeDirection; public class PipeRendererWorld implements ISimpleBlockRenderingHandler { - - private void renderAllFaceExeptAxe(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int x, int y, int z, char axe) { - float minX = (float) renderblocks.renderMinX; - float minY = (float) renderblocks.renderMinY; - float minZ = (float) renderblocks.renderMinZ; - float maxX = (float) renderblocks.renderMaxX; - float maxY = (float) renderblocks.renderMaxY; - float maxZ = (float) renderblocks.renderMaxZ; - if (axe != 'x') { - renderTwoWayXFace(renderblocks, block, icon, x, y, z, minY, minZ, maxY, maxZ, minX); - renderTwoWayXFace(renderblocks, block, icon, x, y, z, minY, minZ, maxY, maxZ, maxX); - } - if (axe != 'y') { - renderTwoWayYFace(renderblocks, block, icon, x, y, z, minX, minZ, maxX, maxZ, minY); - renderTwoWayYFace(renderblocks, block, icon, x, y, z, minX, minZ, maxX, maxZ, maxY); - } - if (axe != 'z') { - renderTwoWayZFace(renderblocks, block, icon, x, y, z, minX, minY, maxX, maxY, minZ); - renderTwoWayZFace(renderblocks, block, icon, x, y, z, minX, minY, maxX, maxY, maxZ); - } - } - - private void renderTwoWayXFace(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int xCoord, int yCoord, int zCoord, float minY, float minZ, float maxY, float maxZ, float x) { - renderblocks.setRenderBounds(x, minY, minZ, x, maxY, maxZ); - block.setRenderAxis('x'); - renderblocks.renderStandardBlock(block, xCoord, yCoord, zCoord); - block.setRenderAxis('a'); - } - - private void renderTwoWayYFace(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int xCoord, int yCoord, int zCoord, float minX, float minZ, float maxX, float maxZ, float y) { - renderblocks.setRenderBounds(minX, y, minZ, maxX, y, maxZ); - block.setRenderAxis('y'); - renderblocks.renderStandardBlock(block, xCoord, yCoord, zCoord); - block.setRenderAxis('a'); - } - - private void renderTwoWayZFace(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int xCoord, int yCoord, int zCoord, float minX, float minY, float maxX, float maxY, float z) { - renderblocks.setRenderBounds(minX, minY, z, maxX, maxY, z); - block.setRenderAxis('z'); - renderblocks.renderStandardBlock(block, xCoord, yCoord, zCoord); - block.setRenderAxis('a'); - } - public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, BlockGenericPipe block, IPipeRenderState renderState, int x, int y, int z) { - - float minSize = CoreConstants.PIPE_MIN_POS; - float maxSize = CoreConstants.PIPE_MAX_POS; - PipeRenderState state = renderState.getRenderState(); IIconProvider icons = renderState.getPipeIcons(); if (icons == null) return; - boolean west = false; - boolean east = false; - boolean down = false; - boolean up = false; - boolean north = false; - boolean south = false; + int connectivity = state.pipeConnectionMatrix.getMask(); + float[] dim = new float[6]; - if (state.pipeConnectionMatrix.isConnected(ForgeDirection.WEST)) { - state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.WEST)); - renderblocks.setRenderBounds(0.0F, minSize, minSize, minSize, maxSize, maxSize); - renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'x'); - west = true; + // render the unconnected pipe faces of the center block (if any) + + if (connectivity != 0x3f) { // note: 0x3f = 0x111111 = all sides + resetToCenterDimensions(dim); + + state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN)); + renderTwoWayBlock(renderblocks, block, x, y, z, dim, connectivity ^ 0x3f); } - if (state.pipeConnectionMatrix.isConnected(ForgeDirection.EAST)) { - state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.EAST)); - renderblocks.setRenderBounds(maxSize, minSize, minSize, 1.0F, maxSize, maxSize); - renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'x'); - east = true; - } + // render the connecting pipe faces - if (state.pipeConnectionMatrix.isConnected(ForgeDirection.DOWN)) { - state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.DOWN)); - renderblocks.setRenderBounds(minSize, 0.0F, minSize, maxSize, minSize, maxSize); - renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'y'); - down = true; - } + for (int dir = 0; dir < 6; dir++) { + int mask = 1 << dir; + if ((connectivity & mask) == 0) continue; // no connection towards dir - if (state.pipeConnectionMatrix.isConnected(ForgeDirection.UP)) { - state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UP)); - renderblocks.setRenderBounds(minSize, maxSize, minSize, maxSize, 1.0F, maxSize); - renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'y'); - up = true; - } + // center piece offsets + resetToCenterDimensions(dim); - if (state.pipeConnectionMatrix.isConnected(ForgeDirection.NORTH)) { - state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.NORTH)); - renderblocks.setRenderBounds(minSize, minSize, 0.0F, maxSize, maxSize, minSize); - renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'z'); - north = true; - } + // extend block towards dir as it's connected to there + dim[dir / 2] = dir % 2 == 0 ? 0 : CoreConstants.PIPE_MAX_POS; + dim[dir / 2 + 3] = dir % 2 == 0 ? CoreConstants.PIPE_MIN_POS : 1; - if (state.pipeConnectionMatrix.isConnected(ForgeDirection.SOUTH)) { - state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.SOUTH)); - renderblocks.setRenderBounds(minSize, minSize, maxSize, maxSize, maxSize, 1.0F); - renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'z'); - south = true; - } + // the mask points to all faces perpendicular to dir, i.e. dirs 0+1 -> mask 111100, 1+2 -> 110011, 3+5 -> 001111 + int renderMask = (3 << (dir / 2 * 2)) ^ 0x3f; - state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN)); - renderblocks.setRenderBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize); - if (!west) - renderTwoWayXFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, minSize); - if (!east) - renderTwoWayXFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, maxSize); - if (!down) - renderTwoWayYFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, minSize); - if (!up) - renderTwoWayYFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, maxSize); - if (!north) - renderTwoWayZFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, minSize); - if (!south) - renderTwoWayZFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, maxSize); + // render sub block + state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.VALID_DIRECTIONS[dir])); + + renderTwoWayBlock(renderblocks, block, x, y, z, dim, renderMask); + } renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); pipeFacadeRenderer(renderblocks, block, state, x, y, z); pipePlugRenderer(renderblocks, block, state, x, y, z); + } + private void resetToCenterDimensions(float[] dim) { + for (int i = 0; i < 3; i++) dim[i] = CoreConstants.PIPE_MIN_POS; + for (int i = 3; i < 6; i++) dim[i] = CoreConstants.PIPE_MAX_POS; + } + + /** + * Render a block with normal and inverted vertex order so back face culling doesn't have any effect. + */ + private void renderTwoWayBlock(RenderBlocks renderblocks, BlockGenericPipe block, int x, int y, int z, float[] dim, int mask) { + assert mask != 0; + + block.setRenderMask(mask); + renderblocks.setRenderBounds(dim[2], dim[0], dim[1], dim[5], dim[3], dim[4]); + renderblocks.renderStandardBlock(block, x, y, z); + block.setRenderMask((mask & 0x15) << 1 | (mask & 0x2a) >> 1); // pairwise swapped mask + renderblocks.setRenderBounds(dim[5], dim[3], dim[4], dim[2], dim[0], dim[1]); + renderblocks.renderStandardBlock(block, x, y, z); } private void pipeFacadeRenderer(RenderBlocks renderblocks, BlockGenericPipe block, PipeRenderState state, int x, int y, int z) { diff --git a/common/buildcraft/transport/utils/ConnectionMatrix.java b/common/buildcraft/transport/utils/ConnectionMatrix.java index 93acc280..dff1f469 100644 --- a/common/buildcraft/transport/utils/ConnectionMatrix.java +++ b/common/buildcraft/transport/utils/ConnectionMatrix.java @@ -3,26 +3,34 @@ package buildcraft.transport.utils; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.util.BitSet; import net.minecraftforge.common.ForgeDirection; public class ConnectionMatrix { - - private BitSet _connected = new BitSet(ForgeDirection.VALID_DIRECTIONS.length); - private final BitSetCodec _bitSetCodec = new BitSetCodec(); + private int mask = 0; private boolean dirty = false; public boolean isConnected(ForgeDirection direction) { - return _connected.get(direction.ordinal()); + // test if the direction.ordinal()'th bit of mask is set + return (mask & (1 << direction.ordinal())) != 0; } public void setConnected(ForgeDirection direction, boolean value) { - if (_connected.get(direction.ordinal()) != value) { - _connected.set(direction.ordinal(), value); + if (isConnected(direction) != value) { + // invert the direction.ordinal()'th bit of mask + mask ^= 1 << direction.ordinal(); dirty = true; } } + /** + * Return a mask representing the connectivity for all sides. + * + * @return mask in ForgeDirection order, least significant bit = first entry + */ + public int getMask() { + return mask; + } + public boolean isDirty() { return dirty; } @@ -32,14 +40,14 @@ public class ConnectionMatrix { } public void writeData(DataOutputStream data) throws IOException { - data.writeByte(_bitSetCodec.encode(_connected)); + data.writeByte(mask); } public void readData(DataInputStream data) throws IOException { - BitSet connection = new BitSet(ForgeDirection.VALID_DIRECTIONS.length); - _bitSetCodec.decode(data.readByte(), connection); - if (!_connected.equals(connection)) { - _connected = connection; + byte newMask = data.readByte(); + + if (newMask != mask) { + mask = newMask; dirty = true; } } From bfbd2ef55d39a30cb8b233054e2b5a8bff040733 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 27 Oct 2013 07:07:55 -0700 Subject: [PATCH 109/121] Clean plug matrix after rerender Should fix constant chunk refreshes. --- common/buildcraft/transport/PipeRenderState.java | 1 + 1 file changed, 1 insertion(+) diff --git a/common/buildcraft/transport/PipeRenderState.java b/common/buildcraft/transport/PipeRenderState.java index 200ea884..4727da75 100644 --- a/common/buildcraft/transport/PipeRenderState.java +++ b/common/buildcraft/transport/PipeRenderState.java @@ -59,6 +59,7 @@ public class PipeRenderState implements IClientState { textureMatrix.clean(); facadeMatrix.clean(); wireMatrix.clean(); + plugMatrix.clean(); } public boolean isDirty() { From a5de67f4f0cdc1d7d058645aa7ed6c31c2102800 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 27 Oct 2013 08:16:03 -0700 Subject: [PATCH 110/121] Allow regex version matching in version file --- common/buildcraft/core/Version.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/core/Version.java b/common/buildcraft/core/Version.java index 2a32bb95..8b5318b6 100644 --- a/common/buildcraft/core/Version.java +++ b/common/buildcraft/core/Version.java @@ -86,7 +86,7 @@ public class Version implements Runnable { String line; String mcVersion = CoreProxy.proxy.getMinecraftVersion(); while ((line = reader.readLine()) != null) { - if (line.startsWith(mcVersion)) { + if (mcVersion.matches(line)) { if (line.contains(DefaultProps.MOD)) { String[] tokens = line.split(":"); From 206f2fe712f7b63c8662b507e398b882c892740a Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 27 Oct 2013 08:19:59 -0700 Subject: [PATCH 111/121] Do it right this time --- common/buildcraft/core/Version.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/common/buildcraft/core/Version.java b/common/buildcraft/core/Version.java index 8b5318b6..4cecd0e6 100644 --- a/common/buildcraft/core/Version.java +++ b/common/buildcraft/core/Version.java @@ -86,13 +86,11 @@ public class Version implements Runnable { String line; String mcVersion = CoreProxy.proxy.getMinecraftVersion(); while ((line = reader.readLine()) != null) { - if (mcVersion.matches(line)) { - if (line.contains(DefaultProps.MOD)) { - - String[] tokens = line.split(":"); - recommendedVersion = tokens[2]; - - if (line.endsWith(VERSION)) { + String[] tokens = line.split(":"); + if (mcVersion.matches(tokens[0])) { + if (DefaultProps.MOD.matches(tokens[1])) { + if (VERSION.matches(tokens[2])) { + recommendedVersion = tokens[2]; BCLog.logger.finer("Using the latest version [" + getVersion() + "] for Minecraft " + mcVersion); currentVersion = EnumUpdateState.CURRENT; return; From 1e0e30d62af681f74ee834ee9db0a8ac77eab4f1 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 27 Oct 2013 08:26:17 -0700 Subject: [PATCH 112/121] Version 4.1.2 --- buildcraft_resources/build.number | 4 ++-- buildcraft_resources/changelog/4.1.2 | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 buildcraft_resources/changelog/4.1.2 diff --git a/buildcraft_resources/build.number b/buildcraft_resources/build.number index 600a792b..7097c342 100644 --- a/buildcraft_resources/build.number +++ b/buildcraft_resources/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Wed Sep 25 22:54:12 PDT 2013 -build.number=47 +#Sun Oct 27 08:22:33 PDT 2013 +build.number=49 diff --git a/buildcraft_resources/changelog/4.1.2 b/buildcraft_resources/changelog/4.1.2 new file mode 100644 index 00000000..53e5b5e8 --- /dev/null +++ b/buildcraft_resources/changelog/4.1.2 @@ -0,0 +1,6 @@ + +#4.1.2 + +- Change: Filtered Buffer Triggers can now be applied to any inventory. (CovertJaguar) +- Fix: Fix tiny derp that was causing massive net spam and chunk rerenders on pipes with plugs. (Player/CovertJaguar) +- Fix: Optimize Pipe World Renderer to render less faces. (Player) \ No newline at end of file From 6969d43d4bfd3a16339012ea75691541e8da4b19 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 28 Oct 2013 16:35:00 -0700 Subject: [PATCH 113/121] Tweak Engines a bit to restore some old behavior --- common/buildcraft/energy/TileEngine.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index 56f6e3ac..68006a70 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -174,8 +174,13 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto if (!isOrientationValid()) switchOrientation(true); } + + if (!isRedstonePowered) + if (energy > 1) + energy--; updateHeatLevel(); + getEnergyStage(); engineUpdate(); TileEntity tile = getTileBuffer(orientation).getTile(); From 7f73cc26918995672f1a511189e7751ae33f0e30 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 29 Oct 2013 03:08:22 -0700 Subject: [PATCH 114/121] Clean up Gate GUIs a bit Size them appropriately and align the slots properly. --- .../textures/gui/gate_interface_1.png | Bin 1369 -> 3090 bytes .../textures/gui/gate_interface_2.png | Bin 1413 -> 3257 bytes .../textures/gui/gate_interface_3.png | Bin 1513 -> 3691 bytes .../textures/gui/gate_interface_4.png | Bin 1574 -> 3709 bytes common/buildcraft/transport/Gate.java | 4 + common/buildcraft/transport/GateVanilla.java | 13 ++++ common/buildcraft/transport/GuiHandler.java | 6 +- .../transport/gui/ContainerGateInterface.java | 10 +-- .../transport/gui/GuiGateInterface.java | 70 +++++++++--------- 9 files changed, 59 insertions(+), 44 deletions(-) diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_1.png b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_1.png index e12bdaaa99b390930f704d5134f9017e09039ef8..bab9025916d4165e4f866ebcc85bbfa5cdbb3710 100644 GIT binary patch literal 3090 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6&2?&#~tz_78O`%fY(kk47* z5n0T@z;^(I8MCf+asma}OFVsD*>7|62r{#UHGU5P3Q3i?MwA5SruXJFv2_H=O!sfc?!$FWZ~QqXm8LmI2j5$%stcq{dF9egB| zD-X5EZHaPXQc>&R^jN{D*m9};^;tL8>^5Sy*jOOA{>|?4_sh2JUa!eeeSf8`*|F!_Q`r(+5|!i5dNJOp_B)?_ ztfD45jloUC?9tVlT*e!({pHt7KfVPtQX=q1NBCz`)`a!8U(ZWE{sk9W3KX*Loo9Zm z7;e^dk%qm`Osejg9QzCx)7NFF{%2D4?~26wow~*h%3RVPv+6t*F+r5+aJbL-{fuRh6p{%t$M(4&!aWc5yMhU%JM6$k8>8{R91Ik|`H zfSvtU_CLi^k85F?ed8IveKfIpF#oc|`@Jxm-*G8e-HBh6$o_C0)V!Y&49^+Y70I+# zZ&F&ou%W%5)!^U9kFOt^zy2J*uK(Hnw*Pe%IsdYM9B)7VJiBjkf&aCS%Yn-FF}%6( zzv{=`5Auia^PXq^_q_f5f6G5dFYx_ce{Jh$)8m0V)L;JyX1HH*nY8RoKZI6?eX9D*BrmUzTZApzTWK5 z&ky{E_pi@h{%zJ{jXRS||7bG2d6>*7qs=1w;9-|Gz~V{yvf8VM zi*K$sob^9wYW(@DOBuGTd0fAq$>P7rjqK28rCZlOe-*?K_3RTcX3uM|UWn#$I2|LW z%=KGxDMOVvW5&$W$u5cZi$xsrH5qh^D|qh-KxK(;TOM7KQ-r0`n<>ACxIMUAH(pCcSVLl zx_)sH?|xvunkKpFVRM?{cO&(1%j55#&gD+{^ZS3skI7#H4)NTq;JKLsm%3ZeBq8~y zqE;)hE$7FA$TNG-oD4npvAXg*Q-HCvSr4paUHu|hFCGs zbyJJ~!~tXL*k3**qk-Yu^II0lc2C9($?w)595>IXo;i8-9I!8q-jzQ5oe^C^`o17U-l2B3rFl=Tj zN~1lFng*lC)Bknkwkid#=!k6@C21T2EWp+? gO+mx$56{llGyW;RS;{+S3OC3uPgg&ebxsLQ060Q;kpKVy literal 1369 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G!U;i$lZxy-8q?;Kn`1yx4R3& ze;|v&SiR;mkm4-xh%9Dc;5!Jyj5{V~zXb}imw5WRvft+B5oBfyYy2L9{Eqr5l^ZtGL zKf7{gsl{HOI*b2F+UAY_W}fKYHl;pp_wV1oXD`cKXS)3LuDjj#sn%P}zU$O2TlW6< z!Spq|kH+ub+g-lqdbWFOptX(7nWT*;E?&Ht_To{z-t)ca z*!NiFeZKvFyOZ3W_k2ESoYcR~VRQGN@AuS6)3<-$JL}29!_RpdGH>htYxj)v|8(`+ zx4$a+sy}mnEB!B!ZZV(qXWo;!Z?Df~JkT<=*qY@r4}$=M11P##U<@QCTnsN`NA1=B z-yg8Evp1)k_)h*=Q>QM+&J-|rSti@xpWAXb$E|;V=J5el1_g!&1_maEnArQ@fx#G( zWj6b-*|p=(mNS??dGh3lBTR+)%J;w7Ywy=Tux*$q`OCi`eD&1k6aQzOP3!-?@Ba}= zhAYyI^I2hTUAO4hd?ui!+j4FBSQfZ_{#he3JEP}m;R7L<3M7~BXnR^z8PBlb+|mDe zleV)my!zrg={gI;tFOx$9Oj;zWFy3|;xfNyod}TH?m3Tx;mXS$uXhvRT(rMuQuYeD?N0rM0t2H3~gB@aw_6Z`FGb93{-`wKE>tqIdEKC|=NoS!v$ zOYQm@-pp%IytVCY)>fnAbF$AzuD>3(${Q`3kUS;;_H4tgm|gM?mrXKnmwhldJT7x= zrOM45v)L*?&mZG1V=+qSDb{<(QBqMcL&eg{>ek-2oxR2lcZCgFWb@BRS{?6mxW|l0 z11N@rlLun~hXX?c*G<6_b1t5L`0WOm-l%+`*oygvEu-^|kH_XLEPliB#1_9Z+ktkh zm>}DDM)I#r-ub20Oa~=^MnV(E^`e)v8_HPCz)s~lW6X8n9jC;hb=#lu%zb<|b2`2- zS76{{+U1~ diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_2.png b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_2.png index 6f3aa85111b28440525c0fddec8e15e071ae3a33..c6b7971c29d9b67c5d236e86d623320133906095 100644 GIT binary patch literal 3257 zcmd^Bc~Fx_6yHQ65I{={sV5+`BOr*VNHc-~H5^(2xe`T5!X-ozGzg(6iCP3f4y|$( z8y!@TFq~GALn2pDfuP70&O%L~5DtUk%Fz$3Oey~3)W7tb`DS$2C{s8~wC=u*>2My0D;&B%F>M~eBg?s!s_yn;e}tLApi z^&kHD@ST-R-=g;ec&Mzf2A-F7kKc1Z!gmp;;k9mQ|&el-2&wACo;TmCVSJ zL#%efot}u^;@i`}5GZq>IrWfJVxSJp)pnkl9Nn!@atKHUk5qVfs;%g$EXS7Qk93t% z{DKL(V5Z11^!R;_f3zIYlceodcO9OagEq@qB^dJ?1DExWS2Cx_u+~94jhrV4-{^YOgchpco5WIMwVtzjqo&5_%PXE1z+YX&Ge0snn<`)DSbK} zzl4c(LDnB0u+|(Y-$L3~!KWRQKAuYC1xvUQypYi{U#^gUEH*8`Zh9;o4HYunT*SOMeK_ z<*9dBZ&Mei2?B2X?IRAHGz;fKnvB*X8l)0hhuD{|F4qe0t7w=Q?k3AeVViP2?QV4Y`J@bNS5i^Bn`&3 zy*=tx-*JOqSqklUKXh&7O^!b+Y8j<^%h7C=iK`IdhfjWW!P|%ptxwr@?1M_7m~Eky zQnmJZ>Z51qlZH?L0(Chf9~4EO!qfYgpM$k|waLuXZ$1+zP+IhAlPgl8keO<%rU4^9 z29`zM7k`B2!mI5Jd6ycDRE+9bmAn;)-Z1<8Q+9yK z{o1pIaUD$w{_Pzz;xJ_hs^yoOp+!*hO^9l|T2lQS8xquo=@!~<2Nv|7#diY@YX0ek zOs>XKuZ5|lxdD+f{splfVxaLCz_&%&{BP}zPbuTW(UhdEbLDx5E%t4Q#9f>1>Wi}q zy+0N_XRCIe3M&eqUTN1uS^&^P4*F!M1w|MxGE=9mM*ArC?{WhKx z!4mS|=2?3BSHq+5Sp0X2YI#w))+jx9HPRJ*r%JtYt%Dhn&Oc-G?Nyla(Vn-oTvSj` zcVV-%K05>X_3)0BNYGPl4}i%1Q5J=wd6=l=%lSfm30 literal 1413 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G!U;i$lZxy-8q?;Kn`1yx4R3& ze;|v&SiR;mkm4-xh%9Dc;5!Jyj5{V~zXb}imw5WRvft+B5#-c${c(6o#$-Biv=9(N>q0gzFekwuv=n9jK_jkT2&LP3uZesdmo(}D=8>= zwAJVV`y;{f%{qCsT+H%1l_HW?J&o%Y&`s&r{V9m+kg5e@0s~z z_1ov)C-0g3Wb@m}e-7sg-1GY6KB;{B{c<*j>NRs_3iKE=IDlfCg+TzuKw`qhkQfPj zR>^bQ%|Fk+{-TNRvdb^$?vUqjD4n%T^2__%+s;<)-DmurS)UPZWP|mg-3;MRo;*3? zctDatfuVtcVI5;g!i)NYv1`Nll+FPyZ?Inc{&zSFgO=$`pE_}%Ga5dw_!rx-Ec4Q~ zwZ9t~u4HVD;;rL;r=|9>=V_fmUhRE*k52_gGiwwW!hhT@=MZk(p*i{Flg#_y=kH)+ z`0DmR9Oj({@rSVu+DS?RAX|W5EZ|+hr^fV<2jN!Z+>mPgZMWo7Ta-}NqpA@5*` zmF!W0-i>$o^J+ftpZ>(;qM5&hJHJ?6etE@jZ!g0exdz2s+s>~!cps^qyTMz8#Q z;=0E?3Evrb5+C)JwyjH6nvjjpPYMitj2sLBio%U+jDMBxuv24-O#kwF21ki^I>T=E z1P&gNS2Zjc&nH(u|FRnlQb!UN+K+nWZhd3s1SQcoC$FZ1*-mprJ zc>X6OAx{Hra&Z1ypvmIP3HTpsGFJ}RWJA#zdy};`OhPU3FvhM3-F70snf-dD4W zYuPYsc%DizDm1wveUE96oV5A&+8t-pHut^-m6{}hsXu{58RzS)tc7<#`aE6zT-G@y GGywocH2X9F diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_3.png b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_3.png index 9bd6d85ef47e6d53c8a4c4046ea4c3e7cc0ef23b..fbc82a02a3d0d51de30093d65c6fb103e72d451c 100644 GIT binary patch literal 3691 zcmd^?dsNe97{}l3xRfC(1QN(OpyUPRq7WITTy%s)fZQA;Z9oSoSb_|63t`Iw$E9W= zA~1oV61Ut$^MWu(goeV{x-3u%2yH_N$NX{I#`f!li4k_v)3N@jowM_M_rA~jKF|9+ zpXYmi%i9s;XM(rJ0{~3?w-Z7Ez`!8}EO-h&qSI;<;A38*PoNI~b!_9wSRDLql)62N z3c#YKsV^q!hdd)VIX~S$(06{f@j_Gl1~2_>GdN|P?i-mNmXeUZFE%Y6?1+7Hce-)ah6kL_@B&)mR;Op`>GYt5=`D?bV$mtzF%f+7VU}kYMfo7M2CP)kaNcq}&;nnYXAby3zlEVN z)FU-wGMmlt%r0hhPfEm!d%fk1i|YLh$&}rd(c>W1go+vX7EMFWm!m&U>g3s9!m zJmcJn0JK0wnQfV3>@CtNE!B%R+M*fAzH&y-q>?tahbo#7UH^Vio7ux}PIl#c;h4!s z8Q4P?TQw>@@g^c-lNp<{bywxV8_^4Dwu(Yj(i`xCs~7Z!C>u|%w~38r;6djh?66_` zb_~s`6ZOD*qp__aqsk*Z#W>ePW@TGf#t?KM90y!qd^DEpe>1zsf!VZ~GQs zPYMO3xD5o0F*p!bU!%Cs_7@U=uFRZS61gxWM_5LLwJKz9$210DXnB_*ay);`$R-K( zvj-OD-U4KE;>&+?SzB#;+5PyYoA#uk=|ik|Dx0>CdmY%^ww+r&}nZb3hbt*!7{fg5(l^{rgGEj(7R3MXC1ZQofmt56mZ z2{0SKrzL;w8JOSuiEexq6P~!AfbV+^-xT1OTiZ+u#8-9FE8J$6;+VoC?5~%ZiEO~b6wp&%i!v;RoM)waDXMMx&FAF=SG8OEdKD$sx``{O;^01#Qo>$S!lfxid zlJvs+CEKH`JPy7X@H6L6A*o7w*nie9*e<B;1ZIj5!G*hL@gP^|&dXDhkBGys6;{!8fPq^)8x_ zKY&$dEvd879J^P0ks?DfWgOTEkzx_i(2%Zt6ftKm)v=mq^ZQTq$W#xi?L&d`vAY&t ztk!i`;0#(~o`p9QnmIb~X!st%=7Z%whpIsK!1MSAXHSMKeaSUA8%QdT+HAzNX#rQQ&y=3!h<;rQO^$Swj|3{i0Y8quP zvu1tbBC32EoWi4Ci>+1pkJ5%pOQzo8Zpi5319S3%;7~)W4KcTGn`5 zFovdfjBeragju`DsXKBDX})I#Dapn`V=<-zXZT0#-~2d=iDcd4^~?^|P^Q>~&td zjd^DEZ~Nx`J@E7A&eexj=!$jEnKLJ4XUsQe^Zz$*Mqa)CY1&zT-<*HiObllG85+*& zGbDWGX1MVOANP*I?EgPyce40IUN))x@Su_VA&W!rv)tL$OP{BJR1*^HbiW_t)h2PkwUU`~O{ePdmR)UX%P|&GZ>( z?5p;?7ytj)Zxwx&O68M_Rraq@{!sE){qA(nxVZW^S5^39?bI2Tlj*P3f409?*fa0Rca{A0|Mvs!RU=s}*O2+H;3_#eoa^n|Al^pVT7^Q^vtiaA4IhJ%`ICGtWO?9Qiyz zj-APXbM@7%58Ka~2{&%rc+PAeuSMJOMh2f(A_gs;4m;RkcKl!dde?Lo1})RsXX~V2 zCx5=&P@SSA;0LijX5s5y*0I-XAIKeGG!X1~4pbyp9{ashnBj_a<9t?_m*=&2I#kC% zZB=7>`>arbVX_q~Pok2*J4T={px&AMa5>}m6D|sKfZ^2;HFxgZyJ8G0ia!IRNcTH~ z7SLADeIB3Y0nL8x&)8rUt5T`L5U^Z+(jN^Vl|R`=kYUB;z1wp2zkNOF%W~_nRr@Ck zi5jL3hC2+xjb)!LB%TyA?s#Z#+75K6?(gjR^Y7R)+*rIVcRm*^l-|sm&vr*yxUql< z99su$8?0t*lIhG3xM3+Fml%J_tPUiw};Uxm%tfV2CklINxvJ@fO4dsvX885G|R z3^7dbco$%J;1Fxc|KQ7)k`L;@$ko1_y*Bv0mGg4-;lqwRSW7~Lulc~ZzW7OY8cxL zJ|44jzHTUZ!WNdSk^Biy@d6CffkCojLZ`zu$-h=_&P^3=Oz81p`6L8R8V%VyKdCKP zdElDlVXO0gtk2q*HvDAbNqn`ov~AtvXIrL25*d=Op{X7uqQIcX$iWbx7~Htl_*dx- z+2F>RGQo{|5i#(fAvcdGO2;b6Mw<&;$UWmMi4| diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_4.png b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_4.png index f678949a94cd0b04872b005c7694ec9112d72c62..c81a098d91332b0e78e31b31077cc4df2e63d029 100644 GIT binary patch literal 3709 zcmeHK2~1OW9R9bnR9hKyqjb1PF$|-CFhmi?%|s4|oWkmqiU-|_(E*wP zBDLTqqQEH7X%wU|P(V4J%RIm`P6y-Af`vj$+qc&u9gvAT;u05M^77h$e)sSDzV;pS z-0G~3TaE(&sJpss@&*8fd_;l8YRF?p#Kj=wv54y6?f^h(Dqb3hLB20J;6kPW@Mg8* zM(w|UYzcCRjdXQ)!t(KIcoTgt-_Q*?S{~{2Nu*C$P-IMC#6I8|_<3lg@m42a-Dor8 z4aTOX&O*nHNY*~rO%A^FfX6KNMRQyiCwWG-^_%%bVKYg|MFfRH= ziux#aS!~@y?Ue(!Tk{9&cGet==V{ndg4(mQd&{SaZX4wB==Iba*^?BW^l2jmNyZ;g zV5o^8UV4D|11Bta$`6!R`?nvu-cB{%f&mAJwh5B4&bO~_2UAd{BiAnvZQ*(KsM*v# ze@gnpUkow1IaYTkc2C8T4M4b-c~6L~50GTl_GY#6C>c0=R?^oN+5UKYf!#rPM+lUW zhklD1sMpe$j=mGGA=^-DqcTd>Vs^yPMdhslpU(KDYBD=$$dM+0sL>mBlv}clD&%W1 z1MIBhWu74d@{C>Q1u*uoyKP87;7_SCY$Pz*BuOwe`ElipGtC#oMNi7bE~S->nR25s zxdM$&%1D@Zh#l96z_h@>7j6#W>?tG(23~bjM4NH`8E?7X#oiID_U2s|prW>>XW$p_^5(#F23jsz3t5YK^qyB;)&+YP#vPwL%@^Q_j#B{4KS|QS#=1b3HSF_$u&Vo?F1&b zNfz7E}PA6%C8O+nbE!On@^tU?XMUtWK+{wYnVoavXNYJQ-?Ohb!*YI z&%lxCcZ`ArC;G|yRGjXXBqQt3w74;K!lF}Vn6x}cEuHnp+pKzH{cdHU8@yNIHO|}| zK09h%s7P=rEeUJG-_5qE>M0EPW?RGsQ0CiElNe+gpVS|w*gOE#l=Dl>=&%IwPG?A=3Dp3OCUZBLGMM+iQ;B-yYDybwO87Qz6b|0de1~ z-OQg15&{Pe6+CJ;v^G(#$e$kIuiuZDdQEqTL^{MP2s`{Pua^MIsHnH2NeQ1kkBD^o(yJ zCHf`W6=rn3rZu833#0Z=Xia;P=qzQpDdf)%k@_@r!?cvolg~Ba`Vj;KGKmkMYapsP zHJ%Sfbi5U`S19j!P&WJ^2VEWS@^S*fshC_wKA$^C!ABuf$ubkA_fG~W(?3(45AriD z_aq7QRSMe3D!paN%TyuPgjTm|+D9R92!ETjvsu0IuG4CY%xxVtBqHS%4xr#h4a>Ai zTiI0G9$Q$wi+p(zBGBoUdnmEW))0A-uC3O4)m#17+j>2#zfO($vy#8NzURb?n6D&k z@>G!o>o6aH)4y*RT3nWypOVA>Q$D^Br1jVlqbBWImZ?&uZ2D3i^jcQW{nxs%>`HYq zbI=V>SMIpccCUl?y~+C)>e}I(FC#BNc-NF&%cw-;)$G5#LYs*cDfY*l+bzbsy4NW( NyE<*%RP4Cx@bBjmwp9QC literal 1574 zcmb7DdsLEV9DeyyRLs=5@=R2kM`dQ-QcunmqT*2+V)N26ud|MqRLa{N=>WB@xvb?a zol;V!78zC^(KHpip_Sn|)T|L=#byXagA@_Tfu*gpf41*E-}yc7@4fw=_j%s(?Zi+s zgbe}!V1^IFMFIfRK^QQG>q30)*;IWmFETU;u1y$!c9G#It8xV05ELD;{v0<`~Ah^h)ml8Tkc=Hj+)Z+ zudYtx$I3!IO575Q;n&2|dB(CWKikfh$byENpN6&1@z!^Fq{kf$C{QtcSmEH+`WZobS`$v9qt5I!y}D{Ge3k^<87QtvhUsLZw}a zXMZ2@hR^5Y<$t)L1EQXaMHXPc!W8(a4FP=t0z?W7pa%i1Itg$_Jiw&b`h(%3KgEN+ z0yfR-JadD&{g#WCEKq-%oG?XkQL}5#)D&NSd{BNcaAcy}5AC#;_? zb{HwdPedrL&r1ud7bp^ywpPq{>~K;)W|K`hbHWJ4lliFtXR^yk9NykZoo!drCLNRv z5Eaw&nH^|yx+WgxNfM4MdX6CR1F=*JdPIO9*f}^HkZAN|)RF2;F4Rg{Ao<4a7L%bK z2p9khfYpos7OcR@vFrsN7L7*tqZmwP`;PM$+VkWS{fU`bQXXIBCsTROHd@b#XfZJ} z2WaZzlMnWG)fU|2@wyeIHrH|<%D<6ycLN##5HJSo0VfdofWYbO^ybxTZ>`lObR$+h zMq{d`gQRCo!^Cp!w}wj-msV6fz9omEV`|mK6PiGF*S%A=hqS4mZL4Bu3mnO$SEVMt zeV-pqK#5MtRVkOksy5c$dFgxCodtT)40Ef!v((~Qq-vSc!@<^!L`zVA_EFX>cl$4+ zxb-WAt&ZaR6gIZ1)2mc~aQ2cYYIEbL{pN7xudbk;WI$QFd@nr+s}lGPO6NXjNXW^N z&Cd}GQe3|VLaVVuCcc^gjOIwud#2crtV%A5So-5h9En6?2cu=2T#!4Fxm#)0$w5c7 z7;KW0nzI%V#zhd|=U0j=0mnyMBTmyzoX3n<=|XSP_{`1ltv%(~RVjn$BEw^W@Z_#t zGjDbfH=jyHO0%8`B7^;^-^@+Z=-I%7du3fQQ|M5gF z9kCC#Vzz$+EXaZx1J6L+cFX#=@3#B#oMVQ79bPpB_oz4CbK=u>r3}ZonNsN(>s}|! ztWSuCaYWRvBve_7HYq1RI6;uy$Y==n(+ zhH&)~QB*)M$Tk1)U3^%o0cV|VGpjug#|q$sYx+8K94uB>mSf-D(|$MPKBxhawNz+y z^6bY;0^N_3zE0qdX8b4qtx#OrE9u2AS|M-$R;b8yg%JlPC4tL!-PLDms#-I$+zGD` z3`dvFM|Vk{HUow|$P4DE-E)2z4C#csB|6mWj^kSK>p6I95<{>EBm- BVv_&> diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java index 275a1441..3e4ffcf1 100644 --- a/common/buildcraft/transport/Gate.java +++ b/common/buildcraft/transport/Gate.java @@ -288,6 +288,10 @@ public abstract class Gate { public abstract ResourceLocation getGuiFile(); + public int getGuiHeight() { + return 207; + } + public static boolean isGateItem(ItemStack stack) { return stack.itemID == BuildCraftTransport.pipeGate.itemID || stack.itemID == BuildCraftTransport.pipeGateAutarchic.itemID; } diff --git a/common/buildcraft/transport/GateVanilla.java b/common/buildcraft/transport/GateVanilla.java index 16958cf5..1c61ed51 100644 --- a/common/buildcraft/transport/GateVanilla.java +++ b/common/buildcraft/transport/GateVanilla.java @@ -322,4 +322,17 @@ public class GateVanilla extends Gate { else return TEXTURE4; } + + @Override + public int getGuiHeight() { + switch (kind) { + case Single: + return 146; + case AND_2: + case OR_2: + return 164; + default: + return 200; + } + } } diff --git a/common/buildcraft/transport/GuiHandler.java b/common/buildcraft/transport/GuiHandler.java index a268a9a6..92de6927 100644 --- a/common/buildcraft/transport/GuiHandler.java +++ b/common/buildcraft/transport/GuiHandler.java @@ -49,7 +49,8 @@ public class GuiHandler implements IGuiHandler { return new ContainerEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe); case GuiIds.GATES: - return new ContainerGateInterface(player.inventory, pipe.pipe); + if (pipe.pipe.hasGate()) + return new ContainerGateInterface(player.inventory, pipe.pipe); default: return null; @@ -89,7 +90,8 @@ public class GuiHandler implements IGuiHandler { return new GuiEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe); case GuiIds.GATES: - return new GuiGateInterface(player.inventory, pipe.pipe); + if (pipe.pipe.hasGate()) + return new GuiGateInterface(player.inventory, pipe.pipe); default: return null; diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java index 5e57c676..f163e5c2 100644 --- a/common/buildcraft/transport/gui/ContainerGateInterface.java +++ b/common/buildcraft/transport/gui/ContainerGateInterface.java @@ -62,14 +62,14 @@ public class ContainerGateInterface extends BuildCraftContainer { super(0); this.playerIInventory = playerInventory; - for (int l = 0; l < 3; l++) { - for (int k1 = 0; k1 < 9; k1++) { - addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 123 + l * 18)); + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(playerInventory, x + y * 9 + 9, 8 + x * 18, pipe.gate.getGuiHeight() - 84 + y * 18)); } } - for (int i1 = 0; i1 < 9; i1++) { - addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 181)); + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(playerInventory, x, 8 + x * 18, pipe.gate.getGuiHeight() - 26)); } this.pipe = pipe; diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java index 5a537b20..df41d431 100644 --- a/common/buildcraft/transport/gui/GuiGateInterface.java +++ b/common/buildcraft/transport/gui/GuiGateInterface.java @@ -1,12 +1,10 @@ /** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com + * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public License + * 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.transport.gui; import buildcraft.api.gates.IAction; @@ -28,9 +26,7 @@ import org.lwjgl.opengl.GL11; public class GuiGateInterface extends GuiAdvancedInterface { IInventory playerInventory; - private final ContainerGateInterface _container; - private int nbEntries; class TriggerSlot extends AdvancedSlot { @@ -54,15 +50,15 @@ public class GuiGateInterface extends GuiAdvancedInterface { return ""; } - @SideOnly(Side.CLIENT) - @Override - public Icon getIcon() { - ITrigger trigger = pipe.gate.getTrigger(slot); - if (trigger != null) - return trigger.getIcon(); - else - return null; - } + @SideOnly(Side.CLIENT) + @Override + public Icon getIcon() { + ITrigger trigger = pipe.gate.getTrigger(slot); + if (trigger != null) + return trigger.getIcon(); + else + return null; + } @Override public boolean isDefined() { @@ -152,8 +148,8 @@ public class GuiGateInterface extends GuiAdvancedInterface { _container = (ContainerGateInterface) this.inventorySlots; this.playerInventory = playerInventory; - xSize = 175; - ySize = 207; + xSize = 176; + ySize = pipe.gate.getGuiHeight(); int position = 0; @@ -161,34 +157,34 @@ public class GuiGateInterface extends GuiAdvancedInterface { nbEntries = 1; slots = new AdvancedSlot[2]; - slots[0] = new TriggerSlot(65, 54, pipe, 0); - slots[1] = new ActionSlot(99, 54, pipe, 0); + slots[0] = new TriggerSlot(62, 26, pipe, 0); + slots[1] = new ActionSlot(98, 26, pipe, 0); } else if (pipe.gate.kind == GateKind.AND_2 || pipe.gate.kind == GateKind.OR_2) { nbEntries = 2; slots = new AdvancedSlot[4]; - slots[0] = new TriggerSlot(65, 46, pipe, 0); - slots[1] = new TriggerSlot(65, 64, pipe, 1); - slots[2] = new ActionSlot(99, 46, pipe, 0); - slots[3] = new ActionSlot(99, 64, pipe, 1); + slots[0] = new TriggerSlot(62, 26, pipe, 0); + slots[1] = new TriggerSlot(62, 44, pipe, 1); + slots[2] = new ActionSlot(98, 26, pipe, 0); + slots[3] = new ActionSlot(98, 44, pipe, 1); } else if (pipe.gate.kind == GateKind.AND_3 || pipe.gate.kind == GateKind.OR_3) { nbEntries = 4; slots = new AdvancedSlot[12]; for (int k = 0; k < 4; ++k) { - slots[position] = new TriggerSlot(60, 36 + 18 * k, pipe, position); + slots[position] = new TriggerSlot(53, 26 + 18 * k, pipe, position); position++; } for (int k = 0; k < 4; ++k) { - slots[position] = new ActionSlot(112, 36 + 18 * k, pipe, position - 4); + slots[position] = new ActionSlot(107, 26 + 18 * k, pipe, position - 4); position++; } for (int k = 0; k < 4; ++k) { - slots[position] = new TriggerParameterSlot(78, 36 + 18 * k, pipe, position - 8); + slots[position] = new TriggerParameterSlot(71, 26 + 18 * k, pipe, position - 8); position++; } @@ -198,23 +194,23 @@ public class GuiGateInterface extends GuiAdvancedInterface { slots = new AdvancedSlot[24]; for (int k = 0; k < 4; ++k) { - slots[position] = new TriggerSlot(8, 36 + 18 * k, pipe, position); + slots[position] = new TriggerSlot(8, 26 + 18 * k, pipe, position); position++; - slots[position] = new TriggerSlot(100, 36 + 18 * k, pipe, position); + slots[position] = new TriggerSlot(98, 26 + 18 * k, pipe, position); position++; } for (int k = 0; k < 4; ++k) { - slots[position] = new ActionSlot(60, 36 + 18 * k, pipe, position - 8); + slots[position] = new ActionSlot(62, 26 + 18 * k, pipe, position - 8); position++; - slots[position] = new ActionSlot(152, 36 + 18 * k, pipe, position - 8); + slots[position] = new ActionSlot(152, 26 + 18 * k, pipe, position - 8); position++; } for (int k = 0; k < 4; ++k) { - slots[position] = new TriggerParameterSlot(26, 36 + 18 * k, pipe, position - 16); + slots[position] = new TriggerParameterSlot(26, 26 + 18 * k, pipe, position - 16); position++; - slots[position] = new TriggerParameterSlot(118, 36 + 18 * k, pipe, position - 16); + slots[position] = new TriggerParameterSlot(116, 26 + 18 * k, pipe, position - 16); position++; } } @@ -225,7 +221,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { protected void drawGuiContainerForegroundLayer(int par1, int par2) { String name = _container.getGateName(); - fontRenderer.drawString(name, getCenteredOffset(name), 15, 0x404040); + fontRenderer.drawString(name, getCenteredOffset(name), 10, 0x404040); fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); drawForegroundSelection(par1, par2); @@ -235,10 +231,10 @@ public class GuiGateInterface extends GuiAdvancedInterface { protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { _container.synchronize(); - + ResourceLocation texture = _container.getGateGuiFile(); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(texture); int cornerX = (width - xSize) / 2; From 17ff442867b622e19f6feddece790b1228b62c6f Mon Sep 17 00:00:00 2001 From: taelnia Date: Wed, 30 Oct 2013 15:54:31 -0400 Subject: [PATCH 115/121] Adjusted FluidContainerTrigger to pass through the side being checked --- common/buildcraft/core/triggers/TriggerFluidContainer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/core/triggers/TriggerFluidContainer.java b/common/buildcraft/core/triggers/TriggerFluidContainer.java index 0674876e..c9caf496 100644 --- a/common/buildcraft/core/triggers/TriggerFluidContainer.java +++ b/common/buildcraft/core/triggers/TriggerFluidContainer.java @@ -66,7 +66,7 @@ public class TriggerFluidContainer extends BCTrigger { searchedFluid.amount = 1; } - FluidTankInfo[] liquids = container.getTankInfo(ForgeDirection.UNKNOWN); + FluidTankInfo[] liquids = container.getTankInfo(side); if (liquids == null || liquids.length == 0) return false; From 0aad0c785b25018f9dcee72d293b8e4078638fc2 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 30 Oct 2013 23:09:35 -0400 Subject: [PATCH 116/121] Add in API markers for all the BC API packages. They come under the umbrella "BuildCraftAPI", expect warnings from now on if you don't include these in your BC dependent mods. --- build.xml | 2 +- common/buildcraft/api/blueprints/package-info.java | 3 +++ common/buildcraft/api/bptblocks/package-info.java | 3 +++ common/buildcraft/api/core/package-info.java | 3 +++ common/buildcraft/api/filler/package-info.java | 3 +++ common/buildcraft/api/fuels/package-info.java | 3 +++ common/buildcraft/api/gates/package-info.java | 3 +++ common/buildcraft/api/inventory/package-info.java | 3 +++ common/buildcraft/api/package-info.java | 3 +++ common/buildcraft/api/power/package-info.java | 3 +++ common/buildcraft/api/recipes/package-info.java | 3 +++ common/buildcraft/api/tools/package-info.java | 3 +++ common/buildcraft/api/transport/package-info.java | 3 +++ 13 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 common/buildcraft/api/blueprints/package-info.java create mode 100644 common/buildcraft/api/bptblocks/package-info.java create mode 100644 common/buildcraft/api/core/package-info.java create mode 100644 common/buildcraft/api/filler/package-info.java create mode 100644 common/buildcraft/api/fuels/package-info.java create mode 100644 common/buildcraft/api/gates/package-info.java create mode 100644 common/buildcraft/api/inventory/package-info.java create mode 100644 common/buildcraft/api/package-info.java create mode 100644 common/buildcraft/api/power/package-info.java create mode 100644 common/buildcraft/api/recipes/package-info.java create mode 100644 common/buildcraft/api/tools/package-info.java create mode 100644 common/buildcraft/api/transport/package-info.java diff --git a/build.xml b/build.xml index a82dea32..27642e35 100644 --- a/build.xml +++ b/build.xml @@ -19,7 +19,7 @@ - + diff --git a/common/buildcraft/api/blueprints/package-info.java b/common/buildcraft/api/blueprints/package-info.java new file mode 100644 index 00000000..d1b8fdae --- /dev/null +++ b/common/buildcraft/api/blueprints/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api.blueprints; +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/bptblocks/package-info.java b/common/buildcraft/api/bptblocks/package-info.java new file mode 100644 index 00000000..97e8e259 --- /dev/null +++ b/common/buildcraft/api/bptblocks/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api.bptblocks; +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/core/package-info.java b/common/buildcraft/api/core/package-info.java new file mode 100644 index 00000000..af6b5113 --- /dev/null +++ b/common/buildcraft/api/core/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api.core; +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/filler/package-info.java b/common/buildcraft/api/filler/package-info.java new file mode 100644 index 00000000..67fec375 --- /dev/null +++ b/common/buildcraft/api/filler/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api.filler; +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/fuels/package-info.java b/common/buildcraft/api/fuels/package-info.java new file mode 100644 index 00000000..37b3dff1 --- /dev/null +++ b/common/buildcraft/api/fuels/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api.fuels; +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/gates/package-info.java b/common/buildcraft/api/gates/package-info.java new file mode 100644 index 00000000..4d795d89 --- /dev/null +++ b/common/buildcraft/api/gates/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api.gates; +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/inventory/package-info.java b/common/buildcraft/api/inventory/package-info.java new file mode 100644 index 00000000..a9701530 --- /dev/null +++ b/common/buildcraft/api/inventory/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api.inventory; +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/package-info.java b/common/buildcraft/api/package-info.java new file mode 100644 index 00000000..34b308b6 --- /dev/null +++ b/common/buildcraft/api/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api; +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/power/package-info.java b/common/buildcraft/api/power/package-info.java new file mode 100644 index 00000000..41cb8af1 --- /dev/null +++ b/common/buildcraft/api/power/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api.power; +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/recipes/package-info.java b/common/buildcraft/api/recipes/package-info.java new file mode 100644 index 00000000..fea04e13 --- /dev/null +++ b/common/buildcraft/api/recipes/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api.recipes; +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/tools/package-info.java b/common/buildcraft/api/tools/package-info.java new file mode 100644 index 00000000..b3a18423 --- /dev/null +++ b/common/buildcraft/api/tools/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api.tools; +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/transport/package-info.java b/common/buildcraft/api/transport/package-info.java new file mode 100644 index 00000000..236c8e95 --- /dev/null +++ b/common/buildcraft/api/transport/package-info.java @@ -0,0 +1,3 @@ +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +package buildcraft.api.transport; +import cpw.mods.fml.common.API; \ No newline at end of file From 643545b271f2b3503052fe2248d475bba39f9107 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 30 Oct 2013 23:16:03 -0700 Subject: [PATCH 117/121] Split API into individual sections Yes, I know this fails. Don't use it. It needs to be fixed on FML's side. --- common/buildcraft/BuildCraftCore.java | 2 -- common/buildcraft/api/blueprints/package-info.java | 2 +- common/buildcraft/api/bptblocks/package-info.java | 2 +- common/buildcraft/api/core/package-info.java | 2 +- common/buildcraft/api/filler/package-info.java | 2 +- common/buildcraft/api/fuels/package-info.java | 2 +- common/buildcraft/api/gates/package-info.java | 2 +- common/buildcraft/api/inventory/package-info.java | 2 +- common/buildcraft/api/package-info.java | 2 +- common/buildcraft/api/power/package-info.java | 2 +- common/buildcraft/api/recipes/package-info.java | 2 +- common/buildcraft/api/tools/package-info.java | 2 +- common/buildcraft/api/transport/package-info.java | 2 +- 13 files changed, 12 insertions(+), 14 deletions(-) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index e79a6af5..313e7a1e 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -11,7 +11,6 @@ package buildcraft; import java.io.File; import java.util.TreeMap; -import java.util.logging.Logger; import net.minecraft.block.Block; import net.minecraft.block.BlockFluid; @@ -66,7 +65,6 @@ import buildcraft.core.triggers.TriggerMachine; import buildcraft.core.utils.BCLog; import buildcraft.core.utils.Localization; import buildcraft.transport.triggers.TriggerRedstoneInput; -import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; diff --git a/common/buildcraft/api/blueprints/package-info.java b/common/buildcraft/api/blueprints/package-info.java index d1b8fdae..0604277f 100644 --- a/common/buildcraft/api/blueprints/package-info.java +++ b/common/buildcraft/api/blueprints/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|blueprints") package buildcraft.api.blueprints; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/bptblocks/package-info.java b/common/buildcraft/api/bptblocks/package-info.java index 97e8e259..227914c4 100644 --- a/common/buildcraft/api/bptblocks/package-info.java +++ b/common/buildcraft/api/bptblocks/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraftAPI|blueprints",provides="BuildCraftAPI|bptblocks") package buildcraft.api.bptblocks; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/core/package-info.java b/common/buildcraft/api/core/package-info.java index af6b5113..bb494d53 100644 --- a/common/buildcraft/api/core/package-info.java +++ b/common/buildcraft/api/core/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI|core") package buildcraft.api.core; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/filler/package-info.java b/common/buildcraft/api/filler/package-info.java index 67fec375..6bd704d3 100644 --- a/common/buildcraft/api/filler/package-info.java +++ b/common/buildcraft/api/filler/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|filler") package buildcraft.api.filler; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/fuels/package-info.java b/common/buildcraft/api/fuels/package-info.java index 37b3dff1..48ad9319 100644 --- a/common/buildcraft/api/fuels/package-info.java +++ b/common/buildcraft/api/fuels/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|fuels") package buildcraft.api.fuels; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/gates/package-info.java b/common/buildcraft/api/gates/package-info.java index 4d795d89..ff77cbac 100644 --- a/common/buildcraft/api/gates/package-info.java +++ b/common/buildcraft/api/gates/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|gates") package buildcraft.api.gates; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/inventory/package-info.java b/common/buildcraft/api/inventory/package-info.java index a9701530..5335e411 100644 --- a/common/buildcraft/api/inventory/package-info.java +++ b/common/buildcraft/api/inventory/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|inventory") package buildcraft.api.inventory; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/package-info.java b/common/buildcraft/api/package-info.java index 34b308b6..c1be5f46 100644 --- a/common/buildcraft/api/package-info.java +++ b/common/buildcraft/api/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI|core") package buildcraft.api; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/power/package-info.java b/common/buildcraft/api/power/package-info.java index 41cb8af1..c119e142 100644 --- a/common/buildcraft/api/power/package-info.java +++ b/common/buildcraft/api/power/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|power") package buildcraft.api.power; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/recipes/package-info.java b/common/buildcraft/api/recipes/package-info.java index fea04e13..a27517f3 100644 --- a/common/buildcraft/api/recipes/package-info.java +++ b/common/buildcraft/api/recipes/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|recipes") package buildcraft.api.recipes; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/tools/package-info.java b/common/buildcraft/api/tools/package-info.java index b3a18423..a5e03a06 100644 --- a/common/buildcraft/api/tools/package-info.java +++ b/common/buildcraft/api/tools/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|tools") package buildcraft.api.tools; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/common/buildcraft/api/transport/package-info.java b/common/buildcraft/api/transport/package-info.java index 236c8e95..46475028 100644 --- a/common/buildcraft/api/transport/package-info.java +++ b/common/buildcraft/api/transport/package-info.java @@ -1,3 +1,3 @@ -@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI") +@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|transport") package buildcraft.api.transport; import cpw.mods.fml.common.API; \ No newline at end of file From 9a8f9606cf399f896212c346d6244409c086e8fe Mon Sep 17 00:00:00 2001 From: bdew Date: Sat, 2 Nov 2013 11:25:22 +0200 Subject: [PATCH 118/121] Workaround for scala compiler derp --- common/buildcraft/api/power/IPowerReceptor.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/buildcraft/api/power/IPowerReceptor.java b/common/buildcraft/api/power/IPowerReceptor.java index a7f6c421..48b84c90 100644 --- a/common/buildcraft/api/power/IPowerReceptor.java +++ b/common/buildcraft/api/power/IPowerReceptor.java @@ -7,7 +7,6 @@ */ package buildcraft.api.power; -import buildcraft.api.power.PowerHandler.PowerReceiver; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; @@ -31,7 +30,7 @@ public interface IPowerReceptor { * @param side * @return */ - public PowerReceiver getPowerReceiver(ForgeDirection side); + public PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side); /** * Call back from the PowerHandler that is called when the stored power From 1e00cf012be0f562b9f03b714be77b30b8276ee1 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 5 Nov 2013 16:27:59 -0800 Subject: [PATCH 119/121] Possible fix for Pipe placement sync issue Theoretically this should send an update on placement to all watching players so everyone can see the pipe. --- common/buildcraft/transport/BlockGenericPipe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 5ea3ff42..25e5297e 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -1010,9 +1010,9 @@ public class BlockGenericPipe extends BlockContainer { boolean placed = world.setBlock(i, j, k, blockId, meta, 1); if (placed) { - TileGenericPipe tile = (TileGenericPipe) world.getBlockTileEntity(i, j, k); tile.initialize(pipe); + tile.sendUpdateToClient(); } return placed; From 7073a10fc57f789be1a5607a985609fd82f5e180 Mon Sep 17 00:00:00 2001 From: "Scott M. Barbour" Date: Wed, 13 Nov 2013 10:37:24 -0600 Subject: [PATCH 120/121] CraftingHelper - Properly name the variables --- .../buildcraft/core/utils/CraftingHelper.java | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/common/buildcraft/core/utils/CraftingHelper.java b/common/buildcraft/core/utils/CraftingHelper.java index 2ba52696..cfa9f706 100644 --- a/common/buildcraft/core/utils/CraftingHelper.java +++ b/common/buildcraft/core/utils/CraftingHelper.java @@ -14,59 +14,61 @@ public class CraftingHelper { @SuppressWarnings({ "unchecked", "rawtypes" }) public static IRecipe findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) { - int var3 = 0; - ItemStack var4 = null; - ItemStack var5 = null; - int var6; + // Begin repair recipe handler + int itemNum = 0; + ItemStack item1 = null; + ItemStack item2 = null; + int slot; - for (var6 = 0; var6 < par1InventoryCrafting.getSizeInventory(); ++var6) + for (slot = 0; slot < par1InventoryCrafting.getSizeInventory(); ++slot) { - ItemStack var7 = par1InventoryCrafting.getStackInSlot(var6); + ItemStack itemInSlot = par1InventoryCrafting.getStackInSlot(slot); - if (var7 != null) + if (itemInSlot != null) { - if (var3 == 0) + if (itemNum == 0) { - var4 = var7; + item1 = itemInSlot; } - if (var3 == 1) + if (itemNum == 1) { - var5 = var7; + item2 = itemInSlot; } - ++var3; + ++itemNum; } } - if (var3 == 2 && var4.itemID == var5.itemID && var4.stackSize == 1 && var5.stackSize == 1 && Item.itemsList[var4.itemID].isRepairable()) + if (itemNum == 2 && item1.itemID == item2.itemID && item1.stackSize == 1 && item2.stackSize == 1 && Item.itemsList[item1.itemID].isRepairable()) { - Item var11 = Item.itemsList[var4.itemID]; - int var13 = var11.getMaxDamage() - var4.getItemDamageForDisplay(); - int var8 = var11.getMaxDamage() - var5.getItemDamageForDisplay(); - int var9 = var13 + var8 + var11.getMaxDamage() * 5 / 100; - int var10 = var11.getMaxDamage() - var9; + Item itemBase = Item.itemsList[item1.itemID]; + int item1Durability = itemBase.getMaxDamage() - item1.getItemDamageForDisplay(); + int item2Durability = itemBase.getMaxDamage() - item2.getItemDamageForDisplay(); + int repairAmt = item1Durability + item2Durability + itemBase.getMaxDamage() * 5 / 100; + int newDamage = itemBase.getMaxDamage() - repairAmt; - if (var10 < 0) + if (newDamage < 0) { - var10 = 0; + newDamage = 0; } ArrayList ingredients = new ArrayList(2); - ingredients.add(var4); - ingredients.add(var5); - return new ShapelessRecipes(new ItemStack(var4.itemID, 1, var10),ingredients); + ingredients.add(item1); + ingredients.add(item2); + return new ShapelessRecipes(new ItemStack(item1.itemID, 1, newDamage),ingredients); } + // End repair recipe handler else { List recipes = CraftingManager.getInstance().getRecipeList(); - for (var6 = 0; var6 < recipes.size(); ++var6) + for (int index = 0; index < recipes.size(); ++index) { - IRecipe var12 = (IRecipe) recipes.get(var6); + IRecipe currentRecipe = (IRecipe) recipes.get(index); - if (var12.matches(par1InventoryCrafting, par2World)) + if (currentRecipe.matches(par1InventoryCrafting, par2World)) { - return var12; + return currentRecipe; } } From 696c2067929c10c93b31282a6d0877749c6ea37c Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 13 Nov 2013 17:23:12 -0800 Subject: [PATCH 121/121] Register all items with FML so they survive 1.7 --- build.xml | 2 +- common/buildcraft/BuildCraftBuilders.java | 10 ++++++---- common/buildcraft/BuildCraftEnergy.java | 2 ++ common/buildcraft/BuildCraftTransport.java | 12 +++++++++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/build.xml b/build.xml index 27642e35..65fbdaca 100644 --- a/build.xml +++ b/build.xml @@ -19,7 +19,7 @@ - + diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index c72cd496..2254f6b8 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -242,10 +242,12 @@ public class BuildCraftBuilders { templateItem = new ItemBptTemplate(templateItemId.getInt()); templateItem.setUnlocalizedName("templateItem"); LanguageRegistry.addName(templateItem, "Template"); + CoreProxy.proxy.registerItem(templateItem); blueprintItem = new ItemBptBluePrint(blueprintItemId.getInt()); blueprintItem.setUnlocalizedName("blueprintItem"); LanguageRegistry.addName(blueprintItem, "Blueprint"); + CoreProxy.proxy.registerItem(blueprintItem); markerBlock = new BlockMarker(markerId.getInt()); CoreProxy.proxy.registerBlock(markerBlock.setUnlocalizedName("markerBlock")); @@ -333,11 +335,11 @@ public class BuildCraftBuilders { FillerManager.registry.addRecipe(new FillerFillPyramid(), new Object[]{" ", " b ", "bbb", 'g', Block.glass, 'b', Block.brick}); FillerManager.registry.addRecipe(new FillerFillStairs(), new Object[]{" b", " bb", "bbb", 'g', Block.glass, 'b', Block.brick}); } - + @EventHandler - public void processIMCRequests(FMLInterModComms.IMCEvent event) { - InterModComms.processIMC(event); - } + public void processIMCRequests(FMLInterModComms.IMCEvent event) { + InterModComms.processIMC(event); + } public static BptPlayerIndex getPlayerIndex(String name) { BptRootIndex rootIndex = getBptRootIndex(); diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index eb84eb13..400b4c7d 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -189,6 +189,7 @@ public class BuildCraftEnergy { bucketOil = new ItemBucketBuildcraft(bucketOilId, blockOil.blockID); bucketOil.setUnlocalizedName("bucketOil").setContainerItem(Item.bucketEmpty); LanguageRegistry.addName(bucketOil, "Oil Bucket"); + CoreProxy.proxy.registerItem(bucketOil); FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("oil", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketOil), new ItemStack(Item.bucketEmpty)); } @@ -196,6 +197,7 @@ public class BuildCraftEnergy { bucketFuel = new ItemBucketBuildcraft(bucketFuelId, blockFuel.blockID); bucketFuel.setUnlocalizedName("bucketFuel").setContainerItem(Item.bucketEmpty); LanguageRegistry.addName(bucketFuel, "Fuel Bucket"); + CoreProxy.proxy.registerItem(bucketFuel); FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("fuel", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketFuel), new ItemStack(Item.bucketEmpty)); } diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 71e12747..309cd3fe 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -264,7 +264,9 @@ public class BuildCraftTransport { pipeWaterproof = new ItemBuildCraft(pipeWaterproofId.getInt()); pipeWaterproof.setUnlocalizedName("pipeWaterproof"); - LanguageRegistry.addName(pipeWaterproof, "Pipe Waterproof"); + LanguageRegistry.addName(pipeWaterproof, "Pipe Sealant"); + CoreProxy.proxy.registerItem(pipeWaterproof); + genericPipeBlock = new BlockGenericPipe(genericPipeId.getInt()); CoreProxy.proxy.registerBlock(genericPipeBlock.setUnlocalizedName("pipeBlock"), ItemBlock.class); @@ -310,6 +312,7 @@ public class BuildCraftTransport { redPipeWire = new ItemBuildCraft(redPipeWireId.getInt()).setPassSneakClick(true); redPipeWire.setUnlocalizedName("redPipeWire"); LanguageRegistry.addName(redPipeWire, "Red Pipe Wire"); + CoreProxy.proxy.registerItem(redPipeWire); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 1), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(redPipeWire, 8))); @@ -317,6 +320,7 @@ public class BuildCraftTransport { bluePipeWire = new ItemBuildCraft(bluePipeWireId.getInt()).setPassSneakClick(true); bluePipeWire.setUnlocalizedName("bluePipeWire"); LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire"); + CoreProxy.proxy.registerItem(bluePipeWire); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 4), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(bluePipeWire, 8))); @@ -324,6 +328,7 @@ public class BuildCraftTransport { greenPipeWire = new ItemBuildCraft(greenPipeWireId.getInt()).setPassSneakClick(true); greenPipeWire.setUnlocalizedName("greenPipeWire"); LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire"); + CoreProxy.proxy.registerItem(greenPipeWire); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 2), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(greenPipeWire, 8))); @@ -331,25 +336,30 @@ public class BuildCraftTransport { yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()).setPassSneakClick(true); yellowPipeWire.setUnlocalizedName("yellowPipeWire"); LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire"); + CoreProxy.proxy.registerItem(yellowPipeWire); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 11), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(yellowPipeWire, 8))); Property pipeGateId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeGate.id", DefaultProps.GATE_ID); pipeGate = new ItemGate(pipeGateId.getInt(), 0); pipeGate.setUnlocalizedName("pipeGate"); + CoreProxy.proxy.registerItem(pipeGate); Property pipeGateAutarchicId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeGateAutarchic.id", DefaultProps.GATE_AUTARCHIC_ID); pipeGateAutarchic = new ItemGate(pipeGateAutarchicId.getInt(), 1); pipeGateAutarchic.setUnlocalizedName("pipeGateAutarchic"); + CoreProxy.proxy.registerItem(pipeGateAutarchic); Property pipeFacadeId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeFacade.id", DefaultProps.PIPE_FACADE_ID); facadeItem = new ItemFacade(pipeFacadeId.getInt()); facadeItem.setUnlocalizedName("pipeFacade"); + CoreProxy.proxy.registerItem(facadeItem); Property pipePlugId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipePlug.id", DefaultProps.PIPE_PLUG_ID); plugItem = new ItemPlug(pipePlugId.getInt()); plugItem.setUnlocalizedName("pipePlug"); + CoreProxy.proxy.registerItem(plugItem); Property filteredBufferId = BuildCraftCore.mainConfiguration.getBlock("filteredBuffer.id", DefaultProps.FILTERED_BUFFER_ID); filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt());