Some fixes for gutter

This commit is contained in:
Calclavia 2014-02-28 23:38:46 +08:00
parent dad66a5f62
commit 6dcdd50437
5 changed files with 33 additions and 9 deletions

View file

@ -38,7 +38,7 @@ public class BlockGutter extends BlockFluidNetwork
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity)
{
float thickness = 0.1F;
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileGutter)
@ -112,7 +112,7 @@ public class BlockGutter extends BlockFluidNetwork
if (checkTile instanceof TileGutter)
{
int deltaPressure = ((TileGutter) checkTile).getPressure(null) - pressure;
int deltaPressure =pressure- ((TileGutter) checkTile).getPressure(null) ;
entity.motionX += 0.01 * dir.offsetX * deltaPressure;
entity.motionY += 0.01 * dir.offsetY * deltaPressure;

View file

@ -21,6 +21,17 @@ public class TileGutter extends TileFluidNetwork implements IFluidPipe
getInternalTank().setCapacity(FluidContainerRegistry.BUCKET_VOLUME);
}
@Override
public void updateEntity()
{
super.updateEntity();
//TODO: Packet before doing.
if (!this.worldObj.isRemote)
sendTankUpdate();
}
@Override
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
{

View file

@ -33,6 +33,7 @@ public abstract class BlockFluidNetwork extends BlockTile
if (tile instanceof TileFluidNetwork)
{
((TileFluidNetwork) tile).refresh();
((TileFluidNetwork) tile).getNetwork().reconstruct();
}
}

View file

@ -1,5 +1,7 @@
package resonantinduction.core.prefab.fluid;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
@ -8,6 +10,8 @@ import resonantinduction.api.mechanical.fluid.IFluidConnector;
import resonantinduction.api.mechanical.fluid.IFluidNetwork;
import resonantinduction.api.mechanical.fluid.IFluidPipe;
import resonantinduction.api.mechanical.fluid.IPressure;
import resonantinduction.archaic.fluid.gutter.TileGutter;
import universalelectricity.core.net.NetworkTickHandler;
/**
* The network for pipe fluid transfer. getNodes() is NOT used.
@ -89,9 +93,11 @@ public class PipeNetwork extends FluidNetwork
*/
public void distribute(IFluidPipe sourcePipe)
{
for (int i = 0; i < 6; i++)
Object[] connections = sourcePipe.getConnections();
for (int i = 0; i < connections.length; i++)
{
Object obj = sourcePipe.getConnections()[i];
Object obj = connections[i];
if (obj instanceof IFluidPipe)
{
@ -159,7 +165,11 @@ public class PipeNetwork extends FluidNetwork
if (transferAmount > 0)
{
FluidStack drainStack = fluidHandler.drain(dir.getOpposite(), transferAmount, false);
fluidHandler.drain(dir.getOpposite(), sourcePipe.fill(dir.getOpposite(), drainStack, true), true);
if (drainStack != null)
{
fluidHandler.drain(dir.getOpposite(), sourcePipe.fill(dir.getOpposite(), drainStack, true), true);
}
}
}
}
@ -205,6 +215,6 @@ public class PipeNetwork extends FluidNetwork
@Override
public void reconstructTankInfo()
{
NetworkTickHandler.addNetwork(this);
}
}

View file

@ -124,7 +124,7 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
{
this.validateConnectionSide(new Vector3(this).translate(dir).getTileEntity(worldObj), dir);
}
/** Only send packet updates if visuallyConnected changed. */
if (previousConnections != renderSides)
{
@ -248,12 +248,14 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
public void sendRenderUpdate()
{
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_RENDER, this, this.colorID, this.renderSides));
if (!this.worldObj.isRemote)
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_RENDER, this, this.colorID, this.renderSides));
}
public void sendTankUpdate()
{
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_TANK, this, getInternalTank().getCapacity(), getInternalTank().writeToNBT(new NBTTagCompound()), pressure), this.worldObj, new Vector3(this), 60);
if (!this.worldObj.isRemote)
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_TANK, this, getInternalTank().getCapacity(), getInternalTank().writeToNBT(new NBTTagCompound()), pressure), this.worldObj, new Vector3(this), 60);
}
@Override