From 3d1815595b88cb4af475f051e6e5f05a6f5a0dc8 Mon Sep 17 00:00:00 2001 From: taelnia Date: Fri, 15 Nov 2013 21:07:15 -0500 Subject: [PATCH 01/45] Add Ore Dictionary support for Assembly Recipes --- common/buildcraft/api/recipes/AssemblyRecipe.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/buildcraft/api/recipes/AssemblyRecipe.java b/common/buildcraft/api/recipes/AssemblyRecipe.java index 573db282..29b1dcee 100644 --- a/common/buildcraft/api/recipes/AssemblyRecipe.java +++ b/common/buildcraft/api/recipes/AssemblyRecipe.java @@ -2,6 +2,7 @@ package buildcraft.api.recipes; import java.util.LinkedList; import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; public class AssemblyRecipe { @@ -35,6 +36,16 @@ public class AssemblyRecipe { if (item.isItemEqual(in)) { found += item.stackSize; // Adds quantity of stack to amount // found + } else { + int oreID = OreDictionary.getOreID(in); + if (oreID >= 0) { + for (ItemStack oreItem : OreDictionary.getOres(oreID)) { + if(OreDictionary.itemMatches(oreItem, item, false)) { + found += item.stackSize; + break; + } + } + } } } From e825066fd037193dfa54fde02614f0b2c359f904 Mon Sep 17 00:00:00 2001 From: Taelnia Date: Fri, 15 Nov 2013 22:27:30 -0500 Subject: [PATCH 02/45] Revert "Add Ore Dictionary support for Assembly Recipes" This reverts commit 3d1815595b88cb4af475f051e6e5f05a6f5a0dc8. --- common/buildcraft/api/recipes/AssemblyRecipe.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/common/buildcraft/api/recipes/AssemblyRecipe.java b/common/buildcraft/api/recipes/AssemblyRecipe.java index 29b1dcee..573db282 100644 --- a/common/buildcraft/api/recipes/AssemblyRecipe.java +++ b/common/buildcraft/api/recipes/AssemblyRecipe.java @@ -2,7 +2,6 @@ package buildcraft.api.recipes; import java.util.LinkedList; import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; public class AssemblyRecipe { @@ -36,16 +35,6 @@ public class AssemblyRecipe { if (item.isItemEqual(in)) { found += item.stackSize; // Adds quantity of stack to amount // found - } else { - int oreID = OreDictionary.getOreID(in); - if (oreID >= 0) { - for (ItemStack oreItem : OreDictionary.getOres(oreID)) { - if(OreDictionary.itemMatches(oreItem, item, false)) { - found += item.stackSize; - break; - } - } - } } } From 91e56489030c3f93d150e10364b244ddbbef7770 Mon Sep 17 00:00:00 2001 From: taelnia Date: Fri, 15 Nov 2013 22:32:30 -0500 Subject: [PATCH 03/45] Prevent Iron Pipes from switching to a plugged side --- common/buildcraft/transport/pipes/PipeLogicIron.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/buildcraft/transport/pipes/PipeLogicIron.java b/common/buildcraft/transport/pipes/PipeLogicIron.java index 486cdb0b..f7b67750 100644 --- a/common/buildcraft/transport/pipes/PipeLogicIron.java +++ b/common/buildcraft/transport/pipes/PipeLogicIron.java @@ -55,6 +55,8 @@ public abstract class PipeLogicIron { return true; TileEntity tile = tileBuffer[side.ordinal()].getTile(); + if ((pipe.container.hasPlug(side)) || (tile != null && tile instanceof TileGenericPipe && ((TileGenericPipe)tile).pipe.container.hasPlug(side.getOpposite()))) + return false; return isValidConnectingTile(tile); } From 05fedb059edbefb57a1730322be3a3f1871c3a1a Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 15 Nov 2013 21:20:46 -0800 Subject: [PATCH 04/45] Buff Oil Spring output It should now produce 4x time amount of Oil, resulting in the same energy output from before the Oil nerf. --- common/buildcraft/core/BlockSpring.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/core/BlockSpring.java b/common/buildcraft/core/BlockSpring.java index b6a3e503..6859e820 100644 --- a/common/buildcraft/core/BlockSpring.java +++ b/common/buildcraft/core/BlockSpring.java @@ -18,7 +18,7 @@ public class BlockSpring extends Block { public enum EnumSpring { WATER(5, -1, Block.waterStill), - OIL(6000, 32, null); // Set in BuildCraftEnergy + OIL(6000, 8, null); // Set in BuildCraftEnergy public static final EnumSpring[] VALUES = values(); public final int tickRate, chance; public Block liquidBlock; From 372941c32f04e472366c2c39aa1f028bd9766091 Mon Sep 17 00:00:00 2001 From: taelnia Date: Sat, 16 Nov 2013 11:23:37 -0500 Subject: [PATCH 05/45] simplify code for iron pipe facing check --- common/buildcraft/transport/pipes/PipeLogicIron.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/transport/pipes/PipeLogicIron.java b/common/buildcraft/transport/pipes/PipeLogicIron.java index f7b67750..c076c62a 100644 --- a/common/buildcraft/transport/pipes/PipeLogicIron.java +++ b/common/buildcraft/transport/pipes/PipeLogicIron.java @@ -47,6 +47,9 @@ public abstract class PipeLogicIron { private boolean isValidFacing(ForgeDirection side) { + if (!pipe.container.isPipeConnected(side)) + return false; + TileBuffer[] tileBuffer = pipe.container.getTileCache(); if (tileBuffer == null) return true; @@ -55,8 +58,6 @@ public abstract class PipeLogicIron { return true; TileEntity tile = tileBuffer[side.ordinal()].getTile(); - if ((pipe.container.hasPlug(side)) || (tile != null && tile instanceof TileGenericPipe && ((TileGenericPipe)tile).pipe.container.hasPlug(side.getOpposite()))) - return false; return isValidConnectingTile(tile); } From 26572907bc69919c114158b27bc9040d1576fed5 Mon Sep 17 00:00:00 2001 From: Taelnia Date: Sat, 16 Nov 2013 20:19:54 -0500 Subject: [PATCH 06/45] Changes to AssemblyRecipe to support OreDict - Moved AssemblyRecipes to Init phase in BuildCraftTransport so that the OreDictionary is completed by then - Added new AssemblyRecipe constructor that can take ore tag strings paired with a desired stack size - Changed pipe wires over to new constructor --- common/buildcraft/BuildCraftTransport.java | 22 +++--- .../api/recipes/AssemblyRecipe.java | 77 +++++++++++++++++-- 2 files changed, 83 insertions(+), 16 deletions(-) diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 309cd3fe..94b33b1a 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -313,32 +313,24 @@ public class BuildCraftTransport { 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))); Property bluePipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "bluePipeWire.id", DefaultProps.BLUE_PIPE_WIRE); 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))); Property greenPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "greenPipeWire.id", DefaultProps.GREEN_PIPE_WIRE); 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))); Property yellowPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "yellowPipeWire.id", DefaultProps.YELLOW_PIPE_WIRE); 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); @@ -365,9 +357,6 @@ public class BuildCraftTransport { filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt()); CoreProxy.proxy.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock")); CoreProxy.proxy.addName(filteredBufferBlock, "Filtered Buffer"); - - AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8))); - } finally { BuildCraftCore.mainConfiguration.save(); } @@ -449,6 +438,17 @@ public class BuildCraftTransport { //Facade turning helper GameRegistry.addRecipe(facadeItem.new FacadeRecipe()); + + // Assembly table recipes, moved from PreInit phase to Init, all mods should be done adding to the OreDictionary by now + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new Object[]{"dyeRed", 1, new ItemStack(Item.redstone, 1), + new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(redPipeWire, 8))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new Object[]{"dyeBlue", 1, new ItemStack(Item.redstone, 1), + new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(bluePipeWire, 8))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new Object[]{"dyeGreen", 1, new ItemStack(Item.redstone, 1), + new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(greenPipeWire, 8))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new Object[]{"dyeYellow", 1, new ItemStack(Item.redstone, 1), + new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(yellowPipeWire, 8))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8))); } @EventHandler diff --git a/common/buildcraft/api/recipes/AssemblyRecipe.java b/common/buildcraft/api/recipes/AssemblyRecipe.java index 573db282..b3abbdbc 100644 --- a/common/buildcraft/api/recipes/AssemblyRecipe.java +++ b/common/buildcraft/api/recipes/AssemblyRecipe.java @@ -1,7 +1,9 @@ package buildcraft.api.recipes; +import java.util.ArrayList; import java.util.LinkedList; import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; public class AssemblyRecipe { @@ -11,34 +13,99 @@ public class AssemblyRecipe { public final ItemStack output; public final float energy; + public final Object[] inputOreDict; + public AssemblyRecipe(ItemStack[] input, int energy, ItemStack output) { this.input = input; this.output = output; this.energy = energy; + this.inputOreDict = input; + } + + /** This version of AssemblyRecipe supports the OreDictionary + * + * @param input Object[] containing either an ItemStack, or a paired string and integer(ex: "dyeBlue", 1) + * @param energy MJ cost to produce + * @param output resulting ItemStack + */ + public AssemblyRecipe(Object[] input, int energy, ItemStack output) { + this.output = output; + this.energy = energy; + + this.inputOreDict = new Object[input.length]; + + int count = 0; + for (int idx = 0; idx < input.length; idx++) { + if (input[idx] == null) { + continue; + } + + ItemStack in; + + if (input[idx] instanceof ItemStack) { + inputOreDict[idx] = input[idx]; + count++; + } else if (input[idx] instanceof String) { + ArrayList oreListWithStackSize = new ArrayList(); + + for (ItemStack oreItem : OreDictionary.getOres((String)input[idx])) { + ItemStack sizeAdjustedOreItem = oreItem.copy(); + + //Desired recipe stacksize is on next index + sizeAdjustedOreItem.stackSize = (int)input[idx + 1]; + + oreListWithStackSize.add(sizeAdjustedOreItem); + } + + inputOreDict[idx++] = oreListWithStackSize; + count++; + } + } + + // create the recipe item array + this.input = new ItemStack[count]; + count = 0; + for(Object recipeItem : inputOreDict) { + if (recipeItem == null) { + continue; + } + + // since the API recipe item array is an ItemStack, just grab the first item from the OreDict list + this.input[count++] = recipeItem instanceof ItemStack ? (ItemStack)recipeItem: ((ArrayList)recipeItem).get(0); + } } public boolean canBeDone(ItemStack[] items) { - for (ItemStack in : input) { + for (Object in : inputOreDict) { if (in == null) { continue; } int found = 0; // Amount of ingredient found in inventory + int expected = in instanceof ItemStack ? ((ItemStack)in).stackSize: in instanceof ArrayList ? ((ArrayList)in).get(0).stackSize: 1; for (ItemStack item : items) { if (item == null) { continue; } - if (item.isItemEqual(in)) { - found += item.stackSize; // Adds quantity of stack to amount - // found + if (in instanceof ItemStack) { + if (item.isItemEqual((ItemStack)in)) { + found += item.stackSize; // Adds quantity of stack to amount found + } + } else if (in instanceof ArrayList) { + for (ItemStack oreItem : (ArrayList)in) { + if(OreDictionary.itemMatches(oreItem, item, true)) { + found += item.stackSize; + break; + } + } } } - if (found < in.stackSize) + if (found < expected) return false; // Return false if the amount of ingredient found // is not enough } From 0f5a47f31fbf566c84b75340b15c49c3643eead1 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 19 Nov 2013 03:54:37 -0800 Subject: [PATCH 07/45] Fairly Major Filler Rework Changes: -The "crafting grid" is gone. -API completely reworked -Patterns can be "stateful", this could bring major improvements to the scanning algorithms if utilized -You can change the pattern via Gate Actions -Various peripherally related GUI framework changes --- .../textures/blocks/fillerPatterns/box.png | Bin 0 -> 444 bytes .../fillerPatterns/{fillAll.png => fill.png} | Bin .../blocks/fillerPatterns/pyramid.png | Bin 374 -> 448 bytes .../textures/blocks/fillerPatterns/stairs.png | Bin 375 -> 452 bytes .../textures/blocks/fillerPatterns/walls.png | Bin 369 -> 0 bytes .../buildcraft/textures/gui/buttons.png | Bin 9591 -> 9724 bytes .../assets/buildcraft/textures/gui/filler.png | Bin 1300 -> 1895 bytes .../lang/buildcraft/en_US.properties | 8 + common/buildcraft/BuildCraftBuilders.java | 96 ++--- .../buildcraft/api/filler/IFillerPattern.java | 22 +- .../api/filler/IFillerRegistry.java | 14 +- .../api/filler/IPatternIterator.java | 20 + .../buildcraft/api/filler/package-info.java | 2 +- common/buildcraft/builders/BlockBuilder.java | 3 +- common/buildcraft/builders/BlockFiller.java | 18 +- .../buildcraft/builders/BptBlockFiller.java | 131 ------ .../builders/BuilderProxyClient.java | 8 - .../buildcraft/builders/FillerRegistry.java | 169 -------- common/buildcraft/builders/TileBuilder.java | 2 +- common/buildcraft/builders/TileFiller.java | 313 ++++++-------- .../builders/filler/FillerRegistry.java | 54 +++ .../{ => filler/pattern}/FillerPattern.java | 90 +++- .../pattern/PatternBox.java} | 31 +- .../pattern/PatternClear.java} | 31 +- .../pattern/PatternFill.java} | 30 +- .../pattern/PatternFlatten.java} | 21 +- .../pattern/PatternHorizon.java} | 22 +- .../pattern/PatternPyramid.java} | 31 +- .../pattern/PatternStairs.java} | 33 +- .../builders/gui/ContainerFiller.java | 86 ++-- .../builders/gui/GuiBlueprintLibrary.java | 2 +- .../buildcraft/builders/gui/GuiBuilder.java | 2 +- common/buildcraft/builders/gui/GuiFiller.java | 89 ++-- .../buildcraft/builders/gui/GuiTemplate.java | 2 +- .../builders/triggers/ActionFiller.java | 37 ++ .../triggers/BuildersActionProvider.java | 25 ++ common/buildcraft/core/Box.java | 41 +- .../core/gui/BuildCraftContainer.java | 36 ++ .../core/gui/GuiAdvancedInterface.java | 4 +- common/buildcraft/core/gui/GuiBuildCraft.java | 392 +++++++++--------- common/buildcraft/core/gui/GuiTools.java | 48 +++ .../core/gui/buttons/GuiBetterButton.java | 14 +- .../buttons/StandardButtonTextureSets.java | 4 +- .../buildcraft/core/gui/slots/SlotBase.java | 14 +- .../core/gui/tooltips/IToolTipProvider.java | 14 + .../core/gui/widgets/FluidGaugeWidget.java | 58 +++ .../gui/widgets/IIndicatorController.java | 16 + .../core/gui/widgets/IndicatorController.java | 31 ++ .../core/gui/widgets/IndicatorWidget.java | 33 ++ .../buildcraft/core/gui/widgets/Widget.java | 78 ++++ .../core/inventory/InventoryIterator.java | 9 +- common/buildcraft/core/triggers/BCAction.java | 6 +- .../energy/gui/GuiCombustionEngine.java | 6 +- common/buildcraft/energy/gui/GuiEngine.java | 4 +- .../buildcraft/energy/gui/GuiStoneEngine.java | 2 +- .../factory/gui/GuiAutoCrafting.java | 6 +- .../buildcraft/factory/gui/GuiRefinery.java | 2 +- .../silicon/gui/GuiAdvancedCraftingTable.java | 6 +- .../silicon/gui/GuiAssemblyTable.java | 2 +- .../transport/gui/GuiDiamondPipe.java | 2 +- .../transport/gui/GuiEmeraldPipe.java | 2 +- .../transport/gui/GuiGateInterface.java | 15 +- 62 files changed, 1173 insertions(+), 1064 deletions(-) create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/box.png rename buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/{fillAll.png => fill.png} (100%) delete mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/walls.png create mode 100644 common/buildcraft/api/filler/IPatternIterator.java delete mode 100644 common/buildcraft/builders/BptBlockFiller.java delete mode 100644 common/buildcraft/builders/FillerRegistry.java create mode 100644 common/buildcraft/builders/filler/FillerRegistry.java rename common/buildcraft/builders/{ => filler/pattern}/FillerPattern.java (61%) rename common/buildcraft/builders/{FillerFillWalls.java => filler/pattern/PatternBox.java} (68%) rename common/buildcraft/builders/{FillerRemover.java => filler/pattern/PatternClear.java} (54%) rename common/buildcraft/builders/{FillerFillAll.java => filler/pattern/PatternFill.java} (64%) rename common/buildcraft/builders/{FillerFlattener.java => filler/pattern/PatternFlatten.java} (70%) rename common/buildcraft/builders/{FillerHorizon.java => filler/pattern/PatternHorizon.java} (70%) rename common/buildcraft/builders/{FillerFillPyramid.java => filler/pattern/PatternPyramid.java} (66%) rename common/buildcraft/builders/{FillerFillStairs.java => filler/pattern/PatternStairs.java} (85%) create mode 100644 common/buildcraft/builders/triggers/ActionFiller.java create mode 100644 common/buildcraft/builders/triggers/BuildersActionProvider.java create mode 100644 common/buildcraft/core/gui/GuiTools.java create mode 100644 common/buildcraft/core/gui/tooltips/IToolTipProvider.java create mode 100644 common/buildcraft/core/gui/widgets/FluidGaugeWidget.java create mode 100644 common/buildcraft/core/gui/widgets/IIndicatorController.java create mode 100644 common/buildcraft/core/gui/widgets/IndicatorController.java create mode 100644 common/buildcraft/core/gui/widgets/IndicatorWidget.java create mode 100644 common/buildcraft/core/gui/widgets/Widget.java diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/box.png b/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/box.png new file mode 100644 index 0000000000000000000000000000000000000000..d8a7105f7bf9a5673517be93abeb706b979e21d6 GIT binary patch literal 444 zcmV;t0YmPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qRNAp5A0003iNklDUWFp&rpY%#624PYy!RwKbn)E7P3otUMdiGB~w*^@b$?#xR6r+GS~6k<2p zvVJy87DFq=`|X{V?vYiSCkyE1L^T(Eu(x}LOcn!m?&X@Jt*E6qS>WBz!1AwCt@xk^gpr+`sT zU{+iYF*eY<+Qe`%Fy^6 z^9c1qj1;Gmiy{!ZQ@^u|#bG~q1Y~{FY9#N>6df2J!AW4HpWK6ivqzSQTAU`uc)mUK m4B1u|Lhq{GNRs*klJo^F#kx{I9NgXj0000A^18Gix*005AYXf^-<00DDSM?wIu&K&6g000DMK}|sb0I`n?{9y$E z000SaNLh0L01m?d01m?e$8V@)0000QbVXQnQ*UN;cVTj608n9RZgehAMN}YmGcGkQ zF)>H;LN@>a0WV2JK~y+Tos#WK!cY{(_g8318RUmv?0uO*rGFLnS1Sq{B&pLjW3z3j zZ8_J9#9pYr)Wf|8xhe?t`!JsS@Ep$WIam5W&C4aF5V_Yj^{ZvF7+NVh=p4QG&aB!h zSwJtxs=4s9eb_f-vKYv@w>yrurIw;(fiFJ;%fCys>+57O%<2l-US~r$#RalBLnrlQ zC2d9MIGayDnhL{V{6!IZ`tV+~zhZ5lRVg-zdj0E3U`jA(_E7%zkSh!^OmS zhEVeJ_>R&XUV!D`l9gAUDl=PBxi2q{h_7e>Lv zod(@wEDrm@BOq%;yAgjh6LesF2N!{re09@9=Y%W~wJNwsit+Yv>KU@FtWCVDP9sk0 b4@lB4iYCo+;>Y+A00000NkvXXu0mjfi$}e8 delta 358 zcmV-s0h#{51NH)t8Gi!+001a04^sdD0Hsh&R7C&)0Mx`E&c7Ps(=FG>BGbbj@ZdZ3 z=0V)eDA&j%%)A%v-8ksjGvw7U4v~fXYBI@vFJ%0eUhyVZp07*qoM6N<$ Eg5z+v$p8QV diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/stairs.png b/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/stairs.png index a964597c72f92817d02bb26665951afb32cea685..af83c0ee4d0e186d2bd50e9eed583629d4a4ec40 100644 GIT binary patch delta 437 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 delta 8552 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 Yqq&f+haiDp00i_>zopr0M==wJpcdz diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index 4512f796..e874bafc 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -2,6 +2,14 @@ chat.pipe.power.iron.mode=Switched to %d MJ/t limit +fillerpattern.clear=Clear +fillerpattern.fill=Fill +fillerpattern.flatten=Flatten +fillerpattern.horizon=Horizon +fillerpattern.pyramid=Pyramid +fillerpattern.stairs=Stairs +fillerpattern.box=Box + gate.pipe.empty=Pipe Empty gate.pipe.containsItems=Items Traversing gate.pipe.containsFluids=Fluid Traversing diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index 2254f6b8..26096fd8 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -27,23 +27,23 @@ import buildcraft.api.bptblocks.BptBlockSign; import buildcraft.api.bptblocks.BptBlockStairs; import buildcraft.api.bptblocks.BptBlockWallSide; import buildcraft.api.filler.FillerManager; +import buildcraft.api.gates.ActionManager; import buildcraft.builders.BlockArchitect; import buildcraft.builders.BlockBlueprintLibrary; import buildcraft.builders.BlockBuilder; import buildcraft.builders.BlockFiller; import buildcraft.builders.BlockMarker; import buildcraft.builders.BlockPathMarker; -import buildcraft.builders.BptBlockFiller; import buildcraft.builders.BuilderProxyClient; import buildcraft.builders.EventHandlerBuilders; -import buildcraft.builders.FillerFillAll; -import buildcraft.builders.FillerFillPyramid; -import buildcraft.builders.FillerFillStairs; -import buildcraft.builders.FillerFillWalls; -import buildcraft.builders.FillerFlattener; -import buildcraft.builders.FillerHorizon; -import buildcraft.builders.FillerRegistry; -import buildcraft.builders.FillerRemover; +import buildcraft.builders.filler.pattern.PatternFill; +import buildcraft.builders.filler.pattern.PatternPyramid; +import buildcraft.builders.filler.pattern.PatternStairs; +import buildcraft.builders.filler.pattern.PatternBox; +import buildcraft.builders.filler.pattern.PatternFlatten; +import buildcraft.builders.filler.pattern.PatternHorizon; +import buildcraft.builders.filler.FillerRegistry; +import buildcraft.builders.filler.pattern.PatternClear; import buildcraft.builders.GuiHandler; import buildcraft.builders.IBuilderHook; import buildcraft.builders.ItemBptBluePrint; @@ -54,7 +54,10 @@ import buildcraft.builders.TileBuilder; import buildcraft.builders.TileFiller; import buildcraft.builders.TileMarker; import buildcraft.builders.TilePathMarker; +import buildcraft.builders.filler.pattern.FillerPattern; import buildcraft.builders.network.PacketHandlerBuilders; +import buildcraft.builders.triggers.ActionFiller; +import buildcraft.builders.triggers.BuildersActionProvider; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.Version; @@ -66,6 +69,7 @@ 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.FMLServerStoppingEvent; import cpw.mods.fml.common.network.NetworkMod; @@ -105,6 +109,7 @@ public class BuildCraftBuilders { public static boolean fillerDestroy; public static int fillerLifespanTough; public static int fillerLifespanNormal; + public static ActionFiller[] fillerActions; private static BptRootIndex rootBptIndex; public static TreeMap playerLibrary = new TreeMap(); private static LinkedList hooks = new LinkedList(); @@ -112,10 +117,7 @@ public class BuildCraftBuilders { public static BuildCraftBuilders instance; @EventHandler - public void load(FMLInitializationEvent evt) { - // Create filler registry - FillerManager.registry = new FillerRegistry(); - + public void init(FMLInitializationEvent evt) { // Register gui handler NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler()); @@ -208,7 +210,6 @@ public class BuildCraftBuilders { new BptBlockWallSide(markerBlock.blockID); new BptBlockWallSide(pathMarkerBlock.blockID); - new BptBlockFiller(fillerBlock.blockID); if (BuildCraftCore.loadDefaultRecipes) { loadRecipes(); @@ -217,7 +218,7 @@ public class BuildCraftBuilders { } @EventHandler - public void initialize(FMLPreInitializationEvent evt) { + public void preInit(FMLPreInitializationEvent evt) { Property templateItemId = BuildCraftCore.mainConfiguration.getItem("templateItem.id", DefaultProps.TEMPLATE_ITEM_ID); Property blueprintItemId = BuildCraftCore.mainConfiguration.getItem("blueprintItem.id", DefaultProps.BLUEPRINT_ITEM_ID); Property markerId = BuildCraftCore.mainConfiguration.getBlock("marker.id", DefaultProps.MARKER_ID); @@ -286,19 +287,25 @@ public class BuildCraftBuilders { MinecraftForge.EVENT_BUS.register(this); - // public static final Block music; - // public static final Block cloth; - // public static final Block tilledField; - // public static final BlockPortal portal; - // public static final Block trapdoor; + // Create filler registry + FillerManager.registry = new FillerRegistry(); - // STANDARD BLOCKS + // INIT FILLER PATTERNS + FillerManager.registry.addPattern(PatternFill.INSTANCE); + FillerManager.registry.addPattern(new PatternFlatten()); + FillerManager.registry.addPattern(new PatternHorizon()); + FillerManager.registry.addPattern(new PatternClear()); + FillerManager.registry.addPattern(new PatternBox()); + FillerManager.registry.addPattern(new PatternPyramid()); + FillerManager.registry.addPattern(new PatternStairs()); + + ActionManager.registerActionProvider(new BuildersActionProvider()); } public static void loadRecipes() { - 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(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", 'i', // new ItemStack(Item.dyePowder, 1, 4), 'p', Item.paper}); @@ -306,34 +313,24 @@ public class BuildCraftBuilders { 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 ", 'l', - new ItemStack(Item.dyePowder, 1, 2), '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", '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", '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(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", '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(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", 'b', - new ItemStack(blueprintItem), 'B', Block.bookShelf}); - - - // / INIT FILLER PATTERNS - FillerManager.registry.addRecipe(new FillerFillAll(), new Object[]{"bbb", "bbb", "bbb", 'g', Block.glass, 'b', Block.brick}); - FillerManager.registry.addRecipe(new FillerFlattener(), new Object[]{"ggg", "bbb", "bbb", 'g', Block.glass, 'b', Block.brick}); - FillerManager.registry.addRecipe(new FillerHorizon(), new Object[]{"ggg", "ggg", "bbb", 'g', Block.glass, 'b', Block.brick}); - FillerManager.registry.addRecipe(new FillerRemover(), new Object[]{"ggg", "ggg", "ggg", 'g', Block.glass, 'b', Block.brick}); - FillerManager.registry.addRecipe(new FillerFillWalls(), new Object[]{"bbb", "b b", "bbb", 'g', Block.glass, 'b', Block.brick}); - 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}); +// CoreProxy.proxy.addCraftingRecipe(new ItemStack(libraryBlock, 1), new Object[]{"bbb", "bBb", "bbb", 'b', +// new ItemStack(blueprintItem), 'B', Block.bookShelf}); } @EventHandler @@ -400,14 +397,9 @@ public class BuildCraftBuilders { @SideOnly(Side.CLIENT) public void loadTextures(TextureStitchEvent.Pre evt) { if (evt.map.textureType == 0) { - TextureMap terrainMap = evt.map; - BuilderProxyClient.fillerFillAllTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/fillAll"); - BuilderProxyClient.fillerClearTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/clear"); - BuilderProxyClient.fillerWallsTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/walls"); - BuilderProxyClient.fillerStairsTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/stairs"); - BuilderProxyClient.fillerFlattenTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/flatten"); - BuilderProxyClient.fillerHorizonTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/horizon"); - BuilderProxyClient.fillerPyramidTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/pyramid"); + for (FillerPattern pattern : FillerPattern.patterns) { + pattern.registerIcon(evt.map); + } } } } diff --git a/common/buildcraft/api/filler/IFillerPattern.java b/common/buildcraft/api/filler/IFillerPattern.java index dd5862bb..45dce17b 100644 --- a/common/buildcraft/api/filler/IFillerPattern.java +++ b/common/buildcraft/api/filler/IFillerPattern.java @@ -3,21 +3,27 @@ package buildcraft.api.filler; import buildcraft.api.core.IBox; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; +import net.minecraftforge.common.ForgeDirection; public interface IFillerPattern { - public int getId(); + public String getUniqueTag(); - public void setId(int id); - - public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace); + /** + * Creates the object that does the pattern iteration. This object may be + * state-full and will be used until the pattern is done or changes. + * + * @param tile the Filler + * @param box the area to fill + * @param orientation not currently used, but may be in the future (the filler needs some orientation code) + * @return + */ + public IPatternIterator createPatternIterator(TileEntity tile, IBox box, ForgeDirection orientation); @SideOnly(Side.CLIENT) - public Icon getTexture(); - - public String getName(); + public Icon getIcon(); + public String getDisplayName(); } diff --git a/common/buildcraft/api/filler/IFillerRegistry.java b/common/buildcraft/api/filler/IFillerRegistry.java index 12bf9799..f0b4c950 100644 --- a/common/buildcraft/api/filler/IFillerRegistry.java +++ b/common/buildcraft/api/filler/IFillerRegistry.java @@ -1,15 +1,17 @@ package buildcraft.api.filler; -import net.minecraft.inventory.IInventory; +import buildcraft.api.gates.IAction; +import java.util.Set; public interface IFillerRegistry { - public void addRecipe(IFillerPattern pattern, Object aobj[]); + public void addPattern(IFillerPattern pattern); - public IFillerPattern findMatchingRecipe(IInventory inventorycrafting); + public IFillerPattern getPattern(String patternName); - public int getPatternNumber(IFillerPattern pattern); - - public IFillerPattern getPattern(int n); + public IFillerPattern getNextPattern(IFillerPattern currentPattern); + public IFillerPattern getPreviousPattern(IFillerPattern currentPattern); + + public Set getActions(); } diff --git a/common/buildcraft/api/filler/IPatternIterator.java b/common/buildcraft/api/filler/IPatternIterator.java new file mode 100644 index 00000000..0ea8c202 --- /dev/null +++ b/common/buildcraft/api/filler/IPatternIterator.java @@ -0,0 +1,20 @@ +/* + * 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.api.filler; + +import net.minecraft.item.ItemStack; + +/** + * + * @author CovertJaguar + */ +public interface IPatternIterator { + + public boolean iteratePattern(ItemStack stackToPlace); +} diff --git a/common/buildcraft/api/filler/package-info.java b/common/buildcraft/api/filler/package-info.java index 6bd704d3..ee52b320 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="BuildCraftAPI|core",provides="BuildCraftAPI|filler") +@API(apiVersion="2.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/builders/BlockBuilder.java b/common/buildcraft/builders/BlockBuilder.java index e4681785..cc1f52f0 100644 --- a/common/buildcraft/builders/BlockBuilder.java +++ b/common/buildcraft/builders/BlockBuilder.java @@ -10,7 +10,6 @@ package buildcraft.builders; import buildcraft.BuildCraftBuilders; import buildcraft.api.core.Position; import buildcraft.api.tools.IToolWrench; -import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.GuiIds; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; @@ -38,7 +37,7 @@ public class BlockBuilder extends BlockContainer { public BlockBuilder(int i) { super(i, Material.iron); setHardness(5F); - setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); + setCreativeTab(null); } @Override diff --git a/common/buildcraft/builders/BlockFiller.java b/common/buildcraft/builders/BlockFiller.java index 9e052f9d..0bc65309 100644 --- a/common/buildcraft/builders/BlockFiller.java +++ b/common/buildcraft/builders/BlockFiller.java @@ -56,29 +56,25 @@ public class BlockFiller extends BlockContainer { } - @SuppressWarnings({ "all" }) - public Icon getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) { - int m = iblockaccess.getBlockMetadata(i, j, k); - - if (iblockaccess == null) - return getIcon(i, m); - - TileEntity tile = iblockaccess.getBlockTileEntity(i, j, k); + @Override + public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) { + int m = world.getBlockMetadata(x, y, z); + TileEntity tile = world.getBlockTileEntity(x, y, z); if (tile != null && tile instanceof TileFiller) { TileFiller filler = (TileFiller) tile; - if (l == 1 || l == 0) { + if (side == 1 || side == 0) { if (!filler.isActive()) return textureTopOff; else return textureTopOn; } else if (filler.currentPattern != null) - return filler.currentPattern.getTexture(); + return filler.currentPattern.getIcon(); else return textureSides; } - return getIcon(l, m); + return getIcon(side, m); } @Override diff --git a/common/buildcraft/builders/BptBlockFiller.java b/common/buildcraft/builders/BptBlockFiller.java deleted file mode 100644 index 4b645033..00000000 --- a/common/buildcraft/builders/BptBlockFiller.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright (c) SpaceToad, 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.builders; - -import buildcraft.BuildCraftBuilders; -import buildcraft.api.blueprints.BptBlock; -import buildcraft.api.blueprints.BptBlockUtils; -import buildcraft.api.blueprints.BptSlotInfo; -import buildcraft.api.blueprints.IBptContext; -import buildcraft.api.core.LaserKind; -import buildcraft.api.core.Position; -import buildcraft.core.Box; -import java.util.LinkedList; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -@Deprecated -public class BptBlockFiller extends BptBlock { - - public BptBlockFiller(int blockId) { - super(blockId); - } - - @Override - public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - ItemStack[] recipeStack = BptBlockUtils.getItemStacks(slot, context); - - for (int i = 0; i < recipeStack.length; ++i) { - if (recipeStack[i] != null) { - requirements.add(recipeStack[i]); - } - } - - requirements.add(new ItemStack(BuildCraftBuilders.fillerBlock)); - } - - @Override - public void rotateLeft(BptSlotInfo slot, IBptContext context) { - super.rotateLeft(slot, context); - - Box box = new Box(); - box.initialize(slot.cpt.getCompoundTag("box")); - - Position pMin = context.rotatePositionLeft(box.pMin()); - Position pMax = context.rotatePositionLeft(box.pMax()); - - box.xMin = (int) pMin.x; - box.yMin = (int) pMin.y; - box.zMin = (int) pMin.z; - - box.xMax = (int) pMax.x; - box.yMax = (int) pMax.y; - box.zMax = (int) pMax.z; - - box.reorder(); - - NBTTagCompound cpt = new NBTTagCompound(); - - box.writeToNBT(cpt); - slot.cpt.setTag("box", cpt); - } - - @Override - public void buildBlock(BptSlotInfo slot, IBptContext context) { - context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId); - - TileFiller filler = (TileFiller) context.world().getBlockTileEntity(slot.x, slot.y, slot.z); - - Box box = new Box(); - box.initialize(slot.cpt.getCompoundTag("box")); - - box.xMin += context.surroundingBox().pMin().x; - box.yMin += context.surroundingBox().pMin().y; - box.zMin += context.surroundingBox().pMin().z; - - box.xMax += context.surroundingBox().pMin().x; - box.yMax += context.surroundingBox().pMin().y; - box.zMax += context.surroundingBox().pMin().z; - - box.reorder(); - - filler.box.deleteLasers(); - filler.box = box; - filler.box.createLasers(context.world(), LaserKind.Stripes); - - ItemStack[] recipeStack = BptBlockUtils.getItemStacks(slot, context); - - for (int i = 0; i < recipeStack.length; ++i) { - filler.setInventorySlotContents(i, recipeStack[i]); - } - } - - @Override - public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) { - TileFiller filler = (TileFiller) context.world().getBlockTileEntity(x, y, z); - - NBTTagCompound cpt = new NBTTagCompound(); - - Box fillerBox = new Box(); - fillerBox.initialize(filler.box); - - fillerBox.xMin -= context.surroundingBox().pMin().x; - fillerBox.yMin -= context.surroundingBox().pMin().y; - fillerBox.zMin -= context.surroundingBox().pMin().z; - - fillerBox.xMax -= context.surroundingBox().pMin().x; - fillerBox.yMax -= context.surroundingBox().pMin().y; - fillerBox.zMax -= context.surroundingBox().pMin().z; - - fillerBox.reorder(); - - fillerBox.writeToNBT(cpt); - slot.cpt.setTag("box", cpt); - - ItemStack[] recipeStack = new ItemStack[9]; - - for (int i = 0; i < 9; ++i) { - recipeStack[i] = filler.getStackInSlot(i); - } - - BptBlockUtils.setItemStacks(slot, context, recipeStack); - } - -} diff --git a/common/buildcraft/builders/BuilderProxyClient.java b/common/buildcraft/builders/BuilderProxyClient.java index c1f3cafc..f06a6569 100644 --- a/common/buildcraft/builders/BuilderProxyClient.java +++ b/common/buildcraft/builders/BuilderProxyClient.java @@ -1,16 +1,8 @@ package buildcraft.builders; import buildcraft.BuildCraftBuilders; -import net.minecraft.util.Icon; public class BuilderProxyClient extends BuilderProxy { - public static Icon fillerFillAllTexture; - public static Icon fillerClearTexture; - public static Icon fillerWallsTexture; - public static Icon fillerStairsTexture; - public static Icon fillerFlattenTexture; - public static Icon fillerHorizonTexture; - public static Icon fillerPyramidTexture; @Override public void registerClientHook() { diff --git a/common/buildcraft/builders/FillerRegistry.java b/common/buildcraft/builders/FillerRegistry.java deleted file mode 100644 index c8325a2b..00000000 --- a/common/buildcraft/builders/FillerRegistry.java +++ /dev/null @@ -1,169 +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.builders; - -import buildcraft.api.filler.IFillerPattern; -import buildcraft.api.filler.IFillerRegistry; -import java.util.HashMap; -import java.util.LinkedList; -import net.minecraft.block.Block; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -public class FillerRegistry implements IFillerRegistry { - - static class ShapedPatternRecipe { - - private int recipeWidth; - private int recipeHeight; - private ItemStack recipeItems[]; - private IFillerPattern recipeOutput; - - public ShapedPatternRecipe(int i, int j, ItemStack aitemstack[], IFillerPattern pattern) { - recipeWidth = i; - recipeHeight = j; - recipeItems = aitemstack; - recipeOutput = pattern; - } - - public boolean matches(IInventory inventorycrafting) { - for (int i = 0; i <= 3 - recipeWidth; i++) { - for (int j = 0; j <= 3 - recipeHeight; j++) { - if (func_21137_a(inventorycrafting, i, j, true)) - return true; - if (func_21137_a(inventorycrafting, i, j, false)) - return true; - } - - } - - return false; - } - - private boolean func_21137_a(IInventory inventorycrafting, int i, int j, boolean flag) { - for (int k = 0; k < 3; k++) { - for (int l = 0; l < 3; l++) { - int i1 = k - i; - int j1 = l - j; - ItemStack itemstack = null; - if (i1 >= 0 && j1 >= 0 && i1 < recipeWidth && j1 < recipeHeight) { - if (flag) { - itemstack = recipeItems[(recipeWidth - i1 - 1) + j1 * recipeWidth]; - } else { - itemstack = recipeItems[i1 + j1 * recipeWidth]; - } - } - ItemStack itemstack1 = inventorycrafting.getStackInSlot(k + l * 3); - if (itemstack1 == null && itemstack == null) { - continue; - } - if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null) - return false; - if (itemstack.itemID != itemstack1.itemID) - return false; - if (itemstack.getItemDamage() != -1 && itemstack.getItemDamage() != itemstack1.getItemDamage()) - return false; - } - - } - - return true; - } - - } - - static LinkedList recipes = new LinkedList(); - - @Override - public void addRecipe(IFillerPattern pattern, Object aobj[]) { - String s = ""; - int i = 0; - int j = 0; - int k = 0; - if (aobj[i] instanceof String[]) { - String as[] = (String[]) aobj[i++]; - for (int l = 0; l < as.length; l++) { - String s2 = as[l]; - k++; - j = s2.length(); - s = (new StringBuilder()).append(s).append(s2).toString(); - } - - } else { - while (aobj[i] instanceof String) { - String s1 = (String) aobj[i++]; - k++; - j = s1.length(); - s = (new StringBuilder()).append(s).append(s1).toString(); - } - } - HashMap hashmap = new HashMap(); - for (; i < aobj.length; i += 2) { - Character character = (Character) aobj[i]; - ItemStack itemstack1 = null; - if (aobj[i + 1] instanceof Item) { - itemstack1 = new ItemStack((Item) aobj[i + 1]); - } else if (aobj[i + 1] instanceof Block) { - itemstack1 = new ItemStack((Block) aobj[i + 1], 1, -1); - } else if (aobj[i + 1] instanceof ItemStack) { - itemstack1 = (ItemStack) aobj[i + 1]; - } - hashmap.put(character, itemstack1); - } - - ItemStack aitemstack[] = new ItemStack[j * k]; - for (int i1 = 0; i1 < j * k; i1++) { - char c = s.charAt(i1); - if (hashmap.containsKey(Character.valueOf(c))) { - aitemstack[i1] = hashmap.get(Character.valueOf(c)).copy(); - } else { - aitemstack[i1] = null; - } - } - - recipes.add(new ShapedPatternRecipe(j, k, aitemstack, pattern)); - pattern.setId(recipes.size()); - } - - @Override - public IFillerPattern findMatchingRecipe(IInventory inventorycrafting) { - for (int i = 0; i < recipes.size(); i++) { - ShapedPatternRecipe irecipe = recipes.get(i); - if (irecipe.matches(inventorycrafting)) - return irecipe.recipeOutput; - } - - return null; - } - - @Override - public int getPatternNumber(IFillerPattern pattern) { - int i = 0; - - for (ShapedPatternRecipe recipe : recipes) { - if (recipe.recipeOutput == pattern) - return i; - - i++; - } - - return -1; - } - - @Override - public IFillerPattern getPattern(int n) { - if (n <= 0) - return null; - - return recipes.get(n - 1).recipeOutput; - } - -} diff --git a/common/buildcraft/builders/TileBuilder.java b/common/buildcraft/builders/TileBuilder.java index 33810d4d..fc2b84e1 100644 --- a/common/buildcraft/builders/TileBuilder.java +++ b/common/buildcraft/builders/TileBuilder.java @@ -337,7 +337,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP box.reset(); /* - box.initialize(bluePrintBuilder); + box.preInit(bluePrintBuilder); box.createLasers(worldObj, LaserKind.Stripes); */ } diff --git a/common/buildcraft/builders/TileFiller.java b/common/buildcraft/builders/TileFiller.java index ea2e9375..b71ac112 100644 --- a/common/buildcraft/builders/TileFiller.java +++ b/common/buildcraft/builders/TileFiller.java @@ -12,53 +12,57 @@ import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.LaserKind; import buildcraft.api.filler.FillerManager; import buildcraft.api.filler.IFillerPattern; +import buildcraft.api.filler.IPatternIterator; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IActionReceptor; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.Type; +import buildcraft.builders.filler.pattern.PatternFill; +import buildcraft.builders.triggers.ActionFiller; import buildcraft.core.Box; import buildcraft.core.IMachine; import buildcraft.core.TileBuildCraft; +import buildcraft.core.inventory.InventoryIterator; +import buildcraft.core.inventory.InventoryIterator.IInvSlot; +import buildcraft.core.inventory.SimpleInventory; +import buildcraft.core.network.IGuiReturnHandler; +import buildcraft.core.network.PacketPayload; +import buildcraft.core.network.PacketPayloadStream; import buildcraft.core.network.PacketUpdate; -import buildcraft.core.network.TileNetworkData; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.triggers.ActionMachineControl; import buildcraft.core.triggers.ActionMachineControl.Mode; import buildcraft.core.utils.Utils; +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.ISidedInventory; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.ForgeDirection; -public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowerReceptor, IMachine, IActionReceptor { +public class TileFiller extends TileBuildCraft implements IInventory, IPowerReceptor, IMachine, IActionReceptor, IGuiReturnHandler { - private static int[] SLOTS_GRID = Utils.createSlotArray(0, 9); - private static int[] SLOTS_INPUT = Utils.createSlotArray(9, 27); - public @TileNetworkData - Box box = new Box(); - public @TileNetworkData - int currentPatternId = 0; - public @TileNetworkData - boolean done = true; - public IFillerPattern currentPattern; - boolean forceDone = false; - private ItemStack contents[]; + public IFillerPattern currentPattern = PatternFill.INSTANCE; + private static int POWER_USAGE = 25; + private final Box box = new Box(); + private boolean done = false; + private IPatternIterator patternIterator; private PowerHandler powerHandler; private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown; + private SimpleInventory inv = new SimpleInventory(27, "Filler", 64); public TileFiller() { - contents = new ItemStack[getSizeInventory()]; + inv.addListener(this); powerHandler = new PowerHandler(this, Type.MACHINE); initPowerProvider(); } private void initPowerProvider() { - powerHandler.configure(30, 50, 25, 100); + powerHandler.configure(30, POWER_USAGE * 2, POWER_USAGE, POWER_USAGE * 4); powerHandler.configurePowerPerdition(1, 1); } @@ -82,23 +86,15 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe sendNetworkUpdate(); } } - - computeRecipe(); } @Override public void updateEntity() { super.updateEntity(); - if (done) { if (lastMode == Mode.Loop) { done = false; - } else - return; - } - - if (powerHandler.getEnergyStored() >= 25) { - doWork(powerHandler); + } } } @@ -106,132 +102,68 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe public void doWork(PowerHandler workProvider) { if (CoreProxy.proxy.isRenderWorld(worldObj)) return; - + if (done) + return; if (lastMode == Mode.Off) return; - - if (powerHandler.useEnergy(25, 25, true) < 25) + if (powerHandler.useEnergy(POWER_USAGE, POWER_USAGE, false) != POWER_USAGE) + return; + if (!box.isInitialized()) return; - if (box.isInitialized() && currentPattern != null && !done) { - ItemStack stack = null; - int stackId = 0; + if (patternIterator == null) + patternIterator = currentPattern.createPatternIterator(this, box, ForgeDirection.NORTH); - for (int s = 9; s < getSizeInventory(); ++s) { - if (getStackInSlot(s) != null && getStackInSlot(s).stackSize > 0) { + ItemStack stackToUse = null; + int slotNum = 0; - stack = contents[s]; - stackId = s; - - break; - } - } - - done = currentPattern.iteratePattern(this, box, stack); - - if (stack != null && stack.stackSize == 0) { - contents[stackId] = null; - } - - if (done) { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - sendNetworkUpdate(); + for (IInvSlot slot : InventoryIterator.getIterable(inv, ForgeDirection.UNKNOWN)) { + ItemStack stack = slot.getStackInSlot(); + if (stack != null && stack.stackSize > 0) { + stackToUse = stack; + slotNum = slot.getIndex(); + break; } } - if (powerHandler.getEnergyStored() >= 25) { + done = patternIterator.iteratePattern(stackToUse); + powerHandler.useEnergy(POWER_USAGE, POWER_USAGE, true); + + if (stackToUse != null && stackToUse.stackSize <= 0) { + setInventorySlotContents(slotNum, null); + } + + if (done) { + patternIterator = null; + sendNetworkUpdate(); + } else if (powerHandler.getEnergyStored() >= POWER_USAGE) { doWork(workProvider); } } @Override public final int getSizeInventory() { - return 36; + return inv.getSizeInventory(); } @Override - public ItemStack getStackInSlot(int i) { - return contents[i]; - } - - public void computeRecipe() { - if (CoreProxy.proxy.isRenderWorld(worldObj)) - return; - - IFillerPattern newPattern = FillerManager.registry.findMatchingRecipe(this); - - if (newPattern == currentPattern) - return; - - currentPattern = newPattern; - - if (currentPattern == null || forceDone) { - done = lastMode != Mode.Loop; - forceDone = false; - } else { - done = false; - } - - if (worldObj != null) { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - - if (currentPattern == null) { - currentPatternId = 0; - } else { - currentPatternId = currentPattern.getId(); - } - - if (CoreProxy.proxy.isSimulating(worldObj)) { - sendNetworkUpdate(); - } + public ItemStack getStackInSlot(int slot) { + return inv.getStackInSlot(slot); } @Override - public ItemStack decrStackSize(int i, int j) { - if (contents[i] != null) { - if (contents[i].stackSize <= j) { - ItemStack itemstack = contents[i]; - contents[i] = null; - // onInventoryChanged(); - - computeRecipe(); - - return itemstack; - } - - ItemStack itemstack1 = contents[i].splitStack(j); - - if (contents[i].stackSize == 0) { - contents[i] = null; - } - // onInventoryChanged(); - - computeRecipe(); - - return itemstack1; - } else - return null; + public ItemStack decrStackSize(int slot, int amount) { + return inv.decrStackSize(slot, amount); } @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - contents[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); - } - - computeRecipe(); - // onInventoryChanged(); + public void setInventorySlotContents(int slot, ItemStack stack) { + inv.setInventorySlotContents(slot, stack); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - if (contents[slot] == null) - return null; - ItemStack toReturn = contents[slot]; - contents[slot] = null; - return toReturn; + return inv.getStackInSlotOnClosing(slot); } @Override @@ -240,40 +172,44 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe } @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); - Utils.readStacksFromNBT(nbttagcompound, "Items", contents); + inv.readFromNBT(nbt); - if (nbttagcompound.hasKey("box")) { - box.initialize(nbttagcompound.getCompoundTag("box")); - } + if (nbt.hasKey("pattern")) + currentPattern = FillerManager.registry.getPattern(nbt.getString("pattern")); - done = nbttagcompound.getBoolean("done"); - lastMode = Mode.values()[nbttagcompound.getByte("lastMode")]; + if (currentPattern == null) + currentPattern = PatternFill.INSTANCE; - forceDone = done; + if (nbt.hasKey("box")) + box.initialize(nbt.getCompoundTag("box")); + + done = nbt.getBoolean("done"); + lastMode = Mode.values()[nbt.getByte("lastMode")]; } @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - super.writeToNBT(nbttagcompound); + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); - Utils.writeStacksToNBT(nbttagcompound, "Items", contents); + inv.writeToNBT(nbt); - if (box != null) { - NBTTagCompound boxStore = new NBTTagCompound(); - box.writeToNBT(boxStore); - nbttagcompound.setTag("box", boxStore); - } + if (currentPattern != null) + nbt.setString("pattern", currentPattern.getUniqueTag()); - nbttagcompound.setBoolean("done", done); - nbttagcompound.setByte("lastMode", (byte) lastMode.ordinal()); + NBTTagCompound boxStore = new NBTTagCompound(); + box.writeToNBT(boxStore); + nbt.setTag("box", boxStore); + + nbt.setBoolean("done", done); + nbt.setByte("lastMode", (byte) lastMode.ordinal()); } @Override public int getInventoryStackLimit() { - return 64; + return inv.getInventoryStackLimit(); } @Override @@ -291,37 +227,52 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe @Override public void destroy() { - if (box != null) { - box.deleteLasers(); + box.deleteLasers(); + } + + public void setPattern(IFillerPattern pattern) { + if (pattern != null && currentPattern != pattern) { + currentPattern = pattern; + patternIterator = null; + done = false; + sendNetworkUpdate(); + } + } + + @Override + public PacketPayload getPacketPayload() { + PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { + @Override + public void writeData(DataOutputStream data) throws IOException { + box.writeToStream(data); + data.writeBoolean(done); + data.writeUTF(currentPattern.getUniqueTag()); + } + }); + + return payload; + } + + public void handlePacketPayload(DataInputStream data) throws IOException { + boolean initialized = box.isInitialized(); + box.readFromStream(data); + done = data.readBoolean(); + setPattern(FillerManager.registry.getPattern(data.readUTF())); + + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + if (!initialized && box.isInitialized()) { + box.createLasers(worldObj, LaserKind.Stripes); } } @Override public void handleDescriptionPacket(PacketUpdate packet) throws IOException { - boolean initialized = box.isInitialized(); - - super.handleDescriptionPacket(packet); - - currentPattern = FillerManager.registry.getPattern(currentPatternId); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - - if (!initialized && box.isInitialized()) { - box.createLasers(worldObj, LaserKind.Stripes); - } + handlePacketPayload(((PacketPayloadStream) packet.payload).stream); } @Override public void handleUpdatePacket(PacketUpdate packet) throws IOException { - boolean initialized = box.isInitialized(); - - super.handleUpdatePacket(packet); - - currentPattern = FillerManager.registry.getPattern(currentPatternId); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - - if (!initialized && box.isInitialized()) { - box.createLasers(worldObj, LaserKind.Stripes); - } + handlePacketPayload(((PacketPayloadStream) packet.payload).stream); } @Override @@ -360,6 +311,9 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe lastMode = ActionMachineControl.Mode.Off; } else if (action == BuildCraftCore.actionLoop) { lastMode = ActionMachineControl.Mode.Loop; + } else if (action instanceof ActionFiller) { + ActionFiller actFill = (ActionFiller) action; + setPattern(actFill.pattern); } } @@ -370,29 +324,22 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { - if (slot < 9) { - if (getStackInSlot(slot) != null) - return false; - return stack.itemID == Block.brick.blockID || stack.itemID == Block.glass.blockID; - } return true; } @Override - public int[] getAccessibleSlotsFromSide(int side) { - if (ForgeDirection.UP.ordinal() == side) { - return SLOTS_GRID; - } - return SLOTS_INPUT; + public void writeGuiData(DataOutputStream data) throws IOException { + data.writeUTF(currentPattern.getUniqueTag()); } @Override - public boolean canInsertItem(int slot, ItemStack stack, int side) { - return isItemValidForSlot(slot, stack); - } - - @Override - public boolean canExtractItem(int slot, ItemStack stack, int side) { - return true; + public void readGuiData(DataInputStream data, EntityPlayer player) throws IOException { + IFillerPattern prev = currentPattern; + currentPattern = FillerManager.registry.getPattern(data.readUTF()); + if (currentPattern == null) + currentPattern = PatternFill.INSTANCE; + if (prev != currentPattern) + done = false; + sendNetworkUpdate(); } } diff --git a/common/buildcraft/builders/filler/FillerRegistry.java b/common/buildcraft/builders/filler/FillerRegistry.java new file mode 100644 index 00000000..abb7141c --- /dev/null +++ b/common/buildcraft/builders/filler/FillerRegistry.java @@ -0,0 +1,54 @@ +/** + * 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.builders.filler; + +import buildcraft.api.filler.IFillerPattern; +import buildcraft.api.filler.IFillerRegistry; +import buildcraft.builders.triggers.ActionFiller; +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeMap; + +public class FillerRegistry implements IFillerRegistry { + + private TreeMap patterns = new TreeMap(); + private Set patternActions = new HashSet(); + + @Override + public void addPattern(IFillerPattern pattern) { + patterns.put(pattern.getUniqueTag(), pattern); + patternActions.add(new ActionFiller(pattern)); + } + + @Override + public IFillerPattern getPattern(String patternName) { + return patterns.get(patternName); + } + + @Override + public IFillerPattern getNextPattern(IFillerPattern currentPattern) { + Entry pattern = patterns.higherEntry(currentPattern.getUniqueTag()); + if (pattern == null) + pattern = patterns.firstEntry(); + return pattern.getValue(); + } + + @Override + public IFillerPattern getPreviousPattern(IFillerPattern currentPattern) { + Entry pattern = patterns.lowerEntry(currentPattern.getUniqueTag()); + if (pattern == null) + pattern = patterns.lastEntry(); + return pattern.getValue(); + } + + @Override + public Set getActions() { + return patternActions; + } +} diff --git a/common/buildcraft/builders/FillerPattern.java b/common/buildcraft/builders/filler/pattern/FillerPattern.java similarity index 61% rename from common/buildcraft/builders/FillerPattern.java rename to common/buildcraft/builders/filler/pattern/FillerPattern.java index 078532fb..f7c141fb 100644 --- a/common/buildcraft/builders/FillerPattern.java +++ b/common/buildcraft/builders/filler/pattern/FillerPattern.java @@ -5,44 +5,88 @@ * 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.builders; +package buildcraft.builders.filler.pattern; import buildcraft.BuildCraftBuilders; import buildcraft.api.core.IBox; import buildcraft.api.filler.IFillerPattern; +import buildcraft.api.filler.IPatternIterator; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.BlockUtil; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.core.utils.StringUtils; +import java.util.HashSet; +import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; public abstract class FillerPattern implements IFillerPattern { - protected int id; + public static final Set patterns = new HashSet(); + private final String tag; + private Icon icon; + + public FillerPattern(String tag) { + this.tag = tag; + patterns.add(this); + } /** * stackToPlace contains the next item that can be place in the world. Null * if there is none. IteratePattern is responsible to decrementing the stack * size if needed. Return true when the iteration process is finished. */ - @Override - public abstract boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace); - - @SideOnly(Side.CLIENT) - @Override - public abstract Icon getTexture(); - - @Override - public void setId(int id) { - this.id = id; + public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { + return true; } @Override - public int getId() { - return this.id; + public String getDisplayName() { + return StringUtils.localize("fillerpattern." + tag); + } + + @Override + public String getUniqueTag() { + return "buildcraft:" + tag; + } + + public void registerIcon(IconRegister iconRegister) { + icon = iconRegister.registerIcon("buildcraft:fillerPatterns/" + tag); + } + + @Override + public Icon getIcon() { + return icon; + } + + @Override + public String toString() { + return "Pattern: " + getUniqueTag(); + } + + @Override + public IPatternIterator createPatternIterator(TileEntity tile, IBox box, ForgeDirection orientation) { + return new PatternIterator(tile, box); + } + + protected class PatternIterator implements IPatternIterator { + + private final IBox box; + private final TileEntity tile; + + public PatternIterator(TileEntity tile, IBox box) { + this.box = box; + this.tile = tile; + } + + @Override + public boolean iteratePattern(ItemStack stackToPlace) { + return FillerPattern.this.iteratePattern(tile, box, stackToPlace); + } } /** @@ -51,7 +95,7 @@ public abstract class FillerPattern implements IFillerPattern { * Return false if the process failed. * */ - public boolean fill(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, ItemStack stackToPlace, World world) { + public static boolean fill(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, ItemStack stackToPlace, World world) { boolean found = false; int lastX = 0, lastY = 0, lastZ = 0; @@ -85,12 +129,11 @@ public abstract class FillerPattern implements IFillerPattern { * Return false if is the process failed. * */ - public boolean empty(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world) { - boolean found = false; + public static boolean empty(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world) { int lastX = Integer.MAX_VALUE, lastY = Integer.MAX_VALUE, lastZ = Integer.MAX_VALUE; for (int y = yMax; y >= yMin; y--) { - found = false; + boolean found = false; for (int x = xMin; x <= xMax; ++x) { for (int z = zMin; z <= zMax; ++z) { if (!BlockUtil.canChangeBlock(world, x, y, z)) @@ -125,7 +168,7 @@ public abstract class FillerPattern implements IFillerPattern { * * Return false if is the process failed. */ - public boolean flatten(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world, ItemStack stackToPlace) { + public static boolean flatten(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world, ItemStack stackToPlace) { int lastX = Integer.MAX_VALUE, lastY = Integer.MAX_VALUE, lastZ = Integer.MAX_VALUE; boolean found = false; @@ -151,7 +194,10 @@ public abstract class FillerPattern implements IFillerPattern { return found; } - private void breakBlock(World world, int x, int y, int z) { + private static void breakBlock(World world, int x, int y, int z) { + Block block = Block.blocksList[world.getBlockId(x, y, z)]; + if (block != null) + world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); if (BuildCraftBuilders.fillerDestroy) { world.setBlockToAir(x, y, z); } else if (BlockUtil.isToughBlock(world, x, y, z)) { diff --git a/common/buildcraft/builders/FillerFillWalls.java b/common/buildcraft/builders/filler/pattern/PatternBox.java similarity index 68% rename from common/buildcraft/builders/FillerFillWalls.java rename to common/buildcraft/builders/filler/pattern/PatternBox.java index 06684e25..44849df8 100644 --- a/common/buildcraft/builders/FillerFillWalls.java +++ b/common/buildcraft/builders/filler/pattern/PatternBox.java @@ -1,22 +1,21 @@ /** - * 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.builders; +package buildcraft.builders.filler.pattern; import buildcraft.api.core.IBox; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -public class FillerFillWalls extends FillerPattern { +public class PatternBox extends FillerPattern { + + public PatternBox() { + super("box"); + } @Override public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { @@ -48,16 +47,4 @@ public class FillerFillWalls extends FillerPattern { return true; } - - @SideOnly(Side.CLIENT) - @Override - public Icon getTexture() { - return BuilderProxyClient.fillerWallsTexture; - } - - @Override - public String getName() { - return "Walls"; - } - } diff --git a/common/buildcraft/builders/FillerRemover.java b/common/buildcraft/builders/filler/pattern/PatternClear.java similarity index 54% rename from common/buildcraft/builders/FillerRemover.java rename to common/buildcraft/builders/filler/pattern/PatternClear.java index 8caee5b8..08f8aa7d 100644 --- a/common/buildcraft/builders/FillerRemover.java +++ b/common/buildcraft/builders/filler/pattern/PatternClear.java @@ -1,22 +1,21 @@ /** - * 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.builders; +package buildcraft.builders.filler.pattern; import buildcraft.api.core.IBox; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -public class FillerRemover extends FillerPattern { +public class PatternClear extends FillerPattern { + + public PatternClear() { + super("clear"); + } @Override public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { @@ -30,16 +29,4 @@ public class FillerRemover extends FillerPattern { return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj); } - - @SideOnly(Side.CLIENT) - @Override - public Icon getTexture() { - return BuilderProxyClient.fillerClearTexture; - } - - @Override - public String getName() { - return "Clear"; - } - } diff --git a/common/buildcraft/builders/FillerFillAll.java b/common/buildcraft/builders/filler/pattern/PatternFill.java similarity index 64% rename from common/buildcraft/builders/FillerFillAll.java rename to common/buildcraft/builders/filler/pattern/PatternFill.java index 884566d2..6f23e86b 100644 --- a/common/buildcraft/builders/FillerFillAll.java +++ b/common/buildcraft/builders/filler/pattern/PatternFill.java @@ -1,22 +1,27 @@ /** - * 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.builders; +package buildcraft.builders.filler.pattern; import buildcraft.api.core.IBox; +import buildcraft.builders.BuilderProxyClient; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; -public class FillerFillAll extends FillerPattern { +public class PatternFill extends FillerPattern { + + public static final PatternFill INSTANCE = new PatternFill(); + + private PatternFill() { + super("fill"); + } @Override public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { @@ -31,15 +36,4 @@ public class FillerFillAll extends FillerPattern { return !fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj); } - @Override - @SideOnly(Side.CLIENT) - public Icon getTexture() { - return BuilderProxyClient.fillerFillAllTexture; - } - - @Override - public String getName() { - return "Fill"; - } - } diff --git a/common/buildcraft/builders/FillerFlattener.java b/common/buildcraft/builders/filler/pattern/PatternFlatten.java similarity index 70% rename from common/buildcraft/builders/FillerFlattener.java rename to common/buildcraft/builders/filler/pattern/PatternFlatten.java index d5b0e00b..fcb662d5 100644 --- a/common/buildcraft/builders/FillerFlattener.java +++ b/common/buildcraft/builders/filler/pattern/PatternFlatten.java @@ -5,17 +5,17 @@ * 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.builders; +package buildcraft.builders.filler.pattern; import buildcraft.api.core.IBox; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -public class FillerFlattener extends FillerPattern { +public class PatternFlatten extends FillerPattern { + public PatternFlatten() { + super("flatten"); + } @Override public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { @@ -32,15 +32,4 @@ public class FillerFlattener extends FillerPattern { } return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj); } - - @SideOnly(Side.CLIENT) - @Override - public Icon getTexture() { - return BuilderProxyClient.fillerFlattenTexture; - } - - @Override - public String getName() { - return "Flatten"; - } } diff --git a/common/buildcraft/builders/FillerHorizon.java b/common/buildcraft/builders/filler/pattern/PatternHorizon.java similarity index 70% rename from common/buildcraft/builders/FillerHorizon.java rename to common/buildcraft/builders/filler/pattern/PatternHorizon.java index 155cb4e1..a034e517 100644 --- a/common/buildcraft/builders/FillerHorizon.java +++ b/common/buildcraft/builders/filler/pattern/PatternHorizon.java @@ -5,16 +5,17 @@ * 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.builders; +package buildcraft.builders.filler.pattern; import buildcraft.api.core.IBox; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -public class FillerHorizon extends FillerPattern { +public class PatternHorizon extends FillerPattern { + + public PatternHorizon() { + super("horizon"); + } @Override public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { @@ -30,15 +31,4 @@ public class FillerHorizon extends FillerPattern { } return !empty(xMin, yMin, zMin, xMax, tile.worldObj.getActualHeight(), zMax, tile.worldObj); } - - @SideOnly(Side.CLIENT) - @Override - public Icon getTexture() { - return BuilderProxyClient.fillerHorizonTexture; - } - - @Override - public String getName() { - return "Horizon"; - } } diff --git a/common/buildcraft/builders/FillerFillPyramid.java b/common/buildcraft/builders/filler/pattern/PatternPyramid.java similarity index 66% rename from common/buildcraft/builders/FillerFillPyramid.java rename to common/buildcraft/builders/filler/pattern/PatternPyramid.java index 7450cdd1..a2a26271 100644 --- a/common/buildcraft/builders/FillerFillPyramid.java +++ b/common/buildcraft/builders/filler/pattern/PatternPyramid.java @@ -1,22 +1,21 @@ /** - * 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.builders; +package buildcraft.builders.filler.pattern; import buildcraft.api.core.IBox; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -public class FillerFillPyramid extends FillerPattern { +public class PatternPyramid extends FillerPattern { + + public PatternPyramid() { + super("pyramid"); + } @Override public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { @@ -58,16 +57,4 @@ public class FillerFillPyramid extends FillerPattern { return true; } - - @Override - @SideOnly(Side.CLIENT) - public Icon getTexture() { - return BuilderProxyClient.fillerPyramidTexture; - } - - @Override - public String getName() { - return "Pyramid"; - } - } diff --git a/common/buildcraft/builders/FillerFillStairs.java b/common/buildcraft/builders/filler/pattern/PatternStairs.java similarity index 85% rename from common/buildcraft/builders/FillerFillStairs.java rename to common/buildcraft/builders/filler/pattern/PatternStairs.java index 21aff72e..2a620176 100644 --- a/common/buildcraft/builders/FillerFillStairs.java +++ b/common/buildcraft/builders/filler/pattern/PatternStairs.java @@ -1,22 +1,21 @@ /** - * 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.builders; +package buildcraft.builders.filler.pattern; import buildcraft.api.core.IBox; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -public class FillerFillStairs extends FillerPattern { +public class PatternStairs extends FillerPattern { + + public PatternStairs() { + super("stairs"); + } @Override public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { @@ -46,7 +45,7 @@ public class FillerFillStairs extends FillerPattern { int kind = 0; - int steps[] = new int[] { 0, 0, 0, 0 }; + int steps[] = new int[]{0, 0, 0, 0}; int x = 0, z = 0; int stepDiagX = 0, stepDiagZ = 0; @@ -189,16 +188,4 @@ public class FillerFillStairs extends FillerPattern { return true; } - - @Override - @SideOnly(Side.CLIENT) - public Icon getTexture() { - return BuilderProxyClient.fillerStairsTexture; - } - - @Override - public String getName() { - return "Stairs"; - } - } diff --git a/common/buildcraft/builders/gui/ContainerFiller.java b/common/buildcraft/builders/gui/ContainerFiller.java index 7c94d7f7..90f614ea 100644 --- a/common/buildcraft/builders/gui/ContainerFiller.java +++ b/common/buildcraft/builders/gui/ContainerFiller.java @@ -1,79 +1,69 @@ /** - * 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.builders.gui; +import buildcraft.builders.TileFiller; import buildcraft.core.gui.BuildCraftContainer; -import buildcraft.core.gui.slots.SlotLimited; +import buildcraft.core.gui.GuiBuildCraft; +import buildcraft.core.gui.widgets.Widget; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; public class ContainerFiller extends BuildCraftContainer { IInventory playerIInventory; - IInventory fillerInventory; + TileFiller tile; - public ContainerFiller(IInventory playerInventory, IInventory fillerInventory) { - super(fillerInventory.getSizeInventory()); + private class PatternWidget extends Widget { + + public PatternWidget() { + super(80, 30, 0, 0, 16, 16); + } + + @SideOnly(Side.CLIENT) + @Override + public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) { + gui.bindTexture(TextureMap.locationBlocksTexture); + gui.drawTexturedModelRectFromIcon(guiX + x, guiY + y, tile.currentPattern.getIcon(), 16, 16); + } + } + + public ContainerFiller(IInventory playerInventory, TileFiller tile) { + super(tile.getSizeInventory()); this.playerIInventory = playerInventory; - this.fillerInventory = fillerInventory; + this.tile = tile; - for (int k = 0; k < 3; k++) { - for (int j1 = 0; j1 < 3; j1++) { - addSlotToContainer(new SlotLimited(fillerInventory, j1 + k * 3, 31 + j1 * 18, 16 + k * 18, 1)); + addWidget(new PatternWidget()); + + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(tile, x + y * 9, 8 + x * 18, 85 + y * 18)); } } - for (int k = 0; k < 3; k++) { - for (int j1 = 0; j1 < 9; j1++) { - addSlotToContainer(new Slot(fillerInventory, 9 + j1 + k * 9, 8 + j1 * 18, 85 + k * 18)); - } - } - - 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, 153 + 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, 153 + y * 18)); } } - for (int i1 = 0; i1 < 9; i1++) { - addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 211)); + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(playerInventory, x, 8 + x * 18, 211)); } } @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return fillerInventory.isUseableByPlayer(entityplayer); + return tile.isUseableByPlayer(entityplayer); } - - @Override - public ItemStack transferStackInSlot(EntityPlayer pl, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) inventorySlots.get(i); - if (slot != null && slot.getHasStack()) { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - if (i < getInventorySize()) { - if (!mergeItemStack(itemstack1, getInventorySize(), inventorySlots.size(), true)) - return null; - } else if (!mergeItemStack(itemstack1, 9, getInventorySize(), false)) - return null; - if (itemstack1.stackSize == 0) { - slot.putStack(null); - } else { - slot.onSlotChanged(); - } - } - return itemstack; - } - } diff --git a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java index 68284f29..11f9be53 100644 --- a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java +++ b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java @@ -33,7 +33,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft { BptPlayerIndex index; public GuiBlueprintLibrary(EntityPlayer player, TileBlueprintLibrary library) { - super(new ContainerBlueprintLibrary(player, library), library); + super(new ContainerBlueprintLibrary(player, library), library, TEXTURE); this.player = player; xSize = 176; ySize = 225; diff --git a/common/buildcraft/builders/gui/GuiBuilder.java b/common/buildcraft/builders/gui/GuiBuilder.java index a3bd533d..4d86191f 100644 --- a/common/buildcraft/builders/gui/GuiBuilder.java +++ b/common/buildcraft/builders/gui/GuiBuilder.java @@ -25,7 +25,7 @@ public class GuiBuilder extends GuiAdvancedInterface { TileBuilder builder; public GuiBuilder(IInventory playerInventory, TileBuilder builder) { - super(new ContainerBuilder(playerInventory, builder), builder); + super(new ContainerBuilder(playerInventory, builder), builder, TEXTURE); this.playerInventory = playerInventory; this.builder = builder; xSize = 176; diff --git a/common/buildcraft/builders/gui/GuiFiller.java b/common/buildcraft/builders/gui/GuiFiller.java index 7c17b209..1a26330a 100644 --- a/common/buildcraft/builders/gui/GuiFiller.java +++ b/common/buildcraft/builders/gui/GuiFiller.java @@ -7,88 +7,63 @@ */ package buildcraft.builders.gui; +import buildcraft.api.filler.FillerManager; import buildcraft.builders.TileFiller; import buildcraft.core.DefaultProps; import buildcraft.core.gui.GuiBuildCraft; +import buildcraft.core.gui.GuiTools; +import buildcraft.core.gui.buttons.GuiBetterButton; +import buildcraft.core.gui.buttons.StandardButtonTextureSets; +import buildcraft.core.network.PacketGuiReturn; import buildcraft.core.utils.StringUtils; -import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.gui.GuiButton; import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; -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.locationBlocksTexture; IInventory playerInventory; TileFiller filler; public GuiFiller(IInventory playerInventory, TileFiller filler) { - super(new ContainerFiller(playerInventory, filler), filler); + super(new ContainerFiller(playerInventory, filler), filler, TEXTURE); this.playerInventory = playerInventory; this.filler = filler; xSize = 175; ySize = 240; } + @Override + public void initGui() { + super.initGui(); + buttonList.clear(); + int w = (width - xSize) / 2; + int h = (height - ySize) / 2; + + buttonList.add(new GuiBetterButton(0, w + 80 - 18, h + 30, 10, StandardButtonTextureSets.LEFT_BUTTON, "")); + buttonList.add(new GuiBetterButton(1, w + 80 + 16 + 8, h + 30, 10, StandardButtonTextureSets.RIGHT_BUTTON, "")); + } + + @Override + protected void actionPerformed(GuiButton button) { + super.actionPerformed(button); + + if (button.id == 0) + filler.currentPattern = FillerManager.registry.getPreviousPattern(filler.currentPattern); + if (button.id == 1) + filler.currentPattern = FillerManager.registry.getNextPattern(filler.currentPattern); + + PacketGuiReturn pkt = new PacketGuiReturn(filler); + pkt.sendPacket(); + } + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { String title = StringUtils.localize("tile.fillerBlock"); fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); fontRenderer.drawString(StringUtils.localize("gui.filling.resources"), 8, 74, 0x404040); fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, 142, 0x404040); - - if (filler.currentPattern != null) { - drawForegroundSelection(filler.currentPattern.getName()); - } + GuiTools.drawCenteredString(fontRenderer, filler.currentPattern.getDisplayName(), 56); } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(TEXTURE); - - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - - if (filler.currentPattern != null) { - mc.renderEngine.bindTexture(BLOCK_TEXTURE); - drawTexturedModelRectFromIcon(guiLeft + patternSymbolX, guiTop + patternSymbolY, filler.currentPattern.getTexture(), 16, 16); - } - - } - - public boolean intersectsWith(int i, int j) { - - if (i >= patternSymbolX && i <= patternSymbolX + 16 && j >= patternSymbolY && j <= patternSymbolY + 16) - return true; - - return false; - } - - protected void drawForegroundSelection(String tag) { - - if (!intersectsWith(lastX - guiLeft, lastY - guiTop)) - return; - - if (tag.length() > 0) { - int i2 = (lastX - guiLeft) + 12; - int k2 = lastY - guiTop - 12; - int l2 = fontRenderer.getStringWidth(tag); - drawGradientRect(i2 - 3, k2 - 3, i2 + l2 + 3, k2 + 8 + 3, 0xc0000000, 0xc0000000); - fontRenderer.drawStringWithShadow(tag, i2, k2, -1); - } - } - - @Override - protected void mouseMovedOrUp(int i, int j, int k) { - super.mouseMovedOrUp(i, j, k); - - lastX = i; - lastY = j; - } - private int lastX = 0; - private int lastY = 0; - public final int patternSymbolX = 125; - public final int patternSymbolY = 34; } diff --git a/common/buildcraft/builders/gui/GuiTemplate.java b/common/buildcraft/builders/gui/GuiTemplate.java index fccefd98..a54f8f1b 100644 --- a/common/buildcraft/builders/gui/GuiTemplate.java +++ b/common/buildcraft/builders/gui/GuiTemplate.java @@ -29,7 +29,7 @@ public class GuiTemplate extends GuiBuildCraft { boolean editMode = false; public GuiTemplate(IInventory playerInventory, TileArchitect template) { - super(new ContainerTemplate(playerInventory, template), template); + super(new ContainerTemplate(playerInventory, template), template, TEXTURE); this.playerInventory = playerInventory; this.template = template; xSize = 175; diff --git a/common/buildcraft/builders/triggers/ActionFiller.java b/common/buildcraft/builders/triggers/ActionFiller.java new file mode 100644 index 00000000..af28dfc7 --- /dev/null +++ b/common/buildcraft/builders/triggers/ActionFiller.java @@ -0,0 +1,37 @@ +/** + * 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.builders.triggers; + +import buildcraft.api.filler.IFillerPattern; +import buildcraft.core.triggers.*; +import net.minecraft.util.Icon; + +public class ActionFiller extends BCAction { + + public final IFillerPattern pattern; + + public ActionFiller(IFillerPattern pattern) { + super(0, "filler:" + pattern.getUniqueTag()); + this.pattern = pattern; + } + + @Override + public String getDescription() { + return "Pattern: " + pattern.getDisplayName(); + } + + @Override + public Icon getIcon() { + return pattern.getIcon(); + } + + @Override + public int getTextureMap() { + return 0; + } +} diff --git a/common/buildcraft/builders/triggers/BuildersActionProvider.java b/common/buildcraft/builders/triggers/BuildersActionProvider.java new file mode 100644 index 00000000..3602034a --- /dev/null +++ b/common/buildcraft/builders/triggers/BuildersActionProvider.java @@ -0,0 +1,25 @@ +package buildcraft.builders.triggers; + +import buildcraft.api.filler.FillerManager; +import buildcraft.api.gates.IAction; +import buildcraft.api.gates.IActionProvider; +import buildcraft.builders.TileFiller; +import java.util.LinkedList; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; + +/** + * + * @author CovertJaguar + */ +public class BuildersActionProvider implements IActionProvider { + + @Override + public LinkedList getNeighborActions(Block block, TileEntity tile) { + LinkedList actions = new LinkedList(); + if (tile instanceof TileFiller) { + actions.addAll(FillerManager.registry.getActions()); + } + return actions; + } +} diff --git a/common/buildcraft/core/Box.java b/common/buildcraft/core/Box.java index 6ffcfbc2..3e9593b6 100644 --- a/common/buildcraft/core/Box.java +++ b/common/buildcraft/core/Box.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.api.core.IAreaProvider; @@ -16,6 +14,9 @@ import buildcraft.api.core.Position; import buildcraft.core.network.TileNetworkData; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import net.minecraft.nbt.NBTTagCompound; @@ -27,7 +28,6 @@ public class Box implements IBox { int xMin, yMin, zMin, xMax, yMax, zMax; public @TileNetworkData boolean initialized; - private EntityBlock lasers[]; public Box() { @@ -57,8 +57,8 @@ public class Box implements IBox { this.xMax = xMax; this.yMax = yMax; this.zMax = zMax; - initialized = !(xMin == Integer.MAX_VALUE || yMin == Integer.MAX_VALUE || zMin == Integer.MAX_VALUE || xMax == Integer.MAX_VALUE || - yMax == Integer.MAX_VALUE || zMax == Integer.MAX_VALUE ); + initialized = !(xMin == Integer.MAX_VALUE || yMin == Integer.MAX_VALUE || zMin == Integer.MAX_VALUE || xMax == Integer.MAX_VALUE + || yMax == Integer.MAX_VALUE || zMax == Integer.MAX_VALUE); } public void initialize(Box box) { @@ -225,6 +225,30 @@ public class Box implements IBox { } } + public void writeToStream(DataOutputStream stream) throws IOException { + stream.writeBoolean(initialized); + + stream.writeInt(xMin); + stream.writeInt(yMin); + stream.writeInt(zMin); + + stream.writeInt(xMax); + stream.writeInt(yMax); + stream.writeInt(zMax); + } + + public void readFromStream(DataInputStream stream) throws IOException { + initialized = stream.readBoolean(); + + xMin = stream.readInt(); + yMin = stream.readInt(); + zMin = stream.readInt(); + + xMax = stream.readInt(); + yMax = stream.readInt(); + zMax = stream.readInt(); + } + public void writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setInteger("xMin", xMin); @@ -240,5 +264,4 @@ public class Box implements IBox { public String toString() { return "{" + xMin + ", " + xMax + "}, {" + yMin + ", " + yMax + "}, {" + zMin + ", " + zMax + "}"; } - } diff --git a/common/buildcraft/core/gui/BuildCraftContainer.java b/common/buildcraft/core/gui/BuildCraftContainer.java index 4984a77c..80fd0979 100644 --- a/common/buildcraft/core/gui/BuildCraftContainer.java +++ b/common/buildcraft/core/gui/BuildCraftContainer.java @@ -9,21 +9,57 @@ package buildcraft.core.gui; import buildcraft.core.gui.slots.IPhantomSlot; import buildcraft.core.gui.slots.SlotBase; +import buildcraft.core.gui.widgets.Widget; import buildcraft.core.inventory.StackHelper; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public abstract class BuildCraftContainer extends Container { + private List widgets = new ArrayList(); private int inventorySize; public BuildCraftContainer(int inventorySize) { this.inventorySize = inventorySize; } + public List getWidgets() { + return widgets; + } + + public void addSlot(Slot slot) { + addSlotToContainer(slot); + } + + public void addWidget(Widget widget) { + widget.addToContainer(this); + widgets.add(widget); + } + + @Override + public void addCraftingToCrafters(ICrafting player) { + super.addCraftingToCrafters(player); + for (Widget widget : widgets) { + widget.initWidget(player); + } + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + for (Widget widget : widgets) { + for (ICrafting player : (List) crafters) { + widget.updateWidget(player); + } + } + } + @Override public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) { Slot slot = slotNum < 0 ? null : (Slot) this.inventorySlots.get(slotNum); diff --git a/common/buildcraft/core/gui/GuiAdvancedInterface.java b/common/buildcraft/core/gui/GuiAdvancedInterface.java index bbcf04c3..fe1259cb 100644 --- a/common/buildcraft/core/gui/GuiAdvancedInterface.java +++ b/common/buildcraft/core/gui/GuiAdvancedInterface.java @@ -110,8 +110,8 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { } public AdvancedSlot[] slots; - public GuiAdvancedInterface(BuildCraftContainer container, IInventory inventory) { - super(container, inventory); + public GuiAdvancedInterface(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) { + super(container, inventory, texture); } public int getSlotAtLocation(int i, int j) { diff --git a/common/buildcraft/core/gui/GuiBuildCraft.java b/common/buildcraft/core/gui/GuiBuildCraft.java index fab83ce5..29e99d48 100644 --- a/common/buildcraft/core/gui/GuiBuildCraft.java +++ b/common/buildcraft/core/gui/GuiBuildCraft.java @@ -1,14 +1,15 @@ 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.IToolTipProvider; import buildcraft.core.gui.tooltips.ToolTip; import buildcraft.core.gui.tooltips.ToolTipLine; +import buildcraft.core.gui.widgets.Widget; import buildcraft.core.utils.SessionVars; import java.util.ArrayList; +import java.util.Collection; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.InventoryPlayer; @@ -22,8 +23,206 @@ import org.lwjgl.opengl.GL11; public abstract class GuiBuildCraft extends GuiContainer { public static final ResourceLocation LEDGER_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/ledger.png"); - // / LEDGERS - protected LedgerManager ledgerManager = new LedgerManager(this); + public final LedgerManager ledgerManager = new LedgerManager(this); + public final TileEntity tile; + public final ResourceLocation texture; + public final BuildCraftContainer container; + + public GuiBuildCraft(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) { + super(container); + this.container = container; + + this.texture = texture; + + if (inventory instanceof TileEntity) { + tile = (TileEntity) inventory; + } else { + tile = null; + } + + initLedgers(inventory); + } + + protected void initLedgers(IInventory inventory) { + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(int mouseX, int mouseY, float par3) { + super.drawScreen(mouseX, mouseY, par3); + int left = this.guiLeft; + int top = this.guiTop; + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glPushMatrix(); + GL11.glTranslatef((float) left, (float) top, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + RenderHelper.disableStandardItemLighting(); + + InventoryPlayer playerInv = this.mc.thePlayer.inventory; + + if (playerInv.getItemStack() == null) { + drawToolTips(container.getWidgets(), mouseX, mouseY); + drawToolTips(buttonList, mouseX, mouseY); + drawToolTips(inventorySlots.inventorySlots, mouseX, mouseY); + } + + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + private void drawToolTips(Collection objects, int mouseX, int mouseY) { + for (Object obj : objects) { + if (!(obj instanceof IToolTipProvider)) + continue; + IToolTipProvider provider = (IToolTipProvider) obj; + if (!provider.isToolTipVisible()) + continue; + ToolTip tips = provider.getToolTip(); + if (tips == null) + continue; + boolean mouseOver = provider.isMouseOver(mouseX - guiLeft, mouseY - guiTop); + tips.onTick(mouseOver); + if (mouseOver && tips.isReady()) { + tips.refresh(); + drawToolTips(tips, mouseX, mouseY); + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(texture); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + + int mX = mouseX - guiLeft; + int mY = mouseY - guiTop; + + for (Widget widget : container.getWidgets()) { + if (widget.hidden) + continue; + widget.draw(this, x, y, mX, mY); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + ledgerManager.drawLedgers(par1, par2); + } + + protected int getCenteredOffset(String string) { + return getCenteredOffset(string, xSize); + } + + protected int getCenteredOffset(String string, int xWidth) { + return (xWidth - fontRenderer.getStringWidth(string)) / 2; + } + + /** + * Returns if the passed mouse position is over the specified slot. + */ + private boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) { + int left = this.guiLeft; + int top = this.guiTop; + mouseX -= left; + mouseY -= top; + return mouseX >= slot.xDisplayPosition - 1 && mouseX < slot.xDisplayPosition + 16 + 1 && mouseY >= slot.yDisplayPosition - 1 && mouseY < slot.yDisplayPosition + 16 + 1; + } + + // / MOUSE CLICKS + @Override + protected void mouseClicked(int par1, int par2, int mouseButton) { + super.mouseClicked(par1, par2, mouseButton); + + // / Handle ledger clicks + 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; + } + + public void bindTexture(ResourceLocation texture) { + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + } + + private void drawToolTips(ToolTip toolTips, int mouseX, int mouseY) { + if (toolTips.size() > 0) { + int left = this.guiLeft; + int top = this.guiTop; + int lenght = 0; + int x; + int y; + + for (ToolTipLine tip : toolTips) { + y = this.fontRenderer.getStringWidth(tip.text); + + if (y > lenght) { + lenght = y; + } + } + + x = mouseX - left + 12; + y = mouseY - top - 12; + int var14 = 8; + + if (toolTips.size() > 1) { + var14 += 2 + (toolTips.size() - 1) * 10; + } + + this.zLevel = 300.0F; + itemRenderer.zLevel = 300.0F; + int var15 = -267386864; + this.drawGradientRect(x - 3, y - 4, x + lenght + 3, y - 3, var15, var15); + this.drawGradientRect(x - 3, y + var14 + 3, x + lenght + 3, y + var14 + 4, var15, var15); + this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y + var14 + 3, var15, var15); + this.drawGradientRect(x - 4, y - 3, x - 3, y + var14 + 3, var15, var15); + this.drawGradientRect(x + lenght + 3, y - 3, x + lenght + 4, y + var14 + 3, var15, var15); + int var16 = 1347420415; + int var17 = (var16 & 16711422) >> 1 | var16 & -16777216; + this.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + var14 + 3 - 1, var16, var17); + this.drawGradientRect(x + lenght + 2, y - 3 + 1, x + lenght + 3, y + var14 + 3 - 1, var16, var17); + this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y - 3 + 1, var16, var16); + this.drawGradientRect(x - 3, y + var14 + 2, x + lenght + 3, y + var14 + 3, var17, var17); + + for (ToolTipLine tip : toolTips) { + String line = tip.text; + + if (tip.color == -1) { + line = "\u00a77" + line; + } else { + line = "\u00a7" + Integer.toHexString(tip.color) + line; + } + + this.fontRenderer.drawStringWithShadow(line, x, y, -1); + + y += 10 + tip.getSpacing(); + } + + this.zLevel = 0.0F; + itemRenderer.zLevel = 0.0F; + } + } protected class LedgerManager { @@ -228,187 +427,4 @@ public abstract class GuiBuildCraft extends GuiContainer { drawTexturedModelRectFromIcon(x, y, icon, 16, 16); } } - protected TileEntity tile; - - public GuiBuildCraft(BuildCraftContainer container, IInventory inventory) { - super(container); - - if (inventory instanceof TileEntity) { - tile = (TileEntity) inventory; - } - - initLedgers(inventory); - } - - protected void initLedgers(IInventory inventory) { - } - - /** - * Draws the screen and all the components in it. - */ - @Override - public void drawScreen(int mouseX, int mouseY, float par3) { - super.drawScreen(mouseX, mouseY, par3); - int left = this.guiLeft; - int top = this.guiTop; - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glPushMatrix(); - GL11.glTranslatef((float) left, (float) top, 0.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - RenderHelper.disableStandardItemLighting(); - - InventoryPlayer playerInv = this.mc.thePlayer.inventory; - - if (playerInv.getItemStack() == null) { - for (Object button : buttonList) { - if (!(button instanceof GuiBetterButton)) { - continue; - } - GuiBetterButton betterButton = (GuiBetterButton) button; - ToolTip tips = betterButton.getToolTip(); - if (tips == null) { - continue; - } - boolean mouseOver = betterButton.isMouseOverButton(mouseX, mouseY); - tips.onTick(mouseOver); - if (mouseOver && tips.isReady()) { - tips.refresh(); - drawToolTips(tips, mouseX, mouseY); - } - } - } - for (Object obj : inventorySlots.inventorySlots) { - if (!(obj instanceof SlotBase)) { - continue; - } - SlotBase slot = (SlotBase) obj; - if (slot.getStack() != null) { - continue; - } - ToolTip tips = slot.getToolTip(); - if (tips == null) { - continue; - } - boolean mouseOver = isMouseOverSlot(slot, mouseX, mouseY); - tips.onTick(mouseOver); - if (mouseOver && tips.isReady()) { - tips.refresh(); - drawToolTips(tips, mouseX, mouseY); - } - } - - GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - ledgerManager.drawLedgers(par1, par2); - } - - protected int getCenteredOffset(String string) { - return getCenteredOffset(string, xSize); - } - - protected int getCenteredOffset(String string, int xWidth) { - return (xWidth - fontRenderer.getStringWidth(string)) / 2; - } - - /** - * Returns if the passed mouse position is over the specified slot. - */ - private boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) { - int left = this.guiLeft; - int top = this.guiTop; - mouseX -= left; - mouseY -= top; - return mouseX >= slot.xDisplayPosition - 1 && mouseX < slot.xDisplayPosition + 16 + 1 && mouseY >= slot.yDisplayPosition - 1 && mouseY < slot.yDisplayPosition + 16 + 1; - } - - // / MOUSE CLICKS - @Override - protected void mouseClicked(int par1, int par2, int mouseButton) { - super.mouseClicked(par1, par2, mouseButton); - - // / Handle ledger clicks - 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; - int top = this.guiTop; - int lenght = 0; - int x; - int y; - - for (ToolTipLine tip : toolTips) { - y = this.fontRenderer.getStringWidth(tip.text); - - if (y > lenght) { - lenght = y; - } - } - - x = mouseX - left + 12; - y = mouseY - top - 12; - int var14 = 8; - - if (toolTips.size() > 1) { - var14 += 2 + (toolTips.size() - 1) * 10; - } - - this.zLevel = 300.0F; - itemRenderer.zLevel = 300.0F; - int var15 = -267386864; - this.drawGradientRect(x - 3, y - 4, x + lenght + 3, y - 3, var15, var15); - this.drawGradientRect(x - 3, y + var14 + 3, x + lenght + 3, y + var14 + 4, var15, var15); - this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y + var14 + 3, var15, var15); - this.drawGradientRect(x - 4, y - 3, x - 3, y + var14 + 3, var15, var15); - this.drawGradientRect(x + lenght + 3, y - 3, x + lenght + 4, y + var14 + 3, var15, var15); - int var16 = 1347420415; - int var17 = (var16 & 16711422) >> 1 | var16 & -16777216; - this.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + var14 + 3 - 1, var16, var17); - this.drawGradientRect(x + lenght + 2, y - 3 + 1, x + lenght + 3, y + var14 + 3 - 1, var16, var17); - this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y - 3 + 1, var16, var16); - this.drawGradientRect(x - 3, y + var14 + 2, x + lenght + 3, y + var14 + 3, var17, var17); - - for (ToolTipLine tip : toolTips) { - String line = tip.text; - - if (tip.color == -1) { - line = "\u00a77" + line; - } else { - line = "\u00a7" + Integer.toHexString(tip.color) + line; - } - - this.fontRenderer.drawStringWithShadow(line, x, y, -1); - - y += 10 + tip.getSpacing(); - } - - this.zLevel = 0.0F; - itemRenderer.zLevel = 0.0F; - } - } } diff --git a/common/buildcraft/core/gui/GuiTools.java b/common/buildcraft/core/gui/GuiTools.java new file mode 100644 index 00000000..570000d8 --- /dev/null +++ b/common/buildcraft/core/gui/GuiTools.java @@ -0,0 +1,48 @@ +package buildcraft.core.gui; + +import buildcraft.core.gui.buttons.GuiBetterButton; +import java.util.List; +import net.minecraft.client.gui.FontRenderer; + +public class GuiTools { + + public static void drawCenteredString(FontRenderer fr, String s, int y) { + drawCenteredString(fr, s, y, 176); + } + + public static void drawCenteredString(FontRenderer fr, String s, int y, int guiWidth) { + drawCenteredString(fr, s, y, guiWidth, 0x404040, false); + } + + public static void drawCenteredString(FontRenderer fr, String s, int y, int guiWidth, int color, boolean shadow) { + int sWidth = fr.getStringWidth(s); + int sPos = guiWidth / 2 - sWidth / 2; + fr.drawString(s, sPos, y, color, shadow); + } + + public static void newButtonRowAuto(List buttonList, int xStart, int xSize, List buttons) { + int buttonWidth = 0; + for (GuiBetterButton b : buttons) { + buttonWidth += b.getWidth(); + } + int remaining = xSize - buttonWidth; + int spacing = remaining / (buttons.size() + 1); + int pointer = 0; + for (GuiBetterButton b : buttons) { + pointer += spacing; + b.xPosition = xStart + pointer; + pointer += b.getWidth(); + buttonList.add(b); + } + } + + public static void newButtonRow(List buttonList, int xStart, int spacing, List buttons) { + int pointer = 0; + for (GuiBetterButton b : buttons) { + b.xPosition = xStart + pointer; + pointer += b.getWidth() + spacing; + buttonList.add(b); + } + } + +} diff --git a/common/buildcraft/core/gui/buttons/GuiBetterButton.java b/common/buildcraft/core/gui/buttons/GuiBetterButton.java index 5fbcaa91..790243db 100644 --- a/common/buildcraft/core/gui/buttons/GuiBetterButton.java +++ b/common/buildcraft/core/gui/buttons/GuiBetterButton.java @@ -1,6 +1,7 @@ package buildcraft.core.gui.buttons; import buildcraft.core.DefaultProps; +import buildcraft.core.gui.tooltips.IToolTipProvider; import buildcraft.core.gui.tooltips.ToolTip; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -15,7 +16,7 @@ import org.lwjgl.opengl.GL11; * @author CovertJaguar */ @SideOnly(Side.CLIENT) -public class GuiBetterButton extends GuiButton { +public class GuiBetterButton extends GuiButton implements IToolTipProvider { public static final ResourceLocation BUTTON_TEXTURES = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/buttons.png"); protected final IButtonTextureSet texture; @@ -80,6 +81,7 @@ public class GuiBetterButton extends GuiButton { drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (h - 8) / 2, getTextColor(mouseOver)); } + @Override public ToolTip getToolTip() { return toolTip; } @@ -87,4 +89,14 @@ public class GuiBetterButton extends GuiButton { public void setToolTip(ToolTip tips) { this.toolTip = tips; } + + @Override + public boolean isToolTipVisible() { + return drawButton; + } + + @Override + public boolean isMouseOver(int mouseX, int mouseY) { + return isMouseOverButton(mouseX, mouseY); + } } diff --git a/common/buildcraft/core/gui/buttons/StandardButtonTextureSets.java b/common/buildcraft/core/gui/buttons/StandardButtonTextureSets.java index 3c4efccf..5155cd29 100644 --- a/common/buildcraft/core/gui/buttons/StandardButtonTextureSets.java +++ b/common/buildcraft/core/gui/buttons/StandardButtonTextureSets.java @@ -7,7 +7,9 @@ package buildcraft.core.gui.buttons; public enum StandardButtonTextureSets implements IButtonTextureSet { LARGE_BUTTON(0, 0, 20, 200), - SMALL_BUTTON(0, 80, 15, 200); + SMALL_BUTTON(0, 80, 15, 200), + LEFT_BUTTON(204, 0, 16, 10), + RIGHT_BUTTON(214, 0, 16, 10); private final int x, y, height, width; private StandardButtonTextureSets(int x, int y, int height, int width) { diff --git a/common/buildcraft/core/gui/slots/SlotBase.java b/common/buildcraft/core/gui/slots/SlotBase.java index 27d7cbf8..63cedc8c 100644 --- a/common/buildcraft/core/gui/slots/SlotBase.java +++ b/common/buildcraft/core/gui/slots/SlotBase.java @@ -7,6 +7,7 @@ */ package buildcraft.core.gui.slots; +import buildcraft.core.gui.tooltips.IToolTipProvider; import buildcraft.core.gui.tooltips.ToolTip; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; @@ -15,7 +16,7 @@ import net.minecraft.inventory.Slot; * * @author CovertJaguar */ -public class SlotBase extends Slot { +public class SlotBase extends Slot implements IToolTipProvider { private ToolTip toolTips; @@ -30,6 +31,7 @@ public class SlotBase extends Slot { /** * @return the toolTips */ + @Override public ToolTip getToolTip() { return toolTips; } @@ -40,4 +42,14 @@ public class SlotBase extends Slot { public void setToolTips(ToolTip toolTips) { this.toolTips = toolTips; } + + @Override + public boolean isToolTipVisible() { + return getStack() == null; + } + + @Override + public boolean isMouseOver(int mouseX, int mouseY) { + return mouseX >= xDisplayPosition && mouseX <= xDisplayPosition + 16 && mouseY >= yDisplayPosition && mouseY <= yDisplayPosition + 16; + } } diff --git a/common/buildcraft/core/gui/tooltips/IToolTipProvider.java b/common/buildcraft/core/gui/tooltips/IToolTipProvider.java new file mode 100644 index 00000000..59351e3f --- /dev/null +++ b/common/buildcraft/core/gui/tooltips/IToolTipProvider.java @@ -0,0 +1,14 @@ +package buildcraft.core.gui.tooltips; + +/** + * + * @author CovertJaguar + */ +public interface IToolTipProvider { + + ToolTip getToolTip(); + + boolean isToolTipVisible(); + + boolean isMouseOver(int mouseX, int mouseY); +} diff --git a/common/buildcraft/core/gui/widgets/FluidGaugeWidget.java b/common/buildcraft/core/gui/widgets/FluidGaugeWidget.java new file mode 100644 index 00000000..acdbbbf0 --- /dev/null +++ b/common/buildcraft/core/gui/widgets/FluidGaugeWidget.java @@ -0,0 +1,58 @@ +package buildcraft.core.gui.widgets; + + +import buildcraft.core.fluids.Tank; +import buildcraft.core.gui.GuiBuildCraft; +import buildcraft.core.gui.tooltips.ToolTip; +import buildcraft.core.render.FluidRenderer; +import net.minecraft.util.Icon; +import net.minecraftforge.fluids.FluidStack; + +/** + * + * @author CovertJaguar + */ +public class FluidGaugeWidget extends Widget { + + public final Tank tank; + + public FluidGaugeWidget(Tank tank, int x, int y, int u, int v, int w, int h) { + super(x, y, u, v, w, h); + this.tank = tank; + } + + @Override + public ToolTip getToolTip() { + return tank.getToolTip(); + } + + @Override + public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) { + if (tank == null) + return; + FluidStack fluidStack = tank.getFluid(); + if (fluidStack == null || fluidStack.amount <= 0 || fluidStack.getFluid() == null) + return; + + Icon liquidIcon = FluidRenderer.getFluidTexture(fluidStack, false); + + if (liquidIcon == null) + return; + + float scale = Math.min(fluidStack.amount, tank.getCapacity()) / (float) tank.getCapacity(); + + gui.bindTexture(FluidRenderer.getFluidSheet(fluidStack)); + + for (int col = 0; col < w / 16; col++) { + for (int row = 0; row <= h / 16; row++) { + gui.drawTexturedModelRectFromIcon(guiX + x + col * 16, guiY + y + row * 16 - 1, liquidIcon, 16, 16); + } + } + + gui.bindTexture(gui.texture); + + gui.drawTexturedModalRect(guiX + x, guiY + y - 1, x, y - 1, w, h - (int) Math.floor(h * scale) + 1); + gui.drawTexturedModalRect(guiX + x, guiY + y, u, v, w, h); + } + +} diff --git a/common/buildcraft/core/gui/widgets/IIndicatorController.java b/common/buildcraft/core/gui/widgets/IIndicatorController.java new file mode 100644 index 00000000..efece096 --- /dev/null +++ b/common/buildcraft/core/gui/widgets/IIndicatorController.java @@ -0,0 +1,16 @@ +package buildcraft.core.gui.widgets; + +import buildcraft.core.gui.tooltips.ToolTip; + + +/** + * + * @author CovertJaguar + */ +public interface IIndicatorController { + + ToolTip getToolTip(); + + int getScaledLevel(int size); + +} diff --git a/common/buildcraft/core/gui/widgets/IndicatorController.java b/common/buildcraft/core/gui/widgets/IndicatorController.java new file mode 100644 index 00000000..85b6c056 --- /dev/null +++ b/common/buildcraft/core/gui/widgets/IndicatorController.java @@ -0,0 +1,31 @@ +package buildcraft.core.gui.widgets; + +import buildcraft.core.gui.tooltips.ToolTip; +import buildcraft.core.gui.tooltips.ToolTipLine; + +/** + * + * @author CovertJaguar + */ +public abstract class IndicatorController implements IIndicatorController { + + private final ToolTip tips = new ToolTip() { + @Override + public void refresh() { + refreshToolTip(); + } + }; + protected ToolTipLine tip = new ToolTipLine(); + + public IndicatorController() { + tips.add(tip); + } + + protected void refreshToolTip() { + } + + @Override + public final ToolTip getToolTip() { + return tips; + } +} diff --git a/common/buildcraft/core/gui/widgets/IndicatorWidget.java b/common/buildcraft/core/gui/widgets/IndicatorWidget.java new file mode 100644 index 00000000..41c7b75f --- /dev/null +++ b/common/buildcraft/core/gui/widgets/IndicatorWidget.java @@ -0,0 +1,33 @@ +package buildcraft.core.gui.widgets; + +import buildcraft.core.gui.GuiBuildCraft; +import buildcraft.core.gui.tooltips.ToolTip; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * + * @author CovertJaguar + */ +public class IndicatorWidget extends Widget { + + public final IIndicatorController controller; + + public IndicatorWidget(IIndicatorController controller, int x, int y, int u, int v, int w, int h) { + super(x, y, u, v, w, h); + this.controller = controller; + } + + @Override + @SideOnly(Side.CLIENT) + public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) { + int scale = controller.getScaledLevel(h); + gui.drawTexturedModalRect(guiX + x, guiY + y + h - scale, u, v + h - scale, w, scale); + } + + @Override + public ToolTip getToolTip() { + return controller.getToolTip(); + } + +} diff --git a/common/buildcraft/core/gui/widgets/Widget.java b/common/buildcraft/core/gui/widgets/Widget.java new file mode 100644 index 00000000..673cb9f6 --- /dev/null +++ b/common/buildcraft/core/gui/widgets/Widget.java @@ -0,0 +1,78 @@ +/** + * 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.gui.widgets; + +import buildcraft.core.gui.BuildCraftContainer; +import buildcraft.core.gui.GuiBuildCraft; +import buildcraft.core.gui.tooltips.IToolTipProvider; +import buildcraft.core.gui.tooltips.ToolTip; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.inventory.ICrafting; + +/** + * + * @author CovertJaguar + */ +public class Widget implements IToolTipProvider { + + public final int x; + public final int y; + public final int u; + public final int v; + public final int w; + public final int h; + public boolean hidden; + protected BuildCraftContainer container; + + public Widget(int x, int y, int u, int v, int w, int h) { + this.x = x; + this.y = y; + this.u = u; + this.v = v; + this.w = w; + this.h = h; + } + + public void addToContainer(BuildCraftContainer container) { + this.container = container; + } + + @SideOnly(Side.CLIENT) + @Override + public final boolean isMouseOver(int mouseX, int mouseY) { + return mouseX >= x - 1 && mouseX < x + w + 1 && mouseY >= y - 1 && mouseY < y + h + 1; + } + + @SideOnly(Side.CLIENT) + public boolean mouseClicked(int mouseX, int mouseY, int button) { + return false; + } + + @SideOnly(Side.CLIENT) + public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) { + gui.drawTexturedModalRect(guiX + x, guiY + y, u, v, w, h); + } + + @SideOnly(Side.CLIENT) + @Override + public ToolTip getToolTip() { + return null; + } + + @Override + public boolean isToolTipVisible() { + return true; + } + + public void initWidget(ICrafting player) { + } + + public void updateWidget(ICrafting player) { + } +} diff --git a/common/buildcraft/core/inventory/InventoryIterator.java b/common/buildcraft/core/inventory/InventoryIterator.java index 62c63d0a..ac349368 100644 --- a/common/buildcraft/core/inventory/InventoryIterator.java +++ b/common/buildcraft/core/inventory/InventoryIterator.java @@ -21,12 +21,17 @@ public class InventoryIterator { if (inv instanceof ISidedInventory) { return new InventoryIteratorSided((ISidedInventory) inv, side); } - + return new InventoryIteratorSimple(inv); } public interface IInvSlot { - + + /** + * Returns the slot number of the underlying Inventory. + * + * @return the slot number + */ int getIndex(); boolean canPutStackInSlot(ItemStack stack); diff --git a/common/buildcraft/core/triggers/BCAction.java b/common/buildcraft/core/triggers/BCAction.java index a407fef6..1ded9a94 100644 --- a/common/buildcraft/core/triggers/BCAction.java +++ b/common/buildcraft/core/triggers/BCAction.java @@ -35,7 +35,7 @@ public abstract class BCAction implements IAction { return this.legacyId; } - public int getIconIndex(){ + public int getIconIndex() { return 0; } @@ -45,6 +45,10 @@ public abstract class BCAction implements IAction { return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex()); } + public int getTextureMap() { + return 1; + } + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { diff --git a/common/buildcraft/energy/gui/GuiCombustionEngine.java b/common/buildcraft/energy/gui/GuiCombustionEngine.java index a2074c57..7bd5c854 100644 --- a/common/buildcraft/energy/gui/GuiCombustionEngine.java +++ b/common/buildcraft/energy/gui/GuiCombustionEngine.java @@ -27,7 +27,7 @@ public class GuiCombustionEngine extends GuiEngine { private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) { - super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine); + super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine, TEXTURE); } @Override @@ -40,11 +40,9 @@ 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.bindTexture(TEXTURE); + super.drawGuiContainerBackgroundLayer(f, x, y); int j = (width - xSize) / 2; int k = (height - ySize) / 2; - drawTexturedModalRect(j, k, 0, 0, xSize, ySize); TileEngineIron engine = (TileEngineIron) tile; diff --git a/common/buildcraft/energy/gui/GuiEngine.java b/common/buildcraft/energy/gui/GuiEngine.java index 5624fb33..1733d5ea 100644 --- a/common/buildcraft/energy/gui/GuiEngine.java +++ b/common/buildcraft/energy/gui/GuiEngine.java @@ -57,8 +57,8 @@ public abstract class GuiEngine extends GuiBuildCraft { } } - public GuiEngine(BuildCraftContainer container, IInventory inventory) { - super(container, inventory); + public GuiEngine(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) { + super(container, inventory, texture); } @Override diff --git a/common/buildcraft/energy/gui/GuiStoneEngine.java b/common/buildcraft/energy/gui/GuiStoneEngine.java index 0972f73c..fa590286 100644 --- a/common/buildcraft/energy/gui/GuiStoneEngine.java +++ b/common/buildcraft/energy/gui/GuiStoneEngine.java @@ -22,7 +22,7 @@ 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, TileEngineWithInventory tileEngine) { - super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine); + super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine, TEXTURE); } @Override diff --git a/common/buildcraft/factory/gui/GuiAutoCrafting.java b/common/buildcraft/factory/gui/GuiAutoCrafting.java index 76293ae9..e45a52f3 100644 --- a/common/buildcraft/factory/gui/GuiAutoCrafting.java +++ b/common/buildcraft/factory/gui/GuiAutoCrafting.java @@ -18,11 +18,11 @@ import org.lwjgl.opengl.GL11; public class GuiAutoCrafting extends GuiBuildCraft { - public static final ResourceLocation gui = new ResourceLocation("buildcraft",DefaultProps.TEXTURE_PATH_GUI + "/autobench.png"); + public static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft",DefaultProps.TEXTURE_PATH_GUI + "/autobench.png"); private TileAutoWorkbench bench; public GuiAutoCrafting(InventoryPlayer inventoryplayer, World world, TileAutoWorkbench tile) { - super(new ContainerAutoWorkbench(inventoryplayer, tile), tile); + super(new ContainerAutoWorkbench(inventoryplayer, tile), tile, TEXTURE); this.bench = tile; } @@ -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.bindTexture(gui); + mc.renderEngine.bindTexture(TEXTURE); int x = (width - xSize) / 2; int y = (height - ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, ySize); diff --git a/common/buildcraft/factory/gui/GuiRefinery.java b/common/buildcraft/factory/gui/GuiRefinery.java index 1b36648c..a8a52d7c 100644 --- a/common/buildcraft/factory/gui/GuiRefinery.java +++ b/common/buildcraft/factory/gui/GuiRefinery.java @@ -28,7 +28,7 @@ public class GuiRefinery extends GuiAdvancedInterface { ContainerRefinery container; public GuiRefinery(InventoryPlayer inventory, TileRefinery refinery) { - super(new ContainerRefinery(inventory, refinery), refinery); + super(new ContainerRefinery(inventory, refinery), refinery, TEXTURE); xSize = 175; ySize = 207; diff --git a/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java b/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java index f74233f4..8449394c 100644 --- a/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java @@ -15,7 +15,7 @@ import org.lwjgl.opengl.GL11; public class GuiAdvancedCraftingTable extends GuiBuildCraft { - public static final ResourceLocation gui = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/assembly_advancedworkbench.png"); + public static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/assembly_advancedworkbench.png"); class AssemblyWorkbenchLedger extends Ledger { @@ -59,7 +59,7 @@ public class GuiAdvancedCraftingTable extends GuiBuildCraft { TileAdvancedCraftingTable workbench; public GuiAdvancedCraftingTable(InventoryPlayer playerInventory, TileAdvancedCraftingTable advancedWorkbench) { - super(new ContainerAdvancedCraftingTable(playerInventory, advancedWorkbench), advancedWorkbench); + super(new ContainerAdvancedCraftingTable(playerInventory, advancedWorkbench), advancedWorkbench, TEXTURE); this.workbench = advancedWorkbench; xSize = 175; ySize = 240; @@ -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.bindTexture(gui); + 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/silicon/gui/GuiAssemblyTable.java b/common/buildcraft/silicon/gui/GuiAssemblyTable.java index d9c04d88..51d06df1 100644 --- a/common/buildcraft/silicon/gui/GuiAssemblyTable.java +++ b/common/buildcraft/silicon/gui/GuiAssemblyTable.java @@ -91,7 +91,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { } public GuiAssemblyTable(IInventory playerInventory, TileAssemblyTable assemblyTable) { - super(new ContainerAssemblyTable(playerInventory, assemblyTable), assemblyTable); + super(new ContainerAssemblyTable(playerInventory, assemblyTable), assemblyTable, TEXTURE); this.assemblyTable = assemblyTable; xSize = 175; diff --git a/common/buildcraft/transport/gui/GuiDiamondPipe.java b/common/buildcraft/transport/gui/GuiDiamondPipe.java index 91b97ec4..85e9a1ad 100644 --- a/common/buildcraft/transport/gui/GuiDiamondPipe.java +++ b/common/buildcraft/transport/gui/GuiDiamondPipe.java @@ -33,7 +33,7 @@ public class GuiDiamondPipe extends GuiBuildCraft { } public GuiDiamondPipe(IInventory playerInventory, PipeItemsDiamond pipe) { - super(new ContainerDiamondPipe(playerInventory, pipe), pipe.getFilters()); + super(new ContainerDiamondPipe(playerInventory, pipe), pipe.getFilters(), TEXTURE); this.playerInventory = playerInventory; this.filterInventory = pipe.getFilters(); xSize = 175; diff --git a/common/buildcraft/transport/gui/GuiEmeraldPipe.java b/common/buildcraft/transport/gui/GuiEmeraldPipe.java index c3e69d0f..8c5e2f59 100644 --- a/common/buildcraft/transport/gui/GuiEmeraldPipe.java +++ b/common/buildcraft/transport/gui/GuiEmeraldPipe.java @@ -30,7 +30,7 @@ public class GuiEmeraldPipe extends GuiBuildCraft { PipeItemsEmerald pipe; public GuiEmeraldPipe(IInventory playerInventory, PipeItemsEmerald pipe) { - super(new ContainerEmeraldPipe(playerInventory, pipe), pipe.getFilters()); + super(new ContainerEmeraldPipe(playerInventory, pipe), pipe.getFilters(), TEXTURE); this.pipe = pipe; this.playerInventory = playerInventory; diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java index df41d431..992b3d36 100644 --- a/common/buildcraft/transport/gui/GuiGateInterface.java +++ b/common/buildcraft/transport/gui/GuiGateInterface.java @@ -11,12 +11,14 @@ import buildcraft.api.gates.IAction; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.gui.GuiAdvancedInterface; +import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; import buildcraft.transport.Gate.GateKind; import buildcraft.transport.Pipe; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.Iterator; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; @@ -101,6 +103,17 @@ public class GuiGateInterface extends GuiAdvancedInterface { return null; } + @Override + public ResourceLocation getTexture() { + IAction action = pipe.gate.getAction(slot); + if (action instanceof BCAction) { + BCAction bcAction = (BCAction) action; + if (bcAction.getTextureMap() == 0) + return TextureMap.locationBlocksTexture; + } + return super.getTexture(); + } + @Override public boolean isDefined() { return pipe.gate.getAction(slot) != null; @@ -143,7 +156,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { } public GuiGateInterface(IInventory playerInventory, Pipe pipe) { - super(new ContainerGateInterface(playerInventory, pipe), null); + super(new ContainerGateInterface(playerInventory, pipe), null, null); _container = (ContainerGateInterface) this.inventorySlots; From f1bec62b90e4fc27ac2a1de97f51a74dbed50cb9 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 19 Nov 2013 05:26:30 -0800 Subject: [PATCH 08/45] Rewrite previous Assembly Table commit Yeah...there were better ways to do that... --- common/buildcraft/BuildCraftTransport.java | 20 ++- .../api/recipes/AssemblyRecipe.java | 119 +++++++----------- .../buildcraft/silicon/TileAssemblyTable.java | 57 ++++----- 3 files changed, 83 insertions(+), 113 deletions(-) diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 94b33b1a..1976130b 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -266,7 +266,7 @@ public class BuildCraftTransport { pipeWaterproof.setUnlocalizedName("pipeWaterproof"); LanguageRegistry.addName(pipeWaterproof, "Pipe Sealant"); CoreProxy.proxy.registerItem(pipeWaterproof); - + genericPipeBlock = new BlockGenericPipe(genericPipeId.getInt()); CoreProxy.proxy.registerBlock(genericPipeBlock.setUnlocalizedName("pipeBlock"), ItemBlock.class); @@ -411,7 +411,7 @@ 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); } @@ -425,7 +425,7 @@ public class BuildCraftTransport { // Add pipe recipes for (PipeRecipe pipe : pipeRecipes) { if (pipe.isShapeless) { - CoreProxy.proxy.addShapelessRecipe(pipe.result, pipe.input); + CoreProxy.proxy.addShapelessRecipe(pipe.result, pipe.input); } else { CoreProxy.proxy.addCraftingRecipe(pipe.result, pipe.input); } @@ -440,20 +440,16 @@ public class BuildCraftTransport { GameRegistry.addRecipe(facadeItem.new FacadeRecipe()); // Assembly table recipes, moved from PreInit phase to Init, all mods should be done adding to the OreDictionary by now - AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new Object[]{"dyeRed", 1, new ItemStack(Item.redstone, 1), - new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(redPipeWire, 8))); - AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new Object[]{"dyeBlue", 1, new ItemStack(Item.redstone, 1), - new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(bluePipeWire, 8))); - AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new Object[]{"dyeGreen", 1, new ItemStack(Item.redstone, 1), - new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(greenPipeWire, 8))); - AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new Object[]{"dyeYellow", 1, new ItemStack(Item.redstone, 1), - new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(yellowPipeWire, 8))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(redPipeWire, 8), "dyeRed", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(bluePipeWire, 8), "dyeBlue", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(greenPipeWire, 8), "dyeGreen", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(yellowPipeWire, 8), "dyeYellow", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8))); } @EventHandler public void processIMCRequests(IMCEvent event) { - InterModComms.processIMC(event); + InterModComms.processIMC(event); } public static Item buildPipe(int defaultID, Class clas, String descr, Object... ingredients) { diff --git a/common/buildcraft/api/recipes/AssemblyRecipe.java b/common/buildcraft/api/recipes/AssemblyRecipe.java index b3abbdbc..6ab39418 100644 --- a/common/buildcraft/api/recipes/AssemblyRecipe.java +++ b/common/buildcraft/api/recipes/AssemblyRecipe.java @@ -8,106 +8,79 @@ import net.minecraftforge.oredict.OreDictionary; public class AssemblyRecipe { public static LinkedList assemblyRecipes = new LinkedList(); - - public final ItemStack[] input; + public final Object[] input; public final ItemStack output; public final float energy; - public final Object[] inputOreDict; - public AssemblyRecipe(ItemStack[] input, int energy, ItemStack output) { this.input = input; this.output = output; this.energy = energy; - this.inputOreDict = input; } - /** This version of AssemblyRecipe supports the OreDictionary - * - * @param input Object[] containing either an ItemStack, or a paired string and integer(ex: "dyeBlue", 1) - * @param energy MJ cost to produce - * @param output resulting ItemStack - */ - public AssemblyRecipe(Object[] input, int energy, ItemStack output) { + /** + * This version of AssemblyRecipe supports the OreDictionary + * + * @param input Object... containing either an ItemStack, or a paired string + * and integer(ex: "dyeBlue", 1) + * @param energy MJ cost to produce + * @param output resulting ItemStack + */ + public AssemblyRecipe(int energy, ItemStack output, Object... input) { this.output = output; this.energy = energy; + this.input = input; - this.inputOreDict = new Object[input.length]; - - int count = 0; - for (int idx = 0; idx < input.length; idx++) { - if (input[idx] == null) { - continue; + for (int i = 0; i < input.length; i++) { + if (input[i] instanceof String) { + input[i] = OreDictionary.getOres((String) input[i]); } - - ItemStack in; - - if (input[idx] instanceof ItemStack) { - inputOreDict[idx] = input[idx]; - count++; - } else if (input[idx] instanceof String) { - ArrayList oreListWithStackSize = new ArrayList(); - - for (ItemStack oreItem : OreDictionary.getOres((String)input[idx])) { - ItemStack sizeAdjustedOreItem = oreItem.copy(); - - //Desired recipe stacksize is on next index - sizeAdjustedOreItem.stackSize = (int)input[idx + 1]; - - oreListWithStackSize.add(sizeAdjustedOreItem); - } - - inputOreDict[idx++] = oreListWithStackSize; - count++; - } - } - - // create the recipe item array - this.input = new ItemStack[count]; - count = 0; - for(Object recipeItem : inputOreDict) { - if (recipeItem == null) { - continue; - } - - // since the API recipe item array is an ItemStack, just grab the first item from the OreDict list - this.input[count++] = recipeItem instanceof ItemStack ? (ItemStack)recipeItem: ((ArrayList)recipeItem).get(0); } } - public boolean canBeDone(ItemStack[] items) { - - for (Object in : inputOreDict) { - - if (in == null) { + public boolean canBeDone(ItemStack... items) { + for (int i = 0; i < input.length; i++) { + if (input[i] == null) continue; - } - int found = 0; // Amount of ingredient found in inventory - int expected = in instanceof ItemStack ? ((ItemStack)in).stackSize: in instanceof ArrayList ? ((ArrayList)in).get(0).stackSize: 1; + if (input[i] instanceof ItemStack) { + ItemStack requirement = (ItemStack) input[i]; + int found = 0; // Amount of ingredient found in inventory + int expected = requirement.stackSize; + for (ItemStack item : items) { + if (item == null) + continue; + + if (item.isItemEqual(requirement)) + found += item.stackSize; // Adds quantity of stack to amount found - for (ItemStack item : items) { - if (item == null) { - continue; } - if (in instanceof ItemStack) { - if (item.isItemEqual((ItemStack)in)) { - found += item.stackSize; // Adds quantity of stack to amount found - } - } else if (in instanceof ArrayList) { - for (ItemStack oreItem : (ArrayList)in) { - if(OreDictionary.itemMatches(oreItem, item, true)) { + // Return false if the amount of ingredient found + // is not enough + if (found < expected) + return false; + } else if (input[i] instanceof ArrayList) { + ArrayList oreList = (ArrayList) input[i]; + int found = 0; // Amount of ingredient found in inventory + int expected = (Integer) input[i++ + 1]; + + for (ItemStack item : items) { + if (item == null) + continue; + for (ItemStack oreItem : oreList) { + if (OreDictionary.itemMatches(oreItem, item, true)) { found += item.stackSize; break; } } } - } - if (found < expected) - return false; // Return false if the amount of ingredient found - // is not enough + // Return false if the amount of ingredient found + // is not enough + if (found < expected) + return false; + } } return true; diff --git a/common/buildcraft/silicon/TileAssemblyTable.java b/common/buildcraft/silicon/TileAssemblyTable.java index dd017f39..ffc6ae5e 100644 --- a/common/buildcraft/silicon/TileAssemblyTable.java +++ b/common/buildcraft/silicon/TileAssemblyTable.java @@ -4,12 +4,16 @@ import buildcraft.api.gates.IAction; import buildcraft.api.recipes.AssemblyRecipe; import buildcraft.core.DefaultProps; import buildcraft.core.IMachine; +import buildcraft.core.inventory.ITransactor; import buildcraft.core.inventory.StackHelper; +import buildcraft.core.inventory.Transactor; +import buildcraft.core.inventory.filters.ArrayStackFilter; import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketNBT; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; import cpw.mods.fml.common.FMLCommonHandler; +import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.LinkedList; import net.minecraft.entity.item.EntityItem; @@ -99,34 +103,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor if (currentRecipe.canBeDone(items)) { - for (ItemStack in : currentRecipe.input) { - if (in == null) { - continue; // Optimisation, reduces calculation for a null ingredient - } - - int found = 0; // Amount of ingredient found in inventory - - for (int i = 0; i < items.length; ++i) { - if (items[i] == null) { - continue; // Broken out of large if statement, increases clarity - } - - if (StackHelper.instance().isCraftingEquivalent(in, items[i], true)) { - - int supply = items[i].stackSize; - int toBeFound = in.stackSize - found; - - if (supply >= toBeFound) { - found += decrStackSize(i, toBeFound).stackSize; // Adds the amount of ingredient taken (in this case the total still needed) - } else { - found += decrStackSize(i, supply).stackSize; // Adds the amount of ingredient taken (in this case the total in that slot) - } - if (found >= in.stackSize) { - break; // Breaks out of the for loop when the required amount of ingredient has been taken - } - } - } - } + useItems(); ItemStack remaining = currentRecipe.output.copy(); remaining.stackSize -= Utils.addToRandomInventoryAround(worldObj, xCoord, yCoord, zCoord, remaining); @@ -146,6 +123,30 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor } } + private void useItems() { + ITransactor tran = Transactor.getTransactorFor(this); + Object[] input = currentRecipe.input; + for (int i = 0; i < input.length; i++) { + if (input[i] instanceof ItemStack) { + ItemStack requirement = (ItemStack) input[i]; + for (int num = 0; num < requirement.stackSize; num++) { + tran.remove(new ArrayStackFilter(requirement), ForgeDirection.UNKNOWN, true); + } + } else if (input[i] instanceof ArrayList) { + ArrayList oreList = (ArrayList) input[i]; + int required = (Integer) input[i + 1]; + for (ItemStack ore : oreList) { + for (int num = 0; num < required; num++) { + if (tran.remove(new ArrayStackFilter(ore), ForgeDirection.UNKNOWN, true) != null) + required--; + } + if (required <= 0) + break; + } + } + } + } + public float getCompletionRatio(float ratio) { if (currentRecipe == null) return 0; From d870fcb1829da8a4fe47e95cecfaa4b8427a69d0 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 19 Nov 2013 06:11:20 -0800 Subject: [PATCH 09/45] Fix Emerald Pipe Button Tooltip Closes #1322 --- .../transport/pipes/PipeItemsEmerald.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/buildcraft/transport/pipes/PipeItemsEmerald.java b/common/buildcraft/transport/pipes/PipeItemsEmerald.java index dcc7fb20..2c13ee40 100644 --- a/common/buildcraft/transport/pipes/PipeItemsEmerald.java +++ b/common/buildcraft/transport/pipes/PipeItemsEmerald.java @@ -40,15 +40,12 @@ import buildcraft.transport.PipeIconProvider; public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGuiReturnHandler { public static enum ButtonState implements IMultiButtonState { - BLOCKING("gui.pipes.emerald.blocking"), NONBLOCKING("gui.pipes.emerald.nonblocking"); + 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 @@ -65,8 +62,14 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu public ToolTip getToolTip() { return this.tip; } + private final ToolTip tip = new ToolTip(500) { + @Override + public void refresh() { + clear(); + tip.add(new ToolTipLine(StringUtils.localize(label + ".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; @@ -108,7 +111,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu /* 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) { @@ -168,7 +171,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu } if (result != null) { - return new ItemStack[] { result }; + return new ItemStack[]{result}; } } From fbffebeef553aaa02c13ed3527991bb90c9f5b76 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 19 Nov 2013 17:18:19 -0800 Subject: [PATCH 10/45] Housecleaning --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 28a79d58..2ae94aed 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ 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! 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 9631ef5de68194f0306c1dbe528d2a399fa7df53 Mon Sep 17 00:00:00 2001 From: DemoXin Date: Tue, 19 Nov 2013 21:02:30 -0500 Subject: [PATCH 11/45] * BlockUtil.getItemStackFromBlock() now properly posts HarvestDropsEvent and loads its results for compatibility. * BlockUtil.breakBlock() now utilizes BlockUtil.getItemStackFromBlock() to get its drop list. --- common/buildcraft/core/utils/BlockUtil.java | 23 ++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/core/utils/BlockUtil.java b/common/buildcraft/core/utils/BlockUtil.java index 3b173e7b..0dde53c8 100644 --- a/common/buildcraft/core/utils/BlockUtil.java +++ b/common/buildcraft/core/utils/BlockUtil.java @@ -10,8 +10,12 @@ package buildcraft.core.utils; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; import buildcraft.api.core.BuildCraftAPI; +import buildcraft.core.proxy.CoreProxy; import cpw.mods.fml.common.FMLCommonHandler; + +import java.util.ArrayList; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.BlockFluid; import net.minecraft.entity.item.EntityItem; @@ -22,12 +26,14 @@ import net.minecraft.network.packet.Packet60Explosion; import net.minecraft.world.ChunkPosition; import net.minecraft.world.Explosion; import net.minecraft.world.World; +import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; + public class BlockUtil { public static List getItemStackFromBlock(World world, int i, int j, int k) { @@ -41,7 +47,19 @@ public class BlockUtil { int meta = world.getBlockMetadata(i, j, k); - return block.getBlockDropped(world, i, j, k, meta, 0); + ArrayList dropsList = block.getBlockDropped(world, i, j, k, meta, 0); + float dropChance = ForgeEventFactory.fireBlockHarvesting(dropsList, world, block, i, j, k, meta, 0, 1.0F, false, CoreProxy.proxy.getBuildCraftPlayer(world)); + + ArrayList returnList = new ArrayList(); + for (ItemStack s : dropsList) + { + if (world.rand.nextFloat() <= dropChance) + { + returnList.add(s); + } + } + + return returnList; } public static void breakBlock(World world, int x, int y, int z) { @@ -50,8 +68,7 @@ public class BlockUtil { public static void breakBlock(World world, int x, int y, int z, int forcedLifespan) { if (!world.isAirBlock(x, y, z) && BuildCraftCore.dropBrokenBlocks && !world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) { - int blockId = world.getBlockId(x, y, z); - List items = Block.blocksList[blockId].getBlockDropped(world, x, y, z, world.getBlockMetadata(x, y, z), 0); + List items = getItemStackFromBlock(world, x, y, z); for (ItemStack item : items) { float var = 0.7F; From 9d4b1b9782fb66e989e8eb9f4a19489ea6689a6e Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 20 Nov 2013 17:27:01 -0800 Subject: [PATCH 12/45] Move ILaserTarget to the power API --- common/buildcraft/api/power/ILaserTarget.java | 46 +++++++++++++++++++ common/buildcraft/silicon/ILaserTarget.java | 15 ------ .../silicon/TileAdvancedCraftingTable.java | 7 +-- .../buildcraft/silicon/TileAssemblyTable.java | 17 +++---- common/buildcraft/silicon/TileLaser.java | 12 ++--- 5 files changed, 65 insertions(+), 32 deletions(-) create mode 100644 common/buildcraft/api/power/ILaserTarget.java delete mode 100644 common/buildcraft/silicon/ILaserTarget.java diff --git a/common/buildcraft/api/power/ILaserTarget.java b/common/buildcraft/api/power/ILaserTarget.java new file mode 100644 index 00000000..3d1eca59 --- /dev/null +++ b/common/buildcraft/api/power/ILaserTarget.java @@ -0,0 +1,46 @@ +/* + * 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.api.power; + +/** + * Specifies a Tile Entity that can receive power via laser beam. + * + * @author cpw + */ +public interface ILaserTarget { + + /** + * Returns true if the target currently needs power. For example, if the Advanced + * Crafting Table has work to do. + * + * @return true if needs power + */ + boolean requiresLaserEnergy(); + + /** + * Transfers energy from the laser to the target. + * + * @param energy + */ + void receiveLaserEnergy(float energy); + + /** + * Return true if the Tile Entity object is no longer a valid target. For + * example, if its been invalidated. + * + * @return true if no longer a valid target object + */ + boolean isInvalidTarget(); + + int getXCoord(); + + int getYCoord(); + + int getZCoord(); +} diff --git a/common/buildcraft/silicon/ILaserTarget.java b/common/buildcraft/silicon/ILaserTarget.java deleted file mode 100644 index 46a39b60..00000000 --- a/common/buildcraft/silicon/ILaserTarget.java +++ /dev/null @@ -1,15 +0,0 @@ -package buildcraft.silicon; - -public interface ILaserTarget { - boolean hasCurrentWork(); - - void receiveLaserEnergy(float energy); - - boolean isInvalidTarget(); - - int getXCoord(); - - int getYCoord(); - - int getZCoord(); -} diff --git a/common/buildcraft/silicon/TileAdvancedCraftingTable.java b/common/buildcraft/silicon/TileAdvancedCraftingTable.java index 8fd35a15..89a1e9d5 100644 --- a/common/buildcraft/silicon/TileAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/TileAdvancedCraftingTable.java @@ -1,5 +1,6 @@ package buildcraft.silicon; +import buildcraft.api.power.ILaserTarget; import buildcraft.BuildCraftCore; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IActionReceptor; @@ -413,8 +414,8 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory, } @Override - public boolean hasCurrentWork() { - return craftable && !justCrafted && lastMode != ActionMachineControl.Mode.Off; + public boolean requiresLaserEnergy() { + return craftable && !justCrafted && lastMode != ActionMachineControl.Mode.Off && storedEnergy < REQUIRED_POWER * 10; } @Override @@ -440,7 +441,7 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory, @Override public boolean isActive() { - return hasCurrentWork(); + return requiresLaserEnergy(); } @Override diff --git a/common/buildcraft/silicon/TileAssemblyTable.java b/common/buildcraft/silicon/TileAssemblyTable.java index ffc6ae5e..f855de21 100644 --- a/common/buildcraft/silicon/TileAssemblyTable.java +++ b/common/buildcraft/silicon/TileAssemblyTable.java @@ -1,5 +1,6 @@ package buildcraft.silicon; +import buildcraft.api.power.ILaserTarget; import buildcraft.api.gates.IAction; import buildcraft.api.recipes.AssemblyRecipe; import buildcraft.core.DefaultProps; @@ -71,12 +72,6 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor return result; } - @Override - public void receiveLaserEnergy(float energy) { - energyStored += energy; - recentEnergy[tick] += energy; - } - @Override public boolean canUpdate() { return !FMLCommonHandler.instance().getEffectiveSide().isClient(); @@ -456,8 +451,14 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor } @Override - public boolean hasCurrentWork() { - return currentRecipe != null; + public boolean requiresLaserEnergy() { + return currentRecipe != null && energyStored < currentRequiredEnergy * 5F; + } + + @Override + public void receiveLaserEnergy(float energy) { + energyStored += energy; + recentEnergy[tick] += energy; } @Override diff --git a/common/buildcraft/silicon/TileLaser.java b/common/buildcraft/silicon/TileLaser.java index c85b983c..7dcace38 100644 --- a/common/buildcraft/silicon/TileLaser.java +++ b/common/buildcraft/silicon/TileLaser.java @@ -7,6 +7,7 @@ */ package buildcraft.silicon; +import buildcraft.api.power.ILaserTarget; import buildcraft.BuildCraftCore; import buildcraft.api.core.Position; import buildcraft.api.core.SafeTimeTracker; @@ -125,7 +126,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction protected boolean isValidTable() { - if (laserTarget == null || laserTarget.isInvalidTarget() || !laserTarget.hasCurrentWork()) + if (laserTarget == null || laserTarget.isInvalidTarget() || !laserTarget.requiresLaserEnergy()) return false; return true; @@ -163,7 +164,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction break; } - List targets = new LinkedList(); + List targets = new LinkedList(); for (int x = minX; x <= maxX; ++x) { for (int y = minY; y <= maxY; ++y) { @@ -173,8 +174,8 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction if (tile instanceof ILaserTarget) { ILaserTarget table = (ILaserTarget) tile; - if (table.hasCurrentWork()) { - targets.add(new BlockIndex(x, y, z)); + if (table.requiresLaserEnergy()) { + targets.add(table); } } @@ -185,8 +186,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction if (targets.isEmpty()) return; - BlockIndex b = targets.get(worldObj.rand.nextInt(targets.size())); - laserTarget = (ILaserTarget) worldObj.getBlockTileEntity(b.x, b.y, b.z); + laserTarget = targets.get(worldObj.rand.nextInt(targets.size())); } protected void createLaser() { From e7c5090e1ef805ff58031957c04300a6a1a2cd80 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 20 Nov 2013 20:13:38 -0800 Subject: [PATCH 13/45] Pumps can now be disabled with redstone --- common/buildcraft/factory/BlockPump.java | 9 +++ common/buildcraft/factory/TilePump.java | 91 ++++++++++++++++-------- 2 files changed, 69 insertions(+), 31 deletions(-) diff --git a/common/buildcraft/factory/BlockPump.java b/common/buildcraft/factory/BlockPump.java index 6dc5585f..51d12c58 100644 --- a/common/buildcraft/factory/BlockPump.java +++ b/common/buildcraft/factory/BlockPump.java @@ -83,6 +83,15 @@ public class BlockPump extends BlockContainer { return false; } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, int id) { + super.onNeighborBlockChange(world, x, y, z, id); + TileEntity tile = world.getBlockTileEntity(x, y, z); + if (tile instanceof TilePump) { + ((TilePump) tile).onNeighborBlockChange(id); + } + } + @SuppressWarnings({"unchecked", "rawtypes"}) @Override public void addCreativeItems(ArrayList itemList) { diff --git a/common/buildcraft/factory/TilePump.java b/common/buildcraft/factory/TilePump.java index e6e419d3..2baa9b3b 100644 --- a/common/buildcraft/factory/TilePump.java +++ b/common/buildcraft/factory/TilePump.java @@ -62,6 +62,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor private SafeTimeTracker timer = new SafeTimeTracker(); private int tick = Utils.RANDOM.nextInt(); private int numFluidBlocksFound = 0; + private boolean powered = false; public TilePump() { powerHandler = new PowerHandler(this, Type.MACHINE); @@ -73,19 +74,26 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor powerHandler.configurePowerPerdition(1, 100); } - // TODO, manage this by different levels (pump what's above first...) @Override public void updateEntity() { super.updateEntity(); - if (tube == null) - return; + if (powered) { + pumpLayerQueues.clear(); + destroyTube(); + } else + createTube(); - - if (CoreProxy.proxy.isRenderWorld(worldObj)) + if (worldObj.isRemote) return; pushToConsumers(); + + if(powered) + return; + + if(tube == null) + return; if (tube.posY - aimY > 0.01) { tubeY = tube.posY - 0.01; @@ -134,6 +142,15 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor } } + public void onNeighborBlockChange(int id) { + boolean p = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); + if (powered != p) { + powered = p; + if(!worldObj.isRemote) + sendNetworkUpdate(); + } + } + private boolean isBlocked(int x, int y, int z) { Material mat = worldObj.getBlockMaterial(x, y, z); return mat.blocksMovement(); @@ -151,28 +168,37 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor return tileBuffer[side.ordinal()].getTile(); } - @Override - public void initialize() { - tube = FactoryProxy.proxy.newPumpTube(worldObj); + private void createTube() { + if (tube == null) { + tube = FactoryProxy.proxy.newPumpTube(worldObj); - if (!Double.isNaN(tubeY)) { - tube.posY = tubeY; - } else { - tube.posY = yCoord; + if (!Double.isNaN(tubeY)) { + tube.posY = tubeY; + } else { + tube.posY = yCoord; + } + + tubeY = tube.posY; + + if (aimY == 0) { + aimY = yCoord; + } + + setTubePosition(); + + worldObj.spawnEntityInWorld(tube); + + if (!worldObj.isRemote) + sendNetworkUpdate(); } + } - tubeY = tube.posY; - - if (aimY == 0) { - aimY = yCoord; - } - - setTubePosition(); - - worldObj.spawnEntityInWorld(tube); - - if (CoreProxy.proxy.isSimulating(worldObj)) { - sendNetworkUpdate(); + private void destroyTube() { + if (tube != null) { + CoreProxy.proxy.removeEntity(tube); + tube = null; + tubeY = Double.NaN; + aimY = 0; } } @@ -298,6 +324,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor powerHandler.readFromNBT(data); tank.readFromNBT(data); + powered = data.getBoolean("powered"); + aimY = data.getInteger("aimY"); tubeY = data.getFloat("tubeY"); @@ -311,6 +339,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor powerHandler.writeToNBT(data); tank.writeToNBT(data); + data.setBoolean("powered", powered); + data.setInteger("aimY", aimY); if (tube != null) { @@ -347,6 +377,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor public void writeData(DataOutputStream data) throws IOException { data.writeInt(aimY); data.writeFloat((float) tubeY); + data.writeBoolean(powered); } }); @@ -359,6 +390,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor DataInputStream data = payload.stream; aimY = data.readInt(); tubeY = data.readFloat(); + powered = data.readBoolean(); setTubePosition(); } @@ -394,12 +426,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor public void destroy() { tileBuffer = null; pumpLayerQueues.clear(); - if (tube != null) { - CoreProxy.proxy.removeEntity(tube); - tube = null; - tubeY = Double.NaN; - aimY = 0; - } + destroyTube(); } @Override @@ -431,7 +458,9 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor @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 28a06b0973f6bc7a72794e6b4e6fe7dd361cbba3 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 20 Nov 2013 20:20:05 -0800 Subject: [PATCH 14/45] Reduce the amount of spam when building --- build.xml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/build.xml b/build.xml index 65fbdaca..39a6a78e 100644 --- a/build.xml +++ b/build.xml @@ -130,7 +130,7 @@ - + @@ -169,10 +169,30 @@ + + + + + + + + + + + + + + + + + + + + From 7ee48c9cbd2408d2670196e0632ea2277eb93dc8 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 20 Nov 2013 20:32:11 -0800 Subject: [PATCH 15/45] Fix Fluid Localization --- .../lang/buildcraft/en_US.properties | 3 ++ common/buildcraft/BuildCraftEnergy.java | 6 ++-- common/buildcraft/core/fluids/BCFluid.java | 28 +++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 common/buildcraft/core/fluids/BCFluid.java diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index 4512f796..ec0bfa22 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -2,6 +2,9 @@ chat.pipe.power.iron.mode=Switched to %d MJ/t limit +fluid.oil=Oil +fluid.fuel=Fuel + gate.pipe.empty=Pipe Empty gate.pipe.containsItems=Items Traversing gate.pipe.containsFluids=Fluid Traversing diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 400b4c7d..0389e623 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -15,6 +15,7 @@ import buildcraft.core.BlockSpring; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.Version; +import buildcraft.core.fluids.BCFluid; import buildcraft.core.network.PacketHandler; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.triggers.BCTrigger; @@ -144,11 +145,12 @@ public class BuildCraftEnergy { // Oil and fuel - buildcraftFluidOil = new Fluid("oil").setDensity(800).setViscosity(1500); + buildcraftFluidOil = new BCFluid("oil").setDensity(800).setViscosity(1500); + FluidRegistry.registerFluid(buildcraftFluidOil); fluidOil = FluidRegistry.getFluid("oil"); - buildcraftFluidFuel = new Fluid("fuel"); + buildcraftFluidFuel = new BCFluid("fuel"); FluidRegistry.registerFluid(buildcraftFluidFuel); fluidFuel = FluidRegistry.getFluid("fuel"); diff --git a/common/buildcraft/core/fluids/BCFluid.java b/common/buildcraft/core/fluids/BCFluid.java new file mode 100644 index 00000000..8df7bbd8 --- /dev/null +++ b/common/buildcraft/core/fluids/BCFluid.java @@ -0,0 +1,28 @@ +/* + * 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.fluids; + +import buildcraft.core.utils.StringUtils; +import net.minecraftforge.fluids.Fluid; + +/** + * + * @author CovertJaguar + */ +public class BCFluid extends Fluid { + + public BCFluid(String name) { + super(name); + } + + @Override + public String getLocalizedName() { + return StringUtils.localize("fluid." + fluidName); + } +} From ec4ed4df99ffef23e4e2922b3dfb618d89a222c0 Mon Sep 17 00:00:00 2001 From: SandGrainOne Date: Thu, 21 Nov 2013 20:57:18 +0100 Subject: [PATCH 16/45] Adding Logemerald pipe This is an action sensitive extraction pipe. The pipe can be configured with 4 different items and actions will decide which one to extract from the connected inventory. --- .../blocks/pipeAllLogemerald_solid.png | Bin 0 -> 325 bytes .../blocks/pipeItemsLogemerald_standard.png | Bin 0 -> 215 bytes .../textures/gui/logemerald_pipe_gui.png | Bin 0 -> 1367 bytes .../items/triggers/extraction_preset_blue.png | Bin 0 -> 169 bytes .../triggers/extraction_preset_green.png | Bin 0 -> 183 bytes .../items/triggers/extraction_preset_red.png | Bin 0 -> 159 bytes .../triggers/extraction_preset_yellow.png | Bin 0 -> 192 bytes .../lang/buildcraft/en_US.properties | 3 + common/buildcraft/BuildCraftTransport.java | 19 +- common/buildcraft/core/DefaultProps.java | 1 + common/buildcraft/core/GuiIds.java | 1 + common/buildcraft/transport/GuiHandler.java | 9 + .../transport/PipeConnectionBans.java | 3 + .../transport/PipeIconProvider.java | 3 + .../transport/TransportProxyClient.java | 1 + .../gui/ContainerLogemeraldPipe.java | 49 ++++ .../transport/gui/GuiLogemeraldPipe.java | 52 ++++ .../transport/pipes/PipeItemsLogemerald.java | 246 ++++++++++++++++++ .../triggers/ActionExtractionPreset.java | 41 +++ 19 files changed, 423 insertions(+), 5 deletions(-) create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllLogemerald_solid.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsLogemerald_standard.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/gui/logemerald_pipe_gui.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_blue.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_green.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_red.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_yellow.png create mode 100644 common/buildcraft/transport/gui/ContainerLogemeraldPipe.java create mode 100644 common/buildcraft/transport/gui/GuiLogemeraldPipe.java create mode 100644 common/buildcraft/transport/pipes/PipeItemsLogemerald.java create mode 100644 common/buildcraft/transport/triggers/ActionExtractionPreset.java diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllLogemerald_solid.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllLogemerald_solid.png new file mode 100644 index 0000000000000000000000000000000000000000..1cdefd74053f0f6bf1772b1eb9d969415ad38a3c GIT binary patch literal 325 zcmV-L0lNN)P)V(Rq-z(srBErY7Of^Uk{*qoXqGgP+Nz&0_Uz`3w8BgC7%+RXGXv^<$FA_^myrhX4Zr XDQ9<_JUwCP00000NkvXXu0mjf4p4yQ literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsLogemerald_standard.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsLogemerald_standard.png new file mode 100644 index 0000000000000000000000000000000000000000..96a09f191faaac03ef6716719a94df795bbf7f5f GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmUzPnffIy#(?lOI#yL zg7ec#$`gxH85~pclTsBta}(23gHjVyDhp4h+5i=0db&7pZM+TIS(n*&FQlxpDg_OdCA?1TgNOa=eY}es)g5I&WUqt_`A3GozQ5U=)m;UXKf7Z^#^x;<9y$_#nIfLn9MF9pagMAm?ewqAN z?tq^D^Qpfk-H)#O{r~m$KOc;Nl90ewVBh`b!}UK}2ey^&3uolm!xg|eyH-T9;i35+ zbEds-^$z6Mb?ss49&4jN~Wl&&fU|?VZMmZ(}B<7I2Z63RT-Dz37e%aF&#}s|f9-e=;`S^bc z`8^L@6do@zIQPS4!PBCjKfY&ekeEZ8BTS1PXCoT%0qyh}8Z<|VmFRVOp%rkM$$CU^EEN9^1ci>rmPfEQ^X7=T2 zxIM1`^!zelf><#jxUqNg9}A!3D-WaqF+__)>GuCJZZ}wR~V`tJ2o+N118M4 b&&0zZw$O7{>Vo-O7=Xaj)z4*}Q$iB}UCGJ3 literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_blue.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..9162f16decab42469419fe973abd7d73501974f3 GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmUzPnffIy#(?lOI#yL zg7ec#$`gxH85~pclTsBta}(23gHjVyDhp4h+5i<^X^@m0;_@H1P+gD z2bj{QPOCe*c-`*Vvy-GR_#8?#ers#XVY=Y~zwoMC4U){vPcj=Am>JeT;yURy^VL(J OF$|urelF{r5}E*lH8)lO literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_green.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_green.png new file mode 100644 index 0000000000000000000000000000000000000000..84f34b2cd4ba96767e06801d4910620530ad3152 GIT binary patch literal 183 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmUzPnffIy#(?lOI#yL zg7ec#$`gxH85~pclTsBta}(23gHjVyDhp4h+5i=Kdb&7^X^@m0;_@H1P+gD z2bwfPer**w_wL!dW6K#MH8*i=GUNKwkZBX9d8=KBRm#9wV6{l9AiH5_ONa6cvt2Dh c4h@V9%jSr@vez@#0~*TU>FVdQ&MBb@0F1La{r~^~ literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_red.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_red.png new file mode 100644 index 0000000000000000000000000000000000000000..6c63995268b4cfb9e64526a7d52e068a61eb8795 GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmUzPnffIy#(?lOI#yL zg7ec#$`gxH85~pclTsBta}(23gHjVyDhp4h+5i<9db&7^X^@m0;_@H1P+gD z2bj`pb#;#}?vs92bjvz3gt<3)*6bZ29@XlMED{WiuUVhneZ{T-)Xd=N>gTe~DWM4f D2SYGi literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_yellow.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..3db999b2e927a951575357b47a9643f480d87b1b GIT binary patch literal 192 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmUzPnffIy#(?lOI#yL zg7ec#$`gxH85~pclTsBta}(23gHjVyDhp4h+5i;=dAc};RNP8>^X^@m0;_@H1P+gD z2bwgO91P@2zyIT6uRrsqpcKKB+=v{9X~#^OIQtU|^fsB@Y8PUaGMMX~qmkIgbFSjR lmKKL24})Cp2QYCMFubjjKl@W{`x>C>44$rjF6*2UngHY4Kw 0) { + ItemStack filter = getCurrentFilter(); + if (filter == null) { + return null; + } + if (!filter.isItemEqual(stack)) { + continue; + } + if (!inventory.canExtractItem(i, stack, from.ordinal())) { + continue; + } + if (doRemove) { + return inventory.decrStackSize(i, (int) powerHandler.useEnergy(1, stack.stackSize, true)); + } else { + return stack; + } + } + } + + return null; + } + + public IInventory getFilters() { + return filters; + } + + @Override + protected void actionsActivated(Map actions) { + super.actionsActivated(actions); + + activeFlags.clear(); + + for (Entry action : actions.entrySet()) { + if (action.getKey() instanceof ActionExtractionPreset && action.getValue() != null && action.getValue()) { + setActivePreset(((ActionExtractionPreset) action.getKey()).color); + } + } + } + + private void setActivePreset(EnumColor color) { + switch (color){ + case RED: + activeFlags.set(0); + break; + case BLUE: + activeFlags.set(1); + break; + case GREEN: + activeFlags.set(2); + break; + case YELLOW: + activeFlags.set(3); + break; + default: + break; + } + } + + @Override + public LinkedList getActions() { + LinkedList result = super.getActions(); + + result.add(BuildCraftTransport.actionExtractionPresetRed); + result.add(BuildCraftTransport.actionExtractionPresetBlue); + result.add(BuildCraftTransport.actionExtractionPresetGreen); + result.add(BuildCraftTransport.actionExtractionPresetYellow); + + return result; + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + filters.readFromNBT(nbt); + currentFilter = nbt.getInteger("currentFilter"); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + filters.writeToNBT(nbt); + nbt.setInteger("currentFilter", currentFilter); + } + + private void incrementFilter() { + int count = 0; + currentFilter++; + + while (!(filters.getStackInSlot(currentFilter % filterCount) != null && activeFlags.get(currentFilter % filterCount)) && count < filterCount) { + currentFilter++; + count++; + } + } + + private ItemStack getCurrentFilter() { + return filters.getStackInSlot(currentFilter % filters.getSizeInventory()); + } +} diff --git a/common/buildcraft/transport/triggers/ActionExtractionPreset.java b/common/buildcraft/transport/triggers/ActionExtractionPreset.java new file mode 100644 index 00000000..7df4992c --- /dev/null +++ b/common/buildcraft/transport/triggers/ActionExtractionPreset.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 buildcraft.core.utils.EnumColor; +import java.util.Locale; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.util.Icon; + +public class ActionExtractionPreset extends BCAction { + + private Icon icon; + public final EnumColor color; + + public ActionExtractionPreset(int id, EnumColor color) { + super(id, "buildcraft.extraction.preset." + color.getTag()); + + this.color = color; + } + + @Override + public String getDescription() { + return color.getName() + " Extraction Preset"; + } + + @Override + public Icon getIcon() { + return icon; + } + + @Override + public void registerIcons(IconRegister iconRegister) { + icon = iconRegister.registerIcon("buildcraft:triggers/extraction_preset_" + color.name().toLowerCase(Locale.ENGLISH)); + } +} From 5971a75e4280b86010aff6436cdbd4cc3341243b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 22 Nov 2013 15:18:43 -0800 Subject: [PATCH 17/45] Allow Draining of Fuel in Iron Engine --- common/buildcraft/energy/TileEngineIron.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index a98a88b2..5595df44 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -71,9 +71,9 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan return false; } ItemStack current = player.getCurrentEquippedItem(); - if (current != null && current.itemID != Item.bucketEmpty.itemID) { + if (current != null) { if (CoreProxy.proxy.isSimulating(worldObj)) { - if (FluidUtils.handleRightClick(this, side, player, true, false)) { + if (FluidUtils.handleRightClick(this, side, player, true, true)) { return true; } } else { @@ -320,18 +320,23 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan /* ITANKCONTAINER */ @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - return null; + return tankFuel.drain(maxDrain, doDrain); } @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (resource == null) + return null; + if (tankCoolant.getFluidType() == resource.getFluid()) + return tankCoolant.drain(resource.amount, doDrain); + if (tankFuel.getFluidType() == resource.getFluid()) + return tankFuel.drain(resource.amount, doDrain); return null; } @Override public boolean canDrain(ForgeDirection from, Fluid fluid) { - // TODO Auto-generated method stub - return false; + return true; } @Override From 71ebc1fb699af27ac1937a343c1701f333aadff9 Mon Sep 17 00:00:00 2001 From: Taelnia Date: Sat, 23 Nov 2013 02:21:40 -0500 Subject: [PATCH 18/45] Fix for creative mode pick block on gates for re-loaded worlds. Also fixes Highlight Overlays such as NEI and Waila --- .../buildcraft/transport/TileGenericPipe.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 9b02066c..92f61a33 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -62,17 +62,20 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui public int pipeId = -1; public int gateKind = 0; + public boolean pulser = false; @Override public void writeData(DataOutputStream data) throws IOException { data.writeInt(pipeId); data.writeInt(gateKind); + data.writeBoolean(pulser); } @Override public void readData(DataInputStream data) throws IOException { pipeId = data.readInt(); gateKind = data.readInt(); + pulser = data.readBoolean(); } } private PipeRenderState renderState = new PipeRenderState(); @@ -362,10 +365,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui bindPipe(); PacketTileState packet = new PacketTileState(this.xCoord, this.yCoord, this.zCoord); - if (pipe != null && pipe.gate != null) + if (pipe != null && pipe.gate != null) { coreState.gateKind = pipe.gate.kind.ordinal(); - else + coreState.pulser = pipe.gate instanceof GateVanilla && ((GateVanilla)pipe.gate).hasPulser() ? true : false; + } else { coreState.gateKind = 0; + coreState.pulser = false; + } if (pipe != null && pipe.transport != null) pipe.transport.sendDescriptionPacket(); @@ -635,8 +641,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui initialize(BlockGenericPipe.createPipe(coreState.pipeId)); if (pipe != null && coreState.gateKind != GateKind.None.ordinal()) { - if (pipe.gate == null) - pipe.gate = new GateVanilla(pipe); + if (pipe.gate == null) { + if (coreState.pulser) { + pipe.gate = new GateVanilla(pipe, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, coreState.gateKind)); + } else { + pipe.gate = new GateVanilla(pipe); + } + } pipe.gate.kind = GateKind.values()[coreState.gateKind]; } worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); From 14dc0014c90c4ecbca54a44bc3a96c7c196ca814 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 23 Nov 2013 23:23:38 -0800 Subject: [PATCH 19/45] Prevent NPE in Coolant API --- common/buildcraft/api/fuels/IronEngineCoolant.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/api/fuels/IronEngineCoolant.java b/common/buildcraft/api/fuels/IronEngineCoolant.java index 347fabd7..50c2097c 100644 --- a/common/buildcraft/api/fuels/IronEngineCoolant.java +++ b/common/buildcraft/api/fuels/IronEngineCoolant.java @@ -29,7 +29,7 @@ public final class IronEngineCoolant { } public static Coolant getCoolant(FluidStack fluidStack) { - return fluidStack != null ? liquidCoolants.get(fluidStack.getFluid().getName()) : null; + return fluidStack != null && fluidStack.getFluid() != null ? liquidCoolants.get(fluidStack.getFluid().getName()) : null; } private IronEngineCoolant() { From 6f57b4a80dfbe2c40061a8a8f16431830c79935b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 24 Nov 2013 06:23:02 -0800 Subject: [PATCH 20/45] Logemerald->Emzuli Rework + PipeEvents Modified Logemerald: -Added ability to paint items as they are extracted -Renamed to Emzuli, texture and recipe changed accordingly PipeEvents: -Added PipeEvents a replacement for Hook interfaces, precursor to 1.7 Pipe API -Implement methods with signature "eventHandler(PipeEventClass event)" to receive events Widgets: -General improvements for use as a button --- .../textures/blocks/pipeAllEmzuli_solid.png | Bin 0 -> 297 bytes .../blocks/pipeAllLogemerald_solid.png | Bin 325 -> 0 bytes .../textures/blocks/pipeItemsDiamond_item.png | Bin 0 -> 244 bytes .../blocks/pipeItemsEmzuli_standard.png | Bin 0 -> 235 bytes .../blocks/pipeItemsLogemerald_standard.png | Bin 215 -> 0 bytes .../buildcraft/textures/gui/pipe_emzuli.png | Bin 0 -> 2163 bytes .../lang/buildcraft/en_US.properties | 26 ++- common/buildcraft/BuildCraftTransport.java | 6 +- common/buildcraft/core/DefaultProps.java | 2 +- .../core/gui/BuildCraftContainer.java | 14 ++ common/buildcraft/core/gui/GuiBuildCraft.java | 47 ++++- .../core/gui/widgets/ButtonWidget.java | 61 +++++++ .../buildcraft/core/gui/widgets/Widget.java | 16 +- .../core/network/IGuiReturnHandler.java | 4 +- .../core/network/PacketGuiWidget.java | 59 ++++++ .../core/network/PacketHandler.java | 25 ++- common/buildcraft/core/network/PacketIds.java | 1 + common/buildcraft/core/utils/EnumColor.java | 2 +- .../buildcraft/core/utils/RevolvingList.java | 65 +++++++ common/buildcraft/transport/GuiHandler.java | 10 +- .../transport/IItemTravelingHook.java | 13 +- .../transport/IPipeTransportItemsHook.java | 12 +- common/buildcraft/transport/Pipe.java | 40 +++- .../transport/PipeConnectionBans.java | 4 +- .../transport/PipeIconProvider.java | 5 +- .../transport/PipeTransportItems.java | 89 +++++---- .../transport/TransportProxyClient.java | 2 +- .../buildcraft/transport/TravelingItem.java | 35 ++-- .../transport/gui/ContainerEmzuliPipe.java | 172 ++++++++++++++++++ .../gui/ContainerLogemeraldPipe.java | 49 ----- ...LogemeraldPipe.java => GuiEmzuliPipe.java} | 28 +-- .../transport/pipes/PipeItemsDaizuli.java | 31 ++-- .../transport/pipes/PipeItemsDiamond.java | 35 ++-- ...msLogemerald.java => PipeItemsEmzuli.java} | 105 +++++++---- .../transport/pipes/PipeItemsGold.java | 21 +-- .../transport/pipes/PipeItemsLapis.java | 37 +--- .../transport/pipes/PipeItemsObsidian.java | 13 +- .../transport/pipes/PipeItemsQuartz.java | 21 +-- .../transport/pipes/PipeItemsStone.java | 21 +-- .../transport/pipes/PipeItemsVoid.java | 24 +-- .../transport/pipes/PipeItemsWood.java | 6 +- .../transport/pipes/events/PipeEvent.java | 16 ++ .../transport/pipes/events/PipeEventItem.java | 84 +++++++++ .../transport/triggers/ActionPipeColor.java | 3 +- 44 files changed, 859 insertions(+), 345 deletions(-) create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllEmzuli_solid.png delete mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllLogemerald_solid.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_item.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsEmzuli_standard.png delete mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsLogemerald_standard.png create mode 100644 buildcraft_resources/assets/buildcraft/textures/gui/pipe_emzuli.png create mode 100644 common/buildcraft/core/gui/widgets/ButtonWidget.java create mode 100644 common/buildcraft/core/network/PacketGuiWidget.java create mode 100644 common/buildcraft/core/utils/RevolvingList.java create mode 100644 common/buildcraft/transport/gui/ContainerEmzuliPipe.java delete mode 100644 common/buildcraft/transport/gui/ContainerLogemeraldPipe.java rename common/buildcraft/transport/gui/{GuiLogemeraldPipe.java => GuiEmzuliPipe.java} (53%) rename common/buildcraft/transport/pipes/{PipeItemsLogemerald.java => PipeItemsEmzuli.java} (74%) create mode 100644 common/buildcraft/transport/pipes/events/PipeEvent.java create mode 100644 common/buildcraft/transport/pipes/events/PipeEventItem.java diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllEmzuli_solid.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllEmzuli_solid.png new file mode 100644 index 0000000000000000000000000000000000000000..0e3626ced7565fe2e9322a52ef38a342ccbfdf53 GIT binary patch literal 297 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmUzPnffIy#(?(3p^r= z85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3Q$0gN_s>q|KvhdU zT^vI!{O3+^o-=X_$dtWVnV6gaq zqH)*M1KT9?)<V(Rq-z(srBErY7Of^Uk{*qoXqGgP+Nz&0_Uz`3w8BgC7%+RXGXv^<$FA_^myrhX4Zr XDQ9<_JUwCP00000NkvXXu0mjf4p4yQ diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_item.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_item.png new file mode 100644 index 0000000000000000000000000000000000000000..ee08f11650346cc35f74d0cc5411217c854021b8 GIT binary patch literal 244 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|Kvl_}E{-7<{%?B%xegd`IPd*m`|a-K3O@5p*=;MGtZ#%fGxDBP4%pc; zGyZq{`)gh%Ja70Il`h?MdtAY3AT7=COTfe-<%RQtqaN%Z)D;ZBC|-CZ+-%RNbDQbM j{(F0a4#+%nDPg|;o&EB1=0op+)-iax`njxgN@xNA(&14- literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsEmzuli_standard.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsEmzuli_standard.png new file mode 100644 index 0000000000000000000000000000000000000000..eedfb7482e963f0129f643ad7f28213161a74d87 GIT binary patch literal 235 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmUzPnffIy#(?(3p^r= z85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3Q$0gN_s>q|Kvn6U zE{-7<{&Ra6`5Fv3m@Aw9e-qsoa+d8@!oh>8-frCL^WNU@|I1hKO;*)fgY(9xO$t#< zcFLB_&r&mC+4N2`nn_2i$?&oP!|sB7*9mX`aM|r`y}NvtxYWHCcDZdSk=_l(krPg; aDT%Y{t!!OTeZLxLC4;A{pUXO@geCxy4ouqs literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsLogemerald_standard.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsLogemerald_standard.png deleted file mode 100644 index 96a09f191faaac03ef6716719a94df795bbf7f5f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmUzPnffIy#(?lOI#yL zg7ec#$`gxH85~pclTsBta}(23gHjVyDhp4h+5i=0db&7R|DNig)We7;j%q!9J za}7}_GuAWJGc|_osQm%WtIEGZjy}k9YXtsfXYoga>fzSWmd$aCRxaly5ac%FW z=YLKFnKWMv-#$~o{P2YSnPo-!~e2NMK}MwTk>>|U_$Bc z=k+qzS~qRE9~z}M``d1>)0K<~FQWcB&b?jV%HaHaLRry<*arLl(l&;w&X97(hIb3^ z2|29ac;!9wmbceq-~LQ*+EsO}l~L~d|F5O*b{5n!+$x(U>mZS}XSu>oAjGOn{lyxyZPm!n}_0n zWE_LUt~lv%b$hiid54$%C$F*xY|Cv}&DOxM>3r|JwO$Q7{u?owGG)9@W!c7P2lA6$ z`K6+JEF1nj6&G9~lyGlXJOk$prWeyoR-O}Z(4Y8f9)k;GG{fJBO;@6sUYJh%mCi7^ zA-W;*fTn|*LEmIsW)64xk1tpm9=|H=6>pWipz13Uh1d^zvXm7<$z4TZmx zFL$@Dd}_n!kzi$Wdnv=E>*@@wzr_-6{kc-%pO~>ThiS(Bzn58neqG1#;Gg}$aONY+ z#JPh{SL(BOuzWlrqabu-@oR=9aSRif7#g-Suc?ns=h#rU@jG+QvZtF`_vS5oYQw-# zA$TAZR3DYxKgt9OwhLFaIY3mcI5z`>QiI*BNv}+T^X-y(7ql08|Gjz+qy`Ljy-xyF zXArQ)eo4_*<6{g}?jt$H{=1Gjx=b%FLR=wo0wVD6C3XkhZVboEJwgp886Qd;}|3o86EUa_p=va0cp zlvu_EFU=TC?y@y3yUlQ+M4Dk%9<#&cT!xHYybQkE2VQb^aYNz{{?(~ + */ +public class ButtonWidget extends Widget { + + private boolean pressed; + private int buttonPressed; + + public ButtonWidget(int x, int y, int u, int v, int w, int h) { + super(x, y, u, v, w, h); + } + + @Override + public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) { + int vv = pressed ? v + h : v; + gui.drawTexturedModalRect(guiX + x, guiY + y, u, vv, w, h); + } + + @Override + public final boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) { + pressed = true; + buttonPressed = mouseButton; + onPress(buttonPressed); + return true; + } + + @Override + public final void handleMouseRelease(int mouseX, int mouseY, int eventType) { + if (pressed) { + pressed = false; + onRelease(buttonPressed); + } + } + + @Override + public final void handleMouseMove(int mouseX, int mouseY, int mouseButton, long time) { + if (pressed && !isMouseOver(mouseX, mouseY)) { + pressed = false; + onRelease(buttonPressed); + } + } + + public void onPress(int mouseButton) { + } + + public void onRelease(int mouseButton) { + } +} diff --git a/common/buildcraft/core/gui/widgets/Widget.java b/common/buildcraft/core/gui/widgets/Widget.java index 673cb9f6..3e79de41 100644 --- a/common/buildcraft/core/gui/widgets/Widget.java +++ b/common/buildcraft/core/gui/widgets/Widget.java @@ -13,6 +13,8 @@ import buildcraft.core.gui.tooltips.IToolTipProvider; import buildcraft.core.gui.tooltips.ToolTip; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.io.DataInputStream; +import java.io.IOException; import net.minecraft.inventory.ICrafting; /** @@ -50,10 +52,22 @@ public class Widget implements IToolTipProvider { } @SideOnly(Side.CLIENT) - public boolean mouseClicked(int mouseX, int mouseY, int button) { + public boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) { return false; } + @SideOnly(Side.CLIENT) + public void handleMouseRelease(int mouseX, int mouseY, int eventType) { + } + + @SideOnly(Side.CLIENT) + public void handleMouseMove(int mouseX, int mouseY, int mouseButton, long time) { + } + + @SideOnly(Side.CLIENT) + public void handleClientPacketData(DataInputStream data) throws IOException { + } + @SideOnly(Side.CLIENT) public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) { gui.drawTexturedModalRect(guiX + x, guiY + y, u, v, w, h); diff --git a/common/buildcraft/core/network/IGuiReturnHandler.java b/common/buildcraft/core/network/IGuiReturnHandler.java index 25b1a63b..3be79132 100644 --- a/common/buildcraft/core/network/IGuiReturnHandler.java +++ b/common/buildcraft/core/network/IGuiReturnHandler.java @@ -14,7 +14,7 @@ import net.minecraft.world.World; public abstract interface IGuiReturnHandler { public World getWorld(); - public void writeGuiData(DataOutputStream paramDataOutputStream) throws IOException; + public void writeGuiData(DataOutputStream data) throws IOException; - public void readGuiData(DataInputStream paramDataInputStream, EntityPlayer paramEntityPlayer) throws IOException; + public void readGuiData(DataInputStream data, EntityPlayer player) throws IOException; } diff --git a/common/buildcraft/core/network/PacketGuiWidget.java b/common/buildcraft/core/network/PacketGuiWidget.java new file mode 100644 index 00000000..e8a78843 --- /dev/null +++ b/common/buildcraft/core/network/PacketGuiWidget.java @@ -0,0 +1,59 @@ +/* + * 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.network; + +import buildcraft.core.gui.BuildCraftContainer; +import cpw.mods.fml.client.FMLClientHandler; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import net.minecraft.client.entity.EntityClientPlayerMP; +/** + * + * @author CovertJaguar + */ +public class PacketGuiWidget extends BuildCraftPacket { + + private byte windowId, widgetId; + private byte[] payload; + + public PacketGuiWidget() { + super(); + } + + public PacketGuiWidget(int windowId, int widgetId, byte[] data) { + this.windowId = (byte) windowId; + this.widgetId = (byte) widgetId; + this.payload = data; + } + + @Override + public void writeData(DataOutputStream data) throws IOException { + data.writeByte(windowId); + data.writeByte(widgetId); + data.write(payload); + } + + @Override + public void readData(DataInputStream data) throws IOException { + windowId = data.readByte(); + widgetId = data.readByte(); + + EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer; + + if (player.openContainer instanceof BuildCraftContainer && player.openContainer.windowId == windowId) + ((BuildCraftContainer) player.openContainer).handleWidgetClientData(widgetId, data); + } + + @Override + public int getID() { + return PacketIds.GUI_WIDGET; + } + +} diff --git a/common/buildcraft/core/network/PacketHandler.java b/common/buildcraft/core/network/PacketHandler.java index a999117e..8c0feb94 100644 --- a/common/buildcraft/core/network/PacketHandler.java +++ b/common/buildcraft/core/network/PacketHandler.java @@ -37,27 +37,32 @@ public class PacketHandler implements IPacketHandler { int packetID = data.read(); switch (packetID) { case PacketIds.TILE_UPDATE: { - PacketTileUpdate packetT = new PacketTileUpdate(); - packetT.readData(data); - onTileUpdate((EntityPlayer) player, packetT); + PacketTileUpdate pkt = new PacketTileUpdate(); + pkt.readData(data); + onTileUpdate((EntityPlayer) player, pkt); break; } case PacketIds.STATE_UPDATE: { - PacketTileState inPacket = new PacketTileState(); - inPacket.readData(data); + PacketTileState pkt = new PacketTileState(); + pkt.readData(data); World world = ((EntityPlayer) player).worldObj; - TileEntity tile = world.getBlockTileEntity(inPacket.posX, inPacket.posY, inPacket.posZ); + TileEntity tile = world.getBlockTileEntity(pkt.posX, pkt.posY, pkt.posZ); if (tile instanceof ISyncedTile) { - inPacket.applyStates(data, (ISyncedTile) tile); + pkt.applyStates(data, (ISyncedTile) tile); } break; } case PacketIds.GUI_RETURN: { - PacketGuiReturn packet1 = new PacketGuiReturn((EntityPlayer) player); - packet1.readData(data); - // onGuiReturn((EntityPlayer) player, packet1); + PacketGuiReturn pkt = new PacketGuiReturn((EntityPlayer) player); + pkt.readData(data); + break; + } + + case PacketIds.GUI_WIDGET: { + PacketGuiWidget pkt = new PacketGuiWidget(); + pkt.readData(data); break; } } diff --git a/common/buildcraft/core/network/PacketIds.java b/common/buildcraft/core/network/PacketIds.java index 34af2c6f..e336111a 100644 --- a/common/buildcraft/core/network/PacketIds.java +++ b/common/buildcraft/core/network/PacketIds.java @@ -36,6 +36,7 @@ public class PacketIds { public static final int SELECTION_ADVANCED_WORKBENCH = 71; public static final int GUI_RETURN = 80; + public static final int GUI_WIDGET = 81; public static final int STATE_UPDATE = 100; } diff --git a/common/buildcraft/core/utils/EnumColor.java b/common/buildcraft/core/utils/EnumColor.java index 426f3a15..2c522f6a 100644 --- a/common/buildcraft/core/utils/EnumColor.java +++ b/common/buildcraft/core/utils/EnumColor.java @@ -157,7 +157,7 @@ public enum EnumColor { return NAMES[ordinal()]; } - public String getTranslatedName() { + public String getLocalizedName() { return StringUtils.localize(getTag()); } diff --git a/common/buildcraft/core/utils/RevolvingList.java b/common/buildcraft/core/utils/RevolvingList.java new file mode 100644 index 00000000..c2b08343 --- /dev/null +++ b/common/buildcraft/core/utils/RevolvingList.java @@ -0,0 +1,65 @@ +/** + * 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.utils; + +import com.google.common.collect.ForwardingCollection; +import java.util.*; + +/** + * + * @author CovertJaguar + */ +public class RevolvingList extends ForwardingCollection { + + private Deque list = new LinkedList(); + + public RevolvingList() { + } + + public RevolvingList(Collection collection) { + list.addAll(collection); + } + + @Override + protected Collection delegate() { + return list; + } + + public void rotateLeft() { + if (list.isEmpty()) + return; + list.addFirst(list.removeLast()); + } + + public void rotateRight() { + if (list.isEmpty()) + return; + list.addLast(list.removeFirst()); + } + + public T getCurrent() { + if (list.isEmpty()) + return null; + return list.getFirst(); + } + + public void setCurrent(T e) { + if (!contains(e)) + return; + + if (e == null) { + while (getCurrent() != null) { + rotateRight(); + } + } else { + while (getCurrent() == null || !getCurrent().equals(e)) { + rotateRight(); + } + } + } +} diff --git a/common/buildcraft/transport/GuiHandler.java b/common/buildcraft/transport/GuiHandler.java index 6687a055..fd9158a0 100644 --- a/common/buildcraft/transport/GuiHandler.java +++ b/common/buildcraft/transport/GuiHandler.java @@ -6,15 +6,15 @@ import buildcraft.transport.gui.ContainerDiamondPipe; import buildcraft.transport.gui.ContainerEmeraldPipe; import buildcraft.transport.gui.ContainerFilteredBuffer; import buildcraft.transport.gui.ContainerGateInterface; -import buildcraft.transport.gui.ContainerLogemeraldPipe; +import buildcraft.transport.gui.ContainerEmzuliPipe; import buildcraft.transport.gui.GuiDiamondPipe; import buildcraft.transport.gui.GuiEmeraldPipe; import buildcraft.transport.gui.GuiFilteredBuffer; import buildcraft.transport.gui.GuiGateInterface; -import buildcraft.transport.gui.GuiLogemeraldPipe; +import buildcraft.transport.gui.GuiEmzuliPipe; import buildcraft.transport.pipes.PipeItemsDiamond; import buildcraft.transport.pipes.PipeItemsEmerald; -import buildcraft.transport.pipes.PipeItemsLogemerald; +import buildcraft.transport.pipes.PipeItemsEmzuli; import cpw.mods.fml.common.network.IGuiHandler; import java.util.logging.Level; import net.minecraft.entity.player.EntityPlayer; @@ -52,7 +52,7 @@ public class GuiHandler implements IGuiHandler { return new ContainerEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe); case GuiIds.PIPE_LOGEMERALD_ITEM: - return new ContainerLogemeraldPipe(player.inventory, (PipeItemsLogemerald) pipe.pipe); + return new ContainerEmzuliPipe(player.inventory, (PipeItemsEmzuli) pipe.pipe); case GuiIds.GATES: if (pipe.pipe.hasGate()) @@ -96,7 +96,7 @@ public class GuiHandler implements IGuiHandler { return new GuiEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe); case GuiIds.PIPE_LOGEMERALD_ITEM: - return new GuiLogemeraldPipe(player.inventory, (PipeItemsLogemerald) pipe.pipe); + return new GuiEmzuliPipe(player.inventory, (PipeItemsEmzuli) pipe.pipe); case GuiIds.GATES: if (pipe.pipe.hasGate()) diff --git a/common/buildcraft/transport/IItemTravelingHook.java b/common/buildcraft/transport/IItemTravelingHook.java index f329947f..51abbad6 100644 --- a/common/buildcraft/transport/IItemTravelingHook.java +++ b/common/buildcraft/transport/IItemTravelingHook.java @@ -2,6 +2,10 @@ package buildcraft.transport; import net.minecraft.tileentity.TileEntity; +/** + * @deprecated This has been replaced by the Pipe Event system. + */ +@Deprecated public interface IItemTravelingHook { public void drop(PipeTransportItems transport, TravelingItem item); @@ -9,13 +13,14 @@ public interface IItemTravelingHook { public void centerReached(PipeTransportItems transport, TravelingItem item); /** - * Overrides default handling of what occurs when an Item reaches the end of the pipe. - * + * Overrides default handling of what occurs when an Item reaches the end of + * the pipe. + * * @param transport * @param item * @param tile - * @return false if the transport code should handle the item normally, true if its been handled + * @return false if the transport code should handle the item normally, true + * if its been handled */ public boolean endReached(PipeTransportItems transport, TravelingItem item, TileEntity tile); - } diff --git a/common/buildcraft/transport/IPipeTransportItemsHook.java b/common/buildcraft/transport/IPipeTransportItemsHook.java index 018bc78a..3be90a42 100644 --- a/common/buildcraft/transport/IPipeTransportItemsHook.java +++ b/common/buildcraft/transport/IPipeTransportItemsHook.java @@ -1,18 +1,20 @@ /** - * 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; import buildcraft.api.core.Position; import java.util.LinkedList; import net.minecraftforge.common.ForgeDirection; +/** + * @deprecated This has been replaced by the Pipe Event system. + */ +@Deprecated public interface IPipeTransportItemsHook { public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item); diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index fe0b9ebb..d0693a64 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -19,15 +19,16 @@ import buildcraft.core.IDropControlInventory; import buildcraft.core.inventory.InvUtils; import buildcraft.core.network.TilePacketWrapper; import buildcraft.core.utils.Utils; +import buildcraft.transport.pipes.events.PipeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Method; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.Random; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -47,6 +48,7 @@ public abstract class Pipe implements IPipe, IDropContr @SuppressWarnings("rawtypes") private static Map networkWrappers = new HashMap(); public SafeTimeTracker actionTracker = new SafeTimeTracker(); + private static Map, Map, EventHandler>> eventHandlers = new HashMap, Map, EventHandler>>(); public Pipe(T transport, int itemID) { this.transport = transport; @@ -65,6 +67,39 @@ public abstract class Pipe implements IPipe, IDropContr transport.setTile((TileGenericPipe) tile); } + private static class EventHandler { + + public final Method method; + + public EventHandler(Method method) { + this.method = method; + } + } + + public final void handlePipeEvent(PipeEvent event) { + Map, EventHandler> handlerMap = eventHandlers.get(getClass()); + if (handlerMap == null) { + handlerMap = new HashMap, EventHandler>(); + eventHandlers.put(getClass(), handlerMap); + } + EventHandler handler = handlerMap.get(event.getClass()); + if (handler == null) { + try { + Method method = getClass().getDeclaredMethod("eventHandler", event.getClass()); + handler = new EventHandler(method); + } catch (Exception ex) { + handler = new EventHandler(null); + } + handlerMap.put(event.getClass(), handler); + } + if (handler.method == null) + return; + try { + handler.method.invoke(this, event); + } catch (Exception ex) { + } + } + public boolean blockActivated(EntityPlayer entityplayer) { return false; } @@ -481,9 +516,6 @@ public abstract class Pipe implements IPipe, IDropContr transport.dropContents(); } - public void onDropped(EntityItem item) { - } - /** * If this pipe is open on one side, return it. */ diff --git a/common/buildcraft/transport/PipeConnectionBans.java b/common/buildcraft/transport/PipeConnectionBans.java index 88db4cb8..12e2db23 100644 --- a/common/buildcraft/transport/PipeConnectionBans.java +++ b/common/buildcraft/transport/PipeConnectionBans.java @@ -12,7 +12,7 @@ import buildcraft.transport.pipes.PipeFluidsCobblestone; import buildcraft.transport.pipes.PipeFluidsStone; import buildcraft.transport.pipes.PipeFluidsWood; import buildcraft.transport.pipes.PipeItemsCobblestone; -import buildcraft.transport.pipes.PipeItemsLogemerald; +import buildcraft.transport.pipes.PipeItemsEmzuli; import buildcraft.transport.pipes.PipeItemsObsidian; import buildcraft.transport.pipes.PipeItemsQuartz; import buildcraft.transport.pipes.PipeItemsStone; @@ -43,7 +43,7 @@ public class PipeConnectionBans { banConnection(PipeItemsObsidian.class); - banConnection(PipeItemsLogemerald.class); + banConnection(PipeItemsEmzuli.class); // Power Pipes banConnection(PipePowerWood.class); diff --git a/common/buildcraft/transport/PipeIconProvider.java b/common/buildcraft/transport/PipeIconProvider.java index 98be048d..40f951fd 100644 --- a/common/buildcraft/transport/PipeIconProvider.java +++ b/common/buildcraft/transport/PipeIconProvider.java @@ -15,6 +15,7 @@ public class PipeIconProvider implements IIconProvider { // PipeItemsCobbleStone("pipeItemsCobblestone"), // + PipeItemsDiamond_Item("pipeItemsDiamond_item"), PipeItemsDiamond_Center("pipeItemsDiamond_center"), PipeItemsDiamond_Down("pipeItemsDiamond_down"), PipeItemsDiamond_Up("pipeItemsDiamond_up"), @@ -64,8 +65,8 @@ public class PipeIconProvider implements IIconProvider { PipeItemsEmerald_Standard("pipeItemsEmerald_standard"), PipeAllEmerald_Solid("pipeAllEmerald_solid"), // - PipeItemsLogemerald_Standard("pipeItemsLogemerald_standard"), - PipeAllLogemerald_Solid("pipeAllLogemerald_solid"), + PipeItemsEmzuli_Standard("pipeItemsEmzuli_standard"), + PipeAllEmzuli_Solid("pipeAllEmzuli_solid"), // PipeItemsGold("pipeItemsGold"), // diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index 13254ab4..e9f2c758 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -22,6 +22,7 @@ import buildcraft.core.utils.BlockUtil; import buildcraft.transport.network.PacketPipeTransportContent; import buildcraft.transport.network.PacketPipeTransportNBT; import buildcraft.transport.network.PacketSimpleId; +import buildcraft.transport.pipes.events.PipeEventItem; import buildcraft.transport.utils.TransportUtils; import com.google.common.collect.BiMap; import com.google.common.collect.ForwardingSet; @@ -125,9 +126,13 @@ public class PipeTransportItems extends PipeTransport { } public void readjustSpeed(TravelingItem item) { - if (container.pipe instanceof IPipeTransportItemsHook) + if (container.pipe instanceof IPipeTransportItemsHook) { ((IPipeTransportItemsHook) container.pipe).readjustSpeed(item); - else + return; + } + PipeEventItem.AdjustSpeed event = new PipeEventItem.AdjustSpeed(item); + container.pipe.handlePipeEvent(event); + if (!event.handled) defaultReajustSpeed(item); } @@ -174,8 +179,6 @@ public class PipeTransportItems extends PipeTransport { item.reset(); item.input = inputOrientation; - items.add(item); - readjustSpeed(item); readjustPosition(item); @@ -188,6 +191,13 @@ public class PipeTransportItems extends PipeTransport { ((IPipeTransportItemsHook) container.pipe).entityEntered(item, inputOrientation); } + PipeEventItem.Entered event = new PipeEventItem.Entered(item); + container.pipe.handlePipeEvent(event); + if (event.cancelled) + return; + + items.add(item); + if (!container.worldObj.isRemote) { sendItemPacket(item); @@ -231,8 +241,6 @@ public class PipeTransportItems extends PipeTransport { // stage, avoid adding it to the pipe to avoid further exceptions. return; - items.unscheduleRemoval(item); - item.toCenter = true; item.input = item.output.getOpposite(); @@ -246,6 +254,12 @@ public class PipeTransportItems extends PipeTransport { if (container.pipe instanceof IPipeTransportItemsHook) { ((IPipeTransportItemsHook) container.pipe).entityEntered(item, item.input); } + PipeEventItem.Entered event = new PipeEventItem.Entered(item); + container.pipe.handlePipeEvent(event); + if (event.cancelled) + return; + + items.unscheduleRemoval(item); if (!container.worldObj.isRemote) { sendItemPacket(item); @@ -253,20 +267,19 @@ public class PipeTransportItems extends PipeTransport { } public ForgeDirection resolveDestination(TravelingItem data) { - LinkedList listOfPossibleMovements = getPossibleMovements(data); + List validDestinations = getPossibleMovements(data); - if (listOfPossibleMovements.isEmpty()) + if (validDestinations.isEmpty()) return ForgeDirection.UNKNOWN; - int i = container.worldObj.rand.nextInt(listOfPossibleMovements.size()); - return listOfPossibleMovements.get(i); + return validDestinations.get(0); } /** * Returns a list of all possible movements, that is to say adjacent * implementers of IPipeEntry or TileEntityChest. */ - public LinkedList getPossibleMovements(TravelingItem item) { + public List getPossibleMovements(TravelingItem item) { LinkedList result = new LinkedList(); item.blacklist.add(item.input.getOpposite()); @@ -282,6 +295,8 @@ 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); } + PipeEventItem.FindDest event = new PipeEventItem.FindDest(item, result); + container.pipe.handlePipeEvent(event); if (allowBouncing && result.isEmpty()) { if (canReceivePipeObjects(item.input.getOpposite(), item)) { @@ -289,6 +304,8 @@ public class PipeTransportItems extends PipeTransport { } } + Collections.shuffle(result); + return result; } @@ -341,29 +358,23 @@ public class PipeTransportItems extends PipeTransport { item.setPosition(container.xCoord + 0.5, container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()), container.zCoord + 0.5); if (item.output == ForgeDirection.UNKNOWN) { - if (travelHook != null) { - travelHook.drop(this, item); - } - - EntityItem dropped = null; - - if (items.scheduleRemoval(item)) { - dropped = item.toEntityItem(item.input); - } - - if (dropped != null) { - onDropped(dropped); - } + if (items.scheduleRemoval(item)) + dropItem(item); } else { if (travelHook != null) { travelHook.centerReached(this, item); } + PipeEventItem.ReachedCenter event = new PipeEventItem.ReachedCenter(item); + container.pipe.handlePipeEvent(event); } } else if (!item.toCenter && endReached(item)) { TileEntity tile = container.getTile(item.output); - boolean handleItem = true; + PipeEventItem.ReachedEnd event = new PipeEventItem.ReachedEnd(item, tile); + container.pipe.handlePipeEvent(event); + boolean handleItem = !event.handled; + if (travelHook != null) { handleItem = !travelHook.endReached(this, item, tile); } @@ -404,19 +415,23 @@ public class PipeTransportItems extends PipeTransport { reverseItem(item); } } - } else { - if (travelHook != null) { - travelHook.drop(this, item); - } + } else + dropItem(item); + } - EntityItem dropped = item.toEntityItem(item.output); + private void dropItem(TravelingItem item) { + if (container.worldObj.isRemote) + return; - if (dropped != null) { - // On SMP, the client side doesn't actually drops - // items - onDropped(dropped); - } + if (travelHook != null) { + travelHook.drop(this, item); } + + PipeEventItem.DropItem event = new PipeEventItem.DropItem(item, item.toEntityItem()); + container.pipe.handlePipeEvent(event); + if (event.entity == null) + return; + container.worldObj.spawnEntityInWorld(event.entity); } protected boolean middleReached(TravelingItem item) { @@ -569,10 +584,6 @@ public class PipeTransportItems extends PipeTransport { return num; } - public void onDropped(EntityItem item) { - this.container.pipe.onDropped(item); - } - protected void neighborChange() { } diff --git a/common/buildcraft/transport/TransportProxyClient.java b/common/buildcraft/transport/TransportProxyClient.java index 4aece58c..84d63d10 100644 --- a/common/buildcraft/transport/TransportProxyClient.java +++ b/common/buildcraft/transport/TransportProxyClient.java @@ -39,7 +39,7 @@ public class TransportProxyClient extends TransportProxy { MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsEmerald.itemID, pipeItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsLapis.itemID, pipeItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsDaizuli.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsLogemerald.itemID, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsEmzuli.itemID, pipeItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsWood.itemID, pipeItemRenderer); MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsCobblestone.itemID, pipeItemRenderer); diff --git a/common/buildcraft/transport/TravelingItem.java b/common/buildcraft/transport/TravelingItem.java index 4fde1ba4..54abccfa 100644 --- a/common/buildcraft/transport/TravelingItem.java +++ b/common/buildcraft/transport/TravelingItem.java @@ -12,6 +12,7 @@ import buildcraft.api.core.Position; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.EnumColor; import java.util.EnumSet; +import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; @@ -102,12 +103,19 @@ public class TravelingItem { return extraData != null; } + @Deprecated public void setInsetionHandler(InsertionHandler handler) { if (handler == null) return; this.insertionHandler = handler; } + public void setInsertionHandler(InsertionHandler handler) { + if (handler == null) + return; + this.insertionHandler = handler; + } + public InsertionHandler getInsertionHandler() { return insertionHandler; } @@ -157,25 +165,30 @@ public class TravelingItem { data.setTag("extraData", extraData); } - public EntityItem toEntityItem(ForgeDirection dir) { + public EntityItem toEntityItem() { if (container != null && !CoreProxy.proxy.isRenderWorld(container.worldObj)) { if (getItemStack().stackSize <= 0) return null; - Position motion = new Position(0, 0, 0, dir); + Position motion = new Position(0, 0, 0, output); motion.moveForwards(0.1 + getSpeed() * 2F); - EntityItem entityitem = new EntityItem(container.worldObj, xCoord, yCoord, zCoord, getItemStack()); + ItemStack stack = getItemStack(); + EntityItem entity = new EntityItem(container.worldObj, xCoord, yCoord, zCoord, getItemStack()); + if (stack.getItem().hasCustomEntity(stack)) { + Entity e = stack.getItem().createEntity(container.worldObj, entity, stack); + if (e instanceof EntityItem) + entity = (EntityItem) e; + } - entityitem.lifespan = BuildCraftCore.itemLifespan; - entityitem.delayBeforeCanPickup = 10; + entity.lifespan = BuildCraftCore.itemLifespan; + entity.delayBeforeCanPickup = 10; float f3 = 0.00F + container.worldObj.rand.nextFloat() * 0.04F - 0.02F; - entityitem.motionX = (float) container.worldObj.rand.nextGaussian() * f3 + motion.x; - entityitem.motionY = (float) container.worldObj.rand.nextGaussian() * f3 + motion.y; - entityitem.motionZ = (float) container.worldObj.rand.nextGaussian() * f3 + +motion.z; - container.worldObj.spawnEntityInWorld(entityitem); - return entityitem; + entity.motionX = (float) container.worldObj.rand.nextGaussian() * f3 + motion.x; + entity.motionY = (float) container.worldObj.rand.nextGaussian() * f3 + motion.y; + entity.motionZ = (float) container.worldObj.rand.nextGaussian() * f3 + +motion.z; + return entity; } return null; } @@ -194,7 +207,7 @@ public class TravelingItem { public boolean isCorrupted() { return getItemStack() == null || getItemStack().stackSize <= 0 || Item.itemsList[getItemStack().itemID] == null; } - + @Override public int hashCode() { int hash = 7; diff --git a/common/buildcraft/transport/gui/ContainerEmzuliPipe.java b/common/buildcraft/transport/gui/ContainerEmzuliPipe.java new file mode 100644 index 00000000..cea906a5 --- /dev/null +++ b/common/buildcraft/transport/gui/ContainerEmzuliPipe.java @@ -0,0 +1,172 @@ +/** + * 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.gui; + +import buildcraft.BuildCraftTransport; +import buildcraft.core.gui.BuildCraftContainer; +import buildcraft.core.gui.GuiBuildCraft; +import buildcraft.core.gui.slots.SlotPhantom; +import buildcraft.core.gui.tooltips.ToolTip; +import buildcraft.core.gui.tooltips.ToolTipLine; +import buildcraft.core.gui.widgets.ButtonWidget; +import buildcraft.core.network.IGuiReturnHandler; +import buildcraft.core.network.PacketGuiReturn; +import buildcraft.core.utils.EnumColor; +import buildcraft.core.utils.RevolvingList; +import buildcraft.core.utils.StringUtils; +import buildcraft.transport.pipes.PipeItemsEmzuli; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; + +public class ContainerEmzuliPipe extends BuildCraftContainer { + + private final PipeItemsEmzuli pipe; + private final IInventory filterInv; + private final byte[] prevSlotColors = new byte[4]; + private final PaintWidget[] paintWidgets = new PaintWidget[4]; + + public ContainerEmzuliPipe(IInventory playerInventory, PipeItemsEmzuli pipe) { + super(pipe.getFilters().getSizeInventory()); + + this.pipe = pipe; + filterInv = pipe.getFilters(); + + addWidget(paintWidgets[0] = new PaintWidget(0, 51, 19)); + addWidget(paintWidgets[1] = new PaintWidget(1, 104, 19)); + addWidget(paintWidgets[2] = new PaintWidget(2, 51, 47)); + addWidget(paintWidgets[3] = new PaintWidget(3, 104, 47)); + + addSlot(new SlotPhantom(filterInv, 0, 25, 21)); + addSlot(new SlotPhantom(filterInv, 1, 134, 21)); + addSlot(new SlotPhantom(filterInv, 2, 25, 49)); + addSlot(new SlotPhantom(filterInv, 3, 134, 49)); + + 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, 84 + l * 18)); + } + } + + for (int i1 = 0; i1 < 9; i1++) { + addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 142)); + } + } + + @Override + public void addCraftingToCrafters(ICrafting player) { + super.addCraftingToCrafters(player); + for (int slot = 0; slot < pipe.slotColors.length; slot++) { + prevSlotColors[slot] = pipe.slotColors[slot]; + player.sendProgressBarUpdate(this, slot, pipe.slotColors[slot]); + } + } + + /** + * Updates crafting matrix; called from onCraftMatrixChanged. Args: none + */ + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + + for (int i = 0; i < crafters.size(); ++i) { + ICrafting player = (ICrafting) crafters.get(i); + + for (int slot = 0; slot < pipe.slotColors.length; slot++) { + if (prevSlotColors[slot] != pipe.slotColors[slot]) + player.sendProgressBarUpdate(this, slot, pipe.slotColors[slot]); + } + } + System.arraycopy(pipe.slotColors, 0, prevSlotColors, 0, pipe.slotColors.length); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int id, int data) { + paintWidgets[id].colors.setCurrent(data == 0 ? null : EnumColor.fromId(data - 1)); + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return pipe.container.isUseableByPlayer(entityplayer); + } + + private class PaintWidget extends ButtonWidget { + + private final int slot; + private RevolvingList colors = new RevolvingList(); + + public PaintWidget(int slot, int x, int y) { + super(x, y, 176, 0, 20, 20); + this.slot = slot; + colors.add(null); + colors.addAll(Arrays.asList(EnumColor.VALUES)); + } + + @Override + public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) { + super.draw(gui, guiX, guiY, mouseX, mouseY); + EnumColor color = colors.getCurrent(); + if (color != null) { + gui.bindTexture(TextureMap.locationItemsTexture); + gui.drawTexturedModelRectFromIcon(guiX + x + 2, guiY + y + 2, BuildCraftTransport.actionPipeColor[color.ordinal()].getIcon(), 16, 16); + } else { + gui.drawTexturedModalRect(guiX + x + 2, guiY + y + 2, u, v + h + h, 16, 16); + } + } + + @Override + public void onRelease(int mouseButton) { + switch (mouseButton) { + case 0: + colors.rotateLeft(); + break; + case 1: + colors.rotateRight(); + break; + case 2: + colors.setCurrent(null); + break; + } + try { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + DataOutputStream data = new DataOutputStream(bytes); + data.writeByte(slot); + EnumColor color = colors.getCurrent(); + data.writeByte(color == null ? 0 : color.ordinal() + 1); + PacketGuiReturn pkt = new PacketGuiReturn((IGuiReturnHandler) pipe.getContainer(), bytes.toByteArray()); + pkt.sendPacket(); + } catch (IOException ex) { + } + } + + @Override + public ToolTip getToolTip() { + return toolTip; + } + private ToolTip toolTip = new ToolTip(500) { + @Override + public void refresh() { + toolTip.clear(); + EnumColor color = colors.getCurrent(); + if (color != null) + toolTip.add(new ToolTipLine(String.format(StringUtils.localize("gui.pipes.emzuli.paint"), color.getLocalizedName()))); + else + toolTip.add(new ToolTipLine(StringUtils.localize("gui.pipes.emzuli.nopaint"))); + } + }; + } +} diff --git a/common/buildcraft/transport/gui/ContainerLogemeraldPipe.java b/common/buildcraft/transport/gui/ContainerLogemeraldPipe.java deleted file mode 100644 index 931aa8cf..00000000 --- a/common/buildcraft/transport/gui/ContainerLogemeraldPipe.java +++ /dev/null @@ -1,49 +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.gui; - -import buildcraft.core.gui.BuildCraftContainer; -import buildcraft.core.gui.slots.SlotPhantom; -import buildcraft.transport.pipes.PipeItemsLogemerald; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; - -public class ContainerLogemeraldPipe extends BuildCraftContainer { - - private final PipeItemsLogemerald logemeraldPipe; - - private final IInventory filterInv; - - public ContainerLogemeraldPipe(IInventory playerInventory, PipeItemsLogemerald pipe) { - super(pipe.getFilters().getSizeInventory()); - - logemeraldPipe = pipe; - filterInv = logemeraldPipe.getFilters(); - - addSlotToContainer(new SlotPhantom(filterInv, 0, 44, 21)); - addSlotToContainer(new SlotPhantom(filterInv, 1, 116, 21)); - addSlotToContainer(new SlotPhantom(filterInv, 2, 44, 49)); - addSlotToContainer(new SlotPhantom(filterInv, 3, 116, 49)); - - 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, 84 + l * 18)); - } - } - - for (int i1 = 0; i1 < 9; i1++) { - addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 142)); - } - } - - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return logemeraldPipe.container.isUseableByPlayer(entityplayer); - } -} diff --git a/common/buildcraft/transport/gui/GuiLogemeraldPipe.java b/common/buildcraft/transport/gui/GuiEmzuliPipe.java similarity index 53% rename from common/buildcraft/transport/gui/GuiLogemeraldPipe.java rename to common/buildcraft/transport/gui/GuiEmzuliPipe.java index 87acd025..73aaecbd 100644 --- a/common/buildcraft/transport/gui/GuiLogemeraldPipe.java +++ b/common/buildcraft/transport/gui/GuiEmzuliPipe.java @@ -10,43 +10,33 @@ package buildcraft.transport.gui; 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.utils.StringUtils; -import buildcraft.transport.pipes.PipeItemsLogemerald; +import buildcraft.transport.pipes.PipeItemsEmzuli; -public class GuiLogemeraldPipe extends GuiBuildCraft { +public class GuiEmzuliPipe extends GuiBuildCraft { - private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/logemerald_pipe_gui.png"); + private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/pipe_emzuli.png"); IInventory filterInventory; - PipeItemsLogemerald logemeraldPipe; + PipeItemsEmzuli pipe; - public GuiLogemeraldPipe(IInventory playerInventory, PipeItemsLogemerald pipe) { - super(new ContainerLogemeraldPipe(playerInventory, pipe), pipe.getFilters()); + public GuiEmzuliPipe(IInventory playerInventory, PipeItemsEmzuli pipe) { + super(new ContainerEmzuliPipe(playerInventory, pipe), pipe.getFilters(), TEXTURE); - logemeraldPipe = pipe; + this.pipe = pipe; filterInventory = pipe.getFilters(); - xSize = 175; + xSize = 176; ySize = 166; } @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - String title = StringUtils.localize("gui.pipes.logemerald.title"); + String title = StringUtils.localize("gui.pipes.emzuli.title"); fontRenderer.drawString(title, (xSize - fontRenderer.getStringWidth(title)) / 2, 6, 0x404040); fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040); } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - 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/pipes/PipeItemsDaizuli.java b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java index cad1b80e..77532486 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java @@ -9,18 +9,17 @@ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.api.core.Position; import buildcraft.api.gates.IAction; import buildcraft.api.tools.IToolWrench; import buildcraft.core.network.TileNetworkData; import buildcraft.core.utils.EnumColor; -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.pipes.events.PipeEventItem; import buildcraft.transport.triggers.ActionPipeColor; import buildcraft.transport.triggers.ActionPipeDirection; import cpw.mods.fml.relauncher.Side; @@ -35,12 +34,12 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; -public class PipeItemsDaizuli extends Pipe implements IPipeTransportItemsHook { +public class PipeItemsDaizuli extends Pipe { private int standardIconIndex = PipeIconProvider.TYPE.PipeItemsDaizuli_Black.ordinal(); private int solidIconIndex = PipeIconProvider.TYPE.PipeAllDaizuli_Solid.ordinal(); @TileNetworkData - private int color = EnumColor.WHITE.ordinal(); + private int color = EnumColor.BLACK.ordinal(); private PipeLogicIron logic = new PipeLogicIron(this) { @Override protected boolean isValidConnectingTile(TileEntity tile) { @@ -119,33 +118,31 @@ public class PipeItemsDaizuli extends Pipe implements IPipeT return true; } - @Override - public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item) { + public void eventHandler(PipeEventItem.FindDest event) { LinkedList newMovements = new LinkedList(); EnumColor c = getColor(); - for (ForgeDirection dir : possibleOrientations) { - if (item.color == c) { + for (ForgeDirection dir : event.destinations) { + if (event.item.color == c) { if (dir.ordinal() == container.getBlockMetadata()) newMovements.add(dir); } else if (dir.ordinal() != container.getBlockMetadata()) { newMovements.add(dir); } } - return newMovements; + event.destinations.retainAll(newMovements); } - @Override - public void entityEntered(TravelingItem item, ForgeDirection orientation) { - } + public void eventHandler(PipeEventItem.AdjustSpeed event) { + event.handled = true; + TravelingItem item = event.item; - @Override - public void readjustSpeed(TravelingItem item) { - if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) + if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) { item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F); + } - - if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) + if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) { item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED); + } } @Override diff --git a/common/buildcraft/transport/pipes/PipeItemsDiamond.java b/common/buildcraft/transport/pipes/PipeItemsDiamond.java index 0ea40d90..21be7f68 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDiamond.java +++ b/common/buildcraft/transport/pipes/PipeItemsDiamond.java @@ -21,22 +21,20 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.api.core.Position; import buildcraft.core.GuiIds; import buildcraft.core.inventory.SimpleInventory; import buildcraft.core.inventory.StackHelper; import buildcraft.core.network.IClientState; import buildcraft.core.proxy.CoreProxy; import buildcraft.transport.BlockGenericPipe; -import buildcraft.transport.IPipeTransportItemsHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; -import buildcraft.transport.TravelingItem; +import buildcraft.transport.pipes.events.PipeEventItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook, IClientState { +public class PipeItemsDiamond extends Pipe implements IClientState { private SimpleInventory filters = new SimpleInventory(54, "Filters", 1); @@ -76,6 +74,11 @@ public class PipeItemsDiamond extends Pipe implements IPipeT } } + @Override + public int getIconIndexForItem() { + return PipeIconProvider.TYPE.PipeItemsDiamond_Item.ordinal(); + } + @Override public boolean blockActivated(EntityPlayer entityplayer) { if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID < Block.blocksList.length) @@ -89,13 +92,12 @@ public class PipeItemsDiamond extends Pipe implements IPipeT return true; } - @Override - public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item) { + public void eventHandler(PipeEventItem.FindDest event) { LinkedList filteredOrientations = new LinkedList(); LinkedList defaultOrientations = new LinkedList(); // Filtered outputs - for (ForgeDirection dir : possibleOrientations) { + for (ForgeDirection dir : event.destinations) { boolean foundFilter = false; // NB: if there's several of the same match, the probability @@ -107,29 +109,20 @@ public class PipeItemsDiamond extends Pipe implements IPipeT if (filter != null) foundFilter = true; - if (StackHelper.instance().isMatchingItem(filter, item.getItemStack(), true, false)) + if (StackHelper.instance().isMatchingItem(filter, event.item.getItemStack(), true, false)) filteredOrientations.add(dir); - } if (!foundFilter) defaultOrientations.add(dir); } + event.destinations.clear(); if (!filteredOrientations.isEmpty()) - return filteredOrientations; - - return defaultOrientations; + event.destinations.addAll(filteredOrientations); + else + event.destinations.addAll(defaultOrientations); } - @Override - public void entityEntered(TravelingItem item, ForgeDirection orientation) { - } - - @Override - public void readjustSpeed(TravelingItem item) { - transport.defaultReajustSpeed(item); - } /* SAVING & LOADING */ - @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); diff --git a/common/buildcraft/transport/pipes/PipeItemsLogemerald.java b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java similarity index 74% rename from common/buildcraft/transport/pipes/PipeItemsLogemerald.java rename to common/buildcraft/transport/pipes/PipeItemsEmzuli.java index 6190d207..53a6b155 100644 --- a/common/buildcraft/transport/pipes/PipeItemsLogemerald.java +++ b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java @@ -25,27 +25,33 @@ import buildcraft.api.inventory.ISelectiveInventory; import buildcraft.api.inventory.ISpecialInventory; import buildcraft.core.GuiIds; import buildcraft.core.inventory.SimpleInventory; +import buildcraft.core.inventory.StackHelper; +import buildcraft.core.network.IGuiReturnHandler; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.EnumColor; import buildcraft.core.utils.Utils; import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.PipeIconProvider; -import buildcraft.transport.pipes.PipeItemsEmerald.ButtonState; +import buildcraft.transport.TravelingItem; +import buildcraft.transport.pipes.events.PipeEventItem; import buildcraft.transport.triggers.ActionExtractionPreset; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; -public class PipeItemsLogemerald extends PipeItemsWood { +public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler { + public final byte[] slotColors = new byte[4]; private final SimpleInventory filters = new SimpleInventory(4, "Filters", 1); - - private BitSet activeFlags = new BitSet(4); - private int filterCount = filters.getSizeInventory(); + private final BitSet activeFlags = new BitSet(4); + private final int filterCount = filters.getSizeInventory(); private int currentFilter = 0; - public PipeItemsLogemerald(int itemID) { + public PipeItemsEmzuli(int itemID) { super(itemID); - standardIconIndex = PipeIconProvider.TYPE.PipeItemsLogemerald_Standard.ordinal(); - solidIconIndex = PipeIconProvider.TYPE.PipeAllLogemerald_Solid.ordinal(); + standardIconIndex = PipeIconProvider.TYPE.PipeItemsEmzuli_Standard.ordinal(); + solidIconIndex = PipeIconProvider.TYPE.PipeAllEmzuli_Solid.ordinal(); } @Override @@ -66,7 +72,16 @@ public class PipeItemsLogemerald extends PipeItemsWood { return true; } - + + @Override + protected TravelingItem makeItem(double x, double y, double z, ItemStack stack) { + TravelingItem item = super.makeItem(x, y, z, stack); + int color = slotColors[currentFilter % filterCount]; + if (color > 0) + item.color = EnumColor.fromId(color - 1); + return item; + } + /** * Return the itemstack that can be if something can be extracted from this * inventory, null if none. On certain cases, the extractable slot depends @@ -75,19 +90,19 @@ public class PipeItemsLogemerald extends PipeItemsWood { @Override public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) { - if (activeFlags.isEmpty()){ + if (activeFlags.isEmpty()) { return null; } - + incrementFilter(); - if (filters.getStackInSlot(currentFilter % filterCount) == null || !activeFlags.get(currentFilter % filterCount)){ + if (filters.getStackInSlot(currentFilter % filterCount) == null || !activeFlags.get(currentFilter % filterCount)) { return null; } - + /* ISELECTIVEINVENTORY */ 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) { @@ -133,9 +148,9 @@ public class PipeItemsLogemerald extends PipeItemsWood { // This is a generic inventory IInventory inv = Utils.getInventory(inventory); ItemStack result = checkExtractGeneric(inv, doRemove, from); - + if (result != null) { - return new ItemStack[] { result }; + return new ItemStack[]{result}; } } @@ -171,11 +186,11 @@ public class PipeItemsLogemerald extends PipeItemsWood { public IInventory getFilters() { return filters; } - + @Override protected void actionsActivated(Map actions) { super.actionsActivated(actions); - + activeFlags.clear(); for (Entry action : actions.entrySet()) { @@ -186,28 +201,28 @@ public class PipeItemsLogemerald extends PipeItemsWood { } private void setActivePreset(EnumColor color) { - switch (color){ - case RED: - activeFlags.set(0); - break; - case BLUE: - activeFlags.set(1); - break; - case GREEN: - activeFlags.set(2); - break; - case YELLOW: - activeFlags.set(3); - break; - default: - break; + switch (color) { + case RED: + activeFlags.set(0); + break; + case BLUE: + activeFlags.set(1); + break; + case GREEN: + activeFlags.set(2); + break; + case YELLOW: + activeFlags.set(3); + break; + default: + break; } } @Override public LinkedList getActions() { LinkedList result = super.getActions(); - + result.add(BuildCraftTransport.actionExtractionPresetRed); result.add(BuildCraftTransport.actionExtractionPresetBlue); result.add(BuildCraftTransport.actionExtractionPresetGreen); @@ -216,11 +231,24 @@ public class PipeItemsLogemerald extends PipeItemsWood { return result; } + @Override + public void writeGuiData(DataOutputStream paramDataOutputStream) throws IOException { + } + + @Override + public void readGuiData(DataInputStream data, EntityPlayer paramEntityPlayer) throws IOException { + byte slot = data.readByte(); + slotColors[slot] = data.readByte(); + } + @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); filters.readFromNBT(nbt); currentFilter = nbt.getInteger("currentFilter"); + for (int slot = 0; slot < slotColors.length; slot++) { + slotColors[slot] = nbt.getByte("slotColors[" + slot + "]"); + } } @Override @@ -228,19 +256,22 @@ public class PipeItemsLogemerald extends PipeItemsWood { super.writeToNBT(nbt); filters.writeToNBT(nbt); nbt.setInteger("currentFilter", currentFilter); + for (int slot = 0; slot < slotColors.length; slot++) { + nbt.setByte("slotColors[" + slot + "]", slotColors[slot]); + } } - + private void incrementFilter() { int count = 0; currentFilter++; - + while (!(filters.getStackInSlot(currentFilter % filterCount) != null && activeFlags.get(currentFilter % filterCount)) && count < filterCount) { currentFilter++; count++; } } - private ItemStack getCurrentFilter() { + private ItemStack getCurrentFilter() { return filters.getStackInSlot(currentFilter % filters.getSizeInventory()); } } diff --git a/common/buildcraft/transport/pipes/PipeItemsGold.java b/common/buildcraft/transport/pipes/PipeItemsGold.java index cc35cc5c..1f6bf80a 100644 --- a/common/buildcraft/transport/pipes/PipeItemsGold.java +++ b/common/buildcraft/transport/pipes/PipeItemsGold.java @@ -9,19 +9,17 @@ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.api.core.Position; -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.pipes.events.PipeEventItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.LinkedList; import net.minecraftforge.common.ForgeDirection; -public class PipeItemsGold extends Pipe implements IPipeTransportItemsHook { +public class PipeItemsGold extends Pipe { public PipeItemsGold(int itemID) { super(new PipeTransportItems(), itemID); @@ -38,18 +36,9 @@ public class PipeItemsGold extends Pipe implements IPipeTransportItemsHook { return PipeIconProvider.TYPE.PipeItemsGold.ordinal(); } - @Override - public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item) { - return possibleOrientations; - } - - @Override - public void entityEntered(TravelingItem item, ForgeDirection orientation) { - readjustSpeed(item); - } - - @Override - public void readjustSpeed(TravelingItem item) { + public void handleEvent(PipeEventItem.AdjustSpeed event) { + event.handled = true; + TravelingItem item = event.item; 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 4df7a8f6..6e7d5352 100644 --- a/common/buildcraft/transport/pipes/PipeItemsLapis.java +++ b/common/buildcraft/transport/pipes/PipeItemsLapis.java @@ -9,17 +9,15 @@ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.api.core.Position; import buildcraft.api.gates.IAction; import buildcraft.api.tools.IToolWrench; import buildcraft.core.utils.EnumColor; -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.pipes.events.PipeEventItem; import buildcraft.transport.triggers.ActionPipeColor; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -29,14 +27,12 @@ import java.util.Map; import java.util.Map.Entry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; -import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; -public class PipeItemsLapis extends Pipe implements IItemTravelingHook, IPipeTransportItemsHook { +public class PipeItemsLapis extends Pipe { public PipeItemsLapis(int itemID) { super(new PipeTransportItems(), itemID); - transport.travelHook = this; } @Override @@ -48,7 +44,7 @@ public class PipeItemsLapis extends Pipe implements IItemTra @Override public int getIconIndex(ForgeDirection direction) { if (container == null) - return PipeIconProvider.TYPE.PipeItemsLapis_White.ordinal(); + return PipeIconProvider.TYPE.PipeItemsLapis_Black.ordinal(); return PipeIconProvider.TYPE.PipeItemsLapis_Black.ordinal() + container.getBlockMetadata(); } @@ -80,22 +76,14 @@ public class PipeItemsLapis extends Pipe implements IItemTra } } - @Override - public void drop(PipeTransportItems transport, TravelingItem data) { + public void eventHandler(PipeEventItem.ReachedCenter event) { + event.item.color = getColor(); } - @Override - public void centerReached(PipeTransportItems transport, TravelingItem item) { - item.color = getColor(); - } + public void eventHandler(PipeEventItem.AdjustSpeed event) { + event.handled = true; + TravelingItem item = event.item; - @Override - public boolean endReached(PipeTransportItems pipe, TravelingItem item, TileEntity tile) { - return false; - } - - @Override - public void readjustSpeed(TravelingItem item) { if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) { item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F); } @@ -105,15 +93,6 @@ public class PipeItemsLapis extends Pipe implements IItemTra } } - @Override - public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem travellingItem) { - return possibleOrientations; - } - - @Override - public void entityEntered(TravelingItem travellingItem, ForgeDirection orientation) { - } - @Override protected void actionsActivated(Map actions) { super.actionsActivated(actions); diff --git a/common/buildcraft/transport/pipes/PipeItemsObsidian.java b/common/buildcraft/transport/pipes/PipeItemsObsidian.java index eff8cfb3..5cfb1405 100644 --- a/common/buildcraft/transport/pipes/PipeItemsObsidian.java +++ b/common/buildcraft/transport/pipes/PipeItemsObsidian.java @@ -22,6 +22,8 @@ import buildcraft.core.proxy.CoreProxy; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; +import buildcraft.transport.pipes.events.PipeEvent; +import buildcraft.transport.pipes.events.PipeEventItem; import buildcraft.transport.utils.TransportUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -234,15 +236,12 @@ public class PipeItemsObsidian extends Pipe implements IPowe } } - @Override - public void onDropped(EntityItem item) { - if (entitiesDroppedIndex + 1 >= entitiesDropped.length) { + public void eventHandler(PipeEventItem.DropItem event) { + if (entitiesDroppedIndex + 1 >= entitiesDropped.length) entitiesDroppedIndex = 0; - } else { + else entitiesDroppedIndex++; - } - - entitiesDropped[entitiesDroppedIndex] = item.entityId; + entitiesDropped[entitiesDroppedIndex] = event.entity.entityId; } public boolean canSuck(Entity entity, int distance) { diff --git a/common/buildcraft/transport/pipes/PipeItemsQuartz.java b/common/buildcraft/transport/pipes/PipeItemsQuartz.java index 13c6a0d5..6873ffde 100644 --- a/common/buildcraft/transport/pipes/PipeItemsQuartz.java +++ b/common/buildcraft/transport/pipes/PipeItemsQuartz.java @@ -9,19 +9,17 @@ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.api.core.Position; -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.pipes.events.PipeEventItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.LinkedList; import net.minecraftforge.common.ForgeDirection; -public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook { +public class PipeItemsQuartz extends Pipe { public PipeItemsQuartz(int itemID) { super(new PipeTransportItems(), itemID); @@ -39,8 +37,10 @@ public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook { return PipeIconProvider.TYPE.PipeItemsQuartz.ordinal(); } - @Override - public void readjustSpeed(TravelingItem item) { + public void eventHandler(PipeEventItem.AdjustSpeed event) { + event.handled = true; + TravelingItem item = event.item; + if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) { item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F); } @@ -49,13 +49,4 @@ public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook { item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED); } } - - @Override - public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item) { - return possibleOrientations; - } - - @Override - public void entityEntered(TravelingItem item, ForgeDirection orientation) { - } } diff --git a/common/buildcraft/transport/pipes/PipeItemsStone.java b/common/buildcraft/transport/pipes/PipeItemsStone.java index 415e5dd2..86c96858 100644 --- a/common/buildcraft/transport/pipes/PipeItemsStone.java +++ b/common/buildcraft/transport/pipes/PipeItemsStone.java @@ -9,19 +9,17 @@ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.api.core.Position; -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.pipes.events.PipeEventItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.LinkedList; import net.minecraftforge.common.ForgeDirection; -public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook { +public class PipeItemsStone extends Pipe { public PipeItemsStone(int itemID) { super(new PipeTransportItems(), itemID); @@ -38,8 +36,10 @@ public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook { return PipeIconProvider.TYPE.PipeItemsStone.ordinal(); } - @Override - public void readjustSpeed(TravelingItem item) { + public void eventHandler(PipeEventItem.AdjustSpeed event) { + event.handled = true; + TravelingItem item = event.item; + if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) { item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 2.0F); } @@ -48,13 +48,4 @@ public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook { item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED); } } - - @Override - public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item) { - return possibleOrientations; - } - - @Override - public void entityEntered(TravelingItem item, ForgeDirection orientation) { - } } diff --git a/common/buildcraft/transport/pipes/PipeItemsVoid.java b/common/buildcraft/transport/pipes/PipeItemsVoid.java index 002f1f9c..37ff877a 100644 --- a/common/buildcraft/transport/pipes/PipeItemsVoid.java +++ b/common/buildcraft/transport/pipes/PipeItemsVoid.java @@ -9,21 +9,18 @@ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.transport.IItemTravelingHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; -import buildcraft.transport.TravelingItem; +import buildcraft.transport.pipes.events.PipeEventItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; -public class PipeItemsVoid extends Pipe implements IItemTravelingHook { +public class PipeItemsVoid extends Pipe { public PipeItemsVoid(int itemID) { super(new PipeTransportItems(), itemID); - transport.travelHook = this; } @Override @@ -37,20 +34,11 @@ public class PipeItemsVoid extends Pipe implements IItemTrav return PipeIconProvider.TYPE.PipeItemsVoid.ordinal(); } - // This is called if the void pipe is only connected to one pipe - @Override - public void drop(PipeTransportItems pipe, TravelingItem item) { - item.getItemStack().stackSize = 0; + public void handleEvent(PipeEventItem.DropItem event) { + event.entity = null; } - // This is called when the void pipe is connected to multiple pipes - @Override - public void centerReached(PipeTransportItems pipe, TravelingItem item) { - transport.items.scheduleRemoval(item); - } - - @Override - public boolean endReached(PipeTransportItems pipe, TravelingItem item, TileEntity tile) { - return false; + public void handleEvent(PipeEventItem.ReachedCenter event) { + transport.items.scheduleRemoval(event.item); } } diff --git a/common/buildcraft/transport/pipes/PipeItemsWood.java b/common/buildcraft/transport/pipes/PipeItemsWood.java index e5746046..4149a055 100644 --- a/common/buildcraft/transport/pipes/PipeItemsWood.java +++ b/common/buildcraft/transport/pipes/PipeItemsWood.java @@ -139,13 +139,17 @@ public class PipeItemsWood extends Pipe implements IPowerRec entityPos.moveForwards(0.6); - TravelingItem entity = new TravelingItem(entityPos.x, entityPos.y, entityPos.z, stack); + TravelingItem entity = makeItem(entityPos.x, entityPos.y, entityPos.z, stack); transport.injectItem(entity, entityPos.orientation); } } } + protected TravelingItem makeItem(double x, double y, double z, ItemStack stack) { + return new TravelingItem(x, y, z, stack); + } + /** * Return the itemstack that can be if something can be extracted from this * inventory, null if none. On certain cases, the extractable slot depends diff --git a/common/buildcraft/transport/pipes/events/PipeEvent.java b/common/buildcraft/transport/pipes/events/PipeEvent.java new file mode 100644 index 00000000..8cc7177e --- /dev/null +++ b/common/buildcraft/transport/pipes/events/PipeEvent.java @@ -0,0 +1,16 @@ +/* + * 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.pipes.events; + +/** + * + * @author CovertJaguar + */ +public abstract class PipeEvent { +} diff --git a/common/buildcraft/transport/pipes/events/PipeEventItem.java b/common/buildcraft/transport/pipes/events/PipeEventItem.java new file mode 100644 index 00000000..0671c8ad --- /dev/null +++ b/common/buildcraft/transport/pipes/events/PipeEventItem.java @@ -0,0 +1,84 @@ +/* + * 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.pipes.events; + +import buildcraft.transport.TravelingItem; +import java.util.List; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; + +/** + * + * @author CovertJaguar + */ +public abstract class PipeEventItem extends PipeEvent { + + public final TravelingItem item; + + public PipeEventItem(TravelingItem item) { + this.item = item; + } + + public static class Entered extends PipeEventItem { + + public boolean cancelled = false; + + public Entered(TravelingItem item) { + super(item); + } + } + + public static class ReachedCenter extends PipeEventItem { + + public ReachedCenter(TravelingItem item) { + super(item); + } + } + + public static class ReachedEnd extends PipeEventItem { + + public final TileEntity dest; + public boolean handled = false; + + public ReachedEnd(TravelingItem item, TileEntity dest) { + super(item); + this.dest = dest; + } + } + + public static class DropItem extends PipeEventItem { + + public EntityItem entity; + + public DropItem(TravelingItem item, EntityItem entity) { + super(item); + this.entity = entity; + } + } + + public static class FindDest extends PipeEventItem { + + public final List destinations; + + public FindDest(TravelingItem item, List destinations) { + super(item); + this.destinations = destinations; + } + } + + public static class AdjustSpeed extends PipeEventItem { + + public boolean handled = false; + + public AdjustSpeed(TravelingItem item) { + super(item); + } + } +} diff --git a/common/buildcraft/transport/triggers/ActionPipeColor.java b/common/buildcraft/transport/triggers/ActionPipeColor.java index 9095d2bc..6f9add53 100644 --- a/common/buildcraft/transport/triggers/ActionPipeColor.java +++ b/common/buildcraft/transport/triggers/ActionPipeColor.java @@ -9,6 +9,7 @@ package buildcraft.transport.triggers; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.EnumColor; +import buildcraft.core.utils.StringUtils; import java.util.Locale; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.util.Icon; @@ -26,7 +27,7 @@ public class ActionPipeColor extends BCAction { @Override public String getDescription() { - return color.getName() + " Pipe Color"; + return String.format(StringUtils.localize("gate.pipe.item.color"), color.getLocalizedName()); } @Override From 023a5d51fb5eaba41ef070e460d0ae45c8099332 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 24 Nov 2013 06:31:40 -0800 Subject: [PATCH 21/45] Some cleanup --- common/buildcraft/transport/gui/ContainerEmzuliPipe.java | 4 ++++ common/buildcraft/transport/gui/GuiEmzuliPipe.java | 5 ++++- common/buildcraft/transport/pipes/PipeItemsEmzuli.java | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/transport/gui/ContainerEmzuliPipe.java b/common/buildcraft/transport/gui/ContainerEmzuliPipe.java index cea906a5..76e5a3ef 100644 --- a/common/buildcraft/transport/gui/ContainerEmzuliPipe.java +++ b/common/buildcraft/transport/gui/ContainerEmzuliPipe.java @@ -32,6 +32,10 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +/** + * + * @author SandGrainOne + */ public class ContainerEmzuliPipe extends BuildCraftContainer { private final PipeItemsEmzuli pipe; diff --git a/common/buildcraft/transport/gui/GuiEmzuliPipe.java b/common/buildcraft/transport/gui/GuiEmzuliPipe.java index 73aaecbd..5336186e 100644 --- a/common/buildcraft/transport/gui/GuiEmzuliPipe.java +++ b/common/buildcraft/transport/gui/GuiEmzuliPipe.java @@ -16,10 +16,13 @@ import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.utils.StringUtils; import buildcraft.transport.pipes.PipeItemsEmzuli; +/** + * + * @author SandGrainOne + */ public class GuiEmzuliPipe extends GuiBuildCraft { private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/pipe_emzuli.png"); - IInventory filterInventory; PipeItemsEmzuli pipe; diff --git a/common/buildcraft/transport/pipes/PipeItemsEmzuli.java b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java index 53a6b155..cb082938 100644 --- a/common/buildcraft/transport/pipes/PipeItemsEmzuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java @@ -25,7 +25,6 @@ import buildcraft.api.inventory.ISelectiveInventory; import buildcraft.api.inventory.ISpecialInventory; import buildcraft.core.GuiIds; import buildcraft.core.inventory.SimpleInventory; -import buildcraft.core.inventory.StackHelper; import buildcraft.core.network.IGuiReturnHandler; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.EnumColor; @@ -33,12 +32,15 @@ import buildcraft.core.utils.Utils; import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.TravelingItem; -import buildcraft.transport.pipes.events.PipeEventItem; import buildcraft.transport.triggers.ActionExtractionPreset; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +/** + * + * @author SandGrainOne + */ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler { public final byte[] slotColors = new byte[4]; From 0f63603bd6f68f00845f049715450f7e4e5f5b21 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 24 Nov 2013 06:50:23 -0800 Subject: [PATCH 22/45] Rework Diazuli Pipe routing to handle overflow --- .../transport/pipes/PipeItemsDaizuli.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java index 77532486..1ae28871 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java @@ -119,17 +119,13 @@ public class PipeItemsDaizuli extends Pipe { } public void eventHandler(PipeEventItem.FindDest event) { - LinkedList newMovements = new LinkedList(); - EnumColor c = getColor(); - for (ForgeDirection dir : event.destinations) { - if (event.item.color == c) { - if (dir.ordinal() == container.getBlockMetadata()) - newMovements.add(dir); - } else if (dir.ordinal() != container.getBlockMetadata()) { - newMovements.add(dir); - } + ForgeDirection output = ForgeDirection.getOrientation(container.getBlockMetadata()); + if (event.item.color == getColor() && event.destinations.contains(output)) { + event.destinations.clear(); + event.destinations.add(output); + return; } - event.destinations.retainAll(newMovements); + event.destinations.remove(output); } public void eventHandler(PipeEventItem.AdjustSpeed event) { From 52ce3ac8c3145ddf70c6c192b6478262f7bfadff Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 24 Nov 2013 07:09:01 -0800 Subject: [PATCH 23/45] Fix full inv item bounce client animation --- 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 e9f2c758..ca61cfc2 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -529,6 +529,7 @@ public class PipeTransportItems extends PipeTransport { item.setSpeed(packet.getSpeed()); + item.toCenter = true; item.input = packet.getInputOrientation(); item.output = packet.getOutputOrientation(); item.color = packet.getColor(); From cc8c707c4665f1876d7374040be9adb5267c07ca Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 24 Nov 2013 07:21:48 -0800 Subject: [PATCH 24/45] Rename Lapis Pipe to Lazuli Pipe --- 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 d80d8d87..5d379677 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -107,7 +107,7 @@ item.PipeItemsGold=Golden Transport Pipe item.PipeItemsDiamond=Diamond Transport Pipe item.PipeItemsObsidian=Obsidian Transport Pipe item.PipeItemsEmerald=Emerald Transport Pipe -item.PipeItemsLapis=Lapis Transport Pipe +item.PipeItemsLapis=Lazuli Transport Pipe item.PipeItemsDaizuli=Daizuli Transport Pipe item.PipeItemsEmzuli=Emzuli Transport Pipe item.PipeFluidsWood=Wooden Fluid Pipe From 81b45b692efe1936d1a52bf24f7e32ac882c5a80 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 24 Nov 2013 07:24:08 -0800 Subject: [PATCH 25/45] Fix Emzuli tooltip --- 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 5d379677..d165edea 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -184,7 +184,7 @@ 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.PipeItemsLogemerald=Action controlled extraction pipe +tip.PipeItemsEmzuli=Gate controlled extraction pipe tip.PipePowerWood=Power Input Pipe tip.PipePowerIron=Selectable Limiter Pipe tip.PipeStructureCobblestone=Support pipe From 65bff981e5bff8e008cb60dbd45a753b5d0b827b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 25 Nov 2013 05:59:05 -0800 Subject: [PATCH 26/45] Fix block placement sync Closes #1334 Closes #1335 --- 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 25e5297e..e2b6fd4a 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -1007,7 +1007,7 @@ public class BlockGenericPipe extends BlockContainer { if (world.isRemote) return true; - boolean placed = world.setBlock(i, j, k, blockId, meta, 1); + boolean placed = world.setBlock(i, j, k, blockId, meta, 3); if (placed) { TileGenericPipe tile = (TileGenericPipe) world.getBlockTileEntity(i, j, k); From 1e24cf4d85e2ebdc7d4feaef99c5b24bb5604364 Mon Sep 17 00:00:00 2001 From: viliml Date: Mon, 25 Nov 2013 21:12:14 +0100 Subject: [PATCH 27/45] Add possible simpler way to send IMC facade requests IMC has a built-in way of sending ItemStacks through it, and it would be simpler if mods could simply use that, instead of encoding the ID and metadata a string. Decoding is a lot simpler too, just one line. --- common/buildcraft/core/InterModComms.java | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/common/buildcraft/core/InterModComms.java b/common/buildcraft/core/InterModComms.java index e4a56ece..854b0bd4 100644 --- a/common/buildcraft/core/InterModComms.java +++ b/common/buildcraft/core/InterModComms.java @@ -38,19 +38,23 @@ public class InterModComms { public static void processFacadeIMC(IMCEvent event, IMCMessage m) { try { - Splitter splitter = Splitter.on("@").trimResults(); + if (m.isStringMessage()) { + 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) { + 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 { - ItemFacade.addFacade(new ItemStack(blId, 1, metaId)); + 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)); + } } + } else if (m.isItemStackMessage()) { + ItemFacade.addFacade(m.getItemStackValue()); } } catch (Exception ex) { From 6b8ec69b37406c0293b1169fe39fbf326c3fa524 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 25 Nov 2013 12:44:01 -0800 Subject: [PATCH 28/45] Store owner information in the Tile --- common/buildcraft/core/BlockBuildCraft.java | 24 ++++++++++- common/buildcraft/core/TileBuildCraft.java | 27 ++++++++++++ common/buildcraft/energy/BlockEngine.java | 8 +--- common/buildcraft/factory/BlockFloodGate.java | 6 +-- common/buildcraft/factory/BlockHopper.java | 1 - .../buildcraft/factory/BlockMachineRoot.java | 43 ------------------- .../buildcraft/factory/BlockMiningWell.java | 3 +- common/buildcraft/factory/BlockPlainPipe.java | 1 - common/buildcraft/factory/BlockPump.java | 6 +-- common/buildcraft/factory/BlockQuarry.java | 5 ++- common/buildcraft/factory/TileRefinery.java | 1 - .../transport/BlockGenericPipe.java | 5 +-- 12 files changed, 62 insertions(+), 68 deletions(-) delete mode 100644 common/buildcraft/factory/BlockMachineRoot.java diff --git a/common/buildcraft/core/BlockBuildCraft.java b/common/buildcraft/core/BlockBuildCraft.java index 5cb35417..7540131a 100644 --- a/common/buildcraft/core/BlockBuildCraft.java +++ b/common/buildcraft/core/BlockBuildCraft.java @@ -4,17 +4,30 @@ import buildcraft.core.utils.Utils; import java.util.Random; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public abstract class BlockBuildCraft extends BlockContainer { protected static boolean keepInventory = false; - protected Random rand; + protected final Random rand = new Random(); protected BlockBuildCraft(int id, Material material) { super(id, material); - this.rand = new Random(); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); + setHardness(5F); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + super.onBlockPlacedBy(world, x, y, z, entity, stack); + TileEntity tile = world.getBlockTileEntity(x, y, z); + if (tile instanceof TileBuildCraft) { + ((TileBuildCraft) tile).onBlockPlacedBy(entity, stack); + } } @Override @@ -23,4 +36,11 @@ public abstract class BlockBuildCraft extends BlockContainer { super.breakBlock(world, x, y, z, par5, par6); } + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + TileEntity tile = world.getBlockTileEntity(x, y, z); + if (tile instanceof IMachine && ((IMachine) tile).isActive()) + return super.getLightValue(world, x, y, z) + 8; + return super.getLightValue(world, x, y, z); + } } diff --git a/common/buildcraft/core/TileBuildCraft.java b/common/buildcraft/core/TileBuildCraft.java index 847c4dfe..773f46b7 100644 --- a/common/buildcraft/core/TileBuildCraft.java +++ b/common/buildcraft/core/TileBuildCraft.java @@ -19,6 +19,10 @@ import buildcraft.core.utils.Utils; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import net.minecraft.entity.EntityLivingBase; +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; @@ -32,6 +36,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized private final TilePacketWrapper descriptionPacket; private final TilePacketWrapper updatePacket; private boolean init = false; + private String owner = "[BuildCraft]"; public TileBuildCraft() { if (!updateWrappers.containsKey(this.getClass())) { @@ -47,6 +52,10 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized } + public String getOwner() { + return owner; + } + @Override public void updateEntity() { if (!init && !isInvalid()) { @@ -70,6 +79,11 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized Utils.handleBufferedDescription(this); } + public void onBlockPlacedBy(EntityLivingBase entity, ItemStack stack) { + if (entity instanceof EntityPlayer) + owner = ((EntityPlayer) entity).username; + } + public void destroy() { } @@ -110,6 +124,19 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized public void postPacketHandling(PacketUpdate packet) { } + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setString("owner", owner); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + if (nbt.hasKey("owner")) + owner = nbt.getString("owner"); + } + public boolean isInvNameLocalized() { // TODO Auto-generated method stub return false; diff --git a/common/buildcraft/energy/BlockEngine.java b/common/buildcraft/energy/BlockEngine.java index 8382700d..3901805c 100644 --- a/common/buildcraft/energy/BlockEngine.java +++ b/common/buildcraft/energy/BlockEngine.java @@ -8,13 +8,12 @@ package buildcraft.energy; import buildcraft.BuildCraftCore; -import buildcraft.core.CreativeTabBuildCraft; +import buildcraft.core.BlockBuildCraft; import buildcraft.core.IItemPipe; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; -import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -25,7 +24,7 @@ import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; -public class BlockEngine extends BlockContainer { +public class BlockEngine extends BlockBuildCraft { private static Icon woodTexture; private static Icon stoneTexture; @@ -33,9 +32,6 @@ public class BlockEngine extends BlockContainer { public BlockEngine(int i) { super(i, Material.iron); - - setHardness(5F); - setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); setUnlocalizedName("engineBlock"); } diff --git a/common/buildcraft/factory/BlockFloodGate.java b/common/buildcraft/factory/BlockFloodGate.java index c0ce9c3d..e78ff8bc 100644 --- a/common/buildcraft/factory/BlockFloodGate.java +++ b/common/buildcraft/factory/BlockFloodGate.java @@ -8,12 +8,12 @@ package buildcraft.factory; import buildcraft.api.tools.IToolWrench; +import buildcraft.core.BlockBuildCraft; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; -import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -23,7 +23,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.World; -public class BlockFloodGate extends BlockContainer { +public class BlockFloodGate extends BlockBuildCraft { private Icon textureTop; private Icon textureBottom; @@ -31,8 +31,6 @@ public class BlockFloodGate extends BlockContainer { public BlockFloodGate(int i) { super(i, Material.iron); - setHardness(5F); - setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/factory/BlockHopper.java b/common/buildcraft/factory/BlockHopper.java index d46484b6..702989a0 100644 --- a/common/buildcraft/factory/BlockHopper.java +++ b/common/buildcraft/factory/BlockHopper.java @@ -23,7 +23,6 @@ public class BlockHopper extends BlockBuildCraft { public BlockHopper(int blockId) { super(blockId, Material.iron); - setHardness(5F); } @Override diff --git a/common/buildcraft/factory/BlockMachineRoot.java b/common/buildcraft/factory/BlockMachineRoot.java deleted file mode 100644 index d98bc802..00000000 --- a/common/buildcraft/factory/BlockMachineRoot.java +++ /dev/null @@ -1,43 +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.factory; - -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.IMachine; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; - -public abstract class BlockMachineRoot extends BlockContainer { - - protected BlockMachineRoot(int i, Material material) { - super(i, material); - setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); - setHardness(5F); - } - - @Override - public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k) { - for (int x = i - 1; x <= i + 1; ++x) { - for (int y = j - 1; y <= j + 1; ++y) { - for (int z = k - 1; z <= k + 1; ++z) { - TileEntity tile = iblockaccess.getBlockTileEntity(x, y, z); - - if (tile instanceof IMachine && ((IMachine) tile).isActive()) - return super.getBlockBrightness(iblockaccess, i, j, k) + 0.5F; - } - } - } - - return super.getBlockBrightness(iblockaccess, i, j, k); - } - -} diff --git a/common/buildcraft/factory/BlockMiningWell.java b/common/buildcraft/factory/BlockMiningWell.java index 44899641..21769331 100644 --- a/common/buildcraft/factory/BlockMiningWell.java +++ b/common/buildcraft/factory/BlockMiningWell.java @@ -11,6 +11,7 @@ package buildcraft.factory; import buildcraft.BuildCraftFactory; import buildcraft.api.core.Position; +import buildcraft.core.BlockBuildCraft; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -24,7 +25,7 @@ import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; -public class BlockMiningWell extends BlockMachineRoot { +public class BlockMiningWell extends BlockBuildCraft { Icon textureFront, textureSides, textureBack, textureTop; diff --git a/common/buildcraft/factory/BlockPlainPipe.java b/common/buildcraft/factory/BlockPlainPipe.java index 5a3f9a85..c49a6685 100644 --- a/common/buildcraft/factory/BlockPlainPipe.java +++ b/common/buildcraft/factory/BlockPlainPipe.java @@ -11,7 +11,6 @@ import buildcraft.core.CoreConstants; 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; diff --git a/common/buildcraft/factory/BlockPump.java b/common/buildcraft/factory/BlockPump.java index 51d12c58..e951ad48 100644 --- a/common/buildcraft/factory/BlockPump.java +++ b/common/buildcraft/factory/BlockPump.java @@ -8,12 +8,12 @@ package buildcraft.factory; import buildcraft.api.tools.IToolWrench; +import buildcraft.core.BlockBuildCraft; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; -import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -23,7 +23,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.World; -public class BlockPump extends BlockContainer { +public class BlockPump extends BlockBuildCraft { private Icon textureTop; private Icon textureBottom; @@ -31,8 +31,6 @@ public class BlockPump extends BlockContainer { public BlockPump(int i) { super(i, Material.iron); - setHardness(5F); - setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override diff --git a/common/buildcraft/factory/BlockQuarry.java b/common/buildcraft/factory/BlockQuarry.java index fa9d3576..3b0151bb 100644 --- a/common/buildcraft/factory/BlockQuarry.java +++ b/common/buildcraft/factory/BlockQuarry.java @@ -10,6 +10,7 @@ package buildcraft.factory; import buildcraft.BuildCraftFactory; import buildcraft.api.core.Position; import buildcraft.api.tools.IToolWrench; +import buildcraft.core.BlockBuildCraft; import buildcraft.core.Box; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; @@ -27,7 +28,7 @@ import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; -public class BlockQuarry extends BlockMachineRoot { +public class BlockQuarry extends BlockBuildCraft { Icon textureTop; Icon textureFront; @@ -38,7 +39,7 @@ public class BlockQuarry extends BlockMachineRoot { setHardness(10F); setResistance(10F); - setStepSound(soundStoneFootstep); + setStepSound(soundAnvilFootstep); } @Override diff --git a/common/buildcraft/factory/TileRefinery.java b/common/buildcraft/factory/TileRefinery.java index 47bd3236..a392f206 100644 --- a/common/buildcraft/factory/TileRefinery.java +++ b/common/buildcraft/factory/TileRefinery.java @@ -19,7 +19,6 @@ import buildcraft.api.recipes.RefineryRecipes.Recipe; import buildcraft.core.IMachine; import buildcraft.core.TileBuildCraft; import buildcraft.core.fluids.SingleUseTank; -import buildcraft.core.fluids.Tank; import buildcraft.core.fluids.TankManager; import buildcraft.core.network.PacketPayload; import buildcraft.core.network.PacketPayloadStream; diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index e2b6fd4a..bc93d289 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -15,7 +15,6 @@ import java.util.Map; import java.util.Random; import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.particle.EntityDiggingFX; @@ -38,6 +37,7 @@ import buildcraft.BuildCraftTransport; import buildcraft.api.tools.IToolWrench; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.ISolidSideTile; +import buildcraft.core.BlockBuildCraft; import buildcraft.core.BlockIndex; import buildcraft.core.CoreConstants; import buildcraft.core.proxy.CoreProxy; @@ -50,7 +50,7 @@ import cpw.mods.fml.relauncher.SideOnly; import java.util.Arrays; import net.minecraft.client.Minecraft; -public class BlockGenericPipe extends BlockContainer { +public class BlockGenericPipe extends BlockBuildCraft { static enum Part { @@ -79,7 +79,6 @@ public class BlockGenericPipe extends BlockContainer { } } private static final ForgeDirection[] DIR_VALUES = ForgeDirection.values(); - private static Random rand = new Random(); private boolean skippedFirstIconRegister; private int renderMask = 0; From 029c448712b8bbad6e0f9c3787a687c5375cf978 Mon Sep 17 00:00:00 2001 From: taelnia Date: Wed, 27 Nov 2013 00:29:55 -0500 Subject: [PATCH 29/45] Add call to onInventoryChanged to extraction pipes --- common/buildcraft/transport/pipes/PipeItemsWood.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/buildcraft/transport/pipes/PipeItemsWood.java b/common/buildcraft/transport/pipes/PipeItemsWood.java index 4149a055..b338bcc6 100644 --- a/common/buildcraft/transport/pipes/PipeItemsWood.java +++ b/common/buildcraft/transport/pipes/PipeItemsWood.java @@ -129,6 +129,8 @@ public class PipeItemsWood extends Pipe implements IPowerRec if (extracted == null) return; + tile.onInventoryChanged(); + for (ItemStack stack : extracted) { if (stack == null || stack.stackSize == 0) { powerHandler.useEnergy(1, 1, true); From ff227f9de9548e98ccbf4ba996cfebb5345f4c5b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 27 Nov 2013 06:20:08 -0800 Subject: [PATCH 30/45] Fix texture fighting on tank bottom --- common/buildcraft/factory/render/RenderTank.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/buildcraft/factory/render/RenderTank.java b/common/buildcraft/factory/render/RenderTank.java index 487f9531..0ccefafa 100644 --- a/common/buildcraft/factory/render/RenderTank.java +++ b/common/buildcraft/factory/render/RenderTank.java @@ -41,8 +41,9 @@ public class RenderTank extends TileEntitySpecialRenderer { bindTexture(FluidRenderer.getFluidSheet(liquid)); FluidRenderer.setColorForFluidStack(liquid); - GL11.glTranslatef((float) x + 0.125F, (float) y, (float) z + 0.125F); + GL11.glTranslatef((float) x + 0.125F, (float) y + 0.5F, (float) z + 0.125F); GL11.glScalef(0.75F, 0.999F, 0.75F); + GL11.glTranslatef(0, -0.5F, 0); GL11.glCallList(displayList[(int) ((float) liquid.amount / (float) (tank.tank.getCapacity()) * (FluidRenderer.DISPLAY_STAGES - 1))]); From 38a6c81ab317ebe3c19bd5b97c2521a47c8a4ff2 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 27 Nov 2013 06:21:24 -0800 Subject: [PATCH 31/45] Pipe Block shouldn't appear in creative --- common/buildcraft/transport/BlockGenericPipe.java | 1 + 1 file changed, 1 insertion(+) diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index bc93d289..0e15e145 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -86,6 +86,7 @@ public class BlockGenericPipe extends BlockBuildCraft { public BlockGenericPipe(int i) { super(i, Material.glass); setRenderAllSides(); + setCreativeTab(null); } @Override From 1527c313cd4b5a3bdbe15fb99e525cd08127b05e Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 28 Nov 2013 03:03:11 -0800 Subject: [PATCH 32/45] Allow placement of Facades over Plugs --- 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 0e15e145..73a93723 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -786,7 +786,7 @@ public class BlockGenericPipe extends BlockBuildCraft { return true; } } - if (rayTraceResult != null && (rayTraceResult.hitPart == Part.Pipe || rayTraceResult.hitPart == Part.Gate)) { + if (rayTraceResult != null && (rayTraceResult.hitPart != Part.Facade)) { if (addFacade(player, pipe, rayTraceResult.sideHit != null && rayTraceResult.sideHit != ForgeDirection.UNKNOWN ? rayTraceResult.sideHit : side)) return true; } From 3c510736537ae197a0b5d9f84ac017c1f3f60325 Mon Sep 17 00:00:00 2001 From: taelnia Date: Wed, 27 Nov 2013 00:29:55 -0500 Subject: [PATCH 33/45] Add call to onInventoryChanged to extraction pipes --- common/buildcraft/transport/pipes/PipeItemsWood.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/buildcraft/transport/pipes/PipeItemsWood.java b/common/buildcraft/transport/pipes/PipeItemsWood.java index 4149a055..b338bcc6 100644 --- a/common/buildcraft/transport/pipes/PipeItemsWood.java +++ b/common/buildcraft/transport/pipes/PipeItemsWood.java @@ -129,6 +129,8 @@ public class PipeItemsWood extends Pipe implements IPowerRec if (extracted == null) return; + tile.onInventoryChanged(); + for (ItemStack stack : extracted) { if (stack == null || stack.stackSize == 0) { powerHandler.useEnergy(1, 1, true); From 8fb31972762e1fa7665fdf39e2586399c4f8a52b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 28 Nov 2013 03:03:11 -0800 Subject: [PATCH 34/45] Allow placement of Facades over Plugs --- 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 0e15e145..73a93723 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -786,7 +786,7 @@ public class BlockGenericPipe extends BlockBuildCraft { return true; } } - if (rayTraceResult != null && (rayTraceResult.hitPart == Part.Pipe || rayTraceResult.hitPart == Part.Gate)) { + if (rayTraceResult != null && (rayTraceResult.hitPart != Part.Facade)) { if (addFacade(player, pipe, rayTraceResult.sideHit != null && rayTraceResult.sideHit != ForgeDirection.UNKNOWN ? rayTraceResult.sideHit : side)) return true; } From 17e7cb9a11b8b794d9278eb2157aa9a5dd6c8f70 Mon Sep 17 00:00:00 2001 From: ganymedes01 Date: Thu, 28 Nov 2013 00:47:47 +0000 Subject: [PATCH 35/45] Fix for Gates with ItemStacks with NBT data Closes #1344 --- .../api/gates/TriggerParameter.java | 10 ++- .../transport/gui/ContainerGateInterface.java | 85 +++++++++++-------- 2 files changed, 57 insertions(+), 38 deletions(-) diff --git a/common/buildcraft/api/gates/TriggerParameter.java b/common/buildcraft/api/gates/TriggerParameter.java index 0127bc85..6295d1cd 100644 --- a/common/buildcraft/api/gates/TriggerParameter.java +++ b/common/buildcraft/api/gates/TriggerParameter.java @@ -47,8 +47,9 @@ public class TriggerParameter implements ITriggerParameter { @Override public void writeToNBT(NBTTagCompound compound) { if (stack != null) { - compound.setInteger("itemID", stack.itemID); - compound.setInteger("itemDMG", stack.getItemDamage()); + NBTTagCompound tagCompound = new NBTTagCompound(); + stack.writeToNBT(tagCompound); + compound.setCompoundTag("stack", tagCompound); } } @@ -59,11 +60,14 @@ public class TriggerParameter implements ITriggerParameter { */ @Override public void readFromNBT(NBTTagCompound compound) { + // Legacy code to prevent existing gates from losing their contents int itemID = compound.getInteger("itemID"); - if (itemID != 0) { stack = new ItemStack(itemID, 1, compound.getInteger("itemDMG")); + return; } + + stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack")); } @Override diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java index f163e5c2..bbaf9580 100644 --- a/common/buildcraft/transport/gui/ContainerGateInterface.java +++ b/common/buildcraft/transport/gui/ContainerGateInterface.java @@ -18,21 +18,28 @@ import buildcraft.core.network.PacketCoordinates; import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketPayload; import buildcraft.core.network.PacketPayloadArrays; +import buildcraft.core.network.PacketPayloadStream; 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.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; import java.util.Comparator; import java.util.Iterator; import java.util.NavigableSet; import java.util.TreeSet; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import net.minecraft.network.packet.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeDirection; @@ -159,45 +166,53 @@ public class ContainerGateInterface extends BuildCraftContainer { * @param packet */ public void setSelection(PacketUpdate packet, boolean notify) { - PacketPayloadArrays payload = (PacketPayloadArrays) packet.payload; - int position = payload.intPayload[0]; - - setTrigger(position, ActionManager.triggers.get(payload.stringPayload[0]), notify); - setAction(position, ActionManager.actions.get(payload.stringPayload[1]), notify); - - int itemID = payload.intPayload[1]; - if (itemID <= 0) { - setTriggerParameter(position, null, notify); - return; + try { + PacketPayloadStream payload = (PacketPayloadStream) packet.payload; + DataInputStream data = payload.stream; + + int position = data.readInt(); + + setTrigger(position, ActionManager.triggers.get(data.readUTF()), notify); + setAction(position, ActionManager.actions.get(data.readUTF()), notify); + + ItemStack parameter = Packet.readItemStack(data); + if(parameter != null) { + ITriggerParameter param = new TriggerParameter(); + param.set(parameter); + setTriggerParameter(position, param, notify); + } else { + setTriggerParameter(position, null, notify); + } + } catch(IOException e) { + e.printStackTrace(); } - - ITriggerParameter param = new TriggerParameter(); - param.set(new ItemStack(itemID, payload.intPayload[2], payload.intPayload[3])); - setTriggerParameter(position, param, notify); } + + private PacketPayload getSelectionPayload(final int position) { + PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { + @Override + public void writeData(DataOutputStream data) throws IOException { + data.writeInt(position); + + if (pipe.gate.triggers[position] != null) { + data.writeUTF(pipe.gate.triggers[position].getUniqueTag()); + } else { + data.writeUTF(""); + } - private PacketPayload getSelectionPayload(int position) { - PacketPayloadArrays payload = new PacketPayloadArrays(4, 0, 2); + if (pipe.gate.actions[position] != null) { + data.writeUTF(pipe.gate.actions[position].getUniqueTag()); + } else { + data.writeUTF(""); + } - payload.intPayload[0] = position; - - if (pipe.gate.triggers[position] != null) { - payload.stringPayload[0] = pipe.gate.triggers[position].getUniqueTag(); - } else { - payload.stringPayload[0] = ""; - } - - if (pipe.gate.actions[position] != null) { - payload.stringPayload[1] = pipe.gate.actions[position].getUniqueTag(); - } else { - payload.stringPayload[1] = ""; - } - - if (pipe.gate.triggerParameters[position] != null && pipe.gate.triggerParameters[position].getItemStack() != null) { - payload.intPayload[1] = pipe.gate.triggerParameters[position].getItemStack().itemID; - payload.intPayload[2] = pipe.gate.triggerParameters[position].getItemStack().stackSize; - payload.intPayload[3] = pipe.gate.triggerParameters[position].getItemStack().getItemDamage(); - } + if (pipe.gate.triggerParameters[position] != null && pipe.gate.triggerParameters[position].getItemStack() != null) { + Packet.writeItemStack(pipe.gate.triggerParameters[position].getItemStack().copy(), data); + } else { + Packet.writeItemStack(null, data); + } + } + }); return payload; } From 6d799894357954057470caaf3aac556e18fad86e Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 29 Nov 2013 12:11:38 -0800 Subject: [PATCH 36/45] Changelog for 4.2.0 --- buildcraft_resources/changelog/4.2.0 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 buildcraft_resources/changelog/4.2.0 diff --git a/buildcraft_resources/changelog/4.2.0 b/buildcraft_resources/changelog/4.2.0 new file mode 100644 index 00000000..554673d5 --- /dev/null +++ b/buildcraft_resources/changelog/4.2.0 @@ -0,0 +1,17 @@ + +#4.2.0 + +- New: Added Emzuli Pipe, a Gate controlled Extraction Pipe. (SandGrainOne/CovertJaguar) +- Change: Fillers no longer have a "crafting" grid, and can be controlled via Gates. (CovertJaguar) +- Change: Oil Springs produce 4x as much Oil as before. +- Change: Pumps can be disabled by applying a Redstone signal. (CovertJaguar) +- Change: Allow draining of Fuel from Combustion Engines. (CovertJaguar) +- Change: Renamed Lapis Pipe to Lazuli Pipe. (CovertJaguar) +- Fix: Players can now see pipes placed by other players. (CovertJaguar) +- Fix: Block Harvesting now calls the appropriate new Forge Events. (DemoXin) +- Fix: Fixed Oil and Fuel Fluid localizations. (CovertJaguar) +- Fix: Diazuli Pipe should now better handle overflow situations similar to how the Diamond Pipe works. (CovertJaguar) +- API: Added API package and dependancy information for new FML features. Should reduce API conflicts going forward. (cpw) +- API: Rewrote Filler Pattern API. (CovertJaguar) +- API: Added a new function to the Assembly Table recipe API that supports the Ore Dictionary. (taelnia/CovertJaguar) +- API: Moved ILaserTarget to the API so that addons can now create blocks that accept power from Lasers. (CovertJaguar) \ No newline at end of file From 0cbc63e91946dc2f226ceae5d421c397c507d491 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 29 Nov 2013 17:02:10 -0800 Subject: [PATCH 37/45] Version 4.2.0 --- buildcraft_resources/build.number | 4 ++-- buildcraft_resources/changelog/4.2.0 | 5 +++-- common/buildcraft/BuildCraftCore.java | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/buildcraft_resources/build.number b/buildcraft_resources/build.number index 7097c342..4bf72182 100644 --- a/buildcraft_resources/build.number +++ b/buildcraft_resources/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sun Oct 27 08:22:33 PDT 2013 -build.number=49 +#Fri Nov 29 16:00:09 PST 2013 +build.number=50 diff --git a/buildcraft_resources/changelog/4.2.0 b/buildcraft_resources/changelog/4.2.0 index 554673d5..ed84dd02 100644 --- a/buildcraft_resources/changelog/4.2.0 +++ b/buildcraft_resources/changelog/4.2.0 @@ -3,15 +3,16 @@ - New: Added Emzuli Pipe, a Gate controlled Extraction Pipe. (SandGrainOne/CovertJaguar) - Change: Fillers no longer have a "crafting" grid, and can be controlled via Gates. (CovertJaguar) -- Change: Oil Springs produce 4x as much Oil as before. +- Change: Oil Springs produce 4x as much Oil as before. (CovertJaguar) - Change: Pumps can be disabled by applying a Redstone signal. (CovertJaguar) - Change: Allow draining of Fuel from Combustion Engines. (CovertJaguar) - Change: Renamed Lapis Pipe to Lazuli Pipe. (CovertJaguar) +- Fix: Register all remaining Items properly with FML so that they will survive a 1.6->1.7 world upgrade. (CovertJaguar) - Fix: Players can now see pipes placed by other players. (CovertJaguar) - Fix: Block Harvesting now calls the appropriate new Forge Events. (DemoXin) - Fix: Fixed Oil and Fuel Fluid localizations. (CovertJaguar) - Fix: Diazuli Pipe should now better handle overflow situations similar to how the Diamond Pipe works. (CovertJaguar) -- API: Added API package and dependancy information for new FML features. Should reduce API conflicts going forward. (cpw) +- API: Added API package and dependency information for new FML features. Should reduce API conflicts going forward. (cpw) - API: Rewrote Filler Pattern API. (CovertJaguar) - API: Added a new function to the Assembly Table recipe API that supports the Ore Dictionary. (taelnia/CovertJaguar) - API: Moved ILaserTarget to the API so that addons can now create blocks that accept power from Lasers. (CovertJaguar) \ No newline at end of file diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 313e7a1e..d11bbce8 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -80,7 +80,7 @@ import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6,1.7)", dependencies = "required-after:Forge@[9.10.0.800,)") +@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6.4,1.7)", dependencies = "required-after:Forge@[9.11.1.953,)") @NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true) public class BuildCraftCore { public static enum RenderMode { From 5dd82d7a953e56e30ded9abdd3c86a604bb12a51 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 29 Nov 2013 19:32:45 -0800 Subject: [PATCH 38/45] Don't render fluid in disconnected pipes --- .../transport/render/PipeRendererTESR.java | 77 ++++++++++--------- 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/common/buildcraft/transport/render/PipeRendererTESR.java b/common/buildcraft/transport/render/PipeRendererTESR.java index 128fad2d..1027a983 100644 --- a/common/buildcraft/transport/render/PipeRendererTESR.java +++ b/common/buildcraft/transport/render/PipeRendererTESR.java @@ -593,49 +593,54 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { boolean sides = false, above = false; - for (int i = 0; i < 6; ++i) { + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + int i = side.ordinal(); + FluidStack fluidStack = trans.renderCache[i]; - if (fluidStack != null && fluidStack.amount > 0) { - DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.worldObj); + if (fluidStack == null || fluidStack.amount <= 0) + continue; - if (d == null) { - continue; - } + if (!pipe.container.isPipeConnected(side)) + continue; - int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1)); + DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.worldObj); - GL11.glPushMatrix(); - int list = 0; + if (d == null) + continue; - switch (ForgeDirection.VALID_DIRECTIONS[i]) { - case UP: - above = true; - list = d.sideVertical[stage]; - break; - case DOWN: - GL11.glTranslatef(0, -0.75F, 0); - list = d.sideVertical[stage]; - break; - case EAST: - case WEST: - case SOUTH: - case NORTH: - sides = true; - // Yes, this is kind of ugly, but was easier than transform the coordinates above. - GL11.glTranslatef(0.5F, 0.0F, 0.5F); - GL11.glRotatef(angleY[i], 0, 1, 0); - GL11.glRotatef(angleZ[i], 0, 0, 1); - GL11.glTranslatef(-0.5F, 0.0F, -0.5F); - list = d.sideHorizontal[stage]; - break; - default: - } - bindTexture(TextureMap.locationBlocksTexture); - FluidRenderer.setColorForFluidStack(fluidStack); - GL11.glCallList(list); - GL11.glPopMatrix(); + int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1)); + + GL11.glPushMatrix(); + int list = 0; + + switch (ForgeDirection.VALID_DIRECTIONS[i]) { + case UP: + above = true; + list = d.sideVertical[stage]; + break; + case DOWN: + GL11.glTranslatef(0, -0.75F, 0); + list = d.sideVertical[stage]; + break; + case EAST: + case WEST: + case SOUTH: + case NORTH: + sides = true; + // Yes, this is kind of ugly, but was easier than transform the coordinates above. + GL11.glTranslatef(0.5F, 0.0F, 0.5F); + GL11.glRotatef(angleY[i], 0, 1, 0); + GL11.glRotatef(angleZ[i], 0, 0, 1); + GL11.glTranslatef(-0.5F, 0.0F, -0.5F); + list = d.sideHorizontal[stage]; + break; + default: } + bindTexture(TextureMap.locationBlocksTexture); + FluidRenderer.setColorForFluidStack(fluidStack); + GL11.glCallList(list); + GL11.glPopMatrix(); } // CENTER FluidStack fluidStack = trans.renderCache[ForgeDirection.UNKNOWN.ordinal()]; From ae67ae3a2c33e2150d8d8ced773efba560a47757 Mon Sep 17 00:00:00 2001 From: SandGrainOne Date: Sat, 30 Nov 2013 13:41:49 +0100 Subject: [PATCH 39/45] Corrected method names in gold and void pipe. --- common/buildcraft/transport/pipes/PipeItemsGold.java | 4 ++-- common/buildcraft/transport/pipes/PipeItemsVoid.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/buildcraft/transport/pipes/PipeItemsGold.java b/common/buildcraft/transport/pipes/PipeItemsGold.java index 1f6bf80a..d474ca2f 100644 --- a/common/buildcraft/transport/pipes/PipeItemsGold.java +++ b/common/buildcraft/transport/pipes/PipeItemsGold.java @@ -36,9 +36,9 @@ public class PipeItemsGold extends Pipe { return PipeIconProvider.TYPE.PipeItemsGold.ordinal(); } - public void handleEvent(PipeEventItem.AdjustSpeed event) { + public void eventHandler(PipeEventItem.AdjustSpeed event) { event.handled = true; TravelingItem item = event.item; - item.setSpeed(Math.min(Math.max(TransportConstants.PIPE_NORMAL_SPEED, item.getSpeed()) * 2f, TransportConstants.PIPE_NORMAL_SPEED * 20F)); + item.setSpeed(Math.min(Math.max(TransportConstants.PIPE_NORMAL_SPEED, item.getSpeed()) * 4f, TransportConstants.PIPE_NORMAL_SPEED * 20F)); } } diff --git a/common/buildcraft/transport/pipes/PipeItemsVoid.java b/common/buildcraft/transport/pipes/PipeItemsVoid.java index 37ff877a..352cf815 100644 --- a/common/buildcraft/transport/pipes/PipeItemsVoid.java +++ b/common/buildcraft/transport/pipes/PipeItemsVoid.java @@ -34,11 +34,11 @@ public class PipeItemsVoid extends Pipe { return PipeIconProvider.TYPE.PipeItemsVoid.ordinal(); } - public void handleEvent(PipeEventItem.DropItem event) { + public void eventHandler(PipeEventItem.DropItem event) { event.entity = null; } - public void handleEvent(PipeEventItem.ReachedCenter event) { + public void eventHandler(PipeEventItem.ReachedCenter event) { transport.items.scheduleRemoval(event.item); } } From 6c770a90a1dbd3d0a8401ff6c71873121752f25c Mon Sep 17 00:00:00 2001 From: ElConquistador Date: Sat, 30 Nov 2013 17:14:43 +0100 Subject: [PATCH 40/45] Added a fluid color render cache so fluids that use colors will get properly renderered in pipes --- common/buildcraft/transport/PipeTransportFluids.java | 8 ++++++++ .../transport/network/PacketFluidUpdate.java | 7 ++++++- .../transport/render/PipeRendererTESR.java | 12 ++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/transport/PipeTransportFluids.java b/common/buildcraft/transport/PipeTransportFluids.java index 4704124e..5bae1f60 100644 --- a/common/buildcraft/transport/PipeTransportFluids.java +++ b/common/buildcraft/transport/PipeTransportFluids.java @@ -141,6 +141,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler public short travelDelay = 12; public short flowRate = 10; public FluidStack[] renderCache = new FluidStack[orientations.length]; + public int[] colorRenderCache = new int[orientations.length]; public final PipeSection[] internalTanks = new PipeSection[orientations.length]; private final TransferState[] transferState = new TransferState[directions.length]; private final int[] inputPerTick = new int[directions.length]; @@ -229,6 +230,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler } FluidStack[] renderCache = this.renderCache.clone(); + int[] colorRenderCache = this.colorRenderCache.clone(); for (ForgeDirection dir : orientations) { FluidStack current = internalTanks[dir.ordinal()].getFluid(); @@ -241,6 +243,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler if (prev == null && current != null) { changed = true; renderCache[dir.ordinal()] = current.copy(); + colorRenderCache[dir.ordinal()] = current.getFluid().getColor(current); delta.set(dir.ordinal() * 3 + 0); delta.set(dir.ordinal() * 3 + 1); delta.set(dir.ordinal() * 3 + 2); @@ -250,6 +253,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler if (prev != null && current == null) { changed = true; renderCache[dir.ordinal()] = null; + colorRenderCache[dir.ordinal()] = 0xFFFFFF; delta.set(dir.ordinal() * 3 + 0); delta.set(dir.ordinal() * 3 + 1); delta.set(dir.ordinal() * 3 + 2); @@ -259,6 +263,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler if (!prev.equals(current) || initPacket) { changed = true; renderCache[dir.ordinal()] = current; + colorRenderCache[dir.ordinal()] = current.getFluid().getColor(current); delta.set(dir.ordinal() * 3 + 0); delta.set(dir.ordinal() * 3 + 1); } @@ -278,11 +283,13 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler if (persistChange) { this.renderCache = renderCache; + this.colorRenderCache = colorRenderCache; } if (changed || initPacket) { PacketFluidUpdate packet = new PacketFluidUpdate(container.xCoord, container.yCoord, container.zCoord, initPacket); packet.renderCache = renderCache; + packet.colorRenderCache = colorRenderCache; packet.delta = delta; return packet; } @@ -485,6 +492,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler internalTanks[direction.ordinal()].reset(); transferState[direction.ordinal()] = TransferState.None; renderCache[direction.ordinal()] = null; + colorRenderCache[direction.ordinal()] = 0xFFFFFF; } } } diff --git a/common/buildcraft/transport/network/PacketFluidUpdate.java b/common/buildcraft/transport/network/PacketFluidUpdate.java index a2dd745b..3da63e76 100644 --- a/common/buildcraft/transport/network/PacketFluidUpdate.java +++ b/common/buildcraft/transport/network/PacketFluidUpdate.java @@ -17,6 +17,7 @@ import net.minecraftforge.fluids.FluidStack; public class PacketFluidUpdate extends PacketCoordinates { public FluidStack[] renderCache = new FluidStack[ForgeDirection.values().length]; + public int[] colorRenderCache = new int[ForgeDirection.values().length]; public BitSet delta; public PacketFluidUpdate(int xCoord, int yCoord, int zCoord) { @@ -53,6 +54,7 @@ public class PacketFluidUpdate extends PacketCoordinates { PipeTransportFluids transLiq = ((PipeTransportFluids) pipe.pipe.transport); renderCache = transLiq.renderCache; + colorRenderCache = transLiq.colorRenderCache; byte[] dBytes = new byte[3]; data.read(dBytes); @@ -63,7 +65,8 @@ public class PacketFluidUpdate extends PacketCoordinates { for (ForgeDirection dir : ForgeDirection.values()) { if (delta.get(dir.ordinal() * 3 + 0)) { int amt = renderCache[dir.ordinal()] != null ? renderCache[dir.ordinal()].amount : 0; - renderCache[dir.ordinal()] = new FluidStack(data.readInt(),amt); + renderCache[dir.ordinal()] = new FluidStack(data.readInt(), amt); + colorRenderCache[dir.ordinal()] = data.readInt(); } if (delta.get(dir.ordinal() * 3 + 2)) { if (renderCache[dir.ordinal()] == null) { @@ -88,8 +91,10 @@ public class PacketFluidUpdate extends PacketCoordinates { if (delta.get(dir.ordinal() * 3 + 0)) { if (liquid != null) { data.writeInt(liquid.fluidID); + data.writeInt(colorRenderCache[dir.ordinal()]); } else { data.writeInt(0); + data.writeInt(0xFFFFFF); } } if (delta.get(dir.ordinal() * 3 + 2)) { diff --git a/common/buildcraft/transport/render/PipeRendererTESR.java b/common/buildcraft/transport/render/PipeRendererTESR.java index 1027a983..f8d90d0d 100644 --- a/common/buildcraft/transport/render/PipeRendererTESR.java +++ b/common/buildcraft/transport/render/PipeRendererTESR.java @@ -597,6 +597,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { int i = side.ordinal(); FluidStack fluidStack = trans.renderCache[i]; + int color = trans.colorRenderCache[i]; if (fluidStack == null || fluidStack.amount <= 0) continue; @@ -638,12 +639,16 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { default: } bindTexture(TextureMap.locationBlocksTexture); - FluidRenderer.setColorForFluidStack(fluidStack); + float red = (float) (color >> 16 & 255) / 255.0F; + float green = (float) (color >> 8 & 255) / 255.0F; + float blue = (float) (color & 255) / 255.0F; + GL11.glColor4f(red, green, blue, 1.0F); GL11.glCallList(list); GL11.glPopMatrix(); } // CENTER FluidStack fluidStack = trans.renderCache[ForgeDirection.UNKNOWN.ordinal()]; + int color = trans.colorRenderCache[ForgeDirection.UNKNOWN.ordinal()]; if (fluidStack != null && fluidStack.amount > 0) { DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.worldObj); @@ -652,7 +657,10 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1)); bindTexture(TextureMap.locationBlocksTexture); - FluidRenderer.setColorForFluidStack(fluidStack); + float red = (float) (color >> 16 & 255) / 255.0F; + float green = (float) (color >> 8 & 255) / 255.0F; + float blue = (float) (color & 255) / 255.0F; + GL11.glColor4f(red, green, blue, 1.0F); if (above) { GL11.glCallList(d.centerVertical[stage]); From 0dd0c6c88511504bd233ec61063389fda91b6cfb Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 30 Nov 2013 08:49:10 -0800 Subject: [PATCH 41/45] Various minor performance tweaks --- common/buildcraft/core/utils/MathUtils.java | 20 +++++++++++++ .../transport/BlockGenericPipe.java | 1 + common/buildcraft/transport/Gate.java | 2 +- common/buildcraft/transport/Pipe.java | 30 +++++++++++++------ .../transport/PipeTransportItems.java | 25 +++++++--------- .../buildcraft/transport/TileGenericPipe.java | 5 +++- .../triggers/TriggerRedstoneInput.java | 2 +- 7 files changed, 58 insertions(+), 27 deletions(-) create mode 100644 common/buildcraft/core/utils/MathUtils.java diff --git a/common/buildcraft/core/utils/MathUtils.java b/common/buildcraft/core/utils/MathUtils.java new file mode 100644 index 00000000..4a676d97 --- /dev/null +++ b/common/buildcraft/core/utils/MathUtils.java @@ -0,0 +1,20 @@ +/* + * 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; + +/** + * + * @author CovertJaguar + */ +public class MathUtils { + + public static double clamp(double value, double min, double max) { + return value < min ? min : (value > max ? max : value); + } +} diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index 73a93723..cd056b73 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -609,6 +609,7 @@ public class BlockGenericPipe extends BlockBuildCraft { if (isValid(pipe)) { pipe.container.scheduleNeighborChange(); + pipe.container.redstonePowered = world.isBlockIndirectlyGettingPowered(x, y, z); } } diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java index 3e4ffcf1..66cfac71 100644 --- a/common/buildcraft/transport/Gate.java +++ b/common/buildcraft/transport/Gate.java @@ -190,7 +190,7 @@ public abstract class Gate { boolean[] oldBroadcastSignal = broadcastSignal; broadcastRedstone = false; - broadcastSignal = new boolean[]{false, false, false, false}; + broadcastSignal = new boolean[4]; // Tell the gate to prepare for resolving actions. (Disable pulser) startResolution(); diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index d0693a64..ad45c878 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -67,6 +67,13 @@ public abstract class Pipe implements IPipe, IDropContr transport.setTile((TileGenericPipe) tile); } +// public final void handlePipeEvent(PipeEvent event) { +// try { +// Method method = getClass().getDeclaredMethod("eventHandler", event.getClass()); +// method.invoke(this, event); +// } catch (Exception ex) { +// } +// } private static class EventHandler { public final Method method; @@ -83,15 +90,8 @@ public abstract class Pipe implements IPipe, IDropContr eventHandlers.put(getClass(), handlerMap); } EventHandler handler = handlerMap.get(event.getClass()); - if (handler == null) { - try { - Method method = getClass().getDeclaredMethod("eventHandler", event.getClass()); - handler = new EventHandler(method); - } catch (Exception ex) { - handler = new EventHandler(null); - } - handlerMap.put(event.getClass(), handler); - } + if (handler == null) + handler = makeEventHandler(event, handlerMap); if (handler.method == null) return; try { @@ -100,6 +100,18 @@ public abstract class Pipe implements IPipe, IDropContr } } + private EventHandler makeEventHandler(PipeEvent event, Map, EventHandler> handlerMap) { + EventHandler handler; + try { + Method method = getClass().getDeclaredMethod("eventHandler", event.getClass()); + handler = new EventHandler(method); + } catch (Exception ex) { + handler = new EventHandler(null); + } + handlerMap.put(event.getClass(), handler); + return handler; + } + public boolean blockActivated(EntityPlayer entityplayer) { return false; } diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index ca61cfc2..3fc178a1 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -19,6 +19,7 @@ import buildcraft.core.network.PacketIds; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BlockUtil; +import buildcraft.core.utils.MathUtils; import buildcraft.transport.network.PacketPipeTransportContent; import buildcraft.transport.network.PacketPipeTransportNBT; import buildcraft.transport.network.PacketSimpleId; @@ -33,12 +34,12 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.EnumSet; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; 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; @@ -47,6 +48,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.packet.Packet; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; import net.minecraftforge.common.ForgeDirection; public class PipeTransportItems extends PipeTransport { @@ -151,17 +153,9 @@ public class PipeTransportItems extends PipeTransport { } private void readjustPosition(TravelingItem item) { - double x = item.xCoord; - double y = item.yCoord; - double z = item.zCoord; - - x = Math.max(x, container.xCoord + 0.01); - y = Math.max(y, container.yCoord + 0.01); - z = Math.max(z, container.zCoord + 0.01); - - x = Math.min(x, container.xCoord + 0.99); - y = Math.min(y, container.yCoord + 0.99); - z = Math.min(z, container.zCoord + 0.99); + double x = MathUtils.clamp(item.xCoord, container.xCoord + 0.01, container.xCoord + 0.99); + double y = MathUtils.clamp(item.yCoord, container.yCoord + 0.01, container.yCoord + 0.99); + double z = MathUtils.clamp(item.zCoord, container.zCoord + 0.01, container.zCoord + 0.99); if (item.input != ForgeDirection.UP && item.input != ForgeDirection.DOWN) { y = container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()); @@ -284,9 +278,10 @@ public class PipeTransportItems extends PipeTransport { item.blacklist.add(item.input.getOpposite()); - for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { - if (item.blacklist.contains(o)) - continue; + EnumSet sides = EnumSet.complementOf(item.blacklist); + sides.remove(ForgeDirection.UNKNOWN); + + for (ForgeDirection o : sides) { if (container.pipe.outputOpen(o) && canReceivePipeObjects(o, item)) result.add(o); } diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 92f61a33..39c73b10 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -89,6 +89,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui private boolean blockNeighborChange = false; private boolean refreshRenderState = false; private boolean pipeBound = false; + public boolean redstonePowered = false; private int[] facadeBlocks = new int[ForgeDirection.VALID_DIRECTIONS.length]; private int[] facadeMeta = new int[ForgeDirection.VALID_DIRECTIONS.length]; private boolean[] plugs = new boolean[ForgeDirection.VALID_DIRECTIONS.length]; @@ -99,6 +100,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); + nbt.setBoolean("redstonePowered", redstonePowered); if (pipe != null) { nbt.setInteger("pipeId", pipe.itemID); @@ -117,7 +119,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - + redstonePowered = nbt.getBoolean("redstonePowered"); + coreState.pipeId = nbt.getInteger("pipeId"); pipe = BlockGenericPipe.createPipe(coreState.pipeId); diff --git a/common/buildcraft/transport/triggers/TriggerRedstoneInput.java b/common/buildcraft/transport/triggers/TriggerRedstoneInput.java index 11c2af88..2aca6efc 100644 --- a/common/buildcraft/transport/triggers/TriggerRedstoneInput.java +++ b/common/buildcraft/transport/triggers/TriggerRedstoneInput.java @@ -44,7 +44,7 @@ public class TriggerRedstoneInput extends BCTrigger implements ITriggerPipe { } private boolean isBeingPowered(Pipe pipe) { - return pipe.container.worldObj.isBlockIndirectlyGettingPowered(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); + return pipe.container.redstonePowered; } @Override From 1f65388c804c9aea2d24ece7f8e2c2ee3253f248 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 30 Nov 2013 13:57:25 -0800 Subject: [PATCH 42/45] Another perf tweak --- common/buildcraft/core/utils/MathUtils.java | 4 ++++ common/buildcraft/transport/pipes/PipeItemsGold.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/common/buildcraft/core/utils/MathUtils.java b/common/buildcraft/core/utils/MathUtils.java index 4a676d97..ad6432fe 100644 --- a/common/buildcraft/core/utils/MathUtils.java +++ b/common/buildcraft/core/utils/MathUtils.java @@ -14,6 +14,10 @@ package buildcraft.core.utils; */ public class MathUtils { + public static float clamp(float value, float min, float max) { + return value < min ? min : (value > max ? max : value); + } + public static double clamp(double value, double min, double max) { return value < min ? min : (value > max ? max : value); } diff --git a/common/buildcraft/transport/pipes/PipeItemsGold.java b/common/buildcraft/transport/pipes/PipeItemsGold.java index d474ca2f..9c5bfa1e 100644 --- a/common/buildcraft/transport/pipes/PipeItemsGold.java +++ b/common/buildcraft/transport/pipes/PipeItemsGold.java @@ -9,6 +9,7 @@ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; +import buildcraft.core.utils.MathUtils; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; @@ -39,6 +40,6 @@ public class PipeItemsGold extends Pipe { public void eventHandler(PipeEventItem.AdjustSpeed event) { event.handled = true; TravelingItem item = event.item; - item.setSpeed(Math.min(Math.max(TransportConstants.PIPE_NORMAL_SPEED, item.getSpeed()) * 4f, TransportConstants.PIPE_NORMAL_SPEED * 20F)); + item.setSpeed(MathUtils.clamp(item.getSpeed() * 4F, TransportConstants.PIPE_NORMAL_SPEED * 4F, TransportConstants.PIPE_NORMAL_SPEED * 20F)); } } From b9b2f1a2380b0a456ad0f364e8f3de3b45e3a4ec Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 30 Nov 2013 14:08:38 -0800 Subject: [PATCH 43/45] Add some API failsafes --- common/buildcraft/BuildCraftBuilders.java | 28 ++++++++++++---------- common/buildcraft/BuildCraftTransport.java | 20 +++++++++------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index 26096fd8..6b64ef73 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -27,6 +27,7 @@ import buildcraft.api.bptblocks.BptBlockSign; import buildcraft.api.bptblocks.BptBlockStairs; import buildcraft.api.bptblocks.BptBlockWallSide; import buildcraft.api.filler.FillerManager; +import buildcraft.api.filler.IFillerPattern; import buildcraft.api.gates.ActionManager; import buildcraft.builders.BlockArchitect; import buildcraft.builders.BlockBlueprintLibrary; @@ -34,7 +35,6 @@ import buildcraft.builders.BlockBuilder; import buildcraft.builders.BlockFiller; import buildcraft.builders.BlockMarker; import buildcraft.builders.BlockPathMarker; -import buildcraft.builders.BuilderProxyClient; import buildcraft.builders.EventHandlerBuilders; import buildcraft.builders.filler.pattern.PatternFill; import buildcraft.builders.filler.pattern.PatternPyramid; @@ -64,12 +64,12 @@ import buildcraft.core.Version; import buildcraft.core.blueprints.BptPlayerIndex; import buildcraft.core.blueprints.BptRootIndex; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.BCLog; 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.FMLServerStoppingEvent; import cpw.mods.fml.common.network.NetworkMod; @@ -82,7 +82,6 @@ import java.io.IOException; import java.util.LinkedList; import java.util.TreeMap; import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -288,16 +287,21 @@ public class BuildCraftBuilders { MinecraftForge.EVENT_BUS.register(this); // Create filler registry - FillerManager.registry = new FillerRegistry(); + try { + FillerManager.registry = new FillerRegistry(); - // INIT FILLER PATTERNS - FillerManager.registry.addPattern(PatternFill.INSTANCE); - FillerManager.registry.addPattern(new PatternFlatten()); - FillerManager.registry.addPattern(new PatternHorizon()); - FillerManager.registry.addPattern(new PatternClear()); - FillerManager.registry.addPattern(new PatternBox()); - FillerManager.registry.addPattern(new PatternPyramid()); - FillerManager.registry.addPattern(new PatternStairs()); + // INIT FILLER PATTERNS + FillerManager.registry.addPattern(PatternFill.INSTANCE); + FillerManager.registry.addPattern(new PatternFlatten()); + FillerManager.registry.addPattern(new PatternHorizon()); + FillerManager.registry.addPattern(new PatternClear()); + FillerManager.registry.addPattern(new PatternBox()); + FillerManager.registry.addPattern(new PatternPyramid()); + FillerManager.registry.addPattern(new PatternStairs()); + } catch (Error error) { + BCLog.logErrorAPI("Buildcraft", error, IFillerPattern.class); + throw error; + } ActionManager.registerActionProvider(new BuildersActionProvider()); } diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 840969c3..6a6199de 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -8,6 +8,7 @@ package buildcraft; import buildcraft.api.core.IIconProvider; +import buildcraft.api.filler.IFillerPattern; import buildcraft.api.gates.ActionManager; import buildcraft.api.recipes.AssemblyRecipe; import buildcraft.api.transport.IExtractionHandler; @@ -20,6 +21,7 @@ import buildcraft.core.Version; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.triggers.BCAction; import buildcraft.core.triggers.BCTrigger; +import buildcraft.core.utils.BCLog; import buildcraft.core.utils.EnumColor; import buildcraft.transport.BlockFilteredBuffer; import buildcraft.transport.BlockGenericPipe; @@ -177,11 +179,9 @@ public class BuildCraftTransport { public static BCAction actionExtractionPresetBlue = new ActionExtractionPreset(-1, EnumColor.BLUE); public static BCAction actionExtractionPresetGreen = new ActionExtractionPreset(-1, EnumColor.GREEN); public static BCAction actionExtractionPresetYellow = new ActionExtractionPreset(-1, EnumColor.YELLOW); - public IIconProvider pipeIconProvider = new PipeIconProvider(); public IIconProvider gateIconProvider = new GateIconProvider(); public IIconProvider wireIconProvider = new WireIconProvider(); - @Instance("BuildCraft|Transport") public static BuildCraftTransport instance; @@ -293,7 +293,7 @@ public class BuildCraftTransport { pipeItemsSandstone = buildPipe(DefaultProps.PIPE_ITEMS_SANDSTONE_ID, PipeItemsSandstone.class, "Sandstone Transport Pipe", Block.sandStone, Block.glass, Block.sandStone); pipeItemsVoid = buildPipe(DefaultProps.PIPE_ITEMS_VOID_ID, PipeItemsVoid.class, "Void Transport Pipe", "dyeBlack", Block.glass, Item.redstone); pipeItemsEmzuli = buildPipe(DefaultProps.PIPE_ITEMS_EMZULI_ID, PipeItemsEmzuli.class, "Emzuli Transport Pipe", Block.blockLapis, Block.glass, Item.emerald); - + pipeFluidsWood = buildPipe(DefaultProps.PIPE_LIQUIDS_WOOD_ID, PipeFluidsWood.class, "Wooden Waterproof Pipe", pipeWaterproof, pipeItemsWood); pipeFluidsCobblestone = buildPipe(DefaultProps.PIPE_LIQUIDS_COBBLESTONE_ID, PipeFluidsCobblestone.class, "Cobblestone Waterproof Pipe", pipeWaterproof, pipeItemsCobblestone); pipeFluidsStone = buildPipe(DefaultProps.PIPE_LIQUIDS_STONE_ID, PipeFluidsStone.class, "Stone Waterproof Pipe", pipeWaterproof, pipeItemsStone); @@ -449,11 +449,15 @@ public class BuildCraftTransport { GameRegistry.addRecipe(facadeItem.new FacadeRecipe()); // Assembly table recipes, moved from PreInit phase to Init, all mods should be done adding to the OreDictionary by now - AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(redPipeWire, 8), "dyeRed", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); - AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(bluePipeWire, 8), "dyeBlue", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); - AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(greenPipeWire, 8), "dyeGreen", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); - AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(yellowPipeWire, 8), "dyeYellow", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); - AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8))); + try { + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(redPipeWire, 8), "dyeRed", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(bluePipeWire, 8), "dyeBlue", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(greenPipeWire, 8), "dyeGreen", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(yellowPipeWire, 8), "dyeYellow", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron))); + AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8))); + } catch (Error error) { + BCLog.logErrorAPI("Buildcraft", error, AssemblyRecipe.class); + } } @EventHandler From fb523870941f1de0f875a16db6d736bfff059908 Mon Sep 17 00:00:00 2001 From: ElConquistador Date: Sun, 1 Dec 2013 08:18:19 +0100 Subject: [PATCH 44/45] Added colorRenderCache to Tank and Refinery --- common/buildcraft/core/fluids/Tank.java | 1 + .../buildcraft/core/fluids/TankManager.java | 8 ++++++-- .../factory/render/RenderRefinery.java | 19 ++++++++++++++++--- .../buildcraft/factory/render/RenderTank.java | 6 +++++- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/common/buildcraft/core/fluids/Tank.java b/common/buildcraft/core/fluids/Tank.java index 1922e79a..e13e5014 100644 --- a/common/buildcraft/core/fluids/Tank.java +++ b/common/buildcraft/core/fluids/Tank.java @@ -23,6 +23,7 @@ import net.minecraftforge.fluids.FluidTank; public class Tank extends FluidTank { private final String name; + public int colorRenderCache = 0xFFFFFF; public Tank(String name, int capacity, TileEntity tile) { super(capacity); diff --git a/common/buildcraft/core/fluids/TankManager.java b/common/buildcraft/core/fluids/TankManager.java index 0b14f078..39d4abbf 100644 --- a/common/buildcraft/core/fluids/TankManager.java +++ b/common/buildcraft/core/fluids/TankManager.java @@ -115,6 +115,7 @@ public class TankManager extends ForwardingList implements IF if (fluidStack != null && fluidStack.getFluid() != null) { data.writeShort(fluidStack.getFluid().getID()); data.writeInt(fluidStack.amount); + data.writeInt(fluidStack.getFluid().getColor(fluidStack)); } else { data.writeShort(-1); } @@ -125,10 +126,13 @@ public class TankManager extends ForwardingList implements IF public void readData(DataInputStream data) throws IOException { for (Tank tank : tanks) { int fluidId = data.readShort(); - if (fluidId > 0) + if (fluidId > 0) { tank.setFluid(new FluidStack(fluidId, data.readInt())); - else + tank.colorRenderCache = data.readInt(); + } else { tank.setFluid(null); + tank.colorRenderCache = 0xFFFFFF; + } } } } diff --git a/common/buildcraft/factory/render/RenderRefinery.java b/common/buildcraft/factory/render/RenderRefinery.java index 4f2a19ba..c3767b31 100644 --- a/common/buildcraft/factory/render/RenderRefinery.java +++ b/common/buildcraft/factory/render/RenderRefinery.java @@ -70,6 +70,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent private void render(TileRefinery tile, double x, double y, double z) { FluidStack liquid1 = null, liquid2 = null, liquidResult = null; + int color1 = 0xFFFFFF, color2 = 0xFFFFFF, colorResult = 0xFFFFFF; float anim = 0; int angle = 0; @@ -77,14 +78,17 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent if (tile != null) { if (tile.tank1.getFluid() != null) { liquid1 = tile.tank1.getFluid(); + color1 = tile.tank1.colorRenderCache; } if (tile.tank2.getFluid() != null) { liquid2 = tile.tank2.getFluid(); + color2 = tile.tank2.colorRenderCache; } if (tile.result.getFluid() != null) { liquidResult = tile.result.getFluid(); + colorResult = tile.result.colorRenderCache; } anim = tile.getAnimationStage(); @@ -183,7 +187,10 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent if (list1 != null) { bindTexture(FluidRenderer.getFluidSheet(liquid1)); - FluidRenderer.setColorForFluidStack(liquid1); + float red = (float) (color1 >> 16 & 255) / 255.0F; + float green = (float) (color1 >> 8 & 255) / 255.0F; + float blue = (float) (color1 & 255) / 255.0F; + GL11.glColor4f(red, green, blue, 1.0F); GL11.glCallList(list1[getDisplayListIndex(tile.tank1)]); } } @@ -195,7 +202,10 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent GL11.glPushMatrix(); GL11.glTranslatef(0, 0, 1); bindTexture(FluidRenderer.getFluidSheet(liquid2)); - FluidRenderer.setColorForFluidStack(liquid2); + float red = (float) (color2 >> 16 & 255) / 255.0F; + float green = (float) (color2 >> 8 & 255) / 255.0F; + float blue = (float) (color2 & 255) / 255.0F; + GL11.glColor4f(red, green, blue, 1.0F); GL11.glCallList(list2[getDisplayListIndex(tile.tank2)]); GL11.glPopMatrix(); } @@ -209,7 +219,10 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent GL11.glPushMatrix(); GL11.glTranslatef(1, 0, 0.5F); bindTexture(FluidRenderer.getFluidSheet(liquidResult)); - FluidRenderer.setColorForFluidStack(liquidResult); + float red = (float) (colorResult >> 16 & 255) / 255.0F; + float green = (float) (colorResult >> 8 & 255) / 255.0F; + float blue = (float) (colorResult & 255) / 255.0F; + GL11.glColor4f(red, green, blue, 1.0F); 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 0ccefafa..e53afa78 100644 --- a/common/buildcraft/factory/render/RenderTank.java +++ b/common/buildcraft/factory/render/RenderTank.java @@ -22,6 +22,7 @@ public class RenderTank extends TileEntitySpecialRenderer { TileTank tank = ((TileTank) tileentity); FluidStack liquid = tank.tank.getFluid(); + int color = tank.tank.colorRenderCache; if (liquid == null || liquid.amount <= 0) { return; } @@ -39,7 +40,10 @@ public class RenderTank extends TileEntitySpecialRenderer { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); bindTexture(FluidRenderer.getFluidSheet(liquid)); - FluidRenderer.setColorForFluidStack(liquid); + float red = (float) (color >> 16 & 255) / 255.0F; + float green = (float) (color >> 8 & 255) / 255.0F; + float blue = (float) (color & 255) / 255.0F; + GL11.glColor4f(red, green, blue, 1.0F); GL11.glTranslatef((float) x + 0.125F, (float) y + 0.5F, (float) z + 0.125F); GL11.glScalef(0.75F, 0.999F, 0.75F); From 3776286e2e9954b9e3314494edd1d64de0820e8d Mon Sep 17 00:00:00 2001 From: ElConquistador Date: Sun, 1 Dec 2013 19:48:08 +0100 Subject: [PATCH 45/45] Combustion Engine also now uses the colorRenderCache --- common/buildcraft/energy/TileEngineIron.java | 17 ++++++++++++---- .../energy/gui/GuiCombustionEngine.java | 20 ++++++++++++------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index 5595df44..fd05b1d6 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -11,7 +11,6 @@ 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; @@ -45,8 +44,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 = new Tank("tankFuel", MAX_LIQUID, this); - private Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this); + public Tank tankFuel = new Tank("tankFuel", MAX_LIQUID, this); + public Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this); private TankManager tankManager = new TankManager(); private Fuel currentFuel = null; public int penaltyCooling = 0; @@ -292,7 +291,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan tankFuel.getFluid().amount = value; } break; - // Fluid coolant amount + // Fluid Coolant amount case 18: if (tankCoolant.getFluid() == null) { tankCoolant.setFluid(new FluidStack(0, value)); @@ -300,6 +299,14 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan tankCoolant.getFluid().amount = value; } break; + //Fluid Fuel color + case 19: + tankFuel.colorRenderCache = value; + break; + //Fluid Coolant color + case 20: + tankCoolant.colorRenderCache = value; + break; } } @@ -310,6 +317,8 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan iCrafting.sendProgressBarUpdate(containerEngine, 16, tankCoolant.getFluid() != null ? tankCoolant.getFluid().fluidID : 0); iCrafting.sendProgressBarUpdate(containerEngine, 17, tankFuel.getFluid() != null ? tankFuel.getFluid().amount : 0); iCrafting.sendProgressBarUpdate(containerEngine, 18, tankCoolant.getFluid() != null ? tankCoolant.getFluid().amount : 0); + iCrafting.sendProgressBarUpdate(containerEngine, 19, tankFuel.colorRenderCache); + iCrafting.sendProgressBarUpdate(containerEngine, 20, tankCoolant.colorRenderCache); } @Override diff --git a/common/buildcraft/energy/gui/GuiCombustionEngine.java b/common/buildcraft/energy/gui/GuiCombustionEngine.java index 7bd5c854..b89b2b61 100644 --- a/common/buildcraft/energy/gui/GuiCombustionEngine.java +++ b/common/buildcraft/energy/gui/GuiCombustionEngine.java @@ -7,16 +7,16 @@ */ package buildcraft.energy.gui; +import org.lwjgl.opengl.GL11; + 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.fluids.Tank; import buildcraft.core.utils.StringUtils; import buildcraft.energy.TileEngineIron; import buildcraft.energy.TileEngineWithInventory; @@ -47,15 +47,15 @@ public class GuiCombustionEngine extends GuiEngine { TileEngineIron engine = (TileEngineIron) tile; if (engine.getScaledBurnTime(58) > 0) { - displayGauge(j, k, 19, 104, engine.getScaledBurnTime(58), engine.getFuel()); + displayGauge(j, k, 19, 104, engine.getScaledBurnTime(58), engine.getFuel(), engine.tankFuel); } if (engine.getScaledCoolant(58) > 0) { - displayGauge(j, k, 19, 122, engine.getScaledCoolant(58), engine.getCoolant()); + displayGauge(j, k, 19, 122, engine.getScaledCoolant(58), engine.getCoolant(), engine.tankCoolant); } } - private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid) { + private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid, Tank tank) { if (liquid == null) { return; } @@ -63,11 +63,16 @@ public class GuiCombustionEngine extends GuiEngine { Icon liquidIcon = null; Fluid fluid = liquid.getFluid(); + int color = tank.colorRenderCache; if (fluid != null && fluid.getStillIcon() != null) { liquidIcon = fluid.getStillIcon(); } mc.renderEngine.bindTexture(BLOCK_TEXTURE); - + float red = (float) (color >> 16 & 255) / 255.0F; + float green = (float) (color >> 8 & 255) / 255.0F; + float blue = (float) (color & 255) / 255.0F; + GL11.glColor4f(red, green, blue, 1.0F); + if (liquidIcon != null) { while (true) { int x; @@ -89,6 +94,7 @@ public class GuiCombustionEngine extends GuiEngine { } } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(TEXTURE); drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60); }