Fixed many bugs!

- Asset issue with Dynamic Valve fixed
- Fixed pipes connecting to Dynamic Valves when not part of structure
- Fixed stack overflow when rendering valve fluids
- Fixed transmitter networks considering pull-based block connections as acceptor connections
- Fixed dynamic tanks maintaining a fluid type even when it has been depleted
- Fixed "clearIfNecessary()" transmitter calls not working
This commit is contained in:
Aidan C. Brady 2015-03-04 20:01:46 -05:00
parent 09f1a04764
commit 6f0cf3a166
9 changed files with 118 additions and 108 deletions

View file

@ -66,7 +66,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
World world = getWorld(); World world = getWorld();
if(acceptor.getTileEntity(world) == null || acceptor.getTileEntity(world).isInvalid() || transmitter.canConnectToAcceptor(side, true)) if(acceptor.getTileEntity(world) == null || acceptor.getTileEntity(world).isInvalid() || !transmitter.canConnectToAcceptor(side, true))
{ {
acceptorDirections.get(acceptor).remove(side.getOpposite()); acceptorDirections.get(acceptor).remove(side.getOpposite());

View file

@ -358,7 +358,6 @@ public class RenderPartTransmitter implements IIconSelfRegister
pop(); pop();
} }
} }
private DisplayInteger[] getListAndRender(ForgeDirection side, Fluid fluid) private DisplayInteger[] getListAndRender(ForgeDirection side, Fluid fluid)
@ -492,6 +491,7 @@ public class RenderPartTransmitter implements IIconSelfRegister
} }
push(); push();
CCRenderState.reset(); CCRenderState.reset();
CCRenderState.useNormals = true; CCRenderState.useNormals = true;
CCRenderState.startDrawing(); CCRenderState.startDrawing();
@ -509,6 +509,7 @@ public class RenderPartTransmitter implements IIconSelfRegister
MekanismRenderer.disableCullFace(); MekanismRenderer.disableCullFace();
MekanismRenderer.glowOff(); MekanismRenderer.glowOff();
pop(); pop();
} }

View file

@ -79,7 +79,6 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
{ {
push(); push();
MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity());
GL11.glTranslated(getX(valveData.location.xCoord), getY(valveData.location.yCoord), getZ(valveData.location.zCoord)); GL11.glTranslated(getX(valveData.location.xCoord), getY(valveData.location.yCoord), getZ(valveData.location.zCoord));
MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity()); MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity());

View file

@ -7,7 +7,6 @@ import java.util.EnumSet;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
@ -18,7 +17,6 @@ import mekanism.api.transmitters.TransmissionType;
import mekanism.api.util.ListUtils; import mekanism.api.util.ListUtils;
import mekanism.common.util.LangUtils; import mekanism.common.util.LangUtils;
import mekanism.common.util.PipeUtils; import mekanism.common.util.PipeUtils;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;

View file

