Added transport part of BuildCraft API
This commit is contained in:
parent
80c7eb930f
commit
9fe604449b
8 changed files with 234 additions and 0 deletions
25
APIs/buildcraft/api/transport/FacadeManager.java
Normal file
25
APIs/buildcraft/api/transport/FacadeManager.java
Normal file
|
@ -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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
APIs/buildcraft/api/transport/IExtractionHandler.java
Normal file
21
APIs/buildcraft/api/transport/IExtractionHandler.java
Normal file
|
@ -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);
|
||||||
|
}
|
45
APIs/buildcraft/api/transport/IPipe.java
Normal file
45
APIs/buildcraft/api/transport/IPipe.java
Normal file
|
@ -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);
|
||||||
|
|
||||||
|
}
|
29
APIs/buildcraft/api/transport/IPipeConnection.java
Normal file
29
APIs/buildcraft/api/transport/IPipeConnection.java
Normal file
|
@ -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);
|
||||||
|
}
|
39
APIs/buildcraft/api/transport/IPipeTile.java
Normal file
39
APIs/buildcraft/api/transport/IPipeTile.java
Normal file
|
@ -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);
|
||||||
|
}
|
7
APIs/buildcraft/api/transport/ISolidSideTile.java
Normal file
7
APIs/buildcraft/api/transport/ISolidSideTile.java
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
package buildcraft.api.transport;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
|
public interface ISolidSideTile {
|
||||||
|
public boolean isSolidOnSide(ForgeDirection side);
|
||||||
|
}
|
36
APIs/buildcraft/api/transport/PipeManager.java
Normal file
36
APIs/buildcraft/api/transport/PipeManager.java
Normal file
|
@ -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<IExtractionHandler> extractionHandlers = new ArrayList<IExtractionHandler>();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
32
src/dark/core/common/ExternalModHandler.java
Normal file
32
src/dark/core/common/ExternalModHandler.java
Normal file
|
@ -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<String, Pair<Integer, Integer>> pipeMap = new HashMap<String, Pair<Integer, Integer>>();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue