Turbine fixes. They're just about polished

This commit is contained in:
aidancbrady 2016-01-26 08:10:36 -05:00
parent 47b06cd577
commit b450e7e408
8 changed files with 102 additions and 57 deletions

View file

@ -473,11 +473,11 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
//TODO perhaps drop from pointer? //TODO perhaps drop from pointer?
cache.apply((T)structureFound); cache.apply((T)structureFound);
onFormed();
structureFound.inventoryID = idToUse; structureFound.inventoryID = idToUse;
onFormed();
List<IStructuralMultiblock> structures = new ArrayList<IStructuralMultiblock>(); List<IStructuralMultiblock> structures = new ArrayList<IStructuralMultiblock>();
Coord4D toUse = null; Coord4D toUse = null;

View file

@ -3,17 +3,20 @@ package mekanism.generators.client.render;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import mekanism.api.Coord4D;
import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.DisplayInteger; import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D; import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.client.render.tileentity.RenderDynamicTank.RenderData; import mekanism.client.render.tileentity.RenderDynamicTank.RenderData;
import mekanism.common.content.tank.TankUpdateProtocol; import mekanism.common.content.tank.TankUpdateProtocol;
import mekanism.generators.common.tile.turbine.TileEntityTurbineCasing; import mekanism.generators.common.tile.turbine.TileEntityTurbineCasing;
import mekanism.generators.common.tile.turbine.TileEntityTurbineRotor;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
@ -33,58 +36,79 @@ public class RenderIndustrialTurbine extends TileEntitySpecialRenderer
public void renderAModelAt(TileEntityTurbineCasing tileEntity, double x, double y, double z, float partialTick) public void renderAModelAt(TileEntityTurbineCasing tileEntity, double x, double y, double z, float partialTick)
{ {
if(tileEntity.clientHasStructure && tileEntity.isRendering && tileEntity.structure != null && tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount != 0) if(tileEntity.clientHasStructure && tileEntity.isRendering && tileEntity.structure != null)
{ {
RenderData data = new RenderData(); RenderTurbineRotor.internalRender = true;
Coord4D coord = tileEntity.structure.complex;
data.location = tileEntity.structure.renderLocation;
data.height = tileEntity.structure.lowerVolume/(tileEntity.structure.volLength*tileEntity.structure.volWidth);
data.length = tileEntity.structure.volLength;
data.width = tileEntity.structure.volWidth;
bindTexture(MekanismRenderer.getBlocksTexture()); while(true)
if(data.location != null && data.height >= 3 && tileEntity.structure.fluidStored.getFluid() != null)
{ {
push(); coord = coord.getFromSide(ForgeDirection.DOWN);
TileEntity tile = coord.getTileEntity(tileEntity.getWorldObj());
GL11.glTranslated(getX(data.location.xCoord), getY(data.location.yCoord), getZ(data.location.zCoord));
if(!(tile instanceof TileEntityTurbineRotor))
MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity()); {
MekanismRenderer.colorFluid(tileEntity.structure.fluidStored.getFluid()); break;
}
DisplayInteger[] displayList = getListAndRender(data, tileEntity.getWorldObj());
TileEntityRendererDispatcher.instance.renderTileEntity(tile, partialTick);
GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.structure.fluidStored.amount / (float)tileEntity.structure.getFluidCapacity())+0.3F)); }
displayList[getStages(data.height)-1].render();
RenderTurbineRotor.internalRender = false;
MekanismRenderer.glowOff();
MekanismRenderer.resetColor(); if(tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount != 0)
{
pop(); RenderData data = new RenderData();
data.location = tileEntity.structure.renderLocation;
data.height = tileEntity.structure.lowerVolume/(tileEntity.structure.volLength*tileEntity.structure.volWidth);
data.length = tileEntity.structure.volLength;
data.width = tileEntity.structure.volWidth;
bindTexture(MekanismRenderer.getBlocksTexture());
if(data.location != null && data.height >= 1 && tileEntity.structure.fluidStored.getFluid() != null)
{
push();
GL11.glTranslated(getX(data.location.xCoord), getY(data.location.yCoord), getZ(data.location.zCoord));
MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity());
MekanismRenderer.colorFluid(tileEntity.structure.fluidStored.getFluid());
DisplayInteger[] displayList = getListAndRender(data, tileEntity.getWorldObj());
GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.structure.fluidStored.amount / (float)tileEntity.structure.getFluidCapacity())+0.3F));
displayList[getStages(data.height+1)-1].render();
MekanismRenderer.glowOff();
MekanismRenderer.resetColor();
pop();
}
} }
} }
} }
private void pop() private void pop()
{ {
GL11.glPopAttrib(); GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
private void push() private void push()
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LIGHTING); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
} }
private int getStages(int height) private int getStages(int height)
{ {
return (height-2)*(TankUpdateProtocol.FLUID_PER_TANK/10); return TankUpdateProtocol.FLUID_PER_TANK/10;
} }
private double getX(int x) private double getX(int x)
@ -129,7 +153,7 @@ public class RenderIndustrialTurbine extends TileEntitySpecialRenderer
toReturn.minZ = 0 + .01; toReturn.minZ = 0 + .01;
toReturn.maxX = data.length - .01; toReturn.maxX = data.length - .01;
toReturn.maxY = ((float)i/(float)stages)*(data.height-2) - .01; toReturn.maxY = ((float)i/(float)stages)*(data.height+1) - .01;
toReturn.maxZ = data.width - .01; toReturn.maxZ = data.width - .01;
MekanismRenderer.renderObject(toReturn); MekanismRenderer.renderObject(toReturn);

