Merge branch 'PipeConnectionRefactor'
Conflicts: common/buildcraft/transport/TileGenericPipe.java
This commit is contained in:
commit
df09099ca6
16 changed files with 79 additions and 92 deletions
|
@ -102,7 +102,6 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
|
|||
public class BuildCraftTransport {
|
||||
public static BlockGenericPipe genericPipeBlock;
|
||||
|
||||
public static boolean alwaysConnectPipes;
|
||||
public static boolean usePipeLoss;
|
||||
public static int maxItemsInPipes;
|
||||
public static float pipeDurability;
|
||||
|
@ -222,11 +221,6 @@ public class BuildCraftTransport {
|
|||
@PreInit
|
||||
public void preInitialize(FMLPreInitializationEvent evt) {
|
||||
try {
|
||||
Property alwaysConnect = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pipes.alwaysConnect",
|
||||
DefaultProps.PIPES_ALWAYS_CONNECT);
|
||||
alwaysConnect.comment = "set to false to deactivate pipe connection rules, true by default";
|
||||
alwaysConnectPipes = alwaysConnect.getBoolean(DefaultProps.PIPES_ALWAYS_CONNECT);
|
||||
|
||||
Property pipeLoss = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "power.usePipeLoss", DefaultProps.USE_PIPELOSS);
|
||||
pipeLoss.comment = "Set to false to turn off energy loss over distance on all power pipes";
|
||||
usePipeLoss = pipeLoss.getBoolean(DefaultProps.USE_PIPELOSS);
|
||||
|
|
|
@ -111,7 +111,6 @@ public class DefaultProps {
|
|||
public static int SPRING_ID = 1522;
|
||||
|
||||
public static boolean CURRENT_CONTINUOUS = false;
|
||||
public static boolean PIPES_ALWAYS_CONNECT = false;
|
||||
public static double PIPES_DURABILITY = 0.25D;
|
||||
public static boolean FILLER_DESTROY = false;
|
||||
public static boolean USE_PIPELOSS = true;
|
||||
|
|
|
@ -14,9 +14,6 @@ import java.util.LinkedList;
|
|||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multiset;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
@ -43,6 +40,10 @@ import buildcraft.core.utils.Utils;
|
|||
import buildcraft.transport.Gate.GateConditional;
|
||||
import buildcraft.transport.pipes.PipeLogic;
|
||||
import buildcraft.transport.triggers.ActionSignalOutput;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multiset;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -136,8 +137,8 @@ public abstract class Pipe implements IPipe, IDropControlInventory {
|
|||
updateSignalState();
|
||||
}
|
||||
|
||||
public boolean isPipeConnected(TileEntity tile, ForgeDirection side) {
|
||||
return logic.isPipeConnected(tile) && transport.isPipeConnected(tile, side);
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
return logic.canPipeConnect(tile, side) && transport.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,7 @@ public abstract class PipeTransport {
|
|||
this.container = tile;
|
||||
}
|
||||
|
||||
public boolean isPipeConnected(TileEntity tile, ForgeDirection side) {
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -85,10 +85,6 @@ public abstract class PipeTransport {
|
|||
|
||||
}
|
||||
|
||||
public boolean allowsConnect(PipeTransport with) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void sendDescriptionPacket() {
|
||||
|
||||
}
|
||||
|
|
|
@ -496,9 +496,15 @@ public class PipeTransportItems extends PipeTransport {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isPipeConnected(TileEntity tile, ForgeDirection side) {
|
||||
return tile instanceof TileGenericPipe || tile instanceof IPipeEntry || tile instanceof ISpecialInventory
|
||||
|| (tile instanceof IInventory && ((IInventory) tile).getSizeInventory() > 0) || (tile instanceof IMachine && ((IMachine) tile).manageSolids());
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
Pipe pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportItems))
|
||||
return false;
|
||||
}
|
||||
|
||||
return tile instanceof TileGenericPipe || tile instanceof IPipeEntry || tile instanceof ISpecialInventory || (tile instanceof IInventory && ((IInventory) tile).getSizeInventory() > 0)
|
||||
|| (tile instanceof IMachine && ((IMachine) tile).manageSolids());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -613,9 +619,4 @@ public class PipeTransportItems extends PipeTransport {
|
|||
|
||||
travelingEntities.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsConnect(PipeTransport with) {
|
||||
return with instanceof PipeTransportItems;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
|
|||
return all;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidTank readFromNBT(NBTTagCompound compoundTag) {
|
||||
this.setCapacity(compoundTag.getInteger("capacity"));
|
||||
|
||||
|
@ -109,6 +110,7 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound subTag) {
|
||||
subTag.setInteger("capacity", this.getCapacity());
|
||||
|
||||
|
@ -488,7 +490,13 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isPipeConnected(TileEntity tile, ForgeDirection side) {
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
Pipe pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportLiquids))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tile instanceof ITankContainer) {
|
||||
ITankContainer liq = (ITankContainer) tile;
|
||||
|
||||
|
@ -503,11 +511,6 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsConnect(PipeTransport with) {
|
||||
return with instanceof PipeTransportLiquids;
|
||||
}
|
||||
|
||||
/** ITankContainer implementation **/
|
||||
|
||||
@Override
|
||||
|
|
|
@ -58,7 +58,13 @@ public class PipeTransportPower extends PipeTransport {
|
|||
SafeTimeTracker tracker = new SafeTimeTracker();
|
||||
|
||||
@Override
|
||||
public boolean isPipeConnected(TileEntity tile, ForgeDirection side) {
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
Pipe pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportPower))
|
||||
return false;
|
||||
}
|
||||
|
||||
return tile instanceof TileGenericPipe || tile instanceof IMachine || tile instanceof IPowerReceptor;
|
||||
}
|
||||
|
||||
|
@ -293,11 +299,6 @@ public class PipeTransportPower extends PipeTransport {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsConnect(PipeTransport with) {
|
||||
return with instanceof PipeTransportPower;
|
||||
}
|
||||
|
||||
/**
|
||||
* Client-side handler for receiving power updates from the server;
|
||||
*
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
package buildcraft.transport;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipeTransportStructure extends PipeTransport {
|
||||
|
||||
@Override
|
||||
public boolean allowsConnect(PipeTransport with) {
|
||||
return with instanceof PipeTransportStructure;
|
||||
}
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
Pipe pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportStructure))
|
||||
return false;
|
||||
}
|
||||
|
||||
return tile instanceof TileGenericPipe;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -453,25 +453,30 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean isPipeConnected(TileEntity with, ForgeDirection side) {
|
||||
/**
|
||||
* Checks if this tile is connected to another tile
|
||||
* @param with - The other Tile
|
||||
* @param side - The orientation to get to the other tile ('with')
|
||||
* @return true if pipes are considered connected
|
||||
*/
|
||||
|
||||
private boolean arePipesConnected(TileEntity with, ForgeDirection side) {
|
||||
Pipe pipe1 = pipe;
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (with instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) with).pipe;
|
||||
}
|
||||
|
||||
if (!BlockGenericPipe.isValid(pipe1))
|
||||
return false;
|
||||
|
||||
if (BlockGenericPipe.isValid(pipe2) && !pipe1.transport.getClass().isAssignableFrom(pipe2.transport.getClass())
|
||||
&& !pipe1.transport.allowsConnect(pipe2.transport))
|
||||
return false;
|
||||
if (with instanceof TileGenericPipe) {
|
||||
Pipe pipe2 = ((TileGenericPipe) with).pipe;
|
||||
|
||||
if (pipe2 != null && !(pipe2.isPipeConnected(this, side)))
|
||||
return false;
|
||||
if (!BlockGenericPipe.isValid(pipe2))
|
||||
return false;
|
||||
|
||||
return pipe1 != null ? pipe1.isPipeConnected(with, side.getOpposite()) : false;
|
||||
if (!pipe2.canPipeConnect(this, side.getOpposite()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return pipe1 != null ? pipe1.canPipeConnect(with, side) : false;
|
||||
}
|
||||
|
||||
private void computeConnections() {
|
||||
|
@ -483,12 +488,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
t.refresh();
|
||||
|
||||
if (t.getTile() != null) {
|
||||
pipeConnectionsBuffer[i] = isPipeConnected(t.getTile(), ForgeDirection.VALID_DIRECTIONS[i].getOpposite());
|
||||
|
||||
if (t.getTile() instanceof TileGenericPipe) {
|
||||
TileGenericPipe pipe = (TileGenericPipe) t.getTile();
|
||||
pipe.pipeConnectionsBuffer[ForgeDirection.VALID_DIRECTIONS[i].getOpposite().ordinal()] = pipeConnectionsBuffer[i];
|
||||
}
|
||||
pipeConnectionsBuffer[i] = arePipesConnected(t.getTile(), ForgeDirection.VALID_DIRECTIONS[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class PipeLogic implements IDropControlInventory {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean isPipeConnected(TileEntity tile) {
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,24 +10,21 @@
|
|||
package buildcraft.transport.pipes;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
|
||||
public class PipeLogicCobblestone extends PipeLogic {
|
||||
|
||||
@Override
|
||||
public boolean isPipeConnected(TileEntity tile) {
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
|
||||
if (BuildCraftTransport.alwaysConnectPipes)
|
||||
return super.isPipeConnected(tile);
|
||||
else
|
||||
return (pipe2 == null || !(pipe2.logic instanceof PipeLogicStone)) && super.isPipeConnected(tile);
|
||||
return (pipe2 == null || !(pipe2.logic instanceof PipeLogicStone)) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,25 +10,21 @@
|
|||
package buildcraft.transport.pipes;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
|
||||
public class PipeLogicObsidian extends PipeLogic {
|
||||
|
||||
@Override
|
||||
public boolean isPipeConnected(TileEntity tile) {
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
|
||||
if (BuildCraftTransport.alwaysConnectPipes)
|
||||
return super.isPipeConnected(tile);
|
||||
else
|
||||
return (pipe2 == null || (!(pipe2.logic instanceof PipeLogicObsidian) && !(pipe2.logic instanceof PipeLogicStripes)))
|
||||
&& super.isPipeConnected(tile);
|
||||
return (pipe2 == null || (!(pipe2.logic instanceof PipeLogicObsidian) && !(pipe2.logic instanceof PipeLogicStripes))) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,11 +10,12 @@
|
|||
package buildcraft.transport.pipes;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
|
||||
public class PipeLogicSandstone extends PipeLogic {
|
||||
@Override
|
||||
public boolean isPipeConnected(TileEntity tile) {
|
||||
return (tile instanceof TileGenericPipe);
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
return (tile instanceof TileGenericPipe) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,24 +10,21 @@
|
|||
package buildcraft.transport.pipes;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
|
||||
public class PipeLogicStone extends PipeLogic {
|
||||
|
||||
@Override
|
||||
public boolean isPipeConnected(TileEntity tile) {
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
|
||||
if (BuildCraftTransport.alwaysConnectPipes)
|
||||
return super.isPipeConnected(tile);
|
||||
else
|
||||
return (pipe2 == null || !(pipe2.logic instanceof PipeLogicCobblestone)) && super.isPipeConnected(tile);
|
||||
return (pipe2 == null || !(pipe2.logic instanceof PipeLogicCobblestone)) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,24 +10,21 @@
|
|||
package buildcraft.transport.pipes;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
|
||||
public class PipeLogicStripes extends PipeLogic {
|
||||
|
||||
@Override
|
||||
public boolean isPipeConnected(TileEntity tile) {
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
|
||||
if (BuildCraftTransport.alwaysConnectPipes)
|
||||
return super.isPipeConnected(tile);
|
||||
else
|
||||
return (pipe2 == null || !(pipe2.logic instanceof PipeLogicStripes) && !(pipe2.logic instanceof PipeLogicObsidian)) && super.isPipeConnected(tile);
|
||||
return (pipe2 == null || !(pipe2.logic instanceof PipeLogicStripes) && !(pipe2.logic instanceof PipeLogicObsidian)) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.api.transport.PipeManager;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
|
@ -67,17 +66,14 @@ public class PipeLogicWood extends PipeLogic {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isPipeConnected(TileEntity tile) {
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
|
||||
if (BuildCraftTransport.alwaysConnectPipes)
|
||||
return super.isPipeConnected(tile);
|
||||
else
|
||||
return (pipe2 == null || !(pipe2.logic instanceof PipeLogicWood)) && super.isPipeConnected(tile);
|
||||
return (pipe2 == null || !(pipe2.logic instanceof PipeLogicWood)) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue