Fixed gutter rendering extra beams

This commit is contained in:
Calclavia 2014-03-11 20:14:39 +08:00
parent 1e0492eb53
commit 57f362dff2
9 changed files with 80 additions and 56 deletions

View file

@ -14,11 +14,10 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import resonantinduction.archaic.fluid.gutter.FluidGravityNode;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.fluid.TilePressureNode; import resonantinduction.core.fluid.TilePressureNode;
import resonantinduction.core.grid.fluid.PressureNode;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.tile.IRotatable; import calclavia.lib.prefab.tile.IRotatable;
import calclavia.lib.utility.FluidUtility; import calclavia.lib.utility.FluidUtility;
@ -38,7 +37,7 @@ public class TileGrate extends TilePressureNode implements IRotatable
isOpaqueCube = false; isOpaqueCube = false;
normalRender = true; normalRender = true;
rotationMask = Byte.parseByte("111111", 2); rotationMask = Byte.parseByte("111111", 2);
node = new PressureNode(this); node = new FluidGravityNode(this);
} }
@Override @Override
@ -100,7 +99,8 @@ public class TileGrate extends TilePressureNode implements IRotatable
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{ {
getPressureTank().fill(resource, doFill); int filled = getPressureTank().fill(resource, doFill);
System.out.println("FILL");
if (getPressureTank().getFluidAmount() > 0) if (getPressureTank().getFluidAmount() > 0)
{ {

View file

@ -0,0 +1,35 @@
package resonantinduction.archaic.fluid.gutter;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.archaic.fluid.grate.TileGrate;
import resonantinduction.core.grid.fluid.IPressureNodeProvider;
import resonantinduction.core.grid.fluid.FluidPressureNode;
import calclavia.lib.utility.WorldUtility;
public class FluidGravityNode extends FluidPressureNode
{
public FluidGravityNode(IPressureNodeProvider parent)
{
super(parent);
}
@Override
public int getPressure(ForgeDirection dir)
{
if (dir == ForgeDirection.UP)
return -1;
if (dir == ForgeDirection.DOWN)
return 1;
return 0;
}
@Override
public int getMaxFlowRate()
{
return 20;
}
}

View file

@ -28,7 +28,7 @@ import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.fluid.TilePressureNode; import resonantinduction.core.fluid.TilePressureNode;
import resonantinduction.core.grid.fluid.IPressureNodeProvider; import resonantinduction.core.grid.fluid.IPressureNodeProvider;
import resonantinduction.core.grid.fluid.PressureNode; import resonantinduction.core.grid.fluid.FluidPressureNode;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.content.module.TileRender; import calclavia.lib.content.module.TileRender;
import calclavia.lib.prefab.vector.Cuboid; import calclavia.lib.prefab.vector.Cuboid;
@ -55,7 +55,7 @@ public class TileGutter extends TilePressureNode
normalRender = false; normalRender = false;
bounds = new Cuboid(0, 0, 0, 1, 0.99, 1); bounds = new Cuboid(0, 0, 0, 1, 0.99, 1);
node = new PressureNode(this) node = new FluidGravityNode(this)
{ {
@Override @Override
public void recache() public void recache()
@ -74,7 +74,7 @@ public class TileGutter extends TilePressureNode
{ {
if (tile instanceof IPressureNodeProvider) if (tile instanceof IPressureNodeProvider)
{ {
PressureNode check = ((IPressureNodeProvider) tile).getNode(PressureNode.class, dir.getOpposite()); FluidPressureNode check = ((IPressureNodeProvider) tile).getNode(FluidPressureNode.class, dir.getOpposite());
if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this)) if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this))
{ {
@ -102,24 +102,6 @@ public class TileGutter extends TilePressureNode
} }
} }
} }
@Override
public int getPressure(ForgeDirection dir)
{
if (dir == ForgeDirection.UP)
return -1;
if (dir == ForgeDirection.DOWN)
return 2;
return 0;
}
@Override
public int getMaxFlowRate()
{
return 20;
}
}; };
} }
@ -184,6 +166,10 @@ public class TileGutter extends TilePressureNode
{ {
entity.setFire(5); entity.setFire(5);
} }
else
{
entity.extinguish();
}
} }
if (entity instanceof EntityItem) if (entity instanceof EntityItem)
@ -208,9 +194,9 @@ public class TileGutter extends TilePressureNode
{ {
for (Object check : node.getGrid().getNodes()) for (Object check : node.getGrid().getNodes())
{ {
if (check instanceof PressureNode) if (check instanceof FluidPressureNode)
{ {
tanks.add(((PressureNode) check).parent.getPressureTank()); tanks.add(((FluidPressureNode) check).parent.getPressureTank());
} }
} }
} }
@ -220,9 +206,9 @@ public class TileGutter extends TilePressureNode
{ {
for (Object check : node.getGrid().getNodes()) for (Object check : node.getGrid().getNodes())
{ {
if (check instanceof PressureNode) if (check instanceof FluidPressureNode)
{ {
((PressureNode) check).parent.onFluidChanged(); ((FluidPressureNode) check).parent.onFluidChanged();
} }
} }
} }
@ -346,7 +332,7 @@ public class TileGutter extends TilePressureNode
public void render(int meta, byte sides) public void render(int meta, byte sides)
{ {
RenderUtility.bind(TEXTURE); RenderUtility.bind(TEXTURE);
// RenderUtility.bind(TextureMap.locationBlocksTexture);
double thickness = 0.055; double thickness = 0.055;
double height = 0.5; double height = 0.5;
@ -371,10 +357,13 @@ public class TileGutter extends TilePressureNode
MODEL.renderOnly("left"); MODEL.renderOnly("left");
} }
if (!WorldUtility.isEnabledSide(sides, dir) || !WorldUtility.isEnabledSide(sides, dir.getRotation(ForgeDirection.UP)))
{
/** /**
* Render strips * Render strips
*/ */
MODEL.renderOnly("backCornerL"); MODEL.renderOnly("backCornerL");
}
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
} }

