Temporarily removed errors

This commit is contained in:
Calclavia 2014-03-07 18:24:19 +08:00
parent be889b7064
commit 59336384f8
3 changed files with 40 additions and 60 deletions

View file

@ -8,16 +8,14 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
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.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.fluid.IPressurizedNode;
import resonantinduction.core.fluid.TilePressurizedNode; import resonantinduction.core.fluid.TilePressurizedNode;
import resonantinduction.core.grid.fluid.IPressureNodeProvider;
import resonantinduction.core.grid.fluid.PressureNode; import resonantinduction.core.grid.fluid.PressureNode;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.vector.Cuboid; import calclavia.lib.prefab.vector.Cuboid;
@ -39,8 +37,42 @@ public class TileGutter extends TilePressurizedNode
isOpaqueCube = false; isOpaqueCube = false;
normalRender = false; normalRender = false;
node = new ExtendedPressureNode(this) node = new PressureNode(this)
{ {
@Override
public void recache()
{
synchronized (connections)
{
connections.clear();
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = position().translate(dir).getTileEntity(world());
if (tile instanceof IFluidHandler)
{
if (tile instanceof IPressureNodeProvider)
{
PressureNode check = ((IPressureNodeProvider) tile).getNode(dir.getOpposite());
if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this))
{
renderSides = WorldUtility.setEnableSide(renderSides, dir, true);
connections.put(check, dir);
}
}
else
{
renderSides = WorldUtility.setEnableSide(renderSides, dir, true);
connections.put(tile, dir);
}
}
}
}
}
@Override @Override
public int getPressure(ForgeDirection dir) public int getPressure(ForgeDirection dir)
{ {
@ -100,7 +132,7 @@ public class TileGutter extends TilePressurizedNode
{ {
if (getInternalTank().getFluidAmount() > 0) if (getInternalTank().getFluidAmount() > 0)
{ {
int pressure = getPressure(null); int pressure = node.pressure;
for (int i = 2; i < 6; i++) for (int i = 2; i < 6; i++)
{ {
@ -111,7 +143,7 @@ public class TileGutter extends TilePressurizedNode
if (checkTile instanceof TileGutter) if (checkTile instanceof TileGutter)
{ {
int deltaPressure = pressure - ((TileGutter) checkTile).getPressure(null); int deltaPressure = pressure - ((TileGutter) checkTile).node.getPressure(dir.getOpposite());
entity.motionX += 0.01 * dir.offsetX * deltaPressure; entity.motionX += 0.01 * dir.offsetX * deltaPressure;
entity.motionY += 0.01 * dir.offsetY * deltaPressure; entity.motionY += 0.01 * dir.offsetY * deltaPressure;
@ -172,19 +204,6 @@ public class TileGutter extends TilePressurizedNode
} }
} }
@Override
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
{
if (!this.worldObj.isRemote)
{
if (tileEntity instanceof IFluidHandler)
{
renderSides = WorldUtility.setEnableSide(renderSides, side, true);
node.getConnections().connectedBlocks[side.ordinal()] = tileEntity;
}
}
}
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{ {

View file

@ -21,37 +21,6 @@ public abstract class TilePressurizedNode extends TileFluidNode implements IPres
{ {
protected PressureNode node; protected PressureNode node;
static class ExtendedPressureNode extends PressureNode
{
public ExtendedPressureNode(IPressureNodeProvider parent)
{
super(parent);
}
@Override
public void recache()
{
if (!world().isRemote)
{
byte previousConnections = renderSides;
connectedBlocks = new Object[6];
renderSides = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
validateConnectionSide(new Vector3(this).translate(dir).getTileEntity(worldObj), dir);
}
/** Only send packet updates if visuallyConnected changed. */
if (previousConnections != renderSides)
{
sendRenderUpdate();
}
}
}
};
public TilePressurizedNode(Material material) public TilePressurizedNode(Material material)
{ {
super(material); super(material);
@ -100,14 +69,6 @@ public abstract class TilePressurizedNode extends TileFluidNode implements IPres
return new FluidTankInfo[] { getInternalTank().getInfo() }; return new FluidTankInfo[] { getInternalTank().getInfo() };
} }
/**
* Checks to make sure the connection is valid to the tileEntity
*
* @param tileEntity - the tileEntity being checked
* @param side - side the connection is too
*/
public abstract void validateConnectionSide(TileEntity tileEntity, ForgeDirection side);
public int getSubID() public int getSubID()
{ {
return this.colorID; return this.colorID;

View file

@ -21,7 +21,7 @@ import codechicken.multipart.TMultiPart;
public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Object> public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Object>
{ {
protected byte connectionMap = Byte.parseByte("111111", 2); protected byte connectionMap = Byte.parseByte("111111", 2);
protected int pressure = 0; public int pressure = 0;
public PressureNode(IPressureNodeProvider parent) public PressureNode(IPressureNodeProvider parent)
{ {
@ -174,7 +174,7 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
return 10; return 10;
} }
protected int getPressure(ForgeDirection dir) public int getPressure(ForgeDirection dir)
{ {
return pressure; return pressure;
} }