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?
cache.apply((T)structureFound);
onFormed();
structureFound.inventoryID = idToUse;
onFormed();
List<IStructuralMultiblock> structures = new ArrayList<IStructuralMultiblock>();
Coord4D toUse = null;

View file

@ -3,17 +3,20 @@ package mekanism.generators.client.render;
import java.util.HashMap;
import java.util.Map;
import mekanism.api.Coord4D;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.client.render.tileentity.RenderDynamicTank.RenderData;
import mekanism.common.content.tank.TankUpdateProtocol;
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.TileEntitySpecialRenderer;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
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)
{
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();
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;
RenderTurbineRotor.internalRender = true;
Coord4D coord = tileEntity.structure.complex;
bindTexture(MekanismRenderer.getBlocksTexture());
if(data.location != null && data.height >= 3 && tileEntity.structure.fluidStored.getFluid() != null)
while(true)
{
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].render();
MekanismRenderer.glowOff();
MekanismRenderer.resetColor();
pop();
coord = coord.getFromSide(ForgeDirection.DOWN);
TileEntity tile = coord.getTileEntity(tileEntity.getWorldObj());
if(!(tile instanceof TileEntityTurbineRotor))
{
break;
}
TileEntityRendererDispatcher.instance.renderTileEntity(tile, partialTick);
}
RenderTurbineRotor.internalRender = false;
if(tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount != 0)
{
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()
{
GL11.glPopAttrib();
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
private void push()
{
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
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)
{
return (height-2)*(TankUpdateProtocol.FLUID_PER_TANK/10);
return TankUpdateProtocol.FLUID_PER_TANK/10;
}
private double getX(int x)
@ -129,7 +153,7 @@ public class RenderIndustrialTurbine extends TileEntitySpecialRenderer
toReturn.minZ = 0 + .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;
MekanismRenderer.renderObject(toReturn);

View file

@ -17,6 +17,8 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderTurbineRotor extends TileEntitySpecialRenderer
{
public static boolean internalRender = false;
private ModelTurbine model = new ModelTurbine();
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)
{
if(tileEntity.multiblockUUID != null && !internalRender)
{
return;
}
GL11.glPushMatrix();
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Turbine.png"));

View file

@ -21,6 +21,7 @@ public class SynchronizedTurbineData extends SynchronizedData<SynchronizedTurbin
public Coord4D complex;
public int lastSteamInput;
public int newSteamInput;
public int clientDispersers;
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
protected boolean canForm(SynchronizedTurbineData structure)
{
@ -207,8 +218,6 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
}
structure.lowerVolume = structure.volLength*structure.volWidth*turbineHeight;
((TileEntityRotationalComplex)complex.getTileEntity(pointer.getWorldObj())).setMultiblock(structure.inventoryID);
structure.complex = complex;
return true;
@ -247,6 +256,8 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
{
((TurbineCache)cache).fluid.amount += ((TurbineCache)merge).fluid.amount;
}
((TurbineCache)cache).electricity += ((TurbineCache)merge).electricity;
}
@Override
@ -258,6 +269,8 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
}
structureFound.electricityStored = Math.min(structureFound.electricityStored, structureFound.getEnergyCapacity());
((TileEntityRotationalComplex)structureFound.complex.getTileEntity(pointer.getWorldObj())).setMultiblock(structureFound.inventoryID);
}
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 final float ROTATION_THRESHOLD = 0.01F;
public static final float ROTATION_THRESHOLD = 0.001F;
public String multiblockUUID;
public float rotation;
@ -33,18 +33,6 @@ public class TileEntityRotationalComplex extends TileEntityBasicBlock
return false;
}
@Override
public void onAdded()
{
super.onAdded();
if(!worldObj.isRemote)
{
setMultiblock("asdf");
setRotation(1F);
}
}
@Override
public void handlePacketData(ByteBuf dataStream)
{

View file

@ -65,8 +65,6 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
{
if(structure != null)
{
structure.lastSteamInput = 0;
if(structure.fluidStored != null && structure.fluidStored.amount <= 0)
{
structure.fluidStored = null;
@ -75,20 +73,24 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
if(isRendering)
{
structure.lastSteamInput = structure.newSteamInput;
structure.newSteamInput = 0;
int stored = structure.fluidStored != null ? structure.fluidStored.amount : 0;
double proportion = (double)stored/(double)structure.getFluidCapacity();
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 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;
rate = Math.min(Math.min(stored, rate), structure.vents*VENT_GAS_FLOW);
rate = Math.min(rate, (getMaxEnergy()-getEnergy())/energyMultiplier);
rate = Math.min(Math.min(stored, rate), (getMaxEnergy()-getEnergy())/energyMultiplier)*proportion;
flowRate = proportion*(rate/origRate);
flowRate = rate/origRate;
setEnergy(getEnergy()+((int)rate)*energyMultiplier);
structure.fluidStored.amount -= rate;
@ -199,6 +201,11 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
else {
data.add(0);
}
if(isRendering)
{
structure.complex.write(data);
}
}
return data;
@ -228,6 +235,11 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
else {
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)
{
structure.lastSteamInput += filled;
structure.newSteamInput += filled;
}
return filled;