Merge master into builder

This commit is contained in:
CovertJaguar 2013-12-03 18:41:13 -08:00
commit b788dfde6a
151 changed files with 3029 additions and 1637 deletions

View file

@ -16,7 +16,6 @@ a problem that might have fixed been already. Such things makes for very grumpy
less time coding and more time doing stuff that makes them less grumpy. 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 <b>not</b> a mcpc+ server. * If the issues occurs on a server, be sure it's a vanilla forge server and <b>not</b> 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 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 #### Frequently reported
* java.lang.AbstractMethodError - Incompatibility between BC/Forge/Mod using BC API. Usually not a BC issue * java.lang.AbstractMethodError - Incompatibility between BC/Forge/Mod using BC API. Usually not a BC issue

View file

@ -130,7 +130,7 @@
</target> </target>
<target name="copy-src" depends="clean-src,initialize-version"> <target name="copy-src" depends="clean-src,initialize-version">
<!-- Copy sources --> <!-- Copy sources -->
<copy todir="${mcpsrc.dir}/minecraft" verbose="true"> <copy todir="${mcpsrc.dir}/minecraft" verbose="false">
<fileset dir="${src.dir}/common"/> <fileset dir="${src.dir}/common"/>
<filterset> <filterset>
<filter token="VERSION" value="${project.complete.version}" /> <filter token="VERSION" value="${project.complete.version}" />
@ -169,10 +169,30 @@
<!-- Reobfuscate --> <!-- Reobfuscate -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows"> <exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c reobfuscate_srg.bat"/> <arg line="/c reobfuscate_srg.bat"/>
<redirector>
<outputfilterchain>
<linecontains negate="true">
<contains value="> New"/>
</linecontains>
<linecontains negate="true">
<contains value="> Outputted"/>
</linecontains>
</outputfilterchain>
</redirector>
</exec> </exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix"> <exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="reobfuscate_srg.sh"/> <arg value="reobfuscate_srg.sh"/>
<redirector>
<outputfilterchain>
<linecontains negate="true">
<contains value="> New"/>
</linecontains>
<linecontains negate="true">
<contains value="> Outputted"/>
</linecontains>
</outputfilterchain>
</redirector>
</exec> </exec>
<!-- Copy classes --> <!-- Copy classes -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 B

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

View file

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Sun Oct 27 08:22:33 PDT 2013 #Fri Nov 29 16:00:09 PST 2013
build.number=49 build.number=50

View file

@ -0,0 +1,18 @@
#4.2.0
- New: Added Emzuli Pipe, a Gate controlled Extraction Pipe. (SandGrainOne/CovertJaguar)
- Change: Fillers no longer have a "crafting" grid, and can be controlled via Gates. (CovertJaguar)
- Change: Oil Springs produce 4x as much Oil as before. (CovertJaguar)
- Change: Pumps can be disabled by applying a Redstone signal. (CovertJaguar)
- Change: Allow draining of Fuel from Combustion Engines. (CovertJaguar)
- Change: Renamed Lapis Pipe to Lazuli Pipe. (CovertJaguar)
- Fix: Register all remaining Items properly with FML so that they will survive a 1.6->1.7 world upgrade. (CovertJaguar)
- Fix: Players can now see pipes placed by other players. (CovertJaguar)
- Fix: Block Harvesting now calls the appropriate new Forge Events. (DemoXin)
- Fix: Fixed Oil and Fuel Fluid localizations. (CovertJaguar)
- Fix: Diazuli Pipe should now better handle overflow situations similar to how the Diamond Pipe works. (CovertJaguar)
- API: Added API package and dependency information for new FML features. Should reduce API conflicts going forward. (cpw)
- API: Rewrote Filler Pattern API. (CovertJaguar)
- API: Added a new function to the Assembly Table recipe API that supports the Ore Dictionary. (taelnia/CovertJaguar)
- API: Moved ILaserTarget to the API so that addons can now create blocks that accept power from Lasers. (CovertJaguar)

View file

@ -2,6 +2,34 @@
chat.pipe.power.iron.mode=Switched to %d MJ/t limit chat.pipe.power.iron.mode=Switched to %d MJ/t limit
color.black=Black
color.blue=Blue
color.brown=Brown
color.cyan=Cyan
color.gray=Gray
color.green=Green
color.light.blue=Light Blue
color.light.gray=Light Gray
color.lime=Lime
color.magenta=Magenta
color.orange=Orange
color.pink=Pink
color.purple=Purple
color.red=Red
color.white=White
color.yellow=Yellow
fillerpattern.clear=Clear
fillerpattern.fill=Fill
fillerpattern.flatten=Flatten
fillerpattern.horizon=Horizon
fillerpattern.pyramid=Pyramid
fillerpattern.stairs=Stairs
fillerpattern.box=Box
fluid.oil=Oil
fluid.fuel=Fuel
gate.pipe.empty=Pipe Empty gate.pipe.empty=Pipe Empty
gate.pipe.containsItems=Items Traversing gate.pipe.containsItems=Items Traversing
gate.pipe.containsFluids=Fluid Traversing gate.pipe.containsFluids=Fluid Traversing
@ -12,6 +40,8 @@ gate.engine.blue=Engine Blue
gate.engine.green=Engine Green gate.engine.green=Engine Green
gate.engine.yellow=Engine Yellow gate.engine.yellow=Engine Yellow
gate.engine.red=Engine Red gate.engine.red=Engine Red
gate.pipe.item.color=Paint Items %s
gui.building.resources=Building Resources gui.building.resources=Building Resources
gui.del=Del gui.del=Del
gui.filling.resources=Filling Resources gui.filling.resources=Filling Resources
@ -30,6 +60,10 @@ gui.pipes.emerald.blocking=Blocking
gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing
gui.pipes.emerald.nonblocking=Non Blocking gui.pipes.emerald.nonblocking=Non Blocking
gui.pipes.emerald.nonblocking.tip=Extraction continues with the next element in filter if one element is missing gui.pipes.emerald.nonblocking.tip=Extraction continues with the next element in filter if one element is missing
gui.pipes.emzuli.title=Extraction Presets
gui.pipes.emzuli.paint=Paint Items %s
gui.pipes.emzuli.nopaint=Don't Paint Items
item.bucketFuel=Fuel Bucket item.bucketFuel=Fuel Bucket
item.bucketOil=Oil Bucket item.bucketOil=Oil Bucket
item.woodenGearItem=Wood Gear item.woodenGearItem=Wood Gear
@ -73,8 +107,9 @@ item.PipeItemsGold=Golden Transport Pipe
item.PipeItemsDiamond=Diamond Transport Pipe item.PipeItemsDiamond=Diamond Transport Pipe
item.PipeItemsObsidian=Obsidian Transport Pipe item.PipeItemsObsidian=Obsidian Transport Pipe
item.PipeItemsEmerald=Emerald Transport Pipe item.PipeItemsEmerald=Emerald Transport Pipe
item.PipeItemsLapis=Lapis Transport Pipe item.PipeItemsLapis=Lazuli Transport Pipe
item.PipeItemsDaizuli=Daizuli Transport Pipe item.PipeItemsDaizuli=Daizuli Transport Pipe
item.PipeItemsEmzuli=Emzuli Transport Pipe
item.PipeFluidsWood=Wooden Fluid Pipe item.PipeFluidsWood=Wooden Fluid Pipe
item.PipeFluidsCobblestone=Cobblestone Fluid Pipe item.PipeFluidsCobblestone=Cobblestone Fluid Pipe
item.PipeFluidsStone=Stone Fluid Pipe item.PipeFluidsStone=Stone Fluid Pipe
@ -149,6 +184,7 @@ tip.PipeItemsSandstone=Only connects to other pipes
tip.PipeItemsStone=Basic pipe, medium drag\nWon't connect to Cobblestone or Quartz tip.PipeItemsStone=Basic pipe, medium drag\nWon't connect to Cobblestone or Quartz
tip.PipeItemsVoid=Destroys items tip.PipeItemsVoid=Destroys items
tip.PipeItemsWood=Extraction pipe tip.PipeItemsWood=Extraction pipe
tip.PipeItemsEmzuli=Gate controlled extraction pipe
tip.PipePowerWood=Power Input Pipe tip.PipePowerWood=Power Input Pipe
tip.PipePowerIron=Selectable Limiter Pipe tip.PipePowerIron=Selectable Limiter Pipe
tip.PipeStructureCobblestone=Support pipe tip.PipeStructureCobblestone=Support pipe

View file

@ -27,23 +27,23 @@ import buildcraft.api.bptblocks.BptBlockSign;
import buildcraft.api.bptblocks.BptBlockStairs; import buildcraft.api.bptblocks.BptBlockStairs;
import buildcraft.api.bptblocks.BptBlockWallSide; import buildcraft.api.bptblocks.BptBlockWallSide;
import buildcraft.api.filler.FillerManager; import buildcraft.api.filler.FillerManager;
import buildcraft.api.filler.IFillerPattern;
import buildcraft.api.gates.ActionManager;
import buildcraft.builders.BlockArchitect; import buildcraft.builders.BlockArchitect;
import buildcraft.builders.BlockBlueprintLibrary; import buildcraft.builders.BlockBlueprintLibrary;
import buildcraft.builders.BlockBuilder; import buildcraft.builders.BlockBuilder;
import buildcraft.builders.BlockFiller; import buildcraft.builders.BlockFiller;
import buildcraft.builders.BlockMarker; import buildcraft.builders.BlockMarker;
import buildcraft.builders.BlockPathMarker; import buildcraft.builders.BlockPathMarker;
import buildcraft.builders.BptBlockFiller;
import buildcraft.builders.BuilderProxyClient;
import buildcraft.builders.EventHandlerBuilders; import buildcraft.builders.EventHandlerBuilders;
import buildcraft.builders.FillerFillAll; import buildcraft.builders.filler.pattern.PatternFill;
import buildcraft.builders.FillerFillPyramid; import buildcraft.builders.filler.pattern.PatternPyramid;
import buildcraft.builders.FillerFillStairs; import buildcraft.builders.filler.pattern.PatternStairs;
import buildcraft.builders.FillerFillWalls; import buildcraft.builders.filler.pattern.PatternBox;
import buildcraft.builders.FillerFlattener; import buildcraft.builders.filler.pattern.PatternFlatten;
import buildcraft.builders.FillerHorizon; import buildcraft.builders.filler.pattern.PatternHorizon;
import buildcraft.builders.FillerRegistry; import buildcraft.builders.filler.FillerRegistry;
import buildcraft.builders.FillerRemover; import buildcraft.builders.filler.pattern.PatternClear;
import buildcraft.builders.GuiHandler; import buildcraft.builders.GuiHandler;
import buildcraft.builders.IBuilderHook; import buildcraft.builders.IBuilderHook;
import buildcraft.builders.ItemBlueprintStandard; import buildcraft.builders.ItemBlueprintStandard;
@ -54,13 +54,17 @@ import buildcraft.builders.TileBuilder;
import buildcraft.builders.TileFiller; import buildcraft.builders.TileFiller;
import buildcraft.builders.TileMarker; import buildcraft.builders.TileMarker;
import buildcraft.builders.TilePathMarker; import buildcraft.builders.TilePathMarker;
import buildcraft.builders.filler.pattern.FillerPattern;
import buildcraft.builders.network.PacketHandlerBuilders; import buildcraft.builders.network.PacketHandlerBuilders;
import buildcraft.builders.triggers.ActionFiller;
import buildcraft.builders.triggers.BuildersActionProvider;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms; import buildcraft.core.InterModComms;
import buildcraft.core.Version; import buildcraft.core.Version;
import buildcraft.core.blueprints.BptPlayerIndex; import buildcraft.core.blueprints.BptPlayerIndex;
import buildcraft.core.blueprints.BptRootIndex; import buildcraft.core.blueprints.BptRootIndex;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.BCLog;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;
@ -78,7 +82,6 @@ import java.io.IOException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.TreeMap; import java.util.TreeMap;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -105,6 +108,7 @@ public class BuildCraftBuilders {
public static boolean fillerDestroy; public static boolean fillerDestroy;
public static int fillerLifespanTough; public static int fillerLifespanTough;
public static int fillerLifespanNormal; public static int fillerLifespanNormal;
public static ActionFiller[] fillerActions;
private static BptRootIndex rootBptIndex; private static BptRootIndex rootBptIndex;
public static TreeMap<String, BptPlayerIndex> playerLibrary = new TreeMap<String, BptPlayerIndex>(); public static TreeMap<String, BptPlayerIndex> playerLibrary = new TreeMap<String, BptPlayerIndex>();
private static LinkedList<IBuilderHook> hooks = new LinkedList<IBuilderHook>(); private static LinkedList<IBuilderHook> hooks = new LinkedList<IBuilderHook>();
@ -112,10 +116,7 @@ public class BuildCraftBuilders {
public static BuildCraftBuilders instance; public static BuildCraftBuilders instance;
@EventHandler @EventHandler
public void load(FMLInitializationEvent evt) { public void init(FMLInitializationEvent evt) {
// Create filler registry
FillerManager.registry = new FillerRegistry();
// Register gui handler // Register gui handler
NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler()); NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());
@ -208,7 +209,6 @@ public class BuildCraftBuilders {
new BptBlockWallSide(markerBlock.blockID); new BptBlockWallSide(markerBlock.blockID);
new BptBlockWallSide(pathMarkerBlock.blockID); new BptBlockWallSide(pathMarkerBlock.blockID);
new BptBlockFiller(fillerBlock.blockID);
if (BuildCraftCore.loadDefaultRecipes) { if (BuildCraftCore.loadDefaultRecipes) {
loadRecipes(); loadRecipes();
@ -217,7 +217,7 @@ public class BuildCraftBuilders {
} }
@EventHandler @EventHandler
public void initialize(FMLPreInitializationEvent evt) { public void preInit(FMLPreInitializationEvent evt) {
Property templateItemId = BuildCraftCore.mainConfiguration.getItem("templateItem.id", DefaultProps.TEMPLATE_ITEM_ID); Property templateItemId = BuildCraftCore.mainConfiguration.getItem("templateItem.id", DefaultProps.TEMPLATE_ITEM_ID);
Property blueprintItemId = BuildCraftCore.mainConfiguration.getItem("blueprintItem.id", DefaultProps.BLUEPRINT_ITEM_ID); Property blueprintItemId = BuildCraftCore.mainConfiguration.getItem("blueprintItem.id", DefaultProps.BLUEPRINT_ITEM_ID);
Property markerId = BuildCraftCore.mainConfiguration.getBlock("marker.id", DefaultProps.MARKER_ID); Property markerId = BuildCraftCore.mainConfiguration.getBlock("marker.id", DefaultProps.MARKER_ID);
@ -286,19 +286,30 @@ public class BuildCraftBuilders {
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
// public static final Block music; // Create filler registry
// public static final Block cloth; try {
// public static final Block tilledField; FillerManager.registry = new FillerRegistry();
// public static final BlockPortal portal;
// public static final Block trapdoor;
// STANDARD BLOCKS // INIT FILLER PATTERNS
FillerManager.registry.addPattern(PatternFill.INSTANCE);
FillerManager.registry.addPattern(new PatternFlatten());
FillerManager.registry.addPattern(new PatternHorizon());
FillerManager.registry.addPattern(new PatternClear());
FillerManager.registry.addPattern(new PatternBox());
FillerManager.registry.addPattern(new PatternPyramid());
FillerManager.registry.addPattern(new PatternStairs());
} catch (Error error) {
BCLog.logErrorAPI("Buildcraft", error, IFillerPattern.class);
throw error;
}
ActionManager.registerActionProvider(new BuildersActionProvider());
} }
public static void loadRecipes() { public static void loadRecipes() {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(templateItem, 1), new Object[]{"ppp", "pip", "ppp", 'i', // CoreProxy.proxy.addCraftingRecipe(new ItemStack(templateItem, 1), new Object[]{"ppp", "pip", "ppp", 'i',
new ItemStack(Item.dyePowder, 1, 0), 'p', Item.paper}); // new ItemStack(Item.dyePowder, 1, 0), 'p', Item.paper});
CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), new Object[]{"ppp", "pip", "ppp", 'i', CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), new Object[]{"ppp", "pip", "ppp", 'i',
new ItemStack(Item.dyePowder, 1, 4), 'p', Item.paper}); new ItemStack(Item.dyePowder, 1, 4), 'p', Item.paper});
@ -306,34 +317,24 @@ public class BuildCraftBuilders {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(markerBlock, 1), new Object[]{"l ", "r ", 'l', CoreProxy.proxy.addCraftingRecipe(new ItemStack(markerBlock, 1), new Object[]{"l ", "r ", 'l',
new ItemStack(Item.dyePowder, 1, 4), 'r', Block.torchRedstoneActive}); new ItemStack(Item.dyePowder, 1, 4), 'r', Block.torchRedstoneActive});
CoreProxy.proxy.addCraftingRecipe(new ItemStack(pathMarkerBlock, 1), new Object[]{"l ", "r ", 'l', // CoreProxy.proxy.addCraftingRecipe(new ItemStack(pathMarkerBlock, 1), new Object[]{"l ", "r ", 'l',
new ItemStack(Item.dyePowder, 1, 2), 'r', Block.torchRedstoneActive}); // new ItemStack(Item.dyePowder, 1, 2), 'r', Block.torchRedstoneActive});
CoreProxy.proxy.addCraftingRecipe(new ItemStack(fillerBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b', 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), new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11),
'c', Block.workbench, 'g', BuildCraftCore.goldGearItem, 'C', Block.chest}); 'c', Block.workbench, 'g', BuildCraftCore.goldGearItem, 'C', Block.chest});
CoreProxy.proxy.addCraftingRecipe(new ItemStack(builderBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b', // 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), // new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11),
'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C', Block.chest}); // 'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C', Block.chest});
CoreProxy.proxy.addCraftingRecipe(new ItemStack(architectBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b', // 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), // new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11),
'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C', // 'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C',
new ItemStack(templateItem, 1)}); // new ItemStack(templateItem, 1)});
CoreProxy.proxy.addCraftingRecipe(new ItemStack(libraryBlock, 1), new Object[]{"bbb", "bBb", "bbb", 'b', // CoreProxy.proxy.addCraftingRecipe(new ItemStack(libraryBlock, 1), new Object[]{"bbb", "bBb", "bbb", 'b',
new ItemStack(blueprintItem), 'B', Block.bookShelf}); // new ItemStack(blueprintItem), 'B', Block.bookShelf});
// / INIT FILLER PATTERNS
FillerManager.registry.addRecipe(new FillerFillAll(), new Object[]{"bbb", "bbb", "bbb", 'g', Block.glass, 'b', Block.brick});
FillerManager.registry.addRecipe(new FillerFlattener(), new Object[]{"ggg", "bbb", "bbb", 'g', Block.glass, 'b', Block.brick});
FillerManager.registry.addRecipe(new FillerHorizon(), new Object[]{"ggg", "ggg", "bbb", 'g', Block.glass, 'b', Block.brick});
FillerManager.registry.addRecipe(new FillerRemover(), new Object[]{"ggg", "ggg", "ggg", 'g', Block.glass, 'b', Block.brick});
FillerManager.registry.addRecipe(new FillerFillWalls(), new Object[]{"bbb", "b b", "bbb", 'g', Block.glass, 'b', Block.brick});
FillerManager.registry.addRecipe(new FillerFillPyramid(), new Object[]{" ", " b ", "bbb", 'g', Block.glass, 'b', Block.brick});
FillerManager.registry.addRecipe(new FillerFillStairs(), new Object[]{" b", " bb", "bbb", 'g', Block.glass, 'b', Block.brick});
} }
@EventHandler @EventHandler
@ -400,14 +401,9 @@ public class BuildCraftBuilders {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void loadTextures(TextureStitchEvent.Pre evt) { public void loadTextures(TextureStitchEvent.Pre evt) {
if (evt.map.textureType == 0) { if (evt.map.textureType == 0) {
TextureMap terrainMap = evt.map; for (FillerPattern pattern : FillerPattern.patterns) {
BuilderProxyClient.fillerFillAllTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/fillAll"); pattern.registerIcon(evt.map);
BuilderProxyClient.fillerClearTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/clear"); }
BuilderProxyClient.fillerWallsTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/walls");
BuilderProxyClient.fillerStairsTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/stairs");
BuilderProxyClient.fillerFlattenTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/flatten");
BuilderProxyClient.fillerHorizonTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/horizon");
BuilderProxyClient.fillerPyramidTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/pyramid");
} }
} }
} }

