Full Imports and Code Format Optimization

This commit is contained in:
Kam committed 2025-03-12 20:11:39 -04:00
1 parent c22c5f9d79
commit afb5f1d645
60 files changed
+592 -509

No files matched your search

@@ -2,10 +2,11 @@ package net.minecraft.block.properties;
import java.util.Collection;
/** This code is owned by Minecraft */
/**
* This code is owned by Minecraft
*/
public interface IProperty<T extends Comparable<T>>
{
public interface IProperty<T extends Comparable<T>> {
String getName();
Collection<T> getAllowedValues();
@@ -16,4 +17,4 @@ public interface IProperty<T extends Comparable<T>>
* Get the name for the given value.
*/
String getName(T value);
}
}
@@ -6,10 +6,11 @@ import net.minecraft.block.properties.IProperty;
import java.util.Collection;
/** This code is owned by Minecraft */
/**
* This code is owned by Minecraft
*/
public interface IBlockState
{
public interface IBlockState {
Collection<IProperty> getPropertyNames();
<T extends Comparable<T>> T getValue(IProperty<T> property);
+42 -47
View File
@@ -2,31 +2,42 @@ package net.minecraft.util;
import com.google.common.base.Objects;
/** This code is owned by Minecraft */
/**
* This code is owned by Minecraft
*/
public class Vec3i implements Comparable<Vec3i>
{
/** X coordinate */
public class Vec3i implements Comparable<Vec3i> {
/**
* X coordinate
*/
private final int x;
/** Y coordinate */
/**
* Y coordinate
*/
private final int y;
/** Z coordinate */
/**
* Z coordinate
*/
private final int z;
/** Double X coordinate */
/**
* Double X coordinate
*/
private final double xd;
/** Double Y coordinate */
/**
* Double Y coordinate
*/
private final double yd;
/** Double Z coordinate */
/**
* Double Z coordinate
*/
private final double zd;
public Vec3i(int xIn, int yIn, int zIn)
{
this((double) xIn, (double) yIn, (double) zIn);
public Vec3i(int xIn, int yIn, int zIn) {
this(xIn, yIn, (double) zIn);
}
public Vec3i(double xIn, double yIn, double zIn)
{
public Vec3i(double xIn, double yIn, double zIn) {
this.x = MathHelper.floor_double(xIn);
this.y = MathHelper.floor_double(yIn);
this.z = MathHelper.floor_double(zIn);
@@ -35,54 +46,43 @@ public class Vec3i implements Comparable<Vec3i>
this.zd = zIn;
}
public boolean equals(Object p_equals_1_)
{
if (this == p_equals_1_)
{
public boolean equals(Object p_equals_1_) {
if (this == p_equals_1_) {
return true;
}
else if (!(p_equals_1_ instanceof Vec3i))
{
} else if (!(p_equals_1_ instanceof Vec3i)) {
return false;
}
else
{
Vec3i vec3I = (Vec3i)p_equals_1_;
return this.getX() != vec3I.getX() ? false : (this.getY() != vec3I.getY() ? false : this.getZ() == vec3I.getZ());
} else {
Vec3i vec3I = (Vec3i) p_equals_1_;
return this.getX() == vec3I.getX() && (this.getY() == vec3I.getY() && this.getZ() == vec3I.getZ());
}
}
public int hashCode()
{
public int hashCode() {
return (this.getY() + this.getZ() * 31) * 31 + this.getX();
}
public int compareTo(Vec3i p_compareTo_1_)
{
public int compareTo(Vec3i p_compareTo_1_) {
return this.getY() == p_compareTo_1_.getY() ? (this.getZ() == p_compareTo_1_.getZ() ? this.getX() - p_compareTo_1_.getX() : this.getZ() - p_compareTo_1_.getZ()) : this.getY() - p_compareTo_1_.getY();
}
/**
* Get the X coordinate
*/
public int getX()
{
public int getX() {
return this.x;
}
/**
* Get the Y coordinate
*/
public int getY()
{
public int getY() {
return this.y;
}
/**
* Get the Z coordinate
*/
public int getZ()
{
public int getZ() {
return this.z;
}
@@ -90,37 +90,32 @@ public class Vec3i implements Comparable<Vec3i>
/**
* Get the X coordinate as a double
*/
public double getXD()
{
public double getXD() {
return this.xd;
}
/**
* Get the Y coordinate as a double
*/
public double getYD()
{
public double getYD() {
return this.yd;
}
/**
* Get the Z coordinate as a double
*/
public double getZD()
{
public double getZD() {
return this.zd;
}
/**
* Calculate the cross product of this and the given Vector
*/
public Vec3i crossProduct(Vec3i vec)
{
public Vec3i crossProduct(Vec3i vec) {
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()
{
public String toString() {
return Objects.toStringHelper(this).add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).toString();
}
}
}
+93 -155
View File
@@ -17,245 +17,208 @@ import java.util.List;
* Pasted in from 1.9, with the Vec3d constructor removed
*/
@Immutable
public class BlockPos extends Vec3i
{
public class BlockPos extends Vec3i {
private static final Logger LOGGER = LogManager.getLogger();
/** The BlockPos with all coordinates 0 */
/**
* The BlockPos with all coordinates 0
*/
public static final BlockPos ORIGIN = new BlockPos(0, 0, 0);
private static final int NUM_X_BITS = 26; //1 + MathHelper.calculateLogBaseTwo(MathHelper.roundUpToPowerOfTwo(30000000)); //Manually calculated because of crash
private static final int NUM_Z_BITS = NUM_X_BITS;
private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
private static final int Y_SHIFT = 0 + NUM_Z_BITS;
private static final int Y_SHIFT = NUM_Z_BITS;
private static final int X_SHIFT = Y_SHIFT + NUM_Y_BITS;
private static final long X_MASK = (1L << NUM_X_BITS) - 1L;
private static final long Y_MASK = (1L << NUM_Y_BITS) - 1L;
private static final long Z_MASK = (1L << NUM_Z_BITS) - 1L;
public BlockPos(int x, int y, int z)
{
public BlockPos(int x, int y, int z) {
super(x, y, z);
}
public BlockPos(double x, double y, double z)
{
public BlockPos(double x, double y, double z) {
super(x, y, z);
}
public BlockPos(Entity source)
{
public BlockPos(Entity source) {
this(source.posX, source.posY, source.posZ);
}
public BlockPos(Vec3i source)
{
public BlockPos(Vec3i source) {
this(source.getXD(), source.getYD(), source.getZD());
}
/**
* Add the given coordinates to the coordinates of this BlockPos
*/
public BlockPos add(double x, double y, double z)
{
public BlockPos add(double x, double y, double z) {
return x == 0.0D && y == 0.0D && z == 0.0D ? this : new BlockPos(this.getXD() + x, this.getYD() + y, this.getZD() + z);
}
/**
* Add the given coordinates to the coordinates of this BlockPos
*/
public BlockPos add(int x, int y, int z)
{
public BlockPos add(int x, int y, int z) {
return x == 0 && y == 0 && z == 0 ? this : new BlockPos(this.getXD() + x, this.getYD() + y, this.getZD() + z);
}
/**
* Add the given Vector to this BlockPos
*/
public BlockPos add(Vec3i vec)
{
public BlockPos add(Vec3i vec) {
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());
}
/**
* Offset this BlockPos 1 block up
*/
public BlockPos up()
{
public BlockPos up() {
return this.up(1);
}
/**
* Offset this BlockPos n blocks up
*/
public BlockPos up(double n)
{
public BlockPos up(double n) {
return this.offset(EnumFacing.UP, n);
}
/**
* Offset this BlockPos 1 block down
*/
public BlockPos down()
{
public BlockPos down() {
return this.down(1);
}
/**
* Offset this BlockPos n blocks down
*/
public BlockPos down(double n)
{
public BlockPos down(double n) {
return this.offset(EnumFacing.DOWN, n);
}
/**
* Offset this BlockPos 1 block in northern direction
*/
public BlockPos north()
{
public BlockPos north() {
return this.north(1);
}
/**
* Offset this BlockPos n blocks in northern direction
*/
public BlockPos north(double n)
{
public BlockPos north(double n) {
return this.offset(EnumFacing.NORTH, n);
}
/**
* Offset this BlockPos 1 block in southern direction
*/
public BlockPos south()
{
public BlockPos south() {
return this.south(1);
}
/**
* Offset this BlockPos n blocks in southern direction
*/
public BlockPos south(double n)
{
public BlockPos south(double n) {
return this.offset(EnumFacing.SOUTH, n);
}
/**
* Offset this BlockPos 1 block in western direction
*/
public BlockPos west()
{
public BlockPos west() {
return this.west(1);
}
/**
* Offset this BlockPos n blocks in western direction
*/
public BlockPos west(double n)
{
public BlockPos west(double n) {
return this.offset(EnumFacing.WEST, n);
}
/**
* Offset this BlockPos 1 block in eastern direction
*/
public BlockPos east()
{
public BlockPos east() {
return this.east(1);
}
/**
* Offset this BlockPos n blocks in eastern direction
*/
public BlockPos east(double n)
{
public BlockPos east(double n) {
return this.offset(EnumFacing.EAST, n);
}
/**
* Offset this BlockPos 1 block in the given direction
*/
public BlockPos offset(EnumFacing facing)
{
public BlockPos offset(EnumFacing facing) {
return this.offset(facing, 1);
}
/**
* Offsets this BlockPos n blocks in the given direction
*/
public BlockPos offset(EnumFacing facing, double n)
{
public BlockPos offset(EnumFacing facing, double n) {
return n == 0 ? this : new BlockPos(this.getXD() + facing.getFrontOffsetX() * n, this.getYD() + facing.getFrontOffsetY() * n, this.getZD() + facing.getFrontOffsetZ() * n);
}
/**
* Calculate the cross product of this and the given Vector
*/
public BlockPos crossProduct(Vec3i vec)
{
public BlockPos crossProduct(Vec3i vec) {
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());
}
/**
* Serialize this BlockPos into a long value
*/
public long toLong()
{
return ((long)this.getX() & X_MASK) << X_SHIFT | ((long)this.getY() & Y_MASK) << Y_SHIFT | ((long)this.getZ() & Z_MASK) << 0;
public long toLong() {
return ((long) this.getX() & X_MASK) << X_SHIFT | ((long) this.getY() & Y_MASK) << Y_SHIFT | ((long) this.getZ() & Z_MASK) << 0;
}
/**
* Create a BlockPos from a serialized long value (created by toLong)
*/
public static BlockPos fromLong(long serialized)
{
int i = (int)(serialized << 64 - X_SHIFT - NUM_X_BITS >> 64 - NUM_X_BITS);
int j = (int)(serialized << 64 - Y_SHIFT - NUM_Y_BITS >> 64 - NUM_Y_BITS);
int k = (int)(serialized << 64 - NUM_Z_BITS >> 64 - NUM_Z_BITS);
public static BlockPos fromLong(long serialized) {
int i = (int) (serialized << 64 - X_SHIFT - NUM_X_BITS >> 64 - NUM_X_BITS);
int j = (int) (serialized << 64 - Y_SHIFT - NUM_Y_BITS >> 64 - NUM_Y_BITS);
int k = (int) (serialized << 64 - NUM_Z_BITS >> 64 - NUM_Z_BITS);
return new BlockPos(i, j, k);
}
/**
* Create an Iterable that returns all positions in the box specified by the given corners
*/
public static Iterable<BlockPos> getAllInBox(BlockPos from, BlockPos to)
{
public static Iterable<BlockPos> getAllInBox(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<BlockPos>()
{
public Iterator<BlockPos> iterator()
{
return new AbstractIterator<BlockPos>()
{
return new Iterable<BlockPos>() {
public Iterator<BlockPos> iterator() {
return new AbstractIterator<BlockPos>() {
private BlockPos lastReturned = null;
protected BlockPos computeNext()
{
if (this.lastReturned == null)
{
protected BlockPos computeNext() {
if (this.lastReturned == null) {
this.lastReturned = blockpos;
return this.lastReturned;
}
else if (this.lastReturned.equals(blockpos1))
{
return (BlockPos)this.endOfData();
}
else
{
} else if (this.lastReturned.equals(blockpos1)) {
return this.endOfData();
} else {
int i = this.lastReturned.getX();
int j = this.lastReturned.getY();
int k = this.lastReturned.getZ();
if (i < blockpos1.getX())
{
if (i < blockpos1.getX()) {
++i;
}
else if (j < blockpos1.getY())
{
} else if (j < blockpos1.getY()) {
i = blockpos.getX();
++j;
}
else if (k < blockpos1.getZ())
{
} else if (k < blockpos1.getZ()) {
i = blockpos.getX();
j = blockpos.getY();
++k;
@@ -270,27 +233,29 @@ public class BlockPos extends Vec3i
};
}
public static class MutableBlockPos extends BlockPos
{
/** Mutable X Coordinate */
public static class MutableBlockPos extends BlockPos {
/**
* Mutable X Coordinate
*/
protected int x;
/** Mutable Y Coordinate */
/**
* Mutable Y Coordinate
*/
protected int y;
/** Mutable Z Coordinate */
/**
* Mutable Z Coordinate
*/
protected int z;
public MutableBlockPos()
{
public MutableBlockPos() {
this(0, 0, 0);
}
public MutableBlockPos(BlockPos pos)
{
public MutableBlockPos(BlockPos pos) {
this(pos.getX(), pos.getY(), pos.getZ());
}
public MutableBlockPos(int x_, int y_, int z_)
{
public MutableBlockPos(int x_, int y_, int z_) {
super(0, 0, 0);
this.x = x_;
this.y = y_;
@@ -300,60 +265,51 @@ public class BlockPos extends Vec3i
/**
* Gets the X coordinate.
*/
public int getX()
{
public int getX() {
return this.x;
}
/**
* Gets the Y coordinate.
*/
public int getY()
{
public int getY() {
return this.y;
}
/**
* Gets the Z coordinate.
*/
public int getZ()
{
public int getZ() {
return this.z;
}
/**
* Sets the position, MUST not be name 'set' as that causes obfusication conflicts with func_185343_d
*/
public BlockPos.MutableBlockPos setPos(int xIn, int yIn, int zIn)
{
public BlockPos.MutableBlockPos setPos(int xIn, int yIn, int zIn) {
this.x = xIn;
this.y = yIn;
this.z = zIn;
return this;
}
public BlockPos.MutableBlockPos setPos(double p_189532_1_, double p_189532_3_, double p_189532_5_)
{
public BlockPos.MutableBlockPos setPos(double p_189532_1_, double p_189532_3_, double p_189532_5_) {
return this.setPos(MathHelper.floor_double(p_189532_1_), MathHelper.floor_double(p_189532_3_), MathHelper.floor_double(p_189532_5_));
}
public BlockPos.MutableBlockPos setPos(Vec3i p_189533_1_)
{
public BlockPos.MutableBlockPos setPos(Vec3i p_189533_1_) {
return this.setPos(p_189533_1_.getX(), p_189533_1_.getY(), p_189533_1_.getZ());
}
public BlockPos.MutableBlockPos move(EnumFacing p_189536_1_)
{
public BlockPos.MutableBlockPos move(EnumFacing p_189536_1_) {
return this.move(p_189536_1_, 1);
}
public BlockPos.MutableBlockPos move(EnumFacing p_189534_1_, int p_189534_2_)
{
public BlockPos.MutableBlockPos move(EnumFacing p_189534_1_, int p_189534_2_) {
return this.setPos(this.x + p_189534_1_.getFrontOffsetX() * p_189534_2_, this.y + p_189534_1_.getFrontOffsetY() * p_189534_2_, this.z + p_189534_1_.getFrontOffsetZ() * p_189534_2_);
}
public void setY(int yIn)
{
public void setY(int yIn) {
this.y = yIn;
}
@@ -363,42 +319,33 @@ public class BlockPos extends Vec3i
* <p>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.</p>
*/
public BlockPos toImmutable()
{
public BlockPos toImmutable() {
return new BlockPos(this);
}
}
public static final class PooledMutableBlockPos extends BlockPos.MutableBlockPos
{
public static final class PooledMutableBlockPos extends BlockPos.MutableBlockPos {
private boolean released;
private static final List<BlockPos.PooledMutableBlockPos> POOL = Lists.<BlockPos.PooledMutableBlockPos>newArrayList();
private static final List<BlockPos.PooledMutableBlockPos> POOL = Lists.newArrayList();
private PooledMutableBlockPos(int xIn, int yIn, int zIn)
{
private PooledMutableBlockPos(int xIn, int yIn, int zIn) {
super(xIn, yIn, zIn);
}
public static BlockPos.PooledMutableBlockPos retain()
{
public static BlockPos.PooledMutableBlockPos retain() {
return retain(0, 0, 0);
}
public static BlockPos.PooledMutableBlockPos retain(double xIn, double yIn, double zIn)
{
public static BlockPos.PooledMutableBlockPos retain(double xIn, double yIn, double zIn) {
return retain(MathHelper.floor_double(xIn), MathHelper.floor_double(yIn), MathHelper.floor_double(zIn));
}
public static BlockPos.PooledMutableBlockPos retain(int xIn, int yIn, int zIn)
{
synchronized (POOL)
{
if (!POOL.isEmpty())
{
BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = (BlockPos.PooledMutableBlockPos)POOL.remove(POOL.size() - 1);
public static BlockPos.PooledMutableBlockPos retain(int xIn, int yIn, int zIn) {
synchronized (POOL) {
if (!POOL.isEmpty()) {
BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = POOL.remove(POOL.size() - 1);
if (blockpos$pooledmutableblockpos != null && blockpos$pooledmutableblockpos.released)
{
if (blockpos$pooledmutableblockpos != null && blockpos$pooledmutableblockpos.released) {
blockpos$pooledmutableblockpos.released = false;
blockpos$pooledmutableblockpos.set(xIn, yIn, zIn);
return blockpos$pooledmutableblockpos;
@@ -409,12 +356,9 @@ public class BlockPos extends Vec3i
return new BlockPos.PooledMutableBlockPos(xIn, yIn, zIn);
}
public void release()
{
synchronized (POOL)
{
if (POOL.size() < 100)
{
public void release() {
synchronized (POOL) {
if (POOL.size() < 100) {
POOL.add(this);
}
@@ -422,35 +366,29 @@ public class BlockPos extends Vec3i
}
}
public BlockPos.PooledMutableBlockPos set(int xIn, int yIn, int zIn)
{
if (this.released)
{
public BlockPos.PooledMutableBlockPos set(int xIn, int yIn, int zIn) {
if (this.released) {
BlockPos.LOGGER.error("PooledMutableBlockPosition modified after it was released.", new Throwable());
this.released = false;
}
return (BlockPos.PooledMutableBlockPos)super.setPos(xIn, yIn, zIn);
return (BlockPos.PooledMutableBlockPos) super.setPos(xIn, yIn, zIn);
}
public BlockPos.PooledMutableBlockPos set(double xIn, double yIn, double zIn)
{
return (BlockPos.PooledMutableBlockPos)super.setPos(xIn, yIn, zIn);
public BlockPos.PooledMutableBlockPos set(double xIn, double yIn, double zIn) {
return (BlockPos.PooledMutableBlockPos) super.setPos(xIn, yIn, zIn);
}
public BlockPos.PooledMutableBlockPos set(Vec3i vec)
{
return (BlockPos.PooledMutableBlockPos)super.setPos(vec);
public BlockPos.PooledMutableBlockPos set(Vec3i vec) {
return (BlockPos.PooledMutableBlockPos) super.setPos(vec);
}
public BlockPos.PooledMutableBlockPos offsetMutable(EnumFacing facing)
{
return (BlockPos.PooledMutableBlockPos)super.move(facing);
public BlockPos.PooledMutableBlockPos offsetMutable(EnumFacing facing) {
return (BlockPos.PooledMutableBlockPos) super.move(facing);
}
public BlockPos.PooledMutableBlockPos movePos(EnumFacing p_189538_1_, int p_189538_2_)
{
return (BlockPos.PooledMutableBlockPos)super.move(p_189538_1_, p_189538_2_);
public BlockPos.PooledMutableBlockPos movePos(EnumFacing p_189538_1_, int p_189538_2_) {
return (BlockPos.PooledMutableBlockPos) super.move(p_189538_1_, p_189538_2_);
}
}
}
+7 -7
View File
@@ -1,5 +1,7 @@
package net.minecraft.util.math;
import java.util.Objects;
public class IntHashMap<V> {
private transient IntHashMap.Entry<V>[] slots = new IntHashMap.Entry[16];
/**
@@ -42,7 +44,7 @@ public class IntHashMap<V> {
}
}
return (V) null;
return null;
}
/**
@@ -131,7 +133,7 @@ public class IntHashMap<V> {
*/
public V removeObject(int p_76049_1_) {
IntHashMap.Entry<V> entry = this.removeEntry(p_76049_1_);
return (V) (entry == null ? null : entry.valueEntry);
return entry == null ? null : entry.valueEntry;
}
final IntHashMap.Entry<V> removeEntry(int p_76036_1_) {
@@ -231,13 +233,11 @@ public class IntHashMap<V> {
Object object = Integer.valueOf(this.getHash());
Object object1 = Integer.valueOf(entry.getHash());
if (object == object1 || object != null && object.equals(object1)) {
if (Objects.equals(object, object1)) {
Object object2 = this.getValue();
Object object3 = entry.getValue();
if (object2 == object3 || object2 != null && object2.equals(object3)) {
return true;
}
return Objects.equals(object2, object3);
}
return false;
@@ -252,4 +252,4 @@ public class IntHashMap<V> {
return this.getHash() + "=" + this.getValue();
}
}
}
}