diff --git a/java/net/minecraft/util/Vec3i.java b/java/net/minecraft/util/Vec3i.java index c31a3e1..cc672cd 100644 --- a/java/net/minecraft/util/Vec3i.java +++ b/java/net/minecraft/util/Vec3i.java @@ -6,8 +6,6 @@ import com.google.common.base.Objects; public class Vec3i implements Comparable { - /** The Null vector constant (0, 0, 0) */ - public static final Vec3i NULL_VECTOR = new Vec3i(0, 0, 0); /** X coordinate */ private final int x; /** Y coordinate */ @@ -15,16 +13,26 @@ public class Vec3i implements Comparable /** Z coordinate */ private final int z; + /** Double X coordinate */ + private final double xd; + /** Double Y coordinate */ + private final double yd; + /** Double Z coordinate */ + private final double zd; + public Vec3i(int xIn, int yIn, int zIn) { - this.x = xIn; - this.y = yIn; - this.z = zIn; + this((double) xIn, (double) yIn, (double) zIn); } public Vec3i(double xIn, double yIn, double zIn) { - this(MathHelper.floor_double(xIn), MathHelper.floor_double(yIn), MathHelper.floor_double(zIn)); + this.x = MathHelper.floor_double(xIn); + this.y = MathHelper.floor_double(yIn); + this.z = MathHelper.floor_double(zIn); + this.xd = xIn; + this.yd = yIn; + this.zd = zIn; } public boolean equals(Object p_equals_1_) @@ -39,8 +47,8 @@ public class Vec3i implements Comparable } else { - Vec3i vec3i = (Vec3i)p_equals_1_; - return this.getX() != vec3i.getX() ? false : (this.getY() != vec3i.getY() ? false : this.getZ() == vec3i.getZ()); + Vec3i vec3I = (Vec3i)p_equals_1_; + return this.getX() != vec3I.getX() ? false : (this.getY() != vec3I.getY() ? false : this.getZ() == vec3I.getZ()); } } @@ -78,42 +86,37 @@ public class Vec3i implements Comparable return this.z; } + + /** + * Get the X coordinate as a double + */ + public double getXD() + { + return this.xd; + } + + /** + * Get the Y coordinate as a double + */ + public double getYD() + { + return this.yd; + } + + /** + * Get the Z coordinate as a double + */ + public double getZD() + { + return this.zd; + } + /** * Calculate the cross product of this and the given Vector */ public Vec3i crossProduct(Vec3i vec) { - return new Vec3i(this.getY() * vec.getZ() - this.getZ() * vec.getY(), this.getZ() * vec.getX() - this.getX() * vec.getZ(), this.getX() * vec.getY() - this.getY() * vec.getX()); - } - - /** - * Calculate squared distance to the given coordinates - */ - public double distanceSq(double toX, double toY, double toZ) - { - double d0 = (double)this.getX() - toX; - double d1 = (double)this.getY() - toY; - double d2 = (double)this.getZ() - toZ; - return d0 * d0 + d1 * d1 + d2 * d2; - } - - /** - * Compute square of distance from point x, y, z to center of this Block - */ - public double distanceSqToCenter(double xIn, double yIn, double zIn) - { - double d0 = (double)this.getX() + 0.5D - xIn; - double d1 = (double)this.getY() + 0.5D - yIn; - double d2 = (double)this.getZ() + 0.5D - zIn; - return d0 * d0 + d1 * d1 + d2 * d2; - } - - /** - * Calculate squared distance to the given Vector - */ - public double distanceSq(Vec3i to) - { - return this.distanceSq((double)to.getX(), (double)to.getY(), (double)to.getZ()); + return new Vec3i(this.getYD() * vec.getZD() - this.getZD() * vec.getYD(), this.getZD() * vec.getXD() - this.getXD() * vec.getZD(), this.getXD() * vec.getYD() - this.getYD() * vec.getXD()); } public String toString() diff --git a/java/net/minecraft/util/math/BlockPos.java b/java/net/minecraft/util/math/BlockPos.java index f1904b4..be39f1f 100644 --- a/java/net/minecraft/util/math/BlockPos.java +++ b/java/net/minecraft/util/math/BlockPos.java @@ -12,8 +12,6 @@ import org.apache.logging.log4j.Logger; import com.google.common.collect.AbstractIterator; import com.google.common.collect.Lists; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.util.EnumFacing; import net.minecraft.util.MathHelper; @@ -53,7 +51,7 @@ public class BlockPos extends Vec3i public BlockPos(Vec3i source) { - this(source.getX(), source.getY(), source.getZ()); + this(source.getXD(), source.getYD(), source.getZD()); } /** @@ -61,7 +59,7 @@ public class BlockPos extends Vec3i */ public BlockPos add(double x, double y, double z) { - return x == 0.0D && y == 0.0D && z == 0.0D ? this : new BlockPos((double)this.getX() + x, (double)this.getY() + y, (double)this.getZ() + z); + return x == 0.0D && y == 0.0D && z == 0.0D ? this : new BlockPos(this.getXD() + x, this.getYD() + y, this.getZD() + z); } /** @@ -69,7 +67,7 @@ public class BlockPos extends Vec3i */ public BlockPos add(int x, int y, int z) { - return x == 0 && y == 0 && z == 0 ? this : new BlockPos(this.getX() + x, this.getY() + y, this.getZ() + z); + return x == 0 && y == 0 && z == 0 ? this : new BlockPos(this.getXD() + x, this.getYD() + y, this.getZD() + z); } /** @@ -77,15 +75,7 @@ public class BlockPos extends Vec3i */ public BlockPos add(Vec3i vec) { - return vec.getX() == 0 && vec.getY() == 0 && vec.getZ() == 0 ? this : new BlockPos(this.getX() + vec.getX(), this.getY() + vec.getY(), this.getZ() + vec.getZ()); - } - - /** - * Subtract the given Vector from this BlockPos - */ - public BlockPos subtract(Vec3i vec) - { - return vec.getX() == 0 && vec.getY() == 0 && vec.getZ() == 0 ? this : new BlockPos(this.getX() - vec.getX(), this.getY() - vec.getY(), this.getZ() - vec.getZ()); + return vec.getXD() == 0 && vec.getYD() == 0 && vec.getZD() == 0 ? this : new BlockPos(this.getXD() + vec.getXD(), this.getYD() + vec.getYD(), this.getZD() + vec.getZD()); } /** @@ -99,7 +89,7 @@ public class BlockPos extends Vec3i /** * Offset this BlockPos n blocks up */ - public BlockPos up(int n) + public BlockPos up(double n) { return this.offset(EnumFacing.UP, n); } @@ -115,7 +105,7 @@ public class BlockPos extends Vec3i /** * Offset this BlockPos n blocks down */ - public BlockPos down(int n) + public BlockPos down(double n) { return this.offset(EnumFacing.DOWN, n); } @@ -131,7 +121,7 @@ public class BlockPos extends Vec3i /** * Offset this BlockPos n blocks in northern direction */ - public BlockPos north(int n) + public BlockPos north(double n) { return this.offset(EnumFacing.NORTH, n); } @@ -147,7 +137,7 @@ public class BlockPos extends Vec3i /** * Offset this BlockPos n blocks in southern direction */ - public BlockPos south(int n) + public BlockPos south(double n) { return this.offset(EnumFacing.SOUTH, n); } @@ -163,7 +153,7 @@ public class BlockPos extends Vec3i /** * Offset this BlockPos n blocks in western direction */ - public BlockPos west(int n) + public BlockPos west(double n) { return this.offset(EnumFacing.WEST, n); } @@ -179,7 +169,7 @@ public class BlockPos extends Vec3i /** * Offset this BlockPos n blocks in eastern direction */ - public BlockPos east(int n) + public BlockPos east(double n) { return this.offset(EnumFacing.EAST, n); } @@ -195,9 +185,9 @@ public class BlockPos extends Vec3i /** * Offsets this BlockPos n blocks in the given direction */ - public BlockPos offset(EnumFacing facing, int n) + public BlockPos offset(EnumFacing facing, double n) { - return n == 0 ? this : new BlockPos(this.getX() + facing.getFrontOffsetX() * n, this.getY() + facing.getFrontOffsetY() * n, this.getZ() + facing.getFrontOffsetZ() * n); + return n == 0 ? this : new BlockPos(this.getXD() + facing.getFrontOffsetX() * n, this.getYD() + facing.getFrontOffsetY() * n, this.getZD() + facing.getFrontOffsetZ() * n); } /** @@ -205,7 +195,7 @@ public class BlockPos extends Vec3i */ public BlockPos crossProduct(Vec3i vec) { - return new BlockPos(this.getY() * vec.getZ() - this.getZ() * vec.getY(), this.getZ() * vec.getX() - this.getX() * vec.getZ(), this.getX() * vec.getY() - this.getY() * vec.getX()); + return new BlockPos(this.getYD() * vec.getZD() - this.getZD() * vec.getYD(), this.getZD() * vec.getXD() - this.getXD() * vec.getZD(), this.getXD() * vec.getYD() - this.getYD() * vec.getXD()); } /** @@ -283,76 +273,6 @@ public class BlockPos extends Vec3i }; } - /** - * Returns a version of this BlockPos that is guaranteed to be immutable. - * - *

When storing a BlockPos given to you for an extended period of time, make sure you - * use this in case the value is changed internally.

- */ - public BlockPos toImmutable() - { - return this; - } - - /** - * Like getAllInBox but reuses a single MutableBlockPos instead. If this method is used, the resulting BlockPos - * instances can only be used inside the iteration loop. - */ - public static Iterable getAllInBoxMutable(BlockPos from, BlockPos to) - { - final BlockPos blockpos = new BlockPos(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()), Math.min(from.getZ(), to.getZ())); - final BlockPos blockpos1 = new BlockPos(Math.max(from.getX(), to.getX()), Math.max(from.getY(), to.getY()), Math.max(from.getZ(), to.getZ())); - return new Iterable() - { - public Iterator iterator() - { - return new AbstractIterator() - { - private BlockPos.MutableBlockPos theBlockPos = null; - protected BlockPos.MutableBlockPos computeNext() - { - if (this.theBlockPos == null) - { - this.theBlockPos = new BlockPos.MutableBlockPos(blockpos.getX(), blockpos.getY(), blockpos.getZ()); - return this.theBlockPos; - } - else if (this.theBlockPos.equals(blockpos1)) - { - return (BlockPos.MutableBlockPos)this.endOfData(); - } - else - { - int i = this.theBlockPos.getX(); - int j = this.theBlockPos.getY(); - int k = this.theBlockPos.getZ(); - - if (i < blockpos1.getX()) - { - ++i; - } - else if (j < blockpos1.getY()) - { - i = blockpos.getX(); - ++j; - } - else if (k < blockpos1.getZ()) - { - i = blockpos.getX(); - j = blockpos.getY(); - ++k; - } - - this.theBlockPos.x = i; - this.theBlockPos.y = j; - this.theBlockPos.z = k; - return this.theBlockPos; - } - } - }; - } - }; - } - public static class MutableBlockPos extends BlockPos { /** Mutable X Coordinate */ @@ -420,12 +340,6 @@ public class BlockPos extends Vec3i return this.setPos(MathHelper.floor_double(p_189532_1_), MathHelper.floor_double(p_189532_3_), MathHelper.floor_double(p_189532_5_)); } - @SideOnly(Side.CLIENT) - public BlockPos.MutableBlockPos setPos(Entity p_189535_1_) - { - return this.setPos(p_189535_1_.posX, p_189535_1_.posY, p_189535_1_.posZ); - } - public BlockPos.MutableBlockPos setPos(Vec3i p_189533_1_) { return this.setPos(p_189533_1_.getX(), p_189533_1_.getY(), p_189533_1_.getZ()); @@ -478,12 +392,6 @@ public class BlockPos extends Vec3i return retain(MathHelper.floor_double(xIn), MathHelper.floor_double(yIn), MathHelper.floor_double(zIn)); } - @SideOnly(Side.CLIENT) - public static BlockPos.PooledMutableBlockPos retain(Vec3i vec) - { - return retain(vec.getX(), vec.getY(), vec.getZ()); - } - public static BlockPos.PooledMutableBlockPos retain(int xIn, int yIn, int zIn) { synchronized (POOL) @@ -528,12 +436,6 @@ public class BlockPos extends Vec3i return (BlockPos.PooledMutableBlockPos)super.setPos(xIn, yIn, zIn); } - @SideOnly(Side.CLIENT) - public BlockPos.PooledMutableBlockPos set(Entity p_189537_1_) - { - return (BlockPos.PooledMutableBlockPos)super.setPos(p_189537_1_); - } - public BlockPos.PooledMutableBlockPos set(double xIn, double yIn, double zIn) { return (BlockPos.PooledMutableBlockPos)super.setPos(xIn, yIn, zIn); diff --git a/java/noppes/npcs/api/IPos.java b/java/noppes/npcs/api/IPos.java index d3ce689..1a8155c 100644 --- a/java/noppes/npcs/api/IPos.java +++ b/java/noppes/npcs/api/IPos.java @@ -8,12 +8,19 @@ package noppes.npcs.api; import net.minecraft.util.math.BlockPos; public interface IPos { + int getX(); int getY(); int getZ(); + double getXD(); + + double getYD(); + + double getZD(); + /** * Shifts the IPos up by 1 block and returns the new object. * @@ -25,7 +32,7 @@ public interface IPos { * @param n The number of blocks to move the position up by. * @return The new IPos object. */ - IPos up(int n); + IPos up(double n); /** * Shifts the IPos down by 1 block and returns the new object. @@ -38,7 +45,7 @@ public interface IPos { * @param n The number of blocks to move the position down by. * @return The new IPos object. */ - IPos down(int n); + IPos down(double n); /** * Shifts the IPos north by 1 block and returns the new object. @@ -51,7 +58,7 @@ public interface IPos { * @param n The number of blocks to move the position north by. * @return The new IPos object. */ - IPos north(int n); + IPos north(double n); /** * Shifts the IPos east by 1 block and returns the new object. @@ -64,7 +71,7 @@ public interface IPos { * @param n The number of blocks to move the position east by. * @return The new IPos object. */ - IPos east(int n); + IPos east(double n); /** * Shifts the IPos south by 1 block and returns the new object. @@ -77,7 +84,7 @@ public interface IPos { * @param n The number of blocks to move the position south by. * @return The new IPos object. */ - IPos south(int n); + IPos south(double n); /** * Shifts the IPos west by 1 block and returns the new object. @@ -90,7 +97,7 @@ public interface IPos { * @param n The number of blocks to move the position west by. * @return The new IPos object. */ - IPos west(int n); + IPos west(double n); /** * Adds the IPos' coordinates by each of the parameters given. @@ -100,7 +107,7 @@ public interface IPos { * @param z Z coordinate amount to be added * @return The resulting IPos from the addition. */ - IPos add(int x, int y, int z); + IPos add(double x, double y, double z); /** * Directly adds the coordinates of two IPos objects and returns the resulting IPos sum. @@ -120,7 +127,7 @@ public interface IPos { * @param z Z coordinate amount to be subtracted * @return The resulting IPos from the subtraction. */ - IPos subtract(int x, int y, int z); + IPos subtract(double x, double y, double z); /** * Directly subtracts the coordinates of two IPos objects and returns the resulting IPos difference. @@ -152,13 +159,13 @@ public interface IPos { * Offsets the block by n blocks in the given direction and returns the resulting IPos object * */ - IPos offset(int direction, int n); + IPos offset(int direction, double n); - IPos crossProduct(int x, int y, int z); + IPos crossProduct(double x, double y, double z); IPos crossProduct(IPos pos); - IPos divide(float scalar); + IPos divide(double scalar); long toLong(); diff --git a/java/noppes/npcs/api/entity/IEntity.java b/java/noppes/npcs/api/entity/IEntity.java index 799344f..e90cdc1 100644 --- a/java/noppes/npcs/api/entity/IEntity.java +++ b/java/noppes/npcs/api/entity/IEntity.java @@ -315,7 +315,7 @@ public interface IEntity { */ void knockback(int power, float direction); - void knockback(int xpower, int ypower, int zpower, float direction); + void knockback(double xpower, double ypower, double zpower, float direction); void knockback(IPos pos, float direction); void setImmune(int ticks);