View file

@ -17,6 +17,8 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class RenderTurbineRotor extends TileEntitySpecialRenderer public class RenderTurbineRotor extends TileEntitySpecialRenderer
{ {
public static boolean internalRender = false;
private ModelTurbine model = new ModelTurbine(); private ModelTurbine model = new ModelTurbine();
private static final float BASE_SPEED = 512F; private static final float BASE_SPEED = 512F;
@ -29,6 +31,11 @@ public class RenderTurbineRotor extends TileEntitySpecialRenderer
private void renderAModelAt(TileEntityTurbineRotor tileEntity, double x, double y, double z, float partialTick) private void renderAModelAt(TileEntityTurbineRotor tileEntity, double x, double y, double z, float partialTick)
{ {
if(tileEntity.multiblockUUID != null && !internalRender)
{
return;
}
GL11.glPushMatrix(); GL11.glPushMatrix();
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Turbine.png")); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Turbine.png"));

View file

@ -21,6 +21,7 @@ public class SynchronizedTurbineData extends SynchronizedData<SynchronizedTurbin
public Coord4D complex; public Coord4D complex;
public int lastSteamInput; public int lastSteamInput;
public int newSteamInput;
public int clientDispersers; public int clientDispersers;
public int clientFlow; public int clientFlow;

View file

@ -63,6 +63,17 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
} }
} }
@Override
public void onStructureDestroyed(SynchronizedTurbineData structure)
{
TileEntity tile = structure.complex.getTileEntity(pointer.getWorldObj());
if(tile instanceof TileEntityRotationalComplex)
{
((TileEntityRotationalComplex)tile).setMultiblock(null);
}
}
@Override @Override
protected boolean canForm(SynchronizedTurbineData structure) protected boolean canForm(SynchronizedTurbineData structure)
{ {
@ -207,8 +218,6 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
} }
structure.lowerVolume = structure.volLength*structure.volWidth*turbineHeight; structure.lowerVolume = structure.volLength*structure.volWidth*turbineHeight;
((TileEntityRotationalComplex)complex.getTileEntity(pointer.getWorldObj())).setMultiblock(structure.inventoryID);
structure.complex = complex; structure.complex = complex;
return true; return true;
@ -247,6 +256,8 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
{ {
((TurbineCache)cache).fluid.amount += ((TurbineCache)merge).fluid.amount; ((TurbineCache)cache).fluid.amount += ((TurbineCache)merge).fluid.amount;
} }
((TurbineCache)cache).electricity += ((TurbineCache)merge).electricity;
} }
@Override @Override
@ -258,6 +269,8 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
} }
structureFound.electricityStored = Math.min(structureFound.electricityStored, structureFound.getEnergyCapacity()); structureFound.electricityStored = Math.min(structureFound.electricityStored, structureFound.getEnergyCapacity());
((TileEntityRotationalComplex)structureFound.complex.getTileEntity(pointer.getWorldObj())).setMultiblock(structureFound.inventoryID);
} }
public class CoilCounter public class CoilCounter

