Fixed Top and Bottom planes being reversed causing encorrect lighting on ponies

This commit is contained in:
Sollace 2018-04-25 09:45:41 +02:00
parent 1718868ca4
commit 228c32b4e5
2 changed files with 29 additions and 29 deletions

View file

@ -10,19 +10,17 @@ import javax.annotation.Nonnull;
public class ModelPlane extends ModelBox { public class ModelPlane extends ModelBox {
private TexturedQuad[] quadList; private TexturedQuad quad;
private final Face face;
public ModelPlane(PlaneRenderer renderer, int textureX, int textureY, public boolean hidden = false;
float x, float y, float z, int w, int h, int d,
float scale, Face face) { public ModelPlane(PlaneRenderer renderer, int textureX, int textureY, float x, float y, float z, int w, int h, int d, float scale, Face face) {
super(renderer, textureX, textureY, x, y, z, w, h, d, scale, false); super(renderer, textureX, textureY, x, y, z, w, h, d, scale, false);
this.face = face;
this.quadList = new TexturedQuad[6];
float x2 = x + w; float x2 = x + w;
float y2 = y + h; float y2 = y + h;
float z2 = z + d; float z2 = z + d;
x -= scale; x -= scale;
y -= scale; y -= scale;
z -= scale; z -= scale;
@ -59,53 +57,57 @@ public class ModelPlane extends ModelBox {
PositionTextureVertex eun = new PositionTextureVertex(x2, y2, z2, 8.0F, 8.0F); PositionTextureVertex eun = new PositionTextureVertex(x2, y2, z2, 8.0F, 8.0F);
PositionTextureVertex wun = new PositionTextureVertex(x, y2, z2, 8.0F, 0.0F); PositionTextureVertex wun = new PositionTextureVertex(x, y2, z2, 8.0F, 0.0F);
// east if (face == Face.EAST) {
this.quadList[0] = new TexturedQuad( quad = new TexturedQuad(
new PositionTextureVertex[]{edn, eds, eus, eun}, new PositionTextureVertex[]{edn, eds, eus, eun},
textureX, textureY, textureX, textureY,
textureX + d, textureY + h, textureX + d, textureY + h,
renderer.textureWidth, renderer.textureHeight); renderer.textureWidth, renderer.textureHeight);
// west }
this.quadList[1] = new TexturedQuad( if (face == Face.WEST) {
quad = new TexturedQuad(
new PositionTextureVertex[]{wds, wdn, wun, wus}, new PositionTextureVertex[]{wds, wdn, wun, wus},
textureX, textureY, textureX, textureY,
textureX + d, textureY + h, textureX + d, textureY + h,
renderer.textureWidth, renderer.textureHeight); renderer.textureWidth, renderer.textureHeight);
// down }
this.quadList[3] = new TexturedQuad( if (face == Face.UP) {
quad = new TexturedQuad(
new PositionTextureVertex[]{edn, wdn, wds, eds}, new PositionTextureVertex[]{edn, wdn, wds, eds},
textureX, textureY, textureX, textureY,
textureX + w, textureY + d, textureX + w, textureY + d,
renderer.textureWidth, renderer.textureHeight); renderer.textureWidth, renderer.textureHeight);
// up }
this.quadList[2] = new TexturedQuad( if (face == Face.DOWN) {
quad = new TexturedQuad(
new PositionTextureVertex[]{eus, wus, wun, eun}, new PositionTextureVertex[]{eus, wus, wun, eun},
textureX, textureY, textureX, textureY,
textureX + w, textureY + d, textureX + w, textureY + d,
renderer.textureWidth, renderer.textureHeight); renderer.textureWidth, renderer.textureHeight);
// south }
this.quadList[4] = new TexturedQuad( if (face == Face.SOUTH) {
quad = new TexturedQuad(
new PositionTextureVertex[]{eds, wds, wus, eus}, new PositionTextureVertex[]{eds, wds, wus, eus},
textureX, textureY, textureX, textureY,
textureX + w, textureY + h, textureX + w, textureY + h,
renderer.textureWidth, renderer.textureHeight); renderer.textureWidth, renderer.textureHeight);
// north }
this.quadList[5] = new TexturedQuad( if (face == Face.NORTH) {
quad = new TexturedQuad(
new PositionTextureVertex[]{wdn, edn, eun, wun}, new PositionTextureVertex[]{wdn, edn, eun, wun},
textureX, textureY, textureX, textureY,
textureX + w, textureY + h, textureX + w, textureY + h,
renderer.textureWidth, renderer.textureHeight); renderer.textureWidth, renderer.textureHeight);
}
if (renderer.mirror || renderer.mirrory || renderer.mirrorz) { if (renderer.mirror || renderer.mirrory || renderer.mirrorz) {
for (TexturedQuad texturedquad : this.quadList) { quad.flipFace();
texturedquad.flipFace();
}
} }
} }
@Override @Override
public void render(@Nonnull BufferBuilder renderer, float scale) { public void render(@Nonnull BufferBuilder renderer, float scale) {
this.quadList[this.face.ordinal()].draw(renderer, scale); if (!hidden) this.quad.draw(renderer, scale);
} }
public enum Face { public enum Face {

View file

@ -8,11 +8,9 @@ import net.minecraft.client.model.ModelRenderer;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class PlaneRenderer extends ModelRenderer { public class PlaneRenderer extends ModelRenderer {
public boolean mirrory; public boolean mirrory, mirrorz;
public boolean mirrorz;
private int textureOffsetX; private int textureOffsetX, textureOffsetY;
private int textureOffsetY;
public PlaneRenderer(ModelBase model) { public PlaneRenderer(ModelBase model) {
super(model); super(model);
@ -30,7 +28,7 @@ public class PlaneRenderer extends ModelRenderer {
return this; return this;
} }
public void addPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale, Face face) { private void addPlane(float offX, float offY, float offZ, int width, int height, int depth, float scale, Face face) {
this.cubeList.add(new ModelPlane(this, this.textureOffsetX, this.textureOffsetY, offX, offY, offZ, width, height, depth, scale, face)); this.cubeList.add(new ModelPlane(this, this.textureOffsetX, this.textureOffsetY, offX, offY, offZ, width, height, depth, scale, face));
} }