diff --git a/APIs/buildcraft/api/transport/FacadeManager.java b/APIs/buildcraft/api/transport/FacadeManager.java new file mode 100644 index 00000000..28cbdd1a --- /dev/null +++ b/APIs/buildcraft/api/transport/FacadeManager.java @@ -0,0 +1,25 @@ +package buildcraft.api.transport; + +import java.lang.reflect.Method; +import net.minecraft.item.ItemStack; + +/** + * You can use this if you wish, but FML InterModComms are recommended. + * + * SYNTAX: add-facade:id@meta + */ +public class FacadeManager { + private static Method addFacade; + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static void addFacade(ItemStack is) { + try { + if (addFacade == null) { + Class facade = Class.forName("buildcraft.transport.ItemFacade"); + addFacade = facade.getMethod("addFacade", ItemStack.class); + } + addFacade.invoke(null, is); + } catch (Exception ex) { + } + } +} diff --git a/APIs/buildcraft/api/transport/IExtractionHandler.java b/APIs/buildcraft/api/transport/IExtractionHandler.java new file mode 100644 index 00000000..e912f65b --- /dev/null +++ b/APIs/buildcraft/api/transport/IExtractionHandler.java @@ -0,0 +1,21 @@ +package buildcraft.api.transport; + +import net.minecraft.world.World; + +/** + * Implement and register with the PipeManager if you want to suppress connections from wooden pipes. + */ +public interface IExtractionHandler { + + /** + * Can this pipe extract items from the block located at these coordinates? + * param extractor can be null + */ + boolean canExtractItems(Object extractor, World world, int i, int j, int k); + + /** + * Can this pipe extract liquids from the block located at these coordinates? + * param extractor can be null + */ + boolean canExtractFluids(Object extractor, World world, int i, int j, int k); +} diff --git a/APIs/buildcraft/api/transport/IPipe.java b/APIs/buildcraft/api/transport/IPipe.java new file mode 100644 index 00000000..20096b76 --- /dev/null +++ b/APIs/buildcraft/api/transport/IPipe.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) SpaceToad, 2011 + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ + +package buildcraft.api.transport; + +import net.minecraft.tileentity.TileEntity; + +public interface IPipe { + + enum DrawingState { + DrawingPipe, DrawingRedWire, DrawingBlueWire, DrawingGreenWire, DrawingYellowWire, DrawingGate + } + + enum WireColor { + Red, Blue, Green, Yellow; + + public WireColor reverse() { + switch (this) { + case Red: + return Yellow; + case Blue: + return Green; + case Green: + return Blue; + default: + return Red; + } + } + } + + public boolean isWired(WireColor color); + + public boolean hasGate(); + + public TileEntity getContainer(); + + public boolean isWireConnectedTo(TileEntity tile, WireColor color); + +} diff --git a/APIs/buildcraft/api/transport/IPipeConnection.java b/APIs/buildcraft/api/transport/IPipeConnection.java new file mode 100644 index 00000000..cbb1d003 --- /dev/null +++ b/APIs/buildcraft/api/transport/IPipeConnection.java @@ -0,0 +1,29 @@ +/** + * 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.api.transport; + +import buildcraft.api.transport.IPipeTile.PipeType; +import net.minecraftforge.common.ForgeDirection; + +public interface IPipeConnection { + + enum ConnectOverride { + + CONNECT, DISCONNECT, DEFAULT + }; + + /** + * Allows you to override pipe connection logic. + * + * @param type + * @param with + * @return CONNECT to force a connection, DISCONNECT to force no connection, + * and DEFAULT to let the pipe decide. + */ + public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with); +} diff --git a/APIs/buildcraft/api/transport/IPipeTile.java b/APIs/buildcraft/api/transport/IPipeTile.java new file mode 100644 index 00000000..13aa8d76 --- /dev/null +++ b/APIs/buildcraft/api/transport/IPipeTile.java @@ -0,0 +1,39 @@ +/** + * 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.api.transport; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.IFluidHandler; + +public interface IPipeTile extends ISolidSideTile, IFluidHandler { + + public enum PipeType { + + ITEM, FLUID, POWER, STRUCTURE; + } + + @Deprecated + IPipe getPipe(); + + PipeType getPipeType(); + + /** + * Offers an ItemStack for addition to the pipe. Will be rejected if the + * pipe doesn't accept items from that side. + * + * @param stack ItemStack offered for addition. Do not manipulate this! + * @param doAdd If false no actual addition should take place. Implementors + * should simulate. + * @param from Orientation the ItemStack is offered from. + * @return Amount of items used from the passed stack. + */ + int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from); + + boolean isPipeConnected(ForgeDirection with); +} diff --git a/APIs/buildcraft/api/transport/ISolidSideTile.java b/APIs/buildcraft/api/transport/ISolidSideTile.java new file mode 100644 index 00000000..627b0d88 --- /dev/null +++ b/APIs/buildcraft/api/transport/ISolidSideTile.java @@ -0,0 +1,7 @@ +package buildcraft.api.transport; + +import net.minecraftforge.common.ForgeDirection; + +public interface ISolidSideTile { + public boolean isSolidOnSide(ForgeDirection side); +} diff --git a/APIs/buildcraft/api/transport/PipeManager.java b/APIs/buildcraft/api/transport/PipeManager.java new file mode 100644 index 00000000..c78c86e2 --- /dev/null +++ b/APIs/buildcraft/api/transport/PipeManager.java @@ -0,0 +1,36 @@ +package buildcraft.api.transport; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.world.World; + +public abstract class PipeManager { + + public static List extractionHandlers = new ArrayList(); + + public static void registerExtractionHandler(IExtractionHandler handler) { + extractionHandlers.add(handler); + } + + /** + * param extractor can be null + */ + public static boolean canExtractItems(Object extractor, World world, int i, int j, int k) { + for (IExtractionHandler handler : extractionHandlers) + if (!handler.canExtractItems(extractor, world, i, j, k)) + return false; + + return true; + } + + /** + * param extractor can be null + */ + public static boolean canExtractFluids(Object extractor, World world, int i, int j, int k) { + for (IExtractionHandler handler : extractionHandlers) + if (!handler.canExtractFluids(extractor, world, i, j, k)) + return false; + + return true; + } +} diff --git a/src/dark/core/common/ExternalModHandler.java b/src/dark/core/common/ExternalModHandler.java new file mode 100644 index 00000000..44bc0e82 --- /dev/null +++ b/src/dark/core/common/ExternalModHandler.java @@ -0,0 +1,32 @@ +package dark.core.common; + +import java.util.HashMap; + +import net.minecraft.tileentity.TileEntity; +import buildcraft.api.transport.IPipeTile; +import buildcraft.api.transport.IPipeTile.PipeType; +import dark.core.prefab.helpers.Pair; + +/** Handles working with other mod without or without the need of the APIs. + * + * @author DarkGuardsman */ +public class ExternalModHandler +{ + private static HashMap> pipeMap = new HashMap>(); + + public static void mapBuildCraftPipes() + { + //TODO map pipe blockIDs, and metadata for later use + } + + /** Is the tileEntity an instanceof IPipeTile and of type fluid from BuildCraft */ + public boolean isBCFluidPipe(TileEntity entity) + { + return entity instanceof IPipeTile && ((IPipeTile) entity).getPipeType() == PipeType.FLUID; + } + + public boolean isBCPowerPipe(TileEntity entity) + { + return entity instanceof IPipeTile && ((IPipeTile) entity).getPipeType() == PipeType.POWER; + } +}