View file

@ -19,7 +19,7 @@ public class TileEntityRotationalComplex extends TileEntityBasicBlock
{ {
public static Map<String, Float> clientRotationMap = new HashMap<String, Float>(); public static Map<String, Float> clientRotationMap = new HashMap<String, Float>();
public static final float ROTATION_THRESHOLD = 0.01F; public static final float ROTATION_THRESHOLD = 0.001F;
public String multiblockUUID; public String multiblockUUID;
public float rotation; public float rotation;
@ -33,18 +33,6 @@ public class TileEntityRotationalComplex extends TileEntityBasicBlock
return false; return false;
} }
@Override
public void onAdded()
{
super.onAdded();
if(!worldObj.isRemote)
{
setMultiblock("asdf");
setRotation(1F);
}
}
@Override @Override
public void handlePacketData(ByteBuf dataStream) public void handlePacketData(ByteBuf dataStream)
{ {

View file

@ -65,8 +65,6 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
{ {
if(structure != null) if(structure != null)
{ {
structure.lastSteamInput = 0;
if(structure.fluidStored != null && structure.fluidStored.amount <= 0) if(structure.fluidStored != null && structure.fluidStored.amount <= 0)
{ {
structure.fluidStored = null; structure.fluidStored = null;
@ -75,20 +73,24 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
if(isRendering) if(isRendering)
{ {
structure.lastSteamInput = structure.newSteamInput;
structure.newSteamInput = 0;
int stored = structure.fluidStored != null ? structure.fluidStored.amount : 0; int stored = structure.fluidStored != null ? structure.fluidStored.amount : 0;
double proportion = (double)stored/(double)structure.getFluidCapacity(); double proportion = (double)stored/(double)structure.getFluidCapacity();
double flowRate = 0; double flowRate = 0;
if(stored > 0 && structure.electricityStored < structure.getEnergyCapacity()) if(stored > 0 && getEnergy() < structure.getEnergyCapacity())
{ {
double energyMultiplier = ENERGY_PER_STEAM*Math.min(structure.blades, structure.coils*BLADE_TO_COIL_RATIO); double energyMultiplier = ENERGY_PER_STEAM*Math.min(structure.blades, structure.coils*BLADE_TO_COIL_RATIO);
double rate = structure.lowerVolume*(structure.getDispersers()*DISPERSER_GAS_FLOW)*proportion; double rate = structure.lowerVolume*(structure.getDispersers()*DISPERSER_GAS_FLOW);
rate = Math.min(rate, structure.vents*VENT_GAS_FLOW);
double origRate = rate; double origRate = rate;
rate = Math.min(Math.min(stored, rate), structure.vents*VENT_GAS_FLOW); rate = Math.min(Math.min(stored, rate), (getMaxEnergy()-getEnergy())/energyMultiplier)*proportion;
rate = Math.min(rate, (getMaxEnergy()-getEnergy())/energyMultiplier);
flowRate = proportion*(rate/origRate); flowRate = rate/origRate;
setEnergy(getEnergy()+((int)rate)*energyMultiplier); setEnergy(getEnergy()+((int)rate)*energyMultiplier);
structure.fluidStored.amount -= rate; structure.fluidStored.amount -= rate;
@ -199,6 +201,11 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
else { else {
data.add(0); data.add(0);
} }
if(isRendering)
{
structure.complex.write(data);
}
} }
return data; return data;
@ -228,6 +235,11 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
else { else {
structure.fluidStored = null; structure.fluidStored = null;
} }
if(isRendering)
{
structure.complex = Coord4D.read(dataStream);
}
} }
} }

View file

@ -363,7 +363,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I
if(structure != null && doFill) if(structure != null && doFill)
{ {
structure.lastSteamInput += filled; structure.newSteamInput += filled;
} }
return filled; return filled;