@ -4,7 +4,6 @@ import mekanism.api.Coord4D;
import mekanism.common.content.tank.SynchronizedTankData.ValveData; import mekanism.common.content.tank.SynchronizedTankData.ValveData;
import mekanism.common.tile.TileEntityDynamicTank; import mekanism.common.tile.TileEntityDynamicTank;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.fluids.IFluidTank;
@ -40,6 +39,11 @@ public class DynamicFluidTank implements IFluidTank
return 0; return 0;
} }
if(dynamicTank.structure.fluidStored != null && !dynamicTank.structure.fluidStored.isFluidEqual(resource))
{
return 0;
}
if(dynamicTank.structure.fluidStored == null || dynamicTank.structure.fluidStored.fluidID <= 0) if(dynamicTank.structure.fluidStored == null || dynamicTank.structure.fluidStored.fluidID <= 0)
{ {
if(resource.amount <= getCapacity()) if(resource.amount <= getCapacity())
@ -47,15 +51,15 @@ public class DynamicFluidTank implements IFluidTank
if(doFill) if(doFill)
{ {
dynamicTank.structure.fluidStored = resource.copy(); dynamicTank.structure.fluidStored = resource.copy();
}
if(resource.amount > 0 && doFill) if(resource.amount > 0)
{ {
MekanismUtils.saveChunk(dynamicTank); MekanismUtils.saveChunk(dynamicTank);
updateValveData(true); updateValveData(true);
dynamicTank.sendPacketToRenderer(); dynamicTank.sendPacketToRenderer();
updateValveData(false); updateValveData(false);
} }
}
return resource.amount; return resource.amount;
} }
@ -64,41 +68,33 @@ public class DynamicFluidTank implements IFluidTank
{ {
dynamicTank.structure.fluidStored = resource.copy(); dynamicTank.structure.fluidStored = resource.copy();
dynamicTank.structure.fluidStored.amount = getCapacity(); dynamicTank.structure.fluidStored.amount = getCapacity();
}
if(getCapacity() > 0 && doFill) if(getCapacity() > 0)
{ {
MekanismUtils.saveChunk(dynamicTank); MekanismUtils.saveChunk(dynamicTank);
updateValveData(true); updateValveData(true);
dynamicTank.sendPacketToRenderer(); dynamicTank.sendPacketToRenderer();
updateValveData(false); updateValveData(false);
} }
}
return getCapacity(); return getCapacity();
} }
} }
else if(resource.amount <= getNeeded())
if(!dynamicTank.structure.fluidStored.isFluidEqual(resource))
{
return 0;
}
int space = getCapacity() - dynamicTank.structure.fluidStored.amount;
if(resource.amount <= space)
{ {
if(doFill) if(doFill)
{ {
dynamicTank.structure.fluidStored.amount += resource.amount; dynamicTank.structure.fluidStored.amount += resource.amount;
}
if(resource.amount > 0 && doFill) if(resource.amount > 0)
{ {
MekanismUtils.saveChunk(dynamicTank); MekanismUtils.saveChunk(dynamicTank);
updateValveData(true); updateValveData(true);
dynamicTank.sendPacketToRenderer(); dynamicTank.sendPacketToRenderer();
updateValveData(false); updateValveData(false);
} }
}
return resource.amount; return resource.amount;
} }
@ -106,17 +102,17 @@ public class DynamicFluidTank implements IFluidTank
if(doFill) if(doFill)
{ {
dynamicTank.structure.fluidStored.amount = getCapacity(); dynamicTank.structure.fluidStored.amount = getCapacity();
}
if(space > 0 && doFill) if(getNeeded() > 0)
{ {
MekanismUtils.saveChunk(dynamicTank); MekanismUtils.saveChunk(dynamicTank);
updateValveData(true); updateValveData(true);
dynamicTank.sendPacketToRenderer(); dynamicTank.sendPacketToRenderer();
updateValveData(false); updateValveData(false);
} }
}
return space; return getNeeded();
} }
} }
@ -183,6 +179,11 @@ public class DynamicFluidTank implements IFluidTank
return null; return null;
} }
public int getNeeded()
{
return getCapacity()-getFluidAmount();
}
@Override @Override
public int getFluidAmount() public int getFluidAmount()
{ {

View file

@ -12,10 +12,8 @@ import mekanism.client.ClientTickHandler;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.network.PacketTransmitterUpdate.PacketType; import mekanism.common.network.PacketTransmitterUpdate.PacketType;
import mekanism.common.network.PacketTransmitterUpdate.TransmitterUpdateMessage; import mekanism.common.network.PacketTransmitterUpdate.TransmitterUpdateMessage;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput; import codechicken.lib.data.MCDataOutput;
import codechicken.multipart.TMultiPart; import codechicken.multipart.TMultiPart;
@ -44,7 +42,7 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends Pa
@Override @Override
public void refreshTransmitterNetwork() public void refreshTransmitterNetwork()
{ {
getTransmitterNetwork().refresh(this); getTransmitterNetwork().refresh((IGridTransmitter<N>)tile());
getTransmitterNetwork().refresh(); getTransmitterNetwork().refresh();
} }
@ -246,6 +244,8 @@ public abstract class PartTransmitter<N extends DynamicNetwork<?, N>> extends Pa
{ {
super.onModeChange(side); super.onModeChange(side);
getTransmitterNetwork().refresh((IGridTransmitter<N>)tile());
if(!world().isRemote) if(!world().isRemote)
{ {
Mekanism.packetHandler.sendToDimension(new TransmitterUpdateMessage(PacketType.UPDATE, Coord4D.get(tile())), world().provider.dimensionId); Mekanism.packetHandler.sendToDimension(new TransmitterUpdateMessage(PacketType.UPDATE, Coord4D.get(tile())), world().provider.dimensionId);

View file

@ -89,6 +89,11 @@ public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTank
{ {
if(structure != null) if(structure != null)
{ {
if(structure.fluidStored != null && structure.fluidStored.amount <= 0)
{
structure.fluidStored = null;
}
manageInventory(); manageInventory();
} }
} }
@ -281,9 +286,8 @@ public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTank
{ {
data.add(structure.volume*TankUpdateProtocol.FLUID_PER_TANK); data.add(structure.volume*TankUpdateProtocol.FLUID_PER_TANK);
data.add(structure.editMode.ordinal()); data.add(structure.editMode.ordinal());
}
if(structure != null && structure.fluidStored != null) if(structure.fluidStored != null)
{ {
data.add(1); data.add(1);
data.add(structure.fluidStored.fluidID); data.add(structure.fluidStored.fluidID);
@ -293,18 +297,18 @@ public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTank
data.add(0); data.add(0);
} }
if(structure != null && isRendering) if(isRendering)
{ {
data.add(structure.valves.size()); data.add(structure.valves.size());
for(ValveData valveData : structure.valves) for(ValveData valveData : structure.valves)
{ {
valveData.location.write(data); valveData.location.write(data);
data.add(valveData.side.ordinal()); data.add(valveData.side.ordinal());
data.add(valveData.serverFluid); data.add(valveData.serverFluid);
} }
} }
}
return data; return data;
} }
@ -318,7 +322,6 @@ public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTank
{ {
clientCapacity = dataStream.readInt(); clientCapacity = dataStream.readInt();
structure.editMode = ContainerEditMode.values()[dataStream.readInt()]; structure.editMode = ContainerEditMode.values()[dataStream.readInt()];
}
if(dataStream.readInt() == 1) if(dataStream.readInt() == 1)
{ {
@ -328,7 +331,7 @@ public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTank
structure.fluidStored = null; structure.fluidStored = null;
} }
if(clientHasStructure && isRendering) if(isRendering)
{ {
int size = dataStream.readInt(); int size = dataStream.readInt();
@ -363,6 +366,7 @@ public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTank
} }
} }
} }
}
public int getScaledFluidLevel(int i) public int getScaledFluidLevel(int i)
{ {

View file

@ -1,8 +1,8 @@
package mekanism.common.tile; package mekanism.common.tile;
import mekanism.common.content.tank.DynamicFluidTank; import mekanism.common.content.tank.DynamicFluidTank;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.PipeUtils; import mekanism.common.util.PipeUtils;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -59,12 +59,18 @@ public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFl
@Override @Override
public boolean canFill(ForgeDirection from, Fluid fluid) public boolean canFill(ForgeDirection from, Fluid fluid)
{ {
return true; return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure));
} }
@Override @Override
public boolean canDrain(ForgeDirection from, Fluid fluid) public boolean canDrain(ForgeDirection from, Fluid fluid)
{ {
return true; return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure));
}
@Override
public String getInventoryName()
{
return MekanismUtils.localize("gui.dynamicTank");
} }
} }

View file

@ -412,6 +412,7 @@ gui.constituents=Constituents
gui.cells=cells gui.cells=cells
gui.providers=providers gui.providers=providers
gui.structure=Structure gui.structure=Structure
gui.dynamicTank=Dynamic Tank
gui.reactor.injectionRate=Injection Rate gui.reactor.injectionRate=Injection Rate