General rendering improvements
*Faster gas rendering in Pressurized Tube. *Lava now glows when in Dynamic Tank. *Mechanical Pipes won't visually connect to Dynamic Valves when not part of a multiblock structure. *Fixed energy cube GUI "Inventory" text color, fixed energy cube GUI energy scale bar.
This commit is contained in:
parent
2553bb40c1
commit
96b192efef
12 changed files with 105 additions and 123 deletions
|
@ -31,9 +31,10 @@ public class EnergyClientUpdate
|
|||
for(Object3D object : found)
|
||||
{
|
||||
TileEntity tileEntity = object.getTileEntity(worldObj);
|
||||
|
||||
if(tileEntity instanceof IUniversalCable)
|
||||
{
|
||||
((IUniversalCable)tileEntity).setEnergyScale(energyScale);
|
||||
((IUniversalCable)tileEntity).setCachedEnergy(energyScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,59 +1,41 @@
|
|||
package mekanism.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.FluidNetwork.NetworkFinder;
|
||||
import mekanism.common.IMechanicalPipe;
|
||||
import mekanism.common.PipeUtils;
|
||||
import mekanism.common.IUniversalCable;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class FluidClientUpdate
|
||||
{
|
||||
/** List of iterated pipes, to prevent infinite loops. */
|
||||
public ArrayList<TileEntity> iteratedPipes = new ArrayList<TileEntity>();
|
||||
public NetworkFinder finder;
|
||||
|
||||
/** Pointer pipe of this calculation */
|
||||
public TileEntity pointer;
|
||||
public World worldObj;
|
||||
|
||||
/** Type of fluid to distribute */
|
||||
public FluidStack fluidToSend;
|
||||
public FluidStack fluidStack;
|
||||
|
||||
public FluidClientUpdate(TileEntity head, FluidStack fluid)
|
||||
{
|
||||
pointer = head;
|
||||
fluidToSend = fluid;
|
||||
worldObj = head.worldObj;
|
||||
fluidStack = fluid;
|
||||
finder = new NetworkFinder(head.worldObj, Object3D.get(head));
|
||||
}
|
||||
|
||||
public void loopThrough(TileEntity tile)
|
||||
{
|
||||
if(!iteratedPipes.contains(tile))
|
||||
{
|
||||
iteratedPipes.add(tile);
|
||||
}
|
||||
|
||||
TileEntity[] pipes = PipeUtils.getConnectedPipes(tile);
|
||||
|
||||
for(TileEntity pipe : pipes)
|
||||
{
|
||||
if(pipe != null)
|
||||
{
|
||||
if(!iteratedPipes.contains(pipe))
|
||||
{
|
||||
loopThrough(pipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void clientUpdate()
|
||||
{
|
||||
loopThrough(pointer);
|
||||
List<Object3D> found = finder.exploreNetwork();
|
||||
|
||||
for(TileEntity tileEntity : iteratedPipes)
|
||||
for(Object3D object : found)
|
||||
{
|
||||
TileEntity tileEntity = object.getTileEntity(worldObj);
|
||||
|
||||
if(tileEntity instanceof IMechanicalPipe)
|
||||
{
|
||||
((IMechanicalPipe)tileEntity).onTransfer(fluidToSend);
|
||||
((IMechanicalPipe)tileEntity).onTransfer(fluidStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,71 +1,40 @@
|
|||
package mekanism.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.EnumGas;
|
||||
import mekanism.api.GasTransmission;
|
||||
import mekanism.api.GasNetwork.NetworkFinder;
|
||||
import mekanism.api.IPressurizedTube;
|
||||
import mekanism.api.Object3D;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* The actual protocol gas goes through when it is transferred via Pressurized Tubes.
|
||||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
public class GasClientUpdate
|
||||
{
|
||||
/** List of iterated tubes, to prevent infinite loops. */
|
||||
public ArrayList<TileEntity> iteratedTubes = new ArrayList<TileEntity>();
|
||||
public NetworkFinder finder;
|
||||
|
||||
/** Pointer tube of this calculation */
|
||||
public TileEntity pointer;
|
||||
public World worldObj;
|
||||
|
||||
/** Type of gas to distribute */
|
||||
public EnumGas transferType;
|
||||
|
||||
/**
|
||||
* GasTransferProtocol -- a calculation used to distribute gasses through a tube network.
|
||||
* @param head - pointer tile entity
|
||||
* @param orig - original outputter
|
||||
* @param type - type of gas being transferred
|
||||
* @param amount - amount of gas to distribute
|
||||
*/
|
||||
public EnumGas gasType;
|
||||
|
||||
public GasClientUpdate(TileEntity head, EnumGas type)
|
||||
{
|
||||
pointer = head;
|
||||
transferType = type;
|
||||
}
|
||||
|
||||
public void loopThrough(TileEntity tile)
|
||||
{
|
||||
if(!iteratedTubes.contains(tile))
|
||||
{
|
||||
iteratedTubes.add(tile);
|
||||
}
|
||||
|
||||
TileEntity[] tubes = GasTransmission.getConnectedTubes(tile);
|
||||
|
||||
for(TileEntity tube : tubes)
|
||||
{
|
||||
if(tube != null)
|
||||
{
|
||||
if(!iteratedTubes.contains(tube))
|
||||
{
|
||||
loopThrough(tube);
|
||||
}
|
||||
}
|
||||
}
|
||||
worldObj = head.worldObj;
|
||||
gasType = type;
|
||||
finder = new NetworkFinder(head.worldObj, Object3D.get(head));
|
||||
}
|
||||
|
||||
public void clientUpdate()
|
||||
{
|
||||
loopThrough(pointer);
|
||||
List<Object3D> found = finder.exploreNetwork();
|
||||
|
||||
for(TileEntity tileEntity : iteratedTubes)
|
||||
for(Object3D object : found)
|
||||
{
|
||||
TileEntity tileEntity = object.getTileEntity(worldObj);
|
||||
|
||||
if(tileEntity instanceof IPressurizedTube)
|
||||
{
|
||||
((IPressurizedTube)tileEntity).onTransfer(transferType);
|
||||
((IPressurizedTube)tileEntity).onTransfer(gasType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class GuiEnergyCube extends GuiContainer
|
|||
fontRenderer.drawString(tileEntity.tier.name + " Energy Cube", 43, 6, 0x404040);
|
||||
fontRenderer.drawString(capacityInfo, 45, 40, 0x00CD00);
|
||||
fontRenderer.drawString(outputInfo, 45, 49, 0x00CD00);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 0x00CD00);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 0x404040);
|
||||
|
||||
redstoneControl.renderForeground(xAxis, yAxis);
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ public class GuiEnergyCube extends GuiContainer
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
int scale = (int)(((double)tileEntity.electricityStored / tileEntity.tier.MAX_ELECTRICITY) * 72);
|
||||
drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 20);
|
||||
int scale = (int)((tileEntity.electricityStored / tileEntity.tier.MAX_ELECTRICITY) * 72);
|
||||
drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 10);
|
||||
|
||||
redstoneControl.renderBackground(xAxis, yAxis, guiWidth, guiHeight);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -54,9 +55,19 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
|
|||
|
||||
GL11.glTranslated(getX(data.location.xCoord), getY(data.location.yCoord), getZ(data.location.zCoord));
|
||||
|
||||
if(tileEntity.structure.fluidStored.getFluid() == FluidRegistry.LAVA)
|
||||
{
|
||||
MekanismRenderer.glowOn();
|
||||
}
|
||||
|
||||
int[] displayList = getListAndRender(data, tileEntity.structure.fluidStored.getFluid(), tileEntity.worldObj);
|
||||
GL11.glCallList(displayList[(int)(((float)tileEntity.structure.fluidStored.amount/(float)tileEntity.clientCapacity)*((float)getStages(data.height)-1))]);
|
||||
|
||||
if(tileEntity.structure.fluidStored.getFluid() == FluidRegistry.LAVA)
|
||||
{
|
||||
MekanismRenderer.glowOff();
|
||||
}
|
||||
|
||||
pop();
|
||||
|
||||
for(ValveData valveData : tileEntity.valveViewing.keySet())
|
||||
|
@ -67,9 +78,19 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
|
|||
|
||||
GL11.glTranslated(getX(valveData.location.xCoord), getY(valveData.location.yCoord), getZ(valveData.location.zCoord));
|
||||
|
||||
if(tileEntity.structure.fluidStored.getFluid() == FluidRegistry.LAVA)
|
||||
{
|
||||
MekanismRenderer.glowOn();
|
||||
}
|
||||
|
||||
int display = getValveDisplay(ValveRenderData.get(data, valveData), tileEntity.structure.fluidStored.getFluid(), tileEntity.worldObj).display;
|
||||
GL11.glCallList(display);
|
||||
|
||||
if(tileEntity.structure.fluidStored.getFluid() == FluidRegistry.LAVA)
|
||||
{
|
||||
MekanismRenderer.glowOff();
|
||||
}
|
||||
|
||||
pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
|||
boolean[] connectable = PipeUtils.getConnections(tileEntity);
|
||||
|
||||
model.renderCenter(connectable);
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
model.renderSide(ForgeDirection.getOrientation(i), connectable[i]);
|
||||
|
|
|
@ -122,6 +122,14 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
func_110628_a(tileEntity.refGas.texturePath);
|
||||
GL11.glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
if(tileEntity.gasScale > 0)
|
||||
{
|
||||
tileEntity.gasScale = Math.max(0, tileEntity.gasScale - .008F);
|
||||
}
|
||||
else {
|
||||
tileEntity.refGas = null;
|
||||
}
|
||||
|
||||
if(tileEntity.canTransferGas())
|
||||
{
|
||||
for(int i = 0; i < 6; i++)
|
||||
|
@ -166,7 +174,9 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
|
||||
Model3D toReturn = new Model3D();
|
||||
toReturn.baseBlock = Block.waterStill;
|
||||
|
||||
toReturn.setTexture(type.gasIcon);
|
||||
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
@ -191,10 +201,13 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
else {
|
||||
HashMap<EnumGas, DisplayInteger> map = new HashMap<EnumGas, DisplayInteger>();
|
||||
map.put(type, display);
|
||||
|
||||
cachedCenterGasses.put(new BooleanArray(connectable), map);
|
||||
}
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
if(cachedSideGasses.containsKey(side) && cachedSideGasses.get(side).containsKey(type))
|
||||
{
|
||||
return cachedSideGasses.get(side).get(type);
|
||||
|
|
|
@ -45,6 +45,9 @@ public interface IUniversalCable
|
|||
*/
|
||||
public void fixNetwork();
|
||||
|
||||
public void setEnergyScale(double energyScale);
|
||||
|
||||
/**
|
||||
* Sets a Universal Cable's energy scale to a new value.
|
||||
* @param energyScale - energy scale to set
|
||||
*/
|
||||
public void setCachedEnergy(double energyScale);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Arrays;
|
|||
import mekanism.api.Object3D;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public final class PipeUtils
|
||||
|
@ -52,7 +52,21 @@ public final class PipeUtils
|
|||
|
||||
if(container.getTankInfo(ForgeDirection.getOrientation(side).getOpposite()) != null && container.getTankInfo(ForgeDirection.getOrientation(side).getOpposite()).length > 0)
|
||||
{
|
||||
connectable[side] = true;
|
||||
boolean notNull = false;
|
||||
|
||||
for(FluidTankInfo info : container.getTankInfo(ForgeDirection.getOrientation(side).getOpposite()))
|
||||
{
|
||||
if(info != null)
|
||||
{
|
||||
notNull = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(notNull)
|
||||
{
|
||||
connectable[side] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFl
|
|||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] {fluidTank.getInfo()};
|
||||
return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fluidTank.getInfo()} : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,7 +46,12 @@ public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFl
|
|||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return fluidTank.drain(maxDrain, doDrain);
|
||||
if(fluidTank.dynamicTank.structure != null)
|
||||
{
|
||||
return fluidTank.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,21 +24,6 @@ public class TileEntityPressurizedTube extends TileEntity implements IPressurize
|
|||
/** The gas network currently in use by this tube segment. */
|
||||
public GasNetwork gasNetwork;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
if(gasScale > 0)
|
||||
{
|
||||
gasScale -= .01;
|
||||
}
|
||||
else {
|
||||
refGas = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasNetwork getNetwork()
|
||||
{
|
||||
|
@ -52,6 +37,7 @@ public class TileEntityPressurizedTube extends TileEntity implements IPressurize
|
|||
{
|
||||
TileEntity[] adjacentPipes = PipeUtils.getConnectedPipes(this);
|
||||
HashSet<GasNetwork> connectedNets = new HashSet<GasNetwork>();
|
||||
|
||||
for(TileEntity cable : adjacentPipes)
|
||||
{
|
||||
if(cable instanceof IPressurizedTube && ((IPressurizedTube)cable).getNetwork(false) != null)
|
||||
|
@ -59,6 +45,7 @@ public class TileEntityPressurizedTube extends TileEntity implements IPressurize
|
|||
connectedNets.add(((IPressurizedTube)cable).getNetwork());
|
||||
}
|
||||
}
|
||||
|
||||
if(connectedNets.size() == 0 || worldObj.isRemote)
|
||||
{
|
||||
gasNetwork = new GasNetwork(this);
|
||||
|
@ -173,7 +160,7 @@ public class TileEntityPressurizedTube extends TileEntity implements IPressurize
|
|||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -163,24 +163,10 @@ public class TileEntityUniversalCable extends TileEntity implements IUniversalCa
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setEnergyScale(double scale)
|
||||
public void setCachedEnergy(double scale)
|
||||
{
|
||||
energyScale = scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
energyScale = getNetwork().getPowerScale();
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
nbtTag.setDouble("energyScale", energyScale);
|
||||
return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
|
||||
}
|
||||
|
||||
public void onDataPacket(INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
setEnergyScale(packet.customParam1.getDouble("energyScale"));
|
||||
}
|
||||
|
||||
public float getEnergyScale()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue