From 08c4bc3f47b99db845ad8da04ce54ddda2f99a92 Mon Sep 17 00:00:00 2001 From: ganymedes01 Date: Sun, 15 Sep 2013 21:40:27 +0100 Subject: [PATCH] Fix for sandstone pipes --- .../transport/IPipeConnectionForced.java | 14 ++++++ .../buildcraft/transport/TileGenericPipe.java | 47 ++++++++++--------- .../transport/pipes/PipeFluidsSandstone.java | 14 ++++-- .../transport/pipes/PipeItemsSandstone.java | 12 +++-- 4 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 common/buildcraft/transport/IPipeConnectionForced.java diff --git a/common/buildcraft/transport/IPipeConnectionForced.java b/common/buildcraft/transport/IPipeConnectionForced.java new file mode 100644 index 00000000..209e5c31 --- /dev/null +++ b/common/buildcraft/transport/IPipeConnectionForced.java @@ -0,0 +1,14 @@ +package buildcraft.transport; + +import net.minecraftforge.common.ForgeDirection; + +public interface IPipeConnectionForced { + + /** + * Allows you to block connection overrides. + * + * @param with + * @return TRUE to block an override. FALSE to allow overrides. + */ + public boolean ignoreConnectionOverrides(ForgeDirection with); +} diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 591102fb..5ae87c2e 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -7,6 +7,24 @@ */ package buildcraft.transport; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.LinkedList; +import java.util.logging.Level; + +import net.minecraft.block.Block; +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; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; @@ -17,6 +35,7 @@ import buildcraft.api.gates.ITrigger; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; +import buildcraft.transport.IPipeConnectionForced; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipeConnection; import buildcraft.api.transport.IPipeTile; @@ -32,23 +51,6 @@ import buildcraft.core.network.PacketTileState; import buildcraft.transport.Gate.GateKind; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.LinkedList; -import java.util.logging.Level; -import net.minecraft.block.Block; -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; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFluidHandler, IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, IDropControlInventory, IPipeRenderState, ISyncedTile, ISolidSideTile { @@ -425,11 +427,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui if (!BlockGenericPipe.isValid(pipe)) return false; - if (with instanceof IPipeConnection) { - IPipeConnection.ConnectOverride override = ((IPipeConnection) with).overridePipeConnection(pipe.transport.getPipeType(), side.getOpposite()); - if (override != IPipeConnection.ConnectOverride.DEFAULT) - return override == IPipeConnection.ConnectOverride.CONNECT ? true : false; - } + if(!(pipe instanceof IPipeConnectionForced) || !((IPipeConnectionForced) pipe).ignoreConnectionOverrides(side)) + if (with instanceof IPipeConnection) { + IPipeConnection.ConnectOverride override = ((IPipeConnection) with).overridePipeConnection(pipe.transport.getPipeType(), side.getOpposite()); + if (override != IPipeConnection.ConnectOverride.DEFAULT) + return override == IPipeConnection.ConnectOverride.CONNECT ? true : false; + } if (with instanceof TileGenericPipe) { if (((TileGenericPipe) with).hasPlug(side.getOpposite())) diff --git a/common/buildcraft/transport/pipes/PipeFluidsSandstone.java b/common/buildcraft/transport/pipes/PipeFluidsSandstone.java index 70b9c63b..1483426c 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsSandstone.java +++ b/common/buildcraft/transport/pipes/PipeFluidsSandstone.java @@ -7,8 +7,12 @@ */ package buildcraft.transport.pipes; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; +import buildcraft.transport.IPipeConnectionForced; import buildcraft.transport.IPipeTransportFluidsHook; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; @@ -16,11 +20,8 @@ import buildcraft.transport.PipeTransportFluids; import buildcraft.transport.TileGenericPipe; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -public class PipeFluidsSandstone extends Pipe implements IPipeTransportFluidsHook { +public class PipeFluidsSandstone extends Pipe implements IPipeTransportFluidsHook, IPipeConnectionForced { public PipeFluidsSandstone(int itemID) { super(new PipeTransportFluids(), itemID); @@ -49,4 +50,9 @@ public class PipeFluidsSandstone extends Pipe implements IP public boolean canPipeConnect(TileEntity tile, ForgeDirection side) { return (tile instanceof TileGenericPipe) && super.canPipeConnect(tile, side); } + + @Override + public boolean ignoreConnectionOverrides(ForgeDirection with) { + return true; + } } diff --git a/common/buildcraft/transport/pipes/PipeItemsSandstone.java b/common/buildcraft/transport/pipes/PipeItemsSandstone.java index fe53d0c8..6e23d15a 100644 --- a/common/buildcraft/transport/pipes/PipeItemsSandstone.java +++ b/common/buildcraft/transport/pipes/PipeItemsSandstone.java @@ -7,18 +7,19 @@ */ package buildcraft.transport.pipes; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; +import buildcraft.transport.IPipeConnectionForced; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TileGenericPipe; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; -public class PipeItemsSandstone extends Pipe { +public class PipeItemsSandstone extends Pipe implements IPipeConnectionForced { public PipeItemsSandstone(int itemID) { super(new PipeTransportItems(), itemID); @@ -39,4 +40,9 @@ public class PipeItemsSandstone extends Pipe { public boolean canPipeConnect(TileEntity tile, ForgeDirection side) { return (tile instanceof TileGenericPipe) && super.canPipeConnect(tile, side); } + + @Override + public boolean ignoreConnectionOverrides(ForgeDirection with) { + return true; + } }