From 2534053305c44e52152cfaaa663490def499b6c4 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 26 Jan 2019 10:21:17 +0200 Subject: [PATCH] Fixed crash due to undefined classes when MineLP is not present --- .../com/minelittlepony/util/render/Box.java | 36 +++++++++++++++++++ .../com/minelittlepony/util/render/Quad.java | 9 +++++ .../minelittlepony/util/render/Vertex.java | 19 ++++++++++ 3 files changed, 64 insertions(+) create mode 100644 src/main/java/com/minelittlepony/util/render/Box.java create mode 100644 src/main/java/com/minelittlepony/util/render/Quad.java create mode 100644 src/main/java/com/minelittlepony/util/render/Vertex.java diff --git a/src/main/java/com/minelittlepony/util/render/Box.java b/src/main/java/com/minelittlepony/util/render/Box.java new file mode 100644 index 00000000..0c4ad8f6 --- /dev/null +++ b/src/main/java/com/minelittlepony/util/render/Box.java @@ -0,0 +1,36 @@ +package com.minelittlepony.util.render; + +import net.minecraft.client.model.ModelBox; +import net.minecraft.client.model.ModelRenderer; + +public abstract class Box extends ModelBox { + + protected final T parent; + + public Box(T renderer, int texU, int texV, float x, float y, float z, int dx, int dy, int dz, float delta) { + super(renderer, texU, texV, x, y, z, dx, dy, dz, delta); + parent = renderer; + } + + public Box(T renderer, int texU, int texV, float x, float y, float z, int dx, int dy, int dz, float delta, boolean mirror) { + super(renderer, texU, texV, x, y, z, dx, dy, dz, delta, mirror); + parent = renderer; + } + + /** + * Creates a new vertex mapping the given (x, y, z) coordinates to a texture offset. + */ + protected Vertex vert(float x, float y, float z, int texX, int texY) { + return new Vertex(x, y, z, texX, texY); + } + + /** + * Creates a new quad with the given spacial vertices. + */ + protected Quad quad(int startX, int width, int startY, int height, Vertex ...verts) { + return new Quad(verts, + startX, startY, + startX + width, startY + height, + parent.textureWidth, parent.textureHeight); + } +} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/util/render/Quad.java b/src/main/java/com/minelittlepony/util/render/Quad.java new file mode 100644 index 00000000..d508dc37 --- /dev/null +++ b/src/main/java/com/minelittlepony/util/render/Quad.java @@ -0,0 +1,9 @@ +package com.minelittlepony.util.render; + +import net.minecraft.client.model.TexturedQuad; + +public class Quad extends TexturedQuad { + Quad(Vertex[] vertices, int texcoordU1, int texcoordV1, int texcoordU2, int texcoordV2, float textureWidth, float textureHeight) { + super(vertices, texcoordU1, texcoordV1, texcoordU2, texcoordV2, textureWidth, textureHeight); + } +} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/util/render/Vertex.java b/src/main/java/com/minelittlepony/util/render/Vertex.java new file mode 100644 index 00000000..e7704ad9 --- /dev/null +++ b/src/main/java/com/minelittlepony/util/render/Vertex.java @@ -0,0 +1,19 @@ +package com.minelittlepony.util.render; + +import net.minecraft.client.model.PositionTextureVertex; + +public class Vertex extends PositionTextureVertex { + + public Vertex(float x, float y, float z, float texX, float texY) { + super(x, y, z, texX, texY); + } + + private Vertex(Vertex old, float texX, float texY) { + super(old, texX, texY); + } + + @Override + public Vertex setTexturePosition(float texX, float texY) { + return new Vertex(this, texX, texY); + } +}