View file

@ -81,7 +81,7 @@ import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6,1.7)", dependencies = "required-after:Forge@[9.10.0.800,)") @Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6.4,1.7)", dependencies = "required-after:Forge@[9.11.1.953,)")
@NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true) @NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true)
public class BuildCraftCore { public class BuildCraftCore {
public static enum RenderMode { public static enum RenderMode {

View file

@ -15,6 +15,7 @@ import buildcraft.core.BlockSpring;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms; import buildcraft.core.InterModComms;
import buildcraft.core.Version; import buildcraft.core.Version;
import buildcraft.core.fluids.BCFluid;
import buildcraft.core.network.PacketHandler; import buildcraft.core.network.PacketHandler;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.BCTrigger; import buildcraft.core.triggers.BCTrigger;
@ -144,11 +145,12 @@ public class BuildCraftEnergy {
// Oil and fuel // Oil and fuel
buildcraftFluidOil = new Fluid("oil").setDensity(800).setViscosity(1500); buildcraftFluidOil = new BCFluid("oil").setDensity(800).setViscosity(1500);
FluidRegistry.registerFluid(buildcraftFluidOil); FluidRegistry.registerFluid(buildcraftFluidOil);
fluidOil = FluidRegistry.getFluid("oil"); fluidOil = FluidRegistry.getFluid("oil");
buildcraftFluidFuel = new Fluid("fuel"); buildcraftFluidFuel = new BCFluid("fuel");
FluidRegistry.registerFluid(buildcraftFluidFuel); FluidRegistry.registerFluid(buildcraftFluidFuel);
fluidFuel = FluidRegistry.getFluid("fuel"); fluidFuel = FluidRegistry.getFluid("fuel");

View file

@ -8,6 +8,7 @@
package buildcraft; package buildcraft;
import buildcraft.api.core.IIconProvider; import buildcraft.api.core.IIconProvider;
import buildcraft.api.filler.IFillerPattern;
import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.ActionManager;
import buildcraft.api.recipes.AssemblyRecipe; import buildcraft.api.recipes.AssemblyRecipe;
import buildcraft.api.transport.IExtractionHandler; import buildcraft.api.transport.IExtractionHandler;
@ -20,6 +21,7 @@ import buildcraft.core.Version;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.BCAction; import buildcraft.core.triggers.BCAction;
import buildcraft.core.triggers.BCTrigger; import buildcraft.core.triggers.BCTrigger;
import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.EnumColor; import buildcraft.core.utils.EnumColor;
import buildcraft.transport.BlockFilteredBuffer; import buildcraft.transport.BlockFilteredBuffer;
import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.BlockGenericPipe;
@ -54,6 +56,7 @@ import buildcraft.transport.pipes.PipeItemsDiamond;
import buildcraft.transport.pipes.PipeItemsEmerald; import buildcraft.transport.pipes.PipeItemsEmerald;
import buildcraft.transport.pipes.PipeItemsGold; import buildcraft.transport.pipes.PipeItemsGold;
import buildcraft.transport.pipes.PipeItemsIron; import buildcraft.transport.pipes.PipeItemsIron;
import buildcraft.transport.pipes.PipeItemsEmzuli;
import buildcraft.transport.pipes.PipeItemsLapis; import buildcraft.transport.pipes.PipeItemsLapis;
import buildcraft.transport.pipes.PipeItemsObsidian; import buildcraft.transport.pipes.PipeItemsObsidian;
import buildcraft.transport.pipes.PipeItemsQuartz; import buildcraft.transport.pipes.PipeItemsQuartz;
@ -71,6 +74,7 @@ import buildcraft.transport.pipes.PipePowerStone;
import buildcraft.transport.pipes.PipePowerWood; import buildcraft.transport.pipes.PipePowerWood;
import buildcraft.transport.pipes.PipeStructureCobblestone; import buildcraft.transport.pipes.PipeStructureCobblestone;
import buildcraft.transport.triggers.ActionEnergyPulser; import buildcraft.transport.triggers.ActionEnergyPulser;
import buildcraft.transport.triggers.ActionExtractionPreset;
import buildcraft.transport.triggers.ActionPipeColor; import buildcraft.transport.triggers.ActionPipeColor;
import buildcraft.transport.triggers.ActionPipeDirection; import buildcraft.transport.triggers.ActionPipeDirection;
import buildcraft.transport.triggers.ActionPowerLimiter; import buildcraft.transport.triggers.ActionPowerLimiter;
@ -126,6 +130,7 @@ public class BuildCraftTransport {
public static Item pipeItemsDaizuli; public static Item pipeItemsDaizuli;
public static Item pipeItemsVoid; public static Item pipeItemsVoid;
public static Item pipeItemsSandstone; public static Item pipeItemsSandstone;
public static Item pipeItemsEmzuli;
public static Item pipeFluidsWood; public static Item pipeFluidsWood;
public static Item pipeFluidsCobblestone; public static Item pipeFluidsCobblestone;
public static Item pipeFluidsStone; public static Item pipeFluidsStone;
@ -170,11 +175,15 @@ public class BuildCraftTransport {
public static BCAction[] actionPipeColor = new BCAction[16]; public static BCAction[] actionPipeColor = new BCAction[16];
public static BCAction[] actionPipeDirection = new BCAction[16]; public static BCAction[] actionPipeDirection = new BCAction[16];
public static BCAction[] actionPowerLimiter = new BCAction[7]; public static BCAction[] actionPowerLimiter = new BCAction[7];
@Instance("BuildCraft|Transport") public static BCAction actionExtractionPresetRed = new ActionExtractionPreset(-1, EnumColor.RED);
public static BuildCraftTransport instance; public static BCAction actionExtractionPresetBlue = new ActionExtractionPreset(-1, EnumColor.BLUE);
public static BCAction actionExtractionPresetGreen = new ActionExtractionPreset(-1, EnumColor.GREEN);
public static BCAction actionExtractionPresetYellow = new ActionExtractionPreset(-1, EnumColor.YELLOW);
public IIconProvider pipeIconProvider = new PipeIconProvider(); public IIconProvider pipeIconProvider = new PipeIconProvider();
public IIconProvider gateIconProvider = new GateIconProvider(); public IIconProvider gateIconProvider = new GateIconProvider();
public IIconProvider wireIconProvider = new WireIconProvider(); public IIconProvider wireIconProvider = new WireIconProvider();
@Instance("BuildCraft|Transport")
public static BuildCraftTransport instance;
private static class PipeRecipe { private static class PipeRecipe {
@ -266,11 +275,10 @@ public class BuildCraftTransport {
pipeWaterproof.setUnlocalizedName("pipeWaterproof"); pipeWaterproof.setUnlocalizedName("pipeWaterproof");
LanguageRegistry.addName(pipeWaterproof, "Pipe Sealant"); LanguageRegistry.addName(pipeWaterproof, "Pipe Sealant");
CoreProxy.proxy.registerItem(pipeWaterproof); CoreProxy.proxy.registerItem(pipeWaterproof);
genericPipeBlock = new BlockGenericPipe(genericPipeId.getInt()); genericPipeBlock = new BlockGenericPipe(genericPipeId.getInt());
CoreProxy.proxy.registerBlock(genericPipeBlock.setUnlocalizedName("pipeBlock"), ItemBlock.class); 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"); 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); pipeItemsEmerald = buildPipe(DefaultProps.PIPE_ITEMS_EMERALD_ID, PipeItemsEmerald.class, "Emerald Transport Pipe", Item.emerald, Block.glass, Item.emerald);
pipeItemsCobblestone = buildPipe(DefaultProps.PIPE_ITEMS_COBBLESTONE_ID, PipeItemsCobblestone.class, "Cobblestone Transport Pipe", "cobblestone", Block.glass, "cobblestone"); pipeItemsCobblestone = buildPipe(DefaultProps.PIPE_ITEMS_COBBLESTONE_ID, PipeItemsCobblestone.class, "Cobblestone Transport Pipe", "cobblestone", Block.glass, "cobblestone");
@ -284,6 +292,7 @@ public class BuildCraftTransport {
pipeItemsDaizuli = buildPipe(DefaultProps.PIPE_ITEMS_DAIZULI_ID, PipeItemsDaizuli.class, "Daizuli Transport Pipe", Block.blockLapis, Block.glass, Item.diamond); pipeItemsDaizuli = buildPipe(DefaultProps.PIPE_ITEMS_DAIZULI_ID, PipeItemsDaizuli.class, "Daizuli Transport Pipe", Block.blockLapis, Block.glass, Item.diamond);
pipeItemsSandstone = buildPipe(DefaultProps.PIPE_ITEMS_SANDSTONE_ID, PipeItemsSandstone.class, "Sandstone Transport Pipe", Block.sandStone, Block.glass, Block.sandStone); pipeItemsSandstone = buildPipe(DefaultProps.PIPE_ITEMS_SANDSTONE_ID, PipeItemsSandstone.class, "Sandstone Transport Pipe", Block.sandStone, Block.glass, Block.sandStone);
pipeItemsVoid = buildPipe(DefaultProps.PIPE_ITEMS_VOID_ID, PipeItemsVoid.class, "Void Transport Pipe", "dyeBlack", Block.glass, Item.redstone); pipeItemsVoid = buildPipe(DefaultProps.PIPE_ITEMS_VOID_ID, PipeItemsVoid.class, "Void Transport Pipe", "dyeBlack", Block.glass, Item.redstone);
pipeItemsEmzuli = buildPipe(DefaultProps.PIPE_ITEMS_EMZULI_ID, PipeItemsEmzuli.class, "Emzuli Transport Pipe", Block.blockLapis, Block.glass, Item.emerald);
pipeFluidsWood = buildPipe(DefaultProps.PIPE_LIQUIDS_WOOD_ID, PipeFluidsWood.class, "Wooden Waterproof Pipe", pipeWaterproof, pipeItemsWood); pipeFluidsWood = buildPipe(DefaultProps.PIPE_LIQUIDS_WOOD_ID, PipeFluidsWood.class, "Wooden Waterproof Pipe", pipeWaterproof, pipeItemsWood);
pipeFluidsCobblestone = buildPipe(DefaultProps.PIPE_LIQUIDS_COBBLESTONE_ID, PipeFluidsCobblestone.class, "Cobblestone Waterproof Pipe", pipeWaterproof, pipeItemsCobblestone); pipeFluidsCobblestone = buildPipe(DefaultProps.PIPE_LIQUIDS_COBBLESTONE_ID, PipeFluidsCobblestone.class, "Cobblestone Waterproof Pipe", pipeWaterproof, pipeItemsCobblestone);
@ -313,32 +322,24 @@ public class BuildCraftTransport {
redPipeWire.setUnlocalizedName("redPipeWire"); redPipeWire.setUnlocalizedName("redPipeWire");
LanguageRegistry.addName(redPipeWire, "Red Pipe Wire"); LanguageRegistry.addName(redPipeWire, "Red Pipe Wire");
CoreProxy.proxy.registerItem(redPipeWire); 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); Property bluePipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "bluePipeWire.id", DefaultProps.BLUE_PIPE_WIRE);
bluePipeWire = new ItemBuildCraft(bluePipeWireId.getInt()).setPassSneakClick(true); bluePipeWire = new ItemBuildCraft(bluePipeWireId.getInt()).setPassSneakClick(true);
bluePipeWire.setUnlocalizedName("bluePipeWire"); bluePipeWire.setUnlocalizedName("bluePipeWire");
LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire"); LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire");
CoreProxy.proxy.registerItem(bluePipeWire); 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); Property greenPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "greenPipeWire.id", DefaultProps.GREEN_PIPE_WIRE);
greenPipeWire = new ItemBuildCraft(greenPipeWireId.getInt()).setPassSneakClick(true); greenPipeWire = new ItemBuildCraft(greenPipeWireId.getInt()).setPassSneakClick(true);
greenPipeWire.setUnlocalizedName("greenPipeWire"); greenPipeWire.setUnlocalizedName("greenPipeWire");
LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire"); LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire");
CoreProxy.proxy.registerItem(greenPipeWire); 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); Property yellowPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "yellowPipeWire.id", DefaultProps.YELLOW_PIPE_WIRE);
yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()).setPassSneakClick(true); yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()).setPassSneakClick(true);
yellowPipeWire.setUnlocalizedName("yellowPipeWire"); yellowPipeWire.setUnlocalizedName("yellowPipeWire");
LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire"); LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire");
CoreProxy.proxy.registerItem(yellowPipeWire); 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); Property pipeGateId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeGate.id", DefaultProps.GATE_ID);
pipeGate = new ItemGate(pipeGateId.getInt(), 0); pipeGate = new ItemGate(pipeGateId.getInt(), 0);
@ -365,9 +366,6 @@ public class BuildCraftTransport {
filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt()); filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt());
CoreProxy.proxy.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock")); CoreProxy.proxy.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock"));
CoreProxy.proxy.addName(filteredBufferBlock, "Filtered Buffer"); CoreProxy.proxy.addName(filteredBufferBlock, "Filtered Buffer");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8)));
} finally { } finally {
BuildCraftCore.mainConfiguration.save(); BuildCraftCore.mainConfiguration.save();
} }
@ -378,7 +376,7 @@ public class BuildCraftTransport {
// Register connection handler // Register connection handler
// MinecraftForge.registerConnectionHandler(new ConnectionHandler()); // MinecraftForge.registerConnectionHandler(new ConnectionHandler());
// Register gui handler // Register GUI handler
// MinecraftForge.setGuiHandler(mod_BuildCraftTransport.instance, new GuiHandler()); // MinecraftForge.setGuiHandler(mod_BuildCraftTransport.instance, new GuiHandler());
TransportProxy.proxy.registerTileEntities(); TransportProxy.proxy.registerTileEntities();
@ -422,7 +420,7 @@ public class BuildCraftTransport {
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
actionPipeDirection[direction.ordinal()] = new ActionPipeDirection(-1, direction); actionPipeDirection[direction.ordinal()] = new ActionPipeDirection(-1, direction);
} }
for (PowerMode limit : PowerMode.VALUES) { for (PowerMode limit : PowerMode.VALUES) {
actionPowerLimiter[limit.ordinal()] = new ActionPowerLimiter(-1, limit); actionPowerLimiter[limit.ordinal()] = new ActionPowerLimiter(-1, limit);
} }
@ -436,7 +434,7 @@ public class BuildCraftTransport {
// Add pipe recipes // Add pipe recipes
for (PipeRecipe pipe : pipeRecipes) { for (PipeRecipe pipe : pipeRecipes) {
if (pipe.isShapeless) { if (pipe.isShapeless) {
CoreProxy.proxy.addShapelessRecipe(pipe.result, pipe.input); CoreProxy.proxy.addShapelessRecipe(pipe.result, pipe.input);
} else { } else {
CoreProxy.proxy.addCraftingRecipe(pipe.result, pipe.input); CoreProxy.proxy.addCraftingRecipe(pipe.result, pipe.input);
} }
@ -449,11 +447,22 @@ public class BuildCraftTransport {
//Facade turning helper //Facade turning helper
GameRegistry.addRecipe(facadeItem.new FacadeRecipe()); GameRegistry.addRecipe(facadeItem.new FacadeRecipe());
// Assembly table recipes, moved from PreInit phase to Init, all mods should be done adding to the OreDictionary by now
try {
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(redPipeWire, 8), "dyeRed", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(bluePipeWire, 8), "dyeBlue", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(greenPipeWire, 8), "dyeGreen", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(yellowPipeWire, 8), "dyeYellow", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8)));
} catch (Error error) {
BCLog.logErrorAPI("Buildcraft", error, AssemblyRecipe.class);
}
} }
@EventHandler @EventHandler
public void processIMCRequests(IMCEvent event) { public void processIMCRequests(IMCEvent event) {
InterModComms.processIMC(event); InterModComms.processIMC(event);
} }
public static Item buildPipe(int defaultID, Class<? extends Pipe> clas, String descr, Object... ingredients) { public static Item buildPipe(int defaultID, Class<? extends Pipe> clas, String descr, Object... ingredients) {

View file

@ -3,21 +3,27 @@ package buildcraft.api.filler;
import buildcraft.api.core.IBox; import buildcraft.api.core.IBox;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
public interface IFillerPattern { public interface IFillerPattern {
public int getId(); public String getUniqueTag();
public void setId(int id); /**
* Creates the object that does the pattern iteration. This object may be
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace); * state-full and will be used until the pattern is done or changes.
*
* @param tile the Filler
* @param box the area to fill
* @param orientation not currently used, but may be in the future (the filler needs some orientation code)
* @return
*/
public IPatternIterator createPatternIterator(TileEntity tile, IBox box, ForgeDirection orientation);
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public Icon getTexture(); public Icon getIcon();
public String getName();
public String getDisplayName();
} }

View file

@ -1,15 +1,17 @@
package buildcraft.api.filler; package buildcraft.api.filler;
import net.minecraft.inventory.IInventory; import buildcraft.api.gates.IAction;
import java.util.Set;
public interface IFillerRegistry { public interface IFillerRegistry {
public void addRecipe(IFillerPattern pattern, Object aobj[]); public void addPattern(IFillerPattern pattern);
public IFillerPattern findMatchingRecipe(IInventory inventorycrafting); public IFillerPattern getPattern(String patternName);
public int getPatternNumber(IFillerPattern pattern); public IFillerPattern getNextPattern(IFillerPattern currentPattern);
public IFillerPattern getPattern(int n);
public IFillerPattern getPreviousPattern(IFillerPattern currentPattern);
public Set<? extends IAction> getActions();
} }

View file

@ -0,0 +1,20 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.filler;
import net.minecraft.item.ItemStack;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public interface IPatternIterator {
public boolean iteratePattern(ItemStack stackToPlace);
}

View file

@ -1,3 +1,3 @@
@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|filler") @API(apiVersion="2.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|filler")
package buildcraft.api.filler; package buildcraft.api.filler;
import cpw.mods.fml.common.API; import cpw.mods.fml.common.API;

View file

@ -29,7 +29,7 @@ public final class IronEngineCoolant {
} }
public static Coolant getCoolant(FluidStack fluidStack) { public static Coolant getCoolant(FluidStack fluidStack) {
return fluidStack != null ? liquidCoolants.get(fluidStack.getFluid().getName()) : null; return fluidStack != null && fluidStack.getFluid() != null ? liquidCoolants.get(fluidStack.getFluid().getName()) : null;
} }
private IronEngineCoolant() { private IronEngineCoolant() {

View file

@ -47,8 +47,9 @@ public class TriggerParameter implements ITriggerParameter {
@Override @Override
public void writeToNBT(NBTTagCompound compound) { public void writeToNBT(NBTTagCompound compound) {
if (stack != null) { if (stack != null) {
compound.setInteger("itemID", stack.itemID); NBTTagCompound tagCompound = new NBTTagCompound();
compound.setInteger("itemDMG", stack.getItemDamage()); stack.writeToNBT(tagCompound);
compound.setCompoundTag("stack", tagCompound);
} }
} }
@ -59,11 +60,14 @@ public class TriggerParameter implements ITriggerParameter {
*/ */
@Override @Override
public void readFromNBT(NBTTagCompound compound) { public void readFromNBT(NBTTagCompound compound) {
// Legacy code to prevent existing gates from losing their contents
int itemID = compound.getInteger("itemID"); int itemID = compound.getInteger("itemID");
if (itemID != 0) { if (itemID != 0) {
stack = new ItemStack(itemID, 1, compound.getInteger("itemDMG")); stack = new ItemStack(itemID, 1, compound.getInteger("itemDMG"));
return;
} }
stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack"));
} }
@Override @Override

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.power;
/**
* Specifies a Tile Entity that can receive power via laser beam.
*
* @author cpw
*/
public interface ILaserTarget {
/**
* Returns true if the target currently needs power. For example, if the Advanced
* Crafting Table has work to do.
*
* @return true if needs power
*/
boolean requiresLaserEnergy();
/**
* Transfers energy from the laser to the target.
*
* @param energy
*/
void receiveLaserEnergy(float energy);
/**
* Return true if the Tile Entity object is no longer a valid target. For
* example, if its been invalidated.
*
* @return true if no longer a valid target object
*/
boolean isInvalidTarget();
int getXCoord();
int getYCoord();
int getZCoord();
}

View file

@ -1,13 +1,14 @@
package buildcraft.api.recipes; package buildcraft.api.recipes;
import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class AssemblyRecipe { public class AssemblyRecipe {
public static LinkedList<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>(); public static LinkedList<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>();
public final Object[] input;
public final ItemStack[] input;
public final ItemStack output; public final ItemStack output;
public final float energy; public final float energy;
@ -17,30 +18,69 @@ public class AssemblyRecipe {
this.energy = energy; this.energy = energy;
} }
public boolean canBeDone(ItemStack[] items) { /**
* This version of AssemblyRecipe supports the OreDictionary
*
* @param input Object... containing either an ItemStack, or a paired string
* and integer(ex: "dyeBlue", 1)
* @param energy MJ cost to produce
* @param output resulting ItemStack
*/
public AssemblyRecipe(int energy, ItemStack output, Object... input) {
this.output = output;
this.energy = energy;
this.input = input;
for (ItemStack in : input) { for (int i = 0; i < input.length; i++) {
if (input[i] instanceof String) {
input[i] = OreDictionary.getOres((String) input[i]);
}
}
}
if (in == null) { public boolean canBeDone(ItemStack... items) {
for (int i = 0; i < input.length; i++) {
if (input[i] == null)
continue; continue;
}
int found = 0; // Amount of ingredient found in inventory if (input[i] instanceof ItemStack) {
ItemStack requirement = (ItemStack) input[i];
int found = 0; // Amount of ingredient found in inventory
int expected = requirement.stackSize;
for (ItemStack item : items) {
if (item == null)
continue;
if (item.isItemEqual(requirement))
found += item.stackSize; // Adds quantity of stack to amount found
for (ItemStack item : items) {
if (item == null) {
continue;
} }
if (item.isItemEqual(in)) { // Return false if the amount of ingredient found
found += item.stackSize; // Adds quantity of stack to amount // is not enough
// found if (found < expected)
} return false;
} } else if (input[i] instanceof ArrayList) {
ArrayList<ItemStack> oreList = (ArrayList<ItemStack>) input[i];
int found = 0; // Amount of ingredient found in inventory
int expected = (Integer) input[i++ + 1];
if (found < in.stackSize) for (ItemStack item : items) {
return false; // Return false if the amount of ingredient found if (item == null)
// is not enough continue;
for (ItemStack oreItem : oreList) {
if (OreDictionary.itemMatches(oreItem, item, true)) {
found += item.stackSize;
break;
}
}
}
// Return false if the amount of ingredient found
// is not enough
if (found < expected)
return false;
}
} }
return true; return true;

View file

@ -10,7 +10,6 @@ package buildcraft.builders;
import buildcraft.BuildCraftBuilders; import buildcraft.BuildCraftBuilders;
import buildcraft.api.core.Position; import buildcraft.api.core.Position;
import buildcraft.api.tools.IToolWrench; import buildcraft.api.tools.IToolWrench;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.GuiIds; import buildcraft.core.GuiIds;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
@ -38,7 +37,7 @@ public class BlockBuilder extends BlockContainer {
public BlockBuilder(int i) { public BlockBuilder(int i) {
super(i, Material.iron); super(i, Material.iron);
setHardness(5F); setHardness(5F);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); setCreativeTab(null);
} }
@Override @Override

View file

@ -56,29 +56,25 @@ public class BlockFiller extends BlockContainer {
} }
@SuppressWarnings({ "all" }) @Override
public Icon getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) { public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) {
int m = iblockaccess.getBlockMetadata(i, j, k); int m = world.getBlockMetadata(x, y, z);
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (iblockaccess == null)
return getIcon(i, m);
TileEntity tile = iblockaccess.getBlockTileEntity(i, j, k);
if (tile != null && tile instanceof TileFiller) { if (tile != null && tile instanceof TileFiller) {
TileFiller filler = (TileFiller) tile; TileFiller filler = (TileFiller) tile;
if (l == 1 || l == 0) { if (side == 1 || side == 0) {
if (!filler.isActive()) if (!filler.isActive())
return textureTopOff; return textureTopOff;
else else
return textureTopOn; return textureTopOn;
} else if (filler.currentPattern != null) } else if (filler.currentPattern != null)
return filler.currentPattern.getTexture(); return filler.currentPattern.getIcon();
else else
return textureSides; return textureSides;
} }
return getIcon(l, m); return getIcon(side, m);
} }
@Override @Override

View file

@ -1,131 +0,0 @@
/**
* Copyright (c) SpaceToad, 2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.builders;
import buildcraft.BuildCraftBuilders;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptBlockUtils;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import buildcraft.api.core.LaserKind;
import buildcraft.api.core.Position;
import buildcraft.core.Box;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@Deprecated
public class BptBlockFiller extends BptBlock {
public BptBlockFiller(int blockId) {
super(blockId);
}
@Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
ItemStack[] recipeStack = BptBlockUtils.getItemStacks(slot, context);
for (int i = 0; i < recipeStack.length; ++i) {
if (recipeStack[i] != null) {
requirements.add(recipeStack[i]);
}
}
requirements.add(new ItemStack(BuildCraftBuilders.fillerBlock));
}
@Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
super.rotateLeft(slot, context);
Box box = new Box();
box.initialize(slot.cpt.getCompoundTag("box"));
Position pMin = context.rotatePositionLeft(box.pMin());
Position pMax = context.rotatePositionLeft(box.pMax());
box.xMin = (int) pMin.x;
box.yMin = (int) pMin.y;
box.zMin = (int) pMin.z;
box.xMax = (int) pMax.x;
box.yMax = (int) pMax.y;
box.zMax = (int) pMax.z;
box.reorder();
NBTTagCompound cpt = new NBTTagCompound();
box.writeToNBT(cpt);
slot.cpt.setTag("box", cpt);
}
@Override
public void buildBlock(BptSlotInfo slot, IBptContext context) {
context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId);
TileFiller filler = (TileFiller) context.world().getBlockTileEntity(slot.x, slot.y, slot.z);
Box box = new Box();
box.initialize(slot.cpt.getCompoundTag("box"));
box.xMin += context.surroundingBox().pMin().x;
box.yMin += context.surroundingBox().pMin().y;
box.zMin += context.surroundingBox().pMin().z;
box.xMax += context.surroundingBox().pMin().x;
box.yMax += context.surroundingBox().pMin().y;
box.zMax += context.surroundingBox().pMin().z;
box.reorder();
filler.box.deleteLasers();
filler.box = box;
filler.box.createLasers(context.world(), LaserKind.Stripes);
ItemStack[] recipeStack = BptBlockUtils.getItemStacks(slot, context);
for (int i = 0; i < recipeStack.length; ++i) {
filler.setInventorySlotContents(i, recipeStack[i]);
}
}
@Override
public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) {
TileFiller filler = (TileFiller) context.world().getBlockTileEntity(x, y, z);
NBTTagCompound cpt = new NBTTagCompound();
Box fillerBox = new Box();
fillerBox.initialize(filler.box);
fillerBox.xMin -= context.surroundingBox().pMin().x;
fillerBox.yMin -= context.surroundingBox().pMin().y;
fillerBox.zMin -= context.surroundingBox().pMin().z;
fillerBox.xMax -= context.surroundingBox().pMin().x;
fillerBox.yMax -= context.surroundingBox().pMin().y;
fillerBox.zMax -= context.surroundingBox().pMin().z;
fillerBox.reorder();
fillerBox.writeToNBT(cpt);
slot.cpt.setTag("box", cpt);
ItemStack[] recipeStack = new ItemStack[9];
for (int i = 0; i < 9; ++i) {
recipeStack[i] = filler.getStackInSlot(i);
}
BptBlockUtils.setItemStacks(slot, context, recipeStack);
}
}

View file

@ -1,16 +1,8 @@
package buildcraft.builders; package buildcraft.builders;
import buildcraft.BuildCraftBuilders; import buildcraft.BuildCraftBuilders;
import net.minecraft.util.Icon;
public class BuilderProxyClient extends BuilderProxy { public class BuilderProxyClient extends BuilderProxy {
public static Icon fillerFillAllTexture;
public static Icon fillerClearTexture;
public static Icon fillerWallsTexture;
public static Icon fillerStairsTexture;
public static Icon fillerFlattenTexture;
public static Icon fillerHorizonTexture;
public static Icon fillerPyramidTexture;
@Override @Override
public void registerClientHook() { public void registerClientHook() {

View file

@ -1,169 +0,0 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.builders;
import buildcraft.api.filler.IFillerPattern;
import buildcraft.api.filler.IFillerRegistry;
import java.util.HashMap;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class FillerRegistry implements IFillerRegistry {
static class ShapedPatternRecipe {
private int recipeWidth;
private int recipeHeight;
private ItemStack recipeItems[];
private IFillerPattern recipeOutput;
public ShapedPatternRecipe(int i, int j, ItemStack aitemstack[], IFillerPattern pattern) {
recipeWidth = i;
recipeHeight = j;
recipeItems = aitemstack;
recipeOutput = pattern;
}
public boolean matches(IInventory inventorycrafting) {
for (int i = 0; i <= 3 - recipeWidth; i++) {
for (int j = 0; j <= 3 - recipeHeight; j++) {
if (func_21137_a(inventorycrafting, i, j, true))
return true;
if (func_21137_a(inventorycrafting, i, j, false))
return true;
}
}
return false;
}
private boolean func_21137_a(IInventory inventorycrafting, int i, int j, boolean flag) {
for (int k = 0; k < 3; k++) {
for (int l = 0; l < 3; l++) {
int i1 = k - i;
int j1 = l - j;
ItemStack itemstack = null;
if (i1 >= 0 && j1 >= 0 && i1 < recipeWidth && j1 < recipeHeight) {
if (flag) {
itemstack = recipeItems[(recipeWidth - i1 - 1) + j1 * recipeWidth];
} else {
itemstack = recipeItems[i1 + j1 * recipeWidth];
}
}
ItemStack itemstack1 = inventorycrafting.getStackInSlot(k + l * 3);
if (itemstack1 == null && itemstack == null) {
continue;
}
if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null)
return false;
if (itemstack.itemID != itemstack1.itemID)
return false;
if (itemstack.getItemDamage() != -1 && itemstack.getItemDamage() != itemstack1.getItemDamage())
return false;
}
}
return true;
}
}
static LinkedList<ShapedPatternRecipe> recipes = new LinkedList<ShapedPatternRecipe>();
@Override
public void addRecipe(IFillerPattern pattern, Object aobj[]) {
String s = "";
int i = 0;
int j = 0;
int k = 0;
if (aobj[i] instanceof String[]) {
String as[] = (String[]) aobj[i++];
for (int l = 0; l < as.length; l++) {
String s2 = as[l];
k++;
j = s2.length();
s = (new StringBuilder()).append(s).append(s2).toString();
}
} else {
while (aobj[i] instanceof String) {
String s1 = (String) aobj[i++];
k++;
j = s1.length();
s = (new StringBuilder()).append(s).append(s1).toString();
}
}
HashMap<Character, ItemStack> hashmap = new HashMap<Character, ItemStack>();
for (; i < aobj.length; i += 2) {
Character character = (Character) aobj[i];
ItemStack itemstack1 = null;
if (aobj[i + 1] instanceof Item) {
itemstack1 = new ItemStack((Item) aobj[i + 1]);
} else if (aobj[i + 1] instanceof Block) {
itemstack1 = new ItemStack((Block) aobj[i + 1], 1, -1);
} else if (aobj[i + 1] instanceof ItemStack) {
itemstack1 = (ItemStack) aobj[i + 1];
}
hashmap.put(character, itemstack1);
}
ItemStack aitemstack[] = new ItemStack[j * k];
for (int i1 = 0; i1 < j * k; i1++) {
char c = s.charAt(i1);
if (hashmap.containsKey(Character.valueOf(c))) {
aitemstack[i1] = hashmap.get(Character.valueOf(c)).copy();
} else {
aitemstack[i1] = null;
}
}
recipes.add(new ShapedPatternRecipe(j, k, aitemstack, pattern));
pattern.setId(recipes.size());
}
@Override
public IFillerPattern findMatchingRecipe(IInventory inventorycrafting) {
for (int i = 0; i < recipes.size(); i++) {
ShapedPatternRecipe irecipe = recipes.get(i);
if (irecipe.matches(inventorycrafting))
return irecipe.recipeOutput;
}
return null;
}
@Override
public int getPatternNumber(IFillerPattern pattern) {
int i = 0;
for (ShapedPatternRecipe recipe : recipes) {
if (recipe.recipeOutput == pattern)
return i;
i++;
}
return -1;
}
@Override
public IFillerPattern getPattern(int n) {
if (n <= 0)
return null;
return recipes.get(n - 1).recipeOutput;
}
}

View file

@ -12,53 +12,57 @@ import buildcraft.api.core.IAreaProvider;
import buildcraft.api.core.LaserKind; import buildcraft.api.core.LaserKind;
import buildcraft.api.filler.FillerManager; import buildcraft.api.filler.FillerManager;
import buildcraft.api.filler.IFillerPattern; import buildcraft.api.filler.IFillerPattern;
import buildcraft.api.filler.IPatternIterator;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionReceptor; import buildcraft.api.gates.IActionReceptor;
import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type; import buildcraft.api.power.PowerHandler.Type;
import buildcraft.builders.filler.pattern.PatternFill;
import buildcraft.builders.triggers.ActionFiller;
import buildcraft.core.Box; import buildcraft.core.Box;
import buildcraft.core.IMachine; import buildcraft.core.IMachine;
import buildcraft.core.TileBuildCraft; import buildcraft.core.TileBuildCraft;
import buildcraft.core.inventory.InventoryIterator;
import buildcraft.core.inventory.InventoryIterator.IInvSlot;
import buildcraft.core.inventory.SimpleInventory;
import buildcraft.core.network.IGuiReturnHandler;
import buildcraft.core.network.PacketPayload;
import buildcraft.core.network.PacketPayloadStream;
import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.PacketUpdate;
import buildcraft.core.network.TileNetworkData;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.ActionMachineControl; import buildcraft.core.triggers.ActionMachineControl;
import buildcraft.core.triggers.ActionMachineControl.Mode; import buildcraft.core.triggers.ActionMachineControl.Mode;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowerReceptor, IMachine, IActionReceptor { public class TileFiller extends TileBuildCraft implements IInventory, IPowerReceptor, IMachine, IActionReceptor, IGuiReturnHandler {
private static int[] SLOTS_GRID = Utils.createSlotArray(0, 9); public IFillerPattern currentPattern = PatternFill.INSTANCE;
private static int[] SLOTS_INPUT = Utils.createSlotArray(9, 27); private static int POWER_USAGE = 25;
public @TileNetworkData private final Box box = new Box();
Box box = new Box(); private boolean done = false;
public @TileNetworkData private IPatternIterator patternIterator;
int currentPatternId = 0;
public @TileNetworkData
boolean done = true;
public IFillerPattern currentPattern;
boolean forceDone = false;
private ItemStack contents[];
private PowerHandler powerHandler; private PowerHandler powerHandler;
private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown; private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown;
private SimpleInventory inv = new SimpleInventory(27, "Filler", 64);
public TileFiller() { public TileFiller() {
contents = new ItemStack[getSizeInventory()]; inv.addListener(this);
powerHandler = new PowerHandler(this, Type.MACHINE); powerHandler = new PowerHandler(this, Type.MACHINE);
initPowerProvider(); initPowerProvider();
} }
private void initPowerProvider() { private void initPowerProvider() {
powerHandler.configure(30, 50, 25, 100); powerHandler.configure(30, POWER_USAGE * 2, POWER_USAGE, POWER_USAGE * 4);
powerHandler.configurePowerPerdition(1, 1); powerHandler.configurePowerPerdition(1, 1);
} }
@ -82,23 +86,15 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
sendNetworkUpdate(); sendNetworkUpdate();
} }
} }
computeRecipe();
} }
@Override @Override
public void updateEntity() { public void updateEntity() {
super.updateEntity(); super.updateEntity();
if (done) { if (done) {
if (lastMode == Mode.Loop) { if (lastMode == Mode.Loop) {
done = false; done = false;
} else }
return;
}
if (powerHandler.getEnergyStored() >= 25) {
doWork(powerHandler);
} }
} }
@ -106,132 +102,68 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
public void doWork(PowerHandler workProvider) { public void doWork(PowerHandler workProvider) {
if (CoreProxy.proxy.isRenderWorld(worldObj)) if (CoreProxy.proxy.isRenderWorld(worldObj))
return; return;
if (done)
return;
if (lastMode == Mode.Off) if (lastMode == Mode.Off)
return; return;
if (powerHandler.useEnergy(POWER_USAGE, POWER_USAGE, false) != POWER_USAGE)
if (powerHandler.useEnergy(25, 25, true) < 25) return;
if (!box.isInitialized())
return; return;
if (box.isInitialized() && currentPattern != null && !done) { if (patternIterator == null)
ItemStack stack = null; patternIterator = currentPattern.createPatternIterator(this, box, ForgeDirection.NORTH);
int stackId = 0;
for (int s = 9; s < getSizeInventory(); ++s) { ItemStack stackToUse = null;
if (getStackInSlot(s) != null && getStackInSlot(s).stackSize > 0) { int slotNum = 0;
stack = contents[s]; for (IInvSlot slot : InventoryIterator.getIterable(inv, ForgeDirection.UNKNOWN)) {
stackId = s; ItemStack stack = slot.getStackInSlot();
if (stack != null && stack.stackSize > 0) {
break; stackToUse = stack;
} slotNum = slot.getIndex();
} break;
done = currentPattern.iteratePattern(this, box, stack);
if (stack != null && stack.stackSize == 0) {
contents[stackId] = null;
}
if (done) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
sendNetworkUpdate();
} }
} }
if (powerHandler.getEnergyStored() >= 25) { done = patternIterator.iteratePattern(stackToUse);
powerHandler.useEnergy(POWER_USAGE, POWER_USAGE, true);
if (stackToUse != null && stackToUse.stackSize <= 0) {
setInventorySlotContents(slotNum, null);
}
if (done) {
patternIterator = null;
sendNetworkUpdate();
} else if (powerHandler.getEnergyStored() >= POWER_USAGE) {
doWork(workProvider); doWork(workProvider);
} }
} }
@Override @Override
public final int getSizeInventory() { public final int getSizeInventory() {
return 36; return inv.getSizeInventory();
} }
@Override @Override
public ItemStack getStackInSlot(int i) { public ItemStack getStackInSlot(int slot) {
return contents[i]; return inv.getStackInSlot(slot);
}
public void computeRecipe() {
if (CoreProxy.proxy.isRenderWorld(worldObj))
return;
IFillerPattern newPattern = FillerManager.registry.findMatchingRecipe(this);
if (newPattern == currentPattern)
return;
currentPattern = newPattern;
if (currentPattern == null || forceDone) {
done = lastMode != Mode.Loop;
forceDone = false;
} else {
done = false;
}
if (worldObj != null) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
if (currentPattern == null) {
currentPatternId = 0;
} else {
currentPatternId = currentPattern.getId();
}
if (CoreProxy.proxy.isSimulating(worldObj)) {
sendNetworkUpdate();
}
} }
@Override @Override
public ItemStack decrStackSize(int i, int j) { public ItemStack decrStackSize(int slot, int amount) {
if (contents[i] != null) { return inv.decrStackSize(slot, amount);
if (contents[i].stackSize <= j) {
ItemStack itemstack = contents[i];
contents[i] = null;
// onInventoryChanged();
computeRecipe();
return itemstack;
}
ItemStack itemstack1 = contents[i].splitStack(j);
if (contents[i].stackSize == 0) {
contents[i] = null;
}
// onInventoryChanged();
computeRecipe();
return itemstack1;
} else
return null;
} }
@Override @Override
public void setInventorySlotContents(int i, ItemStack itemstack) { public void setInventorySlotContents(int slot, ItemStack stack) {
contents[i] = itemstack; inv.setInventorySlotContents(slot, stack);
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
itemstack.stackSize = getInventoryStackLimit();
}
computeRecipe();
// onInventoryChanged();
} }
@Override @Override
public ItemStack getStackInSlotOnClosing(int slot) { public ItemStack getStackInSlotOnClosing(int slot) {
if (contents[slot] == null) return inv.getStackInSlotOnClosing(slot);
return null;
ItemStack toReturn = contents[slot];
contents[slot] = null;
return toReturn;
} }
@Override @Override
@ -240,40 +172,44 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbttagcompound) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbttagcompound); super.readFromNBT(nbt);
Utils.readStacksFromNBT(nbttagcompound, "Items", contents); inv.readFromNBT(nbt);
if (nbttagcompound.hasKey("box")) { if (nbt.hasKey("pattern"))
box.initialize(nbttagcompound.getCompoundTag("box")); currentPattern = FillerManager.registry.getPattern(nbt.getString("pattern"));
}
done = nbttagcompound.getBoolean("done"); if (currentPattern == null)
lastMode = Mode.values()[nbttagcompound.getByte("lastMode")]; currentPattern = PatternFill.INSTANCE;
forceDone = done; if (nbt.hasKey("box"))
box.initialize(nbt.getCompoundTag("box"));
done = nbt.getBoolean("done");
lastMode = Mode.values()[nbt.getByte("lastMode")];
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbttagcompound) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbttagcompound); super.writeToNBT(nbt);
Utils.writeStacksToNBT(nbttagcompound, "Items", contents); inv.writeToNBT(nbt);
if (box != null) { if (currentPattern != null)
NBTTagCompound boxStore = new NBTTagCompound(); nbt.setString("pattern", currentPattern.getUniqueTag());
box.writeToNBT(boxStore);
nbttagcompound.setTag("box", boxStore);
}
nbttagcompound.setBoolean("done", done); NBTTagCompound boxStore = new NBTTagCompound();
nbttagcompound.setByte("lastMode", (byte) lastMode.ordinal()); box.writeToNBT(boxStore);
nbt.setTag("box", boxStore);
nbt.setBoolean("done", done);
nbt.setByte("lastMode", (byte) lastMode.ordinal());
} }
@Override @Override
public int getInventoryStackLimit() { public int getInventoryStackLimit() {
return 64; return inv.getInventoryStackLimit();
} }
@Override @Override
@ -291,37 +227,52 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
@Override @Override
public void destroy() { public void destroy() {
if (box != null) { box.deleteLasers();
box.deleteLasers(); }
public void setPattern(IFillerPattern pattern) {
if (pattern != null && currentPattern != pattern) {
currentPattern = pattern;
patternIterator = null;
done = false;
sendNetworkUpdate();
}
}
@Override
public PacketPayload getPacketPayload() {
PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() {
@Override
public void writeData(DataOutputStream data) throws IOException {
box.writeToStream(data);
data.writeBoolean(done);
data.writeUTF(currentPattern.getUniqueTag());
}
});
return payload;
}
public void handlePacketPayload(DataInputStream data) throws IOException {
boolean initialized = box.isInitialized();
box.readFromStream(data);
done = data.readBoolean();
setPattern(FillerManager.registry.getPattern(data.readUTF()));
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
if (!initialized && box.isInitialized()) {
box.createLasers(worldObj, LaserKind.Stripes);
} }
} }
@Override @Override
public void handleDescriptionPacket(PacketUpdate packet) throws IOException { public void handleDescriptionPacket(PacketUpdate packet) throws IOException {
boolean initialized = box.isInitialized(); handlePacketPayload(((PacketPayloadStream) packet.payload).stream);
super.handleDescriptionPacket(packet);
currentPattern = FillerManager.registry.getPattern(currentPatternId);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
if (!initialized && box.isInitialized()) {
box.createLasers(worldObj, LaserKind.Stripes);
}
} }
@Override @Override
public void handleUpdatePacket(PacketUpdate packet) throws IOException { public void handleUpdatePacket(PacketUpdate packet) throws IOException {
boolean initialized = box.isInitialized(); handlePacketPayload(((PacketPayloadStream) packet.payload).stream);
super.handleUpdatePacket(packet);
currentPattern = FillerManager.registry.getPattern(currentPatternId);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
if (!initialized && box.isInitialized()) {
box.createLasers(worldObj, LaserKind.Stripes);
}
} }
@Override @Override
@ -360,6 +311,9 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
lastMode = ActionMachineControl.Mode.Off; lastMode = ActionMachineControl.Mode.Off;
} else if (action == BuildCraftCore.actionLoop) { } else if (action == BuildCraftCore.actionLoop) {
lastMode = ActionMachineControl.Mode.Loop; lastMode = ActionMachineControl.Mode.Loop;
} else if (action instanceof ActionFiller) {
ActionFiller actFill = (ActionFiller) action;
setPattern(actFill.pattern);
} }
} }
@ -370,29 +324,22 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
@Override @Override
public boolean isItemValidForSlot(int slot, ItemStack stack) { public boolean isItemValidForSlot(int slot, ItemStack stack) {
if (slot < 9) {
if (getStackInSlot(slot) != null)
return false;
return stack.itemID == Block.brick.blockID || stack.itemID == Block.glass.blockID;
}
return true; return true;
} }
@Override @Override
public int[] getAccessibleSlotsFromSide(int side) { public void writeGuiData(DataOutputStream data) throws IOException {
if (ForgeDirection.UP.ordinal() == side) { data.writeUTF(currentPattern.getUniqueTag());
return SLOTS_GRID;
}
return SLOTS_INPUT;
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side) { public void readGuiData(DataInputStream data, EntityPlayer player) throws IOException {
return isItemValidForSlot(slot, stack); IFillerPattern prev = currentPattern;
} currentPattern = FillerManager.registry.getPattern(data.readUTF());
if (currentPattern == null)
@Override currentPattern = PatternFill.INSTANCE;
public boolean canExtractItem(int slot, ItemStack stack, int side) { if (prev != currentPattern)
return true; done = false;
sendNetworkUpdate();
} }
} }

View file

@ -0,0 +1,54 @@
/**
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.builders.filler;
import buildcraft.api.filler.IFillerPattern;
import buildcraft.api.filler.IFillerRegistry;
import buildcraft.builders.triggers.ActionFiller;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
public class FillerRegistry implements IFillerRegistry {
private TreeMap<String, IFillerPattern> patterns = new TreeMap<String, IFillerPattern>();
private Set<ActionFiller> patternActions = new HashSet<ActionFiller>();
@Override
public void addPattern(IFillerPattern pattern) {
patterns.put(pattern.getUniqueTag(), pattern);
patternActions.add(new ActionFiller(pattern));
}
@Override
public IFillerPattern getPattern(String patternName) {
return patterns.get(patternName);
}
@Override
public IFillerPattern getNextPattern(IFillerPattern currentPattern) {
Entry<String, IFillerPattern> pattern = patterns.higherEntry(currentPattern.getUniqueTag());
if (pattern == null)
pattern = patterns.firstEntry();
return pattern.getValue();
}
@Override
public IFillerPattern getPreviousPattern(IFillerPattern currentPattern) {
Entry<String, IFillerPattern> pattern = patterns.lowerEntry(currentPattern.getUniqueTag());
if (pattern == null)
pattern = patterns.lastEntry();
return pattern.getValue();
}
@Override
public Set<ActionFiller> getActions() {
return patternActions;
}
}

View file

@ -5,44 +5,88 @@
* 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.builders; package buildcraft.builders.filler.pattern;
import buildcraft.BuildCraftBuilders; import buildcraft.BuildCraftBuilders;
import buildcraft.api.core.IBox; import buildcraft.api.core.IBox;
import buildcraft.api.filler.IFillerPattern; import buildcraft.api.filler.IFillerPattern;
import buildcraft.api.filler.IPatternIterator;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.BlockUtil; import buildcraft.core.utils.BlockUtil;
import cpw.mods.fml.relauncher.Side; import buildcraft.core.utils.StringUtils;
import cpw.mods.fml.relauncher.SideOnly; import java.util.HashSet;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public abstract class FillerPattern implements IFillerPattern { public abstract class FillerPattern implements IFillerPattern {
protected int id; public static final Set<FillerPattern> patterns = new HashSet<FillerPattern>();
private final String tag;
private Icon icon;
public FillerPattern(String tag) {
this.tag = tag;
patterns.add(this);
}
/** /**
* stackToPlace contains the next item that can be place in the world. Null * stackToPlace contains the next item that can be place in the world. Null
* if there is none. IteratePattern is responsible to decrementing the stack * if there is none. IteratePattern is responsible to decrementing the stack
* size if needed. Return true when the iteration process is finished. * size if needed. Return true when the iteration process is finished.
*/ */
@Override public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
public abstract boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace); return true;
@SideOnly(Side.CLIENT)
@Override
public abstract Icon getTexture();
@Override
public void setId(int id) {
this.id = id;
} }
@Override @Override
public int getId() { public String getDisplayName() {
return this.id; return StringUtils.localize("fillerpattern." + tag);
}
@Override
public String getUniqueTag() {
return "buildcraft:" + tag;
}
public void registerIcon(IconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:fillerPatterns/" + tag);
}
@Override
public Icon getIcon() {
return icon;
}
@Override
public String toString() {
return "Pattern: " + getUniqueTag();
}
@Override
public IPatternIterator createPatternIterator(TileEntity tile, IBox box, ForgeDirection orientation) {
return new PatternIterator(tile, box);
}
protected class PatternIterator implements IPatternIterator {
private final IBox box;
private final TileEntity tile;
public PatternIterator(TileEntity tile, IBox box) {
this.box = box;
this.tile = tile;
}
@Override
public boolean iteratePattern(ItemStack stackToPlace) {
return FillerPattern.this.iteratePattern(tile, box, stackToPlace);
}
} }
/** /**
@ -51,7 +95,7 @@ public abstract class FillerPattern implements IFillerPattern {
* Return false if the process failed. * Return false if the process failed.
* *
*/ */
public boolean fill(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, ItemStack stackToPlace, World world) { public static boolean fill(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, ItemStack stackToPlace, World world) {
boolean found = false; boolean found = false;
int lastX = 0, lastY = 0, lastZ = 0; int lastX = 0, lastY = 0, lastZ = 0;
@ -85,12 +129,11 @@ public abstract class FillerPattern implements IFillerPattern {
* Return false if is the process failed. * Return false if is the process failed.
* *
*/ */
public boolean empty(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world) { public static boolean empty(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world) {
boolean found = false;
int lastX = Integer.MAX_VALUE, lastY = Integer.MAX_VALUE, lastZ = Integer.MAX_VALUE; int lastX = Integer.MAX_VALUE, lastY = Integer.MAX_VALUE, lastZ = Integer.MAX_VALUE;
for (int y = yMax; y >= yMin; y--) { for (int y = yMax; y >= yMin; y--) {
found = false; boolean found = false;
for (int x = xMin; x <= xMax; ++x) { for (int x = xMin; x <= xMax; ++x) {
for (int z = zMin; z <= zMax; ++z) { for (int z = zMin; z <= zMax; ++z) {
if (!BlockUtil.canChangeBlock(world, x, y, z)) if (!BlockUtil.canChangeBlock(world, x, y, z))
@ -125,7 +168,7 @@ public abstract class FillerPattern implements IFillerPattern {
* *
* Return false if is the process failed. * Return false if is the process failed.
*/ */
public boolean flatten(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world, ItemStack stackToPlace) { public static boolean flatten(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world, ItemStack stackToPlace) {
int lastX = Integer.MAX_VALUE, lastY = Integer.MAX_VALUE, lastZ = Integer.MAX_VALUE; int lastX = Integer.MAX_VALUE, lastY = Integer.MAX_VALUE, lastZ = Integer.MAX_VALUE;
boolean found = false; boolean found = false;
@ -151,7 +194,10 @@ public abstract class FillerPattern implements IFillerPattern {
return found; return found;
} }
private void breakBlock(World world, int x, int y, int z) { private static void breakBlock(World world, int x, int y, int z) {
Block block = Block.blocksList[world.getBlockId(x, y, z)];
if (block != null)
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
if (BuildCraftBuilders.fillerDestroy) { if (BuildCraftBuilders.fillerDestroy) {
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
} else if (BlockUtil.isToughBlock(world, x, y, z)) { } else if (BlockUtil.isToughBlock(world, x, y, z)) {

View file

@ -1,22 +1,21 @@
/** /**
* Copyright (c) SpaceToad, 2011 * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public * BuildCraft is distributed under the terms of the Minecraft Mod Public License
* License 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.builders.filler.pattern;
package buildcraft.builders;
import buildcraft.api.core.IBox; import buildcraft.api.core.IBox;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
public class FillerFillWalls extends FillerPattern { public class PatternBox extends FillerPattern {
public PatternBox() {
super("box");
}
@Override @Override
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
@ -48,16 +47,4 @@ public class FillerFillWalls extends FillerPattern {
return true; return true;
} }
@SideOnly(Side.CLIENT)
@Override
public Icon getTexture() {
return BuilderProxyClient.fillerWallsTexture;
}
@Override
public String getName() {
return "Walls";
}
} }

View file

@ -1,22 +1,21 @@
/** /**
* Copyright (c) SpaceToad, 2011 * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public * BuildCraft is distributed under the terms of the Minecraft Mod Public License
* License 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.builders.filler.pattern;
package buildcraft.builders;
import buildcraft.api.core.IBox; import buildcraft.api.core.IBox;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
public class FillerRemover extends FillerPattern { public class PatternClear extends FillerPattern {
public PatternClear() {
super("clear");
}
@Override @Override
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
@ -30,16 +29,4 @@ public class FillerRemover extends FillerPattern {
return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj); return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj);
} }
@SideOnly(Side.CLIENT)
@Override
public Icon getTexture() {
return BuilderProxyClient.fillerClearTexture;
}
@Override
public String getName() {
return "Clear";
}
} }

View file

@ -1,22 +1,27 @@
/** /**
* Copyright (c) SpaceToad, 2011 * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public * BuildCraft is distributed under the terms of the Minecraft Mod Public License
* License 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.builders.filler.pattern;
package buildcraft.builders;
import buildcraft.api.core.IBox; import buildcraft.api.core.IBox;
import buildcraft.builders.BuilderProxyClient;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
public class FillerFillAll extends FillerPattern { public class PatternFill extends FillerPattern {
public static final PatternFill INSTANCE = new PatternFill();
private PatternFill() {
super("fill");
}
@Override @Override
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
@ -31,15 +36,4 @@ public class FillerFillAll extends FillerPattern {
return !fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj); return !fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj);
} }
@Override
@SideOnly(Side.CLIENT)
public Icon getTexture() {
return BuilderProxyClient.fillerFillAllTexture;
}
@Override
public String getName() {
return "Fill";
}
} }

View file

@ -5,17 +5,17 @@
* 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.builders; package buildcraft.builders.filler.pattern;
import buildcraft.api.core.IBox; import buildcraft.api.core.IBox;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
public class FillerFlattener extends FillerPattern { public class PatternFlatten extends FillerPattern {
public PatternFlatten() {
super("flatten");
}
@Override @Override
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
@ -32,15 +32,4 @@ public class FillerFlattener extends FillerPattern {
} }
return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj); return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj);
} }
@SideOnly(Side.CLIENT)
@Override
public Icon getTexture() {
return BuilderProxyClient.fillerFlattenTexture;
}
@Override
public String getName() {
return "Flatten";
}
} }

View file

@ -5,16 +5,17 @@
* 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.builders; package buildcraft.builders.filler.pattern;
import buildcraft.api.core.IBox; import buildcraft.api.core.IBox;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
public class FillerHorizon extends FillerPattern { public class PatternHorizon extends FillerPattern {
public PatternHorizon() {
super("horizon");
}
@Override @Override
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
@ -30,15 +31,4 @@ public class FillerHorizon extends FillerPattern {
} }
return !empty(xMin, yMin, zMin, xMax, tile.worldObj.getActualHeight(), zMax, tile.worldObj); return !empty(xMin, yMin, zMin, xMax, tile.worldObj.getActualHeight(), zMax, tile.worldObj);
} }
@SideOnly(Side.CLIENT)
@Override
public Icon getTexture() {
return BuilderProxyClient.fillerHorizonTexture;
}
@Override
public String getName() {
return "Horizon";
}
} }

View file

@ -1,22 +1,21 @@
/** /**
* Copyright (c) SpaceToad, 2011 * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public * BuildCraft is distributed under the terms of the Minecraft Mod Public License
* License 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.builders.filler.pattern;
package buildcraft.builders;
import buildcraft.api.core.IBox; import buildcraft.api.core.IBox;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
public class FillerFillPyramid extends FillerPattern { public class PatternPyramid extends FillerPattern {
public PatternPyramid() {
super("pyramid");
}
@Override @Override
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
@ -58,16 +57,4 @@ public class FillerFillPyramid extends FillerPattern {
return true; return true;
} }
@Override
@SideOnly(Side.CLIENT)
public Icon getTexture() {
return BuilderProxyClient.fillerPyramidTexture;
}
@Override
public String getName() {
return "Pyramid";
}
} }

View file

@ -1,22 +1,21 @@
/** /**
* Copyright (c) SpaceToad, 2011 * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public * BuildCraft is distributed under the terms of the Minecraft Mod Public License
* License 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.builders.filler.pattern;
package buildcraft.builders;
import buildcraft.api.core.IBox; import buildcraft.api.core.IBox;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
public class FillerFillStairs extends FillerPattern { public class PatternStairs extends FillerPattern {
public PatternStairs() {
super("stairs");
}
@Override @Override
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) { public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
@ -46,7 +45,7 @@ public class FillerFillStairs extends FillerPattern {
int kind = 0; int kind = 0;
int steps[] = new int[] { 0, 0, 0, 0 }; int steps[] = new int[]{0, 0, 0, 0};
int x = 0, z = 0; int x = 0, z = 0;
int stepDiagX = 0, stepDiagZ = 0; int stepDiagX = 0, stepDiagZ = 0;
@ -189,16 +188,4 @@ public class FillerFillStairs extends FillerPattern {
return true; return true;
} }
@Override
@SideOnly(Side.CLIENT)
public Icon getTexture() {
return BuilderProxyClient.fillerStairsTexture;
}
@Override
public String getName() {
return "Stairs";
}
} }

View file

@ -1,79 +1,69 @@
/** /**
* Copyright (c) SpaceToad, 2011 * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public * BuildCraft is distributed under the terms of the Minecraft Mod Public License
* License 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.builders.gui; package buildcraft.builders.gui;
import buildcraft.builders.TileFiller;
import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.gui.BuildCraftContainer;
import buildcraft.core.gui.slots.SlotLimited; import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.gui.widgets.Widget;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerFiller extends BuildCraftContainer { public class ContainerFiller extends BuildCraftContainer {
IInventory playerIInventory; IInventory playerIInventory;
IInventory fillerInventory; TileFiller tile;
public ContainerFiller(IInventory playerInventory, IInventory fillerInventory) { private class PatternWidget extends Widget {
super(fillerInventory.getSizeInventory());
public PatternWidget() {
super(80, 30, 0, 0, 16, 16);
}
@SideOnly(Side.CLIENT)
@Override
public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) {
gui.bindTexture(TextureMap.locationBlocksTexture);
gui.drawTexturedModelRectFromIcon(guiX + x, guiY + y, tile.currentPattern.getIcon(), 16, 16);
}
}
public ContainerFiller(IInventory playerInventory, TileFiller tile) {
super(tile.getSizeInventory());
this.playerIInventory = playerInventory; this.playerIInventory = playerInventory;
this.fillerInventory = fillerInventory; this.tile = tile;
for (int k = 0; k < 3; k++) { addWidget(new PatternWidget());
for (int j1 = 0; j1 < 3; j1++) {
addSlotToContainer(new SlotLimited(fillerInventory, j1 + k * 3, 31 + j1 * 18, 16 + k * 18, 1)); for (int y = 0; y < 3; y++) {
for (int x = 0; x < 9; x++) {
addSlotToContainer(new Slot(tile, x + y * 9, 8 + x * 18, 85 + y * 18));
} }
} }
for (int k = 0; k < 3; k++) { for (int y = 0; y < 3; y++) {
for (int j1 = 0; j1 < 9; j1++) { for (int x = 0; x < 9; x++) {
addSlotToContainer(new Slot(fillerInventory, 9 + j1 + k * 9, 8 + j1 * 18, 85 + k * 18)); addSlotToContainer(new Slot(playerInventory, x + y * 9 + 9, 8 + x * 18, 153 + y * 18));
}
}
for (int l = 0; l < 3; l++) {
for (int k1 = 0; k1 < 9; k1++) {
addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 153 + l * 18));
} }
} }
for (int i1 = 0; i1 < 9; i1++) { for (int x = 0; x < 9; x++) {
addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 211)); addSlotToContainer(new Slot(playerInventory, x, 8 + x * 18, 211));
} }
} }
@Override @Override
public boolean canInteractWith(EntityPlayer entityplayer) { public boolean canInteractWith(EntityPlayer entityplayer) {
return fillerInventory.isUseableByPlayer(entityplayer); return tile.isUseableByPlayer(entityplayer);
} }
@Override
public ItemStack transferStackInSlot(EntityPlayer pl, int i) {
ItemStack itemstack = null;
Slot slot = (Slot) inventorySlots.get(i);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (i < getInventorySize()) {
if (!mergeItemStack(itemstack1, getInventorySize(), inventorySlots.size(), true))
return null;
} else if (!mergeItemStack(itemstack1, 9, getInventorySize(), false))
return null;
if (itemstack1.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
}
return itemstack;
}
} }

View file

@ -33,7 +33,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
BptPlayerIndex index; BptPlayerIndex index;
public GuiBlueprintLibrary(EntityPlayer player, TileBlueprintLibrary library) { public GuiBlueprintLibrary(EntityPlayer player, TileBlueprintLibrary library) {
super(new ContainerBlueprintLibrary(player, library), library); super(new ContainerBlueprintLibrary(player, library), library, TEXTURE);
this.player = player; this.player = player;
xSize = 176; xSize = 176;
ySize = 225; ySize = 225;

View file

@ -26,7 +26,7 @@ public class GuiBuilder extends GuiAdvancedInterface {
TileBuilder builder; TileBuilder builder;
public GuiBuilder(IInventory playerInventory, TileBuilder builder) { public GuiBuilder(IInventory playerInventory, TileBuilder builder) {
super(new ContainerBuilder(playerInventory, builder), builder); super(new ContainerBuilder(playerInventory, builder), builder, TEXTURE);
this.playerInventory = playerInventory; this.playerInventory = playerInventory;
this.builder = builder; this.builder = builder;
xSize = 176; xSize = 176;

View file

@ -7,88 +7,63 @@
*/ */
package buildcraft.builders.gui; package buildcraft.builders.gui;
import buildcraft.api.filler.FillerManager;
import buildcraft.builders.TileFiller; import buildcraft.builders.TileFiller;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.gui.GuiTools;
import buildcraft.core.gui.buttons.GuiBetterButton;
import buildcraft.core.gui.buttons.StandardButtonTextureSets;
import buildcraft.core.network.PacketGuiReturn;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.gui.GuiButton;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiFiller extends GuiBuildCraft { public class GuiFiller extends GuiBuildCraft {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filler.png"); private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filler.png");
private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture;
IInventory playerInventory; IInventory playerInventory;
TileFiller filler; TileFiller filler;
public GuiFiller(IInventory playerInventory, TileFiller filler) { public GuiFiller(IInventory playerInventory, TileFiller filler) {
super(new ContainerFiller(playerInventory, filler), filler); super(new ContainerFiller(playerInventory, filler), filler, TEXTURE);
this.playerInventory = playerInventory; this.playerInventory = playerInventory;
this.filler = filler; this.filler = filler;
xSize = 175; xSize = 175;
ySize = 240; ySize = 240;
} }
@Override
public void initGui() {
super.initGui();
buttonList.clear();
int w = (width - xSize) / 2;
int h = (height - ySize) / 2;
buttonList.add(new GuiBetterButton(0, w + 80 - 18, h + 30, 10, StandardButtonTextureSets.LEFT_BUTTON, ""));
buttonList.add(new GuiBetterButton(1, w + 80 + 16 + 8, h + 30, 10, StandardButtonTextureSets.RIGHT_BUTTON, ""));
}
@Override
protected void actionPerformed(GuiButton button) {
super.actionPerformed(button);
if (button.id == 0)
filler.currentPattern = FillerManager.registry.getPreviousPattern(filler.currentPattern);
if (button.id == 1)
filler.currentPattern = FillerManager.registry.getNextPattern(filler.currentPattern);
PacketGuiReturn pkt = new PacketGuiReturn(filler);
pkt.sendPacket();
}
@Override @Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) { protected void drawGuiContainerForegroundLayer(int par1, int par2) {
String title = StringUtils.localize("tile.fillerBlock"); String title = StringUtils.localize("tile.fillerBlock");
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.filling.resources"), 8, 74, 0x404040); fontRenderer.drawString(StringUtils.localize("gui.filling.resources"), 8, 74, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, 142, 0x404040); fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, 142, 0x404040);
GuiTools.drawCenteredString(fontRenderer, filler.currentPattern.getDisplayName(), 56);
if (filler.currentPattern != null) {
drawForegroundSelection(filler.currentPattern.getName());
}
} }
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(TEXTURE);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if (filler.currentPattern != null) {
mc.renderEngine.bindTexture(BLOCK_TEXTURE);
drawTexturedModelRectFromIcon(guiLeft + patternSymbolX, guiTop + patternSymbolY, filler.currentPattern.getTexture(), 16, 16);
}
}
public boolean intersectsWith(int i, int j) {
if (i >= patternSymbolX && i <= patternSymbolX + 16 && j >= patternSymbolY && j <= patternSymbolY + 16)
return true;
return false;
}
protected void drawForegroundSelection(String tag) {
if (!intersectsWith(lastX - guiLeft, lastY - guiTop))
return;
if (tag.length() > 0) {
int i2 = (lastX - guiLeft) + 12;
int k2 = lastY - guiTop - 12;
int l2 = fontRenderer.getStringWidth(tag);
drawGradientRect(i2 - 3, k2 - 3, i2 + l2 + 3, k2 + 8 + 3, 0xc0000000, 0xc0000000);
fontRenderer.drawStringWithShadow(tag, i2, k2, -1);
}
}
@Override
protected void mouseMovedOrUp(int i, int j, int k) {
super.mouseMovedOrUp(i, j, k);
lastX = i;
lastY = j;
}
private int lastX = 0;
private int lastY = 0;
public final int patternSymbolX = 125;
public final int patternSymbolY = 34;
} }

View file

@ -29,7 +29,7 @@ public class GuiTemplate extends GuiBuildCraft {
boolean editMode = false; boolean editMode = false;
public GuiTemplate(IInventory playerInventory, TileArchitect template) { public GuiTemplate(IInventory playerInventory, TileArchitect template) {
super(new ContainerTemplate(playerInventory, template), template); super(new ContainerTemplate(playerInventory, template), template, TEXTURE);
this.playerInventory = playerInventory; this.playerInventory = playerInventory;
this.template = template; this.template = template;
xSize = 175; xSize = 175;

View file

@ -0,0 +1,37 @@
/**
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.builders.triggers;
import buildcraft.api.filler.IFillerPattern;
import buildcraft.core.triggers.*;
import net.minecraft.util.Icon;
public class ActionFiller extends BCAction {
public final IFillerPattern pattern;
public ActionFiller(IFillerPattern pattern) {
super(0, "filler:" + pattern.getUniqueTag());
this.pattern = pattern;
}
@Override
public String getDescription() {
return "Pattern: " + pattern.getDisplayName();
}
@Override
public Icon getIcon() {
return pattern.getIcon();
}
@Override
public int getTextureMap() {
return 0;
}
}

View file

@ -0,0 +1,25 @@
package buildcraft.builders.triggers;
import buildcraft.api.filler.FillerManager;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionProvider;
import buildcraft.builders.TileFiller;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public class BuildersActionProvider implements IActionProvider {
@Override
public LinkedList<IAction> getNeighborActions(Block block, TileEntity tile) {
LinkedList<IAction> actions = new LinkedList<IAction>();
if (tile instanceof TileFiller) {
actions.addAll(FillerManager.registry.getActions());
}
return actions;
}
}

View file

@ -4,17 +4,30 @@ import buildcraft.core.utils.Utils;
import java.util.Random; import java.util.Random;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
public abstract class BlockBuildCraft extends BlockContainer { public abstract class BlockBuildCraft extends BlockContainer {
protected static boolean keepInventory = false; protected static boolean keepInventory = false;
protected Random rand; protected final Random rand = new Random();
protected BlockBuildCraft(int id, Material material) { protected BlockBuildCraft(int id, Material material) {
super(id, material); super(id, material);
this.rand = new Random();
setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
setHardness(5F);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, entity, stack);
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileBuildCraft) {
((TileBuildCraft) tile).onBlockPlacedBy(entity, stack);
}
} }
@Override @Override
@ -23,4 +36,11 @@ public abstract class BlockBuildCraft extends BlockContainer {
super.breakBlock(world, x, y, z, par5, par6); super.breakBlock(world, x, y, z, par5, par6);
} }
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof IMachine && ((IMachine) tile).isActive())
return super.getLightValue(world, x, y, z) + 8;
return super.getLightValue(world, x, y, z);
}
} }

View file

@ -18,7 +18,7 @@ public class BlockSpring extends Block {
public enum EnumSpring { public enum EnumSpring {
WATER(5, -1, Block.waterStill), WATER(5, -1, Block.waterStill),
OIL(6000, 32, null); // Set in BuildCraftEnergy OIL(6000, 8, null); // Set in BuildCraftEnergy
public static final EnumSpring[] VALUES = values(); public static final EnumSpring[] VALUES = values();
public final int tickRate, chance; public final int tickRate, chance;
public Block liquidBlock; public Block liquidBlock;

View file

@ -1,12 +1,10 @@
/** /**
* Copyright (c) SpaceToad, 2011 * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public * BuildCraft is distributed under the terms of the Minecraft Mod Public License
* License 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.core; package buildcraft.core;
import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.IAreaProvider;
@ -16,6 +14,9 @@ import buildcraft.api.core.Position;
import buildcraft.core.network.TileNetworkData; import buildcraft.core.network.TileNetworkData;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -27,7 +28,6 @@ public class Box implements IBox {
int xMin, yMin, zMin, xMax, yMax, zMax; int xMin, yMin, zMin, xMax, yMax, zMax;
public @TileNetworkData public @TileNetworkData
boolean initialized; boolean initialized;
private EntityBlock lasers[]; private EntityBlock lasers[];
public Box() { public Box() {
@ -57,8 +57,8 @@ public class Box implements IBox {
this.xMax = xMax; this.xMax = xMax;
this.yMax = yMax; this.yMax = yMax;
this.zMax = zMax; this.zMax = zMax;
initialized = !(xMin == Integer.MAX_VALUE || yMin == Integer.MAX_VALUE || zMin == Integer.MAX_VALUE || xMax == Integer.MAX_VALUE || initialized = !(xMin == Integer.MAX_VALUE || yMin == Integer.MAX_VALUE || zMin == Integer.MAX_VALUE || xMax == Integer.MAX_VALUE
yMax == Integer.MAX_VALUE || zMax == Integer.MAX_VALUE ); || yMax == Integer.MAX_VALUE || zMax == Integer.MAX_VALUE);
} }
public void initialize(Box box) { public void initialize(Box box) {
@ -224,6 +224,30 @@ public class Box implements IBox {
} }
} }
public void writeToStream(DataOutputStream stream) throws IOException {
stream.writeBoolean(initialized);
stream.writeInt(xMin);
stream.writeInt(yMin);
stream.writeInt(zMin);
stream.writeInt(xMax);
stream.writeInt(yMax);
stream.writeInt(zMax);
}
public void readFromStream(DataInputStream stream) throws IOException {
initialized = stream.readBoolean();
xMin = stream.readInt();
yMin = stream.readInt();
zMin = stream.readInt();
xMax = stream.readInt();
yMax = stream.readInt();
zMax = stream.readInt();
}
public void writeToNBT(NBTTagCompound nbttagcompound) { public void writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("xMin", xMin); nbttagcompound.setInteger("xMin", xMin);
@ -239,5 +263,4 @@ public class Box implements IBox {
public String toString() { public String toString() {
return "{" + xMin + ", " + xMax + "}, {" + yMin + ", " + yMax + "}, {" + zMin + ", " + zMax + "}"; return "{" + xMin + ", " + xMax + "}, {" + yMin + ", " + yMax + "}, {" + zMin + ", " + zMax + "}";
} }
} }

View file

@ -63,6 +63,7 @@ public class DefaultProps {
public static int PIPE_ITEMS_QUARTZ_ID = 19168; public static int PIPE_ITEMS_QUARTZ_ID = 19168;
public static int PIPE_ITEMS_LAPIS_ID = 19169; public static int PIPE_ITEMS_LAPIS_ID = 19169;
public static int PIPE_ITEMS_DAIZULI_ID = 19170; public static int PIPE_ITEMS_DAIZULI_ID = 19170;
public static int PIPE_ITEMS_EMZULI_ID = 19171;
public static int PIPE_LIQUIDS_WOOD_ID = 19180; public static int PIPE_LIQUIDS_WOOD_ID = 19180;
public static int PIPE_LIQUIDS_COBBLESTONE_ID = 19181; public static int PIPE_LIQUIDS_COBBLESTONE_ID = 19181;

View file

@ -19,6 +19,7 @@ public class GuiIds {
public static final int PIPE_DIAMOND = 50; public static final int PIPE_DIAMOND = 50;
public static final int GATES = 51; public static final int GATES = 51;
public static final int PIPE_EMERALD_ITEM = 52; public static final int PIPE_EMERALD_ITEM = 52;
public static final int PIPE_LOGEMERALD_ITEM = 53;
public static final int FILTERED_BUFFER = 60; public static final int FILTERED_BUFFER = 60;
} }

View file

@ -38,19 +38,23 @@ public class InterModComms {
public static void processFacadeIMC(IMCEvent event, IMCMessage m) { public static void processFacadeIMC(IMCEvent event, IMCMessage m) {
try { try {
Splitter splitter = Splitter.on("@").trimResults(); if (m.isStringMessage()) {
Splitter splitter = Splitter.on("@").trimResults();
String[] array = Iterables.toArray(splitter.split(m.getStringValue()), String.class); String[] array = Iterables.toArray(splitter.split(m.getStringValue()), String.class);
if (array.length != 2) { 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())); Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
} else { } else {
ItemFacade.addFacade(new ItemStack(blId, 1, metaId)); Integer blId = Ints.tryParse(array[0]);
Integer metaId = Ints.tryParse(array[1]);
if (blId == null || metaId == null) {
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
} else {
ItemFacade.addFacade(new ItemStack(blId, 1, metaId));
}
} }
} else if (m.isItemStackMessage()) {
ItemFacade.addFacade(m.getItemStackValue());
} }
} catch (Exception ex) { } catch (Exception ex) {

View file

@ -19,6 +19,10 @@ import buildcraft.core.utils.Utils;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -32,6 +36,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
private final TilePacketWrapper descriptionPacket; private final TilePacketWrapper descriptionPacket;
private final TilePacketWrapper updatePacket; private final TilePacketWrapper updatePacket;
private boolean init = false; private boolean init = false;
private String owner = "[BuildCraft]";
public TileBuildCraft() { public TileBuildCraft() {
if (!updateWrappers.containsKey(this.getClass())) { if (!updateWrappers.containsKey(this.getClass())) {
@ -47,6 +52,10 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
} }
public String getOwner() {
return owner;
}
@Override @Override
public void updateEntity() { public void updateEntity() {
if (!init && !isInvalid()) { if (!init && !isInvalid()) {
@ -70,6 +79,11 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
Utils.handleBufferedDescription(this); Utils.handleBufferedDescription(this);
} }
public void onBlockPlacedBy(EntityLivingBase entity, ItemStack stack) {
if (entity instanceof EntityPlayer)
owner = ((EntityPlayer) entity).username;
}
public void destroy() { public void destroy() {
} }
@ -110,6 +124,19 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
public void postPacketHandling(PacketUpdate packet) { public void postPacketHandling(PacketUpdate packet) {
} }
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setString("owner", owner);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
if (nbt.hasKey("owner"))
owner = nbt.getString("owner");
}
public boolean isInvNameLocalized() { public boolean isInvNameLocalized() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;

View file

@ -0,0 +1,28 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.fluids;
import buildcraft.core.utils.StringUtils;
import net.minecraftforge.fluids.Fluid;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class BCFluid extends Fluid {
public BCFluid(String name) {
super(name);
}
@Override
public String getLocalizedName() {
return StringUtils.localize("fluid." + fluidName);
}
}

View file

@ -23,6 +23,7 @@ import net.minecraftforge.fluids.FluidTank;
public class Tank extends FluidTank { public class Tank extends FluidTank {
private final String name; private final String name;
public int colorRenderCache = 0xFFFFFF;
public Tank(String name, int capacity, TileEntity tile) { public Tank(String name, int capacity, TileEntity tile) {
super(capacity); super(capacity);

View file

@ -115,6 +115,7 @@ public class TankManager<T extends Tank> extends ForwardingList<T> implements IF
if (fluidStack != null && fluidStack.getFluid() != null) { if (fluidStack != null && fluidStack.getFluid() != null) {
data.writeShort(fluidStack.getFluid().getID()); data.writeShort(fluidStack.getFluid().getID());
data.writeInt(fluidStack.amount); data.writeInt(fluidStack.amount);
data.writeInt(fluidStack.getFluid().getColor(fluidStack));
} else { } else {
data.writeShort(-1); data.writeShort(-1);
} }
@ -125,10 +126,13 @@ public class TankManager<T extends Tank> extends ForwardingList<T> implements IF
public void readData(DataInputStream data) throws IOException { public void readData(DataInputStream data) throws IOException {
for (Tank tank : tanks) { for (Tank tank : tanks) {
int fluidId = data.readShort(); int fluidId = data.readShort();
if (fluidId > 0) if (fluidId > 0) {
tank.setFluid(new FluidStack(fluidId, data.readInt())); tank.setFluid(new FluidStack(fluidId, data.readInt()));
else tank.colorRenderCache = data.readInt();
} else {
tank.setFluid(null); tank.setFluid(null);
tank.colorRenderCache = 0xFFFFFF;
}
} }
} }
} }

View file

@ -9,21 +9,71 @@ package buildcraft.core.gui;
import buildcraft.core.gui.slots.IPhantomSlot; import buildcraft.core.gui.slots.IPhantomSlot;
import buildcraft.core.gui.slots.SlotBase; import buildcraft.core.gui.slots.SlotBase;
import buildcraft.core.gui.widgets.Widget;
import buildcraft.core.inventory.StackHelper; import buildcraft.core.inventory.StackHelper;
import buildcraft.core.network.PacketGuiWidget;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public abstract class BuildCraftContainer extends Container { public abstract class BuildCraftContainer extends Container {
private List<Widget> widgets = new ArrayList<Widget>();
private int inventorySize; private int inventorySize;
public BuildCraftContainer(int inventorySize) { public BuildCraftContainer(int inventorySize) {
this.inventorySize = inventorySize; this.inventorySize = inventorySize;
} }
public List<Widget> getWidgets() {
return widgets;
}
public void addSlot(Slot slot) {
addSlotToContainer(slot);
}
public void addWidget(Widget widget) {
widget.addToContainer(this);
widgets.add(widget);
}
public void sendWidgetDataToClient(Widget widget, ICrafting player, byte[] data) {
PacketGuiWidget pkt = new PacketGuiWidget(windowId, widgets.indexOf(widget), data);
PacketDispatcher.sendPacketToPlayer(pkt.getPacket(), (Player) player);
}
public void handleWidgetClientData(int widgetId, DataInputStream data) throws IOException {
widgets.get(widgetId).handleClientPacketData(data);
}
@Override
public void addCraftingToCrafters(ICrafting player) {
super.addCraftingToCrafters(player);
for (Widget widget : widgets) {
widget.initWidget(player);
}
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (Widget widget : widgets) {
for (ICrafting player : (List<ICrafting>) crafters) {
widget.updateWidget(player);
}
}
}
@Override @Override
public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) { public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) {
Slot slot = slotNum < 0 ? null : (Slot) this.inventorySlots.get(slotNum); Slot slot = slotNum < 0 ? null : (Slot) this.inventorySlots.get(slotNum);

View file

@ -110,8 +110,8 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
} }
public AdvancedSlot[] slots; public AdvancedSlot[] slots;
public GuiAdvancedInterface(BuildCraftContainer container, IInventory inventory) { public GuiAdvancedInterface(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) {
super(container, inventory); super(container, inventory, texture);
} }
public int getSlotAtLocation(int i, int j) { public int getSlotAtLocation(int i, int j) {

View file

@ -1,14 +1,15 @@
package buildcraft.core.gui; package buildcraft.core.gui;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.gui.buttons.GuiBetterButton;
import buildcraft.core.gui.slots.IPhantomSlot; import buildcraft.core.gui.slots.IPhantomSlot;
import buildcraft.core.gui.slots.SlotBase; import buildcraft.core.gui.tooltips.IToolTipProvider;
import buildcraft.core.gui.slots.SlotPhantom;
import buildcraft.core.gui.tooltips.ToolTip; import buildcraft.core.gui.tooltips.ToolTip;
import buildcraft.core.gui.tooltips.ToolTipLine; import buildcraft.core.gui.tooltips.ToolTipLine;
import buildcraft.core.gui.widgets.Widget;
import buildcraft.core.utils.SessionVars; import buildcraft.core.utils.SessionVars;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
@ -22,8 +23,239 @@ import org.lwjgl.opengl.GL11;
public abstract class GuiBuildCraft extends GuiContainer { public abstract class GuiBuildCraft extends GuiContainer {
public static final ResourceLocation LEDGER_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/ledger.png"); public static final ResourceLocation LEDGER_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/ledger.png");
// / LEDGERS public final LedgerManager ledgerManager = new LedgerManager(this);
protected LedgerManager ledgerManager = new LedgerManager(this); public final TileEntity tile;
public final ResourceLocation texture;
public final BuildCraftContainer container;
public GuiBuildCraft(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) {
super(container);
this.container = container;
this.texture = texture;
if (inventory instanceof TileEntity) {
tile = (TileEntity) inventory;
} else {
tile = null;
}
initLedgers(inventory);
}
protected void initLedgers(IInventory inventory) {
}
/**
* Draws the screen and all the components in it.
*/
@Override
public void drawScreen(int mouseX, int mouseY, float par3) {
super.drawScreen(mouseX, mouseY, par3);
int left = this.guiLeft;
int top = this.guiTop;
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glPushMatrix();
GL11.glTranslatef((float) left, (float) top, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderHelper.disableStandardItemLighting();
InventoryPlayer playerInv = this.mc.thePlayer.inventory;
if (playerInv.getItemStack() == null) {
drawToolTips(container.getWidgets(), mouseX, mouseY);
drawToolTips(buttonList, mouseX, mouseY);
drawToolTips(inventorySlots.inventorySlots, mouseX, mouseY);
}
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
private void drawToolTips(Collection objects, int mouseX, int mouseY) {
for (Object obj : objects) {
if (!(obj instanceof IToolTipProvider))
continue;
IToolTipProvider provider = (IToolTipProvider) obj;
if (!provider.isToolTipVisible())
continue;
ToolTip tips = provider.getToolTip();
if (tips == null)
continue;
boolean mouseOver = provider.isMouseOver(mouseX - guiLeft, mouseY - guiTop);
tips.onTick(mouseOver);
if (mouseOver && tips.isReady()) {
tips.refresh();
drawToolTips(tips, mouseX, mouseY);
}
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
bindTexture(texture);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
int mX = mouseX - guiLeft;
int mY = mouseY - guiTop;
for (Widget widget : container.getWidgets()) {
if (widget.hidden)
continue;
bindTexture(texture);
widget.draw(this, x, y, mX, mY);
}
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
ledgerManager.drawLedgers(par1, par2);
}
protected int getCenteredOffset(String string) {
return getCenteredOffset(string, xSize);
}
protected int getCenteredOffset(String string, int xWidth) {
return (xWidth - fontRenderer.getStringWidth(string)) / 2;
}
/**
* Returns if the passed mouse position is over the specified slot.
*/
private boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) {
int left = this.guiLeft;
int top = this.guiTop;
mouseX -= left;
mouseY -= top;
return mouseX >= slot.xDisplayPosition - 1 && mouseX < slot.xDisplayPosition + 16 + 1 && mouseY >= slot.yDisplayPosition - 1 && mouseY < slot.yDisplayPosition + 16 + 1;
}
// / MOUSE CLICKS
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
int mX = mouseX - guiLeft;
int mY = mouseY - guiTop;
for (Widget widget : container.getWidgets()) {
if (widget.hidden)
continue;
if (!widget.isMouseOver(mX, mY))
continue;
if (widget.handleMouseClick(mX, mY, mouseButton))
return;
}
super.mouseClicked(mouseX, mouseY, mouseButton);
// / Handle ledger clicks
ledgerManager.handleMouseClicked(mouseX, mouseY, mouseButton);
}
@Override
protected void mouseClickMove(int mouseX, int mouseY, int mouseButton, long time) {
int mX = mouseX - guiLeft;
int mY = mouseY - guiTop;
for (Widget widget : container.getWidgets()) {
if (widget.hidden)
continue;
widget.handleMouseMove(mX, mY, mouseButton, time);
}
Slot slot = getSlotAtPosition(mouseX, mouseY);
if (mouseButton == 1 && slot instanceof IPhantomSlot)
return;
super.mouseClickMove(mouseX, mouseY, mouseButton, time);
}
@Override
protected void mouseMovedOrUp(int mouseX, int mouseY, int eventType) {
super.mouseMovedOrUp(mouseX, mouseY, eventType);
int mX = mouseX - guiLeft;
int mY = mouseY - guiTop;
for (Widget widget : container.getWidgets()) {
if (widget.hidden)
continue;
widget.handleMouseRelease(mX, mY, eventType);
}
}
public Slot getSlotAtPosition(int x, int y) {
for (int slotIndex = 0; slotIndex < this.inventorySlots.inventorySlots.size(); ++slotIndex) {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(slotIndex);
if (isMouseOverSlot(slot, x, y))
return slot;
}
return null;
}
public void bindTexture(ResourceLocation texture) {
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
}
private void drawToolTips(ToolTip toolTips, int mouseX, int mouseY) {
if (toolTips.size() > 0) {
int left = this.guiLeft;
int top = this.guiTop;
int lenght = 0;
int x;
int y;
for (ToolTipLine tip : toolTips) {
y = this.fontRenderer.getStringWidth(tip.text);
if (y > lenght) {
lenght = y;
}
}
x = mouseX - left + 12;
y = mouseY - top - 12;
int var14 = 8;
if (toolTips.size() > 1) {
var14 += 2 + (toolTips.size() - 1) * 10;
}
this.zLevel = 300.0F;
itemRenderer.zLevel = 300.0F;
int var15 = -267386864;
this.drawGradientRect(x - 3, y - 4, x + lenght + 3, y - 3, var15, var15);
this.drawGradientRect(x - 3, y + var14 + 3, x + lenght + 3, y + var14 + 4, var15, var15);
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y + var14 + 3, var15, var15);
this.drawGradientRect(x - 4, y - 3, x - 3, y + var14 + 3, var15, var15);
this.drawGradientRect(x + lenght + 3, y - 3, x + lenght + 4, y + var14 + 3, var15, var15);
int var16 = 1347420415;
int var17 = (var16 & 16711422) >> 1 | var16 & -16777216;
this.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + var14 + 3 - 1, var16, var17);
this.drawGradientRect(x + lenght + 2, y - 3 + 1, x + lenght + 3, y + var14 + 3 - 1, var16, var17);
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y - 3 + 1, var16, var16);
this.drawGradientRect(x - 3, y + var14 + 2, x + lenght + 3, y + var14 + 3, var17, var17);
for (ToolTipLine tip : toolTips) {
String line = tip.text;
if (tip.color == -1) {
line = "\u00a77" + line;
} else {
line = "\u00a7" + Integer.toHexString(tip.color) + line;
}
this.fontRenderer.drawStringWithShadow(line, x, y, -1);
y += 10 + tip.getSpacing();
}
this.zLevel = 0.0F;
itemRenderer.zLevel = 0.0F;
}
}
protected class LedgerManager { protected class LedgerManager {
@ -228,187 +460,4 @@ public abstract class GuiBuildCraft extends GuiContainer {
drawTexturedModelRectFromIcon(x, y, icon, 16, 16); drawTexturedModelRectFromIcon(x, y, icon, 16, 16);
} }
} }
protected TileEntity tile;
public GuiBuildCraft(BuildCraftContainer container, IInventory inventory) {
super(container);
if (inventory instanceof TileEntity) {
tile = (TileEntity) inventory;
}
initLedgers(inventory);
}
protected void initLedgers(IInventory inventory) {
}
/**
* Draws the screen and all the components in it.
*/
@Override
public void drawScreen(int mouseX, int mouseY, float par3) {
super.drawScreen(mouseX, mouseY, par3);
int left = this.guiLeft;
int top = this.guiTop;
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glPushMatrix();
GL11.glTranslatef((float) left, (float) top, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderHelper.disableStandardItemLighting();
InventoryPlayer playerInv = this.mc.thePlayer.inventory;
if (playerInv.getItemStack() == null) {
for (Object button : buttonList) {
if (!(button instanceof GuiBetterButton)) {
continue;
}
GuiBetterButton betterButton = (GuiBetterButton) button;
ToolTip tips = betterButton.getToolTip();
if (tips == null) {
continue;
}
boolean mouseOver = betterButton.isMouseOverButton(mouseX, mouseY);
tips.onTick(mouseOver);
if (mouseOver && tips.isReady()) {
tips.refresh();
drawToolTips(tips, mouseX, mouseY);
}
}
}
for (Object obj : inventorySlots.inventorySlots) {
if (!(obj instanceof SlotBase)) {
continue;
}
SlotBase slot = (SlotBase) obj;
if (slot.getStack() != null) {
continue;
}
ToolTip tips = slot.getToolTip();
if (tips == null) {
continue;
}
boolean mouseOver = isMouseOverSlot(slot, mouseX, mouseY);
tips.onTick(mouseOver);
if (mouseOver && tips.isReady()) {
tips.refresh();
drawToolTips(tips, mouseX, mouseY);
}
}
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
ledgerManager.drawLedgers(par1, par2);
}
protected int getCenteredOffset(String string) {
return getCenteredOffset(string, xSize);
}
protected int getCenteredOffset(String string, int xWidth) {
return (xWidth - fontRenderer.getStringWidth(string)) / 2;
}
/**
* Returns if the passed mouse position is over the specified slot.
*/
private boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) {
int left = this.guiLeft;
int top = this.guiTop;
mouseX -= left;
mouseY -= top;
return mouseX >= slot.xDisplayPosition - 1 && mouseX < slot.xDisplayPosition + 16 + 1 && mouseY >= slot.yDisplayPosition - 1 && mouseY < slot.yDisplayPosition + 16 + 1;
}
// / MOUSE CLICKS
@Override
protected void mouseClicked(int par1, int par2, int mouseButton) {
super.mouseClicked(par1, par2, mouseButton);
// / Handle ledger clicks
ledgerManager.handleMouseClicked(par1, par2, mouseButton);
}
@Override
protected void mouseClickMove(int x, int y, int mouseButton, long time) {
Slot slot = getSlotAtPosition(x, y);
if (mouseButton == 1 && slot instanceof IPhantomSlot)
return;
super.mouseClickMove(x, y, mouseButton, time);
}
public Slot getSlotAtPosition(int x, int y) {
for (int slotIndex = 0; slotIndex < this.inventorySlots.inventorySlots.size(); ++slotIndex) {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(slotIndex);
if (isMouseOverSlot(slot, x, y))
return slot;
}
return null;
}
private void drawToolTips(ToolTip toolTips, int mouseX, int mouseY) {
if (toolTips.size() > 0) {
int left = this.guiLeft;
int top = this.guiTop;
int lenght = 0;
int x;
int y;
for (ToolTipLine tip : toolTips) {
y = this.fontRenderer.getStringWidth(tip.text);
if (y > lenght) {
lenght = y;
}
}
x = mouseX - left + 12;
y = mouseY - top - 12;
int var14 = 8;
if (toolTips.size() > 1) {
var14 += 2 + (toolTips.size() - 1) * 10;
}
this.zLevel = 300.0F;
itemRenderer.zLevel = 300.0F;
int var15 = -267386864;
this.drawGradientRect(x - 3, y - 4, x + lenght + 3, y - 3, var15, var15);
this.drawGradientRect(x - 3, y + var14 + 3, x + lenght + 3, y + var14 + 4, var15, var15);
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y + var14 + 3, var15, var15);
this.drawGradientRect(x - 4, y - 3, x - 3, y + var14 + 3, var15, var15);
this.drawGradientRect(x + lenght + 3, y - 3, x + lenght + 4, y + var14 + 3, var15, var15);
int var16 = 1347420415;
int var17 = (var16 & 16711422) >> 1 | var16 & -16777216;
this.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + var14 + 3 - 1, var16, var17);
this.drawGradientRect(x + lenght + 2, y - 3 + 1, x + lenght + 3, y + var14 + 3 - 1, var16, var17);
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y - 3 + 1, var16, var16);
this.drawGradientRect(x - 3, y + var14 + 2, x + lenght + 3, y + var14 + 3, var17, var17);
for (ToolTipLine tip : toolTips) {
String line = tip.text;
if (tip.color == -1) {
line = "\u00a77" + line;
} else {
line = "\u00a7" + Integer.toHexString(tip.color) + line;
}
this.fontRenderer.drawStringWithShadow(line, x, y, -1);
y += 10 + tip.getSpacing();
}
this.zLevel = 0.0F;
itemRenderer.zLevel = 0.0F;
}
}
} }

View file

@ -0,0 +1,48 @@
package buildcraft.core.gui;
import buildcraft.core.gui.buttons.GuiBetterButton;
import java.util.List;
import net.minecraft.client.gui.FontRenderer;
public class GuiTools {
public static void drawCenteredString(FontRenderer fr, String s, int y) {
drawCenteredString(fr, s, y, 176);
}
public static void drawCenteredString(FontRenderer fr, String s, int y, int guiWidth) {
drawCenteredString(fr, s, y, guiWidth, 0x404040, false);
}
public static void drawCenteredString(FontRenderer fr, String s, int y, int guiWidth, int color, boolean shadow) {
int sWidth = fr.getStringWidth(s);
int sPos = guiWidth / 2 - sWidth / 2;
fr.drawString(s, sPos, y, color, shadow);
}
public static void newButtonRowAuto(List buttonList, int xStart, int xSize, List<? extends GuiBetterButton> buttons) {
int buttonWidth = 0;
for (GuiBetterButton b : buttons) {
buttonWidth += b.getWidth();
}
int remaining = xSize - buttonWidth;
int spacing = remaining / (buttons.size() + 1);
int pointer = 0;
for (GuiBetterButton b : buttons) {
pointer += spacing;
b.xPosition = xStart + pointer;
pointer += b.getWidth();
buttonList.add(b);
}
}
public static void newButtonRow(List buttonList, int xStart, int spacing, List<? extends GuiBetterButton> buttons) {
int pointer = 0;
for (GuiBetterButton b : buttons) {
b.xPosition = xStart + pointer;
pointer += b.getWidth() + spacing;
buttonList.add(b);
}
}
}

View file

@ -1,6 +1,7 @@
package buildcraft.core.gui.buttons; package buildcraft.core.gui.buttons;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.gui.tooltips.IToolTipProvider;
import buildcraft.core.gui.tooltips.ToolTip; import buildcraft.core.gui.tooltips.ToolTip;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -15,7 +16,7 @@ import org.lwjgl.opengl.GL11;
* @author CovertJaguar <railcraft.wikispaces.com> * @author CovertJaguar <railcraft.wikispaces.com>
*/ */
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GuiBetterButton extends GuiButton { public class GuiBetterButton extends GuiButton implements IToolTipProvider {
public static final ResourceLocation BUTTON_TEXTURES = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/buttons.png"); public static final ResourceLocation BUTTON_TEXTURES = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/buttons.png");
protected final IButtonTextureSet texture; protected final IButtonTextureSet texture;
@ -80,6 +81,7 @@ public class GuiBetterButton extends GuiButton {
drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (h - 8) / 2, getTextColor(mouseOver)); drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (h - 8) / 2, getTextColor(mouseOver));
} }
@Override
public ToolTip getToolTip() { public ToolTip getToolTip() {
return toolTip; return toolTip;
} }
@ -87,4 +89,14 @@ public class GuiBetterButton extends GuiButton {
public void setToolTip(ToolTip tips) { public void setToolTip(ToolTip tips) {
this.toolTip = tips; this.toolTip = tips;
} }
@Override
public boolean isToolTipVisible() {
return drawButton;
}
@Override
public boolean isMouseOver(int mouseX, int mouseY) {
return isMouseOverButton(mouseX, mouseY);
}
} }

View file

@ -7,7 +7,9 @@ package buildcraft.core.gui.buttons;
public enum StandardButtonTextureSets implements IButtonTextureSet { public enum StandardButtonTextureSets implements IButtonTextureSet {
LARGE_BUTTON(0, 0, 20, 200), LARGE_BUTTON(0, 0, 20, 200),
SMALL_BUTTON(0, 80, 15, 200); SMALL_BUTTON(0, 80, 15, 200),
LEFT_BUTTON(204, 0, 16, 10),
RIGHT_BUTTON(214, 0, 16, 10);
private final int x, y, height, width; private final int x, y, height, width;
private StandardButtonTextureSets(int x, int y, int height, int width) { private StandardButtonTextureSets(int x, int y, int height, int width) {

View file

@ -7,6 +7,7 @@
*/ */
package buildcraft.core.gui.slots; package buildcraft.core.gui.slots;
import buildcraft.core.gui.tooltips.IToolTipProvider;
import buildcraft.core.gui.tooltips.ToolTip; import buildcraft.core.gui.tooltips.ToolTip;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
@ -15,7 +16,7 @@ import net.minecraft.inventory.Slot;
* *
* @author CovertJaguar <http://www.railcraft.info> * @author CovertJaguar <http://www.railcraft.info>
*/ */
public class SlotBase extends Slot { public class SlotBase extends Slot implements IToolTipProvider {
private ToolTip toolTips; private ToolTip toolTips;
@ -30,6 +31,7 @@ public class SlotBase extends Slot {
/** /**
* @return the toolTips * @return the toolTips
*/ */
@Override
public ToolTip getToolTip() { public ToolTip getToolTip() {
return toolTips; return toolTips;
} }
@ -40,4 +42,14 @@ public class SlotBase extends Slot {
public void setToolTips(ToolTip toolTips) { public void setToolTips(ToolTip toolTips) {
this.toolTips = toolTips; this.toolTips = toolTips;
} }
@Override
public boolean isToolTipVisible() {
return getStack() == null;
}
@Override
public boolean isMouseOver(int mouseX, int mouseY) {
return mouseX >= xDisplayPosition && mouseX <= xDisplayPosition + 16 && mouseY >= yDisplayPosition && mouseY <= yDisplayPosition + 16;
}
} }

View file

@ -0,0 +1,14 @@
package buildcraft.core.gui.tooltips;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public interface IToolTipProvider {
ToolTip getToolTip();
boolean isToolTipVisible();
boolean isMouseOver(int mouseX, int mouseY);
}

View file

@ -0,0 +1,61 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.gui.widgets;
import buildcraft.core.gui.GuiBuildCraft;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class ButtonWidget extends Widget {
private boolean pressed;
private int buttonPressed;
public ButtonWidget(int x, int y, int u, int v, int w, int h) {
super(x, y, u, v, w, h);
}
@Override
public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) {
int vv = pressed ? v + h : v;
gui.drawTexturedModalRect(guiX + x, guiY + y, u, vv, w, h);
}
@Override
public final boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) {
pressed = true;
buttonPressed = mouseButton;
onPress(buttonPressed);
return true;
}
@Override
public final void handleMouseRelease(int mouseX, int mouseY, int eventType) {
if (pressed) {
pressed = false;
onRelease(buttonPressed);
}
}
@Override
public final void handleMouseMove(int mouseX, int mouseY, int mouseButton, long time) {
if (pressed && !isMouseOver(mouseX, mouseY)) {
pressed = false;
onRelease(buttonPressed);
}
}
public void onPress(int mouseButton) {
}
public void onRelease(int mouseButton) {
}
}

View file

@ -0,0 +1,58 @@
package buildcraft.core.gui.widgets;
import buildcraft.core.fluids.Tank;
import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.gui.tooltips.ToolTip;
import buildcraft.core.render.FluidRenderer;
import net.minecraft.util.Icon;
import net.minecraftforge.fluids.FluidStack;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public class FluidGaugeWidget extends Widget {
public final Tank tank;
public FluidGaugeWidget(Tank tank, int x, int y, int u, int v, int w, int h) {
super(x, y, u, v, w, h);
this.tank = tank;
}
@Override
public ToolTip getToolTip() {
return tank.getToolTip();
}
@Override
public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) {
if (tank == null)
return;
FluidStack fluidStack = tank.getFluid();
if (fluidStack == null || fluidStack.amount <= 0 || fluidStack.getFluid() == null)
return;
Icon liquidIcon = FluidRenderer.getFluidTexture(fluidStack, false);
if (liquidIcon == null)
return;
float scale = Math.min(fluidStack.amount, tank.getCapacity()) / (float) tank.getCapacity();
gui.bindTexture(FluidRenderer.getFluidSheet(fluidStack));
for (int col = 0; col < w / 16; col++) {
for (int row = 0; row <= h / 16; row++) {
gui.drawTexturedModelRectFromIcon(guiX + x + col * 16, guiY + y + row * 16 - 1, liquidIcon, 16, 16);
}
}
gui.bindTexture(gui.texture);
gui.drawTexturedModalRect(guiX + x, guiY + y - 1, x, y - 1, w, h - (int) Math.floor(h * scale) + 1);
gui.drawTexturedModalRect(guiX + x, guiY + y, u, v, w, h);
}
}

View file

@ -0,0 +1,16 @@
package buildcraft.core.gui.widgets;
import buildcraft.core.gui.tooltips.ToolTip;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public interface IIndicatorController {
ToolTip getToolTip();
int getScaledLevel(int size);
}

View file

@ -0,0 +1,31 @@
package buildcraft.core.gui.widgets;
import buildcraft.core.gui.tooltips.ToolTip;
import buildcraft.core.gui.tooltips.ToolTipLine;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public abstract class IndicatorController implements IIndicatorController {
private final ToolTip tips = new ToolTip() {
@Override
public void refresh() {
refreshToolTip();
}
};
protected ToolTipLine tip = new ToolTipLine();
public IndicatorController() {
tips.add(tip);
}
protected void refreshToolTip() {
}
@Override
public final ToolTip getToolTip() {
return tips;
}
}

View file

@ -0,0 +1,33 @@
package buildcraft.core.gui.widgets;
import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.gui.tooltips.ToolTip;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public class IndicatorWidget extends Widget {
public final IIndicatorController controller;
public IndicatorWidget(IIndicatorController controller, int x, int y, int u, int v, int w, int h) {
super(x, y, u, v, w, h);
this.controller = controller;
}
@Override
@SideOnly(Side.CLIENT)
public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) {
int scale = controller.getScaledLevel(h);
gui.drawTexturedModalRect(guiX + x, guiY + y + h - scale, u, v + h - scale, w, scale);
}
@Override
public ToolTip getToolTip() {
return controller.getToolTip();
}
}

View file

@ -0,0 +1,92 @@
/**
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.gui.widgets;
import buildcraft.core.gui.BuildCraftContainer;
import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.gui.tooltips.IToolTipProvider;
import buildcraft.core.gui.tooltips.ToolTip;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.io.DataInputStream;
import java.io.IOException;
import net.minecraft.inventory.ICrafting;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class Widget implements IToolTipProvider {
public final int x;
public final int y;
public final int u;
public final int v;
public final int w;
public final int h;
public boolean hidden;
protected BuildCraftContainer container;
public Widget(int x, int y, int u, int v, int w, int h) {
this.x = x;
this.y = y;
this.u = u;
this.v = v;
this.w = w;
this.h = h;
}
public void addToContainer(BuildCraftContainer container) {
this.container = container;
}
@SideOnly(Side.CLIENT)
@Override
public final boolean isMouseOver(int mouseX, int mouseY) {
return mouseX >= x - 1 && mouseX < x + w + 1 && mouseY >= y - 1 && mouseY < y + h + 1;
}
@SideOnly(Side.CLIENT)
public boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) {
return false;
}
@SideOnly(Side.CLIENT)
public void handleMouseRelease(int mouseX, int mouseY, int eventType) {
}
@SideOnly(Side.CLIENT)
public void handleMouseMove(int mouseX, int mouseY, int mouseButton, long time) {
}
@SideOnly(Side.CLIENT)
public void handleClientPacketData(DataInputStream data) throws IOException {
}
@SideOnly(Side.CLIENT)
public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) {
gui.drawTexturedModalRect(guiX + x, guiY + y, u, v, w, h);
}
@SideOnly(Side.CLIENT)
@Override
public ToolTip getToolTip() {
return null;
}
@Override
public boolean isToolTipVisible() {
return true;
}
public void initWidget(ICrafting player) {
}
public void updateWidget(ICrafting player) {
}
}

View file

@ -21,12 +21,17 @@ public class InventoryIterator {
if (inv instanceof ISidedInventory) { if (inv instanceof ISidedInventory) {
return new InventoryIteratorSided((ISidedInventory) inv, side); return new InventoryIteratorSided((ISidedInventory) inv, side);
} }
return new InventoryIteratorSimple(inv); return new InventoryIteratorSimple(inv);
} }
public interface IInvSlot { public interface IInvSlot {
/**
* Returns the slot number of the underlying Inventory.
*
* @return the slot number
*/
int getIndex(); int getIndex();
boolean canPutStackInSlot(ItemStack stack); boolean canPutStackInSlot(ItemStack stack);

View file

@ -14,7 +14,7 @@ import net.minecraft.world.World;
public abstract interface IGuiReturnHandler { public abstract interface IGuiReturnHandler {
public World getWorld(); public World getWorld();
public void writeGuiData(DataOutputStream paramDataOutputStream) throws IOException; public void writeGuiData(DataOutputStream data) throws IOException;
public void readGuiData(DataInputStream paramDataInputStream, EntityPlayer paramEntityPlayer) throws IOException; public void readGuiData(DataInputStream data, EntityPlayer player) throws IOException;
} }

View file

@ -0,0 +1,59 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.network;
import buildcraft.core.gui.BuildCraftContainer;
import cpw.mods.fml.client.FMLClientHandler;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.client.entity.EntityClientPlayerMP;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class PacketGuiWidget extends BuildCraftPacket {
private byte windowId, widgetId;
private byte[] payload;
public PacketGuiWidget() {
super();
}
public PacketGuiWidget(int windowId, int widgetId, byte[] data) {
this.windowId = (byte) windowId;
this.widgetId = (byte) widgetId;
this.payload = data;
}
@Override
public void writeData(DataOutputStream data) throws IOException {
data.writeByte(windowId);
data.writeByte(widgetId);
data.write(payload);
}
@Override
public void readData(DataInputStream data) throws IOException {
windowId = data.readByte();
widgetId = data.readByte();
EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer;
if (player.openContainer instanceof BuildCraftContainer && player.openContainer.windowId == windowId)
((BuildCraftContainer) player.openContainer).handleWidgetClientData(widgetId, data);
}
@Override
public int getID() {
return PacketIds.GUI_WIDGET;
}
}

View file

@ -37,27 +37,32 @@ public class PacketHandler implements IPacketHandler {
int packetID = data.read(); int packetID = data.read();
switch (packetID) { switch (packetID) {
case PacketIds.TILE_UPDATE: { case PacketIds.TILE_UPDATE: {
PacketTileUpdate packetT = new PacketTileUpdate(); PacketTileUpdate pkt = new PacketTileUpdate();
packetT.readData(data); pkt.readData(data);
onTileUpdate((EntityPlayer) player, packetT); onTileUpdate((EntityPlayer) player, pkt);
break; break;
} }
case PacketIds.STATE_UPDATE: { case PacketIds.STATE_UPDATE: {
PacketTileState inPacket = new PacketTileState(); PacketTileState pkt = new PacketTileState();
inPacket.readData(data); pkt.readData(data);
World world = ((EntityPlayer) player).worldObj; World world = ((EntityPlayer) player).worldObj;
TileEntity tile = world.getBlockTileEntity(inPacket.posX, inPacket.posY, inPacket.posZ); TileEntity tile = world.getBlockTileEntity(pkt.posX, pkt.posY, pkt.posZ);
if (tile instanceof ISyncedTile) { if (tile instanceof ISyncedTile) {
inPacket.applyStates(data, (ISyncedTile) tile); pkt.applyStates(data, (ISyncedTile) tile);
} }
break; break;
} }
case PacketIds.GUI_RETURN: { case PacketIds.GUI_RETURN: {
PacketGuiReturn packet1 = new PacketGuiReturn((EntityPlayer) player); PacketGuiReturn pkt = new PacketGuiReturn((EntityPlayer) player);
packet1.readData(data); pkt.readData(data);
// onGuiReturn((EntityPlayer) player, packet1); break;
}
case PacketIds.GUI_WIDGET: {
PacketGuiWidget pkt = new PacketGuiWidget();
pkt.readData(data);
break; break;
} }
} }

View file

@ -36,6 +36,7 @@ public class PacketIds {
public static final int SELECTION_ADVANCED_WORKBENCH = 71; public static final int SELECTION_ADVANCED_WORKBENCH = 71;
public static final int GUI_RETURN = 80; public static final int GUI_RETURN = 80;
public static final int GUI_WIDGET = 81;
public static final int STATE_UPDATE = 100; public static final int STATE_UPDATE = 100;
} }

View file

@ -35,7 +35,7 @@ public abstract class BCAction implements IAction {
return this.legacyId; return this.legacyId;
} }
public int getIconIndex(){ public int getIconIndex() {
return 0; return 0;
} }
@ -45,6 +45,10 @@ public abstract class BCAction implements IAction {
return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex()); return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex());
} }
public int getTextureMap() {
return 1;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) { public void registerIcons(IconRegister iconRegister) {

View file

@ -10,8 +10,12 @@ package buildcraft.core.utils;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftEnergy; import buildcraft.BuildCraftEnergy;
import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.BuildCraftAPI;
import buildcraft.core.proxy.CoreProxy;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockFluid; import net.minecraft.block.BlockFluid;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
@ -22,12 +26,14 @@ import net.minecraft.network.packet.Packet60Explosion;
import net.minecraft.world.ChunkPosition; import net.minecraft.world.ChunkPosition;
import net.minecraft.world.Explosion; import net.minecraft.world.Explosion;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidBlock;
public class BlockUtil { public class BlockUtil {
public static List<ItemStack> getItemStackFromBlock(World world, int i, int j, int k) { public static List<ItemStack> getItemStackFromBlock(World world, int i, int j, int k) {
@ -41,7 +47,19 @@ public class BlockUtil {
int meta = world.getBlockMetadata(i, j, k); int meta = world.getBlockMetadata(i, j, k);
return block.getBlockDropped(world, i, j, k, meta, 0); ArrayList<ItemStack> dropsList = block.getBlockDropped(world, i, j, k, meta, 0);
float dropChance = ForgeEventFactory.fireBlockHarvesting(dropsList, world, block, i, j, k, meta, 0, 1.0F, false, CoreProxy.proxy.getBuildCraftPlayer(world));
ArrayList<ItemStack> returnList = new ArrayList<ItemStack>();
for (ItemStack s : dropsList)
{
if (world.rand.nextFloat() <= dropChance)
{
returnList.add(s);
}
}
return returnList;
} }
public static void breakBlock(World world, int x, int y, int z) { public static void breakBlock(World world, int x, int y, int z) {
@ -50,8 +68,7 @@ public class BlockUtil {
public static void breakBlock(World world, int x, int y, int z, int forcedLifespan) { public static void breakBlock(World world, int x, int y, int z, int forcedLifespan) {
if (!world.isAirBlock(x, y, z) && BuildCraftCore.dropBrokenBlocks && !world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) { if (!world.isAirBlock(x, y, z) && BuildCraftCore.dropBrokenBlocks && !world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
int blockId = world.getBlockId(x, y, z); List<ItemStack> items = getItemStackFromBlock(world, x, y, z);
List<ItemStack> items = Block.blocksList[blockId].getBlockDropped(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
for (ItemStack item : items) { for (ItemStack item : items) {
float var = 0.7F; float var = 0.7F;

View file

@ -157,7 +157,7 @@ public enum EnumColor {
return NAMES[ordinal()]; return NAMES[ordinal()];
} }
public String getTranslatedName() { public String getLocalizedName() {
return StringUtils.localize(getTag()); return StringUtils.localize(getTag());
} }

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.utils;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class MathUtils {
public static float clamp(float value, float min, float max) {
return value < min ? min : (value > max ? max : value);
}
public static double clamp(double value, double min, double max) {
return value < min ? min : (value > max ? max : value);
}
}

View file

@ -0,0 +1,65 @@
/**
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.utils;
import com.google.common.collect.ForwardingCollection;
import java.util.*;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public class RevolvingList<T> extends ForwardingCollection<T> {
private Deque<T> list = new LinkedList<T>();
public RevolvingList() {
}
public RevolvingList(Collection<? extends T> collection) {
list.addAll(collection);
}
@Override
protected Collection<T> delegate() {
return list;
}
public void rotateLeft() {
if (list.isEmpty())
return;
list.addFirst(list.removeLast());
}
public void rotateRight() {
if (list.isEmpty())
return;
list.addLast(list.removeFirst());
}
public T getCurrent() {
if (list.isEmpty())
return null;
return list.getFirst();
}
public void setCurrent(T e) {
if (!contains(e))
return;
if (e == null) {
while (getCurrent() != null) {
rotateRight();
}
} else {
while (getCurrent() == null || !getCurrent().equals(e)) {
rotateRight();
}
}
}
}

View file

@ -8,13 +8,12 @@
package buildcraft.energy; package buildcraft.energy;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.BlockBuildCraft;
import buildcraft.core.IItemPipe; import buildcraft.core.IItemPipe;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@ -25,7 +24,7 @@ import net.minecraft.util.Icon;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
public class BlockEngine extends BlockContainer { public class BlockEngine extends BlockBuildCraft {
private static Icon woodTexture; private static Icon woodTexture;
private static Icon stoneTexture; private static Icon stoneTexture;
@ -33,9 +32,6 @@ public class BlockEngine extends BlockContainer {
public BlockEngine(int i) { public BlockEngine(int i) {
super(i, Material.iron); super(i, Material.iron);
setHardness(5F);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
setUnlocalizedName("engineBlock"); setUnlocalizedName("engineBlock");
} }

View file

@ -11,7 +11,6 @@ import java.util.LinkedList;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.ICrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -45,8 +44,8 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
public static float COOLDOWN_RATE = 0.05F; public static float COOLDOWN_RATE = 0.05F;
public static int MAX_COOLANT_PER_TICK = 40; public static int MAX_COOLANT_PER_TICK = 40;
int burnTime = 0; int burnTime = 0;
private Tank tankFuel = new Tank("tankFuel", MAX_LIQUID, this); public Tank tankFuel = new Tank("tankFuel", MAX_LIQUID, this);
private Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this); public Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this);
private TankManager tankManager = new TankManager(); private TankManager tankManager = new TankManager();
private Fuel currentFuel = null; private Fuel currentFuel = null;
public int penaltyCooling = 0; public int penaltyCooling = 0;
@ -71,9 +70,9 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
return false; return false;
} }
ItemStack current = player.getCurrentEquippedItem(); ItemStack current = player.getCurrentEquippedItem();
if (current != null && current.itemID != Item.bucketEmpty.itemID) { if (current != null) {
if (CoreProxy.proxy.isSimulating(worldObj)) { if (CoreProxy.proxy.isSimulating(worldObj)) {
if (FluidUtils.handleRightClick(this, side, player, true, false)) { if (FluidUtils.handleRightClick(this, side, player, true, true)) {
return true; return true;
} }
} else { } else {
@ -292,7 +291,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
tankFuel.getFluid().amount = value; tankFuel.getFluid().amount = value;
} }
break; break;
// Fluid coolant amount // Fluid Coolant amount
case 18: case 18:
if (tankCoolant.getFluid() == null) { if (tankCoolant.getFluid() == null) {
tankCoolant.setFluid(new FluidStack(0, value)); tankCoolant.setFluid(new FluidStack(0, value));
@ -300,6 +299,14 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
tankCoolant.getFluid().amount = value; tankCoolant.getFluid().amount = value;
} }
break; break;
//Fluid Fuel color
case 19:
tankFuel.colorRenderCache = value;
break;
//Fluid Coolant color
case 20:
tankCoolant.colorRenderCache = value;
break;
} }
} }
@ -310,6 +317,8 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
iCrafting.sendProgressBarUpdate(containerEngine, 16, tankCoolant.getFluid() != null ? tankCoolant.getFluid().fluidID : 0); iCrafting.sendProgressBarUpdate(containerEngine, 16, tankCoolant.getFluid() != null ? tankCoolant.getFluid().fluidID : 0);
iCrafting.sendProgressBarUpdate(containerEngine, 17, tankFuel.getFluid() != null ? tankFuel.getFluid().amount : 0); iCrafting.sendProgressBarUpdate(containerEngine, 17, tankFuel.getFluid() != null ? tankFuel.getFluid().amount : 0);
iCrafting.sendProgressBarUpdate(containerEngine, 18, tankCoolant.getFluid() != null ? tankCoolant.getFluid().amount : 0); iCrafting.sendProgressBarUpdate(containerEngine, 18, tankCoolant.getFluid() != null ? tankCoolant.getFluid().amount : 0);
iCrafting.sendProgressBarUpdate(containerEngine, 19, tankFuel.colorRenderCache);
iCrafting.sendProgressBarUpdate(containerEngine, 20, tankCoolant.colorRenderCache);
} }
@Override @Override
@ -320,18 +329,23 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
/* ITANKCONTAINER */ /* ITANKCONTAINER */
@Override @Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return null; return tankFuel.drain(maxDrain, doDrain);
} }
@Override @Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
if (resource == null)
return null;
if (tankCoolant.getFluidType() == resource.getFluid())
return tankCoolant.drain(resource.amount, doDrain);
if (tankFuel.getFluidType() == resource.getFluid())
return tankFuel.drain(resource.amount, doDrain);
return null; return null;
} }
@Override @Override
public boolean canDrain(ForgeDirection from, Fluid fluid) { public boolean canDrain(ForgeDirection from, Fluid fluid) {
// TODO Auto-generated method stub return true;
return false;
} }
@Override @Override

View file

@ -7,16 +7,16 @@
*/ */
package buildcraft.energy.gui; package buildcraft.energy.gui;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.fluids.Tank;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import buildcraft.energy.TileEngineIron; import buildcraft.energy.TileEngineIron;
import buildcraft.energy.TileEngineWithInventory; import buildcraft.energy.TileEngineWithInventory;
@ -27,7 +27,7 @@ public class GuiCombustionEngine extends GuiEngine {
private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture;
public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) { public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) {
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine); super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine, TEXTURE);
} }
@Override @Override
@ -40,24 +40,22 @@ public class GuiCombustionEngine extends GuiEngine {
@Override @Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); super.drawGuiContainerBackgroundLayer(f, x, y);
mc.renderEngine.bindTexture(TEXTURE);
int j = (width - xSize) / 2; int j = (width - xSize) / 2;
int k = (height - ySize) / 2; int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
TileEngineIron engine = (TileEngineIron) tile; TileEngineIron engine = (TileEngineIron) tile;
if (engine.getScaledBurnTime(58) > 0) { if (engine.getScaledBurnTime(58) > 0) {
displayGauge(j, k, 19, 104, engine.getScaledBurnTime(58), engine.getFuel()); displayGauge(j, k, 19, 104, engine.getScaledBurnTime(58), engine.getFuel(), engine.tankFuel);
} }
if (engine.getScaledCoolant(58) > 0) { if (engine.getScaledCoolant(58) > 0) {
displayGauge(j, k, 19, 122, engine.getScaledCoolant(58), engine.getCoolant()); displayGauge(j, k, 19, 122, engine.getScaledCoolant(58), engine.getCoolant(), engine.tankCoolant);
} }
} }
private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid) { private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid, Tank tank) {
if (liquid == null) { if (liquid == null) {
return; return;
} }
@ -65,11 +63,16 @@ public class GuiCombustionEngine extends GuiEngine {
Icon liquidIcon = null; Icon liquidIcon = null;
Fluid fluid = liquid.getFluid(); Fluid fluid = liquid.getFluid();
int color = tank.colorRenderCache;
if (fluid != null && fluid.getStillIcon() != null) { if (fluid != null && fluid.getStillIcon() != null) {
liquidIcon = fluid.getStillIcon(); liquidIcon = fluid.getStillIcon();
} }
mc.renderEngine.bindTexture(BLOCK_TEXTURE); mc.renderEngine.bindTexture(BLOCK_TEXTURE);
float red = (float) (color >> 16 & 255) / 255.0F;
float green = (float) (color >> 8 & 255) / 255.0F;
float blue = (float) (color & 255) / 255.0F;
GL11.glColor4f(red, green, blue, 1.0F);
if (liquidIcon != null) { if (liquidIcon != null) {
while (true) { while (true) {
int x; int x;
@ -91,6 +94,7 @@ public class GuiCombustionEngine extends GuiEngine {
} }
} }
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(TEXTURE); mc.renderEngine.bindTexture(TEXTURE);
drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60); drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60);
} }

View file

@ -57,8 +57,8 @@ public abstract class GuiEngine extends GuiBuildCraft {
} }
} }
public GuiEngine(BuildCraftContainer container, IInventory inventory) { public GuiEngine(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) {
super(container, inventory); super(container, inventory, texture);
} }
@Override @Override

View file

@ -22,7 +22,7 @@ public class GuiStoneEngine extends GuiEngine {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/steam_engine_gui.png"); private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/steam_engine_gui.png");
public GuiStoneEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) { public GuiStoneEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) {
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine); super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine, TEXTURE);
} }
@Override @Override

View file

@ -8,12 +8,12 @@
package buildcraft.factory; package buildcraft.factory;
import buildcraft.api.tools.IToolWrench; import buildcraft.api.tools.IToolWrench;
import buildcraft.core.BlockBuildCraft;
import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -23,7 +23,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockFloodGate extends BlockContainer { public class BlockFloodGate extends BlockBuildCraft {
private Icon textureTop; private Icon textureTop;
private Icon textureBottom; private Icon textureBottom;
@ -31,8 +31,6 @@ public class BlockFloodGate extends BlockContainer {
public BlockFloodGate(int i) { public BlockFloodGate(int i) {
super(i, Material.iron); super(i, Material.iron);
setHardness(5F);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
} }
@Override @Override

View file

@ -23,7 +23,6 @@ public class BlockHopper extends BlockBuildCraft {
public BlockHopper(int blockId) { public BlockHopper(int blockId) {
super(blockId, Material.iron); super(blockId, Material.iron);
setHardness(5F);
} }
@Override @Override

View file

@ -1,43 +0,0 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.factory;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.IMachine;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
public abstract class BlockMachineRoot extends BlockContainer {
protected BlockMachineRoot(int i, Material material) {
super(i, material);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
setHardness(5F);
}
@Override
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k) {
for (int x = i - 1; x <= i + 1; ++x) {
for (int y = j - 1; y <= j + 1; ++y) {
for (int z = k - 1; z <= k + 1; ++z) {
TileEntity tile = iblockaccess.getBlockTileEntity(x, y, z);
if (tile instanceof IMachine && ((IMachine) tile).isActive())
return super.getBlockBrightness(iblockaccess, i, j, k) + 0.5F;
}
}
}
return super.getBlockBrightness(iblockaccess, i, j, k);
}
}

View file

@ -11,6 +11,7 @@ package buildcraft.factory;
import buildcraft.BuildCraftFactory; import buildcraft.BuildCraftFactory;
import buildcraft.api.core.Position; import buildcraft.api.core.Position;
import buildcraft.core.BlockBuildCraft;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -24,7 +25,7 @@ import net.minecraft.util.Icon;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
public class BlockMiningWell extends BlockMachineRoot { public class BlockMiningWell extends BlockBuildCraft {
Icon textureFront, textureSides, textureBack, textureTop; Icon textureFront, textureSides, textureBack, textureTop;

View file

@ -11,7 +11,6 @@ import buildcraft.core.CoreConstants;
import buildcraft.core.IFramePipeConnection; import buildcraft.core.IFramePipeConnection;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;

View file

@ -8,12 +8,12 @@
package buildcraft.factory; package buildcraft.factory;
import buildcraft.api.tools.IToolWrench; import buildcraft.api.tools.IToolWrench;
import buildcraft.core.BlockBuildCraft;
import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -23,7 +23,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockPump extends BlockContainer { public class BlockPump extends BlockBuildCraft {
private Icon textureTop; private Icon textureTop;
private Icon textureBottom; private Icon textureBottom;
@ -31,8 +31,6 @@ public class BlockPump extends BlockContainer {
public BlockPump(int i) { public BlockPump(int i) {
super(i, Material.iron); super(i, Material.iron);
setHardness(5F);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
} }
@Override @Override
@ -83,6 +81,15 @@ public class BlockPump extends BlockContainer {
return false; return false;
} }
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int id) {
super.onNeighborBlockChange(world, x, y, z, id);
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TilePump) {
((TilePump) tile).onNeighborBlockChange(id);
}
}
@SuppressWarnings({"unchecked", "rawtypes"}) @SuppressWarnings({"unchecked", "rawtypes"})
@Override @Override
public void addCreativeItems(ArrayList itemList) { public void addCreativeItems(ArrayList itemList) {

Some files were not shown because too many files have changed in this diff Show more