From fe0559b0b936ec51d2a2ff1a934771477b306650 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 21 Oct 2019 19:34:55 -0400 Subject: [PATCH] added cuboid --- .../kaptainwutax/seedcracker/render/Cube.java | 33 ++---------- .../seedcracker/render/Cuboid.java | 51 +++++++++++++++++++ 2 files changed, 54 insertions(+), 30 deletions(-) create mode 100644 src/main/java/kaptainwutax/seedcracker/render/Cuboid.java diff --git a/src/main/java/kaptainwutax/seedcracker/render/Cube.java b/src/main/java/kaptainwutax/seedcracker/render/Cube.java index 41bb376..5c734a2 100644 --- a/src/main/java/kaptainwutax/seedcracker/render/Cube.java +++ b/src/main/java/kaptainwutax/seedcracker/render/Cube.java @@ -2,13 +2,9 @@ package kaptainwutax.seedcracker.render; import net.minecraft.client.util.math.Vector4f; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; -public class Cube extends Renderer { - - public BlockPos pos; - public Vector4f color; - - private Line[] edges = new Line[12]; +public class Cube extends Cuboid { public Cube() { this(BlockPos.ORIGIN, new Vector4f(1.0f, 1.0f, 1.0f, 1.0f)); @@ -19,30 +15,7 @@ public class Cube extends Renderer { } public Cube(BlockPos pos, Vector4f color) { - this.pos = pos; - this.color = color; - this.edges[0] = new Line(toVec3d(pos), toVec3d(pos.add(1, 0, 0)), this.color); - this.edges[1] = new Line(toVec3d(pos), toVec3d(pos.add(0, 1, 0)), this.color); - this.edges[2] = new Line(toVec3d(pos), toVec3d(pos.add(0, 0, 1)), this.color); - this.edges[3] = new Line(toVec3d(pos.add(1, 0, 1)), toVec3d(pos.add(1, 0, 0)), this.color); - this.edges[4] = new Line(toVec3d(pos.add(1, 0, 1)), toVec3d(pos.add(1, 1, 1)), this.color); - this.edges[5] = new Line(toVec3d(pos.add(1, 0, 1)), toVec3d(pos.add(0, 0, 1)), this.color); - this.edges[6] = new Line(toVec3d(pos.add(1, 1, 0)), toVec3d(pos.add(1, 0, 0)), this.color); - this.edges[7] = new Line(toVec3d(pos.add(1, 1, 0)), toVec3d(pos.add(0, 1, 0)), this.color); - this.edges[8] = new Line(toVec3d(pos.add(1, 1, 0)), toVec3d(pos.add(1, 1, 1)), this.color); - this.edges[9] = new Line(toVec3d(pos.add(0, 1, 1)), toVec3d(pos.add(0, 0, 1)), this.color); - this.edges[10] = new Line(toVec3d(pos.add(0, 1, 1)), toVec3d(pos.add(0, 1, 0)), this.color); - this.edges[11] = new Line(toVec3d(pos.add(0, 1, 1)), toVec3d(pos.add(1, 1, 1)), this.color); - } - - @Override - public void render() { - if(this.pos == null || this.color == null || this.edges == null)return; - - for(Line edge: this.edges) { - if(edge == null)continue; - edge.render(); - } + super(pos, new Vec3i(1, 1, 1), color); } } diff --git a/src/main/java/kaptainwutax/seedcracker/render/Cuboid.java b/src/main/java/kaptainwutax/seedcracker/render/Cuboid.java new file mode 100644 index 0000000..3b17648 --- /dev/null +++ b/src/main/java/kaptainwutax/seedcracker/render/Cuboid.java @@ -0,0 +1,51 @@ +package kaptainwutax.seedcracker.render; + +import net.minecraft.client.util.math.Vector4f; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; + +public class Cuboid extends Renderer { + + public BlockPos start; + public Vec3i size; + public Vector4f color; + + private Line[] edges = new Line[12]; + + public Cuboid() { + this(BlockPos.ORIGIN, BlockPos.ORIGIN, new Vector4f(1.0f, 1.0f, 1.0f, 1.0f)); + } + + public Cuboid(BlockPos pos) { + this(pos, new BlockPos(1, 1, 1), new Vector4f(1.0f, 1.0f, 1.0f, 1.0f)); + } + + public Cuboid(BlockPos start, Vec3i size, Vector4f color) { + this.start = start; + this.size = size; + this.color = color; + this.edges[0] = new Line(toVec3d(this.start), toVec3d(this.start.add(this.size.getX(), 0, 0)), this.color); + this.edges[1] = new Line(toVec3d(this.start), toVec3d(this.start.add(0, this.size.getY(), 0)), this.color); + this.edges[2] = new Line(toVec3d(this.start), toVec3d(this.start.add(0, 0, this.size.getZ())), this.color); + this.edges[3] = new Line(toVec3d(this.start.add(this.size.getX(), 0, this.size.getZ())), toVec3d(this.start.add(this.size.getX(), 0, 0)), this.color); + this.edges[4] = new Line(toVec3d(this.start.add(this.size.getX(), 0, this.size.getZ())), toVec3d(this.start.add(this.size.getX(), this.size.getY(), this.size.getZ())), this.color); + this.edges[5] = new Line(toVec3d(this.start.add(this.size.getX(), 0, this.size.getZ())), toVec3d(this.start.add(0, 0, this.size.getZ())), this.color); + this.edges[6] = new Line(toVec3d(this.start.add(this.size.getX(), this.size.getY(), 0)), toVec3d(this.start.add(this.size.getX(), 0, 0)), this.color); + this.edges[7] = new Line(toVec3d(this.start.add(this.size.getX(), this.size.getY(), 0)), toVec3d(this.start.add(0, this.size.getY(), 0)), this.color); + this.edges[8] = new Line(toVec3d(this.start.add(this.size.getX(), this.size.getY(), 0)), toVec3d(this.start.add(this.size.getX(), this.size.getY(), this.size.getZ())), this.color); + this.edges[9] = new Line(toVec3d(this.start.add(0, this.size.getY(), this.size.getZ())), toVec3d(this.start.add(0, 0, this.size.getZ())), this.color); + this.edges[10] = new Line(toVec3d(this.start.add(0, this.size.getY(), this.size.getZ())), toVec3d(this.start.add(0, this.size.getY(), 0)), this.color); + this.edges[11] = new Line(toVec3d(this.start.add(0, this.size.getY(), this.size.getZ())), toVec3d(this.start.add(this.size.getX(), this.size.getY(), this.size.getZ())), this.color); + } + + @Override + public void render() { + if(this.start == null || this.size == null || this.color == null || this.edges == null)return; + + for(Line edge: this.edges) { + if(edge == null)continue; + edge.render(); + } + } + +}