diff options
author | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:32:44 -0800 |
---|---|---|
committer | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:32:44 -0800 |
commit | 55f64675b42ac8d3c557cc850f78664bee006f6f (patch) | |
tree | 2afd26dd3d5e6f763119bc192b57c66a1a075922 /src/main/java/gtPlusPlus/api | |
parent | 0f5dfd01b877b6a1019e0671b88d07974aae68c0 (diff) | |
download | GT5-Unofficial-55f64675b42ac8d3c557cc850f78664bee006f6f.tar.gz GT5-Unofficial-55f64675b42ac8d3c557cc850f78664bee006f6f.tar.bz2 GT5-Unofficial-55f64675b42ac8d3c557cc850f78664bee006f6f.zip |
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/gtPlusPlus/api')
46 files changed, 470 insertions, 506 deletions
diff --git a/src/main/java/gtPlusPlus/api/damage/DamageTeslaTower.java b/src/main/java/gtPlusPlus/api/damage/DamageTeslaTower.java index e37a86aaa5..0d9d4d5dc2 100644 --- a/src/main/java/gtPlusPlus/api/damage/DamageTeslaTower.java +++ b/src/main/java/gtPlusPlus/api/damage/DamageTeslaTower.java @@ -1,11 +1,12 @@ package gtPlusPlus.api.damage; -import gtPlusPlus.core.world.damage.BaseCustomDamageSource; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IChatComponent; +import gtPlusPlus.core.world.damage.BaseCustomDamageSource; + public class DamageTeslaTower extends BaseCustomDamageSource { public DamageTeslaTower(Entity transmitter) { diff --git a/src/main/java/gtPlusPlus/api/enums/Quality.java b/src/main/java/gtPlusPlus/api/enums/Quality.java index d6f0667e20..efcf2a015f 100644 --- a/src/main/java/gtPlusPlus/api/enums/Quality.java +++ b/src/main/java/gtPlusPlus/api/enums/Quality.java @@ -1,8 +1,9 @@ package gtPlusPlus.api.enums; -import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.util.EnumChatFormatting; +import gtPlusPlus.core.util.math.MathUtils; + public enum Quality { // Magic Blue diff --git a/src/main/java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java b/src/main/java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java index 99e14cae01..a85bd42213 100644 --- a/src/main/java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java +++ b/src/main/java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java @@ -1,5 +1,10 @@ package gtPlusPlus.api.helpers; +import java.util.HashMap; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.WeightedCollection; import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; @@ -7,9 +12,6 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy_RTG; import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler; -import java.util.HashMap; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; public class GregtechPlusPlus_API { @@ -22,25 +24,25 @@ public class GregtechPlusPlus_API { public static class Multiblock_API { - private static final HashMap<String, SpecialMultiBehaviour> mSpecialBehaviourItemMap = - new HashMap<String, SpecialMultiBehaviour>(); + private static final HashMap<String, SpecialMultiBehaviour> mSpecialBehaviourItemMap = new HashMap<String, SpecialMultiBehaviour>(); /** * Register a special behaviour for GT++ Multis to listen use. + * * @param aBehaviour - An Object which has extended {@link SpecialMultiBehaviour}'s base implementation. * @return - Did this behaviour register properly? */ public static boolean registerSpecialMultiBehaviour(SpecialMultiBehaviour aBehaviour) { - if (aBehaviour.getTriggerItem() == null - || aBehaviour.getTriggerItemTooltip() == null + if (aBehaviour.getTriggerItem() == null || aBehaviour.getTriggerItemTooltip() == null || aBehaviour.getTriggerItemTooltip().length() <= 0) { - Logger.INFO("Failed to attach custom multiblock logic to " - + ItemUtils.getItemName(aBehaviour.getTriggerItem())); + Logger.INFO( + "Failed to attach custom multiblock logic to " + + ItemUtils.getItemName(aBehaviour.getTriggerItem())); return false; } mSpecialBehaviourItemMap.put("UniqueKey_" + aBehaviour.hashCode(), aBehaviour); - SpecialBehaviourTooltipHandler.addTooltipForItem( - aBehaviour.getTriggerItem(), aBehaviour.getTriggerItemTooltip()); + SpecialBehaviourTooltipHandler + .addTooltipForItem(aBehaviour.getTriggerItem(), aBehaviour.getTriggerItemTooltip()); Logger.INFO("Attached custom multiblock logic to " + ItemUtils.getItemName(aBehaviour.getTriggerItem())); return true; } @@ -51,7 +53,8 @@ public class GregtechPlusPlus_API { /** * Allows RTG Fuel pellets from other mods to be used in the RTG hatch. - * @param aStack - The Pellet Stack, sanitsed after passing through. + * + * @param aStack - The Pellet Stack, sanitsed after passing through. * @param aFuelValue - The Fuel Value of the Pellet to be added to the energy storage. * @return - Did register? */ @@ -71,7 +74,8 @@ public class GregtechPlusPlus_API { /** * * Registers an ore block for a dimension. Uses a default weight of 100. - * @param aDim - The Dimension ID + * + * @param aDim - The Dimension ID * @param aOredictName - The OreDict name of the Ore to be mined. * @return - If there was a valid Block found in the OreDict for the provided name. */ @@ -82,9 +86,10 @@ public class GregtechPlusPlus_API { /** * * Registers an ore block for a dimension. Uses a default weight of 100. - * @param aDim - The Dimension ID + * + * @param aDim - The Dimension ID * @param aOredictName - The OreDict name of the Ore to be mined. - * @param aWeight - The weight of this ore Block. + * @param aWeight - The weight of this ore Block. * @return - If there was a valid Block found in the OreDict for the provided name. */ public static boolean registerOreForVoidMiner(int aDim, String aOredictName, int aWeight) { @@ -107,7 +112,8 @@ public class GregtechPlusPlus_API { /** * Registers an ore block for a dimension. Uses a default weight of 100. - * @param aDim - The Dimension ID + * + * @param aDim - The Dimension ID * @param aOreBlock - The Ore Block to be mined. */ public static void registerOreForVoidMiner(int aDim, Block aOreBlock) { @@ -116,9 +122,10 @@ public class GregtechPlusPlus_API { /** * Registers an ore block for a dimension. - * @param aDim - The Dimension ID + * + * @param aDim - The Dimension ID * @param aOreBlock - The Ore Block to be mined. - * @param aWeight - The weight of this ore Block. + * @param aWeight - The weight of this ore Block. */ public static void registerOreForVoidMiner(int aDim, Block aOreBlock, int aWeight) { GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aOreBlock, aWeight); @@ -126,7 +133,8 @@ public class GregtechPlusPlus_API { /** * Registers a surface block for a dimension. Uses a default weight of 100. - * @param aDim - The Dimension ID + * + * @param aDim - The Dimension ID * @param aDirtBlock - The Dirt/Grass Block to be mined. */ public static void registerEarthSurfaceForVoidMiner(int aDim, Block aDirtBlock) { @@ -135,9 +143,10 @@ public class GregtechPlusPlus_API { /** * Registers a surface block for a dimension. - * @param aDim - The Dimension ID + * + * @param aDim - The Dimension ID * @param aDirtBlock - The Dirt/Grass Block to be mined. - * @param aWeight - The weight of this Dirt/Grass Block. + * @param aWeight - The weight of this Dirt/Grass Block. */ public static void registerEarthSurfaceForVoidMiner(int aDim, Block aDirtBlock, int aWeight) { GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aDirtBlock, aWeight); @@ -145,7 +154,8 @@ public class GregtechPlusPlus_API { /** * Registers a stone block for a dimension. Uses a default weight of 100. - * @param aDim - The Dimension ID + * + * @param aDim - The Dimension ID * @param aStoneBlock - The Stone Block to be mined. */ public static void registerEarthStoneForVoidMiner(int aDim, Block aStoneBlock) { @@ -154,9 +164,10 @@ public class GregtechPlusPlus_API { /** * Registers a stone block for a dimension. - * @param aDim - The Dimension ID + * + * @param aDim - The Dimension ID * @param aStoneBlock - The Stone Block to be mined. - * @param aWeight - The weight of this Stone Block. + * @param aWeight - The weight of this Stone Block. */ public static void registerEarthStoneForVoidMiner(int aDim, Block aStoneBlock, int aWeight) { GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aStoneBlock, aWeight); @@ -190,8 +201,8 @@ public class GregtechPlusPlus_API { aMappedBlocks.put(aWeight, aBlock); } - private static WeightedCollection<Block> getBlockMap( - int aType, HashMap<String, WeightedCollection<Block>> aDimMap) { + private static WeightedCollection<Block> getBlockMap(int aType, + HashMap<String, WeightedCollection<Block>> aDimMap) { WeightedCollection<Block> aMappedBlocks; String aTypeName = ((aType == 0) ? "ore" : (aType == 1) ? "dirt" : (aType == 2) ? "stone" : "error"); aMappedBlocks = aDimMap.get(aTypeName); diff --git a/src/main/java/gtPlusPlus/api/helpers/MaterialHelper.java b/src/main/java/gtPlusPlus/api/helpers/MaterialHelper.java index 3f14a9de03..dccb7371d5 100644 --- a/src/main/java/gtPlusPlus/api/helpers/MaterialHelper.java +++ b/src/main/java/gtPlusPlus/api/helpers/MaterialHelper.java @@ -1,5 +1,10 @@ package gtPlusPlus.api.helpers; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +import net.minecraft.item.ItemStack; + import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid; @@ -7,9 +12,6 @@ import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import net.minecraft.item.ItemStack; public class MaterialHelper { @@ -23,38 +25,25 @@ public class MaterialHelper { /** * Generates a 16 Fluid Pipe + * * @see {@code Example: Copper 16x Pipe (Materials.Copper, Materials.Copper.mName, "Copper", ID, 60, 1000, true)} - * @param aMaterial - Pipe Material - * @param name - Pipe Internal name - * @param displayName - Pipe Display Name - * @param aID - Pipe's Meta ID + * @param aMaterial - Pipe Material + * @param name - Pipe Internal name + * @param displayName - Pipe Display Name + * @param aID - Pipe's Meta ID * @param baseCapacity - Pipes Base Capacity * @param heatCapacity - Pipe Max Temp - * @param gasProof - Is Gas Proof? + * @param gasProof - Is Gas Proof? * @return A boolean which corresponds to whether or not the Pipe was registered to the Ore Dictionary. */ - public static boolean generateHexadecuplePipe( - Materials aMaterial, - String name, - String displayName, - int aID, - int baseCapacity, - int heatCapacity, - boolean gasProof) { + public static boolean generateHexadecuplePipe(Materials aMaterial, String name, String displayName, int aID, + int baseCapacity, int heatCapacity, boolean gasProof) { if (Utils.getGregtechVersionAsInt() >= 50930) { try { Class<GT_MetaPipeEntity_Fluid> aPipeEntity = GT_MetaPipeEntity_Fluid.class; - Constructor<GT_MetaPipeEntity_Fluid> constructor = aPipeEntity.getConstructor(new Class[] { - int.class, - String.class, - String.class, - float.class, - Materials.class, - int.class, - int.class, - boolean.class, - int.class - }); + Constructor<GT_MetaPipeEntity_Fluid> constructor = aPipeEntity.getConstructor( + new Class[] { int.class, String.class, String.class, float.class, Materials.class, int.class, + int.class, boolean.class, int.class }); if (constructor != null) { GT_MetaPipeEntity_Fluid aPipe; aPipe = constructor.newInstance( @@ -70,13 +59,8 @@ public class MaterialHelper { return GT_OreDictUnificator.registerOre("pipeHexadecuple" + aMaterial, aPipe.getStackForm(1L)); } - } catch (NoSuchMethodException - | SecurityException - | InstantiationException - | IllegalAccessException - | IllegalArgumentException - | InvocationTargetException e) { - } + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) {} } return false; } diff --git a/src/main/java/gtPlusPlus/api/interfaces/IChunkLoader.java b/src/main/java/gtPlusPlus/api/interfaces/IChunkLoader.java index ad65c03429..cec4d12716 100644 --- a/src/main/java/gtPlusPlus/api/interfaces/IChunkLoader.java +++ b/src/main/java/gtPlusPlus/api/interfaces/IChunkLoader.java @@ -1,6 +1,7 @@ package gtPlusPlus.api.interfaces; import java.util.Set; + import net.minecraft.world.ChunkCoordIntPair; public interface IChunkLoader { diff --git a/src/main/java/gtPlusPlus/api/interfaces/IComparableRecipe.java b/src/main/java/gtPlusPlus/api/interfaces/IComparableRecipe.java index 830b34a41d..06727167bf 100644 --- a/src/main/java/gtPlusPlus/api/interfaces/IComparableRecipe.java +++ b/src/main/java/gtPlusPlus/api/interfaces/IComparableRecipe.java @@ -2,4 +2,5 @@ package gtPlusPlus.api.interfaces; import gregtech.api.util.GT_Recipe; -public interface IComparableRecipe extends Comparable<GT_Recipe> {} +public interface IComparableRecipe extends Comparable<GT_Recipe> { +} diff --git a/src/main/java/gtPlusPlus/api/interfaces/IEntityCatcher.java b/src/main/java/gtPlusPlus/api/interfaces/IEntityCatcher.java index 9e3ea89606..e3aa00e7a1 100644 --- a/src/main/java/gtPlusPlus/api/interfaces/IEntityCatcher.java +++ b/src/main/java/gtPlusPlus/api/interfaces/IEntityCatcher.java @@ -1,10 +1,11 @@ package gtPlusPlus.api.interfaces; -import gtPlusPlus.api.objects.minecraft.BlockPos; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import gtPlusPlus.api.objects.minecraft.BlockPos; + public interface IEntityCatcher { public boolean hasEntity(ItemStack aStack); diff --git a/src/main/java/gtPlusPlus/api/interfaces/IGeneratorWorld.java b/src/main/java/gtPlusPlus/api/interfaces/IGeneratorWorld.java index 251eaa416c..95cd46e443 100644 --- a/src/main/java/gtPlusPlus/api/interfaces/IGeneratorWorld.java +++ b/src/main/java/gtPlusPlus/api/interfaces/IGeneratorWorld.java @@ -1,9 +1,11 @@ package gtPlusPlus.api.interfaces; import java.util.Random; + import net.minecraft.world.World; public abstract interface IGeneratorWorld { + public abstract boolean generate(World paramWorld, Random paramRandom, int paramInt1, int paramInt2); public abstract void initiate(); diff --git a/src/main/java/gtPlusPlus/api/interfaces/IGregtechPower.java b/src/main/java/gtPlusPlus/api/interfaces/IGregtechPower.java index b4223fb558..64c2198662 100644 --- a/src/main/java/gtPlusPlus/api/interfaces/IGregtechPower.java +++ b/src/main/java/gtPlusPlus/api/interfaces/IGregtechPower.java @@ -1,12 +1,13 @@ package gtPlusPlus.api.interfaces; -import gregtech.api.interfaces.IDescribable; -import gregtech.api.interfaces.tileentity.*; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import gregtech.api.interfaces.IDescribable; +import gregtech.api.interfaces.tileentity.*; + public abstract interface IGregtechPower extends IGearEnergyTileEntity, ITurnable, IGregTechDeviceInformation, IDescribable, IBasicEnergyContainer { @@ -134,10 +135,9 @@ public abstract interface IGregtechPower return true; } - /* boolean onPreTick(TilePoweredGT tilePoweredGT, long mTickTimer2); - - boolean onTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2); - - boolean onPostTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2);*/ + /* + * boolean onPreTick(TilePoweredGT tilePoweredGT, long mTickTimer2); boolean onTick(TilePoweredGT + * iGregTechTileEntity, long mTickTimer2); boolean onPostTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2); + */ } diff --git a/src/main/java/gtPlusPlus/api/interfaces/IPlugin.java b/src/main/java/gtPlusPlus/api/interfaces/IPlugin.java index 1f7991540a..d70a19925e 100644 --- a/src/main/java/gtPlusPlus/api/interfaces/IPlugin.java +++ b/src/main/java/gtPlusPlus/api/interfaces/IPlugin.java @@ -10,9 +10,8 @@ public interface IPlugin { public String getPluginName(); /** - * @return - * A {@link String} object which returns the {@link IPlugin}'s short name. - * This String should only contain 4 Characters. + * @return A {@link String} object which returns the {@link IPlugin}'s short name. This String should only contain 4 + * Characters. */ public String getPluginAbbreviation(); diff --git a/src/main/java/gtPlusPlus/api/interfaces/IRandomGenerator.java b/src/main/java/gtPlusPlus/api/interfaces/IRandomGenerator.java index b61528e4b9..ddb4d4d2f1 100644 --- a/src/main/java/gtPlusPlus/api/interfaces/IRandomGenerator.java +++ b/src/main/java/gtPlusPlus/api/interfaces/IRandomGenerator.java @@ -1,35 +1,18 @@ /* - * 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 */ @@ -47,6 +30,7 @@ public interface IRandomGenerator { * Returns N random bits * * See also java.util.Random#next + * * @param numBits * @return and int with the LSB being random */ diff --git a/src/main/java/gtPlusPlus/api/interfaces/ITexturedBlock.java b/src/main/java/gtPlusPlus/api/interfaces/ITexturedBlock.java index 815c399caf..5f45964ca8 100644 --- a/src/main/java/gtPlusPlus/api/interfaces/ITexturedBlock.java +++ b/src/main/java/gtPlusPlus/api/interfaces/ITexturedBlock.java @@ -1,8 +1,9 @@ package gtPlusPlus.api.interfaces; +import net.minecraft.block.Block; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ITexturedTileEntity; -import net.minecraft.block.Block; public interface ITexturedBlock extends ITexturedTileEntity { 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<V> implements Iterable<V>, Cloneable, Serializable, Collect /** * Generates an AutoMap from the List. + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(List<V> aList) { @@ -45,8 +46,10 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect } } } + /** * Generates an AutoMap from a Set. + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(Set<V> aList) { @@ -58,8 +61,10 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collect } } } + /** * Generates an AutoMap from a Collection. + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(Collection<V> aList) { @@ -74,6 +79,7 @@ public class AutoMap<V> implements Iterable<V>, 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<K, V> 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<K, V> { + private static final Object FREE_KEY = new Object(); private static final Object REMOVED_KEY = new Object(); @@ -51,7 +52,7 @@ public class ObjMap<K, V> { 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<K, V> { 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<K, V> { 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<K, V> { /** 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. * - * <p>Note that this function will return 1 when the argument is 0. + * <p> + * Note that this function will return 1 when the argument is 0. * * @param x a long integer smaller than or equal to 2<sup>62</sup>. * @return the least power of two greater than or equal to the specified value. @@ -214,18 +217,19 @@ public class ObjMap<K, V> { return (x | x >> 32) + 1; } - /** Returns the least power of two smaller than or equal to 2<sup>30</sup> and larger than or equal to <code>Math.ceil( expected / f )</code>. + /** + * Returns the least power of two smaller than or equal to 2<sup>30</sup> and larger than or equal to + * <code>Math.ceil( expected / f )</code>. * * @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 2<sup>30</sup>. */ 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<K, V> 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<V> implements Set<V> { - private Map<String, InternalTypeCounterObject<V>> mInternalMap = - new LinkedHashMap<String, InternalTypeCounterObject<V>>(); + private Map<String, InternalTypeCounterObject<V>> mInternalMap = new LinkedHashMap<String, InternalTypeCounterObject<V>>(); private String mHighestValueKey; private int mHighestValue = 0; private final Class mClass; @@ -21,6 +21,7 @@ public class TypeCounter<V> implements Set<V> { } public static class InternalTypeCounterObject<Z> { + 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<E> implements Map<Integer, E> { private NavigableMap<Integer, E> map = new TreeMap<Integer, E>(); 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<T> extends AutoMap<T> { + 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<Integer> tList = new ArrayList<Integer>(); 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<T> { 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<String, FakeBlockPos> 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<String, FakeBlockPos>(); - 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<String, FakeBlockPos>(); 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<String, FakeBlockPos>(); 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<String> { /** * 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<GT_Recipe> { 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<Character, Object>(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<Character, Object>(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<IIcon> mAnimationArray = new AutoMap<IIcon>(); 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<String, Pair<BlockPos, TileEntityPooCollector>> mPooCollectors = - new LinkedHashMap<String, Pair<BlockPos, TileEntityPooCollector>>(); + private static final HashMap<String, Pair<BlockPos, TileEntityPooCollector>> mPooCollectors = new LinkedHashMap<String, Pair<BlockPos, TileEntityPooCollector>>(); 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<EntityAnimal> animals = - w.getEntitiesWithinAABB(EntityAnimal.class, box); + List<EntityAnimal> 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. * * <p> - * The Blum-Blum-Shub is a "cryptographically secure" random number - * generator. It has been proven that predicting the ouput - * is equivalent to factoring <i>n</i>, 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 <i>n</i>, a large integer generated from two prime numbers. * </p> * * <p> * The Algorithm: * </p> * <ol> - * <li> - * (setup) generate two secret prime numbers <i>p</i>, <i>q</i> such that - * <i>p</i> ≠ <i>q</i>, <i>p</i> ≡ 3 mod 4, <i>q</i> ≡ 3 mod 4. - * </li> - * <li> (setup) compute <i>n</i> = <i>pq</i>. <i>n</i> can be re-used, but - * <i>p</i>, and <i>q</i> are secret and should be disposed of.</li> - * <li> Generate a (secure) random seed <i>s</i> in the range [1, <i>n</i> -1] - * such that gcd(<i>s</i>, <i>n</i>) = 1. - * <li> Compute <i>x</i> = <i>s</i><sup>2</sup> mod <i>n</i></li> - * <li> Compute a single random bit with: - * <ol> - * <li> <i>x</i> = <i>x</i><sup>2</sup> mod <i>n</i></li> - * <li> return Least-Significant-Bit(<i>x</i>) (i.e. <i>x</i> & 1)</li> - * </ol> - * Repeat as necessary. - * </li> + * <li>(setup) generate two secret prime numbers <i>p</i>, <i>q</i> such that <i>p</i> ≠ <i>q</i>, <i>p</i> ≡ 3 + * mod 4, <i>q</i> ≡ 3 mod 4.</li> + * <li>(setup) compute <i>n</i> = <i>pq</i>. <i>n</i> can be re-used, but <i>p</i>, and <i>q</i> are secret and should + * be disposed of.</li> + * <li>Generate a (secure) random seed <i>s</i> in the range [1, <i>n</i> -1] such that gcd(<i>s</i>, <i>n</i>) = 1. + * <li>Compute <i>x</i> = <i>s</i><sup>2</sup> mod <i>n</i></li> + * <li>Compute a single random bit with: + * <ol> + * <li><i>x</i> = <i>x</i><sup>2</sup> mod <i>n</i></li> + * <li>return Least-Significant-Bit(<i>x</i>) (i.e. <i>x</i> & 1)</li> + * </ol> + * Repeat as necessary.</li> * </ol> * * <p> - * The code originally appeared in <a href="http://modp.com/cida/"><i>Cryptography for - * Internet and Database Applications </i>, Chapter 4, pages 174-177</a> + * The code originally appeared in <a href="http://modp.com/cida/"><i>Cryptography for Internet and Database + * Applications </i>, Chapter 4, pages 174-177</a> * </p> * <p> - * More details are in the <a href="http://www.cacr.math.uwaterloo.ca/hac/"><i>Handbook of Applied Cryptography</i></a>, + * More details are in the <a href="http://www.cacr.math.uwaterloo.ca/hac/"><i>Handbook of Applied Cryptography</i></a>, * <a href="http://www.cacr.math.uwaterloo.ca/hac/about/chap5.pdf">Section 5.5.2</a> * </p> * @@ -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 <i>n</i>. */ 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:<br /> - * 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 uuid value as a 32-character hex string. */ public String nextHex(int type) { return Base16Encoder.encode(next(type)); } + /** - * Get the timestamp to be used for this uuid. Must be called from - * a synchronized block. + * Get the timestamp to be used for this uuid. Must be called from a synchronized block. * * @return long timestamp */ @@ -219,12 +210,11 @@ public class UUIDGenerator { _lastMillis = newTime; return newTime; } + /** - * Gets the appropriately modified timestamep for the UUID. Must be called - * from a synchronized block. + * Gets the appropriately modified timestamep for the UUID. Must be called from a synchronized block. * - * @return long timestamp in 100ns intervals since the Gregorian change - * offset + * @return long timestamp in 100ns intervals since the Gregorian change offset */ private long getUUIDTime() { if (_currentMillis != System.currentTimeMillis()) { @@ -233,7 +223,7 @@ public class UUIDGenerator { } // check to see if we have created too many uuid's for this timestamp if (_counter + 1 >= MILLI_MULT) { - // Original algorithm threw exception. Seemed like overkill. + // Original algorithm threw exception. Seemed like overkill. // Let's just increment the timestamp instead and start over... _currentMillis++; _counter = 0; @@ -243,9 +233,9 @@ public class UUIDGenerator { // return the uuid time plus the artificial tick counter incremented return currentTime + _counter++; } + /** - * Increments the clock sequence for this uuid. Must be called from a - * synchronized block. + * Increments the clock sequence for this uuid. Must be called from a synchronized block. */ private void incrementSequence() { // increment, but if it's greater than its 14-bits, reset it @@ -257,17 +247,22 @@ public class UUIDGenerator { // Add Dependant classes internally /** - * This class came from the Apache Commons Id sandbox project in support - * of the UUIDGenerator implementation. + * This class came from the Apache Commons Id sandbox project in support of the UUIDGenerator implementation. * - * <p>Static methods for managing byte arrays (all methods follow Big - * Endian order where most significant bits are in front).</p> + * <p> + * Static methods for managing byte arrays (all methods follow Big Endian order where most significant bits are in + * front). + * </p> */ public static final class Bytes { + /** - * <p>Hide constructor in utility class.</p> + * <p> + * Hide constructor in utility class. + * </p> */ private Bytes() {} + /** * Appends two bytes array into one. * @@ -281,6 +276,7 @@ public class UUIDGenerator { System.arraycopy(b, 0, z, a.length, b.length); return z; } + /** * Returns a 8-byte array built from a long. * @@ -290,9 +286,9 @@ public class UUIDGenerator { public static byte[] toBytes(long n) { return toBytes(n, new byte[8]); } + /** - * Build a 8-byte array from a long. No check is performed on the - * array length. + * Build a 8-byte array from a long. No check is performed on the array length. * * @param n The number to convert. * @param b The array to fill. @@ -317,6 +313,7 @@ public class UUIDGenerator { return b; } + /** * Build a long from first 8 bytes of the array. * @@ -324,8 +321,7 @@ public class UUIDGenerator { * @return A long. */ public static long toLong(byte[] b) { - return ((((long) b[7]) & 0xFF) - + ((((long) b[6]) & 0xFF) << 8) + return ((((long) b[7]) & 0xFF) + ((((long) b[6]) & 0xFF) << 8) + ((((long) b[5]) & 0xFF) << 16) + ((((long) b[4]) & 0xFF) << 24) + ((((long) b[3]) & 0xFF) << 32) @@ -333,6 +329,7 @@ public class UUIDGenerator { + ((((long) b[1]) & 0xFF) << 48) + ((((long) b[0]) & 0xFF) << 56)); } + /** * Compares two byte arrays for equality. * @@ -352,14 +349,15 @@ public class UUIDGenerator { } return true; } + /** - * <p>Compares two byte arrays as specified by <code>Comparable</code>. + * <p> + * Compares two byte arrays as specified by <code>Comparable</code>. * * @param lhs - left hand value in the comparison operation. * @param rhs - right hand value in the comparison operation. - * @return a negative integer, zero, or a positive integer as - * <code>lhs</code> is less than, equal to, or greater than - * <code>rhs</code>. + * @return a negative integer, zero, or a positive integer as <code>lhs</code> is less than, equal to, or + * greater than <code>rhs</code>. */ public static int compareTo(byte[] lhs, byte[] rhs) { if (lhs == rhs) { @@ -383,6 +381,7 @@ public class UUIDGenerator { } return 0; } + /** * Build a short from first 2 bytes of the array. * @@ -393,6 +392,7 @@ public class UUIDGenerator { return (short) ((b[1] & 0xFF) + ((b[0] & 0xFF) << 8)); } } + /** * Base 16 encoder. * @@ -400,10 +400,9 @@ public class UUIDGenerator { */ public static final class Base16Encoder { - private static final char[] HEX = new char[] { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' - }; + private static final char[] HEX = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', + 'D', 'E', 'F' }; + /** * Convert bytes to a base16 string. */ @@ -413,6 +412,7 @@ public class UUIDGenerator { for (int j = 1; j >= 0; j--) hexBuffer.append(HEX[(byteArray[i] >> (j * 4)) & 0xF]); return hexBuffer.toString(); } + /** * Convert a base16 string into a byte array. */ diff --git a/src/main/java/gtPlusPlus/api/objects/random/XSTR.java b/src/main/java/gtPlusPlus/api/objects/random/XSTR.java index aaaa7a4d1d..087f9535ce 100644 --- a/src/main/java/gtPlusPlus/api/objects/random/XSTR.java +++ b/src/main/java/gtPlusPlus/api/objects/random/XSTR.java @@ -1,36 +1,28 @@ package gtPlusPlus.api.objects.random; + /** - * A subclass of java.util.random that implements the Xorshift random number - * generator + * A subclass of java.util.random that implements the Xorshift random number generator * - * - it is 30% faster than the generator from Java's library - it produces - * random sequences of higher quality than java.util.Random - this class also - * provides a clone() function + * - it is 30% faster than the generator from Java's library - it produces random sequences of higher quality than + * java.util.Random - this class also provides a clone() function * - * Usage: XSRandom rand = new XSRandom(); //Instantiation x = rand.nextInt(); - * //pull a random number + * Usage: XSRandom rand = new XSRandom(); //Instantiation x = rand.nextInt(); //pull a random number * - * To use the class in legacy code, you may also instantiate an XSRandom object - * and assign it to a java.util.Random object: java.util.Random rand = new - * XSRandom(); + * To use the class in legacy code, you may also instantiate an XSRandom object and assign it to a java.util.Random + * object: java.util.Random rand = new XSRandom(); * - * for an explanation of the algorithm, see - * http://demesos.blogspot.com/2011/09/pseudo-random-number-generators.html + * for an explanation of the algorithm, see http://demesos.blogspot.com/2011/09/pseudo-random-number-generators.html * - * @author Wilfried Elmenreich University of Klagenfurt/Lakeside Labs - * http://www.elmenreich.tk + * @author Wilfried Elmenreich University of Klagenfurt/Lakeside Labs http://www.elmenreich.tk * - * This code is released under the GNU Lesser General Public License Version 3 - * http://www.gnu.org/licenses/lgpl-3.0.txt + * This code is released under the GNU Lesser General Public License Version 3 + * http://www.gnu.org/licenses/lgpl-3.0.txt */ import java.util.Random; import java.util.concurrent.atomic.AtomicLong; /** - * XSTR - Xorshift ThermiteRandom - * Modified by Bogdan-G - * 03.06.2016 - * version 0.0.4 + * XSTR - Xorshift ThermiteRandom Modified by Bogdan-G 03.06.2016 version 0.0.4 */ public class XSTR extends Random implements Cloneable { @@ -40,16 +32,14 @@ public class XSTR extends Random implements Cloneable { private static final long GAMMA = 0x9e3779b97f4a7c15L; private static final int PROBE_INCREMENT = 0x9e3779b9; private static final long SEEDER_INCREMENT = 0xbb67ae8584caa73bL; - private static final double DOUBLE_UNIT = 0x1.0p-53; // 1.0 / (1L << 53) + private static final double DOUBLE_UNIT = 0x1.0p-53; // 1.0 / (1L << 53) private static final float FLOAT_UNIT = 0x1.0p-24f; // 1.0f / (1 << 24) /* - MODIFIED BY: Robotia - Modification: Implemented Random class seed generator - */ + * MODIFIED BY: Robotia Modification: Implemented Random class seed generator + */ /** - * Creates a new pseudo random number generator. The seed is initialized to - * the current time, as if by + * Creates a new pseudo random number generator. The seed is initialized to the current time, as if by * <code>setSeed(System.currentTimeMillis());</code>. */ public XSTR() { @@ -61,7 +51,7 @@ public class XSTR extends Random implements Cloneable { private static long seedUniquifier() { // L'Ecuyer, "Tables of Linear Congruential Generators of // Different Sizes and Good Lattice Structure", 1999 - for (; ; ) { + for (;;) { final long current = seedUniquifier.get(); final long next = current * 181783497276652981L; if (seedUniquifier.compareAndSet(current, next)) { @@ -71,8 +61,8 @@ public class XSTR extends Random implements Cloneable { } /** - * Creates a new pseudo random number generator, starting with the specified - * seed, using <code>setSeed(seed);</code>. + * Creates a new pseudo random number generator, starting with the specified seed, using + * <code>setSeed(seed);</code>. * * @param seed the initial seed */ @@ -89,6 +79,7 @@ public class XSTR extends Random implements Cloneable { public double nextDouble() { return (((long) (this.next(26)) << 27) + this.next(27)) * DOUBLE_UNIT; } + /** * Returns the current state of the seed, can be used to clone the object * @@ -99,9 +90,8 @@ public class XSTR extends Random implements Cloneable { } /** - * Sets the seed for this pseudo random number generator. As described - * above, two instances of the same random class, starting with the same - * seed, produce the same results, if the same methods are called. + * Sets the seed for this pseudo random number generator. As described above, two instances of the same random + * class, starting with the same seed, produce the same results, if the same methods are called. * * @param seed the new seed */ @@ -125,9 +115,8 @@ public class XSTR extends Random implements Cloneable { } /** - * Implementation of George Marsaglia's elegant Xorshift random generator - * 30% faster and better quality than the built-in java.util.random see also - * see http://www.javamex.com/tutorials/random_numbers/xorshift.shtml + * Implementation of George Marsaglia's elegant Xorshift random generator 30% faster and better quality than the + * built-in java.util.random see also see http://www.javamex.com/tutorials/random_numbers/xorshift.shtml * * @param nbits * @return @@ -164,16 +153,16 @@ public class XSTR extends Random implements Cloneable { this.haveNextNextGaussian = true; return v1 * multiplier; } + /** - * Returns a pseudorandom, uniformly distributed {@code int} value between 0 - * (inclusive) and the specified value (exclusive), drawn from this random - * number generator's sequence. The general contract of {@code nextInt} is - * that one {@code int} value in the specified range is pseudorandomly - * generated and returned. All {@code bound} possible {@code int} values are - * produced with (approximately) equal probability. The method - * {@code nextInt(int bound)} is implemented by class {@code Random} as if - * by: - * <pre> {@code + * Returns a pseudorandom, uniformly distributed {@code int} value between 0 (inclusive) and the specified value + * (exclusive), drawn from this random number generator's sequence. The general contract of {@code nextInt} is that + * one {@code int} value in the specified range is pseudorandomly generated and returned. All {@code bound} possible + * {@code int} values are produced with (approximately) equal probability. The method {@code nextInt(int bound)} is + * implemented by class {@code Random} as if by: + * + * <pre> + * {@code * public int nextInt(int bound) { * if (bound <= 0) * throw new IllegalArgumentException("bound must be positive"); @@ -187,35 +176,29 @@ public class XSTR extends Random implements Cloneable { * val = bits % bound; * } while (bits - val + (bound-1) < 0); * return val; - * }}</pre> + * }} + * </pre> * - * <p>The hedge "approx - * imately" is used in the foregoing description only because the next - * method is only approximately an unbiased source of independently chosen - * bits. If it were a perfect source of randomly chosen bits, then the - * algorithm shown would choose {@code int} values from the stated range - * with perfect uniformity. * <p> - * The algorithm is slightly tricky. It rejects values that would result in - * an uneven distribution (due to the fact that 2^31 is not divisible by n). - * The probability of a value being rejected depends on n. The worst case is - * n=2^30+1, for which the probability of a reject is 1/2, and the expected - * number of iterations before the loop terminates is 2. + * The hedge "approx imately" is used in the foregoing description only because the next method is only + * approximately an unbiased source of independently chosen bits. If it were a perfect source of randomly chosen + * bits, then the algorithm shown would choose {@code int} values from the stated range with perfect uniformity. * <p> - * The algorithm treats the case where n is a power of two specially: it - * returns the correct number of high-order bits from the underlying - * pseudo-random number generator. In the absence of special treatment, the - * correct number of <i>low-order</i> bits would be returned. Linear - * congruential pseudo-random number generators such as the one implemented - * by this class are known to have short periods in the sequence of values - * of their low-order bits. Thus, this special case greatly increases the - * length of the sequence of values returned by successive calls to this - * method if n is a small power of two. + * The algorithm is slightly tricky. It rejects values that would result in an uneven distribution (due to the fact + * that 2^31 is not divisible by n). The probability of a value being rejected depends on n. The worst case is + * n=2^30+1, for which the probability of a reject is 1/2, and the expected number of iterations before the loop + * terminates is 2. + * <p> + * The algorithm treats the case where n is a power of two specially: it returns the correct number of high-order + * bits from the underlying pseudo-random number generator. In the absence of special treatment, the correct number + * of <i>low-order</i> bits would be returned. Linear congruential pseudo-random number generators such as the one + * implemented by this class are known to have short periods in the sequence of values of their low-order bits. + * Thus, this special case greatly increases the length of the sequence of values returned by successive calls to + * this method if n is a small power of two. * * @param bound the upper bound (exclusive). Must be positive. - * @return the next pseudorandom, uniformly distributed {@code int} value - * between zero (inclusive) and {@code bound} (exclusive) from this random - * number generator's sequence + * @return the next pseudorandom, uniformly distributed {@code int} value between zero (inclusive) and {@code bound} + * (exclusive) from this random number generator's sequence * @throws IllegalArgumentException if bound is not positive * @since 1.2 */ @@ -229,18 +212,10 @@ public class XSTR extends Random implements Cloneable { newBound = bound; } - /*int r = next(31); - int m = bound - 1; - if ((bound & m) == 0) // i.e., bound is a power of 2 - { - r = (int) ((bound * (long) r) >> 31); - } else { - for (int u = r; - u - (r = u % bound) + m < 0; - u = next(31)) - ; - } - return r;*/ + /* + * int r = next(31); int m = bound - 1; if ((bound & m) == 0) // i.e., bound is a power of 2 { r = (int) ((bound + * * (long) r) >> 31); } else { for (int u = r; u - (r = u % bound) + m < 0; u = next(31)) ; } return r; + */ // speedup, new nextInt ~+40% this.last = this.seed ^ (this.seed << 21); this.last ^= (this.last >>> 35); @@ -268,10 +243,9 @@ public class XSTR extends Random implements Cloneable { @Override public void nextBytes(final byte[] bytes_arr) { - for (int iba = 0, lenba = bytes_arr.length; iba < lenba; ) { - for (int rndba = this.nextInt(), nba = Math.min(lenba - iba, Integer.SIZE / Byte.SIZE); - nba-- > 0; - rndba >>= Byte.SIZE) { + for (int iba = 0, lenba = bytes_arr.length; iba < lenba;) { + for (int rndba = this.nextInt(), nba = Math.min(lenba - iba, Integer.SIZE / Byte.SIZE); nba-- + > 0; rndba >>= Byte.SIZE) { bytes_arr[iba++] = (byte) rndba; } } diff --git a/src/main/java/gtPlusPlus/api/thermal/energy/IThermalConnection.java b/src/main/java/gtPlusPlus/api/thermal/energy/IThermalConnection.java index c495f4856b..fce4ad7c55 100644 --- a/src/main/java/gtPlusPlus/api/thermal/energy/IThermalConnection.java +++ b/src/main/java/gtPlusPlus/api/thermal/energy/IThermalConnection.java @@ -3,5 +3,6 @@ package gtPlusPlus.api.thermal.energy; import net.minecraftforge.common.util.ForgeDirection; public interface IThermalConnection { + boolean canConnectThermalEnergy(ForgeDirection arg0); } diff --git a/src/main/java/gtPlusPlus/api/thermal/sample/ItemThermalContainer.java b/src/main/java/gtPlusPlus/api/thermal/sample/ItemThermalContainer.java index eb4b42259d..57eb1d2c43 100644 --- a/src/main/java/gtPlusPlus/api/thermal/sample/ItemThermalContainer.java +++ b/src/main/java/gtPlusPlus/api/thermal/sample/ItemThermalContainer.java @@ -1,11 +1,13 @@ package gtPlusPlus.api.thermal.sample; -import gtPlusPlus.api.thermal.energy.IThermalContainerItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import gtPlusPlus.api.thermal.energy.IThermalContainerItem; + public class ItemThermalContainer extends Item implements IThermalContainerItem { + protected int capacity; protected int maxReceive; protected int maxExtract; diff --git a/src/main/java/gtPlusPlus/api/thermal/sample/TileThermalHandler.java b/src/main/java/gtPlusPlus/api/thermal/sample/TileThermalHandler.java index 57f1d64f16..8ee401c474 100644 --- a/src/main/java/gtPlusPlus/api/thermal/sample/TileThermalHandler.java +++ b/src/main/java/gtPlusPlus/api/thermal/sample/TileThermalHandler.java @@ -1,11 +1,12 @@ package gtPlusPlus.api.thermal.sample; -import gtPlusPlus.api.thermal.energy.IThermalHandler; -import gtPlusPlus.api.thermal.energy.ThermalStorage; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; +import gtPlusPlus.api.thermal.energy.IThermalHandler; +import gtPlusPlus.api.thermal.energy.ThermalStorage; + public class TileThermalHandler extends TileEntity implements IThermalHandler { protected ThermalStorage storage = new ThermalStorage(32000); |