Fix a GUI bug, fixed gas tanks not loading properly, fix a few culling issues with Chemical Oxidizer, made gas render visually in Chemical Oxidizer

This commit is contained in:
Aidan C. Brady 2013-12-31 16:38:40 -05:00
parent a277b6e266
commit 2dc6a35d16
7 changed files with 154 additions and 8 deletions

View file

@ -191,7 +191,7 @@ public class GasTank
{
if(nbtTags.hasKey("stored"))
{
stored = GasStack.readFromNBT(nbtTags);
stored = GasStack.readFromNBT(nbtTags.getCompoundTag("stored"));
}
maxGas = nbtTags.getInteger("maxGas");

View file

@ -122,7 +122,7 @@ public class GuiChemicalOxidizer extends GuiMekanism
}
}
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiOxidationChamber.png"));
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"));
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 4, 16, 59);
}
}

View file

@ -176,10 +176,12 @@ public class ModelChemicalOxidizer extends ModelBase
GasConnection.render(size);
Machine.render(size);
Post.render(size);
}
public void renderGlass(float size)
{
GL11.glPushMatrix();
MekanismRenderer.blendOn();
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glColor4f(1, 1, 1, 0.2F);
GlassN.render(size);

View file

@ -1,11 +1,20 @@
package mekanism.client.render.tileentity;
import java.util.HashMap;
import java.util.Map;
import mekanism.api.gas.Gas;
import mekanism.client.model.ModelChemicalOxidizer;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.tileentity.TileEntityChemicalOxidizer;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
@ -13,6 +22,10 @@ public class RenderChemicalOxidizer extends TileEntitySpecialRenderer
{
private ModelChemicalOxidizer model = new ModelChemicalOxidizer();
private static final double offset = 0.001;
private Map<ForgeDirection, HashMap<Gas, DisplayInteger>> cachedGasses = new HashMap<ForgeDirection, HashMap<Gas, DisplayInteger>>();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{
@ -20,6 +33,29 @@ public class RenderChemicalOxidizer extends TileEntitySpecialRenderer
}
private void renderAModelAt(TileEntityChemicalOxidizer tileEntity, double x, double y, double z, float partialTick)
{
render(false, x, y, z, tileEntity);
if(tileEntity.gasTank.getGas() != null)
{
push();
GL11.glTranslatef((float)x, (float)y, (float)z);
GL11.glColor4f(1.0F, 1.0F, 1.0F, (float)tileEntity.gasTank.getStored()/tileEntity.gasTank.getMaxGas());
bindTexture(MekanismRenderer.getBlocksTexture());
getListAndRender(ForgeDirection.getOrientation(tileEntity.facing), tileEntity.gasTank.getGas().getGas()).render();
GL11.glColor4f(1, 1, 1, 1);
pop();
}
render(true, x, y, z, tileEntity);
}
/*
* 0: casing, 1: glass
*/
private void render(boolean glass, double x, double y, double z, TileEntityChemicalOxidizer tileEntity)
{
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
@ -35,7 +71,116 @@ public class RenderChemicalOxidizer extends TileEntitySpecialRenderer
}
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
model.render(0.0625F);
if(!glass)
{
model.render(0.0625F);
}
else {
model.renderGlass(0.0625F);
}
GL11.glPopMatrix();
}
@SuppressWarnings("incomplete-switch")
private DisplayInteger getListAndRender(ForgeDirection side, Gas gas)
{
if(gas == null || gas.getIcon() == null)
{
return null;
}
if(cachedGasses.containsKey(side) && cachedGasses.get(side).containsKey(gas))
{
return cachedGasses.get(side).get(gas);
}
Model3D toReturn = new Model3D();
toReturn.baseBlock = Block.waterStill;
toReturn.setTexture(gas.getIcon());
DisplayInteger display = DisplayInteger.createAndStart();
if(cachedGasses.containsKey(side))
{
cachedGasses.get(side).put(gas, display);
}
else {
HashMap<Gas, DisplayInteger> map = new HashMap<Gas, DisplayInteger>();
map.put(gas, display);
cachedGasses.put(side, map);
}
switch(side)
{
case NORTH:
{
toReturn.minX = 0.125 + offset;
toReturn.minY = 0.0625 + offset;
toReturn.minZ = 0.3125 + offset;
toReturn.maxX = 0.5 - offset;
toReturn.maxY = 0.9375 - offset;
toReturn.maxZ = 0.6875 - offset;
break;
}
case SOUTH:
{
toReturn.minX = 0.5 + offset;
toReturn.minY = 0.0625 + offset;
toReturn.minZ = 0.3125 + offset;
toReturn.maxX = 0.875 - offset;
toReturn.maxY = 0.9375 - offset;
toReturn.maxZ = 0.6875 - offset;
break;
}
case WEST:
{
toReturn.minX = 0.3125 + offset;
toReturn.minY = 0.0625 + offset;
toReturn.minZ = 0.5 + offset;
toReturn.maxX = 0.6875 - offset;
toReturn.maxY = 0.9375 - offset;
toReturn.maxZ = 0.875 - offset;
break;
}
case EAST:
{
toReturn.minX = 0.3125 + offset;
toReturn.minY = 0.0625 + offset;
toReturn.minZ = 0.125 + offset;
toReturn.maxX = 0.6875 - offset;
toReturn.maxY = 0.9375 - offset;
toReturn.maxZ = 0.5 - offset;
break;
}
}
MekanismRenderer.renderObject(toReturn);
display.endList();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
return display;
}
private void pop()
{
GL11.glPopAttrib();
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);
}
}

View file

@ -27,7 +27,7 @@ public class ItemDust extends ItemMekanism
@Override
public void registerIcons(IconRegister register)
{
for(int i = 0; i <= 9; i++)
for(int i = 0; i <= 10; i++)
{
icons[i] = register.registerIcon("mekanism:" + en_USNames[i] + "Dust");
}
@ -42,7 +42,7 @@ public class ItemDust extends ItemMekanism
@Override
public void getSubItems(int id, CreativeTabs tabs, List itemList)
{
for(int counter = 0; counter <= 9; ++counter)
for(int counter = 0; counter <= 10; ++counter)
{
itemList.add(new ItemStack(this, 1, counter));
}

View file

@ -278,7 +278,6 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement
nbtTags.setBoolean("isActive", isActive);
nbtTags.setInteger("controlType", controlType.ordinal());
System.out.println("reading");
nbtTags.setCompoundTag("leftTank", leftTank.write(new NBTTagCompound()));
nbtTags.setCompoundTag("rightTank", rightTank.write(new NBTTagCompound()));
nbtTags.setCompoundTag("centerTank", centerTank.write(new NBTTagCompound()));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB