Merge master into builder
|
@ -16,7 +16,6 @@ a problem that might have fixed been already. Such things makes for very grumpy
|
|||
less time coding and more time doing stuff that makes them less grumpy.
|
||||
* If the issues occurs on a server, be sure it's a vanilla forge server and <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 MineFactoryReloaded or PowerCrystalsCore will be closed on sight! They are modifying our code using core mods!
|
||||
|
||||
#### Frequently reported
|
||||
* java.lang.AbstractMethodError - Incompatibility between BC/Forge/Mod using BC API. Usually not a BC issue
|
||||
|
|
22
build.xml
|
@ -130,7 +130,7 @@
|
|||
</target>
|
||||
<target name="copy-src" depends="clean-src,initialize-version">
|
||||
<!-- Copy sources -->
|
||||
<copy todir="${mcpsrc.dir}/minecraft" verbose="true">
|
||||
<copy todir="${mcpsrc.dir}/minecraft" verbose="false">
|
||||
<fileset dir="${src.dir}/common"/>
|
||||
<filterset>
|
||||
<filter token="VERSION" value="${project.complete.version}" />
|
||||
|
@ -169,10 +169,30 @@
|
|||
<!-- Reobfuscate -->
|
||||
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
|
||||
<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 dir="${mcp.dir}" executable="sh" osfamily="unix">
|
||||
<arg value="reobfuscate_srg.sh"/>
|
||||
<redirector>
|
||||
<outputfilterchain>
|
||||
<linecontains negate="true">
|
||||
<contains value="> New"/>
|
||||
</linecontains>
|
||||
<linecontains negate="true">
|
||||
<contains value="> Outputted"/>
|
||||
</linecontains>
|
||||
</outputfilterchain>
|
||||
</redirector>
|
||||
</exec>
|
||||
|
||||
<!-- Copy classes -->
|
||||
|
|
After Width: | Height: | Size: 444 B |
Before Width: | Height: | Size: 362 B After Width: | Height: | Size: 362 B |
Before Width: | Height: | Size: 374 B After Width: | Height: | Size: 448 B |
Before Width: | Height: | Size: 375 B After Width: | Height: | Size: 452 B |
Before Width: | Height: | Size: 369 B |
After Width: | Height: | Size: 297 B |
After Width: | Height: | Size: 244 B |
After Width: | Height: | Size: 235 B |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 169 B |
After Width: | Height: | Size: 183 B |
After Width: | Height: | Size: 159 B |
After Width: | Height: | Size: 192 B |
|
@ -1,3 +1,3 @@
|
|||
#Build Number for ANT. Do not edit!
|
||||
#Sun Oct 27 08:22:33 PDT 2013
|
||||
build.number=49
|
||||
#Fri Nov 29 16:00:09 PST 2013
|
||||
build.number=50
|
||||
|
|
18
buildcraft_resources/changelog/4.2.0
Normal 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)
|
|
@ -2,6 +2,34 @@
|
|||
|
||||
chat.pipe.power.iron.mode=Switched to %d MJ/t limit
|
||||
|
||||
color.black=Black
|
||||
color.blue=Blue
|
||||
color.brown=Brown
|
||||
color.cyan=Cyan
|
||||
color.gray=Gray
|
||||
color.green=Green
|
||||
color.light.blue=Light Blue
|
||||
color.light.gray=Light Gray
|
||||
color.lime=Lime
|
||||
color.magenta=Magenta
|
||||
color.orange=Orange
|
||||
color.pink=Pink
|
||||
color.purple=Purple
|
||||
color.red=Red
|
||||
color.white=White
|
||||
color.yellow=Yellow
|
||||
|
||||
fillerpattern.clear=Clear
|
||||
fillerpattern.fill=Fill
|
||||
fillerpattern.flatten=Flatten
|
||||
fillerpattern.horizon=Horizon
|
||||
fillerpattern.pyramid=Pyramid
|
||||
fillerpattern.stairs=Stairs
|
||||
fillerpattern.box=Box
|
||||
|
||||
fluid.oil=Oil
|
||||
fluid.fuel=Fuel
|
||||
|
||||
gate.pipe.empty=Pipe Empty
|
||||
gate.pipe.containsItems=Items Traversing
|
||||
gate.pipe.containsFluids=Fluid Traversing
|
||||
|
@ -12,6 +40,8 @@ gate.engine.blue=Engine Blue
|
|||
gate.engine.green=Engine Green
|
||||
gate.engine.yellow=Engine Yellow
|
||||
gate.engine.red=Engine Red
|
||||
gate.pipe.item.color=Paint Items %s
|
||||
|
||||
gui.building.resources=Building Resources
|
||||
gui.del=Del
|
||||
gui.filling.resources=Filling Resources
|
||||
|
@ -30,6 +60,10 @@ gui.pipes.emerald.blocking=Blocking
|
|||
gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing
|
||||
gui.pipes.emerald.nonblocking=Non Blocking
|
||||
gui.pipes.emerald.nonblocking.tip=Extraction continues with the next element in filter if one element is missing
|
||||
gui.pipes.emzuli.title=Extraction Presets
|
||||
gui.pipes.emzuli.paint=Paint Items %s
|
||||
gui.pipes.emzuli.nopaint=Don't Paint Items
|
||||
|
||||
item.bucketFuel=Fuel Bucket
|
||||
item.bucketOil=Oil Bucket
|
||||
item.woodenGearItem=Wood Gear
|
||||
|
@ -73,8 +107,9 @@ item.PipeItemsGold=Golden Transport Pipe
|
|||
item.PipeItemsDiamond=Diamond Transport Pipe
|
||||
item.PipeItemsObsidian=Obsidian Transport Pipe
|
||||
item.PipeItemsEmerald=Emerald Transport Pipe
|
||||
item.PipeItemsLapis=Lapis Transport Pipe
|
||||
item.PipeItemsLapis=Lazuli Transport Pipe
|
||||
item.PipeItemsDaizuli=Daizuli Transport Pipe
|
||||
item.PipeItemsEmzuli=Emzuli Transport Pipe
|
||||
item.PipeFluidsWood=Wooden Fluid Pipe
|
||||
item.PipeFluidsCobblestone=Cobblestone Fluid Pipe
|
||||
item.PipeFluidsStone=Stone Fluid Pipe
|
||||
|
@ -149,6 +184,7 @@ tip.PipeItemsSandstone=Only connects to other pipes
|
|||
tip.PipeItemsStone=Basic pipe, medium drag\nWon't connect to Cobblestone or Quartz
|
||||
tip.PipeItemsVoid=Destroys items
|
||||
tip.PipeItemsWood=Extraction pipe
|
||||
tip.PipeItemsEmzuli=Gate controlled extraction pipe
|
||||
tip.PipePowerWood=Power Input Pipe
|
||||
tip.PipePowerIron=Selectable Limiter Pipe
|
||||
tip.PipeStructureCobblestone=Support pipe
|
||||
|
|
|
@ -27,23 +27,23 @@ import buildcraft.api.bptblocks.BptBlockSign;
|
|||
import buildcraft.api.bptblocks.BptBlockStairs;
|
||||
import buildcraft.api.bptblocks.BptBlockWallSide;
|
||||
import buildcraft.api.filler.FillerManager;
|
||||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.builders.BlockArchitect;
|
||||
import buildcraft.builders.BlockBlueprintLibrary;
|
||||
import buildcraft.builders.BlockBuilder;
|
||||
import buildcraft.builders.BlockFiller;
|
||||
import buildcraft.builders.BlockMarker;
|
||||
import buildcraft.builders.BlockPathMarker;
|
||||
import buildcraft.builders.BptBlockFiller;
|
||||
import buildcraft.builders.BuilderProxyClient;
|
||||
import buildcraft.builders.EventHandlerBuilders;
|
||||
import buildcraft.builders.FillerFillAll;
|
||||
import buildcraft.builders.FillerFillPyramid;
|
||||
import buildcraft.builders.FillerFillStairs;
|
||||
import buildcraft.builders.FillerFillWalls;
|
||||
import buildcraft.builders.FillerFlattener;
|
||||
import buildcraft.builders.FillerHorizon;
|
||||
import buildcraft.builders.FillerRegistry;
|
||||
import buildcraft.builders.FillerRemover;
|
||||
import buildcraft.builders.filler.pattern.PatternFill;
|
||||
import buildcraft.builders.filler.pattern.PatternPyramid;
|
||||
import buildcraft.builders.filler.pattern.PatternStairs;
|
||||
import buildcraft.builders.filler.pattern.PatternBox;
|
||||
import buildcraft.builders.filler.pattern.PatternFlatten;
|
||||
import buildcraft.builders.filler.pattern.PatternHorizon;
|
||||
import buildcraft.builders.filler.FillerRegistry;
|
||||
import buildcraft.builders.filler.pattern.PatternClear;
|
||||
import buildcraft.builders.GuiHandler;
|
||||
import buildcraft.builders.IBuilderHook;
|
||||
import buildcraft.builders.ItemBlueprintStandard;
|
||||
|
@ -54,13 +54,17 @@ import buildcraft.builders.TileBuilder;
|
|||
import buildcraft.builders.TileFiller;
|
||||
import buildcraft.builders.TileMarker;
|
||||
import buildcraft.builders.TilePathMarker;
|
||||
import buildcraft.builders.filler.pattern.FillerPattern;
|
||||
import buildcraft.builders.network.PacketHandlerBuilders;
|
||||
import buildcraft.builders.triggers.ActionFiller;
|
||||
import buildcraft.builders.triggers.BuildersActionProvider;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.InterModComms;
|
||||
import buildcraft.core.Version;
|
||||
import buildcraft.core.blueprints.BptPlayerIndex;
|
||||
import buildcraft.core.blueprints.BptRootIndex;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.BCLog;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
|
@ -78,7 +82,6 @@ import java.io.IOException;
|
|||
import java.util.LinkedList;
|
||||
import java.util.TreeMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -105,6 +108,7 @@ public class BuildCraftBuilders {
|
|||
public static boolean fillerDestroy;
|
||||
public static int fillerLifespanTough;
|
||||
public static int fillerLifespanNormal;
|
||||
public static ActionFiller[] fillerActions;
|
||||
private static BptRootIndex rootBptIndex;
|
||||
public static TreeMap<String, BptPlayerIndex> playerLibrary = new TreeMap<String, BptPlayerIndex>();
|
||||
private static LinkedList<IBuilderHook> hooks = new LinkedList<IBuilderHook>();
|
||||
|
@ -112,10 +116,7 @@ public class BuildCraftBuilders {
|
|||
public static BuildCraftBuilders instance;
|
||||
|
||||
@EventHandler
|
||||
public void load(FMLInitializationEvent evt) {
|
||||
// Create filler registry
|
||||
FillerManager.registry = new FillerRegistry();
|
||||
|
||||
public void init(FMLInitializationEvent evt) {
|
||||
// Register gui handler
|
||||
NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());
|
||||
|
||||
|
@ -208,7 +209,6 @@ public class BuildCraftBuilders {
|
|||
|
||||
new BptBlockWallSide(markerBlock.blockID);
|
||||
new BptBlockWallSide(pathMarkerBlock.blockID);
|
||||
new BptBlockFiller(fillerBlock.blockID);
|
||||
|
||||
if (BuildCraftCore.loadDefaultRecipes) {
|
||||
loadRecipes();
|
||||
|
@ -217,7 +217,7 @@ public class BuildCraftBuilders {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
public void initialize(FMLPreInitializationEvent evt) {
|
||||
public void preInit(FMLPreInitializationEvent evt) {
|
||||
Property templateItemId = BuildCraftCore.mainConfiguration.getItem("templateItem.id", DefaultProps.TEMPLATE_ITEM_ID);
|
||||
Property blueprintItemId = BuildCraftCore.mainConfiguration.getItem("blueprintItem.id", DefaultProps.BLUEPRINT_ITEM_ID);
|
||||
Property markerId = BuildCraftCore.mainConfiguration.getBlock("marker.id", DefaultProps.MARKER_ID);
|
||||
|
@ -286,19 +286,30 @@ public class BuildCraftBuilders {
|
|||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
// public static final Block music;
|
||||
// public static final Block cloth;
|
||||
// public static final Block tilledField;
|
||||
// public static final BlockPortal portal;
|
||||
// public static final Block trapdoor;
|
||||
// Create filler registry
|
||||
try {
|
||||
FillerManager.registry = new FillerRegistry();
|
||||
|
||||
// STANDARD BLOCKS
|
||||
// INIT FILLER PATTERNS
|
||||
FillerManager.registry.addPattern(PatternFill.INSTANCE);
|
||||
FillerManager.registry.addPattern(new PatternFlatten());
|
||||
FillerManager.registry.addPattern(new PatternHorizon());
|
||||
FillerManager.registry.addPattern(new PatternClear());
|
||||
FillerManager.registry.addPattern(new PatternBox());
|
||||
FillerManager.registry.addPattern(new PatternPyramid());
|
||||
FillerManager.registry.addPattern(new PatternStairs());
|
||||
} catch (Error error) {
|
||||
BCLog.logErrorAPI("Buildcraft", error, IFillerPattern.class);
|
||||
throw error;
|
||||
}
|
||||
|
||||
ActionManager.registerActionProvider(new BuildersActionProvider());
|
||||
}
|
||||
|
||||
public static void loadRecipes() {
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(templateItem, 1), new Object[]{"ppp", "pip", "ppp", 'i',
|
||||
new ItemStack(Item.dyePowder, 1, 0), 'p', Item.paper});
|
||||
// CoreProxy.proxy.addCraftingRecipe(new ItemStack(templateItem, 1), new Object[]{"ppp", "pip", "ppp", 'i',
|
||||
// new ItemStack(Item.dyePowder, 1, 0), 'p', Item.paper});
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), new Object[]{"ppp", "pip", "ppp", 'i',
|
||||
new ItemStack(Item.dyePowder, 1, 4), 'p', Item.paper});
|
||||
|
@ -306,34 +317,24 @@ public class BuildCraftBuilders {
|
|||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(markerBlock, 1), new Object[]{"l ", "r ", 'l',
|
||||
new ItemStack(Item.dyePowder, 1, 4), 'r', Block.torchRedstoneActive});
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(pathMarkerBlock, 1), new Object[]{"l ", "r ", 'l',
|
||||
new ItemStack(Item.dyePowder, 1, 2), 'r', Block.torchRedstoneActive});
|
||||
// CoreProxy.proxy.addCraftingRecipe(new ItemStack(pathMarkerBlock, 1), new Object[]{"l ", "r ", 'l',
|
||||
// new ItemStack(Item.dyePowder, 1, 2), 'r', Block.torchRedstoneActive});
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(fillerBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b',
|
||||
new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11),
|
||||
'c', Block.workbench, 'g', BuildCraftCore.goldGearItem, 'C', Block.chest});
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(builderBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b',
|
||||
new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11),
|
||||
'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C', Block.chest});
|
||||
// CoreProxy.proxy.addCraftingRecipe(new ItemStack(builderBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b',
|
||||
// new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11),
|
||||
// 'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C', Block.chest});
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(architectBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b',
|
||||
new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11),
|
||||
'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C',
|
||||
new ItemStack(templateItem, 1)});
|
||||
// CoreProxy.proxy.addCraftingRecipe(new ItemStack(architectBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b',
|
||||
// new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11),
|
||||
// 'c', Block.workbench, 'g', BuildCraftCore.diamondGearItem, 'C',
|
||||
// new ItemStack(templateItem, 1)});
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(libraryBlock, 1), new Object[]{"bbb", "bBb", "bbb", 'b',
|
||||
new ItemStack(blueprintItem), 'B', Block.bookShelf});
|
||||
|
||||
|
||||
// / INIT FILLER PATTERNS
|
||||
FillerManager.registry.addRecipe(new FillerFillAll(), new Object[]{"bbb", "bbb", "bbb", 'g', Block.glass, 'b', Block.brick});
|
||||
FillerManager.registry.addRecipe(new FillerFlattener(), new Object[]{"ggg", "bbb", "bbb", 'g', Block.glass, 'b', Block.brick});
|
||||
FillerManager.registry.addRecipe(new FillerHorizon(), new Object[]{"ggg", "ggg", "bbb", 'g', Block.glass, 'b', Block.brick});
|
||||
FillerManager.registry.addRecipe(new FillerRemover(), new Object[]{"ggg", "ggg", "ggg", 'g', Block.glass, 'b', Block.brick});
|
||||
FillerManager.registry.addRecipe(new FillerFillWalls(), new Object[]{"bbb", "b b", "bbb", 'g', Block.glass, 'b', Block.brick});
|
||||
FillerManager.registry.addRecipe(new FillerFillPyramid(), new Object[]{" ", " b ", "bbb", 'g', Block.glass, 'b', Block.brick});
|
||||
FillerManager.registry.addRecipe(new FillerFillStairs(), new Object[]{" b", " bb", "bbb", 'g', Block.glass, 'b', Block.brick});
|
||||
// CoreProxy.proxy.addCraftingRecipe(new ItemStack(libraryBlock, 1), new Object[]{"bbb", "bBb", "bbb", 'b',
|
||||
// new ItemStack(blueprintItem), 'B', Block.bookShelf});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -400,14 +401,9 @@ public class BuildCraftBuilders {
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void loadTextures(TextureStitchEvent.Pre evt) {
|
||||
if (evt.map.textureType == 0) {
|
||||
TextureMap terrainMap = evt.map;
|
||||
BuilderProxyClient.fillerFillAllTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/fillAll");
|
||||
BuilderProxyClient.fillerClearTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/clear");
|
||||
BuilderProxyClient.fillerWallsTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/walls");
|
||||
BuilderProxyClient.fillerStairsTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/stairs");
|
||||
BuilderProxyClient.fillerFlattenTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/flatten");
|
||||
BuilderProxyClient.fillerHorizonTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/horizon");
|
||||
BuilderProxyClient.fillerPyramidTexture = terrainMap.registerIcon("buildcraft:fillerPatterns/pyramid");
|
||||
for (FillerPattern pattern : FillerPattern.patterns) {
|
||||
pattern.registerIcon(evt.map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ import cpw.mods.fml.common.registry.TickRegistry;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6,1.7)", dependencies = "required-after:Forge@[9.10.0.800,)")
|
||||
@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6.4,1.7)", dependencies = "required-after:Forge@[9.11.1.953,)")
|
||||
@NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true)
|
||||
public class BuildCraftCore {
|
||||
public static enum RenderMode {
|
||||
|
|
|
@ -15,6 +15,7 @@ import buildcraft.core.BlockSpring;
|
|||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.InterModComms;
|
||||
import buildcraft.core.Version;
|
||||
import buildcraft.core.fluids.BCFluid;
|
||||
import buildcraft.core.network.PacketHandler;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.triggers.BCTrigger;
|
||||
|
@ -144,11 +145,12 @@ public class BuildCraftEnergy {
|
|||
|
||||
|
||||
// Oil and fuel
|
||||
buildcraftFluidOil = new Fluid("oil").setDensity(800).setViscosity(1500);
|
||||
buildcraftFluidOil = new BCFluid("oil").setDensity(800).setViscosity(1500);
|
||||
|
||||
FluidRegistry.registerFluid(buildcraftFluidOil);
|
||||
fluidOil = FluidRegistry.getFluid("oil");
|
||||
|
||||
buildcraftFluidFuel = new Fluid("fuel");
|
||||
buildcraftFluidFuel = new BCFluid("fuel");
|
||||
FluidRegistry.registerFluid(buildcraftFluidFuel);
|
||||
fluidFuel = FluidRegistry.getFluid("fuel");
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
package buildcraft;
|
||||
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.recipes.AssemblyRecipe;
|
||||
import buildcraft.api.transport.IExtractionHandler;
|
||||
|
@ -20,6 +21,7 @@ import buildcraft.core.Version;
|
|||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
import buildcraft.core.triggers.BCTrigger;
|
||||
import buildcraft.core.utils.BCLog;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.transport.BlockFilteredBuffer;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
|
@ -54,6 +56,7 @@ import buildcraft.transport.pipes.PipeItemsDiamond;
|
|||
import buildcraft.transport.pipes.PipeItemsEmerald;
|
||||
import buildcraft.transport.pipes.PipeItemsGold;
|
||||
import buildcraft.transport.pipes.PipeItemsIron;
|
||||
import buildcraft.transport.pipes.PipeItemsEmzuli;
|
||||
import buildcraft.transport.pipes.PipeItemsLapis;
|
||||
import buildcraft.transport.pipes.PipeItemsObsidian;
|
||||
import buildcraft.transport.pipes.PipeItemsQuartz;
|
||||
|
@ -71,6 +74,7 @@ import buildcraft.transport.pipes.PipePowerStone;
|
|||
import buildcraft.transport.pipes.PipePowerWood;
|
||||
import buildcraft.transport.pipes.PipeStructureCobblestone;
|
||||
import buildcraft.transport.triggers.ActionEnergyPulser;
|
||||
import buildcraft.transport.triggers.ActionExtractionPreset;
|
||||
import buildcraft.transport.triggers.ActionPipeColor;
|
||||
import buildcraft.transport.triggers.ActionPipeDirection;
|
||||
import buildcraft.transport.triggers.ActionPowerLimiter;
|
||||
|
@ -126,6 +130,7 @@ public class BuildCraftTransport {
|
|||
public static Item pipeItemsDaizuli;
|
||||
public static Item pipeItemsVoid;
|
||||
public static Item pipeItemsSandstone;
|
||||
public static Item pipeItemsEmzuli;
|
||||
public static Item pipeFluidsWood;
|
||||
public static Item pipeFluidsCobblestone;
|
||||
public static Item pipeFluidsStone;
|
||||
|
@ -170,11 +175,15 @@ public class BuildCraftTransport {
|
|||
public static BCAction[] actionPipeColor = new BCAction[16];
|
||||
public static BCAction[] actionPipeDirection = new BCAction[16];
|
||||
public static BCAction[] actionPowerLimiter = new BCAction[7];
|
||||
@Instance("BuildCraft|Transport")
|
||||
public static BuildCraftTransport instance;
|
||||
public static BCAction actionExtractionPresetRed = new ActionExtractionPreset(-1, EnumColor.RED);
|
||||
public static BCAction actionExtractionPresetBlue = new ActionExtractionPreset(-1, EnumColor.BLUE);
|
||||
public static BCAction actionExtractionPresetGreen = new ActionExtractionPreset(-1, EnumColor.GREEN);
|
||||
public static BCAction actionExtractionPresetYellow = new ActionExtractionPreset(-1, EnumColor.YELLOW);
|
||||
public IIconProvider pipeIconProvider = new PipeIconProvider();
|
||||
public IIconProvider gateIconProvider = new GateIconProvider();
|
||||
public IIconProvider wireIconProvider = new WireIconProvider();
|
||||
@Instance("BuildCraft|Transport")
|
||||
public static BuildCraftTransport instance;
|
||||
|
||||
private static class PipeRecipe {
|
||||
|
||||
|
@ -266,11 +275,10 @@ public class BuildCraftTransport {
|
|||
pipeWaterproof.setUnlocalizedName("pipeWaterproof");
|
||||
LanguageRegistry.addName(pipeWaterproof, "Pipe Sealant");
|
||||
CoreProxy.proxy.registerItem(pipeWaterproof);
|
||||
|
||||
|
||||
genericPipeBlock = new BlockGenericPipe(genericPipeId.getInt());
|
||||
CoreProxy.proxy.registerBlock(genericPipeBlock.setUnlocalizedName("pipeBlock"), ItemBlock.class);
|
||||
|
||||
// Fixing retro-compatiblity
|
||||
pipeItemsWood = buildPipe(DefaultProps.PIPE_ITEMS_WOOD_ID, PipeItemsWood.class, "Wooden Transport Pipe", "plankWood", Block.glass, "plankWood");
|
||||
pipeItemsEmerald = buildPipe(DefaultProps.PIPE_ITEMS_EMERALD_ID, PipeItemsEmerald.class, "Emerald Transport Pipe", Item.emerald, Block.glass, Item.emerald);
|
||||
pipeItemsCobblestone = buildPipe(DefaultProps.PIPE_ITEMS_COBBLESTONE_ID, PipeItemsCobblestone.class, "Cobblestone Transport Pipe", "cobblestone", Block.glass, "cobblestone");
|
||||
|
@ -284,6 +292,7 @@ public class BuildCraftTransport {
|
|||
pipeItemsDaizuli = buildPipe(DefaultProps.PIPE_ITEMS_DAIZULI_ID, PipeItemsDaizuli.class, "Daizuli Transport Pipe", Block.blockLapis, Block.glass, Item.diamond);
|
||||
pipeItemsSandstone = buildPipe(DefaultProps.PIPE_ITEMS_SANDSTONE_ID, PipeItemsSandstone.class, "Sandstone Transport Pipe", Block.sandStone, Block.glass, Block.sandStone);
|
||||
pipeItemsVoid = buildPipe(DefaultProps.PIPE_ITEMS_VOID_ID, PipeItemsVoid.class, "Void Transport Pipe", "dyeBlack", Block.glass, Item.redstone);
|
||||
pipeItemsEmzuli = buildPipe(DefaultProps.PIPE_ITEMS_EMZULI_ID, PipeItemsEmzuli.class, "Emzuli Transport Pipe", Block.blockLapis, Block.glass, Item.emerald);
|
||||
|
||||
pipeFluidsWood = buildPipe(DefaultProps.PIPE_LIQUIDS_WOOD_ID, PipeFluidsWood.class, "Wooden Waterproof Pipe", pipeWaterproof, pipeItemsWood);
|
||||
pipeFluidsCobblestone = buildPipe(DefaultProps.PIPE_LIQUIDS_COBBLESTONE_ID, PipeFluidsCobblestone.class, "Cobblestone Waterproof Pipe", pipeWaterproof, pipeItemsCobblestone);
|
||||
|
@ -313,32 +322,24 @@ public class BuildCraftTransport {
|
|||
redPipeWire.setUnlocalizedName("redPipeWire");
|
||||
LanguageRegistry.addName(redPipeWire, "Red Pipe Wire");
|
||||
CoreProxy.proxy.registerItem(redPipeWire);
|
||||
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 1), new ItemStack(Item.redstone, 1),
|
||||
new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(redPipeWire, 8)));
|
||||
|
||||
Property bluePipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "bluePipeWire.id", DefaultProps.BLUE_PIPE_WIRE);
|
||||
bluePipeWire = new ItemBuildCraft(bluePipeWireId.getInt()).setPassSneakClick(true);
|
||||
bluePipeWire.setUnlocalizedName("bluePipeWire");
|
||||
LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire");
|
||||
CoreProxy.proxy.registerItem(bluePipeWire);
|
||||
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 4), new ItemStack(Item.redstone, 1),
|
||||
new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(bluePipeWire, 8)));
|
||||
|
||||
Property greenPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "greenPipeWire.id", DefaultProps.GREEN_PIPE_WIRE);
|
||||
greenPipeWire = new ItemBuildCraft(greenPipeWireId.getInt()).setPassSneakClick(true);
|
||||
greenPipeWire.setUnlocalizedName("greenPipeWire");
|
||||
LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire");
|
||||
CoreProxy.proxy.registerItem(greenPipeWire);
|
||||
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 2), new ItemStack(Item.redstone, 1),
|
||||
new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(greenPipeWire, 8)));
|
||||
|
||||
Property yellowPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "yellowPipeWire.id", DefaultProps.YELLOW_PIPE_WIRE);
|
||||
yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()).setPassSneakClick(true);
|
||||
yellowPipeWire.setUnlocalizedName("yellowPipeWire");
|
||||
LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire");
|
||||
CoreProxy.proxy.registerItem(yellowPipeWire);
|
||||
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 11), new ItemStack(Item.redstone, 1),
|
||||
new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(yellowPipeWire, 8)));
|
||||
|
||||
Property pipeGateId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeGate.id", DefaultProps.GATE_ID);
|
||||
pipeGate = new ItemGate(pipeGateId.getInt(), 0);
|
||||
|
@ -365,9 +366,6 @@ public class BuildCraftTransport {
|
|||
filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt());
|
||||
CoreProxy.proxy.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock"));
|
||||
CoreProxy.proxy.addName(filteredBufferBlock, "Filtered Buffer");
|
||||
|
||||
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8)));
|
||||
|
||||
} finally {
|
||||
BuildCraftCore.mainConfiguration.save();
|
||||
}
|
||||
|
@ -378,7 +376,7 @@ public class BuildCraftTransport {
|
|||
// Register connection handler
|
||||
// MinecraftForge.registerConnectionHandler(new ConnectionHandler());
|
||||
|
||||
// Register gui handler
|
||||
// Register GUI handler
|
||||
// MinecraftForge.setGuiHandler(mod_BuildCraftTransport.instance, new GuiHandler());
|
||||
|
||||
TransportProxy.proxy.registerTileEntities();
|
||||
|
@ -422,7 +420,7 @@ public class BuildCraftTransport {
|
|||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
actionPipeDirection[direction.ordinal()] = new ActionPipeDirection(-1, direction);
|
||||
}
|
||||
|
||||
|
||||
for (PowerMode limit : PowerMode.VALUES) {
|
||||
actionPowerLimiter[limit.ordinal()] = new ActionPowerLimiter(-1, limit);
|
||||
}
|
||||
|
@ -436,7 +434,7 @@ public class BuildCraftTransport {
|
|||
// Add pipe recipes
|
||||
for (PipeRecipe pipe : pipeRecipes) {
|
||||
if (pipe.isShapeless) {
|
||||
CoreProxy.proxy.addShapelessRecipe(pipe.result, pipe.input);
|
||||
CoreProxy.proxy.addShapelessRecipe(pipe.result, pipe.input);
|
||||
} else {
|
||||
CoreProxy.proxy.addCraftingRecipe(pipe.result, pipe.input);
|
||||
}
|
||||
|
@ -449,11 +447,22 @@ public class BuildCraftTransport {
|
|||
|
||||
//Facade turning helper
|
||||
GameRegistry.addRecipe(facadeItem.new FacadeRecipe());
|
||||
|
||||
// Assembly table recipes, moved from PreInit phase to Init, all mods should be done adding to the OreDictionary by now
|
||||
try {
|
||||
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(redPipeWire, 8), "dyeRed", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
|
||||
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(bluePipeWire, 8), "dyeBlue", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
|
||||
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(greenPipeWire, 8), "dyeGreen", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
|
||||
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(500, new ItemStack(yellowPipeWire, 8), "dyeYellow", 1, new ItemStack(Item.redstone), new ItemStack(Item.ingotIron)));
|
||||
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8)));
|
||||
} catch (Error error) {
|
||||
BCLog.logErrorAPI("Buildcraft", error, AssemblyRecipe.class);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void processIMCRequests(IMCEvent event) {
|
||||
InterModComms.processIMC(event);
|
||||
InterModComms.processIMC(event);
|
||||
}
|
||||
|
||||
public static Item buildPipe(int defaultID, Class<? extends Pipe> clas, String descr, Object... ingredients) {
|
||||
|
|
|
@ -3,21 +3,27 @@ package buildcraft.api.filler;
|
|||
import buildcraft.api.core.IBox;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public interface IFillerPattern {
|
||||
|
||||
public int getId();
|
||||
public String getUniqueTag();
|
||||
|
||||
public void setId(int id);
|
||||
|
||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace);
|
||||
/**
|
||||
* Creates the object that does the pattern iteration. This object may be
|
||||
* state-full and will be used until the pattern is done or changes.
|
||||
*
|
||||
* @param tile the Filler
|
||||
* @param box the area to fill
|
||||
* @param orientation not currently used, but may be in the future (the filler needs some orientation code)
|
||||
* @return
|
||||
*/
|
||||
public IPatternIterator createPatternIterator(TileEntity tile, IBox box, ForgeDirection orientation);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getTexture();
|
||||
|
||||
public String getName();
|
||||
public Icon getIcon();
|
||||
|
||||
public String getDisplayName();
|
||||
}
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package buildcraft.api.filler;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import java.util.Set;
|
||||
|
||||
public interface IFillerRegistry {
|
||||
|
||||
public void addRecipe(IFillerPattern pattern, Object aobj[]);
|
||||
public void addPattern(IFillerPattern pattern);
|
||||
|
||||
public IFillerPattern findMatchingRecipe(IInventory inventorycrafting);
|
||||
public IFillerPattern getPattern(String patternName);
|
||||
|
||||
public int getPatternNumber(IFillerPattern pattern);
|
||||
|
||||
public IFillerPattern getPattern(int n);
|
||||
public IFillerPattern getNextPattern(IFillerPattern currentPattern);
|
||||
|
||||
public IFillerPattern getPreviousPattern(IFillerPattern currentPattern);
|
||||
|
||||
public Set<? extends IAction> getActions();
|
||||
}
|
||||
|
|
20
common/buildcraft/api/filler/IPatternIterator.java
Normal 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);
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
@API(apiVersion="1.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|filler")
|
||||
@API(apiVersion="2.0",owner="BuildCraftAPI|core",provides="BuildCraftAPI|filler")
|
||||
package buildcraft.api.filler;
|
||||
import cpw.mods.fml.common.API;
|
|
@ -29,7 +29,7 @@ public final class IronEngineCoolant {
|
|||
}
|
||||
|
||||
public static Coolant getCoolant(FluidStack fluidStack) {
|
||||
return fluidStack != null ? liquidCoolants.get(fluidStack.getFluid().getName()) : null;
|
||||
return fluidStack != null && fluidStack.getFluid() != null ? liquidCoolants.get(fluidStack.getFluid().getName()) : null;
|
||||
}
|
||||
|
||||
private IronEngineCoolant() {
|
||||
|
|
|
@ -47,8 +47,9 @@ public class TriggerParameter implements ITriggerParameter {
|
|||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
if (stack != null) {
|
||||
compound.setInteger("itemID", stack.itemID);
|
||||
compound.setInteger("itemDMG", stack.getItemDamage());
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
stack.writeToNBT(tagCompound);
|
||||
compound.setCompoundTag("stack", tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,11 +60,14 @@ public class TriggerParameter implements ITriggerParameter {
|
|||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
// Legacy code to prevent existing gates from losing their contents
|
||||
int itemID = compound.getInteger("itemID");
|
||||
|
||||
if (itemID != 0) {
|
||||
stack = new ItemStack(itemID, 1, compound.getInteger("itemDMG"));
|
||||
return;
|
||||
}
|
||||
|
||||
stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
46
common/buildcraft/api/power/ILaserTarget.java
Normal 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();
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class AssemblyRecipe {
|
||||
|
||||
public static LinkedList<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>();
|
||||
|
||||
public final ItemStack[] input;
|
||||
public final Object[] input;
|
||||
public final ItemStack output;
|
||||
public final float energy;
|
||||
|
||||
|
@ -17,30 +18,69 @@ public class AssemblyRecipe {
|
|||
this.energy = energy;
|
||||
}
|
||||
|
||||
public boolean canBeDone(ItemStack[] items) {
|
||||
/**
|
||||
* This version of AssemblyRecipe supports the OreDictionary
|
||||
*
|
||||
* @param input Object... containing either an ItemStack, or a paired string
|
||||
* and integer(ex: "dyeBlue", 1)
|
||||
* @param energy MJ cost to produce
|
||||
* @param output resulting ItemStack
|
||||
*/
|
||||
public AssemblyRecipe(int energy, ItemStack output, Object... input) {
|
||||
this.output = output;
|
||||
this.energy = energy;
|
||||
this.input = input;
|
||||
|
||||
for (ItemStack in : input) {
|
||||
for (int i = 0; i < input.length; i++) {
|
||||
if (input[i] instanceof String) {
|
||||
input[i] = OreDictionary.getOres((String) input[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in == null) {
|
||||
public boolean canBeDone(ItemStack... items) {
|
||||
for (int i = 0; i < input.length; i++) {
|
||||
if (input[i] == null)
|
||||
continue;
|
||||
}
|
||||
|
||||
int found = 0; // Amount of ingredient found in inventory
|
||||
if (input[i] instanceof ItemStack) {
|
||||
ItemStack requirement = (ItemStack) input[i];
|
||||
int found = 0; // Amount of ingredient found in inventory
|
||||
int expected = requirement.stackSize;
|
||||
for (ItemStack item : items) {
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
if (item.isItemEqual(requirement))
|
||||
found += item.stackSize; // Adds quantity of stack to amount found
|
||||
|
||||
for (ItemStack item : items) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.isItemEqual(in)) {
|
||||
found += item.stackSize; // Adds quantity of stack to amount
|
||||
// found
|
||||
}
|
||||
}
|
||||
// Return false if the amount of ingredient found
|
||||
// is not enough
|
||||
if (found < expected)
|
||||
return false;
|
||||
} else if (input[i] instanceof ArrayList) {
|
||||
ArrayList<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)
|
||||
return false; // Return false if the amount of ingredient found
|
||||
// is not enough
|
||||
for (ItemStack item : items) {
|
||||
if (item == null)
|
||||
continue;
|
||||
for (ItemStack oreItem : oreList) {
|
||||
if (OreDictionary.itemMatches(oreItem, item, true)) {
|
||||
found += item.stackSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return false if the amount of ingredient found
|
||||
// is not enough
|
||||
if (found < expected)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -10,7 +10,6 @@ package buildcraft.builders;
|
|||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
@ -38,7 +37,7 @@ public class BlockBuilder extends BlockContainer {
|
|||
public BlockBuilder(int i) {
|
||||
super(i, Material.iron);
|
||||
setHardness(5F);
|
||||
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
|
||||
setCreativeTab(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,29 +56,25 @@ public class BlockFiller extends BlockContainer {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "all" })
|
||||
public Icon getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) {
|
||||
int m = iblockaccess.getBlockMetadata(i, j, k);
|
||||
|
||||
if (iblockaccess == null)
|
||||
return getIcon(i, m);
|
||||
|
||||
TileEntity tile = iblockaccess.getBlockTileEntity(i, j, k);
|
||||
@Override
|
||||
public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int m = world.getBlockMetadata(x, y, z);
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile != null && tile instanceof TileFiller) {
|
||||
TileFiller filler = (TileFiller) tile;
|
||||
if (l == 1 || l == 0) {
|
||||
if (side == 1 || side == 0) {
|
||||
if (!filler.isActive())
|
||||
return textureTopOff;
|
||||
else
|
||||
return textureTopOn;
|
||||
} else if (filler.currentPattern != null)
|
||||
return filler.currentPattern.getTexture();
|
||||
return filler.currentPattern.getIcon();
|
||||
else
|
||||
return textureSides;
|
||||
}
|
||||
|
||||
return getIcon(l, m);
|
||||
return getIcon(side, m);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +1,8 @@
|
|||
package buildcraft.builders;
|
||||
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class BuilderProxyClient extends BuilderProxy {
|
||||
public static Icon fillerFillAllTexture;
|
||||
public static Icon fillerClearTexture;
|
||||
public static Icon fillerWallsTexture;
|
||||
public static Icon fillerStairsTexture;
|
||||
public static Icon fillerFlattenTexture;
|
||||
public static Icon fillerHorizonTexture;
|
||||
public static Icon fillerPyramidTexture;
|
||||
|
||||
@Override
|
||||
public void registerClientHook() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -12,53 +12,57 @@ import buildcraft.api.core.IAreaProvider;
|
|||
import buildcraft.api.core.LaserKind;
|
||||
import buildcraft.api.filler.FillerManager;
|
||||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.api.filler.IPatternIterator;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IActionReceptor;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.builders.filler.pattern.PatternFill;
|
||||
import buildcraft.builders.triggers.ActionFiller;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.IMachine;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.inventory.InventoryIterator;
|
||||
import buildcraft.core.inventory.InventoryIterator.IInvSlot;
|
||||
import buildcraft.core.inventory.SimpleInventory;
|
||||
import buildcraft.core.network.IGuiReturnHandler;
|
||||
import buildcraft.core.network.PacketPayload;
|
||||
import buildcraft.core.network.PacketPayloadStream;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.network.TileNetworkData;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.triggers.ActionMachineControl;
|
||||
import buildcraft.core.triggers.ActionMachineControl.Mode;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowerReceptor, IMachine, IActionReceptor {
|
||||
public class TileFiller extends TileBuildCraft implements IInventory, IPowerReceptor, IMachine, IActionReceptor, IGuiReturnHandler {
|
||||
|
||||
private static int[] SLOTS_GRID = Utils.createSlotArray(0, 9);
|
||||
private static int[] SLOTS_INPUT = Utils.createSlotArray(9, 27);
|
||||
public @TileNetworkData
|
||||
Box box = new Box();
|
||||
public @TileNetworkData
|
||||
int currentPatternId = 0;
|
||||
public @TileNetworkData
|
||||
boolean done = true;
|
||||
public IFillerPattern currentPattern;
|
||||
boolean forceDone = false;
|
||||
private ItemStack contents[];
|
||||
public IFillerPattern currentPattern = PatternFill.INSTANCE;
|
||||
private static int POWER_USAGE = 25;
|
||||
private final Box box = new Box();
|
||||
private boolean done = false;
|
||||
private IPatternIterator patternIterator;
|
||||
private PowerHandler powerHandler;
|
||||
private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown;
|
||||
private SimpleInventory inv = new SimpleInventory(27, "Filler", 64);
|
||||
|
||||
public TileFiller() {
|
||||
contents = new ItemStack[getSizeInventory()];
|
||||
inv.addListener(this);
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
initPowerProvider();
|
||||
}
|
||||
|
||||
private void initPowerProvider() {
|
||||
powerHandler.configure(30, 50, 25, 100);
|
||||
powerHandler.configure(30, POWER_USAGE * 2, POWER_USAGE, POWER_USAGE * 4);
|
||||
powerHandler.configurePowerPerdition(1, 1);
|
||||
}
|
||||
|
||||
|
@ -82,23 +86,15 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
|
|||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
computeRecipe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (done) {
|
||||
if (lastMode == Mode.Loop) {
|
||||
done = false;
|
||||
} else
|
||||
return;
|
||||
}
|
||||
|
||||
if (powerHandler.getEnergyStored() >= 25) {
|
||||
doWork(powerHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,132 +102,68 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
|
|||
public void doWork(PowerHandler workProvider) {
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
return;
|
||||
|
||||
if (done)
|
||||
return;
|
||||
if (lastMode == Mode.Off)
|
||||
return;
|
||||
|
||||
if (powerHandler.useEnergy(25, 25, true) < 25)
|
||||
if (powerHandler.useEnergy(POWER_USAGE, POWER_USAGE, false) != POWER_USAGE)
|
||||
return;
|
||||
if (!box.isInitialized())
|
||||
return;
|
||||
|
||||
if (box.isInitialized() && currentPattern != null && !done) {
|
||||
ItemStack stack = null;
|
||||
int stackId = 0;
|
||||
if (patternIterator == null)
|
||||
patternIterator = currentPattern.createPatternIterator(this, box, ForgeDirection.NORTH);
|
||||
|
||||
for (int s = 9; s < getSizeInventory(); ++s) {
|
||||
if (getStackInSlot(s) != null && getStackInSlot(s).stackSize > 0) {
|
||||
ItemStack stackToUse = null;
|
||||
int slotNum = 0;
|
||||
|
||||
stack = contents[s];
|
||||
stackId = s;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
done = currentPattern.iteratePattern(this, box, stack);
|
||||
|
||||
if (stack != null && stack.stackSize == 0) {
|
||||
contents[stackId] = null;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
sendNetworkUpdate();
|
||||
for (IInvSlot slot : InventoryIterator.getIterable(inv, ForgeDirection.UNKNOWN)) {
|
||||
ItemStack stack = slot.getStackInSlot();
|
||||
if (stack != null && stack.stackSize > 0) {
|
||||
stackToUse = stack;
|
||||
slotNum = slot.getIndex();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (powerHandler.getEnergyStored() >= 25) {
|
||||
done = patternIterator.iteratePattern(stackToUse);
|
||||
powerHandler.useEnergy(POWER_USAGE, POWER_USAGE, true);
|
||||
|
||||
if (stackToUse != null && stackToUse.stackSize <= 0) {
|
||||
setInventorySlotContents(slotNum, null);
|
||||
}
|
||||
|
||||
if (done) {
|
||||
patternIterator = null;
|
||||
sendNetworkUpdate();
|
||||
} else if (powerHandler.getEnergyStored() >= POWER_USAGE) {
|
||||
doWork(workProvider);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getSizeInventory() {
|
||||
return 36;
|
||||
return inv.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return contents[i];
|
||||
}
|
||||
|
||||
public void computeRecipe() {
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
return;
|
||||
|
||||
IFillerPattern newPattern = FillerManager.registry.findMatchingRecipe(this);
|
||||
|
||||
if (newPattern == currentPattern)
|
||||
return;
|
||||
|
||||
currentPattern = newPattern;
|
||||
|
||||
if (currentPattern == null || forceDone) {
|
||||
done = lastMode != Mode.Loop;
|
||||
forceDone = false;
|
||||
} else {
|
||||
done = false;
|
||||
}
|
||||
|
||||
if (worldObj != null) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
if (currentPattern == null) {
|
||||
currentPatternId = 0;
|
||||
} else {
|
||||
currentPatternId = currentPattern.getId();
|
||||
}
|
||||
|
||||
if (CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inv.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if (contents[i] != null) {
|
||||
if (contents[i].stackSize <= j) {
|
||||
ItemStack itemstack = contents[i];
|
||||
contents[i] = null;
|
||||
// onInventoryChanged();
|
||||
|
||||
computeRecipe();
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
ItemStack itemstack1 = contents[i].splitStack(j);
|
||||
|
||||
if (contents[i].stackSize == 0) {
|
||||
contents[i] = null;
|
||||
}
|
||||
// onInventoryChanged();
|
||||
|
||||
computeRecipe();
|
||||
|
||||
return itemstack1;
|
||||
} else
|
||||
return null;
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
return inv.decrStackSize(slot, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
contents[i] = itemstack;
|
||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
|
||||
computeRecipe();
|
||||
// onInventoryChanged();
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inv.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (contents[slot] == null)
|
||||
return null;
|
||||
ItemStack toReturn = contents[slot];
|
||||
contents[slot] = null;
|
||||
return toReturn;
|
||||
return inv.getStackInSlotOnClosing(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -240,40 +172,44 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
Utils.readStacksFromNBT(nbttagcompound, "Items", contents);
|
||||
inv.readFromNBT(nbt);
|
||||
|
||||
if (nbttagcompound.hasKey("box")) {
|
||||
box.initialize(nbttagcompound.getCompoundTag("box"));
|
||||
}
|
||||
if (nbt.hasKey("pattern"))
|
||||
currentPattern = FillerManager.registry.getPattern(nbt.getString("pattern"));
|
||||
|
||||
done = nbttagcompound.getBoolean("done");
|
||||
lastMode = Mode.values()[nbttagcompound.getByte("lastMode")];
|
||||
if (currentPattern == null)
|
||||
currentPattern = PatternFill.INSTANCE;
|
||||
|
||||
forceDone = done;
|
||||
if (nbt.hasKey("box"))
|
||||
box.initialize(nbt.getCompoundTag("box"));
|
||||
|
||||
done = nbt.getBoolean("done");
|
||||
lastMode = Mode.values()[nbt.getByte("lastMode")];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
Utils.writeStacksToNBT(nbttagcompound, "Items", contents);
|
||||
inv.writeToNBT(nbt);
|
||||
|
||||
if (box != null) {
|
||||
NBTTagCompound boxStore = new NBTTagCompound();
|
||||
box.writeToNBT(boxStore);
|
||||
nbttagcompound.setTag("box", boxStore);
|
||||
}
|
||||
if (currentPattern != null)
|
||||
nbt.setString("pattern", currentPattern.getUniqueTag());
|
||||
|
||||
nbttagcompound.setBoolean("done", done);
|
||||
nbttagcompound.setByte("lastMode", (byte) lastMode.ordinal());
|
||||
NBTTagCompound boxStore = new NBTTagCompound();
|
||||
box.writeToNBT(boxStore);
|
||||
nbt.setTag("box", boxStore);
|
||||
|
||||
nbt.setBoolean("done", done);
|
||||
nbt.setByte("lastMode", (byte) lastMode.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
return inv.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -291,37 +227,52 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
|
|||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (box != null) {
|
||||
box.deleteLasers();
|
||||
box.deleteLasers();
|
||||
}
|
||||
|
||||
public void setPattern(IFillerPattern pattern) {
|
||||
if (pattern != null && currentPattern != pattern) {
|
||||
currentPattern = pattern;
|
||||
patternIterator = null;
|
||||
done = false;
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketPayload getPacketPayload() {
|
||||
PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() {
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
box.writeToStream(data);
|
||||
data.writeBoolean(done);
|
||||
data.writeUTF(currentPattern.getUniqueTag());
|
||||
}
|
||||
});
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void handlePacketPayload(DataInputStream data) throws IOException {
|
||||
boolean initialized = box.isInitialized();
|
||||
box.readFromStream(data);
|
||||
done = data.readBoolean();
|
||||
setPattern(FillerManager.registry.getPattern(data.readUTF()));
|
||||
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
if (!initialized && box.isInitialized()) {
|
||||
box.createLasers(worldObj, LaserKind.Stripes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDescriptionPacket(PacketUpdate packet) throws IOException {
|
||||
boolean initialized = box.isInitialized();
|
||||
|
||||
super.handleDescriptionPacket(packet);
|
||||
|
||||
currentPattern = FillerManager.registry.getPattern(currentPatternId);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
|
||||
if (!initialized && box.isInitialized()) {
|
||||
box.createLasers(worldObj, LaserKind.Stripes);
|
||||
}
|
||||
handlePacketPayload(((PacketPayloadStream) packet.payload).stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUpdatePacket(PacketUpdate packet) throws IOException {
|
||||
boolean initialized = box.isInitialized();
|
||||
|
||||
super.handleUpdatePacket(packet);
|
||||
|
||||
currentPattern = FillerManager.registry.getPattern(currentPatternId);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
|
||||
if (!initialized && box.isInitialized()) {
|
||||
box.createLasers(worldObj, LaserKind.Stripes);
|
||||
}
|
||||
handlePacketPayload(((PacketPayloadStream) packet.payload).stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -360,6 +311,9 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
|
|||
lastMode = ActionMachineControl.Mode.Off;
|
||||
} else if (action == BuildCraftCore.actionLoop) {
|
||||
lastMode = ActionMachineControl.Mode.Loop;
|
||||
} else if (action instanceof ActionFiller) {
|
||||
ActionFiller actFill = (ActionFiller) action;
|
||||
setPattern(actFill.pattern);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,29 +324,22 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
|
|||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
if (slot < 9) {
|
||||
if (getStackInSlot(slot) != null)
|
||||
return false;
|
||||
return stack.itemID == Block.brick.blockID || stack.itemID == Block.glass.blockID;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
if (ForgeDirection.UP.ordinal() == side) {
|
||||
return SLOTS_GRID;
|
||||
}
|
||||
return SLOTS_INPUT;
|
||||
public void writeGuiData(DataOutputStream data) throws IOException {
|
||||
data.writeUTF(currentPattern.getUniqueTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side) {
|
||||
return isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side) {
|
||||
return true;
|
||||
public void readGuiData(DataInputStream data, EntityPlayer player) throws IOException {
|
||||
IFillerPattern prev = currentPattern;
|
||||
currentPattern = FillerManager.registry.getPattern(data.readUTF());
|
||||
if (currentPattern == null)
|
||||
currentPattern = PatternFill.INSTANCE;
|
||||
if (prev != currentPattern)
|
||||
done = false;
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
|
54
common/buildcraft/builders/filler/FillerRegistry.java
Normal 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;
|
||||
}
|
||||
}
|
|
@ -5,44 +5,88 @@
|
|||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.builders;
|
||||
package buildcraft.builders.filler.pattern;
|
||||
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.core.IBox;
|
||||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.api.filler.IPatternIterator;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public abstract class FillerPattern implements IFillerPattern {
|
||||
|
||||
protected int id;
|
||||
public static final Set<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
|
||||
* if there is none. IteratePattern is responsible to decrementing the stack
|
||||
* size if needed. Return true when the iteration process is finished.
|
||||
*/
|
||||
@Override
|
||||
public abstract boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public abstract Icon getTexture();
|
||||
|
||||
@Override
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
public String getDisplayName() {
|
||||
return StringUtils.localize("fillerpattern." + tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueTag() {
|
||||
return "buildcraft:" + tag;
|
||||
}
|
||||
|
||||
public void registerIcon(IconRegister iconRegister) {
|
||||
icon = iconRegister.registerIcon("buildcraft:fillerPatterns/" + tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pattern: " + getUniqueTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPatternIterator createPatternIterator(TileEntity tile, IBox box, ForgeDirection orientation) {
|
||||
return new PatternIterator(tile, box);
|
||||
}
|
||||
|
||||
protected class PatternIterator implements IPatternIterator {
|
||||
|
||||
private final IBox box;
|
||||
private final TileEntity tile;
|
||||
|
||||
public PatternIterator(TileEntity tile, IBox box) {
|
||||
this.box = box;
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iteratePattern(ItemStack stackToPlace) {
|
||||
return FillerPattern.this.iteratePattern(tile, box, stackToPlace);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,7 +95,7 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
* Return false if the process failed.
|
||||
*
|
||||
*/
|
||||
public boolean fill(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, ItemStack stackToPlace, World world) {
|
||||
public static boolean fill(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, ItemStack stackToPlace, World world) {
|
||||
boolean found = false;
|
||||
int lastX = 0, lastY = 0, lastZ = 0;
|
||||
|
||||
|
@ -85,12 +129,11 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
* Return false if is the process failed.
|
||||
*
|
||||
*/
|
||||
public boolean empty(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world) {
|
||||
boolean found = false;
|
||||
public static boolean empty(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world) {
|
||||
int lastX = Integer.MAX_VALUE, lastY = Integer.MAX_VALUE, lastZ = Integer.MAX_VALUE;
|
||||
|
||||
for (int y = yMax; y >= yMin; y--) {
|
||||
found = false;
|
||||
boolean found = false;
|
||||
for (int x = xMin; x <= xMax; ++x) {
|
||||
for (int z = zMin; z <= zMax; ++z) {
|
||||
if (!BlockUtil.canChangeBlock(world, x, y, z))
|
||||
|
@ -125,7 +168,7 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
*
|
||||
* Return false if is the process failed.
|
||||
*/
|
||||
public boolean flatten(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world, ItemStack stackToPlace) {
|
||||
public static boolean flatten(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world, ItemStack stackToPlace) {
|
||||
int lastX = Integer.MAX_VALUE, lastY = Integer.MAX_VALUE, lastZ = Integer.MAX_VALUE;
|
||||
|
||||
boolean found = false;
|
||||
|
@ -151,7 +194,10 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
return found;
|
||||
}
|
||||
|
||||
private void breakBlock(World world, int x, int y, int z) {
|
||||
private static void breakBlock(World world, int x, int y, int z) {
|
||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
if (block != null)
|
||||
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
|
||||
if (BuildCraftBuilders.fillerDestroy) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
} else if (BlockUtil.isToughBlock(world, x, y, z)) {
|
|
@ -1,22 +1,21 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.builders;
|
||||
package buildcraft.builders.filler.pattern;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class FillerFillWalls extends FillerPattern {
|
||||
public class PatternBox extends FillerPattern {
|
||||
|
||||
public PatternBox() {
|
||||
super("box");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
|
||||
|
@ -48,16 +47,4 @@ public class FillerFillWalls extends FillerPattern {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Icon getTexture() {
|
||||
return BuilderProxyClient.fillerWallsTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Walls";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +1,21 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.builders;
|
||||
package buildcraft.builders.filler.pattern;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class FillerRemover extends FillerPattern {
|
||||
public class PatternClear extends FillerPattern {
|
||||
|
||||
public PatternClear() {
|
||||
super("clear");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
|
||||
|
@ -30,16 +29,4 @@ public class FillerRemover extends FillerPattern {
|
|||
|
||||
return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Icon getTexture() {
|
||||
return BuilderProxyClient.fillerClearTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Clear";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +1,27 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.builders;
|
||||
package buildcraft.builders.filler.pattern;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import buildcraft.builders.BuilderProxyClient;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class FillerFillAll extends FillerPattern {
|
||||
public class PatternFill extends FillerPattern {
|
||||
|
||||
public static final PatternFill INSTANCE = new PatternFill();
|
||||
|
||||
private PatternFill() {
|
||||
super("fill");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
|
||||
|
@ -31,15 +36,4 @@ public class FillerFillAll extends FillerPattern {
|
|||
return !fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getTexture() {
|
||||
return BuilderProxyClient.fillerFillAllTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Fill";
|
||||
}
|
||||
|
||||
}
|
|
@ -5,17 +5,17 @@
|
|||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.builders;
|
||||
package buildcraft.builders.filler.pattern;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class FillerFlattener extends FillerPattern {
|
||||
public class PatternFlatten extends FillerPattern {
|
||||
|
||||
public PatternFlatten() {
|
||||
super("flatten");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
|
||||
|
@ -32,15 +32,4 @@ public class FillerFlattener extends FillerPattern {
|
|||
}
|
||||
return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Icon getTexture() {
|
||||
return BuilderProxyClient.fillerFlattenTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Flatten";
|
||||
}
|
||||
}
|
|
@ -5,16 +5,17 @@
|
|||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.builders;
|
||||
package buildcraft.builders.filler.pattern;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class FillerHorizon extends FillerPattern {
|
||||
public class PatternHorizon extends FillerPattern {
|
||||
|
||||
public PatternHorizon() {
|
||||
super("horizon");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
|
||||
|
@ -30,15 +31,4 @@ public class FillerHorizon extends FillerPattern {
|
|||
}
|
||||
return !empty(xMin, yMin, zMin, xMax, tile.worldObj.getActualHeight(), zMax, tile.worldObj);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Icon getTexture() {
|
||||
return BuilderProxyClient.fillerHorizonTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Horizon";
|
||||
}
|
||||
}
|
|
@ -1,22 +1,21 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.builders;
|
||||
package buildcraft.builders.filler.pattern;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class FillerFillPyramid extends FillerPattern {
|
||||
public class PatternPyramid extends FillerPattern {
|
||||
|
||||
public PatternPyramid() {
|
||||
super("pyramid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
|
||||
|
@ -58,16 +57,4 @@ public class FillerFillPyramid extends FillerPattern {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getTexture() {
|
||||
return BuilderProxyClient.fillerPyramidTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Pyramid";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +1,21 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.builders;
|
||||
package buildcraft.builders.filler.pattern;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class FillerFillStairs extends FillerPattern {
|
||||
public class PatternStairs extends FillerPattern {
|
||||
|
||||
public PatternStairs() {
|
||||
super("stairs");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
|
||||
|
@ -46,7 +45,7 @@ public class FillerFillStairs extends FillerPattern {
|
|||
|
||||
int kind = 0;
|
||||
|
||||
int steps[] = new int[] { 0, 0, 0, 0 };
|
||||
int steps[] = new int[]{0, 0, 0, 0};
|
||||
|
||||
int x = 0, z = 0;
|
||||
int stepDiagX = 0, stepDiagZ = 0;
|
||||
|
@ -189,16 +188,4 @@ public class FillerFillStairs extends FillerPattern {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getTexture() {
|
||||
return BuilderProxyClient.fillerStairsTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Stairs";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,79 +1,69 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.builders.gui;
|
||||
|
||||
import buildcraft.builders.TileFiller;
|
||||
import buildcraft.core.gui.BuildCraftContainer;
|
||||
import buildcraft.core.gui.slots.SlotLimited;
|
||||
import buildcraft.core.gui.GuiBuildCraft;
|
||||
import buildcraft.core.gui.widgets.Widget;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerFiller extends BuildCraftContainer {
|
||||
|
||||
IInventory playerIInventory;
|
||||
IInventory fillerInventory;
|
||||
TileFiller tile;
|
||||
|
||||
public ContainerFiller(IInventory playerInventory, IInventory fillerInventory) {
|
||||
super(fillerInventory.getSizeInventory());
|
||||
private class PatternWidget extends Widget {
|
||||
|
||||
public PatternWidget() {
|
||||
super(80, 30, 0, 0, 16, 16);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) {
|
||||
gui.bindTexture(TextureMap.locationBlocksTexture);
|
||||
gui.drawTexturedModelRectFromIcon(guiX + x, guiY + y, tile.currentPattern.getIcon(), 16, 16);
|
||||
}
|
||||
}
|
||||
|
||||
public ContainerFiller(IInventory playerInventory, TileFiller tile) {
|
||||
super(tile.getSizeInventory());
|
||||
this.playerIInventory = playerInventory;
|
||||
this.fillerInventory = fillerInventory;
|
||||
this.tile = tile;
|
||||
|
||||
for (int k = 0; k < 3; k++) {
|
||||
for (int j1 = 0; j1 < 3; j1++) {
|
||||
addSlotToContainer(new SlotLimited(fillerInventory, j1 + k * 3, 31 + j1 * 18, 16 + k * 18, 1));
|
||||
addWidget(new PatternWidget());
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(tile, x + y * 9, 8 + x * 18, 85 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < 3; k++) {
|
||||
for (int j1 = 0; j1 < 9; j1++) {
|
||||
addSlotToContainer(new Slot(fillerInventory, 9 + j1 + k * 9, 8 + j1 * 18, 85 + k * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int l = 0; l < 3; l++) {
|
||||
for (int k1 = 0; k1 < 9; k1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 153 + l * 18));
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(playerInventory, x + y * 9 + 9, 8 + x * 18, 153 + y * 18));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < 9; i1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 211));
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(playerInventory, x, 8 + x * 18, 211));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return fillerInventory.isUseableByPlayer(entityplayer);
|
||||
return tile.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer pl, int i) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(i);
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
if (i < getInventorySize()) {
|
||||
if (!mergeItemStack(itemstack1, getInventorySize(), inventorySlots.size(), true))
|
||||
return null;
|
||||
} else if (!mergeItemStack(itemstack1, 9, getInventorySize(), false))
|
||||
return null;
|
||||
if (itemstack1.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
|
|||
BptPlayerIndex index;
|
||||
|
||||
public GuiBlueprintLibrary(EntityPlayer player, TileBlueprintLibrary library) {
|
||||
super(new ContainerBlueprintLibrary(player, library), library);
|
||||
super(new ContainerBlueprintLibrary(player, library), library, TEXTURE);
|
||||
this.player = player;
|
||||
xSize = 176;
|
||||
ySize = 225;
|
||||
|
|
|
@ -26,7 +26,7 @@ public class GuiBuilder extends GuiAdvancedInterface {
|
|||
TileBuilder builder;
|
||||
|
||||
public GuiBuilder(IInventory playerInventory, TileBuilder builder) {
|
||||
super(new ContainerBuilder(playerInventory, builder), builder);
|
||||
super(new ContainerBuilder(playerInventory, builder), builder, TEXTURE);
|
||||
this.playerInventory = playerInventory;
|
||||
this.builder = builder;
|
||||
xSize = 176;
|
||||
|
|
|
@ -7,88 +7,63 @@
|
|||
*/
|
||||
package buildcraft.builders.gui;
|
||||
|
||||
import buildcraft.api.filler.FillerManager;
|
||||
import buildcraft.builders.TileFiller;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.GuiBuildCraft;
|
||||
import buildcraft.core.gui.GuiTools;
|
||||
import buildcraft.core.gui.buttons.GuiBetterButton;
|
||||
import buildcraft.core.gui.buttons.StandardButtonTextureSets;
|
||||
import buildcraft.core.network.PacketGuiReturn;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiFiller extends GuiBuildCraft {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filler.png");
|
||||
private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture;
|
||||
IInventory playerInventory;
|
||||
TileFiller filler;
|
||||
|
||||
public GuiFiller(IInventory playerInventory, TileFiller filler) {
|
||||
super(new ContainerFiller(playerInventory, filler), filler);
|
||||
super(new ContainerFiller(playerInventory, filler), filler, TEXTURE);
|
||||
this.playerInventory = playerInventory;
|
||||
this.filler = filler;
|
||||
xSize = 175;
|
||||
ySize = 240;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
buttonList.clear();
|
||||
int w = (width - xSize) / 2;
|
||||
int h = (height - ySize) / 2;
|
||||
|
||||
buttonList.add(new GuiBetterButton(0, w + 80 - 18, h + 30, 10, StandardButtonTextureSets.LEFT_BUTTON, ""));
|
||||
buttonList.add(new GuiBetterButton(1, w + 80 + 16 + 8, h + 30, 10, StandardButtonTextureSets.RIGHT_BUTTON, ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
super.actionPerformed(button);
|
||||
|
||||
if (button.id == 0)
|
||||
filler.currentPattern = FillerManager.registry.getPreviousPattern(filler.currentPattern);
|
||||
if (button.id == 1)
|
||||
filler.currentPattern = FillerManager.registry.getNextPattern(filler.currentPattern);
|
||||
|
||||
PacketGuiReturn pkt = new PacketGuiReturn(filler);
|
||||
pkt.sendPacket();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
String title = StringUtils.localize("tile.fillerBlock");
|
||||
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
|
||||
fontRenderer.drawString(StringUtils.localize("gui.filling.resources"), 8, 74, 0x404040);
|
||||
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, 142, 0x404040);
|
||||
|
||||
if (filler.currentPattern != null) {
|
||||
drawForegroundSelection(filler.currentPattern.getName());
|
||||
}
|
||||
GuiTools.drawCenteredString(fontRenderer, filler.currentPattern.getDisplayName(), 56);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(TEXTURE);
|
||||
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
if (filler.currentPattern != null) {
|
||||
mc.renderEngine.bindTexture(BLOCK_TEXTURE);
|
||||
drawTexturedModelRectFromIcon(guiLeft + patternSymbolX, guiTop + patternSymbolY, filler.currentPattern.getTexture(), 16, 16);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean intersectsWith(int i, int j) {
|
||||
|
||||
if (i >= patternSymbolX && i <= patternSymbolX + 16 && j >= patternSymbolY && j <= patternSymbolY + 16)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void drawForegroundSelection(String tag) {
|
||||
|
||||
if (!intersectsWith(lastX - guiLeft, lastY - guiTop))
|
||||
return;
|
||||
|
||||
if (tag.length() > 0) {
|
||||
int i2 = (lastX - guiLeft) + 12;
|
||||
int k2 = lastY - guiTop - 12;
|
||||
int l2 = fontRenderer.getStringWidth(tag);
|
||||
drawGradientRect(i2 - 3, k2 - 3, i2 + l2 + 3, k2 + 8 + 3, 0xc0000000, 0xc0000000);
|
||||
fontRenderer.drawStringWithShadow(tag, i2, k2, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int i, int j, int k) {
|
||||
super.mouseMovedOrUp(i, j, k);
|
||||
|
||||
lastX = i;
|
||||
lastY = j;
|
||||
}
|
||||
private int lastX = 0;
|
||||
private int lastY = 0;
|
||||
public final int patternSymbolX = 125;
|
||||
public final int patternSymbolY = 34;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class GuiTemplate extends GuiBuildCraft {
|
|||
boolean editMode = false;
|
||||
|
||||
public GuiTemplate(IInventory playerInventory, TileArchitect template) {
|
||||
super(new ContainerTemplate(playerInventory, template), template);
|
||||
super(new ContainerTemplate(playerInventory, template), template, TEXTURE);
|
||||
this.playerInventory = playerInventory;
|
||||
this.template = template;
|
||||
xSize = 175;
|
||||
|
|
37
common/buildcraft/builders/triggers/ActionFiller.java
Normal 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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -4,17 +4,30 @@ import buildcraft.core.utils.Utils;
|
|||
import java.util.Random;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class BlockBuildCraft extends BlockContainer {
|
||||
|
||||
protected static boolean keepInventory = false;
|
||||
protected Random rand;
|
||||
protected final Random rand = new Random();
|
||||
|
||||
protected BlockBuildCraft(int id, Material material) {
|
||||
super(id, material);
|
||||
this.rand = new Random();
|
||||
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
|
||||
setHardness(5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, entity, stack);
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof TileBuildCraft) {
|
||||
((TileBuildCraft) tile).onBlockPlacedBy(entity, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,4 +36,11 @@ public abstract class BlockBuildCraft extends BlockContainer {
|
|||
super.breakBlock(world, x, y, z, par5, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof IMachine && ((IMachine) tile).isActive())
|
||||
return super.getLightValue(world, x, y, z) + 8;
|
||||
return super.getLightValue(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class BlockSpring extends Block {
|
|||
public enum EnumSpring {
|
||||
|
||||
WATER(5, -1, Block.waterStill),
|
||||
OIL(6000, 32, null); // Set in BuildCraftEnergy
|
||||
OIL(6000, 8, null); // Set in BuildCraftEnergy
|
||||
public static final EnumSpring[] VALUES = values();
|
||||
public final int tickRate, chance;
|
||||
public Block liquidBlock;
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.core;
|
||||
|
||||
import buildcraft.api.core.IAreaProvider;
|
||||
|
@ -16,6 +14,9 @@ import buildcraft.api.core.Position;
|
|||
import buildcraft.core.network.TileNetworkData;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -27,7 +28,6 @@ public class Box implements IBox {
|
|||
int xMin, yMin, zMin, xMax, yMax, zMax;
|
||||
public @TileNetworkData
|
||||
boolean initialized;
|
||||
|
||||
private EntityBlock lasers[];
|
||||
|
||||
public Box() {
|
||||
|
@ -57,8 +57,8 @@ public class Box implements IBox {
|
|||
this.xMax = xMax;
|
||||
this.yMax = yMax;
|
||||
this.zMax = zMax;
|
||||
initialized = !(xMin == Integer.MAX_VALUE || yMin == Integer.MAX_VALUE || zMin == Integer.MAX_VALUE || xMax == Integer.MAX_VALUE ||
|
||||
yMax == Integer.MAX_VALUE || zMax == Integer.MAX_VALUE );
|
||||
initialized = !(xMin == Integer.MAX_VALUE || yMin == Integer.MAX_VALUE || zMin == Integer.MAX_VALUE || xMax == Integer.MAX_VALUE
|
||||
|| yMax == Integer.MAX_VALUE || zMax == Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public void initialize(Box box) {
|
||||
|
@ -224,6 +224,30 @@ public class Box implements IBox {
|
|||
}
|
||||
}
|
||||
|
||||
public void writeToStream(DataOutputStream stream) throws IOException {
|
||||
stream.writeBoolean(initialized);
|
||||
|
||||
stream.writeInt(xMin);
|
||||
stream.writeInt(yMin);
|
||||
stream.writeInt(zMin);
|
||||
|
||||
stream.writeInt(xMax);
|
||||
stream.writeInt(yMax);
|
||||
stream.writeInt(zMax);
|
||||
}
|
||||
|
||||
public void readFromStream(DataInputStream stream) throws IOException {
|
||||
initialized = stream.readBoolean();
|
||||
|
||||
xMin = stream.readInt();
|
||||
yMin = stream.readInt();
|
||||
zMin = stream.readInt();
|
||||
|
||||
xMax = stream.readInt();
|
||||
yMax = stream.readInt();
|
||||
zMax = stream.readInt();
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
nbttagcompound.setInteger("xMin", xMin);
|
||||
|
@ -239,5 +263,4 @@ public class Box implements IBox {
|
|||
public String toString() {
|
||||
return "{" + xMin + ", " + xMax + "}, {" + yMin + ", " + yMax + "}, {" + zMin + ", " + zMax + "}";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ public class DefaultProps {
|
|||
public static int PIPE_ITEMS_QUARTZ_ID = 19168;
|
||||
public static int PIPE_ITEMS_LAPIS_ID = 19169;
|
||||
public static int PIPE_ITEMS_DAIZULI_ID = 19170;
|
||||
public static int PIPE_ITEMS_EMZULI_ID = 19171;
|
||||
|
||||
public static int PIPE_LIQUIDS_WOOD_ID = 19180;
|
||||
public static int PIPE_LIQUIDS_COBBLESTONE_ID = 19181;
|
||||
|
|
|
@ -19,6 +19,7 @@ public class GuiIds {
|
|||
public static final int PIPE_DIAMOND = 50;
|
||||
public static final int GATES = 51;
|
||||
public static final int PIPE_EMERALD_ITEM = 52;
|
||||
public static final int PIPE_LOGEMERALD_ITEM = 53;
|
||||
|
||||
public static final int FILTERED_BUFFER = 60;
|
||||
}
|
||||
|
|
|
@ -38,19 +38,23 @@ public class InterModComms {
|
|||
|
||||
public static void processFacadeIMC(IMCEvent event, IMCMessage m) {
|
||||
try {
|
||||
Splitter splitter = Splitter.on("@").trimResults();
|
||||
if (m.isStringMessage()) {
|
||||
Splitter splitter = Splitter.on("@").trimResults();
|
||||
|
||||
String[] array = Iterables.toArray(splitter.split(m.getStringValue()), String.class);
|
||||
if (array.length != 2) {
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
} else {
|
||||
Integer blId = Ints.tryParse(array[0]);
|
||||
Integer metaId = Ints.tryParse(array[1]);
|
||||
if (blId == null || metaId == null) {
|
||||
String[] array = Iterables.toArray(splitter.split(m.getStringValue()), String.class);
|
||||
if (array.length != 2) {
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
} else {
|
||||
ItemFacade.addFacade(new ItemStack(blId, 1, metaId));
|
||||
Integer blId = Ints.tryParse(array[0]);
|
||||
Integer metaId = Ints.tryParse(array[1]);
|
||||
if (blId == null || metaId == null) {
|
||||
Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender()));
|
||||
} else {
|
||||
ItemFacade.addFacade(new ItemStack(blId, 1, metaId));
|
||||
}
|
||||
}
|
||||
} else if (m.isItemStackMessage()) {
|
||||
ItemFacade.addFacade(m.getItemStackValue());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
||||
|
|
|
@ -19,6 +19,10 @@ import buildcraft.core.utils.Utils;
|
|||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -32,6 +36,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
private final TilePacketWrapper descriptionPacket;
|
||||
private final TilePacketWrapper updatePacket;
|
||||
private boolean init = false;
|
||||
private String owner = "[BuildCraft]";
|
||||
|
||||
public TileBuildCraft() {
|
||||
if (!updateWrappers.containsKey(this.getClass())) {
|
||||
|
@ -47,6 +52,10 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!init && !isInvalid()) {
|
||||
|
@ -70,6 +79,11 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
Utils.handleBufferedDescription(this);
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy(EntityLivingBase entity, ItemStack stack) {
|
||||
if (entity instanceof EntityPlayer)
|
||||
owner = ((EntityPlayer) entity).username;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
@ -110,6 +124,19 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
public void postPacketHandling(PacketUpdate packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setString("owner", owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
if (nbt.hasKey("owner"))
|
||||
owner = nbt.getString("owner");
|
||||
}
|
||||
|
||||
public boolean isInvNameLocalized() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
|
28
common/buildcraft/core/fluids/BCFluid.java
Normal 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);
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ import net.minecraftforge.fluids.FluidTank;
|
|||
public class Tank extends FluidTank {
|
||||
|
||||
private final String name;
|
||||
public int colorRenderCache = 0xFFFFFF;
|
||||
|
||||
public Tank(String name, int capacity, TileEntity tile) {
|
||||
super(capacity);
|
||||
|
|
|
@ -115,6 +115,7 @@ public class TankManager<T extends Tank> extends ForwardingList<T> implements IF
|
|||
if (fluidStack != null && fluidStack.getFluid() != null) {
|
||||
data.writeShort(fluidStack.getFluid().getID());
|
||||
data.writeInt(fluidStack.amount);
|
||||
data.writeInt(fluidStack.getFluid().getColor(fluidStack));
|
||||
} else {
|
||||
data.writeShort(-1);
|
||||
}
|
||||
|
@ -125,10 +126,13 @@ public class TankManager<T extends Tank> extends ForwardingList<T> implements IF
|
|||
public void readData(DataInputStream data) throws IOException {
|
||||
for (Tank tank : tanks) {
|
||||
int fluidId = data.readShort();
|
||||
if (fluidId > 0)
|
||||
if (fluidId > 0) {
|
||||
tank.setFluid(new FluidStack(fluidId, data.readInt()));
|
||||
else
|
||||
tank.colorRenderCache = data.readInt();
|
||||
} else {
|
||||
tank.setFluid(null);
|
||||
tank.colorRenderCache = 0xFFFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,21 +9,71 @@ package buildcraft.core.gui;
|
|||
|
||||
import buildcraft.core.gui.slots.IPhantomSlot;
|
||||
import buildcraft.core.gui.slots.SlotBase;
|
||||
import buildcraft.core.gui.widgets.Widget;
|
||||
import buildcraft.core.inventory.StackHelper;
|
||||
import buildcraft.core.network.PacketGuiWidget;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class BuildCraftContainer extends Container {
|
||||
|
||||
private List<Widget> widgets = new ArrayList<Widget>();
|
||||
private int inventorySize;
|
||||
|
||||
public BuildCraftContainer(int 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
|
||||
public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) {
|
||||
Slot slot = slotNum < 0 ? null : (Slot) this.inventorySlots.get(slotNum);
|
||||
|
|
|
@ -110,8 +110,8 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
|||
}
|
||||
public AdvancedSlot[] slots;
|
||||
|
||||
public GuiAdvancedInterface(BuildCraftContainer container, IInventory inventory) {
|
||||
super(container, inventory);
|
||||
public GuiAdvancedInterface(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) {
|
||||
super(container, inventory, texture);
|
||||
}
|
||||
|
||||
public int getSlotAtLocation(int i, int j) {
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package buildcraft.core.gui;
|
||||
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.buttons.GuiBetterButton;
|
||||
import buildcraft.core.gui.slots.IPhantomSlot;
|
||||
import buildcraft.core.gui.slots.SlotBase;
|
||||
import buildcraft.core.gui.slots.SlotPhantom;
|
||||
import buildcraft.core.gui.tooltips.IToolTipProvider;
|
||||
import buildcraft.core.gui.tooltips.ToolTip;
|
||||
import buildcraft.core.gui.tooltips.ToolTipLine;
|
||||
import buildcraft.core.gui.widgets.Widget;
|
||||
import buildcraft.core.utils.SessionVars;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
@ -22,8 +23,239 @@ import org.lwjgl.opengl.GL11;
|
|||
public abstract class GuiBuildCraft extends GuiContainer {
|
||||
|
||||
public static final ResourceLocation LEDGER_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/ledger.png");
|
||||
// / LEDGERS
|
||||
protected LedgerManager ledgerManager = new LedgerManager(this);
|
||||
public final LedgerManager ledgerManager = new LedgerManager(this);
|
||||
public final TileEntity tile;
|
||||
public final ResourceLocation texture;
|
||||
public final BuildCraftContainer container;
|
||||
|
||||
public GuiBuildCraft(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) {
|
||||
super(container);
|
||||
this.container = container;
|
||||
|
||||
this.texture = texture;
|
||||
|
||||
if (inventory instanceof TileEntity) {
|
||||
tile = (TileEntity) inventory;
|
||||
} else {
|
||||
tile = null;
|
||||
}
|
||||
|
||||
initLedgers(inventory);
|
||||
}
|
||||
|
||||
protected void initLedgers(IInventory inventory) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float par3) {
|
||||
super.drawScreen(mouseX, mouseY, par3);
|
||||
int left = this.guiLeft;
|
||||
int top = this.guiTop;
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) left, (float) top, 0.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
InventoryPlayer playerInv = this.mc.thePlayer.inventory;
|
||||
|
||||
if (playerInv.getItemStack() == null) {
|
||||
drawToolTips(container.getWidgets(), mouseX, mouseY);
|
||||
drawToolTips(buttonList, mouseX, mouseY);
|
||||
drawToolTips(inventorySlots.inventorySlots, mouseX, mouseY);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
private void drawToolTips(Collection objects, int mouseX, int mouseY) {
|
||||
for (Object obj : objects) {
|
||||
if (!(obj instanceof IToolTipProvider))
|
||||
continue;
|
||||
IToolTipProvider provider = (IToolTipProvider) obj;
|
||||
if (!provider.isToolTipVisible())
|
||||
continue;
|
||||
ToolTip tips = provider.getToolTip();
|
||||
if (tips == null)
|
||||
continue;
|
||||
boolean mouseOver = provider.isMouseOver(mouseX - guiLeft, mouseY - guiTop);
|
||||
tips.onTick(mouseOver);
|
||||
if (mouseOver && tips.isReady()) {
|
||||
tips.refresh();
|
||||
drawToolTips(tips, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
bindTexture(texture);
|
||||
int x = (width - xSize) / 2;
|
||||
int y = (height - ySize) / 2;
|
||||
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
int mX = mouseX - guiLeft;
|
||||
int mY = mouseY - guiTop;
|
||||
|
||||
for (Widget widget : container.getWidgets()) {
|
||||
if (widget.hidden)
|
||||
continue;
|
||||
bindTexture(texture);
|
||||
widget.draw(this, x, y, mX, mY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
ledgerManager.drawLedgers(par1, par2);
|
||||
}
|
||||
|
||||
protected int getCenteredOffset(String string) {
|
||||
return getCenteredOffset(string, xSize);
|
||||
}
|
||||
|
||||
protected int getCenteredOffset(String string, int xWidth) {
|
||||
return (xWidth - fontRenderer.getStringWidth(string)) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the passed mouse position is over the specified slot.
|
||||
*/
|
||||
private boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) {
|
||||
int left = this.guiLeft;
|
||||
int top = this.guiTop;
|
||||
mouseX -= left;
|
||||
mouseY -= top;
|
||||
return mouseX >= slot.xDisplayPosition - 1 && mouseX < slot.xDisplayPosition + 16 + 1 && mouseY >= slot.yDisplayPosition - 1 && mouseY < slot.yDisplayPosition + 16 + 1;
|
||||
}
|
||||
|
||||
// / MOUSE CLICKS
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
int mX = mouseX - guiLeft;
|
||||
int mY = mouseY - guiTop;
|
||||
|
||||
for (Widget widget : container.getWidgets()) {
|
||||
if (widget.hidden)
|
||||
continue;
|
||||
if (!widget.isMouseOver(mX, mY))
|
||||
continue;
|
||||
if (widget.handleMouseClick(mX, mY, mouseButton))
|
||||
return;
|
||||
}
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
// / Handle ledger clicks
|
||||
ledgerManager.handleMouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(int mouseX, int mouseY, int mouseButton, long time) {
|
||||
int mX = mouseX - guiLeft;
|
||||
int mY = mouseY - guiTop;
|
||||
for (Widget widget : container.getWidgets()) {
|
||||
if (widget.hidden)
|
||||
continue;
|
||||
widget.handleMouseMove(mX, mY, mouseButton, time);
|
||||
}
|
||||
|
||||
Slot slot = getSlotAtPosition(mouseX, mouseY);
|
||||
if (mouseButton == 1 && slot instanceof IPhantomSlot)
|
||||
return;
|
||||
super.mouseClickMove(mouseX, mouseY, mouseButton, time);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int mouseX, int mouseY, int eventType) {
|
||||
super.mouseMovedOrUp(mouseX, mouseY, eventType);
|
||||
|
||||
int mX = mouseX - guiLeft;
|
||||
int mY = mouseY - guiTop;
|
||||
for (Widget widget : container.getWidgets()) {
|
||||
if (widget.hidden)
|
||||
continue;
|
||||
widget.handleMouseRelease(mX, mY, eventType);
|
||||
}
|
||||
}
|
||||
|
||||
public Slot getSlotAtPosition(int x, int y) {
|
||||
for (int slotIndex = 0; slotIndex < this.inventorySlots.inventorySlots.size(); ++slotIndex) {
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(slotIndex);
|
||||
if (isMouseOverSlot(slot, x, y))
|
||||
return slot;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void bindTexture(ResourceLocation texture) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
}
|
||||
|
||||
private void drawToolTips(ToolTip toolTips, int mouseX, int mouseY) {
|
||||
if (toolTips.size() > 0) {
|
||||
int left = this.guiLeft;
|
||||
int top = this.guiTop;
|
||||
int lenght = 0;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
for (ToolTipLine tip : toolTips) {
|
||||
y = this.fontRenderer.getStringWidth(tip.text);
|
||||
|
||||
if (y > lenght) {
|
||||
lenght = y;
|
||||
}
|
||||
}
|
||||
|
||||
x = mouseX - left + 12;
|
||||
y = mouseY - top - 12;
|
||||
int var14 = 8;
|
||||
|
||||
if (toolTips.size() > 1) {
|
||||
var14 += 2 + (toolTips.size() - 1) * 10;
|
||||
}
|
||||
|
||||
this.zLevel = 300.0F;
|
||||
itemRenderer.zLevel = 300.0F;
|
||||
int var15 = -267386864;
|
||||
this.drawGradientRect(x - 3, y - 4, x + lenght + 3, y - 3, var15, var15);
|
||||
this.drawGradientRect(x - 3, y + var14 + 3, x + lenght + 3, y + var14 + 4, var15, var15);
|
||||
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y + var14 + 3, var15, var15);
|
||||
this.drawGradientRect(x - 4, y - 3, x - 3, y + var14 + 3, var15, var15);
|
||||
this.drawGradientRect(x + lenght + 3, y - 3, x + lenght + 4, y + var14 + 3, var15, var15);
|
||||
int var16 = 1347420415;
|
||||
int var17 = (var16 & 16711422) >> 1 | var16 & -16777216;
|
||||
this.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + var14 + 3 - 1, var16, var17);
|
||||
this.drawGradientRect(x + lenght + 2, y - 3 + 1, x + lenght + 3, y + var14 + 3 - 1, var16, var17);
|
||||
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y - 3 + 1, var16, var16);
|
||||
this.drawGradientRect(x - 3, y + var14 + 2, x + lenght + 3, y + var14 + 3, var17, var17);
|
||||
|
||||
for (ToolTipLine tip : toolTips) {
|
||||
String line = tip.text;
|
||||
|
||||
if (tip.color == -1) {
|
||||
line = "\u00a77" + line;
|
||||
} else {
|
||||
line = "\u00a7" + Integer.toHexString(tip.color) + line;
|
||||
}
|
||||
|
||||
this.fontRenderer.drawStringWithShadow(line, x, y, -1);
|
||||
|
||||
y += 10 + tip.getSpacing();
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
protected class LedgerManager {
|
||||
|
||||
|
@ -228,187 +460,4 @@ public abstract class GuiBuildCraft extends GuiContainer {
|
|||
drawTexturedModelRectFromIcon(x, y, icon, 16, 16);
|
||||
}
|
||||
}
|
||||
protected TileEntity tile;
|
||||
|
||||
public GuiBuildCraft(BuildCraftContainer container, IInventory inventory) {
|
||||
super(container);
|
||||
|
||||
if (inventory instanceof TileEntity) {
|
||||
tile = (TileEntity) inventory;
|
||||
}
|
||||
|
||||
initLedgers(inventory);
|
||||
}
|
||||
|
||||
protected void initLedgers(IInventory inventory) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float par3) {
|
||||
super.drawScreen(mouseX, mouseY, par3);
|
||||
int left = this.guiLeft;
|
||||
int top = this.guiTop;
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) left, (float) top, 0.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
InventoryPlayer playerInv = this.mc.thePlayer.inventory;
|
||||
|
||||
if (playerInv.getItemStack() == null) {
|
||||
for (Object button : buttonList) {
|
||||
if (!(button instanceof GuiBetterButton)) {
|
||||
continue;
|
||||
}
|
||||
GuiBetterButton betterButton = (GuiBetterButton) button;
|
||||
ToolTip tips = betterButton.getToolTip();
|
||||
if (tips == null) {
|
||||
continue;
|
||||
}
|
||||
boolean mouseOver = betterButton.isMouseOverButton(mouseX, mouseY);
|
||||
tips.onTick(mouseOver);
|
||||
if (mouseOver && tips.isReady()) {
|
||||
tips.refresh();
|
||||
drawToolTips(tips, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Object obj : inventorySlots.inventorySlots) {
|
||||
if (!(obj instanceof SlotBase)) {
|
||||
continue;
|
||||
}
|
||||
SlotBase slot = (SlotBase) obj;
|
||||
if (slot.getStack() != null) {
|
||||
continue;
|
||||
}
|
||||
ToolTip tips = slot.getToolTip();
|
||||
if (tips == null) {
|
||||
continue;
|
||||
}
|
||||
boolean mouseOver = isMouseOverSlot(slot, mouseX, mouseY);
|
||||
tips.onTick(mouseOver);
|
||||
if (mouseOver && tips.isReady()) {
|
||||
tips.refresh();
|
||||
drawToolTips(tips, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
ledgerManager.drawLedgers(par1, par2);
|
||||
}
|
||||
|
||||
protected int getCenteredOffset(String string) {
|
||||
return getCenteredOffset(string, xSize);
|
||||
}
|
||||
|
||||
protected int getCenteredOffset(String string, int xWidth) {
|
||||
return (xWidth - fontRenderer.getStringWidth(string)) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the passed mouse position is over the specified slot.
|
||||
*/
|
||||
private boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) {
|
||||
int left = this.guiLeft;
|
||||
int top = this.guiTop;
|
||||
mouseX -= left;
|
||||
mouseY -= top;
|
||||
return mouseX >= slot.xDisplayPosition - 1 && mouseX < slot.xDisplayPosition + 16 + 1 && mouseY >= slot.yDisplayPosition - 1 && mouseY < slot.yDisplayPosition + 16 + 1;
|
||||
}
|
||||
|
||||
// / MOUSE CLICKS
|
||||
@Override
|
||||
protected void mouseClicked(int par1, int par2, int mouseButton) {
|
||||
super.mouseClicked(par1, par2, mouseButton);
|
||||
|
||||
// / Handle ledger clicks
|
||||
ledgerManager.handleMouseClicked(par1, par2, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(int x, int y, int mouseButton, long time) {
|
||||
Slot slot = getSlotAtPosition(x, y);
|
||||
if (mouseButton == 1 && slot instanceof IPhantomSlot)
|
||||
return;
|
||||
super.mouseClickMove(x, y, mouseButton, time);
|
||||
}
|
||||
|
||||
public Slot getSlotAtPosition(int x, int y) {
|
||||
for (int slotIndex = 0; slotIndex < this.inventorySlots.inventorySlots.size(); ++slotIndex) {
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(slotIndex);
|
||||
if (isMouseOverSlot(slot, x, y))
|
||||
return slot;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void drawToolTips(ToolTip toolTips, int mouseX, int mouseY) {
|
||||
if (toolTips.size() > 0) {
|
||||
int left = this.guiLeft;
|
||||
int top = this.guiTop;
|
||||
int lenght = 0;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
for (ToolTipLine tip : toolTips) {
|
||||
y = this.fontRenderer.getStringWidth(tip.text);
|
||||
|
||||
if (y > lenght) {
|
||||
lenght = y;
|
||||
}
|
||||
}
|
||||
|
||||
x = mouseX - left + 12;
|
||||
y = mouseY - top - 12;
|
||||
int var14 = 8;
|
||||
|
||||
if (toolTips.size() > 1) {
|
||||
var14 += 2 + (toolTips.size() - 1) * 10;
|
||||
}
|
||||
|
||||
this.zLevel = 300.0F;
|
||||
itemRenderer.zLevel = 300.0F;
|
||||
int var15 = -267386864;
|
||||
this.drawGradientRect(x - 3, y - 4, x + lenght + 3, y - 3, var15, var15);
|
||||
this.drawGradientRect(x - 3, y + var14 + 3, x + lenght + 3, y + var14 + 4, var15, var15);
|
||||
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y + var14 + 3, var15, var15);
|
||||
this.drawGradientRect(x - 4, y - 3, x - 3, y + var14 + 3, var15, var15);
|
||||
this.drawGradientRect(x + lenght + 3, y - 3, x + lenght + 4, y + var14 + 3, var15, var15);
|
||||
int var16 = 1347420415;
|
||||
int var17 = (var16 & 16711422) >> 1 | var16 & -16777216;
|
||||
this.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + var14 + 3 - 1, var16, var17);
|
||||
this.drawGradientRect(x + lenght + 2, y - 3 + 1, x + lenght + 3, y + var14 + 3 - 1, var16, var17);
|
||||
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y - 3 + 1, var16, var16);
|
||||
this.drawGradientRect(x - 3, y + var14 + 2, x + lenght + 3, y + var14 + 3, var17, var17);
|
||||
|
||||
for (ToolTipLine tip : toolTips) {
|
||||
String line = tip.text;
|
||||
|
||||
if (tip.color == -1) {
|
||||
line = "\u00a77" + line;
|
||||
} else {
|
||||
line = "\u00a7" + Integer.toHexString(tip.color) + line;
|
||||
}
|
||||
|
||||
this.fontRenderer.drawStringWithShadow(line, x, y, -1);
|
||||
|
||||
y += 10 + tip.getSpacing();
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
48
common/buildcraft/core/gui/GuiTools.java
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package buildcraft.core.gui.buttons;
|
||||
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.tooltips.IToolTipProvider;
|
||||
import buildcraft.core.gui.tooltips.ToolTip;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -15,7 +16,7 @@ import org.lwjgl.opengl.GL11;
|
|||
* @author CovertJaguar <railcraft.wikispaces.com>
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiBetterButton extends GuiButton {
|
||||
public class GuiBetterButton extends GuiButton implements IToolTipProvider {
|
||||
|
||||
public static final ResourceLocation BUTTON_TEXTURES = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/buttons.png");
|
||||
protected final IButtonTextureSet texture;
|
||||
|
@ -80,6 +81,7 @@ public class GuiBetterButton extends GuiButton {
|
|||
drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (h - 8) / 2, getTextColor(mouseOver));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolTip getToolTip() {
|
||||
return toolTip;
|
||||
}
|
||||
|
@ -87,4 +89,14 @@ public class GuiBetterButton extends GuiButton {
|
|||
public void setToolTip(ToolTip tips) {
|
||||
this.toolTip = tips;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isToolTipVisible() {
|
||||
return drawButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOver(int mouseX, int mouseY) {
|
||||
return isMouseOverButton(mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ package buildcraft.core.gui.buttons;
|
|||
public enum StandardButtonTextureSets implements IButtonTextureSet {
|
||||
|
||||
LARGE_BUTTON(0, 0, 20, 200),
|
||||
SMALL_BUTTON(0, 80, 15, 200);
|
||||
SMALL_BUTTON(0, 80, 15, 200),
|
||||
LEFT_BUTTON(204, 0, 16, 10),
|
||||
RIGHT_BUTTON(214, 0, 16, 10);
|
||||
private final int x, y, height, width;
|
||||
|
||||
private StandardButtonTextureSets(int x, int y, int height, int width) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
package buildcraft.core.gui.slots;
|
||||
|
||||
import buildcraft.core.gui.tooltips.IToolTipProvider;
|
||||
import buildcraft.core.gui.tooltips.ToolTip;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
@ -15,7 +16,7 @@ import net.minecraft.inventory.Slot;
|
|||
*
|
||||
* @author CovertJaguar <http://www.railcraft.info>
|
||||
*/
|
||||
public class SlotBase extends Slot {
|
||||
public class SlotBase extends Slot implements IToolTipProvider {
|
||||
|
||||
private ToolTip toolTips;
|
||||
|
||||
|
@ -30,6 +31,7 @@ public class SlotBase extends Slot {
|
|||
/**
|
||||
* @return the toolTips
|
||||
*/
|
||||
@Override
|
||||
public ToolTip getToolTip() {
|
||||
return toolTips;
|
||||
}
|
||||
|
@ -40,4 +42,14 @@ public class SlotBase extends Slot {
|
|||
public void setToolTips(ToolTip toolTips) {
|
||||
this.toolTips = toolTips;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isToolTipVisible() {
|
||||
return getStack() == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOver(int mouseX, int mouseY) {
|
||||
return mouseX >= xDisplayPosition && mouseX <= xDisplayPosition + 16 && mouseY >= yDisplayPosition && mouseY <= yDisplayPosition + 16;
|
||||
}
|
||||
}
|
||||
|
|
14
common/buildcraft/core/gui/tooltips/IToolTipProvider.java
Normal 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);
|
||||
}
|
61
common/buildcraft/core/gui/widgets/ButtonWidget.java
Normal 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) {
|
||||
}
|
||||
}
|
58
common/buildcraft/core/gui/widgets/FluidGaugeWidget.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
16
common/buildcraft/core/gui/widgets/IIndicatorController.java
Normal 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);
|
||||
|
||||
}
|
31
common/buildcraft/core/gui/widgets/IndicatorController.java
Normal 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;
|
||||
}
|
||||
}
|
33
common/buildcraft/core/gui/widgets/IndicatorWidget.java
Normal 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();
|
||||
}
|
||||
|
||||
}
|
92
common/buildcraft/core/gui/widgets/Widget.java
Normal 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) {
|
||||
}
|
||||
}
|
|
@ -21,12 +21,17 @@ public class InventoryIterator {
|
|||
if (inv instanceof ISidedInventory) {
|
||||
return new InventoryIteratorSided((ISidedInventory) inv, side);
|
||||
}
|
||||
|
||||
|
||||
return new InventoryIteratorSimple(inv);
|
||||
}
|
||||
|
||||
public interface IInvSlot {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the slot number of the underlying Inventory.
|
||||
*
|
||||
* @return the slot number
|
||||
*/
|
||||
int getIndex();
|
||||
|
||||
boolean canPutStackInSlot(ItemStack stack);
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.minecraft.world.World;
|
|||
public abstract interface IGuiReturnHandler {
|
||||
public World getWorld();
|
||||
|
||||
public void writeGuiData(DataOutputStream paramDataOutputStream) throws IOException;
|
||||
public void writeGuiData(DataOutputStream data) throws IOException;
|
||||
|
||||
public void readGuiData(DataInputStream paramDataInputStream, EntityPlayer paramEntityPlayer) throws IOException;
|
||||
public void readGuiData(DataInputStream data, EntityPlayer player) throws IOException;
|
||||
}
|
||||
|
|
59
common/buildcraft/core/network/PacketGuiWidget.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -37,27 +37,32 @@ public class PacketHandler implements IPacketHandler {
|
|||
int packetID = data.read();
|
||||
switch (packetID) {
|
||||
case PacketIds.TILE_UPDATE: {
|
||||
PacketTileUpdate packetT = new PacketTileUpdate();
|
||||
packetT.readData(data);
|
||||
onTileUpdate((EntityPlayer) player, packetT);
|
||||
PacketTileUpdate pkt = new PacketTileUpdate();
|
||||
pkt.readData(data);
|
||||
onTileUpdate((EntityPlayer) player, pkt);
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.STATE_UPDATE: {
|
||||
PacketTileState inPacket = new PacketTileState();
|
||||
inPacket.readData(data);
|
||||
PacketTileState pkt = new PacketTileState();
|
||||
pkt.readData(data);
|
||||
World world = ((EntityPlayer) player).worldObj;
|
||||
TileEntity tile = world.getBlockTileEntity(inPacket.posX, inPacket.posY, inPacket.posZ);
|
||||
TileEntity tile = world.getBlockTileEntity(pkt.posX, pkt.posY, pkt.posZ);
|
||||
if (tile instanceof ISyncedTile) {
|
||||
inPacket.applyStates(data, (ISyncedTile) tile);
|
||||
pkt.applyStates(data, (ISyncedTile) tile);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.GUI_RETURN: {
|
||||
PacketGuiReturn packet1 = new PacketGuiReturn((EntityPlayer) player);
|
||||
packet1.readData(data);
|
||||
// onGuiReturn((EntityPlayer) player, packet1);
|
||||
PacketGuiReturn pkt = new PacketGuiReturn((EntityPlayer) player);
|
||||
pkt.readData(data);
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.GUI_WIDGET: {
|
||||
PacketGuiWidget pkt = new PacketGuiWidget();
|
||||
pkt.readData(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public class PacketIds {
|
|||
public static final int SELECTION_ADVANCED_WORKBENCH = 71;
|
||||
|
||||
public static final int GUI_RETURN = 80;
|
||||
public static final int GUI_WIDGET = 81;
|
||||
|
||||
public static final int STATE_UPDATE = 100;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public abstract class BCAction implements IAction {
|
|||
return this.legacyId;
|
||||
}
|
||||
|
||||
public int getIconIndex(){
|
||||
public int getIconIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,10 @@ public abstract class BCAction implements IAction {
|
|||
return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex());
|
||||
}
|
||||
|
||||
public int getTextureMap() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
|
|
|
@ -10,8 +10,12 @@ package buildcraft.core.utils;
|
|||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftEnergy;
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFluid;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
@ -22,12 +26,14 @@ import net.minecraft.network.packet.Packet60Explosion;
|
|||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
|
||||
|
||||
public class BlockUtil {
|
||||
|
||||
public static List<ItemStack> getItemStackFromBlock(World world, int i, int j, int k) {
|
||||
|
@ -41,7 +47,19 @@ public class BlockUtil {
|
|||
|
||||
int meta = world.getBlockMetadata(i, j, k);
|
||||
|
||||
return block.getBlockDropped(world, i, j, k, meta, 0);
|
||||
ArrayList<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) {
|
||||
|
@ -50,8 +68,7 @@ public class BlockUtil {
|
|||
|
||||
public static void breakBlock(World world, int x, int y, int z, int forcedLifespan) {
|
||||
if (!world.isAirBlock(x, y, z) && BuildCraftCore.dropBrokenBlocks && !world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
|
||||
int blockId = world.getBlockId(x, y, z);
|
||||
List<ItemStack> items = Block.blocksList[blockId].getBlockDropped(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
||||
List<ItemStack> items = getItemStackFromBlock(world, x, y, z);
|
||||
|
||||
for (ItemStack item : items) {
|
||||
float var = 0.7F;
|
||||
|
|
|
@ -157,7 +157,7 @@ public enum EnumColor {
|
|||
return NAMES[ordinal()];
|
||||
}
|
||||
|
||||
public String getTranslatedName() {
|
||||
public String getLocalizedName() {
|
||||
return StringUtils.localize(getTag());
|
||||
}
|
||||
|
||||
|
|
24
common/buildcraft/core/utils/MathUtils.java
Normal 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);
|
||||
}
|
||||
}
|
65
common/buildcraft/core/utils/RevolvingList.java
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,13 +8,12 @@
|
|||
package buildcraft.energy;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.BlockBuildCraft;
|
||||
import buildcraft.core.IItemPipe;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
@ -25,7 +24,7 @@ import net.minecraft.util.Icon;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class BlockEngine extends BlockContainer {
|
||||
public class BlockEngine extends BlockBuildCraft {
|
||||
|
||||
private static Icon woodTexture;
|
||||
private static Icon stoneTexture;
|
||||
|
@ -33,9 +32,6 @@ public class BlockEngine extends BlockContainer {
|
|||
|
||||
public BlockEngine(int i) {
|
||||
super(i, Material.iron);
|
||||
|
||||
setHardness(5F);
|
||||
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
|
||||
setUnlocalizedName("engineBlock");
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.LinkedList;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -45,8 +44,8 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
public static float COOLDOWN_RATE = 0.05F;
|
||||
public static int MAX_COOLANT_PER_TICK = 40;
|
||||
int burnTime = 0;
|
||||
private Tank tankFuel = new Tank("tankFuel", MAX_LIQUID, this);
|
||||
private Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this);
|
||||
public Tank tankFuel = new Tank("tankFuel", MAX_LIQUID, this);
|
||||
public Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this);
|
||||
private TankManager tankManager = new TankManager();
|
||||
private Fuel currentFuel = null;
|
||||
public int penaltyCooling = 0;
|
||||
|
@ -71,9 +70,9 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
return false;
|
||||
}
|
||||
ItemStack current = player.getCurrentEquippedItem();
|
||||
if (current != null && current.itemID != Item.bucketEmpty.itemID) {
|
||||
if (current != null) {
|
||||
if (CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (FluidUtils.handleRightClick(this, side, player, true, false)) {
|
||||
if (FluidUtils.handleRightClick(this, side, player, true, true)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
@ -292,7 +291,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
tankFuel.getFluid().amount = value;
|
||||
}
|
||||
break;
|
||||
// Fluid coolant amount
|
||||
// Fluid Coolant amount
|
||||
case 18:
|
||||
if (tankCoolant.getFluid() == null) {
|
||||
tankCoolant.setFluid(new FluidStack(0, value));
|
||||
|
@ -300,6 +299,14 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
tankCoolant.getFluid().amount = value;
|
||||
}
|
||||
break;
|
||||
//Fluid Fuel color
|
||||
case 19:
|
||||
tankFuel.colorRenderCache = value;
|
||||
break;
|
||||
//Fluid Coolant color
|
||||
case 20:
|
||||
tankCoolant.colorRenderCache = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,6 +317,8 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
iCrafting.sendProgressBarUpdate(containerEngine, 16, tankCoolant.getFluid() != null ? tankCoolant.getFluid().fluidID : 0);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 17, tankFuel.getFluid() != null ? tankFuel.getFluid().amount : 0);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 18, tankCoolant.getFluid() != null ? tankCoolant.getFluid().amount : 0);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 19, tankFuel.colorRenderCache);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 20, tankCoolant.colorRenderCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -320,18 +329,23 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
/* ITANKCONTAINER */
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return null;
|
||||
return tankFuel.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
if (resource == null)
|
||||
return null;
|
||||
if (tankCoolant.getFluidType() == resource.getFluid())
|
||||
return tankCoolant.drain(resource.amount, doDrain);
|
||||
if (tankFuel.getFluidType() == resource.getFluid())
|
||||
return tankFuel.drain(resource.amount, doDrain);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
*/
|
||||
package buildcraft.energy.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.fluids.Tank;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.energy.TileEngineIron;
|
||||
import buildcraft.energy.TileEngineWithInventory;
|
||||
|
@ -27,7 +27,7 @@ public class GuiCombustionEngine extends GuiEngine {
|
|||
private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture;
|
||||
|
||||
public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) {
|
||||
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine);
|
||||
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine, TEXTURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,24 +40,22 @@ public class GuiCombustionEngine extends GuiEngine {
|
|||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(TEXTURE);
|
||||
super.drawGuiContainerBackgroundLayer(f, x, y);
|
||||
int j = (width - xSize) / 2;
|
||||
int k = (height - ySize) / 2;
|
||||
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
|
||||
|
||||
TileEngineIron engine = (TileEngineIron) tile;
|
||||
|
||||
if (engine.getScaledBurnTime(58) > 0) {
|
||||
displayGauge(j, k, 19, 104, engine.getScaledBurnTime(58), engine.getFuel());
|
||||
displayGauge(j, k, 19, 104, engine.getScaledBurnTime(58), engine.getFuel(), engine.tankFuel);
|
||||
}
|
||||
|
||||
if (engine.getScaledCoolant(58) > 0) {
|
||||
displayGauge(j, k, 19, 122, engine.getScaledCoolant(58), engine.getCoolant());
|
||||
displayGauge(j, k, 19, 122, engine.getScaledCoolant(58), engine.getCoolant(), engine.tankCoolant);
|
||||
}
|
||||
}
|
||||
|
||||
private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid) {
|
||||
private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid, Tank tank) {
|
||||
if (liquid == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -65,11 +63,16 @@ public class GuiCombustionEngine extends GuiEngine {
|
|||
|
||||
Icon liquidIcon = null;
|
||||
Fluid fluid = liquid.getFluid();
|
||||
int color = tank.colorRenderCache;
|
||||
if (fluid != null && fluid.getStillIcon() != null) {
|
||||
liquidIcon = fluid.getStillIcon();
|
||||
}
|
||||
mc.renderEngine.bindTexture(BLOCK_TEXTURE);
|
||||
|
||||
float red = (float) (color >> 16 & 255) / 255.0F;
|
||||
float green = (float) (color >> 8 & 255) / 255.0F;
|
||||
float blue = (float) (color & 255) / 255.0F;
|
||||
GL11.glColor4f(red, green, blue, 1.0F);
|
||||
|
||||
if (liquidIcon != null) {
|
||||
while (true) {
|
||||
int x;
|
||||
|
@ -91,6 +94,7 @@ public class GuiCombustionEngine extends GuiEngine {
|
|||
}
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(TEXTURE);
|
||||
drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60);
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ public abstract class GuiEngine extends GuiBuildCraft {
|
|||
}
|
||||
}
|
||||
|
||||
public GuiEngine(BuildCraftContainer container, IInventory inventory) {
|
||||
super(container, inventory);
|
||||
public GuiEngine(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) {
|
||||
super(container, inventory, texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,7 @@ public class GuiStoneEngine extends GuiEngine {
|
|||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/steam_engine_gui.png");
|
||||
|
||||
public GuiStoneEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) {
|
||||
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine);
|
||||
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine, TEXTURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
package buildcraft.factory;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.BlockBuildCraft;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -23,7 +23,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockFloodGate extends BlockContainer {
|
||||
public class BlockFloodGate extends BlockBuildCraft {
|
||||
|
||||
private Icon textureTop;
|
||||
private Icon textureBottom;
|
||||
|
@ -31,8 +31,6 @@ public class BlockFloodGate extends BlockContainer {
|
|||
|
||||
public BlockFloodGate(int i) {
|
||||
super(i, Material.iron);
|
||||
setHardness(5F);
|
||||
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,6 @@ public class BlockHopper extends BlockBuildCraft {
|
|||
|
||||
public BlockHopper(int blockId) {
|
||||
super(blockId, Material.iron);
|
||||
setHardness(5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,7 @@ package buildcraft.factory;
|
|||
|
||||
import buildcraft.BuildCraftFactory;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.core.BlockBuildCraft;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -24,7 +25,7 @@ import net.minecraft.util.Icon;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class BlockMiningWell extends BlockMachineRoot {
|
||||
public class BlockMiningWell extends BlockBuildCraft {
|
||||
|
||||
Icon textureFront, textureSides, textureBack, textureTop;
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import buildcraft.core.CoreConstants;
|
|||
import buildcraft.core.IFramePipeConnection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
package buildcraft.factory;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.BlockBuildCraft;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -23,7 +23,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockPump extends BlockContainer {
|
||||
public class BlockPump extends BlockBuildCraft {
|
||||
|
||||
private Icon textureTop;
|
||||
private Icon textureBottom;
|
||||
|
@ -31,8 +31,6 @@ public class BlockPump extends BlockContainer {
|
|||
|
||||
public BlockPump(int i) {
|
||||
super(i, Material.iron);
|
||||
setHardness(5F);
|
||||
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,6 +81,15 @@ public class BlockPump extends BlockContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int id) {
|
||||
super.onNeighborBlockChange(world, x, y, z, id);
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof TilePump) {
|
||||
((TilePump) tile).onNeighborBlockChange(id);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Override
|
||||
public void addCreativeItems(ArrayList itemList) {
|
||||
|
|