aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity/implementations
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2023-12-04 05:34:27 +0900
committerGitHub <noreply@github.com>2023-12-03 21:34:27 +0100
commitf74c7cc297d1d19d38a19683cd277ad9ce605d3a (patch)
treeb2a5d66ec5a959099240fb1db239ffc0f9531839 /src/main/java/gregtech/api/metatileentity/implementations
parentb08cde7de4ec93cba05fb070991ad1dffb800ce1 (diff)
downloadGT5-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/api/metatileentity/implementations')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java4
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java22
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java325
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java14
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java278
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java8
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ExtendedPowerMultiBlockBase.java31
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java10
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java17
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java107
10 files changed, 303 insertions, 513 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java
index f17626cdd8..399c536b9f 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java
@@ -1,6 +1,6 @@
package gregtech.api.metatileentity.implementations;
-import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sAssemblerRecipes;
+import static gregtech.api.recipe.RecipeMaps.assemblerRecipes;
import static gregtech.api.util.GT_RecipeBuilder.SECONDS;
import static gregtech.api.util.GT_RecipeBuilder.TICKS;
import static gregtech.api.util.GT_Utility.calculateRecipeEU;
@@ -54,7 +54,7 @@ public class GT_MetaPipeEntity_Frame extends MetaPipeEntity {
.itemOutputs(getStackForm(1))
.duration(3 * SECONDS + 4 * TICKS)
.eut(calculateRecipeEU(aMaterial, 7))
- .addTo(sAssemblerRecipes);
+ .addTo(assemblerRecipes);
}
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
index 93bbdd2d18..897f9dad6f 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
@@ -15,14 +15,17 @@ import gregtech.api.enums.Textures;
import gregtech.api.gui.modularui.GT_UIInfos;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.interfaces.tileentity.RecipeMapWorkable;
import gregtech.api.objects.ItemData;
+import gregtech.api.recipe.RecipeMap;
+import gregtech.api.recipe.maps.FuelBackend;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;
-import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_Pollution;
-public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity_BasicTank {
+public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity_BasicTank
+ implements RecipeMapWorkable {
public GT_MetaTileEntity_BasicGenerator(int aID, String aName, String aNameRegional, int aTier, String aDescription,
ITexture... aTextures) {
@@ -273,7 +276,8 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
public abstract int getPollution();
- public abstract GT_Recipe_Map getRecipes();
+ @Override
+ public abstract RecipeMap<?> getRecipeMap();
public abstract int getEfficiency();
@@ -287,8 +291,8 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
}
public long getFuelValue(FluidStack aLiquid, boolean aLong) {
- GT_Recipe_Map tRecipes = getRecipes();
- if (aLiquid == null || !(tRecipes instanceof GT_Recipe.GT_Recipe_Map_Fuel tFuels)) return 0;
+ RecipeMap<?> tRecipes = getRecipeMap();
+ if (aLiquid == null || !(tRecipes.getBackend() instanceof FuelBackend tFuels)) return 0;
GT_Recipe tFuel = tFuels.findFuel(aLiquid);
if (tFuel == null) return 0;
@@ -301,8 +305,8 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
}
public long getFuelValue(ItemStack aStack, boolean aLong) {
- if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0;
- GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack);
+ if (GT_Utility.isStackInvalid(aStack) || getRecipeMap() == null) return 0;
+ GT_Recipe tFuel = getRecipeMap().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack);
if (tFuel == null) return 0;
long liters = 10L; // 1000mb/100
@@ -310,8 +314,8 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
}
public ItemStack getEmptyContainer(ItemStack aStack) {
- if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null;
- GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack);
+ if (GT_Utility.isStackInvalid(aStack) || getRecipeMap() == null) return null;
+ GT_Recipe tFuel = getRecipeMap().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack);
if (tFuel != null) return GT_Utility.copyOrNull(tFuel.getOutput(0));
return GT_Utility.getContainerItem(aStack, true);
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
index 0e86829027..ba8c865301 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
@@ -14,6 +14,8 @@ import static gregtech.api.metatileentity.BaseTileEntity.STALLED_STUTTERING_TOOL
import static gregtech.api.metatileentity.BaseTileEntity.STALLED_VENT_TOOLTIP;
import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY;
import static gregtech.api.metatileentity.BaseTileEntity.UNUSED_SLOT_TOOLTIP;
+import static gregtech.api.util.GT_RecipeConstants.EXPLODE;
+import static gregtech.api.util.GT_RecipeConstants.ON_FIRE;
import static gregtech.api.util.GT_Utility.moveMultipleItemStacks;
import static net.minecraftforge.common.util.ForgeDirection.DOWN;
import static net.minecraftforge.common.util.ForgeDirection.UNKNOWN;
@@ -23,6 +25,8 @@ import java.util.Arrays;
import java.util.Collections;
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;
@@ -39,7 +43,6 @@ import net.minecraftforge.fluids.IFluidHandler;
import org.apache.commons.lang3.tuple.Pair;
import com.gtnewhorizons.modularui.api.drawable.IDrawable;
-import com.gtnewhorizons.modularui.api.drawable.UITexture;
import com.gtnewhorizons.modularui.api.math.Pos2d;
import com.gtnewhorizons.modularui.api.math.Size;
import com.gtnewhorizons.modularui.api.screen.ModularWindow;
@@ -65,21 +68,24 @@ import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.modularui.IAddGregtechLogo;
import gregtech.api.interfaces.modularui.IAddUIWidgets;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.interfaces.tileentity.IOverclockDescriptionProvider;
+import gregtech.api.interfaces.tileentity.RecipeMapWorkable;
import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.recipe.check.FindRecipeResult;
+import gregtech.api.objects.overclockdescriber.EUOverclockDescriber;
+import gregtech.api.objects.overclockdescriber.OverclockDescriber;
+import gregtech.api.recipe.BasicUIProperties;
+import gregtech.api.recipe.RecipeMap;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_ClientPreference;
import gregtech.api.util.GT_CoverBehaviorBase;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_OverclockCalculator;
import gregtech.api.util.GT_Recipe;
-import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_TooltipDataCache;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.GT_Waila;
import gregtech.common.gui.modularui.UIHelper;
-import gregtech.common.power.BasicMachineEUPower;
-import gregtech.common.power.Power;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -89,8 +95,8 @@ import mcp.mobius.waila.api.IWailaDataAccessor;
* This is the main construct for my Basic Machines such as the Automatic Extractor Extend this class to make a simple
* Machine
*/
-public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank
- implements IConfigurationCircuitSupport, IAddGregtechLogo, IAddUIWidgets {
+public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank implements RecipeMapWorkable,
+ IConfigurationCircuitSupport, IOverclockDescriptionProvider, IAddGregtechLogo, IAddUIWidgets {
/**
* return values for checkRecipe()
@@ -108,9 +114,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
public int mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0;
public ForgeDirection mMainFacing = ForgeDirection.WEST;
public FluidStack mOutputFluid;
- @Deprecated
- public String mGUIName = "", mNEIName = "";
- protected final Power mPower;
+ protected final OverclockDescriber overclockDescriber;
/**
* Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have
@@ -147,29 +151,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
mInputSlotCount = Math.max(0, aInputSlotCount);
mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)];
mAmperage = aAmperage;
- mPower = buildPower();
- }
-
- /**
- * @deprecated Use {@link #GT_MetaTileEntity_BasicMachine(int, String, String, int, int, String, int, int,
- * ITexture...)}
- */
- @Deprecated
- public GT_MetaTileEntity_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage,
- String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName,
- ITexture... aOverlays) {
- super(
- aID,
- aName,
- aNameRegional,
- aTier,
- OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1,
- aDescription,
- aOverlays);
- mInputSlotCount = Math.max(0, aInputSlotCount);
- mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)];
- mAmperage = aAmperage;
- mPower = buildPower();
+ overclockDescriber = createOverclockDescriber();
}
/**
@@ -188,42 +170,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
mInputSlotCount = Math.max(0, aInputSlotCount);
mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)];
mAmperage = aAmperage;
- mPower = buildPower();
- }
-
- /**
- * @deprecated Use {@link #GT_MetaTileEntity_BasicMachine(int, String, String, int, int, String[], int, int,
- * ITexture...)}
- */
- @Deprecated
- public GT_MetaTileEntity_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage,
- String[] aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName,
- ITexture... aOverlays) {
- super(
- aID,
- aName,
- aNameRegional,
- aTier,
- OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1,
- aDescription,
- aOverlays);
- mInputSlotCount = Math.max(0, aInputSlotCount);
- mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)];
- mAmperage = aAmperage;
- mPower = buildPower();
- }
-
- /**
- * @deprecated Use {@link #GT_MetaTileEntity_BasicMachine(String, int, int, String[], ITexture[][][], int, int)}
- */
- @Deprecated
- public GT_MetaTileEntity_BasicMachine(String aName, int aTier, int aAmperage, String aDescription,
- ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) {
- super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures);
- mInputSlotCount = Math.max(0, aInputSlotCount);
- mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)];
- mAmperage = aAmperage;
- mPower = buildPower();
+ overclockDescriber = createOverclockDescriber();
}
/**
@@ -235,27 +182,14 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
mInputSlotCount = Math.max(0, aInputSlotCount);
mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)];
mAmperage = aAmperage;
- mPower = buildPower();
- }
-
- /**
- * @deprecated Use {@link #GT_MetaTileEntity_BasicMachine(String, int, int, String[], ITexture[][][], int, int)}
- */
- @Deprecated
- public GT_MetaTileEntity_BasicMachine(String aName, int aTier, int aAmperage, String[] aDescription,
- ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) {
- super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures);
- mInputSlotCount = Math.max(0, aInputSlotCount);
- mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)];
- mAmperage = aAmperage;
- mPower = buildPower();
+ overclockDescriber = createOverclockDescriber();
}
/**
- * To be called by the constructor to initialize this instance's Power
+ * To be called by the constructor to initialize this instance's overclock behavior
*/
- protected Power buildPower() {
- return new BasicMachineEUPower(mTier, mAmperage);
+ protected OverclockDescriber createOverclockDescriber() {
+ return new EUOverclockDescriber(mTier, mAmperage);
}
protected boolean isValidMainFacing(ForgeDirection side) {
@@ -502,7 +436,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
@Override
public boolean isFluidInputAllowed(FluidStack aFluid) {
- return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid));
+ return getFillableStack() != null || (getRecipeMap() != null && getRecipeMap().containsInput(aFluid));
}
@Override
@@ -780,20 +714,30 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
return getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEUt, false);
}
- protected void calculateOverclockedNess(GT_Recipe aRecipe) {
- calculateOverclockedNess(aRecipe.mEUt, aRecipe.mDuration);
+ /**
+ * Calculates overclock based on {@link #overclockDescriber}.
+ */
+ protected void calculateCustomOverclock(GT_Recipe recipe) {
+ GT_OverclockCalculator calculator = overclockDescriber.createCalculator(
+ new GT_OverclockCalculator().setRecipeEUt(recipe.mEUt)
+ .setDuration(recipe.mDuration)
+ .setOneTickDiscount(true),
+ recipe);
+ calculator.calculate();
+ mEUt = (int) calculator.getConsumption();
+ mMaxProgresstime = calculator.getDuration();
}
/**
- * Calcualtes overclocked ness using long integers
- *
- * @param aEUt - recipe EUt
- * @param aDuration - recipe Duration
+ * Helper method for calculating simple overclock.
*/
- protected void calculateOverclockedNess(int aEUt, int aDuration) {
- mPower.computePowerUsageAndDuration(aEUt, aDuration);
- mEUt = mPower.getEuPerTick();
- mMaxProgresstime = mPower.getDurationTicks();
+ protected void calculateOverclockedNess(int eut, int duration) {
+ GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(eut)
+ .setDuration(duration)
+ .setOneTickDiscount(true)
+ .calculate();
+ mEUt = (int) calculator.getConsumption();
+ mMaxProgresstime = calculator.getDuration();
}
protected ItemStack getSpecialSlot() {
@@ -1063,10 +1007,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
return GregTech_API.getConfigurationCircuitList(mTier);
}
- /**
- * @return the Recipe List which is used for this Machine, this is a useful Default Handler
- */
- public GT_Recipe_Map getRecipeList() {
+ @Override
+ public RecipeMap<?> getRecipeMap() {
return null;
}
@@ -1115,26 +1057,26 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
* FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2;
*/
public int checkRecipe(boolean skipOC) {
- GT_Recipe_Map tMap = getRecipeList();
+ RecipeMap<?> tMap = getRecipeMap();
if (tMap == null) return DID_NOT_FIND_RECIPE;
- FindRecipeResult result = tMap.findRecipeWithResult(
- mLastRecipe,
- false,
- false,
- V[mTier],
- new FluidStack[] { getFillableStack() },
- getSpecialSlot(),
- getAllInputs());
- if (result.getState() == FindRecipeResult.State.EXPLODE && getBaseMetaTileEntity() != null) {
+ GT_Recipe tRecipe = tMap.findRecipeQuery()
+ .items(getAllInputs())
+ .fluids(getFillableStack())
+ .specialSlot(getSpecialSlot())
+ .voltage(V[mTier])
+ .cachedRecipe(mLastRecipe)
+ .find();
+ if (tRecipe == null) {
+ return DID_NOT_FIND_RECIPE;
+ }
+ if (tRecipe.getMetadataOrDefault(EXPLODE, false) && getBaseMetaTileEntity() != null) {
getBaseMetaTileEntity().doExplosion(V[mTier] * 4);
return DID_NOT_FIND_RECIPE;
}
- if (result.getState() == FindRecipeResult.State.ON_FIRE && getBaseMetaTileEntity() != null) {
+ if (tRecipe.getMetadataOrDefault(ON_FIRE, false) && getBaseMetaTileEntity() != null) {
getBaseMetaTileEntity().setOnFire();
return DID_NOT_FIND_RECIPE;
}
- if (!result.isSuccessful()) return DID_NOT_FIND_RECIPE;
- GT_Recipe tRecipe = result.getRecipeNonNull();
if (GT_Mod.gregtechproxy.mLowGravProcessing && (tRecipe.mSpecialValue == -100 || tRecipe.mSpecialValue == -300)
&& !isValidForLowGravity(tRecipe, getBaseMetaTileEntity().getWorld().provider.dimensionId))
@@ -1169,7 +1111,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
}
mOutputFluid = tRecipe.getFluidOutput(0);
if (!skipOC) {
- calculateOverclockedNess(tRecipe);
+ calculateCustomOverclock(tRecipe);
// 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;
@@ -1317,16 +1259,17 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
}
}
+ @Nonnull
@Override
- public Power getPower() {
- return mPower;
+ public OverclockDescriber getOverclockDescriber() {
+ return overclockDescriber;
}
// GUI stuff
@Override
public boolean useModularUI() {
- return getRecipeList() != null && getRecipeList().useModularUI;
+ return getRecipeMap() != null;
}
@Override
@@ -1341,8 +1284,9 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
@Override
public void addGregTechLogo(ModularWindow.Builder builder) {
- if (getRecipeList() != null) {
- getRecipeList().addGregTechLogoUI(builder, new Pos2d(0, 0));
+ if (getRecipeMap() != null) {
+ getRecipeMap().getFrontend()
+ .addGregTechLogo(builder, new Pos2d(0, 0));
} else {
builder.widget(
new DrawableWidget().setDrawable(getGUITextureSet().getGregTechLogo())
@@ -1358,22 +1302,13 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
builder.widget(createItemAutoOutputButton());
}
- addIOSlots(builder);
+ BasicUIProperties uiProperties = getUIProperties();
+ addIOSlots(builder, uiProperties);
builder.widget(createChargerSlot(79, 62));
- if (getRecipeList() != null) {
- builder.widget(
- setNEITransferRect(
- createProgressBar(
- isSteampowered() ? getRecipeList().getProgressBarTextureSteam(getSteamVariant())
- : getRecipeList().getProgressBarTexture(),
- getRecipeList().getProgressBarImageSize(),
- getRecipeList().progressBarDirection,
- getRecipeList().progressBarPos,
- getRecipeList().progressBarSize),
- getRecipeList().mNEIName));
- addProgressBarSpecialTextures(builder);
- }
+
+ addProgressBar(builder, uiProperties);
+
builder.widget(
createErrorStatusArea(
builder,
@@ -1381,29 +1316,82 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
}
/**
+ * Override to specify UI properties if this machine doesn't work with recipemap.
+ */
+ protected BasicUIProperties getUIProperties() {
+ if (getRecipeMap() != null) {
+ BasicUIProperties originalProperties = getRecipeMap().getFrontend()
+ .getUIProperties();
+ return originalProperties.toBuilder()
+ .maxItemInputs(mInputSlotCount)
+ .maxItemOutputs(mOutputItems.length)
+ .maxFluidInputs(Math.min(originalProperties.maxFluidInputs, 1))
+ .maxFluidOutputs(Math.min(originalProperties.maxFluidOutputs, 1))
+ .build();
+ }
+ return BasicUIProperties.builder()
+ .maxItemInputs(mInputSlotCount)
+ .maxItemOutputs(mOutputItems.length)
+ .maxFluidInputs(getCapacity() != 0 ? 1 : 0)
+ .maxFluidOutputs(0)
+ .build();
+ }
+
+ /**
* Adds item I/O, special item, and fluid I/O slots.
*/
- protected void addIOSlots(ModularWindow.Builder builder) {
- final boolean hasFluidInput = getRecipeList() != null ? (getRecipeList().hasFluidInputs())
- : (getCapacity() != 0);
- final boolean hasFluidOutput = getRecipeList() != null && getRecipeList().hasFluidOutputs();
+ protected void addIOSlots(ModularWindow.Builder builder, BasicUIProperties uiProperties) {
UIHelper.forEachSlots(
(i, backgrounds, pos) -> builder.widget(createItemInputSlot(i, backgrounds, pos)),
(i, backgrounds, pos) -> builder.widget(createItemOutputSlot(i, backgrounds, pos)),
- (i, backgrounds, pos) -> builder.widget(createSpecialSlot(backgrounds, pos)),
+ (i, backgrounds, pos) -> builder.widget(createSpecialSlot(backgrounds, pos, uiProperties)),
(i, backgrounds, pos) -> builder.widget(createFluidInputSlot(backgrounds, pos)),
(i, backgrounds, pos) -> builder.widget(createFluidOutputSlot(backgrounds, pos)),
getGUITextureSet().getItemSlot(),
getGUITextureSet().getFluidSlot(),
- getRecipeList(),
- mInputSlotCount,
- mOutputItems.length,
- hasFluidInput ? 1 : 0,
- hasFluidOutput ? 1 : 0,
+ uiProperties,
+ uiProperties.maxItemInputs,
+ uiProperties.maxItemOutputs,
+ uiProperties.maxFluidInputs,
+ uiProperties.maxFluidOutputs,
getSteamVariant(),
Pos2d.ZERO);
}
+ protected void addProgressBar(ModularWindow.Builder builder, BasicUIProperties uiProperties) {
+ boolean isSteamPowered = isSteampowered();
+ RecipeMap<?> recipeMap = getRecipeMap();
+ if (!isSteamPowered && uiProperties.progressBarTexture == null) {
+ if (recipeMap != null) {
+ // Require progress bar texture for machines working with recipemap, otherwise permit
+ throw new RuntimeException("Missing progressbar texture for " + recipeMap.unlocalizedName);
+ } else {
+ return;
+ }
+ }
+ if (isSteamPowered && uiProperties.progressBarTextureSteam == null) {
+ if (recipeMap != null) {
+ throw new RuntimeException("Missing steam progressbar texture for " + recipeMap.unlocalizedName);
+ } else {
+ return;
+ }
+ }
+
+ builder.widget(
+ setNEITransferRect(
+ new ProgressBar()
+ .setProgress(() -> maxProgresstime() != 0 ? (float) getProgresstime() / maxProgresstime() : 0)
+ .setTexture(
+ isSteamPowered ? uiProperties.progressBarTextureSteam.get(getSteamVariant())
+ : uiProperties.progressBarTexture.get(),
+ uiProperties.progressBarImageSize)
+ .setDirection(uiProperties.progressBarDirection)
+ .setPos(uiProperties.progressBarPos)
+ .setSize(uiProperties.progressBarSize),
+ uiProperties.neiTransferRectId));
+ addProgressBarSpecialTextures(builder, uiProperties);
+ }
+
/**
* Override this as needed instead of calling.
*/
@@ -1425,13 +1413,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
/**
* Override this as needed instead of calling.
*/
- protected SlotWidget createSpecialSlot(IDrawable[] backgrounds, Pos2d pos) {
+ protected SlotWidget createSpecialSlot(IDrawable[] backgrounds, Pos2d pos, BasicUIProperties uiProperties) {
return (SlotWidget) new SlotWidget(inventoryHandler, getSpecialSlotIndex()).setAccess(true, true)
.disableShiftInsert()
.setGTTooltip(
- () -> mTooltipCache.getData(
- getRecipeList() != null && getRecipeList().usesSpecialSlot() ? SPECIAL_SLOT_TOOLTIP
- : UNUSED_SLOT_TOOLTIP))
+ () -> mTooltipCache.getData(uiProperties.useSpecialSlot ? SPECIAL_SLOT_TOOLTIP : UNUSED_SLOT_TOOLTIP))
.setTooltipShowUpDelay(TOOLTIP_DELAY)
.setBackground(backgrounds)
.setPos(pos);
@@ -1478,40 +1464,25 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
.setSize(18, 18);
}
- protected ProgressBar createProgressBar(UITexture texture, int imageSize, ProgressBar.Direction direction,
- Pos2d pos, Size size) {
- final ProgressBar ret = new ProgressBar();
- ret.setProgress(() -> maxProgresstime() != 0 ? (float) getProgresstime() / maxProgresstime() : 0)
- .setTexture(texture, imageSize)
- .setDirection(direction)
- .setPos(pos)
- .setSize(size);
- return ret;
- }
-
- public boolean hasNEITransferRect() {
- return getRecipeList() != null;
- }
-
protected Widget setNEITransferRect(Widget widget, String transferRectID) {
- if (hasNEITransferRect()) {
- final Power powerInfo = getPower();
- final String transferRectTooltip;
- if (isSteampowered()) {
- transferRectTooltip = StatCollector
- .translateToLocalFormatted(NEI_TRANSFER_STEAM_TOOLTIP, powerInfo.getTierString());
- } else {
- transferRectTooltip = StatCollector
- .translateToLocalFormatted(NEI_TRANSFER_VOLTAGE_TOOLTIP, powerInfo.getTierString());
- }
- widget.setNEITransferRect(transferRectID, new Object[] { powerInfo }, transferRectTooltip);
+ if (GT_Utility.isStringInvalid(transferRectID)) {
+ return widget;
+ }
+ final String transferRectTooltip;
+ if (isSteampowered()) {
+ transferRectTooltip = StatCollector
+ .translateToLocalFormatted(NEI_TRANSFER_STEAM_TOOLTIP, overclockDescriber.getTierString());
+ } else {
+ transferRectTooltip = StatCollector
+ .translateToLocalFormatted(NEI_TRANSFER_VOLTAGE_TOOLTIP, overclockDescriber.getTierString());
}
+ widget.setNEITransferRect(transferRectID, new Object[] { overclockDescriber }, transferRectTooltip);
return widget;
}
- protected void addProgressBarSpecialTextures(ModularWindow.Builder builder) {
+ protected void addProgressBarSpecialTextures(ModularWindow.Builder builder, BasicUIProperties uiProperties) {
if (isSteampowered()) {
- for (Pair<SteamTexture, Pair<Size, Pos2d>> specialTexture : getRecipeList().specialTexturesSteam) {
+ for (Pair<SteamTexture, Pair<Size, Pos2d>> specialTexture : uiProperties.specialTexturesSteam) {
builder.widget(
new DrawableWidget().setDrawable(
specialTexture.getLeft()
@@ -1524,7 +1495,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
.getRight()));
}
} else {
- for (Pair<IDrawable, Pair<Size, Pos2d>> specialTexture : getRecipeList().specialTextures) {
+ for (Pair<IDrawable, Pair<Size, Pos2d>> specialTexture : uiProperties.specialTextures) {
builder.widget(
new DrawableWidget().setDrawable(specialTexture.getLeft())
.setSize(
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java
index e1321c144f..5eb648d560 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java
@@ -35,13 +35,13 @@ import gregtech.api.gui.modularui.GUITextureSet;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.objects.GT_ItemStack;
+import gregtech.api.objects.overclockdescriber.OverclockDescriber;
+import gregtech.api.objects.overclockdescriber.SteamOverclockDescriber;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder;
-import gregtech.common.power.Power;
-import gregtech.common.power.SteamPower;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
@@ -70,8 +70,8 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE
}
@Override
- public Power buildPower() {
- return new SteamPower(mTier, 1, 2);
+ public OverclockDescriber createOverclockDescriber() {
+ return new SteamOverclockDescriber(SteamVariant.BRONZE, 1, 2);
}
@Override
@@ -189,11 +189,11 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_