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
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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 00000000..d8a7105f
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/box.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/fillAll.png b/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/fill.png
similarity index 100%
rename from buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/fillAll.png
rename to buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/fill.png
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/pyramid.png b/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/pyramid.png
index c3984038..466ce7fd 100644
Binary files a/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/pyramid.png and b/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/pyramid.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/stairs.png b/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/stairs.png
index a964597c..af83c0ee 100644
Binary files a/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/stairs.png and b/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/stairs.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/walls.png b/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/walls.png
deleted file mode 100644
index d717bb8b..00000000
Binary files a/buildcraft_resources/assets/buildcraft/textures/blocks/fillerPatterns/walls.png and /dev/null differ
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 00000000..0e3626ce
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllEmzuli_solid.png differ
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 00000000..ee08f116
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_item.png differ
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 00000000..eedfb748
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsEmzuli_standard.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/buttons.png b/buildcraft_resources/assets/buildcraft/textures/gui/buttons.png
index 967c6b4e..4b3d069c 100644
Binary files a/buildcraft_resources/assets/buildcraft/textures/gui/buttons.png and b/buildcraft_resources/assets/buildcraft/textures/gui/buttons.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/filler.png b/buildcraft_resources/assets/buildcraft/textures/gui/filler.png
index 8cc126aa..b6440948 100644
Binary files a/buildcraft_resources/assets/buildcraft/textures/gui/filler.png and b/buildcraft_resources/assets/buildcraft/textures/gui/filler.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/logemerald_pipe_gui.png b/buildcraft_resources/assets/buildcraft/textures/gui/logemerald_pipe_gui.png
new file mode 100644
index 00000000..3d62f71e
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/gui/logemerald_pipe_gui.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/pipe_emzuli.png b/buildcraft_resources/assets/buildcraft/textures/gui/pipe_emzuli.png
new file mode 100644
index 00000000..3fd376d2
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/gui/pipe_emzuli.png differ
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 00000000..9162f16d
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_blue.png differ
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 00000000..84f34b2c
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_green.png differ
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 00000000..6c639952
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_red.png differ
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 00000000..3db999b2
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/extraction_preset_yellow.png differ
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
new file mode 100644
index 00000000..ed84dd02
--- /dev/null
+++ b/buildcraft_resources/changelog/4.2.0
@@ -0,0 +1,18 @@
+
+#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. (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 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/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties
index 4512f796..d165edea 100644
--- a/buildcraft_resources/lang/buildcraft/en_US.properties
+++ b/buildcraft_resources/lang/buildcraft/en_US.properties
@@ -2,6 +2,34 @@
chat.pipe.power.iron.mode=Switched to %d MJ/t limit
+color.black=Black
+color.blue=Blue
+color.brown=Brown
+color.cyan=Cyan
+color.gray=Gray
+color.green=Green
+color.light.blue=Light Blue
+color.light.gray=Light Gray
+color.lime=Lime
+color.magenta=Magenta
+color.orange=Orange
+color.pink=Pink
+color.purple=Purple
+color.red=Red
+color.white=White
+color.yellow=Yellow
+
+fillerpattern.clear=Clear
+fillerpattern.fill=Fill
+fillerpattern.flatten=Flatten
+fillerpattern.horizon=Horizon
+fillerpattern.pyramid=Pyramid
+fillerpattern.stairs=Stairs
+fillerpattern.box=Box
+
+fluid.oil=Oil
+fluid.fuel=Fuel
+
gate.pipe.empty=Pipe Empty
gate.pipe.containsItems=Items Traversing
gate.pipe.containsFluids=Fluid Traversing
@@ -12,6 +40,8 @@ gate.engine.blue=Engine Blue
gate.engine.green=Engine Green
gate.engine.yellow=Engine Yellow
gate.engine.red=Engine Red
+gate.pipe.item.color=Paint Items %s
+
gui.building.resources=Building Resources
gui.del=Del
gui.filling.resources=Filling Resources
@@ -30,6 +60,10 @@ gui.pipes.emerald.blocking=Blocking
gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing
gui.pipes.emerald.nonblocking=Non Blocking
gui.pipes.emerald.nonblocking.tip=Extraction continues with the next element in filter if one element is missing
+gui.pipes.emzuli.title=Extraction Presets
+gui.pipes.emzuli.paint=Paint Items %s
+gui.pipes.emzuli.nopaint=Don't Paint Items
+
item.bucketFuel=Fuel Bucket
item.bucketOil=Oil Bucket
item.woodenGearItem=Wood Gear
@@ -73,8 +107,9 @@ 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
item.PipeFluidsCobblestone=Cobblestone Fluid Pipe
item.PipeFluidsStone=Stone Fluid Pipe
@@ -149,6 +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.PipeItemsEmzuli=Gate controlled extraction pipe
tip.PipePowerWood=Power Input Pipe
tip.PipePowerIron=Selectable Limiter Pipe
tip.PipeStructureCobblestone=Support pipe
diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java
index b9c1d059..5892aeba 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.filler.IFillerPattern;
+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.ItemBlueprintStandard;
@@ -54,13 +54,17 @@ 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;
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;
@@ -78,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;
@@ -105,6 +108,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 +116,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 +209,6 @@ public class BuildCraftBuilders {
new BptBlockWallSide(markerBlock.blockID);
new BptBlockWallSide(pathMarkerBlock.blockID);
- new BptBlockFiller(fillerBlock.blockID);
if (BuildCraftCore.loadDefaultRecipes) {
loadRecipes();
@@ -217,7 +217,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 +286,30 @@ 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
+ try {
+ 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());
+ } catch (Error error) {
+ BCLog.logErrorAPI("Buildcraft", error, IFillerPattern.class);
+ throw error;
+ }
+
+ 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 +317,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 +401,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/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java
index e026e847..29657faf 100644
--- a/common/buildcraft/BuildCraftCore.java
+++ b/common/buildcraft/BuildCraftCore.java
@@ -81,7 +81,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 {
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/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java
index 309cd3fe..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;
@@ -54,6 +56,7 @@ import buildcraft.transport.pipes.PipeItemsDiamond;
import buildcraft.transport.pipes.PipeItemsEmerald;
import buildcraft.transport.pipes.PipeItemsGold;
import buildcraft.transport.pipes.PipeItemsIron;
+import buildcraft.transport.pipes.PipeItemsEmzuli;
import buildcraft.transport.pipes.PipeItemsLapis;
import buildcraft.transport.pipes.PipeItemsObsidian;
import buildcraft.transport.pipes.PipeItemsQuartz;
@@ -71,6 +74,7 @@ import buildcraft.transport.pipes.PipePowerStone;
import buildcraft.transport.pipes.PipePowerWood;
import buildcraft.transport.pipes.PipeStructureCobblestone;
import buildcraft.transport.triggers.ActionEnergyPulser;
+import buildcraft.transport.triggers.ActionExtractionPreset;
import buildcraft.transport.triggers.ActionPipeColor;
import buildcraft.transport.triggers.ActionPipeDirection;
import buildcraft.transport.triggers.ActionPowerLimiter;
@@ -126,6 +130,7 @@ public class BuildCraftTransport {
public static Item pipeItemsDaizuli;
public static Item pipeItemsVoid;
public static Item pipeItemsSandstone;
+ public static Item pipeItemsEmzuli;
public static Item pipeFluidsWood;
public static Item pipeFluidsCobblestone;
public static Item pipeFluidsStone;
@@ -170,11 +175,15 @@ public class BuildCraftTransport {
public static BCAction[] actionPipeColor = new BCAction[16];
public static BCAction[] actionPipeDirection = new BCAction[16];
public static BCAction[] actionPowerLimiter = new BCAction[7];
- @Instance("BuildCraft|Transport")
- public static BuildCraftTransport instance;
+ public static BCAction actionExtractionPresetRed = new ActionExtractionPreset(-1, EnumColor.RED);
+ 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;
private static class PipeRecipe {
@@ -266,11 +275,10 @@ 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);
- // Fixing retro-compatiblity
pipeItemsWood = buildPipe(DefaultProps.PIPE_ITEMS_WOOD_ID, PipeItemsWood.class, "Wooden Transport Pipe", "plankWood", Block.glass, "plankWood");
pipeItemsEmerald = buildPipe(DefaultProps.PIPE_ITEMS_EMERALD_ID, PipeItemsEmerald.class, "Emerald Transport Pipe", Item.emerald, Block.glass, Item.emerald);
pipeItemsCobblestone = buildPipe(DefaultProps.PIPE_ITEMS_COBBLESTONE_ID, PipeItemsCobblestone.class, "Cobblestone Transport Pipe", "cobblestone", Block.glass, "cobblestone");
@@ -284,6 +292,7 @@ public class BuildCraftTransport {
pipeItemsDaizuli = buildPipe(DefaultProps.PIPE_ITEMS_DAIZULI_ID, PipeItemsDaizuli.class, "Daizuli Transport Pipe", Block.blockLapis, Block.glass, Item.diamond);
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);
@@ -313,32 +322,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 +366,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();
}
@@ -378,7 +376,7 @@ public class BuildCraftTransport {
// Register connection handler
// MinecraftForge.registerConnectionHandler(new ConnectionHandler());
- // Register gui handler
+ // Register GUI handler
// MinecraftForge.setGuiHandler(mod_BuildCraftTransport.instance, new GuiHandler());
TransportProxy.proxy.registerTileEntities();
@@ -422,7 +420,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);
}
@@ -436,7 +434,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);
}
@@ -449,11 +447,22 @@ 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
+ 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
public void processIMCRequests(IMCEvent event) {
- InterModComms.processIMC(event);
+ InterModComms.processIMC(event);
}
public static Item buildPipe(int defaultID, Class extends Pipe> clas, String descr, Object... ingredients) {
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 extends IAction> 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/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() {
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/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/api/recipes/AssemblyRecipe.java b/common/buildcraft/api/recipes/AssemblyRecipe.java
index 573db282..6ab39418 100644
--- a/common/buildcraft/api/recipes/AssemblyRecipe.java
+++ b/common/buildcraft/api/recipes/AssemblyRecipe.java
@@ -1,13 +1,14 @@
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 {
public static LinkedList assemblyRecipes = new LinkedList();
-
- public final ItemStack[] input;
+ public final Object[] input;
public final ItemStack output;
public final float energy;
@@ -17,30 +18,69 @@ public class AssemblyRecipe {
this.energy = energy;
}
- public boolean canBeDone(ItemStack[] items) {
+ /**
+ * 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;
- for (ItemStack in : input) {
+ for (int i = 0; i < input.length; i++) {
+ if (input[i] instanceof String) {
+ input[i] = OreDictionary.getOres((String) input[i]);
+ }
+ }
+ }
- 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
+ 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 (item.isItemEqual(in)) {
- found += item.stackSize; // Adds quantity of stack to amount
- // found
- }
- }
+ // 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];
- if (found < in.stackSize)
- return false; // Return false if the amount of ingredient found
- // is not enough
+ for (ItemStack item : items) {
+ if (item == null)
+ continue;
+ for (ItemStack oreItem : oreList) {
+ if (OreDictionary.itemMatches(oreItem, item, true)) {
+ found += item.stackSize;
+ break;
+ }
+ }
+ }
+
+ // Return false if the amount of ingredient found
+ // is not enough
+ if (found < expected)
+ return false;
+ }
}
return true;
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/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 3657bb49..ec2d3404 100644
--- a/common/buildcraft/builders/gui/GuiBuilder.java
+++ b/common/buildcraft/builders/gui/GuiBuilder.java
@@ -26,7 +26,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/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/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;
diff --git a/common/buildcraft/core/Box.java b/common/buildcraft/core/Box.java
index f56535a8..cd78b962 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) {
@@ -224,6 +224,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);
@@ -239,5 +263,4 @@ public class Box implements IBox {
public String toString() {
return "{" + xMin + ", " + xMax + "}, {" + yMin + ", " + yMax + "}, {" + zMin + ", " + zMax + "}";
}
-
}
diff --git a/common/buildcraft/core/DefaultProps.java b/common/buildcraft/core/DefaultProps.java
index f55e6d37..8a79ef0a 100644
--- a/common/buildcraft/core/DefaultProps.java
+++ b/common/buildcraft/core/DefaultProps.java
@@ -63,6 +63,7 @@ public class DefaultProps {
public static int PIPE_ITEMS_QUARTZ_ID = 19168;
public static int PIPE_ITEMS_LAPIS_ID = 19169;
public static int PIPE_ITEMS_DAIZULI_ID = 19170;
+ public static int PIPE_ITEMS_EMZULI_ID = 19171;
public static int PIPE_LIQUIDS_WOOD_ID = 19180;
public static int PIPE_LIQUIDS_COBBLESTONE_ID = 19181;
diff --git a/common/buildcraft/core/GuiIds.java b/common/buildcraft/core/GuiIds.java
index b3735d6e..3d1263fb 100644
--- a/common/buildcraft/core/GuiIds.java
+++ b/common/buildcraft/core/GuiIds.java
@@ -19,6 +19,7 @@ public class GuiIds {
public static final int PIPE_DIAMOND = 50;
public static final int GATES = 51;
public static final int PIPE_EMERALD_ITEM = 52;
+ public static final int PIPE_LOGEMERALD_ITEM = 53;
public static final int FILTERED_BUFFER = 60;
}
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) {
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/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);
+ }
+}
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/core/gui/BuildCraftContainer.java b/common/buildcraft/core/gui/BuildCraftContainer.java
index 4984a77c..838486a4 100644
--- a/common/buildcraft/core/gui/BuildCraftContainer.java
+++ b/common/buildcraft/core/gui/BuildCraftContainer.java
@@ -9,21 +9,71 @@ 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 buildcraft.core.network.PacketGuiWidget;
+import cpw.mods.fml.common.network.PacketDispatcher;
+import cpw.mods.fml.common.network.Player;
+import java.io.DataInputStream;
+import java.io.IOException;
+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);
+ }
+
+ public void sendWidgetDataToClient(Widget widget, ICrafting player, byte[] data) {
+ PacketGuiWidget pkt = new PacketGuiWidget(windowId, widgets.indexOf(widget), data);
+ PacketDispatcher.sendPacketToPlayer(pkt.getPacket(), (Player) player);
+ }
+
+ public void handleWidgetClientData(int widgetId, DataInputStream data) throws IOException {
+ widgets.get(widgetId).handleClientPacketData(data);
+ }
+
+ @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..62368652 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,239 @@ 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);
+ 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;
+ bindTexture(texture);
+ 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 mouseX, int mouseY, int mouseButton) {
+ int mX = mouseX - guiLeft;
+ int mY = mouseY - guiTop;
+
+ for (Widget widget : container.getWidgets()) {
+ if (widget.hidden)
+ continue;
+ if (!widget.isMouseOver(mX, mY))
+ continue;
+ if (widget.handleMouseClick(mX, mY, mouseButton))
+ return;
+ }
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+
+ // / Handle ledger clicks
+ ledgerManager.handleMouseClicked(mouseX, mouseY, mouseButton);
+ }
+
+ @Override
+ protected void mouseClickMove(int mouseX, int mouseY, int mouseButton, long time) {
+ int mX = mouseX - guiLeft;
+ int mY = mouseY - guiTop;
+ for (Widget widget : container.getWidgets()) {
+ if (widget.hidden)
+ continue;
+ widget.handleMouseMove(mX, mY, mouseButton, time);
+ }
+
+ Slot slot = getSlotAtPosition(mouseX, mouseY);
+ if (mouseButton == 1 && slot instanceof IPhantomSlot)
+ return;
+ super.mouseClickMove(mouseX, mouseY, mouseButton, time);
+ }
+
+ @Override
+ protected void mouseMovedOrUp(int mouseX, int mouseY, int eventType) {
+ super.mouseMovedOrUp(mouseX, mouseY, eventType);
+
+ int mX = mouseX - guiLeft;
+ int mY = mouseY - guiTop;
+ for (Widget widget : container.getWidgets()) {
+ if (widget.hidden)
+ continue;
+ widget.handleMouseRelease(mX, mY, eventType);
+ }
+ }
+
+ 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 +460,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 extends GuiBetterButton> 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 extends GuiBetterButton> 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/ButtonWidget.java b/common/buildcraft/core/gui/widgets/ButtonWidget.java
new file mode 100644
index 00000000..0cb200fc
--- /dev/null
+++ b/common/buildcraft/core/gui/widgets/ButtonWidget.java
@@ -0,0 +1,61 @@
+/*
+ * 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.gui.widgets;
+
+import buildcraft.core.gui.GuiBuildCraft;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+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/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..3e79de41
--- /dev/null
+++ b/common/buildcraft/core/gui/widgets/Widget.java
@@ -0,0 +1,92 @@
+/**
+ * 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 java.io.DataInputStream;
+import java.io.IOException;
+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 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);
+ }
+
+ @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/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/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/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;
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/MathUtils.java b/common/buildcraft/core/utils/MathUtils.java
new file mode 100644
index 00000000..ad6432fe
--- /dev/null
+++ b/common/buildcraft/core/utils/MathUtils.java
@@ -0,0 +1,24 @@
+/*
+ * 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 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/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 extends T> 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/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/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java
index a98a88b2..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;
@@ -71,9 +70,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 {
@@ -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
@@ -320,18 +329,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
diff --git a/common/buildcraft/energy/gui/GuiCombustionEngine.java b/common/buildcraft/energy/gui/GuiCombustionEngine.java
index a2074c57..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;
@@ -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,24 +40,22 @@ 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;
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;
}
@@ -65,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;
@@ -91,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);
}
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/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 6dc5585f..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
@@ -83,6 +81,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/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/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);
}
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/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/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 487f9531..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,10 +40,14 @@ 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, (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))]);
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 dd017f39..f855de21 100644
--- a/common/buildcraft/silicon/TileAssemblyTable.java
+++ b/common/buildcraft/silicon/TileAssemblyTable.java
@@ -1,15 +1,20 @@
package buildcraft.silicon;
+import buildcraft.api.power.ILaserTarget;
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;
@@ -67,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();
@@ -99,34 +98,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 +118,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;
@@ -455,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() {
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/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java
index 25e5297e..cd056b73 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;
@@ -87,6 +86,7 @@ public class BlockGenericPipe extends BlockContainer {
public BlockGenericPipe(int i) {
super(i, Material.glass);
setRenderAllSides();
+ setCreativeTab(null);
}
@Override
@@ -609,6 +609,7 @@ public class BlockGenericPipe extends BlockContainer {
if (isValid(pipe)) {
pipe.container.scheduleNeighborChange();
+ pipe.container.redstonePowered = world.isBlockIndirectlyGettingPowered(x, y, z);
}
}
@@ -786,7 +787,7 @@ public class BlockGenericPipe extends BlockContainer {
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;
}
@@ -1007,7 +1008,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);
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/GuiHandler.java b/common/buildcraft/transport/GuiHandler.java
index 92de6927..fd9158a0 100644
--- a/common/buildcraft/transport/GuiHandler.java
+++ b/common/buildcraft/transport/GuiHandler.java
@@ -6,12 +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.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.GuiEmzuliPipe;
import buildcraft.transport.pipes.PipeItemsDiamond;
import buildcraft.transport.pipes.PipeItemsEmerald;
+import buildcraft.transport.pipes.PipeItemsEmzuli;
import cpw.mods.fml.common.network.IGuiHandler;
import java.util.logging.Level;
import net.minecraft.entity.player.EntityPlayer;
@@ -48,6 +51,9 @@ public class GuiHandler implements IGuiHandler {
case GuiIds.PIPE_EMERALD_ITEM:
return new ContainerEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe);
+ case GuiIds.PIPE_LOGEMERALD_ITEM:
+ return new ContainerEmzuliPipe(player.inventory, (PipeItemsEmzuli) pipe.pipe);
+
case GuiIds.GATES:
if (pipe.pipe.hasGate())
return new ContainerGateInterface(player.inventory, pipe.pipe);
@@ -89,6 +95,9 @@ public class GuiHandler implements IGuiHandler {
case GuiIds.PIPE_EMERALD_ITEM:
return new GuiEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe);
+ case GuiIds.PIPE_LOGEMERALD_ITEM:
+ return new GuiEmzuliPipe(player.inventory, (PipeItemsEmzuli) pipe.pipe);
+
case GuiIds.GATES:
if (pipe.pipe.hasGate())
return new GuiGateInterface(player.inventory, pipe.pipe);
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..ad45c878 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,51 @@ 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;
+
+ 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)
+ handler = makeEventHandler(event, handlerMap);
+ if (handler.method == null)
+ return;
+ try {
+ handler.method.invoke(this, event);
+ } catch (Exception ex) {
+ }
+ }
+
+ 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;
}
@@ -481,9 +528,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 3e641a1c..12e2db23 100644
--- a/common/buildcraft/transport/PipeConnectionBans.java
+++ b/common/buildcraft/transport/PipeConnectionBans.java
@@ -12,6 +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.PipeItemsEmzuli;
import buildcraft.transport.pipes.PipeItemsObsidian;
import buildcraft.transport.pipes.PipeItemsQuartz;
import buildcraft.transport.pipes.PipeItemsStone;
@@ -41,6 +42,8 @@ public class PipeConnectionBans {
banConnection(PipeItemsWood.class);
banConnection(PipeItemsObsidian.class);
+
+ banConnection(PipeItemsEmzuli.class);
// Power Pipes
banConnection(PipePowerWood.class);
diff --git a/common/buildcraft/transport/PipeIconProvider.java b/common/buildcraft/transport/PipeIconProvider.java
index e9ba64f2..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,6 +65,9 @@ public class PipeIconProvider implements IIconProvider {
PipeItemsEmerald_Standard("pipeItemsEmerald_standard"),
PipeAllEmerald_Solid("pipeAllEmerald_solid"),
//
+ PipeItemsEmzuli_Standard("pipeItemsEmzuli_standard"),
+ PipeAllEmzuli_Solid("pipeAllEmzuli_solid"),
+ //
PipeItemsGold("pipeItemsGold"),
//
PipeItemsIron_Standard("pipeItemsIron_standard"),
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/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java
index 13254ab4..3fc178a1 100644
--- a/common/buildcraft/transport/PipeTransportItems.java
+++ b/common/buildcraft/transport/PipeTransportItems.java
@@ -19,9 +19,11 @@ 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;
+import buildcraft.transport.pipes.events.PipeEventItem;
import buildcraft.transport.utils.TransportUtils;
import com.google.common.collect.BiMap;
import com.google.common.collect.ForwardingSet;
@@ -32,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;
@@ -46,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 {
@@ -125,9 +128,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);
}
@@ -146,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());
@@ -174,8 +173,6 @@ public class PipeTransportItems extends PipeTransport {
item.reset();
item.input = inputOrientation;
- items.add(item);
-
readjustSpeed(item);
readjustPosition(item);
@@ -188,6 +185,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 +235,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 +248,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,27 +261,27 @@ 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());
- 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);
}
@@ -282,6 +290,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 +299,8 @@ public class PipeTransportItems extends PipeTransport {
}
}
+ Collections.shuffle(result);
+
return result;
}
@@ -341,29 +353,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 +410,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) {
@@ -514,6 +524,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();
@@ -569,10 +580,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/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java
index 9b02066c..39c73b10 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();
@@ -86,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];
@@ -96,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);
@@ -114,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);
@@ -362,10 +368,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 +644,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);
diff --git a/common/buildcraft/transport/TransportProxyClient.java b/common/buildcraft/transport/TransportProxyClient.java
index b654f44d..84d63d10 100644
--- a/common/buildcraft/transport/TransportProxyClient.java
+++ b/common/buildcraft/transport/TransportProxyClient.java
@@ -39,6 +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.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..76e5a3ef
--- /dev/null
+++ b/common/buildcraft/transport/gui/ContainerEmzuliPipe.java
@@ -0,0 +1,176 @@
+/**
+ * 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;
+
+/**
+ *
+ * @author SandGrainOne
+ */
+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/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;
}
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/GuiEmzuliPipe.java b/common/buildcraft/transport/gui/GuiEmzuliPipe.java
new file mode 100644
index 00000000..5336186e
--- /dev/null
+++ b/common/buildcraft/transport/gui/GuiEmzuliPipe.java
@@ -0,0 +1,45 @@
+/**
+ * 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 net.minecraft.inventory.IInventory;
+import net.minecraft.util.ResourceLocation;
+
+
+import buildcraft.core.DefaultProps;
+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;
+
+ public GuiEmzuliPipe(IInventory playerInventory, PipeItemsEmzuli pipe) {
+ super(new ContainerEmzuliPipe(playerInventory, pipe), pipe.getFilters(), TEXTURE);
+
+ this.pipe = pipe;
+ filterInventory = pipe.getFilters();
+
+ xSize = 176;
+ ySize = 166;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ 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);
+ }
+}
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;
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/pipes/PipeItemsDaizuli.java b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java
index cad1b80e..1ae28871 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,27 @@ public class PipeItemsDaizuli extends Pipe implements IPipeT
return true;
}
- @Override
- public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item) {
- LinkedList newMovements = new LinkedList();
- EnumColor c = getColor();
- for (ForgeDirection dir : possibleOrientations) {
- if (item.color == c) {
- if (dir.ordinal() == container.getBlockMetadata())
- newMovements.add(dir);
- } else if (dir.ordinal() != container.getBlockMetadata()) {
- newMovements.add(dir);
- }
+ public void eventHandler(PipeEventItem.FindDest event) {
+ ForgeDirection output = ForgeDirection.getOrientation(container.getBlockMetadata());
+ if (event.item.color == getColor() && event.destinations.contains(output)) {
+ event.destinations.clear();
+ event.destinations.add(output);
+ return;
}
- return newMovements;
+ event.destinations.remove(output);
}
- @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/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};
}
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsEmzuli.java b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java
new file mode 100644
index 00000000..cb082938
--- /dev/null
+++ b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java
@@ -0,0 +1,279 @@
+/*
+ * 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;
+
+import java.util.BitSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.ForgeDirection;
+import buildcraft.BuildCraftTransport;
+import buildcraft.api.gates.IAction;
+import buildcraft.api.inventory.ISelectiveInventory;
+import buildcraft.api.inventory.ISpecialInventory;
+import buildcraft.core.GuiIds;
+import buildcraft.core.inventory.SimpleInventory;
+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.TravelingItem;
+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];
+ private final SimpleInventory filters = new SimpleInventory(4, "Filters", 1);
+ private final BitSet activeFlags = new BitSet(4);
+ private final int filterCount = filters.getSizeInventory();
+ private int currentFilter = 0;
+
+ public PipeItemsEmzuli(int itemID) {
+ super(itemID);
+
+ standardIconIndex = PipeIconProvider.TYPE.PipeItemsEmzuli_Standard.ordinal();
+ solidIconIndex = PipeIconProvider.TYPE.PipeAllEmzuli_Solid.ordinal();
+ }
+
+ @Override
+ public boolean blockActivated(EntityPlayer entityplayer) {
+ if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID < Block.blocksList.length) {
+ if (Block.blocksList[entityplayer.getCurrentEquippedItem().itemID] instanceof BlockGenericPipe) {
+ return false;
+ }
+ }
+
+ if (super.blockActivated(entityplayer)) {
+ return true;
+ }
+
+ if (!CoreProxy.proxy.isRenderWorld(container.worldObj)) {
+ entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_LOGEMERALD_ITEM, container.worldObj, container.xCoord, container.yCoord, container.zCoord);
+ }
+
+ 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
+ * on the position of the pipe.
+ */
+ @Override
+ public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) {
+
+ if (activeFlags.isEmpty()) {
+ return null;
+ }
+
+ incrementFilter();
+
+ 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());
+ if (doRemove) {
+ for (ItemStack stack : stacks) {
+ if (stack != null) {
+ powerHandler.useEnergy(stack.stackSize, stack.stackSize, true);
+ }
+ }
+ }
+ return stacks;
+
+ /* ISPECIALINVENTORY */
+ } else if (inventory instanceof ISpecialInventory) {
+ ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(false, from, (int) powerHandler.getEnergyStored());
+ if (stacks != null) {
+ for (ItemStack stack : stacks) {
+ if (stack == null)
+ continue;
+
+ boolean matches = false;
+ for (int i = 0; i < filters.getSizeInventory(); i++) {
+ ItemStack filter = filters.getStackInSlot(i);
+ if (filter != null && filter.isItemEqual(stack)) {
+ matches = true;
+ break;
+ }
+ }
+ if (!matches) {
+ return null;
+ }
+ }
+ if (doRemove) {
+ stacks = ((ISpecialInventory) inventory).extractItem(true, from, (int) powerHandler.getEnergyStored());
+ for (ItemStack stack : stacks) {
+ if (stack != null) {
+ powerHandler.useEnergy(stack.stackSize, stack.stackSize, true);
+ }
+ }
+ }
+ }
+ return stacks;
+
+ } else {
+
+ // This is a generic inventory
+ IInventory inv = Utils.getInventory(inventory);
+ ItemStack result = checkExtractGeneric(inv, doRemove, from);
+
+ if (result != null) {
+ return new ItemStack[]{result};
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public ItemStack checkExtractGeneric(net.minecraft.inventory.ISidedInventory inventory, boolean doRemove, ForgeDirection from) {
+ for (int i : inventory.getAccessibleSlotsFromSide(from.ordinal())) {
+ ItemStack stack = inventory.getStackInSlot(i);
+ if (stack != null && stack.stackSize > 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 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
+ public void writeToNBT(NBTTagCompound nbt) {
+ 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() {
+ return filters.getStackInSlot(currentFilter % filters.getSizeInventory());
+ }
+}
diff --git a/common/buildcraft/transport/pipes/PipeItemsGold.java b/common/buildcraft/transport/pipes/PipeItemsGold.java
index cc35cc5c..9c5bfa1e 100644
--- a/common/buildcraft/transport/pipes/PipeItemsGold.java
+++ b/common/buildcraft/transport/pipes/PipeItemsGold.java
@@ -9,19 +9,18 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
-import buildcraft.api.core.Position;
-import buildcraft.transport.IPipeTransportItemsHook;
+import buildcraft.core.utils.MathUtils;
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 +37,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) {
- item.setSpeed(Math.min(Math.max(TransportConstants.PIPE_NORMAL_SPEED, item.getSpeed()) * 2f, TransportConstants.PIPE_NORMAL_SPEED * 20F));
+ public void eventHandler(PipeEventItem.AdjustSpeed event) {
+ event.handled = true;
+ TravelingItem item = event.item;
+ item.setSpeed(MathUtils.clamp(item.getSpeed() * 4F, TransportConstants.PIPE_NORMAL_SPEED * 4F, 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..352cf815 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 eventHandler(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 eventHandler(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..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);
@@ -139,13 +141,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/PipeLogicIron.java b/common/buildcraft/transport/pipes/PipeLogicIron.java
index 486cdb0b..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;
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/render/PipeRendererTESR.java b/common/buildcraft/transport/render/PipeRendererTESR.java
index 128fad2d..f8d90d0d 100644
--- a/common/buildcraft/transport/render/PipeRendererTESR.java
+++ b/common/buildcraft/transport/render/PipeRendererTESR.java
@@ -593,52 +593,62 @@ 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];
+ int color = trans.colorRenderCache[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);
+ 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);
@@ -647,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]);
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));
+ }
+}
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
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