From 6f31720697bcc351421a4d86ba3bf749375dd12c Mon Sep 17 00:00:00 2001 From: Raven Szewczyk Date: Sat, 27 Aug 2022 10:19:57 +0100 Subject: Update buildscript & apply spotless (#1306) * Update dependencies * Update buildscript, apply spotless --- .../GT_MetaTileEntity_AdvSeismicProspector.java | 219 ++++---- .../basic/GT_MetaTileEntity_Boxinator.java | 144 +++-- .../machines/basic/GT_MetaTileEntity_Charger.java | 70 ++- .../basic/GT_MetaTileEntity_CuringOven.java | 86 ++- .../basic/GT_MetaTileEntity_Disassembler.java | 395 +++++++------- .../basic/GT_MetaTileEntity_IndustrialApiary.java | 596 ++++++++++----------- .../basic/GT_MetaTileEntity_Massfabricator.java | 115 ++-- ..._MetaTileEntity_MicrowaveEnergyTransmitter.java | 142 +++-- .../machines/basic/GT_MetaTileEntity_Miner.java | 210 +++++--- .../basic/GT_MetaTileEntity_MonsterRepellent.java | 97 ++-- .../basic/GT_MetaTileEntity_PotionBrewer.java | 98 +++- .../machines/basic/GT_MetaTileEntity_Printer.java | 32 +- .../machines/basic/GT_MetaTileEntity_Pump.java | 287 ++++++---- .../basic/GT_MetaTileEntity_Replicator.java | 121 +++-- .../basic/GT_MetaTileEntity_RockBreaker.java | 97 +++- .../machines/basic/GT_MetaTileEntity_Scanner.java | 224 +++++--- .../basic/GT_MetaTileEntity_SeismicProspector.java | 207 ++++--- .../basic/GT_MetaTileEntity_Teleporter.java | 265 ++++++--- 18 files changed, 2096 insertions(+), 1309 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities/machines/basic') diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java index 10bfd92f37..ee2ddcdfed 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java @@ -1,5 +1,8 @@ package gregtech.common.tileentities.machines.basic; +import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; + import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -14,6 +17,10 @@ import gregtech.api.util.GT_Utility; import gregtech.common.blocks.GT_Block_Ores_Abstract; import gregtech.common.blocks.GT_TileEntity_Ores; import ic2.core.Ic2Items; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -24,15 +31,6 @@ import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - -import static gregtech.api.enums.Textures.BlockIcons.*; -import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; - - public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_BasicMachine { boolean ready = false; int radius; @@ -40,60 +38,91 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba int cX; int cZ; - public GT_MetaTileEntity_AdvSeismicProspector(int aID, String aName, String aNameRegional, int aTier, int aRadius, int aStep) { - super(aID, aName, aNameRegional, aTier, 1, // amperage + public GT_MetaTileEntity_AdvSeismicProspector( + int aID, String aName, String aNameRegional, int aTier, int aRadius, int aStep) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, // amperage "", 1, // input slot count 1, // output slot count "Default.png", // GUI name "", // NEI name - TextureFactory.of( - TextureFactory.of(OVERLAY_SIDE_ROCK_BREAKER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_SIDE_ROCK_BREAKER_ACTIVE_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_SIDE_ROCK_BREAKER), - TextureFactory.builder().addIcon(OVERLAY_SIDE_ROCK_BREAKER_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_TOP_ROCK_BREAKER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_TOP_ROCK_BREAKER_ACTIVE_GLOW).glow().build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_SIDE_ROCK_BREAKER_ACTIVE), + TextureFactory.builder() + .addIcon(OVERLAY_SIDE_ROCK_BREAKER_ACTIVE_GLOW) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_SIDE_ROCK_BREAKER), + TextureFactory.builder() + .addIcon(OVERLAY_SIDE_ROCK_BREAKER_GLOW) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_TOP_ROCK_BREAKER_ACTIVE), + TextureFactory.builder() + .addIcon(OVERLAY_TOP_ROCK_BREAKER_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_TOP_ROCK_BREAKER), - TextureFactory.builder().addIcon(OVERLAY_TOP_ROCK_BREAKER_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_FRONT_ROCK_BREAKER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ROCK_BREAKER_ACTIVE_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_FRONT_ROCK_BREAKER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ROCK_BREAKER_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_BOTTOM_ROCK_BREAKER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_BOTTOM_ROCK_BREAKER_ACTIVE_GLOW).glow().build()), - TextureFactory.of( - TextureFactory.of(OVERLAY_BOTTOM_ROCK_BREAKER), - TextureFactory.builder().addIcon(OVERLAY_BOTTOM_ROCK_BREAKER_GLOW).glow().build())); + TextureFactory.builder() + .addIcon(OVERLAY_TOP_ROCK_BREAKER_GLOW) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_FRONT_ROCK_BREAKER_ACTIVE), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ROCK_BREAKER_ACTIVE_GLOW) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_FRONT_ROCK_BREAKER), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ROCK_BREAKER_GLOW) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_BOTTOM_ROCK_BREAKER_ACTIVE), + TextureFactory.builder() + .addIcon(OVERLAY_BOTTOM_ROCK_BREAKER_ACTIVE_GLOW) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(OVERLAY_BOTTOM_ROCK_BREAKER), + TextureFactory.builder() + .addIcon(OVERLAY_BOTTOM_ROCK_BREAKER_GLOW) + .glow() + .build())); radius = aRadius; step = aStep; } @Override public String[] getDescription() { - return new String[]{ - "Place, activate with explosives", - "2 Powderbarrels, " - + "4 Glyceryl Trinitrate, " - + "16 TNT, or " - + "8 ITNT", - "Use Data Stick, Scan Data Stick, Print Data Stick, Bind Pages into Book", - "Ore prospecting area = " - + radius*2 - + "x" - + radius*2 - + " ONLY blocks below prospector", - "Oil prospecting area 3x3 oilfields, each is 8x8 chunks"}; + return new String[] { + "Place, activate with explosives", + "2 Powderbarrels, " + "4 Glyceryl Trinitrate, " + "16 TNT, or " + "8 ITNT", + "Use Data Stick, Scan Data Stick, Print Data Stick, Bind Pages into Book", + "Ore prospecting area = " + radius * 2 + "x" + radius * 2 + " ONLY blocks below prospector", + "Oil prospecting area 3x3 oilfields, each is 8x8 chunks" + }; } - protected GT_MetaTileEntity_AdvSeismicProspector(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, - String aGUIName, String aNEIName, int aRadius, int aStep) { + protected GT_MetaTileEntity_AdvSeismicProspector( + String aName, + int aTier, + String[] aDescription, + ITexture[][][] aTextures, + String aGUIName, + String aNEIName, + int aRadius, + int aStep) { super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); radius = aRadius; step = aStep; @@ -101,8 +130,15 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_AdvSeismicProspector(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, - this.mGUIName, this.mNEIName, this.radius, this.step); + return new GT_MetaTileEntity_AdvSeismicProspector( + this.mName, + this.mTier, + this.mDescriptionArray, + this.mTextures, + this.mGUIName, + this.mNEIName, + this.radius, + this.step); } @Override @@ -110,16 +146,19 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba if (aBaseMetaTileEntity.isServerSide()) { ItemStack aStack = aPlayer.getCurrentEquippedItem(); - if (!ready && (GT_Utility.consumeItems(aPlayer, aStack, Item.getItemFromBlock(Blocks.tnt), 16) - || GT_Utility.consumeItems(aPlayer, aStack, Ic2Items.industrialTnt.getItem(), 8) - || GT_Utility.consumeItems(aPlayer, aStack, Materials.Glyceryl, 4) - || GT_Utility.consumeItems(aPlayer, aStack, ItemList.Block_Powderbarrel.getItem(), 2) )) { + if (!ready + && (GT_Utility.consumeItems(aPlayer, aStack, Item.getItemFromBlock(Blocks.tnt), 16) + || GT_Utility.consumeItems(aPlayer, aStack, Ic2Items.industrialTnt.getItem(), 8) + || GT_Utility.consumeItems(aPlayer, aStack, Materials.Glyceryl, 4) + || GT_Utility.consumeItems(aPlayer, aStack, ItemList.Block_Powderbarrel.getItem(), 2))) { this.ready = true; this.mMaxProgresstime = (aPlayer.capabilities.isCreativeMode ? 20 : 800); - } else if (ready && mMaxProgresstime == 0 - && aStack != null && aStack.stackSize == 1 + } else if (ready + && mMaxProgresstime == 0 + && aStack != null + && aStack.stackSize == 1 && aStack.getItem() == ItemList.Tool_DataStick.getItem()) { this.ready = false; @@ -132,15 +171,16 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba ArrayList tOils = new ArrayList<>(); prospectOils(tOils); - GT_Utility.ItemNBT.setAdvancedProspectionData(mTier, - aStack, - this.getBaseMetaTileEntity().getXCoord(), - this.getBaseMetaTileEntity().getYCoord(), - this.getBaseMetaTileEntity().getZCoord(), - this.getBaseMetaTileEntity().getWorld().provider.dimensionId, - tOils, - GT_Utility.sortByValueToList(tOres), - radius); + GT_Utility.ItemNBT.setAdvancedProspectionData( + mTier, + aStack, + this.getBaseMetaTileEntity().getXCoord(), + this.getBaseMetaTileEntity().getYCoord(), + this.getBaseMetaTileEntity().getZCoord(), + this.getBaseMetaTileEntity().getWorld().provider.dimensionId, + tOils, + GT_Utility.sortByValueToList(tOres), + radius); } } @@ -165,15 +205,14 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba for (int i = 0; i < oilfieldSize; i++) { for (int j = 0; j < oilfieldSize; j++) { - Chunk tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords( - xChunk + i + x * oilfieldSize, - zChunk + j + z * oilfieldSize); + Chunk tChunk = getBaseMetaTileEntity() + .getWorld() + .getChunkFromChunkCoords( + xChunk + i + x * oilfieldSize, zChunk + j + z * oilfieldSize); FluidStack tFluid = undergroundOilReadInformation(tChunk); if (tFluid != null) { - if (tFluid.amount > max) - max = tFluid.amount; - if (tFluid.amount < min) - min = tFluid.amount; + if (tFluid.amount > max) max = tFluid.amount; + if (tFluid.amount < min) min = tFluid.amount; if (!tFluids.containsKey(cInts)) { tFluids.put(cInts, tFluid); } @@ -181,33 +220,32 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba } } - aOils.add(++oilFieldCount + "," + min + "-" + max + "," + tFluids.get(cInts).getLocalizedName()); + aOils.add(++oilFieldCount + "," + min + "-" + max + "," + + tFluids.get(cInts).getLocalizedName()); } } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } private void prospectOres(Map aOres) { int tLeftXBound = this.getBaseMetaTileEntity().getXCoord() - radius; - int tRightXBound = tLeftXBound + 2*radius; + int tRightXBound = tLeftXBound + 2 * radius; int tLeftZBound = this.getBaseMetaTileEntity().getZCoord() - radius; - int tRightZBound = tLeftZBound + 2*radius; + int tRightZBound = tLeftZBound + 2 * radius; for (int i = tLeftXBound; i <= tRightXBound; i += step) { - if (Math.abs(i >> 4) % 3 != 1) - continue; + if (Math.abs(i >> 4) % 3 != 1) continue; for (int k = tLeftZBound; k <= tRightZBound; k += step) { - if (Math.abs(k >> 4) % 3 != 1) - continue; + if (Math.abs(k >> 4) % 3 != 1) continue; cX = (i >> 4) << 4; cZ = (k >> 4) << 4; - String separator = (cX +8)+ "," + (cZ + 8) + " --------"; + String separator = (cX + 8) + "," + (cZ + 8) + " --------"; aOres.put(separator, 1); prospectHole(i, k, aOres); - } } } @@ -216,8 +254,7 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba String tFoundOre; for (int j = this.getBaseMetaTileEntity().getYCoord(); j > 0; j--) { tFoundOre = checkForOre(i, j, k); - if (tFoundOre != null) - countOre(aOres, tFoundOre, cX, cZ); + if (tFoundOre != null) countOre(aOres, tFoundOre, cX, cZ); } } @@ -228,12 +265,11 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba TileEntity tTileEntity = getBaseMetaTileEntity().getWorld().getTileEntity(x, y, z); if ((tTileEntity instanceof GT_TileEntity_Ores) - && (((GT_TileEntity_Ores) tTileEntity).mMetaData < 16000)) { // Filtering small ores - Materials tMaterial - = GregTech_API.sGeneratedMaterials[((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000]; + && (((GT_TileEntity_Ores) tTileEntity).mMetaData < 16000)) { // Filtering small ores + Materials tMaterial = + GregTech_API.sGeneratedMaterials[((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000]; - if ((tMaterial != null) && (tMaterial != Materials._NULL)) - return tMaterial.mDefaultLocalName; + if ((tMaterial != null) && (tMaterial != Materials._NULL)) return tMaterial.mDefaultLocalName; } } else { int tMetaID = getBaseMetaTileEntity().getWorld().getBlockMetadata(x, y, z); @@ -241,14 +277,13 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba ItemData association = GT_OreDictUnificator.getAssociation(is); if ((association != null) && (association.mPrefix.toString().startsWith("ore"))) return association.mMaterial.mMaterial.mDefaultLocalName; - else if (GT_Utility.isOre(tBlock, tMetaID)) - return tBlock.getLocalizedName(); + else if (GT_Utility.isOre(tBlock, tMetaID)) return tBlock.getLocalizedName(); } return null; } private static void countOre(Map map, String ore, int cCX, int cCZ) { - ore = (cCX +8)+ "," + (cCZ + 8) + " has " + ore; + ore = (cCX + 8) + "," + (cCZ + 8) + " has " + ore; Integer oldCount = map.get(ore); oldCount = (oldCount == null) ? 0 : oldCount; diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java index c0d4616bf9..49b6e4d473 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java @@ -1,5 +1,7 @@ package gregtech.common.tileentities.machines.basic; +import static gregtech.api.enums.Textures.BlockIcons.*; + import gregtech.api.enums.ItemList; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -11,52 +13,92 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.item.ItemStack; -import static gregtech.api.enums.Textures.BlockIcons.*; - public class GT_MetaTileEntity_Boxinator extends GT_MetaTileEntity_BasicMachine { ItemStack aInputCache; ItemStack aOutputCache; int aTypeCache = 0; public GT_MetaTileEntity_Boxinator(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "Puts things into Boxes", 2, 1, "Packager.png", "", + super( + aID, + aName, + aNameRegional, + aTier, + 1, + "Puts things into Boxes", + 2, + 1, + "Packager.png", + "", TextureFactory.of( TextureFactory.of(OVERLAY_SIDE_BOXINATOR_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_SIDE_BOXINATOR_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_SIDE_BOXINATOR_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_SIDE_BOXINATOR), - TextureFactory.builder().addIcon(OVERLAY_SIDE_BOXINATOR_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_SIDE_BOXINATOR_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_FRONT_BOXINATOR_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_BOXINATOR_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_BOXINATOR_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_FRONT_BOXINATOR), - TextureFactory.builder().addIcon(OVERLAY_FRONT_BOXINATOR_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_BOXINATOR_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_TOP_BOXINATOR_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_TOP_BOXINATOR_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_TOP_BOXINATOR_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_TOP_BOXINATOR), - TextureFactory.builder().addIcon(OVERLAY_TOP_BOXINATOR_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_TOP_BOXINATOR_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_BOTTOM_BOXINATOR_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_BOTTOM_BOXINATOR_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_BOTTOM_BOXINATOR_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_BOTTOM_BOXINATOR), - TextureFactory.builder().addIcon(OVERLAY_BOTTOM_BOXINATOR_GLOW).glow().build())); + TextureFactory.builder() + .addIcon(OVERLAY_BOTTOM_BOXINATOR_GLOW) + .glow() + .build())); } - public GT_MetaTileEntity_Boxinator(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + public GT_MetaTileEntity_Boxinator( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 2, 1, aGUIName, aNEIName); } - public GT_MetaTileEntity_Boxinator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + public GT_MetaTileEntity_Boxinator( + String aName, + int aTier, + String[] aDescription, + ITexture[][][] aTextures, + String aGUIName, + String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 2, 1, aGUIName, aNEIName); } @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boxinator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mGUIName, this.mNEIName); + return new GT_MetaTileEntity_Boxinator( + this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mGUIName, this.mNEIName); } @Override @@ -64,13 +106,12 @@ public class GT_MetaTileEntity_Boxinator extends GT_MetaTileEntity_BasicMachine return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes; } - private boolean hasValidCache(ItemStack mItem,int mType,boolean mClearOnFailure) { + private boolean hasValidCache(ItemStack mItem, int mType, boolean mClearOnFailure) { if (aInputCache != null && aOutputCache != null && aTypeCache == mType && aInputCache.isItemEqual(mItem) - && ItemStack.areItemStackTagsEqual(mItem,aInputCache)) - return true; + && ItemStack.areItemStackTagsEqual(mItem, aInputCache)) return true; // clear cache if it was invalid if (mClearOnFailure) { aInputCache = null; @@ -80,7 +121,7 @@ public class GT_MetaTileEntity_Boxinator extends GT_MetaTileEntity_BasicMachine return false; } - private void cacheItem(ItemStack mInputItem,ItemStack mOutputItem,int mType) { + private void cacheItem(ItemStack mInputItem, ItemStack mOutputItem, int mType) { aTypeCache = mType; aOutputCache = mOutputItem.copy(); aInputCache = mInputItem.copy(); @@ -94,53 +135,57 @@ public class GT_MetaTileEntity_Boxinator extends GT_MetaTileEntity_BasicMachine } ItemStack tSlot0 = getInputAt(0); ItemStack tSlot1 = getInputAt(1); - if ((GT_Utility.isStackValid(tSlot0)) && (GT_Utility.isStackValid(tSlot1)) && (GT_Utility.getContainerItem(tSlot0, true) == null)) { + if ((GT_Utility.isStackValid(tSlot0)) + && (GT_Utility.isStackValid(tSlot1)) + && (GT_Utility.getContainerItem(tSlot0, true) == null)) { if ((ItemList.Schematic_1by1.isStackEqual(tSlot1)) && (tSlot0.stackSize >= 1)) { - boolean tIsCached = hasValidCache(tSlot0,1,true); + boolean tIsCached = hasValidCache(tSlot0, 1, true); this.mOutputItems[0] = tIsCached ? aOutputCache.copy() : GT_ModHandler.getRecipeOutput(tSlot0); if (this.mOutputItems[0] != null) { if (canOutput(this.mOutputItems[0])) { tSlot0.stackSize -= 1; - calculateOverclockedNess(32,16); - //In case recipe is too OP for that machine + calculateOverclockedNess(32, 16); + // In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - if (!tIsCached) - cacheItem(tSlot0,this.mOutputItems[0],1); + if (!tIsCached) cacheItem(tSlot0, this.mOutputItems[0], 1); return FOUND_AND_SUCCESSFULLY_USED_RECIPE; } } return DID_NOT_FIND_RECIPE; } if ((ItemList.Schematic_2by2.isStackEqual(tSlot1)) && (getInputAt(0).stackSize >= 4)) { - boolean tIsCached = hasValidCache(tSlot0,2,true); - this.mOutputItems[0] = tIsCached ? aOutputCache.copy() : GT_ModHandler.getRecipeOutput(tSlot0, tSlot0, null, tSlot0, tSlot0); + boolean tIsCached = hasValidCache(tSlot0, 2, true); + this.mOutputItems[0] = tIsCached + ? aOutputCache.copy() + : GT_ModHandler.getRecipeOutput(tSlot0, tSlot0, null, tSlot0, tSlot0); if (this.mOutputItems[0] != null) { if (canOutput(this.mOutputItems[0])) { getInputAt(0).stackSize -= 4; - calculateOverclockedNess(32,32); - //In case recipe is too OP for that machine + calculateOverclockedNess(32, 32); + // In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - if (!tIsCached) - cacheItem(tSlot0,this.mOutputItems[0],2); + if (!tIsCached) cacheItem(tSlot0, this.mOutputItems[0], 2); return FOUND_AND_SUCCESSFULLY_USED_RECIPE; } } return DID_NOT_FIND_RECIPE; } if ((ItemList.Schematic_3by3.isStackEqual(tSlot1)) && (getInputAt(0).stackSize >= 9)) { - boolean tIsCached = hasValidCache(tSlot0,3,true); - this.mOutputItems[0] = tIsCached ? aOutputCache.copy() : GT_ModHandler.getRecipeOutput(tSlot0, tSlot0, tSlot0, tSlot0, tSlot0, tSlot0, tSlot0, tSlot0, tSlot0); + boolean tIsCached = hasValidCache(tSlot0, 3, true); + this.mOutputItems[0] = tIsCached + ? aOutputCache.copy() + : GT_ModHandler.getRecipeOutput( + tSlot0, tSlot0, tSlot0, tSlot0, tSlot0, tSlot0, tSlot0, tSlot0, tSlot0); if (this.mOutputItems[0] != null) { if (canOutput(this.mOutputItems[0])) { getInputAt(0).stackSize -= 9; - calculateOverclockedNess(32,64); - //In case recipe is too OP for that machine + calculateOverclockedNess(32, 64); + // In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - if (!tIsCached) - cacheItem(tSlot0,this.mOutputItems[0],3); + if (!tIsCached) cacheItem(tSlot0, this.mOutputItems[0], 3); return FOUND_AND_SUCCESSFULLY_USED_RECIPE; } } @@ -151,23 +196,36 @@ public class GT_MetaTileEntity_Boxinator extends GT_MetaTileEntity_BasicMachine } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + protected boolean allowPutStackValidated( + IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { if (!super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) { return false; } ItemStack tInput1 = getInputAt(1); - if ((ItemList.Schematic_1by1.isStackEqual(tInput1)) || (ItemList.Schematic_2by2.isStackEqual(tInput1)) || (ItemList.Schematic_3by3.isStackEqual(tInput1))) { - if (hasValidCache(aStack,aTypeCache,false)) - return true; - if (GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.findRecipe(getBaseMetaTileEntity(), true, gregtech.api.enums.GT_Values.V[mTier], null, GT_Utility.copyAmount(64L, aStack), tInput1) != null) { + if ((ItemList.Schematic_1by1.isStackEqual(tInput1)) + || (ItemList.Schematic_2by2.isStackEqual(tInput1)) + || (ItemList.Schematic_3by3.isStackEqual(tInput1))) { + if (hasValidCache(aStack, aTypeCache, false)) return true; + if (GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.findRecipe( + getBaseMetaTileEntity(), + true, + gregtech.api.enums.GT_Values.V[mTier], + null, + GT_Utility.copyAmount(64L, aStack), + tInput1) + != null) { return true; } if (ItemList.Schematic_1by1.isStackEqual(getInputAt(1)) && GT_ModHandler.getRecipeOutput(aStack) != null) return true; - if (ItemList.Schematic_2by2.isStackEqual(getInputAt(1)) && GT_ModHandler.getRecipeOutput(aStack, aStack, null, aStack, aStack) != null) { + if (ItemList.Schematic_2by2.isStackEqual(getInputAt(1)) + && GT_ModHandler.getRecipeOutput(aStack, aStack, null, aStack, aStack) != null) { return true; } - return ItemList.Schematic_3by3.isStackEqual(getInputAt(1)) && (GT_ModHandler.getRecipeOutput(aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack) != null); + return ItemList.Schematic_3by3.isStackEqual(getInputAt(1)) + && (GT_ModHandler.getRecipeOutput( + aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack) + != null); } else { return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.containsInput(aStack); } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Charger.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Charger.java index b614bc598e..f6223a4a0d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Charger.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Charger.java @@ -1,5 +1,7 @@ package gregtech.common.tileentities.machines.basic; +import static gregtech.api.enums.GT_Values.V; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -9,19 +11,20 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicBatter import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; -import static gregtech.api.enums.GT_Values.V; - public class GT_MetaTileEntity_Charger extends GT_MetaTileEntity_BasicBatteryBuffer { - public GT_MetaTileEntity_Charger(int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { + public GT_MetaTileEntity_Charger( + int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount); } - public GT_MetaTileEntity_Charger(String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { + public GT_MetaTileEntity_Charger( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { super(aName, aTier, aDescription, aTextures, aSlotCount); } - public GT_MetaTileEntity_Charger(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aSlotCount) { + public GT_MetaTileEntity_Charger( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aSlotCount) { super(aName, aTier, aDescription, aTextures, aSlotCount); } @@ -36,16 +39,18 @@ public class GT_MetaTileEntity_Charger extends GT_MetaTileEntity_BasicBatteryBuf } @Override - public long maxEUStore() { return V[mTier] * 256L * mInventory.length;} + public long maxEUStore() { + return V[mTier] * 256L * mInventory.length; + } @Override public long maxAmperesIn() { - return Math.max(mChargeableCount * 8L,4L); + return Math.max(mChargeableCount * 8L, 4L); } @Override public long maxAmperesOut() { - return Math.max(mBatteryCount * 4L,2L); + return Math.max(mBatteryCount * 4L, 2L); } @Override @@ -56,25 +61,50 @@ public class GT_MetaTileEntity_Charger extends GT_MetaTileEntity_BasicBatteryBuf BaseMetaTileEntity mBaseMetaTileEntity = (BaseMetaTileEntity) getBaseMetaTileEntity(); if (mBaseMetaTileEntity.getMetaTileEntity() instanceof MetaTileEntity) { MetaTileEntity mMetaTileEntity = (MetaTileEntity) mBaseMetaTileEntity.getMetaTileEntity(); - //for (int t = 0; t < 6; t++) { - if (mMetaTileEntity.dechargerSlotCount() > 0 && mBaseMetaTileEntity.getStoredEU() < mBaseMetaTileEntity.getEUCapacity()) { - for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { - if (mMetaTileEntity.mInventory[i] != null && mBaseMetaTileEntity.getStoredEU() < mBaseMetaTileEntity.getEUCapacity()) { - mBaseMetaTileEntity.increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(mMetaTileEntity.mInventory[i], GT_Utility.safeInt(Math.min(V[mTier] * 15, mBaseMetaTileEntity.getEUCapacity() - mBaseMetaTileEntity.getStoredEU())), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), true, false, false), true); - if (mMetaTileEntity.mInventory[i].stackSize <= 0) - mMetaTileEntity.mInventory[i] = null; + // for (int t = 0; t < 6; t++) { + if (mMetaTileEntity.dechargerSlotCount() > 0 + && mBaseMetaTileEntity.getStoredEU() < mBaseMetaTileEntity.getEUCapacity()) { + for (int i = mMetaTileEntity.dechargerSlotStartIndex(), + k = mMetaTileEntity.dechargerSlotCount() + i; + i < k; + i++) { + if (mMetaTileEntity.mInventory[i] != null + && mBaseMetaTileEntity.getStoredEU() < mBaseMetaTileEntity.getEUCapacity()) { + mBaseMetaTileEntity.increaseStoredEnergyUnits( + GT_ModHandler.dischargeElectricItem( + mMetaTileEntity.mInventory[i], + GT_Utility.safeInt(Math.min( + V[mTier] * 15, + mBaseMetaTileEntity.getEUCapacity() + - mBaseMetaTileEntity.getStoredEU())), + (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), + true, + false, + false), + true); + if (mMetaTileEntity.mInventory[i].stackSize <= 0) mMetaTileEntity.mInventory[i] = null; } } } if (mMetaTileEntity.rechargerSlotCount() > 0 && mBaseMetaTileEntity.getStoredEU() > 0) { - for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { + for (int i = mMetaTileEntity.rechargerSlotStartIndex(), + k = mMetaTileEntity.rechargerSlotCount() + i; + i < k; + i++) { if (mBaseMetaTileEntity.getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { - mBaseMetaTileEntity.decreaseStoredEU(GT_ModHandler.chargeElectricItem(mMetaTileEntity.mInventory[i], GT_Utility.safeInt(Math.min(V[mTier] * 15, mBaseMetaTileEntity.getStoredEU())), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getOutputTier()), true, false), true); - if (mMetaTileEntity.mInventory[i].stackSize <= 0) - mMetaTileEntity.mInventory[i] = null; + mBaseMetaTileEntity.decreaseStoredEU( + GT_ModHandler.chargeElectricItem( + mMetaTileEntity.mInventory[i], + GT_Utility.safeInt( + Math.min(V[mTier] * 15, mBaseMetaTileEntity.getStoredEU())), + (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getOutputTier()), + true, + false), + true); + if (mMetaTileEntity.mInventory[i].stackSize <= 0) mMetaTileEntity.mInventory[i] = null; } } - //} + // } } } } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java index d249cae2a1..dc5c976eac 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java @@ -1,6 +1,5 @@ package gregtech.common.tileentities.machines.basic; - import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; import gregtech.api.gui.GT_Container_1by1; @@ -19,32 +18,63 @@ import net.minecraftforge.fluids.FluidStack; public class GT_MetaTileEntity_CuringOven extends GT_MetaTileEntity_BasicMachine { public GT_MetaTileEntity_CuringOven(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "Heats tools for hardening", 1, 1, "E_Oven.png", "", TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_SIDE_ACTIVE")), TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_SIDE")), TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_FRONT_ACTIVE")), TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_FRONT")), TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_TOP_ACTIVE")), TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_TOP")), TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_BOTTOM_ACTIVE")), TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_BOTTOM"))); + super( + aID, + aName, + aNameRegional, + aTier, + 1, + "Heats tools for hardening", + 1, + 1, + "E_Oven.png", + "", + TextureFactory.of( + new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_SIDE_ACTIVE")), + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_SIDE")), + TextureFactory.of( + new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_FRONT_ACTIVE")), + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_FRONT")), + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_TOP_ACTIVE")), + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_TOP")), + TextureFactory.of( + new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_BOTTOM_ACTIVE")), + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/ELECTRIC_OVEN/OVERLAY_BOTTOM"))); } - public GT_MetaTileEntity_CuringOven(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + public GT_MetaTileEntity_CuringOven( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); } - public GT_MetaTileEntity_CuringOven(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + public GT_MetaTileEntity_CuringOven( + String aName, + int aTier, + String[] aDescription, + ITexture[][][] aTextures, + String aGUIName, + String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); } @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_CuringOven(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mGUIName, this.mNEIName); + return new GT_MetaTileEntity_CuringOven( + this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mGUIName, this.mNEIName); } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) && ItemList.Cell_Empty.isStackEqual(aStack); + protected boolean allowPutStackValidated( + IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) + && ItemList.Cell_Empty.isStackEqual(aStack); } @Override public boolean isFluidInputAllowed(FluidStack aFluid) { return false; } - + @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); @@ -59,30 +89,34 @@ public class GT_MetaTileEntity_CuringOven extends GT_MetaTileEntity_BasicMachine public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { for (ItemStack tStack : mInventory) - if (tStack!=null&&tStack.getItem() instanceof GT_MetaGenerated_Tool &&getBaseMetaTileEntity().getStoredEU()>0) { - getBaseMetaTileEntity().decreaseStoredEnergyUnits(24, true); + if (tStack != null + && tStack.getItem() instanceof GT_MetaGenerated_Tool + && getBaseMetaTileEntity().getStoredEU() > 0) { + getBaseMetaTileEntity().decreaseStoredEnergyUnits(24, true); NBTTagCompound aNBT = tStack.getTagCompound(); if (aNBT != null) { - int tHeat = 300; - long tWorldTime = getBaseMetaTileEntity().getWorld().getTotalWorldTime(); + int tHeat = 300; + long tWorldTime = getBaseMetaTileEntity().getWorld().getTotalWorldTime(); aNBT = aNBT.getCompoundTag("GT.ToolStats"); - if (aNBT != null&&aNBT.hasKey("Heat")) { - tHeat = aNBT.getInteger("Heat"); - if(aNBT.hasKey("HeatTime")){ - long tHeatTime = aNBT.getLong("HeatTime"); - if(tWorldTime>(tHeatTime+10)){ - tHeat = (int) (tHeat - ((tWorldTime-tHeatTime)/10)); - if(tHeat<300)tHeat=300; - } - } + if (aNBT != null && aNBT.hasKey("Heat")) { + tHeat = aNBT.getInteger("Heat"); + if (aNBT.hasKey("HeatTime")) { + long tHeatTime = aNBT.getLong("HeatTime"); + if (tWorldTime > (tHeatTime + 10)) { + tHeat = (int) (tHeat - ((tWorldTime - tHeatTime) / 10)); + if (tHeat < 300) tHeat = 300; + } + } } tHeat++; - if(aNBT!=null){ - aNBT.setInteger("Heat", tHeat); - aNBT.setLong("HeatTime", tWorldTime);} - if(tHeat>GT_MetaGenerated_Tool.getPrimaryMaterial(tStack).mMeltingPoint){mInventory[0]=null;} + if (aNBT != null) { + aNBT.setInteger("Heat", tHeat); + aNBT.setLong("HeatTime", tWorldTime); + } + if (tHeat > GT_MetaGenerated_Tool.getPrimaryMaterial(tStack).mMeltingPoint) { + mInventory[0] = null; + } } - } } } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java index 318acbea51..1f9b93a8d2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java @@ -1,5 +1,8 @@ package gregtech.common.tileentities.machines.basic; +import static gregtech.api.enums.GT_Values.MOD_ID_RC; +import static gregtech.api.enums.Textures.BlockIcons.*; + import com.google.common.collect.ArrayListMultimap; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; @@ -22,19 +25,15 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.api.util.extensions.ArrayExt; import ic2.api.item.IC2Items; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.IntStream; - -import static gregtech.api.enums.GT_Values.MOD_ID_RC; -import static gregtech.api.enums.Textures.BlockIcons.*; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachine { @@ -45,7 +44,7 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi aNameRegional, aTier, 1, - new String[]{ + new String[] { "Disassembles Machines up to " + GT_Values.TIER_COLORS[aTier] + GT_Values.VOLTAGE_NAMES[aTier], "Can also disassemble most assembler recipes!" }, @@ -54,77 +53,103 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi "Disassembler.png", "", - //Textures + // Textures TextureFactory.of( TextureFactory.of(OVERLAY_SIDE_DISASSEMBLER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_SIDE_DISASSEMBLER_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_SIDE_DISASSEMBLER_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_SIDE_DISASSEMBLER), - TextureFactory.builder().addIcon(OVERLAY_SIDE_DISASSEMBLER_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_SIDE_DISASSEMBLER_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_FRONT_DISASSEMBLER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_DISASSEMBLER_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISASSEMBLER_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_FRONT_DISASSEMBLER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_DISASSEMBLER_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISASSEMBLER_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_TOP_DISASSEMBLER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_TOP_DISASSEMBLER_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_TOP_DISASSEMBLER_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_TOP_DISASSEMBLER), - TextureFactory.builder().addIcon(OVERLAY_TOP_DISASSEMBLER_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_TOP_DISASSEMBLER_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_BOTTOM_DISASSEMBLER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_BOTTOM_DISASSEMBLER_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_BOTTOM_DISASSEMBLER_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_BOTTOM_DISASSEMBLER), - TextureFactory.builder().addIcon(OVERLAY_BOTTOM_DISASSEMBLER_GLOW).glow().build()) - ); + TextureFactory.builder() + .addIcon(OVERLAY_BOTTOM_DISASSEMBLER_GLOW) + .glow() + .build())); } - public GT_MetaTileEntity_Disassembler(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + public GT_MetaTileEntity_Disassembler( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 1, 9, aGUIName, aNEIName); } - public GT_MetaTileEntity_Disassembler(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + public GT_MetaTileEntity_Disassembler( + String aName, + int aTier, + String[] aDescription, + ITexture[][][] aTextures, + String aGUIName, + String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 1, 9, aGUIName, aNEIName); } @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Disassembler(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mGUIName, this.mNEIName); + return new GT_MetaTileEntity_Disassembler( + this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mGUIName, this.mNEIName); } private static final ItemStack[][] alwaysReplace = { - { - //ItemStack to look for - new ItemStack(Blocks.trapped_chest, 1, OreDictionary.WILDCARD_VALUE) - }, - { - //ItemStack to replace - new ItemStack(Blocks.chest) - } + { + // ItemStack to look for + new ItemStack(Blocks.trapped_chest, 1, OreDictionary.WILDCARD_VALUE) + }, + { + // ItemStack to replace + new ItemStack(Blocks.chest) + } }; private static final Object[][] OreDictionaryOverride = { - { - //String to look for - "plankWood", - "stoneCobble", - "gemDiamond", - "logWood", - "stickWood", - "treeSapling" - }, - { - //ItemStack to replace - new ItemStack(Blocks.planks), - new ItemStack(Blocks.cobblestone), - new ItemStack(Items.diamond), - new ItemStack(Blocks.log), - new ItemStack(Items.stick), - new ItemStack(Blocks.sapling) - } + { + // String to look for + "plankWood", "stoneCobble", "gemDiamond", "logWood", "stickWood", "treeSapling" + }, + { + // ItemStack to replace + new ItemStack(Blocks.planks), + new ItemStack(Blocks.cobblestone), + new ItemStack(Items.diamond), + new ItemStack(Blocks.log), + new ItemStack(Items.stick), + new ItemStack(Blocks.sapling) + } }; public static ArrayListMultimap getOutputHardOverrides() { @@ -141,7 +166,7 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi static { outputHardOverrides = ArrayListMultimap.create(); - outputHardOverrides.put(new GT_ItemStack(new ItemStack(Blocks.torch,6)), new ItemStack(Items.stick)); + outputHardOverrides.put(new GT_ItemStack(new ItemStack(Blocks.torch, 6)), new ItemStack(Items.stick)); addBlacklist(ItemList.Casing_Coil_Superconductor.get(1L)); addBlacklist(Materials.Graphene.getDust(1)); addBlacklist(ItemList.Circuit_Parts_Vacuum_Tube.get(1L)); @@ -179,34 +204,24 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi return false; } - private boolean compareToUnpacker(ItemStack is){ - return null != GT_Recipe.GT_Recipe_Map.sUnboxinatorRecipes.findRecipe( - null, - true, - true, - Long.MAX_VALUE, - null, - is); + private boolean compareToUnpacker(ItemStack is) { + return null + != GT_Recipe.GT_Recipe_Map.sUnboxinatorRecipes.findRecipe(null, true, true, Long.MAX_VALUE, null, is); } @Override public int checkRecipe() { ItemStack is = getInputAt(0); - if (GT_Utility.isStackInvalid(is)) - return DID_NOT_FIND_RECIPE; + if (GT_Utility.isStackInvalid(is)) return DID_NOT_FIND_RECIPE; - if ( - is.getItem() instanceof GT_MetaGenerated_Tool + if (is.getItem() instanceof GT_MetaGenerated_Tool || isCircuit(is) || blackList.stream().anyMatch(t -> GT_Utility.areStacksEqual(t.toStack(), is, true)) - || compareToUnpacker(is) - ) - return DID_NOT_FIND_RECIPE; + || compareToUnpacker(is)) return DID_NOT_FIND_RECIPE; Integer handleHardOverride = handleHardOverride(is); - if (handleHardOverride != null) - return handleHardOverride; + if (handleHardOverride != null) return handleHardOverride; return process(); } @@ -230,24 +245,22 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi if (is.getItem() == comp.getItem()) { IMetaTileEntity iMetaTileEntity = GregTech_API.METATILEENTITIES[is.getItemDamage()]; - return iMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock && - ((GT_MetaTileEntity_TieredMachineBlock) iMetaTileEntity).mTier > this.mTier; + return iMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock + && ((GT_MetaTileEntity_TieredMachineBlock) iMetaTileEntity).mTier > this.mTier; } return false; } - private int process(){ + private int process() { int statusCode = onTheFlyGeneration(); - if (statusCode != DID_NOT_FIND_RECIPE) - return statusCode; + if (statusCode != DID_NOT_FIND_RECIPE) return statusCode; return checkRecipeMap(); } private int onTheFlyGeneration() { Collection recipes = this.findRecipeFromMachine(); - if (recipes.isEmpty()) - return DID_NOT_FIND_RECIPE; + if (recipes.isEmpty()) return DID_NOT_FIND_RECIPE; DissassembleReference recipe = ensureDowncasting(recipes); @@ -264,16 +277,15 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi private void removeInvalidStacks(DissassembleReference recipe) { for (int i = 0; i < recipe.inputs.length; i++) - if (GT_Utility.isStackInvalid(recipe.inputs[i]) || recipe.inputs[i].stackSize < 1) - recipe.inputs[i] = null; + if (GT_Utility.isStackInvalid(recipe.inputs[i]) || recipe.inputs[i].stackSize < 1) recipe.inputs[i] = null; recipe.inputs = ArrayExt.withoutNulls(recipe.inputs, ItemStack[]::new); } private int checkRecipeMap() { - GT_Recipe gt_recipe = GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.findRecipe(this.getBaseMetaTileEntity(), true, this.maxEUInput(), null, this.getAllInputs()); - if (gt_recipe == null) - return DID_NOT_FIND_RECIPE; + GT_Recipe gt_recipe = GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.findRecipe( + this.getBaseMetaTileEntity(), true, this.maxEUInput(), null, this.getAllInputs()); + if (gt_recipe == null) return DID_NOT_FIND_RECIPE; if (gt_recipe.isRecipeInputEqual(false, null, this.getAllInputs())) { if (gt_recipe.mSpecialValue == -100) { // Bypass standard disassembler restrictions. @@ -292,52 +304,43 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } - private boolean setOutputsAndTime(ItemStack[] inputs, int stackSize){ + private boolean setOutputsAndTime(ItemStack[] inputs, int stackSize) { ItemStack machineInput =