diff --git a/.classpath b/.classpath
index 9d71da7e..2af1d2f7 100644
--- a/.classpath
+++ b/.classpath
@@ -1,7 +1,8 @@
-
+
+
-
+
diff --git a/.project b/.project
index c4146540..d2bbeb49 100644
--- a/.project
+++ b/.project
@@ -14,4 +14,11 @@
org.eclipse.jdt.core.javanature
+
+
+ common/assets
+ 2
+ PROJECT_LOC/buildcraft_resources/assets
+
+
diff --git a/README.md b/README.md
index d137b77b..28a79d58 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,9 @@
If you wish to submit a pull request to fix bugs or broken behaviour feel free to do so. If you would like to add
features or change existing behaviour or balance, please discuss it with Sengir or Krapht before submiting the pull request.
+Do not submit pull requests which solely "fix" formatting. As these kinds of changes are usually very intrusive in commit history and everyone has their own idea what "proper formatting" is, they should be done by one of the main contributors.
+Please only submit "code cleanup", if the changes actually have a substantial impact on readability.
+
### Reporting issues
* Before reporting an issue, please check that it has not been reported before.
* Issues are for bugs/crashes, please do not use them to ask general questions.
@@ -12,6 +15,8 @@ If you don't, we might assume that you are using latest-greatest and waste a bun
a problem that might have fixed been already. Such things makes for very grumpy devs. Grumpy devs spend
less time coding and more time doing stuff that makes them less grumpy.
* If the issues occurs on a server, be sure it's a vanilla forge server and not a mcpc+ server.
+* Issues with any logs mentioning Optifine will be closed on sight! Remove Optifine before reporting any issue.
+* 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 c21fb782..65fbdaca 100644
--- a/build.xml
+++ b/build.xml
@@ -18,8 +18,8 @@
-
-
+
+
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_west_cb.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_west_cb.png
new file mode 100644
index 00000000..aae93acb
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_west_cb.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM128.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM128.png
new file mode 100644
index 00000000..874cddaa
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM128.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM16.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM16.png
new file mode 100644
index 00000000..a354a891
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM16.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM2.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM2.png
new file mode 100644
index 00000000..3e6626a6
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM2.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM32.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM32.png
new file mode 100644
index 00000000..30231a74
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM32.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM4.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM4.png
new file mode 100644
index 00000000..bfddb905
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM4.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM64.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM64.png
new file mode 100644
index 00000000..4503f6b7
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM64.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM8.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM8.png
new file mode 100644
index 00000000..4d83d7ef
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipePowerIronM8.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/filter_cb.png b/buildcraft_resources/assets/buildcraft/textures/gui/filter_cb.png
new file mode 100644
index 00000000..cc76dfe9
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/gui/filter_cb.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_1.png b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_1.png
index e12bdaaa..bab90259 100644
Binary files a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_1.png and b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_1.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_2.png b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_2.png
index 6f3aa851..c6b7971c 100644
Binary files a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_2.png and b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_2.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_3.png b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_3.png
index 9bd6d85e..fbc82a02 100644
Binary files a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_3.png and b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_3.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_4.png b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_4.png
index f678949a..c81a098d 100644
Binary files a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_4.png and b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_4.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m128.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m128.png
new file mode 100644
index 00000000..2ea44f1d
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m128.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m16.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m16.png
new file mode 100644
index 00000000..2a822427
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m16.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m2.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m2.png
new file mode 100644
index 00000000..5b066173
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m2.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m32.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m32.png
new file mode 100644
index 00000000..b4136883
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m32.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m4.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m4.png
new file mode 100644
index 00000000..0079f1bb
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m4.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m64.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m64.png
new file mode 100644
index 00000000..0587671c
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m64.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m8.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m8.png
new file mode 100644
index 00000000..f3c7d9da
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_limiter_m8.png differ
diff --git a/buildcraft_resources/build.number b/buildcraft_resources/build.number
index b13dc05d..7097c342 100644
--- a/buildcraft_resources/build.number
+++ b/buildcraft_resources/build.number
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
-#Fri Aug 09 09:44:46 CEST 2013
-build.number=39
+#Sun Oct 27 08:22:33 PDT 2013
+build.number=49
diff --git a/buildcraft_resources/changelog/4.1.0 b/buildcraft_resources/changelog/4.1.0
new file mode 100644
index 00000000..8de1a9b4
--- /dev/null
+++ b/buildcraft_resources/changelog/4.1.0
@@ -0,0 +1,17 @@
+
+#4.1.0
+
+- New: Added Iron Kinesis Pipe. (CovertJaguar)
+- New: Added Non-Round Robin mode to Emerald Item Pipe. (Flow86)
+- New: Pipes have tool tips now. (CovertJaguar)
+- New: Added config option for update check (Prototik)
+- New: Added config option for Oil Well proclivity. (sadris)
+- New: Added config options for various Quarry/Mining Well tweaks/nerfs. (CovertJaguar)
+- New: Added config options for Colorblind mode. (Krapht)
+- Change: Reworked Combustion Engine heat mechanics. (CovertJaguar)
+- Fix: Fixed Quarries in the Nether (cpw)
+- Fix: Autarchic Gate single pulses are now more reliable. (cpw)
+- Fix: Laser's hadWork trigger should work correctly now. (CovertJaguar)
+- Fix: Refineries no longer forget their filters. (CovertJaguar)
+- Fix: Pumps can now pump Oil out of Oceans again. (CovertJaguar)
+- And: Various other small fixes/tweaks.
\ No newline at end of file
diff --git a/buildcraft_resources/changelog/4.1.1 b/buildcraft_resources/changelog/4.1.1
new file mode 100644
index 00000000..65c05f30
--- /dev/null
+++ b/buildcraft_resources/changelog/4.1.1
@@ -0,0 +1,11 @@
+
+#4.1.1
+
+- New: Massive rework of Pipe/Player interactions with improvements to selection, Gate/Wire/Facade/Plug placement and removal, Facade rendering and more. (CovertJaguar)
+- New: Added config options for fluid fuel values. (CovertJaguar)
+- Change: Move Gate/Wire rending to the Pipe TESR, should improve fps when lots of Gates are used. (CovertJaguar)
+- Change: Reduce burn time of fluid fuels. (Player)
+- Change: Fuel/Oil explode if placed in the Nether. (CovertJaguar)
+- Fix: Fix version check so it isn't giving wrong results. (CovertJaguar)
+- Fix: Add missing zero to Wooden Engine pump speed. (CovertJaguar)
+- Fix: Increase Gate response time. (CovertJaguar)
\ No newline at end of file
diff --git a/buildcraft_resources/changelog/4.1.2 b/buildcraft_resources/changelog/4.1.2
new file mode 100644
index 00000000..53e5b5e8
--- /dev/null
+++ b/buildcraft_resources/changelog/4.1.2
@@ -0,0 +1,6 @@
+
+#4.1.2
+
+- Change: Filtered Buffer Triggers can now be applied to any inventory. (CovertJaguar)
+- Fix: Fix tiny derp that was causing massive net spam and chunk rerenders on pipes with plugs. (Player/CovertJaguar)
+- Fix: Optimize Pipe World Renderer to render less faces. (Player)
\ No newline at end of file
diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties
index 4a7375d6..4512f796 100644
--- a/buildcraft_resources/lang/buildcraft/en_US.properties
+++ b/buildcraft_resources/lang/buildcraft/en_US.properties
@@ -1,8 +1,10 @@
# Master language file
+chat.pipe.power.iron.mode=Switched to %d MJ/t limit
+
gate.pipe.empty=Pipe Empty
gate.pipe.containsItems=Items Traversing
-gate.pipe.containsLiquids=Liquid Traversing
+gate.pipe.containsFluids=Fluid Traversing
gate.pipe.containsEnergy=Power Traversing
gate.pipe.requestsEnergy=Power Requested
gate.pipe.tooMuchEnergy=Power Overloaded
@@ -24,6 +26,10 @@ gui.heat=Heat
gui.assemblyRate=Energy Rate
gui.assemblyCurrentRequired=Energy Required
gui.clickcraft=-Click to Craft-
+gui.pipes.emerald.blocking=Blocking
+gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing
+gui.pipes.emerald.nonblocking=Non Blocking
+gui.pipes.emerald.nonblocking.tip=Extraction continues with the next element in filter if one element is missing
item.bucketFuel=Fuel Bucket
item.bucketOil=Oil Bucket
item.woodenGearItem=Wood Gear
@@ -33,7 +39,6 @@ item.goldGearItem=Gold Gear
item.diamondGearItem=Diamond Gear
item.templateItem=Template
item.wrenchItem=Wrench
-item.fuel=Fuel
item.pipeWaterproof=Pipe Sealant
item.pipeGate.0=Gate
item.pipeGate.1=Iron AND Gate
@@ -80,6 +85,7 @@ item.PipePowerWood=Wooden Kinesis Pipe
item.PipePowerCobblestone=Cobblestone Kinesis Pipe
item.PipePowerStone=Stone Kinesis Pipe
item.PipePowerQuartz=Quartz Kinesis Pipe
+item.PipePowerIron=Iron Kinesis Pipe
item.PipePowerGold=Golden Kinesis Pipe
item.PipePowerDiamond=Diamond Kinesis Pipe
item.PipeItemsStripes=Stripes Transport Pipe
@@ -90,6 +96,10 @@ item.PipeItemsSandstone=Sandstone Transport Pipe
item.PipeFluidsSandstone=Sandstone Fluid Pipe
item.Facade=Facade
item.PipePlug=Pipe Plug
+
+tab.machines=Buildcraft Machines
+tab.facades=Buildcraft Facades
+
tile.miningWellBlock=Mining Well
tile.plainPipeBlock=Mining Pipe
tile.autoWorkbenchBlock=Auto Workbench
@@ -112,8 +122,33 @@ tile.floodGateBlock=Flood Gate
tile.engineWood=Redstone Engine
tile.engineStone=Stirling Engine
tile.engineIron=Combustion Engine
-tile.oilStill=Oil
+tile.blockOil=Oil
+tile.blockFuel=Fuel
tile.spring.water=Water Spring
tile.spring.oil=Oil Spring
-tile.oilMoving=Oil
tile.filteredBufferBlock=Filtered Buffer
+
+tip.PipeFluidsCobblestone=Basic pipe, 10 mB/t\nWon't connect to Stone
+tip.PipeFluidsEmerald=Extraction pipe, 40 mB/t
+tip.PipeFluidsGold=Basic pipe, 40 mB/t
+tip.PipeFluidsIron=Valve pipe, 10 mB/t
+tip.PipeFluidsSandstone=Only connects to other pipes, 10 mB/t
+tip.PipeFluidsStone=Basic pipe, 10 mB/t\nWon't connect to Cobblestone
+tip.PipeFluidsVoid=Destroys fluids, 10 mB/t
+tip.PipeFluidsWood=Extraction pipe, 10 mB/t
+tip.PipeItemsCobblestone=Basic pipe, high drag\nWon't connect to Stone or Quartz
+tip.PipeItemsDaizuli=Routes painted items
+tip.PipeItemsDiamond=Sorts items
+tip.PipeItemsEmerald=Round-robin extraction pipe
+tip.PipeItemsGold=Speeds up items
+tip.PipeItemsIron=Routes items
+tip.PipeItemsLapis=Paints items
+tip.PipeItemsObsidian=Sucks up items
+tip.PipeItemsQuartz=Basic pipe, low drag\nWon't connect to Cobblestone or Stone
+tip.PipeItemsSandstone=Only connects to other pipes
+tip.PipeItemsStone=Basic pipe, medium drag\nWon't connect to Cobblestone or Quartz
+tip.PipeItemsVoid=Destroys items
+tip.PipeItemsWood=Extraction pipe
+tip.PipePowerWood=Power Input Pipe
+tip.PipePowerIron=Selectable Limiter Pipe
+tip.PipeStructureCobblestone=Support pipe
diff --git a/buildcraft_resources/mcmod.info b/buildcraft_resources/mcmod.info
index a11c4a8f..b8f1fceb 100644
--- a/buildcraft_resources/mcmod.info
+++ b/buildcraft_resources/mcmod.info
@@ -3,10 +3,10 @@
"modid": "BuildCraft|Core",
"name": "BuildCraft",
"version": "@VERSION@",
- "mcversion": "",
+ "mcversion": "@MC_VERSION@",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more!",
"credits": "Created by SpaceToad",
- "logoFile": "/gfx/buildcraft/logo.png",
+ "logoFile": "/assets/buildcraft/logo.png",
"url": "http://www.mod-buildcraft.com/",
"updateUrl": "",
"authors": [ "SpaceToad", "BuildCraft Team" ],
@@ -20,10 +20,10 @@
"modid": "BuildCraft|Builders",
"name": "BC Builders",
"version": "@VERSION@",
- "mcversion": "",
+ "mcversion": "@MC_VERSION@",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Builders Component)",
"credits": "Created by SpaceToad",
- "logoFile": "/gfx/buildcraft/logo.png",
+ "logoFile": "/assets/buildcraft/logo.png",
"url": "http://www.mod-buildcraft.com/",
"updateUrl": "",
"authors": [ "SpaceToad", "BuildCraft Team" ],
@@ -37,10 +37,10 @@
"modid": "BuildCraft|Energy",
"name": "BC Energy",
"version": "@VERSION@",
- "mcversion": "",
+ "mcversion": "@MC_VERSION@",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Energy Component)",
"credits": "Created by SpaceToad",
- "logoFile": "/gfx/buildcraft/logo.png",
+ "logoFile": "/assets/buildcraft/logo.png",
"url": "http://www.mod-buildcraft.com/",
"updateUrl": "",
"authors": [ "SpaceToad", "BuildCraft Team" ],
@@ -54,10 +54,10 @@
"modid": "BuildCraft|Factory",
"name": "BC Factory",
"version": "@VERSION@",
- "mcversion": "",
+ "mcversion": "@MC_VERSION@",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Factory Component)",
"credits": "Created by SpaceToad",
- "logoFile": "/gfx/buildcraft/logo.png",
+ "logoFile": "/assets/buildcraft/logo.png",
"url": "http://www.mod-buildcraft.com/",
"updateUrl": "",
"authors": [ "SpaceToad", "BuildCraft Team" ],
@@ -71,10 +71,10 @@
"modid": "BuildCraft|Silicon",
"name": "BC Silicon",
"version": "@VERSION@",
- "mcversion": "",
+ "mcversion": "@MC_VERSION@",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Silicon Component)",
"credits": "Created by SpaceToad",
- "logoFile": "/gfx/buildcraft/logo.png",
+ "logoFile": "/assets/buildcraft/logo.png",
"url": "http://www.mod-buildcraft.com/",
"updateUrl": "",
"authors": [ "SpaceToad", "BuildCraft Team" ],
@@ -88,10 +88,10 @@
"modid": "BuildCraft|Transport",
"name": "BC Transport",
"version": "@VERSION@",
- "mcversion": "",
+ "mcversion": "@MC_VERSION@",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Transport Component)",
"credits": "Created by SpaceToad",
- "logoFile": "/gfx/buildcraft/logo.png",
+ "logoFile": "/assets/buildcraft/logo.png",
"url": "http://www.mod-buildcraft.com/",
"updateUrl": "",
"authors": [ "SpaceToad", "BuildCraft Team" ],
diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java
index b18cb4a6..2254f6b8 100644
--- a/common/buildcraft/BuildCraftBuilders.java
+++ b/common/buildcraft/BuildCraftBuilders.java
@@ -56,6 +56,7 @@ import buildcraft.builders.TileMarker;
import buildcraft.builders.TilePathMarker;
import buildcraft.builders.network.PacketHandlerBuilders;
import buildcraft.core.DefaultProps;
+import buildcraft.core.InterModComms;
import buildcraft.core.Version;
import buildcraft.core.blueprints.BptPlayerIndex;
import buildcraft.core.blueprints.BptRootIndex;
@@ -64,6 +65,7 @@ import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkMod;
@@ -240,10 +242,12 @@ public class BuildCraftBuilders {
templateItem = new ItemBptTemplate(templateItemId.getInt());
templateItem.setUnlocalizedName("templateItem");
LanguageRegistry.addName(templateItem, "Template");
+ CoreProxy.proxy.registerItem(templateItem);
blueprintItem = new ItemBptBluePrint(blueprintItemId.getInt());
blueprintItem.setUnlocalizedName("blueprintItem");
LanguageRegistry.addName(blueprintItem, "Blueprint");
+ CoreProxy.proxy.registerItem(blueprintItem);
markerBlock = new BlockMarker(markerId.getInt());
CoreProxy.proxy.registerBlock(markerBlock.setUnlocalizedName("markerBlock"));
@@ -293,33 +297,33 @@ public class BuildCraftBuilders {
public static void loadRecipes() {
- CoreProxy.proxy.addCraftingRecipe(new ItemStack(templateItem, 1), new Object[]{"ppp", "pip", "ppp", Character.valueOf('i'),
- new ItemStack(Item.dyePowder, 1, 0), Character.valueOf('p'), Item.paper});
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(templateItem, 1), new Object[]{"ppp", "pip", "ppp", 'i',
+ new ItemStack(Item.dyePowder, 1, 0), 'p', Item.paper});
-// CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), new Object[]{"ppp", "pip", "ppp", Character.valueOf('i'),
-// new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('p'), Item.paper});
+// CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), new Object[]{"ppp", "pip", "ppp", 'i',
+// new ItemStack(Item.dyePowder, 1, 4), 'p', Item.paper});
- CoreProxy.proxy.addCraftingRecipe(new ItemStack(markerBlock, 1), new Object[]{"l ", "r ", Character.valueOf('l'),
- new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('r'), Block.torchRedstoneActive});
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(markerBlock, 1), new Object[]{"l ", "r ", 'l',
+ new ItemStack(Item.dyePowder, 1, 4), 'r', Block.torchRedstoneActive});
- CoreProxy.proxy.addCraftingRecipe(new ItemStack(pathMarkerBlock, 1), new Object[]{"l ", "r ", Character.valueOf('l'),
- new ItemStack(Item.dyePowder, 1, 2), Character.valueOf('r'), Block.torchRedstoneActive});
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(pathMarkerBlock, 1), new Object[]{"l ", "r ", 'l',
+ new ItemStack(Item.dyePowder, 1, 2), 'r', Block.torchRedstoneActive});
- CoreProxy.proxy.addCraftingRecipe(new ItemStack(fillerBlock, 1), new Object[]{"btb", "ycy", "gCg", Character.valueOf('b'),
- new ItemStack(Item.dyePowder, 1, 0), Character.valueOf('t'), markerBlock, Character.valueOf('y'), new ItemStack(Item.dyePowder, 1, 11),
- Character.valueOf('c'), Block.workbench, Character.valueOf('g'), BuildCraftCore.goldGearItem, Character.valueOf('C'), Block.chest});
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(fillerBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b',
+ new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11),
+ 'c', Block.workbench, 'g', BuildCraftCore.goldGearItem, 'C', Block.chest});
- CoreProxy.proxy.addCraftingRecipe(new ItemStack(builderBlock, 1), new Object[]{"btb", "ycy", "gCg", Character.valueOf('b'),
- new ItemStack(Item.dyePowder, 1, 0), Character.valueOf('t'), markerBlock, Character.valueOf('y'), new ItemStack(Item.dyePowder, 1, 11),
- Character.valueOf('c'), Block.workbench, Character.valueOf('g'), BuildCraftCore.diamondGearItem, Character.valueOf('C'), Block.chest});
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(builderBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b',
+ new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11),
+ 'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C', Block.chest});
- CoreProxy.proxy.addCraftingRecipe(new ItemStack(architectBlock, 1), new Object[]{"btb", "ycy", "gCg", Character.valueOf('b'),
- new ItemStack(Item.dyePowder, 1, 0), Character.valueOf('t'), markerBlock, Character.valueOf('y'), new ItemStack(Item.dyePowder, 1, 11),
- Character.valueOf('c'), Block.workbench, Character.valueOf('g'), BuildCraftCore.diamondGearItem, Character.valueOf('C'),
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(architectBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b',
+ new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11),
+ 'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C',
new ItemStack(templateItem, 1)});
- CoreProxy.proxy.addCraftingRecipe(new ItemStack(libraryBlock, 1), new Object[]{"bbb", "bBb", "bbb", Character.valueOf('b'),
- new ItemStack(blueprintItem), Character.valueOf('B'), Block.bookShelf});
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(libraryBlock, 1), new Object[]{"bbb", "bBb", "bbb", 'b',
+ new ItemStack(blueprintItem), 'B', Block.bookShelf});
// / INIT FILLER PATTERNS
@@ -332,6 +336,11 @@ public class BuildCraftBuilders {
FillerManager.registry.addRecipe(new FillerFillStairs(), new Object[]{" b", " bb", "bbb", 'g', Block.glass, 'b', Block.brick});
}
+ @EventHandler
+ public void processIMCRequests(FMLInterModComms.IMCEvent event) {
+ InterModComms.processIMC(event);
+ }
+
public static BptPlayerIndex getPlayerIndex(String name) {
BptRootIndex rootIndex = getBptRootIndex();
diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java
index e4f1dc17..6b2676c5 100644
--- a/common/buildcraft/BuildCraftCore.java
+++ b/common/buildcraft/BuildCraftCore.java
@@ -9,6 +9,23 @@
package buildcraft;
+import java.io.File;
+import java.util.TreeMap;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockFluid;
+import net.minecraft.entity.EntityList;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
+import net.minecraftforge.client.event.TextureStitchEvent;
+import net.minecraftforge.common.Configuration;
+import net.minecraftforge.common.IPlantable;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.Property;
+import net.minecraftforge.event.ForgeSubscribe;
+import net.minecraftforge.oredict.OreDictionary;
+import net.minecraftforge.fluids.IFluidBlock;
import buildcraft.api.core.BuildCraftAPI;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.gates.ActionManager;
@@ -22,6 +39,7 @@ import buildcraft.core.DefaultProps;
import buildcraft.core.EntityEnergyLaser;
import buildcraft.core.EntityPowerLaser;
import buildcraft.core.EntityRobot;
+import buildcraft.core.InterModComms;
import buildcraft.core.ItemBuildCraft;
import buildcraft.core.ItemSpring;
import buildcraft.core.ItemWrench;
@@ -43,42 +61,27 @@ import buildcraft.core.triggers.DefaultActionProvider;
import buildcraft.core.triggers.DefaultTriggerProvider;
import buildcraft.core.triggers.TriggerFluidContainer;
import buildcraft.core.triggers.TriggerInventory;
+import buildcraft.core.triggers.TriggerInventoryLevel;
import buildcraft.core.triggers.TriggerMachine;
+import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.Localization;
import buildcraft.transport.triggers.TriggerRedstoneInput;
-import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
-import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import java.io.File;
-import java.util.TreeMap;
-import java.util.logging.Logger;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockFluid;
-import net.minecraft.entity.EntityList;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.Icon;
-import net.minecraftforge.client.event.TextureStitchEvent;
-import net.minecraftforge.common.Configuration;
-import net.minecraftforge.common.IPlantable;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.common.Property;
-import net.minecraftforge.event.ForgeSubscribe;
-import net.minecraftforge.fluids.IFluidBlock;
-@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", dependencies = "required-after:Forge@[9.10.0.800,)")
+@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6,1.7)", dependencies = "required-after:Forge@[9.10.0.800,)")
@NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true)
public class BuildCraftCore {
public static enum RenderMode {
@@ -90,6 +93,7 @@ public class BuildCraftCore {
public static boolean debugMode = false;
public static boolean modifyWorld = false;
public static boolean trackNetworkUsage = false;
+ public static boolean colorBlindMode = false;
public static boolean dropBrokenBlocks = true; // Set to false to prevent the filler from dropping broken blocks.
@@ -145,6 +149,10 @@ public class BuildCraftCore {
public static BCTrigger triggerFullFluid = new TriggerFluidContainer(DefaultProps.TRIGGER_FULL_LIQUID, TriggerFluidContainer.State.Full);
public static BCTrigger triggerRedstoneActive = new TriggerRedstoneInput(DefaultProps.TRIGGER_REDSTONE_ACTIVE, true);
public static BCTrigger triggerRedstoneInactive = new TriggerRedstoneInput(DefaultProps.TRIGGER_REDSTONE_INACTIVE, false);
+
+ public static BCTrigger triggerInventoryBelow25 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_25);
+ public static BCTrigger triggerInventoryBelow50 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_50);
+ public static BCTrigger triggerInventoryBelow75 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_75);
public static BCAction actionRedstone = new ActionRedstoneOutput(DefaultProps.ACTION_REDSTONE);
public static BCAction actionOn = new ActionMachineControl(DefaultProps.ACTION_ON, Mode.On);
@@ -157,25 +165,24 @@ public class BuildCraftCore {
public static BptItem[] itemBptProps = new BptItem[Item.itemsList.length];
- public static final Logger bcLog = Logger.getLogger("Buildcraft");
-
@Instance("BuildCraft|Core")
public static BuildCraftCore instance;
@EventHandler
public void loadConfiguration(FMLPreInitializationEvent evt) {
- Version.check();
-
- bcLog.setParent(FMLLog.getLogger());
- bcLog.info("Starting BuildCraft " + Version.getVersion());
- bcLog.info("Copyright (c) SpaceToad, 2011");
- bcLog.info("http://www.mod-buildcraft.com");
+ BCLog.initLog();
BlueprintDatabase.configFolder = evt.getModConfigurationDirectory();
mainConfiguration = new BuildCraftConfiguration(new File(evt.getModConfigurationDirectory(), "buildcraft/main.conf"));
try {
mainConfiguration.load();
+
+ Property updateCheck = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "update.check", true);
+ updateCheck.comment = "set to true for version check on startup";
+ if (updateCheck.getBoolean(true)) {
+ Version.check();
+ }
Property continuousCurrent = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "current.continuous",
DefaultProps.CURRENT_CONTINUOUS);
@@ -236,23 +243,32 @@ public class BuildCraftCore {
woodenGearItem = (new ItemBuildCraft(woodenGearId.getInt())).setUnlocalizedName("woodenGearItem");
LanguageRegistry.addName(woodenGearItem, "Wooden Gear");
CoreProxy.proxy.registerItem(woodenGearItem);
+ OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem));
stoneGearItem = (new ItemBuildCraft(stoneGearId.getInt())).setUnlocalizedName("stoneGearItem");
LanguageRegistry.addName(stoneGearItem, "Stone Gear");
CoreProxy.proxy.registerItem(stoneGearItem);
+ OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem));
ironGearItem = (new ItemBuildCraft(ironGearId.getInt())).setUnlocalizedName("ironGearItem");
LanguageRegistry.addName(ironGearItem, "Iron Gear");
CoreProxy.proxy.registerItem(ironGearItem);
-
+ OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem));
+
goldGearItem = (new ItemBuildCraft(goldenGearId.getInt())).setUnlocalizedName("goldGearItem");
LanguageRegistry.addName(goldGearItem, "Gold Gear");
CoreProxy.proxy.registerItem(goldGearItem);
+ OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem));
diamondGearItem = (new ItemBuildCraft(diamondGearId.getInt())).setUnlocalizedName("diamondGearItem");
LanguageRegistry.addName(diamondGearItem, "Diamond Gear");
CoreProxy.proxy.registerItem(diamondGearItem);
+ OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem));
+ Property colorBlindProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "client.colorblindmode", false);
+ colorBlindProp.comment = "Set to true to enable alternate textures";
+ colorBlindMode = colorBlindProp.getBoolean(false);
+
MinecraftForge.EVENT_BUS.register(this);
} finally {
@@ -329,12 +345,17 @@ public class BuildCraftCore {
}
public void loadRecipes() {
- GameRegistry.addRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", Character.valueOf('I'), Item.ingotIron, Character.valueOf('G'), stoneGearItem);
- GameRegistry.addRecipe(new ItemStack(woodenGearItem), " S ", "S S", " S ", Character.valueOf('S'), Item.stick);
- GameRegistry.addRecipe(new ItemStack(stoneGearItem), " I ", "IGI", " I ", Character.valueOf('I'), Block.cobblestone, Character.valueOf('G'),
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", 'I', Item.ingotIron, 'G', stoneGearItem);
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(woodenGearItem), " S ", "S S", " S ", 'S', "stickWood");
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(stoneGearItem), " I ", "IGI", " I ", 'I', "cobblestone", 'G',
woodenGearItem);
- GameRegistry.addRecipe(new ItemStack(ironGearItem), " I ", "IGI", " I ", Character.valueOf('I'), Item.ingotIron, Character.valueOf('G'), stoneGearItem);
- GameRegistry.addRecipe(new ItemStack(goldGearItem), " I ", "IGI", " I ", Character.valueOf('I'), Item.ingotGold, Character.valueOf('G'), ironGearItem);
- GameRegistry.addRecipe(new ItemStack(diamondGearItem), " I ", "IGI", " I ", Character.valueOf('I'), Item.diamond, Character.valueOf('G'), goldGearItem);
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(ironGearItem), " I ", "IGI", " I ", 'I', Item.ingotIron, 'G', stoneGearItem);
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(goldGearItem), " I ", "IGI", " I ", 'I', Item.ingotGold, 'G', ironGearItem);
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(diamondGearItem), " I ", "IGI", " I ", 'I', Item.diamond, 'G', goldGearItem);
}
+
+ @EventHandler
+ public void processIMCRequests(FMLInterModComms.IMCEvent event) {
+ InterModComms.processIMC(event);
+ }
}
diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java
index 6e8fe47d..400b4c7d 100644
--- a/common/buildcraft/BuildCraftEnergy.java
+++ b/common/buildcraft/BuildCraftEnergy.java
@@ -13,6 +13,7 @@ import buildcraft.api.recipes.RefineryRecipes;
import buildcraft.core.BlockIndex;
import buildcraft.core.BlockSpring;
import buildcraft.core.DefaultProps;
+import buildcraft.core.InterModComms;
import buildcraft.core.Version;
import buildcraft.core.network.PacketHandler;
import buildcraft.core.proxy.CoreProxy;
@@ -44,8 +45,6 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.TreeMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
@@ -81,6 +80,7 @@ public class BuildCraftEnergy {
public static Item bucketFuel;
public static Item fuel;
public static boolean canOilBurn;
+ public static double oilWellScalar;
public static TreeMap saturationStored = new TreeMap();
public static BCTrigger triggerBlueEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_BLUE_ENGINE_HEAT, EnergyStage.BLUE, "buildcraft.engine.stage.blue");
public static BCTrigger triggerGreenEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_GREEN_ENGINE_HEAT, EnergyStage.GREEN, "buildcraft.engine.stage.green");
@@ -107,6 +107,10 @@ public class BuildCraftEnergy {
int oilDesertBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilDesert", DefaultProps.BIOME_OIL_DESERT).getInt(DefaultProps.BIOME_OIL_DESERT);
int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN);
canOilBurn = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "burnOil", true, "Can oil burn?").getBoolean(true);
+ oilWellScalar = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilWellGenerationRate", 1.0, "Probability of oil well generation").getDouble(1.0);
+
+ double fuelOilMultiplier = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.oil.combustion", 1.0F, "adjust energy value of Oil in Combustion Engines").getDouble(1.0F);
+ double fuelFuelMultiplier = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.fuel.combustion", 1.0F, "adjust energy value of Fuel in Combustion Engines").getDouble(1.0F);
BuildCraftCore.mainConfiguration.save();
class BiomeIdException extends RuntimeException {
@@ -185,6 +189,7 @@ public class BuildCraftEnergy {
bucketOil = new ItemBucketBuildcraft(bucketOilId, blockOil.blockID);
bucketOil.setUnlocalizedName("bucketOil").setContainerItem(Item.bucketEmpty);
LanguageRegistry.addName(bucketOil, "Oil Bucket");
+ CoreProxy.proxy.registerItem(bucketOil);
FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("oil", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketOil), new ItemStack(Item.bucketEmpty));
}
@@ -192,6 +197,7 @@ public class BuildCraftEnergy {
bucketFuel = new ItemBucketBuildcraft(bucketFuelId, blockFuel.blockID);
bucketFuel.setUnlocalizedName("bucketFuel").setContainerItem(Item.bucketEmpty);
LanguageRegistry.addName(bucketFuel, "Fuel Bucket");
+ CoreProxy.proxy.registerItem(bucketFuel);
FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("fuel", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketFuel), new ItemStack(Item.bucketEmpty));
}
@@ -202,9 +208,9 @@ public class BuildCraftEnergy {
RefineryRecipes.addRecipe(new FluidStack(fluidOil, 1), new FluidStack(fluidFuel, 1), 12, 1);
// Iron Engine Fuels
- IronEngineFuel.addFuel("lava", 1, 20000);
- IronEngineFuel.addFuel("oil", 3, 20000);
- IronEngineFuel.addFuel("fuel", 6, 100000);
+// IronEngineFuel.addFuel("lava", 1, 20000);
+ IronEngineFuel.addFuel("oil", 3, (int) (5000 * fuelOilMultiplier));
+ IronEngineFuel.addFuel("fuel", 6, (int) (25000 * fuelFuelMultiplier));
// Iron Engine Coolants
IronEngineCoolant.addCoolant(FluidRegistry.getFluid("water"), 0.0023F);
@@ -245,47 +251,17 @@ public class BuildCraftEnergy {
public static void loadRecipes() {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 0),
- new Object[]{"www", " g ", "GpG", Character.valueOf('w'), "plankWood", Character.valueOf('g'), Block.glass, Character.valueOf('G'),
- BuildCraftCore.woodenGearItem, Character.valueOf('p'), Block.pistonBase});
- CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 1), new Object[]{"www", " g ", "GpG", Character.valueOf('w'), Block.cobblestone,
- Character.valueOf('g'), Block.glass, Character.valueOf('G'), BuildCraftCore.stoneGearItem, Character.valueOf('p'), Block.pistonBase});
- CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 2), new Object[]{"www", " g ", "GpG", Character.valueOf('w'), Item.ingotIron,
- Character.valueOf('g'), Block.glass, Character.valueOf('G'), BuildCraftCore.ironGearItem, Character.valueOf('p'), Block.pistonBase});
+ new Object[]{"www", " g ", "GpG", 'w', "plankWood", 'g', Block.glass, 'G',
+ BuildCraftCore.woodenGearItem, 'p', Block.pistonBase});
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 1), new Object[]{"www", " g ", "GpG", 'w', "cobblestone",
+ 'g', Block.glass, 'G', BuildCraftCore.stoneGearItem, 'p', Block.pistonBase});
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 2), new Object[]{"www", " g ", "GpG", 'w', Item.ingotIron,
+ 'g', Block.glass, 'G', BuildCraftCore.ironGearItem, 'p', Block.pistonBase});
}
- @Mod.IMCCallback
+ @EventHandler
public void processIMCRequests(FMLInterModComms.IMCEvent event) {
- for (FMLInterModComms.IMCMessage m : event.getMessages()) {
- if (m.key.equals("oil-lake-biome")) {
- try {
- String biomeID = m.getStringValue().trim();
- int id = Integer.valueOf(biomeID);
- if (id >= BiomeGenBase.biomeList.length) {
- throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length);
- }
- OilPopulate.INSTANCE.surfaceDepositBiomes.add(id);
- } catch (Exception ex) {
- Logger.getLogger("Buildcraft").log(Level.WARNING,
- String.format("Received an invalid oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender()));
- }
- Logger.getLogger("Buildcraft").log(Level.INFO,
- String.format("Received an successfull oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender()));
- } else if (m.key.equals("oil-gen-exclude")) {
- try {
- String biomeID = m.getStringValue().trim();
- int id = Integer.valueOf(biomeID);
- if (id >= BiomeGenBase.biomeList.length) {
- throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length);
- }
- OilPopulate.INSTANCE.excludedBiomes.add(id);
- } catch (Exception ex) {
- Logger.getLogger("Buildcraft").log(Level.WARNING,
- String.format("Received an invalid oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender()));
- }
- Logger.getLogger("Buildcraft").log(Level.INFO,
- String.format("Received an successfull oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender()));
- }
- }
+ InterModComms.processIMC(event);
}
// public static int createPollution (World world, int i, int j, int k, int
// saturation) {
diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java
index b5370298..4ed83863 100644
--- a/common/buildcraft/BuildCraftFactory.java
+++ b/common/buildcraft/BuildCraftFactory.java
@@ -8,8 +8,10 @@
package buildcraft;
import buildcraft.core.DefaultProps;
+import buildcraft.core.InterModComms;
import buildcraft.core.Version;
import buildcraft.core.proxy.CoreProxy;
+import buildcraft.core.utils.ConfigUtils;
import buildcraft.factory.BlockAutoWorkbench;
import buildcraft.factory.BlockFloodGate;
import buildcraft.factory.BlockFrame;
@@ -42,6 +44,7 @@ import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
@@ -59,12 +62,14 @@ import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.Property;
import net.minecraftforge.event.ForgeSubscribe;
@Mod(name = "BuildCraft Factory", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Factory", dependencies = DefaultProps.DEPENDENCY_CORE)
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerFactory.class, clientSideRequired = true, serverSideRequired = true)
public class BuildCraftFactory {
+ public static final int MINING_MJ_COST_PER_BLOCK = 64;
public static BlockQuarry quarryBlock;
public static BlockMiningWell miningWellBlock;
public static BlockAutoWorkbench autoWorkbenchBlock;
@@ -75,8 +80,10 @@ public class BuildCraftFactory {
public static BlockTank tankBlock;
public static BlockRefinery refineryBlock;
public static BlockHopper hopperBlock;
- public static boolean hopperDisabled;
public static boolean allowMining = true;
+ public static boolean quarryOneTimeUse = false;
+ public static float miningMultiplier = 1;
+ public static int miningDepth = 256;
public static PumpDimensionList pumpDimensionList;
@Instance("BuildCraft|Factory")
public static BuildCraftFactory instance;
@@ -131,10 +138,7 @@ public class BuildCraftFactory {
CoreProxy.proxy.registerTileEntity(TileFloodGate.class, "net.minecraft.src.buildcraft.factory.TileFloodGate");
CoreProxy.proxy.registerTileEntity(TileTank.class, "net.minecraft.src.buildcraft.factory.TileTank");
CoreProxy.proxy.registerTileEntity(TileRefinery.class, "net.minecraft.src.buildcraft.factory.Refinery");
-
- if (!hopperDisabled) {
- CoreProxy.proxy.registerTileEntity(TileHopper.class, "net.minecraft.src.buildcraft.factory.TileHopper");
- }
+ CoreProxy.proxy.registerTileEntity(TileHopper.class, "net.minecraft.src.buildcraft.factory.TileHopper");
FactoryProxy.proxy.initializeTileEntities();
@@ -150,9 +154,19 @@ public class BuildCraftFactory {
@EventHandler
public void initialize(FMLPreInitializationEvent evt) {
- allowMining = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "mining.enabled", true).getBoolean(true);
+ ConfigUtils genCat = new ConfigUtils(BuildCraftCore.mainConfiguration, Configuration.CATEGORY_GENERAL);
- pumpDimensionList = new PumpDimensionList(BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pumping.controlList", DefaultProps.PUMP_DIMENSION_LIST).getString());
+ allowMining = genCat.get("mining.enabled", true, "disables the recipes for automated mining machines");
+ quarryOneTimeUse = genCat.get("quarry.one.time.use", false, "Quarry cannot be picked back up after placement");
+ miningMultiplier = genCat.get("mining.cost.multipler", 1F, 1F, 10F, "cost multiplier for mining operations, range (1.0 - 10.0)\nhigh values may render engines incapable of powering machines directly");
+ miningDepth = genCat.get("mining.depth", 2, 256, 256, "how far below the machine can mining machines dig, range (2 - 256), default 256");
+
+ Property pumpList = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pumping.controlList", DefaultProps.PUMP_DIMENSION_LIST);
+ pumpList.comment = "Allows admins to whitelist or blacklist pumping of specific fluids in specific dimensions.\n"
+ + "Eg. \"-/-1/Lava\" will disable lava in the nether. \"-/*/Lava\" will disable lava in any dimension. \"+/0/*\" will enable any fluid in the overworld.\n"
+ + "Entries are comma seperated, banned fluids have precedence over allowed ones."
+ + "Default is \"+/*/*,+/-1/Lava\" - the second redundant entry (\"+/-1/lava\") is there to show the format.";
+ pumpDimensionList = new PumpDimensionList(pumpList.getString());
int miningWellId = BuildCraftCore.mainConfiguration.getBlock("miningWell.id", DefaultProps.MINING_WELL_ID).getInt(DefaultProps.MINING_WELL_ID);
int plainPipeId = BuildCraftCore.mainConfiguration.getBlock("drill.id", DefaultProps.DRILL_ID).getInt(DefaultProps.DRILL_ID);
@@ -317,6 +331,11 @@ public class BuildCraftFactory {
'G', BuildCraftCore.ironGearItem,
'F', new ItemStack(Block.fenceIron));
}
+
+ @EventHandler
+ public void processIMCRequests(FMLInterModComms.IMCEvent event) {
+ InterModComms.processIMC(event);
+ }
@ForgeSubscribe
@SideOnly(Side.CLIENT)
diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java
index 39e0d326..b15a4200 100644
--- a/common/buildcraft/BuildCraftSilicon.java
+++ b/common/buildcraft/BuildCraftSilicon.java
@@ -11,6 +11,7 @@ import buildcraft.api.bptblocks.BptBlockInventory;
import buildcraft.api.bptblocks.BptBlockRotateMeta;
import buildcraft.api.recipes.AssemblyRecipe;
import buildcraft.core.DefaultProps;
+import buildcraft.core.InterModComms;
import buildcraft.core.ItemRedstoneChipset;
import buildcraft.core.Version;
import buildcraft.core.proxy.CoreProxy;
@@ -27,6 +28,7 @@ import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
@@ -40,7 +42,7 @@ import net.minecraftforge.common.Property;
@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerSilicon.class, clientSideRequired = true, serverSideRequired = true)
public class BuildCraftSilicon {
- public static Item redstoneChipset;
+ public static ItemRedstoneChipset redstoneChipset;
public static BlockLaser laserBlock;
public static BlockLaserTable assemblyTableBlock;
@Instance("BuildCraft|Silicon")
@@ -68,7 +70,8 @@ public class BuildCraftSilicon {
redstoneChipset = new ItemRedstoneChipset(redstoneChipsetId.getInt());
redstoneChipset.setUnlocalizedName("redstoneChipset");
-
+ CoreProxy.proxy.registerItem(redstoneChipset);
+ redstoneChipset.registerItemStacks();
}
@EventHandler
@@ -91,14 +94,14 @@ public class BuildCraftSilicon {
public static void loadRecipes() {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(laserBlock),
- new Object[]{"ORR", "DDR", "ORR", Character.valueOf('O'), Block.obsidian, Character.valueOf('R'), Item.redstone, Character.valueOf('D'),
+ new Object[]{"ORR", "DDR", "ORR", 'O', Block.obsidian, 'R', Item.redstone, 'D',
Item.diamond,});
- CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 0), new Object[]{"ORO", "ODO", "OGO", Character.valueOf('O'), Block.obsidian,
- Character.valueOf('R'), Item.redstone, Character.valueOf('D'), Item.diamond, Character.valueOf('G'), BuildCraftCore.diamondGearItem,});
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 0), new Object[]{"ORO", "ODO", "OGO", 'O', Block.obsidian,
+ 'R', Item.redstone, 'D', Item.diamond, 'G', BuildCraftCore.diamondGearItem,});
- CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 1), new Object[]{"OWO", "OCO", "ORO", Character.valueOf('O'), Block.obsidian,
- Character.valueOf('W'), Block.workbench, Character.valueOf('C'), Block.chest, Character.valueOf('R'), new ItemStack(redstoneChipset, 1, 0),});
+ CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 1), new Object[]{"OWO", "OCO", "ORO", 'O', Block.obsidian,
+ 'W', Block.workbench, 'C', Block.chest, 'R', new ItemStack(redstoneChipset, 1, 0),});
// Add reverse recipies for all gates
// Iron
@@ -224,4 +227,9 @@ public class BuildCraftSilicon {
CoreProxy.proxy.addName(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, 6), "Autarchic Diamond OR Gate");
}
+
+ @EventHandler
+ public void processIMCRequests(FMLInterModComms.IMCEvent event) {
+ InterModComms.processIMC(event);
+ }
}
diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java
index e5345e60..309cd3fe 100644
--- a/common/buildcraft/BuildCraftTransport.java
+++ b/common/buildcraft/BuildCraftTransport.java
@@ -13,8 +13,8 @@ import buildcraft.api.recipes.AssemblyRecipe;
import buildcraft.api.transport.IExtractionHandler;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.PipeManager;
-import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.DefaultProps;
+import buildcraft.core.InterModComms;
import buildcraft.core.ItemBuildCraft;
import buildcraft.core.Version;
import buildcraft.core.proxy.CoreProxy;
@@ -64,6 +64,8 @@ import buildcraft.transport.pipes.PipeItemsWood;
import buildcraft.transport.pipes.PipePowerCobblestone;
import buildcraft.transport.pipes.PipePowerDiamond;
import buildcraft.transport.pipes.PipePowerGold;
+import buildcraft.transport.pipes.PipePowerIron;
+import buildcraft.transport.pipes.PipePowerIron.PowerMode;
import buildcraft.transport.pipes.PipePowerQuartz;
import buildcraft.transport.pipes.PipePowerStone;
import buildcraft.transport.pipes.PipePowerWood;
@@ -71,21 +73,17 @@ import buildcraft.transport.pipes.PipeStructureCobblestone;
import buildcraft.transport.triggers.ActionEnergyPulser;
import buildcraft.transport.triggers.ActionPipeColor;
import buildcraft.transport.triggers.ActionPipeDirection;
+import buildcraft.transport.triggers.ActionPowerLimiter;
import buildcraft.transport.triggers.ActionSignalOutput;
import buildcraft.transport.triggers.ActionSingleEnergyPulse;
-import buildcraft.transport.triggers.TriggerFilteredBufferInventoryLevel;
import buildcraft.transport.triggers.TriggerPipeContents;
import buildcraft.transport.triggers.TriggerPipeContents.Kind;
import buildcraft.transport.triggers.TriggerPipeSignal;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Iterables;
-import com.google.common.primitives.Ints;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
-import cpw.mods.fml.common.event.FMLInterModComms;
-import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
+import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
@@ -93,8 +91,6 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import java.util.LinkedList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
@@ -142,6 +138,7 @@ public class BuildCraftTransport {
public static Item pipePowerCobblestone;
public static Item pipePowerStone;
public static Item pipePowerQuartz;
+ public static Item pipePowerIron;
public static Item pipePowerGold;
public static Item pipePowerDiamond;
public static ItemFacade facadeItem;
@@ -164,9 +161,6 @@ public class BuildCraftTransport {
public static BCTrigger triggerGreenSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_GREEN_SIGNAL_INACTIVE, false, IPipe.WireColor.Green);
public static BCTrigger triggerYellowSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_ACTIVE, true, IPipe.WireColor.Yellow);
public static BCTrigger triggerYellowSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_INACTIVE, false, IPipe.WireColor.Yellow);
- public static BCTrigger triggerInventoryBelow25 = new TriggerFilteredBufferInventoryLevel(DefaultProps.TRIGGER_INVENTORY_LEVEL_BELOW25, TriggerFilteredBufferInventoryLevel.State.Below25);
- public static BCTrigger triggerInventoryBelow50 = new TriggerFilteredBufferInventoryLevel(DefaultProps.TRIGGER_INVENTORY_LEVEL_BELOW50, TriggerFilteredBufferInventoryLevel.State.Below50);
- public static BCTrigger triggerInventoryBelow75 = new TriggerFilteredBufferInventoryLevel(DefaultProps.TRIGGER_INVENTORY_LEVEL_BELOW75, TriggerFilteredBufferInventoryLevel.State.Below75);
public static BCAction actionRedSignal = new ActionSignalOutput(DefaultProps.ACTION_RED_SIGNAL, IPipe.WireColor.Red);
public static BCAction actionBlueSignal = new ActionSignalOutput(DefaultProps.ACTION_BLUE_SIGNAL, IPipe.WireColor.Blue);
public static BCAction actionGreenSignal = new ActionSignalOutput(DefaultProps.ACTION_GREEN_SIGNAL, IPipe.WireColor.Green);
@@ -175,6 +169,7 @@ public class BuildCraftTransport {
public static BCAction actionSingleEnergyPulse = new ActionSingleEnergyPulse(DefaultProps.ACTION_SINGLE_ENERGY_PULSE);
public static BCAction[] actionPipeColor = new BCAction[16];
public static BCAction[] actionPipeDirection = new BCAction[16];
+ public static BCAction[] actionPowerLimiter = new BCAction[7];
@Instance("BuildCraft|Transport")
public static BuildCraftTransport instance;
public IIconProvider pipeIconProvider = new PipeIconProvider();
@@ -269,16 +264,17 @@ public class BuildCraftTransport {
pipeWaterproof = new ItemBuildCraft(pipeWaterproofId.getInt());
pipeWaterproof.setUnlocalizedName("pipeWaterproof");
- pipeWaterproof.setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
- LanguageRegistry.addName(pipeWaterproof, "Pipe Waterproof");
+ LanguageRegistry.addName(pipeWaterproof, "Pipe Sealant");
+ CoreProxy.proxy.registerItem(pipeWaterproof);
+
genericPipeBlock = new BlockGenericPipe(genericPipeId.getInt());
CoreProxy.proxy.registerBlock(genericPipeBlock.setUnlocalizedName("pipeBlock"), ItemBlock.class);
// Fixing retro-compatiblity
pipeItemsWood = buildPipe(DefaultProps.PIPE_ITEMS_WOOD_ID, PipeItemsWood.class, "Wooden Transport Pipe", "plankWood", Block.glass, "plankWood");
pipeItemsEmerald = buildPipe(DefaultProps.PIPE_ITEMS_EMERALD_ID, PipeItemsEmerald.class, "Emerald Transport Pipe", Item.emerald, Block.glass, Item.emerald);
- pipeItemsCobblestone = buildPipe(DefaultProps.PIPE_ITEMS_COBBLESTONE_ID, PipeItemsCobblestone.class, "Cobblestone Transport Pipe", Block.cobblestone, Block.glass, Block.cobblestone);
- pipeItemsStone = buildPipe(DefaultProps.PIPE_ITEMS_STONE_ID, PipeItemsStone.class, "Stone Transport Pipe", Block.stone, Block.glass, Block.stone);
+ pipeItemsCobblestone = buildPipe(DefaultProps.PIPE_ITEMS_COBBLESTONE_ID, PipeItemsCobblestone.class, "Cobblestone Transport Pipe", "cobblestone", Block.glass, "cobblestone");
+ pipeItemsStone = buildPipe(DefaultProps.PIPE_ITEMS_STONE_ID, PipeItemsStone.class, "Stone Transport Pipe", "stone", Block.glass, "stone");
pipeItemsQuartz = buildPipe(DefaultProps.PIPE_ITEMS_QUARTZ_ID, PipeItemsQuartz.class, "Quartz Transport Pipe", Block.blockNetherQuartz, Block.glass, Block.blockNetherQuartz);
pipeItemsIron = buildPipe(DefaultProps.PIPE_ITEMS_IRON_ID, PipeItemsIron.class, "Iron Transport Pipe", Item.ingotIron, Block.glass, Item.ingotIron);
pipeItemsGold = buildPipe(DefaultProps.PIPE_ITEMS_GOLD_ID, PipeItemsGold.class, "Golden Transport Pipe", Item.ingotGold, Block.glass, Item.ingotGold);
@@ -298,12 +294,13 @@ public class BuildCraftTransport {
pipeFluidsSandstone = buildPipe(DefaultProps.PIPE_LIQUIDS_SANDSTONE_ID, PipeFluidsSandstone.class, "Sandstone Waterproof Pipe", pipeWaterproof, pipeItemsSandstone);
pipeFluidsVoid = buildPipe(DefaultProps.PIPE_LIQUIDS_VOID_ID, PipeFluidsVoid.class, "Void Waterproof Pipe", pipeWaterproof, pipeItemsVoid);
- pipePowerWood = buildPipe(DefaultProps.PIPE_POWER_WOOD_ID, PipePowerWood.class, "Wooden Conductive Pipe", Item.redstone, pipeItemsWood);
- pipePowerCobblestone = buildPipe(DefaultProps.PIPE_POWER_COBBLESTONE_ID, PipePowerCobblestone.class, "Cobblestone Conductive Pipe", Item.redstone, pipeItemsCobblestone);
- pipePowerStone = buildPipe(DefaultProps.PIPE_POWER_STONE_ID, PipePowerStone.class, "Stone Conductive Pipe", Item.redstone, pipeItemsStone);
- pipePowerQuartz = buildPipe(DefaultProps.PIPE_POWER_QUARTZ_ID, PipePowerQuartz.class, "Quartz Conductive Pipe", Item.redstone, pipeItemsQuartz);
- pipePowerGold = buildPipe(DefaultProps.PIPE_POWER_GOLD_ID, PipePowerGold.class, "Golden Conductive Pipe", Item.redstone, pipeItemsGold);
- pipePowerDiamond = buildPipe(DefaultProps.PIPE_POWER_DIAMOND_ID, PipePowerDiamond.class, "Diamond Conductive Pipe", Item.redstone, pipeItemsDiamond);
+ pipePowerWood = buildPipe(DefaultProps.PIPE_POWER_WOOD_ID, PipePowerWood.class, "Wooden Kinesis Pipe", Item.redstone, pipeItemsWood);
+ pipePowerCobblestone = buildPipe(DefaultProps.PIPE_POWER_COBBLESTONE_ID, PipePowerCobblestone.class, "Cobblestone Kinesis Pipe", Item.redstone, pipeItemsCobblestone);
+ pipePowerStone = buildPipe(DefaultProps.PIPE_POWER_STONE_ID, PipePowerStone.class, "Stone Kinesis Pipe", Item.redstone, pipeItemsStone);
+ pipePowerQuartz = buildPipe(DefaultProps.PIPE_POWER_QUARTZ_ID, PipePowerQuartz.class, "Quartz Kinesis Pipe", Item.redstone, pipeItemsQuartz);
+ pipePowerIron = buildPipe(DefaultProps.PIPE_POWER_IRON_ID, PipePowerIron.class, "Iron Kinesis Pipe", Item.redstone, pipeItemsIron);
+ pipePowerGold = buildPipe(DefaultProps.PIPE_POWER_GOLD_ID, PipePowerGold.class, "Golden Kinesis Pipe", Item.redstone, pipeItemsGold);
+ pipePowerDiamond = buildPipe(DefaultProps.PIPE_POWER_DIAMOND_ID, PipePowerDiamond.class, "Diamond Kinesis Pipe", Item.redstone, pipeItemsDiamond);
pipeStructureCobblestone = buildPipe(DefaultProps.PIPE_STRUCTURE_COBBLESTONE_ID, PipeStructureCobblestone.class, "Cobblestone Structure Pipe", Block.gravel, pipeItemsCobblestone);
@@ -312,49 +309,57 @@ public class BuildCraftTransport {
// 1, 0), Block.glass, new ItemStack(Item.dyePowder, 1, 11));
Property redPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "redPipeWire.id", DefaultProps.RED_PIPE_WIRE);
- redPipeWire = new ItemBuildCraft(redPipeWireId.getInt());
+ redPipeWire = new ItemBuildCraft(redPipeWireId.getInt()).setPassSneakClick(true);
redPipeWire.setUnlocalizedName("redPipeWire");
LanguageRegistry.addName(redPipeWire, "Red Pipe Wire");
+ 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());
+ 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());
+ 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());
+ yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()).setPassSneakClick(true);
yellowPipeWire.setUnlocalizedName("yellowPipeWire");
LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire");
+ CoreProxy.proxy.registerItem(yellowPipeWire);
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 11), new ItemStack(Item.redstone, 1),
new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(yellowPipeWire, 8)));
Property pipeGateId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeGate.id", DefaultProps.GATE_ID);
pipeGate = new ItemGate(pipeGateId.getInt(), 0);
pipeGate.setUnlocalizedName("pipeGate");
+ CoreProxy.proxy.registerItem(pipeGate);
Property pipeGateAutarchicId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeGateAutarchic.id",
DefaultProps.GATE_AUTARCHIC_ID);
pipeGateAutarchic = new ItemGate(pipeGateAutarchicId.getInt(), 1);
pipeGateAutarchic.setUnlocalizedName("pipeGateAutarchic");
+ CoreProxy.proxy.registerItem(pipeGateAutarchic);
Property pipeFacadeId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeFacade.id", DefaultProps.PIPE_FACADE_ID);
facadeItem = new ItemFacade(pipeFacadeId.getInt());
facadeItem.setUnlocalizedName("pipeFacade");
+ CoreProxy.proxy.registerItem(facadeItem);
Property pipePlugId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipePlug.id", DefaultProps.PIPE_PLUG_ID);
plugItem = new ItemPlug(pipePlugId.getInt());
plugItem.setUnlocalizedName("pipePlug");
+ CoreProxy.proxy.registerItem(plugItem);
Property filteredBufferId = BuildCraftCore.mainConfiguration.getBlock("filteredBuffer.id", DefaultProps.FILTERED_BUFFER_ID);
filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt());
@@ -417,6 +422,10 @@ public class BuildCraftTransport {
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
actionPipeDirection[direction.ordinal()] = new ActionPipeDirection(-1, direction);
}
+
+ for (PowerMode limit : PowerMode.VALUES) {
+ actionPowerLimiter[limit.ordinal()] = new ActionPowerLimiter(-1, limit);
+ }
}
public void loadRecipes() {
@@ -427,15 +436,15 @@ public class BuildCraftTransport {
// Add pipe recipes
for (PipeRecipe pipe : pipeRecipes) {
if (pipe.isShapeless) {
- GameRegistry.addShapelessRecipe(pipe.result, pipe.input);
+ CoreProxy.proxy.addShapelessRecipe(pipe.result, pipe.input);
} else {
CoreProxy.proxy.addCraftingRecipe(pipe.result, pipe.input);
}
}
CoreProxy.proxy.addCraftingRecipe(new ItemStack(filteredBufferBlock, 1),
- new Object[]{"wdw", "wcw", "wpw", Character.valueOf('w'), "plankWood", Character.valueOf('d'),
- BuildCraftTransport.pipeItemsDiamond, Character.valueOf('c'), Block.chest, Character.valueOf('p'),
+ new Object[]{"wdw", "wcw", "wpw", 'w', "plankWood", 'd',
+ BuildCraftTransport.pipeItemsDiamond, 'c', Block.chest, 'p',
Block.pistonBase});
//Facade turning helper
@@ -443,26 +452,8 @@ public class BuildCraftTransport {
}
@EventHandler
- public void processIMCRequests(FMLInterModComms.IMCEvent event) {
- Splitter splitter = Splitter.on("@").trimResults();
- for (IMCMessage m : event.getMessages()) {
- if ("add-facade".equals(m.key)) {
- String[] array = Iterables.toArray(splitter.split(m.getStringValue()), String.class);
- if (array.length != 2) {
- Logger.getLogger("Buildcraft").log(Level.INFO,
- String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
- continue;
- }
- Integer blId = Ints.tryParse(array[0]);
- Integer metaId = Ints.tryParse(array[1]);
- if (blId == null || metaId == null) {
- Logger.getLogger("Buildcraft").log(Level.INFO,
- String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
- continue;
- }
- ItemFacade.addFacade(new ItemStack(blId, 1, metaId));
- }
- }
+ public void processIMCRequests(IMCEvent event) {
+ InterModComms.processIMC(event);
}
public static Item buildPipe(int defaultID, Class extends Pipe> clas, String descr, Object... ingredients) {
@@ -480,7 +471,7 @@ public class BuildCraftTransport {
if (ingredients.length == 3) {
recipe.result = new ItemStack(res, 8);
- recipe.input = new Object[]{"ABC", Character.valueOf('A'), ingredients[0], Character.valueOf('B'), ingredients[1], Character.valueOf('C'), ingredients[2]};
+ recipe.input = new Object[]{"ABC", 'A', ingredients[0], 'B', ingredients[1], 'C', ingredients[2]};
pipeRecipes.add(recipe);
} else if (ingredients.length == 2) {
diff --git a/common/buildcraft/api/blueprints/package-info.java b/common/buildcraft/api/blueprints/package-info.java
new file mode 100644
index 00000000..0604277f
--- /dev/null
+++ b/common/buildcraft/api/blueprints/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|blueprints")
+package buildcraft.api.blueprints;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/api/bptblocks/package-info.java b/common/buildcraft/api/bptblocks/package-info.java
new file mode 100644
index 00000000..227914c4
--- /dev/null
+++ b/common/buildcraft/api/bptblocks/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraftAPI|blueprints",provides="BuildCraftAPI|bptblocks")
+package buildcraft.api.bptblocks;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/api/core/package-info.java b/common/buildcraft/api/core/package-info.java
new file mode 100644
index 00000000..bb494d53
--- /dev/null
+++ b/common/buildcraft/api/core/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI|core")
+package buildcraft.api.core;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/api/filler/package-info.java b/common/buildcraft/api/filler/package-info.java
new file mode 100644
index 00000000..6bd704d3
--- /dev/null
+++ b/common/buildcraft/api/filler/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|filler")
+package buildcraft.api.filler;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/api/fuels/package-info.java b/common/buildcraft/api/fuels/package-info.java
new file mode 100644
index 00000000..48ad9319
--- /dev/null
+++ b/common/buildcraft/api/fuels/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|fuels")
+package buildcraft.api.fuels;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/api/gates/ActionManager.java b/common/buildcraft/api/gates/ActionManager.java
index 26cfd2c7..919874e7 100644
--- a/common/buildcraft/api/gates/ActionManager.java
+++ b/common/buildcraft/api/gates/ActionManager.java
@@ -19,12 +19,12 @@ public class ActionManager {
triggerProviders.add(provider);
}
}
-
- public static void registerTrigger(ITrigger trigger){
+
+ public static void registerTrigger(ITrigger trigger) {
triggers.put(trigger.getUniqueTag(), trigger);
}
-
- public static void registerAction(IAction action){
+
+ public static void registerAction(IAction action) {
actions.put(action.getUniqueTag(), action);
}
@@ -52,6 +52,7 @@ public class ActionManager {
}
}
+ //TODO: Use sets not lists
public static LinkedList getNeighborActions(Block block, TileEntity entity) {
LinkedList actions = new LinkedList();
@@ -87,18 +88,18 @@ public class ActionManager {
return triggers;
}
-
- public static ITrigger getTriggerFromLegacyId(int legacyId){
- for(ITrigger trigger : triggers.values()){
- if(trigger.getLegacyId() == legacyId)
+
+ public static ITrigger getTriggerFromLegacyId(int legacyId) {
+ for (ITrigger trigger : triggers.values()) {
+ if (trigger.getLegacyId() == legacyId)
return trigger;
}
return null;
}
-
- public static IAction getActionFromLegacyId(int legacyId){
- for(IAction action : actions.values()){
- if(action.getLegacyId() == legacyId)
+
+ public static IAction getActionFromLegacyId(int legacyId) {
+ for (IAction action : actions.values()) {
+ if (action.getLegacyId() == legacyId)
return action;
}
return null;
diff --git a/common/buildcraft/api/gates/ITrigger.java b/common/buildcraft/api/gates/ITrigger.java
index ab59616b..64851f56 100644
--- a/common/buildcraft/api/gates/ITrigger.java
+++ b/common/buildcraft/api/gates/ITrigger.java
@@ -28,6 +28,11 @@ public interface ITrigger {
*/
boolean hasParameter();
+ /**
+ * Return true if this trigger requires a parameter
+ */
+ boolean requiresParameter();
+
/**
* Return the trigger description in the UI
*/
diff --git a/common/buildcraft/api/gates/ITriggerParameter.java b/common/buildcraft/api/gates/ITriggerParameter.java
index cef436a6..b097667a 100644
--- a/common/buildcraft/api/gates/ITriggerParameter.java
+++ b/common/buildcraft/api/gates/ITriggerParameter.java
@@ -13,6 +13,7 @@ public interface ITriggerParameter {
public abstract void readFromNBT(NBTTagCompound compound);
+ @Deprecated
public abstract ItemStack getItem();
}
diff --git a/common/buildcraft/api/gates/TriggerParameter.java b/common/buildcraft/api/gates/TriggerParameter.java
index c76ce99a..0127bc85 100644
--- a/common/buildcraft/api/gates/TriggerParameter.java
+++ b/common/buildcraft/api/gates/TriggerParameter.java
@@ -66,12 +66,8 @@ public class TriggerParameter implements ITriggerParameter {
}
}
- /*
- * (non-Javadoc)
- *
- * @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#getItem()
- */
@Override
+ @Deprecated
public ItemStack getItem() {
return stack;
}
diff --git a/common/buildcraft/api/gates/package-info.java b/common/buildcraft/api/gates/package-info.java
new file mode 100644
index 00000000..ff77cbac
--- /dev/null
+++ b/common/buildcraft/api/gates/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|gates")
+package buildcraft.api.gates;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/api/inventory/package-info.java b/common/buildcraft/api/inventory/package-info.java
new file mode 100644
index 00000000..5335e411
--- /dev/null
+++ b/common/buildcraft/api/inventory/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|inventory")
+package buildcraft.api.inventory;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/api/package-info.java b/common/buildcraft/api/package-info.java
new file mode 100644
index 00000000..c1be5f46
--- /dev/null
+++ b/common/buildcraft/api/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraft|Core",provides="BuildCraftAPI|core")
+package buildcraft.api;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/api/power/IPowerReceptor.java b/common/buildcraft/api/power/IPowerReceptor.java
index a7f6c421..48b84c90 100644
--- a/common/buildcraft/api/power/IPowerReceptor.java
+++ b/common/buildcraft/api/power/IPowerReceptor.java
@@ -7,7 +7,6 @@
*/
package buildcraft.api.power;
-import buildcraft.api.power.PowerHandler.PowerReceiver;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@@ -31,7 +30,7 @@ public interface IPowerReceptor {
* @param side
* @return
*/
- public PowerReceiver getPowerReceiver(ForgeDirection side);
+ public PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side);
/**
* Call back from the PowerHandler that is called when the stored power
diff --git a/common/buildcraft/api/power/PowerHandler.java b/common/buildcraft/api/power/PowerHandler.java
index bc23ebda..5f405546 100644
--- a/common/buildcraft/api/power/PowerHandler.java
+++ b/common/buildcraft/api/power/PowerHandler.java
@@ -11,6 +11,24 @@ import buildcraft.api.core.SafeTimeTracker;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
+/**
+ * The PowerHandler is similar to FluidTank in that it holds your power and
+ * allows standardized interaction between machines.
+ *
+ * To receive power to your machine you needs create an instance of PowerHandler
+ * and implement IPowerReceptor on the TileEntity.
+ *
+ * If you plan emit power, you need only implement IPowerEmitter. You do not
+ * need a PowerHandler. Engines have a PowerHandler because they can also
+ * receive power from other Engines.
+ *
+ * See TileRefinery for a simple example of a power using machine.
+ *
+ * @see IPowerReceptor
+ * @see IPowerEmitter
+ *
+ * @author CovertJaguar
+ */
public final class PowerHandler {
public static enum Type {
@@ -23,7 +41,7 @@ public final class PowerHandler {
case STORAGE:
return true;
default:
- return false;
+ return false;
}
}
@@ -33,11 +51,16 @@ public final class PowerHandler {
case STORAGE:
return true;
default:
- return false;
+ return false;
}
}
}
+ /**
+ * Extend this class to create custom Perdition algorithms (its not final).
+ *
+ * NOTE: It is not possible to create a Zero perdition algorithm.
+ */
public static class PerditionCalculator {
public static final float DEFAULT_POWERLOSS = 1F;
@@ -48,6 +71,11 @@ public final class PowerHandler {
powerLoss = DEFAULT_POWERLOSS;
}
+ /**
+ * Simple constructor for simple Perdition per tick.
+ *
+ * @param powerLoss power loss per tick
+ */
public PerditionCalculator(float powerLoss) {
if (powerLoss < MIN_POWERLOSS) {
powerLoss = MIN_POWERLOSS;
@@ -66,12 +94,25 @@ public final class PowerHandler {
* @return
*/
public float applyPerdition(PowerHandler powerHandler, float current, long ticksPassed) {
+// float prev = current;
current -= powerLoss * ticksPassed;
if (current < 0) {
current = 0;
}
+// powerHandler.totalLostPower += prev - current;
return current;
}
+
+ /**
+ * Taxes a flat rate on all incoming power.
+ *
+ * Defaults to 0% tax rate.
+ *
+ * @return percent of input to tax
+ */
+ public float getTaxPercent() {
+ return 0;
+ }
}
public static final PerditionCalculator DEFAULT_PERDITION = new PerditionCalculator();
private float minEnergyReceived;
@@ -87,6 +128,11 @@ public final class PowerHandler {
private PerditionCalculator perdition;
private final PowerReceiver receiver;
private final Type type;
+ // Debug
+// private double totalLostPower = 0;
+// private double totalReceivedPower = 0;
+// private double totalUsedPower = 0;
+// private long startTime = -1;
public PowerHandler(IPowerReceptor receptor, Type type) {
this.receptor = receptor;
@@ -147,6 +193,16 @@ public final class PowerHandler {
this.activationEnergy = activationEnergy;
}
+ /**
+ * Allows you define perdition in terms of loss/ticks.
+ *
+ * This function is mostly for legacy implementations. See
+ * PerditionCalculator for more complex perdition formulas.
+ *
+ * @param powerLoss
+ * @param powerLossRegularity
+ * @see PerditionCalculator
+ */
public void configurePowerPerdition(int powerLoss, int powerLossRegularity) {
if (powerLoss == 0 || powerLossRegularity == 0) {
perdition = new PerditionCalculator(0);
@@ -186,6 +242,13 @@ public final class PowerHandler {
* design around this though if you are aware of the limitations.
*/
public void update() {
+// if (startTime == -1)
+// startTime = receptor.getWorld().getTotalWorldTime();
+// else {
+// long duration = receptor.getWorld().getTotalWorldTime() - startTime;
+// System.out.printf("Power Stats: %s - Stored: %.2f Gained: %.2f - %.2f/t Lost: %.2f - %.2f/t Used: %.2f - %.2f/t%n", receptor.getClass().getSimpleName(), energyStored, totalReceivedPower, totalReceivedPower / duration, totalLostPower, totalLostPower / duration, totalUsedPower, totalUsedPower / duration);
+// }
+
applyPerdition();
applyWork();
validateEnergy();
@@ -254,6 +317,9 @@ public final class PowerHandler {
validateEnergy();
+// if (doUse)
+// totalUsedPower += result;
+
return result;
}
@@ -322,6 +388,8 @@ public final class PowerHandler {
/**
* Add power to the PowerReceiver from an external source.
*
+ * IPowerEmitters are responsible for calling this themselves.
+ *
* @param quantity
* @param from
* @return the amount of power used
@@ -338,14 +406,18 @@ public final class PowerHandler {
updateSources(from);
+ used -= used * getPerdition().getTaxPercent();
+
used = addEnergy(used);
applyWork();
if (source == Type.ENGINE && type.eatsEngineExcess()) {
- return Math.min(quantity, maxEnergyReceived);
+ used = Math.min(quantity, maxEnergyReceived);
}
+// totalReceivedPower += used;
+
return used;
}
}
diff --git a/common/buildcraft/api/power/package-info.java b/common/buildcraft/api/power/package-info.java
new file mode 100644
index 00000000..c119e142
--- /dev/null
+++ b/common/buildcraft/api/power/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|power")
+package buildcraft.api.power;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/api/recipes/package-info.java b/common/buildcraft/api/recipes/package-info.java
new file mode 100644
index 00000000..a27517f3
--- /dev/null
+++ b/common/buildcraft/api/recipes/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|recipes")
+package buildcraft.api.recipes;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/api/tools/package-info.java b/common/buildcraft/api/tools/package-info.java
new file mode 100644
index 00000000..a5e03a06
--- /dev/null
+++ b/common/buildcraft/api/tools/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|tools")
+package buildcraft.api.tools;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/api/transport/package-info.java b/common/buildcraft/api/transport/package-info.java
new file mode 100644
index 00000000..46475028
--- /dev/null
+++ b/common/buildcraft/api/transport/package-info.java
@@ -0,0 +1,3 @@
+@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|transport")
+package buildcraft.api.transport;
+import cpw.mods.fml.common.API;
\ No newline at end of file
diff --git a/common/buildcraft/builders/BlockArchitect.java b/common/buildcraft/builders/BlockArchitect.java
index 06f9c3f4..c88b2bca 100644
--- a/common/buildcraft/builders/BlockArchitect.java
+++ b/common/buildcraft/builders/BlockArchitect.java
@@ -41,8 +41,8 @@ public class BlockArchitect extends BlockContainer {
public BlockArchitect(int i) {
super(i, Material.iron);
- setHardness(0.5F);
- //setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setHardness(5F);
+ //setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
diff --git a/common/buildcraft/builders/BlockBlueprintLibrary.java b/common/buildcraft/builders/BlockBlueprintLibrary.java
index 7ccf77d0..10276562 100644
--- a/common/buildcraft/builders/BlockBlueprintLibrary.java
+++ b/common/buildcraft/builders/BlockBlueprintLibrary.java
@@ -32,8 +32,8 @@ public class BlockBlueprintLibrary extends BlockContainer {
public BlockBlueprintLibrary(int i) {
super(i, Material.wood);
- //setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
- setHardness(0.7F);
+ //setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
+ setHardness(5F);
}
@Override
diff --git a/common/buildcraft/builders/BlockBuilder.java b/common/buildcraft/builders/BlockBuilder.java
index 5eae766c..e4681785 100644
--- a/common/buildcraft/builders/BlockBuilder.java
+++ b/common/buildcraft/builders/BlockBuilder.java
@@ -37,8 +37,8 @@ public class BlockBuilder extends BlockContainer {
public BlockBuilder(int i) {
super(i, Material.iron);
- setHardness(0.7F);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setHardness(5F);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
diff --git a/common/buildcraft/builders/BlockFiller.java b/common/buildcraft/builders/BlockFiller.java
index 0c223c17..9e052f9d 100644
--- a/common/buildcraft/builders/BlockFiller.java
+++ b/common/buildcraft/builders/BlockFiller.java
@@ -38,8 +38,8 @@ public class BlockFiller extends BlockContainer {
public BlockFiller(int i) {
super(i, Material.iron);
- setHardness(0.5F);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setHardness(5F);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
diff --git a/common/buildcraft/builders/BlockMarker.java b/common/buildcraft/builders/BlockMarker.java
index adfc49e7..f4001be8 100644
--- a/common/buildcraft/builders/BlockMarker.java
+++ b/common/buildcraft/builders/BlockMarker.java
@@ -31,7 +31,7 @@ public class BlockMarker extends BlockContainer {
super(i, Material.circuits);
setLightValue(0.5F);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
private AxisAlignedBB getBoundingBox(int meta) {
diff --git a/common/buildcraft/builders/ItemBptBase.java b/common/buildcraft/builders/ItemBptBase.java
index 4f623d20..040137ad 100644
--- a/common/buildcraft/builders/ItemBptBase.java
+++ b/common/buildcraft/builders/ItemBptBase.java
@@ -27,7 +27,7 @@ public abstract class ItemBptBase extends ItemBuildCraft {
super(i);
maxStackSize = 1;
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@SuppressWarnings({ "all" })
diff --git a/common/buildcraft/builders/blueprints/Blueprint.java b/common/buildcraft/builders/blueprints/Blueprint.java
index 49e8622a..8552100e 100644
--- a/common/buildcraft/builders/blueprints/Blueprint.java
+++ b/common/buildcraft/builders/blueprints/Blueprint.java
@@ -10,6 +10,7 @@ package buildcraft.builders.blueprints;
import buildcraft.BuildCraftCore;
import buildcraft.api.builder.BlockHandler;
import buildcraft.core.inventory.StackHelper;
+import buildcraft.core.utils.BCLog;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
@@ -78,8 +79,8 @@ public class Blueprint {
setSchematic(x, y, z, schematic);
}
} catch (Throwable error) {
- BuildCraftCore.bcLog.severe(String.format("Error while trying to save block [%s:%d] to blueprint, skipping.", block.getUnlocalizedName(), block.blockID));
- BuildCraftCore.bcLog.throwing(getClass().getCanonicalName(), "setBlock", error);
+ BCLog.logger.severe(String.format("Error while trying to save block [%s:%d] to blueprint, skipping.", block.getUnlocalizedName(), block.blockID));
+ BCLog.logger.throwing(getClass().getCanonicalName(), "setBlock", error);
}
}
@@ -94,8 +95,8 @@ public class Blueprint {
setSchematic(x, y, z, schematic);
}
} catch (Throwable error) {
- BuildCraftCore.bcLog.severe(String.format("Error while trying to save item [%s:%d] to blueprint, skipping.", item.getItem().getUnlocalizedName(), item.itemID));
- BuildCraftCore.bcLog.throwing(getClass().getCanonicalName(), "setBlock", error);
+ BCLog.logger.severe(String.format("Error while trying to save item [%s:%d] to blueprint, skipping.", item.getItem().getUnlocalizedName(), item.itemID));
+ BCLog.logger.throwing(getClass().getCanonicalName(), "setBlock", error);
}
}
diff --git a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java
index 43b19929..68284f29 100644
--- a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java
+++ b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java
@@ -106,7 +106,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
diff --git a/common/buildcraft/builders/gui/GuiBuilder.java b/common/buildcraft/builders/gui/GuiBuilder.java
index 01c0a7d6..a3bd533d 100644
--- a/common/buildcraft/builders/gui/GuiBuilder.java
+++ b/common/buildcraft/builders/gui/GuiBuilder.java
@@ -64,10 +64,10 @@ public class GuiBuilder extends GuiAdvancedInterface {
int realXSize = 0;
if (builder.isBuildingBlueprint()) {
- mc.renderEngine.func_110577_a(BLUEPRINT_TEXTURE);
+ mc.renderEngine.bindTexture(BLUEPRINT_TEXTURE);
realXSize = 256;
} else {
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
realXSize = 176;
}
diff --git a/common/buildcraft/builders/gui/GuiFiller.java b/common/buildcraft/builders/gui/GuiFiller.java
index 6a881622..7c17b209 100644
--- a/common/buildcraft/builders/gui/GuiFiller.java
+++ b/common/buildcraft/builders/gui/GuiFiller.java
@@ -19,7 +19,7 @@ import org.lwjgl.opengl.GL11;
public class GuiFiller extends GuiBuildCraft {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filler.png");
- private static final ResourceLocation BLOCK_TEXTURE = TextureMap.field_110575_b;
+ private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture;
IInventory playerInventory;
TileFiller filler;
@@ -47,12 +47,12 @@ public class GuiFiller extends GuiBuildCraft {
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if (filler.currentPattern != null) {
- mc.renderEngine.func_110577_a(BLOCK_TEXTURE);
+ mc.renderEngine.bindTexture(BLOCK_TEXTURE);
drawTexturedModelRectFromIcon(guiLeft + patternSymbolX, guiTop + patternSymbolY, filler.currentPattern.getTexture(), 16, 16);
}
diff --git a/common/buildcraft/builders/gui/GuiTemplate.java b/common/buildcraft/builders/gui/GuiTemplate.java
index aee74cfb..fccefd98 100644
--- a/common/buildcraft/builders/gui/GuiTemplate.java
+++ b/common/buildcraft/builders/gui/GuiTemplate.java
@@ -52,7 +52,7 @@ public class GuiTemplate extends GuiBuildCraft {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
diff --git a/common/buildcraft/core/BlockBuildCraft.java b/common/buildcraft/core/BlockBuildCraft.java
index 74e84669..5cb35417 100644
--- a/common/buildcraft/core/BlockBuildCraft.java
+++ b/common/buildcraft/core/BlockBuildCraft.java
@@ -14,7 +14,7 @@ public abstract class BlockBuildCraft extends BlockContainer {
protected BlockBuildCraft(int id, Material material) {
super(id, material);
this.rand = new Random();
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
diff --git a/common/buildcraft/core/BlockSpring.java b/common/buildcraft/core/BlockSpring.java
index d4e2115a..b6a3e503 100644
--- a/common/buildcraft/core/BlockSpring.java
+++ b/common/buildcraft/core/BlockSpring.java
@@ -45,7 +45,7 @@ public class BlockSpring extends Block {
setStepSound(soundStoneFootstep);
disableStats();
setTickRandomly(true);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
@@ -92,6 +92,12 @@ public class BlockSpring extends Block {
world.setBlock(x, y + 1, z, spring.liquidBlock.blockID);
}
+ // Prevents updates on chunk generation
+ @Override
+ public boolean func_82506_l() {
+ return false;
+ }
+
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
diff --git a/common/buildcraft/core/CommandBuildCraft.java b/common/buildcraft/core/CommandBuildCraft.java
index f55b391f..6aa5b796 100644
--- a/common/buildcraft/core/CommandBuildCraft.java
+++ b/common/buildcraft/core/CommandBuildCraft.java
@@ -46,9 +46,9 @@ public class CommandBuildCraft extends CommandBase {
commandVersion(sender, arguments);
return;
} else if (arguments[0].matches("help")) {
- sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Format: '" + this.getCommandName() + " '"));
- sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("Available commands:"));
- sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("- version : Version information."));
+ sender.sendChatToPlayer(ChatMessageComponent.createFromText("Format: '" + this.getCommandName() + " '"));
+ sender.sendChatToPlayer(ChatMessageComponent.createFromText("Available commands:"));
+ sender.sendChatToPlayer(ChatMessageComponent.createFromText("- version : Version information."));
return;
}
@@ -58,11 +58,11 @@ public class CommandBuildCraft extends CommandBase {
private void commandVersion(ICommandSender sender, String[] arguments) {
String colour = Version.isOutdated() ? "\u00A7c" : "\u00A7a";
- sender.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(colour + "BuildCraft %s for Minecraft %s (Latest: %s).", Version.getVersion(),
+ sender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format(colour + "BuildCraft %s for Minecraft %s (Latest: %s).", Version.getVersion(),
CoreProxy.proxy.getMinecraftVersion(), Version.getRecommendedVersion())));
if (Version.isOutdated()) {
for (String updateLine : Version.getChangelog()) {
- sender.sendChatToPlayer(ChatMessageComponent.func_111066_d("\u00A79" + updateLine));
+ sender.sendChatToPlayer(ChatMessageComponent.createFromText("\u00A79" + updateLine));
}
}
}
diff --git a/common/buildcraft/core/CoreConstants.java b/common/buildcraft/core/CoreConstants.java
new file mode 100644
index 00000000..eb9ab89d
--- /dev/null
+++ b/common/buildcraft/core/CoreConstants.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.core;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public class CoreConstants {
+
+ public static final float PIPE_MIN_POS = 0.25F;
+ public static final float PIPE_MAX_POS = 0.75F;
+}
diff --git a/common/buildcraft/core/CreativeTabBuildCraft.java b/common/buildcraft/core/CreativeTabBuildCraft.java
index dcb77115..da3c6b07 100644
--- a/common/buildcraft/core/CreativeTabBuildCraft.java
+++ b/common/buildcraft/core/CreativeTabBuildCraft.java
@@ -1,24 +1,59 @@
package buildcraft.core;
import buildcraft.BuildCraftCore;
+import buildcraft.core.utils.Localization;
+import buildcraft.transport.ItemFacade;
+import java.util.Locale;
+import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
-public class CreativeTabBuildCraft extends CreativeTabs {
+public enum CreativeTabBuildCraft {
- public static final CreativeTabs tabBuildCraft = new CreativeTabBuildCraft("buildcraft");
-
- public CreativeTabBuildCraft(String label) {
- super(label);
+ MACHINES,
+ FACADES;
+ private final CreativeTabs tab;
+
+ private CreativeTabBuildCraft() {
+ tab = new Tab();
}
- @Override
- public ItemStack getIconItemStack() {
- return new ItemStack(BuildCraftCore.diamondGearItem);
+ public CreativeTabs get() {
+ return tab;
}
-
- @Override
- public String getTranslatedTabLabel() {
- return "BuildCraft";
+
+ private String getLabel() {
+ return "buildcraft." + name().toLowerCase(Locale.ENGLISH);
+ }
+
+ private String translate() {
+ return Localization.get("tab." + name().toLowerCase(Locale.ENGLISH));
+ }
+
+ private ItemStack getItem() {
+ switch (this) {
+ case FACADES:
+ return ItemFacade.getStack(Block.stoneBrick, 0);
+ default:
+ return new ItemStack(BuildCraftCore.diamondGearItem);
+ }
+
+ }
+
+ private class Tab extends CreativeTabs {
+
+ private Tab() {
+ super(getLabel());
+ }
+
+ @Override
+ public ItemStack getIconItemStack() {
+ return getItem();
+ }
+
+ @Override
+ public String getTranslatedTabLabel() {
+ return translate();
+ }
}
}
diff --git a/common/buildcraft/core/DefaultProps.java b/common/buildcraft/core/DefaultProps.java
index 32cfffd8..f55e6d37 100644
--- a/common/buildcraft/core/DefaultProps.java
+++ b/common/buildcraft/core/DefaultProps.java
@@ -127,6 +127,7 @@ public class DefaultProps {
public static final int FILLER_LIFESPAN_TOUGH = 20;
public static final int FILLER_LIFESPAN_NORMAL = 6000;
+ // These are only till here for Legacy support, new Triggers/Action don't need them
public static int TRIGGER_REDSTONE_ACTIVE = 1;
public static int TRIGGER_REDSTONE_INACTIVE = 2;
public static int TRIGGER_MACHINE_ACTIVE = 3;
@@ -157,9 +158,6 @@ public class DefaultProps {
public static int TRIGGER_RED_ENGINE_HEAT = 28;
public static int TRIGGER_PIPE_REQUESTS_ENERGY = 29;
public static int TRIGGER_PIPE_TOO_MUCH_ENERGY = 30;
- public static int TRIGGER_INVENTORY_LEVEL_BELOW25 = 31;
- public static int TRIGGER_INVENTORY_LEVEL_BELOW50 = 32;
- public static int TRIGGER_INVENTORY_LEVEL_BELOW75 = 33;
public static int ACTION_REDSTONE = 1;
public static int ACTION_RED_SIGNAL = 2;
diff --git a/common/buildcraft/core/EntityRobot.java b/common/buildcraft/core/EntityRobot.java
index 392eae8b..10bb4679 100644
--- a/common/buildcraft/core/EntityRobot.java
+++ b/common/buildcraft/core/EntityRobot.java
@@ -7,10 +7,13 @@
*/
package buildcraft.core;
+
import buildcraft.BuildCraftCore;
-import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder;
import buildcraft.api.core.Position;
+import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder;
+import buildcraft.core.blueprints.BptSlot.Mode;
import buildcraft.core.proxy.CoreProxy;
+import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.BlockUtil;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
@@ -182,6 +185,7 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
targets.pop();
} else if (BlockUtil.canChangeBlock(worldObj, target.getX(), target.getY(), target.getZ())) {
//System.out.printf("RobotChanging %d %d %d %s\n",target.x, target.y, target.z, target.mode);
+
if (!worldObj.isAirBlock(target.getX(), target.getY(), target.getZ())) {
BlockUtil.breakBlock(worldObj, target.getX(), target.getY(), target.getZ());
} else {
@@ -193,7 +197,7 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
targets.pop();
// Defensive code against errors in implementers
t.printStackTrace();
- BuildCraftCore.bcLog.throwing("EntityRobot", "update", t);
+ BCLog.logger.throwing("EntityRobot", "update", t);
}
if (!target.isComplete()) {
targets.addLast(target);
diff --git a/common/buildcraft/core/InterModComms.java b/common/buildcraft/core/InterModComms.java
new file mode 100644
index 00000000..e4a56ece
--- /dev/null
+++ b/common/buildcraft/core/InterModComms.java
@@ -0,0 +1,87 @@
+/**
+ * BuildCraft is open-source. It is distributed under the terms of the
+ * BuildCraft Open Source License. It grants rights to read, modify, compile or
+ * run the code. It does *NOT* grant the right to redistribute this software or
+ * its modifications in any form, binary or source, except if expressively
+ * granted by the copyright holder.
+ */
+package buildcraft.core;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.biome.BiomeGenBase;
+import buildcraft.energy.worldgen.OilPopulate;
+import buildcraft.transport.ItemFacade;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
+import com.google.common.primitives.Ints;
+
+import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
+import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
+
+public class InterModComms {
+
+ public static void processIMC(IMCEvent event) {
+ for (IMCMessage m : event.getMessages()) {
+ if ("add-facade".equals(m.key)) {
+ processFacadeIMC(event, m);
+ } else if (m.key.equals("oil-lake-biome")) {
+ processOilLakeBiomeIMC(event, m);
+ } else if (m.key.equals("oil-gen-exclude")) {
+ processOilGenExcludeIMC(event, m);
+ }
+ }
+ }
+
+ public static void processFacadeIMC(IMCEvent event, IMCMessage m) {
+ try {
+ Splitter splitter = Splitter.on("@").trimResults();
+
+ String[] array = Iterables.toArray(splitter.split(m.getStringValue()), String.class);
+ if (array.length != 2) {
+ Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
+ } else {
+ Integer blId = Ints.tryParse(array[0]);
+ Integer metaId = Ints.tryParse(array[1]);
+ if (blId == null || metaId == null) {
+ Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
+ } else {
+ ItemFacade.addFacade(new ItemStack(blId, 1, metaId));
+ }
+ }
+ } catch (Exception ex) {
+
+ }
+ }
+
+ public static void processOilLakeBiomeIMC(IMCEvent event, IMCMessage m) {
+ try {
+ String biomeID = m.getStringValue().trim();
+ int id = Integer.valueOf(biomeID);
+ if (id >= BiomeGenBase.biomeList.length) {
+ throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length);
+ }
+ OilPopulate.INSTANCE.surfaceDepositBiomes.add(id);
+ } catch (Exception ex) {
+ Logger.getLogger("Buildcraft").log(Level.WARNING, String.format("Received an invalid oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender()));
+ }
+ Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an successfull oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender()));
+ }
+
+ public static void processOilGenExcludeIMC(IMCEvent event, IMCMessage m) {
+ try {
+ String biomeID = m.getStringValue().trim();
+ int id = Integer.valueOf(biomeID);
+ if (id >= BiomeGenBase.biomeList.length) {
+ throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length);
+ }
+ OilPopulate.INSTANCE.excludedBiomes.add(id);
+ } catch (Exception ex) {
+ Logger.getLogger("Buildcraft").log(Level.WARNING, String.format("Received an invalid oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender()));
+ }
+ Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an successfull oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender()));
+ }
+}
diff --git a/common/buildcraft/core/ItemBuildCraft.java b/common/buildcraft/core/ItemBuildCraft.java
index 42a8467b..8b4980bb 100644
--- a/common/buildcraft/core/ItemBuildCraft.java
+++ b/common/buildcraft/core/ItemBuildCraft.java
@@ -1,12 +1,10 @@
/**
- * Copyright (c) SpaceToad, 2011
- * http://www.mod-buildcraft.com
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
- * BuildCraft is distributed under the terms of the Minecraft Mod Public
- * License 1.0, or MMPL. Please check the contents of the license located in
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
-
package buildcraft.core;
import buildcraft.core.utils.StringUtils;
@@ -15,13 +13,16 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
public class ItemBuildCraft extends Item {
private String iconName;
+ private boolean passSneakClick = false;
+
public ItemBuildCraft(int i) {
super(i);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
@@ -36,9 +37,18 @@ public class ItemBuildCraft extends Item {
}
@Override
- @SideOnly(Side.CLIENT)
- public void registerIcons(IconRegister par1IconRegister)
- {
- this.itemIcon = par1IconRegister.registerIcon("buildcraft:" + iconName);
- }
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ this.itemIcon = par1IconRegister.registerIcon("buildcraft:" + iconName);
+ }
+
+ public Item setPassSneakClick(boolean passClick) {
+ this.passSneakClick = passClick;
+ return this;
+ }
+
+ @Override
+ public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6) {
+ return passSneakClick;
+ }
}
diff --git a/common/buildcraft/core/ItemRedstoneChipset.java b/common/buildcraft/core/ItemRedstoneChipset.java
index ff3bd7e5..73f706bf 100644
--- a/common/buildcraft/core/ItemRedstoneChipset.java
+++ b/common/buildcraft/core/ItemRedstoneChipset.java
@@ -1,5 +1,6 @@
package buildcraft.core;
+import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
@@ -10,8 +11,8 @@ import net.minecraft.util.Icon;
public class ItemRedstoneChipset extends ItemBuildCraft {
- @SideOnly(Side.CLIENT)
- private Icon[] icons;
+ @SideOnly(Side.CLIENT)
+ private Icon[] icons;
public ItemRedstoneChipset(int i) {
super(i);
@@ -20,10 +21,10 @@ public class ItemRedstoneChipset extends ItemBuildCraft {
setMaxDamage(0);
}
- @SuppressWarnings({ "all" })
+ @SuppressWarnings({"all"})
@Override
public Icon getIconFromDamage(int i) {
- return i < icons.length ? icons[i] : null;
+ return i < icons.length ? icons[i] : null;
}
@Override
@@ -31,7 +32,7 @@ public class ItemRedstoneChipset extends ItemBuildCraft {
return (new StringBuilder()).append(super.getUnlocalizedName()).append(".").append(itemstack.getItemDamage()).toString();
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings({"rawtypes", "unchecked"})
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List itemList) {
@@ -39,16 +40,21 @@ public class ItemRedstoneChipset extends ItemBuildCraft {
itemList.add(new ItemStack(this, 1, i));
}
}
+ private static String[] chipsetNames = {"redstone_red", "redstone_iron", "redstone_gold", "redstone_diamond", "redstone_pulsating"};
- private static String[] chipsetNames = { "redstone_red", "redstone_iron", "redstone_gold", "redstone_diamond", "redstone_pulsating" };
@Override
@SideOnly(Side.CLIENT)
- public void registerIcons(IconRegister par1IconRegister)
- {
- icons = new Icon[chipsetNames.length];
- int i = 0;
- for (String csName : chipsetNames) {
- icons[i++] = par1IconRegister.registerIcon("buildcraft:"+csName+"_chipset");
- }
+ public void registerIcons(IconRegister par1IconRegister) {
+ icons = new Icon[chipsetNames.length];
+ int i = 0;
+ for (String csName : chipsetNames) {
+ icons[i++] = par1IconRegister.registerIcon("buildcraft:" + csName + "_chipset");
+ }
+ }
+
+ public void registerItemStacks() {
+ for (int i = 0; i < 5; i++) {
+ GameRegistry.registerCustomItemStack(chipsetNames[i] + "_chipset", new ItemStack(this, 1, i));
+ }
}
}
diff --git a/common/buildcraft/core/ItemWrench.java b/common/buildcraft/core/ItemWrench.java
index b4427ae2..da8c2747 100644
--- a/common/buildcraft/core/ItemWrench.java
+++ b/common/buildcraft/core/ItemWrench.java
@@ -5,6 +5,7 @@ import java.util.HashSet;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.block.BlockButton;
+import net.minecraft.block.BlockChest;
import net.minecraft.block.BlockLever;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -20,6 +21,7 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench {
setFull3D();
shiftRotations.add(BlockLever.class);
shiftRotations.add(BlockButton.class);
+ shiftRotations.add(BlockChest.class);
}
private boolean isShiftRotation(Class extends Block> cls) {
diff --git a/common/buildcraft/core/Version.java b/common/buildcraft/core/Version.java
index 20150603..4cecd0e6 100644
--- a/common/buildcraft/core/Version.java
+++ b/common/buildcraft/core/Version.java
@@ -2,6 +2,7 @@ package buildcraft.core;
import buildcraft.BuildCraftCore;
import buildcraft.core.proxy.CoreProxy;
+import buildcraft.core.utils.BCLog;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
@@ -11,23 +12,20 @@ import net.minecraftforge.common.Property;
public class Version implements Runnable {
- private static Version instance = new Version();
+ private static Version instance = new Version();
public enum EnumUpdateState {
+
CURRENT, OUTDATED, CONNECTION_ERROR
}
-
public static final String VERSION = "@VERSION@";
public static final String BUILD_NUMBER = "@BUILD_NUMBER@";
- private static final String REMOTE_VERSION_FILE = "http://bit.ly/buildcraftver";
- private static final String REMOTE_CHANGELOG_ROOT = "https://dl.dropbox.com/u/44760587/buildcraft/changelog/";
-
+ private static final String REMOTE_VERSION_FILE = "http://bit.ly/buildcraftversion";
+ private static final String REMOTE_CHANGELOG_ROOT = "https://dl.dropboxusercontent.com/u/38558957/Minecraft/Buildcraft/changelogs/";
public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT;
-
public static final int FORGE_VERSION_MAJOR = 4;
public static final int FORGE_VERSION_MINOR = 0;
public static final int FORGE_VERSION_PATCH = 0;
-
private static String recommendedVersion;
private static String[] cachedChangelog;
@@ -62,40 +60,38 @@ public class Version implements Runnable {
public static void versionCheck() {
try {
- if ("0.0.0".equals(VERSION)) return;
-
+ if ("0.0.0".equals(VERSION))
+ return;
+
String location = REMOTE_VERSION_FILE;
HttpURLConnection conn = null;
while (location != null && !location.isEmpty()) {
URL url = new URL(location);
-
- if(conn != null)
+
+ if (conn != null)
conn.disconnect();
-
+
conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("User-Agent",
"Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)");
conn.connect();
location = conn.getHeaderField("Location");
}
-
- if(conn == null)
+
+ if (conn == null)
throw new NullPointerException();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- conn.disconnect();
- String line = null;
+ String line;
String mcVersion = CoreProxy.proxy.getMinecraftVersion();
while ((line = reader.readLine()) != null) {
- if (line.startsWith(mcVersion)) {
- if (line.contains(DefaultProps.MOD)) {
-
- String[] tokens = line.split(":");
- recommendedVersion = tokens[2];
-
- if (line.endsWith(VERSION)) {
- BuildCraftCore.bcLog.finer("Using the latest version [" + getVersion() + "] for Minecraft " + mcVersion);
+ String[] tokens = line.split(":");
+ if (mcVersion.matches(tokens[0])) {
+ if (DefaultProps.MOD.matches(tokens[1])) {
+ if (VERSION.matches(tokens[2])) {
+ recommendedVersion = tokens[2];
+ BCLog.logger.finer("Using the latest version [" + getVersion() + "] for Minecraft " + mcVersion);
currentVersion = EnumUpdateState.CURRENT;
return;
}
@@ -103,13 +99,15 @@ public class Version implements Runnable {
}
}
- BuildCraftCore.bcLog.warning("Using outdated version [" + VERSION + " (build:" + BUILD_NUMBER + ")] for Minecraft " + mcVersion
+ BCLog.logger.warning("Using outdated version [" + VERSION + " (build:" + BUILD_NUMBER + ")] for Minecraft " + mcVersion
+ ". Consider updating.");
currentVersion = EnumUpdateState.OUTDATED;
+ conn.disconnect();
+ reader.close();
} catch (Exception e) {
- BuildCraftCore.bcLog.warning("Unable to read from remote version authority.");
- BuildCraftCore.bcLog.warning(e.toString());
+ BCLog.logger.warning("Unable to read from remote version authority.");
+ BCLog.logger.warning(e.toString());
currentVersion = EnumUpdateState.CONNECTION_ERROR;
}
}
@@ -130,20 +128,20 @@ public class Version implements Runnable {
HttpURLConnection conn = null;
while (location != null && !location.isEmpty()) {
URL url = new URL(location);
-
- if(conn != null)
+
+ if (conn != null)
conn.disconnect();
-
+
conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("User-Agent",
"Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)");
conn.connect();
location = conn.getHeaderField("Location");
}
-
- if(conn == null)
+
+ if (conn == null)
throw new NullPointerException();
-
+
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
conn.disconnect();
@@ -164,44 +162,42 @@ public class Version implements Runnable {
} catch (Exception ex) {
ex.printStackTrace();
- BuildCraftCore.bcLog.warning("Unable to read changelog from remote site.");
+ BCLog.logger.warning("Unable to read changelog from remote site.");
}
- return new String[] { String.format("Unable to retrieve changelog for %s %s", DefaultProps.MOD, version) };
+ return new String[]{String.format("Unable to retrieve changelog for %s %s", DefaultProps.MOD, version)};
}
- @Override
- public void run() {
+ @Override
+ public void run() {
- int count = 0;
- currentVersion = null;
+ int count = 0;
+ currentVersion = null;
- BuildCraftCore.bcLog.info("Beginning version check");
+ BCLog.logger.info("Beginning version check");
- try {
- while ((count < 3) && ((currentVersion == null) || (currentVersion == EnumUpdateState.CONNECTION_ERROR))) {
- versionCheck();
- count++;
+ try {
+ while ((count < 3) && ((currentVersion == null) || (currentVersion == EnumUpdateState.CONNECTION_ERROR))) {
+ versionCheck();
+ count++;
- if (currentVersion == EnumUpdateState.CONNECTION_ERROR) {
- BuildCraftCore.bcLog.info("Version check attempt " + count + " failed, trying again in 10 seconds");
- Thread.sleep(10000);
- }
- }
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
+ if (currentVersion == EnumUpdateState.CONNECTION_ERROR) {
+ BCLog.logger.info("Version check attempt " + count + " failed, trying again in 10 seconds");
+ Thread.sleep(10000);
+ }
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
- if (currentVersion == EnumUpdateState.CONNECTION_ERROR) {
- BuildCraftCore.bcLog.info("Version check failed");
- }
+ if (currentVersion == EnumUpdateState.CONNECTION_ERROR) {
+ BCLog.logger.info("Version check failed");
+ }
- }
+ }
- public static void check() {
-
- new Thread(instance).start();
- }
+ public static void check() {
+ new Thread(instance).start();
+ }
}
diff --git a/common/buildcraft/core/blueprints/BptBase.java b/common/buildcraft/core/blueprints/BptBase.java
index 0f578278..819419d8 100644
--- a/common/buildcraft/core/blueprints/BptBase.java
+++ b/common/buildcraft/core/blueprints/BptBase.java
@@ -13,6 +13,7 @@ import buildcraft.BuildCraftCore;
import buildcraft.core.Box;
import buildcraft.core.Version;
import buildcraft.core.proxy.CoreProxy;
+import buildcraft.core.utils.BCLog;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -81,7 +82,7 @@ public abstract class BptBase {
} catch (Throwable t) {
// Defensive code against errors in implementers
t.printStackTrace();
- BuildCraftCore.bcLog.throwing("BptBase", "rotateLeft", t);
+ BCLog.logger.throwing("BptBase", "rotateLeft", t);
}
}
}
diff --git a/common/buildcraft/core/blueprints/BptBlueprint.java b/common/buildcraft/core/blueprints/BptBlueprint.java
index e52aeeac..16cb545c 100644
--- a/common/buildcraft/core/blueprints/BptBlueprint.java
+++ b/common/buildcraft/core/blueprints/BptBlueprint.java
@@ -9,7 +9,6 @@
package buildcraft.core.blueprints;
-import buildcraft.BuildCraftCore;
import buildcraft.api.blueprints.BlockSignature;
import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.api.blueprints.BptBlock;
@@ -17,6 +16,7 @@ import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import buildcraft.api.blueprints.ItemSignature;
import buildcraft.core.IBptContributor;
+import buildcraft.core.utils.BCLog;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
@@ -76,7 +76,7 @@ public class BptBlueprint extends BptBase {
} catch (Throwable t) {
// Defensive code against errors in implementers
t.printStackTrace();
- BuildCraftCore.bcLog.throwing("BptBlueprint", "readFromWorld", t);
+ BCLog.logger.throwing("BptBlueprint", "readFromWorld", t);
}
}
diff --git a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java
index 9b888f5a..7ba5c0e3 100644
--- a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java
+++ b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java
@@ -9,9 +9,9 @@
package buildcraft.core.blueprints;
-import buildcraft.BuildCraftCore;
import buildcraft.core.IBuilderInventory;
import buildcraft.core.blueprints.BptSlot.Mode;
+import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.BlockUtil;
import java.util.Comparator;
import java.util.LinkedList;
@@ -186,7 +186,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} catch (Throwable t) {
// Defensive code against errors in implementers
t.printStackTrace();
- BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "internalGetBlock", t);
+ BCLog.logger.throwing("BptBuilderBlueprint", "internalGetBlock", t);
getNext = false;
}
@@ -232,7 +232,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} catch (Throwable t) {
// Defensive code against errors in implementers
t.printStackTrace();
- BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "checkRequirements", t);
+ BCLog.logger.throwing("BptBuilderBlueprint", "checkRequirements", t);
}
int size = inv.getSizeInventory();
@@ -260,7 +260,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} catch (Throwable t) {
// Defensive code against errors in implementers
t.printStackTrace();
- BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "checkRequirements", t);
+ BCLog.logger.throwing("BptBuilderBlueprint", "checkRequirements", t);
}
if (reqStk.stackSize == 0) {
@@ -290,7 +290,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} catch (Throwable t) {
// Defensive code against errors in implementers
t.printStackTrace();
- BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "useRequirements", t);
+ BCLog.logger.throwing("BptBuilderBlueprint", "useRequirements", t);
}
@@ -319,7 +319,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} catch (Throwable t) {
// Defensive code against errors in implementers
t.printStackTrace();
- BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "useRequirements", t);
+ BCLog.logger.throwing("BptBuilderBlueprint", "useRequirements", t);
}
if (invStk.stackSize == 0) {
@@ -373,7 +373,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} catch (Throwable t) {
// Defensive code against errors in implementers
t.printStackTrace();
- BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "recomputeIfNeeded", t);
+ BCLog.logger.throwing("BptBuilderBlueprint", "recomputeIfNeeded", t);
}
for (ItemStack stack : stacks) {
@@ -429,7 +429,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} catch (Throwable t) {
// Defensive code against errors in implementers
t.printStackTrace();
- BuildCraftCore.bcLog.throwing("BptBuilderBlueprint", "postProcessing", t);
+ BCLog.logger.throwing("BptBuilderBlueprint", "postProcessing", t);
}
}
}
diff --git a/common/buildcraft/core/blueprints/BptError.java b/common/buildcraft/core/blueprints/BptError.java
index 91492698..7a4fa0a5 100644
--- a/common/buildcraft/core/blueprints/BptError.java
+++ b/common/buildcraft/core/blueprints/BptError.java
@@ -9,7 +9,7 @@
package buildcraft.core.blueprints;
-import buildcraft.BuildCraftCore;
+import buildcraft.core.utils.BCLog;
public class BptError extends Exception {
@@ -21,7 +21,7 @@ public class BptError extends Exception {
public BptError(String str) {
super(str);
- BuildCraftCore.bcLog.fine("BLUEPRINT ERROR:" + str);
+ BCLog.logger.fine("BLUEPRINT ERROR:" + str);
}
diff --git a/common/buildcraft/core/fluids/RestrictedTank.java b/common/buildcraft/core/fluids/RestrictedTank.java
index b2f82b9a..40f92e11 100644
--- a/common/buildcraft/core/fluids/RestrictedTank.java
+++ b/common/buildcraft/core/fluids/RestrictedTank.java
@@ -8,6 +8,7 @@
*/
package buildcraft.core.fluids;
+import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
@@ -19,8 +20,8 @@ public class RestrictedTank extends Tank {
private final Fluid[] acceptedFluids;
- public RestrictedTank(String name, int capacity, Fluid... acceptedFluids) {
- super(name, capacity);
+ public RestrictedTank(String name, int capacity, TileEntity tile, Fluid... acceptedFluids) {
+ super(name, capacity, tile);
this.acceptedFluids = acceptedFluids;
}
diff --git a/common/buildcraft/core/fluids/SingleUseTank.java b/common/buildcraft/core/fluids/SingleUseTank.java
index 9b2c4f0d..2b18ba63 100644
--- a/common/buildcraft/core/fluids/SingleUseTank.java
+++ b/common/buildcraft/core/fluids/SingleUseTank.java
@@ -9,10 +9,10 @@
package buildcraft.core.fluids;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.fluids.FluidTank;
/**
*
@@ -22,8 +22,8 @@ public class SingleUseTank extends Tank {
private Fluid acceptedFluid;
- public SingleUseTank(String name, int capacity) {
- super(name, capacity);
+ public SingleUseTank(String name, int capacity, TileEntity tile) {
+ super(name, capacity, tile);
}
@Override
@@ -50,17 +50,15 @@ public class SingleUseTank extends Tank {
}
@Override
- public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
- super.writeToNBT(nbt);
+ public void writeTankToNBT(NBTTagCompound nbt) {
+ super.writeTankToNBT(nbt);
if (acceptedFluid != null)
nbt.setString("acceptedFluid", acceptedFluid.getName());
- return nbt;
}
@Override
- public FluidTank readFromNBT(NBTTagCompound nbt) {
- super.readFromNBT(nbt);
+ public void readTankFromNBT(NBTTagCompound nbt) {
+ super.readTankFromNBT(nbt);
acceptedFluid = FluidRegistry.getFluid(nbt.getString("acceptedFluid"));
- return this;
}
}
diff --git a/common/buildcraft/core/fluids/Tank.java b/common/buildcraft/core/fluids/Tank.java
index 9db95505..1922e79a 100644
--- a/common/buildcraft/core/fluids/Tank.java
+++ b/common/buildcraft/core/fluids/Tank.java
@@ -12,6 +12,7 @@ import buildcraft.core.gui.tooltips.ToolTip;
import buildcraft.core.gui.tooltips.ToolTipLine;
import java.util.Locale;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidTank;
@@ -23,9 +24,10 @@ public class Tank extends FluidTank {
private final String name;
- public Tank(String name, int capacity) {
+ public Tank(String name, int capacity, TileEntity tile) {
super(capacity);
this.name = name;
+ this.tile = tile;
}
public boolean isEmpty() {
@@ -41,22 +43,30 @@ public class Tank extends FluidTank {
}
@Override
- public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
+ public final NBTTagCompound writeToNBT(NBTTagCompound nbt) {
NBTTagCompound tankData = new NBTTagCompound();
super.writeToNBT(tankData);
+ writeTankToNBT(tankData);
nbt.setCompoundTag(name, tankData);
return nbt;
}
@Override
- public FluidTank readFromNBT(NBTTagCompound nbt) {
+ public final FluidTank readFromNBT(NBTTagCompound nbt) {
if (nbt.hasKey(name)) {
NBTTagCompound tankData = nbt.getCompoundTag(name);
super.readFromNBT(tankData);
+ readTankFromNBT(tankData);
}
return this;
}
+ public void writeTankToNBT(NBTTagCompound nbt) {
+ }
+
+ public void readTankFromNBT(NBTTagCompound nbt) {
+ }
+
public ToolTip getToolTip() {
return toolTip;
}
diff --git a/common/buildcraft/core/fluids/TankManager.java b/common/buildcraft/core/fluids/TankManager.java
index 25633d1f..0b14f078 100644
--- a/common/buildcraft/core/fluids/TankManager.java
+++ b/common/buildcraft/core/fluids/TankManager.java
@@ -112,7 +112,7 @@ public class TankManager extends ForwardingList implements IF
public void writeData(DataOutputStream data) throws IOException {
for (Tank tank : tanks) {
FluidStack fluidStack = tank.getFluid();
- if (fluidStack != null) {
+ if (fluidStack != null && fluidStack.getFluid() != null) {
data.writeShort(fluidStack.getFluid().getID());
data.writeInt(fluidStack.amount);
} else {
diff --git a/common/buildcraft/core/gui/GuiAdvancedInterface.java b/common/buildcraft/core/gui/GuiAdvancedInterface.java
index d9108443..bbcf04c3 100644
--- a/common/buildcraft/core/gui/GuiAdvancedInterface.java
+++ b/common/buildcraft/core/gui/GuiAdvancedInterface.java
@@ -36,7 +36,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
}
public ResourceLocation getTexture() {
- return TextureMap.field_110576_c;
+ return TextureMap.locationItemsTexture;
}
public ItemStack getItemStack() {
@@ -54,7 +54,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
if (getItemStack() != null) {
drawStack(getItemStack());
} else if (getIcon() != null) {
- mc.renderEngine.func_110577_a(getTexture());
+ mc.renderEngine.bindTexture(getTexture());
//System.out.printf("Drawing advanced sprite %s (%d,%d) at %d %d\n", getIcon().getIconName(), getIcon().getOriginX(),getIcon().getOriginY(),cornerX + x, cornerY + y);
drawTexturedModelRectFromIcon(cornerX + x, cornerY + y, getIcon(), 16, 16);
}
diff --git a/common/buildcraft/core/gui/GuiBuildCraft.java b/common/buildcraft/core/gui/GuiBuildCraft.java
index 86baf703..fab83ce5 100644
--- a/common/buildcraft/core/gui/GuiBuildCraft.java
+++ b/common/buildcraft/core/gui/GuiBuildCraft.java
@@ -2,7 +2,9 @@ package buildcraft.core.gui;
import buildcraft.core.DefaultProps;
import buildcraft.core.gui.buttons.GuiBetterButton;
+import buildcraft.core.gui.slots.IPhantomSlot;
import buildcraft.core.gui.slots.SlotBase;
+import buildcraft.core.gui.slots.SlotPhantom;
import buildcraft.core.gui.tooltips.ToolTip;
import buildcraft.core.gui.tooltips.ToolTipLine;
import buildcraft.core.utils.SessionVars;
@@ -209,7 +211,7 @@ public abstract class GuiBuildCraft extends GuiContainer {
GL11.glColor4f(colorR, colorG, colorB, 1.0F);
- mc.renderEngine.func_110577_a(LEDGER_TEXTURE);
+ mc.renderEngine.bindTexture(LEDGER_TEXTURE);
drawTexturedModalRect(x, y, 0, 256 - currentHeight, 4, currentHeight);
drawTexturedModalRect(x + 4, y, 256 - currentWidth + 4, 0, currentWidth - 4, 4);
// Add in top left corner again
@@ -335,6 +337,23 @@ public abstract class GuiBuildCraft extends GuiContainer {
ledgerManager.handleMouseClicked(par1, par2, mouseButton);
}
+ @Override
+ protected void mouseClickMove(int x, int y, int mouseButton, long time) {
+ Slot slot = getSlotAtPosition(x, y);
+ if (mouseButton == 1 && slot instanceof IPhantomSlot)
+ return;
+ super.mouseClickMove(x, y, mouseButton, time);
+ }
+
+ public Slot getSlotAtPosition(int x, int y) {
+ for (int slotIndex = 0; slotIndex < this.inventorySlots.inventorySlots.size(); ++slotIndex) {
+ Slot slot = (Slot) this.inventorySlots.inventorySlots.get(slotIndex);
+ if (isMouseOverSlot(slot, x, y))
+ return slot;
+ }
+ return null;
+ }
+
private void drawToolTips(ToolTip toolTips, int mouseX, int mouseY) {
if (toolTips.size() > 0) {
int left = this.guiLeft;
diff --git a/common/buildcraft/core/gui/buttons/GuiBetterButton.java b/common/buildcraft/core/gui/buttons/GuiBetterButton.java
index 7b24f659..5fbcaa91 100644
--- a/common/buildcraft/core/gui/buttons/GuiBetterButton.java
+++ b/common/buildcraft/core/gui/buttons/GuiBetterButton.java
@@ -57,7 +57,7 @@ public class GuiBetterButton extends GuiButton {
}
protected void bindButtonTextures(Minecraft minecraft) {
- minecraft.renderEngine.func_110577_a(BUTTON_TEXTURES);
+ minecraft.renderEngine.bindTexture(BUTTON_TEXTURES);
}
@Override
diff --git a/common/buildcraft/core/gui/buttons/GuiMultiButton.java b/common/buildcraft/core/gui/buttons/GuiMultiButton.java
index d5928ff2..3bc4ea36 100644
--- a/common/buildcraft/core/gui/buttons/GuiMultiButton.java
+++ b/common/buildcraft/core/gui/buttons/GuiMultiButton.java
@@ -1,13 +1,16 @@
package buildcraft.core.gui.buttons;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
+
import org.lwjgl.opengl.GL11;
+import buildcraft.core.gui.tooltips.ToolTip;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
/**
- *
+ *
* @author CovertJaguar
*/
@SideOnly(Side.CLIENT)
@@ -68,4 +71,13 @@ public class GuiMultiButton extends GuiBetterButton {
public MultiButtonController getController() {
return control;
}
+
+ @Override
+ public ToolTip getToolTip() {
+ ToolTip tip = this.control.getButtonState().getToolTip();
+ if (tip != null) {
+ return tip;
+ }
+ return super.getToolTip();
+ }
}
diff --git a/common/buildcraft/core/gui/buttons/IMultiButtonState.java b/common/buildcraft/core/gui/buttons/IMultiButtonState.java
index 92879613..33deca20 100644
--- a/common/buildcraft/core/gui/buttons/IMultiButtonState.java
+++ b/common/buildcraft/core/gui/buttons/IMultiButtonState.java
@@ -1,7 +1,9 @@
package buildcraft.core.gui.buttons;
+import buildcraft.core.gui.tooltips.ToolTip;
+
/**
- *
+ *
* @author CovertJaguar
*/
public interface IMultiButtonState {
@@ -11,4 +13,6 @@ public interface IMultiButtonState {
public String name();
public IButtonTextureSet getTextureSet();
+
+ public ToolTip getToolTip();
}
diff --git a/common/buildcraft/core/gui/buttons/LockButtonState.java b/common/buildcraft/core/gui/buttons/LockButtonState.java
index 88686b34..db86bed9 100644
--- a/common/buildcraft/core/gui/buttons/LockButtonState.java
+++ b/common/buildcraft/core/gui/buttons/LockButtonState.java
@@ -1,13 +1,14 @@
package buildcraft.core.gui.buttons;
+import buildcraft.core.gui.tooltips.ToolTip;
+
/**
- *
+ *
* @author CovertJaguar
*/
public enum LockButtonState implements IMultiButtonState {
- UNLOCKED(new ButtonTextureSet(224, 0, 16, 16)),
- LOCKED(new ButtonTextureSet(240, 0, 16, 16));
+ UNLOCKED(new ButtonTextureSet(224, 0, 16, 16)), LOCKED(new ButtonTextureSet(240, 0, 16, 16));
public static final LockButtonState[] VALUES = values();
private final IButtonTextureSet texture;
@@ -24,4 +25,9 @@ public enum LockButtonState implements IMultiButtonState {
public IButtonTextureSet getTextureSet() {
return texture;
}
+
+ @Override
+ public ToolTip getToolTip() {
+ return null;
+ }
}
diff --git a/common/buildcraft/core/network/IGuiReturnHandler.java b/common/buildcraft/core/network/IGuiReturnHandler.java
new file mode 100644
index 00000000..25b1a63b
--- /dev/null
+++ b/common/buildcraft/core/network/IGuiReturnHandler.java
@@ -0,0 +1,20 @@
+package buildcraft.core.network;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.world.World;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public abstract interface IGuiReturnHandler {
+ public World getWorld();
+
+ public void writeGuiData(DataOutputStream paramDataOutputStream) throws IOException;
+
+ public void readGuiData(DataInputStream paramDataInputStream, EntityPlayer paramEntityPlayer) throws IOException;
+}
diff --git a/common/buildcraft/core/network/PacketGuiReturn.java b/common/buildcraft/core/network/PacketGuiReturn.java
new file mode 100644
index 00000000..e559b24b
--- /dev/null
+++ b/common/buildcraft/core/network/PacketGuiReturn.java
@@ -0,0 +1,89 @@
+package buildcraft.core.network;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import net.minecraftforge.common.DimensionManager;
+import cpw.mods.fml.common.network.PacketDispatcher;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public class PacketGuiReturn extends BuildCraftPacket {
+ private EntityPlayer sender;
+ private IGuiReturnHandler obj;
+ private byte[] extraData;
+
+ public PacketGuiReturn(EntityPlayer sender) {
+ this.sender = sender;
+ }
+
+ public PacketGuiReturn(IGuiReturnHandler obj) {
+ this.obj = obj;
+ this.extraData = null;
+ }
+
+ public PacketGuiReturn(IGuiReturnHandler obj, byte[] extraData) {
+ this.obj = obj;
+ this.extraData = extraData;
+ }
+
+ @Override
+ public void writeData(DataOutputStream data) throws IOException {
+ data.writeInt(obj.getWorld().provider.dimensionId);
+ if (obj instanceof TileEntity) {
+ TileEntity tile = (TileEntity) obj;
+ data.writeBoolean(true);
+ data.writeInt(tile.xCoord);
+ data.writeInt(tile.yCoord);
+ data.writeInt(tile.zCoord);
+ } else if (obj instanceof Entity) {
+ Entity entity = (Entity) obj;
+ data.writeBoolean(false);
+ data.writeInt(entity.entityId);
+ } else
+ return;
+ obj.writeGuiData(data);
+ if (extraData != null)
+ data.write(extraData);
+ }
+
+ @Override
+ public void readData(DataInputStream data) throws IOException {
+ int dim = data.readInt();
+ World world = DimensionManager.getWorld(dim);
+ boolean tileReturn = data.readBoolean();
+ if (tileReturn) {
+ int x = data.readInt();
+ int y = data.readInt();
+ int z = data.readInt();
+
+ TileEntity t = world.getBlockTileEntity(x, y, z);
+
+ if (t instanceof IGuiReturnHandler)
+ ((IGuiReturnHandler) t).readGuiData(data, sender);
+
+ } else {
+ int entityId = data.readInt();
+ Entity entity = world.getEntityByID(entityId);
+
+ if (entity instanceof IGuiReturnHandler)
+ ((IGuiReturnHandler) entity).readGuiData(data, sender);
+ }
+ }
+
+ public void sendPacket() {
+ PacketDispatcher.sendPacketToServer(getPacket());
+ }
+
+ @Override
+ public int getID() {
+ return PacketIds.GUI_RETURN;
+ }
+}
\ No newline at end of file
diff --git a/common/buildcraft/core/network/PacketHandler.java b/common/buildcraft/core/network/PacketHandler.java
index bac2e773..a999117e 100644
--- a/common/buildcraft/core/network/PacketHandler.java
+++ b/common/buildcraft/core/network/PacketHandler.java
@@ -1,15 +1,16 @@
package buildcraft.core.network;
-import cpw.mods.fml.common.network.IPacketHandler;
-import cpw.mods.fml.common.network.Player;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
+
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
+import cpw.mods.fml.common.network.IPacketHandler;
+import cpw.mods.fml.common.network.Player;
public class PacketHandler implements IPacketHandler {
@@ -35,13 +36,14 @@ public class PacketHandler implements IPacketHandler {
int packetID = data.read();
switch (packetID) {
- case PacketIds.TILE_UPDATE:
+ case PacketIds.TILE_UPDATE: {
PacketTileUpdate packetT = new PacketTileUpdate();
packetT.readData(data);
onTileUpdate((EntityPlayer) player, packetT);
break;
+ }
- case PacketIds.STATE_UPDATE:
+ case PacketIds.STATE_UPDATE: {
PacketTileState inPacket = new PacketTileState();
inPacket.readData(data);
World world = ((EntityPlayer) player).worldObj;
@@ -50,6 +52,14 @@ public class PacketHandler implements IPacketHandler {
inPacket.applyStates(data, (ISyncedTile) tile);
}
break;
+ }
+
+ case PacketIds.GUI_RETURN: {
+ PacketGuiReturn packet1 = new PacketGuiReturn((EntityPlayer) player);
+ packet1.readData(data);
+ // onGuiReturn((EntityPlayer) player, packet1);
+ break;
+ }
}
} catch (Exception ex) {
ex.printStackTrace();
diff --git a/common/buildcraft/core/network/PacketIds.java b/common/buildcraft/core/network/PacketIds.java
index a60e97c4..34af2c6f 100644
--- a/common/buildcraft/core/network/PacketIds.java
+++ b/common/buildcraft/core/network/PacketIds.java
@@ -3,32 +3,39 @@ package buildcraft.core.network;
public class PacketIds {
public static final int TILE_UPDATE = 0;
-// public static final int PIPE_DESCRIPTION = 1;
+ // public static final int PIPE_DESCRIPTION = 1;
public static final int PIPE_CONTENTS = 2;
public static final int PIPE_LIQUID = 3;
public static final int PIPE_POWER = 4;
public static final int REQUEST_ITEM_NBT = 5;
public static final int PIPE_ITEM_NBT = 6;
+
public static final int SELECTION_ASSEMBLY_GET = 20;
/** Packet sent to server when a recipe is clicked on in the assembly table */
public static final int SELECTION_ASSEMBLY = 21;
/** Packet to send recipes to client */
public static final int SELECTION_ASSEMBLY_SEND = 22;
+
public static final int DIAMOND_PIPE_SELECT = 31;
public static final int EMERALD_PIPE_SELECT = 32;
+
public static final int GATE_ACTIONS = 40;
public static final int GATE_REQUEST_INIT = 41;
public static final int GATE_REQUEST_SELECTION = 42;
public static final int GATE_SELECTION = 43;
public static final int GATE_SELECTION_CHANGE = 44;
public static final int GATE_TRIGGERS = 45;
+
public static final int REFINERY_FILTER_SET = 50;
+
public static final int ARCHITECT_NAME = 60;
public static final int LIBRARY_ACTION = 61;
public static final int LIBRARY_SELECT = 62;
- public static final int STATE_UPDATE = 100;
-
public static final int ADVANCED_WORKBENCH_SETSLOT = 70;
public static final int SELECTION_ADVANCED_WORKBENCH = 71;
+
+ public static final int GUI_RETURN = 80;
+
+ public static final int STATE_UPDATE = 100;
}
diff --git a/common/buildcraft/core/proxy/CoreProxy.java b/common/buildcraft/core/proxy/CoreProxy.java
index ed15fa5a..14ea71c5 100644
--- a/common/buildcraft/core/proxy/CoreProxy.java
+++ b/common/buildcraft/core/proxy/CoreProxy.java
@@ -34,6 +34,7 @@ import net.minecraft.util.ChatMessageComponent;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.oredict.ShapedOreRecipe;
+import net.minecraftforge.oredict.ShapelessOreRecipe;
public class CoreProxy {
@@ -126,7 +127,8 @@ public class CoreProxy {
}
public void addShapelessRecipe(ItemStack result, Object... recipe) {
- GameRegistry.addShapelessRecipe(result, recipe);
+ CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(result, recipe));
+ //GameRegistry.addShapelessRecipe(result, recipe);
}
public void sendToPlayers(Packet packet, World world, int x, int y, int z, int maxDistance) {
diff --git a/common/buildcraft/core/proxy/CoreProxyClient.java b/common/buildcraft/core/proxy/CoreProxyClient.java
index c30dedca..ebbde727 100644
--- a/common/buildcraft/core/proxy/CoreProxyClient.java
+++ b/common/buildcraft/core/proxy/CoreProxyClient.java
@@ -79,7 +79,7 @@ public class CoreProxyClient extends CoreProxy {
/* LOCALIZATION */
@Override
public String getCurrentLanguage() {
- return Minecraft.getMinecraft().func_135016_M().func_135041_c().func_135034_a();
+ return Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode();
}
@Override
diff --git a/common/buildcraft/core/render/FluidRenderer.java b/common/buildcraft/core/render/FluidRenderer.java
index dd76870a..e5c3836b 100644
--- a/common/buildcraft/core/render/FluidRenderer.java
+++ b/common/buildcraft/core/render/FluidRenderer.java
@@ -7,7 +7,7 @@
*/
package buildcraft.core.render;
-import buildcraft.core.render.RenderEntityBlock.BlockInterface;
+import buildcraft.core.render.RenderEntityBlock.RenderInfo;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
@@ -27,11 +27,11 @@ import org.lwjgl.opengl.GL11;
*/
public class FluidRenderer {
- private static final ResourceLocation BLOCK_TEXTURE = TextureMap.field_110575_b;
+ private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture;
private static Map flowingRenderCache = new HashMap();
private static Map stillRenderCache = new HashMap();
public static final int DISPLAY_STAGES = 100;
- private static final BlockInterface liquidBlock = new BlockInterface();
+ private static final RenderInfo liquidBlock = new RenderInfo();
public static Icon getFluidTexture(FluidStack fluidStack, boolean flowing) {
if (fluidStack == null) {
@@ -46,7 +46,7 @@ public class FluidRenderer {
}
Icon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon();
if (icon == null) {
- icon = ((TextureMap) Minecraft.getMinecraft().func_110434_K().func_110581_b(TextureMap.field_110575_b)).func_110572_b("missingno");
+ icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
}
return icon;
}
diff --git a/common/buildcraft/core/render/RenderEntityBlock.java b/common/buildcraft/core/render/RenderEntityBlock.java
index 6c967381..11955ee3 100644
--- a/common/buildcraft/core/render/RenderEntityBlock.java
+++ b/common/buildcraft/core/render/RenderEntityBlock.java
@@ -8,6 +8,7 @@
package buildcraft.core.render;
import buildcraft.core.EntityBlock;
+import java.util.Arrays;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
@@ -20,15 +21,15 @@ import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
public class RenderEntityBlock extends Render {
-
+
public static RenderEntityBlock INSTANCE = new RenderEntityBlock();
@Override
- protected ResourceLocation func_110775_a(Entity entity) {
+ protected ResourceLocation getEntityTexture(Entity entity) {
throw new UnsupportedOperationException("Not supported yet.");
}
- public static class BlockInterface {
+ public static class RenderInfo {
public double minX;
public double minY;
@@ -38,17 +39,81 @@ public class RenderEntityBlock extends Render {
public double maxZ;
public Block baseBlock = Block.sand;
public Icon texture = null;
+ public Icon[] textureArray = null;
+ public boolean[] renderSide = new boolean[6];
+ public float light = -1f;
+ public int brightness = -1;
- public Icon getBlockTextureFromSide(int i) {
- if (texture == null)
- return baseBlock.getBlockTextureFromSide(i);
- else
- return texture;
+ public RenderInfo() {
+ setRenderAllSides();
+ }
+
+ public RenderInfo(Block template, Icon[] texture) {
+ this();
+ this.baseBlock = template;
+ this.textureArray = texture;
+ }
+
+ public RenderInfo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
+ this();
+ setBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k) {
return baseBlock.getBlockBrightness(iblockaccess, i, j, k);
}
+
+ public final void setBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
+ this.minX = minX;
+ this.minY = minY;
+ this.minZ = minZ;
+ this.maxX = maxX;
+ this.maxY = maxY;
+ this.maxZ = maxZ;
+ }
+
+ public final void setRenderSingleSide(int side) {
+ Arrays.fill(renderSide, false);
+ renderSide[side] = true;
+ }
+
+ public final void setRenderAllSides() {
+ Arrays.fill(renderSide, true);
+ }
+
+ public void rotate() {
+ double temp = minX;
+ minX = minZ;
+ minZ = temp;
+
+ temp = maxX;
+ maxX = maxZ;
+ maxZ = temp;
+ }
+
+ public void reverseX() {
+ double temp = minX;
+ minX = 1 - maxX;
+ maxX = 1 - temp;
+ }
+
+ public void reverseZ() {
+ double temp = minZ;
+ minZ = 1 - maxZ;
+ maxZ = 1 - temp;
+ }
+
+ public Icon getBlockTextureFromSide(int i) {
+ if (texture != null)
+ return texture;
+ if (textureArray == null || textureArray.length == 0)
+ return baseBlock.getBlockTextureFromSide(i);
+ else {
+ if (i >= textureArray.length)
+ i = 0;
+ return textureArray[i];
+ }
+ }
}
private RenderEntityBlock() {
@@ -65,9 +130,9 @@ public class RenderEntityBlock extends Render {
shadowSize = entity.shadowSize;
World world = entity.worldObj;
- BlockInterface util = new BlockInterface();
+ RenderInfo util = new RenderInfo();
util.texture = entity.texture;
- func_110776_a(TextureMap.field_110575_b);
+ bindTexture(TextureMap.locationBlocksTexture);
for (int iBase = 0; iBase < entity.iSize; ++iBase) {
for (int jBase = 0; jBase < entity.jSize; ++jBase) {
@@ -99,7 +164,7 @@ public class RenderEntityBlock extends Render {
lightZ = (int) (Math.floor(entity.posZ) + kBase);
GL11.glDisable(2896 /* GL_LIGHTING */);
- renderBlock(util, world, lightX, lightY, lightZ, false, true);
+ renderBlock(util, world, 0, 0, 0, lightX, lightY, lightZ, false, true);
GL11.glEnable(2896 /* GL_LIGHTING */);
GL11.glPopMatrix();
@@ -108,92 +173,169 @@ public class RenderEntityBlock extends Render {
}
}
- public void renderBlock(BlockInterface block, IBlockAccess blockAccess, int i, int j, int k, boolean doLight, boolean doTessellating) {
- float f = 0.5F;
- float f1 = 1.0F;
- float f2 = 0.8F;
- float f3 = 0.6F;
-
- renderBlocks.renderMaxX = block.maxX;
- renderBlocks.renderMinX = block.minX;
- renderBlocks.renderMaxY = block.maxY;
- renderBlocks.renderMinY = block.minY;
- renderBlocks.renderMaxZ = block.maxZ;
- renderBlocks.renderMinZ = block.minZ;
- renderBlocks.enableAO = false;
+ public void renderBlock(RenderInfo info, IBlockAccess blockAccess, int x, int y, int z, boolean doLight, boolean doTessellating) {
+ renderBlock(info, blockAccess, x, y, z, x, y, z, doLight, doTessellating);
+ }
+ public void renderBlock(RenderInfo info, IBlockAccess blockAccess, double x, double y, double z, int lightX, int lightY, int lightZ, boolean doLight, boolean doTessellating) {
+ float lightBottom = 0.5F;
+ float lightTop = 1.0F;
+ float lightEastWest = 0.8F;
+ float lightNorthSouth = 0.6F;
Tessellator tessellator = Tessellator.instance;
- if (doTessellating) {
+ if (blockAccess == null)
+ doLight = false;
+
+ if (doTessellating && !tessellator.isDrawing)
tessellator.startDrawingQuads();
- }
-
- float f4 = 0, f5 = 0;
+ float light = 0;
if (doLight) {
- f4 = block.getBlockBrightness(blockAccess, i, j, k);
- f5 = block.getBlockBrightness(blockAccess, i, j, k);
- if (f5 < f4) {
- f5 = f4;
- }
- tessellator.setColorOpaque_F(f * f5, f * f5, f * f5);
+ if (info.light < 0) {
+ light = info.baseBlock.getBlockBrightness(blockAccess, (int) lightX, (int) lightY, (int) lightZ);
+ light = light + ((1.0f - light) * 0.4f);
+ } else
+ light = info.light;
+ int brightness = 0;
+ if (info.brightness < 0)
+ brightness = info.baseBlock.getMixedBrightnessForBlock(blockAccess, lightX, lightY, lightZ);
+ else
+ brightness = info.brightness;
+ tessellator.setBrightness(brightness);
+ tessellator.setColorOpaque_F(lightBottom * light, lightBottom * light, lightBottom * light);
+ } else {
+// tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
+ if (info.brightness >= 0)
+ tessellator.setBrightness(info.brightness);
}
- renderBlocks.renderFaceYNeg(null, 0, 0, 0, block.getBlockTextureFromSide(0));
+ renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ);
- if (doLight) {
- f5 = block.getBlockBrightness(blockAccess, i, j, k);
- if (f5 < f4) {
- f5 = f4;
- }
- tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5);
- }
+ if (info.renderSide[0])
+ renderBlocks.renderFaceYNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(0));
- renderBlocks.renderFaceYPos(null, 0, 0, 0, block.getBlockTextureFromSide(1));
+ if (doLight)
+ tessellator.setColorOpaque_F(lightTop * light, lightTop * light, lightTop * light);
- if (doLight) {
- f5 = block.getBlockBrightness(blockAccess, i, j, k);
- if (f5 < f4) {
- f5 = f4;
- }
- tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
- }
+ if (info.renderSide[1])
+ renderBlocks.renderFaceYPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(1));
- renderBlocks.renderFaceZNeg(null, 0, 0, 0, block.getBlockTextureFromSide(2));
+ if (doLight)
+ tessellator.setColorOpaque_F(lightEastWest * light, lightEastWest * light, lightEastWest * light);
- if (doLight) {
- f5 = block.getBlockBrightness(blockAccess, i, j, k);
- if (f5 < f4) {
- f5 = f4;
- }
- tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
- }
+ if (info.renderSide[2])
+ renderBlocks.renderFaceZNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(2));
- renderBlocks.renderFaceZPos(null, 0, 0, 0, block.getBlockTextureFromSide(3));
+ if (doLight)
+ tessellator.setColorOpaque_F(lightEastWest * light, lightEastWest * light, lightEastWest * light);
- if (doLight) {
- f5 = block.getBlockBrightness(blockAccess, i, j, k);
- if (f5 < f4) {
- f5 = f4;
- }
- tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
- }
+ if (info.renderSide[3])
+ renderBlocks.renderFaceZPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(3));
- renderBlocks.renderFaceXNeg(null, 0, 0, 0, block.getBlockTextureFromSide(4));
+ if (doLight)
+ tessellator.setColorOpaque_F(lightNorthSouth * light, lightNorthSouth * light, lightNorthSouth * light);
- if (doLight) {
- f5 = block.getBlockBrightness(blockAccess, i, j, k);
- if (f5 < f4) {
- f5 = f4;
- }
- tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
- }
+ if (info.renderSide[4])
+ renderBlocks.renderFaceXNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(4));
- renderBlocks.renderFaceXPos(null, 0, 0, 0, block.getBlockTextureFromSide(5));
+ if (doLight)
+ tessellator.setColorOpaque_F(lightNorthSouth * light, lightNorthSouth * light, lightNorthSouth * light);
- if (doTessellating) {
+ if (info.renderSide[5])
+ renderBlocks.renderFaceXPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(5));
+
+ if (doTessellating && tessellator.isDrawing)
tessellator.draw();
- }
}
+//
+// public void renderBlock(RenderInfo block, IBlockAccess blockAccess, int i, int j, int k, boolean doLight, boolean doTessellating) {
+// float f = 0.5F;
+// float f1 = 1.0F;
+// float f2 = 0.8F;
+// float f3 = 0.6F;
+//
+// renderBlocks.renderMaxX = block.maxX;
+// renderBlocks.renderMinX = block.minX;
+// renderBlocks.renderMaxY = block.maxY;
+// renderBlocks.renderMinY = block.minY;
+// renderBlocks.renderMaxZ = block.maxZ;
+// renderBlocks.renderMinZ = block.minZ;
+// renderBlocks.enableAO = false;
+//
+//
+// Tessellator tessellator = Tessellator.instance;
+//
+// if (doTessellating) {
+// tessellator.startDrawingQuads();
+// }
+//
+// float f4 = 0, f5 = 0;
+//
+// if (doLight) {
+// f4 = block.getBlockBrightness(blockAccess, i, j, k);
+// f5 = block.getBlockBrightness(blockAccess, i, j, k);
+// if (f5 < f4) {
+// f5 = f4;
+// }
+// tessellator.setColorOpaque_F(f * f5, f * f5, f * f5);
+// }
+//
+// renderBlocks.renderFaceYNeg(null, 0, 0, 0, block.getBlockTextureFromSide(0));
+//
+// if (doLight) {
+// f5 = block.getBlockBrightness(blockAccess, i, j, k);
+// if (f5 < f4) {
+// f5 = f4;
+// }
+// tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5);
+// }
+//
+// renderBlocks.renderFaceYPos(null, 0, 0, 0, block.getBlockTextureFromSide(1));
+//
+// if (doLight) {
+// f5 = block.getBlockBrightness(blockAccess, i, j, k);
+// if (f5 < f4) {
+// f5 = f4;
+// }
+// tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
+// }
+//
+// renderBlocks.renderFaceZNeg(null, 0, 0, 0, block.getBlockTextureFromSide(2));
+//
+// if (doLight) {
+// f5 = block.getBlockBrightness(blockAccess, i, j, k);
+// if (f5 < f4) {
+// f5 = f4;
+// }
+// tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
+// }
+//
+// renderBlocks.renderFaceZPos(null, 0, 0, 0, block.getBlockTextureFromSide(3));
+//
+// if (doLight) {
+// f5 = block.getBlockBrightness(blockAccess, i, j, k);
+// if (f5 < f4) {
+// f5 = f4;
+// }
+// tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
+// }
+//
+// renderBlocks.renderFaceXNeg(null, 0, 0, 0, block.getBlockTextureFromSide(4));
+//
+// if (doLight) {
+// f5 = block.getBlockBrightness(blockAccess, i, j, k);
+// if (f5 < f4) {
+// f5 = f4;
+// }
+// tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
+// }
+//
+// renderBlocks.renderFaceXPos(null, 0, 0, 0, block.getBlockTextureFromSide(5));
+//
+// if (doTessellating) {
+// tessellator.draw();
+// }
+// }
}
diff --git a/common/buildcraft/core/render/RenderLaser.java b/common/buildcraft/core/render/RenderLaser.java
index b74ae911..dc5b859a 100644
--- a/common/buildcraft/core/render/RenderLaser.java
+++ b/common/buildcraft/core/render/RenderLaser.java
@@ -46,7 +46,7 @@ public class RenderLaser extends Render {
GL11.glRotatef((float) laser.angleZ, 0, 1, 0);
GL11.glRotatef((float) laser.angleY, 0, 0, 1);
- renderManager.renderEngine.func_110577_a(laser.getTexture());
+ renderManager.renderEngine.bindTexture(laser.getTexture());
float factor = (float) (1.0 / 16.0);
@@ -78,7 +78,7 @@ public class RenderLaser extends Render {
}
@Override
- protected ResourceLocation func_110775_a(Entity entity) {
+ protected ResourceLocation getEntityTexture(Entity entity) {
return ((EntityLaser) entity).getTexture();
}
}
diff --git a/common/buildcraft/core/render/RenderRobot.java b/common/buildcraft/core/render/RenderRobot.java
index 1aae2e11..6af671a5 100644
--- a/common/buildcraft/core/render/RenderRobot.java
+++ b/common/buildcraft/core/render/RenderRobot.java
@@ -35,7 +35,7 @@ public class RenderRobot extends Render {
GL11.glDisable(2896 /* GL_LIGHTING */);
GL11.glTranslated(x, y, z);
- renderManager.renderEngine.func_110577_a(TEXTURE);
+ renderManager.renderEngine.bindTexture(TEXTURE);
float factor = (float) (1.0 / 16.0);
@@ -47,7 +47,7 @@ public class RenderRobot extends Render {
}
@Override
- protected ResourceLocation func_110775_a(Entity entity) {
+ protected ResourceLocation getEntityTexture(Entity entity) {
return TEXTURE;
}
}
diff --git a/common/buildcraft/core/render/RenderVoid.java b/common/buildcraft/core/render/RenderVoid.java
index 155e23b7..842ed879 100644
--- a/common/buildcraft/core/render/RenderVoid.java
+++ b/common/buildcraft/core/render/RenderVoid.java
@@ -22,7 +22,7 @@ public class RenderVoid extends Render {
}
@Override
- protected ResourceLocation func_110775_a(Entity entity) {
+ protected ResourceLocation getEntityTexture(Entity entity) {
throw new UnsupportedOperationException("Not supported yet.");
}
diff --git a/common/buildcraft/core/render/RenderingEntityBlocks.java b/common/buildcraft/core/render/RenderingEntityBlocks.java
index 157c07a2..cc4a8bc2 100644
--- a/common/buildcraft/core/render/RenderingEntityBlocks.java
+++ b/common/buildcraft/core/render/RenderingEntityBlocks.java
@@ -1,6 +1,7 @@
package buildcraft.core.render;
import buildcraft.BuildCraftCore;
+import buildcraft.core.CoreConstants;
import buildcraft.core.IInventoryRenderer;
import buildcraft.core.utils.Utils;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
@@ -16,7 +17,7 @@ import org.lwjgl.opengl.GL11;
public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler {
- private static final ResourceLocation BLOCK_TEXTURE = TextureMap.field_110575_b;
+ private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture;
public static class EntityRenderIndex {
@@ -57,7 +58,7 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler {
} else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
Tessellator tessellator = Tessellator.instance;
- block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
+ block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
renderer.setRenderBoundsFromBlock(block);
block.setBlockBoundsForItemRender();
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
@@ -96,7 +97,7 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler {
if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {
// renderblocks.renderStandardBlock(block, i, j, k);
} else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
- Minecraft.getMinecraft().renderEngine.func_110577_a(BLOCK_TEXTURE);
+ Minecraft.getMinecraft().renderEngine.bindTexture(BLOCK_TEXTURE);
legacyPipeRender(renderer, world, x, y, z, block, modelId);
}
@@ -116,8 +117,8 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler {
/* LEGACY PIPE RENDERING and quarry frames! */
private void legacyPipeRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l) {
- float minSize = Utils.pipeMinPos;
- float maxSize = Utils.pipeMaxPos;
+ float minSize = CoreConstants.PIPE_MIN_POS;
+ float maxSize = CoreConstants.PIPE_MAX_POS;
block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
renderblocks.setRenderBoundsFromBlock(block);
diff --git a/common/buildcraft/core/triggers/ActionTriggerIconProvider.java b/common/buildcraft/core/triggers/ActionTriggerIconProvider.java
index ad928323..c70aa07a 100644
--- a/common/buildcraft/core/triggers/ActionTriggerIconProvider.java
+++ b/common/buildcraft/core/triggers/ActionTriggerIconProvider.java
@@ -52,7 +52,7 @@ public class ActionTriggerIconProvider implements IIconProvider {
@SideOnly(Side.CLIENT)
- private Icon[] icons;
+ private final Icon[] icons = new Icon[MAX];
private ActionTriggerIconProvider(){}
@@ -65,8 +65,6 @@ public class ActionTriggerIconProvider implements IIconProvider {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) {
- icons = new Icon[MAX];
-
icons[ActionTriggerIconProvider.Action_MachineControl_On] = iconRegister.registerIcon("buildcraft:triggers/action_machinecontrol_on");
icons[ActionTriggerIconProvider.Action_MachineControl_Off] = iconRegister.registerIcon("buildcraft:triggers/action_machinecontrol_off");
icons[ActionTriggerIconProvider.Action_MachineControl_Loop] = iconRegister.registerIcon("buildcraft:triggers/action_machinecontrol_loop");
diff --git a/common/buildcraft/core/triggers/BCTrigger.java b/common/buildcraft/core/triggers/BCTrigger.java
index ecaec208..e94aaeba 100644
--- a/common/buildcraft/core/triggers/BCTrigger.java
+++ b/common/buildcraft/core/triggers/BCTrigger.java
@@ -64,6 +64,11 @@ public abstract class BCTrigger implements ITrigger {
return false;
}
+ @Override
+ public boolean requiresParameter() {
+ return false;
+ }
+
@Override
public String getDescription() {
return "";
diff --git a/common/buildcraft/core/triggers/DefaultTriggerProvider.java b/common/buildcraft/core/triggers/DefaultTriggerProvider.java
index 48c5e643..8f2392a1 100644
--- a/common/buildcraft/core/triggers/DefaultTriggerProvider.java
+++ b/common/buildcraft/core/triggers/DefaultTriggerProvider.java
@@ -29,6 +29,9 @@ public class DefaultTriggerProvider implements ITriggerProvider {
res.add(BuildCraftCore.triggerContainsInventory);
res.add(BuildCraftCore.triggerSpaceInventory);
res.add(BuildCraftCore.triggerFullInventory);
+ res.add(BuildCraftCore.triggerInventoryBelow25);
+ res.add(BuildCraftCore.triggerInventoryBelow50);
+ res.add(BuildCraftCore.triggerInventoryBelow75);
}
if (tile instanceof IFluidHandler) {
diff --git a/common/buildcraft/core/triggers/TriggerFluidContainer.java b/common/buildcraft/core/triggers/TriggerFluidContainer.java
index 6754003a..c9caf496 100644
--- a/common/buildcraft/core/triggers/TriggerFluidContainer.java
+++ b/common/buildcraft/core/triggers/TriggerFluidContainer.java
@@ -58,15 +58,15 @@ public class TriggerFluidContainer extends BCTrigger {
FluidStack searchedFluid = null;
- if (parameter != null && parameter.getItem() != null) {
- searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItem());
+ if (parameter != null && parameter.getItemStack() != null) {
+ searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack());
}
if (searchedFluid != null) {
searchedFluid.amount = 1;
}
- FluidTankInfo[] liquids = container.getTankInfo(ForgeDirection.UNKNOWN);
+ FluidTankInfo[] liquids = container.getTankInfo(side);
if (liquids == null || liquids.length == 0)
return false;
diff --git a/common/buildcraft/core/triggers/TriggerInventory.java b/common/buildcraft/core/triggers/TriggerInventory.java
index 294f596e..7a74d870 100644
--- a/common/buildcraft/core/triggers/TriggerInventory.java
+++ b/common/buildcraft/core/triggers/TriggerInventory.java
@@ -9,10 +9,11 @@ package buildcraft.core.triggers;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.inventory.ISpecialInventory;
-import buildcraft.core.inventory.InventoryWrapper;
+import buildcraft.core.inventory.InventoryIterator;
+import buildcraft.core.inventory.InventoryIterator.IInvSlot;
+import buildcraft.core.inventory.StackHelper;
import java.util.Locale;
import net.minecraft.inventory.IInventory;
-import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
@@ -58,7 +59,7 @@ public class TriggerInventory extends BCTrigger {
ItemStack searchedStack = null;
if (parameter != null) {
- searchedStack = parameter.getItem();
+ searchedStack = parameter.getItemStack();
}
if (tile instanceof ISpecialInventory) {
@@ -82,34 +83,21 @@ public class TriggerInventory extends BCTrigger {
}
if (tile instanceof IInventory) {
- ISidedInventory inv = InventoryWrapper.getWrappedInventory(tile);
- int invSize = inv.getSizeInventory();
-
- if (invSize <= 0)
- return false;
-
+ boolean hasSlots = false;
boolean foundItems = false;
boolean foundSpace = false;
- for (int i : inv.getAccessibleSlotsFromSide(side.ordinal())) {
- ItemStack stack = inv.getStackInSlot(i);
-
- boolean slotEmpty = stack == null || stack.stackSize == 0;
-
- if (searchedStack == null) {
- foundItems |= !slotEmpty;
- } else if (!slotEmpty) {
- foundItems |= stack.isItemEqual(searchedStack);
- }
-
- if (slotEmpty) {
- foundSpace = true;
- } else if (searchedStack != null) {
- if (stack.stackSize < stack.getMaxStackSize() && stack.isItemEqual(searchedStack)) {
- foundSpace = true;
- }
- }
+ for (IInvSlot slot : InventoryIterator.getIterable((IInventory) tile, side)) {
+ hasSlots = true;
+ ItemStack stack = slot.getStackInSlot();
+
+ foundItems |= stack != null && (searchedStack == null || StackHelper.instance().canStacksMerge(stack, searchedStack));
+ foundSpace |= (stack == null || (StackHelper.instance().canStacksMerge(stack, searchedStack) && stack.stackSize < stack.getMaxStackSize()))
+ && (searchedStack == null || slot.canPutStackInSlot(searchedStack));
}
+
+ if(!hasSlots)
+ return false;
switch (state) {
case Empty:
diff --git a/common/buildcraft/core/triggers/TriggerInventoryLevel.java b/common/buildcraft/core/triggers/TriggerInventoryLevel.java
new file mode 100644
index 00000000..9dc2560d
--- /dev/null
+++ b/common/buildcraft/core/triggers/TriggerInventoryLevel.java
@@ -0,0 +1,109 @@
+/**
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.core.triggers;
+
+import buildcraft.api.gates.ActionManager;
+import buildcraft.api.gates.ITriggerParameter;
+import buildcraft.core.inventory.InventoryIterator;
+import buildcraft.core.inventory.InventoryIterator.IInvSlot;
+import buildcraft.core.inventory.StackHelper;
+import java.util.Locale;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.ForgeDirection;
+
+public class TriggerInventoryLevel extends BCTrigger {
+
+ public enum TriggerType {
+
+ BELOW_25, BELOW_50, BELOW_75
+ };
+ public TriggerType type;
+
+ public TriggerInventoryLevel(TriggerType type) {
+ super(0, "buildcraft.inventorylevel." + type.name().toLowerCase(Locale.ENGLISH));
+ this.type = type;
+
+ // Legacy migration code
+ ActionManager.triggers.put("buildcraft.filteredBuffer." + type.name().toLowerCase(Locale.ENGLISH), this);
+ }
+
+ @Override
+ public boolean hasParameter() {
+ return true;
+ }
+
+ @Override
+ public boolean requiresParameter() {
+ return true;
+ }
+
+ @Override
+ public String getDescription() {
+ switch (type) {
+ case BELOW_25:
+ return "Contains < 25%";
+ case BELOW_50:
+ return "Contains < 50%";
+ default:
+ return "Contains < 75%";
+ }
+ }
+
+ @Override
+ public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) {
+ // A parameter is required
+ if (parameter == null)
+ return false;
+
+ if (tile instanceof IInventory) {
+ ItemStack searchStack = parameter.getItemStack();
+
+ int stackSpace = 0;
+ int foundItems = 0;
+ for (IInvSlot slot : InventoryIterator.getIterable((IInventory) tile, side)) {
+ if (slot.canPutStackInSlot(searchStack)) {
+ ItemStack stackInSlot = slot.getStackInSlot();
+ if (stackInSlot == null || StackHelper.instance().canStacksMerge(stackInSlot, searchStack)) {
+ stackSpace++;
+ foundItems += stackInSlot == null ? 0 : stackInSlot.stackSize;
+ }
+ }
+ }
+
+ if (stackSpace > 0) {
+ float percentage = (float) foundItems / ((float) stackSpace * (float) searchStack.getMaxStackSize());
+
+ switch (type) {
+ case BELOW_25:
+ return percentage < 0.25f;
+ case BELOW_50:
+ return percentage < 0.5f;
+ default:
+ return percentage < 0.75f;
+ }
+ }
+
+ }
+
+ return false;
+ }
+
+ @Override
+ public int getIconIndex() {
+ switch (type) {
+ case BELOW_25:
+ return ActionTriggerIconProvider.Trigger_Inventory_Below25;
+ case BELOW_50:
+ return ActionTriggerIconProvider.Trigger_Inventory_Below50;
+ default:
+ return ActionTriggerIconProvider.Trigger_Inventory_Below75;
+ }
+ }
+}
diff --git a/common/buildcraft/core/utils/BCLog.java b/common/buildcraft/core/utils/BCLog.java
new file mode 100644
index 00000000..e987345e
--- /dev/null
+++ b/common/buildcraft/core/utils/BCLog.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.core.utils;
+
+import buildcraft.core.Version;
+import cpw.mods.fml.common.FMLLog;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public class BCLog {
+
+ public static final Logger logger = Logger.getLogger("Buildcraft");
+
+ public static void initLog() {
+ logger.setParent(FMLLog.getLogger());
+ logger.info("Starting BuildCraft " + Version.getVersion());
+ logger.info("Copyright (c) SpaceToad, 2011");
+ logger.info("http://www.mod-buildcraft.com");
+ }
+
+ public static void logErrorAPI(String mod, Throwable error, Class classFile) {
+ StringBuilder msg = new StringBuilder(mod);
+ msg.append(" API error, please update your mods. Error: ").append(error);
+ StackTraceElement[] stackTrace = error.getStackTrace();
+ if (stackTrace.length > 0)
+ msg.append(", ").append(stackTrace[0]);
+ logger.log(Level.SEVERE, msg.toString());
+
+ if (classFile != null) {
+ msg = new StringBuilder(mod);
+ msg.append(" API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain().getCodeSource().getLocation());
+ logger.log(Level.SEVERE, msg.toString());
+ }
+ }
+}
diff --git a/common/buildcraft/core/utils/BlockUtil.java b/common/buildcraft/core/utils/BlockUtil.java
index d1ddfac7..3b173e7b 100644
--- a/common/buildcraft/core/utils/BlockUtil.java
+++ b/common/buildcraft/core/utils/BlockUtil.java
@@ -74,6 +74,14 @@ public class BlockUtil {
return canChangeBlock(world.getBlockId(x, y, z), world, x, y, z);
}
+ public static boolean isAnObstructingBlock(int blockID, World world, int x, int y, int z) {
+ Block block = Block.blocksList[blockID];
+
+ if (blockID == 0 || block == null || block.isAirBlock(world, x, y, z))
+ return false;
+ return true;
+ }
+
public static boolean canChangeBlock(int blockID, World world, int x, int y, int z) {
Block block = Block.blocksList[blockID];
diff --git a/common/buildcraft/core/utils/ConfigUtils.java b/common/buildcraft/core/utils/ConfigUtils.java
new file mode 100644
index 00000000..cb439f66
--- /dev/null
+++ b/common/buildcraft/core/utils/ConfigUtils.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.core.utils;
+
+import buildcraft.BuildCraftCore;
+import java.util.logging.Level;
+import net.minecraftforge.common.Configuration;
+import net.minecraftforge.common.Property;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public class ConfigUtils {
+
+ private static final String COMMENT_PREFIX = "";
+ private static final String COMMENT_SUFFIX = "";
+ private final Configuration config;
+ private final String cat;
+
+ public ConfigUtils(Configuration config, String cat) {
+ this.config = config;
+ this.cat = cat;
+ }
+
+ public boolean get(String tag, boolean defaultValue, String comment) {
+ return get(tag, defaultValue, false, comment);
+ }
+
+ public boolean get(String tag, boolean defaultValue, boolean reset, String comment) {
+ comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX;
+ Property prop = config.get(cat, tag, defaultValue);
+ prop.comment = comment;
+ boolean ret = parseBoolean(prop, defaultValue);
+ if (reset)
+ prop.set(defaultValue);
+ return ret;
+ }
+
+ public int get(String tag, int defaultValue, String comment) {
+ comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX;
+ Property prop = config.get(cat, tag, defaultValue);
+ prop.comment = comment;
+ return parseInteger(prop, defaultValue);
+ }
+
+ public int get(String tag, int min, int defaultValue, int max, String comment) {
+ comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX;
+ Property prop = config.get(cat, tag, defaultValue);
+ prop.comment = comment;
+ int parsed = parseInteger(prop, defaultValue);
+ int clamped = Math.max(parsed, min);
+ clamped = Math.min(clamped, max);
+ if (clamped != parsed)
+ prop.set(clamped);
+ return clamped;
+ }
+
+ public float get(String tag, float min, float defaultValue, float max, String comment) {
+ comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX;
+ Property prop = config.get(cat, tag, defaultValue);
+ prop.comment = comment;
+ double parsed = parseDouble(prop, defaultValue);
+ double clamped = Math.max(parsed, min);
+ clamped = Math.min(clamped, max);
+ if (clamped != parsed)
+ prop.set(clamped);
+ return (float) clamped;
+ }
+
+ private boolean parseBoolean(Property prop, boolean defaultValue) {
+ String value = prop.getString();
+ boolean parsed;
+ try {
+ parsed = Boolean.parseBoolean(value);
+ } catch (NumberFormatException ex) {
+ BCLog.logger.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex);
+ prop.set(defaultValue);
+ return defaultValue;
+ }
+ return parsed;
+ }
+
+ private int parseInteger(Property prop, int defaultValue) {
+ String value = prop.getString();
+ int parsed;
+ try {
+ parsed = Integer.parseInt(value);
+ } catch (NumberFormatException ex) {
+ BCLog.logger.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex);
+ prop.set(defaultValue);
+ return defaultValue;
+ }
+ return parsed;
+ }
+
+ private double parseDouble(Property prop, double defaultValue) {
+ String value = prop.getString();
+ double parsed;
+ try {
+ parsed = Double.parseDouble(value);
+ } catch (NumberFormatException ex) {
+ BCLog.logger.log(Level.WARNING, "Failed to parse config tag, reseting to default: " + prop.getName(), ex);
+ prop.set(defaultValue);
+ return defaultValue;
+ }
+ return parsed;
+ }
+}
diff --git a/common/buildcraft/core/utils/CraftingHelper.java b/common/buildcraft/core/utils/CraftingHelper.java
index 2ba52696..cfa9f706 100644
--- a/common/buildcraft/core/utils/CraftingHelper.java
+++ b/common/buildcraft/core/utils/CraftingHelper.java
@@ -14,59 +14,61 @@ public class CraftingHelper {
@SuppressWarnings({ "unchecked", "rawtypes" })
public static IRecipe findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World)
{
- int var3 = 0;
- ItemStack var4 = null;
- ItemStack var5 = null;
- int var6;
+ // Begin repair recipe handler
+ int itemNum = 0;
+ ItemStack item1 = null;
+ ItemStack item2 = null;
+ int slot;
- for (var6 = 0; var6 < par1InventoryCrafting.getSizeInventory(); ++var6)
+ for (slot = 0; slot < par1InventoryCrafting.getSizeInventory(); ++slot)
{
- ItemStack var7 = par1InventoryCrafting.getStackInSlot(var6);
+ ItemStack itemInSlot = par1InventoryCrafting.getStackInSlot(slot);
- if (var7 != null)
+ if (itemInSlot != null)
{
- if (var3 == 0)
+ if (itemNum == 0)
{
- var4 = var7;
+ item1 = itemInSlot;
}
- if (var3 == 1)
+ if (itemNum == 1)
{
- var5 = var7;
+ item2 = itemInSlot;
}
- ++var3;
+ ++itemNum;
}
}
- if (var3 == 2 && var4.itemID == var5.itemID && var4.stackSize == 1 && var5.stackSize == 1 && Item.itemsList[var4.itemID].isRepairable())
+ if (itemNum == 2 && item1.itemID == item2.itemID && item1.stackSize == 1 && item2.stackSize == 1 && Item.itemsList[item1.itemID].isRepairable())
{
- Item var11 = Item.itemsList[var4.itemID];
- int var13 = var11.getMaxDamage() - var4.getItemDamageForDisplay();
- int var8 = var11.getMaxDamage() - var5.getItemDamageForDisplay();
- int var9 = var13 + var8 + var11.getMaxDamage() * 5 / 100;
- int var10 = var11.getMaxDamage() - var9;
+ Item itemBase = Item.itemsList[item1.itemID];
+ int item1Durability = itemBase.getMaxDamage() - item1.getItemDamageForDisplay();
+ int item2Durability = itemBase.getMaxDamage() - item2.getItemDamageForDisplay();
+ int repairAmt = item1Durability + item2Durability + itemBase.getMaxDamage() * 5 / 100;
+ int newDamage = itemBase.getMaxDamage() - repairAmt;
- if (var10 < 0)
+ if (newDamage < 0)
{
- var10 = 0;
+ newDamage = 0;
}
ArrayList ingredients = new ArrayList(2);
- ingredients.add(var4);
- ingredients.add(var5);
- return new ShapelessRecipes(new ItemStack(var4.itemID, 1, var10),ingredients);
+ ingredients.add(item1);
+ ingredients.add(item2);
+ return new ShapelessRecipes(new ItemStack(item1.itemID, 1, newDamage),ingredients);
}
+ // End repair recipe handler
else
{
List recipes = CraftingManager.getInstance().getRecipeList();
- for (var6 = 0; var6 < recipes.size(); ++var6)
+ for (int index = 0; index < recipes.size(); ++index)
{
- IRecipe var12 = (IRecipe) recipes.get(var6);
+ IRecipe currentRecipe = (IRecipe) recipes.get(index);
- if (var12.matches(par1InventoryCrafting, par2World))
+ if (currentRecipe.matches(par1InventoryCrafting, par2World))
{
- return var12;
+ return currentRecipe;
}
}
diff --git a/common/buildcraft/core/utils/EnumColor.java b/common/buildcraft/core/utils/EnumColor.java
index dcbc39a8..426f3a15 100644
--- a/common/buildcraft/core/utils/EnumColor.java
+++ b/common/buildcraft/core/utils/EnumColor.java
@@ -132,12 +132,12 @@ public enum EnumColor {
}
public EnumColor getNext() {
- EnumColor next = VALUES[(ordinal() + 1) % (VALUES.length - 1)];
+ EnumColor next = VALUES[(ordinal() + 1) % VALUES.length];
return next;
}
public EnumColor getPrevious() {
- EnumColor previous = VALUES[(ordinal() + VALUES.length - 2) % (VALUES.length - 1)];
+ EnumColor previous = VALUES[(ordinal() + VALUES.length - 1) % VALUES.length];
return previous;
}
diff --git a/common/buildcraft/core/utils/Localization.java b/common/buildcraft/core/utils/Localization.java
index 34fc65c8..9ec1fa45 100644
--- a/common/buildcraft/core/utils/Localization.java
+++ b/common/buildcraft/core/utils/Localization.java
@@ -64,6 +64,22 @@ public class Localization {
return mappings.getProperty(key, defaultMappings.getProperty(key, key));
}
+
+ public static synchronized boolean hasKey(String key) {
+ if (getCurrentLanguage() == null) {
+ return false;
+ }
+ if (!getCurrentLanguage().equals(loadedLanguage)) {
+ defaultMappings.clear();
+ mappings.clear();
+ for (modInfo mInfo : mods) {
+ load(mInfo.modName, mInfo.defaultLanguage);
+ }
+ loadedLanguage = getCurrentLanguage();
+ }
+
+ return mappings.getProperty(key, defaultMappings.getProperty(key)) != null;
+ }
private static void load(String path, String default_language) {
InputStream langStream = null;
diff --git a/common/buildcraft/core/utils/MatrixTranformations.java b/common/buildcraft/core/utils/MatrixTranformations.java
new file mode 100644
index 00000000..c5eae1a4
--- /dev/null
+++ b/common/buildcraft/core/utils/MatrixTranformations.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.core.utils;
+
+import net.minecraftforge.common.ForgeDirection;
+
+/**
+ *
+ * @author Krapht
+ */
+public class MatrixTranformations {
+
+ /**
+ * Mirrors the array on the Y axis by calculating offsets from 0.5F
+ *
+ * @param targetArray
+ */
+ public static void mirrorY(float[][] targetArray) {
+ float temp = targetArray[1][0];
+ targetArray[1][0] = (targetArray[1][1] - 0.5F) * -1F + 0.5F; // 1 -> 0.5F -> -0.5F -> 0F
+ targetArray[1][1] = (temp - 0.5F) * -1F + 0.5F; // 0 -> -0.5F -> 0.5F -> 1F
+ }
+
+ /**
+ * Shifts the coordinates around effectively rotating something. Zero state
+ * is DOWN then -> NORTH -> WEST Note - To obtain Position, do a mirrorY() before
+ * rotating
+ *
+ * @param targetArray the array that should be rotated
+ */
+ public static void rotate(float[][] targetArray) {
+ for (int i = 0; i < 2; i++) {
+ float temp = targetArray[2][i];
+ targetArray[2][i] = targetArray[1][i];
+ targetArray[1][i] = targetArray[0][i];
+ targetArray[0][i] = temp;
+ }
+ }
+
+ /**
+ * @param targetArray the array that should be transformed
+ * @param direction
+ */
+ public static void transform(float[][] targetArray, ForgeDirection direction) {
+ if ((direction.ordinal() & 0x1) == 1) {
+ mirrorY(targetArray);
+ }
+
+ for (int i = 0; i < (direction.ordinal() >> 1); i++) {
+ rotate(targetArray);
+ }
+ }
+
+ /**
+ * Clones both dimensions of a float[][]
+ *
+ * @param source the float[][] to deepClone
+ * @return
+ */
+ public static float[][] deepClone(float[][] source) {
+ float[][] target = source.clone();
+ for (int i = 0; i < target.length; i++) {
+ target[i] = source[i].clone();
+ }
+ return target;
+ }
+}
diff --git a/common/buildcraft/core/utils/Utils.java b/common/buildcraft/core/utils/Utils.java
index c4435fcb..435170de 100644
--- a/common/buildcraft/core/utils/Utils.java
+++ b/common/buildcraft/core/utils/Utils.java
@@ -47,9 +47,6 @@ import net.minecraftforge.common.ForgeDirection;
public class Utils {
public static final Random RANDOM = new Random();
- public static final float pipeMinPos = 0.25F;
- public static final float pipeMaxPos = 0.75F;
- public static float pipeNormalSpeed = 0.01F;
private static final List directions = new ArrayList(Arrays.asList(ForgeDirection.VALID_DIRECTIONS));
/* IINVENTORY HELPERS */
@@ -80,14 +77,6 @@ public class Utils {
}
- /**
- * Depending on the kind of item in the pipe, set the floor at a different
- * level to optimize graphical aspect.
- */
- public static float getPipeFloorOf(ItemStack item) {
- return pipeMinPos;
- }
-
public static ForgeDirection get2dOrientation(Position pos1, Position pos2) {
double Dx = pos1.x - pos2.x;
double Dz = pos1.z - pos2.z;
@@ -338,7 +327,7 @@ public class Utils {
if (tile instanceof IInventory && !CoreProxy.proxy.isRenderWorld(world)) {
if (!(tile instanceof IDropControlInventory) || ((IDropControlInventory) tile).doDrop()) {
InvUtils.dropItems(world, (IInventory) tile, i, j, k);
- InvUtils.wipeInventory((IInventory)tile);
+ InvUtils.wipeInventory((IInventory) tile);
}
}
diff --git a/common/buildcraft/energy/BlockBuildcraftFluid.java b/common/buildcraft/energy/BlockBuildcraftFluid.java
index 37fca7fc..b2fe7b3b 100644
--- a/common/buildcraft/energy/BlockBuildcraftFluid.java
+++ b/common/buildcraft/energy/BlockBuildcraftFluid.java
@@ -49,7 +49,16 @@ public class BlockBuildcraftFluid extends BlockFluidClassic {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) {
- this.theIcon = new Icon[]{iconRegister.registerIcon("buildcraft:" + fluidName + "_still"), iconRegister.registerIcon("buildcraft:" + fluidName + "_flow")};
+ this.theIcon = new Icon[] { iconRegister.registerIcon("buildcraft:" + fluidName + "_still"), iconRegister.registerIcon("buildcraft:" + fluidName + "_flow") };
+ }
+
+ @Override
+ public void onNeighborBlockChange(World world, int x, int y, int z, int blockId) {
+ super.onNeighborBlockChange(world, x, y, z, blockId);
+ if (flammable && world.provider.dimensionId == -1) {
+ world.newExplosion(null, x, y, z, 4F, true, true);
+ world.setBlockToAir(x, y, z);
+ }
}
public BlockBuildcraftFluid setFlammable(boolean flammable) {
@@ -82,13 +91,13 @@ public class BlockBuildcraftFluid extends BlockFluidClassic {
return flammable && flammability == 0;
}
- public BlockBuildcraftFluid setParticleColor(float particleRed, float particleGreen, float particleBlue){
+ public BlockBuildcraftFluid setParticleColor(float particleRed, float particleGreen, float particleBlue) {
this.particleRed = particleRed;
this.particleGreen = particleGreen;
this.particleBlue = particleBlue;
return this;
}
-
+
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
@@ -98,21 +107,23 @@ public class BlockBuildcraftFluid extends BlockFluidClassic {
double px = (double) ((float) x + rand.nextFloat());
double py = (double) y - 1.05D;
double pz = (double) ((float) z + rand.nextFloat());
-
+
EntityFX fx = new EntityDropParticleFX(world, px, py, pz, particleRed, particleGreen, particleBlue);
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
}
-
+
@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
- if (world.getBlockMaterial(x, y, z).isLiquid()) return false;
+ if (world.getBlockMaterial(x, y, z).isLiquid())
+ return false;
return super.canDisplace(world, x, y, z);
}
-
+
@Override
public boolean displaceIfPossible(World world, int x, int y, int z) {
- if (world.getBlockMaterial(x, y, z).isLiquid()) return false;
+ if (world.getBlockMaterial(x, y, z).isLiquid())
+ return false;
return super.displaceIfPossible(world, x, y, z);
}
}
diff --git a/common/buildcraft/energy/BlockEngine.java b/common/buildcraft/energy/BlockEngine.java
index 7b76c692..8382700d 100644
--- a/common/buildcraft/energy/BlockEngine.java
+++ b/common/buildcraft/energy/BlockEngine.java
@@ -34,8 +34,8 @@ public class BlockEngine extends BlockContainer {
public BlockEngine(int i) {
super(i, Material.iron);
- setHardness(0.5F);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setHardness(5F);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
setUnlocalizedName("engineBlock");
}
@@ -95,7 +95,7 @@ public class BlockEngine extends BlockContainer {
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileEngine) {
- return ((TileEngine) tile).switchOrientation();
+ return ((TileEngine) tile).switchOrientation(false);
}
return false;
}
@@ -127,7 +127,8 @@ public class BlockEngine extends BlockContainer {
public void onPostBlockPlaced(World world, int x, int y, int z, int par5) {
TileEngine tile = (TileEngine) world.getBlockTileEntity(x, y, z);
tile.orientation = ForgeDirection.UP;
- tile.switchOrientation();
+ if (!tile.isOrientationValid())
+ tile.switchOrientation(true);
}
@Override
diff --git a/common/buildcraft/energy/GuiHandler.java b/common/buildcraft/energy/GuiHandler.java
index 1e084b0f..580a9867 100644
--- a/common/buildcraft/energy/GuiHandler.java
+++ b/common/buildcraft/energy/GuiHandler.java
@@ -1,13 +1,13 @@
package buildcraft.energy;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
import buildcraft.core.GuiIds;
import buildcraft.energy.gui.ContainerEngine;
import buildcraft.energy.gui.GuiCombustionEngine;
import buildcraft.energy.gui.GuiStoneEngine;
import cpw.mods.fml.common.network.IGuiHandler;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.world.World;
public class GuiHandler implements IGuiHandler {
@@ -18,10 +18,10 @@ public class GuiHandler implements IGuiHandler {
return null;
TileEntity tile = world.getBlockTileEntity(x, y, z);
- if (!(tile instanceof TileEngine))
+ if (!(tile instanceof TileEngineWithInventory))
return null;
- TileEngine engine = (TileEngine) tile;
+ TileEngineWithInventory engine = (TileEngineWithInventory) tile;
switch (ID) {
@@ -43,10 +43,10 @@ public class GuiHandler implements IGuiHandler {
return null;
TileEntity tile = world.getBlockTileEntity(x, y, z);
- if (!(tile instanceof TileEngine))
+ if (!(tile instanceof TileEngineWithInventory))
return null;
- TileEngine engine = (TileEngine) tile;
+ TileEngineWithInventory engine = (TileEngineWithInventory) tile;
switch (ID) {
diff --git a/common/buildcraft/energy/ItemBucketBuildcraft.java b/common/buildcraft/energy/ItemBucketBuildcraft.java
index b4a2ff46..8501e23d 100644
--- a/common/buildcraft/energy/ItemBucketBuildcraft.java
+++ b/common/buildcraft/energy/ItemBucketBuildcraft.java
@@ -22,7 +22,7 @@ public class ItemBucketBuildcraft extends ItemBucket {
public ItemBucketBuildcraft(int i, int blockId) {
super(i, blockId);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
setContainerItem(Item.bucketEmpty);
}
diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java
index 2013c9ae..68006a70 100644
--- a/common/buildcraft/energy/TileEngine.java
+++ b/common/buildcraft/energy/TileEngine.java
@@ -7,8 +7,17 @@
*/
package buildcraft.energy;
+import java.util.LinkedList;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagFloat;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftEnergy;
-import buildcraft.api.core.Position;
import buildcraft.api.gates.IOverrideDefaultTriggers;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.power.IPowerEmitter;
@@ -17,28 +26,16 @@ import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import buildcraft.api.transport.IPipeConnection;
+import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.IPipeTile.PipeType;
import buildcraft.core.DefaultProps;
import buildcraft.core.TileBuffer;
import buildcraft.core.TileBuildCraft;
-import buildcraft.core.inventory.InvUtils;
-import buildcraft.core.inventory.SimpleInventory;
import buildcraft.core.network.TileNetworkData;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.energy.gui.ContainerEngine;
-import java.util.LinkedList;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.ICrafting;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTBase;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagFloat;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.common.ForgeDirection;
-public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter, IInventory, IOverrideDefaultTriggers, IPipeConnection {
+public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter, IOverrideDefaultTriggers, IPipeConnection {
public static final ResourceLocation WOOD_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png");
public static final ResourceLocation STONE_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_stone.png");
@@ -56,11 +53,11 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
protected PowerHandler powerHandler;
public float currentOutput = 0;
public boolean isRedstonePowered = false;
- public TileBuffer[] tileCache;
+ private boolean checkOrienation = false;
+ private TileBuffer[] tileCache;
public float progress;
public float energy;
public float heat = MIN_HEAT;
- private final SimpleInventory inv;
//
public @TileNetworkData
EnergyStage energyStage = EnergyStage.BLUE;
@@ -69,17 +66,14 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
public @TileNetworkData
boolean isPumping = false; // Used for SMP synch
- public TileEngine(int invSize) {
+ public TileEngine() {
powerHandler = new PowerHandler(this, Type.ENGINE);
powerHandler.configurePowerPerdition(1, 100);
-
- inv = new SimpleInventory(invSize, "Engine", 64);
}
@Override
public void initialize() {
if (!CoreProxy.proxy.isRenderWorld(worldObj)) {
- tileCache = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, true);
powerHandler.configure(minEnergyReceived(), maxEnergyReceived(), 1, getMaxEnergy());
checkRedstonePower();
}
@@ -175,10 +169,21 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
return;
}
+ if (checkOrienation) {
+ checkOrienation = false;
+ if (!isOrientationValid())
+ switchOrientation(true);
+ }
+
+ if (!isRedstonePowered)
+ if (energy > 1)
+ energy--;
+
updateHeatLevel();
+ getEnergyStage();
engineUpdate();
- TileEntity tile = tileCache[orientation.ordinal()].getTile();
+ TileEntity tile = getTileBuffer(orientation).getTile();
if (progressPart != 0) {
progress += getPistonSpeed();
@@ -211,14 +216,14 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
}
private float getPowerToExtract() {
- TileEntity tile = tileCache[orientation.ordinal()].getTile();
+ TileEntity tile = getTileBuffer(orientation).getTile();
PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite());
return extractEnergy(receptor.getMinEnergyReceived(), receptor.getMaxEnergyReceived(), false); // Comment out for constant power
// return extractEnergy(0, getActualOutput(), false); // Uncomment for constant power
}
private void sendPower() {
- TileEntity tile = tileCache[orientation.ordinal()].getTile();
+ TileEntity tile = getTileBuffer(orientation).getTile();
if (isPoweredTile(tile, orientation)) {
PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite());
@@ -259,15 +264,24 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
sendNetworkUpdate();
}
- public boolean switchOrientation() {
+ public boolean isOrientationValid() {
+ TileEntity tile = getTileBuffer(orientation).getTile();
+ return isPoweredTile(tile, orientation);
+ }
+
+ public boolean switchOrientation(boolean preferPipe) {
+ if (preferPipe && switchOrientation_do(true))
+ return true;
+ return switchOrientation_do(false);
+ }
+
+ private boolean switchOrientation_do(boolean pipesOnly) {
for (int i = orientation.ordinal() + 1; i <= orientation.ordinal() + 6; ++i) {
ForgeDirection o = ForgeDirection.VALID_DIRECTIONS[i % 6];
- Position pos = new Position(xCoord, yCoord, zCoord, o);
- pos.moveForwards(1);
- TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
+ TileEntity tile = getTileBuffer(o).getTile();
- if (isPoweredTile(tile, o)) {
+ if ((!pipesOnly || tile instanceof IPipeTile) && isPoweredTile(tile, o)) {
orientation = o;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord));
@@ -278,6 +292,26 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
return false;
}
+ public TileBuffer getTileBuffer(ForgeDirection side) {
+ if (tileCache == null)
+ tileCache = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, false);
+ return tileCache[side.ordinal()];
+ }
+
+ @Override
+ public void invalidate() {
+ super.invalidate();
+ tileCache = null;
+ checkOrienation = true;
+ }
+
+ @Override
+ public void validate() {
+ super.validate();
+ tileCache = null;
+ checkOrienation = true;
+ }
+
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
@@ -287,7 +321,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
NBTBase tag = data.getTag("heat");
if (tag instanceof NBTTagFloat)
heat = data.getFloat("heat");
- inv.readFromNBT(data);
}
@Override
@@ -297,7 +330,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
data.setFloat("progress", progress);
data.setFloat("energyF", energy);
data.setFloat("heat", heat);
- inv.writeToNBT(data);
}
public void getGUINetworkData(int id, int value) {
@@ -327,55 +359,8 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
iCrafting.sendProgressBarUpdate(containerEngine, 2, Math.round(currentOutput * 10));
iCrafting.sendProgressBarUpdate(containerEngine, 3, Math.round(heat * 100));
}
- /* IINVENTORY IMPLEMENTATION */
-
- @Override
- public int getSizeInventory() {
- return inv.getSizeInventory();
- }
-
- @Override
- public ItemStack getStackInSlot(int slot) {
- return inv.getStackInSlot(slot);
- }
-
- @Override
- public ItemStack decrStackSize(int slot, int amount) {
- return inv.decrStackSize(slot, amount);
- }
-
- @Override
- public ItemStack getStackInSlotOnClosing(int slot) {
- return inv.getStackInSlotOnClosing(slot);
- }
-
- @Override
- public void setInventorySlotContents(int slot, ItemStack itemstack) {
- inv.setInventorySlotContents(slot, itemstack);
- }
-
- @Override
- public boolean isItemValidForSlot(int i, ItemStack itemstack) {
- return true;
- }
public void delete() {
- InvUtils.dropItems(worldObj, inv, xCoord, yCoord, zCoord);
- }
-
- @Override
- public String getInvName() {
- return "Engine";
- }
-
- @Override
- public int getInventoryStackLimit() {
- return 64;
- }
-
- @Override
- public boolean isUseableByPlayer(EntityPlayer entityplayer) {
- return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this;
}
/* STATE INFORMATION */
@@ -444,14 +429,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
return false;
}
- @Override
- public void openChest() {
- }
-
- @Override
- public void closeChest() {
- }
-
public abstract float getMaxEnergy();
public float minEnergyReceived() {
diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java
index c6b2cdae..a98a88b2 100644
--- a/common/buildcraft/energy/TileEngineIron.java
+++ b/common/buildcraft/energy/TileEngineIron.java
@@ -7,6 +7,21 @@
*/
package buildcraft.energy;
+import java.util.LinkedList;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.biome.BiomeGenBase;
+import net.minecraftforge.common.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidContainerRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftEnergy;
import buildcraft.api.fuels.IronEngineCoolant;
@@ -22,37 +37,24 @@ import buildcraft.core.fluids.TankManager;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils;
import buildcraft.energy.gui.ContainerEngine;
-import java.util.LinkedList;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.ICrafting;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.common.ForgeDirection;
-import net.minecraftforge.fluids.Fluid;
-import net.minecraftforge.fluids.FluidContainerRegistry;
-import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.fluids.FluidTankInfo;
-import net.minecraftforge.fluids.IFluidHandler;
-public class TileEngineIron extends TileEngine implements IFluidHandler {
+public class TileEngineIron extends TileEngineWithInventory implements IFluidHandler {
public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 10;
public static float HEAT_PER_MJ = 0.0023F;
- public static float COOLDOWN_RATE = 0.01F;
+ public static float COOLDOWN_RATE = 0.05F;
+ public static int MAX_COOLANT_PER_TICK = 40;
int burnTime = 0;
- private Tank tankFuel;
- private Tank tankCoolant;
+ private Tank tankFuel = new Tank("tankFuel", MAX_LIQUID, this);
+ private Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this);
private TankManager tankManager = new TankManager();
private Fuel currentFuel = null;
public int penaltyCooling = 0;
boolean lastPowered = false;
+ private BiomeGenBase biomeCache;
public TileEngineIron() {
super(1);
- tankFuel = new Tank("tankFuel", MAX_LIQUID);
- tankCoolant = new Tank("tankCoolant",MAX_LIQUID);
tankManager.add(tankFuel);
tankManager.add(tankCoolant);
}
@@ -111,6 +113,21 @@ public class TileEngineIron extends TileEngine implements IFluidHandler {
}
}
+ private float getBiomeTempScalar() {
+ if (biomeCache == null)
+ biomeCache = worldObj.getBiomeGenForCoords(xCoord, zCoord);
+ float tempScalar = biomeCache.temperature - 1.0F;
+ tempScalar *= 0.5F;
+ tempScalar += 1.0F;
+ return tempScalar;
+ }
+
+ @Override
+ public void invalidate() {
+ super.invalidate();
+ biomeCache = null;
+ }
+
@Override
public boolean isBurning() {
FluidStack fuel = tankFuel.getFluid();
@@ -148,13 +165,13 @@ public class TileEngineIron extends TileEngine implements IFluidHandler {
}
currentOutput = currentFuel.powerPerCycle; // Comment out for constant power
addEnergy(currentFuel.powerPerCycle);
- heat += currentFuel.powerPerCycle * HEAT_PER_MJ;
+ heat += currentFuel.powerPerCycle * HEAT_PER_MJ * getBiomeTempScalar();
}
} else if (penaltyCooling <= 0) {
if (lastPowered) {
lastPowered = false;
- penaltyCooling = 30 * 20;
- // 30 sec of penalty on top of the cooling
+ penaltyCooling = 10;
+ // 10 tick of penalty on top of the cooling
}
}
}
@@ -169,7 +186,7 @@ public class TileEngineIron extends TileEngine implements IFluidHandler {
final ItemStack stack = getStackInSlot(0);
if (stack != null) {
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
- if (liquid == null && heat > IDEAL_HEAT) {
+ if (liquid == null && heat > MIN_HEAT * 2) {
liquid = IronEngineCoolant.getFluidCoolant(stack);
}
@@ -181,34 +198,40 @@ public class TileEngineIron extends TileEngine implements IFluidHandler {
}
}
- if (heat > IDEAL_HEAT) {
- float extraHeat = heat - IDEAL_HEAT;
-
- FluidStack coolant = this.tankCoolant.getFluid();
- Coolant currentCoolant = IronEngineCoolant.getCoolant(coolant);
- if (currentCoolant != null) {
- float cooling = currentCoolant.getDegreesCoolingPerMB(heat);
- if (coolant.amount * cooling > extraHeat) {
- coolant.amount -= Math.round(extraHeat / cooling);
- heat = IDEAL_HEAT;
- } else {
- heat -= coolant.amount * cooling;
- tankCoolant.setFluid(null);
- }
- }
- }
-
if (heat > MIN_HEAT && (penaltyCooling > 0 || !isRedstonePowered)) {
heat -= COOLDOWN_RATE;
-
+ coolEngine(MIN_HEAT);
+ getEnergyStage();
+ } else if (heat > IDEAL_HEAT) {
+ coolEngine(IDEAL_HEAT);
}
- if (heat <= MIN_HEAT) {
- heat = MIN_HEAT;
- }
-
- if (heat <= MIN_HEAT && penaltyCooling > 0) {
+ if (heat <= MIN_HEAT && penaltyCooling > 0)
penaltyCooling--;
+
+ if (heat <= MIN_HEAT)
+ heat = MIN_HEAT;
+ }
+
+ private void coolEngine(float idealHeat) {
+ float extraHeat = heat - idealHeat;
+
+ FluidStack coolant = this.tankCoolant.getFluid();
+ if (coolant == null)
+ return;
+
+ int coolantAmount = Math.min(MAX_COOLANT_PER_TICK, coolant.amount);
+ Coolant currentCoolant = IronEngineCoolant.getCoolant(coolant);
+ if (currentCoolant != null) {
+ float cooling = currentCoolant.getDegreesCoolingPerMB(heat);
+ cooling /= getBiomeTempScalar();
+ if (coolantAmount * cooling > extraHeat) {
+ tankCoolant.drain(Math.round(extraHeat / cooling), true);
+ heat -= extraHeat;
+ } else {
+ tankCoolant.drain(coolantAmount, true);
+ heat -= coolantAmount * cooling;
+ }
}
}
diff --git a/common/buildcraft/energy/TileEngineLegacy.java b/common/buildcraft/energy/TileEngineLegacy.java
index c33dfa4b..10364828 100644
--- a/common/buildcraft/energy/TileEngineLegacy.java
+++ b/common/buildcraft/energy/TileEngineLegacy.java
@@ -7,7 +7,6 @@
*/
package buildcraft.energy;
-import buildcraft.core.DefaultProps;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
@@ -23,10 +22,6 @@ public class TileEngineLegacy extends TileEngine {
private NBTTagCompound nbt;
- public TileEngineLegacy() {
- super(0);
- }
-
@Override
public void updateEntity() {
worldObj.removeBlockTileEntity(xCoord, yCoord, zCoord);
diff --git a/common/buildcraft/energy/TileEngineStone.java b/common/buildcraft/energy/TileEngineStone.java
index e5d53c1f..6f385d79 100644
--- a/common/buildcraft/energy/TileEngineStone.java
+++ b/common/buildcraft/energy/TileEngineStone.java
@@ -7,14 +7,8 @@
*/
package buildcraft.energy;
-import buildcraft.BuildCraftCore;
-import buildcraft.BuildCraftEnergy;
-import buildcraft.api.gates.ITrigger;
-import buildcraft.core.GuiIds;
-import buildcraft.core.proxy.CoreProxy;
-import buildcraft.core.utils.Utils;
-import buildcraft.energy.gui.ContainerEngine;
import java.util.LinkedList;
+
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
@@ -22,8 +16,15 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;
+import buildcraft.BuildCraftCore;
+import buildcraft.BuildCraftEnergy;
+import buildcraft.api.gates.ITrigger;
+import buildcraft.core.GuiIds;
+import buildcraft.core.proxy.CoreProxy;
+import buildcraft.core.utils.Utils;
+import buildcraft.energy.gui.ContainerEngine;
-public class TileEngineStone extends TileEngine {
+public class TileEngineStone extends TileEngineWithInventory {
final float MAX_OUTPUT = 1f;
final float MIN_OUTPUT = MAX_OUTPUT / 3;
diff --git a/common/buildcraft/energy/TileEngineWithInventory.java b/common/buildcraft/energy/TileEngineWithInventory.java
new file mode 100644
index 00000000..1eba264f
--- /dev/null
+++ b/common/buildcraft/energy/TileEngineWithInventory.java
@@ -0,0 +1,91 @@
+package buildcraft.energy;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import buildcraft.core.inventory.InvUtils;
+import buildcraft.core.inventory.SimpleInventory;
+
+public abstract class TileEngineWithInventory extends TileEngine implements IInventory{
+
+ private final SimpleInventory inv;
+
+ public TileEngineWithInventory(int invSize) {
+ inv = new SimpleInventory(invSize, "Engine", 64);
+ }
+
+ /* IINVENTORY IMPLEMENTATION */
+
+ @Override
+ public int getSizeInventory() {
+ return inv.getSizeInventory();
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int slot) {
+ return inv.getStackInSlot(slot);
+ }
+
+ @Override
+ public ItemStack decrStackSize(int slot, int amount) {
+ return inv.decrStackSize(slot, amount);
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int slot) {
+ return inv.getStackInSlotOnClosing(slot);
+ }
+
+ @Override
+ public void setInventorySlotContents(int slot, ItemStack itemstack) {
+ inv.setInventorySlotContents(slot, itemstack);
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
+ return true;
+ }
+
+ @Override
+ public String getInvName() {
+ return "Engine";
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer) {
+ return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this;
+ }
+
+ @Override
+ public void openChest() {
+ }
+
+ @Override
+ public void closeChest() {
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound data) {
+ super.readFromNBT(data);
+ inv.readFromNBT(data);
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound data) {
+ super.writeToNBT(data);
+ inv.writeToNBT(data);
+ }
+
+ @Override
+ public void delete() {
+ super.delete();
+ InvUtils.dropItems(worldObj, inv, xCoord, yCoord, zCoord);
+ }
+
+}
\ No newline at end of file
diff --git a/common/buildcraft/energy/TileEngineWood.java b/common/buildcraft/energy/TileEngineWood.java
index f1c0f9da..5791cd62 100644
--- a/common/buildcraft/energy/TileEngineWood.java
+++ b/common/buildcraft/energy/TileEngineWood.java
@@ -7,19 +7,16 @@
*/
package buildcraft.energy;
-import buildcraft.api.transport.IPipeTile.PipeType;
-import buildcraft.core.proxy.CoreProxy;
+import buildcraft.api.power.PowerHandler;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;
+import buildcraft.api.transport.IPipeTile.PipeType;
+import buildcraft.core.proxy.CoreProxy;
public class TileEngineWood extends TileEngine {
public static final float OUTPUT = 0.05F;
- public TileEngineWood() {
- super(0);
- }
-
@Override
public ResourceLocation getTextureFile() {
return WOOD_TEXTURE;
@@ -56,10 +53,8 @@ public class TileEngineWood extends TileEngine {
@Override
public float getPistonSpeed() {
if (CoreProxy.proxy.isSimulating(worldObj))
- return Math.max(0.8f * getHeatLevel(), 0.01f);
+ return Math.max(0.08f * getHeatLevel(), 0.01f);
switch (getEnergyStage()) {
- case BLUE:
- return 0.01F;
case GREEN:
return 0.02F;
case YELLOW:
@@ -67,7 +62,7 @@ public class TileEngineWood extends TileEngine {
case RED:
return 0.08F;
default:
- return 0;
+ return 0.01F;
}
}
@@ -76,7 +71,7 @@ public class TileEngineWood extends TileEngine {
super.engineUpdate();
if (isRedstonePowered)
- if (worldObj.getWorldTime() % 20 == 0)
+ if (worldObj.getTotalWorldTime() % 16 == 0)
addEnergy(1);
}
@@ -107,6 +102,6 @@ public class TileEngineWood extends TileEngine {
@Override
public float maxEnergyExtracted() {
- return 1;
+ return 1 + PowerHandler.PerditionCalculator.MIN_POWERLOSS;
}
}
diff --git a/common/buildcraft/energy/gui/ContainerEngine.java b/common/buildcraft/energy/gui/ContainerEngine.java
index 9c90557d..5b8d017a 100644
--- a/common/buildcraft/energy/gui/ContainerEngine.java
+++ b/common/buildcraft/energy/gui/ContainerEngine.java
@@ -7,19 +7,19 @@
*/
package buildcraft.energy.gui;
-import buildcraft.core.gui.BuildCraftContainer;
-import buildcraft.energy.TileEngine;
-import buildcraft.energy.TileEngineStone;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
+import buildcraft.core.gui.BuildCraftContainer;
+import buildcraft.energy.TileEngineStone;
+import buildcraft.energy.TileEngineWithInventory;
public class ContainerEngine extends BuildCraftContainer {
- protected TileEngine engine;
+ protected TileEngineWithInventory engine;
- public ContainerEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) {
+ public ContainerEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) {
super(tileEngine.getSizeInventory());
engine = tileEngine;
diff --git a/common/buildcraft/energy/gui/GuiCombustionEngine.java b/common/buildcraft/energy/gui/GuiCombustionEngine.java
index a76ae901..a2074c57 100644
--- a/common/buildcraft/energy/gui/GuiCombustionEngine.java
+++ b/common/buildcraft/energy/gui/GuiCombustionEngine.java
@@ -7,24 +7,26 @@
*/
package buildcraft.energy.gui;
-import buildcraft.core.DefaultProps;
-import buildcraft.core.utils.StringUtils;
-import buildcraft.energy.TileEngine;
-import buildcraft.energy.TileEngineIron;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
+
import org.lwjgl.opengl.GL11;
+import buildcraft.core.DefaultProps;
+import buildcraft.core.utils.StringUtils;
+import buildcraft.energy.TileEngineIron;
+import buildcraft.energy.TileEngineWithInventory;
+
public class GuiCombustionEngine extends GuiEngine {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/combustion_engine_gui.png");
- private static final ResourceLocation BLOCK_TEXTURE = TextureMap.field_110575_b;
+ private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture;
- public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) {
+ public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) {
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine);
}
@@ -39,7 +41,7 @@ public class GuiCombustionEngine extends GuiEngine {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
@@ -66,7 +68,7 @@ public class GuiCombustionEngine extends GuiEngine {
if (fluid != null && fluid.getStillIcon() != null) {
liquidIcon = fluid.getStillIcon();
}
- mc.renderEngine.func_110577_a(BLOCK_TEXTURE);
+ mc.renderEngine.bindTexture(BLOCK_TEXTURE);
if (liquidIcon != null) {
while (true) {
@@ -89,7 +91,7 @@ public class GuiCombustionEngine extends GuiEngine {
}
}
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60);
}
}
diff --git a/common/buildcraft/energy/gui/GuiEngine.java b/common/buildcraft/energy/gui/GuiEngine.java
index 2012d034..5624fb33 100644
--- a/common/buildcraft/energy/gui/GuiEngine.java
+++ b/common/buildcraft/energy/gui/GuiEngine.java
@@ -13,7 +13,7 @@ import net.minecraft.util.ResourceLocation;
public abstract class GuiEngine extends GuiBuildCraft {
- private static final ResourceLocation ITEM_TEXTURE = TextureMap.field_110576_c;
+ private static final ResourceLocation ITEM_TEXTURE = TextureMap.locationItemsTexture;
protected class EngineLedger extends Ledger {
@@ -35,7 +35,7 @@ public abstract class GuiEngine extends GuiBuildCraft {
drawBackground(x, y);
// Draw icon
- Minecraft.getMinecraft().renderEngine.func_110577_a(ITEM_TEXTURE);
+ Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);
drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4);
if (!isFullyOpened())
diff --git a/common/buildcraft/energy/gui/GuiStoneEngine.java b/common/buildcraft/energy/gui/GuiStoneEngine.java
index dee51ab7..0972f73c 100644
--- a/common/buildcraft/energy/gui/GuiStoneEngine.java
+++ b/common/buildcraft/energy/gui/GuiStoneEngine.java
@@ -7,18 +7,21 @@
*/
package buildcraft.energy.gui;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.util.ResourceLocation;
+
+import org.lwjgl.opengl.GL11;
+
import buildcraft.core.DefaultProps;
import buildcraft.core.utils.StringUtils;
import buildcraft.energy.TileEngine;
-import net.minecraft.entity.player.InventoryPlayer;
-import net.minecraft.util.ResourceLocation;
-import org.lwjgl.opengl.GL11;
+import buildcraft.energy.TileEngineWithInventory;
public class GuiStoneEngine extends GuiEngine {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/steam_engine_gui.png");
- public GuiStoneEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) {
+ public GuiStoneEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) {
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine);
}
@@ -33,7 +36,7 @@ public class GuiStoneEngine extends GuiEngine {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
diff --git a/common/buildcraft/energy/render/RenderEngine.java b/common/buildcraft/energy/render/RenderEngine.java
index 1326ec7f..a72a96c8 100644
--- a/common/buildcraft/energy/render/RenderEngine.java
+++ b/common/buildcraft/energy/render/RenderEngine.java
@@ -161,7 +161,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor
float factor = (float) (1.0 / 16.0);
- func_110628_a(baseTexture);
+ bindTexture(baseTexture);
box.render(factor);
@@ -169,7 +169,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor
movingBox.render(factor);
GL11.glTranslatef(-translate[0] * translatefact, -translate[1] * translatefact, -translate[2] * translatefact);
- func_110628_a(CHAMBER_TEXTURE);
+ bindTexture(CHAMBER_TEXTURE);
float chamberf = 2F / 16F;
@@ -199,7 +199,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor
break;
}
- func_110628_a(texture);
+ bindTexture(texture);
trunk.render(factor);
diff --git a/common/buildcraft/energy/worldgen/OilPopulate.java b/common/buildcraft/energy/worldgen/OilPopulate.java
index bfc1bf4a..1846e891 100644
--- a/common/buildcraft/energy/worldgen/OilPopulate.java
+++ b/common/buildcraft/energy/worldgen/OilPopulate.java
@@ -87,6 +87,7 @@ public class OilPopulate {
|| (BiomeDictionary.isBiomeOfType(biome, FOREST) && BiomeDictionary.isBiomeOfType(biome, FROZEN));
double bonus = oilBiome ? 3.0 : 1.0;
+ bonus *= BuildCraftEnergy.oilWellScalar;
if (excessiveBiomes.contains(biome.biomeID)) {
bonus *= 30.0;
} else if (BuildCraftCore.debugMode) {
diff --git a/common/buildcraft/factory/BlockAutoWorkbench.java b/common/buildcraft/factory/BlockAutoWorkbench.java
index 83a7b4a4..45e1e90e 100644
--- a/common/buildcraft/factory/BlockAutoWorkbench.java
+++ b/common/buildcraft/factory/BlockAutoWorkbench.java
@@ -32,7 +32,7 @@ public class BlockAutoWorkbench extends BlockBuildCraft {
public BlockAutoWorkbench(int i) {
super(i, Material.wood);
- setHardness(1.0F);
+ setHardness(3.0F);
}
@Override
diff --git a/common/buildcraft/factory/BlockFloodGate.java b/common/buildcraft/factory/BlockFloodGate.java
index cd123bd4..c0ce9c3d 100644
--- a/common/buildcraft/factory/BlockFloodGate.java
+++ b/common/buildcraft/factory/BlockFloodGate.java
@@ -32,7 +32,7 @@ public class BlockFloodGate extends BlockContainer {
public BlockFloodGate(int i) {
super(i, Material.iron);
setHardness(5F);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
diff --git a/common/buildcraft/factory/BlockFrame.java b/common/buildcraft/factory/BlockFrame.java
index a6a155db..19a96c38 100644
--- a/common/buildcraft/factory/BlockFrame.java
+++ b/common/buildcraft/factory/BlockFrame.java
@@ -10,16 +10,17 @@
package buildcraft.factory;
import buildcraft.BuildCraftCore;
+import buildcraft.core.CoreConstants;
import buildcraft.core.IFramePipeConnection;
import buildcraft.core.utils.Utils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
@@ -69,7 +70,7 @@ public class BlockFrame extends Block implements IFramePipeConnection {
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) {
- float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos;
+ float xMin = CoreConstants.PIPE_MIN_POS, xMax = CoreConstants.PIPE_MAX_POS, yMin = CoreConstants.PIPE_MIN_POS, yMax = CoreConstants.PIPE_MAX_POS, zMin = CoreConstants.PIPE_MIN_POS, zMax = CoreConstants.PIPE_MAX_POS;
if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) {
xMin = 0.0F;
@@ -107,36 +108,36 @@ public class BlockFrame extends Block implements IFramePipeConnection {
@SuppressWarnings("rawtypes")
@Override
public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List arraylist, Entity par7Entity) {
- setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) {
- setBlockBounds(0.0F, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos);
+ setBlockBounds(0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (Utils.checkLegacyPipesConnections(world, i, j, k, i + 1, j, k)) {
- setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, 1.0F, Utils.pipeMaxPos, Utils.pipeMaxPos);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 1.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j - 1, k)) {
- setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j + 1, k)) {
- setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j, k - 1)) {
- setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, 0.0F, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j, k + 1)) {
- setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, 1.0F);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, 1.0F);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
@@ -145,7 +146,7 @@ public class BlockFrame extends Block implements IFramePipeConnection {
@Override
public MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3 vec3d, Vec3 vec3d1) {
- float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos;
+ float xMin = CoreConstants.PIPE_MIN_POS, xMax = CoreConstants.PIPE_MAX_POS, yMin = CoreConstants.PIPE_MIN_POS, yMax = CoreConstants.PIPE_MAX_POS, zMin = CoreConstants.PIPE_MIN_POS, zMax = CoreConstants.PIPE_MAX_POS;
if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) {
xMin = 0.0F;
@@ -187,8 +188,8 @@ public class BlockFrame extends Block implements IFramePipeConnection {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
- public void addCreativeItems(ArrayList itemList) {
- itemList.add(new ItemStack(this));
+ public void getSubBlocks(int id, CreativeTabs tab, List list) {
+ list.add(new ItemStack(this));
}
@Override
diff --git a/common/buildcraft/factory/BlockMachineRoot.java b/common/buildcraft/factory/BlockMachineRoot.java
index 843301e7..d98bc802 100644
--- a/common/buildcraft/factory/BlockMachineRoot.java
+++ b/common/buildcraft/factory/BlockMachineRoot.java
@@ -20,7 +20,8 @@ public abstract class BlockMachineRoot extends BlockContainer {
protected BlockMachineRoot(int i, Material material) {
super(i, material);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
+ setHardness(5F);
}
@Override
diff --git a/common/buildcraft/factory/BlockMiningWell.java b/common/buildcraft/factory/BlockMiningWell.java
index 85712ae5..44899641 100644
--- a/common/buildcraft/factory/BlockMiningWell.java
+++ b/common/buildcraft/factory/BlockMiningWell.java
@@ -31,7 +31,7 @@ public class BlockMiningWell extends BlockMachineRoot {
public BlockMiningWell(int i) {
super(i, Material.ground);
- setHardness(1.5F);
+ setHardness(5F);
setResistance(10F);
setStepSound(soundStoneFootstep);
}
diff --git a/common/buildcraft/factory/BlockPlainPipe.java b/common/buildcraft/factory/BlockPlainPipe.java
index 13a0f444..5a3f9a85 100644
--- a/common/buildcraft/factory/BlockPlainPipe.java
+++ b/common/buildcraft/factory/BlockPlainPipe.java
@@ -1,23 +1,23 @@
/**
- * Copyright (c) SpaceToad, 2011
- * http://www.mod-buildcraft.com
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
- * BuildCraft is distributed under the terms of the Minecraft Mod Public
- * License 1.0, or MMPL. Please check the contents of the license located in
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
-
package buildcraft.factory;
+import buildcraft.core.CoreConstants;
import buildcraft.core.IFramePipeConnection;
-import buildcraft.core.utils.Utils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
+import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
@@ -26,13 +26,13 @@ public class BlockPlainPipe extends Block implements IFramePipeConnection {
public BlockPlainPipe(int i) {
super(i, Material.glass);
- minX = Utils.pipeMinPos;
+ minX = CoreConstants.PIPE_MIN_POS;
minY = 0.0;
- minZ = Utils.pipeMinPos;
+ minZ = CoreConstants.PIPE_MIN_POS;
- maxX = Utils.pipeMaxPos;
+ maxX = CoreConstants.PIPE_MAX_POS;
maxY = 1.0;
- maxZ = Utils.pipeMaxPos;
+ maxZ = CoreConstants.PIPE_MAX_POS;
}
@Override
@@ -65,15 +65,13 @@ public class BlockPlainPipe extends Block implements IFramePipeConnection {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
- public void addCreativeItems(ArrayList itemList) {
- itemList.add(new ItemStack(this));
+ public void getSubBlocks(int id, CreativeTabs tab, List list) {
+ list.add(new ItemStack(this));
}
-
@Override
@SideOnly(Side.CLIENT)
- public void registerIcons(IconRegister par1IconRegister)
- {
- this.blockIcon = par1IconRegister.registerIcon("buildcraft:blockPlainPipe");
+ public void registerIcons(IconRegister par1IconRegister) {
+ this.blockIcon = par1IconRegister.registerIcon("buildcraft:blockPlainPipe");
}
}
diff --git a/common/buildcraft/factory/BlockPump.java b/common/buildcraft/factory/BlockPump.java
index ed30afe5..6dc5585f 100644
--- a/common/buildcraft/factory/BlockPump.java
+++ b/common/buildcraft/factory/BlockPump.java
@@ -32,7 +32,7 @@ public class BlockPump extends BlockContainer {
public BlockPump(int i) {
super(i, Material.iron);
setHardness(5F);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
diff --git a/common/buildcraft/factory/BlockQuarry.java b/common/buildcraft/factory/BlockQuarry.java
index ecee8fbd..fa9d3576 100644
--- a/common/buildcraft/factory/BlockQuarry.java
+++ b/common/buildcraft/factory/BlockQuarry.java
@@ -1,12 +1,10 @@
/**
- * Copyright (c) SpaceToad, 2011
- * http://www.mod-buildcraft.com
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
- * BuildCraft is distributed under the terms of the Minecraft Mod Public
- * License 1.0, or MMPL. Please check the contents of the license located in
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
-
package buildcraft.factory;
import buildcraft.BuildCraftFactory;
@@ -38,7 +36,7 @@ public class BlockQuarry extends BlockMachineRoot {
public BlockQuarry(int i) {
super(i, Material.iron);
- setHardness(1.5F);
+ setHardness(10F);
setResistance(10F);
setStepSound(soundStoneFootstep);
}
@@ -49,7 +47,7 @@ public class BlockQuarry extends BlockMachineRoot {
ForgeDirection orientation = Utils.get2dOrientation(new Position(entityliving.posX, entityliving.posY, entityliving.posZ), new Position(i, j, k));
- world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(),1);
+ world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1);
if (entityliving instanceof EntityPlayer) {
TileQuarry tq = (TileQuarry) world.getBlockTileEntity(i, j, k);
tq.placedBy = (EntityPlayer) entityliving;
@@ -62,14 +60,14 @@ public class BlockQuarry extends BlockMachineRoot {
if (j == 0 && i == 3)
return textureFront;
- if (i == j && i>1) // Front can't be top or bottom.
+ if (i == j && i > 1) // Front can't be top or bottom.
return textureFront;
switch (i) {
- case 1:
- return textureTop;
- default:
- return textureSide;
+ case 1:
+ return textureTop;
+ default:
+ return textureSide;
}
}
@@ -91,25 +89,25 @@ public class BlockQuarry extends BlockMachineRoot {
int meta = world.getBlockMetadata(i, j, k);
if ((meta & 8) == 0) {
- world.setBlockMetadataWithNotify(i, j, k, meta | 8,0);
+ world.setBlockMetadataWithNotify(i, j, k, meta | 8, 0);
ForgeDirection[] dirs = ForgeDirection.VALID_DIRECTIONS;
for (ForgeDirection dir : dirs) {
switch (dir) {
- case UP:
- searchFrames(world, i, j + 1, k);
- case DOWN:
- searchFrames(world, i, j - 1, k);
- case SOUTH:
- searchFrames(world, i, j, k + 1);
- case NORTH:
- searchFrames(world, i, j, k - 1);
- case EAST:
- searchFrames(world, i + 1, j, k);
- case WEST:
- default:
- searchFrames(world, i - 1, j, k);
+ case UP:
+ searchFrames(world, i, j + 1, k);
+ case DOWN:
+ searchFrames(world, i, j - 1, k);
+ case SOUTH:
+ searchFrames(world, i, j, k + 1);
+ case NORTH:
+ searchFrames(world, i, j, k - 1);
+ case EAST:
+ searchFrames(world, i + 1, j, k);
+ case WEST:
+ default:
+ searchFrames(world, i - 1, j, k);
}
}
}
@@ -117,10 +115,18 @@ public class BlockQuarry extends BlockMachineRoot {
private void markFrameForDecay(World world, int x, int y, int z) {
if (world.getBlockId(x, y, z) == BuildCraftFactory.frameBlock.blockID) {
- world.setBlockMetadataWithNotify(x, y, z, 1,0);
+ world.setBlockMetadataWithNotify(x, y, z, 1, 0);
}
}
+ @Override
+ public ArrayList getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) {
+ if (BuildCraftFactory.quarryOneTimeUse) {
+ return new ArrayList();
+ }
+ return super.getBlockDropped(world, x, y, z, metadata, fortune);
+ }
+
@Override
public void breakBlock(World world, int i, int j, int k, int par5, int par6) {
@@ -214,7 +220,7 @@ public class BlockQuarry extends BlockMachineRoot {
return false;
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void addCreativeItems(ArrayList itemList) {
itemList.add(new ItemStack(this));
@@ -222,10 +228,9 @@ public class BlockQuarry extends BlockMachineRoot {
@Override
@SideOnly(Side.CLIENT)
- public void registerIcons(IconRegister par1IconRegister)
- {
- textureSide = par1IconRegister.registerIcon("buildcraft:quarry_side");
- textureTop = par1IconRegister.registerIcon("buildcraft:quarry_top");
- textureFront = par1IconRegister.registerIcon("buildcraft:quarry_front");
+ public void registerIcons(IconRegister par1IconRegister) {
+ textureSide = par1IconRegister.registerIcon("buildcraft:quarry_side");
+ textureTop = par1IconRegister.registerIcon("buildcraft:quarry_top");
+ textureFront = par1IconRegister.registerIcon("buildcraft:quarry_front");
}
}
diff --git a/common/buildcraft/factory/BlockRefinery.java b/common/buildcraft/factory/BlockRefinery.java
index 6f91e3c0..de22da93 100644
--- a/common/buildcraft/factory/BlockRefinery.java
+++ b/common/buildcraft/factory/BlockRefinery.java
@@ -42,8 +42,8 @@ public class BlockRefinery extends BlockContainer {
public BlockRefinery(int i) {
super(i, Material.iron);
- setHardness(0.5F);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setHardness(5F);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
diff --git a/common/buildcraft/factory/BlockTank.java b/common/buildcraft/factory/BlockTank.java
index ad1266e7..75bbc95c 100644
--- a/common/buildcraft/factory/BlockTank.java
+++ b/common/buildcraft/factory/BlockTank.java
@@ -23,6 +23,7 @@ import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
@@ -36,7 +37,7 @@ public class BlockTank extends BlockContainer {
super(i, Material.glass);
setBlockBounds(0.125F, 0F, 0.125F, 0.875F, 1F, 0.875F);
setHardness(0.5F);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
@@ -71,6 +72,7 @@ public class BlockTank extends BlockContainer {
}
@SuppressWarnings({"all"})
+ @Override
public Icon getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) {
switch (l) {
case 0:
@@ -156,4 +158,14 @@ public class BlockTank extends BlockContainer {
textureBottomSide = par1IconRegister.registerIcon("buildcraft:tank_bottom_side");
textureTop = par1IconRegister.registerIcon("buildcraft:tank_top");
}
+
+ @Override
+ public int getLightValue(IBlockAccess world, int x, int y, int z) {
+ TileEntity tile = world.getBlockTileEntity(x, y, z);
+ if (tile instanceof TileTank) {
+ TileTank tank = (TileTank) tile;
+ return tank.getFluidLightLevel();
+ }
+ return super.getLightValue(world, x, y, z);
+ }
}
diff --git a/common/buildcraft/factory/FactoryProxyClient.java b/common/buildcraft/factory/FactoryProxyClient.java
index daebdc08..a988c1f5 100644
--- a/common/buildcraft/factory/FactoryProxyClient.java
+++ b/common/buildcraft/factory/FactoryProxyClient.java
@@ -1,11 +1,11 @@
package buildcraft.factory;
-import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftFactory;
import buildcraft.core.EntityBlock;
import buildcraft.core.render.RenderVoid;
import buildcraft.core.render.RenderingEntityBlocks;
import buildcraft.core.render.RenderingEntityBlocks.EntityRenderIndex;
+import buildcraft.core.utils.BCLog;
import buildcraft.factory.gui.GuiAutoCrafting;
import buildcraft.factory.render.RenderHopper;
import buildcraft.factory.render.RenderRefinery;
@@ -17,18 +17,25 @@ import net.minecraft.util.Icon;
import net.minecraft.world.World;
public class FactoryProxyClient extends FactoryProxy {
- public static Icon pumpTexture;
- public static Icon drillTexture;
- public static Icon drillHeadTexture;
- @Override
+ public static Icon pumpTexture;
+ public static Icon drillTexture;
+ public static Icon drillHeadTexture;
+
+ @Override
public void initializeTileEntities() {
super.initializeTileEntities();
- ClientRegistry.bindTileEntitySpecialRenderer(TileTank.class, new RenderTank());
- ClientRegistry.bindTileEntitySpecialRenderer(TileRefinery.class, new RenderRefinery());
- RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftFactory.refineryBlock, 0), new RenderRefinery());
- if (!BuildCraftFactory.hopperDisabled) {
+ if (BuildCraftFactory.tankBlock != null) {
+ ClientRegistry.bindTileEntitySpecialRenderer(TileTank.class, new RenderTank());
+ }
+
+ if (BuildCraftFactory.refineryBlock != null) {
+ ClientRegistry.bindTileEntitySpecialRenderer(TileRefinery.class, new RenderRefinery());
+ RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftFactory.refineryBlock, 0), new RenderRefinery());
+ }
+
+ if (BuildCraftFactory.hopperBlock != null) {
ClientRegistry.bindTileEntitySpecialRenderer(TileHopper.class, new RenderHopper());
RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftFactory.hopperBlock, 0), new RenderHopper());
}
@@ -46,33 +53,30 @@ public class FactoryProxyClient extends FactoryProxy {
Class> neiRenderer = Class.forName("codechicken.nei.DefaultOverlayRenderer");
Method method = neiRenderer.getMethod("registerGuiOverlay", Class.class, String.class, int.class, int.class);
method.invoke(null, GuiAutoCrafting.class, "crafting", 5, 11);
- BuildCraftCore.bcLog.fine("NEI detected, adding NEI overlay");
+ BCLog.logger.fine("NEI detected, adding NEI overlay");
} catch (Exception e) {
- BuildCraftCore.bcLog.fine("NEI not detected.");
+ BCLog.logger.fine("NEI not detected.");
}
}
@Override
- public EntityBlock newPumpTube(World w)
- {
- EntityBlock eb = super.newPumpTube(w);
- eb.texture = pumpTexture;
- return eb;
+ public EntityBlock newPumpTube(World w) {
+ EntityBlock eb = super.newPumpTube(w);
+ eb.texture = pumpTexture;
+ return eb;
}
@Override
- public EntityBlock newDrill(World w, double i, double j, double k, double l, double d, double e)
- {
- EntityBlock eb = super.newDrill(w, i, j, k, l, d, e);
- eb.texture = drillTexture;
- return eb;
+ public EntityBlock newDrill(World w, double i, double j, double k, double l, double d, double e) {
+ EntityBlock eb = super.newDrill(w, i, j, k, l, d, e);
+ eb.texture = drillTexture;
+ return eb;
}
@Override
- public EntityBlock newDrillHead(World w, double i, double j, double k, double l, double d, double e)
- {
- EntityBlock eb = super.newDrillHead(w, i, j, k, l, d, e);
- eb.texture = drillHeadTexture;
- return eb;
- }
+ public EntityBlock newDrillHead(World w, double i, double j, double k, double l, double d, double e) {
+ EntityBlock eb = super.newDrillHead(w, i, j, k, l, d, e);
+ eb.texture = drillHeadTexture;
+ return eb;
+ }
}
diff --git a/common/buildcraft/factory/PumpDimensionList.java b/common/buildcraft/factory/PumpDimensionList.java
index eca15387..d8e5da4d 100644
--- a/common/buildcraft/factory/PumpDimensionList.java
+++ b/common/buildcraft/factory/PumpDimensionList.java
@@ -3,6 +3,7 @@ package buildcraft.factory;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.Locale;
import net.minecraftforge.fluids.Fluid;
public class PumpDimensionList {
@@ -34,7 +35,7 @@ public class PumpDimensionList {
else
e.dimID = Integer.parseInt(dimIDString);
- e.fluidName = entryString.substring(i + 1);
+ e.fluidName = entryString.substring(i + 1).toLowerCase(Locale.ENGLISH);
if(e.fluidName.equals("*"))
e.matchAnyFluid = true;
diff --git a/common/buildcraft/factory/TileFloodGate.java b/common/buildcraft/factory/TileFloodGate.java
index 3593b8a7..7cb99338 100644
--- a/common/buildcraft/factory/TileFloodGate.java
+++ b/common/buildcraft/factory/TileFloodGate.java
@@ -24,6 +24,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
+import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
@@ -35,7 +36,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
private final TreeMap> pumpLayerQueues = new TreeMap>();
private final Set visitedBlocks = new HashSet();
private Deque fluidsFound = new LinkedList();
- private final Tank tank;
+ private final Tank tank = new Tank("tank", MAX_LIQUID, this);
private int rebuildDelay;
private int tick = Utils.RANDOM.nextInt();
private boolean powered = false;
@@ -52,7 +53,6 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
}
public TileFloodGate() {
- tank = new Tank("tank", MAX_LIQUID);
}
@Override
@@ -68,7 +68,16 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
tick++;
if (tick % 16 == 0) {
FluidStack fluidtoFill = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false);
- if (fluidtoFill != null && fluidtoFill.amount == FluidContainerRegistry.BUCKET_VOLUME && fluidtoFill.getFluid() != null && fluidtoFill.getFluid().canBePlacedInWorld()) {
+ if (fluidtoFill != null && fluidtoFill.amount == FluidContainerRegistry.BUCKET_VOLUME) {
+ Fluid fluid = fluidtoFill.getFluid();
+ if (fluid == null || !fluid.canBePlacedInWorld())
+ return;
+
+ if (fluid == FluidRegistry.WATER && worldObj.provider.dimensionId == -1) {
+ tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
+ return;
+ }
+
if (tick % REBUILD_DELAY[rebuildDelay] == 0) {
rebuildDelay++;
if (rebuildDelay >= REBUILD_DELAY.length)
@@ -77,7 +86,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
}
BlockIndex index = getNextIndexToFill(true);
- if (index != null && placeFluid(index.x, index.y, index.z, fluidtoFill.getFluid())) {
+ if (index != null && placeFluid(index.x, index.y, index.z, fluid)) {
tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
rebuildDelay = 0;
}
diff --git a/common/buildcraft/factory/TileHopper.java b/common/buildcraft/factory/TileHopper.java
index 74cec761..c375bd06 100644
--- a/common/buildcraft/factory/TileHopper.java
+++ b/common/buildcraft/factory/TileHopper.java
@@ -1,16 +1,16 @@
package buildcraft.factory;
-import buildcraft.core.TileBuildCraft;
-import buildcraft.core.inventory.ITransactor;
-import buildcraft.core.inventory.SimpleInventory;
-import buildcraft.core.inventory.Transactor;
-import buildcraft.core.proxy.CoreProxy;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
+import buildcraft.core.TileBuildCraft;
+import buildcraft.core.inventory.ITransactor;
+import buildcraft.core.inventory.SimpleInventory;
+import buildcraft.core.inventory.Transactor;
+import buildcraft.core.proxy.CoreProxy;
public class TileHopper extends TileBuildCraft implements IInventory {
@@ -34,7 +34,7 @@ public class TileHopper extends TileBuildCraft implements IInventory {
@Override
public void updateEntity() {
super.updateEntity();
- if (CoreProxy.proxy.isRenderWorld(worldObj) || worldObj.getWorldTime() % 2 != 0)
+ if (CoreProxy.proxy.isRenderWorld(worldObj) || worldObj.getTotalWorldTime() % 2 != 0)
return;
TileEntity tile = this.worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
diff --git a/common/buildcraft/factory/TileMiningWell.java b/common/buildcraft/factory/TileMiningWell.java
index ba4d5257..03c8b3fd 100644
--- a/common/buildcraft/factory/TileMiningWell.java
+++ b/common/buildcraft/factory/TileMiningWell.java
@@ -31,7 +31,9 @@ public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerRe
public TileMiningWell() {
powerHandler = new PowerHandler(this, Type.MACHINE);
- powerHandler.configure(100, 100, 60, 1000);
+
+ float mj = BuildCraftFactory.MINING_MJ_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier;
+ powerHandler.configure(100 * BuildCraftFactory.miningMultiplier, 100 * BuildCraftFactory.miningMultiplier, mj, 1000 * BuildCraftFactory.miningMultiplier);
powerHandler.configurePowerPerdition(1, 1);
}
@@ -41,7 +43,8 @@ public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerRe
*/
@Override
public void doWork(PowerHandler workProvider) {
- if (powerHandler.useEnergy(60, 60, true) != 60)
+ float mj = BuildCraftFactory.MINING_MJ_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier;
+ if (powerHandler.useEnergy(mj, mj, true) != mj)
return;
World world = worldObj;
@@ -52,7 +55,7 @@ public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerRe
depth = depth - 1;
}
- if (depth < 1 || !BlockUtil.canChangeBlock(world, xCoord, depth, zCoord)) {
+ if (depth < 1 || depth < yCoord - BuildCraftFactory.miningDepth || !BlockUtil.canChangeBlock(world, xCoord, depth, zCoord)) {
isDigging = false;
return;
}
diff --git a/common/buildcraft/factory/TilePump.java b/common/buildcraft/factory/TilePump.java
index 5285ef1e..e6e419d3 100644
--- a/common/buildcraft/factory/TilePump.java
+++ b/common/buildcraft/factory/TilePump.java
@@ -16,6 +16,7 @@ import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import buildcraft.core.BlockIndex;
+import buildcraft.core.CoreConstants;
import buildcraft.core.EntityBlock;
import buildcraft.core.IMachine;
import buildcraft.core.TileBuffer;
@@ -36,6 +37,7 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.TreeMap;
+import net.minecraft.block.material.Material;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
@@ -52,19 +54,18 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 16;
EntityBlock tube;
private TreeMap> pumpLayerQueues = new TreeMap>();
- SingleUseTank tank;
+ SingleUseTank tank = new SingleUseTank("tank", MAX_LIQUID, this);
double tubeY = Double.NaN;
int aimY = 0;
private PowerHandler powerHandler;
private TileBuffer[] tileBuffer = null;
private SafeTimeTracker timer = new SafeTimeTracker();
private int tick = Utils.RANDOM.nextInt();
- private int numFluidBlocksFound = 0;
+ private int numFluidBlocksFound = 0;
public TilePump() {
powerHandler = new PowerHandler(this, Type.MACHINE);
initPowerProvider();
- tank = new SingleUseTank("tank", MAX_LIQUID);
}
private void initPowerProvider() {
@@ -82,8 +83,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
if (CoreProxy.proxy.isRenderWorld(worldObj))
- return;
-
+ return;
+
pushToConsumers();
if (tube.posY - aimY > 0.01) {
@@ -124,7 +125,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
if (isPumpableFluid(xCoord, y, zCoord)) {
aimY = y;
return;
- } else if (!worldObj.isAirBlock(xCoord, y, zCoord)) {
+ } else if (isBlocked(xCoord, y, zCoord)) {
return;
}
}
@@ -133,8 +134,13 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
}
}
+ private boolean isBlocked(int x, int y, int z) {
+ Material mat = worldObj.getBlockMaterial(x, y, z);
+ return mat.blocksMovement();
+ }
+
private void pushToConsumers() {
- if(tileBuffer == null)
+ if (tileBuffer == null)
tileBuffer = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, false);
FluidUtils.pushFluidToConsumers(tank, 400, tileBuffer);
}
@@ -232,7 +238,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
queueForPumping(index.x - 1, index.y, index.z, visitedBlocks, fluidsFound, pumpingFluid);
queueForPumping(index.x, index.y, index.z + 1, visitedBlocks, fluidsFound, pumpingFluid);
queueForPumping(index.x, index.y, index.z - 1, visitedBlocks, fluidsFound, pumpingFluid);
-
+
if (pumpingFluid == FluidRegistry.WATER && !BuildCraftCore.consumeWaterSources && numFluidBlocksFound >= 9)
return;
@@ -265,6 +271,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
return false;
if (!isFluidAllowed(fluid))
return false;
+ if (tank.getAcceptedFluid() != null && tank.getAcceptedFluid() != fluid)
+ return false;
return true;
}
@@ -315,11 +323,11 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
@Override
public boolean isActive() {
BlockIndex next = getNextIndexToPump(false);
-
+
if (next != null) {
return isPumpableFluid(next.x, next.y, next.z);
}
-
+
return false;
}
@@ -362,11 +370,11 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
private void setTubePosition() {
if (tube != null) {
- tube.iSize = Utils.pipeMaxPos - Utils.pipeMinPos;
- tube.kSize = Utils.pipeMaxPos - Utils.pipeMinPos;
+ tube.iSize = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
+ tube.kSize = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
tube.jSize = yCoord - tube.posY;
- tube.setPosition(xCoord + Utils.pipeMinPos, tubeY, zCoord + Utils.pipeMinPos);
+ tube.setPosition(xCoord + CoreConstants.PIPE_MIN_POS, tubeY, zCoord + CoreConstants.PIPE_MIN_POS);
}
}
diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java
index c9cb1e3c..8ff61649 100644
--- a/common/buildcraft/factory/TileQuarry.java
+++ b/common/buildcraft/factory/TileQuarry.java
@@ -20,6 +20,7 @@ import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.core.Box;
+import buildcraft.core.CoreConstants;
import buildcraft.core.DefaultAreaProvider;
import buildcraft.core.EntityRobot;
import buildcraft.core.IBuilderInventory;
@@ -73,6 +74,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
public PowerHandler powerHandler;
boolean isDigging = false;
public static final int MAX_ENERGY = 15000;
+ private static final PowerHandler.PerditionCalculator PERDITION = new PowerHandler.PerditionCalculator(2 * BuildCraftFactory.miningMultiplier);
public TileQuarry() {
powerHandler = new PowerHandler(this, PowerHandler.Type.MACHINE);
@@ -80,8 +82,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
}
private void initPowerProvider() {
- powerHandler.configure(50, 100, 25, MAX_ENERGY);
- powerHandler.configurePowerPerdition(2, 1);
+ float mj = 25 * BuildCraftFactory.miningMultiplier;
+ powerHandler.configure(50 * BuildCraftFactory.miningMultiplier, 100 * BuildCraftFactory.miningMultiplier, mj, MAX_ENERGY * BuildCraftFactory.miningMultiplier);
+ powerHandler.setPerdition(PERDITION);
}
public void createUtilsIfNeeded() {
@@ -126,9 +129,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
private void createArm() {
- worldObj.spawnEntityInWorld(new EntityMechanicalArm(worldObj, box.xMin + Utils.pipeMaxPos, yCoord + blueprintBuilder.blueprint.sizeY - 1
- + Utils.pipeMinPos, box.zMin + Utils.pipeMaxPos, blueprintBuilder.blueprint.sizeX - 2 + Utils.pipeMinPos * 2, blueprintBuilder.blueprint.sizeZ
- - 2 + Utils.pipeMinPos * 2, this));
+ worldObj.spawnEntityInWorld(new EntityMechanicalArm(worldObj, box.xMin + CoreConstants.PIPE_MAX_POS, yCoord + blueprintBuilder.blueprint.sizeY - 1
+ + CoreConstants.PIPE_MIN_POS, box.zMin + CoreConstants.PIPE_MAX_POS, blueprintBuilder.blueprint.sizeX - 2 + CoreConstants.PIPE_MIN_POS * 2, blueprintBuilder.blueprint.sizeZ
+ - 2 + CoreConstants.PIPE_MIN_POS * 2, this));
}
// Callback from the arm once it's created
@@ -192,11 +195,12 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
}
protected void buildFrame() {
-
if (!blueprintIterator.hasNext())
return;
- if (powerHandler.useEnergy(25, 25, false) != 25)
+ float mj = 25 * BuildCraftFactory.miningMultiplier;
+ powerHandler.configure(50 * BuildCraftFactory.miningMultiplier, 100 * BuildCraftFactory.miningMultiplier, mj, MAX_ENERGY * BuildCraftFactory.miningMultiplier);
+ if (powerHandler.useEnergy(mj, mj, true) != mj)
return;
if (builder == null) {
@@ -215,8 +219,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
}
protected void dig() {
- powerHandler.configure(100, 500, 60, MAX_ENERGY);
- if (powerHandler.useEnergy(60, 60, true) != 60)
+ powerHandler.configure(100 * BuildCraftFactory.miningMultiplier, 500 * BuildCraftFactory.miningMultiplier, BuildCraftFactory.MINING_MJ_COST_PER_BLOCK, MAX_ENERGY * BuildCraftFactory.miningMultiplier);
+
+ float mj = BuildCraftFactory.MINING_MJ_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier;
+ if (powerHandler.useEnergy(mj, mj, true) != mj)
return;
if (!findTarget(true)) {
@@ -260,15 +266,22 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
if (!columnVisitListIsUpdated) { // nextTarget may not be accurate, at least search the target column for changes
for (int y = nextTarget[1] + 1; y < yCoord + 3; y++) {
int blockID = worldObj.getBlockId(nextTarget[0], y, nextTarget[2]);
-
- if (BlockUtil.canChangeBlock(blockID, worldObj, nextTarget[0], y, nextTarget[2]) && !BlockUtil.isSoftBlock(blockID, worldObj, nextTarget[0], y, nextTarget[2])) {
+ if (BlockUtil.isAnObstructingBlock(blockID, worldObj, nextTarget[0], y, nextTarget[2]) || !BlockUtil.isSoftBlock(blockID, worldObj, nextTarget[0], y, nextTarget[2])) {
createColumnVisitList();
- nextTarget = visitList.removeFirst();
-
+ columnVisitListIsUpdated = true;
+ nextTarget = null;
break;
}
}
}
+ if (columnVisitListIsUpdated && nextTarget == null && !visitList.isEmpty())
+ {
+ nextTarget = visitList.removeFirst();
+ }
+ else if (columnVisitListIsUpdated && nextTarget == null)
+ {
+ return false;
+ }
setTarget(nextTarget[0], nextTarget[1] + 1, nextTarget[2]);
@@ -317,8 +330,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
if (height == null)
columnHeights[searchX][searchZ] = height = worldObj.getHeightValue(bx, bz);
- if (height < by)
- continue;
+ if (height > 0 && height < by && worldObj.provider.dimensionId != -1)
+ {
+ continue;
+ }
int blockID = worldObj.getBlockId(bx, by, bz);
@@ -327,6 +342,11 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
} else if (!BlockUtil.isSoftBlock(blockID, worldObj, bx, by, bz)) {
visitList.add(new int[]{bx, by, bz});
}
+ if (height == 0 && !worldObj.isAirBlock(bx, by, bz))
+ {
+ columnHeights[searchX][searchZ] = by;
+ }
+
// Stop at two planes - generally any obstructions will have been found and will force a recompute prior to this
if (visitList.size() > blueprintBuilder.blueprint.sizeZ * blueprintBuilder.blueprint.sizeX * 2)
return;
@@ -420,7 +440,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
}
worldObj.playAuxSFXAtEntity(null, 2001, i, j, k, blockId + (worldObj.getBlockMetadata(i, j, k) << 12));
- worldObj.setBlock(i, j, k, 0);
+ worldObj.setBlockToAir(i, j, k);
}
// Collect any lost items laying around
@@ -518,7 +538,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
isAlive = false;
if (placedBy != null && CoreProxy.proxy.isSimulating(worldObj)) {
PacketDispatcher.sendPacketToPlayer(
- new Packet3Chat(ChatMessageComponent.func_111066_d(String.format("[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available",
+ new Packet3Chat(ChatMessageComponent.createFromText(String.format("[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available",
xCoord, yCoord, zCoord))), (Player) placedBy);
}
sendNetworkUpdate();
@@ -547,7 +567,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
if (xSize < 3 || zSize < 3 || ((xSize * zSize) >> 8) >= chunkTicket.getMaxChunkListDepth()) {
if (placedBy != null) {
PacketDispatcher.sendPacketToPlayer(
- new Packet3Chat(ChatMessageComponent.func_111066_d(String.format("Quarry size is outside of chunkloading bounds or too small %d %d (%d)", xSize, zSize,
+ new Packet3Chat(ChatMessageComponent.createFromText(String.format("Quarry size is outside of chunkloading bounds or too small %d %d (%d)", xSize, zSize,
chunkTicket.getMaxChunkListDepth()))), (Player) placedBy);
}
a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10);
@@ -830,7 +850,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
}
if (placedBy != null) {
PacketDispatcher.sendPacketToPlayer(
- new Packet3Chat(ChatMessageComponent.func_111066_d(String.format("[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded", xCoord, yCoord, zCoord, chunks.size()))),
+ new Packet3Chat(ChatMessageComponent.createFromText(String.format("[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded", xCoord, yCoord, zCoord, chunks.size()))),
(Player) placedBy);
}
sendNetworkUpdate();
diff --git a/common/buildcraft/factory/TileRefinery.java b/common/buildcraft/factory/TileRefinery.java
index b931a736..47bd3236 100644
--- a/common/buildcraft/factory/TileRefinery.java
+++ b/common/buildcraft/factory/TileRefinery.java
@@ -45,9 +45,9 @@ import net.minecraftforge.fluids.IFluidHandler;
public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowerReceptor, IInventory, IMachine {
public static int LIQUID_PER_SLOT = FluidContainerRegistry.BUCKET_VOLUME * 4;
- public SingleUseTank tank1 = new SingleUseTank("tank1", LIQUID_PER_SLOT);
- public SingleUseTank tank2 = new SingleUseTank("tank2", LIQUID_PER_SLOT);
- public SingleUseTank result = new SingleUseTank("result", LIQUID_PER_SLOT);
+ public SingleUseTank tank1 = new SingleUseTank("tank1", LIQUID_PER_SLOT, this);
+ public SingleUseTank tank2 = new SingleUseTank("tank2", LIQUID_PER_SLOT, this);
+ public SingleUseTank result = new SingleUseTank("result", LIQUID_PER_SLOT, this);
public TankManager tankManager = new TankManager(tank1, tank2, result);
public float animationSpeed = 1;
private int animationStage = 0;
@@ -62,7 +62,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe
}
private void initPowerProvider() {
- powerHandler.configure(25, 100, 25, 1000);
+ powerHandler.configure(50, 150, 25, 1000);
powerHandler.configurePowerPerdition(1, 1);
}
diff --git a/common/buildcraft/factory/TileTank.java b/common/buildcraft/factory/TileTank.java
index 9d36643d..ffc08e27 100644
--- a/common/buildcraft/factory/TileTank.java
+++ b/common/buildcraft/factory/TileTank.java
@@ -21,6 +21,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.EnumSkyBlock;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
@@ -31,22 +32,29 @@ import net.minecraftforge.fluids.IFluidHandler;
public class TileTank extends TileBuildCraft implements IFluidHandler {
- public final Tank tank = new Tank("tank", FluidContainerRegistry.BUCKET_VOLUME * 16);
+ public final Tank tank = new Tank("tank", FluidContainerRegistry.BUCKET_VOLUME * 16, this);
public final TankManager tankManager = new TankManager(tank);
public boolean hasUpdate = false;
public SafeTimeTracker tracker = new SafeTimeTracker();
+ private int prevLightValue = 0;
/* UPDATING */
@Override
public void updateEntity() {
- if (CoreProxy.proxy.isRenderWorld(worldObj))
+ if (CoreProxy.proxy.isRenderWorld(worldObj)) {
+ int lightValue = getFluidLightLevel();
+ if (prevLightValue != lightValue) {
+ prevLightValue = lightValue;
+ worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
+ }
return;
-
+ }
+
// Have liquid flow down into tanks below if any.
if (tank.getFluid() != null) {
moveFluidBelow();
}
-
+
if (hasUpdate && tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)) {
sendNetworkUpdate();
hasUpdate = false;
@@ -191,7 +199,9 @@ public class TileTank extends TileBuildCraft implements IFluidHandler {
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
- if (resource != null && !resource.isFluidEqual(tank.getFluid()))
+ if (resource == null)
+ return null;
+ if (!resource.isFluidEqual(tank.getFluid()))
return null;
return drain(from, resource.amount, doDrain);
}
@@ -240,4 +250,9 @@ public class TileTank extends TileBuildCraft implements IFluidHandler {
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return false;
}
+
+ public int getFluidLightLevel() {
+ FluidStack tankFluid = tank.getFluid();
+ return tankFluid == null ? 0 : tankFluid.getFluid().getLuminosity(tankFluid);
+ }
}
diff --git a/common/buildcraft/factory/gui/GuiAutoCrafting.java b/common/buildcraft/factory/gui/GuiAutoCrafting.java
index 8aa44f89..76293ae9 100644
--- a/common/buildcraft/factory/gui/GuiAutoCrafting.java
+++ b/common/buildcraft/factory/gui/GuiAutoCrafting.java
@@ -44,7 +44,7 @@ public class GuiAutoCrafting extends GuiBuildCraft {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(gui);
+ mc.renderEngine.bindTexture(gui);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
diff --git a/common/buildcraft/factory/gui/GuiHopper.java b/common/buildcraft/factory/gui/GuiHopper.java
index 5ab38dc3..2ab5c7c5 100644
--- a/common/buildcraft/factory/gui/GuiHopper.java
+++ b/common/buildcraft/factory/gui/GuiHopper.java
@@ -19,7 +19,7 @@ public class GuiHopper extends GuiContainer {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
diff --git a/common/buildcraft/factory/gui/GuiRefinery.java b/common/buildcraft/factory/gui/GuiRefinery.java
index ab5486c0..1b36648c 100644
--- a/common/buildcraft/factory/gui/GuiRefinery.java
+++ b/common/buildcraft/factory/gui/GuiRefinery.java
@@ -56,7 +56,7 @@ public class GuiRefinery extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
diff --git a/common/buildcraft/factory/render/RenderHopper.java b/common/buildcraft/factory/render/RenderHopper.java
index 46e519fd..12f5a64c 100644
--- a/common/buildcraft/factory/render/RenderHopper.java
+++ b/common/buildcraft/factory/render/RenderHopper.java
@@ -56,10 +56,10 @@ public class RenderHopper extends TileEntitySpecialRenderer implements IInventor
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glTranslated(x, y, z);
- func_110628_a(HOPPER_TEXTURE);
+ bindTexture(HOPPER_TEXTURE);
top.render((float) (1.0 / 16.0));
bottom.render((float) (1.0 / 16.0));
- func_110628_a(HOPPER_MIDDLE_TEXTURE);
+ bindTexture(HOPPER_MIDDLE_TEXTURE);
middle.render(Tessellator.instance, 1F / 16F);
GL11.glEnable(GL11.GL_LIGHTING);
diff --git a/common/buildcraft/factory/render/RenderRefinery.java b/common/buildcraft/factory/render/RenderRefinery.java
index 89ee424f..4f2a19ba 100644
--- a/common/buildcraft/factory/render/RenderRefinery.java
+++ b/common/buildcraft/factory/render/RenderRefinery.java
@@ -126,7 +126,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent
GL11.glRotatef(angle, 0, 1, 0);
- func_110628_a(TEXTURE);
+ bindTexture(TEXTURE);
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
@@ -182,7 +182,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent
int[] list1 = FluidRenderer.getFluidDisplayLists(liquid1, tile.worldObj, false);
if (list1 != null) {
- func_110628_a(FluidRenderer.getFluidSheet(liquid1));
+ bindTexture(FluidRenderer.getFluidSheet(liquid1));
FluidRenderer.setColorForFluidStack(liquid1);
GL11.glCallList(list1[getDisplayListIndex(tile.tank1)]);
}
@@ -194,7 +194,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent
if (list2 != null) {
GL11.glPushMatrix();
GL11.glTranslatef(0, 0, 1);
- func_110628_a(FluidRenderer.getFluidSheet(liquid2));
+ bindTexture(FluidRenderer.getFluidSheet(liquid2));
FluidRenderer.setColorForFluidStack(liquid2);
GL11.glCallList(list2[getDisplayListIndex(tile.tank2)]);
GL11.glPopMatrix();
@@ -208,7 +208,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent
if (list3 != null) {
GL11.glPushMatrix();
GL11.glTranslatef(1, 0, 0.5F);
- func_110628_a(FluidRenderer.getFluidSheet(liquidResult));
+ bindTexture(FluidRenderer.getFluidSheet(liquidResult));
FluidRenderer.setColorForFluidStack(liquidResult);
GL11.glCallList(list3[getDisplayListIndex(tile.result)]);
GL11.glPopMatrix();
diff --git a/common/buildcraft/factory/render/RenderTank.java b/common/buildcraft/factory/render/RenderTank.java
index 579c961a..487f9531 100644
--- a/common/buildcraft/factory/render/RenderTank.java
+++ b/common/buildcraft/factory/render/RenderTank.java
@@ -38,7 +38,7 @@ public class RenderTank extends TileEntitySpecialRenderer {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- func_110628_a(FluidRenderer.getFluidSheet(liquid));
+ bindTexture(FluidRenderer.getFluidSheet(liquid));
FluidRenderer.setColorForFluidStack(liquid);
GL11.glTranslatef((float) x + 0.125F, (float) y, (float) z + 0.125F);
diff --git a/common/buildcraft/silicon/BlockLaser.java b/common/buildcraft/silicon/BlockLaser.java
index 0d25f117..b0eb8320 100644
--- a/common/buildcraft/silicon/BlockLaser.java
+++ b/common/buildcraft/silicon/BlockLaser.java
@@ -27,8 +27,8 @@ public class BlockLaser extends BlockContainer {
public BlockLaser(int i) {
super(i, Material.iron);
- setHardness(0.5F);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setHardness(10F);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
diff --git a/common/buildcraft/silicon/BlockLaserTable.java b/common/buildcraft/silicon/BlockLaserTable.java
index 2ae0d3b0..4cd9204f 100644
--- a/common/buildcraft/silicon/BlockLaserTable.java
+++ b/common/buildcraft/silicon/BlockLaserTable.java
@@ -26,8 +26,8 @@ public class BlockLaserTable extends BlockContainer {
super(i, Material.iron);
setBlockBounds(0, 0, 0, 1, 9F / 16F, 1);
- setHardness(0.5F);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setHardness(10F);
+ setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
}
@Override
diff --git a/common/buildcraft/silicon/SiliconRenderBlock.java b/common/buildcraft/silicon/SiliconRenderBlock.java
index 0732e9e6..fcb1f0f8 100644
--- a/common/buildcraft/silicon/SiliconRenderBlock.java
+++ b/common/buildcraft/silicon/SiliconRenderBlock.java
@@ -9,7 +9,7 @@
package buildcraft.silicon;
-import buildcraft.core.utils.Utils;
+import buildcraft.core.CoreConstants;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
@@ -121,7 +121,7 @@ public class SiliconRenderBlock implements ISimpleBlockRenderingHandler {
@Override
public void renderInventoryBlock(Block block, int i, int j, RenderBlocks renderblocks) {
- block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
+ block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1, 4F / 16F, 1);
diff --git a/common/buildcraft/silicon/TileAdvancedCraftingTable.java b/common/buildcraft/silicon/TileAdvancedCraftingTable.java
index 42ea6138..8fd35a15 100644
--- a/common/buildcraft/silicon/TileAdvancedCraftingTable.java
+++ b/common/buildcraft/silicon/TileAdvancedCraftingTable.java
@@ -72,7 +72,6 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory,
if (useRecipeStack || tempStacks == null) {
return craftingSlots.getStackInSlot(slot);
} else {
-
if (bindings[slot] >= 0) {
return tempStacks[bindings[slot]];
}
@@ -85,14 +84,14 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory,
@Override
public void setInventorySlotContents(int slot, ItemStack par2ItemStack) {
- if (tempStacks != null && slot >= 0 && slot < 9) {
+ if (tempStacks != null && slot >= 0 && slot < 9 && bindings[slot] >= 0) {
tempStacks[bindings[slot]] = par2ItemStack;
}
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
- if (tempStacks != null && slot >= 0 && slot < 9) {
+ if (tempStacks != null && slot >= 0 && slot < 9 && bindings[slot] >= 0) {
if (tempStacks[bindings[slot]].stackSize <= amount) {
ItemStack result = tempStacks[bindings[slot]];
tempStacks[bindings[slot]] = null;
diff --git a/common/buildcraft/silicon/TileLaser.java b/common/buildcraft/silicon/TileLaser.java
index fd73b00c..c85b983c 100644
--- a/common/buildcraft/silicon/TileLaser.java
+++ b/common/buildcraft/silicon/TileLaser.java
@@ -23,6 +23,7 @@ import buildcraft.core.TileBuildCraft;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.ActionMachineControl;
import java.util.LinkedList;
+import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
@@ -39,6 +40,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
private int nextLaserUpdate = 10;
private int nextLaserSearch = 100;
private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown;
+ private static final PowerHandler.PerditionCalculator PERDITION = new PowerHandler.PerditionCalculator(0.5F);
public TileLaser() {
powerHandler = new PowerHandler(this, Type.MACHINE);
@@ -47,7 +49,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
private void initPowerProvider() {
powerHandler.configure(25, 150, 25, 1000);
- powerHandler.configurePowerPerdition(1, 1);
+ powerHandler.setPerdition(PERDITION);
}
@Override
@@ -57,12 +59,6 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
if (!CoreProxy.proxy.isSimulating(worldObj))
return;
- // Disable the laser and do nothing if no energy is available.
- if (powerHandler.getEnergyStored() == 0) {
- removeLaser();
- return;
- }
-
// If a gate disabled us, remove laser and do nothing.
if (lastMode == ActionMachineControl.Mode.Off) {
removeLaser();
@@ -82,6 +78,12 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
return;
}
+ // Disable the laser and do nothing if no energy is available.
+ if (powerHandler.getEnergyStored() == 0) {
+ removeLaser();
+ return;
+ }
+
// We have a table and can work, so we create a laser if
// necessary.
if (laser == null) {
@@ -100,19 +102,19 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
if (laser != null) {
laser.pushPower(power);
}
-
+
onPowerSent(power);
sendNetworkUpdate();
}
- protected float getMaxPowerSent(){
+ protected float getMaxPowerSent() {
return 4;
}
protected void onPowerSent(float power) {
}
-
+
protected boolean canFindTable() {
return searchTracker.markTimeIfDelay(worldObj, nextLaserSearch);
}
@@ -161,7 +163,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
break;
}
- LinkedList targets = new LinkedList();
+ List targets = new LinkedList();
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
@@ -180,7 +182,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
}
}
- if (targets.size() == 0)
+ if (targets.isEmpty())
return;
BlockIndex b = targets.get(worldObj.rand.nextInt(targets.size()));
@@ -279,7 +281,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
@Override
public boolean isActive() {
- return laser != null;
+ return isValidTable();
}
@Override
diff --git a/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java b/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java
index 2b188f88..f74233f4 100644
--- a/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java
+++ b/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java
@@ -35,7 +35,7 @@ public class GuiAdvancedCraftingTable extends GuiBuildCraft {
drawBackground(x, y);
// Draw icon
- Minecraft.getMinecraft().renderEngine.func_110577_a(TextureMap.field_110576_c);
+ Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4);
if (!isFullyOpened())
@@ -76,7 +76,7 @@ public class GuiAdvancedCraftingTable extends GuiBuildCraft {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(gui);
+ mc.renderEngine.bindTexture(gui);
int cornerX = (width - xSize) / 2;
int cornerY = (height - ySize) / 2;
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
diff --git a/common/buildcraft/silicon/gui/GuiAssemblyTable.java b/common/buildcraft/silicon/gui/GuiAssemblyTable.java
index 48108ccf..d9c04d88 100644
--- a/common/buildcraft/silicon/gui/GuiAssemblyTable.java
+++ b/common/buildcraft/silicon/gui/GuiAssemblyTable.java
@@ -50,7 +50,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
drawBackground(x, y);
// Draw icon
- mc.renderEngine.func_110577_a(TextureMap.field_110576_c);
+ mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4);
if (!isFullyOpened())
@@ -141,7 +141,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
int cornerX = (width - xSize) / 2;
int cornerY = (height - ySize) / 2;
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java
index f4587597..25e5297e 100644
--- a/common/buildcraft/transport/BlockGenericPipe.java
+++ b/common/buildcraft/transport/BlockGenericPipe.java
@@ -7,24 +7,13 @@
*/
package buildcraft.transport;
-import buildcraft.BuildCraftCore;
-import buildcraft.BuildCraftTransport;
-import buildcraft.api.tools.IToolWrench;
-import buildcraft.api.transport.IPipe;
-import buildcraft.api.transport.ISolidSideTile;
-import buildcraft.core.BlockIndex;
-import buildcraft.core.proxy.CoreProxy;
-import buildcraft.core.utils.Utils;
-import buildcraft.transport.render.PipeWorldRenderer;
-import cpw.mods.fml.common.registry.GameRegistry;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
+
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -45,31 +34,59 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
+import buildcraft.BuildCraftTransport;
+import buildcraft.api.tools.IToolWrench;
+import buildcraft.api.transport.IPipe;
+import buildcraft.api.transport.ISolidSideTile;
+import buildcraft.core.BlockIndex;
+import buildcraft.core.CoreConstants;
+import buildcraft.core.proxy.CoreProxy;
+import buildcraft.core.utils.BCLog;
+import buildcraft.core.utils.Utils;
+import buildcraft.core.utils.MatrixTranformations;
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import java.util.Arrays;
+import net.minecraft.client.Minecraft;
public class BlockGenericPipe extends BlockContainer {
static enum Part {
Pipe,
- Gate
+ Gate,
+ Facade,
+ Plug
}
static class RaytraceResult {
- RaytraceResult(Part hitPart, MovingObjectPosition movingObjectPosition) {
+ RaytraceResult(Part hitPart, MovingObjectPosition movingObjectPosition, AxisAlignedBB boundingBox, ForgeDirection side) {
this.hitPart = hitPart;
this.movingObjectPosition = movingObjectPosition;
+ this.boundingBox = boundingBox;
+ this.sideHit = side;
+ }
+ public final Part hitPart;
+ public final MovingObjectPosition movingObjectPosition;
+ public final AxisAlignedBB boundingBox;
+ public final ForgeDirection sideHit;
+
+ @Override
+ public String toString() {
+ return String.format("RayTraceResult: %s, %s", hitPart == null ? "null" : hitPart.name(), boundingBox == null ? "null" : boundingBox.toString());
}
- public Part hitPart;
- public MovingObjectPosition movingObjectPosition;
}
+ private static final ForgeDirection[] DIR_VALUES = ForgeDirection.values();
private static Random rand = new Random();
private boolean skippedFirstIconRegister;
- private char renderAxis = 'a';
+ private int renderMask = 0;
/* Defined subprograms ************************************************* */
public BlockGenericPipe(int i) {
super(i, Material.glass);
+ setRenderAllSides();
}
@Override
@@ -97,20 +114,26 @@ public class BlockGenericPipe extends BlockContainer {
return false;
}
- public void setRenderAxis(char axis) {
- this.renderAxis = axis;
+ public void setRenderMask(int mask) {
+ renderMask = mask;
+ }
+
+ public final void setRenderAllSides() {
+ renderMask = 0x3f;
+ }
+
+ public void setRenderSide(ForgeDirection side, boolean render) {
+ if (render) {
+ renderMask |= 1 << side.ordinal();
+ } else {
+ renderMask &= ~(1 << side.ordinal());
+ }
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side) {
- if (renderAxis == 'x')
- return side == 4 || side == 5;
- if (renderAxis == 'y')
- return side == 0 || side == 1;
- if (renderAxis == 'z')
- return side == 2 || side == 3;
- return true;
+ return (renderMask & (1 << side)) != 0;
}
@Override
@@ -129,7 +152,7 @@ public class BlockGenericPipe extends BlockContainer {
@SuppressWarnings("rawtypes")
@Override
public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List arraylist, Entity par7Entity) {
- setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
TileEntity tile1 = world.getBlockTileEntity(i, j, k);
@@ -137,36 +160,36 @@ public class BlockGenericPipe extends BlockContainer {
TileGenericPipe tileG = (TileGenericPipe) tile1;
if (tileG.isPipeConnected(ForgeDirection.WEST)) {
- setBlockBounds(0.0F, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos);
+ setBlockBounds(0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (tileG.isPipeConnected(ForgeDirection.EAST)) {
- setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, 1.0F, Utils.pipeMaxPos, Utils.pipeMaxPos);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 1.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (tileG.isPipeConnected(ForgeDirection.DOWN)) {
- setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (tileG.isPipeConnected(ForgeDirection.UP)) {
- setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (tileG.isPipeConnected(ForgeDirection.NORTH)) {
- setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, 0.0F, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (tileG.isPipeConnected(ForgeDirection.SOUTH)) {
- setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, 1.0F);
+ setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, 1.0F);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
- float facadeThickness = PipeWorldRenderer.facadeThickness;
+ float facadeThickness = TransportConstants.FACADE_THICKNESS;
if (tileG.hasFacade(ForgeDirection.EAST)) {
setBlockBounds(1 - facadeThickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
@@ -201,61 +224,29 @@ public class BlockGenericPipe extends BlockContainer {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
+ @SideOnly(Side.CLIENT)
@Override
- public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
- float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos;
+ public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
+ RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, Minecraft.getMinecraft().thePlayer);
- TileEntity tile1 = world.getBlockTileEntity(i, j, k);
-
- if (tile1 instanceof TileGenericPipe) {
- TileGenericPipe tileG = (TileGenericPipe) tile1;
- if (tileG.isPipeConnected(ForgeDirection.WEST) || tileG.hasFacade(ForgeDirection.WEST)) {
- xMin = 0.0F;
- }
-
- if (tileG.isPipeConnected(ForgeDirection.EAST) || tileG.hasFacade(ForgeDirection.EAST)) {
- xMax = 1.0F;
- }
-
- if (tileG.isPipeConnected(ForgeDirection.DOWN) || tileG.hasFacade(ForgeDirection.DOWN)) {
- yMin = 0.0F;
- }
-
- if (tileG.isPipeConnected(ForgeDirection.UP) || tileG.hasFacade(ForgeDirection.UP)) {
- yMax = 1.0F;
- }
-
- if (tileG.isPipeConnected(ForgeDirection.NORTH) || tileG.hasFacade(ForgeDirection.NORTH)) {
- zMin = 0.0F;
- }
-
- if (tileG.isPipeConnected(ForgeDirection.SOUTH) || tileG.hasFacade(ForgeDirection.SOUTH)) {
- zMax = 1.0F;
- }
-
- if (tileG.hasFacade(ForgeDirection.EAST) || tileG.hasFacade(ForgeDirection.WEST)) {
- yMin = 0.0F;
- yMax = 1.0F;
- zMin = 0.0F;
- zMax = 1.0F;
- }
-
- if (tileG.hasFacade(ForgeDirection.UP) || tileG.hasFacade(ForgeDirection.DOWN)) {
- xMin = 0.0F;
- xMax = 1.0F;
- zMin = 0.0F;
- zMax = 1.0F;
- }
-
- if (tileG.hasFacade(ForgeDirection.SOUTH) || tileG.hasFacade(ForgeDirection.NORTH)) {
- xMin = 0.0F;
- xMax = 1.0F;
- yMin = 0.0F;
- yMax = 1.0F;
+ if (rayTraceResult != null && rayTraceResult.boundingBox != null) {
+ AxisAlignedBB box = rayTraceResult.boundingBox;
+ switch (rayTraceResult.hitPart) {
+ case Gate:
+ case Plug: {
+ float scale = 0.001F;
+ box = box.expand(scale, scale, scale);
+ break;
+ }
+ case Pipe: {
+ float scale = 0.08F;
+ box = box.expand(scale, scale, scale);
+ break;
+ }
}
+ return box.getOffsetBoundingBox(x, y, z);
}
-
- return AxisAlignedBB.getBoundingBox((double) i + xMin, (double) j + yMin, (double) k + zMin, (double) i + xMax, (double) j + yMax, (double) k + zMax);
+ return super.getSelectedBoundingBoxFromPool(world, x, y, z).expand(-0.85F, -0.85F, -0.85F);
}
@Override
@@ -290,8 +281,6 @@ public class BlockGenericPipe extends BlockContainer {
}
private RaytraceResult doRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) {
- float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos;
-
TileEntity pipeTileEntity = world.getBlockTileEntity(x, y, z);
TileGenericPipe tileG = null;
@@ -310,96 +299,60 @@ public class BlockGenericPipe extends BlockContainer {
* pipe hits along x, y, and z axis, gate (all 6 sides) [and
* wires+facades]
*/
- MovingObjectPosition[] hits = new MovingObjectPosition[9];
+ MovingObjectPosition[] hits = new MovingObjectPosition[25];
+ AxisAlignedBB[] boxes = new AxisAlignedBB[25];
+ ForgeDirection[] sideHit = new ForgeDirection[25];
+ Arrays.fill(sideHit, ForgeDirection.UNKNOWN);
- boolean needAxisCheck = false;
- boolean needCenterCheck = true;
+ // pipe
- // check along the x axis
-
- if (tileG.isPipeConnected(ForgeDirection.WEST)) {
- xMin = 0.0F;
- needAxisCheck = true;
- }
-
- if (tileG.isPipeConnected(ForgeDirection.WEST)) {
- xMax = 1.0F;
- needAxisCheck = true;
- }
-
- if (needAxisCheck) {
- setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
-
- hits[0] = super.collisionRayTrace(world, x, y, z, origin, direction);
- xMin = Utils.pipeMinPos;
- xMax = Utils.pipeMaxPos;
- needAxisCheck = false;
- needCenterCheck = false; // center already checked through this axis
- }
-
- // check along the y axis
-
- if (tileG.isPipeConnected(ForgeDirection.DOWN)) {
- yMin = 0.0F;
- needAxisCheck = true;
- }
-
- if (tileG.isPipeConnected(ForgeDirection.UP)) {
- yMax = 1.0F;
- needAxisCheck = true;
- }
-
- if (needAxisCheck) {
- setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
-
- hits[1] = super.collisionRayTrace(world, x, y, z, origin, direction);
- yMin = Utils.pipeMinPos;
- yMax = Utils.pipeMaxPos;
- needAxisCheck = false;
- needCenterCheck = false; // center already checked through this axis
- }
-
- // check along the z axis
-
- if (tileG.isPipeConnected(ForgeDirection.NORTH)) {
- zMin = 0.0F;
- needAxisCheck = true;
- }
-
- if (tileG.isPipeConnected(ForgeDirection.SOUTH)) {
- zMax = 1.0F;
- needAxisCheck = true;
- }
-
- if (needAxisCheck) {
- setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
-
- hits[2] = super.collisionRayTrace(world, x, y, z, origin, direction);
- zMin = Utils.pipeMinPos;
- zMax = Utils.pipeMaxPos;
- needAxisCheck = false;
- needCenterCheck = false; // center already checked through this axis
- }
-
- // check center (only if no axis were checked/the pipe has no connections)
-
- if (needCenterCheck) {
- setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
-
- hits[0] = super.collisionRayTrace(world, x, y, z, origin, direction);
+ for (ForgeDirection side : DIR_VALUES) {
+ if (side == ForgeDirection.UNKNOWN || tileG.isPipeConnected(side)) {
+ AxisAlignedBB bb = getPipeBoundingBox(side);
+ setBlockBounds(bb);
+ boxes[side.ordinal()] = bb;
+ hits[side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction);
+ sideHit[side.ordinal()] = side;
+ }
}
// gates
- if (pipe.hasGate()) {
- for (int side = 0; side < 6; side++) {
- setBlockBoundsToGate(ForgeDirection.VALID_DIRECTIONS[side]);
-
- hits[3 + side] = super.collisionRayTrace(world, x, y, z, origin, direction);
+ for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
+ if (pipe.hasGate(side)) {
+ AxisAlignedBB bb = getGateBoundingBox(side);
+ setBlockBounds(bb);
+ boxes[7 + side.ordinal()] = bb;
+ hits[7 + side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction);
+ sideHit[7 + side.ordinal()] = side;
}
}
- // TODO: check wires, facades
+ // facades
+
+ for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
+ if (tileG.hasFacade(side)) {
+ AxisAlignedBB bb = getFacadeBoundingBox(side);
+ setBlockBounds(bb);
+ boxes[13 + side.ordinal()] = bb;
+ hits[13 + side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction);
+ sideHit[13 + side.ordinal()] = side;
+ }
+ }
+
+ // plugs
+
+ for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
+ if (tileG.hasPlug(side)) {
+ AxisAlignedBB bb = getPlugBoundingBox(side);
+ setBlockBounds(bb);
+ boxes[19 + side.ordinal()] = bb;
+ hits[19 + side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction);
+ sideHit[19 + side.ordinal()] = side;
+ }
+ }
+
+ // TODO: check wires
// get closest hit
@@ -428,41 +381,96 @@ public class BlockGenericPipe extends BlockContainer {
} else {
Part hitPart;
- if (minIndex < 3) {
+ if (minIndex < 7) {
hitPart = Part.Pipe;
- } else {
+ } else if (minIndex < 13) {
hitPart = Part.Gate;
+ } else if (minIndex < 19) {
+ hitPart = Part.Facade;
+ } else {
+ hitPart = Part.Plug;
}
- return new RaytraceResult(hitPart, hits[minIndex]);
+ return new RaytraceResult(hitPart, hits[minIndex], boxes[minIndex], sideHit[minIndex]);
}
}
- private void setBlockBoundsToGate(ForgeDirection dir) {
- float min = Utils.pipeMinPos + 0.05F;
- float max = Utils.pipeMaxPos - 0.05F;
+ private void setBlockBounds(AxisAlignedBB bb) {
+ setBlockBounds((float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ);
+ }
- switch (dir) {
- case DOWN:
- setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos, max);
- break;
- case UP:
- setBlockBounds(min, Utils.pipeMaxPos, min, max, Utils.pipeMaxPos + 0.10F, max);
- break;
- case NORTH:
- setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos);
- break;
- case SOUTH:
- setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F);
- break;
- case WEST:
- setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos, max, max);
- break;
- default:
- case EAST:
- setBlockBounds(Utils.pipeMaxPos, min, min, Utils.pipeMaxPos + 0.10F, max, max);
- break;
+ private AxisAlignedBB getGateBoundingBox(ForgeDirection side) {
+ float min = CoreConstants.PIPE_MIN_POS + 0.05F;
+ float max = CoreConstants.PIPE_MAX_POS - 0.05F;
+
+ float[][] bounds = new float[3][2];
+ // X START - END
+ bounds[0][0] = min;
+ bounds[0][1] = max;
+ // Y START - END
+ bounds[1][0] = CoreConstants.PIPE_MIN_POS - 0.10F;
+ bounds[1][1] = CoreConstants.PIPE_MIN_POS;
+ // Z START - END
+ bounds[2][0] = min;
+ bounds[2][1] = max;
+
+ MatrixTranformations.transform(bounds, side);
+ return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]);
+ }
+
+ private AxisAlignedBB getFacadeBoundingBox(ForgeDirection side) {
+ float[][] bounds = new float[3][2];
+ // X START - END
+ bounds[0][0] = 0.0F;
+ bounds[0][1] = 1.0F;
+ // Y START - END
+ bounds[1][0] = 0.0F;
+ bounds[1][1] = TransportConstants.FACADE_THICKNESS;
+ // Z START - END
+ bounds[2][0] = 0.0F;
+ bounds[2][1] = 1.0F;
+
+ MatrixTranformations.transform(bounds, side);
+ return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]);
+ }
+
+ private AxisAlignedBB getPlugBoundingBox(ForgeDirection side) {
+ float[][] bounds = new float[3][2];
+ // X START - END
+ bounds[0][0] = 0.25F;
+ bounds[0][1] = 0.75F;
+ // Y START - END
+ bounds[1][0] = 0.125F;
+ bounds[1][1] = 0.251F;
+ // Z START - END
+ bounds[2][0] = 0.25F;
+ bounds[2][1] = 0.75F;
+
+ MatrixTranformations.transform(bounds, side);
+ return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]);
+ }
+
+ private AxisAlignedBB getPipeBoundingBox(ForgeDirection side) {
+ float min = CoreConstants.PIPE_MIN_POS;
+ float max = CoreConstants.PIPE_MAX_POS;
+
+ if (side == ForgeDirection.UNKNOWN) {
+ return AxisAlignedBB.getAABBPool().getAABB(min, min, min, max, max, max);
}
+
+ float[][] bounds = new float[3][2];
+ // X START - END
+ bounds[0][0] = min;
+ bounds[0][1] = max;
+ // Y START - END
+ bounds[1][0] = 0;
+ bounds[1][1] = min;
+ // Z START - END
+ bounds[2][0] = min;
+ bounds[2][1] = max;
+
+ MatrixTranformations.transform(bounds, side);
+ return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]);
}
public static void removePipe(Pipe pipe) {
@@ -482,8 +490,8 @@ public class BlockGenericPipe extends BlockContainer {
int y = pipe.container.yCoord;
int z = pipe.container.zCoord;
- if (lastRemovedDate != world.getWorldTime()) {
- lastRemovedDate = world.getWorldTime();
+ if (lastRemovedDate != world.getTotalWorldTime()) {
+ lastRemovedDate = world.getTotalWorldTime();
pipeRemoved.clear();
}
@@ -575,6 +583,23 @@ public class BlockGenericPipe extends BlockContainer {
return pipe.itemID;
}
+ @SideOnly(Side.CLIENT)
+ @Override
+ public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
+ RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, Minecraft.getMinecraft().thePlayer);
+
+ if (rayTraceResult != null && rayTraceResult.boundingBox != null) {
+ switch (rayTraceResult.hitPart) {
+ case Gate:
+ Pipe pipe = getPipe(world, x, y, z);
+ return pipe.gate.getGateItem();
+ case Plug:
+ return new ItemStack(BuildCraftTransport.plugItem);
+ }
+ }
+ return super.getPickBlock(target, world, x, y, z);
+ }
+
/* Wrappers ************************************************************ */
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int id) {
@@ -618,91 +643,65 @@ public class BlockGenericPipe extends BlockContainer {
Pipe pipe = getPipe(world, x, y, z);
if (isValid(pipe)) {
+ ItemStack currentItem = player.getCurrentEquippedItem();
- // / Right click while sneaking without wrench to strip equipment
+ // Right click while sneaking with empty hand to strip equipment
// from the pipe.
- if (player.isSneaking()
- && (player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof IToolWrench))) {
-
- if (pipe.hasGate() || pipe.isWired())
- return stripEquipment(pipe);
-
- } else if (player.getCurrentEquippedItem() == null) {
+ if (player.isSneaking() && currentItem == null) {
+ if (stripEquipment(world, x, y, z, player, pipe))
+ return true;
+ } else if (currentItem == null) {
// Fall through the end of the test
- } else if (player.getCurrentEquippedItem().itemID == Item.sign.itemID)
+ } else if (currentItem.itemID == Item.sign.itemID)
// Sign will be placed anyway, so lets show the sign gui
return false;
- else if (player.getCurrentEquippedItem().getItem() instanceof ItemPipe)
+ else if (currentItem.getItem() instanceof ItemPipe)
return false;
- else if (player.getCurrentEquippedItem().getItem() instanceof IToolWrench)
+ else if (currentItem.getItem() instanceof IToolWrench)
// Only check the instance at this point. Call the IToolWrench
// interface callbacks for the individual pipe/logic calls
return pipe.blockActivated(player);
- else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.redPipeWire) {
- if (!pipe.wireSet[IPipe.WireColor.Red.ordinal()]) {
- pipe.wireSet[IPipe.WireColor.Red.ordinal()] = true;
- if (!player.capabilities.isCreativeMode) {
- player.getCurrentEquippedItem().splitStack(1);
- }
- pipe.signalStrength[IPipe.WireColor.Red.ordinal()] = 0;
- pipe.container.scheduleNeighborChange();
+ else if (currentItem.getItem() == BuildCraftTransport.redPipeWire) {
+ if (addOrStripWire(player, pipe, IPipe.WireColor.Red)) {
return true;
}
- } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.bluePipeWire) {
- if (!pipe.wireSet[IPipe.WireColor.Blue.ordinal()]) {
- pipe.wireSet[IPipe.WireColor.Blue.ordinal()] = true;
- if (!player.capabilities.isCreativeMode) {
- player.getCurrentEquippedItem().splitStack(1);
- }
- pipe.signalStrength[IPipe.WireColor.Blue.ordinal()] = 0;
- pipe.container.scheduleNeighborChange();
+ } else if (currentItem.getItem() == BuildCraftTransport.bluePipeWire) {
+ if (addOrStripWire(player, pipe, IPipe.WireColor.Blue)) {
return true;
}
- } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.greenPipeWire) {
- if (!pipe.wireSet[IPipe.WireColor.Green.ordinal()]) {
- pipe.wireSet[IPipe.WireColor.Green.ordinal()] = true;
- if (!player.capabilities.isCreativeMode) {
- player.getCurrentEquippedItem().splitStack(1);
- }
- pipe.signalStrength[IPipe.WireColor.Green.ordinal()] = 0;
- pipe.container.scheduleNeighborChange();
+ } else if (currentItem.getItem() == BuildCraftTransport.greenPipeWire) {
+ if (addOrStripWire(player, pipe, IPipe.WireColor.Green)) {
return true;
}
- } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.yellowPipeWire) {
- if (!pipe.wireSet[IPipe.WireColor.Yellow.ordinal()]) {
- pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] = true;
- if (!player.capabilities.isCreativeMode) {
- player.getCurrentEquippedItem().splitStack(1);
- }
- pipe.signalStrength[IPipe.WireColor.Yellow.ordinal()] = 0;
- pipe.container.scheduleNeighborChange();
+ } else if (currentItem.getItem() == BuildCraftTransport.yellowPipeWire) {
+ if (addOrStripWire(player, pipe, IPipe.WireColor.Yellow)) {
return true;
}
- } else if (player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGate.itemID
- || player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGateAutarchic.itemID)
- if (!pipe.hasGate()) {
-
- pipe.gate = Gate.makeGate(pipe, player.getCurrentEquippedItem());
- if (!player.capabilities.isCreativeMode) {
- player.getCurrentEquippedItem().splitStack(1);
- }
- pipe.container.scheduleRenderUpdate();
+ } else if (currentItem.getItem() instanceof ItemGate) {
+ if (addOrStripGate(world, x, y, z, player, pipe)) {
+ return true;
+ }
+ } else if (currentItem.getItem() instanceof ItemPlug) {
+ if (addOrStripPlug(world, x, y, z, player, ForgeDirection.getOrientation(side), pipe)) {
+ return true;
+ }
+ } else if (currentItem.getItem() instanceof ItemFacade)
+ if (addOrStripFacade(world, x, y, z, player, ForgeDirection.getOrientation(side), pipe)) {
return true;
}
- boolean openGateGui = false;
+ boolean clickedOnGate = false;
if (pipe.hasGate()) {
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
if (rayTraceResult != null && rayTraceResult.hitPart == Part.Gate) {
- openGateGui = true;
+ clickedOnGate = true;
}
}
- if (openGateGui) {
+ if (clickedOnGate) {
pipe.gate.openGui(player);
-
return true;
} else
return pipe.blockActivated(player);
@@ -711,22 +710,32 @@ public class BlockGenericPipe extends BlockContainer {
return false;
}
- private boolean stripEquipment(Pipe pipe) {
-
- // Try to strip wires first, starting with yellow.
- for (IPipe.WireColor color : IPipe.WireColor.values()) {
- if (pipe.wireSet[color.reverse().ordinal()]) {
- if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) {
- dropWire(color.reverse(), pipe);
- }
- pipe.wireSet[color.reverse().ordinal()] = false;
- // pipe.worldObj.markBlockNeedsUpdate(pipe.xCoord, pipe.yCoord, pipe.zCoord);
- pipe.container.scheduleRenderUpdate();
- return true;
+ private boolean addOrStripGate(World world, int x, int y, int z, EntityPlayer player, Pipe pipe) {
+ if (addGate(player, pipe))
+ return true;
+ if (player.isSneaking()) {
+ RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
+ if (rayTraceResult != null && rayTraceResult.hitPart == Part.Gate) {
+ if (stripGate(pipe))
+ return true;
}
}
+ return false;
+ }
- // Try to strip gate next
+ private boolean addGate(EntityPlayer player, Pipe pipe) {
+ if (!pipe.hasGate()) {
+ pipe.gate = Gate.makeGate(pipe, player.getCurrentEquippedItem());
+ if (!player.capabilities.isCreativeMode) {
+ player.getCurrentEquippedItem().splitStack(1);
+ }
+ pipe.container.scheduleRenderUpdate();
+ return true;
+ }
+ return false;
+ }
+
+ private boolean stripGate(Pipe pipe) {
if (pipe.hasGate()) {
if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) {
pipe.gate.dropGate();
@@ -734,10 +743,118 @@ public class BlockGenericPipe extends BlockContainer {
pipe.resetGate();
return true;
}
-
return false;
}
+ private boolean addOrStripWire(EntityPlayer player, Pipe pipe, IPipe.WireColor color) {
+ if (addWire(pipe, color)) {
+ if (!player.capabilities.isCreativeMode) {
+ player.getCurrentEquippedItem().splitStack(1);
+ }
+ return true;
+ }
+ return player.isSneaking() && stripWire(pipe, color);
+ }
+
+ private boolean addWire(Pipe pipe, IPipe.WireColor color) {
+ if (!pipe.wireSet[color.ordinal()]) {
+ pipe.wireSet[color.ordinal()] = true;
+ pipe.signalStrength[color.ordinal()] = 0;
+ pipe.container.scheduleNeighborChange();
+ return true;
+ }
+ return false;
+ }
+
+ private boolean stripWire(Pipe pipe, IPipe.WireColor color) {
+ if (pipe.wireSet[color.ordinal()]) {
+ if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) {
+ dropWire(color, pipe);
+ }
+ pipe.wireSet[color.ordinal()] = false;
+ pipe.container.scheduleRenderUpdate();
+ return true;
+ }
+ return false;
+ }
+
+ private boolean addOrStripFacade(World world, int x, int y, int z, EntityPlayer player, ForgeDirection side, Pipe pipe) {
+ RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
+ if (player.isSneaking()) {
+ if (rayTraceResult != null && rayTraceResult.hitPart == Part.Facade) {
+ if (stripFacade(pipe, rayTraceResult.sideHit))
+ return true;
+ }
+ }
+ if (rayTraceResult != null && (rayTraceResult.hitPart == Part.Pipe || rayTraceResult.hitPart == Part.Gate)) {
+ if (addFacade(player, pipe, rayTraceResult.sideHit != null && rayTraceResult.sideHit != ForgeDirection.UNKNOWN ? rayTraceResult.sideHit : side))
+ return true;
+ }
+ return false;
+ }
+
+ private boolean addFacade(EntityPlayer player, Pipe pipe, ForgeDirection side) {
+ ItemStack stack = player.getCurrentEquippedItem();
+ if (pipe.container.addFacade(side, ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) {
+ if (!player.capabilities.isCreativeMode) {
+ stack.stackSize--;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private boolean stripFacade(Pipe pipe, ForgeDirection side) {
+ return pipe.container.dropFacade(side);
+ }
+
+ private boolean addOrStripPlug(World world, int x, int y, int z, EntityPlayer player, ForgeDirection side, Pipe pipe) {
+ RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
+ if (player.isSneaking()) {
+ if (rayTraceResult != null && rayTraceResult.hitPart == Part.Plug) {
+ if (stripPlug(pipe, rayTraceResult.sideHit))
+ return true;
+ }
+ }
+ if (rayTraceResult != null && (rayTraceResult.hitPart == Part.Pipe || rayTraceResult.hitPart == Part.Gate)) {
+ if (addPlug(player, pipe, rayTraceResult.sideHit != null && rayTraceResult.sideHit != ForgeDirection.UNKNOWN ? rayTraceResult.sideHit : side))
+ return true;
+ }
+ return false;
+ }
+
+ private boolean addPlug(EntityPlayer player, Pipe pipe, ForgeDirection side) {
+ ItemStack stack = player.getCurrentEquippedItem();
+ if (pipe.container.addPlug(side)) {
+ if (!player.capabilities.isCreativeMode) {
+ stack.stackSize--;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private boolean stripPlug(Pipe pipe, ForgeDirection side) {
+ return pipe.container.removeAndDropPlug(side);
+ }
+
+ private boolean stripEquipment(World world, int x, int y, int z, EntityPlayer player, Pipe pipe) {
+ // Try to strip facades first
+ RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
+ if (rayTraceResult != null && rayTraceResult.hitPart == Part.Facade) {
+ if (stripFacade(pipe, rayTraceResult.sideHit))
+ return true;
+ }
+
+ // Try to strip wires second, starting with yellow.
+ for (IPipe.WireColor color : IPipe.WireColor.values()) {
+ if (stripWire(pipe, color))
+ return true;
+ }
+
+ return stripGate(pipe);
+ }
+
/**
* Drops a pipe wire item of the passed color.
*
@@ -766,11 +883,13 @@ public class BlockGenericPipe extends BlockContainer {
@SuppressWarnings({"all"})
@SideOnly(Side.CLIENT)
@Override
- public Icon getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) {
+ public Icon getBlockTexture(IBlockAccess iblockaccess, int x, int y, int z, int side) {
- TileEntity tile = iblockaccess.getBlockTileEntity(i, j, k);
+ TileEntity tile = iblockaccess.getBlockTileEntity(x, y, z);
if (!(tile instanceof IPipeRenderState))
return null;
+ if (((IPipeRenderState) tile).getRenderState().textureArray != null)
+ return ((IPipeRenderState) tile).getRenderState().textureArray[side];
return ((IPipeRenderState) tile).getRenderState().currentTexture;
// Pipe pipe = getPipe(iblockaccess, i, j, k);
@@ -874,11 +993,11 @@ public class BlockGenericPipe extends BlockContainer {
if (pipe != null)
return pipe.getConstructor(int.class).newInstance(key);
else {
- BuildCraftCore.bcLog.warning("Detected pipe with unknown key (" + key + "). Did you remove a buildcraft addon?");
+ BCLog.logger.warning("Detected pipe with unknown key (" + key + "). Did you remove a buildcraft addon?");
}
} catch (Throwable t) {
- BuildCraftCore.bcLog.warning("Failed to create pipe with (" + key + "). No valid constructor found. Possibly a item ID conflit.");
+ BCLog.logger.warning("Failed to create pipe with (" + key + "). No valid constructor found. Possibly a item ID conflit.");
}
return null;
@@ -891,9 +1010,9 @@ public class BlockGenericPipe extends BlockContainer {
boolean placed = world.setBlock(i, j, k, blockId, meta, 1);
if (placed) {
-
TileGenericPipe tile = (TileGenericPipe) world.getBlockTileEntity(i, j, k);
tile.initialize(pipe);
+ tile.sendUpdateToClient();
}
return placed;
@@ -973,31 +1092,31 @@ public class BlockGenericPipe extends BlockContainer {
double pz = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (b * 2.0F)) + b + block.getBlockBoundsMinZ();
if (sideHit == 0) {
- py = (double) y + block.getBlockBoundsMinY() - (double) b;
+ py = y + block.getBlockBoundsMinY() - b;
}
if (sideHit == 1) {
- py = (double) y + block.getBlockBoundsMaxY() + (double) b;
+ py = y + block.getBlockBoundsMaxY() + b;
}
if (sideHit == 2) {
- pz = (double) z + block.getBlockBoundsMinZ() - (double) b;
+ pz = z + block.getBlockBoundsMinZ() - b;
}
if (sideHit == 3) {
- pz = (double) z + block.getBlockBoundsMaxZ() + (double) b;
+ pz = z + block.getBlockBoundsMaxZ() + b;
}
if (sideHit == 4) {
- px = (double) x + block.getBlockBoundsMinX() - (double) b;
+ px = x + block.getBlockBoundsMinX() - b;
}
if (sideHit == 5) {
- px = (double) x + block.getBlockBoundsMaxX() + (double) b;
+ px = x + block.getBlockBoundsMaxX() + b;
}
EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, worldObj.getBlockMetadata(x, y, z));
- fx.func_110125_a(icon);
+ fx.setParticleIcon(icon);
effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
return true;
}
@@ -1029,12 +1148,12 @@ public class BlockGenericPipe extends BlockContainer {
for (int i = 0; i < its; ++i) {
for (int j = 0; j < its; ++j) {
for (int k = 0; k < its; ++k) {
- double px = x + (i + 0.5D) / (double) its;
- double py = y + (j + 0.5D) / (double) its;
- double pz = z + (k + 0.5D) / (double) its;
+ double px = x + (i + 0.5D) / its;
+ double py = y + (j + 0.5D) / its;
+ double pz = z + (k + 0.5D) / its;
int random = rand.nextInt(6);
EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, BuildCraftTransport.genericPipeBlock, random, meta);
- fx.func_110125_a(icon);
+ fx.setParticleIcon(icon);
effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
}
}
diff --git a/common/buildcraft/transport/EnergyPulser.java b/common/buildcraft/transport/EnergyPulser.java
index 91c11140..53b7602f 100644
--- a/common/buildcraft/transport/EnergyPulser.java
+++ b/common/buildcraft/transport/EnergyPulser.java
@@ -27,7 +27,7 @@ public class EnergyPulser {
return;
if (!singlePulse || !hasPulsed) {
- powerReceptor.getPowerReceiver(null).receiveEnergy(Type.GATE, Math.min(1 << (pulseCount - 1), 64), ForgeDirection.WEST);
+ powerReceptor.getPowerReceiver(null).receiveEnergy(Type.GATE, Math.min(1 << (pulseCount - 1), 64) *1.01f, ForgeDirection.WEST);
hasPulsed = true;
}
}
diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java
index e5453285..3e4ffcf1 100644
--- a/common/buildcraft/transport/Gate.java
+++ b/common/buildcraft/transport/Gate.java
@@ -153,7 +153,11 @@ public abstract class Gate {
// / UPDATING
public abstract void update();
- public abstract void dropGate();
+ public abstract ItemStack getGateItem();
+
+ public void dropGate() {
+ pipe.dropItem(getGateItem());
+ }
public void resetGate() {
if (broadcastRedstone) {
@@ -247,7 +251,6 @@ public abstract class Gate {
for (int i = 0; i < oldBroadcastSignal.length; ++i) {
if (oldBroadcastSignal[i] != broadcastSignal[i]) {
- // worldObj.markBlockNeedsUpdate(container.xCoord, container.yCoord, zCoord);
pipe.container.scheduleRenderUpdate();
pipe.updateSignalState();
break;
@@ -285,6 +288,10 @@ public abstract class Gate {
public abstract ResourceLocation getGuiFile();
+ public int getGuiHeight() {
+ return 207;
+ }
+
public static boolean isGateItem(ItemStack stack) {
return stack.itemID == BuildCraftTransport.pipeGate.itemID || stack.itemID == BuildCraftTransport.pipeGateAutarchic.itemID;
}
diff --git a/common/buildcraft/transport/GateVanilla.java b/common/buildcraft/transport/GateVanilla.java
index 8d0726e3..1c61ed51 100644
--- a/common/buildcraft/transport/GateVanilla.java
+++ b/common/buildcraft/transport/GateVanilla.java
@@ -140,7 +140,7 @@ public class GateVanilla extends Gate {
* @param k
*/
@Override
- public void dropGate() {
+ public ItemStack getGateItem() {
int gateDamage;
switch (kind) {
@@ -175,7 +175,7 @@ public class GateVanilla extends Gate {
gateItem = BuildCraftTransport.pipeGate;
}
- pipe.dropItem(new ItemStack(gateItem, 1, gateDamage));
+ return new ItemStack(gateItem, 1, gateDamage);
}
@@ -322,4 +322,17 @@ public class GateVanilla extends Gate {
else
return TEXTURE4;
}
+
+ @Override
+ public int getGuiHeight() {
+ switch (kind) {
+ case Single:
+ return 146;
+ case AND_2:
+ case OR_2:
+ return 164;
+ default:
+ return 200;
+ }
+ }
}
diff --git a/common/buildcraft/transport/GuiHandler.java b/common/buildcraft/transport/GuiHandler.java
index 767dcd34..92de6927 100644
--- a/common/buildcraft/transport/GuiHandler.java
+++ b/common/buildcraft/transport/GuiHandler.java
@@ -1,7 +1,7 @@
package buildcraft.transport;
-import buildcraft.BuildCraftCore;
import buildcraft.core.GuiIds;
+import buildcraft.core.utils.BCLog;
import buildcraft.transport.gui.ContainerDiamondPipe;
import buildcraft.transport.gui.ContainerEmeraldPipe;
import buildcraft.transport.gui.ContainerFilteredBuffer;
@@ -49,13 +49,14 @@ public class GuiHandler implements IGuiHandler {
return new ContainerEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe);
case GuiIds.GATES:
- return new ContainerGateInterface(player.inventory, pipe.pipe);
+ if (pipe.pipe.hasGate())
+ return new ContainerGateInterface(player.inventory, pipe.pipe);
default:
return null;
}
} catch (Exception ex) {
- BuildCraftCore.bcLog.log(Level.SEVERE, "Failed to open GUI", ex);
+ BCLog.logger.log(Level.SEVERE, "Failed to open GUI", ex);
}
return null;
}
@@ -89,13 +90,14 @@ public class GuiHandler implements IGuiHandler {
return new GuiEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe);
case GuiIds.GATES:
- return new GuiGateInterface(player.inventory, pipe.pipe);
+ if (pipe.pipe.hasGate())
+ return new GuiGateInterface(player.inventory, pipe.pipe);
default:
return null;
}
} catch (Exception ex) {
- BuildCraftCore.bcLog.log(Level.SEVERE, "Failed to open GUI", ex);
+ BCLog.logger.log(Level.SEVERE, "Failed to open GUI", ex);
}
return null;
}
diff --git a/common/buildcraft/transport/IPipeConnectionForced.java b/common/buildcraft/transport/IPipeConnectionForced.java
new file mode 100644
index 00000000..209e5c31
--- /dev/null
+++ b/common/buildcraft/transport/IPipeConnectionForced.java
@@ -0,0 +1,14 @@
+package buildcraft.transport;
+
+import net.minecraftforge.common.ForgeDirection;
+
+public interface IPipeConnectionForced {
+
+ /**
+ * Allows you to block connection overrides.
+ *
+ * @param with
+ * @return TRUE to block an override. FALSE to allow overrides.
+ */
+ public boolean ignoreConnectionOverrides(ForgeDirection with);
+}
diff --git a/common/buildcraft/transport/IPipeTransportPowerHook.java b/common/buildcraft/transport/IPipeTransportPowerHook.java
index 28cc3450..898019ca 100644
--- a/common/buildcraft/transport/IPipeTransportPowerHook.java
+++ b/common/buildcraft/transport/IPipeTransportPowerHook.java
@@ -13,7 +13,15 @@ import net.minecraftforge.common.ForgeDirection;
public interface IPipeTransportPowerHook {
+ /**
+ * Override default behavior on receiving energy into the pipe.
+ *
+ * @return The amount of power used, or -1 for default behavior.
+ */
public float receiveEnergy(ForgeDirection from, float val);
+ /**
+ * Override default requested power.
+ */
public float requestEnergy(ForgeDirection from, float amount);
}
diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java
index 7dd4553b..eec7a89f 100644
--- a/common/buildcraft/transport/ItemFacade.java
+++ b/common/buildcraft/transport/ItemFacade.java
@@ -1,6 +1,7 @@
package buildcraft.transport;
import buildcraft.BuildCraftTransport;
+import buildcraft.api.core.Position;
import buildcraft.api.recipes.AssemblyRecipe;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.ItemBuildCraft;
@@ -36,7 +37,7 @@ public class ItemFacade extends ItemBuildCraft {
setHasSubtypes(true);
setMaxDamage(0);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setCreativeTab(CreativeTabBuildCraft.FACADES.get());
}
@Override
@@ -72,28 +73,24 @@ public class ItemFacade extends ItemBuildCraft {
}
@Override
- public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
+ public boolean onItemUse(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (worldObj.isRemote)
return false;
- TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
+ Position pos = new Position(x, y, z, ForgeDirection.getOrientation(side));
+ pos.moveForwards(1.0);
+
+ TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
if (!(tile instanceof TileGenericPipe))
return false;
TileGenericPipe pipeTile = (TileGenericPipe) tile;
- if (player.isSneaking()) { // Strip facade
- if (!pipeTile.hasFacade(ForgeDirection.VALID_DIRECTIONS[side]))
- return false;
- pipeTile.dropFacade(ForgeDirection.VALID_DIRECTIONS[side]);
- return true;
- } else {
- if (((TileGenericPipe) tile).addFacade(ForgeDirection.values()[side], ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) {
- if (!player.capabilities.isCreativeMode) {
- stack.stackSize--;
- }
- return true;
+ if (pipeTile.addFacade(ForgeDirection.getOrientation(side).getOpposite(), ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) {
+ if (!player.capabilities.isCreativeMode) {
+ stack.stackSize--;
}
- return false;
+ return true;
}
+ return false;
}
public static void initialize() {
@@ -126,7 +123,7 @@ public class ItemFacade extends ItemBuildCraft {
Set names = Sets.newHashSet();
for (int meta = 0; meta <= 15; meta++) {
ItemStack is = new ItemStack(b, 1, meta);
- if (!Strings.isNullOrEmpty(is.getItemName()) && names.add(is.getItemName())) {
+ if (!Strings.isNullOrEmpty(is.getUnlocalizedName()) && names.add(is.getUnlocalizedName())) {
ItemFacade.addFacade(is);
}
}
@@ -219,13 +216,13 @@ public class ItemFacade extends ItemBuildCraft {
Block bl = Block.blocksList[blockId];
// No Meta
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0xC) == 0)
- return getStack(blockId, (blockMeta & 0x3) | 4);
+ return getStack(bl, (blockMeta & 0x3) | 4);
// Meta | 4 = true
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x8) == 0)
- return getStack(blockId, (blockMeta & 0x3) | 8);
+ return getStack(bl, (blockMeta & 0x3) | 8);
// Meta | 8 = true
if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x4) == 0)
- return getStack(blockId, (blockMeta & 0x3));
+ return getStack(bl, (blockMeta & 0x3));
}
return null;
}
@@ -253,6 +250,10 @@ public class ItemFacade extends ItemBuildCraft {
return 0;
}
+ public static ItemStack getStack(Block block, int metadata) {
+ return getStack(block.blockID, metadata);
+ }
+
public static ItemStack getStack(int blockID, int metadata) {
ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0);
NBTTagCompound nbt = new NBTTagCompound("tag");
diff --git a/common/buildcraft/transport/ItemGate.java b/common/buildcraft/transport/ItemGate.java
index 43c0ba7e..4e7286af 100644
--- a/common/buildcraft/transport/ItemGate.java
+++ b/common/buildcraft/transport/ItemGate.java
@@ -3,7 +3,6 @@ package buildcraft.transport;
import buildcraft.api.gates.ActionManager;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.ITrigger;
-import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.ItemBuildCraft;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -45,7 +44,7 @@ public class ItemGate extends ItemBuildCraft {
setHasSubtypes(true);
setMaxDamage(0);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
+ setPassSneakClick(true);
}
@SuppressWarnings({ "all" })
diff --git a/common/buildcraft/transport/ItemPipe.java b/common/buildcraft/transport/ItemPipe.java
index 9eafad8b..13893649 100644
--- a/common/buildcraft/transport/ItemPipe.java
+++ b/common/buildcraft/transport/ItemPipe.java
@@ -7,12 +7,11 @@
*/
package buildcraft.transport;
-import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
-import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.IItemPipe;
import buildcraft.core.ItemBuildCraft;
+import buildcraft.core.utils.BCLog;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
@@ -32,7 +31,6 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
protected ItemPipe(int i) {
super(i);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
}
@Override
@@ -72,7 +70,7 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
Pipe pipe = BlockGenericPipe.createPipe(itemID);
if (pipe == null) {
- BuildCraftCore.bcLog.log(Level.WARNING, "Pipe failed to create during placement at {0},{1},{2}", new Object[]{i, j, k});
+ BCLog.logger.log(Level.WARNING, "Pipe failed to create during placement at {0},{1},{2}", new Object[]{i, j, k});
return true;
}
if (BlockGenericPipe.placePipe(pipe, world, i, j, k, blockID, 0)) {
@@ -121,12 +119,11 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
}
@Override
+ @SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
super.addInformation(stack, player, list, advanced);
Class extends Pipe> pipe = BlockGenericPipe.pipes.get(itemID);
- Integer capacity = PipeTransportPower.powerCapacities.get(pipe);
- if (capacity != null) {
- list.add(String.format("%d MJ/t", capacity));
- }
+ List toolTip = PipeToolTipManager.getToolTip(pipe);
+ list.addAll(toolTip);
}
}
diff --git a/common/buildcraft/transport/ItemPlug.java b/common/buildcraft/transport/ItemPlug.java
index f819d006..94b5fcbf 100644
--- a/common/buildcraft/transport/ItemPlug.java
+++ b/common/buildcraft/transport/ItemPlug.java
@@ -1,21 +1,16 @@
package buildcraft.transport;
-import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.ItemBuildCraft;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
-import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
-import net.minecraftforge.common.ForgeDirection;
public class ItemPlug extends ItemBuildCraft {
public ItemPlug(int i) {
super(i);
- setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
}
@Override
@@ -23,30 +18,30 @@ public class ItemPlug extends ItemBuildCraft {
return "item.PipePlug";
}
- @Override
- public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
- if (worldObj.isRemote)
- return false;
- TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
- if (!(tile instanceof TileGenericPipe))
- return false;
- TileGenericPipe pipeTile = (TileGenericPipe) tile;
-
- if (player.isSneaking()) { // Strip plug
- if (!pipeTile.hasPlug(ForgeDirection.VALID_DIRECTIONS[side]))
- return false;
- pipeTile.removeAndDropPlug(ForgeDirection.VALID_DIRECTIONS[side]);
- return true;
- } else {
- if (((TileGenericPipe) tile).addPlug(ForgeDirection.VALID_DIRECTIONS[side])){
- if (!player.capabilities.isCreativeMode) {
- stack.stackSize--;
- }
- return true;
- }
- return false;
- }
- }
+// @Override
+// public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
+// if (worldObj.isRemote)
+// return false;
+// TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
+// if (!(tile instanceof TileGenericPipe))
+// return false;
+// TileGenericPipe pipeTile = (TileGenericPipe) tile;
+//
+// if (player.isSneaking()) { // Strip plug
+// if (!pipeTile.hasPlug(ForgeDirection.VALID_DIRECTIONS[side]))
+// return false;
+// pipeTile.removeAndDropPlug(ForgeDirection.VALID_DIRECTIONS[side]);
+// return true;
+// } else {
+// if (((TileGenericPipe) tile).addPlug(ForgeDirection.VALID_DIRECTIONS[side])){
+// if (!player.capabilities.isCreativeMode) {
+// stack.stackSize--;
+// }
+// return true;
+// }
+// return false;
+// }
+// }
@Override
public boolean shouldPassSneakingClickToBlock(World worldObj, int x, int y, int z ) {
diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java
index e3d0f05e..fe0b9ebb 100644
--- a/common/buildcraft/transport/Pipe.java
+++ b/common/buildcraft/transport/Pipe.java
@@ -86,6 +86,10 @@ public abstract class Pipe implements IPipe, IDropContr
Pipe otherPipe;
if (tile instanceof TileGenericPipe) {
otherPipe = ((TileGenericPipe) tile).pipe;
+
+ if (!BlockGenericPipe.isFullyDefined(otherPipe))
+ return false;
+
if (!PipeConnectionBans.canPipesConnect(getClass(), otherPipe.getClass()))
return false;
}
@@ -135,15 +139,11 @@ public abstract class Pipe implements IPipe, IDropContr
if (container.worldObj.isRemote)
return;
- if (actionTracker.markTimeIfDelay(container.worldObj, 10)) {
- resolveActions();
- }
-
// Update the gate if we have any
if (gate != null) {
+ gate.resolveActions();
gate.update();
}
-
}
private void internalUpdate() {
@@ -293,9 +293,7 @@ public abstract class Pipe implements IPipe, IDropContr
internalUpdateScheduled = true;
if (oldSignal == 0) {
- // worldObj.markBlockNeedsUpdate(container.xCoord, container.yCoord, zCoord);
container.scheduleRenderUpdate();
-
}
return true;
@@ -361,6 +359,30 @@ public abstract class Pipe implements IPipe, IDropContr
return gate != null;
}
+ public boolean hasGate(ForgeDirection side) {
+ if (!hasGate())
+ return false;
+ if (container.hasFacade(side))
+ return false;
+ if (container.hasPlug(side))
+ return false;
+
+ int connections = 0;
+ ForgeDirection targetOrientation = ForgeDirection.UNKNOWN;
+ for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
+ if (container.isPipeConnected(o)) {
+ connections++;
+ if (connections == 1)
+ targetOrientation = o;
+ }
+ }
+
+ if (connections > 1 || connections == 0)
+ return true;
+
+ return targetOrientation.getOpposite() != side;
+ }
+
protected void notifyBlocksOfNeighborChange(ForgeDirection side) {
container.worldObj.notifyBlocksOfNeighborChange(container.xCoord + side.offsetX, container.yCoord + side.offsetY, container.zCoord + side.offsetZ, BuildCraftTransport.genericPipeBlock.blockID);
}
@@ -430,13 +452,6 @@ public abstract class Pipe implements IPipe, IDropContr
container.scheduleRenderUpdate();
}
- private void resolveActions() {
- if (!hasGate())
- return;
-
- gate.resolveActions();
- }
-
protected void actionsActivated(Map actions) {
}
diff --git a/common/buildcraft/transport/PipeIconProvider.java b/common/buildcraft/transport/PipeIconProvider.java
index 1f1714ec..e9ba64f2 100644
--- a/common/buildcraft/transport/PipeIconProvider.java
+++ b/common/buildcraft/transport/PipeIconProvider.java
@@ -1,10 +1,11 @@
package buildcraft.transport;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.util.Icon;
+import buildcraft.BuildCraftCore;
import buildcraft.api.core.IIconProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import net.minecraft.client.renderer.texture.IconRegister;
-import net.minecraft.util.Icon;
public class PipeIconProvider implements IIconProvider {
@@ -19,7 +20,7 @@ public class PipeIconProvider implements IIconProvider {
PipeItemsDiamond_Up("pipeItemsDiamond_up"),
PipeItemsDiamond_North("pipeItemsDiamond_north"),
PipeItemsDiamond_South("pipeItemsDiamond_south"),
- PipeItemsDiamond_West("pipeItemsDiamond_west"),
+ PipeItemsDiamond_West("pipeItemsDiamond_west", "pipeItemsDiamond_west_cb"),
PipeItemsDiamond_East("pipeItemsDiamond_east"),
//
PipeItemsLapis_Black("pipeItemsLapis_black"),
@@ -90,6 +91,14 @@ public class PipeIconProvider implements IIconProvider {
PipePowerCobblestone("pipePowerCobblestone"),
PipePowerWood_Standard("pipePowerWood_standard"),
//
+ PipePowerIronM2("pipePowerIronM2"),
+ PipePowerIronM4("pipePowerIronM4"),
+ PipePowerIronM8("pipePowerIronM8"),
+ PipePowerIronM16("pipePowerIronM16"),
+ PipePowerIronM32("pipePowerIronM32"),
+ PipePowerIronM64("pipePowerIronM64"),
+ PipePowerIronM128("pipePowerIronM128"),
+ //
Power_Normal("texture_cyan"),
Power_Overload("texture_red_lit"),
Stripes("pipeStripes"),
@@ -97,14 +106,20 @@ public class PipeIconProvider implements IIconProvider {
ItemBox("itemBox");
public static final TYPE[] VALUES = values();
private final String iconTag;
+ private final String iconTagColorBlind;
private Icon icon;
- private TYPE(String iconTag) {
+ private TYPE(String iconTag, String IconTagColorBlind) {
this.iconTag = iconTag;
+ this.iconTagColorBlind = IconTagColorBlind;
+ }
+
+ private TYPE(String iconTag) {
+ this(iconTag, iconTag);
}
private void registerIcon(IconRegister iconRegister) {
- icon = iconRegister.registerIcon("buildcraft:" + iconTag);
+ icon = iconRegister.registerIcon("buildcraft:" + (BuildCraftCore.colorBlindMode ? iconTagColorBlind : iconTag));
}
public Icon getIcon() {
diff --git a/common/buildcraft/transport/PipeRenderState.java b/common/buildcraft/transport/PipeRenderState.java
index 7448d50c..4727da75 100644
--- a/common/buildcraft/transport/PipeRenderState.java
+++ b/common/buildcraft/transport/PipeRenderState.java
@@ -16,14 +16,11 @@ public class PipeRenderState implements IClientState {
private boolean hasGate = false;
private int gateIconIndex = 0;
-
public final ConnectionMatrix pipeConnectionMatrix = new ConnectionMatrix();
public final TextureMatrix textureMatrix = new TextureMatrix();
public final WireMatrix wireMatrix = new WireMatrix();
public final ConnectionMatrix plugMatrix = new ConnectionMatrix();
-
public final FacadeMatrix facadeMatrix = new FacadeMatrix();
-
private boolean dirty = true;
/*
@@ -31,6 +28,8 @@ public class PipeRenderState implements IClientState {
*/
@SideOnly(Side.CLIENT)
public Icon currentTexture;
+ @SideOnly(Side.CLIENT)
+ public Icon[] textureArray;
public void setHasGate(boolean value) {
if (hasGate != value) {
@@ -58,14 +57,19 @@ public class PipeRenderState implements IClientState {
dirty = false;
pipeConnectionMatrix.clean();
textureMatrix.clean();
- wireMatrix.clean();
facadeMatrix.clean();
+ wireMatrix.clean();
+ plugMatrix.clean();
}
public boolean isDirty() {
return dirty || pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || wireMatrix.isDirty() || facadeMatrix.isDirty() || plugMatrix.isDirty();
}
+ public boolean needsRenderUpdate() {
+ return pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || facadeMatrix.isDirty() || plugMatrix.isDirty();
+ }
+
@Override
public void writeData(DataOutputStream data) throws IOException {
data.writeBoolean(hasGate);
diff --git a/common/buildcraft/transport/PipeToolTipManager.java b/common/buildcraft/transport/PipeToolTipManager.java
new file mode 100644
index 00000000..f7c22df1
--- /dev/null
+++ b/common/buildcraft/transport/PipeToolTipManager.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.transport;
+
+import buildcraft.core.utils.Localization;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+@SideOnly(Side.CLIENT)
+public class PipeToolTipManager {
+
+ private static final Map, String> toolTips = new HashMap, String>();
+
+ static {
+ for (Map.Entry, Integer> pipe : PipeTransportPower.powerCapacities.entrySet()) {
+ PipeToolTipManager.addToolTip(pipe.getKey(), String.format("%d MJ/t", pipe.getValue()));
+ }
+ }
+
+ public static void addToolTip(Class extends Pipe> pipe, String toolTip) {
+ toolTips.put(pipe, toolTip);
+ }
+
+ public static List getToolTip(Class extends Pipe> pipe) {
+ List tips = new ArrayList();
+ String tipTag = "tip." + pipe.getSimpleName();
+ if (Localization.hasKey(tipTag)) {
+ String localized = Localization.get(tipTag);
+ if (localized != null) {
+ String[] lines = localized.split("\\n");
+ tips.addAll(Arrays.asList(lines));
+ }
+ }
+ String tip = toolTips.get(pipe);
+ if (tip != null)
+ tips.add(tip);
+ return tips;
+ }
+}
diff --git a/common/buildcraft/transport/PipeTransportFluids.java b/common/buildcraft/transport/PipeTransportFluids.java
index 51b523e8..4704124e 100644
--- a/common/buildcraft/transport/PipeTransportFluids.java
+++ b/common/buildcraft/transport/PipeTransportFluids.java
@@ -7,16 +7,8 @@
*/
package buildcraft.transport;
-import buildcraft.BuildCraftCore;
-import buildcraft.api.core.SafeTimeTracker;
-import buildcraft.api.gates.ITrigger;
-import buildcraft.api.transport.IPipeTile.PipeType;
-import buildcraft.core.DefaultProps;
-import buildcraft.core.IMachine;
-import buildcraft.core.proxy.CoreProxy;
-import buildcraft.core.utils.Utils;
-import buildcraft.transport.network.PacketFluidUpdate;
import java.util.BitSet;
+
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
@@ -28,6 +20,14 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
+import buildcraft.BuildCraftCore;
+import buildcraft.api.core.SafeTimeTracker;
+import buildcraft.api.gates.ITrigger;
+import buildcraft.api.transport.IPipeTile.PipeType;
+import buildcraft.core.DefaultProps;
+import buildcraft.core.IMachine;
+import buildcraft.core.proxy.CoreProxy;
+import buildcraft.transport.network.PacketFluidUpdate;
public class PipeTransportFluids extends PipeTransport implements IFluidHandler {
@@ -330,7 +330,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
}
private void moveFluids() {
- short newTimeSlot = (short) (container.worldObj.getWorldTime() % travelDelay);
+ short newTimeSlot = (short) (container.worldObj.getTotalWorldTime() % travelDelay);
short outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot);
moveFromPipe(outputCount);
diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java
index 5fe69429..13254ab4 100644
--- a/common/buildcraft/transport/PipeTransportItems.java
+++ b/common/buildcraft/transport/PipeTransportItems.java
@@ -7,7 +7,6 @@
*/
package buildcraft.transport;
-import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.Position;
import buildcraft.api.gates.ITrigger;
@@ -18,11 +17,12 @@ import buildcraft.core.IMachine;
import buildcraft.core.inventory.Transactor;
import buildcraft.core.network.PacketIds;
import buildcraft.core.proxy.CoreProxy;
+import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.BlockUtil;
-import buildcraft.core.utils.Utils;
import buildcraft.transport.network.PacketPipeTransportContent;
import buildcraft.transport.network.PacketPipeTransportNBT;
import buildcraft.transport.network.PacketSimpleId;
+import buildcraft.transport.utils.TransportUtils;
import com.google.common.collect.BiMap;
import com.google.common.collect.ForwardingSet;
import com.google.common.collect.HashBiMap;
@@ -40,6 +40,7 @@ import java.util.logging.Level;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -133,12 +134,12 @@ public class PipeTransportItems extends PipeTransport {
public void defaultReajustSpeed(TravelingItem item) {
float speed = item.getSpeed();
- if (speed > Utils.pipeNormalSpeed) {
- speed -= Utils.pipeNormalSpeed;
+ if (speed > TransportConstants.PIPE_NORMAL_SPEED) {
+ speed -= TransportConstants.PIPE_NORMAL_SPEED;
}
- if (speed < Utils.pipeNormalSpeed) {
- speed = Utils.pipeNormalSpeed;
+ if (speed < TransportConstants.PIPE_NORMAL_SPEED) {
+ speed = TransportConstants.PIPE_NORMAL_SPEED;
}
item.setSpeed(speed);
@@ -158,7 +159,7 @@ public class PipeTransportItems extends PipeTransport {
z = Math.min(z, container.zCoord + 0.99);
if (item.input != ForgeDirection.UP && item.input != ForgeDirection.DOWN) {
- y = container.yCoord + Utils.getPipeFloorOf(item.getItemStack());
+ y = container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack());
}
item.setPosition(x, y, z);
@@ -195,7 +196,7 @@ public class PipeTransportItems extends PipeTransport {
}
if (items.size() > MAX_PIPE_STACKS) {
- BuildCraftCore.bcLog.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many stacks: %d", container.xCoord, container.yCoord, container.zCoord, items.size()));
+ BCLog.logger.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many stacks: %d", container.xCoord, container.yCoord, container.zCoord, items.size()));
destroyPipe();
return;
}
@@ -208,7 +209,7 @@ public class PipeTransportItems extends PipeTransport {
}
if (numItems > MAX_PIPE_ITEMS) {
- BuildCraftCore.bcLog.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many items: %d", container.xCoord, container.yCoord, container.zCoord, numItems));
+ BCLog.logger.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many items: %d", container.xCoord, container.yCoord, container.zCoord, numItems));
destroyPipe();
}
}
@@ -271,23 +272,23 @@ public class PipeTransportItems extends PipeTransport {
item.blacklist.add(item.input.getOpposite());
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
- if(item.blacklist.contains(o))
+ if (item.blacklist.contains(o))
continue;
if (container.pipe.outputOpen(o) && canReceivePipeObjects(o, item))
result.add(o);
}
+ if (this.container.pipe instanceof IPipeTransportItemsHook) {
+ Position pos = new Position(container.xCoord, container.yCoord, container.zCoord, item.input);
+ result = ((IPipeTransportItemsHook) this.container.pipe).filterPossibleMovements(result, pos, item);
+ }
+
if (allowBouncing && result.isEmpty()) {
if (canReceivePipeObjects(item.input.getOpposite(), item)) {
result.add(item.input.getOpposite());
}
}
- if (this.container.pipe instanceof IPipeTransportItemsHook) {
- Position pos = new Position(container.xCoord, container.yCoord, container.zCoord, item.input);
- result = ((IPipeTransportItemsHook) this.container.pipe).filterPossibleMovements(result, pos, item);
- }
-
return result;
}
@@ -337,7 +338,7 @@ public class PipeTransportItems extends PipeTransport {
item.toCenter = false;
// Reajusting to the middle
- item.setPosition(container.xCoord + 0.5, container.yCoord + Utils.getPipeFloorOf(item.getItemStack()), container.zCoord + 0.5);
+ item.setPosition(container.xCoord + 0.5, container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()), container.zCoord + 0.5);
if (item.output == ForgeDirection.UNKNOWN) {
if (travelHook != null) {
@@ -420,7 +421,7 @@ public class PipeTransportItems extends PipeTransport {
protected boolean middleReached(TravelingItem item) {
float middleLimit = item.getSpeed() * 1.01F;
- return (Math.abs(container.xCoord + 0.5 - item.xCoord) < middleLimit && Math.abs(container.yCoord + Utils.getPipeFloorOf(item.getItemStack()) - item.yCoord) < middleLimit && Math
+ return (Math.abs(container.xCoord + 0.5 - item.xCoord) < middleLimit && Math.abs(container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()) - item.yCoord) < middleLimit && Math
.abs(container.zCoord + 0.5 - item.zCoord) < middleLimit);
}
@@ -554,10 +555,20 @@ public class PipeTransportItems extends PipeTransport {
PacketDispatcher.sendPacketToAllAround(container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST, dimension, createItemPacket(data));
}
- public int getNumberOfItems() {
+ public int getNumberOfStacks() {
return items.size();
}
+ public int getNumberOfItems() {
+ int num = 0;
+ for (TravelingItem item : items) {
+ if (item.getItemStack() == null)
+ continue;
+ num += item.getItemStack().stackSize;
+ }
+ return num;
+ }
+
public void onDropped(EntityItem item) {
this.container.pipe.onDropped(item);
}
@@ -573,6 +584,11 @@ public class PipeTransportItems extends PipeTransport {
return false;
}
+ if (tile instanceof ISidedInventory) {
+ int[] slots = ((ISidedInventory) tile).getAccessibleSlotsFromSide(side.getOpposite().ordinal());
+ return slots != null && slots.length > 0;
+ }
+
return tile instanceof TileGenericPipe || tile instanceof ISpecialInventory || (tile instanceof IInventory && ((IInventory) tile).getSizeInventory() > 0)
|| (tile instanceof IMachine && ((IMachine) tile).manageSolids());
}
diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java
index bf5e4ea8..e048132e 100644
--- a/common/buildcraft/transport/PipeTransportPower.java
+++ b/common/buildcraft/transport/PipeTransportPower.java
@@ -7,6 +7,13 @@
*/
package buildcraft.transport;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.gates.ITrigger;
@@ -17,20 +24,14 @@ import buildcraft.api.power.PowerHandler.Type;
import buildcraft.api.transport.IPipeTile.PipeType;
import buildcraft.core.DefaultProps;
import buildcraft.core.proxy.CoreProxy;
-import buildcraft.core.utils.Utils;
import buildcraft.transport.network.PacketPowerUpdate;
import buildcraft.transport.pipes.PipePowerCobblestone;
import buildcraft.transport.pipes.PipePowerDiamond;
import buildcraft.transport.pipes.PipePowerGold;
+import buildcraft.transport.pipes.PipePowerIron;
import buildcraft.transport.pipes.PipePowerQuartz;
import buildcraft.transport.pipes.PipePowerStone;
import buildcraft.transport.pipes.PipePowerWood;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraftforge.common.ForgeDirection;
public class PipeTransportPower extends PipeTransport {
@@ -44,6 +45,7 @@ public class PipeTransportPower extends PipeTransport {
powerCapacities.put(PipePowerStone.class, 16);
powerCapacities.put(PipePowerWood.class, 32);
powerCapacities.put(PipePowerQuartz.class, 64);
+ powerCapacities.put(PipePowerIron.class, 128);
powerCapacities.put(PipePowerGold.class, 256);
powerCapacities.put(PipePowerDiamond.class, 1024);
}
@@ -278,8 +280,8 @@ public class PipeTransportPower extends PipeTransport {
}
private void step() {
- if (currentDate != container.worldObj.getWorldTime()) {
- currentDate = container.worldObj.getWorldTime();
+ if (currentDate != container.worldObj.getTotalWorldTime()) {
+ currentDate = container.worldObj.getTotalWorldTime();
powerQuery = nextPowerQuery;
nextPowerQuery = new int[6];
@@ -321,14 +323,21 @@ public class PipeTransportPower extends PipeTransport {
step();
if (this.container.pipe instanceof IPipeTransportPowerHook) {
- return ((IPipeTransportPowerHook) this.container.pipe).receiveEnergy(from, val);
- } else {
- internalNextPower[from.ordinal()] += val;
+ float ret = ((IPipeTransportPowerHook) this.container.pipe).receiveEnergy(from, val);
+ if (ret >= 0)
+ return ret;
+ }
+ int side = from.ordinal();
+ if (internalNextPower[side] > maxPower)
+ return 0;
- if (internalNextPower[from.ordinal()] > maxPower) {
- val -= internalNextPower[from.ordinal()] - maxPower;
- internalNextPower[from.ordinal()] = maxPower;
- }
+ internalNextPower[side] += val;
+
+ if (internalNextPower[side] > maxPower) {
+ val -= internalNextPower[side] - maxPower;
+ internalNextPower[side] = maxPower;
+ if (val < 0)
+ val = 0;
}
return val;
}
@@ -344,7 +353,7 @@ public class PipeTransportPower extends PipeTransport {
@Override
public void initialize() {
- currentDate = container.worldObj.getWorldTime();
+ currentDate = container.worldObj.getTotalWorldTime();
}
@Override
diff --git a/common/buildcraft/transport/TileFilteredBuffer.java b/common/buildcraft/transport/TileFilteredBuffer.java
index dbb8c0b5..3101a9a4 100644
--- a/common/buildcraft/transport/TileFilteredBuffer.java
+++ b/common/buildcraft/transport/TileFilteredBuffer.java
@@ -1,18 +1,14 @@
package buildcraft.transport;
-import buildcraft.BuildCraftTransport;
-import buildcraft.api.gates.IOverrideDefaultTriggers;
-import buildcraft.api.gates.ITrigger;
import buildcraft.core.TileBuildCraft;
import buildcraft.core.inventory.SimpleInventory;
-import java.util.LinkedList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
-public class TileFilteredBuffer extends TileBuildCraft implements IInventory, IOverrideDefaultTriggers {
+public class TileFilteredBuffer extends TileBuildCraft implements IInventory {
private final SimpleInventory inventoryFilters = new SimpleInventory(9, "FilteredBufferFilters", 1);
private final SimpleInventory inventoryStorage = new SimpleInventory(9, "FilteredBufferStorage", 64);
@@ -93,17 +89,6 @@ public class TileFilteredBuffer extends TileBuildCraft implements IInventory, IO
return false;
}
- @Override
- public LinkedList getTriggers() {
- LinkedList result = new LinkedList();
-
- result.add(BuildCraftTransport.triggerInventoryBelow25);
- result.add(BuildCraftTransport.triggerInventoryBelow50);
- result.add(BuildCraftTransport.triggerInventoryBelow75);
-
- return result;
- }
-
@Override
public void readFromNBT(NBTTagCompound nbtTagCompound) {
super.readFromNBT(nbtTagCompound);
diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java
index 14a13bf5..9b02066c 100644
--- a/common/buildcraft/transport/TileGenericPipe.java
+++ b/common/buildcraft/transport/TileGenericPipe.java
@@ -7,6 +7,24 @@
*/
package buildcraft.transport;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.logging.Level;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.packet.Packet;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
@@ -27,32 +45,18 @@ import buildcraft.core.ITileBufferHolder;
import buildcraft.core.TileBuffer;
import buildcraft.core.inventory.InvUtils;
import buildcraft.core.network.IClientState;
+import buildcraft.core.network.IGuiReturnHandler;
import buildcraft.core.network.ISyncedTile;
import buildcraft.core.network.PacketTileState;
+import buildcraft.core.utils.BCLog;
import buildcraft.transport.Gate.GateKind;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.logging.Level;
-import net.minecraft.block.Block;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.network.packet.Packet;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.world.World;
-import net.minecraftforge.common.ForgeDirection;
-import net.minecraftforge.fluids.Fluid;
-import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.fluids.FluidTankInfo;
-import net.minecraftforge.fluids.IFluidHandler;
+import net.minecraft.server.management.PlayerInstance;
+import net.minecraft.world.WorldServer;
public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFluidHandler, IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder,
- IDropControlInventory, IPipeRenderState, ISyncedTile, ISolidSideTile {
+ IDropControlInventory, IPipeRenderState, ISyncedTile, ISolidSideTile, IGuiReturnHandler {
private class CoreState implements IClientState {
@@ -78,6 +82,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
public boolean[] pipeConnectionsBuffer = new boolean[6];
public SafeTimeTracker networkSyncTracker = new SafeTimeTracker();
public Pipe pipe;
+ private boolean sendClientUpdate = false;
private boolean blockNeighborChange = false;
private boolean refreshRenderState = false;
private boolean pipeBound = false;
@@ -116,7 +121,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
if (pipe != null)
pipe.readFromNBT(nbt);
else {
- BuildCraftCore.bcLog.log(Level.WARNING, "Pipe failed to load from NBT at {0},{1},{2}", new Object[]{xCoord, yCoord, zCoord});
+ BCLog.logger.log(Level.WARNING, "Pipe failed to load from NBT at {0},{1},{2}", new Object[]{xCoord, yCoord, zCoord});
deletePipe = true;
}
@@ -140,6 +145,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
@Override
public void validate() {
super.validate();
+ initialized = false;
tileBuffer = null;
bindPipe();
if (pipe != null)
@@ -183,6 +189,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
PowerReceiver provider = getPowerReceiver(null);
if (provider != null)
provider.update();
+
+ if (sendClientUpdate) {
+ sendClientUpdate = false;
+ if (worldObj instanceof WorldServer) {
+ WorldServer world = (WorldServer) worldObj;
+ PlayerInstance playerInstance = world.getPlayerManager().getOrCreateChunkWatcher(xCoord >> 4, zCoord >> 4, false);
+ if (playerInstance != null) {
+ playerInstance.sendToAllPlayersWatchingChunk(getDescriptionPacket());
+ }
+ }
+ }
}
// PRECONDITION: worldObj must not be null
@@ -241,8 +258,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
}
if (renderState.isDirty()) {
- markBlockForUpdate();
renderState.clean();
+ sendUpdateToClient();
}
}
@@ -251,7 +268,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
this.blockType = getBlockType();
if (pipe == null) {
- BuildCraftCore.bcLog.log(Level.WARNING, "Pipe failed to initialize at {0},{1},{2}, deleting", new Object[]{xCoord, yCoord, zCoord});
+ BCLog.logger.log(Level.WARNING, "Pipe failed to initialize at {0},{1},{2}, deleting", new Object[]{xCoord, yCoord, zCoord});
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
return;
}
@@ -360,6 +377,10 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
return packet.getPacket();
}
+ public void sendUpdateToClient() {
+ sendClientUpdate = true;
+ }
+
@Override
public LinkedList getTriggers() {
LinkedList result = new LinkedList();
@@ -425,11 +446,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
if (!BlockGenericPipe.isValid(pipe))
return false;
- if (with instanceof IPipeConnection) {
- IPipeConnection.ConnectOverride override = ((IPipeConnection) with).overridePipeConnection(pipe.transport.getPipeType(), side.getOpposite());
- if (override != IPipeConnection.ConnectOverride.DEFAULT)
- return override == IPipeConnection.ConnectOverride.CONNECT ? true : false;
- }
+ if (!(pipe instanceof IPipeConnectionForced) || !((IPipeConnectionForced) pipe).ignoreConnectionOverrides(side))
+ if (with instanceof IPipeConnection) {
+ IPipeConnection.ConnectOverride override = ((IPipeConnection) with).overridePipeConnection(pipe.transport.getPipeType(), side.getOpposite());
+ if (override != IPipeConnection.ConnectOverride.DEFAULT)
+ return override == IPipeConnection.ConnectOverride.CONNECT ? true : false;
+ }
if (with instanceof TileGenericPipe) {
if (((TileGenericPipe) with).hasPlug(side.getOpposite()))
@@ -549,6 +571,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
}
public boolean hasFacade(ForgeDirection direction) {
+ if (direction == null || direction == ForgeDirection.UNKNOWN)
+ return false;
if (this.worldObj.isRemote)
return renderState.facadeMatrix.getFacadeBlockId(direction) != 0;
return (this.facadeBlocks[direction.ordinal()] != 0);
@@ -558,16 +582,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
InvUtils.dropItems(worldObj, ItemFacade.getStack(this.facadeBlocks[direction.ordinal()], this.facadeMeta[direction.ordinal()]), this.xCoord, this.yCoord, this.zCoord);
}
- public void dropFacade(ForgeDirection direction) {
- if (this.worldObj.isRemote)
- return;
+ public boolean dropFacade(ForgeDirection direction) {
if (!hasFacade(direction))
- return;
- dropFacadeItem(direction);
- this.facadeBlocks[direction.ordinal()] = 0;
- this.facadeMeta[direction.ordinal()] = 0;
- worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId());
- scheduleRenderUpdate();
+ return false;
+ if (!worldObj.isRemote) {
+ dropFacadeItem(direction);
+ this.facadeBlocks[direction.ordinal()] = 0;
+ this.facadeMeta[direction.ordinal()] = 0;
+ worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId());
+ scheduleRenderUpdate();
+ }
+ return true;
}
/**
@@ -614,9 +639,16 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
pipe.gate = new GateVanilla(pipe);
pipe.gate.kind = GateKind.values()[coreState.gateKind];
}
+ worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
break;
+ case 1: {
+ if (renderState.needsRenderUpdate()) {
+ worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
+ renderState.clean();
+ }
+ break;
+ }
}
- worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
@Override
@@ -649,15 +681,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
return plugs[side.ordinal()];
}
- public void removeAndDropPlug(ForgeDirection side) {
+ public boolean removeAndDropPlug(ForgeDirection side) {
if (!hasPlug(side))
- return;
-
- plugs[side.ordinal()] = false;
- InvUtils.dropItems(worldObj, new ItemStack(BuildCraftTransport.plugItem), this.xCoord, this.yCoord, this.zCoord);
- worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId());
- scheduleNeighborChange(); //To force recalculation of connections
- scheduleRenderUpdate();
+ return false;
+ if (!worldObj.isRemote) {
+ plugs[side.ordinal()] = false;
+ InvUtils.dropItems(worldObj, new ItemStack(BuildCraftTransport.plugItem), this.xCoord, this.yCoord, this.zCoord);
+ worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId());
+ scheduleNeighborChange(); //To force recalculation of connections
+ scheduleRenderUpdate();
+ }
+ return true;
}
public boolean addPlug(ForgeDirection forgeDirection) {
@@ -687,7 +721,15 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this;
}
- public void markBlockForUpdate() {
- worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
+ @Override
+ public void writeGuiData(DataOutputStream data) throws IOException {
+ if (BlockGenericPipe.isValid(pipe) && pipe instanceof IGuiReturnHandler)
+ ((IGuiReturnHandler) pipe).writeGuiData(data);
+ }
+
+ @Override
+ public void readGuiData(DataInputStream data, EntityPlayer sender) throws IOException {
+ if (BlockGenericPipe.isValid(pipe) && pipe instanceof IGuiReturnHandler)
+ ((IGuiReturnHandler) pipe).readGuiData(data, sender);
}
}
diff --git a/common/buildcraft/transport/TransportConstants.java b/common/buildcraft/transport/TransportConstants.java
new file mode 100644
index 00000000..e76ef048
--- /dev/null
+++ b/common/buildcraft/transport/TransportConstants.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.transport;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public class TransportConstants {
+
+ public static final float FACADE_THICKNESS = 2F / 16F;
+ public static final float PIPE_NORMAL_SPEED = 0.01F;
+}
diff --git a/common/buildcraft/transport/TransportProxyClient.java b/common/buildcraft/transport/TransportProxyClient.java
index 7c3ea24b..b654f44d 100644
--- a/common/buildcraft/transport/TransportProxyClient.java
+++ b/common/buildcraft/transport/TransportProxyClient.java
@@ -3,23 +3,23 @@ package buildcraft.transport;
import buildcraft.BuildCraftTransport;
import buildcraft.transport.render.FacadeItemRenderer;
import buildcraft.transport.render.PipeItemRenderer;
-import buildcraft.transport.render.PipeWorldRenderer;
+import buildcraft.transport.render.PipeRendererWorld;
import buildcraft.transport.render.PlugItemRenderer;
-import buildcraft.transport.render.RenderPipe;
+import buildcraft.transport.render.PipeRendererTESR;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraftforge.client.MinecraftForgeClient;
public class TransportProxyClient extends TransportProxy {
public final static PipeItemRenderer pipeItemRenderer = new PipeItemRenderer();
- public final static PipeWorldRenderer pipeWorldRenderer = new PipeWorldRenderer();
+ public final static PipeRendererWorld pipeWorldRenderer = new PipeRendererWorld();
public final static FacadeItemRenderer facadeItemRenderer = new FacadeItemRenderer();
public final static PlugItemRenderer plugItemRenderer = new PlugItemRenderer();
@Override
public void registerTileEntities() {
super.registerTileEntities();
- RenderPipe rp = new RenderPipe();
+ PipeRendererTESR rp = new PipeRendererTESR();
ClientRegistry.bindTileEntitySpecialRenderer(TileDummyGenericPipe.class, rp);
ClientRegistry.bindTileEntitySpecialRenderer(TileDummyGenericPipe2.class, rp);
ClientRegistry.bindTileEntitySpecialRenderer(TileGenericPipe.class, rp);
@@ -51,6 +51,7 @@ public class TransportProxyClient extends TransportProxy {
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerCobblestone.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerStone.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerQuartz.itemID, pipeItemRenderer);
+ MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerIron.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerGold.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerDiamond.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeStructureCobblestone.itemID, pipeItemRenderer);
diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java
index e728e2e8..f163e5c2 100644
--- a/common/buildcraft/transport/gui/ContainerGateInterface.java
+++ b/common/buildcraft/transport/gui/ContainerGateInterface.java
@@ -7,7 +7,6 @@
*/
package buildcraft.transport.gui;
-import buildcraft.api.core.Position;
import buildcraft.api.gates.ActionManager;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IOverrideDefaultTriggers;
@@ -21,9 +20,13 @@ import buildcraft.core.network.PacketPayload;
import buildcraft.core.network.PacketPayloadArrays;
import buildcraft.core.network.PacketUpdate;
import buildcraft.core.proxy.CoreProxy;
+import buildcraft.core.utils.BCLog;
+import buildcraft.transport.Gate;
import buildcraft.transport.Pipe;
+import java.util.Comparator;
import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.NavigableSet;
+import java.util.TreeSet;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
@@ -38,8 +41,18 @@ public class ContainerGateInterface extends BuildCraftContainer {
IInventory playerIInventory;
Pipe pipe;
- private final LinkedList _potentialTriggers = new LinkedList();
- private final LinkedList _potentialActions = new LinkedList();
+ private final NavigableSet _potentialTriggers = new TreeSet(new Comparator() {
+ @Override
+ public int compare(ITrigger o1, ITrigger o2) {
+ return o1.getUniqueTag().compareTo(o2.getUniqueTag());
+ }
+ });
+ private final NavigableSet _potentialActions = new TreeSet(new Comparator() {
+ @Override
+ public int compare(IAction o1, IAction o2) {
+ return o1.getUniqueTag().compareTo(o2.getUniqueTag());
+ }
+ });
private boolean isSynchronized = false;
private boolean isNetInitialized = false;
public boolean[] triggerState = new boolean[8];
@@ -49,14 +62,14 @@ public class ContainerGateInterface extends BuildCraftContainer {
super(0);
this.playerIInventory = playerInventory;
- for (int l = 0; l < 3; l++) {
- for (int k1 = 0; k1 < 9; k1++) {
- addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 123 + l * 18));
+ for (int y = 0; y < 3; y++) {
+ for (int x = 0; x < 9; x++) {
+ addSlotToContainer(new Slot(playerInventory, x + y * 9 + 9, 8 + x * 18, pipe.gate.getGuiHeight() - 84 + y * 18));
}
}
- for (int i1 = 0; i1 < 9; i1++) {
- addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 181));
+ for (int x = 0; x < 9; x++) {
+ addSlotToContainer(new Slot(playerInventory, x, 8 + x * 18, pipe.gate.getGuiHeight() - 26));
}
this.pipe = pipe;
@@ -75,20 +88,19 @@ public class ContainerGateInterface extends BuildCraftContainer {
TileEntity tile = pipe.container.getTile(o);
int blockID = pipe.container.getBlockId(o);
Block block = Block.blocksList[blockID];
+ _potentialTriggers.addAll(ActionManager.getNeighborTriggers(block, tile));
+ _potentialActions.addAll(ActionManager.getNeighborActions(block, tile));
+ }
- LinkedList nearbyTriggers = ActionManager.getNeighborTriggers(block, tile);
-
- for (ITrigger t : nearbyTriggers) {
- if (!_potentialTriggers.contains(t)) {
- _potentialTriggers.add(t);
- }
- }
-
- LinkedList nearbyActions = ActionManager.getNeighborActions(block, tile);
-
- for (IAction a : nearbyActions) {
- if (!_potentialActions.contains(a)) {
- _potentialActions.add(a);
+ if (getGateOrdinal() < Gate.GateKind.AND_3.ordinal()) {
+ Iterator it = _potentialTriggers.iterator();
+ while (it.hasNext()) {
+ ITrigger trigger = it.next();
+ try {
+ if (trigger.requiresParameter())
+ it.remove();
+ } catch (Throwable error) {
+ BCLog.logErrorAPI("Buildcraft", error, trigger.getClass());
}
}
}
@@ -269,8 +281,9 @@ public class ContainerGateInterface extends BuildCraftContainer {
PacketPayloadArrays payload = new PacketPayloadArrays(1, 0, length);
payload.intPayload[0] = length;
- for (int i = 0; i < length; i++) {
- payload.stringPayload[i] = _potentialActions.get(i).getUniqueTag();
+ int i = 0;
+ for (IAction action : _potentialActions) {
+ payload.stringPayload[i++] = action.getUniqueTag();
}
PacketUpdate packet = new PacketUpdate(PacketIds.GATE_ACTIONS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload);
@@ -291,8 +304,9 @@ public class ContainerGateInterface extends BuildCraftContainer {
PacketPayloadArrays payload = new PacketPayloadArrays(1, 0, length);
payload.intPayload[0] = length;
- for (int i = 0; i < length; i++) {
- payload.stringPayload[i] = _potentialTriggers.get(i).getUniqueTag();
+ int i = 0;
+ for (ITrigger trigger : _potentialTriggers) {
+ payload.stringPayload[i++] = trigger.getUniqueTag();
}
PacketUpdate packet = new PacketUpdate(PacketIds.GATE_TRIGGERS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload);
@@ -344,11 +358,15 @@ public class ContainerGateInterface extends BuildCraftContainer {
}
public ITrigger getFirstTrigger() {
- return _potentialTriggers.size() > 0 ? _potentialTriggers.getFirst() : null;
+ if (_potentialTriggers.isEmpty())
+ return null;
+ return _potentialTriggers.first();
}
public ITrigger getLastTrigger() {
- return _potentialTriggers.size() > 0 ? _potentialTriggers.getLast() : null;
+ if (_potentialTriggers.isEmpty())
+ return null;
+ return _potentialTriggers.last();
}
public Iterator getTriggerIterator(boolean descending) {
@@ -381,11 +399,15 @@ public class ContainerGateInterface extends BuildCraftContainer {
}
public IAction getFirstAction() {
- return _potentialActions.peekFirst();
+ if (_potentialActions.isEmpty())
+ return null;
+ return _potentialActions.first();
}
public IAction getLastAction() {
- return _potentialActions.peekLast();
+ if (_potentialActions.isEmpty())
+ return null;
+ return _potentialActions.last();
}
public Iterator getActionIterator(boolean descending) {
@@ -406,7 +428,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
return pipe.gate.getGuiFile();
}
- public int getGateOrdinal() {
+ public final int getGateOrdinal() {
return pipe.gate.kind.ordinal();
}
diff --git a/common/buildcraft/transport/gui/GuiDiamondPipe.java b/common/buildcraft/transport/gui/GuiDiamondPipe.java
index c402b509..91b97ec4 100644
--- a/common/buildcraft/transport/gui/GuiDiamondPipe.java
+++ b/common/buildcraft/transport/gui/GuiDiamondPipe.java
@@ -7,20 +7,31 @@
*/
package buildcraft.transport.gui;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.util.ResourceLocation;
+
+import org.lwjgl.opengl.GL11;
+
+import buildcraft.BuildCraftCore;
import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.utils.StringUtils;
import buildcraft.transport.pipes.PipeItemsDiamond;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.util.ResourceLocation;
-import org.lwjgl.opengl.GL11;
public class GuiDiamondPipe extends GuiBuildCraft {
- private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter.png");
+ private static final ResourceLocation TEXTURE;
IInventory playerInventory;
IInventory filterInventory;
+ static {
+ if (!BuildCraftCore.colorBlindMode){
+ TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter.png");
+ } else {
+ TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter_cb.png");
+ }
+ }
+
public GuiDiamondPipe(IInventory playerInventory, PipeItemsDiamond pipe) {
super(new ContainerDiamondPipe(playerInventory, pipe), pipe.getFilters());
this.playerInventory = playerInventory;
@@ -38,7 +49,7 @@ public class GuiDiamondPipe extends GuiBuildCraft {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
diff --git a/common/buildcraft/transport/gui/GuiEmeraldPipe.java b/common/buildcraft/transport/gui/GuiEmeraldPipe.java
index b70a423f..c3e69d0f 100644
--- a/common/buildcraft/transport/gui/GuiEmeraldPipe.java
+++ b/common/buildcraft/transport/gui/GuiEmeraldPipe.java
@@ -7,28 +7,59 @@
*/
package buildcraft.transport.gui;
-import buildcraft.core.DefaultProps;
-import buildcraft.core.gui.GuiBuildCraft;
-import buildcraft.core.utils.StringUtils;
-import buildcraft.transport.pipes.PipeItemsEmerald;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
+
import org.lwjgl.opengl.GL11;
+import buildcraft.core.DefaultProps;
+import buildcraft.core.gui.GuiBuildCraft;
+import buildcraft.core.gui.buttons.GuiMultiButton;
+import buildcraft.core.network.PacketGuiReturn;
+import buildcraft.core.proxy.CoreProxy;
+import buildcraft.core.utils.StringUtils;
+import buildcraft.transport.pipes.PipeItemsEmerald;
+
public class GuiEmeraldPipe extends GuiBuildCraft {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter_2.png");
+ private GuiMultiButton button;
+
IInventory playerInventory;
IInventory filterInventory;
+ PipeItemsEmerald pipe;
public GuiEmeraldPipe(IInventory playerInventory, PipeItemsEmerald pipe) {
super(new ContainerEmeraldPipe(playerInventory, pipe), pipe.getFilters());
+
+ this.pipe = pipe;
this.playerInventory = playerInventory;
this.filterInventory = pipe.getFilters();
+
xSize = 175;
ySize = 132;
}
+ @Override
+ public void initGui() {
+ super.initGui();
+
+ this.buttonList.clear();
+ this.button = new GuiMultiButton(0, this.guiLeft + this.xSize - (80 + 6), this.guiTop + 34, 80, this.pipe.getStateController().copy());
+ this.buttonList.add(this.button);
+ }
+
+ @Override
+ public void onGuiClosed() {
+ if (CoreProxy.proxy.isRenderWorld(pipe.getWorld())) {
+ pipe.getStateController().setCurrentState(button.getController().getCurrentState());
+ PacketGuiReturn pkt = new PacketGuiReturn(pipe.getContainer());
+ pkt.sendPacket();
+ }
+
+ super.onGuiClosed();
+ }
+
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRenderer.drawString(filterInventory.getInvName(), getCenteredOffset(filterInventory.getInvName()), 6, 0x404040);
@@ -38,7 +69,7 @@ public class GuiEmeraldPipe extends GuiBuildCraft {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
diff --git a/common/buildcraft/transport/gui/GuiFilteredBuffer.java b/common/buildcraft/transport/gui/GuiFilteredBuffer.java
index 617dce39..ec2356f4 100644
--- a/common/buildcraft/transport/gui/GuiFilteredBuffer.java
+++ b/common/buildcraft/transport/gui/GuiFilteredBuffer.java
@@ -39,7 +39,7 @@ public class GuiFilteredBuffer extends GuiContainer {
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(TEXTURE);
+ mc.renderEngine.bindTexture(TEXTURE);
int cornerX = (width - xSize) / 2;
int cornerY = (height - ySize) / 2;
diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java
index a24883f6..df41d431 100644
--- a/common/buildcraft/transport/gui/GuiGateInterface.java
+++ b/common/buildcraft/transport/gui/GuiGateInterface.java
@@ -1,12 +1,10 @@
/**
- * Copyright (c) SpaceToad, 2011
- * http://www.mod-buildcraft.com
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
- * BuildCraft is distributed under the terms of the Minecraft Mod Public
- * License 1.0, or MMPL. Please check the contents of the license located in
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
-
package buildcraft.transport.gui;
import buildcraft.api.gates.IAction;
@@ -28,9 +26,7 @@ import org.lwjgl.opengl.GL11;
public class GuiGateInterface extends GuiAdvancedInterface {
IInventory playerInventory;
-
private final ContainerGateInterface _container;
-
private int nbEntries;
class TriggerSlot extends AdvancedSlot {
@@ -54,15 +50,15 @@ public class GuiGateInterface extends GuiAdvancedInterface {
return "";
}
- @SideOnly(Side.CLIENT)
- @Override
- public Icon getIcon() {
- ITrigger trigger = pipe.gate.getTrigger(slot);
- if (trigger != null)
- return trigger.getIcon();
- else
- return null;
- }
+ @SideOnly(Side.CLIENT)
+ @Override
+ public Icon getIcon() {
+ ITrigger trigger = pipe.gate.getTrigger(slot);
+ if (trigger != null)
+ return trigger.getIcon();
+ else
+ return null;
+ }
@Override
public boolean isDefined() {
@@ -136,7 +132,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
public ItemStack getItemStack() {
ITriggerParameter parameter = pipe.gate.getTriggerParameter(slot);
if (parameter != null)
- return parameter.getItem();
+ return parameter.getItemStack();
else
return null;
}
@@ -152,8 +148,8 @@ public class GuiGateInterface extends GuiAdvancedInterface {
_container = (ContainerGateInterface) this.inventorySlots;
this.playerInventory = playerInventory;
- xSize = 175;
- ySize = 207;
+ xSize = 176;
+ ySize = pipe.gate.getGuiHeight();
int position = 0;
@@ -161,34 +157,34 @@ public class GuiGateInterface extends GuiAdvancedInterface {
nbEntries = 1;
slots = new AdvancedSlot[2];
- slots[0] = new TriggerSlot(65, 54, pipe, 0);
- slots[1] = new ActionSlot(99, 54, pipe, 0);
+ slots[0] = new TriggerSlot(62, 26, pipe, 0);
+ slots[1] = new ActionSlot(98, 26, pipe, 0);
} else if (pipe.gate.kind == GateKind.AND_2 || pipe.gate.kind == GateKind.OR_2) {
nbEntries = 2;
slots = new AdvancedSlot[4];
- slots[0] = new TriggerSlot(65, 46, pipe, 0);
- slots[1] = new TriggerSlot(65, 64, pipe, 1);
- slots[2] = new ActionSlot(99, 46, pipe, 0);
- slots[3] = new ActionSlot(99, 64, pipe, 1);
+ slots[0] = new TriggerSlot(62, 26, pipe, 0);
+ slots[1] = new TriggerSlot(62, 44, pipe, 1);
+ slots[2] = new ActionSlot(98, 26, pipe, 0);
+ slots[3] = new ActionSlot(98, 44, pipe, 1);
} else if (pipe.gate.kind == GateKind.AND_3 || pipe.gate.kind == GateKind.OR_3) {
nbEntries = 4;
slots = new AdvancedSlot[12];
for (int k = 0; k < 4; ++k) {
- slots[position] = new TriggerSlot(60, 36 + 18 * k, pipe, position);
+ slots[position] = new TriggerSlot(53, 26 + 18 * k, pipe, position);
position++;
}
for (int k = 0; k < 4; ++k) {
- slots[position] = new ActionSlot(112, 36 + 18 * k, pipe, position - 4);
+ slots[position] = new ActionSlot(107, 26 + 18 * k, pipe, position - 4);
position++;
}
for (int k = 0; k < 4; ++k) {
- slots[position] = new TriggerParameterSlot(78, 36 + 18 * k, pipe, position - 8);
+ slots[position] = new TriggerParameterSlot(71, 26 + 18 * k, pipe, position - 8);
position++;
}
@@ -198,23 +194,23 @@ public class GuiGateInterface extends GuiAdvancedInterface {
slots = new AdvancedSlot[24];
for (int k = 0; k < 4; ++k) {
- slots[position] = new TriggerSlot(8, 36 + 18 * k, pipe, position);
+ slots[position] = new TriggerSlot(8, 26 + 18 * k, pipe, position);
position++;
- slots[position] = new TriggerSlot(100, 36 + 18 * k, pipe, position);
+ slots[position] = new TriggerSlot(98, 26 + 18 * k, pipe, position);
position++;
}
for (int k = 0; k < 4; ++k) {
- slots[position] = new ActionSlot(60, 36 + 18 * k, pipe, position - 8);
+ slots[position] = new ActionSlot(62, 26 + 18 * k, pipe, position - 8);
position++;
- slots[position] = new ActionSlot(152, 36 + 18 * k, pipe, position - 8);
+ slots[position] = new ActionSlot(152, 26 + 18 * k, pipe, position - 8);
position++;
}
for (int k = 0; k < 4; ++k) {
- slots[position] = new TriggerParameterSlot(26, 36 + 18 * k, pipe, position - 16);
+ slots[position] = new TriggerParameterSlot(26, 26 + 18 * k, pipe, position - 16);
position++;
- slots[position] = new TriggerParameterSlot(118, 36 + 18 * k, pipe, position - 16);
+ slots[position] = new TriggerParameterSlot(116, 26 + 18 * k, pipe, position - 16);
position++;
}
}
@@ -225,7 +221,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String name = _container.getGateName();
- fontRenderer.drawString(name, getCenteredOffset(name), 15, 0x404040);
+ fontRenderer.drawString(name, getCenteredOffset(name), 10, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
drawForegroundSelection(par1, par2);
@@ -235,11 +231,11 @@ public class GuiGateInterface extends GuiAdvancedInterface {
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
_container.synchronize();
-
+
ResourceLocation texture = _container.getGateGuiFile();
-
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.func_110577_a(texture);
+
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ mc.renderEngine.bindTexture(texture);
int cornerX = (width - xSize) / 2;
int cornerY = (height - ySize) / 2;
@@ -255,18 +251,18 @@ public class GuiGateInterface extends GuiAdvancedInterface {
if (_container.getGateOrdinal() >= GateKind.AND_3.ordinal()) {
if (_container.triggerState[triggerTracker++]) {
- mc.renderEngine.func_110577_a(texture);
+ mc.renderEngine.bindTexture(texture);
drawTexturedModalRect(cornerX + slot.x + 35, cornerY + slot.y + 6, 176, 18, 18, 4);
}
if (trigger == null || !trigger.hasParameter()) {
- mc.renderEngine.func_110577_a(texture);
+ mc.renderEngine.bindTexture(texture);
drawTexturedModalRect(cornerX + slot.x + 17, cornerY + slot.y - 1, 176, 0, 18, 18);
}
} else if (_container.triggerState[triggerTracker++]) {
- mc.renderEngine.func_110577_a(texture);
+ mc.renderEngine.bindTexture(texture);
drawTexturedModalRect(cornerX + slot.x + 17, cornerY + slot.y + 6, 176, 18, 18, 4);
}
diff --git a/common/buildcraft/transport/pipes/PipeFluidsIron.java b/common/buildcraft/transport/pipes/PipeFluidsIron.java
index 3698a398..dafe22b5 100644
--- a/common/buildcraft/transport/pipes/PipeFluidsIron.java
+++ b/common/buildcraft/transport/pipes/PipeFluidsIron.java
@@ -83,14 +83,10 @@ public class PipeFluidsIron extends Pipe {
public int getIconIndex(ForgeDirection direction) {
if (direction == ForgeDirection.UNKNOWN)
return standardIconIndex;
- else {
- int metadata = container.getBlockMetadata();
+ if (container != null && container.getBlockMetadata() == direction.ordinal())
+ return standardIconIndex;
+ return solidIconIndex;
- if (metadata == direction.ordinal())
- return solidIconIndex;
- else
- return standardIconIndex;
- }
}
@Override
diff --git a/common/buildcraft/transport/pipes/PipeFluidsSandstone.java b/common/buildcraft/transport/pipes/PipeFluidsSandstone.java
index 70b9c63b..1483426c 100644
--- a/common/buildcraft/transport/pipes/PipeFluidsSandstone.java
+++ b/common/buildcraft/transport/pipes/PipeFluidsSandstone.java
@@ -7,8 +7,12 @@
*/
package buildcraft.transport.pipes;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.ForgeDirection;
+import net.minecraftforge.fluids.FluidStack;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
+import buildcraft.transport.IPipeConnectionForced;
import buildcraft.transport.IPipeTransportFluidsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
@@ -16,11 +20,8 @@ import buildcraft.transport.PipeTransportFluids;
import buildcraft.transport.TileGenericPipe;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraftforge.common.ForgeDirection;
-import net.minecraftforge.fluids.FluidStack;
-public class PipeFluidsSandstone extends Pipe implements IPipeTransportFluidsHook {
+public class PipeFluidsSandstone extends Pipe implements IPipeTransportFluidsHook, IPipeConnectionForced {
public PipeFluidsSandstone(int itemID) {
super(new PipeTransportFluids(), itemID);
@@ -49,4 +50,9 @@ public class PipeFluidsSandstone extends Pipe implements IP
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
return (tile instanceof TileGenericPipe) && super.canPipeConnect(tile, side);
}
+
+ @Override
+ public boolean ignoreConnectionOverrides(ForgeDirection with) {
+ return true;
+ }
}
diff --git a/common/buildcraft/transport/pipes/PipeFluidsWood.java b/common/buildcraft/transport/pipes/PipeFluidsWood.java
index 7896d110..22792a15 100644
--- a/common/buildcraft/transport/pipes/PipeFluidsWood.java
+++ b/common/buildcraft/transport/pipes/PipeFluidsWood.java
@@ -13,8 +13,8 @@ import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
+import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.PipeManager;
-import buildcraft.core.TileBuffer;
import buildcraft.core.network.TileNetworkData;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
@@ -41,6 +41,8 @@ public class PipeFluidsWood extends Pipe implements IPowerR
private PipeLogicWood logic = new PipeLogicWood(this) {
@Override
protected boolean isValidConnectingTile(TileEntity tile) {
+ if(tile instanceof IPipeTile)
+ return false;
if (!(tile instanceof IFluidHandler))
return false;
if (!PipeManager.canExtractFluids(pipe, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord))
diff --git a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java
index 6cad55c5..cad1b80e 100644
--- a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java
+++ b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java
@@ -14,12 +14,12 @@ import buildcraft.api.gates.IAction;
import buildcraft.api.tools.IToolWrench;
import buildcraft.core.network.TileNetworkData;
import buildcraft.core.utils.EnumColor;
-import buildcraft.core.utils.Utils;
import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TileGenericPipe;
+import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem;
import buildcraft.transport.triggers.ActionPipeColor;
import buildcraft.transport.triggers.ActionPipeDirection;
@@ -72,7 +72,6 @@ public class PipeItemsDaizuli extends Pipe implements IPipeT
if (color != c.ordinal()) {
this.color = c.ordinal();
container.scheduleRenderUpdate();
- container.markBlockForUpdate();
}
}
@@ -102,9 +101,11 @@ public class PipeItemsDaizuli extends Pipe implements IPipeT
@Override
public int getIconIndex(ForgeDirection direction) {
+ if (direction == ForgeDirection.UNKNOWN)
+ return standardIconIndex + color;
if (container != null && container.getBlockMetadata() == direction.ordinal())
- return solidIconIndex;
- return standardIconIndex + color;
+ return standardIconIndex + color;
+ return solidIconIndex;
}
@Override
@@ -139,12 +140,12 @@ public class PipeItemsDaizuli extends Pipe implements IPipeT
@Override
public void readjustSpeed(TravelingItem item) {
- if (item.getSpeed() > Utils.pipeNormalSpeed)
- item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F);
+ if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED)
+ item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F);
- if (item.getSpeed() < Utils.pipeNormalSpeed)
- item.setSpeed(Utils.pipeNormalSpeed);
+ if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED)
+ item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED);
}
@Override
diff --git a/common/buildcraft/transport/pipes/PipeItemsDiamond.java b/common/buildcraft/transport/pipes/PipeItemsDiamond.java
index c8c831ba..0ea40d90 100644
--- a/common/buildcraft/transport/pipes/PipeItemsDiamond.java
+++ b/common/buildcraft/transport/pipes/PipeItemsDiamond.java
@@ -7,6 +7,18 @@
*/
package buildcraft.transport.pipes;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.LinkedList;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.Position;
@@ -23,17 +35,6 @@ import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TravelingItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.LinkedList;
-import net.minecraft.block.Block;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTBase;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraftforge.common.ForgeDirection;
public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook, IClientState {
diff --git a/common/buildcraft/transport/pipes/PipeItemsEmerald.java b/common/buildcraft/transport/pipes/PipeItemsEmerald.java
index 475aaf5a..dcc7fb20 100644
--- a/common/buildcraft/transport/pipes/PipeItemsEmerald.java
+++ b/common/buildcraft/transport/pipes/PipeItemsEmerald.java
@@ -7,19 +7,10 @@
*/
package buildcraft.transport.pipes;
-import buildcraft.BuildCraftTransport;
-import buildcraft.api.inventory.ISelectiveInventory;
-import buildcraft.api.inventory.ISpecialInventory;
-import buildcraft.core.GuiIds;
-import buildcraft.core.inventory.SimpleInventory;
-import buildcraft.core.network.IClientState;
-import buildcraft.core.proxy.CoreProxy;
-import buildcraft.core.utils.Utils;
-import buildcraft.transport.BlockGenericPipe;
-import buildcraft.transport.PipeIconProvider;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
@@ -27,10 +18,57 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
+import buildcraft.BuildCraftTransport;
+import buildcraft.api.inventory.ISelectiveInventory;
+import buildcraft.api.inventory.ISpecialInventory;
+import buildcraft.core.GuiIds;
+import buildcraft.core.gui.buttons.IButtonTextureSet;
+import buildcraft.core.gui.buttons.IMultiButtonState;
+import buildcraft.core.gui.buttons.MultiButtonController;
+import buildcraft.core.gui.buttons.StandardButtonTextureSets;
+import buildcraft.core.gui.tooltips.ToolTip;
+import buildcraft.core.gui.tooltips.ToolTipLine;
+import buildcraft.core.inventory.SimpleInventory;
+import buildcraft.core.network.IClientState;
+import buildcraft.core.network.IGuiReturnHandler;
+import buildcraft.core.proxy.CoreProxy;
+import buildcraft.core.utils.StringUtils;
+import buildcraft.core.utils.Utils;
+import buildcraft.transport.BlockGenericPipe;
+import buildcraft.transport.PipeIconProvider;
-public class PipeItemsEmerald extends PipeItemsWood implements IClientState {
+public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGuiReturnHandler {
- private SimpleInventory filters = new SimpleInventory(9, "Filters", 1);
+ public static enum ButtonState implements IMultiButtonState {
+ BLOCKING("gui.pipes.emerald.blocking"), NONBLOCKING("gui.pipes.emerald.nonblocking");
+
+ private final String label;
+ private final ToolTip tip;
+
+ private ButtonState(String label) {
+ this.label = label;
+ tip = new ToolTip();
+ tip.add(new ToolTipLine(label + ".tip"));
+ }
+
+ @Override
+ public String getLabel() {
+ return StringUtils.localize(this.label);
+ }
+
+ @Override
+ public IButtonTextureSet getTextureSet() {
+ return StandardButtonTextureSets.SMALL_BUTTON;
+ }
+
+ @Override
+ public ToolTip getToolTip() {
+ return this.tip;
+ }
+ }
+
+ private final MultiButtonController stateController = MultiButtonController.getController(ButtonState.BLOCKING.ordinal(), ButtonState.values());
+ private final SimpleInventory filters = new SimpleInventory(9, "Filters", 1);
private int currentFilter = 0;
public PipeItemsEmerald(int itemID) {
@@ -68,8 +106,9 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState {
public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) {
/* ISELECTIVEINVENTORY */
+ // non blocking mode is not implemented for ISelectiveInventory yet
if (inventory instanceof ISelectiveInventory) {
- ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[]{getCurrentFilter()}, false, doRemove, from, (int) powerHandler.getEnergyStored());
+ ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[] { getCurrentFilter() }, false, doRemove, from, (int) powerHandler.getEnergyStored());
if (doRemove) {
for (ItemStack stack : stacks) {
if (stack != null) {
@@ -81,6 +120,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState {
return stacks;
/* ISPECIALINVENTORY */
+ // non blocking mode is not needed for ISpecialInventory since its not round robin anyway
} else if (inventory instanceof ISpecialInventory) {
ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(false, from, (int) powerHandler.getEnergyStored());
if (stacks != null) {
@@ -117,8 +157,18 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState {
IInventory inv = Utils.getInventory(inventory);
ItemStack result = checkExtractGeneric(inv, doRemove, from);
+ // check through every filter once if non-blocking
+ if (doRemove && stateController.getButtonState() == ButtonState.NONBLOCKING && result == null) {
+ int count = 1;
+ while (result == null && count < filters.getSizeInventory()) {
+ incrementFilter();
+ result = checkExtractGeneric(inv, doRemove, from);
+ count++;
+ }
+ }
+
if (result != null) {
- return new ItemStack[]{result};
+ return new ItemStack[] { result };
}
}
@@ -176,6 +226,8 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState {
super.readFromNBT(nbt);
filters.readFromNBT(nbt);
currentFilter = nbt.getInteger("currentFilter");
+
+ stateController.readFromNBT(nbt, "state");
}
@Override
@@ -183,6 +235,8 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState {
super.writeToNBT(nbt);
filters.writeToNBT(nbt);
nbt.setInteger("currentFilter", currentFilter);
+
+ stateController.writeToNBT(nbt, "state");
}
// ICLIENTSTATE
@@ -204,4 +258,18 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState {
public IInventory getFilters() {
return filters;
}
+
+ public MultiButtonController getStateController() {
+ return stateController;
+ }
+
+ @Override
+ public void writeGuiData(DataOutputStream data) throws IOException {
+ data.writeByte(stateController.getCurrentState());
+ }
+
+ @Override
+ public void readGuiData(DataInputStream data, EntityPlayer sender) throws IOException {
+ stateController.setCurrentState(data.readByte());
+ }
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsGold.java b/common/buildcraft/transport/pipes/PipeItemsGold.java
index 13ec571b..cc35cc5c 100644
--- a/common/buildcraft/transport/pipes/PipeItemsGold.java
+++ b/common/buildcraft/transport/pipes/PipeItemsGold.java
@@ -10,11 +10,11 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.Position;
-import buildcraft.core.utils.Utils;
import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
+import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -50,6 +50,6 @@ public class PipeItemsGold extends Pipe implements IPipeTransportItemsHook {
@Override
public void readjustSpeed(TravelingItem item) {
- item.setSpeed(Math.min(Math.max(Utils.pipeNormalSpeed, item.getSpeed()) * 2f, Utils.pipeNormalSpeed * 20F));
+ item.setSpeed(Math.min(Math.max(TransportConstants.PIPE_NORMAL_SPEED, item.getSpeed()) * 2f, TransportConstants.PIPE_NORMAL_SPEED * 20F));
}
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsIron.java b/common/buildcraft/transport/pipes/PipeItemsIron.java
index 7df0178b..2b884897 100644
--- a/common/buildcraft/transport/pipes/PipeItemsIron.java
+++ b/common/buildcraft/transport/pipes/PipeItemsIron.java
@@ -14,11 +14,9 @@ import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TileGenericPipe;
-import buildcraft.transport.triggers.ActionPipeColor;
import buildcraft.transport.triggers.ActionPipeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import java.util.Arrays;
import java.util.LinkedList;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
diff --git a/common/buildcraft/transport/pipes/PipeItemsLapis.java b/common/buildcraft/transport/pipes/PipeItemsLapis.java
index 10d83ff8..4df7a8f6 100644
--- a/common/buildcraft/transport/pipes/PipeItemsLapis.java
+++ b/common/buildcraft/transport/pipes/PipeItemsLapis.java
@@ -13,12 +13,12 @@ import buildcraft.api.core.Position;
import buildcraft.api.gates.IAction;
import buildcraft.api.tools.IToolWrench;
import buildcraft.core.utils.EnumColor;
-import buildcraft.core.utils.Utils;
import buildcraft.transport.IItemTravelingHook;
import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
+import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem;
import buildcraft.transport.triggers.ActionPipeColor;
import cpw.mods.fml.relauncher.Side;
@@ -77,7 +77,6 @@ public class PipeItemsLapis extends Pipe implements IItemTra
if (color.ordinal() != container.getBlockMetadata()) {
container.worldObj.setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, color.ordinal(), 3);
container.scheduleRenderUpdate();
- container.markBlockForUpdate();
}
}
@@ -97,12 +96,12 @@ public class PipeItemsLapis extends Pipe implements IItemTra
@Override
public void readjustSpeed(TravelingItem item) {
- if (item.getSpeed() > Utils.pipeNormalSpeed) {
- item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F);
+ if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) {
+ item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F);
}
- if (item.getSpeed() < Utils.pipeNormalSpeed) {
- item.setSpeed(Utils.pipeNormalSpeed);
+ if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) {
+ item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED);
}
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsObsidian.java b/common/buildcraft/transport/pipes/PipeItemsObsidian.java
index cc88e9e5..eff8cfb3 100644
--- a/common/buildcraft/transport/pipes/PipeItemsObsidian.java
+++ b/common/buildcraft/transport/pipes/PipeItemsObsidian.java
@@ -14,20 +14,23 @@ import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
+import buildcraft.core.inventory.ITransactor;
+import buildcraft.core.inventory.Transactor;
+import buildcraft.core.inventory.filters.StackFilter;
import buildcraft.transport.TravelingItem;
import buildcraft.core.proxy.CoreProxy;
-import buildcraft.core.utils.Utils;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
+import buildcraft.transport.utils.TransportUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import java.util.Arrays;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityMinecartChest;
import net.minecraft.entity.projectile.EntityArrow;
-import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
@@ -35,6 +38,7 @@ import net.minecraftforge.common.ForgeDirection;
public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
+ private static final PowerHandler.PerditionCalculator PERDITION = new PowerHandler.PerditionCalculator(0.5F);
private PowerHandler powerHandler;
private int[] entitiesDropped;
private int entitiesDroppedIndex = 0;
@@ -43,14 +47,11 @@ public class PipeItemsObsidian extends Pipe implements IPowe
super(new PipeTransportItems(), itemID);
entitiesDropped = new int[32];
-
- for (int i = 0; i < entitiesDropped.length; ++i) {
- entitiesDropped[i] = -1;
- }
+ Arrays.fill(entitiesDropped, -1);
powerHandler = new PowerHandler(this, Type.MACHINE);
powerHandler.configure(1, 64, 1, 256);
- powerHandler.configurePowerPerdition(1, 1);
+ powerHandler.setPerdition(PERDITION);
}
@Override
@@ -138,48 +139,45 @@ public class PipeItemsObsidian extends Pipe implements IPowe
Position min = p1.min(p2);
Position max = p1.max(p2);
- return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
+ return AxisAlignedBB.getAABBPool().getAABB(min.x, min.y, min.z, max.x, max.y, max.z);
}
@Override
public void doWork(PowerHandler workProvider) {
for (int j = 1; j < 5; ++j) {
- if (trySucc(j))
+ if (suckItem(j))
return;
}
-
- powerHandler.useEnergy(1, 1, true);
}
- private boolean trySucc(int distance) {
+ private boolean suckItem(int distance) {
AxisAlignedBB box = getSuckingBox(getOpenOrientation(), distance);
if (box == null)
return false;
@SuppressWarnings("rawtypes")
- List list = container.worldObj.getEntitiesWithinAABB(Entity.class, box);
+ List discoveredEntities = (List) container.worldObj.getEntitiesWithinAABB(Entity.class, box);
- for (int g = 0; g < list.size(); g++) {
- if (list.get(g) instanceof Entity) {
- Entity entity = (Entity) list.get(g);
+ for (Entity entity : discoveredEntities) {
+ if (canSuck(entity, distance)) {
+ pullItemIntoPipe(entity, distance);
+ return true;
+ }
- if (canSuck(entity, distance)) {
- pullItemIntoPipe(entity, distance);
- return true;
- }
-
- if (distance == 1 && list.get(g) instanceof EntityMinecartChest) {
- EntityMinecartChest cart = (EntityMinecartChest) list.get(g);
- if (!cart.isDead) {
- ItemStack stack = checkExtractGeneric(cart, true, getOpenOrientation());
- if (stack != null && powerHandler.useEnergy(1, 1, true) == 1) {
- EntityItem entityitem = new EntityItem(container.worldObj, cart.posX, cart.posY + 0.3F, cart.posZ, stack);
- entityitem.delayBeforeCanPickup = 10;
- container.worldObj.spawnEntityInWorld(entityitem);
- pullItemIntoPipe(entityitem, 1);
- return true;
- }
+ if (distance == 1 && entity instanceof EntityMinecartChest) {
+ EntityMinecartChest cart = (EntityMinecartChest) entity;
+ if (!cart.isDead) {
+ ITransactor trans = Transactor.getTransactorFor(cart);
+ ForgeDirection openOrientation = getOpenOrientation();
+ ItemStack stack = trans.remove(StackFilter.ALL, openOrientation, false);
+ if (stack != null && powerHandler.useEnergy(1, 1, true) == 1) {
+ trans.remove(StackFilter.ALL, openOrientation, true);
+ EntityItem entityitem = new EntityItem(container.worldObj, cart.posX, cart.posY + 0.3F, cart.posZ, stack);
+ entityitem.delayBeforeCanPickup = 10;
+ container.worldObj.spawnEntityInWorld(entityitem);
+ pullItemIntoPipe(entityitem, 1);
+ return true;
}
}
}
@@ -188,23 +186,6 @@ public class PipeItemsObsidian extends Pipe implements IPowe
return false;
}
- public ItemStack checkExtractGeneric(IInventory inventory, boolean doRemove, ForgeDirection from) {
- for (int k = 0; k < inventory.getSizeInventory(); ++k) {
- if (inventory.getStackInSlot(k) != null && inventory.getStackInSlot(k).stackSize > 0) {
-
- ItemStack slot = inventory.getStackInSlot(k);
-
- if (slot != null && slot.stackSize > 0)
- if (doRemove)
- return inventory.decrStackSize(k, 1);
- else
- return slot;
- }
- }
-
- return null;
- }
-
public void pullItemIntoPipe(Entity entity, int distance) {
if (CoreProxy.proxy.isRenderWorld(container.worldObj))
return;
@@ -245,7 +226,7 @@ public class PipeItemsObsidian extends Pipe implements IPowe
CoreProxy.proxy.removeEntity(entity);
}
- TravelingItem passive = new TravelingItem(container.xCoord + 0.5, container.yCoord + Utils.getPipeFloorOf(stack), container.zCoord + 0.5, stack);
+ TravelingItem passive = new TravelingItem(container.xCoord + 0.5, container.yCoord + TransportUtils.getPipeFloorOf(stack), container.zCoord + 0.5, stack);
passive.setSpeed((float) speed);
@@ -281,12 +262,9 @@ public class PipeItemsObsidian extends Pipe implements IPowe
return powerHandler.useEnergy(1, distance, false) >= distance;
} else if (entity instanceof EntityArrow) {
EntityArrow arrow = (EntityArrow) entity;
- if (arrow.canBePickedUp == 1)
- return powerHandler.useEnergy(1, distance, false) >= distance;
- else
- return false;
- } else
- return false;
+ return arrow.canBePickedUp == 1 && powerHandler.useEnergy(1, distance, false) >= distance;
+ }
+ return false;
}
@Override
diff --git a/common/buildcraft/transport/pipes/PipeItemsQuartz.java b/common/buildcraft/transport/pipes/PipeItemsQuartz.java
index 384c21e0..13c6a0d5 100644
--- a/common/buildcraft/transport/pipes/PipeItemsQuartz.java
+++ b/common/buildcraft/transport/pipes/PipeItemsQuartz.java
@@ -10,11 +10,11 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.Position;
-import buildcraft.core.utils.Utils;
import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
+import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -41,12 +41,12 @@ public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook {
@Override
public void readjustSpeed(TravelingItem item) {
- if (item.getSpeed() > Utils.pipeNormalSpeed) {
- item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F);
+ if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) {
+ item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F);
}
- if (item.getSpeed() < Utils.pipeNormalSpeed) {
- item.setSpeed(Utils.pipeNormalSpeed);
+ if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) {
+ item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED);
}
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsSandstone.java b/common/buildcraft/transport/pipes/PipeItemsSandstone.java
index fe53d0c8..6e23d15a 100644
--- a/common/buildcraft/transport/pipes/PipeItemsSandstone.java
+++ b/common/buildcraft/transport/pipes/PipeItemsSandstone.java
@@ -7,18 +7,19 @@
*/
package buildcraft.transport.pipes;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
+import buildcraft.transport.IPipeConnectionForced;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TileGenericPipe;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraftforge.common.ForgeDirection;
-public class PipeItemsSandstone extends Pipe {
+public class PipeItemsSandstone extends Pipe implements IPipeConnectionForced {
public PipeItemsSandstone(int itemID) {
super(new PipeTransportItems(), itemID);
@@ -39,4 +40,9 @@ public class PipeItemsSandstone extends Pipe {
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
return (tile instanceof TileGenericPipe) && super.canPipeConnect(tile, side);
}
+
+ @Override
+ public boolean ignoreConnectionOverrides(ForgeDirection with) {
+ return true;
+ }
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsStone.java b/common/buildcraft/transport/pipes/PipeItemsStone.java
index 6199c8ea..415e5dd2 100644
--- a/common/buildcraft/transport/pipes/PipeItemsStone.java
+++ b/common/buildcraft/transport/pipes/PipeItemsStone.java
@@ -10,11 +10,11 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.Position;
-import buildcraft.core.utils.Utils;
import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
+import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -40,12 +40,12 @@ public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook {
@Override
public void readjustSpeed(TravelingItem item) {
- if (item.getSpeed() > Utils.pipeNormalSpeed) {
- item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 2.0F);
+ if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) {
+ item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 2.0F);
}
- if (item.getSpeed() < Utils.pipeNormalSpeed) {
- item.setSpeed(Utils.pipeNormalSpeed);
+ if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) {
+ item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED);
}
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsWood.java b/common/buildcraft/transport/pipes/PipeItemsWood.java
index 70c850e0..e5746046 100644
--- a/common/buildcraft/transport/pipes/PipeItemsWood.java
+++ b/common/buildcraft/transport/pipes/PipeItemsWood.java
@@ -15,8 +15,8 @@ import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
+import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.PipeManager;
-import buildcraft.core.TileBuffer;
import buildcraft.transport.TravelingItem;
import buildcraft.core.inventory.InventoryWrapper;
import buildcraft.core.utils.Utils;
@@ -40,6 +40,8 @@ public class PipeItemsWood extends Pipe implements IPowerRec
private PipeLogicWood logic = new PipeLogicWood(this) {
@Override
protected boolean isValidConnectingTile(TileEntity tile) {
+ if (tile instanceof IPipeTile)
+ return false;
if (!(tile instanceof IInventory))
return false;
if (!PipeManager.canExtractItems(pipe, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord))
@@ -52,7 +54,7 @@ public class PipeItemsWood extends Pipe implements IPowerRec
super(new PipeTransportItems(), itemID);
powerHandler = new PowerHandler(this, Type.MACHINE);
- powerHandler.configure(1, 64, 1, 64);
+ powerHandler.configure(1, 64.1f, 1, 64.1f);
powerHandler.configurePowerPerdition(0, 0);
}
@@ -103,7 +105,8 @@ public class PipeItemsWood extends Pipe implements IPowerRec
if (powerHandler.getEnergyStored() <= 0)
return;
- extractItems();
+ if (transport.getNumberOfStacks() < PipeTransportItems.MAX_PIPE_STACKS)
+ extractItems();
powerHandler.setEnergy(0);
}
@@ -152,7 +155,7 @@ public class PipeItemsWood extends Pipe implements IPowerRec
/* ISPECIALINVENTORY */
if (inventory instanceof ISpecialInventory) {
- ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(doRemove, from, (int) powerHandler.getEnergyStored());
+ ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(doRemove, from, Math.min((int) powerHandler.getEnergyStored(), PipeTransportItems.MAX_PIPE_ITEMS - transport.getNumberOfItems()));
if (stacks != null && doRemove) {
for (ItemStack stack : stacks) {
if (stack != null) {
diff --git a/common/buildcraft/transport/pipes/PipeLogicIron.java b/common/buildcraft/transport/pipes/PipeLogicIron.java
index 9bce940a..486cdb0b 100644
--- a/common/buildcraft/transport/pipes/PipeLogicIron.java
+++ b/common/buildcraft/transport/pipes/PipeLogicIron.java
@@ -82,7 +82,7 @@ public abstract class PipeLogicIron {
Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null;
if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord)) {
switchPosition();
- pipe.container.worldObj.markBlockForUpdate(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
+ pipe.container.scheduleRenderUpdate();
((IToolWrench) equipped).wrenchUsed(entityplayer, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
return true;
diff --git a/common/buildcraft/transport/pipes/PipePowerIron.java b/common/buildcraft/transport/pipes/PipePowerIron.java
new file mode 100644
index 00000000..2a6b30bd
--- /dev/null
+++ b/common/buildcraft/transport/pipes/PipePowerIron.java
@@ -0,0 +1,131 @@
+/**
+ * BuildCraft is open-source. It is distributed under the terms of the
+ * BuildCraft Open Source License. It grants rights to read, modify, compile or
+ * run the code. It does *NOT* grant the right to redistribute this software or
+ * its modifications in any form, binary or source, except if expressively
+ * granted by the copyright holder.
+ */
+package buildcraft.transport.pipes;
+
+import buildcraft.BuildCraftTransport;
+import buildcraft.api.core.IIconProvider;
+import buildcraft.api.gates.IAction;
+import buildcraft.api.tools.IToolWrench;
+import buildcraft.core.utils.StringUtils;
+import buildcraft.transport.Pipe;
+import buildcraft.transport.PipeIconProvider;
+import buildcraft.transport.PipeTransportPower;
+import buildcraft.transport.triggers.ActionPowerLimiter;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import java.util.LinkedList;
+import java.util.Map;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraftforge.common.ForgeDirection;
+
+public class PipePowerIron extends Pipe {
+
+ public static enum PowerMode {
+
+ M2(2), M4(4), M8(8), M16(16), M32(32), M64(64), M128(128);
+ public static final PowerMode[] VALUES = values();
+ public final int maxPower;
+
+ private PowerMode(int max) {
+ this.maxPower = max;
+ }
+
+ public PowerMode getNext() {
+ PowerMode next = VALUES[(ordinal() + 1) % VALUES.length];
+ return next;
+ }
+
+ public PowerMode getPrevious() {
+ PowerMode previous = VALUES[(ordinal() + VALUES.length - 1) % VALUES.length];
+ return previous;
+ }
+
+ public static PowerMode fromId(int id) {
+ if (id < 0 || id >= VALUES.length) {
+ return M128;
+ }
+ return VALUES[id];
+ }
+ }
+
+ public PipePowerIron(int itemID) {
+ super(new PipeTransportPower(), itemID);
+ transport.initFromPipe(getClass());
+ }
+
+ @Override
+ public int getIconIndex(ForgeDirection direction) {
+ if (container == null)
+ return PipeIconProvider.TYPE.PipePowerIronM128.ordinal();
+ return PipeIconProvider.TYPE.PipePowerIronM2.ordinal() + container.getBlockMetadata();
+ }
+
+ @Override
+ public boolean blockActivated(EntityPlayer player) {
+ Item equipped = player.getCurrentEquippedItem() != null ? player.getCurrentEquippedItem().getItem() : null;
+ if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(player, container.xCoord, container.yCoord, container.zCoord)) {
+ if (player.isSneaking()) {
+ setMode(getMode().getPrevious());
+ } else {
+ setMode(getMode().getNext());
+ }
+ if (getWorld().isRemote)
+ player.addChatMessage(String.format(StringUtils.localize("chat.pipe.power.iron.mode"), getMode().maxPower));
+
+ ((IToolWrench) equipped).wrenchUsed(player, container.xCoord, container.yCoord, container.zCoord);
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public void updateEntity() {
+ super.updateEntity();
+ transport.maxPower = getMode().maxPower;
+ }
+
+ public PowerMode getMode() {
+ return PowerMode.fromId(container.getBlockMetadata());
+ }
+
+ public void setMode(PowerMode mode) {
+ if (mode.ordinal() != container.getBlockMetadata()) {
+ container.worldObj.setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, mode.ordinal(), 3);
+ container.scheduleRenderUpdate();
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIconProvider getIconProvider() {
+ return BuildCraftTransport.instance.pipeIconProvider;
+ }
+
+ @Override
+ protected void actionsActivated(Map actions) {
+ super.actionsActivated(actions);
+
+ for (Map.Entry action : actions.entrySet()) {
+ if (action.getKey() instanceof ActionPowerLimiter && action.getValue() == Boolean.TRUE) {
+ setMode(((ActionPowerLimiter) action.getKey()).limit);
+ break;
+ }
+ }
+ }
+
+ @Override
+ public LinkedList getActions() {
+ LinkedList action = super.getActions();
+ for (PowerMode mode : PowerMode.VALUES) {
+ action.add(BuildCraftTransport.actionPowerLimiter[mode.ordinal()]);
+ }
+ return action;
+ }
+}
diff --git a/common/buildcraft/transport/pipes/PipePowerWood.java b/common/buildcraft/transport/pipes/PipePowerWood.java
index ca1d1cfb..433224d3 100644
--- a/common/buildcraft/transport/pipes/PipePowerWood.java
+++ b/common/buildcraft/transport/pipes/PipePowerWood.java
@@ -13,6 +13,8 @@ import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
+import buildcraft.api.transport.IPipeTile;
+import buildcraft.transport.IPipeTransportPowerHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportPower;
@@ -21,8 +23,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
-
-public class PipePowerWood extends Pipe implements IPowerReceptor {
+public class PipePowerWood extends Pipe implements IPowerReceptor, IPipeTransportPowerHook {
private PowerHandler powerHandler;
protected int standardIconIndex = PipeIconProvider.TYPE.PipePowerWood_Standard.ordinal();
@@ -39,7 +40,7 @@ public class PipePowerWood extends Pipe implements IPowerRec
}
private void initPowerProvider() {
- powerHandler.configure(2, 250, 1, 1500);
+ powerHandler.configure(2, 500, 1, 1500);
powerHandler.configurePowerPerdition(1, 10);
}
@@ -108,9 +109,9 @@ public class PipePowerWood extends Pipe implements IPowerRec
float energyUsable = powerHandler.useEnergy(0, energyToRemove, false);
- float energySend = transport.receiveEnergy(o, energyUsable);
- if (energySend > 0) {
- powerHandler.useEnergy(0, energySend, true);
+ float energySent = transport.receiveEnergy(o, energyUsable);
+ if (energySent > 0) {
+ powerHandler.useEnergy(0, energySent, true);
}
}
}
@@ -145,4 +146,17 @@ public class PipePowerWood extends Pipe implements IPowerRec
powerSources[i] = data.getBoolean("powerSources[" + i + "]");
}
}
+
+ @Override
+ public float receiveEnergy(ForgeDirection from, float val) {
+ return -1;
+ }
+
+ @Override
+ public float requestEnergy(ForgeDirection from, float amount) {
+ if (container.getTile(from) instanceof IPipeTile) {
+ return amount;
+ }
+ return 0;
+ }
}
diff --git a/common/buildcraft/transport/render/FacadeItemRenderer.java b/common/buildcraft/transport/render/FacadeItemRenderer.java
index 56e98d1d..2572ae6e 100644
--- a/common/buildcraft/transport/render/FacadeItemRenderer.java
+++ b/common/buildcraft/transport/render/FacadeItemRenderer.java
@@ -1,7 +1,7 @@
package buildcraft.transport.render;
import buildcraft.BuildCraftTransport;
-import buildcraft.core.utils.Utils;
+import buildcraft.core.CoreConstants;
import buildcraft.transport.ItemFacade;
import buildcraft.transport.PipeIconProvider;
import net.minecraft.block.Block;
@@ -11,6 +11,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraftforge.client.IItemRenderer;
+import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON;
import org.lwjgl.opengl.GL11;
public class FacadeItemRenderer implements IItemRenderer {
@@ -72,7 +73,7 @@ public class FacadeItemRenderer implements IItemRenderer {
block = BuildCraftTransport.genericPipeBlock;
Icon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe
- block.setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos - 1F / 16F);
+ block.setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS - 1F / 16F);
block.setBlockBoundsForItemRender();
render.setRenderBoundsFromBlock(block);
GL11.glTranslatef(translateX, translateY, translateZ + 0.25F);
@@ -112,6 +113,8 @@ public class FacadeItemRenderer implements IItemRenderer {
return true;
case EQUIPPED:
return true;
+ case EQUIPPED_FIRST_PERSON:
+ return true;
case INVENTORY:
return true;
default:
@@ -133,6 +136,7 @@ public class FacadeItemRenderer implements IItemRenderer {
renderFacadeItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F);
break;
case EQUIPPED:
+ case EQUIPPED_FIRST_PERSON:
renderFacadeItem((RenderBlocks) data[0], item, 0F, 0F, 0f);
break;
case INVENTORY:
diff --git a/common/buildcraft/transport/render/FacadeRenderHelper.java b/common/buildcraft/transport/render/FacadeRenderHelper.java
new file mode 100644
index 00000000..6ff9e549
--- /dev/null
+++ b/common/buildcraft/transport/render/FacadeRenderHelper.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.transport.render;
+
+import buildcraft.BuildCraftTransport;
+import buildcraft.core.CoreConstants;
+import buildcraft.core.utils.MatrixTranformations;
+import buildcraft.transport.BlockGenericPipe;
+import buildcraft.transport.PipeIconProvider;
+import buildcraft.transport.PipeRenderState;
+import buildcraft.transport.TransportConstants;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
+import net.minecraftforge.common.ForgeDirection;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public class FacadeRenderHelper {
+
+ private static final float zFightOffset = 1F / 4096F;
+ private static final float[][] zeroStateFacade = new float[3][2];
+ private static final float[][] zeroStateSupport = new float[3][2];
+ private static final float[] xOffsets = new float[6];
+ private static final float[] yOffsets = new float[6];
+ private static final float[] zOffsets = new float[6];
+
+ static {
+
+ // X START - END
+ zeroStateFacade[0][0] = 0.0F;
+ zeroStateFacade[0][1] = 1.0F;
+ // Y START - END
+ zeroStateFacade[1][0] = 0.0F;
+ zeroStateFacade[1][1] = TransportConstants.FACADE_THICKNESS;
+ // Z START - END
+ zeroStateFacade[2][0] = 0.0F;
+ zeroStateFacade[2][1] = 1.0F;
+
+ // X START - END
+ zeroStateSupport[0][0] = CoreConstants.PIPE_MIN_POS;
+ zeroStateSupport[0][1] = CoreConstants.PIPE_MAX_POS;
+ // Y START - END
+ zeroStateSupport[1][0] = TransportConstants.FACADE_THICKNESS;
+ zeroStateSupport[1][1] = CoreConstants.PIPE_MIN_POS;
+ // Z START - END
+ zeroStateSupport[2][0] = CoreConstants.PIPE_MIN_POS;
+ zeroStateSupport[2][1] = CoreConstants.PIPE_MAX_POS;
+
+ xOffsets[0] = zFightOffset;
+ xOffsets[1] = zFightOffset;
+ xOffsets[2] = 0;
+ xOffsets[3] = 0;
+ xOffsets[4] = 0;
+ xOffsets[5] = 0;
+
+ yOffsets[0] = 0;
+ yOffsets[1] = 0;
+ yOffsets[2] = zFightOffset;
+ yOffsets[3] = zFightOffset;
+ yOffsets[4] = 0;
+ yOffsets[5] = 0;
+
+ zOffsets[0] = zFightOffset;
+ zOffsets[1] = zFightOffset;
+ zOffsets[2] = 0;
+ zOffsets[3] = 0;
+ zOffsets[4] = 0;
+ zOffsets[5] = 0;
+ }
+
+ private static void setRenderBounds(RenderBlocks renderblocks, float[][] rotated, ForgeDirection side) {
+ renderblocks.setRenderBounds(
+ rotated[0][0] + xOffsets[side.ordinal()],
+ rotated[1][0] + yOffsets[side.ordinal()],
+ rotated[2][0] + zOffsets[side.ordinal()],
+ rotated[0][1] - xOffsets[side.ordinal()],
+ rotated[1][1] - yOffsets[side.ordinal()],
+ rotated[2][1] - zOffsets[side.ordinal()]);
+ }
+
+ public static void pipeFacadeRenderer(RenderBlocks renderblocks, BlockGenericPipe block, PipeRenderState state, int x, int y, int z) {
+ state.textureArray = new Icon[6];
+
+ for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
+ int facadeId = state.facadeMatrix.getFacadeBlockId(direction);
+ if (facadeId != 0) {
+ Block renderBlock = Block.blocksList[facadeId];
+ int renderMeta = state.facadeMatrix.getFacadeMetaId(direction);
+
+ for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
+ state.textureArray[side.ordinal()] = renderBlock.getIcon(side.ordinal(), renderMeta);
+ if (side == direction || side == direction.getOpposite())
+ block.setRenderSide(side, true);
+ else
+ block.setRenderSide(side, state.facadeMatrix.getFacadeBlockId(side) == 0);
+ }
+
+ try {
+ BlockGenericPipe.facadeRenderColor = Item.itemsList[state.facadeMatrix.getFacadeBlockId(direction)].getColorFromItemStack(new ItemStack(facadeId, 1, renderMeta), 0);
+ } catch (Throwable error) {
+ }
+
+ if (renderBlock.getRenderType() == 31) {
+ if ((renderMeta & 12) == 4) {
+ renderblocks.uvRotateEast = 1;
+ renderblocks.uvRotateWest = 1;
+ renderblocks.uvRotateTop = 1;
+ renderblocks.uvRotateBottom = 1;
+ } else if ((renderMeta & 12) == 8) {
+ renderblocks.uvRotateSouth = 1;
+ renderblocks.uvRotateNorth = 1;
+ }
+ }
+
+ // Hollow facade
+ if (state.pipeConnectionMatrix.isConnected(direction)) {
+ float[][] rotated = MatrixTranformations.deepClone(zeroStateFacade);
+ rotated[0][0] = CoreConstants.PIPE_MIN_POS - zFightOffset * 4;
+ rotated[0][1] = CoreConstants.PIPE_MAX_POS + zFightOffset * 4;
+ rotated[2][0] = 0.0F;
+ rotated[2][1] = CoreConstants.PIPE_MIN_POS - zFightOffset * 2;
+ MatrixTranformations.transform(rotated, direction);
+ setRenderBounds(renderblocks, rotated, direction);
+ renderblocks.renderStandardBlock(block, x, y, z);
+
+ rotated = MatrixTranformations.deepClone(zeroStateFacade);
+ rotated[0][0] = CoreConstants.PIPE_MIN_POS - zFightOffset * 4;
+ rotated[0][1] = CoreConstants.PIPE_MAX_POS + zFightOffset * 4;
+ rotated[2][0] = CoreConstants.PIPE_MAX_POS + zFightOffset * 2;
+ MatrixTranformations.transform(rotated, direction);
+ setRenderBounds(renderblocks, rotated, direction);
+ renderblocks.renderStandardBlock(block, x, y, z);
+
+ rotated = MatrixTranformations.deepClone(zeroStateFacade);
+ rotated[0][0] = 0.0F;
+ rotated[0][1] = CoreConstants.PIPE_MIN_POS - zFightOffset * 2;
+ MatrixTranformations.transform(rotated, direction);
+ setRenderBounds(renderblocks, rotated, direction);
+ renderblocks.renderStandardBlock(block, x, y, z);
+
+ rotated = MatrixTranformations.deepClone(zeroStateFacade);
+ rotated[0][0] = CoreConstants.PIPE_MAX_POS + zFightOffset * 2;
+ rotated[0][1] = 1F;
+ MatrixTranformations.transform(rotated, direction);
+ setRenderBounds(renderblocks, rotated, direction);
+ renderblocks.renderStandardBlock(block, x, y, z);
+ } else { // Solid facade
+ float[][] rotated = MatrixTranformations.deepClone(zeroStateFacade);
+ MatrixTranformations.transform(rotated, direction);
+ setRenderBounds(renderblocks, rotated, direction);
+ renderblocks.renderStandardBlock(block, x, y, z);
+ }
+
+ if (renderBlock.getRenderType() == 31) {
+ renderblocks.uvRotateSouth = 0;
+ renderblocks.uvRotateEast = 0;
+ renderblocks.uvRotateWest = 0;
+ renderblocks.uvRotateNorth = 0;
+ renderblocks.uvRotateTop = 0;
+ renderblocks.uvRotateBottom = 0;
+ }
+ }
+
+ BlockGenericPipe.facadeRenderColor = -1;
+ }
+
+ state.textureArray = null;
+ block.setRenderAllSides();
+
+ state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe
+
+ for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
+ if (state.facadeMatrix.getFacadeBlockId(direction) != 0 && !state.pipeConnectionMatrix.isConnected(direction)) {
+ float[][] rotated = MatrixTranformations.deepClone(zeroStateSupport);
+ MatrixTranformations.transform(rotated, direction);
+
+ renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
+ renderblocks.renderStandardBlock(block, x, y, z);
+ }
+ }
+ }
+}
diff --git a/common/buildcraft/transport/render/PipeItemRenderer.java b/common/buildcraft/transport/render/PipeItemRenderer.java
index a0ce62a1..7d8f39e3 100644
--- a/common/buildcraft/transport/render/PipeItemRenderer.java
+++ b/common/buildcraft/transport/render/PipeItemRenderer.java
@@ -1,7 +1,7 @@
package buildcraft.transport.render;
import buildcraft.BuildCraftTransport;
-import buildcraft.core.utils.Utils;
+import buildcraft.core.CoreConstants;
import buildcraft.transport.ItemPipe;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
@@ -25,9 +25,9 @@ public class PipeItemRenderer implements IItemRenderer {
Icon icon = ((ItemPipe) Item.itemsList[item.itemID]).getIconFromDamage(0);
if (icon == null)
- icon = ((TextureMap) Minecraft.getMinecraft().func_110434_K().func_110581_b(TextureMap.field_110575_b)).func_110572_b("missingno");
+ icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
- block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
+ block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
block.setBlockBoundsForItemRender();
render.setRenderBoundsFromBlock(block);
diff --git a/common/buildcraft/transport/render/RenderPipe.java b/common/buildcraft/transport/render/PipeRendererTESR.java
similarity index 52%
rename from common/buildcraft/transport/render/RenderPipe.java
rename to common/buildcraft/transport/render/PipeRendererTESR.java
index 2319f511..128fad2d 100644
--- a/common/buildcraft/transport/render/RenderPipe.java
+++ b/common/buildcraft/transport/render/PipeRendererTESR.java
@@ -10,13 +10,16 @@ package buildcraft.transport.render;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftCore.RenderMode;
import buildcraft.BuildCraftTransport;
+import buildcraft.api.transport.IPipe;
+import buildcraft.api.transport.IPipe.WireColor;
+import buildcraft.core.CoreConstants;
import buildcraft.core.render.FluidRenderer;
import buildcraft.core.render.RenderEntityBlock;
-import buildcraft.core.render.RenderEntityBlock.BlockInterface;
+import buildcraft.core.render.RenderEntityBlock.RenderInfo;
import buildcraft.core.utils.EnumColor;
-import buildcraft.core.utils.Utils;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
+import buildcraft.transport.PipeRenderState;
import buildcraft.transport.PipeTransportFluids;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.PipeTransportPower;
@@ -26,6 +29,7 @@ import com.google.common.collect.Maps;
import java.util.HashMap;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.GLAllocation;
+import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
@@ -40,7 +44,7 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
-public class RenderPipe extends TileEntitySpecialRenderer {
+public class PipeRendererTESR extends TileEntitySpecialRenderer {
final static private int LIQUID_STAGES = 40;
final static private int MAX_ITEMS_TO_RENDER = 10;
@@ -61,7 +65,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
public int[] displayPowerList = new int[POWER_STAGES];
public int[] displayPowerListOverload = new int[POWER_STAGES];
- public RenderPipe() {
+ public PipeRendererTESR() {
customRenderItem = new RenderItem() {
@Override
public boolean shouldBob() {
@@ -84,7 +88,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
DisplayFluidList d = new DisplayFluidList();
displayFluidLists.put(liquidId, d);
- BlockInterface block = new BlockInterface();
+ RenderInfo block = new RenderInfo();
Fluid fluid = FluidRegistry.getFluid(liquidId);
if (fluid.getBlockID() > 0) {
@@ -94,7 +98,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
}
block.texture = fluid.getStillIcon();
- float size = Utils.pipeMaxPos - Utils.pipeMinPos;
+ float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
// render size
@@ -107,12 +111,12 @@ public class RenderPipe extends TileEntitySpecialRenderer {
GL11.glNewList(d.sideHorizontal[s], 4864 /* GL_COMPILE */);
block.minX = 0.0F;
- block.minZ = Utils.pipeMinPos + 0.01F;
+ block.minZ = CoreConstants.PIPE_MIN_POS + 0.01F;
block.maxX = block.minX + size / 2F + 0.01F;
block.maxZ = block.minZ + size - 0.02F;
- block.minY = Utils.pipeMinPos + 0.01F;
+ block.minY = CoreConstants.PIPE_MIN_POS + 0.01F;
block.maxY = block.minY + (size - 0.02F) * ratio;
RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true);
@@ -124,7 +128,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
d.sideVertical[s] = GLAllocation.generateDisplayLists(1);
GL11.glNewList(d.sideVertical[s], 4864 /* GL_COMPILE */);
- block.minY = Utils.pipeMaxPos - 0.01;
+ block.minY = CoreConstants.PIPE_MAX_POS - 0.01;
block.maxY = 1;
block.minX = 0.5 - (size / 2 - 0.01) * ratio;
@@ -142,13 +146,13 @@ public class RenderPipe extends TileEntitySpecialRenderer {
d.centerHorizontal[s] = GLAllocation.generateDisplayLists(1);
GL11.glNewList(d.centerHorizontal[s], 4864 /* GL_COMPILE */);
- block.minX = Utils.pipeMinPos + 0.01;
- block.minZ = Utils.pipeMinPos + 0.01;
+ block.minX = CoreConstants.PIPE_MIN_POS + 0.01;
+ block.minZ = CoreConstants.PIPE_MIN_POS + 0.01;
block.maxX = block.minX + size - 0.02;
block.maxZ = block.minZ + size - 0.02;
- block.minY = Utils.pipeMinPos + 0.01;
+ block.minY = CoreConstants.PIPE_MIN_POS + 0.01;
block.maxY = block.minY + (size - 0.02F) * ratio;
RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true);
@@ -160,8 +164,8 @@ public class RenderPipe extends TileEntitySpecialRenderer {
d.centerVertical[s] = GLAllocation.generateDisplayLists(1);
GL11.glNewList(d.centerVertical[s], 4864 /* GL_COMPILE */);
- block.minY = Utils.pipeMinPos + 0.01;
- block.maxY = Utils.pipeMaxPos - 0.01;
+ block.minY = CoreConstants.PIPE_MIN_POS + 0.01;
+ block.maxY = CoreConstants.PIPE_MAX_POS - 0.01;
block.minX = 0.5 - (size / 2 - 0.02) * ratio;
block.maxX = 0.5 + (size / 2 - 0.02) * ratio;
@@ -185,10 +189,10 @@ public class RenderPipe extends TileEntitySpecialRenderer {
initialized = true;
- BlockInterface block = new BlockInterface();
+ RenderInfo block = new RenderInfo();
block.texture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Power_Normal.ordinal());
- float size = Utils.pipeMaxPos - Utils.pipeMinPos;
+ float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
for (int s = 0; s < POWER_STAGES; ++s) {
displayPowerList[s] = GLAllocation.generateDisplayLists(1);
@@ -214,7 +218,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
block.texture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Power_Overload.ordinal());
- size = Utils.pipeMaxPos - Utils.pipeMinPos;
+ size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
for (int s = 0; s < POWER_STAGES; ++s) {
displayPowerListOverload[s] = GLAllocation.generateDisplayLists(1);
@@ -250,6 +254,8 @@ public class RenderPipe extends TileEntitySpecialRenderer {
if (pipe.pipe == null)
return;
+ renderGatesWires(pipe, x, y, z);
+
switch (pipe.getPipeType()) {
case ITEM:
renderSolids(pipe.pipe, x, y, z);
@@ -263,31 +269,288 @@ public class RenderPipe extends TileEntitySpecialRenderer {
}
}
+ private void renderGatesWires(TileGenericPipe pipe, double x, double y, double z) {
+ PipeRenderState state = pipe.getRenderState();
+
+ if (state.wireMatrix.hasWire(WireColor.Red)) {
+ pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MIN_POS, IPipe.WireColor.Red, x, y, z);
+ }
+
+ if (state.wireMatrix.hasWire(WireColor.Blue)) {
+ pipeWireRender(pipe, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, IPipe.WireColor.Blue, x, y, z);
+ }
+
+ if (state.wireMatrix.hasWire(WireColor.Green)) {
+ pipeWireRender(pipe, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, IPipe.WireColor.Green, x, y, z);
+ }
+
+ if (state.wireMatrix.hasWire(WireColor.Yellow)) {
+ pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, IPipe.WireColor.Yellow, x, y, z);
+ }
+
+ if (state.hasGate()) {
+ pipeGateRender(pipe, x, y, z);
+ }
+ }
+
+ private void pipeWireRender(TileGenericPipe pipe, float cx, float cy, float cz, IPipe.WireColor color, double x, double y, double z) {
+
+ PipeRenderState state = pipe.getRenderState();
+
+ float minX = CoreConstants.PIPE_MIN_POS;
+ float minY = CoreConstants.PIPE_MIN_POS;
+ float minZ = CoreConstants.PIPE_MIN_POS;
+
+ float maxX = CoreConstants.PIPE_MAX_POS;
+ float maxY = CoreConstants.PIPE_MAX_POS;
+ float maxZ = CoreConstants.PIPE_MAX_POS;
+
+ boolean foundX = false, foundY = false, foundZ = false;
+
+ if (state.wireMatrix.isWireConnected(color, ForgeDirection.WEST)) {
+ minX = 0;
+ foundX = true;
+ }
+
+ if (state.wireMatrix.isWireConnected(color, ForgeDirection.EAST)) {
+ maxX = 1;
+ foundX = true;
+ }
+
+ if (state.wireMatrix.isWireConnected(color, ForgeDirection.DOWN)) {
+ minY = 0;
+ foundY = true;
+ }
+
+ if (state.wireMatrix.isWireConnected(color, ForgeDirection.UP)) {
+ maxY = 1;
+ foundY = true;
+ }
+
+ if (state.wireMatrix.isWireConnected(color, ForgeDirection.NORTH)) {
+ minZ = 0;
+ foundZ = true;
+ }
+
+ if (state.wireMatrix.isWireConnected(color, ForgeDirection.SOUTH)) {
+ maxZ = 1;
+ foundZ = true;
+ }
+
+ boolean center = false;
+
+ if (minX == 0 && maxX != 1 && (foundY || foundZ))
+ if (cx == CoreConstants.PIPE_MIN_POS) {
+ maxX = CoreConstants.PIPE_MIN_POS;
+ } else {
+ center = true;
+ }
+
+ if (minX != 0 && maxX == 1 && (foundY || foundZ))
+ if (cx == CoreConstants.PIPE_MAX_POS) {
+ minX = CoreConstants.PIPE_MAX_POS;
+ } else {
+ center = true;
+ }
+
+ if (minY == 0 && maxY != 1 && (foundX || foundZ))
+ if (cy == CoreConstants.PIPE_MIN_POS) {
+ maxY = CoreConstants.PIPE_MIN_POS;
+ } else {
+ center = true;
+ }
+
+ if (minY != 0 && maxY == 1 && (foundX || foundZ))
+ if (cy == CoreConstants.PIPE_MAX_POS) {
+ minY = CoreConstants.PIPE_MAX_POS;
+ } else {
+ center = true;
+ }
+
+ if (minZ == 0 && maxZ != 1 && (foundX || foundY))
+ if (cz == CoreConstants.PIPE_MIN_POS) {
+ maxZ = CoreConstants.PIPE_MIN_POS;
+ } else {
+ center = true;
+ }
+
+ if (minZ != 0 && maxZ == 1 && (foundX || foundY))
+ if (cz == CoreConstants.PIPE_MAX_POS) {
+ minZ = CoreConstants.PIPE_MAX_POS;
+ } else {
+ center = true;
+ }
+
+ boolean found = foundX || foundY || foundZ;
+
+ GL11.glPushMatrix();
+ GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glEnable(GL11.GL_CULL_FACE);
+ RenderHelper.disableStandardItemLighting();
+
+ GL11.glColor3f(1, 1, 1);
+ GL11.glTranslatef((float) x, (float) y, (float) z);
+
+ float scale = 1.001f;
+ GL11.glTranslatef(0.5F, 0.5F, 0.5F);
+ GL11.glScalef(scale, scale, scale);
+ GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
+
+
+ bindTexture(TextureMap.locationBlocksTexture);
+
+ RenderInfo box = new RenderInfo();
+ box.texture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(color));
+
+ // Z render
+
+ if (minZ != CoreConstants.PIPE_MIN_POS || maxZ != CoreConstants.PIPE_MAX_POS || !found) {
+ box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, minZ, cx == CoreConstants.PIPE_MIN_POS ? cx
+ : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, maxZ);
+ RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
+ }
+
+ // X render
+
+ if (minX != CoreConstants.PIPE_MIN_POS || maxX != CoreConstants.PIPE_MAX_POS || !found) {
+ box.setBounds(minX, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, maxX, cy == CoreConstants.PIPE_MIN_POS ? cy
+ : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
+ RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
+ }
+
+ // Y render
+
+ if (minY != CoreConstants.PIPE_MIN_POS || maxY != CoreConstants.PIPE_MAX_POS || !found) {
+ box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, minY, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, cx == CoreConstants.PIPE_MIN_POS ? cx
+ : cx + 0.05F, maxY, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
+ RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
+ }
+
+ if (center || !found) {
+ box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz,
+ cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
+ RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
+ }
+
+ RenderHelper.enableStandardItemLighting();
+
+ GL11.glPopAttrib();
+ GL11.glPopMatrix();
+ }
+
+ private void pipeGateRender(TileGenericPipe pipe, double x, double y, double z) {
+ GL11.glPushMatrix();
+ GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
+// GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glEnable(GL11.GL_CULL_FACE);
+// GL11.glDisable(GL11.GL_TEXTURE_2D);
+ RenderHelper.disableStandardItemLighting();
+
+ GL11.glColor3f(1, 1, 1);
+ GL11.glTranslatef((float) x, (float) y, (float) z);
+
+ bindTexture(TextureMap.locationBlocksTexture);
+
+ PipeRenderState state = pipe.getRenderState();
+
+ float min = CoreConstants.PIPE_MIN_POS + 0.05F;
+ float max = CoreConstants.PIPE_MAX_POS - 0.05F;
+
+ RenderInfo box = new RenderInfo();
+ box.texture = BuildCraftTransport.instance.gateIconProvider.getIcon(state.getGateIconIndex());
+
+ if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) {
+ box.setBounds(CoreConstants.PIPE_MIN_POS - 0.10F, min, min, CoreConstants.PIPE_MIN_POS + 0.001F, max, max);
+ RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
+ }
+
+ if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) {
+ box.setBounds(CoreConstants.PIPE_MAX_POS + 0.001F, min, min, CoreConstants.PIPE_MAX_POS + 0.10F, max, max);
+ RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
+ }
+
+ if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) {
+ box.setBounds(min, CoreConstants.PIPE_MIN_POS - 0.10F, min, max, CoreConstants.PIPE_MIN_POS + 0.001F, max);
+ RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
+ }
+
+ if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) {
+ box.setBounds(min, CoreConstants.PIPE_MAX_POS + 0.001F, min, max, CoreConstants.PIPE_MAX_POS + 0.10F, max);
+ RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
+ }
+
+ if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) {
+ box.setBounds(min, min, CoreConstants.PIPE_MIN_POS - 0.10F, max, max, CoreConstants.PIPE_MIN_POS + 0.001F);
+ RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
+ }
+
+ if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) {
+ box.setBounds(min, min, CoreConstants.PIPE_MAX_POS + 0.001F, max, max, CoreConstants.PIPE_MAX_POS + 0.10F);
+ RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
+ }
+
+ RenderHelper.enableStandardItemLighting();
+
+ GL11.glPopAttrib();
+ GL11.glPopMatrix();
+ }
+
+ private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) {
+ return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) == 0 && !state.plugMatrix.isConnected(direction) && !isOpenOrientation(state, direction);
+ }
+
+ public boolean isOpenOrientation(PipeRenderState state, ForgeDirection direction) {
+ int connections = 0;
+
+ ForgeDirection targetOrientation = ForgeDirection.UNKNOWN;
+
+ for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
+ if (state.pipeConnectionMatrix.isConnected(o)) {
+
+ connections++;
+
+ if (connections == 1)
+ targetOrientation = o;
+ }
+ }
+
+ if (connections > 1 || connections == 0)
+ return false;
+
+ return targetOrientation.getOpposite() == direction;
+ }
+
private void renderPower(Pipe pipe, double x, double y, double z) {
initializeDisplayPowerList(pipe.container.worldObj);
PipeTransportPower pow = pipe.transport;
GL11.glPushMatrix();
- GL11.glDisable(2896 /* GL_LIGHTING */);
+ GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
+ GL11.glDisable(GL11.GL_LIGHTING);
+// GL11.glEnable(GL11.GL_BLEND);
GL11.glTranslatef((float) x, (float) y, (float) z);
- func_110628_a(TextureMap.field_110575_b);
+ bindTexture(TextureMap.locationBlocksTexture);
int[] displayList = pow.overload > 0 ? displayPowerListOverload : displayPowerList;
- for (int i = 0; i < 6; ++i) {
+ for (int side = 0; side < 6; ++side) {
GL11.glPushMatrix();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
- GL11.glRotatef(angleY[i], 0, 1, 0);
- GL11.glRotatef(angleZ[i], 0, 0, 1);
+ GL11.glRotatef(angleY[side], 0, 1, 0);
+ GL11.glRotatef(angleZ[side], 0, 0, 1);
+ float scale = 1.0F - side * 0.0001F;
+ GL11.glScalef(scale, scale, scale);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
- if (pow.clientDisplayPower[i] >= 1.0) {
- short stage = pow.clientDisplayPower[i];
-
+ short stage = pow.clientDisplayPower[side];
+ if (stage >= 1) {
if (stage < displayList.length) {
GL11.glCallList(displayList[stage]);
} else {
@@ -298,7 +561,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
GL11.glPopMatrix();
}
- GL11.glEnable(2896 /* GL_LIGHTING */);
+ GL11.glPopAttrib();
GL11.glPopMatrix();
}
@@ -368,7 +631,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
break;
default:
}
- func_110628_a(TextureMap.field_110575_b);
+ bindTexture(TextureMap.locationBlocksTexture);
FluidRenderer.setColorForFluidStack(fluidStack);
GL11.glCallList(list);
GL11.glPopMatrix();
@@ -383,9 +646,9 @@ public class RenderPipe extends TileEntitySpecialRenderer {
if (d != null) {
int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
- func_110628_a(TextureMap.field_110575_b);
+ bindTexture(TextureMap.locationBlocksTexture);
FluidRenderer.setColorForFluidStack(fluidStack);
-
+
if (above) {
GL11.glCallList(d.centerVertical[stage]);
}
@@ -445,8 +708,8 @@ public class RenderPipe extends TileEntitySpecialRenderer {
dummyEntityItem.setEntityItemStack(itemstack);
customRenderItem.doRenderItem(dummyEntityItem, 0, 0, 0, 0, 0);
if (color != null) {
- func_110628_a(TextureMap.field_110575_b);
- BlockInterface block = new BlockInterface();
+ bindTexture(TextureMap.locationBlocksTexture);
+ RenderInfo block = new RenderInfo();
block.texture = PipeIconProvider.TYPE.ItemBox.getIcon();
diff --git a/common/buildcraft/transport/render/PipeRendererWorld.java b/common/buildcraft/transport/render/PipeRendererWorld.java
new file mode 100644
index 00000000..bddbb397
--- /dev/null
+++ b/common/buildcraft/transport/render/PipeRendererWorld.java
@@ -0,0 +1,169 @@
+package buildcraft.transport.render;
+
+import buildcraft.BuildCraftTransport;
+import buildcraft.api.core.IIconProvider;
+import buildcraft.core.CoreConstants;
+import buildcraft.transport.BlockGenericPipe;
+import buildcraft.transport.IPipeRenderState;
+import buildcraft.transport.PipeIconProvider;
+import buildcraft.transport.PipeRenderState;
+import buildcraft.transport.TransportProxy;
+import buildcraft.core.utils.MatrixTranformations;
+
+import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.IBlockAccess;
+
+import net.minecraftforge.common.ForgeDirection;
+
+public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
+ public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, BlockGenericPipe block, IPipeRenderState renderState, int x, int y, int z) {
+ PipeRenderState state = renderState.getRenderState();
+ IIconProvider icons = renderState.getPipeIcons();
+ if (icons == null)
+ return;
+
+ int connectivity = state.pipeConnectionMatrix.getMask();
+ float[] dim = new float[6];
+
+ // render the unconnected pipe faces of the center block (if any)
+
+ if (connectivity != 0x3f) { // note: 0x3f = 0x111111 = all sides
+ resetToCenterDimensions(dim);
+
+ state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN));
+ renderTwoWayBlock(renderblocks, block, x, y, z, dim, connectivity ^ 0x3f);
+ }
+
+ // render the connecting pipe faces
+
+ for (int dir = 0; dir < 6; dir++) {
+ int mask = 1 << dir;
+ if ((connectivity & mask) == 0) continue; // no connection towards dir
+
+ // center piece offsets
+ resetToCenterDimensions(dim);
+
+ // extend block towards dir as it's connected to there
+ dim[dir / 2] = dir % 2 == 0 ? 0 : CoreConstants.PIPE_MAX_POS;
+ dim[dir / 2 + 3] = dir % 2 == 0 ? CoreConstants.PIPE_MIN_POS : 1;
+
+ // the mask points to all faces perpendicular to dir, i.e. dirs 0+1 -> mask 111100, 1+2 -> 110011, 3+5 -> 001111
+ int renderMask = (3 << (dir / 2 * 2)) ^ 0x3f;
+
+ // render sub block
+ state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.VALID_DIRECTIONS[dir]));
+
+ renderTwoWayBlock(renderblocks, block, x, y, z, dim, renderMask);
+ }
+
+ renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
+
+ pipeFacadeRenderer(renderblocks, block, state, x, y, z);
+ pipePlugRenderer(renderblocks, block, state, x, y, z);
+ }
+
+ private void resetToCenterDimensions(float[] dim) {
+ for (int i = 0; i < 3; i++) dim[i] = CoreConstants.PIPE_MIN_POS;
+ for (int i = 3; i < 6; i++) dim[i] = CoreConstants.PIPE_MAX_POS;
+ }
+
+ /**
+ * Render a block with normal and inverted vertex order so back face culling doesn't have any effect.
+ */
+ private void renderTwoWayBlock(RenderBlocks renderblocks, BlockGenericPipe block, int x, int y, int z, float[] dim, int mask) {
+ assert mask != 0;
+
+ block.setRenderMask(mask);
+ renderblocks.setRenderBounds(dim[2], dim[0], dim[1], dim[5], dim[3], dim[4]);
+ renderblocks.renderStandardBlock(block, x, y, z);
+ block.setRenderMask((mask & 0x15) << 1 | (mask & 0x2a) >> 1); // pairwise swapped mask
+ renderblocks.setRenderBounds(dim[5], dim[3], dim[4], dim[2], dim[0], dim[1]);
+ renderblocks.renderStandardBlock(block, x, y, z);
+ }
+
+ private void pipeFacadeRenderer(RenderBlocks renderblocks, BlockGenericPipe block, PipeRenderState state, int x, int y, int z) {
+ FacadeRenderHelper.pipeFacadeRenderer(renderblocks, block, state, x, y, z);
+ }
+
+ private void pipePlugRenderer(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) {
+
+ float zFightOffset = 1F / 4096F;
+
+ float[][] zeroState = new float[3][2];
+ // X START - END
+ zeroState[0][0] = 0.25F + zFightOffset;
+ zeroState[0][1] = 0.75F - zFightOffset;
+ // Y START - END
+ zeroState[1][0] = 0.125F;
+ zeroState[1][1] = 0.251F;
+ // Z START - END
+ zeroState[2][0] = 0.25F + zFightOffset;
+ zeroState[2][1] = 0.75F - zFightOffset;
+
+ state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe
+
+ for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
+ if (state.plugMatrix.isConnected(direction)) {
+ float[][] rotated = MatrixTranformations.deepClone(zeroState);
+ MatrixTranformations.transform(rotated, direction);
+
+ renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
+ renderblocks.renderStandardBlock(block, x, y, z);
+ }
+ }
+
+ // X START - END
+ zeroState[0][0] = 0.25F + 0.125F / 2 + zFightOffset;
+ zeroState[0][1] = 0.75F - 0.125F / 2 + zFightOffset;
+ // Y START - END
+ zeroState[1][0] = 0.25F;
+ zeroState[1][1] = 0.25F + 0.125F;
+ // Z START - END
+ zeroState[2][0] = 0.25F + 0.125F / 2;
+ zeroState[2][1] = 0.75F - 0.125F / 2;
+
+ state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe
+
+ for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
+ if (state.plugMatrix.isConnected(direction)) {
+ float[][] rotated = MatrixTranformations.deepClone(zeroState);
+ MatrixTranformations.transform(rotated, direction);
+
+ renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
+ renderblocks.renderStandardBlock(block, x, y, z);
+ }
+ }
+
+ }
+
+ @Override
+ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
+ TileEntity tile = world.getBlockTileEntity(x, y, z);
+
+ if (tile instanceof IPipeRenderState) {
+ IPipeRenderState pipeTile = (IPipeRenderState) tile;
+ renderPipe(renderer, world, (BlockGenericPipe) block, pipeTile, x, y, z);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean shouldRender3DInInventory() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public int getRenderId() {
+ return TransportProxy.pipeModel;
+ }
+}
diff --git a/common/buildcraft/transport/render/PipeWorldRenderer.java b/common/buildcraft/transport/render/PipeWorldRenderer.java
deleted file mode 100644
index b4487001..00000000
--- a/common/buildcraft/transport/render/PipeWorldRenderer.java
+++ /dev/null
@@ -1,584 +0,0 @@
-package buildcraft.transport.render;
-
-import buildcraft.BuildCraftTransport;
-import buildcraft.api.core.IIconProvider;
-import buildcraft.api.transport.IPipe;
-import buildcraft.api.transport.IPipe.WireColor;
-import buildcraft.core.utils.Utils;
-import buildcraft.transport.BlockGenericPipe;
-import buildcraft.transport.IPipeRenderState;
-import buildcraft.transport.PipeIconProvider;
-import buildcraft.transport.PipeRenderState;
-import buildcraft.transport.TransportProxy;
-import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
-import net.minecraft.block.Block;
-import net.minecraft.client.renderer.RenderBlocks;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.Icon;
-import net.minecraft.world.IBlockAccess;
-import net.minecraftforge.common.ForgeDirection;
-
-public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
-
- public static final float facadeThickness = 1F / 16F;
-
- /**
- * Mirrors the array on the Y axis by calculating offsets from 0.5F
- *
- * @param targetArray
- */
- private void mirrorY(float[][] targetArray) {
- float temp = targetArray[1][0];
- targetArray[1][0] = (targetArray[1][1] - 0.5F) * -1F + 0.5F; // 1 -> 0.5F -> -0.5F -> 0F
- targetArray[1][1] = (temp - 0.5F) * -1F + 0.5F; // 0 -> -0.5F -> 0.5F -> 1F
- }
-
- /**
- * Shifts the coordinates around effectivly rotating something. Zero state
- * is DOWN then -> NORTH -> WEST Note - To obtain Pos, do a mirrorY() before
- * rotating
- *
- * @param targetArray the array that should be rotated
- */
- private void rotate(float[][] targetArray) {
- for (int i = 0; i < 2; i++) {
- float temp = targetArray[2][i];
- targetArray[2][i] = targetArray[1][i];
- targetArray[1][i] = targetArray[0][i];
- targetArray[0][i] = temp;
- }
- }
-
- /**
- * @param targetArray the array that should be transformed
- * @param direction
- */
- private void transform(float[][] targetArray, ForgeDirection direction) {
- if ((direction.ordinal() & 0x1) == 1) {
- mirrorY(targetArray);
- }
-
- for (int i = 0; i < (direction.ordinal() >> 1); i++) {
- rotate(targetArray);
- }
- }
-
- /**
- * Clones both dimensions of a float[][]
- *
- * @param source the float[][] to deepClone
- * @return
- */
- private float[][] deepClone(float[][] source) {
- float[][] target = source.clone();
- for (int i = 0; i < target.length; i++) {
- target[i] = source[i].clone();
- }
- return target;
- }
-
- private void renderAllFaceExeptAxe(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int x, int y, int z, char axe) {
- float minX = (float) renderblocks.renderMinX;
- float minY = (float) renderblocks.renderMinY;
- float minZ = (float) renderblocks.renderMinZ;
- float maxX = (float) renderblocks.renderMaxX;
- float maxY = (float) renderblocks.renderMaxY;
- float maxZ = (float) renderblocks.renderMaxZ;
- if (axe != 'x') {
- renderTwoWayXFace(renderblocks, block, icon, x, y, z, minY, minZ, maxY, maxZ, minX);
- renderTwoWayXFace(renderblocks, block, icon, x, y, z, minY, minZ, maxY, maxZ, maxX);
- }
- if (axe != 'y') {
- renderTwoWayYFace(renderblocks, block, icon, x, y, z, minX, minZ, maxX, maxZ, minY);
- renderTwoWayYFace(renderblocks, block, icon, x, y, z, minX, minZ, maxX, maxZ, maxY);
- }
- if (axe != 'z') {
- renderTwoWayZFace(renderblocks, block, icon, x, y, z, minX, minY, maxX, maxY, minZ);
- renderTwoWayZFace(renderblocks, block, icon, x, y, z, minX, minY, maxX, maxY, maxZ);
- }
- }
-
- private void renderTwoWayXFace(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int xCoord, int yCoord, int zCoord, float minY, float minZ, float maxY, float maxZ, float x) {
- renderblocks.setRenderBounds(x, minY, minZ, x, maxY, maxZ);
- block.setRenderAxis('x');
- renderblocks.renderStandardBlock(block, xCoord, yCoord, zCoord);
- block.setRenderAxis('a');
- }
-
- private void renderTwoWayYFace(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int xCoord, int yCoord, int zCoord, float minX, float minZ, float maxX, float maxZ, float y) {
- renderblocks.setRenderBounds(minX, y, minZ, maxX, y, maxZ);
- block.setRenderAxis('y');
- renderblocks.renderStandardBlock(block, xCoord, yCoord, zCoord);
- block.setRenderAxis('a');
- }
-
- private void renderTwoWayZFace(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int xCoord, int yCoord, int zCoord, float minX, float minY, float maxX, float maxY, float z) {
- renderblocks.setRenderBounds(minX, minY, z, maxX, maxY, z);
- block.setRenderAxis('z');
- renderblocks.renderStandardBlock(block, xCoord, yCoord, zCoord);
- block.setRenderAxis('a');
- }
-
- public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, BlockGenericPipe block, IPipeRenderState renderState, int x, int y, int z) {
-
- float minSize = Utils.pipeMinPos;
- float maxSize = Utils.pipeMaxPos;
-
- PipeRenderState state = renderState.getRenderState();
- IIconProvider icons = renderState.getPipeIcons();
- if (icons == null)
- return;
-
- boolean west = false;
- boolean east = false;
- boolean down = false;
- boolean up = false;
- boolean north = false;
- boolean south = false;
-
- if (state.pipeConnectionMatrix.isConnected(ForgeDirection.WEST)) {
- state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.WEST));
- renderblocks.setRenderBounds(0.0F, minSize, minSize, minSize, maxSize, maxSize);
- renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'x');
- west = true;
- }
-
- if (state.pipeConnectionMatrix.isConnected(ForgeDirection.EAST)) {
- state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.EAST));
- renderblocks.setRenderBounds(maxSize, minSize, minSize, 1.0F, maxSize, maxSize);
- renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'x');
- east = true;
- }
-
- if (state.pipeConnectionMatrix.isConnected(ForgeDirection.DOWN)) {
- state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.DOWN));
- renderblocks.setRenderBounds(minSize, 0.0F, minSize, maxSize, minSize, maxSize);
- renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'y');
- down = true;
- }
-
- if (state.pipeConnectionMatrix.isConnected(ForgeDirection.UP)) {
- state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UP));
- renderblocks.setRenderBounds(minSize, maxSize, minSize, maxSize, 1.0F, maxSize);
- renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'y');
- up = true;
- }
-
- if (state.pipeConnectionMatrix.isConnected(ForgeDirection.NORTH)) {
- state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.NORTH));
- renderblocks.setRenderBounds(minSize, minSize, 0.0F, maxSize, maxSize, minSize);
- renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'z');
- north = true;
- }
-
- if (state.pipeConnectionMatrix.isConnected(ForgeDirection.SOUTH)) {
- state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.SOUTH));
- renderblocks.setRenderBounds(minSize, minSize, maxSize, maxSize, maxSize, 1.0F);
- renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'z');
- south = true;
- }
-
- state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN));
- renderblocks.setRenderBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
- if (!west)
- renderTwoWayXFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, minSize);
- if (!east)
- renderTwoWayXFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, maxSize);
- if (!down)
- renderTwoWayYFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, minSize);
- if (!up)
- renderTwoWayYFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, maxSize);
- if (!north)
- renderTwoWayZFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, minSize);
- if (!south)
- renderTwoWayZFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, maxSize);
-
- renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
-
- if (state.wireMatrix.hasWire(WireColor.Red)) {
- state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Red));
-
- pipeWireRender(renderblocks, block, state, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMinPos, IPipe.WireColor.Red, x, y, z);
- }
-
- if (state.wireMatrix.hasWire(WireColor.Blue)) {
- state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Blue));
- pipeWireRender(renderblocks, block, state, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos, IPipe.WireColor.Blue, x, y, z);
- }
-
- if (state.wireMatrix.hasWire(WireColor.Green)) {
- state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Green));
- pipeWireRender(renderblocks, block, state, Utils.pipeMaxPos, Utils.pipeMinPos, Utils.pipeMinPos, IPipe.WireColor.Green, x, y, z);
- }
-
- if (state.wireMatrix.hasWire(WireColor.Yellow)) {
- state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Yellow));
- pipeWireRender(renderblocks, block, state, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, IPipe.WireColor.Yellow, x, y, z);
- }
-
- if (state.hasGate()) {
- pipeGateRender(renderblocks, block, state, x, y, z);
- }
-
- pipeFacadeRenderer(renderblocks, block, state, x, y, z);
- pipePlugRenderer(renderblocks, block, state, x, y, z);
-
- }
-
- private void pipeFacadeRenderer(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) {
-
- float zFightOffset = 1F / 4096F;
-
- float[][] zeroState = new float[3][2];
- // X START - END
- zeroState[0][0] = 0.0F - zFightOffset / 2;
- zeroState[0][1] = 1.0F + zFightOffset / 2;
- // Y START - END
- zeroState[1][0] = 0.0F - zFightOffset;
- zeroState[1][1] = facadeThickness;
- // Z START - END
- zeroState[2][0] = 0.0F;
- zeroState[2][1] = 1.0F;
-
- for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
- int facadeId = state.facadeMatrix.getFacadeBlockId(direction);
- if (facadeId != 0) {
- Block renderBlock = Block.blocksList[facadeId];
- int renderMeta = state.facadeMatrix.getFacadeMetaId(direction);
- state.currentTexture = renderBlock.getIcon(direction.ordinal(), renderMeta);
-
- try {
- BlockGenericPipe.facadeRenderColor = Item.itemsList[state.facadeMatrix.getFacadeBlockId(direction)].getColorFromItemStack(new ItemStack(facadeId, 1, renderMeta), 0);
- } catch (Throwable error) {
- }
-
- if (renderBlock.getRenderType() == 31) {
- if ((renderMeta & 12) == 4) {
- renderblocks.uvRotateEast = 1;
- renderblocks.uvRotateWest = 1;
- renderblocks.uvRotateTop = 1;
- renderblocks.uvRotateBottom = 1;
- } else if ((renderMeta & 12) == 8) {
- renderblocks.uvRotateSouth = 1;
- renderblocks.uvRotateNorth = 1;
- }
- }
-
- // Hollow facade
- if (state.pipeConnectionMatrix.isConnected(direction)) {
- float[][] rotated = deepClone(zeroState);
- rotated[2][0] = 0.0F;
- rotated[2][1] = Utils.pipeMinPos;
- rotated[1][0] -= zFightOffset / 2;
- transform(rotated, direction);
- renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
- renderblocks.renderStandardBlock(block, x, y, z);
-
- rotated = deepClone(zeroState);
- rotated[2][0] = Utils.pipeMaxPos;
- rotated[1][0] -= zFightOffset / 2;
- transform(rotated, direction);
- renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
- renderblocks.renderStandardBlock(block, x, y, z);
-
- rotated = deepClone(zeroState);
- rotated[0][0] = 0.0F;
- rotated[0][1] = Utils.pipeMinPos;
- rotated[1][1] -= zFightOffset;
- transform(rotated, direction);
- renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
- renderblocks.renderStandardBlock(block, x, y, z);
-
- rotated = deepClone(zeroState);
- rotated[0][0] = Utils.pipeMaxPos;
- rotated[0][1] = 1F;
- rotated[1][1] -= zFightOffset;
- transform(rotated, direction);
- renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
- renderblocks.renderStandardBlock(block, x, y, z);
- } else { // Solid facade
- float[][] rotated = deepClone(zeroState);
- transform(rotated, direction);
- renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
-
- if (renderBlock.getRenderType() == 31) {
- renderblocks.uvRotateSouth = 0;
- renderblocks.uvRotateEast = 0;
- renderblocks.uvRotateWest = 0;
- renderblocks.uvRotateNorth = 0;
- renderblocks.uvRotateTop = 0;
- renderblocks.uvRotateBottom = 0;
- }
- }
-
- BlockGenericPipe.facadeRenderColor = -1;
- }
-
- // X START - END
- zeroState[0][0] = Utils.pipeMinPos;
- zeroState[0][1] = Utils.pipeMaxPos;
- // Y START - END
- zeroState[1][0] = facadeThickness;
- zeroState[1][1] = Utils.pipeMinPos;
- // Z START - END
- zeroState[2][0] = Utils.pipeMinPos;
- zeroState[2][1] = Utils.pipeMaxPos;
-
- state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe
-
- for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
- if (state.facadeMatrix.getFacadeBlockId(direction) != 0 && !state.pipeConnectionMatrix.isConnected(direction)) {
- float[][] rotated = deepClone(zeroState);
- transform(rotated, direction);
-
- renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
- }
- }
-
- private void pipePlugRenderer(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) {
-
- float zFightOffset = 1F / 4096F;
-
- float[][] zeroState = new float[3][2];
- // X START - END
- zeroState[0][0] = 0.25F + zFightOffset;
- zeroState[0][1] = 0.75F - zFightOffset;
- // Y START - END
- zeroState[1][0] = 0.125F;
- zeroState[1][1] = 0.251F;
- // Z START - END
- zeroState[2][0] = 0.25F + zFightOffset;
- zeroState[2][1] = 0.75F - zFightOffset;
-
- state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe
-
- for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
- if (state.plugMatrix.isConnected(direction)) {
- float[][] rotated = deepClone(zeroState);
- transform(rotated, direction);
-
- renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
- }
-
- // X START - END
- zeroState[0][0] = 0.25F + 0.125F / 2 + zFightOffset;
- zeroState[0][1] = 0.75F - 0.125F / 2 + zFightOffset;
- // Y START - END
- zeroState[1][0] = 0.25F;
- zeroState[1][1] = 0.25F + 0.125F;
- // Z START - END
- zeroState[2][0] = 0.25F + 0.125F / 2;
- zeroState[2][1] = 0.75F - 0.125F / 2;
-
- state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe
-
- for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
- if (state.plugMatrix.isConnected(direction)) {
- float[][] rotated = deepClone(zeroState);
- transform(rotated, direction);
-
- renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
- }
-
- }
-
- private void pipeWireRender(RenderBlocks renderblocks, Block block, PipeRenderState state, float cx, float cy, float cz, IPipe.WireColor color, int x,
- int y, int z) {
-
- float minX = Utils.pipeMinPos;
- float minY = Utils.pipeMinPos;
- float minZ = Utils.pipeMinPos;
-
- float maxX = Utils.pipeMaxPos;
- float maxY = Utils.pipeMaxPos;
- float maxZ = Utils.pipeMaxPos;
-
- boolean foundX = false, foundY = false, foundZ = false;
-
- if (state.wireMatrix.isWireConnected(color, ForgeDirection.WEST)) {
- minX = 0;
- foundX = true;
- }
-
- if (state.wireMatrix.isWireConnected(color, ForgeDirection.EAST)) {
- maxX = 1;
- foundX = true;
- }
-
- if (state.wireMatrix.isWireConnected(color, ForgeDirection.DOWN)) {
- minY = 0;
- foundY = true;
- }
-
- if (state.wireMatrix.isWireConnected(color, ForgeDirection.UP)) {
- maxY = 1;
- foundY = true;
- }
-
- if (state.wireMatrix.isWireConnected(color, ForgeDirection.NORTH)) {
- minZ = 0;
- foundZ = true;
- }
-
- if (state.wireMatrix.isWireConnected(color, ForgeDirection.SOUTH)) {
- maxZ = 1;
- foundZ = true;
- }
-
- boolean center = false;
-
- if (minX == 0 && maxX != 1 && (foundY || foundZ))
- if (cx == Utils.pipeMinPos) {
- maxX = Utils.pipeMinPos;
- } else {
- center = true;
- }
-
- if (minX != 0 && maxX == 1 && (foundY || foundZ))
- if (cx == Utils.pipeMaxPos) {
- minX = Utils.pipeMaxPos;
- } else {
- center = true;
- }
-
- if (minY == 0 && maxY != 1 && (foundX || foundZ))
- if (cy == Utils.pipeMinPos) {
- maxY = Utils.pipeMinPos;
- } else {
- center = true;
- }
-
- if (minY != 0 && maxY == 1 && (foundX || foundZ))
- if (cy == Utils.pipeMaxPos) {
- minY = Utils.pipeMaxPos;
- } else {
- center = true;
- }
-
- if (minZ == 0 && maxZ != 1 && (foundX || foundY))
- if (cz == Utils.pipeMinPos) {
- maxZ = Utils.pipeMinPos;
- } else {
- center = true;
- }
-
- if (minZ != 0 && maxZ == 1 && (foundX || foundY))
- if (cz == Utils.pipeMaxPos) {
- minZ = Utils.pipeMaxPos;
- } else {
- center = true;
- }
-
- boolean found = foundX || foundY || foundZ;
-
- // Z render
-
- if (minZ != Utils.pipeMinPos || maxZ != Utils.pipeMaxPos || !found) {
- renderblocks.setRenderBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, minZ, cx == Utils.pipeMinPos ? cx
- : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, maxZ);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
-
- // X render
-
- if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) {
- renderblocks.setRenderBounds(minX, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, maxX, cy == Utils.pipeMinPos ? cy
- : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
-
- // Y render
-
- if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) {
- renderblocks.setRenderBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, minY, cz == Utils.pipeMinPos ? cz - 0.05F : cz, cx == Utils.pipeMinPos ? cx
- : cx + 0.05F, maxY, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
-
- if (center || !found) {
- renderblocks.setRenderBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz,
- cx == Utils.pipeMinPos ? cx : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
-
- }
-
- private void pipeGateRender(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) {
-
- state.currentTexture = BuildCraftTransport.instance.gateIconProvider.getIcon(state.getGateIconIndex());
-
- float min = Utils.pipeMinPos + 0.05F;
- float max = Utils.pipeMaxPos - 0.05F;
-
- if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) {
- renderblocks.setRenderBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos + 0.001F, max, max);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
-
- if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) {
- renderblocks.setRenderBounds(Utils.pipeMaxPos + 0.001F, min, min, Utils.pipeMaxPos + 0.10F, max, max);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
-
- if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) {
- renderblocks.setRenderBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos + 0.001F, max);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
-
- if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) {
- renderblocks.setRenderBounds(min, Utils.pipeMaxPos + 0.001F, min, max, Utils.pipeMaxPos + 0.10F, max);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
-
- if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) {
- renderblocks.setRenderBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos + 0.001F);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
-
- if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) {
- renderblocks.setRenderBounds(min, min, Utils.pipeMaxPos + 0.001F, max, max, Utils.pipeMaxPos + 0.10F);
- renderblocks.renderStandardBlock(block, x, y, z);
- }
- }
-
- private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) {
- return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) == 0 && !state.plugMatrix.isConnected(direction);
- }
-
- @Override
- public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
- TileEntity tile = world.getBlockTileEntity(x, y, z);
-
- if (tile instanceof IPipeRenderState) {
- IPipeRenderState pipeTile = (IPipeRenderState) tile;
- renderPipe(renderer, world, (BlockGenericPipe) block, pipeTile, x, y, z);
- }
- return true;
- }
-
- @Override
- public boolean shouldRender3DInInventory() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public int getRenderId() {
- return TransportProxy.pipeModel;
- }
-}
diff --git a/common/buildcraft/transport/render/PlugItemRenderer.java b/common/buildcraft/transport/render/PlugItemRenderer.java
index d30a9f40..88602f67 100644
--- a/common/buildcraft/transport/render/PlugItemRenderer.java
+++ b/common/buildcraft/transport/render/PlugItemRenderer.java
@@ -8,15 +8,16 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraftforge.client.IItemRenderer;
+import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON;
import org.lwjgl.opengl.GL11;
-public class PlugItemRenderer implements IItemRenderer{
+public class PlugItemRenderer implements IItemRenderer {
private void renderPlugItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
// Render StructurePipe
Block block = BuildCraftTransport.genericPipeBlock;
Tessellator tessellator = Tessellator.instance;
-
+
block = BuildCraftTransport.genericPipeBlock;
Icon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe
@@ -29,67 +30,74 @@ public class PlugItemRenderer implements IItemRenderer{
tessellator.setNormal(0.0F, -0F, 0.0F);
render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
-
+
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
-
+
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1F);
render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
-
+
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
-
+
tessellator.startDrawingQuads();
tessellator.setNormal(-1F, 0.0F, 0.0F);
render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
-
+
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, textureID);
tessellator.draw();
}
-
+
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
switch (type) {
- case ENTITY:
- return true;
- case EQUIPPED:
- return true;
- case INVENTORY:
- return true;
- default:
- return false;
+ case ENTITY:
+ return true;
+ case EQUIPPED:
+ return true;
+ case EQUIPPED_FIRST_PERSON:
+ return true;
+ case INVENTORY:
+ return true;
+ default:
+ return false;
}
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
- return true;
+ return helper != ItemRendererHelper.BLOCK_3D;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
switch (type) {
- case ENTITY:
- GL11.glScalef(0.50F, 0.50F, 0.50F);
- renderPlugItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F);
- break;
- case EQUIPPED:
- renderPlugItem((RenderBlocks) data[0], item, 0F, 0F, 0f);
- break;
- case INVENTORY:
- GL11.glScalef(1.1F, 1.1F, 1.1F);
- renderPlugItem((RenderBlocks) data[0], item, -0.3f, -0.35f, -0.7f);
- break;
- default:
+ case ENTITY:
+ GL11.glScalef(0.50F, 0.50F, 0.50F);
+ renderPlugItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F);
+ break;
+ case EQUIPPED:
+ case EQUIPPED_FIRST_PERSON:
+ GL11.glRotatef(70, 0, 0, 1F);
+ GL11.glRotatef(-55, 1, 0, 0);
+ GL11.glScalef(2F, 2F, 2F);
+ GL11.glTranslatef(0, -0.6F, -0.4F);
+ renderPlugItem((RenderBlocks) data[0], item, 0F, 0F, 0f);
+ break;
+ case INVENTORY:
+ GL11.glScalef(1.1F, 1.1F, 1.1F);
+ renderPlugItem((RenderBlocks) data[0], item, -0.3f, -0.35f, -0.7f);
+ break;
+ default:
}
}
}
diff --git a/common/buildcraft/transport/render/TileEntityPickupFX.java b/common/buildcraft/transport/render/TileEntityPickupFX.java
index 3a525cbd..d5ac1411 100644
--- a/common/buildcraft/transport/render/TileEntityPickupFX.java
+++ b/common/buildcraft/transport/render/TileEntityPickupFX.java
@@ -11,7 +11,7 @@
*/
package buildcraft.transport.render;
-import buildcraft.core.utils.Utils;
+import buildcraft.transport.utils.TransportUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityFX;
@@ -42,7 +42,7 @@ public class TileEntityPickupFX extends EntityFX
this.entityToPickUp = par2Entity;
this.entityPickingUp = par3Entity;
this.maxAge = 3;
- this.yOffs = Utils.getPipeFloorOf(par2Entity.getEntityItem());
+ this.yOffs = TransportUtils.getPipeFloorOf(par2Entity.getEntityItem());
}
@Override
diff --git a/common/buildcraft/transport/triggers/ActionPowerLimiter.java b/common/buildcraft/transport/triggers/ActionPowerLimiter.java
new file mode 100644
index 00000000..787cfea8
--- /dev/null
+++ b/common/buildcraft/transport/triggers/ActionPowerLimiter.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.transport.triggers;
+
+import buildcraft.core.triggers.BCAction;
+import buildcraft.transport.pipes.PipePowerIron.PowerMode;
+import java.util.Locale;
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.util.Icon;
+
+public class ActionPowerLimiter extends BCAction {
+
+ private Icon icon;
+ public final PowerMode limit;
+
+ public ActionPowerLimiter(int id, PowerMode limit) {
+ super(id, "buildcraft.power.limiter." + limit.name().toLowerCase(Locale.ENGLISH));
+
+ this.limit = limit;
+ }
+
+ @Override
+ public String getDescription() {
+ return limit.maxPower + " MJ/t Limit";
+ }
+
+ @Override
+ public Icon getIcon() {
+ return icon;
+ }
+
+ @Override
+ public void registerIcons(IconRegister iconRegister) {
+ icon = iconRegister.registerIcon("buildcraft:triggers/trigger_limiter_" + limit.name().toLowerCase(Locale.ENGLISH));
+ }
+}
diff --git a/common/buildcraft/transport/triggers/TriggerFilteredBufferInventoryLevel.java b/common/buildcraft/transport/triggers/TriggerFilteredBufferInventoryLevel.java
deleted file mode 100644
index 7cb69aa7..00000000
--- a/common/buildcraft/transport/triggers/TriggerFilteredBufferInventoryLevel.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
- *
- * BuildCraft is distributed under the terms of the Minecraft Mod Public License
- * 1.0, or MMPL. Please check the contents of the license located in
- * http://www.mod-buildcraft.com/MMPL-1.0.txt
- */
-package buildcraft.transport.triggers;
-
-import buildcraft.api.gates.ITriggerParameter;
-import buildcraft.core.triggers.ActionTriggerIconProvider;
-import buildcraft.core.triggers.BCTrigger;
-import buildcraft.transport.TileFilteredBuffer;
-import java.util.Locale;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraftforge.common.ForgeDirection;
-
-public class TriggerFilteredBufferInventoryLevel extends BCTrigger {
-
- public enum State {
-
- Below25, Below50, Below75
- };
- public State state;
-
- public TriggerFilteredBufferInventoryLevel(int legacyId, State state) {
- super(legacyId, "buildcraft.filteredBuffer." + state.name().toLowerCase(Locale.ENGLISH));
-
- this.state = state;
- }
-
- @Override
- public boolean hasParameter() {
- return true;
- }
-
- @Override
- public String getDescription() {
- switch (state) {
- case Below25:
- return "Contains < 25%";
- case Below50:
- return "Contains < 50%";
- default:
- return "Contains < 75%";
- }
- }
-
- @Override
- public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) {
- if (tile instanceof TileFilteredBuffer) {
-
- // A parameter is required
- if (parameter == null) {
- return false;
- }
-
- TileFilteredBuffer filteredBuffer = (TileFilteredBuffer) tile;
- ItemStack searchStack = parameter.getItem();
-
- int foundStackCount = 0;
- int foundItemCount = 0;
-
- IInventory filters = filteredBuffer.getFilters();
-
- for (int i = 0; i < filters.getSizeInventory(); i++) {
- ItemStack filterStack = filters.getStackInSlot(i);
-
- if (filterStack != null && filterStack.isItemEqual(searchStack)) {
- ItemStack foundStack = filteredBuffer.getStackInSlot(i);
-
- if (foundStack != null)
- foundItemCount += foundStack.stackSize;
-
- foundStackCount++;
- }
- }
-
- if (foundStackCount > 0) {
- float percentage = (float) foundItemCount / ((float) foundStackCount * (float) searchStack.getMaxStackSize());
-
- switch (state) {
- case Below25:
- return percentage < 0.25f;
- case Below50:
- return percentage < 0.5f;
- default:
- return percentage < 0.75f;
- }
- }
- }
-
- return false;
- }
-
- @Override
- public int getIconIndex() {
- switch (state) {
- case Below25:
- return ActionTriggerIconProvider.Trigger_Inventory_Below25;
- case Below50:
- return ActionTriggerIconProvider.Trigger_Inventory_Below50;
- default:
- return ActionTriggerIconProvider.Trigger_Inventory_Below75;
- }
- }
-}
diff --git a/common/buildcraft/transport/triggers/TriggerPipeContents.java b/common/buildcraft/transport/triggers/TriggerPipeContents.java
index 4b4bce49..afa4d353 100644
--- a/common/buildcraft/transport/triggers/TriggerPipeContents.java
+++ b/common/buildcraft/transport/triggers/TriggerPipeContents.java
@@ -90,10 +90,10 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
if (kind == Kind.Empty)
return transportItems.items.isEmpty();
else if (kind == Kind.ContainsItems)
- if (parameter != null && parameter.getItem() != null) {
+ if (parameter != null && parameter.getItemStack()!= null) {
for (TravelingItem item : transportItems.items) {
- if (item.getItemStack().itemID == parameter.getItem().itemID
- && item.getItemStack().getItemDamage() == parameter.getItem().getItemDamage())
+ if (item.getItemStack().itemID == parameter.getItemStack().itemID
+ && item.getItemStack().getItemDamage() == parameter.getItemStack().getItemDamage())
return true;
}
} else
@@ -103,8 +103,8 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
FluidStack searchedFluid = null;
- if (parameter != null && parameter.getItem() != null) {
- searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItem());
+ if (parameter != null && parameter.getItemStack() != null) {
+ searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack());
}
if (kind == Kind.Empty) {
@@ -129,14 +129,14 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
switch (kind) {
case Empty:
for (double s : transportPower.displayPower) {
- if (s > 0)
+ if (s > 1e-4)
return false;
}
return true;
case ContainsEnergy:
for (double s : transportPower.displayPower) {
- if (s > 0)
+ if (s > 1e-4)
return true;
}
diff --git a/common/buildcraft/transport/utils/ConnectionMatrix.java b/common/buildcraft/transport/utils/ConnectionMatrix.java
index 778e7ba7..dff1f469 100644
--- a/common/buildcraft/transport/utils/ConnectionMatrix.java
+++ b/common/buildcraft/transport/utils/ConnectionMatrix.java
@@ -3,27 +3,34 @@ package buildcraft.transport.utils;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-import java.util.BitSet;
import net.minecraftforge.common.ForgeDirection;
public class ConnectionMatrix {
-
- private final BitSet _connected = new BitSet(ForgeDirection.VALID_DIRECTIONS.length);
- private final BitSetCodec _bitSetCodec = new BitSetCodec();
-
+ private int mask = 0;
private boolean dirty = false;
public boolean isConnected(ForgeDirection direction) {
- return _connected.get(direction.ordinal());
+ // test if the direction.ordinal()'th bit of mask is set
+ return (mask & (1 << direction.ordinal())) != 0;
}
public void setConnected(ForgeDirection direction, boolean value) {
- if (_connected.get(direction.ordinal()) != value){
- _connected.set(direction.ordinal(), value);
+ if (isConnected(direction) != value) {
+ // invert the direction.ordinal()'th bit of mask
+ mask ^= 1 << direction.ordinal();
dirty = true;
}
}
+ /**
+ * Return a mask representing the connectivity for all sides.
+ *
+ * @return mask in ForgeDirection order, least significant bit = first entry
+ */
+ public int getMask() {
+ return mask;
+ }
+
public boolean isDirty() {
return dirty;
}
@@ -33,10 +40,15 @@ public class ConnectionMatrix {
}
public void writeData(DataOutputStream data) throws IOException {
- data.writeByte(_bitSetCodec.encode(_connected));
+ data.writeByte(mask);
}
public void readData(DataInputStream data) throws IOException {
- _bitSetCodec.decode(data.readByte(), _connected);
+ byte newMask = data.readByte();
+
+ if (newMask != mask) {
+ mask = newMask;
+ dirty = true;
+ }
}
}
diff --git a/common/buildcraft/transport/utils/FacadeMatrix.java b/common/buildcraft/transport/utils/FacadeMatrix.java
index 086eecc5..b4ce11d4 100644
--- a/common/buildcraft/transport/utils/FacadeMatrix.java
+++ b/common/buildcraft/transport/utils/FacadeMatrix.java
@@ -6,27 +6,27 @@ import java.io.IOException;
import net.minecraftforge.common.ForgeDirection;
public class FacadeMatrix {
+
private final int[] _blockIds = new int[ForgeDirection.VALID_DIRECTIONS.length];
private final int[] _blockMetas = new int[ForgeDirection.VALID_DIRECTIONS.length];
-
private boolean dirty = false;
public FacadeMatrix() {
}
- public void setFacade(ForgeDirection direction, int blockId, int blockMeta){
- if (_blockIds[direction.ordinal()] != blockId || _blockMetas[direction.ordinal()] != blockMeta){
+ public void setFacade(ForgeDirection direction, int blockId, int blockMeta) {
+ if (_blockIds[direction.ordinal()] != blockId || _blockMetas[direction.ordinal()] != blockMeta) {
_blockIds[direction.ordinal()] = blockId;
_blockMetas[direction.ordinal()] = blockMeta;
dirty = true;
}
}
-
- public int getFacadeBlockId(ForgeDirection direction){
+
+ public int getFacadeBlockId(ForgeDirection direction) {
return _blockIds[direction.ordinal()];
}
-
- public int getFacadeMetaId(ForgeDirection direction){
+
+ public int getFacadeMetaId(ForgeDirection direction) {
return _blockMetas[direction.ordinal()];
}
@@ -38,17 +38,25 @@ public class FacadeMatrix {
dirty = false;
}
- public void readData(DataInputStream data) throws IOException {
- for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
- _blockIds[i] = data.readShort();
- _blockMetas[i] = data.readByte();
- }
- }
-
public void writeData(DataOutputStream data) throws IOException {
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
data.writeShort(_blockIds[i]);
data.writeByte(_blockMetas[i]);
}
}
+
+ public void readData(DataInputStream data) throws IOException {
+ for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
+ short id = data.readShort();
+ if (_blockIds[i] != id) {
+ _blockIds[i] = id;
+ dirty = true;
+ }
+ byte meta = data.readByte();
+ if (_blockMetas[i] != meta) {
+ _blockMetas[i] = meta;
+ dirty = true;
+ }
+ }
+ }
}
diff --git a/common/buildcraft/transport/utils/TextureMatrix.java b/common/buildcraft/transport/utils/TextureMatrix.java
index eb535a9b..2da1e5d7 100644
--- a/common/buildcraft/transport/utils/TextureMatrix.java
+++ b/common/buildcraft/transport/utils/TextureMatrix.java
@@ -8,7 +8,6 @@ import net.minecraftforge.common.ForgeDirection;
public class TextureMatrix {
private final int[] _iconIndexes = new int[7];
-
private boolean dirty = false;
public int getTextureIndex(ForgeDirection direction) {
@@ -38,7 +37,11 @@ public class TextureMatrix {
public void readData(DataInputStream data) throws IOException {
for (int i = 0; i < _iconIndexes.length; i++) {
- _iconIndexes[i] = data.readByte();
+ int icon = data.readByte();
+ if (_iconIndexes[i] != icon) {
+ _iconIndexes[i] = icon;
+ dirty = true;
+ }
}
}
}
diff --git a/common/buildcraft/transport/utils/TransportUtils.java b/common/buildcraft/transport/utils/TransportUtils.java
new file mode 100644
index 00000000..fb601108
--- /dev/null
+++ b/common/buildcraft/transport/utils/TransportUtils.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.transport.utils;
+
+import buildcraft.core.CoreConstants;
+import net.minecraft.item.ItemStack;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public class TransportUtils {
+
+ /**
+ * Depending on the kind of item in the pipe, set the floor at a different
+ * level to optimize graphical aspect.
+ */
+ public static float getPipeFloorOf(ItemStack item) {
+ return CoreConstants.PIPE_MIN_POS;
+ }
+}