View file

@ -14,7 +14,7 @@ import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.grid.INodeProvider; import resonantinduction.core.grid.INodeProvider;
import resonantinduction.core.grid.fluid.IPressureNodeProvider; import resonantinduction.core.grid.fluid.IPressureNodeProvider;
import resonantinduction.core.grid.fluid.PressureNode; import resonantinduction.core.grid.fluid.FluidPressureNode;
import resonantinduction.core.prefab.part.PartFace; import resonantinduction.core.prefab.part.PartFace;
import resonantinduction.electrical.Electrical; import resonantinduction.electrical.Electrical;
import resonantinduction.mechanical.energy.grid.MechanicalNode; import resonantinduction.mechanical.energy.grid.MechanicalNode;
@ -308,7 +308,7 @@ public class PartMultimeter extends PartFace implements IConnector<MultimeterNet
if (tileEntity instanceof IPressureNodeProvider) if (tileEntity instanceof IPressureNodeProvider)
{ {
getNetwork().pressureGraph.queue(((IPressureNodeProvider) tileEntity).getNode(PressureNode.class, receivingSide).getPressure(receivingSide)); getNetwork().pressureGraph.queue(((IPressureNodeProvider) tileEntity).getNode(FluidPressureNode.class, receivingSide).getPressure(receivingSide));
} }
if (tileEntity instanceof ITemperature) if (tileEntity instanceof ITemperature)

View file

