Cleanup and more bug fixes
Trying to reduce pack load Fixed mech rod not slowing down when force = 0 Fixed Pipes render bug
This commit is contained in:
parent
5d2450a061
commit
89e5ca315b
6 changed files with 127 additions and 142 deletions
|
@ -37,17 +37,15 @@ public class BlockPipe extends BlockContainer
|
||||||
super.onBlockAdded(world, x, y, z);
|
super.onBlockAdded(world, x, y, z);
|
||||||
this.updateConductorTileEntity(world, x, y, z);
|
this.updateConductorTileEntity(world, x, y, z);
|
||||||
}
|
}
|
||||||
public static TileEntity getLiquidUnit(World world, int x, int y, int z, int side,Liquid type)
|
public static TileEntity getLiquidUnit(World world, int x, int y, int z, ForgeDirection side,Liquid type)
|
||||||
{
|
{
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(side);
|
|
||||||
|
|
||||||
//Check if the designated block is a UE Unit - producer, consumer or a conductor
|
//Check if the designated block is a UE Unit - producer, consumer or a conductor
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ);
|
TileEntity tileEntity = world.getBlockTileEntity(x+side.offsetX, y+side.offsetY, z+side.offsetZ);
|
||||||
TileEntity returnValue = null;
|
TileEntity returnValue = null;
|
||||||
|
|
||||||
if(tileEntity instanceof ILiquidConsumer)
|
if(tileEntity instanceof ILiquidConsumer)
|
||||||
{
|
{
|
||||||
if(((ILiquidConsumer)tileEntity).canRecieveLiquid(type,ForgeDirection.getOrientation(side)))
|
if(((ILiquidConsumer)tileEntity).canRecieveLiquid(type,side))
|
||||||
{
|
{
|
||||||
returnValue = tileEntity;
|
returnValue = tileEntity;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +53,7 @@ public class BlockPipe extends BlockContainer
|
||||||
|
|
||||||
if (tileEntity instanceof ILiquidProducer)
|
if (tileEntity instanceof ILiquidProducer)
|
||||||
{
|
{
|
||||||
if(((ILiquidProducer)tileEntity).canProduceLiquid(type,ForgeDirection.getOrientation(side)))
|
if(((ILiquidProducer)tileEntity).canProduceLiquid(type,side))
|
||||||
{
|
{
|
||||||
returnValue = tileEntity;
|
returnValue = tileEntity;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +93,8 @@ public class BlockPipe extends BlockContainer
|
||||||
{
|
{
|
||||||
TileEntityPipe conductorTileEntity = (TileEntityPipe) tileEntity;
|
TileEntityPipe conductorTileEntity = (TileEntityPipe) tileEntity;
|
||||||
Liquid type = conductorTileEntity.getType();
|
Liquid type = conductorTileEntity.getType();
|
||||||
conductorTileEntity.addConnection(getLiquidUnit(world, x, y, z, i, type), ForgeDirection.getOrientation(i));
|
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||||
|
conductorTileEntity.addConnection(getLiquidUnit(world, x, y, z, side, type), side);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
||||||
{
|
{
|
||||||
this.connectedBlocks[side.ordinal()] = tileEntity;
|
this.connectedBlocks[side.ordinal()] = tileEntity;
|
||||||
}
|
}
|
||||||
}
|
}else
|
||||||
if(tileEntity instanceof ILiquidProducer)
|
if(tileEntity instanceof ILiquidProducer)
|
||||||
{
|
{
|
||||||
if(((ILiquidProducer)tileEntity).canProduceLiquid(this.type, side))
|
if(((ILiquidProducer)tileEntity).canProduceLiquid(this.type, side))
|
||||||
|
@ -73,13 +73,15 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
if(++count >= 5 && !this.worldObj.isRemote)
|
if(++count >= 10 || firstUpdate)
|
||||||
{count = 0;
|
{count = 0;firstUpdate = false;
|
||||||
//update connections
|
|
||||||
BlockPipe.updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
BlockPipe.updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||||
|
if(!this.worldObj.isRemote){
|
||||||
|
//update connections
|
||||||
|
|
||||||
//send packet with liquid type data
|
//send packet with liquid type data
|
||||||
Packet packet = PacketManager.getPacket("Pipes",this, new Object[]{this.type.ordinal()});
|
Packet packet = PacketManager.getPacket("Pipes",this, new Object[]{this.type.ordinal()});
|
||||||
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 40);
|
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 60);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,6 +179,7 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Return the stored volume in this pipe.
|
* @return Return the stored volume in this pipe.
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class TileEntityRod extends TileEntity implements IPacketReceiver,IMechan
|
||||||
}
|
}
|
||||||
if(!worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(ff instanceof IMechanical)
|
if(ff instanceof IMechanical)
|
||||||
{
|
{
|
||||||
if(((IMechanical) ff).canInputSide(backDir))
|
if(((IMechanical) ff).canInputSide(backDir))
|
||||||
|
@ -62,17 +63,13 @@ public class TileEntityRod extends TileEntity implements IPacketReceiver,IMechan
|
||||||
}
|
}
|
||||||
if(bb instanceof IMechanical)
|
if(bb instanceof IMechanical)
|
||||||
{
|
{
|
||||||
if(((IMechanical) bb).getForce() <= 0)
|
|
||||||
{
|
|
||||||
this.force = 0;
|
|
||||||
}
|
|
||||||
if(((IMechanical) bb).canOutputSide(frontDir))
|
if(((IMechanical) bb).canOutputSide(frontDir))
|
||||||
{
|
{
|
||||||
this.force = ((IMechanical) bb).getForce();
|
this.force = ((IMechanical) bb).getForce();
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
this.force = 0;
|
this.force -=Math.max(force/10, 0);
|
||||||
}
|
}
|
||||||
aForce = Math.max(force - 10,0);
|
aForce = Math.max(force - 10,0);
|
||||||
Packet packet = PacketManager.getPacket(SteamPowerMain.channel,this, new Object[]{force,aForce});
|
Packet packet = PacketManager.getPacket(SteamPowerMain.channel,this, new Object[]{force,aForce});
|
||||||
|
|
|
@ -34,28 +34,30 @@ public class TileEntityPump extends TileEntityElectricityReceiver implements ILi
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
if(count++ >= 20)
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
sList = TradeHelper.getSourounding(this);
|
sList = TradeHelper.getSourounding(this);
|
||||||
int bBlock = worldObj.getBlockId(xCoord, yCoord -1, zCoord);
|
int bBlock = worldObj.getBlockId(xCoord, yCoord -1, zCoord);
|
||||||
Liquid bellow = Liquid.getLiquidByBlock(bBlock);
|
Liquid bellow = Liquid.getLiquidByBlock(bBlock);
|
||||||
|
|
||||||
if(bellow != null && this.lStored <= 0)
|
if(bellow != null && this.lStored <= 0)
|
||||||
{
|
{
|
||||||
this.type = bellow;
|
this.type = bellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
count++;
|
if(bBlock == type.Still && this.eStored > 200 && this.lStored < this.wMax)
|
||||||
|
|
||||||
|
|
||||||
if(bBlock == type.Still && this.eStored > 200 && this.lStored < this.wMax && count>=20)
|
|
||||||
{
|
{
|
||||||
eStored -= 200;
|
eStored -= 200;
|
||||||
lStored += 1;
|
lStored += 1;
|
||||||
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord-1, zCoord, 0, 0);
|
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord-1, zCoord, 0, 0);
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canReceiveFromSide(ForgeDirection side) {
|
public boolean canReceiveFromSide(ForgeDirection side) {
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class TileEntityMachine extends TileEntity implements IInventory, ISided
|
||||||
{
|
{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if(count ++ >= 10 && !worldObj.isRemote)
|
if(count ++ >= 20 && !worldObj.isRemote)
|
||||||
{count = 0;
|
{count = 0;
|
||||||
Packet packet = PacketManager.getPacket(SteamPowerMain.channel,this, getSendData());
|
Packet packet = PacketManager.getPacket(SteamPowerMain.channel,this, getSendData());
|
||||||
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 40);
|
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 40);
|
||||||
|
|
|
@ -36,22 +36,6 @@ public class RenderPipe extends TileEntitySpecialRenderer
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
||||||
GL11.glScalef(1.0F, -1F, -1F);
|
GL11.glScalef(1.0F, -1F, -1F);
|
||||||
if(size == 4)
|
|
||||||
{
|
|
||||||
switch(type.ordinal())
|
|
||||||
{
|
|
||||||
case 0: bindTextureByName(BasicPipesMain.textureFile+"/pipes/SteamPipe.png");break;
|
|
||||||
case 1: bindTextureByName(BasicPipesMain.textureFile+"/pipes/WaterPipe.png");break;
|
|
||||||
default:bindTextureByName(BasicPipesMain.textureFile+"/pipes/DefaultPipe.png"); break;
|
|
||||||
}
|
|
||||||
if(tileEntity.connectedBlocks[0] != null) fourPipe.renderBottom();
|
|
||||||
if(tileEntity.connectedBlocks[1] != null) fourPipe.renderTop();
|
|
||||||
if(tileEntity.connectedBlocks[2] != null) fourPipe.renderFront();
|
|
||||||
if(tileEntity.connectedBlocks[3] != null) fourPipe.renderBack();
|
|
||||||
if(tileEntity.connectedBlocks[4] != null) fourPipe.renderRight();
|
|
||||||
if(tileEntity.connectedBlocks[5] != null) fourPipe.renderLeft();
|
|
||||||
fourPipe.renderMiddle();
|
|
||||||
}
|
|
||||||
if(size == 6)
|
if(size == 6)
|
||||||
{
|
{
|
||||||
switch(type.ordinal())
|
switch(type.ordinal())
|
||||||
|
@ -64,10 +48,10 @@ public class RenderPipe extends TileEntitySpecialRenderer
|
||||||
}
|
}
|
||||||
if(tileEntity.connectedBlocks[0] != null) SixPipe.renderBottom();
|
if(tileEntity.connectedBlocks[0] != null) SixPipe.renderBottom();
|
||||||
if(tileEntity.connectedBlocks[1] != null) SixPipe.renderTop();
|
if(tileEntity.connectedBlocks[1] != null) SixPipe.renderTop();
|
||||||
if(tileEntity.connectedBlocks[2] != null) SixPipe.renderFront();
|
if(tileEntity.connectedBlocks[3] != null) SixPipe.renderFront();
|
||||||
if(tileEntity.connectedBlocks[3] != null) SixPipe.renderBack();
|
if(tileEntity.connectedBlocks[2] != null) SixPipe.renderBack();
|
||||||
if(tileEntity.connectedBlocks[4] != null) SixPipe.renderRight();
|
if(tileEntity.connectedBlocks[5] != null) SixPipe.renderRight();
|
||||||
if(tileEntity.connectedBlocks[5] != null) SixPipe.renderLeft();
|
if(tileEntity.connectedBlocks[4] != null) SixPipe.renderLeft();
|
||||||
SixPipe.renderMiddle();
|
SixPipe.renderMiddle();
|
||||||
}
|
}
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
Loading…
Reference in a new issue