Make the transmitters' internal renders look a bit nicer (hopefully also a bit
faster). Framework is in place to change transparency of energy in cables but the client-side ones don't know what they're doing yet.
This commit is contained in:
parent
c642792cb6
commit
04e7fdcf23
6 changed files with 309 additions and 191 deletions
|
@ -45,7 +45,7 @@ public class MekanismRenderer
|
|||
|
||||
public Icon[] textures = new Icon[6];
|
||||
|
||||
public boolean[] renderSides = new boolean[] {true, true, true, true, true, true};
|
||||
public boolean[] renderSides = new boolean[] {true, true, true, true, true, true, false};
|
||||
|
||||
public Block baseBlock = Block.sand;
|
||||
|
||||
|
@ -306,6 +306,39 @@ public class MekanismRenderer
|
|||
return null;
|
||||
}
|
||||
|
||||
public static class BooleanArray
|
||||
{
|
||||
private final boolean[] boolArray;
|
||||
|
||||
public BooleanArray(boolean[] array)
|
||||
{
|
||||
boolArray = array.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if(o instanceof BooleanArray)
|
||||
{
|
||||
return Arrays.equals(boolArray, ((BooleanArray)o).boolArray);
|
||||
}
|
||||
else if(o instanceof boolean[])
|
||||
{
|
||||
return Arrays.equals(boolArray, (boolean[])o);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Arrays.hashCode(boolArray);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getPartialTicks()
|
||||
{
|
||||
try {
|
||||
|
|
|
@ -8,6 +8,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.client.MekanismRenderer.BooleanArray;
|
||||
import mekanism.client.MekanismRenderer.DisplayInteger;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.TextureOffset;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
|
@ -35,7 +37,7 @@ public class ModelRendererSelectiveFace
|
|||
private int textureOffsetX;
|
||||
private int textureOffsetY;
|
||||
private ModelBase baseModel;
|
||||
private Map<BooleanArray, Integer> displayLists = new HashMap<BooleanArray, Integer>();
|
||||
private Map<BooleanArray, DisplayInteger> displayLists = new HashMap<BooleanArray, DisplayInteger>();
|
||||
|
||||
|
||||
public ModelRendererSelectiveFace(ModelBase modelBase)
|
||||
|
@ -80,7 +82,7 @@ public class ModelRendererSelectiveFace
|
|||
{
|
||||
if (showModel)
|
||||
{
|
||||
Integer currentDisplayList = displayLists.get(new BooleanArray(dontRender));
|
||||
DisplayInteger currentDisplayList = displayLists.get(new BooleanArray(dontRender));
|
||||
if (currentDisplayList == null)
|
||||
{
|
||||
currentDisplayList = compileDisplayList(dontRender, scaleFactor);
|
||||
|
@ -93,12 +95,12 @@ public class ModelRendererSelectiveFace
|
|||
{
|
||||
if (rotationPointX == 0.0F && rotationPointY == 0.0F && rotationPointZ == 0.0F)
|
||||
{
|
||||
GL11.glCallList(currentDisplayList);
|
||||
currentDisplayList.render();
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glTranslatef(rotationPointX * scaleFactor, rotationPointY * scaleFactor, rotationPointZ * scaleFactor);
|
||||
GL11.glCallList(currentDisplayList);
|
||||
currentDisplayList.render();
|
||||
GL11.glTranslatef(-rotationPointX * scaleFactor, -rotationPointY * scaleFactor, -rotationPointZ * scaleFactor);
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +124,7 @@ public class ModelRendererSelectiveFace
|
|||
GL11.glRotatef(rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
GL11.glCallList(currentDisplayList);
|
||||
currentDisplayList.render();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
@ -132,10 +134,9 @@ public class ModelRendererSelectiveFace
|
|||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private int compileDisplayList(boolean[] dontRender, float scaleFactor)
|
||||
private DisplayInteger compileDisplayList(boolean[] dontRender, float scaleFactor)
|
||||
{
|
||||
int displayList = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displayList, GL11.GL_COMPILE);
|
||||
DisplayInteger displayList = DisplayInteger.createAndStart();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
for (int i = 0; i < cubeList.size(); ++i)
|
||||
|
@ -143,7 +144,7 @@ public class ModelRendererSelectiveFace
|
|||
cubeList.get(i).render(tessellator, dontRender, scaleFactor);
|
||||
}
|
||||
|
||||
GL11.glEndList();
|
||||
displayList.endList();
|
||||
displayLists.put(new BooleanArray(dontRender), displayList);
|
||||
return displayList;
|
||||
}
|
||||
|
@ -154,39 +155,4 @@ public class ModelRendererSelectiveFace
|
|||
textureHeight = (float)sizeY;
|
||||
return this;
|
||||
}
|
||||
|
||||
private class BooleanArray
|
||||
{
|
||||
private final boolean[] boolArray;
|
||||
|
||||
public BooleanArray(boolean[] array)
|
||||
{
|
||||
boolArray = array.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if(o instanceof BooleanArray)
|
||||
{
|
||||
return Arrays.equals(boolArray, ((BooleanArray)o).boolArray);
|
||||
}
|
||||
else if(o instanceof boolean[])
|
||||
{
|
||||
return Arrays.equals(boolArray, (boolean[])o);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Arrays.hashCode(boolArray);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package mekanism.client;
|
|||
|
||||
import java.util.HashMap;
|
||||
|
||||
import mekanism.client.MekanismRenderer.DisplayInteger;
|
||||
import mekanism.client.MekanismRenderer.Model3D;
|
||||
import mekanism.common.MekanismUtils;
|
||||
import mekanism.common.MekanismUtils.ResourceType;
|
||||
|
@ -26,7 +27,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
|||
{
|
||||
private ModelTransmitter model = new ModelTransmitter();
|
||||
|
||||
private HashMap<ForgeDirection, HashMap<Fluid, int[]>> cachedLiquids = new HashMap<ForgeDirection, HashMap<Fluid, int[]>>();
|
||||
private HashMap<ForgeDirection, HashMap<Fluid, DisplayInteger[]>> cachedLiquids = new HashMap<ForgeDirection, HashMap<Fluid, DisplayInteger[]>>();
|
||||
|
||||
private static final int stages = 40;
|
||||
|
||||
|
@ -73,20 +74,20 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
|||
{
|
||||
if(connectable[i])
|
||||
{
|
||||
int[] displayList = getListAndRender(ForgeDirection.getOrientation(i), tileEntity.refFluid.getFluid());
|
||||
DisplayInteger[] displayLists = getListAndRender(ForgeDirection.getOrientation(i), tileEntity.refFluid.getFluid());
|
||||
|
||||
if(displayList != null)
|
||||
if(displayLists != null)
|
||||
{
|
||||
GL11.glCallList(displayList[Math.max(3, (int)((float)tileEntity.fluidScale*(stages-1)))]);
|
||||
displayLists[Math.max(3, (int)((float)tileEntity.fluidScale*(stages-1)))].render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int[] displayList = getListAndRender(ForgeDirection.UNKNOWN, tileEntity.refFluid.getFluid());
|
||||
DisplayInteger[] displayLists = getListAndRender(ForgeDirection.UNKNOWN, tileEntity.refFluid.getFluid());
|
||||
|
||||
if(displayList != null)
|
||||
if(displayLists != null)
|
||||
{
|
||||
GL11.glCallList(displayList[Math.max(3, (int)((float)tileEntity.fluidScale*(stages-1)))]);
|
||||
displayLists[Math.max(3, (int)((float)tileEntity.fluidScale*(stages-1)))].render();
|
||||
}
|
||||
|
||||
if(tileEntity.refFluid.getFluid() == FluidRegistry.LAVA)
|
||||
|
@ -114,7 +115,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
|||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
private int[] getListAndRender(ForgeDirection side, Fluid fluid)
|
||||
private DisplayInteger[] getListAndRender(ForgeDirection side, Fluid fluid)
|
||||
{
|
||||
if(side == null || fluid == null || fluid.getIcon() == null)
|
||||
{
|
||||
|
@ -130,14 +131,17 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
|||
toReturn.baseBlock = Block.waterStill;
|
||||
toReturn.setTexture(fluid.getIcon());
|
||||
|
||||
int[] displays = new int[stages];
|
||||
toReturn.setSideRender(side, false);
|
||||
toReturn.setSideRender(side.getOpposite(), false);
|
||||
|
||||
DisplayInteger[] displays = new DisplayInteger[stages];
|
||||
|
||||
if(cachedLiquids.containsKey(side))
|
||||
{
|
||||
cachedLiquids.get(side).put(fluid, displays);
|
||||
}
|
||||
else {
|
||||
HashMap<Fluid, int[]> map = new HashMap<Fluid, int[]>();
|
||||
HashMap<Fluid, DisplayInteger[]> map = new HashMap<Fluid, DisplayInteger[]>();
|
||||
map.put(fluid, displays);
|
||||
cachedLiquids.put(side, map);
|
||||
}
|
||||
|
@ -146,8 +150,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
|||
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
displays[i] = DisplayInteger.createAndStart();
|
||||
|
||||
switch(side)
|
||||
{
|
||||
|
@ -231,7 +234,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
|||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
GL11.glEndList();
|
||||
DisplayInteger.endList();
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
|
|
@ -7,6 +7,7 @@ import mekanism.api.EnumGas;
|
|||
import mekanism.api.GasTransmission;
|
||||
import mekanism.api.ITubeConnection;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.client.MekanismRenderer.BooleanArray;
|
||||
import mekanism.client.MekanismRenderer.DisplayInteger;
|
||||
import mekanism.client.MekanismRenderer.Model3D;
|
||||
import mekanism.common.MekanismUtils;
|
||||
|
@ -29,7 +30,10 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
{
|
||||
private ModelTransmitter model = new ModelTransmitter();
|
||||
|
||||
private HashMap<ForgeDirection, HashMap<EnumGas, DisplayInteger>> cachedGasses = new HashMap<ForgeDirection, HashMap<EnumGas, DisplayInteger>>();
|
||||
private boolean[] connectable;
|
||||
|
||||
private HashMap<ForgeDirection, HashMap<EnumGas, DisplayInteger>> cachedSideGasses = new HashMap<ForgeDirection, HashMap<EnumGas, DisplayInteger>>();
|
||||
private HashMap<BooleanArray, HashMap<EnumGas, DisplayInteger>> cachedCenterGasses = new HashMap<BooleanArray, HashMap<EnumGas, DisplayInteger>>();
|
||||
|
||||
private static final double offset = 0.015;
|
||||
|
||||
|
@ -48,7 +52,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
|
||||
boolean[] connectable = new boolean[] {false, false, false, false, false, false};
|
||||
connectable = new boolean[] {false, false, false, false, false, false};
|
||||
|
||||
ITubeConnection[] connections = GasTransmission.getConnections(tileEntity);
|
||||
|
||||
|
@ -124,14 +128,12 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
{
|
||||
if(connectable[i])
|
||||
{
|
||||
int displayList = getListAndRender(ForgeDirection.getOrientation(i), tileEntity.refGas).display;
|
||||
GL11.glCallList(displayList);
|
||||
getListAndRender(ForgeDirection.getOrientation(i), tileEntity.refGas).render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int displayList = getListAndRender(ForgeDirection.UNKNOWN, tileEntity.refGas).display;
|
||||
GL11.glCallList(displayList);
|
||||
getListAndRender(ForgeDirection.UNKNOWN, tileEntity.refGas).render();
|
||||
|
||||
pop();
|
||||
}
|
||||
|
@ -155,43 +157,70 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
|
||||
private DisplayInteger getListAndRender(ForgeDirection side, EnumGas type)
|
||||
{
|
||||
if(cachedGasses.containsKey(side) && cachedGasses.get(side).containsKey(type))
|
||||
if(side == ForgeDirection.UNKNOWN)
|
||||
{
|
||||
return cachedGasses.get(side).get(type);
|
||||
if(cachedCenterGasses.containsKey(side) && cachedCenterGasses.get(side).containsKey(type))
|
||||
{
|
||||
return cachedCenterGasses.get(new BooleanArray(connectable)).get(type);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.7 - offset;
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
|
||||
for(ForgeDirection face : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
toReturn.setSideRender(face, !connectable[face.ordinal()]);
|
||||
}
|
||||
|
||||
DisplayInteger display = DisplayInteger.createAndStart();
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
DisplayInteger.endList();
|
||||
|
||||
if(cachedCenterGasses.containsKey(side))
|
||||
{
|
||||
cachedCenterGasses.get(side).put(type, display);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
Model3D toReturn = new Model3D();
|
||||
toReturn.baseBlock = Block.waterStill;
|
||||
toReturn.setTexture(type.gasIcon);
|
||||
|
||||
DisplayInteger display = new DisplayInteger();
|
||||
toReturn.setSideRender(side, false);
|
||||
toReturn.setSideRender(side.getOpposite(), false);
|
||||
|
||||
if(cachedGasses.containsKey(side))
|
||||
DisplayInteger display = DisplayInteger.createAndStart();
|
||||
|
||||
if(cachedSideGasses.containsKey(side))
|
||||
{
|
||||
cachedGasses.get(side).put(type, display);
|
||||
cachedSideGasses.get(side).put(type, display);
|
||||
}
|
||||
else {
|
||||
HashMap<EnumGas, DisplayInteger> map = new HashMap<EnumGas, DisplayInteger>();
|
||||
map.put(type, display);
|
||||
cachedGasses.put(side, map);
|
||||
cachedSideGasses.put(side, map);
|
||||
}
|
||||
|
||||
display.display = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(display.display, 4864);
|
||||
|
||||
|
||||
switch(side)
|
||||
{
|
||||
case UNKNOWN:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.7 - offset;
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
break;
|
||||
}
|
||||
case DOWN:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
|
@ -206,7 +235,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
case UP:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 - offset;
|
||||
toReturn.minY = 0.7 - offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
|
@ -261,7 +290,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
|
|||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
GL11.glEndList();
|
||||
DisplayInteger.endList();
|
||||
|
||||
return display;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package mekanism.client;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.client.MekanismRenderer.BooleanArray;
|
||||
import mekanism.client.MekanismRenderer.DisplayInteger;
|
||||
import mekanism.client.MekanismRenderer.Model3D;
|
||||
import mekanism.common.CableUtils;
|
||||
import mekanism.common.Mekanism;
|
||||
|
@ -7,6 +12,7 @@ import mekanism.common.MekanismUtils;
|
|||
import mekanism.common.TileEntityUniversalCable;
|
||||
import mekanism.common.MekanismUtils.ResourceType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
|
@ -21,12 +27,19 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class RenderUniversalCable extends TileEntitySpecialRenderer
|
||||
{
|
||||
private ModelTransmitter model = new ModelTransmitter();
|
||||
private static ModelTransmitter model = new ModelTransmitter();
|
||||
|
||||
private Icon renderIcon = MekanismRenderer.getTextureMap(1).registerIcon("mekanism:LiquidEnergy");
|
||||
private static Icon renderIcon = MekanismRenderer.getTextureMap(1).registerIcon("mekanism:LiquidEnergy");
|
||||
|
||||
private static Model3D[] energy = null;
|
||||
|
||||
private static Map<ForgeDirection, DisplayInteger> sideDisplayLists = new HashMap<ForgeDirection, DisplayInteger>();
|
||||
private static Map<BooleanArray, DisplayInteger> centerDisplayLists = new HashMap<BooleanArray, DisplayInteger>();
|
||||
|
||||
private static final double offset = 0.015;
|
||||
|
||||
private boolean[] connectable;
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
|
||||
{
|
||||
|
@ -41,7 +54,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
|
|||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
|
||||
boolean[] connectable = CableUtils.getConnections(tileEntity);
|
||||
connectable = CableUtils.getConnections(tileEntity);
|
||||
|
||||
model.renderCenter(connectable);
|
||||
for(int i = 0; i < 6; i++)
|
||||
|
@ -51,30 +64,44 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
|
|||
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(Mekanism.fancyUniversalCableRender)
|
||||
|
||||
if(tileEntity.getEnergyScale() <= 0 || !Mekanism.fancyUniversalCableRender)
|
||||
{
|
||||
push();
|
||||
MekanismRenderer.glowOn();
|
||||
|
||||
func_110628_a(MekanismUtils.getResource(ResourceType.TEXTURE_ITEMS, "LiquidEnergy.png"));
|
||||
GL11.glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectable[i])
|
||||
{
|
||||
renderEnergy(ForgeDirection.getOrientation(i));
|
||||
}
|
||||
}
|
||||
|
||||
renderEnergy(ForgeDirection.UNKNOWN);
|
||||
|
||||
MekanismRenderer.glowOff();
|
||||
pop();
|
||||
return;
|
||||
}
|
||||
|
||||
push();
|
||||
|
||||
MekanismRenderer.glowOn();
|
||||
GL11.glColor4f(1.F, 1.F, 1.F, tileEntity.getEnergyScale());
|
||||
func_110628_a(MekanismUtils.getResource(ResourceType.TEXTURE_ITEMS, "LiquidEnergy.png"));
|
||||
GL11.glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
if(energy == null)
|
||||
{
|
||||
energy = assignEnergy();
|
||||
}
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectable[i])
|
||||
{
|
||||
renderEnergy(ForgeDirection.getOrientation(i));
|
||||
}
|
||||
}
|
||||
|
||||
renderEnergy(ForgeDirection.UNKNOWN);
|
||||
|
||||
MekanismRenderer.glowOff();
|
||||
pop();
|
||||
}
|
||||
|
||||
private void renderEnergy(ForgeDirection side)
|
||||
{
|
||||
DisplayInteger list = getDisplayList(side);
|
||||
list.render();
|
||||
}
|
||||
|
||||
private void pop()
|
||||
{
|
||||
GL11.glPopAttrib();
|
||||
|
@ -91,93 +118,147 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
|
|||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
private void renderEnergy(ForgeDirection side)
|
||||
private static Model3D[] assignEnergy()
|
||||
{
|
||||
Model3D toReturn = new Model3D();
|
||||
toReturn.baseBlock = Block.waterStill;
|
||||
toReturn.setTexture(renderIcon);
|
||||
Model3D[] energyArray = new Model3D[7];
|
||||
Model3D centerModel = new Model3D();
|
||||
centerModel.baseBlock = Block.waterStill;
|
||||
centerModel.setTexture(renderIcon);
|
||||
|
||||
switch(side)
|
||||
centerModel.minX = 0.3 + offset;
|
||||
centerModel.minY = 0.3 + offset;
|
||||
centerModel.minZ = 0.3 + offset;
|
||||
|
||||
centerModel.maxX = 0.7 - offset;
|
||||
centerModel.maxY = 0.7 - offset;
|
||||
centerModel.maxZ = 0.7 - offset;
|
||||
|
||||
energyArray[ForgeDirection.UNKNOWN.ordinal()] = centerModel;
|
||||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
case UNKNOWN:
|
||||
Model3D toReturn = new Model3D();
|
||||
toReturn.baseBlock = Block.waterStill;
|
||||
toReturn.setTexture(renderIcon);
|
||||
|
||||
toReturn.setSideRender(side, false);
|
||||
toReturn.setSideRender(side.getOpposite(), false);
|
||||
|
||||
switch(side)
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.7 - offset;
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
break;
|
||||
}
|
||||
case DOWN:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.0;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.3 + offset;
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
break;
|
||||
}
|
||||
case UP:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.7 - offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 1.0;
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
break;
|
||||
}
|
||||
case NORTH:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.0;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.7 - offset;
|
||||
toReturn.maxZ = 0.3 + offset;
|
||||
break;
|
||||
}
|
||||
case SOUTH:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.7 - offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.7 - offset;
|
||||
toReturn.maxZ = 1.0;
|
||||
break;
|
||||
}
|
||||
case WEST:
|
||||
{
|
||||
toReturn.minX = 0.0;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.3 + offset;
|
||||
toReturn.maxY = 0.7 - offset;
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
break;
|
||||
}
|
||||
case EAST:
|
||||
{
|
||||
toReturn.minX = 0.7 - offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 1.0;
|
||||
toReturn.maxY = 0.7 - offset;
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
break;
|
||||
case DOWN:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.0;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.3 + offset;
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
break;
|
||||
}
|
||||
case UP:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.7 - offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 1.0;
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
break;
|
||||
}
|
||||
case NORTH:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.0;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.7 - offset;
|
||||
toReturn.maxZ = 0.3 + offset;
|
||||
break;
|
||||
}
|
||||
case SOUTH:
|
||||
{
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.7 - offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.7 - offset;
|
||||
toReturn.maxZ = 1.0;
|
||||
break;
|
||||
}
|
||||
case WEST:
|
||||
{
|
||||
toReturn.minX = 0.0;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.3 + offset;
|
||||
toReturn.maxY = 0.7 - offset;
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
break;
|
||||
}
|
||||
case EAST:
|
||||
{
|
||||
toReturn.minX = 0.7 - offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 1.0;
|
||||
toReturn.maxY = 0.7 - offset;
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
energyArray[side.ordinal()] = toReturn;
|
||||
}
|
||||
return energyArray;
|
||||
}
|
||||
|
||||
private DisplayInteger getDisplayList(ForgeDirection side)
|
||||
{
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
DisplayInteger newDisplayList;
|
||||
|
||||
Model3D toRender = energy[side.ordinal()];
|
||||
if(side == ForgeDirection.UNKNOWN)
|
||||
{
|
||||
newDisplayList = centerDisplayLists.get(new BooleanArray(connectable));
|
||||
if(newDisplayList != null)
|
||||
{
|
||||
return newDisplayList;
|
||||
}
|
||||
|
||||
for(ForgeDirection face : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
toRender.setSideRender(face, !connectable[face.ordinal()]);
|
||||
}
|
||||
|
||||
newDisplayList = DisplayInteger.createAndStart();
|
||||
|
||||
MekanismRenderer.renderObject(toRender);
|
||||
|
||||
newDisplayList.endList();
|
||||
centerDisplayLists.put(new BooleanArray(connectable), newDisplayList);
|
||||
}
|
||||
else {
|
||||
newDisplayList = sideDisplayLists.get(side);
|
||||
if(newDisplayList != null)
|
||||
{
|
||||
return newDisplayList;
|
||||
}
|
||||
|
||||
newDisplayList = DisplayInteger.createAndStart();
|
||||
|
||||
MekanismRenderer.renderObject(toRender);
|
||||
|
||||
newDisplayList.endList();
|
||||
sideDisplayLists.put(side, newDisplayList);
|
||||
}
|
||||
return newDisplayList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,12 @@ public class TileEntityUniversalCable extends TileEntity implements IUniversalCa
|
|||
return getNetwork(true);
|
||||
}
|
||||
|
||||
public float getEnergyScale()
|
||||
{
|
||||
//TODO: Let the client know how much power's being transferred
|
||||
return 1.F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnergyNetwork getNetwork(boolean createIfNull)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue