From 55f64675b42ac8d3c557cc850f78664bee006f6f Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Sat, 28 Jan 2023 19:32:44 -0800 Subject: [ci skip] spotlessApply with the new settings --- src/main/java/gtPlusPlus/api/objects/Logger.java | 7 +- .../java/gtPlusPlus/api/objects/data/AutoMap.java | 6 + .../gtPlusPlus/api/objects/data/FlexiblePair.java | 3 +- .../java/gtPlusPlus/api/objects/data/ObjMap.java | 24 ++-- .../java/gtPlusPlus/api/objects/data/Pair.java | 3 +- .../gtPlusPlus/api/objects/data/TypeCounter.java | 7 +- .../api/objects/data/WeightedCollection.java | 3 +- .../api/objects/data/weakref/WeakAutoMap.java | 4 +- .../gtPlusPlus/api/objects/minecraft/AABB.java | 13 +- .../api/objects/minecraft/BTF_FluidTank.java | 18 +-- .../api/objects/minecraft/BTF_Inventory.java | 81 +++++------- .../gtPlusPlus/api/objects/minecraft/BlockPos.java | 9 +- .../api/objects/minecraft/CubicObject.java | 3 +- .../api/objects/minecraft/DimChunkPos.java | 8 +- .../api/objects/minecraft/FakeBlockPos.java | 29 +++-- .../api/objects/minecraft/FakeWorld.java | 29 ++--- .../gtPlusPlus/api/objects/minecraft/FluidGT6.java | 7 +- .../api/objects/minecraft/ItemPackage.java | 4 +- .../api/objects/minecraft/ItemStackData.java | 3 +- .../objects/minecraft/NoConflictGTRecipeMap.java | 5 +- .../api/objects/minecraft/SafeTexture.java | 7 +- .../api/objects/minecraft/ShapedRecipe.java | 62 +++++---- .../api/objects/minecraft/TexturePackage.java | 4 +- .../api/objects/minecraft/ThreadPooCollector.java | 23 ++-- .../minecraft/multi/NoEUBonusMultiBehaviour.java | 3 +- .../multi/NoOutputBonusMultiBehaviour.java | 3 +- .../multi/NoSpeedBonusMultiBehaviour.java | 3 +- .../minecraft/multi/SpecialMultiBehaviour.java | 10 +- .../api/objects/random/CSPRNG_DO_NOT_USE.java | 125 +++++++----------- .../api/objects/random/UUIDGenerator.java | 120 ++++++++--------- .../java/gtPlusPlus/api/objects/random/XSTR.java | 142 +++++++++------------ 31 files changed, 371 insertions(+), 397 deletions(-) (limited to 'src/main/java/gtPlusPlus/api/objects') diff --git a/src/main/java/gtPlusPlus/api/objects/Logger.java b/src/main/java/gtPlusPlus/api/objects/Logger.java index 78f8ff101b..9b6591abd2 100644 --- a/src/main/java/gtPlusPlus/api/objects/Logger.java +++ b/src/main/java/gtPlusPlus/api/objects/Logger.java @@ -1,11 +1,12 @@ package gtPlusPlus.api.objects; +import org.apache.logging.log4j.LogManager; + import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.FMLRelaunchLog; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.preloader.CORE_Preloader; import gtPlusPlus.preloader.asm.AsmConfig; -import org.apache.logging.log4j.LogManager; public class Logger { @@ -88,6 +89,7 @@ public class Logger { public static void BEES(final String s) { modLogger.info("[Bees] " + s); } + /** * Special Logger for Debugging Bee related content */ @@ -109,6 +111,7 @@ public class Logger { } } } + /** * Special Logger for Debugging Materials related content */ @@ -145,7 +148,7 @@ public class Logger { public static void RECIPE(String string) { if (enabled) { if ( - /*CORE_Preloader.DEV_ENVIRONMENT || */ CORE_Preloader.DEBUG_MODE) { + /* CORE_Preloader.DEV_ENVIRONMENT || */ CORE_Preloader.DEBUG_MODE) { modLogger.info("[Recipe] " + string); } } diff --git a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java index f0687fae4f..92ba97e722 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java @@ -34,6 +34,7 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect /** * Generates an AutoMap from the List. + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(List aList) { @@ -45,8 +46,10 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect } } } + /** * Generates an AutoMap from a Set. + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(Set aList) { @@ -58,8 +61,10 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect } } } + /** * Generates an AutoMap from a Collection. + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(Collection aList) { @@ -74,6 +79,7 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect /** * Generates an AutoMap from a Array. + * * @param aArray - Data to be inserted into the AutoMap. */ public AutoMap(V[] aArray) { diff --git a/src/main/java/gtPlusPlus/api/objects/data/FlexiblePair.java b/src/main/java/gtPlusPlus/api/objects/data/FlexiblePair.java index 698e56ae45..8ec21dab59 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/FlexiblePair.java +++ b/src/main/java/gtPlusPlus/api/objects/data/FlexiblePair.java @@ -1,8 +1,9 @@ package gtPlusPlus.api.objects.data; -import com.google.common.base.Objects; import java.io.Serializable; +import com.google.common.base.Objects; + public class FlexiblePair implements Serializable { /** diff --git a/src/main/java/gtPlusPlus/api/objects/data/ObjMap.java b/src/main/java/gtPlusPlus/api/objects/data/ObjMap.java index 1f8a4baa2c..eff314f9ae 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/ObjMap.java +++ b/src/main/java/gtPlusPlus/api/objects/data/ObjMap.java @@ -6,6 +6,7 @@ import java.util.Arrays; * Object-2-object map based on IntIntMap4a */ public class ObjMap { + private static final Object FREE_KEY = new Object(); private static final Object REMOVED_KEY = new Object(); @@ -51,7 +52,7 @@ public class ObjMap { if (k == FREE_KEY) return null; // end of chain already if (k.equals(key)) // we check FREE and REMOVED prior to this call - return (V) m_data[ptr + 1]; + return (V) m_data[ptr + 1]; while (true) { ptr = (ptr + 2) & m_mask2; // that's next index k = m_data[ptr]; @@ -72,7 +73,7 @@ public class ObjMap { m_data[ptr] = key; m_data[ptr + 1] = value; if (m_size >= m_threshold) rehash(m_data.length * 2); // size is set inside - else ++m_size; + else++m_size; return null; } else if (k.equals(key)) // we check FREE and REMOVED prior to this call { @@ -92,7 +93,7 @@ public class ObjMap { m_data[ptr] = key; m_data[ptr + 1] = value; if (m_size >= m_threshold) rehash(m_data.length * 2); // size is set inside - else ++m_size; + else++m_size; return null; } else if (k.equals(key)) { final Object ret = m_data[ptr + 1]; @@ -196,9 +197,11 @@ public class ObjMap { /** Taken from FastUtil implementation */ - /** Return the least power of two greater than or equal to the specified value. + /** + * Return the least power of two greater than or equal to the specified value. * - *

Note that this function will return 1 when the argument is 0. + *

+ * Note that this function will return 1 when the argument is 0. * * @param x a long integer smaller than or equal to 262. * @return the least power of two greater than or equal to the specified value. @@ -214,18 +217,19 @@ public class ObjMap { return (x | x >> 32) + 1; } - /** Returns the least power of two smaller than or equal to 230 and larger than or equal to Math.ceil( expected / f ). + /** + * Returns the least power of two smaller than or equal to 230 and larger than or equal to + * Math.ceil( expected / f ). * * @param expected the expected number of elements in a hash table. - * @param f the load factor. + * @param f the load factor. * @return the minimum possible size for a backing array. * @throws IllegalArgumentException if the necessary size is larger than 230. */ public static int arraySize(final int expected, final float f) { final long s = Math.max(2, nextPowerOfTwo((long) Math.ceil(expected / f))); - if (s > (1 << 30)) - throw new IllegalArgumentException( - "Too large (" + expected + " expected elements with load factor " + f + ")"); + if (s > (1 << 30)) throw new IllegalArgumentException( + "Too large (" + expected + " expected elements with load factor " + f + ")"); return (int) s; } diff --git a/src/main/java/gtPlusPlus/api/objects/data/Pair.java b/src/main/java/gtPlusPlus/api/objects/data/Pair.java index 33b2ade368..93bf075c8f 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/Pair.java +++ b/src/main/java/gtPlusPlus/api/objects/data/Pair.java @@ -1,8 +1,9 @@ package gtPlusPlus.api.objects.data; -import com.google.common.base.Objects; import java.io.Serializable; +import com.google.common.base.Objects; + public class Pair implements Serializable { /** diff --git a/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java b/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java index 6acf62aa53..c282ce1eb3 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java +++ b/src/main/java/gtPlusPlus/api/objects/data/TypeCounter.java @@ -1,16 +1,16 @@ package gtPlusPlus.api.objects.data; -import gtPlusPlus.api.objects.Logger; import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; +import gtPlusPlus.api.objects.Logger; + public class TypeCounter implements Set { - private Map> mInternalMap = - new LinkedHashMap>(); + private Map> mInternalMap = new LinkedHashMap>(); private String mHighestValueKey; private int mHighestValue = 0; private final Class mClass; @@ -21,6 +21,7 @@ public class TypeCounter implements Set { } public static class InternalTypeCounterObject { + private final Z mObject; private int mCounter = 0; diff --git a/src/main/java/gtPlusPlus/api/objects/data/WeightedCollection.java b/src/main/java/gtPlusPlus/api/objects/data/WeightedCollection.java index 20eed5cdc5..46cb8b35d9 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/WeightedCollection.java +++ b/src/main/java/gtPlusPlus/api/objects/data/WeightedCollection.java @@ -1,6 +1,5 @@ package gtPlusPlus.api.objects.data; -import gtPlusPlus.api.objects.random.XSTR; import java.util.Collection; import java.util.Map; import java.util.NavigableMap; @@ -8,6 +7,8 @@ import java.util.Random; import java.util.Set; import java.util.TreeMap; +import gtPlusPlus.api.objects.random.XSTR; + public class WeightedCollection implements Map { private NavigableMap map = new TreeMap(); diff --git a/src/main/java/gtPlusPlus/api/objects/data/weakref/WeakAutoMap.java b/src/main/java/gtPlusPlus/api/objects/data/weakref/WeakAutoMap.java index fcf6131611..c9176c00c5 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/weakref/WeakAutoMap.java +++ b/src/main/java/gtPlusPlus/api/objects/data/weakref/WeakAutoMap.java @@ -1,9 +1,11 @@ package gtPlusPlus.api.objects.data.weakref; -import gtPlusPlus.api.objects.data.AutoMap; import java.util.WeakHashMap; +import gtPlusPlus.api.objects.data.AutoMap; + public class WeakAutoMap extends AutoMap { + private static final long serialVersionUID = 8328345351801363386L; public WeakAutoMap() { diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/AABB.java b/src/main/java/gtPlusPlus/api/objects/minecraft/AABB.java index cefc4fce37..e516f12ddd 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/AABB.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/AABB.java @@ -1,12 +1,14 @@ package gtPlusPlus.api.objects.minecraft; -import gtPlusPlus.core.util.minecraft.EntityUtils; import net.minecraft.entity.Entity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; +import gtPlusPlus.core.util.minecraft.EntityUtils; + /** * Generates an AABB around an entity. + * * @author Alkalus * */ @@ -17,10 +19,11 @@ public class AABB { /** * Creates a AxisAlignedBB based around an Entity. + * * @param aEntity - The Entity to work with. - * @param x - Maximum X from origin. - * @param y - Maximum Y from origin. - * @param z - Maximum Z from origin. + * @param x - Maximum X from origin. + * @param y - Maximum Y from origin. + * @param z - Maximum Z from origin. */ public AABB(Entity aEntity, int x, int y, int z) { if (aEntity == null) { @@ -42,6 +45,7 @@ public class AABB { /** * Used to get the AxisAlignedBB from this class. + * * @return */ public AxisAlignedBB get() { @@ -50,6 +54,7 @@ public class AABB { /** * Used to determine if this object is valid or not. + * * @return */ public boolean valid() { diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java index f7d29e1200..56a134716b 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_FluidTank.java @@ -15,6 +15,7 @@ public class BTF_FluidTank extends FluidTank { /** * Let's replace the Default handling with GT's own handling code, because it's probably better, right? + * * @author Alkalus/GregoriusT */ public FluidStack getFluid() { @@ -38,13 +39,10 @@ public class BTF_FluidTank extends FluidTank { return this; } - /* public abstract boolean isLiquidInput(byte arg0); - - public abstract boolean isLiquidOutput(byte arg0); - - public abstract boolean doesFillContainers(); - - public abstract boolean doesEmptyContainers();*/ + /* + * public abstract boolean isLiquidInput(byte arg0); public abstract boolean isLiquidOutput(byte arg0); public + * abstract boolean doesFillContainers(); public abstract boolean doesEmptyContainers(); + */ public boolean canTankBeFilled() { return true; @@ -85,13 +83,11 @@ public class BTF_FluidTank extends FluidTank { } public int fill(FluidStack aFluid, boolean doFill) { - if (aFluid != null - && aFluid.getFluid().getID() > 0 + if (aFluid != null && aFluid.getFluid().getID() > 0 && aFluid.amount > 0 && this.canTankBeFilled() && this.isFluidInputAllowed(aFluid)) { - if (this.getFillableStack() != null - && this.getFillableStack().getFluid().getID() > 0) { + if (this.getFillableStack() != null && this.getFillableStack().getFluid().getID() > 0) { if (!this.getFillableStack().isFluidEqual(aFluid)) { return 0; } else { diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java index d23ea97072..6dac3a7acd 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java @@ -1,13 +1,15 @@ package gtPlusPlus.api.objects.minecraft; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.tileentities.base.TileEntityBase; -import gtPlusPlus.core.util.data.ArrayUtils; import java.util.ArrayList; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.tileentities.base.TileEntityBase; +import gtPlusPlus.core.util.data.ArrayUtils; + public class BTF_Inventory implements ISidedInventory { public final ItemStack[] mInventory; @@ -59,7 +61,7 @@ public class BTF_Inventory implements ISidedInventory { public ItemStack decrStackSize(int aIndex, int aAmount) { ItemStack tStack = this.getStackInSlot(aIndex); - ItemStack rStack = GT_Utility.copy(new Object[] {tStack}); + ItemStack rStack = GT_Utility.copy(new Object[] { tStack }); if (tStack != null) { if (tStack.stackSize <= aAmount) { if (this.setStackToZeroInsteadOfNull(aIndex)) { @@ -81,42 +83,33 @@ public class BTF_Inventory implements ISidedInventory { public int[] getAccessibleSlotsFromSide(int aSide) { ArrayList tList = new ArrayList(); TileEntityBase tTileEntity = this.mTile; - boolean tSkip = tTileEntity - .getCoverBehaviorAtSide((byte) aSide) - .letsItemsIn( - (byte) aSide, - tTileEntity.getCoverIDAtSide((byte) aSide), - tTileEntity.getCoverDataAtSide((byte) aSide), - -2, - tTileEntity) - || tTileEntity - .getCoverBehaviorAtSide((byte) aSide) - .letsItemsOut( - (byte) aSide, - tTileEntity.getCoverIDAtSide((byte) aSide), - tTileEntity.getCoverDataAtSide((byte) aSide), - -2, - tTileEntity); + boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getCoverDataAtSide((byte) aSide), + -2, + tTileEntity) + || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getCoverDataAtSide((byte) aSide), + -2, + tTileEntity); for (int rArray = 0; rArray < this.getSizeInventory(); ++rArray) { - if (this.isValidSlot(rArray) - && (tSkip - || tTileEntity - .getCoverBehaviorAtSide((byte) aSide) - .letsItemsOut( - (byte) aSide, - tTileEntity.getCoverIDAtSide((byte) aSide), - tTileEntity.getCoverDataAtSide((byte) aSide), - rArray, - tTileEntity) - || tTileEntity - .getCoverBehaviorAtSide((byte) aSide) - .letsItemsIn( - (byte) aSide, - tTileEntity.getCoverIDAtSide((byte) aSide), - tTileEntity.getCoverDataAtSide((byte) aSide), - rArray, - tTileEntity))) { + if (this.isValidSlot(rArray) && (tSkip + || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsOut( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getCoverDataAtSide((byte) aSide), + rArray, + tTileEntity) + || tTileEntity.getCoverBehaviorAtSide((byte) aSide).letsItemsIn( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getCoverDataAtSide((byte) aSide), + rArray, + tTileEntity))) { tList.add(Integer.valueOf(rArray)); } } @@ -131,16 +124,14 @@ public class BTF_Inventory implements ISidedInventory { } public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return this.isValidSlot(aIndex) - && aStack != null + return this.isValidSlot(aIndex) && aStack != null && aIndex < this.mInventory.length && (this.mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, this.mInventory[aIndex])) && this.allowPutStack(this.mTile, aIndex, (byte) aSide, aStack); } public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return this.isValidSlot(aIndex) - && aStack != null + return this.isValidSlot(aIndex) && aStack != null && aIndex < this.mInventory.length && this.allowPullStack(this.mTile, aIndex, (byte) aSide, aStack); } @@ -209,10 +200,8 @@ public class BTF_Inventory implements ISidedInventory { for (int s = 0; s < this.getSizeInventory(); s++) { if (mInventory != null && mInventory[s] != null) { ItemStack slot = mInventory[s]; - if (slot == null - || (slot != null - && GT_Utility.areStacksEqual(aInput, slot) - && slot.stackSize != slot.getItem().getItemStackLimit(slot))) { + if (slot == null || (slot != null && GT_Utility.areStacksEqual(aInput, slot) + && slot.stackSize != slot.getItem().getItemStackLimit(slot))) { if (slot == null) { slot = aInput.copy(); } else { diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/BlockPos.java b/src/main/java/gtPlusPlus/api/objects/minecraft/BlockPos.java index 451d1aca77..cd6edf5411 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/BlockPos.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/BlockPos.java @@ -1,15 +1,17 @@ package gtPlusPlus.api.objects.minecraft; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.api.objects.data.AutoMap; import java.io.Serializable; import java.util.HashSet; import java.util.Set; + import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.api.objects.data.AutoMap; + public class BlockPos implements Serializable { private static final long serialVersionUID = -7271947491316682006L; @@ -89,8 +91,7 @@ public class BlockPos implements Serializable { return false; } BlockPos otherPoint = (BlockPos) other; - return this.xPos == otherPoint.xPos - && this.yPos == otherPoint.yPos + return this.xPos == otherPoint.xPos && this.yPos == otherPoint.yPos && this.zPos == otherPoint.zPos && this.dim == otherPoint.dim; } diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java b/src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java index 04b1f2b59b..5799a12822 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/CubicObject.java @@ -1,8 +1,9 @@ package gtPlusPlus.api.objects.minecraft; -import gtPlusPlus.api.objects.data.AutoMap; import net.minecraftforge.common.util.ForgeDirection; +import gtPlusPlus.api.objects.data.AutoMap; + public class CubicObject { public final T NORTH; diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/DimChunkPos.java b/src/main/java/gtPlusPlus/api/objects/minecraft/DimChunkPos.java index 492d0b3aeb..6748b58537 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/DimChunkPos.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/DimChunkPos.java @@ -30,9 +30,7 @@ public class DimChunkPos { this.dimension = dim; this.xPos = x; this.zPos = z; - Chunk h = Minecraft.getMinecraft() - .getIntegratedServer() - .worldServerForDimension(dim) + Chunk h = Minecraft.getMinecraft().getIntegratedServer().worldServerForDimension(dim) .getChunkFromChunkCoords(xPos, zPos); if (h == null) { this.mainChunk = null; @@ -45,9 +43,7 @@ public class DimChunkPos { if (this.mainChunk != null) { return this.mainChunk; } - Chunk h = Minecraft.getMinecraft() - .getIntegratedServer() - .worldServerForDimension(this.dimension) + Chunk h = Minecraft.getMinecraft().getIntegratedServer().worldServerForDimension(this.dimension) .getChunkFromChunkCoords(xPos, zPos); return h; } diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java b/src/main/java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java index 40f78763d0..d627d47349 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java @@ -1,13 +1,15 @@ package gtPlusPlus.api.objects.minecraft; -import gtPlusPlus.api.objects.data.AutoMap; import java.util.HashSet; import java.util.Set; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; +import gtPlusPlus.api.objects.data.AutoMap; + public class FakeBlockPos extends BlockPos { private static final long serialVersionUID = -6442245826092414593L; @@ -43,7 +45,13 @@ public class FakeBlockPos extends BlockPos { } public String getUniqueIdentifier() { - String S = "" + this.xPos + "@" + this.yPos + "@" + this.zPos + this.aBlockAtPos.getLocalizedName() + "@" + String S = "" + this.xPos + + "@" + + this.yPos + + "@" + + this.zPos + + this.aBlockAtPos.getLocalizedName() + + "@" + this.aBlockMetaAtPos; return S; } @@ -222,18 +230,17 @@ public class FakeBlockPos extends BlockPos { } /** - * Called when a plant grows on this block, only implemented for saplings using the WorldGen*Trees classes right now. - * Modder may implement this for custom plants. - * This does not use ForgeDirection, because large/huge trees can be located in non-representable direction, - * so the source location is specified. - * Currently this just changes the block to dirt if it was grass. + * Called when a plant grows on this block, only implemented for saplings using the WorldGen*Trees classes right + * now. Modder may implement this for custom plants. This does not use ForgeDirection, because large/huge trees can + * be located in non-representable direction, so the source location is specified. Currently this just changes the + * block to dirt if it was grass. * * Note: This happens DURING the generation, the generation may not be complete when this is called. * - * @param world Current world - * @param x Soil X - * @param y Soil Y - * @param z Soil Z + * @param world Current world + * @param x Soil X + * @param y Soil Y + * @param z Soil Z * @param sourceX Plant growth location X * @param sourceY Plant growth location Y * @param sourceZ Plant growth location Z diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeWorld.java b/src/main/java/gtPlusPlus/api/objects/minecraft/FakeWorld.java index 2a55282623..d294326ff3 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeWorld.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/FakeWorld.java @@ -1,10 +1,7 @@ package gtPlusPlus.api.objects.minecraft; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; import java.util.HashMap; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; @@ -14,6 +11,11 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.util.ForgeDirection; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + public class FakeWorld implements IBlockAccess { public static HashMap mStaticFakeWorldData; @@ -48,18 +50,13 @@ public class FakeWorld implements IBlockAccess { public void init() { - /*if (mStaticFakeWorldData == null) { - Logger.WARNING("Setting all Blocks in Fake World to Air."); - mStaticFakeWorldData = new HashMap(); - for (int y=0;y<=aWorldHeight;y++) { - for (int x=-aDistanceFromOrigin;x<=aDistanceFromOrigin;x++) { - for (int z=-aDistanceFromOrigin;z<=aDistanceFromOrigin;z++) { - FakeBlockPos aTempPos = new FakeBlockPos(x, y, z, Blocks.air, 0); - mStaticFakeWorldData.put(aTempPos.getLocationString(), aTempPos); - } - } - } - }*/ + /* + * if (mStaticFakeWorldData == null) { Logger.WARNING("Setting all Blocks in Fake World to Air."); + * mStaticFakeWorldData = new HashMap(); for (int y=0;y<=aWorldHeight;y++) { for (int + * x=-aDistanceFromOrigin;x<=aDistanceFromOrigin;x++) { for (int + * z=-aDistanceFromOrigin;z<=aDistanceFromOrigin;z++) { FakeBlockPos aTempPos = new FakeBlockPos(x, y, z, + * Blocks.air, 0); mStaticFakeWorldData.put(aTempPos.getLocationString(), aTempPos); } } } } + */ // if (mStaticFakeWorldData != null) { // Logger.WARNING(" Instancing static air world."); mFakeWorldData = new HashMap(); diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/FluidGT6.java b/src/main/java/gtPlusPlus/api/objects/minecraft/FluidGT6.java index 1cc3c2c0aa..a90d72864c 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/FluidGT6.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/FluidGT6.java @@ -1,10 +1,12 @@ package gtPlusPlus.api.objects.minecraft; +import net.minecraftforge.fluids.Fluid; + import gregtech.api.GregTech_API; import gtPlusPlus.core.lib.CORE; -import net.minecraftforge.fluids.Fluid; public class FluidGT6 extends Fluid implements Runnable { + private final short[] mRGBa; public final String mTextureName; @@ -19,8 +21,7 @@ public class FluidGT6 extends Fluid implements Runnable { @Override public int getColor() { - return (Math.max(0, Math.min(255, this.mRGBa[0])) << 16) - | (Math.max(0, Math.min(255, this.mRGBa[1])) << 8) + return (Math.max(0, Math.min(255, this.mRGBa[0])) << 16) | (Math.max(0, Math.min(255, this.mRGBa[1])) << 8) | Math.max(0, Math.min(255, this.mRGBa[2])); } diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/ItemPackage.java b/src/main/java/gtPlusPlus/api/objects/minecraft/ItemPackage.java index 9500d862fa..6fe2f9ddb5 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/ItemPackage.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/ItemPackage.java @@ -47,11 +47,11 @@ public abstract class ItemPackage implements RunnableWithInfo { /** * Override this to handle GT Recipe map manipulation after they're Baked. + * * @param event - the {@link FMLLoadCompleteEvent}. * @return - Did we do anything? */ public boolean onLoadComplete(FMLLoadCompleteEvent event) { return false; - } - ; + }; } diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/ItemStackData.java b/src/main/java/gtPlusPlus/api/objects/minecraft/ItemStackData.java index 7e0e0bb9ea..f5e483b91c 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/ItemStackData.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/ItemStackData.java @@ -1,10 +1,11 @@ package gtPlusPlus.api.objects.minecraft; -import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import gtPlusPlus.core.util.minecraft.ItemUtils; + public class ItemStackData { protected final Item mItem; diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java b/src/main/java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java index a8768f7604..e8b4a19031 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/NoConflictGTRecipeMap.java @@ -1,10 +1,11 @@ package gtPlusPlus.api.objects.minecraft; +import java.util.Collection; +import java.util.Iterator; + import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Recipe; import gtPlusPlus.api.objects.data.AutoMap; -import java.util.Collection; -import java.util.Iterator; public class NoConflictGTRecipeMap implements Collection { diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/SafeTexture.java b/src/main/java/gtPlusPlus/api/objects/minecraft/SafeTexture.java index 0ec01e3825..84f5fe5fba 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/SafeTexture.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/SafeTexture.java @@ -1,14 +1,17 @@ package gtPlusPlus.api.objects.minecraft; +import java.util.HashMap; + +import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; import gtPlusPlus.core.util.Utils; -import java.util.HashMap; -import net.minecraft.util.IIcon; /** * A Server Side safe object that can hold {@link IIcon}s. + * * @author Alkalus * */ diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java b/src/main/java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java index 98232fb4c4..12916af64b 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java @@ -1,12 +1,13 @@ package gtPlusPlus.api.objects.minecraft; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.ShapedOreRecipe; + import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.util.minecraft.ItemUtils; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.ShapedOreRecipe; public class ShapedRecipe { @@ -15,19 +16,10 @@ public class ShapedRecipe { ItemStack[] mBlackList = null; - public ShapedRecipe( - Object aInput1, - Object aInput2, - Object aInput3, - Object aInput4, - Object aInput5, - Object aInput6, - Object aInput7, - Object aInput8, - Object aInput9, - ItemStack aOutput) { - - this(new Object[] {aInput1, aInput2, aInput3, aInput4, aInput5, aInput6, aInput7, aInput8, aInput9}, aOutput); + public ShapedRecipe(Object aInput1, Object aInput2, Object aInput3, Object aInput4, Object aInput5, Object aInput6, + Object aInput7, Object aInput8, Object aInput9, ItemStack aOutput) { + + this(new Object[] { aInput1, aInput2, aInput3, aInput4, aInput5, aInput6, aInput7, aInput8, aInput9 }, aOutput); } public ShapedRecipe(Object[] aInputs, ItemStack aOutput) { @@ -75,8 +67,11 @@ public class ShapedRecipe { Logger.RECIPE("Generating Shaped Crafting Recipe for " + aOutput.getDisplayName()); if (aInputs.length < 9 || aInputs.length > 9) { - Logger.RECIPE("[Fix] Recipe for " + aOutput.getDisplayName() - + " has incorrect number of inputs. Size: " + aInputs.length + "."); + Logger.RECIPE( + "[Fix] Recipe for " + aOutput.getDisplayName() + + " has incorrect number of inputs. Size: " + + aInputs.length + + "."); // Logger.RECIPE("[1234abcd] Reciped exists at location: "+ReflectionUtils.getMethodName(1)); // Logger.RECIPE("[1234abcd] Reciped exists at location: "+ReflectionUtils.getMethodName(2)); // Logger.RECIPE("[1234abcd] Reciped exists at location: "+ReflectionUtils.getMethodName(3)); @@ -101,8 +96,12 @@ public class ShapedRecipe { mInfo = ((ItemStack) stack).getDisplayName(); } aRecipePairs.put(new Pair(CHARS.charAt(aCharSlot), stack)); - Logger.RECIPE("Storing '" + CHARS.charAt(aCharSlot) + "' with an object of type " - + stack.getClass().getSimpleName() + " and a value of " + mInfo); + Logger.RECIPE( + "Storing '" + CHARS.charAt(aCharSlot) + + "' with an object of type " + + stack.getClass().getSimpleName() + + " and a value of " + + mInfo); aChar[aMemSlot++] = CHARS.charAt(aCharSlot); aCharSlot++; aLoggingInfo[aInfoSlot++] = mInfo; @@ -160,23 +159,30 @@ public class ShapedRecipe { mInfo = ((ItemStack) stack).getDisplayName(); } aRecipePairs.put(new Pair(CHARS.charAt(aCharSlot), stack)); - Logger.RECIPE("Registering Pair of '" + CHARS.charAt(aCharSlot) + "' and a " - + stack.getClass().getSimpleName() + " object. Object has a value of " + mInfo); + Logger.RECIPE( + "Registering Pair of '" + CHARS.charAt(aCharSlot) + + "' and a " + + stack.getClass().getSimpleName() + + " object. Object has a value of " + + mInfo); aCharSlot++; counter++; } } - Logger.RECIPE("Counter started at " + KEY_COUNTER + ", counter is now at " + counter - + ". Trying to create Varag array with a size of " - + (KEY_COUNTER + (counter - KEY_COUNTER) * 2)); + Logger.RECIPE( + "Counter started at " + KEY_COUNTER + + ", counter is now at " + + counter + + ". Trying to create Varag array with a size of " + + (KEY_COUNTER + (counter - KEY_COUNTER) * 2)); // Counter started at 3, counter is now at 4. Trying to create Varag array with a size of 2 // Register the shaped grid straight to the varags mVarags2 = new Object[(KEY_COUNTER + (counter - KEY_COUNTER) * 2)]; - /*mVarags2[0] = aGrid[0]; - mVarags2[1] = aGrid[1]; - mVarags2[2] = aGrid[2];*/ + /* + * mVarags2[0] = aGrid[0]; mVarags2[1] = aGrid[1]; mVarags2[2] = aGrid[2]; + */ mVarags2[0] = aGrid; // Add Each Char, then Item to the varags, sequentially. diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/TexturePackage.java b/src/main/java/gtPlusPlus/api/objects/minecraft/TexturePackage.java index c5703d12fb..4e4e0e9780 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/TexturePackage.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/TexturePackage.java @@ -1,10 +1,12 @@ package gtPlusPlus.api.objects.minecraft; -import gtPlusPlus.api.objects.data.AutoMap; import java.util.LinkedHashMap; import java.util.Set; + import net.minecraft.util.IIcon; +import gtPlusPlus.api.objects.data.AutoMap; + public class TexturePackage { private AutoMap mAnimationArray = new AutoMap(); diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java b/src/main/java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java index b40696747b..f38a960044 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java @@ -1,18 +1,20 @@ package gtPlusPlus.api.objects.minecraft; -import gtPlusPlus.GTplusplus; -import gtPlusPlus.GTplusplus.INIT_PHASE; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; -import gtPlusPlus.core.util.Utils; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; + import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.GTplusplus.INIT_PHASE; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; +import gtPlusPlus.core.util.Utils; + public class ThreadPooCollector extends Thread { public boolean canRun = true; @@ -22,8 +24,7 @@ public class ThreadPooCollector extends Thread { private static long internalTickCounter = 0; private static final ThreadPooCollector mThread; - private static final HashMap> mPooCollectors = - new LinkedHashMap>(); + private static final HashMap> mPooCollectors = new LinkedHashMap>(); static { mThread = new ThreadPooCollector(); @@ -82,12 +83,12 @@ public class ThreadPooCollector extends Thread { int endX = p.xPos + 3; int endY = p.yPos + 5; int endZ = p.zPos + 3; - AxisAlignedBB box = AxisAlignedBB.getBoundingBox( - startX, startY, startZ, endX, endY, endZ); + AxisAlignedBB box = AxisAlignedBB + .getBoundingBox(startX, startY, startZ, endX, endY, endZ); if (box != null) { @SuppressWarnings("unchecked") - List animals = - w.getEntitiesWithinAABB(EntityAnimal.class, box); + List animals = w + .getEntitiesWithinAABB(EntityAnimal.class, box); if (animals != null && !animals.isEmpty()) { pair.getValue().onPostTick(animals); } diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoEUBonusMultiBehaviour.java b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoEUBonusMultiBehaviour.java index 4dea1c22d6..b4ab2c9315 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoEUBonusMultiBehaviour.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoEUBonusMultiBehaviour.java @@ -1,8 +1,9 @@ package gtPlusPlus.api.objects.minecraft.multi; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import net.minecraft.item.ItemStack; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; + public class NoEUBonusMultiBehaviour extends SpecialMultiBehaviour { public NoEUBonusMultiBehaviour() { diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java index d8ddbea5e7..cea7e40a51 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java @@ -1,8 +1,9 @@ package gtPlusPlus.api.objects.minecraft.multi; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import net.minecraft.item.ItemStack; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; + public class NoOutputBonusMultiBehaviour extends SpecialMultiBehaviour { public NoOutputBonusMultiBehaviour() { diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoSpeedBonusMultiBehaviour.java b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoSpeedBonusMultiBehaviour.java index 834c93890d..cfe6afee66 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoSpeedBonusMultiBehaviour.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoSpeedBonusMultiBehaviour.java @@ -1,8 +1,9 @@ package gtPlusPlus.api.objects.minecraft.multi; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import net.minecraft.item.ItemStack; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; + public class NoSpeedBonusMultiBehaviour extends SpecialMultiBehaviour { public NoSpeedBonusMultiBehaviour() { diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java index 03f000fcc2..94c87ab71b 100644 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java +++ b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java @@ -1,12 +1,14 @@ package gtPlusPlus.api.objects.minecraft.multi; -import gregtech.api.util.GT_Utility; import net.minecraft.item.ItemStack; +import gregtech.api.util.GT_Utility; + /** - * Extend this class to implement custom behaviour for multiblocks. - * The Trigger item when in a special slot or input bus, will cause the multiblock to behave as specified. - * Not overriding a method here will cause the default values to be used. + * Extend this class to implement custom behaviour for multiblocks. The Trigger item when in a special slot or input + * bus, will cause the multiblock to behave as specified. Not overriding a method here will cause the default values to + * be used. + * * @author Alkalus * */ diff --git a/src/main/java/gtPlusPlus/api/objects/random/CSPRNG_DO_NOT_USE.java b/src/main/java/gtPlusPlus/api/objects/random/CSPRNG_DO_NOT_USE.java index 86ea4b4ad6..07c8c3609b 100644 --- a/src/main/java/gtPlusPlus/api/objects/random/CSPRNG_DO_NOT_USE.java +++ b/src/main/java/gtPlusPlus/api/objects/random/CSPRNG_DO_NOT_USE.java @@ -1,84 +1,62 @@ /* - * Copyright 2005, Nick Galbreath -- nickg [at] modp [dot] com - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the modp.com nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This is the standard "new" BSD license: + * Copyright 2005, Nick Galbreath -- nickg [at] modp [dot] com All rights reserved. Redistribution and use in source and + * binary forms, with or without modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following + * disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of + * the modp.com nor the names of its contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. This is the standard "new" BSD license: * http://www.opensource.org/licenses/bsd-license.php */ package gtPlusPlus.api.objects.random; -import gtPlusPlus.api.interfaces.IRandomGenerator; -import gtPlusPlus.core.util.Utils; import java.math.BigInteger; import java.security.SecureRandom; import java.util.Random; +import gtPlusPlus.api.interfaces.IRandomGenerator; +import gtPlusPlus.core.util.Utils; + /** * The Blum-Blum-Shub random number generator. * *

- * The Blum-Blum-Shub is a "cryptographically secure" random number - * generator. It has been proven that predicting the ouput - * is equivalent to factoring n, a large integer generated - * from two prime numbers. + * The Blum-Blum-Shub is a "cryptographically secure" random number generator. It has been proven that predicting the + * ouput is equivalent to factoring n, a large integer generated from two prime numbers. *

* *

* The Algorithm: *

*
    - *
  1. - * (setup) generate two secret prime numbers p, q such that - * pq, p ≡ 3 mod 4, q ≡ 3 mod 4. - *
  2. - *
  3. (setup) compute n = pq. n can be re-used, but - * p, and q are secret and should be disposed of.
  4. - *
  5. Generate a (secure) random seed s in the range [1, n -1] - * such that gcd(s, n) = 1. - *
  6. Compute x = s2 mod n
  7. - *
  8. Compute a single random bit with: - *
      - *
    1. x = x2 mod n
    2. - *
    3. return Least-Significant-Bit(x) (i.e. x & 1)
    4. - *
    - * Repeat as necessary. - *
  9. + *
  10. (setup) generate two secret prime numbers p, q such that pq, p ≡ 3 + * mod 4, q ≡ 3 mod 4.
  11. + *
  12. (setup) compute n = pq. n can be re-used, but p, and q are secret and should + * be disposed of.
  13. + *
  14. Generate a (secure) random seed s in the range [1, n -1] such that gcd(s, n) = 1. + *
  15. Compute x = s2 mod n
  16. + *
  17. Compute a single random bit with: + *
      + *
    1. x = x2 mod n
    2. + *
    3. return Least-Significant-Bit(x) (i.e. x & 1)
    4. + *
    + * Repeat as necessary.
  18. *
* *

- * The code originally appeared in Cryptography for - * Internet and Database Applications , Chapter 4, pages 174-177 + * The code originally appeared in Cryptography for Internet and Database + * Applications , Chapter 4, pages 174-177 *

*

- * More details are in the Handbook of Applied Cryptography, + * More details are in the Handbook of Applied Cryptography, * Section 5.5.2 *

* @@ -105,8 +83,7 @@ public class CSPRNG_DO_NOT_USE extends Random implements IRandomGenerator { /** * Generate appropriate prime number for use in Blum-Blum-Shub. * - * This generates the appropriate primes (p = 3 mod 4) needed to compute the - * "n-value" for Blum-Blum-Shub. + * This generates the appropriate primes (p = 3 mod 4) needed to compute the "n-value" for Blum-Blum-Shub. * * @param bits Number of bits in prime * @param rand A source of randomness @@ -121,13 +98,11 @@ public class CSPRNG_DO_NOT_USE extends Random implements IRandomGenerator { } /** - * This generates the "n value" -- the multiplication of two equally sized - * random prime numbers -- for use in the Blum-Blum-Shub algorithm. + * This generates the "n value" -- the multiplication of two equally sized random prime numbers -- for use in the + * Blum-Blum-Shub algorithm. * - * @param bits - * The number of bits of security - * @param rand - * A random instance to aid in generating primes + * @param bits The number of bits of security + * @param rand A random instance to aid in generating primes * @return A BigInteger, the n. */ public static BigInteger generateN(int bits, Random rand) { @@ -161,25 +136,20 @@ public class CSPRNG_DO_NOT_USE extends Random implements IRandomGenerator { } /** - * A constructor to specify the "n-value" to the Blum-Blum-Shub algorithm. - * The inital seed is computed using Java's internal "true" random number - * generator. + * A constructor to specify the "n-value" to the Blum-Blum-Shub algorithm. The inital seed is computed using Java's + * internal "true" random number generator. * - * @param n - * The n-value. + * @param n The n-value. */ public CSPRNG_DO_NOT_USE(BigInteger n) { this(n, SecureRandom.getSeed(n.bitLength() / 8)); } /** - * A constructor to specify both the n-value and the seed to the - * Blum-Blum-Shub algorithm. + * A constructor to specify both the n-value and the seed to the Blum-Blum-Shub algorithm. * - * @param n - * The n-value using a BigInteger - * @param seed - * The seed value using a byte[] array. + * @param n The n-value using a BigInteger + * @param seed The seed value using a byte[] array. */ public CSPRNG_DO_NOT_USE(BigInteger n, byte[] seed) { this.n = n; @@ -189,8 +159,7 @@ public class CSPRNG_DO_NOT_USE extends Random implements IRandomGenerator { /** * Sets or resets the seed value and internal state * - * @param seedBytes - * The new seed. + * @param seedBytes The new seed. */ public void setSeed(byte[] seedBytes) { // ADD: use hardwired default for n @@ -206,7 +175,7 @@ public class CSPRNG_DO_NOT_USE extends Random implements IRandomGenerator { @Override public int next(int numBits) { // TODO: find out how many LSB one can extract per cycle. - // it is more than one. + // it is more than one. int result = 0; for (int i = numBits; i != 0; --i) { state = state.modPow(two, n); diff --git a/src/main/java/gtPlusPlus/api/objects/random/UUIDGenerator.java b/src/main/java/gtPlusPlus/api/objects/random/UUIDGenerator.java index 8b70955e63..bfed0ce346 100644 --- a/src/main/java/gtPlusPlus/api/objects/random/UUIDGenerator.java +++ b/src/main/java/gtPlusPlus/api/objects/random/UUIDGenerator.java @@ -7,9 +7,8 @@ import java.util.UUID; /** * - * Implement modified version of Apache's OpenJPA UUID generator. - * This UUID generator is paired with a Blum-Blum-Shub random number generator - * which in itself is seeded by custom SecureRandom. + * Implement modified version of Apache's OpenJPA UUID generator. This UUID generator is paired with a Blum-Blum-Shub + * random number generator which in itself is seeded by custom SecureRandom. * * The UUID generator class has been converted from a static factory to an instanced factory. * @@ -18,36 +17,24 @@ import java.util.UUID; // ========================================= APACHE BLOCK ========================================= /* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE + * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by + * applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ /** - * UUID value generator. Type 1 generator is based on the time-based generator - * in the Apache Commons Id project: http://jakarta.apache.org/commons/sandbox - * /id/uuid.html The type 4 generator uses the standard Java UUID generator. + * UUID value generator. Type 1 generator is based on the time-based generator in the Apache Commons Id project: + * http://jakarta.apache.org/commons/sandbox /id/uuid.html The type 4 generator uses the standard Java UUID generator. * - * The type 1 code has been vastly simplified and modified to replace the - * ethernet address of the host machine with the IP, since we do not want to - * require native libs and Java cannot access the MAC address directly. + * The type 1 code has been vastly simplified and modified to replace the ethernet address of the host machine with the + * IP, since we do not want to require native libs and Java cannot access the MAC address directly. * * In spirit, implements the IETF UUID draft specification, found here:
- * http://www1.ics.uci.edu/~ejw/authoring/uuid-guid/draft-leach-uuids-guids-01 - * .txt + * http://www1.ics.uci.edu/~ejw/authoring/uuid-guid/draft-leach-uuids-guids-01 .txt * * @author Abe White, Kevin Sutter * @since 0.3.3 @@ -95,9 +82,9 @@ public class UUIDGenerator { private static final int MAX_14BIT = 0x3FFF; private short _seq = 0; private boolean type1Initialized = false; /* - * Initializer for type 1 UUIDs. Creates random generator and genenerates - * the node portion of the UUID using the IP address. - */ + * Initializer for type 1 UUIDs. Creates random generator and genenerates + * the node portion of the UUID using the IP address. + */ private synchronized void initializeForType1() { if (type1Initialized == true) { @@ -123,6 +110,7 @@ public class UUIDGenerator { } type1Initialized = true; } + /** * Return a unique UUID value. */ @@ -132,6 +120,7 @@ public class UUIDGenerator { } return createType1(); } + /* * Creates a type 1 UUID */ @@ -142,11 +131,11 @@ public class UUIDGenerator { // set ip addr byte[] uuid = new byte[16]; System.arraycopy(IP, 0, uuid, 10, IP.length); - // Set time info. Have to do this processing within a synchronized + // Set time info. Have to do this processing within a synchronized // block because of the statics... long now = 0; synchronized (UUIDGenerator.class) { - // Get the time to use for this uuid. This method has the side + // Get the time to use for this uuid. This method has the side // effect of modifying the clock sequence, as well. now = getTime(); // Insert the resulting clock sequence into the uuid @@ -166,6 +155,7 @@ public class UUIDGenerator { uuid[IDX_TYPE] |= TYPE_TIME_BASED; // 0001 0000 return uuid; } + /* * Creates a type 4 UUID */ @@ -176,9 +166,9 @@ public class UUIDGenerator { longToBytes(type4.getLeastSignificantBits(), uuid, 8); return uuid; } + /* - * Converts a long to byte values, setting them in a byte array - * at a given starting position. + * Converts a long to byte values, setting them in a byte array at a given starting position. */ private void longToBytes(long longVal, byte[] buf, int sPos) { sPos += 7; @@ -196,15 +186,16 @@ public class UUIDGenerator { return new String(bytes); } } + /** * Return the next unique