aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util/GT_Util.java
diff options
context:
space:
mode:
authorJason Mitchell <mitchej@gmail.com>2023-01-30 10:56:42 -0800
committerJason Mitchell <mitchej@gmail.com>2023-01-30 10:56:42 -0800
commit0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a (patch)
tree1e2c649f3a6ce3f6b2babd0098a5f4819e9cd0b6 /src/main/java/gregtech/api/util/GT_Util.java
parentf8cc82edeb9810c45cba762d733a2c909a302faa (diff)
downloadGT5-Unofficial-0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a.tar.gz
GT5-Unofficial-0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a.tar.bz2
GT5-Unofficial-0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a.zip
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/gregtech/api/util/GT_Util.java')
-rw-r--r--src/main/java/gregtech/api/util/GT_Util.java56
1 files changed, 26 insertions, 30 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Util.java b/src/main/java/gregtech/api/util/GT_Util.java
index 9de1726162..6e203a2682 100644
--- a/src/main/java/gregtech/api/util/GT_Util.java
+++ b/src/main/java/gregtech/api/util/GT_Util.java
@@ -1,6 +1,5 @@
package gregtech.api.util;
-import gregtech.api.multitileentity.interfaces.IMultiTileEntity;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTBase;
@@ -11,7 +10,10 @@ import net.minecraft.util.Tuple;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
+import gregtech.api.multitileentity.interfaces.IMultiTileEntity;
+
public class GT_Util {
+
// Last broken tile entity
public static final ThreadLocal<TileEntity> LAST_BROKEN_TILEENTITY = new ThreadLocal<>();
@@ -23,13 +25,13 @@ public class GT_Util {
if (aNBT1 == null) return aNBT2 == null ? new NBTTagCompound() : (NBTTagCompound) aNBT2.copy();
final NBTTagCompound rNBT = (NBTTagCompound) aNBT1.copy();
if (aNBT2 == null) return rNBT;
- for (Object tKey : aNBT2.func_150296_c /*getKeySet*/())
+ for (Object tKey : aNBT2.func_150296_c /* getKeySet */())
if (!rNBT.hasKey(tKey.toString())) rNBT.setTag(tKey.toString(), aNBT2.getTag(tKey.toString()));
return rNBT;
}
/**
- * Construct a NBTTagCompound from a series of key, value pairs. Inspired from GT6.
+ * Construct a NBTTagCompound from a series of key, value pairs. Inspired from GT6.
*/
public static NBTTagCompound makeNBT(Tuple... aTags) {
final NBTTagCompound rNBT = new NBTTagCompound();
@@ -43,10 +45,8 @@ public class GT_Util {
rNBT.setInteger(t.getFirst().toString(), (Integer) t.getSecond());
else if (t.getSecond() instanceof Long) rNBT.setLong(t.getFirst().toString(), (Long) t.getSecond());
else if (t.getSecond() instanceof Float) rNBT.setFloat(t.getFirst().toString(), (Float) t.getSecond());
- else if (t.getSecond() instanceof Double)
- rNBT.setDouble(t.getFirst().toString(), (Double) t.getSecond());
- else if (t.getSecond() instanceof String)
- rNBT.setString(t.getFirst().toString(), (String) t.getSecond());
+ else if (t.getSecond() instanceof Double) rNBT.setDouble(t.getFirst().toString(), (Double) t.getSecond());
+ else if (t.getSecond() instanceof String) rNBT.setString(t.getFirst().toString(), (String) t.getSecond());
else if (t.getSecond() instanceof NBTBase) rNBT.setTag(t.getFirst().toString(), (NBTBase) t.getSecond());
else rNBT.setString(t.getFirst().toString(), t.getSecond().toString());
}
@@ -70,22 +70,22 @@ public class GT_Util {
}
/** Sets the TileEntity at the passed position, with the option of turning adjacent TileEntity updates off. */
- public static TileEntity setTileEntity(
- World aWorld, int aX, int aY, int aZ, TileEntity aTileEntity, boolean aCauseTileEntityUpdates) {
+ public static TileEntity setTileEntity(World aWorld, int aX, int aY, int aZ, TileEntity aTileEntity,
+ boolean aCauseTileEntityUpdates) {
if (aCauseTileEntityUpdates) aWorld.setTileEntity(aX, aY, aZ, aTileEntity);
else {
Chunk tChunk = aWorld.getChunkFromChunkCoords(aX >> 4, aZ >> 4);
if (tChunk != null) {
aWorld.addTileEntity(aTileEntity);
- tChunk.func_150812_a /*setBlockTileEntityInChunk*/(aX & 15, aY, aZ & 15, aTileEntity);
+ tChunk.func_150812_a /* setBlockTileEntityInChunk */(aX & 15, aY, aZ & 15, aTileEntity);
tChunk.setChunkModified();
}
}
return aTileEntity;
}
- public static boolean setTileEntity(
- World aWorld, int aX, int aY, int aZ, Block aBlock, short aMeta, long aFlags, boolean aRemoveGrassBelow) {
+ public static boolean setTileEntity(World aWorld, int aX, int aY, int aZ, Block aBlock, short aMeta, long aFlags,
+ boolean aRemoveGrassBelow) {
if (aRemoveGrassBelow) {
final Block tBlock = aWorld.getBlock(aX, aY - 1, aZ);
if (tBlock == Blocks.grass || tBlock == Blocks.mycelium)
@@ -106,29 +106,29 @@ public class GT_Util {
aWorld.getBlockMetadata(aX, 0, aZ);
aChunk = aWorld.getChunkFromBlockCoords(aX, aZ);
if (aChunk == null) {
- GT_Log.err.println("Some important Chunk does not exist for some reason at Coordinates X: " + aX
- + " and Z: " + aZ);
+ GT_Log.err.println(
+ "Some important Chunk does not exist for some reason at Coordinates X: " + aX
+ + " and Z: "
+ + aZ);
return false;
}
}
aChunk.setChunkModified();
return true;
}
+
/** Marks a Chunk dirty so it is saved */
public static boolean markChunkDirty(Object aTileEntity) {
- return aTileEntity instanceof TileEntity
- && markChunkDirty(
- ((TileEntity) aTileEntity).getWorldObj(),
- ((TileEntity) aTileEntity).xCoord,
- ((TileEntity) aTileEntity).zCoord);
+ return aTileEntity instanceof TileEntity && markChunkDirty(
+ ((TileEntity) aTileEntity).getWorldObj(),
+ ((TileEntity) aTileEntity).xCoord,
+ ((TileEntity) aTileEntity).zCoord);
}
public static int mixRGBInt(int aRGB1, int aRGB2) {
- return getRGBInt(new short[] {
- (short) ((getR(aRGB1) + getR(aRGB2)) >> 1),
- (short) ((getG(aRGB1) + getG(aRGB2)) >> 1),
- (short) ((getB(aRGB1) + getB(aRGB2)) >> 1)
- });
+ return getRGBInt(
+ new short[] { (short) ((getR(aRGB1) + getR(aRGB2)) >> 1), (short) ((getG(aRGB1) + getG(aRGB2)) >> 1),
+ (short) ((getB(aRGB1) + getB(aRGB2)) >> 1) });
}
public static int getRGBInt(short[] aColors) {
@@ -152,12 +152,8 @@ public class GT_Util {
}
public static short[] getRGBaArray(int aColors) {
- return new short[] {
- (short) ((aColors >>> 16) & 255),
- (short) ((aColors >>> 8) & 255),
- (short) (aColors & 255),
- (short) ((aColors >>> 24) & 255)
- };
+ return new short[] { (short) ((aColors >>> 16) & 255), (short) ((aColors >>> 8) & 255), (short) (aColors & 255),
+ (short) ((aColors >>> 24) & 255) };
}
public static short getR(int aColors) {