From d92b0a6a311e307ef52f930b3153a077d2cae29d Mon Sep 17 00:00:00 2001 From: Chicken-Bomes Date: Fri, 16 Jan 2015 18:33:29 +1000 Subject: [PATCH] Potentially breaking change to InventoryRange constructor Added some new methods to CuboidCoord Removed unused methods from RayTracer --- build/build.properties | 2 +- .../lib/inventory/InventoryRange.java | 4 +- src/codechicken/lib/raytracer/RayTracer.java | 41 ------- src/codechicken/lib/vec/CuboidCoord.java | 103 ++++++++---------- 4 files changed, 50 insertions(+), 100 deletions(-) diff --git a/build/build.properties b/build/build.properties index 481366a..27f3785 100644 --- a/build/build.properties +++ b/build/build.properties @@ -1,3 +1,3 @@ minecraft_version=1.7.10 forge_version=10.13.0.1151 -mod_version=1.1.1 +mod_version=1.1.3 diff --git a/src/codechicken/lib/inventory/InventoryRange.java b/src/codechicken/lib/inventory/InventoryRange.java index f3d8c2d..9622325 100644 --- a/src/codechicken/lib/inventory/InventoryRange.java +++ b/src/codechicken/lib/inventory/InventoryRange.java @@ -36,10 +36,10 @@ public class InventoryRange this(inv, 0); } - public InventoryRange(IInventory inv, int fslot, int lslot) + public InventoryRange(IInventory inv, int fslot, int size) { this.inv = inv; - slots = new int[lslot-fslot]; + slots = new int[size]; for(int i = 0; i < slots.length; i++) slots[i] = fslot+i; } diff --git a/src/codechicken/lib/raytracer/RayTracer.java b/src/codechicken/lib/raytracer/RayTracer.java index 12d9d49..d648699 100644 --- a/src/codechicken/lib/raytracer/RayTracer.java +++ b/src/codechicken/lib/raytracer/RayTracer.java @@ -107,30 +107,6 @@ public class RayTracer return mop; } - public MovingObjectPosition rayTraceCuboid(Vector3 start, Vector3 end, Cuboid6 cuboid, BlockCoord pos) - { - MovingObjectPosition mop = rayTraceCuboid(start, end, cuboid); - if(mop != null) - { - mop.typeOfHit = MovingObjectType.BLOCK; - mop.blockX = pos.x; - mop.blockY = pos.y; - mop.blockZ = pos.z; - } - return mop; - } - - public MovingObjectPosition rayTraceCuboid(Vector3 start, Vector3 end, Cuboid6 cuboid, Entity e) - { - MovingObjectPosition mop = rayTraceCuboid(start, end, cuboid); - if(mop != null) - { - mop.typeOfHit = MovingObjectType.ENTITY; - mop.entityHit = e; - } - return mop; - } - public MovingObjectPosition rayTraceCuboids(Vector3 start, Vector3 end, List cuboids) { double c_dist = Double.MAX_VALUE; @@ -166,23 +142,6 @@ public class RayTracer return mop; } - public void rayTraceCuboids(Vector3 start, Vector3 end, List cuboids, BlockCoord pos, Block block, List hitList) - { - for(IndexedCuboid6 cuboid : cuboids) - { - MovingObjectPosition mop = rayTraceCuboid(start, end, cuboid); - if(mop != null) - { - ExtendedMOP emop = new ExtendedMOP(mop, cuboid.data, s_dist); - emop.typeOfHit = MovingObjectType.BLOCK; - emop.blockX = pos.x; - emop.blockY = pos.y; - emop.blockZ = pos.z; - hitList.add(emop); - } - } - } - public static MovingObjectPosition retraceBlock(World world, EntityPlayer player, int x, int y, int z) { Block block = world.getBlock(x, y, z); diff --git a/src/codechicken/lib/vec/CuboidCoord.java b/src/codechicken/lib/vec/CuboidCoord.java index a3c598a..ef05e75 100644 --- a/src/codechicken/lib/vec/CuboidCoord.java +++ b/src/codechicken/lib/vec/CuboidCoord.java @@ -10,30 +10,25 @@ public class CuboidCoord implements Iterable, Copyable public BlockCoord min; public BlockCoord max; - public CuboidCoord() - { + public CuboidCoord() { min = new BlockCoord(); max = new BlockCoord(); } - public CuboidCoord(BlockCoord min, BlockCoord max) - { + public CuboidCoord(BlockCoord min, BlockCoord max) { this.min = min; this.max = max; } - - public CuboidCoord(BlockCoord coord) - { + + public CuboidCoord(BlockCoord coord) { this(coord, coord.copy()); } - public CuboidCoord(int[] ia) - { + public CuboidCoord(int[] ia) { this(ia[0], ia[1], ia[2], ia[3], ia[4], ia[5]); } - public CuboidCoord(int x1, int y1, int z1, int x2, int y2, int z2) - { + public CuboidCoord(int x1, int y1, int z1, int x2, int y2, int z2) { this(new BlockCoord(x1, y1, z1), new BlockCoord(x2, y2, z2)); } @@ -47,19 +42,28 @@ public class CuboidCoord implements Iterable, Copyable return this; } - public CuboidCoord expand(int side, int amount) - { - if(side%2 == 0)//negative side + public CuboidCoord expand(int side, int amount) { + if (side % 2 == 0)//negative side min = min.offset(side, amount); else max = max.offset(side, amount); return this; } + + public CuboidCoord offset(BlockCoord b) { + min.add(b); + max.add(b); + return this; + } + + public CuboidCoord offset(int x, int y, int z) { + min.add(x, y, z); + max.add(x, y, z); + return this; + } - public int size(int s) - { - switch(s) - { + public int size(int s) { + switch(s) { case 0: case 1: return max.y - min.y+1; @@ -74,10 +78,8 @@ public class CuboidCoord implements Iterable, Copyable } } - public int getSide(int s) - { - switch(s) - { + public int getSide(int s) { + switch(s) { case 0: return min.y; case 1: return max.y; case 2: return min.z; @@ -88,10 +90,8 @@ public class CuboidCoord implements Iterable, Copyable throw new IndexOutOfBoundsException("Switch Falloff"); } - public CuboidCoord setSide(int s, int v) - { - switch(s) - { + public CuboidCoord setSide(int s, int v) { + switch(s) { case 0: min.y = v; break; case 1: max.y = v; break; case 2: min.z = v; break; @@ -103,75 +103,66 @@ public class CuboidCoord implements Iterable, Copyable return this; } - public int getVolume() - { + public int getVolume() { return (max.x-min.x+1)*(max.y-min.y+1)*(max.z-min.z+1); } - public Vector3 getCenterVec() - { + public Vector3 getCenterVec() { return new Vector3(min.x+(max.x-min.x+1)/2D, min.y+(max.y-min.y+1)/2D, min.z+(max.z-min.z+1)/2D); } - public BlockCoord getCenter(BlockCoord store) - { + public BlockCoord getCenter(BlockCoord store) { store.set(min.x+(max.x-min.x)/2, min.y+(max.y-min.y)/2, min.z+(max.z-min.z)/2); return store; } - public boolean contains(BlockCoord coord) - { + public boolean contains(BlockCoord coord) { return contains(coord.x, coord.y, coord.z); } - public boolean contains(int x, int y, int z) - { + public boolean contains(int x, int y, int z) { return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z; } - public int[] intArray() - { + public int[] intArray() { return new int[]{min.x, min.y, min.z, max.x, max.y, max.z}; } - public CuboidCoord copy() - { + public CuboidCoord copy() { return new CuboidCoord(min.copy(), max.copy()); } - public Cuboid6 bounds() - { - return new Cuboid6(min.x, min.y, min.z, max.x+1, max.y+1, max.z+1); + public Cuboid6 bounds() { + return new Cuboid6(min.x, min.y, min.z, max.x + 1, max.y + 1, max.z + 1); } - public AxisAlignedBB toAABB() - { + public AxisAlignedBB toAABB() { return bounds().toAABB(); } - public void set(BlockCoord min, BlockCoord max) - { - this.min.set(min); - this.max.set(max); + public CuboidCoord set(CuboidCoord c) { + return set(c.min, c.max); } - public CuboidCoord set(int x1, int y1, int z1, int x2, int y2, int z2) - { + public CuboidCoord set(BlockCoord min, BlockCoord max) { + this.min.set(min); + this.max.set(max); + return this; + } + + public CuboidCoord set(int x1, int y1, int z1, int x2, int y2, int z2) { min.set(x1, y1, z1); max.set(x2, y2, z2); return this; } public CuboidCoord set(BlockCoord coord) { - min.set(coord); - max.set(coord); - return this; + return set(coord, coord); } - public CuboidCoord set(int[] ia) - { + public CuboidCoord set(int[] ia) { return set(ia[0], ia[1], ia[2], ia[3], ia[4], ia[5]); }