Make the tank-type renderers reset their DisplayLists on texture reload.
This will prevent missing-texture/wrong-texture weirdness when changing texturepacks in-world. Also noticed that two old render classes from my first rewrite of transmitter rendering are now unused, so deleted them.
This commit is contained in:
parent
99a5702de9
commit
c21404dd2d
7 changed files with 35 additions and 274 deletions
|
@ -1,105 +0,0 @@
|
|||
package mekanism.client.model;
|
||||
|
||||
import net.minecraft.client.model.PositionTextureVertex;
|
||||
import net.minecraft.client.model.TexturedQuad;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelBoxSelectiveFace
|
||||
{
|
||||
private PositionTextureVertex[] vertexPositions;
|
||||
|
||||
private TexturedQuad[] quadList;
|
||||
|
||||
public final float posX1;
|
||||
public final float posY1;
|
||||
public final float posZ1;
|
||||
|
||||
public final float posX2;
|
||||
public final float posY2;
|
||||
public final float posZ2;
|
||||
|
||||
public ModelBoxSelectiveFace(ModelRendererSelectiveFace modelRenderer, int textureOffsetU, int textureOffsetV, float xMin, float yMin, float zMin, int xSize, int ySize, int zSize, float scaleFactor)
|
||||
{
|
||||
posX1 = xMin;
|
||||
posY1 = yMin;
|
||||
posZ1 = zMin;
|
||||
|
||||
posX2 = xMin + xSize;
|
||||
posY2 = yMin + ySize;
|
||||
posZ2 = zMin + zSize;
|
||||
|
||||
vertexPositions = new PositionTextureVertex[8];
|
||||
|
||||
quadList = new TexturedQuad[6];
|
||||
|
||||
float xMax = xMin + xSize;
|
||||
float yMax = yMin + ySize;
|
||||
float zMax = zMin + zSize;
|
||||
|
||||
xMin -= scaleFactor;
|
||||
yMin -= scaleFactor;
|
||||
zMin -= scaleFactor;
|
||||
|
||||
xMax += scaleFactor;
|
||||
yMax += scaleFactor;
|
||||
zMax += scaleFactor;
|
||||
|
||||
if(modelRenderer.mirror)
|
||||
{
|
||||
float placeholder = xMax;
|
||||
xMax = xMin;
|
||||
xMin = placeholder;
|
||||
}
|
||||
|
||||
PositionTextureVertex positiontexturevertex0 = new PositionTextureVertex(xMin, yMin, zMin, 0.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(xMax, yMin, zMin, 0.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(xMax, yMax, zMin, 8.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(xMin, yMax, zMin, 8.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(xMin, yMin, zMax, 0.0F, 0.0F);
|
||||
PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(xMax, yMin, zMax, 0.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(xMax, yMax, zMax, 8.0F, 8.0F);
|
||||
PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(xMin, yMax, zMax, 8.0F, 0.0F);
|
||||
|
||||
vertexPositions[0] = positiontexturevertex0;
|
||||
vertexPositions[1] = positiontexturevertex1;
|
||||
vertexPositions[2] = positiontexturevertex2;
|
||||
vertexPositions[3] = positiontexturevertex3;
|
||||
vertexPositions[4] = positiontexturevertex4;
|
||||
vertexPositions[5] = positiontexturevertex5;
|
||||
vertexPositions[6] = positiontexturevertex6;
|
||||
vertexPositions[7] = positiontexturevertex7;
|
||||
|
||||
quadList[0] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex2, positiontexturevertex3, positiontexturevertex7, positiontexturevertex6}, textureOffsetU + zSize + xSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize + xSize, textureOffsetV, modelRenderer.textureWidth, modelRenderer.textureHeight);
|
||||
quadList[1] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex5, positiontexturevertex4, positiontexturevertex0, positiontexturevertex1}, textureOffsetU + zSize, textureOffsetV, textureOffsetU + zSize + xSize, textureOffsetV + zSize, modelRenderer.textureWidth, modelRenderer.textureHeight);
|
||||
quadList[2] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex4, positiontexturevertex5, positiontexturevertex6, positiontexturevertex7}, textureOffsetU + zSize + xSize + zSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize + zSize + xSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight);
|
||||
quadList[3] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex1, positiontexturevertex0, positiontexturevertex3, positiontexturevertex2}, textureOffsetU + zSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight);
|
||||
quadList[4] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex0, positiontexturevertex4, positiontexturevertex7, positiontexturevertex3}, textureOffsetU, textureOffsetV + zSize, textureOffsetU + zSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight);
|
||||
quadList[5] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex5, positiontexturevertex1, positiontexturevertex2, positiontexturevertex6}, textureOffsetU + zSize + xSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize + zSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight);
|
||||
|
||||
if(modelRenderer.mirror)
|
||||
{
|
||||
for(int quad = 0; quad < quadList.length; quad++)
|
||||
{
|
||||
quadList[quad].flipFace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(Tessellator tessellator, boolean[] skippedFaces, float scaleFactor)
|
||||
{
|
||||
if(skippedFaces.length == quadList.length)
|
||||
{
|
||||
for(int i = 0; i < skippedFaces.length; ++i)
|
||||
{
|
||||
if(!skippedFaces[i])
|
||||
{
|
||||
quadList[i].draw(tessellator, scaleFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
package mekanism.client.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.client.render.MekanismRenderer.BooleanArray;
|
||||
import mekanism.client.render.MekanismRenderer.DisplayInteger;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelRendererSelectiveFace
|
||||
{
|
||||
public float textureWidth;
|
||||
public float textureHeight;
|
||||
|
||||
public float offsetX;
|
||||
public float offsetY;
|
||||
public float offsetZ;
|
||||
|
||||
public float rotationPointX;
|
||||
public float rotationPointY;
|
||||
public float rotationPointZ;
|
||||
|
||||
public float rotateAngleX;
|
||||
public float rotateAngleY;
|
||||
public float rotateAngleZ;
|
||||
|
||||
public boolean mirror;
|
||||
public boolean showModel;
|
||||
public boolean isHidden;
|
||||
|
||||
public List<ModelBoxSelectiveFace> cubeList = new ArrayList<ModelBoxSelectiveFace>();
|
||||
|
||||
private int textureOffsetX;
|
||||
private int textureOffsetY;
|
||||
|
||||
private ModelBase baseModel;
|
||||
|
||||
private Map<BooleanArray, DisplayInteger> displayLists = new HashMap<BooleanArray, DisplayInteger>();
|
||||
|
||||
|
||||
public ModelRendererSelectiveFace(ModelBase modelBase)
|
||||
{
|
||||
textureWidth = 64.0F;
|
||||
textureHeight = 32.0F;
|
||||
showModel = true;
|
||||
baseModel = modelBase;
|
||||
|
||||
setTextureSize(modelBase.textureWidth, modelBase.textureHeight);
|
||||
}
|
||||
|
||||
public ModelRendererSelectiveFace(ModelBase modelBase, int offsetX, int offsetY)
|
||||
{
|
||||
this(modelBase);
|
||||
setTextureOffset(offsetX, offsetY);
|
||||
}
|
||||
|
||||
public ModelRendererSelectiveFace setTextureOffset(int offsetX, int offsetY)
|
||||
{
|
||||
textureOffsetX = offsetX;
|
||||
textureOffsetY = offsetY;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModelRendererSelectiveFace addBox(float minX, float minY, float minZ, int sizeX, int sizeY, int sizeZ)
|
||||
{
|
||||
cubeList.add(new ModelBoxSelectiveFace(this, textureOffsetX, textureOffsetY, minX, minY, minZ, sizeX, sizeY, sizeZ, 0.0F));
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setRotationPoint(float pointX, float pointY, float pointZ)
|
||||
{
|
||||
rotationPointX = pointX;
|
||||
rotationPointY = pointY;
|
||||
rotationPointZ = pointZ;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(boolean[] dontRender, float scaleFactor)
|
||||
{
|
||||
if(!isHidden)
|
||||
{
|
||||
if(showModel)
|
||||
{
|
||||
DisplayInteger currentDisplayList = displayLists.get(new BooleanArray(dontRender));
|
||||
|
||||
if(currentDisplayList == null)
|
||||
{
|
||||
currentDisplayList = compileDisplayList(dontRender, scaleFactor);
|
||||
}
|
||||
|
||||
GL11.glTranslatef(offsetX, offsetY, offsetZ);
|
||||
|
||||
int i;
|
||||
|
||||
if(rotateAngleX == 0.0F && rotateAngleY == 0.0F && rotateAngleZ == 0.0F)
|
||||
{
|
||||
if(rotationPointX == 0.0F && rotationPointY == 0.0F && rotationPointZ == 0.0F)
|
||||
{
|
||||
currentDisplayList.render();
|
||||
}
|
||||
else {
|
||||
GL11.glTranslatef(rotationPointX * scaleFactor, rotationPointY * scaleFactor, rotationPointZ * scaleFactor);
|
||||
currentDisplayList.render();
|
||||
GL11.glTranslatef(-rotationPointX * scaleFactor, -rotationPointY * scaleFactor, -rotationPointZ * scaleFactor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(rotationPointX * scaleFactor, rotationPointY * scaleFactor, rotationPointZ * scaleFactor);
|
||||
|
||||
if(rotateAngleZ != 0.0F)
|
||||
{
|
||||
GL11.glRotatef(rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(rotateAngleY != 0.0F)
|
||||
{
|
||||
GL11.glRotatef(rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if(rotateAngleX != 0.0F)
|
||||
{
|
||||
GL11.glRotatef(rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
currentDisplayList.render();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-offsetX, -offsetY, -offsetZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private DisplayInteger compileDisplayList(boolean[] dontRender, float scaleFactor)
|
||||
{
|
||||
DisplayInteger displayList = DisplayInteger.createAndStart();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
for(int i = 0; i < cubeList.size(); ++i)
|
||||
{
|
||||
cubeList.get(i).render(tessellator, dontRender, scaleFactor);
|
||||
}
|
||||
|
||||
displayList.endList();
|
||||
displayLists.put(new BooleanArray(dontRender), displayList);
|
||||
|
||||
return displayList;
|
||||
}
|
||||
|
||||
public ModelRendererSelectiveFace setTextureSize(int sizeX, int sizeY)
|
||||
{
|
||||
textureWidth = sizeX;
|
||||
textureHeight = sizeY;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,9 @@ import mekanism.api.gas.Gas;
|
|||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.OreGas;
|
||||
import mekanism.client.render.tileentity.RenderConfigurableMachine;
|
||||
import mekanism.client.render.tileentity.RenderDynamicTank;
|
||||
import mekanism.client.render.tileentity.RenderPortableTank;
|
||||
import mekanism.client.render.tileentity.RenderSalinationController;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.base.ISpecialBounds;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
@ -105,6 +108,14 @@ public class MekanismRenderer
|
|||
}
|
||||
|
||||
FluidRegistry.getFluid("brine").setIcons(event.map.registerIcon("mekanism:LiquidBrine"));
|
||||
|
||||
if(RenderPartTransmitter.getInstance() != null)
|
||||
{
|
||||
RenderPartTransmitter.getInstance().resetDisplayInts();
|
||||
}
|
||||
RenderDynamicTank.resetDisplayInts();
|
||||
RenderSalinationController.resetDisplayInts();
|
||||
RenderPortableTank.resetDisplayInts();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -728,4 +728,10 @@ public class RenderPartTransmitter implements IIconSelfRegister
|
|||
|
||||
return display;
|
||||
}
|
||||
|
||||
public void resetDisplayInts()
|
||||
{
|
||||
cachedLiquids.clear();
|
||||
cachedOverlays.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import mekanism.api.Coord4D;
|
|||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.render.MekanismRenderer.DisplayInteger;
|
||||
import mekanism.client.render.MekanismRenderer.Model3D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.content.tank.TankUpdateProtocol;
|
||||
import mekanism.common.content.tank.SynchronizedTankData.ValveData;
|
||||
import mekanism.common.tile.TileEntityDynamicTank;
|
||||
|
@ -358,4 +359,10 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
|
|||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
public static void resetDisplayInts()
|
||||
{
|
||||
cachedCenterFluids.clear();
|
||||
cachedValveFluids.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,4 +193,10 @@ public class RenderPortableTank extends TileEntitySpecialRenderer
|
|||
|
||||
return displays;
|
||||
}
|
||||
|
||||
public static void resetDisplayInts()
|
||||
{
|
||||
cachedCenterFluids.clear();
|
||||
cachedValveFluids.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,4 +204,9 @@ public class RenderSalinationController extends TileEntitySpecialRenderer
|
|||
((SalinationRenderData)data).side == side;
|
||||
}
|
||||
}
|
||||
|
||||
public static void resetDisplayInts()
|
||||
{
|
||||
cachedCenterFluids.clear();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue