remove IExtractionHandlers
This commit is contained in:
parent
6fd9f36775
commit
1b03c24574
16 changed files with 40 additions and 170 deletions
|
@ -1,29 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License.
|
||||
* Please check the contents of the license, which should be located
|
||||
* as "LICENSE.API" in the BuildCraft source code distribution.
|
||||
*/
|
||||
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);
|
||||
}
|
|
@ -16,11 +16,6 @@ import buildcraft.api.transport.pluggable.PipePluggable;
|
|||
|
||||
public interface IPipeContainer extends IInjectable {
|
||||
|
||||
public enum PipeType {
|
||||
|
||||
ITEM, FLUID, POWER, STRUCTURE
|
||||
}
|
||||
|
||||
PipeType getPipeType();
|
||||
|
||||
World getWorldObj();
|
||||
|
@ -47,4 +42,12 @@ public interface IPipeContainer extends IInjectable {
|
|||
|
||||
PipePluggable getPipePluggable(ForgeDirection direction);
|
||||
boolean hasPipePluggable(ForgeDirection direction);
|
||||
|
||||
/**
|
||||
* Created by asie on 12/19/14.
|
||||
*/
|
||||
enum PipeType {
|
||||
|
||||
ITEM, FLUID, POWER, STRUCTURE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,23 +13,17 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.api.transport.pluggable.PipePluggable;
|
||||
|
||||
public abstract class PipeManager {
|
||||
|
||||
public static List<IStripesHandler> stripesHandlers = new ArrayList<IStripesHandler>();
|
||||
public static List<IExtractionHandler> extractionHandlers = new ArrayList<IExtractionHandler>();
|
||||
public static ArrayList<Class<? extends PipePluggable>> pipePluggables = new ArrayList<Class<? extends PipePluggable>>();
|
||||
private static Map<String, Class<? extends PipePluggable>> pipePluggableNames =
|
||||
new HashMap<String, Class<? extends PipePluggable>>();
|
||||
private static Map<Class<? extends PipePluggable>, String> pipePluggableByNames =
|
||||
new HashMap<Class<? extends PipePluggable>, String>();
|
||||
|
||||
public static void registerExtractionHandler(IExtractionHandler handler) {
|
||||
extractionHandlers.add(handler);
|
||||
}
|
||||
|
||||
public static void registerStripesHandler(IStripesHandler handler) {
|
||||
stripesHandlers.add(handler);
|
||||
}
|
||||
|
@ -40,32 +34,6 @@ public abstract class PipeManager {
|
|||
pipePluggableByNames.put(pluggable, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
public static Class<?> getPluggableByName(String pluggableName) {
|
||||
return pipePluggableNames.get(pluggableName);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ import buildcraft.api.recipes.BuildcraftRecipeRegistry;
|
|||
import buildcraft.api.statements.IActionInternal;
|
||||
import buildcraft.api.statements.ITriggerInternal;
|
||||
import buildcraft.api.statements.StatementManager;
|
||||
import buildcraft.api.transport.IExtractionHandler;
|
||||
import buildcraft.api.transport.PipeManager;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
|
@ -245,49 +244,6 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
Object[] input;
|
||||
}
|
||||
|
||||
private static class ExtractionHandler implements IExtractionHandler {
|
||||
|
||||
private final String[] items;
|
||||
private final String[] liquids;
|
||||
|
||||
public ExtractionHandler(String[] items, String[] liquids) {
|
||||
this.items = items;
|
||||
this.liquids = liquids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItems(Object extractor, World world, int i, int j, int k) {
|
||||
return testStrings(items, world, i, j, k);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractFluids(Object extractor, World world, int i, int j, int k) {
|
||||
return testStrings(liquids, world, i, j, k);
|
||||
}
|
||||
|
||||
private boolean testStrings(String[] excludedBlocks, World world, int i, int j, int k) {
|
||||
Block block = world.getBlock(i, j, k);
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//int meta = world.getBlockMetadata(i, j, k);
|
||||
|
||||
// TODO: the exculded list is not taken into account. This probably
|
||||
// needs to be migrated to an implementation based on names instead
|
||||
// of ids, low priority for now.
|
||||
/*for (String excluded : excludedBlocks) {
|
||||
if (excluded.equals(block.getUnlocalizedName()))
|
||||
return false;
|
||||
|
||||
String[] tokens = excluded.split(":");
|
||||
if (tokens[0].equals(Integer.toString(id)) && (tokens.length == 1 || tokens[1].equals(Integer.toString(meta))))
|
||||
return false;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent evt) {
|
||||
try {
|
||||
|
@ -301,33 +257,9 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
Property printFacadeList = BuildCraftCore.mainConfiguration.get("debug", "facades.printFacadeList", false);
|
||||
debugPrintFacadeList = printFacadeList.getBoolean();
|
||||
|
||||
Property exclusionItemList = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "woodenPipe.item.exclusion", new String[0]);
|
||||
|
||||
String[] excludedItemBlocks = exclusionItemList.getStringList();
|
||||
if (excludedItemBlocks != null) {
|
||||
for (int j = 0; j < excludedItemBlocks.length; ++j) {
|
||||
excludedItemBlocks[j] = excludedItemBlocks[j].trim();
|
||||
}
|
||||
} else {
|
||||
excludedItemBlocks = new String[0];
|
||||
}
|
||||
|
||||
Property exclusionFluidList = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "woodenPipe.liquid.exclusion", new String[0]);
|
||||
|
||||
String[] excludedFluidBlocks = exclusionFluidList.getStringList();
|
||||
if (excludedFluidBlocks != null) {
|
||||
for (int j = 0; j < excludedFluidBlocks.length; ++j) {
|
||||
excludedFluidBlocks[j] = excludedFluidBlocks[j].trim();
|
||||
}
|
||||
} else {
|
||||
excludedFluidBlocks = new String[0];
|
||||
}
|
||||
|
||||
filteredBufferBlock = new BlockFilteredBuffer();
|
||||
CoreProxy.proxy.registerBlock(filteredBufferBlock.setBlockName("filteredBufferBlock"));
|
||||
|
||||
PipeManager.registerExtractionHandler(new ExtractionHandler(excludedItemBlocks, excludedFluidBlocks));
|
||||
|
||||
GateExpansions.registerExpansion(GateExpansionPulsar.INSTANCE);
|
||||
GateExpansions.registerExpansion(GateExpansionTimer.INSTANCE);
|
||||
GateExpansions.registerExpansion(GateExpansionRedstoneFader.INSTANCE);
|
||||
|
|
|
@ -10,7 +10,7 @@ package buildcraft.core.robots;
|
|||
|
||||
import buildcraft.api.robots.AIRobot;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
import buildcraft.transport.PipeTransportPower;
|
||||
|
||||
public class AIRobotRecharge extends AIRobot {
|
||||
|
@ -28,7 +28,7 @@ public class AIRobotRecharge extends AIRobot {
|
|||
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new IStationFilter() {
|
||||
@Override
|
||||
public boolean matches(DockingStation station) {
|
||||
return station.getPipe().getPipeType() == PipeType.POWER;
|
||||
return station.getPipe().getPipeType() == IPipeContainer.PipeType.POWER;
|
||||
}
|
||||
}, null));
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import buildcraft.api.core.IAreaProvider;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.EntityBlock;
|
||||
import buildcraft.core.IDropControlInventory;
|
||||
|
@ -67,7 +66,6 @@ public final class Utils {
|
|||
private Utils() {
|
||||
}
|
||||
|
||||
/* IINVENTORY HELPERS */
|
||||
/**
|
||||
* Tries to add the passed stack to any valid inventories around the given
|
||||
* coordinates.
|
||||
|
@ -165,7 +163,7 @@ public final class Utils {
|
|||
|
||||
if (tile instanceof IPipeContainer) {
|
||||
IPipeContainer pipe = (IPipeContainer) tile;
|
||||
if (pipe.getPipeType() != PipeType.ITEM) {
|
||||
if (pipe.getPipeType() != IPipeContainer.PipeType.ITEM) {
|
||||
continue;
|
||||
}
|
||||
if (!pipe.isPipeConnected(side.getOpposite())) {
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
import buildcraft.core.TileBuffer;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
|
||||
|
@ -65,9 +65,9 @@ public class TileEnergyReceiver extends TileBuildCraft implements IPipeConnectio
|
|||
}
|
||||
|
||||
@Override
|
||||
public ConnectOverride overridePipeConnection(PipeType type,
|
||||
public ConnectOverride overridePipeConnection(IPipeContainer.PipeType type,
|
||||
ForgeDirection with) {
|
||||
return type == PipeType.POWER ? ConnectOverride.CONNECT : ConnectOverride.DISCONNECT;
|
||||
return type == IPipeContainer.PipeType.POWER ? ConnectOverride.CONNECT : ConnectOverride.DISCONNECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,6 @@ import buildcraft.api.tiles.IHeatable;
|
|||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.utils.MathUtils;
|
||||
|
@ -550,8 +549,8 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
public abstract int calculateCurrentOutput();
|
||||
|
||||
@Override
|
||||
public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with) {
|
||||
if (type == PipeType.POWER) {
|
||||
public ConnectOverride overridePipeConnection(IPipeContainer.PipeType type, ForgeDirection with) {
|
||||
if (type == IPipeContainer.PipeType.POWER) {
|
||||
return ConnectOverride.DEFAULT;
|
||||
} else if (with == orientation) {
|
||||
return ConnectOverride.DISCONNECT;
|
||||
|
|
|
@ -12,7 +12,6 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.api.power.IRedstoneEngineReceiver;
|
||||
|
||||
public class TileEngineWood extends TileEngine {
|
||||
|
@ -88,7 +87,7 @@ public class TileEngineWood extends TileEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with) {
|
||||
public ConnectOverride overridePipeConnection(IPipeContainer.PipeType type, ForgeDirection with) {
|
||||
return ConnectOverride.DISCONNECT;
|
||||
}
|
||||
|
||||
|
@ -127,7 +126,7 @@ public class TileEngineWood extends TileEngine {
|
|||
|
||||
// TODO: Make a proper API out of this
|
||||
if ((tile instanceof IRedstoneEngineReceiver && ((IRedstoneEngineReceiver) tile).canConnectRedstoneEngine(orientation.getOpposite())) ||
|
||||
(tile instanceof IPipeContainer && ((IPipeContainer) tile).getPipeType() != PipeType.POWER)) {
|
||||
(tile instanceof IPipeContainer && ((IPipeContainer) tile).getPipeType() != IPipeContainer.PipeType.POWER)) {
|
||||
super.sendPower();
|
||||
} else {
|
||||
this.energy = 0;
|
||||
|
|
|
@ -15,7 +15,7 @@ import buildcraft.api.blueprints.BuilderAPI;
|
|||
import buildcraft.api.tiles.IControllable;
|
||||
import buildcraft.api.tiles.IHasWork;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
import buildcraft.core.RFBattery;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.utils.BlockUtils;
|
||||
|
@ -110,9 +110,9 @@ public class TileMiningWell extends TileBuildCraft implements IHasWork, IPipeCon
|
|||
}
|
||||
|
||||
@Override
|
||||
public ConnectOverride overridePipeConnection(PipeType type,
|
||||
public ConnectOverride overridePipeConnection(IPipeContainer.PipeType type,
|
||||
ForgeDirection with) {
|
||||
return type == PipeType.ITEM ? ConnectOverride.CONNECT : ConnectOverride.DEFAULT;
|
||||
return type == IPipeContainer.PipeType.ITEM ? ConnectOverride.CONNECT : ConnectOverride.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
import buildcraft.core.utils.BitSetUtils;
|
||||
|
||||
public abstract class PipeTransport {
|
||||
|
@ -34,7 +34,7 @@ public abstract class PipeTransport {
|
|||
}
|
||||
}
|
||||
|
||||
public abstract PipeType getPipeType();
|
||||
public abstract IPipeContainer.PipeType getPipeType();
|
||||
|
||||
public World getWorld() {
|
||||
return container.getWorldObj();
|
||||
|
|
|
@ -25,7 +25,7 @@ import net.minecraftforge.fluids.IFluidHandler;
|
|||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.utils.MathUtils;
|
||||
import buildcraft.transport.network.PacketFluidUpdate;
|
||||
|
@ -184,8 +184,8 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public PipeType getPipeType() {
|
||||
return PipeType.FLUID;
|
||||
public IPipeContainer.PipeType getPipeType() {
|
||||
return IPipeContainer.PipeType.FLUID;
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
|
|
|
@ -28,7 +28,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.BCLog;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.inventory.Transactor;
|
||||
import buildcraft.core.utils.BlockUtils;
|
||||
|
@ -46,8 +46,8 @@ public class PipeTransportItems extends PipeTransport {
|
|||
public final TravelerSet items = new TravelerSet(this);
|
||||
|
||||
@Override
|
||||
public PipeType getPipeType() {
|
||||
return PipeType.ITEM;
|
||||
public IPipeContainer.PipeType getPipeType() {
|
||||
return IPipeContainer.PipeType.ITEM;
|
||||
}
|
||||
|
||||
public void readjustSpeed(TravelingItem item) {
|
||||
|
|
|
@ -22,7 +22,7 @@ import buildcraft.BuildCraftCore;
|
|||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.api.power.IEngine;
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.transport.network.PacketPowerUpdate;
|
||||
|
@ -75,8 +75,8 @@ public class PipeTransportPower extends PipeTransport {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PipeType getPipeType() {
|
||||
return PipeType.POWER;
|
||||
public IPipeContainer.PipeType getPipeType() {
|
||||
return IPipeContainer.PipeType.POWER;
|
||||
}
|
||||
|
||||
public void initFromPipe(Class<? extends Pipe> pipeClass) {
|
||||
|
|
|
@ -12,13 +12,13 @@ import net.minecraft.tileentity.TileEntity;
|
|||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
|
||||
public class PipeTransportStructure extends PipeTransport {
|
||||
|
||||
@Override
|
||||
public PipeType getPipeType() {
|
||||
return PipeType.STRUCTURE;
|
||||
public IPipeContainer.PipeType getPipeType() {
|
||||
return IPipeContainer.PipeType.STRUCTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,7 +37,7 @@ import buildcraft.BuildCraftCore.RenderMode;
|
|||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.api.gates.IGateExpansion;
|
||||
import buildcraft.api.transport.IPipeContainer.PipeType;
|
||||
import buildcraft.api.transport.IPipeContainer;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
import buildcraft.core.CoreConstants;
|
||||
import buildcraft.core.DefaultProps;
|
||||
|
@ -290,14 +290,14 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
|
|||
renderGatesWires(pipe, x, y, z);
|
||||
renderGates(pipe, x, y, z);
|
||||
|
||||
PipeType pipeType = pipe.getPipeType();
|
||||
IPipeContainer.PipeType pipeType = pipe.getPipeType();
|
||||
|
||||
// do not use switch. we will be transitioning away from the enum
|
||||
if (pipeType == PipeType.ITEM) {
|
||||
if (pipeType == IPipeContainer.PipeType.ITEM) {
|
||||
renderSolids(pipe.pipe, x, y, z);
|
||||
} else if (pipeType == PipeType.FLUID) {
|
||||
} else if (pipeType == IPipeContainer.PipeType.FLUID) {
|
||||
renderFluids(pipe.pipe, x, y, z);
|
||||
} else if (pipeType == PipeType.POWER) {
|
||||
} else if (pipeType == IPipeContainer.PipeType.POWER) {
|
||||
renderPower(pipe.pipe, x, y, z);
|
||||
} /* else if (pipeType == PipeType.STRUCTURE) {
|
||||
// no object to render in a structure pipe;
|
||||
|
|
Loading…
Add table
Reference in a new issue