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

View file

@ -8,11 +8,9 @@ import net.minecraft.client.model.ModelRenderer;
@SuppressWarnings("unused")
public class PlaneRenderer extends ModelRenderer {
public boolean mirrory;
public boolean mirrorz;
public boolean mirrory, mirrorz;
private int textureOffsetX;
private int textureOffsetY;
private int textureOffsetX, textureOffsetY;
public PlaneRenderer(ModelBase model) {
super(model);
@ -30,7 +28,7 @@ public class PlaneRenderer extends ModelRenderer {
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));
}