move IPipePluggable to PipePluggable, move Diamond Liquid Pipes to the event system

This commit is contained in:
asiekierka 2014-12-16 10:44:49 +01:00
parent c47173f4e6
commit 9b857eaba7
20 changed files with 103 additions and 185 deletions

View file

@ -46,4 +46,7 @@ public interface IPipeContainer extends IInjectable {
IPipe getNeighborPipe(ForgeDirection dir);
IPipe getPipe();
PipePluggable getPipePluggable(ForgeDirection direction);
boolean hasPipePluggable(ForgeDirection direction);
}

View file

@ -6,6 +6,6 @@ import buildcraft.api.core.render.ITextureStates;
public interface IPipePluggableRenderer {
void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side,
IPipePluggable pipePluggable, ITextureStates blockStateMachine,
PipePluggable pipePluggable, ITextureStates blockStateMachine,
int x, int y, int z);
}

View file

@ -20,11 +20,11 @@ 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 IPipePluggable>> pipePluggables = new ArrayList<Class<? extends IPipePluggable>>();
private static Map<String, Class<? extends IPipePluggable>> pipePluggableNames =
new HashMap<String, Class<? extends IPipePluggable>>();
private static Map<Class<? extends IPipePluggable>, String> pipePluggableByNames =
new HashMap<Class<? extends IPipePluggable>, String>();
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);
@ -34,7 +34,7 @@ public abstract class PipeManager {
stripesHandlers.add(handler);
}
public static void registerPipePluggable(Class<? extends IPipePluggable> pluggable, String name) {
public static void registerPipePluggable(Class<? extends PipePluggable> pluggable, String name) {
pipePluggables.add(pluggable);
pipePluggableNames.put(name, pluggable);
pipePluggableByNames.put(pluggable, name);
@ -70,7 +70,7 @@ public abstract class PipeManager {
return pipePluggableNames.get(pluggableName);
}
public static String getPluggableName(Class<? extends IPipePluggable> aClass) {
public static String getPluggableName(Class<? extends PipePluggable> aClass) {
return pipePluggableByNames.get(aClass);
}
}

View file

@ -22,21 +22,33 @@ import buildcraft.api.core.ISerializable;
* An IPipePluggable MUST have an empty constructor for client-side
* rendering!
*/
public interface IPipePluggable extends INBTStoreable, ISerializable {
ItemStack[] getDropItems(IPipeContainer pipe);
public abstract class PipePluggable implements INBTStoreable, ISerializable {
public abstract ItemStack[] getDropItems(IPipeContainer pipe);
void onAttachedPipe(IPipeContainer pipe, ForgeDirection direction);
public void update(IPipeContainer pipe, ForgeDirection direction) {
void onDetachedPipe(IPipeContainer pipe, ForgeDirection direction);
}
boolean isBlocking(IPipeContainer pipe, ForgeDirection direction);
public void onAttachedPipe(IPipeContainer pipe, ForgeDirection direction) {
validate(pipe, direction);
}
void invalidate();
public void onDetachedPipe(IPipeContainer pipe, ForgeDirection direction) {
invalidate();
}
void validate(IPipeContainer pipe, ForgeDirection direction);
public abstract boolean isBlocking(IPipeContainer pipe, ForgeDirection direction);
AxisAlignedBB getBoundingBox(ForgeDirection side);
public void invalidate() {
}
public void validate(IPipeContainer pipe, ForgeDirection direction) {
}
public abstract AxisAlignedBB getBoundingBox(ForgeDirection side);
@SideOnly(Side.CLIENT)
IPipePluggableRenderer getRenderer();
public abstract IPipePluggableRenderer getRenderer();
}

View file

@ -52,7 +52,7 @@ import buildcraft.api.events.PipePlacedEvent;
import buildcraft.api.events.RobotPlacementEvent;
import buildcraft.api.gates.GateExpansions;
import buildcraft.api.gates.IGateExpansion;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.PipePluggable;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.tools.IToolWrench;
import buildcraft.api.pipes.PipeWire;
@ -513,7 +513,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
switch (rayTraceResult.hitPart) {
case Pluggable: {
Pipe<?> pipe = getPipe(world, x, y, z);
IPipePluggable pluggable = pipe.container.getPipePluggable(rayTraceResult.sideHit);
PipePluggable pluggable = pipe.container.getPipePluggable(rayTraceResult.sideHit);
if (pluggable instanceof FacadePluggable) {
ForgeDirection dir = ForgeDirection
.getOrientation(target.sideHit);

View file

@ -7,11 +7,11 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.pipes.IPipeContainer;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.IPipePluggableRenderer;
import buildcraft.api.pipes.PipePluggable;
import buildcraft.core.utils.MatrixTranformations;
public class FacadePluggable implements IPipePluggable {
public class FacadePluggable extends PipePluggable {
public ItemFacade.FacadeState[] states;
public FacadePluggable(ItemFacade.FacadeState[] states) {
@ -40,36 +40,11 @@ public class FacadePluggable implements IPipePluggable {
return states == null ? null : new ItemStack[] { ItemFacade.getFacade(states) };
}
@Override
public void update(IPipeContainer pipe, ForgeDirection direction) {
}
@Override
public void onAttachedPipe(IPipeContainer pipe, ForgeDirection direction) {
}
@Override
public void onDetachedPipe(IPipeContainer pipe, ForgeDirection direction) {
}
@Override
public boolean isBlocking(IPipeContainer pipe, ForgeDirection direction) {
return false;
}
@Override
public void invalidate() {
}
@Override
public void validate(IPipeContainer pipe, ForgeDirection direction) {
}
@Override
public AxisAlignedBB getBoundingBox(ForgeDirection side) {
float[][] bounds = new float[3][2];

View file

@ -37,7 +37,6 @@ import buildcraft.api.core.Position;
import buildcraft.api.facades.FacadeType;
import buildcraft.api.facades.IFacadeItem;
import buildcraft.api.recipes.BuildcraftRecipeRegistry;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.IPipeContainer;
import buildcraft.api.pipes.PipeWire;
import buildcraft.core.BlockSpring;

View file

@ -11,7 +11,7 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.PipePluggable;
import buildcraft.core.ItemBuildCraft;
import buildcraft.core.utils.NBTUtils;
import buildcraft.transport.BlockGenericPipe.Part;
@ -56,7 +56,7 @@ public class ItemGateCopier extends ItemBuildCraft {
RaytraceResult rayTraceResult = ((BlockGenericPipe) block).doRayTrace(world, x, y, z, player);
if (rayTraceResult != null && rayTraceResult.boundingBox != null && rayTraceResult.hitPart == Part.Pluggable) {
IPipePluggable pluggable = ((TileGenericPipe) tile).getPipePluggable(rayTraceResult.sideHit);
PipePluggable pluggable = ((TileGenericPipe) tile).getPipePluggable(rayTraceResult.sideHit);
if (pluggable instanceof GatePluggable) {
gate = ((TileGenericPipe) tile).pipe.gates[rayTraceResult.sideHit.ordinal()];
}

View file

@ -20,7 +20,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.IPipeContainer;
import buildcraft.core.ItemBuildCraft;

View file

@ -20,7 +20,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.IPipeContainer;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.ItemBuildCraft;

View file

@ -52,12 +52,14 @@ public class PipeEventBus {
Map<Method, Class<? extends PipeEvent>> methods = new HashMap<Method, Class<? extends PipeEvent>>();
for (Method m: handler.getClass().getDeclaredMethods()) {
Class[] parameters = m.getParameterTypes();
if (parameters.length == 1 && PipeEvent.class.isAssignableFrom(parameters[0])) {
Class<? extends PipeEvent> eventType = (Class<? extends PipeEvent>) parameters[0];
List<EventHandler> eventHandlerList = getHandlerList(eventType);
eventHandlerList.add(new EventHandler(m, handler));
methods.put(m, eventType);
if ("eventHandler".equals(m.getName())) {
Class[] parameters = m.getParameterTypes();
if (parameters.length == 1 && PipeEvent.class.isAssignableFrom(parameters[0])) {
Class<? extends PipeEvent> eventType = (Class<? extends PipeEvent>) parameters[0];
List<EventHandler> eventHandlerList = getHandlerList(eventType);
eventHandlerList.add(new EventHandler(m, handler));
methods.put(m, eventType);
}
}
}

View file

@ -4,23 +4,23 @@ import io.netty.buffer.ByteBuf;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.ISerializable;
import buildcraft.api.pipes.IPipe;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.PipeManager;
import buildcraft.api.pipes.PipePluggable;
import buildcraft.transport.utils.ConnectionMatrix;
public class PipePluggableState implements ISerializable {
private IPipePluggable[] pluggables = new IPipePluggable[6];
private PipePluggable[] pluggables = new PipePluggable[6];
private ConnectionMatrix pluggableMatrix = new ConnectionMatrix();
public PipePluggableState() {
}
public IPipePluggable[] getPluggables() {
public PipePluggable[] getPluggables() {
return pluggables;
}
public void setPluggables(IPipePluggable[] pluggables) {
public void setPluggables(PipePluggable[] pluggables) {
this.pluggables = pluggables;
this.pluggableMatrix.clean();
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
@ -31,7 +31,7 @@ public class PipePluggableState implements ISerializable {
@Override
public void writeData(ByteBuf data) {
this.pluggableMatrix.writeData(data);
for (IPipePluggable p : pluggables) {
for (PipePluggable p : pluggables) {
if (p != null) {
data.writeShort(PipeManager.pipePluggables.indexOf(p.getClass()));
p.writeData(data);
@ -45,7 +45,7 @@ public class PipePluggableState implements ISerializable {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (this.pluggableMatrix.isConnected(dir)) {
try {
IPipePluggable p = PipeManager.pipePluggables.get(data.readUnsignedShort()).newInstance();
PipePluggable p = PipeManager.pipePluggables.get(data.readUnsignedShort()).newInstance();
p.readData(data);
pluggables[dir.ordinal()] = p;
} catch(Exception e) {

View file

@ -10,16 +10,16 @@ import buildcraft.BuildCraftTransport;
import buildcraft.api.core.render.ITextureStates;
import buildcraft.api.pipes.IPipe;
import buildcraft.api.pipes.IPipeContainer;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.IPipePluggableRenderer;
import buildcraft.api.pipes.PipePluggable;
import buildcraft.core.utils.MatrixTranformations;
public class PlugPluggable implements IPipePluggable {
public class PlugPluggable extends PipePluggable {
public class PlugPluggableRenderer implements IPipePluggableRenderer {
private float zFightOffset = 1 / 4096.0F;
@Override
public void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side, IPipePluggable pipePluggable, ITextureStates blockStateMachine, int x, int y, int z) {
public void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side, PipePluggable pipePluggable, ITextureStates blockStateMachine, int x, int y, int z) {
float[][] zeroState = new float[3][2];
// X START - END
@ -78,36 +78,11 @@ public class PlugPluggable implements IPipePluggable {
return new ItemStack[] { new ItemStack(BuildCraftTransport.plugItem) };
}
@Override
public void update(IPipeContainer pipe, ForgeDirection direction) {
}
@Override
public void onAttachedPipe(IPipeContainer pipe, ForgeDirection direction) {
}
@Override
public void onDetachedPipe(IPipeContainer pipe, ForgeDirection direction) {
}
@Override
public boolean isBlocking(IPipeContainer pipe, ForgeDirection direction) {
return true;
}
@Override
public void invalidate() {
}
@Override
public void validate(IPipeContainer pipe, ForgeDirection direction) {
}
@Override
public AxisAlignedBB getBoundingBox(ForgeDirection side) {
float[][] bounds = new float[3][2];

View file

@ -1,6 +1,5 @@
package buildcraft.transport;
import java.awt.*;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.ItemStack;
@ -11,8 +10,8 @@ import buildcraft.BuildCraftTransport;
import buildcraft.api.core.render.ITextureStates;
import buildcraft.api.pipes.IPipe;
import buildcraft.api.pipes.IPipeContainer;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.IPipePluggableRenderer;
import buildcraft.api.pipes.PipePluggable;
import buildcraft.core.robots.DockingStation;
import buildcraft.core.robots.RobotRegistry;
import buildcraft.core.utils.MatrixTranformations;
@ -20,7 +19,7 @@ import buildcraft.core.utils.MatrixTranformations;
/**
* Created by asie on 12/15/14.
*/
public class RobotStationPluggable implements IPipePluggable {
public class RobotStationPluggable extends PipePluggable {
public class RobotStationPluggableRenderer implements IPipePluggableRenderer {
private float zFightOffset = 1 / 4096.0F;
@ -66,7 +65,7 @@ public class RobotStationPluggable implements IPipePluggable {
}
@Override
public void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side, IPipePluggable pipePluggable, ITextureStates blockStateMachine, int x, int y, int z) {
public void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side, PipePluggable pipePluggable, ITextureStates blockStateMachine, int x, int y, int z) {
RobotStationState state = ((RobotStationPluggable) pipePluggable).renderState;
//float width = 0.075F;
@ -165,21 +164,6 @@ public class RobotStationPluggable implements IPipePluggable {
return new ItemStack[] { new ItemStack(BuildCraftTransport.robotStationItem) };
}
@Override
public void update(IPipeContainer pipe, ForgeDirection direction) {
}
@Override
public void onAttachedPipe(IPipeContainer pipe, ForgeDirection direction) {
validate(pipe, direction);
}
@Override
public void onDetachedPipe(IPipeContainer pipe, ForgeDirection direction) {
invalidate();
}
public DockingStation getStation() {
return station;
}

View file

@ -39,9 +39,9 @@ import buildcraft.api.core.Position;
import buildcraft.api.gates.IGateExpansion;
import buildcraft.api.pipes.IPipe;
import buildcraft.api.pipes.IPipeConnection;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.IPipeContainer;
import buildcraft.api.pipes.PipeManager;
import buildcraft.api.pipes.PipePluggable;
import buildcraft.api.pipes.PipeWire;
import buildcraft.core.DefaultProps;
import buildcraft.core.IDropControlInventory;
@ -100,11 +100,11 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
}
public static class SideProperties {
IPipePluggable[] pluggables = new IPipePluggable[ForgeDirection.VALID_DIRECTIONS.length];
PipePluggable[] pluggables = new PipePluggable[ForgeDirection.VALID_DIRECTIONS.length];
public void writeToNBT(NBTTagCompound nbt) {
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
IPipePluggable pluggable = pluggables[i];
PipePluggable pluggable = pluggables[i];
final String key = "pluggable[" + i + "]";
if (pluggable == null) {
nbt.removeTag(key);
@ -141,11 +141,11 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
} else {
pluggableClass = PipeManager.getPluggableByName(pluggableData.getString("pluggableName"));
}
if (!IPipePluggable.class.isAssignableFrom(pluggableClass)) {
if (!PipePluggable.class.isAssignableFrom(pluggableClass)) {
BCLog.logger.warn("Wrong pluggable class: " + pluggableClass);
continue;
}
IPipePluggable pluggable = (IPipePluggable) pluggableClass.newInstance();
PipePluggable pluggable = (PipePluggable) pluggableClass.newInstance();
pluggable.readFromNBT(pluggableData);
pluggables[i] = pluggable;
} catch (Exception e) {
@ -156,7 +156,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
// Migration code
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
IPipePluggable pluggable = null;
PipePluggable pluggable = null;
if (nbt.hasKey("facadeState[" + i + "]")) {
pluggable = new FacadePluggable(FacadeState.readArray(nbt.getTagList("facadeState[" + i + "]", Constants.NBT.TAG_COMPOUND)));
} else {
@ -203,7 +203,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
}
public void rotateLeft() {
IPipePluggable[] newPluggables = new IPipePluggable[ForgeDirection.VALID_DIRECTIONS.length];
PipePluggable[] newPluggables = new PipePluggable[ForgeDirection.VALID_DIRECTIONS.length];
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
newPluggables[dir.getRotation(ForgeDirection.UP).ordinal()] = pluggables[dir.ordinal()];
}
@ -212,7 +212,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
public boolean dropItem(TileGenericPipe pipe, ForgeDirection direction) {
boolean result = false;
IPipePluggable pluggable = pluggables[direction.ordinal()];
PipePluggable pluggable = pluggables[direction.ordinal()];
if (pluggable != null) {
pluggable.onDetachedPipe(pipe, direction);
ItemStack[] stacks = pluggable.getDropItems(pipe);
@ -229,7 +229,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
}
public void invalidate() {
for (IPipePluggable p : pluggables) {
for (PipePluggable p : pluggables) {
if (p != null) {
p.invalidate();
}
@ -238,7 +238,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
public void validate(TileGenericPipe pipe) {
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
IPipePluggable p = pluggables[d.ordinal()];
PipePluggable p = pluggables[d.ordinal()];
if (p != null) {
p.validate(pipe, d);
@ -376,7 +376,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
pipe.updateEntity();
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
IPipePluggable p = getPipePluggable(direction);
PipePluggable p = getPipePluggable(direction);
if (p != null) {
p.update(this, direction);
}
@ -501,7 +501,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
// Facades
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
PipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
if (!(pluggable instanceof FacadePluggable)) {
renderState.facadeMatrix.setFacade(direction, null, 0, true);
continue;
@ -772,7 +772,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
}
protected boolean hasBlockingPluggable(ForgeDirection side) {
IPipePluggable pluggable = getPipePluggable(side);
PipePluggable pluggable = getPipePluggable(side);
return pluggable != null && pluggable.isBlocking(this, side);
}
@ -907,7 +907,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
}
}
public boolean setPluggable(ForgeDirection direction, IPipePluggable pluggable) {
public boolean setPluggable(ForgeDirection direction, PipePluggable pluggable) {
if (worldObj != null && worldObj.isRemote || pluggable == null) {
return false;
}
@ -934,13 +934,13 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
}
public ItemStack getFacade(ForgeDirection direction) {
IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
PipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
return pluggable instanceof FacadePluggable ?
ItemFacade.getFacade(((FacadePluggable) pluggable).states) : null;
}
public DockingStation getStation(ForgeDirection direction) {
IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
PipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
return pluggable instanceof RobotStationPluggable ?
((RobotStationPluggable) pluggable).getStation() : null;
}
@ -1008,7 +1008,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
}
case 2: {
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
final IPipePluggable pluggable = getPipePluggable(ForgeDirection.getOrientation(i));
final PipePluggable pluggable = getPipePluggable(ForgeDirection.getOrientation(i));
if (pluggable != null && pluggable instanceof GatePluggable) {
final GatePluggable gatePluggable = (GatePluggable) pluggable;
Gate gate = pipe.gates[i];
@ -1078,7 +1078,7 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
}
@Override
public IPipePluggable getPipePluggable(ForgeDirection side) {
public PipePluggable getPipePluggable(ForgeDirection side) {
if (side == null || side == ForgeDirection.UNKNOWN) {
return null;
}

View file

@ -12,14 +12,14 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.GateExpansions;
import buildcraft.api.gates.IGateExpansion;
import buildcraft.api.pipes.IPipeContainer;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.IPipePluggableRenderer;
import buildcraft.api.pipes.PipePluggable;
import buildcraft.core.CoreConstants;
import buildcraft.core.utils.MatrixTranformations;
import buildcraft.transport.Gate;
import buildcraft.transport.TileGenericPipe;
public class GatePluggable implements IPipePluggable {
public class GatePluggable extends PipePluggable {
public GateDefinition.GateMaterial material;
public GateDefinition.GateLogic logic;
public IGateExpansion[] expansions;
@ -93,11 +93,6 @@ public class GatePluggable implements IPipePluggable {
return new ItemStack[] { gate };
}
@Override
public void update(IPipeContainer pipe, ForgeDirection direction) {
}
@Override
public void onAttachedPipe(IPipeContainer pipe, ForgeDirection direction) {
TileGenericPipe pipeReal = (TileGenericPipe) pipe;
@ -154,16 +149,6 @@ public class GatePluggable implements IPipePluggable {
return true;
}
@Override
public void invalidate() {
}
@Override
public void validate(IPipeContainer pipe, ForgeDirection direction) {
}
@Override
public AxisAlignedBB getBoundingBox(ForgeDirection side) {
float min = CoreConstants.PIPE_MIN_POS + 0.05F;

View file

@ -1,15 +0,0 @@
package buildcraft.transport.gates;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.render.ITextureStates;
import buildcraft.api.pipes.IPipe;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.IPipePluggableRenderer;
public class GatePluggableRender implements IPipePluggableRenderer {
@Override
public void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side, IPipePluggable pipePluggable, ITextureStates blockStateMachine, int x, int y, int z) {
}
}

View file

@ -33,7 +33,6 @@ import buildcraft.api.gates.GateExpansions;
import buildcraft.api.gates.IGateExpansion;
import buildcraft.api.pipes.IPipePluggableRenderer;
import buildcraft.api.statements.StatementManager;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.IPipeContainer;
import buildcraft.core.ItemBuildCraft;
import buildcraft.core.inventory.InvUtils;

View file

@ -8,6 +8,8 @@
*/
package buildcraft.transport.pipes;
import java.util.ArrayList;
import java.util.List;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
@ -31,6 +33,7 @@ import buildcraft.transport.IDiamondPipe;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportFluids;
import buildcraft.transport.pipes.events.PipeEventFluid;
public class PipeFluidsDiamond extends Pipe<PipeTransportFluids> implements IDiamondPipe {
@ -124,22 +127,13 @@ public class PipeFluidsDiamond extends Pipe<PipeTransportFluids> implements IDia
return true;
}
@Override
public boolean outputOpen(ForgeDirection to) {
if (!super.outputOpen(to)) {
return false;
}
public void eventHandler(PipeEventFluid.FindDest event) {
Fluid fluidInTank = event.fluidStack.getFluid();
List<ForgeDirection> removedDestinations = new ArrayList<ForgeDirection>();
// get center tank, from which outputs are checked; ignore if has no fluid
FluidTankInfo[] tanks = transport.getTankInfo(ForgeDirection.UNKNOWN);
if (tanks == null || tanks[0] == null || tanks[0].fluid == null || tanks[0].fluid.amount == 0) {
return true;
}
Fluid fluidInTank = tanks[0].fluid.getFluid();
boolean[] validFilter = new boolean[6];
boolean isFiltered = false;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
for (ForgeDirection dir : event.destinations) {
if (container.isPipeConnected(dir) && filters.filteredDirections[dir.ordinal()]) {
for (int slot = dir.ordinal() * 9; slot < dir.ordinal() * 9 + 9; ++slot) {
if (filters.fluids[slot] != null && filters.fluids[slot].getID() == fluidInTank.getID()) {
@ -150,18 +144,25 @@ public class PipeFluidsDiamond extends Pipe<PipeTransportFluids> implements IDia
}
}
}
// the direction is filtered and liquids match
if (filters.filteredDirections[to.ordinal()] && validFilter[to.ordinal()]) {
return true;
for (ForgeDirection to : event.destinations) {
// the direction is filtered and liquids match
if (filters.filteredDirections[to.ordinal()] && validFilter[to.ordinal()]) {
continue;
}
// we haven't found a filter for this liquid and the direction is free
if (!isFiltered && !filters.filteredDirections[to.ordinal()]) {
continue;
}
// we have a filter for the liquid, but not a valid direction
removedDestinations.add(to);
}
// we haven't found a filter for this liquid and the direction is free
if (!isFiltered && !filters.filteredDirections[to.ordinal()]) {
return true;
for (ForgeDirection dir : removedDestinations) {
event.destinations.remove(dir);
}
// we have a filter for the liquid, but not a valid direction
return false;
}
/* SAVING & LOADING */

View file

@ -17,8 +17,8 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.render.ITextureStates;
import buildcraft.api.pipes.IPipePluggable;
import buildcraft.api.pipes.IPipePluggableRenderer;
import buildcraft.api.pipes.PipePluggable;
import buildcraft.core.CoreConstants;
import buildcraft.core.utils.ColorUtils;
import buildcraft.transport.PipeIconProvider;
@ -113,7 +113,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
if (renderPass == 0) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (tile.hasPipePluggable(dir)) {
IPipePluggable p = tile.getPipePluggable(dir);
PipePluggable p = tile.getPipePluggable(dir);
IPipePluggableRenderer r = p.getRenderer();
if (r != null) {
r.renderPluggable(renderblocks, tile.getPipe(), dir, p, fakeBlock, x, y, z);