diff options
| author | miozune <miozune@gmail.com> | 2023-12-04 05:34:27 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-03 21:34:27 +0100 |
| commit | f74c7cc297d1d19d38a19683cd277ad9ce605d3a (patch) | |
| tree | b2a5d66ec5a959099240fb1db239ffc0f9531839 /src/main/java/gregtech/common/tileentities/machines | |
| parent | b08cde7de4ec93cba05fb070991ad1dffb800ce1 (diff) | |
| download | GT5-Unofficial-f74c7cc297d1d19d38a19683cd277ad9ce605d3a.tar.gz GT5-Unofficial-f74c7cc297d1d19d38a19683cd277ad9ce605d3a.tar.bz2 GT5-Unofficial-f74c7cc297d1d19d38a19683cd277ad9ce605d3a.zip | |
Refactor RecipeMap (#2345)
* Remove deprecated and unused things
* Move recipemap subclasses
* Move GT_Recipe_Map to outside and rename to RecipeMap
* Move recipemap instances to separated class & remove prepending s
* Remove useless GT_Recipe constructors
* Always use ModularUI
* Rename IGT_RecipeMap -> IRecipeMap
* Add RecipeMapBuilder
* Remove more deprecated and unused things
* Fix RecipeMap type parameters
* Use multimap for recipe index
* Fix bending recipe error in dev env
* Remove mUniqueIdentifier
* Update AE2FC
* Less edgy texture for NEI recipe background
* Add replicator fluid output slot for NEI and machine GUI
* Fix fluid fuels not having fuel value in large boilers
* Remove GT_RectHandler and NEI_TransferRectHost
* Remove RecipeMapHandler
* Move NEI energy description from RecipeMapFrontend to Power
* Refactor the way to filter fusion recipes
* Check restriction for some properties
* Remove showVoltageAmperage
* Make Power accept GT_Recipe
* Fix NPE
* Move NEI duration description to Power from Frontend
* Directly implement IRecipeProcessingAwareHatch for GT_MetaTileEntity_Hatch_InputBus_ME
* Make Power integrated with GT_OverclockCalculator
* Rename Power -> OverclockDescriber
* Don't modify recipe find logic until postload finishes
* Reformat reserved MTE ids
* Fix check for too few inputs on recipe addition
* Move replicator logic to backend
* Stop un-hiding assline recipes
* Allow setting custom recipe comparator & implement for fusion
* Update AE2FC
* Rename getRecipeList and getRecipes -> getRecipeMap
* Automatically register recipe catalysts
* Cleanup the way to detect recipe collision
* Make use of BasicUIProperties for basic machines
* Make use of BasicUIProperties for UIHelper
* Rename specialHandler -> recipeTransformer
* Add way to automatically register handler info
* Add recipe category
* Add some APIs for addons
* Rename blastRecipes ->
blastFurnaceRecipes
* Remove GT_MetaTileEntity_BasicMachine_GT_Recipe#mSharedTank and #mRequiresFluidForFiltering
* Don't require setting duration and EU/t for fuel recipes
* Don't require setting EU/t for primitive blast furnace recipes
* Revert change to addMultiblockChemicalRecipe
* Fix large boiler general desc recipe not being added
* Hide duration and EU/t from large boiler
* Cleanup recipe stacktrace draw
* Extend metadata usage of recipe builder to recipe itself
* Implement metadata handling & NEI comparator for PCB factory
* Some rename around NEIRecipeInfo
* Some toString implementations
* Add more APIs for addons & some rename
* Infer handler icon from recipe catalyst if one is not set
* Also shrink recipe title when OC is not used
* Remove rare earth centrifuge recipe
* Use metadata for replicator backend
* Adjust geothermal generator output slot
* Allow having multiple transferrects
* Store recipemap reference in backend
* Rename vacuumRecipes -> vacuumFreezerRecipes
* Add config to tweak visibility of recipe categories
* Remove mHideRecyclingRecipes in favor of recipe category config
* Fix typo fluidSolidfierRecipes -> fluidSolidifierRecipes
* Refactor findRecipe and ProcessingLogic to use Stream
* Fix BBF handler icon & remove bronze blast furnace
* Add fluent API for findRecipe
* Add way to stop adding progressbar
* Change arg order for special texture
* Avoid overwriting interesting failure with NO_RECIPE
* Some changes for FuelBackend
* Set space project icon
* Remove localization from TT
* Remove CNC recipe adder
* Move recipe extractor from AE2FC
* Minor internal change for ProcessingLogic#applyRecipe
* More javadoc on #getAvailableRecipeMaps
* Better implementation of #ofSupplier
* Move replicator exponent config to GT_Proxy
* Remove RC & IC2 macerator handling
* Rename StreamUtil -> GT_StreamUtil
* Refactor code around RecipeMetadataStorage
* Revise #compileRecipe javadoc
* Switch extreme diesel recipe loader to downstream recipe map
* Optimize #reMap
* Rename reload -> reloadNEICache
* Minor tweak for drawEnergyInfo
* a bit more doc
* Adjust recipe catalysts
* Add toString implementation for GT_Fluid for debug
* Minor revision for OilCrackerBackend
* Index replicator recipes by material
---------
Co-authored-by: Glease <4586901+Glease@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/machines')
53 files changed, 366 insertions, 483 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java index 2449719079..59746800b1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java @@ -74,8 +74,8 @@ import gregtech.common.gui.modularui.widget.AESlotWidget; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; -public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch_InputBus - implements IConfigurationCircuitSupport, IAddGregtechLogo, IAddUIWidgets, IPowerChannelState { +public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch_InputBus implements + IConfigurationCircuitSupport, IRecipeProcessingAwareHatch, IAddGregtechLogo, IAddUIWidgets, IPowerChannelState { private static final int SLOT_COUNT = 16; private BaseActionSource requestSource = null; diff --git a/src/main/java/gregtech/common/tileentities/machines/IRecipeProcessingAwareHatch.java b/src/main/java/gregtech/common/tileentities/machines/IRecipeProcessingAwareHatch.java index d78400b30e..c7a97ce969 100644 --- a/src/main/java/gregtech/common/tileentities/machines/IRecipeProcessingAwareHatch.java +++ b/src/main/java/gregtech/common/tileentities/machines/IRecipeProcessingAwareHatch.java @@ -2,30 +2,25 @@ package gregtech.common.tileentities.machines; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.recipe.check.CheckRecipeResult; -import gregtech.api.recipe.check.CheckRecipeResultRegistry; +/** + * Implement this interface for {@link gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch} + * if it does special stuff while multiblock controller is processing recipe. + */ public interface IRecipeProcessingAwareHatch { /** * Called when multiblock controller starts processing. - * {@link #endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase)} is called on the same tick. + * {@link #endRecipeProcessing} is called on the same tick. */ - default void startRecipeProcessing() {} + void startRecipeProcessing(); /** - * Called when multiblock controller ends processing. {@link #startRecipeProcessing()} is called on the same tick. + * Called when multiblock controller ends processing. {@link #startRecipeProcessing} is called on the same tick. * * @param controller Caller of this method. * @return Result of the process of this method. {@code !wasSuccessful()} means the returned result should * overwrite the result calculated on multiblock whatever the reason is. */ - default CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase controller) { - endRecipeProcessing(); - return CheckRecipeResultRegistry.SUCCESSFUL; - } - - /** - * Simple version of {@link #endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase)}. Maybe use it instead. - */ - default void endRecipeProcessing() {} + CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase controller); } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java index 34bb0b782c..6c908aadac 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java @@ -26,9 +26,10 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; public class GT_MetaTileEntity_Boxinator extends GT_MetaTileEntity_BasicMachine { @@ -107,8 +108,8 @@ public class GT_MetaTileEntity_Boxinator extends GT_MetaTileEntity_BasicMachine } @Override - public GT_Recipe.GT_Recipe_Map getRecipeList() { - return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes; + public RecipeMap<?> getRecipeMap() { + return RecipeMaps.packagerRecipes; } private boolean hasValidCache(ItemStack mItem, int mType, boolean mClearOnFailure) { @@ -206,7 +207,7 @@ public class GT_MetaTileEntity_Boxinator extends GT_MetaTileEntity_BasicMachine if ((ItemList.Schematic_1by1.isStackEqual(tInput1)) || (ItemList.Schematic_2by2.isStackEqual(tInput1)) || (ItemList.Schematic_3by3.isStackEqual(tInput1))) { if (hasValidCache(aStack, aTypeCache, false)) return true; - if (GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.findRecipe( + if (RecipeMaps.packagerRecipes.findRecipe( getBaseMetaTileEntity(), true, gregtech.api.enums.GT_Values.V[mTier], @@ -224,7 +225,7 @@ public class GT_MetaTileEntity_Boxinator extends GT_MetaTileEntity_BasicMachine return ItemList.Schematic_3by3.isStackEqual(getInputAt(1)) && (GT_ModHandler .getRecipeOutput(aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack) != null); } else { - return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.containsInput(aStack); + return RecipeMaps.packagerRecipes.containsInput(aStack); } } } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java index ad7b15ed60..3753fb8cd8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_IndustrialApiary.java @@ -50,6 +50,7 @@ import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.util.ForgeDirection; import com.google.common.collect.ImmutableSet; +import com.gtnewhorizons.modularui.api.drawable.FallbackableUITexture; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; import com.gtnewhorizons.modularui.api.math.Pos2d; @@ -63,7 +64,6 @@ import com.gtnewhorizons.modularui.common.widget.ButtonWidget; import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget; import com.gtnewhorizons.modularui.common.widget.DrawableWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; -import com.gtnewhorizons.modularui.common.widget.ProgressBar; import com.gtnewhorizons.modularui.common.widget.SlotGroup; import com.gtnewhorizons.modularui.common.widget.SlotWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; @@ -110,6 +110,7 @@ import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.recipe.BasicUIProperties; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ApiaryModifier; import gregtech.api.util.GT_ApiaryUpgrade; @@ -1178,17 +1179,12 @@ public class GT_MetaTileEntity_IndustrialApiary extends GT_MetaTileEntity_BasicM super.addUIWidgets(builder, buildContext); builder.widget( - new ProgressBar().setProgress(() -> (float) getProgresstime() / Math.max(maxProgresstime(), 1)) - .setTexture(GT_UITextures.PROGRESSBAR_ARROW, 20) - .setPos(70, 3) - .setSize(20, 18)) - .widget( - new ButtonWidget().setOnClick((clickData, widget) -> cancelProcess()) - .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CROSS) - .setGTTooltip(() -> mTooltipCache.getData(CANCEL_PROCESS_TOOLTIP)) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setPos(7, 26) - .setSize(18, 18)) + new ButtonWidget().setOnClick((clickData, widget) -> cancelProcess()) + .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CROSS) + .setGTTooltip(() -> mTooltipCache.getData(CANCEL_PROCESS_TOOLTIP)) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(7, 26) + .setSize(18, 18)) .widget( new CycleButtonWidget().setToggle(() -> mAutoQueen, x -> mAutoQueen = x) .setTextureGetter( @@ -1286,6 +1282,17 @@ public class GT_MetaTileEntity_IndustrialApiary extends GT_MetaTileEntity_BasicM .setPos(26, 72)); } + private static final FallbackableUITexture progressBarTexture = GT_UITextures + .fallbackableProgressbar("iapiary", GT_UITextures.PROGRESSBAR_ARROW); + + @Override + protected BasicUIProperties getUIProperties() { + return super.getUIProperties().toBuilder() + .progressBarTexture(progressBarTexture) + .progressBarPos(new Pos2d(70, 3)) + .build(); + } + @Override protected SlotWidget createItemInputSlot(int index, IDrawable[] backgrounds, Pos2d pos) { // we have custom input slots diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Massfabricator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Massfabricator.java index ca3707abc9..3e00bd1b1b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Massfabricator.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Massfabricator.java @@ -20,8 +20,12 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_TOP_MASSFAB_GLOW; import java.util.Arrays; +import javax.annotation.ParametersAreNonnullByDefault; + import net.minecraftforge.fluids.FluidStack; +import com.google.common.primitives.Ints; + import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.ItemList; import gregtech.api.enums.MachineType; @@ -30,12 +34,16 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.overclockdescriber.EUOverclockDescriber; +import gregtech.api.objects.overclockdescriber.OverclockDescriber; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_OverclockCalculator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.common.power.BasicMachineEUPower; -import gregtech.common.power.Power; +import gregtech.api.util.MethodsReturnNonnullByDefault; public class GT_MetaTileEntity_Massfabricator extends GT_MetaTileEntity_BasicMachine { @@ -43,7 +51,9 @@ public class GT_MetaTileEntity_Massfabricator extends GT_MetaTileEntity_BasicMac public static int sUUASpeedBonus = 4; public static int sDurationMultiplier = 3215; public static boolean sRequiresUUA = false; - protected final long EUt; + public static int BASE_EUT = 256; + public static GT_Recipe nonUUARecipe; + public static GT_Recipe uuaRecipe; public GT_MetaTileEntity_Massfabricator(int aID, String aName, String aNameRegional, int aTier) { super( @@ -51,7 +61,7 @@ public class GT_MetaTileEntity_Massfabricator extends GT_MetaTileEntity_BasicMac aName, aNameRegional, aTier, - 1, + 8, MachineType.MATTER_FABRICATOR.tooltipDescription(), 1, 1, @@ -103,12 +113,10 @@ public class GT_MetaTileEntity_Massfabricator extends GT_MetaTileEntity_BasicMac .addIcon(OVERLAY_BOTTOM_MASSFAB_GLOW) .glow() .build())); - EUt = V[1] * (long) Math.pow(2, mTier + 2); } public GT_MetaTileEntity_Massfabricator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, 1, aDescription, aTextures, 1, 1); - EUt = V[1] * (long) Math.pow(2, mTier + 2); } @Override @@ -122,8 +130,8 @@ public class GT_MetaTileEntity_Massfabricator extends GT_MetaTileEntity_BasicMac } @Override - protected Power buildPower() { - return new MassfabricatorPower(mTier, mAmperage); + protected OverclockDescriber createOverclockDescriber() { + return new MassfabricatorOverclockDescriber(mTier, mAmperage); } @Override @@ -152,9 +160,7 @@ public class GT_MetaTileEntity_Massfabricator extends GT_MetaTileEntity_BasicMac FluidStack tFluid = getDrainableStack(); if ((tFluid == null) || (tFluid.amount < getCapacity())) { this.mOutputFluid = Materials.UUMatter.getFluid(1L); - calculateOverclockedNess( - (int) EUt, - containsUUA(getFillableStack()) ? sDurationMultiplier / sUUASpeedBonus : sDurationMultiplier); + calculateCustomOverclock(containsUUA(getFillableStack()) ? uuaRecipe : nonUUARecipe); // In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; @@ -171,8 +177,8 @@ public class GT_MetaTileEntity_Massfabricator extends GT_MetaTileEntity_BasicMac } @Override - public GT_Recipe.GT_Recipe_Map getRecipeList() { - return GT_Recipe.GT_Recipe_Map.sMassFabFakeRecipes; + public RecipeMap<?> getRecipeMap() { + return RecipeMaps.massFabFakeRecipes; } @Override @@ -189,64 +195,37 @@ public class GT_MetaTileEntity_Massfabricator extends GT_MetaTileEntity_BasicMac return aFluid != null && aFluid.amount >= sUUAperUUM && aFluid.isFluidEqual(Materials.UUAmplifier.getFluid(1L)); } - protected class MassfabricatorPower extends BasicMachineEUPower { + @ParametersAreNonnullByDefault + @MethodsReturnNonnullByDefault + protected class MassfabricatorOverclockDescriber extends EUOverclockDescriber { - protected MassfabricatorPower(byte tier, int amperage) { + protected MassfabricatorOverclockDescriber(byte tier, int amperage) { super(t |
