diff --git a/dependencies.gradle b/dependencies.gradle index 91e4989ea4b..cd31dd1ba53 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -42,8 +42,8 @@ dependencies { api("com.github.GTNewHorizons:ModularUI:1.2.17:dev") api("com.github.GTNewHorizons:ModularUI2:2.2.0-1.7.10:dev") api("com.github.GTNewHorizons:waila:1.8.2:dev") - api("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-518-GTNH:dev") - api("com.github.GTNewHorizons:AE2FluidCraft-Rework:1.4.16-gtnh:dev") + api("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-521-GTNH:dev") + api("com.github.GTNewHorizons:AE2FluidCraft-Rework:1.4.21-gtnh:dev") api('com.github.GTNewHorizons:Yamcl:0.6.0:dev') api("com.github.GTNewHorizons:Postea:1.0.13:dev") @@ -72,7 +72,7 @@ dependencies { compileOnly('com.github.GTNewHorizons:VisualProspecting:1.4.0:dev') { transitive = false } compileOnly("com.github.GTNewHorizons:Galaxy-Space-GTNH:1.1.106-GTNH:dev") { transitive = false } - compileOnlyApi("com.github.GTNewHorizons:Galacticraft:3.3.1-GTNH:dev") { transitive = false } + compileOnlyApi("com.github.GTNewHorizons:Galacticraft:3.3.2-GTNH:dev") { transitive = false } implementation("com.github.GTNewHorizons:TinkersConstruct:1.13.3-GTNH:dev") compileOnly("com.github.GTNewHorizons:Chisel:2.16.1-GTNH:dev") { transitive = false } @@ -97,7 +97,7 @@ dependencies { compileOnly('com.github.GTNewHorizons:SC2:2.3.0:dev') {transitive=false} compileOnly('com.github.GTNewHorizons:Binnie:2.5.2:dev') {transitive = false} compileOnly('curse.maven:PlayerAPI-228969:2248928') {transitive=false} - devOnlyNonPublishable('com.github.GTNewHorizons:BlockRenderer6343:1.3.0:dev'){transitive=false} + devOnlyNonPublishable('com.github.GTNewHorizons:BlockRenderer6343:1.3.1:dev'){transitive=false} compileOnly("com.google.auto.value:auto-value-annotations:1.10.1") { transitive = false } annotationProcessor("com.google.auto.value:auto-value:1.10.1") diff --git a/src/main/java/bartworks/common/loaders/FluidLoader.java b/src/main/java/bartworks/common/loaders/FluidLoader.java index b5f8283aa02..97ca7f5d1d1 100644 --- a/src/main/java/bartworks/common/loaders/FluidLoader.java +++ b/src/main/java/bartworks/common/loaders/FluidLoader.java @@ -123,6 +123,7 @@ public static void run() { public static Fluid createAndRegisterFluid(String Name, Color color) { return GTFluidFactory.builder(Name) + .withLocalizedName(Name) .withTextureName("molten.autogenerated") .withColorRGBA( new short[] { (short) color.getRed(), (short) color.getGreen(), (short) color.getBlue(), @@ -134,6 +135,7 @@ public static Fluid createAndRegisterFluid(String Name, Color color) { public static Fluid createAndRegisterFluid(String Name, Color color, int temperature) { return GTFluidFactory.builder(Name) + .withLocalizedName(Name) .withTextureName("molten.autogenerated") .withColorRGBA( new short[] { (short) color.getRed(), (short) color.getGreen(), (short) color.getBlue(), diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java b/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java index dd74cfc8364..b8a5ace3cd7 100644 --- a/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java +++ b/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java @@ -14,6 +14,8 @@ package bartworks.common.tileentities.multis; import static bartworks.common.loaders.ItemRegistry.BW_BLOCKS; +import static com.gtnewhorizon.structurelib.structure.IStructureElement.PlaceResult.REJECT; +import static com.gtnewhorizon.structurelib.structure.IStructureElement.PlaceResult.SKIP; import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; @@ -76,6 +78,7 @@ import gregtech.api.enums.Mods; import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; +import gregtech.api.interfaces.INEIPreviewModifier; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -93,7 +96,7 @@ import gregtech.api.util.shutdown.ShutDownReason; public class MTEElectricImplosionCompressor extends MTEExtendedPowerMultiBlockBase - implements ISurvivalConstructable { + implements ISurvivalConstructable, INEIPreviewModifier { private static final boolean pistonEnabled = !Configuration.multiblocks.disablePistonInEIC; private Boolean piston = true; @@ -188,12 +191,31 @@ public boolean placeBlock(MTEElectricImplosionCompressor te, World world, int x, @Override public BlocksToPlace getBlocksToPlace(MTEElectricImplosionCompressor t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) { + if (t.piston) { + Pair tier = getTier(trigger); + return BlocksToPlace.create(tier.getKey(), tier.getValue()); + } return BlocksToPlace.createEmpty(); } @Override public PlaceResult survivalPlaceBlock(MTEElectricImplosionCompressor t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) { + if (t.piston) { + if (check(t, world, x, y, z)) return SKIP; + Pair tier = getTier(trigger); + if (tier == null) return REJECT; + return StructureUtility.survivalPlaceBlock( + tier.getKey(), + tier.getValue(), + world, + x, + y, + z, + env.getSource(), + env.getActor(), + env.getChatter()); + } return isAir().survivalPlaceBlock(t, world, x, y, z, trigger, env); } }) @@ -222,7 +244,7 @@ private static int getTierOfBlock(Block block, int meta) { if (block == GregTechAPI.sBlockMetal5 && meta == 2) { return 1; // Neutronium } - if (block == LudicrousBlocks.resource_block && meta == 1) { + if (Mods.Avaritia.isModLoaded() && block == LudicrousBlocks.resource_block && meta == 1) { return 2; // Infinity } if (block == GregTechAPI.sBlockMetal9) { @@ -548,4 +570,9 @@ public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrench public boolean supportsVoidProtection() { return true; } + + @Override + public void onPreviewStructureComplete(@NotNull ItemStack trigger) { + resetPiston(mBlockTier); + } } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer1.java b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer1.java index 0d36a897aec..cde9519e351 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer1.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer1.java @@ -72,7 +72,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputHatch("1-16, Hint block with dot 1", 1) .addStructureInfo("Supports Crafting Input Buffer") .addStructureInfo( - "ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier()) + "Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier()) + EnumChatFormatting.GRAY + " or better") .toolTipFinisher(); @@ -120,7 +120,7 @@ public int getGlassMeta() { } @Override - public int hatchTier() { + public int energyHatchTier() { return 6; } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer2.java b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer2.java index 472af5e84e2..44af8fb18dd 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer2.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer2.java @@ -73,7 +73,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputHatch("1-16, Hint block with dot 1", 1) .addStructureInfo("Supports Crafting Input Buffer") .addStructureInfo( - "ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier()) + "Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier()) + EnumChatFormatting.GRAY + " or better") .toolTipFinisher(); @@ -121,7 +121,7 @@ public int getGlassMeta() { } @Override - public int hatchTier() { + public int energyHatchTier() { return 7; } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer3.java b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer3.java index f1e46b2c6f9..6e89cf067ff 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer3.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer3.java @@ -74,7 +74,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputHatch("1-16, Hint block with dot 1", 1) .addStructureInfo("Supports Crafting Input Buffer") .addStructureInfo( - "ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier()) + "Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier()) + EnumChatFormatting.GRAY + " or better") .toolTipFinisher(); @@ -122,7 +122,7 @@ public int getGlassMeta() { } @Override - public int hatchTier() { + public int energyHatchTier() { return 8; } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer4.java b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer4.java index a54348f19ac..bff630a06ea 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer4.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer4.java @@ -73,7 +73,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputHatch("1-16, Hint block with dot 1", 1) .addStructureInfo("Supports Crafting Input Buffer") .addStructureInfo( - "ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier()) + "Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier()) + EnumChatFormatting.GRAY + " or better") .toolTipFinisher(); @@ -121,7 +121,7 @@ public int getGlassMeta() { } @Override - public int hatchTier() { + public int energyHatchTier() { return 9; } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer5.java b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer5.java index fd652356f95..e382dc99a9b 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer5.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTELargeFusionComputer5.java @@ -74,7 +74,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addOutputHatch("1-16, Hint block with dot 1", 1) .addStructureInfo("Supports Crafting Input Buffer") .addStructureInfo( - "ALL Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) hatchTier()) + "Energy Hatches must be " + GTUtility.getColoredTierNameFromTier((byte) energyHatchTier()) + EnumChatFormatting.GRAY + " or better") .toolTipFinisher(); @@ -122,7 +122,7 @@ public int getGlassMeta() { } @Override - public int hatchTier() { + public int energyHatchTier() { return 10; } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTENeutronActivator.java b/src/main/java/goodgenerator/blocks/tileEntity/MTENeutronActivator.java index 29b8c52c72f..d03ad532ac3 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTENeutronActivator.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTENeutronActivator.java @@ -129,7 +129,7 @@ public CheckRecipeResult process() { mFloor = (lastRecipe.mSpecialValue % 10000) * 1000000; mCeil = (lastRecipe.mSpecialValue / 10000) * 1000000; if (eV > mCeil || eV < mFloor) { - setOutputItems(ItemRefer.Radioactive_Waste.get(4)); + overwriteOutputItems(ItemRefer.Radioactive_Waste.get(4)); } // NA does not consume power, its hatches do. Set it to 0 to be sure calculatedEut = 0; diff --git a/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeFusionComputer.java b/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeFusionComputer.java index c6c54e448a8..5c1a49e58f0 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeFusionComputer.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeFusionComputer.java @@ -105,10 +105,8 @@ protected IStructureDefinition computeValue(Class typ .atLeast( gregtech.api.enums.HatchElement.InputHatch.or(gregtech.api.enums.HatchElement.InputBus), gregtech.api.enums.HatchElement.OutputHatch) - .adder(MTELargeFusionComputer::addFluidIO) .casingIndex(x.textureIndex()) .dot(1) - .hatchItemFilterAnd(x2 -> filterByMTETier(x2.hatchTier(), Integer.MAX_VALUE)) .buildAndChain(x.getGlassBlock(), x.getGlassMeta()))) .addElement( 'E', @@ -119,7 +117,7 @@ protected IStructureDefinition computeValue(Class typ .or(gregtech.api.enums.HatchElement.Energy)) .adder(MTELargeFusionComputer::addEnergyInjector) .casingIndex(x.textureIndex()) - .hatchItemFilterAnd(x2 -> filterByMTETier(x2.hatchTier(), Integer.MAX_VALUE)) + .hatchItemFilterAnd(x2 -> filterByMTETier(x2.energyHatchTier(), Integer.MAX_VALUE)) .dot(2) .buildAndChain(x.getCasingBlock(), x.getCasingMeta()))) .addElement('F', lazy(x -> ofFrame(x.getFrameBox()))) @@ -197,7 +195,7 @@ public long maxEUStore() { public abstract int getGlassMeta(); - public abstract int hatchTier(); + public abstract int energyHatchTier(); public abstract Materials getFrameBox(); @@ -485,40 +483,17 @@ private boolean addEnergyInjector(IGregTechTileEntity aBaseMetaTileEntity, int a IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; if (aMetaTileEntity instanceof MTEHatchEnergy tHatch) { - if (tHatch.getTierForStructure() < hatchTier()) return false; + if (tHatch.getTierForStructure() < energyHatchTier()) return false; tHatch.updateTexture(aBaseCasingIndex); return mEnergyHatches.add(tHatch); } else if (aMetaTileEntity instanceof MTEHatchEnergyMulti tHatch) { - if (tHatch.getTierForStructure() < hatchTier()) return false; + if (tHatch.getTierForStructure() < energyHatchTier()) return false; tHatch.updateTexture(aBaseCasingIndex); return eEnergyMulti.add(tHatch); } return false; } - private boolean addFluidIO(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) { - IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof MTEHatch hatch) { - hatch.updateTexture(aBaseCasingIndex); - hatch.updateCraftingIcon(this.getMachineCraftingIcon()); - } - if (aMetaTileEntity instanceof MTEHatchInput tInput) { - if (tInput.getTierForStructure() < hatchTier()) return false; - tInput.mRecipeMap = getRecipeMap(); - return mInputHatches.add(tInput); - } - if (aMetaTileEntity instanceof MTEHatchOutput tOutput) { - if (tOutput.getTierForStructure() < hatchTier()) return false; - return mOutputHatches.add(tOutput); - } - if (aMetaTileEntity instanceof IDualInputHatch tInput) { - tInput.updateCraftingIcon(this.getMachineCraftingIcon()); - return mDualInputHatches.add(tInput); - } - return false; - } - private boolean addDroneHatch(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) { if (aBaseMetaTileEntity == null) return false; IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity(); diff --git a/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeTurbineBase.java b/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeTurbineBase.java index 75f234a9fbb..c9280e03df2 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeTurbineBase.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/base/MTELargeTurbineBase.java @@ -32,6 +32,7 @@ import gregtech.api.interfaces.IHatchElement; import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.INEIPreviewModifier; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.MetaGeneratedTool; import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; @@ -45,7 +46,7 @@ import gregtech.common.items.MetaGeneratedTool01; public abstract class MTELargeTurbineBase extends MTEEnhancedMultiBlockBase - implements ISurvivalConstructable { + implements ISurvivalConstructable, INEIPreviewModifier { private static final String STRUCTURE_PIECE_MAIN = "main"; private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue<>() { @@ -114,18 +115,6 @@ protected IHatchElement[] getHatchElements() { return new IHatchElement[] { Maintenance, InputHatch, OutputHatch, OutputBus, InputBus, Muffler }; } - @Override - public boolean checkStructure(boolean aForceReset, IGregTechTileEntity aBaseMetaTileEntity) { - boolean f = super.checkStructure(aForceReset, aBaseMetaTileEntity); - if (f && getBaseMetaTileEntity().isServerSide()) { - // while is this a client side field, blockrenderer will reuse the server world for client side rendering - // so we must set it as well... - mFormed = true; - return true; - } - return f; - } - @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { maxPower = 0; @@ -405,4 +394,9 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu if (mMachine) return -1; return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 2, 2, 1, elementBudget, env, false, true); } + + @Override + public void onPreviewStructureComplete(@NotNull ItemStack trigger) { + mFormed = true; + } } diff --git a/src/main/java/goodgenerator/loader/RecipeLoader2.java b/src/main/java/goodgenerator/loader/RecipeLoader2.java index 284b900a5fb..2485eb1d680 100644 --- a/src/main/java/goodgenerator/loader/RecipeLoader2.java +++ b/src/main/java/goodgenerator/loader/RecipeLoader2.java @@ -56,7 +56,6 @@ import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.api.util.recipe.Scanning; -import gtPlusPlus.core.item.chemistry.GenericChem; import gtPlusPlus.core.material.MaterialsAlloy; import gtPlusPlus.core.material.MaterialsElements; import gtPlusPlus.core.recipe.common.CI; @@ -1556,8 +1555,8 @@ public static void RecipeLoad() { MaterialsAlloy.TITANSTEEL.getPlateDense(8), ItemRefer.HiC_T4.get(8), ItemList.Field_Generator_UHV.get(8), GGMaterial.enrichedNaquadahAlloy.get(OrePrefixes.gearGtSmall, 64) }, - new FluidStack[] { GenericChem.TEFLON.getFluidStack(2304), GGMaterial.dalisenite.getMolten(1152), - MaterialsAlloy.BOTMIUM.getFluidStack(288) }, + new FluidStack[] { MaterialsElements.STANDALONE.RHUGNOR.getFluidStack(144), + GGMaterial.dalisenite.getMolten(1152), MaterialsAlloy.BOTMIUM.getFluidStack(288) }, ItemRefer.Compact_Fusion_MK4.get(1), 6000, (int) TierEU.RECIPE_UV); diff --git a/src/main/java/gregtech/GTMod.java b/src/main/java/gregtech/GTMod.java index ea5a98ec060..a9379f18df2 100644 --- a/src/main/java/gregtech/GTMod.java +++ b/src/main/java/gregtech/GTMod.java @@ -63,6 +63,7 @@ import gregtech.api.interfaces.internal.IGTMod; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.implementations.MTEHatchNonConsumableBase; +import gregtech.api.objects.GTItemStack; import gregtech.api.objects.ItemData; import gregtech.api.objects.XSTR; import gregtech.api.registries.LHECoolantRegistry; @@ -77,7 +78,6 @@ import gregtech.api.util.GTRecipeRegistrator; import gregtech.api.util.GTSpawnEventHandler; import gregtech.api.util.GTUtility; -import gregtech.api.util.item.ItemHolder; import gregtech.common.GTDummyWorld; import gregtech.common.GTNetwork; import gregtech.common.GTProxy; @@ -786,7 +786,7 @@ public void onIDChangingEvent(FMLModIdMappingEvent aEvent) { for (Map gt_itemStackMap : GregTechAPI.sItemStackMappings) { GTUtility.reMap(gt_itemStackMap); } - for (SetMultimap gt_itemStackMap : GregTechAPI.itemStackMultiMaps) { + for (SetMultimap gt_itemStackMap : GregTechAPI.itemStackMultiMaps) { GTUtility.reMap(gt_itemStackMap); } } catch (Throwable e) { diff --git a/src/main/java/gregtech/api/GregTechAPI.java b/src/main/java/gregtech/api/GregTechAPI.java index 7b65e6bde5a..95388686c66 100644 --- a/src/main/java/gregtech/api/GregTechAPI.java +++ b/src/main/java/gregtech/api/GregTechAPI.java @@ -57,7 +57,6 @@ import gregtech.api.util.GTModHandler; import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTUtility; -import gregtech.api.util.item.ItemHolder; import gregtech.api.world.GTWorldgen; import gregtech.common.GTDummyWorld; import gregtech.common.items.ItemIntegratedCircuit; @@ -89,7 +88,7 @@ public class GregTechAPI { * {@link GTItemStack} */ public static final Collection> sItemStackMappings = new ArrayList<>(); - public static final Collection> itemStackMultiMaps = new ArrayList<>(); + public static final Collection> itemStackMultiMaps = new ArrayList<>(); /** * The MetaTileEntity-ID-List-Length @@ -146,17 +145,16 @@ public class GregTechAPI { /** * The List of Tools, which can be used. Accepts regular damageable Items and Electric Items */ - public static final GTHashSet sToolList = new GTHashSet<>(), sCrowbarList = new GTHashSet<>(), - sScrewdriverList = new GTHashSet<>(), sWrenchList = new GTHashSet<>(), sSoftHammerList = new GTHashSet<>(), - sHardHammerList = new GTHashSet<>(), sWireCutterList = new GTHashSet<>(), - sSolderingToolList = new GTHashSet<>(), sSolderingMetalList = new GTHashSet<>(), - sJackhammerList = new GTHashSet<>(); + public static final GTHashSet sToolList = new GTHashSet(), sCrowbarList = new GTHashSet(), + sScrewdriverList = new GTHashSet(), sWrenchList = new GTHashSet(), sSoftHammerList = new GTHashSet(), + sHardHammerList = new GTHashSet(), sWireCutterList = new GTHashSet(), sSolderingToolList = new GTHashSet(), + sSolderingMetalList = new GTHashSet(), sJackhammerList = new GTHashSet(); /** * The List of Hazmat Armors */ - public static final GTHashSet sGasHazmatList = new GTHashSet<>(), sBioHazmatList = new GTHashSet<>(), - sFrostHazmatList = new GTHashSet<>(), sHeatHazmatList = new GTHashSet<>(), sRadioHazmatList = new GTHashSet<>(), - sElectroHazmatList = new GTHashSet<>(); + public static final GTHashSet sGasHazmatList = new GTHashSet(), sBioHazmatList = new GTHashSet(), + sFrostHazmatList = new GTHashSet(), sHeatHazmatList = new GTHashSet(), sRadioHazmatList = new GTHashSet(), + sElectroHazmatList = new GTHashSet(); private static final Multimap sRealConfigurationList = Multimaps .newListMultimap(new TreeMap<>(), ArrayList::new); diff --git a/src/main/java/gregtech/api/enums/GTValues.java b/src/main/java/gregtech/api/enums/GTValues.java index 4223a7ed3fe..1c5dedee8a7 100644 --- a/src/main/java/gregtech/api/enums/GTValues.java +++ b/src/main/java/gregtech/api/enums/GTValues.java @@ -230,79 +230,7 @@ public class GTValues { */ public static final class NBT { - public static final String COLOR = "gt.color", // Integer - COVERS = "gt.covers", // String - CUSTOM_NAME = "name", // String - DISPLAY = "gt.display", // String - TIER = "gt.tier", // Number - FACING = "gt.facing", // Byte - LOCK_UPGRADE = "gt.locked", // Boolean - MATERIAL = "gt.material", // String containing the Material Name. - MODE = "gt.mode", // Number - ALLOWED_MODES = "gt.amode", // Number - MTE_ID = "gt.mte.id", // Containing the MTE ID - MTE_REG = "gt.mte.reg", // Containing the MTE Registry ID - OWNER = "gt.owner", // String - OWNER_UUID = "gt.ownerUuid", // UUID (String) - - // Machines - ACTIVE = "gt.active", // Boolean - FLUID_OUT = "gt.fluidout", // Output Fluid - ITEM_OUT = "gt.itemout", // Output Item - PARALLEL = "gt.parallel", // Number - TANK_CAPACITY = "gt.tankcap", // Number - TANK_IN = "gt.tank.in.", // FluidStack - TANK_OUT = "gt.tank.out.", // FluidStack - TEXTURE_FOLDER = "gt.texture.folder", // String - INV_INPUT_SIZE = "gt.invsize.in", // Number - INV_OUTPUT_SIZE = "gt.invsize.out", // Number - INV_INPUT_LIST = "gt.invlist.in", // NBT List - INV_OUTPUT_LIST = "gt.invlist.out", // NBT List - VOLTAGE = "gt.voltage", // Number - AMPERAGE = "gt.amperage", // Number - STORED_ENERGY = "gt.stored.energy", // Number - MAXIMUM_ENERGY = "gt.maximum.energy", // Number - EUT_CONSUMPTION = "gt.eut.consumption", // Number - BURN_TIME_LEFT = "gt.burn.time.left", // Number - TOTAL_BURN_TIME = "gt.total.burn.time", // Number - ALLOWED_WORK = "gt.allowed.work", // Boolean - TASKS = "gt.tasks", // Compound - - // MultiBlock - STRUCTURE_OK = "gt.structure.ok", ROTATION = "gt.eRotation", FLIP = "gt.eFlip", TARGET = "gt.target", // Boolean - TARGET_X = "gt.target.x", // Number - TARGET_Y = "gt.target.y", // Number - TARGET_Z = "gt.target.z", // Number - LOCKED_FLUID = "gt.locked.fluid", // String - LOCKED_INVENTORY = "gt.locked.inv", // String - LOCKED_INVENTORY_INDEX = "gt.locked.inv.index", // Number - UPGRADE_INVENTORY_SIZE = "gt.invsize.upg", // String - UPGRADE_INVENTORY_UUID = "gt.invuuid.upg", // String - UPGRADE_INVENTORY_NAME = "gt.invname.upg", // String - UPGRADE_INVENTORIES_INPUT = "gt.invlist.upg.in", // NBT List - UPGRADE_INVENTORIES_OUTPUT = "gt.invlist.upg.out", // NBT List - UPGRADE_TANK_CAPACITY = "gt.tank.cap.upg", // Long - UPGRADE_TANK_COUNT = "gt.tank.ct.upg", // Int - UPGRADE_TANK_CAPACITY_MULTIPLIER = "gt.tank.cap.mult.upg", // Long - UPGRADE_TANK_UUID = "gt.tankuuid.upg", // String - UPGRADE_TANK_NAME = "gt.tankname.upg", // String - UPGRADE_TANKS_INPUT = "gt.tanklist.upg.in", // NBT List - UPGRADE_TANKS_OUTPUT = "gt.tanklist.upg.out", // NBT List - UPGRADE_TANKS_PREFIX = "gt.tank.upg", // NBT Tag - UPGRADE_AMPERAGE = "gt.amp.upg", // Long - SEPARATE_INPUTS = "gt.separate.inputs", // Boolean - VOIDING_MODE = "gt.voiding.mode", // String - BATCH_MODE = "gt.batch.mode", // Boolean - RECIPE_LOCK = "gt.recipe.lock", // Boolean - - // Logic - POWER_LOGIC = "gt.pow.logic", // NBT Tag - POWER_LOGIC_STORED_ENERGY = "gt.pow.energy", // Number - POWER_LOGIC_ENERGY_CAPACITY = "gt.pow.energy.cap", // Number - POWER_LOGIC_VOLTAGE = "gt.pow.volt", // Number - POWER_LOGIC_AMPERAGE = "gt.pow.amp", // Number - POWER_LOGIC_TYPE = "gt.pow.type", // Number - empty_ = ""; + public static final String COVERS = "gt.covers"; // String } /** The Color White as RGB Short Array. */ @@ -435,11 +363,6 @@ public static final class NBT { * Debug parameter for {@link GTChunkAssociatedData} */ public static boolean debugWorldData = false; - /** - * Parameter if multi tile entities (MuTEs) should be enabled in the pack. Turned off by default until - * implementation is done. - */ - public static boolean enableMultiTileEntities = false; /** * Number of ticks between sending sound packets to clients for electric machines. Default is 1.5 seconds. Trying to * mitigate lag and FPS drops. diff --git a/src/main/java/gregtech/api/enums/InventoryType.java b/src/main/java/gregtech/api/enums/InventoryType.java deleted file mode 100644 index 50927381748..00000000000 --- a/src/main/java/gregtech/api/enums/InventoryType.java +++ /dev/null @@ -1,7 +0,0 @@ -package gregtech.api.enums; - -public enum InventoryType { - Input, - Output, - Both -} diff --git a/src/main/java/gregtech/api/gui/GUIHost.java b/src/main/java/gregtech/api/gui/GUIHost.java deleted file mode 100644 index bbb94317c47..00000000000 --- a/src/main/java/gregtech/api/gui/GUIHost.java +++ /dev/null @@ -1,56 +0,0 @@ -package gregtech.api.gui; - -import java.util.Objects; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; - -import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; - -public interface GUIHost extends ITileWithModularUI { - - @Nonnull - @Override - default ModularWindow createWindow(UIBuildContext uiContext) { - Objects.requireNonNull(uiContext); - GUIProvider gui = getGUI(uiContext); - return gui.openGUI(uiContext); - } - - /** - * Width of the GUI when its being displayed - */ - default int getWidth() { - return 170; - } - - default int getHeight() { - return 192; - } - - @Nonnull - GUIProvider getGUI(@Nonnull UIBuildContext uiContext); - - ItemStack getAsItem(); - - String getMachineName(); - - default boolean hasItemInput() { - return true; - } - - default boolean hasItemOutput() { - return true; - } - - default boolean hasFluidInput() { - return true; - } - - default boolean hasFluidOutput() { - return true; - } -} diff --git a/src/main/java/gregtech/api/gui/GUIProvider.java b/src/main/java/gregtech/api/gui/GUIProvider.java deleted file mode 100644 index 6fec4aa52af..00000000000 --- a/src/main/java/gregtech/api/gui/GUIProvider.java +++ /dev/null @@ -1,38 +0,0 @@ -package gregtech.api.gui; - -import java.util.Objects; - -import javax.annotation.Nonnull; - -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; - -public abstract class GUIProvider { - - @Nonnull - protected final T host; - - public GUIProvider(@Nonnull T host) { - this.host = host; - } - - @Nonnull - public ModularWindow openGUI(@Nonnull UIBuildContext uiContext) { - Builder builder = Objects.requireNonNull(ModularWindow.builder(host.getWidth(), host.getHeight())); - if (shouldBindPlayerInventory()) { - builder.bindPlayerInventory(uiContext.getPlayer()); - } - attachSynchHandlers(builder, uiContext); - addWidgets(builder, uiContext); - return Objects.requireNonNull(builder.build()); - } - - protected abstract void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext); - - protected abstract void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext); - - protected boolean shouldBindPlayerInventory() { - return true; - } -} diff --git a/src/main/java/gregtech/api/interfaces/INEIPreviewModifier.java b/src/main/java/gregtech/api/interfaces/INEIPreviewModifier.java new file mode 100644 index 00000000000..757b99f7f3f --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/INEIPreviewModifier.java @@ -0,0 +1,13 @@ +package gregtech.api.interfaces; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.NotNull; + +@SuppressWarnings("unused") +public interface INEIPreviewModifier { + + default void onPreviewConstruct(@NotNull ItemStack trigger) {} + + default void onPreviewStructureComplete(@NotNull ItemStack trigger) {} +} diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java index 6dbc6bd5b8b..2139bb4c547 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java @@ -2,15 +2,11 @@ import java.util.Objects; -import javax.annotation.Nonnull; - import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import cofh.api.energy.IEnergyReceiver; import gregtech.api.GregTechAPI; -import gregtech.api.logic.PowerLogic; -import gregtech.api.logic.interfaces.PowerLogicHost; import gregtech.api.util.GTUtility; import ic2.api.energy.tile.IEnergySink; @@ -77,15 +73,7 @@ public static long emitEnergyToNetwork(long voltage, long amperage, IEnergyConne final ForgeDirection oppositeSide = Objects.requireNonNull(side.getOpposite()); final TileEntity tTileEntity = emitterTile.getTileEntityAtSide(side); - if (tTileEntity instanceof PowerLogicHost host) { - - final PowerLogic logic = host.getPowerLogic(oppositeSide); - if (logic == null || logic.isEnergyReceiver()) { - continue; - } - - usedAmperes += logic.injectEnergy(voltage, amperage - usedAmperes); - } else if (tTileEntity instanceof IEnergyConnected energyConnected) { + if (tTileEntity instanceof IEnergyConnected energyConnected) { if (emitter.getColorization() >= 0) { final byte tColor = energyConnected.getColorization(); if (tColor >= 0 && tColor != emitter.getColorization()) continue; @@ -107,72 +95,5 @@ public static long emitEnergyToNetwork(long voltage, long amperage, IEnergyConne } return usedAmperes; } - - /** - * Same as {@link #emitEnergyToNetwork(long, long, IEnergyConnected)}, but instead we remove the energy directly from the logic itself. - * @param emitter The host, which is trying to emit energy in the network - * @param outputSide side from where energy is being outputted to. If its {@link ForgeDirection#UNKNOWN} then it doesn't emit energy to the network - */ - public static void emitEnergyToNetwork(@Nonnull final PowerLogicHost emitter, @Nonnull final ForgeDirection outputSide) { - if (outputSide == ForgeDirection.UNKNOWN) return; - final PowerLogic emitterLogic = emitter.getPowerLogic(); - long usedAmperes = 0; - long voltage = emitterLogic.getVoltage(); - long amperage = emitterLogic.getMaxAmperage(); - if (!(emitter instanceof final IHasWorldObjectAndCoords emitterTile)) { - return; - } - // We need to make sure we can actually output energy on this side. This is more of a safety check. - if (emitter.getPowerLogic(outputSide) == null) { - return; - } - - final ForgeDirection oppositeSide = Objects.requireNonNull(outputSide.getOpposite()); - final TileEntity tileEntity = emitterTile.getTileEntityAtSide(outputSide); - if (tileEntity instanceof PowerLogicHost host) { - - final PowerLogic logic = host.getPowerLogic(oppositeSide); - if (logic == null || logic.isEnergyReceiver()) { - return; - } - - usedAmperes += logic.injectEnergy(voltage, amperage); - emitterLogic.removeEnergyUnsafe(usedAmperes * voltage); - return; - } - - if (tileEntity instanceof IEnergyConnected energyConnected) { - if (emitter instanceof IColoredTileEntity coloredEmitter && coloredEmitter.getColorization() >= 0) { - final byte tColor = energyConnected.getColorization(); - if (tColor >= 0 && tColor != coloredEmitter.getColorization()) { - return; - } - } - usedAmperes += energyConnected.injectEnergyUnits(oppositeSide, voltage, amperage - usedAmperes); - emitterLogic.removeEnergyUnsafe(usedAmperes * voltage); - return; - } - - if (tileEntity instanceof IEnergySink sink) { - if (sink.acceptsEnergyFrom((TileEntity) emitter, oppositeSide)) { - while (amperage > usedAmperes && sink.getDemandedEnergy() > 0 - && sink.injectEnergy(oppositeSide, voltage, voltage) < voltage) { - usedAmperes++; - } - emitterLogic.removeEnergyUnsafe(usedAmperes * voltage); - return; - } - } - - if (GregTechAPI.mOutputRF && tileEntity instanceof IEnergyReceiver receiver) { - final int rfOut = GTUtility.safeInt(voltage * GregTechAPI.mEUtoRF / 100); - if (receiver.receiveEnergy(oppositeSide, rfOut, true) == rfOut) { - receiver.receiveEnergy(oppositeSide, rfOut, false); - usedAmperes++; - emitterLogic.removeEnergyUnsafe(usedAmperes * voltage); - return; - } - } - } } } diff --git a/src/main/java/gregtech/api/logic/AbstractProcessingLogic.java b/src/main/java/gregtech/api/logic/AbstractProcessingLogic.java deleted file mode 100644 index d4f0e96a36b..00000000000 --- a/src/main/java/gregtech/api/logic/AbstractProcessingLogic.java +++ /dev/null @@ -1,344 +0,0 @@ -package gregtech.api.logic; - -import java.util.function.Supplier; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -import gregtech.api.interfaces.tileentity.IVoidable; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.check.CheckRecipeResult; -import gregtech.api.recipe.check.CheckRecipeResultRegistry; -import gregtech.api.util.GTRecipe; -import gregtech.api.util.OverclockCalculator; -import gregtech.api.util.ParallelHelper; - -/** - * Logic class to calculate result of recipe check from inputs. - */ -@SuppressWarnings({ "unused", "UnusedReturnValue" }) -public abstract class AbstractProcessingLogic

> { - - protected IVoidable machine; - protected Supplier> recipeMapSupplier; - protected GTRecipe lastRecipe; - protected RecipeMap lastRecipeMap; - protected ItemStack[] outputItems; - protected FluidStack[] outputFluids; - protected long calculatedEut; - protected int duration; - protected long availableVoltage; - protected long availableAmperage; - protected double overClockTimeReduction = 2.0; - protected double overClockPowerIncrease = 4.0; - protected boolean protectItems; - protected boolean protectFluids; - protected int maxParallel = 1; - protected Supplier maxParallelSupplier; - protected int calculatedParallels = 0; - protected int batchSize = 1; - protected double euModifier = 1.0; - protected double speedBoost = 1.0; - protected boolean amperageOC = true; - protected boolean isCleanroom; - protected boolean needWipeCraftingPatternRecipeCache; - - // #region Setters - - /** - * Overwrites item output result of the calculation. - */ - public P setOutputItems(ItemStack... itemOutputs) { - this.outputItems = itemOutputs; - return getThis(); - } - - /** - * Overwrites fluid output result of the calculation. - */ - public P setOutputFluids(FluidStack... fluidOutputs) { - this.outputFluids = fluidOutputs; - return getThis(); - } - - public P setIsCleanroom(boolean isCleanroom) { - this.isCleanroom = isCleanroom; - return getThis(); - } - - /** - * Sets max amount of parallel. - */ - public P setMaxParallel(int maxParallel) { - this.maxParallel = maxParallel; - return getThis(); - } - - /** - * Sets method to get max amount of parallel. - */ - public P setMaxParallelSupplier(Supplier supplier) { - this.maxParallelSupplier = supplier; - return getThis(); - } - - /** - * Sets batch size for batch mode. - */ - public P setBatchSize(int size) { - this.batchSize = size; - return getThis(); - } - - public P setRecipeMap(RecipeMap recipeMap) { - return setRecipeMapSupplier(() -> recipeMap); - } - - public P setRecipeMapSupplier(Supplier> supplier) { - this.recipeMapSupplier = supplier; - return getThis(); - } - - public P setEuModifier(double modifier) { - this.euModifier = modifier; - return getThis(); - } - - public P setSpeedBonus(double speedModifier) { - this.speedBoost = speedModifier; - return getThis(); - } - - /** - * Sets machine used for void protection logic. - */ - public P setMachine(IVoidable machine) { - this.machine = machine; - return getThis(); - } - - /** - * Overwrites duration result of the calculation. - */ - public P setDuration(int duration) { - this.duration = duration; - return getThis(); - } - - /** - * Overwrites EU/t result of the calculation. - */ - public P setCalculatedEut(long calculatedEut) { - this.calculatedEut = calculatedEut; - return getThis(); - } - - /** - * Sets voltage of the machine. It doesn't need to be actual voltage (excluding amperage) of the machine; - * For example, most of the multiblock machines set maximum possible input power (including amperage) as voltage - * and 1 as amperage. That way recipemap search will be executed with overclocked voltage. - */ - public P setAvailableVoltage(long voltage) { - availableVoltage = voltage; - return getThis(); - } - - /** - * Sets amperage of the machine. This amperage doesn't involve in EU/t when searching recipemap. - * Useful for preventing tier skip but still considering amperage for parallel. - */ - public P setAvailableAmperage(long amperage) { - availableAmperage = amperage; - return getThis(); - } - - public P setVoidProtection(boolean protectItems, boolean protectFluids) { - this.protectItems = protectItems; - this.protectFluids = protectFluids; - return getThis(); - } - - public P setOverclock(double timeReduction, double powerIncrease) { - this.overClockTimeReduction = timeReduction; - this.overClockPowerIncrease = powerIncrease; - return getThis(); - } - - /** - * Sets overclock ratio to 4/4. - */ - public P enablePerfectOverclock() { - return this.setOverclock(4.0, 4.0); - } - - /** - * Sets whether the multi should use amperage to OC or not - */ - public P setAmperageOC(boolean amperageOC) { - this.amperageOC = amperageOC; - return getThis(); - } - - /** - * Clears calculated results (and provided machine inputs) to prepare for the next machine operation. - */ - public P clear() { - this.calculatedEut = 0; - this.duration = 0; - this.calculatedParallels = 0; - return getThis(); - } - - // #endregion - - // #region Logic - - /** - * Executes the recipe check: Find recipe from recipemap, Calculate parallel, overclock and outputs. - */ - @Nonnull - public abstract CheckRecipeResult process(); - - /** - * Refreshes recipemap to use. Remember to call this before {@link #process} to make sure correct recipemap is used. - * - * @return Recipemap to use now - */ - protected RecipeMap preProcess() { - RecipeMap recipeMap; - if (recipeMapSupplier == null) { - recipeMap = null; - } else { - recipeMap = recipeMapSupplier.get(); - } - if (lastRecipeMap != recipeMap) { - if (lastRecipeMap != null) needWipeCraftingPatternRecipeCache = true; - lastRecipe = null; - lastRecipeMap = recipeMap; - } - - if (maxParallelSupplier != null) { - maxParallel = maxParallelSupplier.get(); - } - - return recipeMap; - } - - /** - * Check has been succeeded, so it applies the recipe and calculated parameters. - * At this point, inputs have been already consumed. - */ - @Nonnull - protected CheckRecipeResult applyRecipe(@Nonnull GTRecipe recipe, @Nonnull ParallelHelper helper, - @Nonnull OverclockCalculator calculator, @Nonnull CheckRecipeResult result) { - if (recipe.mCanBeBuffered) { - lastRecipe = recipe; - } else { - lastRecipe = null; - } - calculatedParallels = helper.getCurrentParallel(); - - if (calculator.getConsumption() == Long.MAX_VALUE) { - return CheckRecipeResultRegistry.POWER_OVERFLOW; - } - if (calculator.getDuration() == Integer.MAX_VALUE) { - return CheckRecipeResultRegistry.DURATION_OVERFLOW; - } - - calculatedEut = calculator.getConsumption(); - - double finalDuration = calculateDuration(recipe, helper, calculator); - if (finalDuration >= Integer.MAX_VALUE) { - return CheckRecipeResultRegistry.DURATION_OVERFLOW; - } - duration = (int) finalDuration; - - CheckRecipeResult hookResult = onRecipeStart(recipe); - if (!hookResult.wasSuccessful()) { - return hookResult; - } - - outputItems = helper.getItemOutputs(); - outputFluids = helper.getFluidOutputs(); - - return result; - } - - /** - * Override to tweak final duration that will be set as a result of this logic class. - */ - protected double calculateDuration(@Nonnull GTRecipe recipe, @Nonnull ParallelHelper helper, - @Nonnull OverclockCalculator calculator) { - return calculator.getDuration() * helper.getDurationMultiplierDouble(); - } - - /** - * Override to do additional check for found recipe if needed. - */ - @Nonnull - protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - /** - * Override to perform additional logic when recipe starts. - *

- * This is called when the recipe processing logic has finished all - * checks, consumed all inputs, but has not yet set the outputs to - * be produced. Returning a result other than SUCCESSFUL will void - * all inputs! - */ - @Nonnull - protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - /** - * Override to tweak overclock logic if needed. - */ - @Nonnull - protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { - return new OverclockCalculator().setRecipeEUt(recipe.mEUt) - .setAmperage(availableAmperage) - .setEUt(availableVoltage) - .setDuration(recipe.mDuration) - .setSpeedBoost(speedBoost) - .setEUtDiscount(euModifier) - .setAmperageOC(amperageOC) - .setDurationDecreasePerOC(overClockTimeReduction) - .setEUtIncreasePerOC(overClockPowerIncrease); - } - // #endregion - - // #region Getters - - public ItemStack[] getOutputItems() { - return outputItems; - } - - public FluidStack[] getOutputFluids() { - return outputFluids; - } - - public int getDuration() { - return duration; - } - - public long getCalculatedEut() { - return calculatedEut; - } - - public int getCurrentParallels() { - return calculatedParallels; - } - - @SuppressWarnings("unchecked") - @Nonnull - public P getThis() { - return (P) this; - } - - // #endregion -} diff --git a/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java b/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java deleted file mode 100644 index 91df0bb1b64..00000000000 --- a/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java +++ /dev/null @@ -1,113 +0,0 @@ -package gregtech.api.logic; - -import java.util.stream.LongStream; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -public class ComplexParallelProcessingLogic

> - extends MuTEProcessingLogic

{ - - protected int maxComplexParallels; - protected ItemStack[][] outputItems; - protected FluidStack[][] outputFluids; - protected long[] calculatedEutValues; - protected int[] durations; - protected int[] progresses; - - public P setMaxComplexParallel(int maxComplexParallels) { - this.maxComplexParallels = maxComplexParallels; - reinitializeProcessingArrays(); - return getThis(); - } - - public ItemStack[] getOutputItems(int index) { - if (index >= 0 && index < maxComplexParallels) { - return outputItems[index]; - } - return null; - } - - public FluidStack[] getOutputFluids(int index) { - if (index >= 0 && index < maxComplexParallels) { - return outputFluids[index]; - } - return null; - } - - @Override - public boolean canWork() { - for (int i = 0; i < maxComplexParallels; i++) { - if (progresses[i] >= durations[i]) { - return machineHost.isAllowedToWork(); - } - } - return false; - } - - @Override - public long getCalculatedEut() { - return LongStream.of(this.calculatedEutValues) - .sum(); - } - - public int getDuration(int index) { - return durations[index]; - } - - public int getProgress(int index) { - return progresses[index]; - } - - @Override - public void progress() { - for (int i = 0; i < maxComplexParallels; i++) { - if (progresses[i] == durations[i]) { - progresses[i] = 0; - durations[i] = 0; - output(i); - continue; - } - progresses[i] = progresses[i] + 1; - } - } - - @Override - public void startCheck() { - for (int i = 0; i < maxComplexParallels; i++) { - if (durations[i] > 0) continue; - recipeResult = process(); - calculatedEutValues[i] = calculatedEut; - durations[i] = duration; - progresses[i] = 0; - outputItems[i] = getOutputItems(); - outputFluids[i] = getOutputFluids(); - } - } - - protected void output(int index) { - setOutputItems(getOutputItems(index)); - setOutputFluids(getOutputFluids(index)); - output(); - } - - protected void reinitializeProcessingArrays() { - ItemStack[][] oldOutputItems = outputItems; - FluidStack[][] oldOutputFluids = outputFluids; - long[] oldCalculatedEutValues = calculatedEutValues; - int[] oldDurations = durations; - int[] oldProgresses = progresses; - outputItems = new ItemStack[maxComplexParallels][]; - outputFluids = new FluidStack[maxComplexParallels][]; - calculatedEutValues = new long[maxComplexParallels]; - durations = new int[maxComplexParallels]; - progresses = new int[maxComplexParallels]; - System.arraycopy(oldOutputItems, 0, outputItems, 0, oldOutputItems.length); - System.arraycopy(oldOutputFluids, 0, outputFluids, 0, oldOutputFluids.length); - System.arraycopy(oldCalculatedEutValues, 0, calculatedEutValues, 0, oldCalculatedEutValues.length); - for (int i = 0; i < oldDurations[i]; i++) { - durations[i] = oldDurations[i]; - } - System.arraycopy(oldProgresses, 0, progresses, 0, oldProgresses.length); - } -} diff --git a/src/main/java/gregtech/api/logic/ControllerFluidLogic.java b/src/main/java/gregtech/api/logic/ControllerFluidLogic.java deleted file mode 100644 index 227f7641ce5..00000000000 --- a/src/main/java/gregtech/api/logic/ControllerFluidLogic.java +++ /dev/null @@ -1,152 +0,0 @@ -package gregtech.api.logic; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; -import java.util.stream.Collectors; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.Constants; - -import org.apache.commons.lang3.tuple.Pair; - -/** - * Controller logic for Fluid inventories - * - * @author BlueWeabo - */ -public class ControllerFluidLogic { - - private final Map inventories = new HashMap<>(); - private final Set> unallocatedInventories = new HashSet<>(); - - public void addInventory(@Nonnull UUID id, @Nonnull FluidInventoryLogic inventory) { - Pair found = checkIfInventoryExistsAsUnallocated(inventory); - if (inventory.isUpgradeInventory() && found != null) { - unallocatedInventories.remove(found); - inventories.put(id, found.getRight()); - return; - } - inventories.put(id, inventory); - } - - @Nonnull - public UUID addInventory(@Nonnull FluidInventoryLogic inventory) { - Pair found = checkIfInventoryExistsAsUnallocated(inventory); - if (inventory.isUpgradeInventory() && found != null) { - unallocatedInventories.remove(found); - inventories.put(found.getLeft(), found.getRight()); - return Objects.requireNonNull(found.getLeft()); - } - UUID generatedUUID = Objects.requireNonNull(UUID.randomUUID()); - inventories.put(generatedUUID, inventory); - return generatedUUID; - } - - @Nullable - private Pair checkIfInventoryExistsAsUnallocated( - @Nonnull FluidInventoryLogic inventory) { - if (unallocatedInventories.isEmpty()) { - return null; - } - return unallocatedInventories.stream() - .filter( - unallocated -> unallocated.getRight() - .getTier() == inventory.getTier()) - .findFirst() - .get(); - } - - /** - * Removes the inventory with said id and gives it back to be processed if needed. - */ - @Nonnull - public FluidInventoryLogic removeInventory(@Nonnull UUID id) { - return Objects.requireNonNull(inventories.remove(id)); - } - - @Nonnull - public FluidInventoryLogic getAllInventoryLogics() { - return new FluidInventoryLogic( - inventories.values() - .stream() - .map(inv -> inv.getInventory()) - .collect(Collectors.toList())); - } - - @Nonnull - public FluidInventoryLogic getInventoryLogic(@Nullable UUID id) { - if (id == null) return getAllInventoryLogics(); - return Objects.requireNonNull(inventories.getOrDefault(id, getAllInventoryLogics())); - } - - @Nonnull - public Set> getAllInventoryLogicsAsEntrySet() { - return Objects.requireNonNull(inventories.entrySet()); - } - - @Nonnull - public String getInventoryDisplayName(@Nullable UUID id) { - if (id == null) return ""; - FluidInventoryLogic logic = inventories.get(id); - if (logic == null) return ""; - String displayName = logic.getDisplayName(); - if (displayName == null) return Objects.requireNonNull(id.toString()); - return displayName; - } - - public void setInventoryDisplayName(@Nullable UUID id, @Nullable String displayName) { - if (id == null) return; - FluidInventoryLogic logic = inventories.get(id); - if (logic == null) return; - logic.setDisplayName(displayName); - } - - @Nonnull - public NBTTagCompound saveToNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - NBTTagList inventoriesNBT = new NBTTagList(); - inventories.forEach((uuid, inventory) -> { - NBTTagCompound inventoryNBT = new NBTTagCompound(); - inventoryNBT.setTag("inventory", inventory.saveToNBT()); - inventoryNBT.setString("uuid", uuid.toString()); - inventoryNBT.setInteger( - "invSize", - inventory.getInventory() - .getTanks()); - inventoryNBT.setLong( - "tankCapacity", - inventory.getInventory() - .getTankCapacity(0)); - inventoriesNBT.appendTag(inventoryNBT); - }); - nbt.setTag("inventories", inventoriesNBT); - return nbt; - } - - public void loadFromNBT(@Nonnull NBTTagCompound nbt) { - NBTTagList inventoriesNBT = nbt.getTagList("inventories", Constants.NBT.TAG_COMPOUND); - if (inventoriesNBT == null) return; - for (int i = 0; i < inventoriesNBT.tagCount(); i++) { - NBTTagCompound inventoryNBT = inventoriesNBT.getCompoundTagAt(i); - UUID uuid = UUID.fromString(inventoryNBT.getString("uuid")); - FluidInventoryLogic inventory = new FluidInventoryLogic( - inventoryNBT.getInteger("invSize"), - inventoryNBT.getLong("tankCapacity")); - inventory.loadFromNBT(inventoryNBT.getCompoundTag("inventory")); - if (inventory.isUpgradeInventory()) { - unallocatedInventories.add(Pair.of(uuid, inventory)); - } else { - inventories.put(uuid, inventory); - } - } - } -} diff --git a/src/main/java/gregtech/api/logic/ControllerItemLogic.java b/src/main/java/gregtech/api/logic/ControllerItemLogic.java deleted file mode 100644 index 28cc75313a3..00000000000 --- a/src/main/java/gregtech/api/logic/ControllerItemLogic.java +++ /dev/null @@ -1,148 +0,0 @@ -package gregtech.api.logic; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; -import java.util.stream.Collectors; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.Constants; - -import org.apache.commons.lang3.tuple.Pair; - -/** - * Logic of the Item logic for the controller. This is controlling all of the inventories. - * - * @author BlueWeabo - */ -public class ControllerItemLogic { - - private final Map inventories = new HashMap<>(); - private final Set> unallocatedInventories = new HashSet<>(); - - public void addInventory(@Nonnull UUID id, @Nonnull ItemInventoryLogic inventory) { - Pair found = checkIfInventoryExistsAsUnallocated(inventory); - if (inventory.isUpgradeInventory() && found != null) { - unallocatedInventories.remove(found); - inventories.put(id, found.getRight()); - return; - } - inventories.put(id, inventory); - } - - @Nonnull - public UUID addInventory(@Nonnull ItemInventoryLogic inventory) { - Pair found = checkIfInventoryExistsAsUnallocated(inventory); - if (inventory.isUpgradeInventory() && found != null) { - unallocatedInventories.remove(found); - inventories.put(found.getLeft(), found.getRight()); - return Objects.requireNonNull(found.getLeft()); - } - UUID generatedUUID = Objects.requireNonNull(UUID.randomUUID()); - inventories.put(generatedUUID, inventory); - return generatedUUID; - } - - @Nullable - private Pair checkIfInventoryExistsAsUnallocated(@Nonnull ItemInventoryLogic inventory) { - if (unallocatedInventories.isEmpty()) { - return null; - } - return unallocatedInventories.stream() - .filter( - unallocated -> unallocated.getRight() - .getTier() == inventory.getTier() - && unallocated.getRight() - .getSlots() == inventory.getSlots()) - .findFirst() - .get(); - } - - /** - * Removes the inventory with said id and gives it back to be processed if needed. - */ - @Nonnull - public ItemInventoryLogic removeInventory(@Nonnull UUID id) { - return Objects.requireNonNull(inventories.remove(id)); - } - - @Nonnull - public ItemInventoryLogic getAllInventoryLogics() { - return new ItemInventoryLogic( - inventories.values() - .stream() - .map(inv -> inv.getInventory()) - .collect(Collectors.toList())); - } - - @Nonnull - public ItemInventoryLogic getInventoryLogic(@Nullable UUID id) { - if (id == null) return getAllInventoryLogics(); - return Objects.requireNonNull(inventories.getOrDefault(id, getAllInventoryLogics())); - } - - @Nonnull - public Set> getAllInventoryLogicsAsEntrySet() { - return Objects.requireNonNull(inventories.entrySet()); - } - - @Nullable - public String getInventoryDisplayName(@Nullable UUID id) { - if (id == null) return ""; - ItemInventoryLogic logic = inventories.get(id); - if (logic == null) return ""; - String displayName = logic.getDisplayName(); - if (displayName == null) return Objects.requireNonNull(id.toString()); - return displayName; - } - - public void setInventoryDisplayName(@Nullable UUID id, @Nullable String displayName) { - if (id == null) return; - ItemInventoryLogic logic = inventories.get(id); - if (logic == null) return; - logic.setDisplayName(displayName); - } - - @Nonnull - public NBTTagCompound saveToNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - NBTTagList inventoriesNBT = new NBTTagList(); - inventories.forEach((uuid, inventory) -> { - NBTTagCompound inventoryNBT = new NBTTagCompound(); - inventoryNBT.setTag("inventory", inventory.saveToNBT()); - inventoryNBT.setString("uuid", uuid.toString()); - inventoryNBT.setInteger( - "invSize", - inventory.getInventory() - .getSlots()); - inventoriesNBT.appendTag(inventoryNBT); - }); - nbt.setTag("inventories", inventoriesNBT); - return nbt; - } - - public void loadFromNBT(@Nonnull NBTTagCompound nbt) { - NBTTagList inventoriesNBT = nbt.getTagList("inventories", Constants.NBT.TAG_COMPOUND); - if (inventoriesNBT == null) return; - for (int i = 0; i < inventoriesNBT.tagCount(); i++) { - NBTTagCompound inventoryNBT = inventoriesNBT.getCompoundTagAt(i); - UUID uuid = UUID.fromString(inventoryNBT.getString("uuid")); - ItemInventoryLogic inventory = new ItemInventoryLogic(inventoryNBT.getInteger("invSize")); - NBTTagCompound internalInventoryNBT = inventoryNBT.getCompoundTag("inventory"); - if (internalInventoryNBT != null) inventory.loadFromNBT(internalInventoryNBT); - if (inventory.isUpgradeInventory()) { - unallocatedInventories.add(Pair.of(uuid, inventory)); - } else { - inventories.put(uuid, inventory); - } - } - } -} diff --git a/src/main/java/gregtech/api/logic/FluidInventoryLogic.java b/src/main/java/gregtech/api/logic/FluidInventoryLogic.java deleted file mode 100644 index 1949a27e2ae..00000000000 --- a/src/main/java/gregtech/api/logic/FluidInventoryLogic.java +++ /dev/null @@ -1,268 +0,0 @@ -package gregtech.api.logic; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.Constants; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import com.gtnewhorizons.modularui.api.fluids.FluidTanksHandler; -import com.gtnewhorizons.modularui.api.fluids.IFluidTankLong; -import com.gtnewhorizons.modularui.api.fluids.IFluidTanksHandler; -import com.gtnewhorizons.modularui.api.fluids.ListFluidHandler; -import com.gtnewhorizons.modularui.api.math.Size; -import com.gtnewhorizons.modularui.api.widget.Widget; -import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget; -import com.gtnewhorizons.modularui.common.widget.Scrollable; - -/** - * Generic Fluid logic for MuTEs. - * - * @author BlueWeabo - */ -public class FluidInventoryLogic { - - private static final int DEFAULT_COLUMNS_PER_ROW = 4; - private static final int POSITION_INTERVAL = 18; - private static final Size SIZE = new Size(18, 18); - - protected String displayName = ""; - @Nonnull - protected final IFluidTanksHandler inventory; - protected final Map fluidToTankMap; - protected int tier = 0; - protected boolean isUpgradeInventory = false; - - public FluidInventoryLogic(int numberOfSlots, long capacityOfEachTank) { - this(new FluidTanksHandler(numberOfSlots, capacityOfEachTank), 0, false); - } - - public FluidInventoryLogic(int numberOfSlots, long capacityOfEachTank, int tier) { - this(new FluidTanksHandler(numberOfSlots, capacityOfEachTank), tier, false); - } - - public FluidInventoryLogic(int numberOfSlots, long capacityOfEachTank, int tier, boolean isUpgradeInventory) { - this(new FluidTanksHandler(numberOfSlots, capacityOfEachTank), tier, isUpgradeInventory); - } - - public FluidInventoryLogic(@Nonnull IFluidTanksHandler inventory, int tier, boolean isUpgradeInventory) { - this.inventory = inventory; - fluidToTankMap = new HashMap<>(inventory.getTanks()); - this.tier = tier; - this.isUpgradeInventory = isUpgradeInventory; - } - - public FluidInventoryLogic(Collection inventories) { - this(new ListFluidHandler(inventories), -1, false); - } - - @Nullable - public String getDisplayName() { - return displayName; - } - - public int getTier() { - return tier; - } - - public boolean isUpgradeInventory() { - return isUpgradeInventory; - } - - public void setDisplayName(@Nullable String displayName) { - this.displayName = displayName; - } - - /** - * - * @return The Fluid Inventory Logic as an NBTTagList to be saved in another nbt as how one wants. - */ - @Nonnull - public NBTTagCompound saveToNBT() { - final NBTTagCompound nbt = new NBTTagCompound(); - final NBTTagList tList = new NBTTagList(); - for (int tankNumber = 0; tankNumber < inventory.getTanks(); tankNumber++) { - final IFluidTankLong tank = inventory.getFluidTank(tankNumber); - if (tank == null) continue; - - final NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("s", (byte) tankNumber); - tank.saveToNBT(tag); - tList.appendTag(tag); - } - nbt.setTag("inventory", tList); - nbt.setInteger("tier", tier); - if (displayName != null) { - nbt.setString("displayName", displayName); - } - nbt.setBoolean("isUpgradeInventory", isUpgradeInventory); - return nbt; - } - - /** - * Loads the Item Inventory Logic from an NBTTagList. - */ - public void loadFromNBT(@Nonnull NBTTagCompound nbt) { - NBTTagList nbtList = nbt.getTagList("inventory", Constants.NBT.TAG_COMPOUND); - for (int i = 0; i < nbtList.tagCount(); i++) { - final NBTTagCompound tankNBT = nbtList.getCompoundTagAt(i); - final int tank = tankNBT.getShort("s"); - if (tank >= 0 && tank < inventory.getTanks()) inventory.getFluidTank(tank) - .loadFromNBT(tankNBT); - if (inventory.getFluidInTank(tank) != null) { - fluidToTankMap.put(inventory.getFluidInTank(tank), inventory.getFluidTank(tank)); - } - } - tier = nbt.getInteger("tier"); - if (nbt.hasKey("displayName")) { - displayName = nbt.getString("displayName"); - } - isUpgradeInventory = nbt.getBoolean("isUpgradeInventory"); - } - - @Nonnull - public IFluidTanksHandler getInventory() { - return inventory; - } - - @Nonnull - public FluidStack[] getStoredFluids() { - final FluidStack[] fluids = inventory.getFluids() - .stream() - .filter(Objects::nonNull) - .toArray(FluidStack[]::new); - if (fluids == null) { - return new FluidStack[0]; - } - return fluids; - } - - public boolean isFluidValid(@Nullable Fluid fluid) { - return fluid != null; - } - - /** - * @param fluid What we are trying to input - * @param amount amount of fluid we are trying to put - * @return amount of fluid filled into the tank - */ - public long fill(@Nullable Fluid fluid, long amount, boolean simulate) { - if (!isFluidValid(fluid)) return 0; - IFluidTankLong tank = fluidToTankMap.get(fluid); - if (tank != null) { - return tank.fill(fluid, amount, !simulate); - } - int tankNumber = 0; - tank = inventory.getFluidTank(tankNumber++); - while (tank.getStoredFluid() != fluid && tank.getStoredFluid() != null) { - tank = inventory.getFluidTank(tankNumber++); - } - fluidToTankMap.put(fluid, tank); - return tank.fill(fluid, amount, !simulate); - } - - @Nullable - public FluidStack fill(@Nullable FluidStack fluid) { - if (fluid == null) return null; - for (int i = 0; i < inventory.getTanks(); i++) { - fill(fluid.getFluid(), fluid.amount, false); - } - return fluid; - } - - /** - * Try and drain the first fluid found for that amount. Used by GT_Cover_Pump - * - * @param amount Fluid to drain from the tank - * @return A fluidstack with the possible amount drained - */ - @Nullable - public FluidStack drain(long amount, boolean simulate) { - for (int i = 0; i < inventory.getTanks(); i++) { - Fluid fluid = inventory.getFluidInTank(i); - FluidStack drained = drain(fluid, amount, simulate); - if (drained != null) return drained; - } - - return null; - } - - @Nullable - public FluidStack drain(Fluid fluid, long amount, boolean simulate) { - if (!isFluidValid(fluid)) return null; - IFluidTankLong tank = fluidToTankMap.get(fluid); - if (tank != null) { - return tank.drain(amount, !simulate); - } - int tankNumber = 0; - tank = inventory.getFluidTank(tankNumber++); - while (tank.getStoredFluid() != fluid) { - tank = inventory.getFluidTank(tankNumber++); - } - fluidToTankMap.put(fluid, tank); - return tank.drain(amount, !simulate); - } - - public void update() { - for (int i = 0; i < inventory.getTanks(); i++) { - IFluidTankLong tank = inventory.getFluidTank(i); - if (tank.getFluidAmountLong() > 0) continue; - tank.setFluid(null, 0); - } - } - - public long calculateAmountOfTimesFluidCanBeTaken(Fluid fluid, long amountToTake) { - if (!isFluidValid(fluid)) return 0; - IFluidTankLong tank = fluidToTankMap.get(fluid); - if (tank == null) return 0; - return tank.getFluidAmountLong() / amountToTake; - } - - @Nonnull - public Map getMapOfStoredFluids() { - Map map = new HashMap<>(); - for (int i = 0; i < inventory.getTanks(); i++) { - IFluidTankLong tank = inventory.getFluidTank(i); - if (tank == null) continue; - Fluid fluid = tank.getStoredFluid(); - if (fluid == null) continue; - map.put(fluid, map.getOrDefault(fluid, 0L) + tank.getFluidAmountLong()); - } - return map; - } - - /** - * Return a scrollable widget with only the inventory. - */ - @Nonnull - public Widget getGuiPart() { - return getGUIPart(DEFAULT_COLUMNS_PER_ROW); - } - - /** - * Return a scrollable widget with only the inventory. - */ - @Nonnull - public Widget getGUIPart(int columnsPerRow) { - final Scrollable scrollable = new Scrollable(); - scrollable.setVerticalScroll(); - for (int rows = 0; rows * 4 < inventory.getTanks(); rows++) { - final int columnsToMake = Math.min(inventory.getTanks() - rows * 4, 4); - for (int column = 0; column < columnsToMake; column++) { - final FluidSlotWidget fluidSlot = new FluidSlotWidget(inventory, rows * 4 + column); - scrollable.widget( - fluidSlot.setPos(column * POSITION_INTERVAL, rows * POSITION_INTERVAL) - .setSize(SIZE)); - } - } - return scrollable; - } -} diff --git a/src/main/java/gregtech/api/logic/ItemInventoryLogic.java b/src/main/java/gregtech/api/logic/ItemInventoryLogic.java deleted file mode 100644 index b37920d2061..00000000000 --- a/src/main/java/gregtech/api/logic/ItemInventoryLogic.java +++ /dev/null @@ -1,314 +0,0 @@ -package gregtech.api.logic; - -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; -import java.util.stream.Collectors; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.Constants; - -import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; -import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; -import com.gtnewhorizons.modularui.api.forge.ListItemHandler; -import com.gtnewhorizons.modularui.api.math.Size; -import com.gtnewhorizons.modularui.api.widget.Widget; -import com.gtnewhorizons.modularui.common.widget.Scrollable; -import com.gtnewhorizons.modularui.common.widget.SlotWidget; - -import gregtech.api.util.GTUtility; -import gregtech.api.util.item.ItemHolder; - -/** - * Generic Item logic for MuTEs. - * - * @author BlueWeabo - */ -public class ItemInventoryLogic { - - private static final int DEFAULT_COLUMNS_PER_ROW = 4; - private static final int POSITION_INTERVAL = 18; - private static final Size SIZE = new Size(18, 18); - - protected String displayName; - @Nonnull - protected final IItemHandlerModifiable inventory; - protected UUID connectedFluidInventory; - protected int tier; - protected boolean isUpgradeInventory; - protected Map cachedItemMap; - protected boolean inRecipeCheck; - - public ItemInventoryLogic(int numberOfSlots) { - this(numberOfSlots, 0); - } - - public ItemInventoryLogic(int numberOfSlots, int tier) { - this(new ItemStackHandler(numberOfSlots), tier, false); - } - - public ItemInventoryLogic(int numberOfSlots, int tier, boolean isUpgradeInventory) { - this(new ItemStackHandler(numberOfSlots), tier, isUpgradeInventory); - } - - public ItemInventoryLogic(@Nonnull IItemHandlerModifiable inventory, int tier, boolean isUpgradeInventory) { - this.inventory = inventory; - this.tier = tier; - this.isUpgradeInventory = isUpgradeInventory; - } - - public ItemInventoryLogic(Collection inventories) { - this(new ListItemHandler(inventories), -1, false); - } - - @Nullable - public String getDisplayName() { - return displayName; - } - - public int getTier() { - return tier; - } - - public boolean isUpgradeInventory() { - return isUpgradeInventory; - } - - public int getSlots() { - return getInventory().getSlots(); - } - - public void setDisplayName(@Nullable String displayName) { - this.displayName = displayName; - } - - @Nullable - public UUID getConnectedFluidInventoryID() { - return connectedFluidInventory; - } - - public void setConnectedFluidInventoryID(@Nullable UUID connectedFluidTank) { - this.connectedFluidInventory = connectedFluidTank; - } - - /** - * - * @return The Item Inventory Logic as an NBTTagCompound to be saved in another nbt as how one wants. - */ - @Nonnull - public NBTTagCompound saveToNBT() { - final NBTTagCompound nbt = new NBTTagCompound(); - final NBTTagList tList = new NBTTagList(); - for (int slot = 0; slot < inventory.getSlots(); slot++) { - final ItemStack tStack = inventory.getStackInSlot(slot); - if (tStack == null) continue; - - final NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("s", (byte) slot); - tStack.writeToNBT(tag); - tList.appendTag(tag); - } - nbt.setTag("inventory", tList); - nbt.setInteger("tier", tier); - if (displayName != null) { - nbt.setString("displayName", displayName); - } - nbt.setBoolean("isUpgradeInventory", isUpgradeInventory); - if (connectedFluidInventory != null) { - nbt.setString("connectedFluidInventory", connectedFluidInventory.toString()); - } - return nbt; - } - - /** - * Loads the Item Inventory Logic from an NBTTagCompound. - */ - public void loadFromNBT(@Nonnull NBTTagCompound nbt) { - tier = nbt.getInteger("tier"); - if (nbt.hasKey("displayName")) { - displayName = nbt.getString("displayName"); - } - - isUpgradeInventory = nbt.getBoolean("isUpgradeInventory"); - if (nbt.hasKey("connectedFluidInventory")) { - connectedFluidInventory = UUID.fromString(nbt.getString("connectedFluidInventory")); - } - - NBTTagList nbtList = nbt.getTagList("inventory", Constants.NBT.TAG_COMPOUND); - if (nbtList == null) return; - - for (int i = 0; i < nbtList.tagCount(); i++) { - final NBTTagCompound tNBT = nbtList.getCompoundTagAt(i); - final int tSlot = tNBT.getShort("s"); - if (tSlot >= 0 && tSlot < inventory.getSlots()) { - inventory.setStackInSlot(tSlot, GTUtility.loadItem(tNBT)); - } - } - } - - @Nonnull - public IItemHandlerModifiable getInventory() { - return inventory; - } - - @Nonnull - public ItemStack[] getStoredItems() { - final ItemStack[] items = inventory.getStacks() - .stream() - .filter(Objects::nonNull) - .toArray(ItemStack[]::new); - if (items == null) { - return new ItemStack[0]; - } - return items; - } - - public boolean isStackValid(ItemStack item) { - return true; - } - - @Nullable - public ItemStack insertItem(ItemStack item) { - if (!isStackValid(item)) return item; - for (int i = 0; i < inventory.getSlots() && item != null && item.stackSize > 0; i++) { - item = inventory.insertItem(i, item, false); - } - return item; - } - - @Nullable - public ItemStack extractItem(int slot, int amount) { - return inventory.extractItem(slot, amount, false); - } - - public boolean subtractItemAmount(@Nonnull ItemHolder item, long amount, boolean simulate) { - Map itemMap = getMapOfStoredItems(); - if (!itemMap.containsKey(item)) { - return false; - } - - if (itemMap.get(item) < amount) { - return false; - } - - if (simulate) { - return true; - } - - itemMap.put(item, itemMap.get(item) - amount); - return true; - } - - @Nullable - public ItemStack getItemInSlot(int slot) { - return inventory.getStackInSlot(slot); - } - - public void sort() { - Map itemMap = getMapOfStoredItems(); - List sortedItems = itemMap.keySet() - .stream() - .sorted( - Comparator.comparing( - a -> a.getItem() - .getUnlocalizedName() + a.getMeta())) - .collect(Collectors.toList()); - putInItemsFromMap(itemMap, sortedItems); - } - - public void update(boolean shouldSort) { - if (shouldSort) { - sort(); - } - - for (int i = 0; i < inventory.getSlots(); i++) { - ItemStack item = inventory.getStackInSlot(i); - if (item == null) continue; - if (item.stackSize > 0) continue; - inventory.setStackInSlot(i, null); - } - } - - /** - * Return a scrollable widget with only the inventory. - */ - @Nonnull - public Widget getGuiPart() { - return getGUIPart(DEFAULT_COLUMNS_PER_ROW); - } - - /** - * Return a scrollable widget with only the inventory. - */ - @Nonnull - public Widget getGUIPart(int columnsPerRow) { - final Scrollable scrollable = new Scrollable(); - scrollable.setVerticalScroll(); - for (int rows = 0; rows * columnsPerRow < Math.min(inventory.getSlots(), 128); rows++) { - final int columnsToMake = Math - .min(Math.min(inventory.getSlots(), 128) - rows * columnsPerRow, columnsPerRow); - for (int column = 0; column < columnsToMake; column++) { - scrollable.widget( - new SlotWidget(inventory, rows * columnsPerRow + column) - .setPos(column * POSITION_INTERVAL, rows * POSITION_INTERVAL) - .setSize(SIZE)); - } - } - return scrollable; - } - - public void startRecipeCheck() { - cachedItemMap = getMapOfStoredItems(); - inRecipeCheck = true; - } - - public void stopRecipeCheck() { - inRecipeCheck = false; - putInItemsFromMap(cachedItemMap, null); - cachedItemMap = null; - } - - @Nonnull - public Map getMapOfStoredItems() { - if (inRecipeCheck) return cachedItemMap; - Map items = new HashMap<>(); - for (int i = 0; i < inventory.getSlots(); i++) { - ItemStack item = extractItem(i, Integer.MAX_VALUE); - if (item == null) continue; - ItemHolder itemHolder = new ItemHolder(item); - items.put(itemHolder, items.getOrDefault(itemHolder, 0L) + item.stackSize); - } - return items; - } - - protected void putInItemsFromMap(@Nonnull Map itemMap, @Nullable List sortedList) { - for (ItemHolder itemHolder : (sortedList == null ? itemMap.keySet() : sortedList)) { - long itemAmount = itemMap.get(itemHolder); - ItemStack item = new ItemStack(itemHolder.getItem(), 0, itemHolder.getMeta()); - item.setTagCompound(itemHolder.getNBT()); - while (itemAmount > 0) { - item.stackSize = (int) Math.min(item.getMaxStackSize(), itemAmount); - itemAmount -= item.stackSize; - insertItem(item); - } - } - } - - public long calculateAmountOfTimesItemCanBeTaken(ItemHolder item, long amount) { - return getMapOfStoredItems().getOrDefault(item, 0L) / amount; - } - - public Set getSetOfStoredItems() { - return getMapOfStoredItems().keySet(); - } -} diff --git a/src/main/java/gregtech/api/logic/ModelRenderLogic.java b/src/main/java/gregtech/api/logic/ModelRenderLogic.java deleted file mode 100644 index d9f2fdcf274..00000000000 --- a/src/main/java/gregtech/api/logic/ModelRenderLogic.java +++ /dev/null @@ -1,5 +0,0 @@ -package gregtech.api.logic; - -public abstract class ModelRenderLogic { - -} diff --git a/src/main/java/gregtech/api/logic/MuTEProcessingLogic.java b/src/main/java/gregtech/api/logic/MuTEProcessingLogic.java deleted file mode 100644 index 0d6bf4cac95..00000000000 --- a/src/main/java/gregtech/api/logic/MuTEProcessingLogic.java +++ /dev/null @@ -1,256 +0,0 @@ -package gregtech.api.logic; - -import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND; - -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.UUID; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.fluids.FluidStack; - -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.widget.Widget; -import com.gtnewhorizons.modularui.common.widget.Scrollable; - -import gregtech.api.enums.InventoryType; -import gregtech.api.logic.interfaces.ProcessingLogicHost; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.check.CheckRecipeResult; -import gregtech.api.recipe.check.CheckRecipeResultRegistry; -import gregtech.api.util.GTRecipe; -import gregtech.api.util.GTUtility; -import gregtech.api.util.OverclockCalculator; -import gregtech.api.util.ParallelHelper; - -/** - * Processing logic class, dedicated for MultiTileEntities. - */ -public class MuTEProcessingLogic

> extends AbstractProcessingLogic

{ - - protected boolean hasWork; - protected int progress; - protected ProcessingLogicHost

machineHost; - @Nonnull - protected CheckRecipeResult recipeResult = CheckRecipeResultRegistry.NONE; - @Nullable - protected UUID itemOutputID; - @Nullable - protected UUID fluidOutputID; - - public P setMachineHost(@Nonnull ProcessingLogicHost

machineHost) { - this.machineHost = machineHost; - return getThis(); - } - - // #region Logic - - @Nonnull - @Override - public CheckRecipeResult process() { - RecipeMap recipeMap = preProcess(); - - ItemInventoryLogic itemInput = null; - FluidInventoryLogic fluidInput = null; - if (machineHost.isInputSeparated()) { - for (Map.Entry itemEntry : machineHost - .getAllItemInventoryLogics(InventoryType.Input)) { - itemOutputID = Objects.requireNonNull(itemEntry.getKey()); - itemInput = Objects.requireNonNull(itemEntry.getValue()); - fluidInput = Objects.requireNonNull( - machineHost.getFluidLogic(InventoryType.Input, itemInput.getConnectedFluidInventoryID())); - fluidOutputID = itemInput.getConnectedFluidInventoryID(); - } - } else { - itemInput = Objects.requireNonNull(machineHost.getItemLogic(InventoryType.Input, null)); - fluidInput = Objects.requireNonNull(machineHost.getFluidLogic(InventoryType.Input, null)); - } - - CheckRecipeResult recipeValidatorResult = null; - if (recipeValidatorResult != null) { - return recipeValidatorResult; - } - - return processRecipe(null, Objects.requireNonNull(itemInput), Objects.requireNonNull(fluidInput)); - } - - @Nonnull - protected CheckRecipeResult processRecipe(@Nonnull List recipes, @Nonnull ItemInventoryLogic itemInput, - @Nonnull FluidInventoryLogic fluidInput) { - CheckRecipeResult result = CheckRecipeResultRegistry.INTERNAL_ERROR; - for (GTRecipe recipe : recipes) { - Objects.requireNonNull(recipe); - ParallelHelper helper = createParallelHelper(recipe, itemInput, fluidInput); - OverclockCalculator calculator = createOverclockCalculator(recipe); - helper.setCalculator(calculator); - helper.build(); - result = helper.getResult(); - if (result.wasSuccessful()) { - return applyRecipe(recipe, helper, calculator, result); - } - } - return result; - } - - /** - * Override if you don't work with regular gt recipe maps - */ - @Nonnull - protected Object findRecipe(@Nullable RecipeMap map, @Nonnull ItemInventoryLogic itemInput, - @Nonnull FluidInventoryLogic fluidInput) { - if (map == null) { - return false; - } - - return true; - } - - @Nonnull - protected ParallelHelper createParallelHelper(@Nonnull GTRecipe recipe, @Nonnull ItemInventoryLogic itemInput, - @Nonnull FluidInventoryLogic fluidInput) { - return new ParallelHelper().setRecipe(recipe) - .setItemInputInventory(itemInput) - .setFluidInputInventory(fluidInput) - .setAvailableEUt(availableVoltage * availableAmperage) - .setMaxParallel(maxParallel) - .setEUtModifier(euModifier) - .enableBatchMode(batchSize) - .setConsumption(true) - .setOutputCalculation(true) - .setMuTEMode(true); - } - - // #endregion - - // #region Getters - - @Nonnull - public CheckRecipeResult getResult() { - return recipeResult; - } - - public int getProgress() { - return progress; - } - - // #endregion - - // #region Other - - public void startCheck() { - recipeResult = process(); - } - - public void progress() { - if (!hasWork) return; - if (progress == duration) { - progress = 0; - duration = 0; - calculatedEut = 0; - output(); - return; - } - progress++; - } - - protected void output() { - ItemInventoryLogic itemOutput = machineHost.getItemLogic(InventoryType.Output, itemOutputID); - FluidInventoryLogic fluidOutput = machineHost.getFluidLogic(InventoryType.Output, fluidOutputID); - if (itemOutput == null || fluidOutput == null) return; - for (ItemStack item : outputItems) { - if (item == null) continue; - itemOutput.insertItem(item); - } - for (FluidStack fluid : outputFluids) { - if (fluid == null) continue; - fluidOutput.fill(fluid.getFluid(), fluid.amount, false); - } - outputItems = new ItemStack[0]; - outputFluids = new FluidStack[0]; - } - - public boolean canWork() { - return !hasWork && machineHost.isAllowedToWork(); - } - - /** - * By how much to increase the progress? - * - * @param progressAmount in ticks - */ - public void increaseProgress(int progressAmount) { - progress += progressAmount; - } - - public NBTTagCompound saveToNBT() { - NBTTagCompound logicNBT = new NBTTagCompound(); - logicNBT.setLong("eutConsumption", calculatedEut); - logicNBT.setInteger("duration", duration); - logicNBT.setInteger("progress", progress); - logicNBT.setBoolean("hasWork", hasWork); - if (outputItems != null) { - NBTTagList itemOutputsNBT = new NBTTagList(); - for (ItemStack item : outputItems) { - itemOutputsNBT.appendTag(GTUtility.saveItem(item)); - } - logicNBT.setTag("itemOutputs", itemOutputsNBT); - } - if (outputFluids != null) { - NBTTagList fluidOutputsNBT = new NBTTagList(); - for (FluidStack fluid : outputFluids) { - fluidOutputsNBT.appendTag(fluid.writeToNBT(new NBTTagCompound())); - } - logicNBT.setTag("fluidOutputs", fluidOutputsNBT); - } - if (itemOutputID != null) { - logicNBT.setString("itemOutputID", itemOutputID.toString()); - } - if (fluidOutputID != null) { - logicNBT.setString("fluidOutputID", fluidOutputID.toString()); - } - return logicNBT; - } - - public void loadFromNBT(@Nonnull NBTTagCompound logicNBT) { - calculatedEut = logicNBT.getLong("eutConsumption"); - duration = logicNBT.getInteger("duration"); - progress = logicNBT.getInteger("progress"); - hasWork = logicNBT.getBoolean("hasWork"); - if (logicNBT.hasKey("itemOutputs")) { - NBTTagList itemOutputsNBT = logicNBT.getTagList("itemOutputs", TAG_COMPOUND); - outputItems = new ItemStack[itemOutputsNBT.tagCount()]; - for (int i = 0; i < itemOutputsNBT.tagCount(); i++) { - outputItems[i] = GTUtility.loadItem(itemOutputsNBT.getCompoundTagAt(i)); - } - } - if (logicNBT.hasKey("fluidOutputs")) { - NBTTagList fluidOutputsNBT = logicNBT.getTagList("fluidOutputs", TAG_COMPOUND); - outputFluids = new FluidStack[fluidOutputsNBT.tagCount()]; - for (int i = 0; i < fluidOutputsNBT.tagCount(); i++) { - outputFluids[i] = FluidStack.loadFluidStackFromNBT(fluidOutputsNBT.getCompoundTagAt(i)); - } - } - if (logicNBT.hasKey("itemOutputID")) { - itemOutputID = UUID.fromString(logicNBT.getString("itemOutputID")); - } - if (logicNBT.hasKey("fluidOutputID")) { - fluidOutputID = UUID.fromString(logicNBT.getString("fluidOutputID")); - } - } - - /** - * Returns a gui part, which will be displayed in a separate tab on the machine's gui. - */ - @Nonnull - public Widget getGUIPart(ModularWindow.Builder builder) { - return new Scrollable(); - } - - // #endregion -} diff --git a/src/main/java/gregtech/api/logic/NullPowerLogic.java b/src/main/java/gregtech/api/logic/NullPowerLogic.java deleted file mode 100644 index 0017f0e6473..00000000000 --- a/src/main/java/gregtech/api/logic/NullPowerLogic.java +++ /dev/null @@ -1,5 +0,0 @@ -package gregtech.api.logic; - -public class NullPowerLogic extends PowerLogic { - -} diff --git a/src/main/java/gregtech/api/logic/PowerLogic.java b/src/main/java/gregtech/api/logic/PowerLogic.java deleted file mode 100644 index 52fc762d1b9..00000000000 --- a/src/main/java/gregtech/api/logic/PowerLogic.java +++ /dev/null @@ -1,254 +0,0 @@ -package gregtech.api.logic; - -import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; - -import java.util.UUID; - -import javax.annotation.Nonnull; - -import net.minecraft.nbt.NBTTagCompound; - -import gregtech.api.enums.GTValues.NBT; - -/** - * Power logic for machines. This is used to store all the important variables for a machine to have energy and use it - * in any way. - * - * @author BlueWeabo, Maxim - */ -public class PowerLogic { - - public static final int NONE = 0; - public static final int RECEIVER = 1; - public static final int EMITTER = 2; - public static final int BOTH = RECEIVER | EMITTER; - private static final float wirelessChargeFactor = 0.5F; - private long storedEnergy = 0; - private long energyCapacity = 0; - private long voltage = 0; - private long amperage = 0; - private int type = 0; - private boolean canUseLaser = false; - private boolean canUseWireless = false; - private UUID owner; - - public PowerLogic() {} - - /** - * Sets the max voltage the logic can accept - */ - @Nonnull - public PowerLogic setMaxVoltage(long voltage) { - this.voltage = voltage; - return this; - } - - /** - * Sets the maximum amount of energy the machine can store inside of it - */ - @Nonnull - public PowerLogic setEnergyCapacity(long energyCapacity) { - this.energyCapacity = energyCapacity; - return this; - } - - /** - * Sets the maximum amount of amps a machine can receive from an emitter - */ - @Nonnull - public PowerLogic setMaxAmperage(long amperage) { - this.amperage = amperage; - return this; - } - - /** - * Sets the type of power logic this is. Whether it will receive EU or emit it to others, or do both - */ - @Nonnull - public PowerLogic setType(int type) { - this.type = type; - return this; - } - - /** - * If this power logic can use lasers to be used for it - */ - @Nonnull - public PowerLogic setCanUseLaser(boolean canUse) { - canUseLaser = canUse; - return this; - } - - /** - * If the power logic should use wireless EU first before using its internal buffer - */ - @Nonnull - public PowerLogic setCanUseWireless(boolean canUse, UUID owner) { - canUseWireless = canUse; - this.owner = owner; - return this; - } - - /** - * Adding energy directly to the buffer, but only if it has the capacity. - */ - public boolean addEnergyUnsafe(long totalEUAdded) { - if (storedEnergy + totalEUAdded >= energyCapacity) { - return false; - } - - storedEnergy += totalEUAdded; - return true; - } - - /** - * Adding energy to the buffer if the voltage given isn't higher than the voltage of the logic - */ - public boolean addEnergy(long voltage, long amperage) { - if (voltage > this.voltage) { - return false; - } - - return addEnergyUnsafe(voltage * amperage); - } - - /** - * Same as {@link #addEnergy(long, long)}, but only 1 amp of it - */ - public boolean addEnergy(long voltage) { - return addEnergy(voltage, 1); - } - - /** - * Injecting energy in the multiblock ampere per ampere until full or until we have added the maximum possible - * amperes for this tick - * - * @param voltage At what voltage are the amps? - * @param availableAmperage How much amperage do we have available - * @return Amount of amperes used - */ - public long injectEnergy(long voltage, long availableAmperage) { - if (canUseWireless) return 0; - long usedAmperes = 0; - while (addEnergy(voltage, 1) && usedAmperes < amperage) { - usedAmperes++; - } - - return usedAmperes; - } - - /** - * Remove energy from the logic only if it has enough to be removed. - */ - public boolean removeEnergyUnsafe(long totalEURemoved) { - if (canUseWireless) { - if (storedEnergy < energyCapacity * wirelessChargeFactor) { - if (addEUToGlobalEnergyMap(owner, -(energyCapacity - storedEnergy))) { - storedEnergy = energyCapacity; - } - } - } - if (storedEnergy - totalEURemoved < 0) { - return false; - } - - storedEnergy -= totalEURemoved; - return true; - } - - /** - * Remove the given voltage for the amount of amperage if the removed isn't higher than the logic's voltage - */ - public boolean removeEnergy(long voltage, long amperage) { - if (voltage > this.voltage) { - return false; - } - - return removeEnergyUnsafe(voltage * amperage); - } - - /** - * Same as {@link #removeEnergy(long, long)}, but with only 1 amperage - */ - public boolean removeEnergy(long voltage) { - return removeEnergy(voltage, 1); - } - - /** - * @return The maximum energy that can be stored. - */ - public long getCapacity() { - return energyCapacity; - } - - /** - * @return The maximum voltage that is available - */ - public long getVoltage() { - return voltage; - } - - /** - * @return The current energy stored - */ - public long getStoredEnergy() { - return storedEnergy; - } - - /** - * @return The current maximum Amperage - */ - public long getMaxAmperage() { - return amperage; - } - - /** - * Is the logic a receiver to receive energy - */ - public boolean isEnergyReceiver() { - return (type & RECEIVER) > 0; - } - - /** - * Is the logic a emitter to emit energy - */ - public boolean isEnergyEmitter() { - return (type & EMITTER) > 0; - } - - /** - * Saves the power logic to its own nbt tag before saving it to the given one. - * - * @param nbt Tag where you want to save the power logic tag to. - */ - public void saveToNBT(NBTTagCompound nbt) { - NBTTagCompound powerLogic = new NBTTagCompound(); - powerLogic.setLong(NBT.POWER_LOGIC_ENERGY_CAPACITY, energyCapacity); - powerLogic.setLong(NBT.POWER_LOGIC_STORED_ENERGY, storedEnergy); - powerLogic.setLong(NBT.POWER_LOGIC_AMPERAGE, amperage); - powerLogic.setLong(NBT.POWER_LOGIC_VOLTAGE, voltage); - powerLogic.setInteger(NBT.POWER_LOGIC_TYPE, type); - nbt.setTag(NBT.POWER_LOGIC, powerLogic); - } - - /** - * Loads the power logic from its own nbt after getting it from the given one - * - * @param nbt Tag where the power logic tag was saved to - */ - public void loadFromNBT(NBTTagCompound nbt) { - NBTTagCompound powerLogic = nbt.getCompoundTag(NBT.POWER_LOGIC); - energyCapacity = powerLogic.getLong(NBT.POWER_LOGIC_ENERGY_CAPACITY); - storedEnergy = powerLogic.getLong(NBT.POWER_LOGIC_STORED_ENERGY); - amperage = powerLogic.getLong(NBT.POWER_LOGIC_AMPERAGE); - voltage = powerLogic.getLong(NBT.POWER_LOGIC_VOLTAGE); - type = powerLogic.getInteger(NBT.POWER_LOGIC_TYPE); - } - - /** - * Can we use lasers for inputting EU - */ - public boolean canUseLaser() { - return canUseLaser; - } -} diff --git a/src/main/java/gregtech/api/logic/ProcessingLogic.java b/src/main/java/gregtech/api/logic/ProcessingLogic.java index 3a381ee2041..18807bdb8ab 100644 --- a/src/main/java/gregtech/api/logic/ProcessingLogic.java +++ b/src/main/java/gregtech/api/logic/ProcessingLogic.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -14,6 +15,7 @@ import net.minecraftforge.fluids.FluidStack; import gregtech.api.interfaces.tileentity.IRecipeLockable; +import gregtech.api.interfaces.tileentity.IVoidable; import gregtech.api.objects.GTDualInputs; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.check.CheckRecipeResult; @@ -28,89 +30,244 @@ * Logic class to calculate result of recipe check from inputs, based on recipemap. */ @SuppressWarnings({ "unused", "UnusedReturnValue" }) -public class ProcessingLogic extends AbstractProcessingLogic { +public class ProcessingLogic { + // Traits + protected IVoidable machine; protected IRecipeLockable recipeLockableMachine; - protected ItemStack specialSlotItem; + protected boolean isRecipeLocked; protected ItemStack[] inputItems; protected FluidStack[] inputFluids; - protected boolean isRecipeLocked; + protected ItemStack specialSlotItem; protected IDualInputInventory craftingPattern; + protected int maxParallel = 1; + protected Supplier maxParallelSupplier; + protected int batchSize = 1; + protected Supplier> recipeMapSupplier; + protected double euModifier = 1.0; + protected double speedBoost = 1.0; + protected long availableVoltage; + protected long availableAmperage; + protected boolean protectItems; + protected boolean protectFluids; + protected double overClockTimeReduction = 2.0; + protected double overClockPowerIncrease = 4.0; + protected boolean amperageOC = true; + + // Calculated results + protected ItemStack[] outputItems; + protected FluidStack[] outputFluids; + protected long calculatedEut; + protected int duration; + protected int calculatedParallels = 0; + + // Cache + protected RecipeMap lastRecipeMap; + protected GTRecipe lastRecipe; protected Map> craftingPatternRecipeCache = new HashMap<>(); public ProcessingLogic() {} - // #region Setters + // region Setters + + /** + * Sets machine used for void protection logic. + */ + public ProcessingLogic setMachine(IVoidable machine) { + this.machine = machine; + return this; + } + + /** + * Enables single recipe locking mode. + */ + public ProcessingLogic setRecipeLocking(IRecipeLockable recipeLockableMachine, boolean isRecipeLocked) { + this.recipeLockableMachine = recipeLockableMachine; + this.isRecipeLocked = isRecipeLocked; + return this; + } @Nonnull public ProcessingLogic setInputItems(ItemStack... itemInputs) { this.inputItems = itemInputs; - return getThis(); + return this; } @Nonnull public ProcessingLogic setInputItems(List itemOutputs) { this.inputItems = itemOutputs.toArray(new ItemStack[0]); - return getThis(); + return this; } @Nonnull public ProcessingLogic setInputFluids(FluidStack... fluidInputs) { this.inputFluids = fluidInputs; - return getThis(); + return this; } @Nonnull public ProcessingLogic setInputFluids(List fluidInputs) { this.inputFluids = fluidInputs.toArray(new FluidStack[0]); - return getThis(); + return this; } public ProcessingLogic setSpecialSlotItem(ItemStack specialSlotItem) { this.specialSlotItem = specialSlotItem; - return getThis(); + return this; } public boolean craftingPatternHandler(IDualInputInventory slot) { - if (needWipeCraftingPatternRecipeCache) { - craftingPatternRecipeCache.clear(); - needWipeCraftingPatternRecipeCache = false; + if (craftingPatternRecipeCache.containsKey(slot)) { + craftingPattern = slot; + return true; } - if (craftingPatternRecipeCache.containsKey(slot)) { + GTDualInputs inputs = slot.getPatternInputs(); + setInputItems(inputs.inputItems); + setInputFluids(inputs.inputFluid); + Set recipes = findRecipeMatches(getCurrentRecipeMap()).collect(Collectors.toSet()); + if (!recipes.isEmpty()) { + craftingPatternRecipeCache.put(slot, recipes); craftingPattern = slot; return true; - } else { - GTDualInputs inputs = slot.getPatternInputs(); - setInputItems(inputs.inputItems); - setInputFluids(inputs.inputFluid); - Set recipes = findRecipeMatches(preProcess()).collect(Collectors.toSet()); - if (!recipes.isEmpty()) { - craftingPatternRecipeCache.put(slot, recipes); - craftingPattern = slot; - return true; - } - return false; } + return false; } - public void removeEntryCraftingPatternRecipeCache(IDualInputInventory slot) { + public void clearCraftingPatternRecipeCache(IDualInputInventory slot) { craftingPatternRecipeCache.remove(slot); } /** - * Enables single recipe locking mode. + * Sets max amount of parallel. */ - public ProcessingLogic setRecipeLocking(IRecipeLockable recipeLockableMachine, boolean isRecipeLocked) { - this.recipeLockableMachine = recipeLockableMachine; - this.isRecipeLocked = isRecipeLocked; - return getThis(); + public ProcessingLogic setMaxParallel(int maxParallel) { + this.maxParallel = maxParallel; + return this; } /** - * Clears calculated results and provided machine inputs to prepare for the next machine operation. + * Sets method to get max amount of parallel. */ + public ProcessingLogic setMaxParallelSupplier(Supplier supplier) { + this.maxParallelSupplier = supplier; + return this; + } + + /** + * Sets batch size for batch mode. + */ + public ProcessingLogic setBatchSize(int size) { + this.batchSize = size; + return this; + } + + public ProcessingLogic setRecipeMap(RecipeMap recipeMap) { + return setRecipeMapSupplier(() -> recipeMap); + } + + public ProcessingLogic setRecipeMapSupplier(Supplier> supplier) { + this.recipeMapSupplier = supplier; + return this; + } + public ProcessingLogic setEuModifier(double modifier) { + this.euModifier = modifier; + return this; + } + + public ProcessingLogic setSpeedBonus(double speedModifier) { + this.speedBoost = speedModifier; + return this; + } + + /** + * Sets voltage of the machine. It doesn't need to be actual voltage (excluding amperage) of the machine; + * For example, most of the multiblock machines set maximum possible input power (including amperage) as voltage + * and 1 as amperage. That way recipemap search will be executed with overclocked voltage. + */ + public ProcessingLogic setAvailableVoltage(long voltage) { + this.availableVoltage = voltage; + return this; + } + + /** + * Sets amperage of the machine. This amperage doesn't involve in EU/t when searching recipemap. + * Useful for preventing tier skip but still considering amperage for parallel. + */ + public ProcessingLogic setAvailableAmperage(long amperage) { + this.availableAmperage = amperage; + return this; + } + + public ProcessingLogic setVoidProtection(boolean protectItems, boolean protectFluids) { + this.protectItems = protectItems; + this.protectFluids = protectFluids; + return this; + } + + public ProcessingLogic setOverclock(double timeReduction, double powerIncrease) { + this.overClockTimeReduction = timeReduction; + this.overClockPowerIncrease = powerIncrease; + return this; + } + + /** + * Sets overclock ratio to 4/4. + */ + public ProcessingLogic enablePerfectOverclock() { + return this.setOverclock(4.0, 4.0); + } + + /** + * Sets whether the multi should use amperage to OC or not. + */ + public ProcessingLogic setAmperageOC(boolean amperageOC) { + this.amperageOC = amperageOC; + return this; + } + + // endregion + + // region Overwrite calculated result + + /** + * Overwrites calculated item output. + */ + public ProcessingLogic overwriteOutputItems(ItemStack... itemOutputs) { + this.outputItems = itemOutputs; + return this; + } + + /** + * Overwrites calculated fluid output. + */ + public ProcessingLogic overwriteOutputFluids(FluidStack... fluidOutputs) { + this.outputFluids = fluidOutputs; + return this; + } + + /** + * Overwrites calculated EU/t. + */ + public ProcessingLogic overwriteCalculatedEut(long calculatedEut) { + this.calculatedEut = calculatedEut; + return this; + } + + /** + * Overwrites calculated duration. + */ + public ProcessingLogic overwriteCalculatedDuration(int duration) { + this.duration = duration; + return this; + } + + // endregion + + /** + * Clears calculated results and provided machine inputs to prepare for the next machine operation. + */ public ProcessingLogic clear() { this.inputItems = null; this.inputFluids = null; @@ -121,19 +278,43 @@ public ProcessingLogic clear() { this.duration = 0; this.calculatedParallels = 0; this.craftingPattern = null; - return getThis(); + return this; } - // #endregion + // region Logic - // #region Logic + /** + * Refreshes recipemap to use. Remember to call this before {@link #process} to make sure correct recipemap is used. + * + * @return Recipemap to use now + */ + protected RecipeMap getCurrentRecipeMap() { + RecipeMap recipeMap; + if (recipeMapSupplier == null) { + recipeMap = null; + } else { + recipeMap = recipeMapSupplier.get(); + } + if (lastRecipeMap != recipeMap) { + if (lastRecipeMap != null) { + craftingPatternRecipeCache.clear(); + } + lastRecipe = null; + lastRecipeMap = recipeMap; + } + return recipeMap; + } /** * Executes the recipe check: Find recipe from recipemap, Calculate parallel, overclock and outputs. */ @Nonnull public CheckRecipeResult process() { - RecipeMap recipeMap = preProcess(); + RecipeMap recipeMap = getCurrentRecipeMap(); + + if (maxParallelSupplier != null) { + maxParallel = maxParallelSupplier.get(); + } if (inputItems == null) { inputItems = new ItemStack[0]; @@ -210,6 +391,54 @@ private CalculationResult validateAndCalculateRecipe(@Nonnull GTRecipe recipe) { return CalculationResult.ofSuccess(applyRecipe(recipe, helper, calculator, result)); } + /** + * Check has been succeeded, so it applies the recipe and calculated parameters. + * At this point, inputs have been already consumed. + */ + @Nonnull + private CheckRecipeResult applyRecipe(@Nonnull GTRecipe recipe, @Nonnull ParallelHelper helper, + @Nonnull OverclockCalculator calculator, @Nonnull CheckRecipeResult result) { + if (recipe.mCanBeBuffered) { + lastRecipe = recipe; + } else { + lastRecipe = null; + } + calculatedParallels = helper.getCurrentParallel(); + + if (calculator.getConsumption() == Long.MAX_VALUE) { + return CheckRecipeResultRegistry.POWER_OVERFLOW; + } + if (calculator.getDuration() == Integer.MAX_VALUE) { + return CheckRecipeResultRegistry.DURATION_OVERFLOW; + } + + calculatedEut = calculator.getConsumption(); + + double finalDuration = calculateDuration(recipe, helper, calculator); + if (finalDuration >= Integer.MAX_VALUE) { + return CheckRecipeResultRegistry.DURATION_OVERFLOW; + } + duration = (int) finalDuration; + + CheckRecipeResult hookResult = onRecipeStart(recipe); + if (!hookResult.wasSuccessful()) { + return hookResult; + } + + outputItems = helper.getItemOutputs(); + outputFluids = helper.getFluidOutputs(); + + return result; + } + + /** + * Override to tweak final duration that will be set as a result of this logic class. + */ + protected double calculateDuration(@Nonnull GTRecipe recipe, @Nonnull ParallelHelper helper, + @Nonnull OverclockCalculator calculator) { + return calculator.getDuration() * helper.getDurationMultiplierDouble(); + } + /** * Finds a list of matched recipes. At this point no additional check to the matched recipe has been done. *

@@ -230,6 +459,14 @@ protected Stream findRecipeMatches(@Nullable RecipeMap map) { .findAll(); } + /** + * Override to do additional check for found recipe if needed. + */ + @Nonnull + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + return CheckRecipeResultRegistry.SUCCESSFUL; + } + /** * Override to tweak parallel logic if needed. */ @@ -248,7 +485,60 @@ protected ParallelHelper createParallelHelper(@Nonnull GTRecipe recipe) { .setOutputCalculation(true); } - // #endregion + /** + * Override to tweak overclock logic if needed. + */ + @Nonnull + protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { + return new OverclockCalculator().setRecipeEUt(recipe.mEUt) + .setAmperage(availableAmperage) + .setEUt(availableVoltage) + .setDuration(recipe.mDuration) + .setSpeedBoost(speedBoost) + .setEUtDiscount(euModifier) + .setAmperageOC(amperageOC) + .setDurationDecreasePerOC(overClockTimeReduction) + .setEUtIncreasePerOC(overClockPowerIncrease); + } + + /** + * Override to perform additional logic when recipe starts. + *

+ * This is called when the recipe processing logic has finished all + * checks, consumed all inputs, but has not yet set the outputs to + * be produced. Returning a result other than SUCCESSFUL will void + * all inputs! + */ + @Nonnull + protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + // endregion + + // region Getters + + public ItemStack[] getOutputItems() { + return outputItems; + } + + public FluidStack[] getOutputFluids() { + return outputFluids; + } + + public int getDuration() { + return duration; + } + + public long getCalculatedEut() { + return calculatedEut; + } + + public int getCurrentParallels() { + return calculatedParallels; + } + + // endregion /** * Represents the status of check recipe calculation. {@link #successfullyConsumedInputs} does not necessarily mean diff --git a/src/main/java/gregtech/api/logic/interfaces/FluidInventoryLogicHost.java b/src/main/java/gregtech/api/logic/interfaces/FluidInventoryLogicHost.java deleted file mode 100644 index c12333a4c6b..00000000000 --- a/src/main/java/gregtech/api/logic/interfaces/FluidInventoryLogicHost.java +++ /dev/null @@ -1,95 +0,0 @@ -package gregtech.api.logic.interfaces; - -import static com.google.common.primitives.Ints.saturatedCast; - -import java.util.HashSet; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; - -import gregtech.api.enums.InventoryType; -import gregtech.api.logic.FluidInventoryLogic; - -public interface FluidInventoryLogicHost extends IFluidHandler { - - /** - * To be used for single blocks or when directly interacting with the controller - * - * @param side The side from where fluids are being inputted or extracted from - * @param type The type of inventory being accessed. For inputting its Input, For outputting its Output. - * @return The Fluid Logic responsible for said type. Can return null if the side is invalid - */ - @Nullable - FluidInventoryLogic getFluidLogic(@Nonnull ForgeDirection side, @Nonnull InventoryType type); - - /** - * Only to be used by MultiBlockPart for accessing the Controller Inventory - * - * @param type Type of inventory, is it Input or Output - * @param id ID of the locked inventory. A null id is all inventories of said controller of said type - * @return The Fluid Logic responsible for everything that should be done with said inventory - */ - @Nonnull - default FluidInventoryLogic getFluidLogic(@Nonnull InventoryType type, @Nullable UUID id) { - return Objects.requireNonNull(getFluidLogic(ForgeDirection.UNKNOWN, type)); - } - - /** - * Returns an empty set if the type is {@link InventoryType#Both} or when the machine isn't a controller. - */ - @Nonnull - default Set> getAllFluidInventoryLogics(@Nonnull InventoryType type) { - return new HashSet<>(); - } - - @Override - default boolean canDrain(@Nonnull ForgeDirection from, Fluid fluid) { - FluidInventoryLogic logic = getFluidLogic(from, InventoryType.Output); - return logic != null; - } - - @Override - default boolean canFill(@Nonnull ForgeDirection from, Fluid fluid) { - FluidInventoryLogic logic = getFluidLogic(from, InventoryType.Input); - return logic != null; - } - - @Override - @Nullable - default FluidStack drain(@Nonnull ForgeDirection from, @Nonnull FluidStack resource, boolean doDrain) { - FluidInventoryLogic logic = getFluidLogic(from, InventoryType.Output); - if (logic == null) return null; - return logic.drain(resource.getFluid(), resource.amount, !doDrain); - } - - @Override - @Nullable - default FluidStack drain(@Nonnull ForgeDirection from, int maxDrain, boolean doDrain) { - FluidInventoryLogic logic = getFluidLogic(from, InventoryType.Output); - if (logic == null) return null; - return logic.drain(maxDrain, !doDrain); - } - - @Override - default int fill(@Nonnull ForgeDirection from, @Nonnull FluidStack resource, boolean doFill) { - FluidInventoryLogic logic = getFluidLogic(from, InventoryType.Input); - if (logic == null) return 0; - return saturatedCast(logic.fill(resource.getFluid(), resource.amount, !doFill)); - } - - @Override - @Nullable - default FluidTankInfo[] getTankInfo(@Nonnull ForgeDirection from) { - return null; - } -} diff --git a/src/main/java/gregtech/api/logic/interfaces/ItemInventoryLogicHost.java b/src/main/java/gregtech/api/logic/interfaces/ItemInventoryLogicHost.java deleted file mode 100644 index a65f3c50f19..00000000000 --- a/src/main/java/gregtech/api/logic/interfaces/ItemInventoryLogicHost.java +++ /dev/null @@ -1,172 +0,0 @@ -package gregtech.api.logic.interfaces; - -import java.util.HashSet; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.InventoryType; -import gregtech.api.logic.ItemInventoryLogic; - -public interface ItemInventoryLogicHost extends ISidedInventory { - - /** - * To be used for single blocks or when directly interacting with the controller - * - * @param side The side from where items are being inputted or extracted from - * @param type The type of inventory being accessed. For inputting its Input, For outputting its Output. - * @return The Item Logic responsible for said type. Will return null if the side is not valid - */ - @Nullable - ItemInventoryLogic getItemLogic(@Nonnull ForgeDirection side, @Nonnull InventoryType type); - - /** - * Only to be used by MultiBlockPart for accessing the Controller Inventory - * - * @param type Type of inventory, is it Input or Output - * @param id ID of the locked inventory. A null id is all inventories of said controller of said type - * @return The Item Logic responsible for everything that should be done with said inventory - */ - @Nonnull - default ItemInventoryLogic getItemLogic(@Nonnull InventoryType type, @Nullable UUID id) { - return Objects.requireNonNull(getItemLogic(ForgeDirection.UNKNOWN, type)); - } - - /** - * Only to be used for MultiBlockPart - * - * @return - */ - @Nullable - default InventoryType getItemInventoryType() { - return null; - } - - /** - * Returns an empty set if the type is {@link InventoryType#Both} or this is used when the machine isn't a - * controller - */ - @Nonnull - default Set> getAllItemInventoryLogics(@Nonnull InventoryType type) { - return new HashSet<>(); - } - - @Override - @Nullable - default ItemStack decrStackSize(int slot, int count) { - InventoryType type = getItemInventoryType(); - if (type == InventoryType.Both) return null; - ItemInventoryLogic logic = getItemLogic(ForgeDirection.UNKNOWN, type == null ? InventoryType.Output : type); - if (logic == null) return null; - return logic.extractItem(slot, count); - } - - @Override - default int getSizeInventory() { - InventoryType type = getItemInventoryType(); - if (type == InventoryType.Both) return 0; - ItemInventoryLogic logic = getItemLogic(ForgeDirection.UNKNOWN, type == null ? InventoryType.Output : type); - if (logic == null) return 0; - return logic.getSlots(); - } - - @Override - @Nullable - default ItemStack getStackInSlot(int slot) { - InventoryType type = getItemInventoryType(); - if (type == InventoryType.Both) return null; - ItemInventoryLogic logic = getItemLogic(ForgeDirection.UNKNOWN, type == null ? InventoryType.Output : type); - if (logic == null) return null; - return logic.getInventory() - .getStackInSlot(slot); - } - - @Override - default boolean isItemValidForSlot(int slot, @Nullable ItemStack stack) { - InventoryType type = getItemInventoryType(); - if (type == InventoryType.Both) return false; - ItemInventoryLogic logic = getItemLogic(ForgeDirection.UNKNOWN, type == null ? InventoryType.Output : type); - if (logic == null) return false; - return logic.getInventory() - .isItemValid(slot, stack); - } - - @Override - default void setInventorySlotContents(int slot, @Nullable ItemStack stack) { - InventoryType type = getItemInventoryType(); - if (type == InventoryType.Both) return; - ItemInventoryLogic logic = getItemLogic(ForgeDirection.UNKNOWN, type == null ? InventoryType.Output : type); - if (logic == null) return; - logic.getInventory() - .setStackInSlot(slot, stack); - } - - @Override - default boolean canExtractItem(int ignoredSlot, ItemStack ignoredItem, int side) { - InventoryType type = getItemInventoryType(); - if (type == null) return false; - return getItemLogic(ForgeDirection.getOrientation(side), type) != null; - } - - @Override - default boolean canInsertItem(int ignoredSlot, ItemStack ignoredItem, int side) { - InventoryType type = getItemInventoryType(); - if (type == null) return false; - return getItemInventoryType() != InventoryType.Output - && getItemLogic(ForgeDirection.getOrientation(side), type) != null; - } - - @Override - default int[] getAccessibleSlotsFromSide(int side) { - InventoryType type = getItemInventoryType(); - if (type == null) return new int[0]; - ItemInventoryLogic logic = getItemLogic(ForgeDirection.UNKNOWN, type == null ? InventoryType.Output : type); - if (logic == null) return new int[0]; - int[] indexes = new int[logic.getSlots()]; - for (int i = 0; i < logic.getSlots(); i++) { - indexes[i] = i; - } - return indexes; - } - - @Override - default void closeInventory() {} - - @Override - default String getInventoryName() { - return ""; - } - - @Override - default int getInventoryStackLimit() { - return 64; - } - - @Override - default ItemStack getStackInSlotOnClosing(int index) { - return null; - } - - @Override - default boolean hasCustomInventoryName() { - return false; - } - - @Override - default boolean isUseableByPlayer(@Nonnull EntityPlayer player) { - return false; - } - - @Override - default void openInventory() {} - -} diff --git a/src/main/java/gregtech/api/logic/interfaces/ModelRenderLogicHost.java b/src/main/java/gregtech/api/logic/interfaces/ModelRenderLogicHost.java deleted file mode 100644 index 9a0afaa5397..00000000000 --- a/src/main/java/gregtech/api/logic/interfaces/ModelRenderLogicHost.java +++ /dev/null @@ -1,10 +0,0 @@ -package gregtech.api.logic.interfaces; - -import gregtech.api.logic.ModelRenderLogic; - -public interface ModelRenderLogicHost { - - ModelRenderLogic getRenderLogic(); - - boolean shouldRenderModel(); -} diff --git a/src/main/java/gregtech/api/logic/interfaces/PowerLogicHost.java b/src/main/java/gregtech/api/logic/interfaces/PowerLogicHost.java deleted file mode 100644 index 4903d7fa231..00000000000 --- a/src/main/java/gregtech/api/logic/interfaces/PowerLogicHost.java +++ /dev/null @@ -1,60 +0,0 @@ -package gregtech.api.logic.interfaces; - -import java.util.Objects; - -import javax.annotation.Nonnull; - -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.interfaces.tileentity.IEnergyConnected; -import gregtech.api.logic.PowerLogic; - -/** - * Power logic class for one to use to enable a machine to use energy - */ -public interface PowerLogicHost { - - /** - * - * @param side Side being access to try and get the power logic from - * @return Can return NullPowerLogic if the side doesn't allow the return of the logic. That power logic is unusable - */ - @Nonnull - PowerLogic getPowerLogic(@Nonnull ForgeDirection side); - - /** - * Gives the power logic ignoring the side. - */ - @Nonnull - default PowerLogic getPowerLogic() { - return Objects.requireNonNull(getPowerLogic(ForgeDirection.UNKNOWN)); - } - - /** - * Shortcut to the method of {@link PowerLogic#isEnergyReceiver()} - */ - default boolean isEnergyReceiver() { - return getPowerLogic().isEnergyReceiver(); - } - - /** - * Shortcut to the method of {@link PowerLogic#isEnergyEmitter()} - */ - default boolean isEnergyEmitter() { - return getPowerLogic().isEnergyEmitter(); - } - - /** - * Method for emitting energy to other blocks and machines. Override when it needs to be changed. - */ - default void emitEnergyFromLogic() { - IEnergyConnected.Util.emitEnergyToNetwork(this, getPowerOutputSide()); - } - - /** - * From where does the machine output energy from? - * When the output side is {@link ForgeDirection#UNKNOWN} then it won't output energy - */ - @Nonnull - ForgeDirection getPowerOutputSide(); -} diff --git a/src/main/java/gregtech/api/logic/interfaces/ProcessingLogicHost.java b/src/main/java/gregtech/api/logic/interfaces/ProcessingLogicHost.java deleted file mode 100644 index 314d0d3d975..00000000000 --- a/src/main/java/gregtech/api/logic/interfaces/ProcessingLogicHost.java +++ /dev/null @@ -1,82 +0,0 @@ -package gregtech.api.logic.interfaces; - -import javax.annotation.Nonnull; - -import gregtech.api.enums.VoidingMode; -import gregtech.api.interfaces.tileentity.IMachineProgress; -import gregtech.api.interfaces.tileentity.IVoidable; -import gregtech.api.logic.MuTEProcessingLogic; - -public interface ProcessingLogicHost

> - extends IVoidable, ItemInventoryLogicHost, FluidInventoryLogicHost, IMachineProgress { - - /** - * Get the processing logic for the current machine - */ - @Nonnull - P getProcessingLogic(); - - boolean isInputSeparated(); - - void setInputSeparation(Boolean inputSeparation); - - default boolean supportsInputSeparation() { - return true; - } - - default boolean getDefaultInputSeparationMode() { - return false; - } - - boolean isRecipeLockingEnabled(); - - void setRecipeLocking(Boolean recipeLocked); - - default boolean supportsSingleRecipeLocking() { - return true; - } - - default boolean getDefaultRecipeLockingMode() { - return false; - } - - default boolean supportsBatchMode() { - return true; - } - - void setBatchMode(Boolean batchMode); - - boolean isBatchModeEnabled(); - - default boolean getDefaultBatchMode() { - return false; - } - - /** - * Get what the machine can void or not - */ - @Nonnull - VoidingMode getVoidMode(); - - /** - * Called when the processing logic should be updated by {@link #needsUpdate()} - */ - default void updateProcessingLogic(@Nonnull P processingLogic) {} - - /** - * Called before the recipe check, but after any other updates - */ - default void setProcessingLogicPower(@Nonnull P processingLogic) {} - - /** - * DO NOT CALL YOURSELF!!! - *

- * If you want to make the processing logic be updated call {@link #setProcessingUpdate(boolean)} - */ - boolean needsUpdate(); - - /** - * To be called when one needs to updated the processing logic. That can be when parallel changes, ect. - */ - void setProcessingUpdate(boolean update); -} diff --git a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java index 02877d8497f..7398b7af8eb 100644 --- a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java @@ -247,8 +247,6 @@ protected void updateCoverBehavior() { @Override public void issueCoverUpdate(ForgeDirection side) { - // If we've got a null worldObj we're getting called as a part of readingNBT from a non tickable MultiTileEntity - // on chunk load before the world is set, so we'll want to send a cover update. final CoverInfo coverInfo = getCoverInfoAtSide(side); if (worldObj == null || (isServerSide() && coverInfo.isDataNeededOnClient())) coverInfo.setNeedsUpdate(true); } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java index ef1a3fe96b2..51b7a48d500 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java @@ -44,7 +44,6 @@ import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IEnergyConnected; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.interfaces.PowerLogicHost; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GTCoverNone; @@ -339,10 +338,9 @@ public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { final ForgeDirection oppositeSide = side.getOpposite(); // GT Machine handling - if ((tileEntity instanceof PowerLogicHost powerLogic && powerLogic.getPowerLogic(oppositeSide) != null) - || ((tileEntity instanceof IEnergyConnected energyConnected) - && (energyConnected.inputEnergyFrom(oppositeSide, false) - || energyConnected.outputsEnergyTo(oppositeSide, false)))) + if (((tileEntity instanceof IEnergyConnected energyConnected) + && (energyConnected.inputEnergyFrom(oppositeSide, false) + || energyConnected.outputsEnergyTo(oppositeSide, false)))) return true; // Solar Panel Compat diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java index 755b023b24b..5210c567df3 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java @@ -907,6 +907,11 @@ protected CheckRecipeResult doCheckRecipe() { } } + result = checkRecipeForCustomHatches(result); + if (result.wasSuccessful()) { + return result; + } + processingLogic.setInputFluids(getStoredFluids()); if (isInputSeparationEnabled()) { @@ -934,7 +939,7 @@ protected CheckRecipeResult doCheckRecipe() { if (canUseControllerSlotForRecipe() && getControllerSlot() != null) { inputItems.add(getControllerSlot()); } - processingLogic.setInputItems(inputItems.toArray(new ItemStack[0])); + processingLogic.setInputItems(inputItems); CheckRecipeResult foundResult = processingLogic.process(); if (foundResult.wasSuccessful()) { return foundResult; @@ -963,6 +968,18 @@ protected CheckRecipeResult doCheckRecipe() { return result; } + /** + * Override to perform additional checkRecipe logic. It gets called after CRIBs and before ordinal hatches. + * + * @param lastResult Last result of checkRecipe. It might contain interesting info about failure, so don't blindly + * overwrite it. Refer to {@link #doCheckRecipe} for how to handle it. + * @return Result of the checkRecipe. + */ + @Nonnull + protected CheckRecipeResult checkRecipeForCustomHatches(CheckRecipeResult lastResult) { + return lastResult; + } + /** * Performs additional check for {@link #processingLogic} after all the calculations are done. * As many as checks should be done inside of custom {@link ProcessingLogic}, which you can specify with diff --git a/src/main/java/gregtech/api/objects/GTHashSet.java b/src/main/java/gregtech/api/objects/GTHashSet.java index df012c05f73..fa85a9a411f 100644 --- a/src/main/java/gregtech/api/objects/GTHashSet.java +++ b/src/main/java/gregtech/api/objects/GTHashSet.java @@ -7,12 +7,14 @@ import java.util.LinkedHashMap; import java.util.Map; +import javax.annotation.Nonnull; + import net.minecraft.item.ItemStack; import gregtech.api.GregTechAPI; import gregtech.api.util.GTUtility; -public class GTHashSet extends AbstractSet { +public class GTHashSet extends AbstractSet { private static final Object OBJECT = new Object(); private final transient HashMap map; @@ -22,7 +24,7 @@ public GTHashSet() { GregTechAPI.sItemStackMappings.add(map); } - public GTHashSet(Collection c) { + public GTHashSet(Collection c) { map = new HashMap<>(Math.max((int) (c.size() / .75f) + 1, 16)); addAll(c); GregTechAPI.sItemStackMappings.add(map); @@ -47,10 +49,10 @@ public Map getMap() { return map; } - @SuppressWarnings("unchecked") // The downcasting below will throw ClassCastException unless E is GT_ItemStack. + @Nonnull @Override - public Iterator iterator() { - return (Iterator) map.keySet() + public Iterator iterator() { + return map.keySet() .iterator(); } @@ -75,7 +77,7 @@ public boolean add(ItemStack aStack) { } @Override - public boolean add(E e) { + public boolean add(GTItemStack e) { return map.put(e, OBJECT) == null; } diff --git a/src/main/java/gregtech/api/objects/GTItemStack.java b/src/main/java/gregtech/api/objects/GTItemStack.java index 3ddfcd706a2..692ee34837d 100644 --- a/src/main/java/gregtech/api/objects/GTItemStack.java +++ b/src/main/java/gregtech/api/objects/GTItemStack.java @@ -6,14 +6,13 @@ import gregtech.api.enums.GTValues; import gregtech.api.util.GTUtility; -import gregtech.api.util.item.ItemHolder; import it.unimi.dsi.fastutil.Hash; /** * An optimization of {@link ItemStack} to have a better {@code hashcode} and {@code equals} in order to improve * {@code HashMap} and {@code Set} performance */ -public class GTItemStack extends ItemHolder { +public class GTItemStack { /** * A better {@link Hash.Strategy} for {@link ItemStack}. Implementation originally from {@code GT_ItemStack2}. @@ -39,7 +38,6 @@ public boolean equals(ItemStack a, ItemStack b) { public final short mMetaData; public GTItemStack(Item aItem, long aStackSize, long aMetaData) { - super(new ItemStack(aItem, 1, (int) aMetaData)); mItem = aItem; mStackSize = (byte) aStackSize; mMetaData = (short) aMetaData; diff --git a/src/main/java/gregtech/api/objects/GTItemStack2.java b/src/main/java/gregtech/api/objects/GTItemStack2.java deleted file mode 100644 index 798915d8489..00000000000 --- a/src/main/java/gregtech/api/objects/GTItemStack2.java +++ /dev/null @@ -1,41 +0,0 @@ -package gregtech.api.objects; - -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 - * that contains GT_ItemStack. - * - * @deprecated See {@link GTItemStack#ITEMSTACK_HASH_STRATEGY2} - */ -@Deprecated -public class GTItemStack2 extends GTItemStack { - - public GTItemStack2(Item aItem, long aStackSize, long aMetaData) { - super(aItem, aStackSize, aMetaData); - } - - public GTItemStack2(ItemStack aStack) { - super(aStack); - } - - public GTItemStack2(ItemStack aStack, boolean wildcard) { - super(aStack, wildcard); - } - - @Override - public boolean equals(Object aStack) { - if (aStack == this) return true; - if (aStack instanceof GTItemStack) { - return ((GTItemStack) aStack).mItem == mItem && ((GTItemStack) aStack).mMetaData == mMetaData; - } - return false; - } - - @Override - public int hashCode() { - return mItem.hashCode() * 38197 + mMetaData; - } -} diff --git a/src/main/java/gregtech/api/task/TaskHost.java b/src/main/java/gregtech/api/task/TaskHost.java deleted file mode 100644 index d6377949c16..00000000000 --- a/src/main/java/gregtech/api/task/TaskHost.java +++ /dev/null @@ -1,18 +0,0 @@ -package gregtech.api.task; - -import javax.annotation.Nonnull; - -import org.jetbrains.annotations.ApiStatus; - -/** - * Classes implementing this interface can have {@link TickableTask} to run. Tasks with conflicting name should not be - * allowed, to prevent them from overwriting others' NBT load/save. - */ -public interface TaskHost { - - /** - * This method should be called ONLY by {@link TickableTask} constructor. - */ - @ApiStatus.OverrideOnly - void registerTask(@Nonnull TickableTask task); -} diff --git a/src/main/java/gregtech/api/task/TickableTask.java b/src/main/java/gregtech/api/task/TickableTask.java deleted file mode 100644 index 3bbeb216e7c..00000000000 --- a/src/main/java/gregtech/api/task/TickableTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package gregtech.api.task; - -import javax.annotation.Nonnull; - -import net.minecraft.nbt.NBTTagCompound; - -/** - * This class aims at separating logic run on {@link TaskHost}, rather than using interface layers. - * It has two main functionalities: Run tick and Save/Load. - * - * @param Type of the host - */ -public abstract class TickableTask { - - @Nonnull - protected final T taskHost; - - public TickableTask(@Nonnull T taskHost) { - this.taskHost = taskHost; - taskHost.registerTask(this); - } - - /** - * @return Name of this task. Tasks with conflicting name cannot be registered to the same machine. - */ - @Nonnull - public abstract String getName(); - - /** - * Called once per world tick. - */ - public abstract void update(long tick, boolean isServerSide); - - /** - * Save info to NBT. - */ - public void writeToNBT(@Nonnull NBTTagCompound nbt) {} - - /** - * Read info from NBT. - */ - public void readFromNBT(@Nonnull NBTTagCompound nbt) {} - - @Override - public String toString() { - return "TickableTask{" + "name=" + getName() + ", taskHost=" + taskHost + "}"; - } -} diff --git a/src/main/java/gregtech/api/task/tasks/PollutionTask.java b/src/main/java/gregtech/api/task/tasks/PollutionTask.java deleted file mode 100644 index c8c9705e6c7..00000000000 --- a/src/main/java/gregtech/api/task/tasks/PollutionTask.java +++ /dev/null @@ -1,45 +0,0 @@ -package gregtech.api.task.tasks; - -import javax.annotation.Nonnull; - -import net.minecraft.tileentity.TileEntity; - -import gregtech.api.enums.TickTime; -import gregtech.api.interfaces.tileentity.IMachineProgress; -import gregtech.api.task.TaskHost; -import gregtech.api.task.TickableTask; -import gregtech.common.pollution.Pollution; - -public class PollutionTask extends TickableTask { - - private int pollutionPerSecond; - private static final int POLLUTION_TICK = TickTime.SECOND; - - public PollutionTask(@Nonnull T taskHost) { - super(taskHost); - } - - public PollutionTask setPollutionPerSecond(int pollutionPerSecond) { - this.pollutionPerSecond = pollutionPerSecond; - return this; - } - - public int getPollutionPerSecond() { - return pollutionPerSecond; - } - - @Nonnull - @Override - public String getName() { - return "pollution"; - } - - @Override - public void update(long tick, boolean isServerSide) { - if (isServerSide && tick % POLLUTION_TICK == 0 && taskHost.hasThingsToDo()) { - if (taskHost instanceof final TileEntity entity) { - Pollution.addPollution(entity, getPollutionPerSecond()); - } - } - } -} diff --git a/src/main/java/gregtech/api/task/tasks/PowerOutputTask.java b/src/main/java/gregtech/api/task/tasks/PowerOutputTask.java deleted file mode 100644 index ef800635fb1..00000000000 --- a/src/main/java/gregtech/api/task/tasks/PowerOutputTask.java +++ /dev/null @@ -1,32 +0,0 @@ -package gregtech.api.task.tasks; - -import javax.annotation.Nonnull; - -import gregtech.api.interfaces.tileentity.IMachineProgress; -import gregtech.api.logic.interfaces.PowerLogicHost; -import gregtech.api.task.TaskHost; -import gregtech.api.task.TickableTask; - -public class PowerOutputTask extends TickableTask { - - private static final String NAME = "powerOutput"; - - public PowerOutputTask(@Nonnull T taskHost) { - super(taskHost); - } - - @Override - @Nonnull - public String getName() { - return NAME; - } - - @Override - public void update(long tick, boolean isServerSide) { - if (!isServerSide) return; - if (!taskHost.isActive()) return; - if (!taskHost.isEnergyEmitter()) return; - taskHost.emitEnergyFromLogic(); - } - -} diff --git a/src/main/java/gregtech/api/task/tasks/ProcessingTask.java b/src/main/java/gregtech/api/task/tasks/ProcessingTask.java deleted file mode 100644 index 410c8d7a6f6..00000000000 --- a/src/main/java/gregtech/api/task/tasks/ProcessingTask.java +++ /dev/null @@ -1,51 +0,0 @@ -package gregtech.api.task.tasks; - -import javax.annotation.Nonnull; - -import gregtech.api.interfaces.tileentity.IMachineProgress; -import gregtech.api.logic.MuTEProcessingLogic; -import gregtech.api.logic.interfaces.ProcessingLogicHost; -import gregtech.api.task.TaskHost; -import gregtech.api.task.TickableTask; - -public class ProcessingTask & IMachineProgress, P extends MuTEProcessingLogic

> - extends TickableTask { - - public ProcessingTask(@Nonnull T taskHost) { - super(taskHost); - } - - private static final String NAME = "processing"; - - @Override - @Nonnull - public String getName() { - return NAME; - } - - @Override - public void update(long tick, boolean isServerSide) { - if (!isServerSide) return; - if (!taskHost.isAllowedToWork()) return; - final P logic = taskHost.getProcessingLogic(); - if (taskHost.needsUpdate()) { - taskHost.updateProcessingLogic(logic); - taskHost.setProcessingUpdate(false); - } - if (logic.canWork() && tick % 100 == 0) { - taskHost.setProcessingLogicPower(logic); - logic.startCheck(); - if (logic.getResult() - .wasSuccessful()) { - taskHost.setActive(true); - } - } - - if (taskHost.hasThingsToDo()) { - logic.progress(); - } else { - taskHost.setActive(false); - } - } - -} diff --git a/src/main/java/gregtech/api/util/GTModHandler.java b/src/main/java/gregtech/api/util/GTModHandler.java index a564af1ffb0..ab6ec46658a 100644 --- a/src/main/java/gregtech/api/util/GTModHandler.java +++ b/src/main/java/gregtech/api/util/GTModHandler.java @@ -102,7 +102,7 @@ public class GTModHandler { private static final List delayedRemovalByRecipe = new ArrayList<>(); public static Collection sNativeRecipeClasses = new HashSet<>(), sSpecialRecipeClasses = new HashSet<>(); - public static GTHashSet sNonReplaceableItems = new GTHashSet<>(); + public static GTHashSet sNonReplaceableItems = new GTHashSet(); public static Object sBoxableWrapper = new GTIBoxableWrapper(); public static Collection sBoxableItems = new ArrayList<>(); private static final Map emptyRecipeMap = new HashMap<>(); diff --git a/src/main/java/gregtech/api/util/GTRecipe.java b/src/main/java/gregtech/api/util/GTRecipe.java index ce17f693331..329816c6c5c 100644 --- a/src/main/java/gregtech/api/util/GTRecipe.java +++ b/src/main/java/gregtech/api/util/GTRecipe.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -26,8 +25,6 @@ import gregtech.api.GregTechAPI; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; -import gregtech.api.logic.FluidInventoryLogic; -import gregtech.api.logic.ItemInventoryLogic; import gregtech.api.metatileentity.implementations.MTEHatchInput; import gregtech.api.metatileentity.implementations.MTEHatchInputBus; import gregtech.api.metatileentity.implementations.MTEHatchMultiInput; @@ -40,7 +37,6 @@ import gregtech.api.recipe.metadata.EmptyRecipeMetadataStorage; import gregtech.api.recipe.metadata.IRecipeMetadataStorage; import gregtech.api.util.extensions.ArrayExt; -import gregtech.api.util.item.ItemHolder; import gregtech.common.tileentities.machines.MTEHatchInputBusME; import gregtech.common.tileentities.machines.MTEHatchInputME; import gregtech.nei.GTNEIDefaultHandler; @@ -687,60 +683,6 @@ private static boolean shouldCheckNBT(ItemStack item) { return false; } - public boolean isRecipePossible(@Nullable ItemInventoryLogic itemInput, @Nullable FluidInventoryLogic fluidInput) { - return getAmountOfRecipesDone(itemInput, fluidInput, 1, true) > 0; - } - - public long getAmountOfRecipesDone(@Nullable ItemInventoryLogic itemInput, @Nullable FluidInventoryLogic fluidInput, - long maxParallel, boolean simulate) { - if (itemInput == null) { - itemInput = new ItemInventoryLogic(0); - } - - if (fluidInput == null) { - fluidInput = new FluidInventoryLogic(0, 0); - } - - itemInput.startRecipeCheck(); - Map recipeItems = getItemInputsAsItemMap(); - for (Entry entry : recipeItems.entrySet()) { - maxParallel = Math - .min(maxParallel, itemInput.calculateAmountOfTimesItemCanBeTaken(entry.getKey(), entry.getValue())); - } - - for (FluidStack fluid : mFluidInputs) { - if (fluid == null) continue; - maxParallel = Math - .min(maxParallel, fluidInput.calculateAmountOfTimesFluidCanBeTaken(fluid.getFluid(), fluid.amount)); - } - - if (simulate) { - itemInput.stopRecipeCheck(); - return maxParallel; - } - - for (Entry entry : recipeItems.entrySet()) { - itemInput.subtractItemAmount(entry.getKey(), entry.getValue() * maxParallel, false); - } - - for (FluidStack fluid : mFluidInputs) { - if (fluid == null) continue; - fluidInput.drain(fluid.getFluid(), fluid.amount * maxParallel, false); - } - itemInput.stopRecipeCheck(); - return maxParallel; - } - - private Map getItemInputsAsItemMap() { - Map items = new HashMap<>(); - for (ItemStack item : mInputs) { - if (item == null) continue; - ItemHolder itemHolder = new ItemHolder(item); - items.put(itemHolder, items.getOrDefault(itemHolder, 0L) + item.stackSize); - } - return items; - } - @Override public int compareTo(GTRecipe recipe) { // first lowest tier recipes diff --git a/src/main/java/gregtech/api/util/GTUtility.java b/src/main/java/gregtech/api/util/GTUtility.java index fbaa3357d73..8098c372fd4 100644 --- a/src/main/java/gregtech/api/util/GTUtility.java +++ b/src/main/java/gregtech/api/util/GTUtility.java @@ -164,7 +164,6 @@ import gregtech.api.net.GTPacketSound; import gregtech.api.objects.CollectorUtils; import gregtech.api.objects.GTItemStack; -import gregtech.api.objects.GTItemStack2; import gregtech.api.objects.ItemData; import gregtech.api.recipe.RecipeMaps; import gregtech.api.threads.RunnableSound; @@ -3019,23 +3018,11 @@ public static boolean isStackInList(ItemStack aStack, Collection aL return isStackInList(new GTItemStack(aStack), aList); } - public static boolean isStackInList(ItemStack aStack, Set aList) { - if (aStack == null) { - return false; - } - return isStackInList(new GTItemStack2(aStack), aList); - } - public static boolean isStackInList(GTItemStack aStack, Collection aList) { return aStack != null && (aList.contains(aStack) || aList.contains(new GTItemStack(aStack.mItem, aStack.mStackSize, W))); } - public static boolean isStackInList(GTItemStack2 aStack, Set aList) { - return aStack != null - && (aList.contains(aStack) || aList.contains(new GTItemStack2(aStack.mItem, aStack.mStackSize, W))); - } - /** * re-maps all Keys of a Map after the Keys were weakened. */ diff --git a/src/main/java/gregtech/api/util/ParallelHelper.java b/src/main/java/gregtech/api/util/ParallelHelper.java index de08a594721..99e7cac569f 100644 --- a/src/main/java/gregtech/api/util/ParallelHelper.java +++ b/src/main/java/gregtech/api/util/ParallelHelper.java @@ -13,8 +13,6 @@ import gregtech.api.interfaces.tileentity.IRecipeLockable; import gregtech.api.interfaces.tileentity.IVoidable; -import gregtech.api.logic.FluidInventoryLogic; -import gregtech.api.logic.ItemInventoryLogic; import gregtech.api.objects.XSTR; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.check.CheckRecipeResult; @@ -62,14 +60,6 @@ public class ParallelHelper { * The inputs of the multiblock for the current recipe check */ private ItemStack[] itemInputs; - /** - * The inputs of the machine for current recipe check - */ - private ItemInventoryLogic itemInputInventory; - /** - * The output item inventory of the machine - */ - private ItemInventoryLogic itemOutputInventory; /** * The outputs of the recipe with the applied parallel */ @@ -78,14 +68,6 @@ public class ParallelHelper { * The inputs of the multiblock for the current recipe check */ private FluidStack[] fluidInputs; - /** - * The inputs of the machine for the current recipe check - */ - private FluidInventoryLogic fluidInputInventory; - /** - * The output fluid inventory of the machine; - */ - private FluidInventoryLogic fluidOutputInventory; /** * The outputs of the recipe with the applied parallel */ @@ -150,12 +132,6 @@ public class ParallelHelper { private Function customFluidOutputCalculation; - /** - * MuTE Mode this is a mode for changing how the GT_ParallelHelper works as Mutes don't use ItemStack and FluidStack - * arrays for inputs - */ - private boolean muteMode = false; - public ParallelHelper() {} /** @@ -316,24 +292,6 @@ public ParallelHelper setCustomFluidOutputCalculation(Function fluidOutputInventory.getInventory() - .getTanks()) { - return 0; - } - - // A map to hold the items we will be 'inputting' into the output hatches. These fluidstacks are actually - // the recipe outputs. - Map tFluidOutputMap = new HashMap<>(); - - // Map that keeps track of the number of parallel crafts we can accommodate for each fluid output. - // In the pair, we keep track of number of full crafts plus mb of fluid in a partial craft, to avoid - // issues with floating point math not being completely accurate when summing. - Map tParallels = new HashMap<>(); - - // Iterate over the outputs, calculating require stack spacing they will require. - for (FluidStack aY : fluidOutputs) { - if (aY == null) continue; - int fluidAmount = aY.amount * outputMultiplier; - if (fluidAmount <= 0) continue; - tFluidOutputMap.merge(aY, fluidAmount, Integer::sum); - tParallels.put(aY, new ParallelData(0, 0)); - } - - if (tFluidOutputMap.isEmpty()) { - // nothing to output, bail early - return maxParallel; - } - - for (int i = 0; i < fluidOutputInventory.getInventory() - .getTanks(); i++) { - IFluidTankLong tank = fluidOutputInventory.getInventory() - .getFluidTank(i); - long tSpaceLeft = tank.getCapacityLong() - tank.getFluidAmountLong(); - // check if hatch filled - if (tSpaceLeft <= 0) continue; - // check if hatch is empty and unrestricted - if (tank.getStoredFluid() == null) continue; - - for (Map.Entry entry : tParallels.entrySet()) { - FluidStack tFluidOutput = entry.getKey(); - if (tank.fill(tFluidOutput.getFluid(), tFluidOutput.amount, false) == tFluidOutput.amount) continue; - // this fluid is not prevented by restrictions on output hatch - ParallelData tParallel = entry.getValue(); - Integer tCraftSize = tFluidOutputMap.get(tFluidOutput); - tParallel.batch += (tParallel.partial + tSpaceLeft) / tCraftSize; - tParallel.partial = (tParallel.partial + tSpaceLeft) % tCraftSize; - } - } - // now that all partial/restricted hatches have been counted, create a priority queue for our outputs - // the lowest priority fluid is the number of complete parallel crafts we can support - PriorityQueue> aParallelQueue = new PriorityQueue<>( - Comparator.comparing(i -> i.batch)); - for (Map.Entry entry : tParallels.entrySet()) { - aParallelQueue - .add(new ParallelStackInfo<>(entry.getValue().batch, entry.getValue().partial, entry.getKey())); - } - // add extra parallels for open slots as well - for (int i = 0; i < fluidOutputInventory.getInventory() - .getTanks(); i++) { - IFluidTankLong tank = fluidOutputInventory.getInventory() - .getFluidTank(i); - // partially filled or restricted hatch. done in the last pass - if (tank.getStoredFluid() != null) continue; - - ParallelStackInfo tParallel = aParallelQueue.poll(); - assert tParallel != null; // will always be true, specifying assert here to avoid IDE/compiler warnings - Integer tCraftSize = tFluidOutputMap.get(tParallel.stack); - long tSpaceLeft = tank.getCapacityLong(); - tParallel.batch += (tParallel.partial + tSpaceLeft) / tCraftSize; - tParallel.partial = (tParallel.partial + tSpaceLeft) % tCraftSize; - aParallelQueue.add(tParallel); - } - - return aParallelQueue.element().batch; - } - /** * Calculates the max parallels one can do with items if void protection is on */ private int calculateMaxItemParallels() { - List busStacks; - - if (muteMode) { - busStacks = itemOutputInventory.getInventory() - .getStacks(); - } else { - busStacks = machine.getItemOutputSlots(itemOutputs); - } + List busStacks = machine.getItemOutputSlots(itemOutputs); // A map to hold the items we will be 'inputting' into the output buses. These itemstacks are actually the // recipe outputs. Map tItemOutputMap = new ItemStackMap<>(); diff --git a/src/main/java/gregtech/api/util/item/ItemHolder.java b/src/main/java/gregtech/api/util/item/ItemHolder.java deleted file mode 100644 index 51215c93cbf..00000000000 --- a/src/main/java/gregtech/api/util/item/ItemHolder.java +++ /dev/null @@ -1,79 +0,0 @@ -package gregtech.api.util.item; - -import static net.minecraftforge.oredict.OreDictionary.getOreIDs; - -import java.util.Arrays; - -import javax.annotation.Nonnull; - -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import gregtech.api.util.GTUtility; - -public class ItemHolder { - - private final Item item; - private final int meta; - private final NBTTagCompound tag; - private final int[] oreIDs; - - public ItemHolder(@Nonnull ItemStack item) { - this.item = item.getItem(); - this.meta = Items.feather.getDamage(item); - this.tag = item.getTagCompound(); - this.oreIDs = getOreIDs(item); - } - - public Item getItem() { - return item; - } - - public int getMeta() { - return meta; - } - - public NBTTagCompound getNBT() { - return tag; - } - - public int[] getOreDictTagIDs() { - return oreIDs; - } - - @Override - public boolean equals(Object other) { - if (other == this) return true; - if (!(other instanceof ItemHolder otherIH)) return false; - if (Arrays.stream(oreIDs) - .anyMatch(id -> { - for (int i = 0; i < otherIH.getOreDictTagIDs().length; i++) { - if (id == otherIH.getOreDictTagIDs()[i]) return true; - } - return false; - })) { - return true; - } - - if (item != otherIH.getItem() || meta != otherIH.getMeta()) { - return false; - } - if (this.tag == null && otherIH.getNBT() == null) return true; - if (this.tag == null || otherIH.getNBT() == null) return false; - return this.tag.equals(otherIH); - } - - @Override - public int hashCode() { - return GTUtility.stackToInt(toStack()); - } - - @Nonnull - private ItemStack toStack() { - ItemStack item = new ItemStack(this.item, 1, meta); - item.stackTagCompound = tag; - return item; - } -} diff --git a/src/main/java/gregtech/api/util/recipe/RecipeInputRequirements.java b/src/main/java/gregtech/api/util/recipe/RecipeInputRequirements.java deleted file mode 100644 index 485ee991c54..00000000000 --- a/src/main/java/gregtech/api/util/recipe/RecipeInputRequirements.java +++ /dev/null @@ -1,77 +0,0 @@ -package gregtech.api.util.recipe; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import gregtech.api.util.GTRecipe; -import gregtech.api.util.item.ItemHolder; - -public class RecipeInputRequirements { - - protected Map itemInputs = new HashMap<>(); - protected Set itemInputsMet = new HashSet<>(); - protected boolean metAllItem = false; - protected Map fluidInputs = new HashMap<>(); - protected Set fluidInputsMet = new HashSet<>(); - protected boolean metAllFluid = false; - - public RecipeInputRequirements(@Nonnull GTRecipe recipe) { - this(recipe.mInputs, recipe.mFluidInputs); - } - - public RecipeInputRequirements(@Nonnull ItemStack[] itemInputs, @Nonnull FluidStack[] fluidInputs) { - for (ItemStack item : itemInputs) { - if (item == null) continue; - ItemHolder itemIH = new ItemHolder(item); - this.itemInputs.put(itemIH, this.itemInputs.getOrDefault(itemIH, 0L) + item.stackSize); - } - - for (FluidStack fluid : fluidInputs) { - if (fluid == null) continue; - this.fluidInputs.put(fluid.getFluid(), this.fluidInputs.getOrDefault(fluid.getFluid(), 0L) + fluid.amount); - } - } - - /** - * - * @param itemInputs we have and want to fill this request - * @return {@code true} when all item inputs are met - */ - public boolean tryToFillItemRequirements(Map itemInputs) { - if (metAllItem) return metAllItem; - for (Entry entry : itemInputs.entrySet()) { - if (itemInputsMet.contains(entry.getKey())) continue; - if (!this.itemInputs.containsKey(entry.getKey())) continue; - if (this.itemInputs.get(entry.getKey()) > entry.getValue()) continue; - itemInputsMet.add(entry.getKey()); - } - metAllItem = itemInputsMet.containsAll(this.itemInputs.keySet()); - return metAllItem; - } - - /** - * - * @param fluidInputs we have and want to fill this request - * @return {@code true} when all fluid inputs are met - */ - public boolean tryToFillFluidRequirements(Map fluidInputs) { - if (metAllFluid) return metAllFluid; - for (Entry entry : fluidInputs.entrySet()) { - if (fluidInputsMet.contains(entry.getKey())) continue; - if (!this.fluidInputs.containsKey(entry.getKey())) continue; - if (this.fluidInputs.get(entry.getKey()) > entry.getValue()) continue; - fluidInputsMet.add(entry.getKey()); - } - metAllFluid = fluidInputsMet.containsAll(this.fluidInputs.keySet()); - return metAllFluid; - } -} diff --git a/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java b/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java deleted file mode 100644 index 89b42c8500f..00000000000 --- a/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -package gregtech.common.gui; - -import javax.annotation.Nonnull; - -import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; - -import gregtech.api.gui.GUIHost; -import gregtech.api.logic.ComplexParallelProcessingLogic; -import gregtech.api.logic.interfaces.PowerLogicHost; -import gregtech.api.logic.interfaces.ProcessingLogicHost; - -/** - * Default GUI class for machines with complex parallel - */ -public class ComplexParallelMachineGUIProvider> & PowerLogicHost> - extends MachineGUIProvider { - - public ComplexParallelMachineGUIProvider(@Nonnull T host) { - super(host); - } - - @Override - protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { - - } - - @Override - protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { - - } -} diff --git a/src/main/java/gregtech/common/gui/MachineGUIProvider.java b/src/main/java/gregtech/common/gui/MachineGUIProvider.java deleted file mode 100644 index a8d8804ebe9..00000000000 --- a/src/main/java/gregtech/common/gui/MachineGUIProvider.java +++ /dev/null @@ -1,510 +0,0 @@ -package gregtech.common.gui; - -import static gregtech.api.metatileentity.BaseTileEntity.BUTTON_FORBIDDEN_TOOLTIP; -import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import javax.annotation.Nonnull; - -import net.minecraft.util.StatCollector; - -import com.gtnewhorizons.modularui.api.ModularUITextures; -import com.gtnewhorizons.modularui.api.NumberFormatMUI; -import com.gtnewhorizons.modularui.api.drawable.IDrawable; -import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; -import com.gtnewhorizons.modularui.api.drawable.UITexture; -import com.gtnewhorizons.modularui.api.math.Pos2d; -import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; -import com.gtnewhorizons.modularui.api.widget.Widget; -import com.gtnewhorizons.modularui.common.widget.ButtonWidget; -import com.gtnewhorizons.modularui.common.widget.DrawableWidget; -import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; -import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; -import com.gtnewhorizons.modularui.common.widget.TabButton; -import com.gtnewhorizons.modularui.common.widget.TabContainer; -import com.gtnewhorizons.modularui.common.widget.TextWidget; - -import gregtech.api.enums.InventoryType; -import gregtech.api.enums.SoundResource; -import gregtech.api.enums.VoidingMode; -import gregtech.api.gui.GUIHost; -import gregtech.api.gui.GUIProvider; -import gregtech.api.gui.modularui.GTUITextures; -import gregtech.api.gui.modularui.GUITextureSet; -import gregtech.api.logic.MuTEProcessingLogic; -import gregtech.api.logic.PowerLogic; -import gregtech.api.logic.interfaces.PowerLogicHost; -import gregtech.api.logic.interfaces.ProcessingLogicHost; - -/** - * Default GUI a machine will use to show its information - */ -public class MachineGUIProvider> & PowerLogicHost> - extends GUIProvider { - - private static final int LOGO_SIZE = 17; - @Nonnull - protected static final Pos2d POWER_SWITCH_BUTTON_DEFAULT_POS = new Pos2d(144, 0); - @Nonnull - protected static final Pos2d VOIDING_MODE_BUTTON_DEFAULT_POS = new Pos2d(54, 0); - @Nonnull - protected static final Pos2d INPUT_SEPARATION_BUTTON_DEFAULT_POS = new Pos2d(36, 0); - @Nonnull - protected static final Pos2d BATCH_MODE_BUTTON_DEFAULT_POS = new Pos2d(18, 0); - @Nonnull - protected static final Pos2d RECIPE_LOCKING_BUTTON_DEFAULT_POS = new Pos2d(0, 0); - - protected static final NumberFormatMUI numberFormat = new NumberFormatMUI(); - - public MachineGUIProvider(@Nonnull T host) { - super(host); - } - - @Override - protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { - - } - - @Override - protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { - int page = 0; - builder.setBackground(GTUITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); - MultiChildWidget mainTab = new MultiChildWidget(); - mainTab.setSize(host.getWidth(), host.getHeight()); - createMainTab(mainTab, builder, uiContext); - TabContainer tabs = new TabContainer().setButtonSize(20, 24); - tabs.addTabButton( - new TabButton(page++) - .setBackground( - false, - ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0, 1f, 0.5f), - new ItemDrawable(host.getAsItem()).withFixedSize(16, 16) - .withOffset(2, 4)) - .setBackground( - true, - ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0.5f, 1f, 1f), - new ItemDrawable(host.getAsItem()).withFixedSize(16, 16) - .withOffset(2, 4)) - .addTooltip(host.getMachineName()) - .setPos(20 * (page - 1), -20)) - .addPage(mainTab); - if (host.hasItemInput()) { - MultiChildWidget itemInputTab = new MultiChildWidget(); - itemInputTab.setSize(host.getWidth(), host.getHeight()); - createItemInputTab(itemInputTab, builder, uiContext); - tabs.addTabButton( - new TabButton(page++) - .setBackground( - false, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), - GTUITextures.PICTURE_ITEM_IN.withFixedSize(16, 16) - .withOffset(2, 4)) - .setBackground( - true, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), - GTUITextures.PICTURE_ITEM_IN.withFixedSize(16, 16) - .withOffset(2, 4)) - .addTooltip("Item Input Inventory") - .setPos(20 * (page - 1), -20)) - .addPage(itemInputTab.addChild(getLogo().setPos(147, 86))); - } - - if (host.hasItemOutput()) { - MultiChildWidget itemOutputTab = new MultiChildWidget(); - itemOutputTab.setSize(host.getWidth(), host.getHeight()); - createItemOutputTab(itemOutputTab, builder, uiContext); - tabs.addTabButton( - new TabButton(page++) - .setBackground( - false, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), - GTUITextures.PICTURE_ITEM_OUT.withFixedSize(16, 16) - .withOffset(2, 4)) - .setBackground( - true, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), - GTUITextures.PICTURE_ITEM_OUT.withFixedSize(16, 16) - .withOffset(2, 4)) - .addTooltip("Item Output Inventory") - .setPos(20 * (page - 1), -20)) - .addPage(itemOutputTab.addChild(getLogo().setPos(147, 86))); - } - - if (host.hasFluidInput()) { - MultiChildWidget fluidInputTab = new MultiChildWidget(); - fluidInputTab.setSize(host.getWidth(), host.getHeight()); - createFluidInputTab(fluidInputTab, builder, uiContext); - tabs.addTabButton( - new TabButton(page++) - .setBackground( - false, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), - GTUITextures.PICTURE_FLUID_IN.withFixedSize(16, 16) - .withOffset(2, 4)) - .setBackground( - true, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), - GTUITextures.PICTURE_FLUID_IN.withFixedSize(16, 16) - .withOffset(2, 4)) - .addTooltip("Fluid Input Tanks") - .setPos(20 * (page - 1), -20)) - .addPage(fluidInputTab.addChild(getLogo().setPos(147, 86))); - } - - if (host.hasFluidOutput()) { - MultiChildWidget fluidOutputTab = new MultiChildWidget(); - fluidOutputTab.setSize(host.getWidth(), host.getHeight()); - createFluidOutputTab(fluidOutputTab, builder, uiContext); - tabs.addTabButton( - new TabButton(page++) - .setBackground( - false, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), - GTUITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) - .withOffset(2, 4)) - .setBackground( - true, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), - GTUITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) - .withOffset(2, 4)) - .addTooltip("Fluid Output Tanks") - .setPos(20 * (page - 1), -20)) - .addPage(fluidOutputTab.addChild(getLogo().setPos(147, 86))); - } - MultiChildWidget powerInfoTab = new MultiChildWidget(); - powerInfoTab.setSize(host.getWidth(), host.getHeight()); - createPowerTab(powerInfoTab, builder, uiContext); - tabs.addTabButton( - new TabButton(page++) - .setBackground( - false, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), - GTUITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) - .withOffset(2, 4)) - .setBackground( - true, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), - GTUITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) - .withOffset(2, 4)) - .addTooltip("Power Information") - .setPos(20 * (page - 1), -20)) - .addPage(powerInfoTab.addChild(getLogo().setPos(147, 86))); - builder.widget(tabs); - } - - protected void createMainTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, - @Nonnull UIBuildContext uiBuildContext) { - MultiChildWidget buttons = new MultiChildWidget(); - buttons.setSize(16, 167) - .setPos(7, 86); - buttons.addChild(createPowerSwitchButton(builder)) - .addChild(createVoidExcessButton(builder)) - .addChild(createInputSeparationButton(builder)) - .addChild(createBatchModeButton(builder)) - .addChild(createLockToSingleRecipeButton(builder)); - tab.addChild( - new DrawableWidget().setDrawable(GTUITextures.PICTURE_SCREEN_BLACK) - .setPos(7, 4) - .setSize(160, 75)) - .addChild(buttons); - } - - protected void createItemInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, - @Nonnull UIBuildContext uiBuildContext) { - tab.addChild( - host.getItemLogic(InventoryType.Input, null) - .getGuiPart() - .setSize(18 * 4 + 9, 5 * 18) - .setPos(host.getWidth() / 2 - 2 * 18, 10)); - } - - protected void createItemOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, - @Nonnull UIBuildContext uiBuildContext) { - tab.addChild( - host.getItemLogic(InventoryType.Output, null) - .getGuiPart() - .setSize(18 * 4 + 9, 5 * 18) - .setPos(host.getWidth() / 2 - 2 * 18, 10)); - } - - protected void createFluidInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, - @Nonnull UIBuildContext uiBuildContext) { - tab.addChild( - host.getFluidLogic(InventoryType.Input, null) - .getGuiPart() - .setSize(18 * 4 + 9, 5 * 18) - .setPos(host.getWidth() / 2 - 2 * 18, 10)); - } - - protected void createFluidOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, - @Nonnull UIBuildContext uiBuildContext) { - tab.addChild( - host.getFluidLogic(InventoryType.Output, null) - .getGuiPart() - .setSize(18 * 4 + 9, 5 * 18) - .setPos(host.getWidth() / 2 - 2 * 18, 10)); - } - - protected void createPowerTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, - @Nonnull UIBuildContext uiBuildContext) { - PowerLogic power = host.getPowerLogic(); - tab.addChild( - new TextWidget() - .setStringSupplier( - () -> numberFormat.format(power.getStoredEnergy()) + "/" - + numberFormat.format(power.getCapacity()) - + " EU") - .setPos(10, 30)) - .addChild( - new TextWidget() - .setStringSupplier( - () -> numberFormat.format(power.getVoltage()) + " EU/t" - + "(" - + numberFormat.format(power.getMaxAmperage()) - + " A)") - .setPos(10, 60)); - } - - /** - * Should return the logo you want to use that is pasted on each tab. Default is the GT logo. - */ - @Nonnull - protected Widget getLogo() { - DrawableWidget logo = new DrawableWidget(); - logo.setDrawable(GUITextureSet.DEFAULT.getGregTechLogo()) - .setSize(LOGO_SIZE, LOGO_SIZE); - return logo; - } - - protected Pos2d getPowerSwitchButtonPos() { - return POWER_SWITCH_BUTTON_DEFAULT_POS; - } - - protected ButtonWidget createPowerSwitchButton(IWidgetBuilder builder) { - ButtonWidget button = new ButtonWidget(); - button.setOnClick((clickData, widget) -> { - if (host.isAllowedToWork()) { - host.disableWorking(); - } else { - host.enableWorking(); - } - }) - .setPlayClickSoundResource( - () -> host.isAllowedToWork() ? SoundResource.GUI_BUTTON_UP.resourceLocation - : SoundResource.GUI_BUTTON_DOWN.resourceLocation) - .setBackground(() -> { - if (host.isAllowedToWork()) { - return new IDrawable[] { GTUITextures.BUTTON_STANDARD_PRESSED, - GTUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON }; - } else { - return new IDrawable[] { GTUITextures.BUTTON_STANDARD, - GTUITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF }; - } - }) - .attachSyncer(new FakeSyncWidget.BooleanSyncer(host::isAllowedToWork, host::setAllowedToWork), builder) - .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.power_switch")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setPos(getPowerSwitchButtonPos()) - .setSize(16, 16); - return button; - } - - @Nonnull - protected Pos2d getVoidingModeButtonPos() { - return VOIDING_MODE_BUTTON_DEFAULT_POS; - } - - @Nonnull - protected ButtonWidget createVoidExcessButton(IWidgetBuilder builder) { - ButtonWidget button = new ButtonWidget(); - button.setOnClick((clickData, widget) -> { - if (host.supportsVoidProtection()) { - Set allowed = host.getAllowedVoidingModes(); - switch (clickData.mouseButton) { - case 0 -> host.setVoidingMode( - host.getVoidingMode() - .nextInCollection(allowed)); - case 1 -> host.setVoidingMode( - host.getVoidingMode() - .previousInCollection(allowed)); - } - widget.notifyTooltipChange(); - } - }) - .setPlayClickSound(host.supportsVoidProtection()) - .setBackground(() -> { - List ret = new ArrayList<>(); - ret.add(host.getVoidingMode().buttonTexture); - ret.add(host.getVoidingMode().buttonOverlay); - if (!host.supportsVoidProtection()) { - ret.add(GTUITextures.OVERLAY_BUTTON_FORBIDDEN); - } - return ret.toArray(new IDrawable[0]); - }) - .attachSyncer( - new FakeSyncWidget.IntegerSyncer( - () -> host.getVoidingMode() - .ordinal(), - val -> host.setVoidingMode(VoidingMode.fromOrdinal(val))), - builder) - .dynamicTooltip( - () -> Arrays.asList( - StatCollector.translateToLocal("GT5U.gui.button.voiding_mode"), - StatCollector.translateToLocal( - host.getVoidingMode() - .getTransKey()))) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setPos(getVoidingModeButtonPos()) - .setSize(16, 16); - if (!host.supportsVoidProtection()) { - button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); - } - return button; - } - - @Nonnull - protected Pos2d getInputSeparationButtonPos() { - return INPUT_SEPARATION_BUTTON_DEFAULT_POS; - } - - protected ButtonWidget createInputSeparationButton(IWidgetBuilder builder) { - ButtonWidget button = new ButtonWidget(); - button.setOnClick((clickData, widget) -> { - if (host.supportsInputSeparation()) { - host.setInputSeparation(!host.isInputSeparated()); - } - }) - .setPlayClickSound(host.supportsInputSeparation()) - .setBackground(() -> { - List ret = new ArrayList<>(); - if (host.isInputSeparated()) { - ret.add(GTUITextures.BUTTON_STANDARD_PRESSED); - if (host.supportsInputSeparation()) { - ret.add(GTUITextures.OVERLAY_BUTTON_INPUT_SEPARATION_ON); - } else { - ret.add(GTUITextures.OVERLAY_BUTTON_INPUT_SEPARATION_ON_DISABLED); - } - } else { - ret.add(GTUITextures.BUTTON_STANDARD); - if (host.supportsInputSeparation()) { - ret.add(GTUITextures.OVERLAY_BUTTON_INPUT_SEPARATION_OFF); - } else { - ret.add(GTUITextures.OVERLAY_BUTTON_INPUT_SEPARATION_OFF_DISABLED); - } - } - if (!host.supportsInputSeparation()) { - ret.add(GTUITextures.OVERLAY_BUTTON_FORBIDDEN); - } - return ret.toArray(new IDrawable[0]); - }) - .attachSyncer(new FakeSyncWidget.BooleanSyncer(host::isInputSeparated, host::setInputSeparation), builder) - .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.input_separation")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setPos(getInputSeparationButtonPos()) - .setSize(16, 16); - if (!host.supportsInputSeparation()) { - button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); - } - return button; - } - - @Nonnull - protected Pos2d getBatchModeButtonPos() { - return BATCH_MODE_BUTTON_DEFAULT_POS; - } - - protected ButtonWidget createBatchModeButton(IWidgetBuilder builder) { - ButtonWidget button = new ButtonWidget(); - button.setOnClick((clickData, widget) -> { - if (host.supportsBatchMode()) { - host.setBatchMode(!host.isBatchModeEnabled()); - } - }) - .setPlayClickSound(host.supportsBatchMode()) - .setBackground(() -> { - List ret = new ArrayList<>(); - if (host.isBatchModeEnabled()) { - ret.add(GTUITextures.BUTTON_STANDARD_PRESSED); - if (host.supportsBatchMode()) { - ret.add(GTUITextures.OVERLAY_BUTTON_BATCH_MODE_ON); - } else { - ret.add(GTUITextures.OVERLAY_BUTTON_BATCH_MODE_ON_DISABLED); - } - } else { - ret.add(GTUITextures.BUTTON_STANDARD); - if (host.supportsBatchMode()) { - ret.add(GTUITextures.OVERLAY_BUTTON_BATCH_MODE_OFF); - } else { - ret.add(GTUITextures.OVERLAY_BUTTON_BATCH_MODE_OFF_DISABLED); - } - } - if (!host.supportsBatchMode()) { - ret.add(GTUITextures.OVERLAY_BUTTON_FORBIDDEN); - } - return ret.toArray(new IDrawable[0]); - }) - .attachSyncer(new FakeSyncWidget.BooleanSyncer(host::isBatchModeEnabled, host::setBatchMode), builder) - .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.batch_mode")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setPos(getBatchModeButtonPos()) - .setSize(16, 16); - if (!host.supportsBatchMode()) { - button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); - } - return button; - } - - @Nonnull - protected Pos2d getRecipeLockingButtonPos() { - return RECIPE_LOCKING_BUTTON_DEFAULT_POS; - } - - protected ButtonWidget createLockToSingleRecipeButton(IWidgetBuilder builder) { - ButtonWidget button = new ButtonWidget(); - button.setOnClick((clickData, widget) -> { - if (host.supportsSingleRecipeLocking()) { - host.setRecipeLocking(!host.isRecipeLockingEnabled()); - } - }) - .setPlayClickSound(host.supportsSingleRecipeLocking()) - .setBackground(() -> { - List ret = new ArrayList<>(); - if (host.isRecipeLockingEnabled()) { - ret.add(GTUITextures.BUTTON_STANDARD_PRESSED); - if (host.supportsSingleRecipeLocking()) { - ret.add(GTUITextures.OVERLAY_BUTTON_RECIPE_LOCKED); - } else { - ret.add(GTUITextures.OVERLAY_BUTTON_RECIPE_LOCKED_DISABLED); - } - } else { - ret.add(GTUITextures.BUTTON_STANDARD); - if (host.supportsSingleRecipeLocking()) { - ret.add(GTUITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED); - } else { - ret.add(GTUITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED_DISABLED); - } - } - if (!host.supportsSingleRecipeLocking()) { - ret.add(GTUITextures.OVERLAY_BUTTON_FORBIDDEN); - } - return ret.toArray(new IDrawable[0]); - }) - .attachSyncer( - new FakeSyncWidget.BooleanSyncer(host::isRecipeLockingEnabled, host::setRecipeLocking), - builder) - .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.lock_recipe")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setPos(getRecipeLockingButtonPos()) - .setSize(16, 16); - if (!host.supportsSingleRecipeLocking()) { - button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); - } - return button; - } -} diff --git a/src/main/java/gregtech/common/gui/PartGUIProvider.java b/src/main/java/gregtech/common/gui/PartGUIProvider.java deleted file mode 100644 index 7600444f712..00000000000 --- a/src/main/java/gregtech/common/gui/PartGUIProvider.java +++ /dev/null @@ -1,33 +0,0 @@ -package gregtech.common.gui; - -import javax.annotation.Nonnull; - -import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; - -import gregtech.api.gui.GUIHost; -import gregtech.api.gui.GUIProvider; -import gregtech.api.logic.interfaces.FluidInventoryLogicHost; -import gregtech.api.logic.interfaces.ItemInventoryLogicHost; -import gregtech.api.logic.interfaces.PowerLogicHost; - -public class PartGUIProvider - extends GUIProvider { - - public PartGUIProvider(@Nonnull T host) { - super(host); - } - - @Override - protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'attachSynchHandlers'"); - } - - @Override - protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'addWidgets'"); - } - -} diff --git a/src/main/java/gregtech/common/items/ItemComb.java b/src/main/java/gregtech/common/items/ItemComb.java index 6313cabcc49..01a0c2c66e5 100644 --- a/src/main/java/gregtech/common/items/ItemComb.java +++ b/src/main/java/gregtech/common/items/ItemComb.java @@ -653,7 +653,7 @@ public void initCombsRecipes() { CombType.ENDDUST, new ItemStack[] { GTModHandler.getModItem(MagicBees.ID, "wax", 1L, 0), GTBees.propolis.getStackForType(PropolisType.End), GTBees.drop.getStackForType(DropType.ENDERGOO), - Materials.Endstone.getBlocks(4) }, + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Endstone, 1L) }, new int[] { 20 * 100, 15 * 100, 10 * 100, 100 * 100 }, Voltage.HV); addCentrifugeToItemStack( diff --git a/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputME.java b/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputME.java index fd7d291c29d..841739ffca7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputME.java +++ b/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputME.java @@ -122,13 +122,7 @@ public interface SharedItemGetter { private final GTUtility.ItemId itemId; public PatternSlot(ItemStack pattern, World world, SharedItemGetter getter) { - this.pattern = pattern; - this.patternDetails = ((ICraftingPatternItem) Objects.requireNonNull(pattern.getItem())) - .getPatternForItem(pattern, world); - this.itemInventory = new ArrayList<>(); - this.fluidInventory = new ArrayList<>(); - this.sharedItemGetter = getter; - this.itemId = GTUtility.ItemId.create(pattern); + this(pattern, null, world, getter); } public PatternSlot(ItemStack pattern, NBTTagCompound nbt, World world, SharedItemGetter getter) { @@ -139,6 +133,7 @@ public PatternSlot(ItemStack pattern, NBTTagCompound nbt, World world, SharedIte this.fluidInventory = new ArrayList<>(); this.sharedItemGetter = getter; this.itemId = GTUtility.ItemId.create(pattern); + if (nbt == null) return; NBTTagList inv = nbt.getTagList("inventory", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < inv.tagCount(); i++) { NBTTagCompound tagItemStack = inv.getCompoundTagAt(i); @@ -390,10 +385,10 @@ public MTEHatchCraftingInputME(int aID, String aName, String aNameRegional, bool aID, aName, aNameRegional, - supportFluids ? 11 : 6, + supportFluids ? 10 : 6, MAX_INV_COUNT, new String[] { "Advanced item input for Multiblocks", - "Hatch Tier: " + TIER_COLORS[supportFluids ? 11 : 6] + VN[supportFluids ? 11 : 6], + "Hatch Tier: " + TIER_COLORS[supportFluids ? 10 : 6] + VN[supportFluids ? 10 : 6], "Processes patterns directly from ME", supportFluids ? "It supports patterns including fluids" : "It does not support patterns including fluids", @@ -831,7 +826,7 @@ private void onPatternChange(int index, ItemStack newItem) { try { originalPattern.refund(getProxy(), getRequest()); for (ProcessingLogic pl : processingLogics) { - pl.removeEntryCraftingPatternRecipeCache(originalPattern); + pl.clearCraftingPatternRecipeCache(originalPattern); } } catch (GridAccessException ignored) {} internalInventory[index] = null; @@ -870,7 +865,7 @@ private void resetCraftingInputRecipeMap() { for (ProcessingLogic pl : processingLogics) { for (PatternSlot sl : internalInventory) { if (sl == null) continue; - pl.removeEntryCraftingPatternRecipeCache(sl); + pl.clearCraftingPatternRecipeCache(sl); } } } diff --git a/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputSlave.java b/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputSlave.java index 73216f46743..43db24f49b3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputSlave.java +++ b/src/main/java/gregtech/common/tileentities/machines/MTEHatchCraftingInputSlave.java @@ -1,5 +1,7 @@ package gregtech.common.tileentities.machines; +import static gregtech.api.enums.GTValues.TIER_COLORS; +import static gregtech.api.enums.GTValues.VN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_CRAFTING_INPUT_SLAVE; import java.util.ArrayList; @@ -42,9 +44,9 @@ public MTEHatchCraftingInputSlave(int aID, String aName, String aNameRegional) { aID, aName, aNameRegional, - 6, + 11, 0, - new String[] { "Proxy for Crafting Input Buffer/Bus", + new String[] { "Proxy for Crafting Input Buffer/Bus", "Hatch Tier: " + TIER_COLORS[11] + VN[11], "Link with Crafting Input Buffer/Bus using Data Stick to share inventory", "Left click on the Crafting Input Buffer/Bus, then right click on this block to link them", }); disableSort = true; diff --git a/src/main/java/gregtech/common/tileentities/machines/MTEHatchInputME.java b/src/main/java/gregtech/common/tileentities/machines/MTEHatchInputME.java index 5fc0156c851..5e7fd23d95e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/MTEHatchInputME.java +++ b/src/main/java/gregtech/common/tileentities/machines/MTEHatchInputME.java @@ -117,7 +117,7 @@ public class MTEHatchInputME extends MTEHatchInput implements IPowerChannelState protected static final FluidStack[] EMPTY_FLUID_STACK = new FluidStack[0]; public MTEHatchInputME(int aID, boolean autoPullAvailable, String aName, String aNameRegional) { - super(aID, aName, aNameRegional, autoPullAvailable ? 10 : 8, 1, getDescriptionArray(autoPullAvailable)); + super(aID, aName, aNameRegional, autoPullAvailable ? 9 : 8, 1, getDescriptionArray(autoPullAvailable)); this.autoPullAvailable = autoPullAvailable; } @@ -929,7 +929,7 @@ public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompou private static String[] getDescriptionArray(boolean autoPullAvailable) { List strings = new ArrayList<>(8); strings.add("Advanced fluid input for Multiblocks"); - strings.add("Hatch Tier: " + TIER_COLORS[autoPullAvailable ? 10 : 8] + VN[autoPullAvailable ? 10 : 8]); + strings.add("Hatch Tier: " + TIER_COLORS[autoPullAvailable ? 9 : 8] + VN[autoPullAvailable ? 9 : 8]); strings.add("Retrieves directly from ME"); strings.add("Keeps 16 fluid types in stock"); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEIndustrialElectromagneticSeparator.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEIndustrialElectromagneticSeparator.java index b2954f15e05..38ae848b060 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEIndustrialElectromagneticSeparator.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEIndustrialElectromagneticSeparator.java @@ -408,7 +408,7 @@ public boolean supportsSingleRecipeLocking() { @Override protected void setProcessingLogicPower(ProcessingLogic logic) { // This fix works for normal energy hatches, preventing over-paralleling with 1 energy hatch - // However, it does not work with multiamp. MuTEs can't come soon enough. + // However, it does not work with multiamp. if (mExoticEnergyHatches.isEmpty()) { logic.setAvailableVoltage(GTUtility.roundUpVoltage(this.getMaxInputVoltage())); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbine.java index aac42f28c4f..b929647d127 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeTurbine.java @@ -45,6 +45,7 @@ import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.IHatchElement; import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.INEIPreviewModifier; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.MetaGeneratedTool; import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; @@ -58,7 +59,7 @@ import gregtech.common.items.MetaGeneratedTool01; public abstract class MTELargeTurbine extends MTEEnhancedMultiBlockBase - implements ISurvivalConstructable { + implements ISurvivalConstructable, INEIPreviewModifier { private static final String STRUCTURE_PIECE_MAIN = "main"; private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue<>() { @@ -148,18 +149,6 @@ protected IHatchElement[] getHatchElements() { return new IHatchElement[] { Maintenance, InputHatch, OutputHatch, OutputBus, InputBus, Muffler }; } - @Override - public boolean checkStructure(boolean aForceReset, IGregTechTileEntity aBaseMetaTileEntity) { - boolean f = super.checkStructure(aForceReset, aBaseMetaTileEntity); - if (f && getBaseMetaTileEntity().isServerSide()) { - // while is this a client side field, blockrenderer will reuse the server world for client side rendering - // so we must set it as well... - mFormed = true; - return true; - } - return f; - } - @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { return checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 1) && mMaintenanceHatches.size() == 1 @@ -449,4 +438,9 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu protected SoundResource getActivitySoundLoop() { return SoundResource.GT_MACHINES_LARGE_TURBINES_LOOP; } + + @Override + public void onPreviewStructureComplete(@NotNull ItemStack trigger) { + mFormed = true; + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiSolidifier.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiSolidifier.java index ef409934211..6c071c74b5c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiSolidifier.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiSolidifier.java @@ -21,6 +21,8 @@ import java.util.Collection; import java.util.List; +import javax.annotation.Nonnull; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -32,7 +34,6 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.ArrayUtils; import org.jetbrains.annotations.NotNull; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -52,7 +53,6 @@ import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; import gregtech.api.metatileentity.implementations.MTEHatchEnergy; import gregtech.api.metatileentity.implementations.MTEHatchInput; -import gregtech.api.metatileentity.implementations.MTEHatchInputBus; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.RecipeMaps; import gregtech.api.recipe.check.CheckRecipeResult; @@ -62,9 +62,6 @@ import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.common.blocks.BlockCasings10; -import gregtech.common.tileentities.machines.IDualInputHatch; -import gregtech.common.tileentities.machines.IDualInputInventory; -import gregtech.common.tileentities.machines.MTEHatchCraftingInputME; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchSolidifier; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; @@ -294,12 +291,8 @@ protected ProcessingLogic createProcessingLogic() { // Override is needed so that switching recipe maps does not stop recipe locking. @Override - protected RecipeMap preProcess() { + protected RecipeMap getCurrentRecipeMap() { lastRecipeMap = currentRecipeMap; - - if (maxParallelSupplier != null) { - maxParallel = maxParallelSupplier.get(); - } return currentRecipeMap; } @@ -430,35 +423,9 @@ public boolean supportsBatchMode() { return true; } - @NotNull + @Nonnull @Override - protected CheckRecipeResult doCheckRecipe() { - CheckRecipeResult result = CheckRecipeResultRegistry.NO_RECIPE; - - // check crafting input hatches first - for (IDualInputHatch dualInputHatch : mDualInputHatches) { - ItemStack[] sharedItems = dualInputHatch.getSharedItems(); - for (var it = dualInputHatch.inventories(); it.hasNext();) { - IDualInputInventory slot = it.next(); - - if (!slot.isEmpty() && processingLogic.craftingPatternHandler(slot)) { - - processingLogic.setInputItems(ArrayUtils.addAll(sharedItems, slot.getItemInputs())); - processingLogic.setInputFluids(slot.getFluidInputs()); - - CheckRecipeResult foundResult = processingLogic.process(); - if (foundResult.wasSuccessful()) { - return foundResult; - } - if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { - // Recipe failed in interesting way, so remember that and continue searching - result = foundResult; - } - } - } - } - - // Logic for GT_MetaTileEntity_Hatch_Solidifier + protected CheckRecipeResult checkRecipeForCustomHatches(CheckRecipeResult lastResult) { for (MTEHatchInput solidifierHatch : mInputHatches) { if (solidifierHatch instanceof MTEHatchSolidifier hatch) { ItemStack mold = hatch.getMold(); @@ -468,7 +435,7 @@ protected CheckRecipeResult doCheckRecipe() { List inputItems = new ArrayList<>(); inputItems.add(mold); - processingLogic.setInputItems(inputItems.toArray(new ItemStack[0])); + processingLogic.setInputItems(inputItems); processingLogic.setInputFluids(fluid); CheckRecipeResult foundResult = processingLogic.process(); @@ -477,39 +444,13 @@ protected CheckRecipeResult doCheckRecipe() { } if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { // Recipe failed in interesting way, so remember that and continue searching - result = foundResult; + lastResult = foundResult; } } } } processingLogic.clear(); - processingLogic.setInputFluids(getStoredFluids()); - // Default logic - for (MTEHatchInputBus bus : mInputBusses) { - if (bus instanceof MTEHatchCraftingInputME) { - continue; - } - List inputItems = new ArrayList<>(); - for (int i = bus.getSizeInventory() - 1; i >= 0; i--) { - ItemStack stored = bus.getStackInSlot(i); - if (stored != null) { - inputItems.add(stored); - } - } - if (canUseControllerSlotForRecipe() && getControllerSlot() != null) { - inputItems.add(getControllerSlot()); - } - processingLogic.setInputItems(inputItems.toArray(new ItemStack[0])); - CheckRecipeResult foundResult = processingLogic.process(); - if (foundResult.wasSuccessful()) { - return foundResult; - } - if (foundResult != CheckRecipeResultRegistry.NO_RECIPE) { - // Recipe failed in interesting way, so remember that and continue searching - result = foundResult; - } - } - return result; + return lastResult; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java index 11ecfbddb60..caa163f387b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPCBFactory.java @@ -59,14 +59,13 @@ import com.gtnewhorizons.modularui.common.widget.TextWidget; import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; -import blockrenderer6343.client.world.ClientFakePlayer; import gregtech.api.GregTechAPI; import gregtech.api.enums.Materials; -import gregtech.api.enums.Mods; import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.gui.modularui.GTUITextures; import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.INEIPreviewModifier; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -97,7 +96,8 @@ import gregtech.common.blocks.BlockCasings8; @SuppressWarnings("SpellCheckingInspection") -public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase implements ISurvivalConstructable { +public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase + implements ISurvivalConstructable, INEIPreviewModifier { private static final String tier1 = "tier1"; private static final String tier2 = "tier2"; @@ -332,19 +332,6 @@ public void construct(ItemStack stackSize, boolean hintsOnly) { public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { int built = 0; - if (Mods.BlockRenderer6343.isModLoaded() && env.getActor() instanceof ClientFakePlayer) { - if (stackSize.stackSize < 3) { - built = survivialBuildPiece(tier1, stackSize, 3, 5, 0, elementBudget, env, false, true); - if (built >= 0) return built; - if (stackSize.stackSize == 2) { - built = survivialBuildPiece(tier2, stackSize, 7, 6, 2, elementBudget, env, false, true); - } - } else { - built = survivialBuildPiece(tier3, stackSize, 3, 21, 0, elementBudget, env, false, true); - } - return built; - } - if (mMachine) return -1; if (mSetTier < 3) { built += survivialBuildPiece(tier1, stackSize, 3, 5, 0, elementBudget, env, false, true); @@ -1357,4 +1344,9 @@ public boolean supportsSingleRecipeLocking() { public boolean supportsBatchMode() { return true; } + + @Override + public void onPreviewConstruct(@NotNull ItemStack trigger) { + mSetTier = trigger.stackSize; + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTETranscendentPlasmaMixer.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTETranscendentPlasmaMixer.java index 52186e1d7d3..8953318e200 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTETranscendentPlasmaMixer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTETranscendentPlasmaMixer.java @@ -210,7 +210,7 @@ protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { return CheckRecipeResultRegistry.insufficientStartupPower(finalConsumption); } // Energy consumed all at once from wireless net. - setCalculatedEut(0); + overwriteCalculatedEut(0); return CheckRecipeResultRegistry.SUCCESSFUL; } diff --git a/src/main/java/gregtech/common/tileentities/storage/MTEDigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/MTEDigitalChestBase.java index 274856742de..e6f274b8e5b 100644 --- a/src/main/java/gregtech/common/tileentities/storage/MTEDigitalChestBase.java +++ b/src/main/java/gregtech/common/tileentities/storage/MTEDigitalChestBase.java @@ -62,7 +62,7 @@ public MTEDigitalChestBase(int aID, String aName, String aNameRegional, int aTie aNameRegional, aTier, 3, - new String[] { "This Chest stores " + GTUtility.formatNumbers(commonSizeCompute(aTier)) + " Blocks", + new String[] { "Stores " + GTUtility.formatNumbers(commonSizeCompute(aTier)) + " items", "Use a screwdriver to enable", "voiding items on overflow", "Will keep its contents when harvested", }); } diff --git a/src/main/java/gregtech/loaders/postload/recipes/PlasmaForgeRecipes.java b/src/main/java/gregtech/loaders/postload/recipes/PlasmaForgeRecipes.java index 478e0c0d97b..be32db7050c 100644 --- a/src/main/java/gregtech/loaders/postload/recipes/PlasmaForgeRecipes.java +++ b/src/main/java/gregtech/loaders/postload/recipes/PlasmaForgeRecipes.java @@ -27,6 +27,98 @@ public class PlasmaForgeRecipes implements Runnable { @Override public void run() { + // Dimensionally transcendent plasma forge recipes. + // Ordered so that recipes using higher tier catalysts are prioritized. + + { + // Dimensionally Shifted Superfluid + + Fluid celestialTungstenPlasma = MaterialsElements.STANDALONE.CELESTIAL_TUNGSTEN.getPlasma(); + + // Tier 5 + // Best recipe, unlocks with Stellar Catalyst. + // Quadruples the cost of everything except for Metastable and Celestial, which are only doubled, + // but gives 4x the output. + GTValues.RA.stdBuilder() + .itemInputs() + .fluidInputs( + Materials.StableBaryonicMatter.getFluid(8000), + GGMaterial.metastableOganesson.getMolten(144 * 4), + Materials.Grade8PurifiedWater.getFluid(12800), + new FluidStack(celestialTungstenPlasma, 96 * 144), + Materials.RadoxHeavy.getFluid(32000), + MaterialsUEVplus.ExcitedDTSC.getFluid(2000)) + .fluidOutputs( + MaterialsUEVplus.DimensionallyShiftedSuperfluid.getFluid(360000), + MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(4000)) + .duration(7 * SECONDS + 10 * TICKS) + .eut((int) TierEU.RECIPE_UXV) + .metadata(COIL_HEAT, 13500) + .addTo(plasmaForgeRecipes); + + // Tier 4 + // Better recipe, unlocks with Eternal coil. + // Doubles the cost across the board, but outputs 3x more. + // Switches to Heavy Radox, which can be mass-produced with the QFT. + GTValues.RA.stdBuilder() + .itemInputs() + .fluidInputs( + Materials.StableBaryonicMatter.getFluid(2000), + GGMaterial.metastableOganesson.getMolten(144 * 2), + Materials.Grade8PurifiedWater.getFluid(3200), + new FluidStack(celestialTungstenPlasma, 48 * 144), + Materials.RadoxHeavy.getFluid(4000), + MaterialsUEVplus.ExcitedDTEC.getFluid(2000)) + .fluidOutputs( + MaterialsUEVplus.DimensionallyShiftedSuperfluid.getFluid(90000), + MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(2000)) + .duration(30 * SECONDS) + .eut((int) TierEU.RECIPE_UMV) + .metadata(COIL_HEAT, 13500) + .addTo(plasmaForgeRecipes); + + // Tier 3 + // Better recipe, unlocks with Hypogen coil. + // This recipe takes UMV power but processes 4x input and output as the original recipe, making it a free + // POC + // over the original recipe. Only increases the cost of baryonic and water, making the ratio much cheaper. + GTValues.RA.stdBuilder() + .itemInputs() + .fluidInputs( + Materials.StableBaryonicMatter.getFluid(1000), + GGMaterial.metastableOganesson.getMolten(144), + Materials.Grade8PurifiedWater.getFluid(1600), + new FluidStack(celestialTungstenPlasma, 24 * 144), + Materials.RadoxSuperHeavy.getFluid(2000), + MaterialsUEVplus.ExcitedDTRC.getFluid(2000)) + .fluidOutputs( + MaterialsUEVplus.DimensionallyShiftedSuperfluid.getFluid(30000), + MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(1000)) + .duration(30 * SECONDS) + .eut((int) TierEU.RECIPE_UMV) + .metadata(COIL_HEAT, 12600) + .addTo(plasmaForgeRecipes); + + // Tier 2 + // First recipe using AwDr coil and super heavy radox + GTValues.RA.stdBuilder() + .itemInputs() + .fluidInputs( + Materials.StableBaryonicMatter.getFluid(250), + GGMaterial.metastableOganesson.getMolten(144), + Materials.Grade8PurifiedWater.getFluid(400), + new FluidStack(celestialTungstenPlasma, 24 * 144), + Materials.RadoxSuperHeavy.getFluid(2000), + MaterialsUEVplus.ExcitedDTPC.getFluid(1000)) + .fluidOutputs( + MaterialsUEVplus.DimensionallyShiftedSuperfluid.getFluid(7500), + MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(250)) + .duration(30 * SECONDS) + .eut((int) TierEU.RECIPE_UIV) + .metadata(COIL_HEAT, 10800) + .addTo(plasmaForgeRecipes); + } + // Giga chad trophy. GTValues.RA.stdBuilder() .itemInputs( @@ -73,87 +165,5 @@ public void run() { .metadata(COIL_HEAT, 12600) .addTo(plasmaForgeRecipes); } - - Fluid celestialTungstenPlasma = MaterialsElements.STANDALONE.CELESTIAL_TUNGSTEN.getPlasma(); - - // Dimensionally shifted superfluid - - // First recipe using AwDr coil and super heavy radox - GTValues.RA.stdBuilder() - .itemInputs() - .fluidInputs( - Materials.StableBaryonicMatter.getFluid(250), - GGMaterial.metastableOganesson.getMolten(144), - Materials.Grade8PurifiedWater.getFluid(400), - new FluidStack(celestialTungstenPlasma, 24 * 144), - Materials.RadoxSuperHeavy.getFluid(2000), - MaterialsUEVplus.ExcitedDTPC.getFluid(1000)) - .fluidOutputs( - MaterialsUEVplus.DimensionallyShiftedSuperfluid.getFluid(7500), - MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(250)) - .duration(30 * SECONDS) - .eut((int) TierEU.RECIPE_UIV) - .metadata(COIL_HEAT, 10800) - .addTo(plasmaForgeRecipes); - - // Better recipe, unlocks with Hypogen coil. - // This recipe takes UMV power but processes 4x input and output as the original recipe, making it a free POC - // over the original recipe. Only increases the cost of baryonic and water, making the ratio much cheaper. - GTValues.RA.stdBuilder() - .itemInputs() - .fluidInputs( - Materials.StableBaryonicMatter.getFluid(1000), - GGMaterial.metastableOganesson.getMolten(144), - Materials.Grade8PurifiedWater.getFluid(1600), - new FluidStack(celestialTungstenPlasma, 24 * 144), - Materials.RadoxSuperHeavy.getFluid(2000), - MaterialsUEVplus.ExcitedDTRC.getFluid(2000)) - .fluidOutputs( - MaterialsUEVplus.DimensionallyShiftedSuperfluid.getFluid(30000), - MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(1000)) - .duration(30 * SECONDS) - .eut((int) TierEU.RECIPE_UMV) - .metadata(COIL_HEAT, 12600) - .addTo(plasmaForgeRecipes); - - // Better recipe, unlocks with Eternal coil. - // Doubles the cost across the board, but outputs 3x more. - // Switches to Heavy Radox, which can be mass-produced with the QFT. - GTValues.RA.stdBuilder() - .itemInputs() - .fluidInputs( - Materials.StableBaryonicMatter.getFluid(2000), - GGMaterial.metastableOganesson.getMolten(144 * 2), - Materials.Grade8PurifiedWater.getFluid(3200), - new FluidStack(celestialTungstenPlasma, 48 * 144), - Materials.RadoxHeavy.getFluid(4000), - MaterialsUEVplus.ExcitedDTEC.getFluid(2000)) - .fluidOutputs( - MaterialsUEVplus.DimensionallyShiftedSuperfluid.getFluid(90000), - MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(2000)) - .duration(30 * SECONDS) - .eut((int) TierEU.RECIPE_UMV) - .metadata(COIL_HEAT, 13500) - .addTo(plasmaForgeRecipes); - - // Best recipe, unlocks with Stellar Catalyst. - // Quadruples the cost of everything except for Metastable and Celestial, which are only doubled, - // but gives 4x the output. - GTValues.RA.stdBuilder() - .itemInputs() - .fluidInputs( - Materials.StableBaryonicMatter.getFluid(8000), - GGMaterial.metastableOganesson.getMolten(144 * 4), - Materials.Grade8PurifiedWater.getFluid(12800), - new FluidStack(celestialTungstenPlasma, 96 * 144), - Materials.RadoxHeavy.getFluid(32000), - MaterialsUEVplus.ExcitedDTSC.getFluid(2000)) - .fluidOutputs( - MaterialsUEVplus.DimensionallyShiftedSuperfluid.getFluid(360000), - MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(4000)) - .duration(7 * SECONDS + 10 * TICKS) - .eut((int) TierEU.RECIPE_UXV) - .metadata(COIL_HEAT, 13500) - .addTo(plasmaForgeRecipes); } } diff --git a/src/main/java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java index efe18ed70c8..1ad5c75c1f2 100644 --- a/src/main/java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java +++ b/src/main/java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java @@ -16,12 +16,13 @@ import net.minecraft.world.World; import baubles.api.BaubleType; +import cofh.api.energy.IEnergyContainerItem; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.GTValues; +import gregtech.common.config.OPStuff; import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; @@ -39,7 +40,7 @@ public BatteryPackBaseBauble(int tier) { @SideOnly(Side.CLIENT) @Override - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { ItemStack itemStack = new ItemStack(this, 1); ItemStack charged; if (this.getEmptyItem(itemStack) == this) { @@ -60,31 +61,14 @@ public void onUpdate(final ItemStack itemStack, final World worldObj, final Enti super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); } - @Override - public boolean canProvideEnergy(final ItemStack itemStack) { - double aItemCharge = ElectricItem.manager.getCharge(itemStack); - return aItemCharge > 0; - } - @Override public String getItemStackDisplayName(final ItemStack p_77653_1_) { return (EnumChatFormatting.BLUE + super.getItemStackDisplayName(p_77653_1_) + EnumChatFormatting.GRAY); } @Override - public boolean showDurabilityBar(final ItemStack stack) { - return true; - } - - public int secondsLeft(final ItemStack stack) { - double r = 0; - r = this.getCharge(stack) / (10000 * 20); - return (int) MathUtils.decimalRounding(r); - } - - @SuppressWarnings("unchecked") - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, + final boolean bool) { list.add(""); String aString1 = StatCollector.translateToLocal("GTPP.battpack.tooltip.1"); String aString2 = StatCollector.translateToLocal("GTPP.battpack.tooltip.2"); @@ -122,110 +106,86 @@ public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { return true; } - @Override // TODO + @Override public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) {} - @Override // TODO + @Override public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) {} - @Override // TODO - public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayer) { - if (!aPlayer.worldObj.isRemote) { - + @Override + public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aLivingBase) { + if (!aLivingBase.worldObj.isRemote) { try { - if (this.getCharge(aBaubleStack) >= getTransferLimit(aBaubleStack)) { - // Try To Iterate Armour Slots of Player - if (aPlayer instanceof EntityPlayer) { - - // amour - for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.armorInventory) { - if (aInvStack != null) { - if (aInvStack == aBaubleStack) { - continue; - } - if (ChargingHelper.isItemValid(aInvStack)) { - double aTransferRate; - final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); - if (electricItem != null) { - aTransferRate = electricItem.getTransferLimit(aInvStack); - double aItemCharge = ElectricItem.manager.getCharge(aInvStack); - if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { - if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { - if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { - if (ElectricItem.manager.getCharge(aInvStack) - <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { - double d = ElectricItem.manager - .charge(aInvStack, aTransferRate * 16, mTier, false, true); - if (d > 0) { - d = ElectricItem.manager.charge( - aInvStack, - aTransferRate * 16, - mTier, - false, - false); - ElectricItem.manager - .discharge(aBaubleStack, d, mTier, false, true, false); - } - } - } - } - - } + if (aLivingBase instanceof EntityPlayer aPlayer) { - } - } - } - if (!(this.getCharge(aBaubleStack) > 0)) { - break; - } - } + // Armor + ItemStack[] inv = aPlayer.inventory.armorInventory; + chargeInventory(inv, inv.length, aBaubleStack); // Hotbar Slots - int aSlotCounter = 0; - for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.mainInventory) { - if (aSlotCounter > (InventoryPlayer.getHotbarSize() - 1)) { - break; - } - aSlotCounter++; - if (aInvStack != null) { - if (aInvStack == aBaubleStack) { - continue; - } - if (ChargingHelper.isItemValid(aInvStack)) { - double aTransferRate = 0; - final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); - if (electricItem != null) { - aTransferRate = electricItem.getTransferLimit(aInvStack); - double aItemCharge = ElectricItem.manager.getCharge(aInvStack); - if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { - if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { - if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { - if (ElectricItem.manager.getCharge(aInvStack) - <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { - double d = ElectricItem.manager - .charge(aInvStack, aTransferRate, mTier, false, true); - if (d > 0) { - d = ElectricItem.manager - .charge(aInvStack, aTransferRate, mTier, false, false); - ElectricItem.manager - .discharge(aBaubleStack, d, mTier, false, true, false); - } - } - } - } + inv = aPlayer.inventory.mainInventory; + chargeInventory(inv, InventoryPlayer.getHotbarSize(), aBaubleStack); + } + } + } catch (Throwable ignored) {} + } + } + private void chargeInventory(ItemStack[] inventory, int endIndex, ItemStack aBaubleStack) { + for (int i = 0; i < endIndex && i < inventory.length; i++) { + ItemStack aInvStack = inventory[i]; + if (aInvStack != null && aInvStack != aBaubleStack) { + Item aItem = aInvStack.getItem(); + + if (ChargingHelper.isItemValid(aInvStack)) { + // IElectricItem (EU) + final IElectricItem electricItem = (IElectricItem) aItem; + if (electricItem != null) { + double aTransferRate = electricItem.getTransferLimit(aInvStack); + double aItemCharge = ElectricItem.manager.getCharge(aInvStack); + if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { + if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { + if (ElectricItem.manager.getCharge(aInvStack) + <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + double d = ElectricItem.manager + .charge(aInvStack, aTransferRate * 16, mTier, false, true); + if (d > 0) { + d = ElectricItem.manager + .charge(aInvStack, aTransferRate * 16, mTier, false, false); + ElectricItem.manager.discharge(aBaubleStack, d, mTier, false, true, false); } } } } - if (!(this.getCharge(aBaubleStack) > 0)) { - break; - } + } + } + } else if (OPStuff.outputRF) { + // IEnergyContainerItem (RF) + if (aItem instanceof IEnergyContainerItem energyItem) { + int aItemCharge = energyItem.getEnergyStored(aInvStack); + int aItemMaxCharge = energyItem.getMaxEnergyStored(aInvStack); + double aBaubleCharge = ElectricItem.manager.getCharge(aBaubleStack); + if (aItemCharge >= 0 && aItemCharge < aItemMaxCharge && aBaubleCharge > 0) { + int aMaxChargeAmount = aItemMaxCharge - aItemCharge; + double aMaxChargeAmountInEU = Math + .ceil(aMaxChargeAmount * 100.0D / OPStuff.howMuchRFWith100EUInInput); + double aActualChargeInEU = Math.min(aBaubleCharge, aMaxChargeAmountInEU); + int aActualCharge = (int) Math + .floor(aActualChargeInEU * OPStuff.howMuchRFWith100EUInInput / 100); + + int aCharged = energyItem.receiveEnergy(aInvStack, aActualCharge, false); + double aDischarge = Math.ceil(aCharged * 100.0D / OPStuff.howMuchRFWith100EUInInput); + ElectricItem.manager.discharge(aBaubleStack, aDischarge, mTier, false, true, false); } } } - } catch (Throwable ignored) {} + } + + if (this.getCharge(aBaubleStack) <= 0) { + break; + } } } diff --git a/src/main/java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java index 5717a1e9260..9756b98b0e9 100644 --- a/src/main/java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java +++ b/src/main/java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java @@ -56,10 +56,9 @@ public ElectricBaseBauble(BaubleType aType, int aTier, double aMaxEU, String aUn public abstract String getTextureNameForBauble(); - @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) @Override - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { ItemStack itemStack = new ItemStack(this, 1); ItemStack charged; if (this.getEmptyItem(itemStack) == this) { @@ -125,9 +124,9 @@ public boolean showDurabilityBar(final ItemStack stack) { return true; } - @SuppressWarnings("unchecked") @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, + final boolean bool) { list.add(""); String aEuInfo = StatCollector.translateToLocal("GTPP.info.euInfo"); String aTier = StatCollector.translateToLocal("GTPP.machines.tier"); diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/GenericChem.java b/src/main/java/gtPlusPlus/core/item/chemistry/GenericChem.java index 9150bf53a35..aeeaad5c037 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/GenericChem.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/GenericChem.java @@ -21,7 +21,6 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.TextureSet; import gregtech.api.enums.TierEU; import gregtech.api.util.GTModHandler; import gregtech.api.util.GTOreDictUnificator; @@ -30,13 +29,8 @@ import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.item.circuit.GTPPIntegratedCircuitItem; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.material.MaterialMisc; -import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.material.MaterialsElements; -import gtPlusPlus.core.material.MaterialsOther; -import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -45,28 +39,6 @@ public class GenericChem extends ItemPackage { - /** - * Materials - */ - - // Refined PTFE - public static final Material TEFLON = new Material( - "Teflon", - MaterialState.SOLID, - TextureSet.SET_SHINY, - new short[] { 75, 45, 75 }, - 330, - 640, - -1, - -1, - false, - null, - 0, - new MaterialStack(MaterialsOther.PTFE, 75), - new MaterialStack(MaterialsOther.PLASTIC, 15), - new MaterialStack(MaterialsElements.getInstance().CARBON, 5), - new MaterialStack(MaterialsElements.getInstance().SODIUM, 5)); - /** * Fluids */ @@ -140,8 +112,6 @@ public class GenericChem extends ItemPackage { @Override public void items() { - MaterialGenerator.generate(TEFLON, false); - mGenericChemItem1 = new ItemGenericChemBase(); mAdvancedCircuit = new GTPPIntegratedCircuitItem("T3RecipeSelector", "science/general/AdvancedCircuit"); GregtechItemList.Circuit_T3RecipeSelector.set(mAdvancedCircuit); diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/items/MBItemFrame.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/items/MBItemFrame.java index 54b003386e8..8264817d166 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/items/MBItemFrame.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/items/MBItemFrame.java @@ -92,11 +92,6 @@ public boolean isBookEnchantable(final ItemStack itemstack1, final ItemStack ite return false; } - @Override - public boolean isRepairable() { - return false; - } - public float getTerritoryModifier(final IBeeGenome genome, final float currentModifier) { return this.type.getTerritoryModifier(genome, currentModifier); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCentrifuge.java index 365a2595547..19895c83742 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCentrifuge.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/MTEIndustrialCentrifuge.java @@ -21,6 +21,8 @@ import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.util.ForgeDirection; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -28,6 +30,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.INEIPreviewModifier; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.logic.ProcessingLogic; @@ -43,7 +46,7 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; public class MTEIndustrialCentrifuge extends GTPPMultiBlockBase - implements ISurvivalConstructable { + implements ISurvivalConstructable, INEIPreviewModifier { private boolean mIsAnimated; private int mCasing; @@ -128,18 +131,6 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); } - @Override - public boolean checkStructure(boolean aForceReset, IGregTechTileEntity aBaseMetaTileEntity) { - boolean f = super.checkStructure(aForceReset, aBaseMetaTileEntity); - if (f && getBaseMetaTileEntity().isServerSide()) { - // while is this a client side field, blockrenderer will reuse the server world for client side rendering - // so we must set it as well... - mFormed = true; - return true; - } - return f; - } - @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mCasing = 0; @@ -263,4 +254,9 @@ public void onValueUpdate(byte aValue) { public byte getUpdateData() { return (byte) ((mMachine ? 1 : 0)); } + + @Override + public void onPreviewStructureComplete(@NotNull ItemStack trigger) { + mFormed = true; + } } diff --git a/src/main/java/gtnhlanth/common/item/ItemPhotolithographicMask.java b/src/main/java/gtnhlanth/common/item/ItemPhotolithographicMask.java index c96212c8e61..6ef577aa4e9 100644 --- a/src/main/java/gtnhlanth/common/item/ItemPhotolithographicMask.java +++ b/src/main/java/gtnhlanth/common/item/ItemPhotolithographicMask.java @@ -10,22 +10,20 @@ public class ItemPhotolithographicMask extends Item implements ICanFocus { - private final String name; private final String descSpectrum; public ItemPhotolithographicMask(String name, int maxDamage, String descSpectrum) { super(); - this.name = name; this.descSpectrum = descSpectrum; this.setUnlocalizedName("photomask." + name); this.setMaxStackSize(1); this.setMaxDamage(maxDamage); + this.setNoRepair(); this.setTextureName(Tags.MODID + ":photomask/" + name); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { if (!this.descSpectrum.isEmpty()) list.add("Suitable for the " + this.descSpectrum + " segment of the electromagnetic spectrum and lower"); diff --git a/src/main/java/tectech/TecTech.java b/src/main/java/tectech/TecTech.java index 1c30594c0f1..8027aee6d35 100644 --- a/src/main/java/tectech/TecTech.java +++ b/src/main/java/tectech/TecTech.java @@ -18,7 +18,6 @@ import tectech.loader.ConfigHandler; import tectech.loader.MainLoader; import tectech.loader.gui.CreativeTabTecTech; -import tectech.loader.thing.MuTeLoader; import tectech.mechanics.enderStorage.EnderWorldSavedData; import tectech.proxy.CommonProxy; import tectech.recipe.EyeOfHarmonyRecipeStorage; @@ -81,7 +80,6 @@ public void PreLoad(FMLPreInitializationEvent PreEvent) { TecTechRecipeMaps.init(); MainLoader.preLoad(); - new MuTeLoader().run(); } @Mod.EventHandler diff --git a/src/main/java/tectech/loader/thing/MachineLoader.java b/src/main/java/tectech/loader/thing/MachineLoader.java index 6b181bf124b..b0897e0d520 100644 --- a/src/main/java/tectech/loader/thing/MachineLoader.java +++ b/src/main/java/tectech/loader/thing/MachineLoader.java @@ -2322,13 +2322,13 @@ public void run() { WirelessAssemblylineSlaveConnector.ID, "hatch.datainass.wireless.tier.12", "Wireless Assembly line Reception Connector", - 12).getStackForm(1L)); + 10).getStackForm(1L)); dataOutAss_Wireless_Hatch.set( new MTEHatchWirelessDataItemsOutput( WirelessDataBankMasterConnector.ID, "hatch.dataoutass.wireless.tier.12", "Wireless Data Bank Transmission Connector", - 12).getStackForm(1L)); + 10).getStackForm(1L)); rack_Hatch.set(new MTEHatchRack(ComputerRack.ID, "hatch.rack.tier.08", "Computer Rack", 8).getStackForm(1L)); holder_Hatch.set( new MTEHatchObjectHolder(ObjectHolder.ID, "hatch.holder.tier.09", "Object Holder", 8).getStackForm(1L)); @@ -2506,7 +2506,7 @@ public void run() { AutoTapingMaintenanceHatch.ID, "debug.tt.maintenance", "Auto-Taping Maintenance Hatch", - 14).getStackForm(1L)); + 8).getStackForm(1L)); Machine_DebugGenny.set( new MTEDebugPowerGenerator(DebugPowerGenerator.ID, "debug.tt.genny", "Debug Power Generator", 14) .getStackForm(1L)); @@ -2515,7 +2515,7 @@ public void run() { .getStackForm(1L)); UnusedStuff.set(new ItemStack(Blocks.air)); hatch_CreativeUncertainty.set( - new MTEHatchCreativeUncertainty(UncertaintyResolution.ID, "debug.tt.certain", "Uncertainty Resolution", 14) + new MTEHatchCreativeUncertainty(UncertaintyResolution.ID, "debug.tt.certain", "Uncertainty Resolution", 11) .getStackForm(1)); // =================================================================================================== diff --git a/src/main/java/tectech/loader/thing/MuTeLoader.java b/src/main/java/tectech/loader/thing/MuTeLoader.java deleted file mode 100644 index 74c51f1bf16..00000000000 --- a/src/main/java/tectech/loader/thing/MuTeLoader.java +++ /dev/null @@ -1,21 +0,0 @@ -package tectech.loader.thing; - -import tectech.TecTech; - -public class MuTeLoader implements Runnable { - - @Override - public void run() { - TecTech.LOGGER.info("TecTech: Registering MultiTileEntities"); - registerMachines(); - registerCasings(); - } - - private static void registerMachines() { - - } - - private static void registerCasings() { - - } -} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDynamoTunnel.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDynamoTunnel.java index 703a269bf0d..314d52ad841 100644 --- a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDynamoTunnel.java +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDynamoTunnel.java @@ -21,8 +21,6 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.PowerLogic; -import gregtech.api.logic.interfaces.PowerLogicHost; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.util.GTUtility; import tectech.mechanics.pipe.IConnectsToEnergyTunnel; @@ -235,15 +233,6 @@ private void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { return; } } else { - if (tGTTileEntity instanceof PowerLogicHost) { - PowerLogic logic = ((PowerLogicHost) tGTTileEntity).getPowerLogic(opposite); - if (logic == null || !logic.canUseLaser() || opposite != tGTTileEntity.getFrontFacing()) { - return; - } - - long ampsUsed = logic.injectEnergy(maxEUOutput(), Amperes); - setEUVar(aBaseMetaTileEntity.getStoredEU() - ampsUsed * maxEUOutput()); - } return; } } else { diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java index e14a40f8631..71e68ae91b7 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java @@ -181,7 +181,7 @@ protected CheckRecipeResult onRecipeStart(@NotNull GTRecipe recipe) { addToPowerTally(powerForRecipe); addToRecipeTally(calculatedParallels); - setCalculatedEut(0); + overwriteCalculatedEut(0); plasmaRecipe = null; recipeInProgress = false; return CheckRecipeResultRegistry.SUCCESSFUL; diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 314cf9919c9..f97c7c55fd4 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -88,12 +88,10 @@ import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; -import blockrenderer6343.client.world.ClientFakePlayer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Materials; import gregtech.api.enums.MaterialsUEVplus; -import gregtech.api.enums.Mods; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; @@ -238,35 +236,6 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu int realBudget = elementBudget >= 1000 ? elementBudget : Math.min(1000, elementBudget * 5); int built = 0; - if (Mods.BlockRenderer6343.isModLoaded() && env.getActor() instanceof ClientFakePlayer) { - built = survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 63, 14, 1, elementBudget, env, false, true); - if (stackSize.stackSize > 1) { - built += survivialBuildPiece( - STRUCTURE_PIECE_SECOND_RING, - stackSize, - 55, - 11, - -67, - realBudget, - env, - false, - true); - } - if (stackSize.stackSize > 2) { - built += survivialBuildPiece( - STRUCTURE_PIECE_THIRD_RING, - stackSize, - 47, - 13, - -76, - realBudget, - env, - false, - true); - } - return built; - } - survivialBuildPiece(STRUCTURE_PIECE_SHAFT, stackSize, 63, 14, 1, realBudget, env, false, true); if (stackSize.stackSize > 0) { diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEMoltenModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEMoltenModule.java index eace01bb6a7..a7080a4fe1a 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEMoltenModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEMoltenModule.java @@ -93,7 +93,7 @@ protected CheckRecipeResult onRecipeStart(@NotNull GTRecipe recipe) { addToRecipeTally(calculatedParallels); currentParallel = calculatedParallels; EUt = calculatedEut; - setCalculatedEut(0); + overwriteCalculatedEut(0); return CheckRecipeResultRegistry.SUCCESSFUL; } }; diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEPlasmaModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEPlasmaModule.java index 05ae43e341b..48a4388048f 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEPlasmaModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEPlasmaModule.java @@ -100,7 +100,7 @@ protected CheckRecipeResult onRecipeStart(@NotNull GTRecipe recipe) { addToRecipeTally(calculatedParallels); currentParallel = calculatedParallels; EUt = calculatedEut; - setCalculatedEut(0); + overwriteCalculatedEut(0); return CheckRecipeResultRegistry.SUCCESSFUL; } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTESmeltingModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTESmeltingModule.java index 1e499b3507a..c1bd1502eb3 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTESmeltingModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTESmeltingModule.java @@ -118,7 +118,7 @@ protected CheckRecipeResult onRecipeStart(@NotNull GTRecipe recipe) { } currentParallel = calculatedParallels; EUt = calculatedEut; - setCalculatedEut(0); + overwriteCalculatedEut(0); return CheckRecipeResultRegistry.SUCCESSFUL; } diff --git a/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergy.java b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergy.java index e94f4d31ff3..9610030311d 100644 --- a/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergy.java +++ b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergy.java @@ -21,8 +21,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IColoredTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.PowerLogic; -import gregtech.api.logic.interfaces.PowerLogicHost; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GTRenderedTexture; @@ -119,14 +117,6 @@ public void updateNetwork(boolean nestedCall) { continue; } } - if (tTileEntity instanceof PowerLogicHost host) { - PowerLogic logic = host.getPowerLogic(oppositeSide); - if (logic != null && logic.canUseLaser()) { - mConnections |= side.flag; - connectionCount++; - continue; - } - } if (tTileEntity instanceof IConnectsToEnergyTunnel tunnel && tunnel.canConnect(oppositeSide)) { mConnections |= side.flag; connectionCount++; diff --git a/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergyMirror.java b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergyMirror.java index 91fdc3e3a1f..d5c525a2fdb 100644 --- a/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergyMirror.java +++ b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergyMirror.java @@ -17,8 +17,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IColoredTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.logic.PowerLogic; -import gregtech.api.logic.interfaces.PowerLogicHost; import gregtech.api.objects.GTRenderedTexture; import gregtech.common.GTClient; import tectech.TecTech; @@ -108,15 +106,6 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { continue; } } - if (tTileEntity instanceof PowerLogicHost) { - PowerLogic logic = ((PowerLogicHost) tTileEntity).getPowerLogic(oppositeSide); - if (logic != null && logic.canUseLaser()) { - mConnections |= 1 << side.ordinal(); - connectedSides[connectionCount] = side; - connectionCount++; - continue; - } - } if (tTileEntity instanceof IConnectsToEnergyTunnel && ((IConnectsToEnergyTunnel) tTileEntity).canConnect(oppositeSide)) { mConnections |= 1 << side.ordinal(); @@ -197,12 +186,6 @@ public IGregTechTileEntity bendAround(ForgeDirection inputSide) { return null; } } else { - if (tGTTileEntity instanceof PowerLogicHost) { - PowerLogic logic = ((PowerLogicHost) tGTTileEntity).getPowerLogic(opposite); - if (logic == null || !logic.canUseLaser() || opposite != tGTTileEntity.getFrontFacing()) { - return tGTTileEntity; - } - } return null; } } else { diff --git a/src/main/resources/assets/miscutils/lang/en_US.lang b/src/main/resources/assets/miscutils/lang/en_US.lang index dbf21e27d6b..1f701bd12cd 100644 --- a/src/main/resources/assets/miscutils/lang/en_US.lang +++ b/src/main/resources/assets/miscutils/lang/en_US.lang @@ -2215,7 +2215,6 @@ block.Tantalloy61.frame.name=Tantalloy-61 Frame Box block.Tantalloy61.standard.name=Block of Tantalloy-61 block.TantalumCarbide.frame.name=Tantalum Carbide Frame Box block.TantalumCarbide.standard.name=Block of Tantalum Carbide -block.Teflon.standard.name=Block of Teflon block.Thallium.frame.name=Thallium Frame Box block.Thallium.standard.name=Block of Thallium block.Titansteel.frame.name=Titansteel Frame Box @@ -3104,15 +3103,6 @@ item.itemPlateNylon.name=Nylon Plate item.itemPlateDoubleNylon.name=Double Nylon Plate item.itemCellNylon.name=Nylon Cell tile.Block of Nylon.name=Block of Nylon -item.itemIngotTeflon.name=Teflon Ingot -item.itemDustTeflon.name=Teflon Dust -item.itemDustTinyTeflon.name=Tiny Pile of Teflon Dust -item.itemDustSmallTeflon.name=Small Pile of Teflon Dust -item.itemNuggetTeflon.name=Teflon Nugget -item.itemPlateTeflon.name=Teflon Plate -item.itemPlateDoubleTeflon.name=Double Teflon Plate -item.itemCellTeflon.name=Teflon Cell -tile.Block of Teflon.name=Block of Teflon # Added 17/4/19 # Spelling Corrections diff --git a/src/main/resources/assets/miscutils/lang/ru_RU.lang b/src/main/resources/assets/miscutils/lang/ru_RU.lang index e4d77619a83..8ab52ce2c1b 100644 --- a/src/main/resources/assets/miscutils/lang/ru_RU.lang +++ b/src/main/resources/assets/miscutils/lang/ru_RU.lang @@ -2745,15 +2745,6 @@ item.itemPlateNylon.name=Nylon Plate item.itemPlateDoubleNylon.name=Double Nylon Plate item.itemCellNylon.name=Nylon Cell tile.Block of Nylon.name=Block of Nylon -item.itemIngotTeflon.name=Teflon Ingot -item.itemDustTeflon.name=Teflon Dust -item.itemDustTinyTeflon.name=Tiny Pile of Teflon Dust -item.itemDustSmallTeflon.name=Small Pile of Teflon Dust -item.itemNuggetTeflon.name=Teflon Nugget -item.itemPlateTeflon.name=Teflon Plate -item.itemPlateDoubleTeflon.name=Double Teflon Plate -item.itemCellTeflon.name=Teflon Cell -tile.Block of Teflon.name=Block of Teflon //Added 17/4/19 //Spelling Corrections diff --git a/src/main/resources/assets/miscutils/lang/zh_CN.lang b/src/main/resources/assets/miscutils/lang/zh_CN.lang index dd21e51aad8..e6812034d27 100644 --- a/src/main/resources/assets/miscutils/lang/zh_CN.lang +++ b/src/main/resources/assets/miscutils/lang/zh_CN.lang @@ -2745,15 +2745,6 @@ item.itemPlateNylon.name=尼龙板 item.itemPlateDoubleNylon.name=双重尼龙板 item.itemCellNylon.name=尼龙单元 tile.Block of Nylon.name=尼龙块 -item.itemIngotTeflon.name=特氟龙锭 -item.itemDustTeflon.name=特氟龙粉 -item.itemDustTinyTeflon.name=小撮特氟龙粉 -item.itemDustSmallTeflon.name=小堆特氟龙粉 -item.itemNuggetTeflon.name=特氟龙粒 -item.itemPlateTeflon.name=特氟龙板 -item.itemPlateDoubleTeflon.name=双重特氟龙板 -item.itemCellTeflon.name=特氟龙单元 -tile.Block of Teflon.name=特氟龙块 //Added 17/4/19 //Spelling Corrections