diff options
Diffstat (limited to 'src/main/java/gregtech/api/objects')
27 files changed, 341 insertions, 416 deletions
diff --git a/src/main/java/gregtech/api/objects/AE2DigitalChestHandler.java b/src/main/java/gregtech/api/objects/AE2DigitalChestHandler.java index 1fe4536085..3294af2fd0 100644 --- a/src/main/java/gregtech/api/objects/AE2DigitalChestHandler.java +++ b/src/main/java/gregtech/api/objects/AE2DigitalChestHandler.java @@ -1,10 +1,11 @@ package gregtech.api.objects; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.common.Optional; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.common.tileentities.storage.GT_MetaTileEntity_DigitalChestBase; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; @Optional.Interface( iface = "appeng.api.storage.IExternalStorageHandler", @@ -14,23 +15,16 @@ public class AE2DigitalChestHandler implements appeng.api.storage.IExternalStora @Override @Optional.Method(modid = "appliedenergistics2") - public boolean canHandle( - final TileEntity te, - final ForgeDirection d, - final appeng.api.storage.StorageChannel chan, + public boolean canHandle(final TileEntity te, final ForgeDirection d, final appeng.api.storage.StorageChannel chan, final appeng.api.networking.security.BaseActionSource mySrc) { - return chan == appeng.api.storage.StorageChannel.ITEMS - && te instanceof BaseMetaTileEntity + return chan == appeng.api.storage.StorageChannel.ITEMS && te instanceof BaseMetaTileEntity && ((BaseMetaTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_DigitalChestBase; } @Override @Optional.Method(modid = "appliedenergistics2") - public appeng.api.storage.IMEInventory getInventory( - final TileEntity te, - final ForgeDirection d, - final appeng.api.storage.StorageChannel chan, - final appeng.api.networking.security.BaseActionSource src) { + public appeng.api.storage.IMEInventory getInventory(final TileEntity te, final ForgeDirection d, + final appeng.api.storage.StorageChannel chan, final appeng.api.networking.security.BaseActionSource src) { if (chan == appeng.api.storage.StorageChannel.ITEMS) { return ((GT_MetaTileEntity_DigitalChestBase) (((BaseMetaTileEntity) te).getMetaTileEntity())); } diff --git a/src/main/java/gregtech/api/objects/CollectorUtils.java b/src/main/java/gregtech/api/objects/CollectorUtils.java index 41ca5e1e05..178ea0d5e8 100644 --- a/src/main/java/gregtech/api/objects/CollectorUtils.java +++ b/src/main/java/gregtech/api/objects/CollectorUtils.java @@ -9,20 +9,18 @@ import java.util.stream.Collector; import java.util.stream.Collectors; public class CollectorUtils { + /** - * Returns a merge function, suitable for use in - * {@link Map#merge(Object, Object, BiFunction) Map.merge()} or - * {@link Collectors#toMap(Function, Function, BinaryOperator) toMap()}, which always - * throws {@code IllegalStateException}. This can be used to enforce the - * assumption that the elements being collected are distinct. + * Returns a merge function, suitable for use in {@link Map#merge(Object, Object, BiFunction) Map.merge()} or + * {@link Collectors#toMap(Function, Function, BinaryOperator) toMap()}, which always throws + * {@code IllegalStateException}. This can be used to enforce the assumption that the elements being collected are + * distinct. * * @param <T> the type of input arguments to the merge function * @return a merge function which always throw {@code IllegalStateException} */ public static <T> BinaryOperator<T> throwingMerger() { - return (u, v) -> { - throw new IllegalStateException(String.format("Duplicate key %s", u)); - }; + return (u, v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); }; } public static <K, V, E extends Map.Entry<K, V>, M extends Map<K, V>> Collector<E, ?, M> entriesToMap( diff --git a/src/main/java/gregtech/api/objects/ElementStack.java b/src/main/java/gregtech/api/objects/ElementStack.java index 29f043188c..4f71c6efee 100644 --- a/src/main/java/gregtech/api/objects/ElementStack.java +++ b/src/main/java/gregtech/api/objects/ElementStack.java @@ -3,6 +3,7 @@ package gregtech.api.objects; import gregtech.api.enums.Element; public class ElementStack implements Cloneable { + public int mAmount; public Element mElement; @@ -29,11 +30,8 @@ public class ElementStack implements Cloneable { if (aObject == this) return true; if (aObject == null) return false; if (aObject instanceof Element) return aObject == mElement; - if (aObject instanceof ElementStack) - return ((ElementStack) aObject).mElement == mElement - && (mAmount < 0 - || ((ElementStack) aObject).mAmount < 0 - || ((ElementStack) aObject).mAmount == mAmount); + if (aObject instanceof ElementStack) return ((ElementStack) aObject).mElement == mElement + && (mAmount < 0 || ((ElementStack) aObject).mAmount < 0 || ((ElementStack) aObject).mAmount == mAmount); return false; } diff --git a/src/main/java/gregtech/api/objects/GT_ArrayList.java b/src/main/java/gregtech/api/objects/GT_ArrayList.java index fe6bd4a214..50eb3ebcc1 100644 --- a/src/main/java/gregtech/api/objects/GT_ArrayList.java +++ b/src/main/java/gregtech/api/objects/GT_ArrayList.java @@ -1,12 +1,14 @@ package gregtech.api.objects; -import com.google.common.collect.Collections2; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Objects; +import com.google.common.collect.Collections2; + public class GT_ArrayList<E> extends ArrayList<E> { + private static final long serialVersionUID = 1L; private int size_sS; @@ -22,11 +24,10 @@ public class GT_ArrayList<E> extends ArrayList<E> { mAllowNulls = aAllowNulls; if (!mAllowNulls) { size_sS = size(); - for (int i = 0; i < size_sS; i++) - if (get(i) == null) { - remove(i--); - size_sS = size(); - } + for (int i = 0; i < size_sS; i++) if (get(i) == null) { + remove(i--); + size_sS = size(); + } } } @@ -35,11 +36,10 @@ public class GT_ArrayList<E> extends ArrayList<E> { mAllowNulls = aAllowNulls; if (!mAllowNulls) { size_sS = size(); - for (int i = 0; i < size_sS; i++) - if (get(i) == null) { - remove(i--); - size_sS = size(); - } + for (int i = 0; i < size_sS; i++) if (get(i) == null) { + remove(i--); + size_sS = size(); + } } } diff --git a/src/main/java/gregtech/api/objects/GT_ChunkManager.java b/src/main/java/gregtech/api/objects/GT_ChunkManager.java index e06834fe1f..291e669741 100644 --- a/src/main/java/gregtech/api/objects/GT_ChunkManager.java +++ b/src/main/java/gregtech/api/objects/GT_ChunkManager.java @@ -1,16 +1,10 @@ package gregtech.api.objects; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import gregtech.GT_Mod; -import gregtech.api.enums.GT_Values; -import gregtech.api.interfaces.IChunkLoader; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Log; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.ChunkCoordIntPair; @@ -18,9 +12,19 @@ import net.minecraft.world.World; import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; + +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.IChunkLoader; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Log; + // This class handles re-initializing chunks after a server restart public class GT_ChunkManager implements ForgeChunkManager.OrderedLoadingCallback, ForgeChunkManager.PlayerOrderedLoadingCallback { + private Map<TileEntity, Ticket> registeredTickets = new HashMap<>(); public static GT_ChunkManager instance = new GT_ChunkManager(); @@ -32,9 +36,9 @@ public class GT_ChunkManager @Override public void ticketsLoaded(List<Ticket> tickets, World world) {} - // Determine if tickets should be kept. Based on if the ticket is a machine or working chunk ticket. Working chunk + // Determine if tickets should be kept. Based on if the ticket is a machine or working chunk ticket. Working chunk // tickets are tossed - // and re-created when the machine re-activates. Machine tickets are kept only if the config + // and re-created when the machine re-activates. Machine tickets are kept only if the config // alwaysReloadChunkloaders is true. Otherwise // machine chunks are tossed and re-created only when the machine re-activates, similar to a Passive Anchor. @Override @@ -47,8 +51,7 @@ public class GT_ChunkManager int z = ticket.getModData().getInteger("OwnerZ"); if (y > 0) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null - && tile instanceof IGregTechTileEntity + if (tile != null && tile instanceof IGregTechTileEntity && ((IGregTechTileEntity) tile).isAllowedToWork()) { ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(x >> 4, z >> 4)); if (!registeredTickets.containsKey(tile)) { @@ -67,7 +70,7 @@ public class GT_ChunkManager return validTickets; } - // Determine if player tickets should be kept. This is where a ticket list per player would be created and + // Determine if player tickets should be kept. This is where a ticket list per player would be created and // maintained. When // a player join event occurs, their name/UUID/whatevs is compared against tickets on this list and those tickets // reactivated. @@ -83,27 +86,28 @@ public class GT_ChunkManager public static boolean requestPlayerChunkLoad(TileEntity owner, ChunkCoordIntPair chunkXZ, String player) { if (!GT_Values.enableChunkloaders) return false; if (!GT_Values.alwaysReloadChunkloaders && chunkXZ == null) return false; - if (GT_Values.debugChunkloaders && chunkXZ != null) - GT_Log.out.println( - "GT_ChunkManager: Chunk request: (" + chunkXZ.chunkXPos + ", " + chunkXZ.chunkZPos + ")"); + if (GT_Values.debugChunkloaders && chunkXZ != null) GT_Log.out + .println("GT_ChunkManager: Chunk request: (" + chunkXZ.chunkXPos + ", " + chunkXZ.chunkZPos + ")"); if (instance.registeredTickets.containsKey(owner)) { ForgeChunkManager.forceChunk(instance.registeredTickets.get(owner), chunkXZ); } else { Ticket ticket; - if (player.equals("")) - ticket = ForgeChunkManager.requestTicket( - GT_Mod.instance, owner.getWorldObj(), ForgeChunkManager.Type.NORMAL); - else - ticket = ForgeChunkManager.requestPlayerTicket( - GT_Mod.instance, player, owner.getWorldObj(), ForgeChunkManager.Type.NORMAL); + if (player.equals("")) ticket = ForgeChunkManager + .requestTicket(GT_Mod.instance, owner.getWorldObj(), ForgeChunkManager.Type.NORMAL); + else ticket = ForgeChunkManager + .requestPlayerTicket(GT_Mod.instance, player, owner.getWorldObj(), ForgeChunkManager.Type.NORMAL); if (ticket == null) { if (GT_Values.debugChunkloaders) GT_Log.out.println("GT_ChunkManager: ForgeChunkManager.requestTicket failed"); return false; } - if (GT_Values.debugChunkloaders) - GT_Log.out.println("GT_ChunkManager: ticket issued for machine at: (" + owner.xCoord + ", " - + owner.yCoord + ", " + owner.zCoord + ")"); + if (GT_Values.debugChunkloaders) GT_Log.out.println( + "GT_ChunkManager: ticket issued for machine at: (" + owner.xCoord + + ", " + + owner.yCoord + + ", " + + owner.zCoord + + ")"); NBTTagCompound tag = ticket.getModData(); tag.setInteger("OwnerX", owner.xCoord); tag.setInteger("OwnerY", owner.yCoord); @@ -124,9 +128,8 @@ public class GT_ChunkManager if (!GT_Values.enableChunkloaders) return; Ticket ticket = instance.registeredTickets.get(owner); if (ticket != null) { - if (GT_Values.debugChunkloaders) - GT_Log.out.println( - "GT_ChunkManager: Chunk release: (" + chunkXZ.chunkXPos + ", " + chunkXZ.chunkZPos + ")"); + if (GT_Values.debugChunkloaders) GT_Log.out + .println("GT_ChunkManager: Chunk release: (" + chunkXZ.chunkXPos + ", " + chunkXZ.chunkZPos + ")"); ForgeChunkManager.unforceChunk(ticket, chunkXZ); } } @@ -136,11 +139,15 @@ public class GT_ChunkManager Ticket ticket = instance.registeredTickets.get(owner); if (ticket != null) { if (GT_Values.debugChunkloaders) { - GT_Log.out.println("GT_ChunkManager: ticket released by machine at: (" + owner.xCoord + ", " - + owner.yCoord + ", " + owner.zCoord + ")"); - for (ChunkCoordIntPair chunk : ticket.getChunkList()) - GT_Log.out.println( - "GT_ChunkManager: Chunk release: (" + chunk.chunkXPos + ", " + chunk.chunkZPos + ")"); + GT_Log.out.println( + "GT_ChunkManager: ticket released by machine at: (" + owner.xCoord + + ", " + + owner.yCoord + + ", " + + owner.zCoord + + ")"); + for (ChunkCoordIntPair chunk : ticket.getChunkList()) GT_Log.out + .println("GT_ChunkManager: Chunk release: (" + chunk.chunkXPos + ", " + chunk.chunkZPos + ")"); } ForgeChunkManager.releaseTicket(ticket); instance.registeredTickets.remove(owner); @@ -150,8 +157,13 @@ public class GT_ChunkManager public static void printTickets() { GT_Log.out.println("GT_ChunkManager: Start forced chunks dump:"); instance.registeredTickets.forEach((machine, ticket) -> { - GT_Log.out.print("GT_ChunkManager: Chunks forced by the machine at (" + machine.xCoord + ", " - + machine.yCoord + ", " + machine.zCoord + ")"); + GT_Log.out.print( + "GT_ChunkManager: Chunks forced by the machine at (" + machine.xCoord + + ", " + + machine.yCoord + + ", " + + machine.zCoord + + ")"); if (ticket.isPlayerTicket()) GT_Log.out.print(" Owner: " + ticket.getPlayerName()); GT_Log.out.print(" :"); for (ChunkCoordIntPair c : ticket.getChunkList()) { diff --git a/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java b/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java index cfecc9d736..8ea4ce008d 100644 --- a/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java +++ b/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java @@ -1,14 +1,16 @@ package gregtech.api.objects; +import net.minecraft.block.Block; + import gregtech.api.enums.Dyes; import gregtech.api.interfaces.ITexture; -import net.minecraft.block.Block; /** * @deprecated Replaced by the {@link gregtech.api.render.TextureFactory} API. */ @Deprecated public class GT_CopiedBlockTexture extends gregtech.common.render.GT_CopiedBlockTexture implements ITexture { + // Backwards Compat @Deprecated public short[] mRGBa; diff --git a/src/main/java/gregtech/api/objects/GT_Cover_Default.java b/src/main/java/gregtech/api/objects/GT_Cover_Default.java index 4f5eca5b24..04659d584f 100644 --- a/src/main/java/gregtech/api/objects/GT_Cover_Default.java +++ b/src/main/java/gregtech/api/objects/GT_Cover_Default.java @@ -1,12 +1,14 @@ package gregtech.api.objects; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fluids.Fluid; + import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.fluids.Fluid; public class GT_Cover_Default extends GT_CoverBehavior { + /** * This is the Dummy, if there is a generic Cover without behavior */ @@ -20,15 +22,8 @@ public class GT_Cover_Default extends GT_CoverBehavior { } @Override - public int onCoverScrewdriverclick( - byte aSide, - int aCoverID, - int aCoverVariable, - ICoverable aTileEntity, - EntityPlayer aPlayer, - float aX, - float aY, - float aZ) { + public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = ((aCoverVariable + 1) & 15); GT_Utility.sendChatToPlayer( aPlayer, diff --git a/src/main/java/gregtech/api/objects/GT_Cover_None.java b/src/main/java/gregtech/api/objects/GT_Cover_None.java index e0cd5aa061..58d43476ef 100644 --- a/src/main/java/gregtech/api/objects/GT_Cover_None.java +++ b/src/main/java/gregtech/api/objects/GT_Cover_None.java @@ -2,13 +2,14 @@ package gregtech.api.objects; import static gregtech.api.enums.GT_Values.E; -import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.util.GT_CoverBehavior; -import gregtech.api.util.ISerializableObject; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.util.GT_CoverBehavior; +import gregtech.api.util.ISerializableObject; + public class GT_Cover_None extends GT_CoverBehavior { /** @@ -67,33 +68,26 @@ public class GT_Cover_None extends GT_CoverBehavior { } @Override - public boolean manipulatesSidedRedstoneOutput( - byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean manipulatesSidedRedstoneOutput(byte aSide, int aCoverID, int aCoverVariable, + ICoverable aTileEntity) { return false; } @Override - public boolean onCoverRightclick( - byte aSide, - int aCoverID, - int aCoverVariable, - ICoverable aTileEntity, - EntityPlayer aPlayer, - float aX, - float aY, - float aZ) { + public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { return false; } @Override - public boolean onCoverRemoval( - byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, boolean aForced) { + public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + boolean aForced) { return true; } @Override - public int doCoverThings( - byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + long aTimer) { return 0; } @@ -103,203 +97,154 @@ public class GT_Cover_None extends GT_CoverBehavior { } @Override - protected boolean isRedstoneSensitiveImpl( - byte aSide, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity, - long aTimer) { + protected boolean isRedstoneSensitiveImpl(byte aSide, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { return false; } @Override - protected ISerializableObject.LegacyCoverData doCoverThingsImpl( - byte aSide, - byte aInputRedstone, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity, - long aTimer) { + protected ISerializableObject.LegacyCoverData doCoverThingsImpl(byte aSide, byte aInputRedstone, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, long aTimer) { return aCoverVariable; } @Override - protected boolean onCoverRightClickImpl( - byte aSide, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity, - EntityPlayer aPlayer, - float aX, - float aY, - float aZ) { + protected boolean onCoverRightClickImpl(byte aSide, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, + float aY, float aZ) { return false; } @Override - protected ISerializableObject.LegacyCoverData onCoverScrewdriverClickImpl( - byte aSide, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity, - EntityPlayer aPlayer, - float aX, - float aY, - float aZ) { + protected ISerializableObject.LegacyCoverData onCoverScrewdriverClickImpl(byte aSide, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, + float aY, float aZ) { return aCoverVariable; } @Override - protected boolean onCoverShiftRightClickImpl( - byte aSide, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity, - EntityPlayer aPlayer) { + protected boolean onCoverShiftRightClickImpl(byte aSide, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { return false; } @Override - protected boolean onCoverRemovalImpl( - byte aSide, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity, - boolean aForced) { + protected boolean onCoverRemovalImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity, boolean aForced) { return true; } @Override - protected String getDescriptionImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected String getDescriptionImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return E; } @Override - protected float getBlastProofLevelImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected float getBlastProofLevelImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return 10.0F; } @Override - protected boolean letsRedstoneGoInImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsRedstoneGoInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return true; } @Override - protected boolean letsRedstoneGoOutImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsRedstoneGoOutImpl(byte aSide, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFibreGoInImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsFibreGoInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return true; } @Override - protected boolean letsFibreGoOutImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsFibreGoOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return true; } @Override - protected boolean letsEnergyInImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsEnergyInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return true; } @Override - protected boolean letsEnergyOutImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean letsEnergyOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidInImpl( - byte aSide, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - Fluid aFluid, - ICoverable aTileEntity) { + protected boolean letsFluidInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected boolean letsFluidOutImpl( - byte aSide, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - Fluid aFluid, - ICoverable aTileEntity) { + protected boolean letsFluidOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + Fluid aFluid, ICoverable aTileEntity) { return true; } @Override - protected boolean letsItemsInImpl( - byte aSide, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - int aSlot, - ICoverable aTileEntity) { + protected boolean letsItemsInImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean letsItemsOutImpl( - byte aSide, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - int aSlot, - ICoverable aTileEntity) { + protected boolean letsItemsOutImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + int aSlot, ICoverable aTileEntity) { return true; } @Override - protected boolean isGUIClickableImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean isGUIClickableImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return true; } @Override - protected boolean manipulatesSidedRedstoneOutputImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean manipulatesSidedRedstoneOutputImpl(byte aSide, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return false; } @Override - protected boolean alwaysLookConnectedImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected boolean alwaysLookConnectedImpl(byte aSide, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return false; } @Override - protected byte getRedstoneInputImpl( - byte aSide, - byte aInputRedstone, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity) { + protected byte getRedstoneInputImpl(byte aSide, byte aInputRedstone, int aCoverID, + ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { return aInputRedstone; } @Override - protected int getTickRateImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected int getTickRateImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return 0; } @Override - protected byte getLensColorImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected byte getLensColorImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return -1; } @Override - protected ItemStack getDropImpl( - byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, ICoverable aTileEntity) { + protected ItemStack getDropImpl(byte aSide, int aCoverID, ISerializableObject.LegacyCoverData aCoverVariable, + ICoverable aTileEntity) { return null; } } diff --git a/src/main/java/gregtech/api/objects/GT_Fluid.java b/src/main/java/gregtech/api/objects/GT_Fluid.java index 91c5eac092..db240479de 100644 --- a/src/main/java/gregtech/api/objects/GT_Fluid.java +++ b/src/main/java/gregtech/api/objects/GT_Fluid.java @@ -2,15 +2,17 @@ package gregtech.api.objects; import static gregtech.api.enums.GT_Values.RES_PATH_BLOCK; +import net.minecraftforge.fluids.Fluid; + import gregtech.api.GregTech_API; import gregtech.api.fluid.GT_FluidFactory; -import net.minecraftforge.fluids.Fluid; /** * @deprecated use {@link GT_FluidFactory#builder} */ @Deprecated public class GT_Fluid extends Fluid implements Runnable { + public final String mTextureName; private final short[] mRGBa; @@ -23,8 +25,7 @@ public class GT_Fluid extends Fluid implements Runnable { @Override public int getColor() { - return (Math.max(0, Math.min(255, mRGBa[0])) << 16) - | (Math.max(0, Math.min(255, mRGBa[1])) << 8) + return (Math.max(0, Math.min(255, mRGBa[0])) << 16) | (Math.max(0, Math.min(255, mRGBa[1])) << 8) | Math.max(0, Math.min(255, mRGBa[2])); } diff --git a/src/main/java/gregtech/api/objects/GT_FluidStack.java b/src/main/java/gregtech/api/objects/GT_FluidStack.java index 8f796430e5..55bbf712fa 100644 --- a/src/main/java/gregtech/api/objects/GT_FluidStack.java +++ b/src/main/java/gregtech/api/objects/GT_FluidStack.java @@ -1,22 +1,25 @@ package gregtech.api.objects; -import gregtech.api.GregTech_API; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.WeakHashMap; + import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Utility; + /** * Because Forge fucked this one up royally. */ public class GT_FluidStack extends FluidStack { - private static final Collection<GT_FluidStack> sAllFluidStacks = - Collections.newSetFromMap(new WeakHashMap<>(10000)); + + private static final Collection<GT_FluidStack> sAllFluidStacks = Collections + .newSetFromMap(new WeakHashMap<>(10000)); private static volatile boolean lock = false; private Fluid mFluid; @@ -38,8 +41,7 @@ public class GT_FluidStack extends FluidStack { while (lock) { Thread.sleep(1); } - } catch (InterruptedException e) { - } + } catch (InterruptedException e) {} lock = true; for (GT_FluidStack tFluid : sAllFluidStacks) tFluid.fixFluidIDForFucksSake(); try { @@ -77,7 +79,7 @@ public class GT_FluidStack extends FluidStack { @Override public String toString() { - return String.format( - "GT_FluidStack: %s x %s, ID:%s", this.amount, this.getFluid().getName(), this.getFluidID()); + return String + .format("GT_FluidStack: %s x %s, ID:%s", this.amount, this.getFluid().getName(), this.getFluidID()); } } diff --git a/src/main/java/gregtech/api/objects/GT_HashSet.java b/src/main/java/gregtech/api/objects/GT_HashSet.java index 01c4b00995..578d22a4a3 100644 --- a/src/main/java/gregtech/api/objects/GT_HashSet.java +++ b/src/main/java/gregtech/api/objects/GT_HashSet.java @@ -1,11 +1,14 @@ package gregtech.api.objects; -import gregtech.api.GregTech_API; -import gregtech.api.util.GT_Utility; import java.util.*; + import net.minecraft.item.ItemStack; +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_Utility; + public class GT_HashSet<E extends GT_ItemStack> extends AbstractSet<E> { + private static final Object OBJECT = new Object(); private final transient HashMap<GT_ItemStack, Object> map; diff --git a/src/main/java/gregtech/api/objects/GT_ItemStack.java b/src/main/java/gregtech/api/objects/GT_ItemStack.java index a6c892c4f9..21dffd1945 100644 --- a/src/main/java/gregtech/api/objects/GT_ItemStack.java +++ b/src/main/java/gregtech/api/objects/GT_ItemStack.java @@ -1,12 +1,14 @@ package gregtech.api.objects; -import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_Utility; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Utility; + public class GT_ItemStack { + public final Item mItem; public final byte mStackSize; public final short mMetaData; diff --git a/src/main/java/gregtech/api/objects/GT_ItemStack2.java b/src/main/java/gregtech/api/objects/GT_ItemStack2.java index 93f2da6d6b..b137e78829 100644 --- a/src/main/java/gregtech/api/objects/GT_ItemStack2.java +++ b/src/main/java/gregtech/api/objects/GT_ItemStack2.java @@ -4,8 +4,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; /** - * GT_ItemStack, but with a better hashCode(). Due to this change, it should not be placed in the same hash based - * data structure with GT_ItemStack. It also shouldn't be used to construct search query into a hash based data structure + * GT_ItemStack, but with a better hashCode(). Due to this change, it should not be placed in the same hash based data + * structure with GT_ItemStack. It also shouldn't be used to construct search query into a hash based data structure * that contains GT_ItemStack. */ public class GT_ItemStack2 extends GT_ItemStack { diff --git a/src/main/java/gregtech/api/objects/GT_MultiTexture.java b/src/main/java/gregtech/api/objects/GT_MultiTexture.java index 82df899135..9748ecb934 100644 --- a/src/main/java/gregtech/api/objects/GT_MultiTexture.java +++ b/src/main/java/gregtech/api/objects/GT_MultiTexture.java @@ -3,12 +3,18 @@ package gregtech.api.objects; import gregtech.api.interfaces.ITexture; /** - * <p>Lets Multiple ITextures Render overlay over each other.<</p> - * <p>I should have done this much earlier...</p> + * <p> + * Lets Multiple ITextures Render overlay over each other.< + * </p> + * <p> + * I should have done this much earlier... + * </p> + * * @deprecated Replaced by the {@link gregtech.api.render.TextureFactory} API. */ @Deprecated public class GT_MultiTexture extends gregtech.common.render.GT_MultiTexture implements ITexture { + public GT_MultiTexture(ITexture... aTextures) { super(aTextures); } diff --git a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java index 4c17afde17..330d72b88a 100644 --- a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java +++ b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java @@ -8,6 +8,7 @@ import gregtech.api.interfaces.ITexture; @Deprecated public class GT_RenderedTexture extends gregtech.common.render.GT_RenderedTexture implements ITexture, IColorModulationContainer { + @Deprecated public short[] mRGBa; diff --git a/src/main/java/gregtech/api/objects/GT_SidedTexture.java b/src/main/java/gregtech/api/objects/GT_SidedTexture.java index 25b941e968..8ceb6a9a6d 100644 --- a/src/main/java/gregtech/api/objects/GT_SidedTexture.java +++ b/src/main/java/gregtech/api/objects/GT_SidedTexture.java @@ -11,42 +11,25 @@ import gregtech.api.interfaces.ITexture; @Deprecated public class GT_SidedTexture extends gregtech.common.render.GT_SidedTexture implements ITexture, IColorModulationContainer { + @Deprecated public short[] mRGBa; - public GT_SidedTexture( - IIconContainer aIcon0, - IIconContainer aIcon1, - IIconContainer aIcon2, - IIconContainer aIcon3, - IIconContainer aIcon4, - IIconContainer aIcon5, - short[] aRGBa, - boolean aAllowAlpha) { + public GT_SidedTexture(IIconContainer aIcon0, IIconContainer aIcon1, IIconContainer aIcon2, IIconContainer aIcon3, + IIconContainer aIcon4, IIconContainer aIcon5, short[] aRGBa, boolean aAllowAlpha) { super(aIcon0, aIcon1, aIcon2, aIcon3, aIcon4, aIcon5, aRGBa, aAllowAlpha); // Backwards Compat GT_SidedTexture.this.mRGBa = aRGBa; } - public GT_SidedTexture( - IIconContainer aIcon0, - IIconContainer aIcon1, - IIconContainer aIcon2, - IIconContainer aIcon3, - IIconContainer aIcon4, - IIconContainer aIcon5, - short[] aRGBa) { + public GT_SidedTexture(IIconContainer aIcon0, IIconContainer aIcon1, IIconContainer aIcon2, IIconContainer aIcon3, + IIconContainer aIcon4, IIconContainer aIcon5, short[] aRGBa) { this(aIcon0, aIcon1, aIcon2, aIcon3, aIcon4, aIcon5, aRGBa, true); } - public GT_SidedTexture( - IIconContainer aIcon0, - IIconContainer aIcon1, - IIconContainer aIcon2, - IIconContainer aIcon3, - IIconContainer aIcon4, - IIconContainer aIcon5) { + public GT_SidedTexture(IIconContainer aIcon0, IIconContainer aIcon1, IIconContainer aIcon2, IIconContainer aIcon3, + IIconContainer aIcon4, IIconContainer aIcon5) { this(aIcon0, aIcon1, aIcon2, aIcon3, aIcon4, aIcon5, Dyes._NULL.mRGBa); } diff --git a/src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java b/src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java index 3966b060a3..079260c7dc 100644 --- a/src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java +++ b/src/main/java/gregtech/api/objects/GT_StdRenderedTexture.java @@ -1,17 +1,18 @@ package gregtech.api.objects; -import gregtech.api.enums.Dyes; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.util.LightingHelper; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraftforge.common.util.ForgeDirection; +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.util.LightingHelper; + /** - * This ITexture implementation extends the GT_RenderedTexture class - * to render with bottom side flipped as with dumb blocks rendering. - * It is used in Ore blocks rendering so they better blends with dumb block ores - * from vanilla or other mods, when seen from bottom. + * This ITexture implementation extends the GT_RenderedTexture class to render with bottom side flipped as with dumb + * blocks rendering. It is used in Ore blocks rendering so they better blends with dumb block ores from vanilla or other + * mods, when seen from bottom. + * * @deprecated Replaced by the {@link gregtech.api.render.TextureFactory} API. */ @Deprecated diff --git a/src/main/java/gregtech/api/objects/GT_UO_Dimension.java b/src/main/java/gregtech/api/objects/GT_UO_Dimension.java index f449478860..fffa68fadf 100644 --- a/src/main/java/gregtech/api/objects/GT_UO_Dimension.java +++ b/src/main/java/gregtech/api/objects/GT_UO_Dimension.java @@ -1,10 +1,12 @@ package gregtech.api.objects; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; import java.util.Random; + import net.minecraftforge.common.config.ConfigCategory; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + public class GT_UO_Dimension { private BiMap<String, GT_UO_Fluid> fFluids; @@ -20,8 +22,7 @@ public class GT_UO_Dimension { maxChance = 0; // GT_FML_LOGGER.info("GT UO "+aConfigCategory.getName()+" Dimension:"+Dimension); for (int i = 0; i < aConfigCategory.getChildren().size(); i++) { - GT_UO_Fluid fluid = new GT_UO_Fluid( - (ConfigCategory) aConfigCategory.getChildren().toArray()[i]); + GT_UO_Fluid fluid = new GT_UO_Fluid((ConfigCategory) aConfigCategory.getChildren().toArray()[i]); fFluids.put(fluid.Registry, fluid); maxChance += fluid.Chance; } diff --git a/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java b/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java index 44b56938b4..e717f857d5 100644 --- a/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java +++ b/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java @@ -1,11 +1,12 @@ package gregtech.api.objects; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.Configuration; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + public class GT_UO_DimensionList { private Configuration fConfig; @@ -37,15 +38,8 @@ public class GT_UO_DimensionList { } } - public void SetConfigValues( - String aDimensionName, - String aDimension, - String aName, - String aRegistry, - int aMinAmount, - int aMaxAmount, - int aChance, - int aDecreasePerOperationAmount) { + public void SetConfigValues(String aDimensionName, String aDimension, String aName, String aRegistry, + int aMinAmount, int aMaxAmount, int aChance, int aDecreasePerOperationAmount) { String Category = fCategory + "." + aDimensionName; fConfig.get(Category, "Dimension", aDimension).getString(); Category += "." + aName; @@ -74,18 +68,18 @@ public class GT_UO_DimensionList { fConfig.setCategoryComment(fCategory, "Config Underground Fluids (Delete this Category for regenerate)"); fConfig.setCategoryComment( - fCategory + ".Default", "Set Default Generating (Use this Category for Default settings)"); + fCategory + ".Default", + "Set Default Generating (Use this Category for Default settings)"); fConfig.setCategoryComment(fCategory + ".Overworld", "Set Overworld Generating"); fConfig.setCategoryComment(fCategory + ".Moon", "Set Moon Generating"); - blackList = new int[] {-1, 1}; - blackList = aConfig.get(fCategory, "DimBlackList", blackList, "Dimension IDs Black List") - .getIntList(); + blackList = new int[] { -1, 1 }; + blackList = aConfig.get(fCategory, "DimBlackList", blackList, "Dimension IDs Black List").getIntList(); java.util.Arrays.sort(blackList); for (int i = 0; i < fConfig.getCategory(fCategory).getChildren().size(); i++) { - GT_UO_Dimension Dimension = new GT_UO_Dimension((ConfigCategory) - fConfig.getCategory(fCategory).getChildren().toArray()[i]); + GT_UO_Dimension Dimension = new GT_UO_Dimension( + (ConfigCategory) fConfig.getCategory(fCategory).getChildren().toArray()[i]); fDimensionList.put(Dimension.Dimension, Dimension); } } diff --git a/src/main/java/gregtech/api/objects/GT_UO_Fluid.java b/src/main/java/gregtech/api/objects/GT_UO_Fluid.java index e43f80913e..7916131b63 100644 --- a/src/main/java/gregtech/api/objects/GT_UO_Fluid.java +++ b/src/main/java/gregtech/api/objects/GT_UO_Fluid.java @@ -3,11 +3,13 @@ package gregtech.api.objects; import static gregtech.common.GT_UndergroundOil.DIVIDER; import java.util.Random; + import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; public class GT_UO_Fluid { + public String Registry = "null"; public int MaxAmount = 0; public int MinAmount = 0; @@ -20,8 +22,8 @@ public class GT_UO_Fluid { Registry = aConfigCategory.get("Registry").getString(); } if (aConfigCategory.containsKey("MaxAmount")) { - aConfigCategory.get("MaxAmount").comment = - "Max amount generation (per operation, sets the VeinData) 80000 MAX"; + aConfigCategory + .get("MaxAmount").comment = "Max amount generation (per operation, sets the VeinData) 80000 MAX"; MaxAmount = aConfigCategory.get("MaxAmount").getInt(0); } if (aConfigCategory.containsKey("MinAmount")) { @@ -29,15 +31,14 @@ public class GT_UO_Fluid { MinAmount = aConfigCategory.get("MinAmount").getInt(0); } if (aConfigCategory.containsKey("Chance")) { - aConfigCategory.get("Chance").comment = - "Chance generating (weighted chance!, there will be a fluid in chunk always!)"; + aConfigCategory.get( + "Chance").comment = "Chance generating (weighted chance!, there will be a fluid in chunk always!)"; Chance = aConfigCategory.get("Chance").getInt(0); } if (aConfigCategory.containsKey("DecreasePerOperationAmount")) { - aConfigCategory.get("DecreasePerOperationAmount").comment = - "Decrease per operation (actual fluid gained works like (Litre)VeinData/5000)"; - DecreasePerOperationAmount = - aConfigCategory.get("DecreasePerOperationAmount").getInt(5); + aConfigCategory.get( + "DecreasePerOperationAmount").comment = "Decrease per operation (actual fluid gained works like (Litre)VeinData/5000)"; + DecreasePerOperationAmount = aConfigCategory.get("DecreasePerOperationAmount").getInt(5); } // GT_FML_LOGGER.info("GT UO "+aConfigCategory.getName()+" Fluid:"+Registry+" Max:"+MaxAmount+" // Min:"+MinAmount+" Chance:"+Chance); @@ -51,11 +52,11 @@ public class GT_UO_Fluid { } } - public int getRandomAmount( - Random aRandom) { // generates some random ass number that correlates to extraction speeds - int smax = (int) Math.floor(Math.pow( - MaxAmount * 100.d * DIVIDER, - 0.2d)); // use scaled max and min values for the randomness to make high values more rare. + public int getRandomAmount(Random aRandom) { // generates some random ass number that correlates to extraction + // speeds + int smax = (int) Math.floor(Math.pow(MaxAmount * 100.d * DIVIDER, 0.2d)); // use scaled max and min values for + // the randomness to make high values + // more rare. double smin = Math.pow(MinAmount * 100.d * DIVIDER, 0.2d); double samount = Math.max(smin, aRandom.nextInt(smax) + aRandom.nextDouble()); return (int) (Math.pow(samount, 5) / 100); // reverses the computation above diff --git a/src/main/java/gregtech/api/objects/ItemData.java b/src/main/java/gregtech/api/objects/ItemData.java index cf3c2b5c14..52abab19cb 100644 --- a/src/main/java/gregtech/api/objects/ItemData.java +++ b/src/main/java/gregtech/api/objects/ItemData.java @@ -1,11 +1,14 @@ package gregtech.api.objects; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; import java.util.*; + import net.minecraft.item.ItemStack; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; + public class ItemData { + private static final MaterialStack[] EMPTY_MATERIALSTACK_ARRAY = new MaterialStack[0]; public final List<Object> mExtraData = new GT_ArrayList<Object>(false, 1); @@ -21,7 +24,7 @@ public class ItemData { mBlackListed = aBlackListed; mByProducts = aPrefix.mSecondaryMaterial == null || aPrefix.mSecondaryMaterial.mMaterial == null ? EMPTY_MATERIALSTACK_ARRAY - : new MaterialStack[] {aPrefix.mSecondaryMaterial.clone()}; + : new MaterialStack[] { aPrefix.mSecondaryMaterial.clone() }; } public ItemData(OrePrefixes aPrefix, Materials aMaterial) { @@ -35,12 +38,11 @@ public class ItemData { if (aByProducts == null) { mByProducts = EMPTY_MATERIALSTACK_ARRAY; } else { - MaterialStack[] tByProducts = - aByProducts.length < 1 ? EMPTY_MATERIALSTACK_ARRAY : new MaterialStack[aByProducts.length]; + MaterialStack[] tByProducts = aByProducts.length < 1 ? EMPTY_MATERIALSTACK_ARRAY + : new MaterialStack[aByProducts.length]; int j = 0; - for (int i = 0; i < aByProducts.length; i++) - if (aByProducts[i] != null && aByProducts[i].mMaterial != null) - tByProducts[j++] = aByProducts[i].clone(); + for (int i = 0; i < aByProducts.length; i++) if (aByProducts[i] != null && aByProducts[i].mMaterial != null) + tByProducts[j++] = aByProducts[i].clone(); mByProducts = j > 0 ? new MaterialStack[j] : EMPTY_MATERIALSTACK_ARRAY; for (int i = 0; i < mByProducts.length; i++) mByProducts[i] = tByProducts[i]; } @@ -60,25 +62,23 @@ public class ItemData { ArrayList<MaterialStack> aList = new ArrayList<MaterialStack>(), rList = new ArrayList<MaterialStack>(); - for (ItemData tData : aData) - if (tData != null) { - if (tData.hasValidMaterialData() && tData.mMaterial.mAmount > 0) aList.add(tData.mMaterial.clone()); - for (MaterialStack tMaterial : tData.mByProducts) - if (tMaterial.mAmount > 0) aList.add(tMaterial.clone()); - } + for (ItemData tData : aData) if (tData != null) { + if (tData.hasValidMaterialData() && tData.mMaterial.mAmount > 0) aList.add(tData.mMaterial.clone()); + for (MaterialStack tMaterial : tData.mByProducts) if (tMaterial.mAmount > 0) aList.add(tMaterial.clone()); + } for (MaterialStack aMaterial : aList) { boolean temp = true; - for (MaterialStack tMaterial : rList) - if (aMaterial.mMaterial == tMaterial.mMaterial) { - tMaterial.mAmount += aMaterial.mAmount; - temp = false; - break; - } + for (MaterialStack tMaterial : rList) if (aMaterial.mMaterial == tMaterial.mMaterial) { + tMaterial.mAmount += aMaterial.mAmount; + temp = false; + break; + } if (temp) rList.add(aMaterial.clone()); } Collections.sort(rList, new Comparator<MaterialStack>() { + @Override public int compare(MaterialStack a, MaterialStack b) { return a.mAmount == b.mAmount ? 0 : a.mAmount > b.mAmount ? -1 : +1; diff --git a/src/main/java/gregtech/api/objects/MaterialStack.java b/src/main/java/gregtech/api/objects/MaterialStack.java index 21fee36b17..c2ce2f951a 100644 --- a/src/main/java/gregtech/api/objects/MaterialStack.java +++ b/src/main/java/gregtech/api/objects/MaterialStack.java @@ -4,6 +4,7 @@ import gregtech.api.enums.Materials; import gregtech.api.util.GT_Utility; public class MaterialStack implements Cloneable { + public long mAmount; public Materials mMaterial; @@ -30,11 +31,9 @@ public class MaterialStack implements Cloneable { if (aObject == this) return true; if (aObject == null) return false; if (aObject instanceof Materials) return aObject == mMaterial; - if (aObject instanceof MaterialStack) - return ((MaterialStack) aObject).mMaterial == mMaterial - && (mAmount < 0 - || ((MaterialStack) aObject).mAmount < 0 - || ((MaterialStack) aObject).mAmount == mAmount); + if (aObject instanceof MaterialStack) return ((MaterialStack) aObject).mMaterial == mMaterial + && (mAmount < 0 || ((MaterialStack) aObject).mAmount < 0 + || ((MaterialStack) aObject).mAmount == mAmount); return false; } diff --git a/src/main/java/gregtech/api/objects/ObjMap.java b/src/main/java/gregtech/api/objects/ObjMap.java index 0a3b3a8fbe..05205b92c4 100644 --- a/src/main/java/gregtech/api/objects/ObjMap.java +++ b/src/main/java/gregtech/api/objects/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]; @@ -192,9 +193,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. @@ -210,18 +213,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/gregtech/api/objects/ReverseShapedRecipe.java b/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java index 60a5c13d74..5dd14186e1 100644 --- a/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java +++ b/src/main/java/gregtech/api/objects/ReverseShapedRecipe.java @@ -2,16 +2,19 @@ package gregtech.api.objects; import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Disassembler; import java.util.Collections; import java.util.LinkedList; import java.util.Optional; import java.util.Queue; + import net.minecraft.item.ItemStack; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Disassembler; + public class ReverseShapedRecipe { + private static Queue<ReverseShapedRecipe> reverseRecipes = new LinkedList<>(); private ItemStack aResult; private Object[] aRecipe; @@ -32,8 +35,8 @@ public class ReverseShapedRecipe { if (!recipeOptional.isPresent()) continue; GT_Recipe recipe = recipeOptional.get(); ItemStack[] replacement = new ItemStack[recipe.mOutputs.length]; - GT_MetaTileEntity_Disassembler.handleRecipeTransformation( - recipe.mOutputs, replacement, Collections.singleton(recipe.mOutputs)); + GT_MetaTileEntity_Disassembler + .handleRecipeTransformation(recipe.mOutputs, replacement, Collections.singleton(recipe.mOutputs)); recipe.mOutputs = replacement; sDisassemblerRecipes.add(recipe); diff --git a/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java b/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java index 6593dc60d8..656f7728c5 100644 --- a/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java +++ b/src/main/java/gregtech/api/objects/ReverseShapelessRecipe.java @@ -2,16 +2,19 @@ package gregtech.api.objects; import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Disassembler; import java.util.Collections; import java.util.LinkedList; import java.util.Optional; import java.util.Queue; + import net.minecraft.item.ItemStack; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Disassembler; + public class ReverseShapelessRecipe { + private static Queue<ReverseShapelessRecipe> reverseRecipes = new LinkedList<>(); private ItemStack aResult; private Object[] aRecipe; @@ -32,8 +35,8 @@ public class ReverseShapelessRecipe { if (!recipeOptional.isPresent()) continue; GT_Recipe recipe = recipeOptional.get(); ItemStack[] replacement = new ItemStack[recipe.mOutputs.length]; - GT_MetaTileEntity_Disassembler.handleRecipeTransformation( - recipe.mOutputs, replacement, Collections.singleton(recipe.mOutputs)); + GT_MetaTileEntity_Disassembler + .handleRecipeTransformation(recipe.mOutputs, replacement, Collections.singleton(recipe.mOutputs)); recipe.mOutputs = replacement; sDisassemblerRecipes.add(recipe); diff --git a/src/main/java/gregtech/api/objects/XSTR.java b/src/main/java/gregtech/api/objects/XSTR.java index b5ed4a00b4..cd4f0e6bb4 100644 --- a/src/main/java/gregtech/api/objects/XSTR.java +++ b/src/main/java/gregtech/api/objects/XSTR.java @@ -1,36 +1,28 @@ package gregtech.api.objects; + /** - * 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 { @@ -40,10 +32,11 @@ public class XSTR extends Random { 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) private static final AtomicLong seedUniquifier = new AtomicLong(8682522807148012L); public static final XSTR XSTR_INSTANCE = new XSTR() { + @Override public synchronized void setSeed(long seed) { if (!Thread.currentThread().getStackTrace()[2].getClassName().equals(Random.class.getName())) @@ -52,12 +45,10 @@ public class XSTR extends Random { }; /* - 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() { @@ -67,7 +58,7 @@ public class XSTR extends Random { private static long seedUniquifier() { // L'Ecuyer, "Tables of Linear Congruential Generators of // Different Sizes and Good Lattice Structure", 1999 - for (; ; ) { + for (;;) { long current = seedUniquifier.get(); long next = current * 181783497276652981L; if (seedUniquifier.compareAndSet(current, next)) { @@ -77,8 +68,8 @@ public class XSTR extends Random { } /** - * 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 */ @@ -95,6 +86,7 @@ public class XSTR extends Random { public double nextDouble() { return (((long) (next(26)) << 27) + next(27)) * DOUBLE_UNIT; } + /** * Returns the current state of the seed, can be used to clone the object * @@ -105,9 +97,8 @@ public class XSTR extends Random { } /** - * 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 +116,8 @@ public class XSTR extends Random { } /** - * 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 @@ -165,16 +155,16 @@ public class XSTR extends Random { 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"); @@ -188,35 +178,29 @@ public class XSTR extends Random { * 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 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. + * 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 */ @@ -226,18 +210,10 @@ public class XSTR extends Random { // throw new RuntimeException("BadBound"); // } - /*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% last = seed ^ (seed << 21); last ^= (last >>> 35); @@ -265,9 +241,9 @@ public class XSTR extends Random { @Override public void nextBytes(byte[] bytes_arr) { - for (int iba = 0, lenba = bytes_arr.length; iba < lenba; ) - for (int rndba = nextInt(), nba = Math.min(lenba - iba, Integer.SIZE / Byte.SIZE); - nba-- > 0; - rndba >>= Byte.SIZE) bytes_arr[iba++] = (byte) rndba; + for (int iba = 0, lenba = bytes_arr.length; iba < lenba;) + for (int rndba = 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/gregtech/api/objects/iterators/MergedIterator.java b/src/main/java/gregtech/api/objects/iterators/MergedIterator.java index 77fac8d22f..961c98e81a 100644 --- a/src/main/java/gregtech/api/objects/iterators/MergedIterator.java +++ b/src/main/java/gregtech/api/objects/iterators/MergedIterator.java @@ -3,6 +3,7 @@ package gregtech.api.objects.iterators; import java.util.Iterator; public class MergedIterator<T> implements Iterator<T> { + private final Iterator<T>[] inners; private int current; |