@ -13,7 +13,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.grid.fluid.IPressureNodeProvider; import resonantinduction.core.grid.fluid.IPressureNodeProvider;
import resonantinduction.core.grid.fluid.PressureNode; import resonantinduction.core.grid.fluid.FluidPressureNode;
import resonantinduction.core.prefab.part.PartFramedNode; import resonantinduction.core.prefab.part.PartFramedNode;
import resonantinduction.mechanical.Mechanical; import resonantinduction.mechanical.Mechanical;
import calclavia.lib.utility.WorldUtility; import calclavia.lib.utility.WorldUtility;
@ -28,7 +28,7 @@ import codechicken.multipart.TSlottedPart;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPressureNodeProvider> implements IPressureNodeProvider, TSlottedPart, JNormalOcclusion, IHollowConnect public class PartPipe extends PartFramedNode<EnumPipeMaterial, FluidPressureNode, IPressureNodeProvider> implements IPressureNodeProvider, TSlottedPart, JNormalOcclusion, IHollowConnect
{ {
protected FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME); protected FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
private boolean markPacket = true; private boolean markPacket = true;
@ -39,7 +39,7 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
material = EnumPipeMaterial.values()[typeID]; material = EnumPipeMaterial.values()[typeID];
requiresInsulation = false; requiresInsulation = false;
node = new PressureNode(this) node = new FluidPressureNode(this)
{ {
@Override @Override
public void recache() public void recache()
@ -61,7 +61,7 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
{ {
if (tile instanceof IPressureNodeProvider) if (tile instanceof IPressureNodeProvider)
{ {
PressureNode check = ((IPressureNodeProvider) tile).getNode(PressureNode.class, dir.getOpposite()); FluidPressureNode check = ((IPressureNodeProvider) tile).getNode(FluidPressureNode.class, dir.getOpposite());
if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this)) if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this))
{ {
@ -90,9 +90,9 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
@Override @Override
public boolean canConnect(ForgeDirection from, Object source) public boolean canConnect(ForgeDirection from, Object source)
{ {
if (source instanceof PressureNode) if (source instanceof FluidPressureNode)
{ {
PressureNode otherNode = (PressureNode) source; FluidPressureNode otherNode = (FluidPressureNode) source;
if (otherNode.parent instanceof PartPipe) if (otherNode.parent instanceof PartPipe)
{ {

View file

@ -9,18 +9,18 @@ import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.core.grid.Node; import resonantinduction.core.grid.Node;
import resonantinduction.core.grid.fluid.IPressureNodeProvider; import resonantinduction.core.grid.fluid.IPressureNodeProvider;
import resonantinduction.core.grid.fluid.PressureNode; import resonantinduction.core.grid.fluid.FluidPressureNode;
import resonantinduction.mechanical.energy.grid.TileMechanical; import resonantinduction.mechanical.energy.grid.TileMechanical;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.tile.IRotatable; import calclavia.lib.prefab.tile.IRotatable;
public class TilePump extends TileMechanical implements IPressureNodeProvider, IRotatable public class TilePump extends TileMechanical implements IPressureNodeProvider, IRotatable
{ {
private final PressureNode pressureNode; private final FluidPressureNode pressureNode;
public TilePump() public TilePump()
{ {
pressureNode = new PressureNode(this) pressureNode = new FluidPressureNode(this)
{ {
@Override @Override
public int getPressure(ForgeDirection dir) public int getPressure(ForgeDirection dir)

View file

@ -9,7 +9,7 @@ import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.grid.fluid.PressureNode; import resonantinduction.core.grid.fluid.FluidPressureNode;
import calclavia.lib.render.RenderUtility; import calclavia.lib.render.RenderUtility;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -8,7 +8,7 @@ import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import resonantinduction.core.grid.Node; import resonantinduction.core.grid.Node;
import resonantinduction.core.grid.fluid.IPressureNodeProvider; import resonantinduction.core.grid.fluid.IPressureNodeProvider;
import resonantinduction.core.grid.fluid.PressureNode; import resonantinduction.core.grid.fluid.FluidPressureNode;
import calclavia.lib.network.IPacketReceiverWithID; import calclavia.lib.network.IPacketReceiverWithID;
/** /**
@ -18,7 +18,7 @@ import calclavia.lib.network.IPacketReceiverWithID;
*/ */
public abstract class TilePressureNode extends TileFluidNode implements IPressureNodeProvider, IPacketReceiverWithID public abstract class TilePressureNode extends TileFluidNode implements IPressureNodeProvider, IPacketReceiverWithID
{ {
protected PressureNode node; protected FluidPressureNode node;
public TilePressureNode(Material material) public TilePressureNode(Material material)
{ {

View file

@ -15,19 +15,19 @@ import resonantinduction.core.grid.TickingGrid;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import codechicken.multipart.TMultiPart; import codechicken.multipart.TMultiPart;
public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Object> public class FluidPressureNode extends Node<IPressureNodeProvider, TickingGrid, Object>
{ {
protected byte connectionMap = Byte.parseByte("111111", 2); protected byte connectionMap = Byte.parseByte("111111", 2);
private int pressure = 0; private int pressure = 0;
public int maxFlowRate = 10; public int maxFlowRate = 10;
public int maxPressure = 10; public int maxPressure = 10;
public PressureNode(IPressureNodeProvider parent) public FluidPressureNode(IPressureNodeProvider parent)
{ {
super(parent); super(parent);
} }
public PressureNode setConnection(byte connectionMap) public FluidPressureNode setConnection(byte connectionMap)
{ {
this.connectionMap = connectionMap; this.connectionMap = connectionMap;
return this; return this;
@ -57,9 +57,9 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
Entry<Object, ForgeDirection> entry = it.next(); Entry<Object, ForgeDirection> entry = it.next();
Object obj = entry.getKey(); Object obj = entry.getKey();
if (obj instanceof PressureNode) if (obj instanceof FluidPressureNode)
{ {
int pressure = ((PressureNode) obj).getPressure(entry.getValue().getOpposite()); int pressure = ((FluidPressureNode) obj).getPressure(entry.getValue().getOpposite());
minPressure = Math.min(pressure, minPressure); minPressure = Math.min(pressure, minPressure);
maxPressure = Math.max(pressure, maxPressure); maxPressure = Math.max(pressure, maxPressure);
@ -98,9 +98,9 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
Object obj = entry.getKey(); Object obj = entry.getKey();
ForgeDirection dir = entry.getValue(); ForgeDirection dir = entry.getValue();
if (obj instanceof PressureNode) if (obj instanceof FluidPressureNode)
{ {
PressureNode otherPipe = (PressureNode) obj; FluidPressureNode otherPipe = (FluidPressureNode) obj;
/** /**
* Move fluid from higher pressure to lower. In this case, move from tankA to * Move fluid from higher pressure to lower. In this case, move from tankA to
@ -149,7 +149,7 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
{ {
IFluidHandler fluidHandler = (IFluidHandler) obj; IFluidHandler fluidHandler = (IFluidHandler) obj;
int pressure = getPressure(dir); int pressure = getPressure(dir);
int tankPressure = fluidHandler instanceof IPressureNodeProvider ? ((IPressureNodeProvider) fluidHandler).getNode(PressureNode.class, dir.getOpposite()).getPressure(dir.getOpposite()) : 0; int tankPressure = fluidHandler instanceof IPressureNodeProvider ? ((IPressureNodeProvider) fluidHandler).getNode(FluidPressureNode.class, dir.getOpposite()).getPressure(dir.getOpposite()) : 0;
FluidTank sourceTank = parent.getPressureTank(); FluidTank sourceTank = parent.getPressureTank();
int transferAmount = (Math.max(pressure, tankPressure) - Math.min(pressure, tankPressure)) * getMaxFlowRate(); int transferAmount = (Math.max(pressure, tankPressure) - Math.min(pressure, tankPressure)) * getMaxFlowRate();
@ -212,7 +212,7 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
if (tile instanceof IPressureNodeProvider) if (tile instanceof IPressureNodeProvider)
{ {
PressureNode check = ((IPressureNodeProvider) tile).getNode(PressureNode.class, dir.getOpposite()); FluidPressureNode check = ((IPressureNodeProvider) tile).getNode(FluidPressureNode.class, dir.getOpposite());
if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this)) if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this))
{ {
@ -236,13 +236,13 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
@Override @Override
public boolean canConnect(ForgeDirection from, Object source) public boolean canConnect(ForgeDirection from, Object source)
{ {
return (source instanceof PressureNode) && (connectionMap & (1 << from.ordinal())) != 0; return (source instanceof FluidPressureNode) && (connectionMap & (1 << from.ordinal())) != 0;
} }
@Override @Override
public TickingGrid newGrid() public TickingGrid newGrid()
{ {
return new TickingGrid<PressureNode>(this, PressureNode.class); return new TickingGrid<FluidPressureNode>(this, FluidPressureNode.class);
} }
@Override @Override