aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util/GT_Recipe.java
diff options
context:
space:
mode:
authorBlueWeabo <ilia.iliev2005@gmail.com>2023-02-26 13:16:07 +0200
committerGitHub <noreply@github.com>2023-02-26 12:16:07 +0100
commitb8d1ecf8b9b6348304392d09e4490d473dbb120d (patch)
tree1cdc59a1b660510fe2abd40686b2abed8b0ab40f /src/main/java/gregtech/api/util/GT_Recipe.java
parentebd7df3a1ddba9105df008d44ab046d159279628 (diff)
downloadGT5-Unofficial-b8d1ecf8b9b6348304392d09e4490d473dbb120d.tar.gz
GT5-Unofficial-b8d1ecf8b9b6348304392d09e4490d473dbb120d.tar.bz2
GT5-Unofficial-b8d1ecf8b9b6348304392d09e4490d473dbb120d.zip
Add a completely new system for late/endgame content (#1754)
* basic work * typo fixes * make an enum folder * location enums * space project manager * implement the space project teams * commands * move things around and new things * upgrade work * requirement work * if possible use an upgrades values * cleanup * more helpers in command * fix AOOBE * fix world saved data * builder for requirements * add command autocomplete * fix command npe * mark world saved data dirty * switch to saving to json string. this is fine * fix npe * fix files not saving correctly. serialization * spotless * part 1 of fixing json saving * working json file saving * rename fields * full implementation of SP_Upgrade * fixes * cleanup * texture prep * documentation part 1 * documentation part 2 and rework of json saving * fix the missed conversions * set texture when copying * more interface usage and fixes * rework saving. * Added rudimentary NEI handler for projects * Revert "Added rudimentary NEI handler for projects" This reverts commit 6d8210e25b27fee7dc1865d1afa91708a8d9b875. * address NPEs * some textures * higher quality textures, put in the moon as a temp texture * add a check to create a team if one smt weird happens * command work * add ability to localize the space bodies * Added disabled button and toggle button * Added possibility to not render the original stacksize of item stacks in NEI * Added NEI handler * Fixes item count on tooltip always rendering as 1 * Fix refactor * 5 new body textures * fix misspelled texture name --------- Co-authored-by: minecraft7771 <maxim235@gmx.de>
Diffstat (limited to 'src/main/java/gregtech/api/util/GT_Recipe.java')
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java146
1 files changed, 146 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index 506ab9ba6b..3b7f64aae8 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -3,6 +3,7 @@ package gregtech.api.util;
import static gregtech.api.enums.GT_Values.*;
import static gregtech.api.util.GT_Utility.formatNumbers;
import static net.minecraft.util.EnumChatFormatting.GRAY;
+import static net.minecraft.util.StatCollector.translateToLocal;
import java.awt.*;
import java.util.*;
@@ -29,6 +30,8 @@ import net.minecraftforge.fluids.IFluidContainerItem;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
+import appeng.util.ReadableNumberConverter;
+import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import com.gtnewhorizons.modularui.api.GlStateManager;
@@ -65,6 +68,9 @@ import gregtech.api.objects.ItemData;
import gregtech.api.objects.MaterialStack;
import gregtech.api.util.extensions.ArrayExt;
import gregtech.common.gui.modularui.UIHelper;
+import gregtech.common.items.GT_FluidDisplayItem;
+import gregtech.common.misc.spaceprojects.SpaceProjectManager;
+import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject;
import gregtech.common.power.EUPower;
import gregtech.common.power.Power;
import gregtech.common.power.UnspecifiedEUPower;
@@ -1748,6 +1754,131 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
false,
true);
+ public static class GT_FakeSpaceProjectRecipe extends GT_Recipe {
+
+ public final String projectName;
+
+ public GT_FakeSpaceProjectRecipe(boolean aOptimize, ItemStack[] aInputs, FluidStack[] aFluidInputs,
+ int aDuration, int aEUt, int aSpecialValue, String projectName) {
+ super(aOptimize, aInputs, null, null, null, aFluidInputs, null, aDuration, aEUt, aSpecialValue);
+ this.projectName = projectName;
+ }
+ }
+
+ public static final GT_Recipe_Map sFakeSpaceProjectRecipes = new GT_Recipe_Map(
+ new HashSet<>(20),
+ "gt.recipe.fakespaceprojects",
+ "Space Projects",
+ null,
+ RES_PATH_GUI + "basicmachines/Default",
+ 12,
+ 0,
+ 0,
+ 0,
+ 1,
+ translateToLocal("gt.specialvalue.stages") + " ",
+ 1,
+ "",
+ false,
+ true) {
+
+ IDrawable projectTexture;
+
+ @Override
+ public ModularWindow.Builder createNEITemplate(IItemHandlerModifiable itemInputsInventory,
+ IItemHandlerModifiable itemOutputsInventory, IItemHandlerModifiable specialSlotInventory,
+ IItemHandlerModifiable fluidInputsInventory, IItemHandlerModifiable fluidOutputsInventory,
+ Supplier<Float> progressSupplier, Pos2d windowOffset) {
+ ModularWindow.Builder builder = super.createNEITemplate(
+ itemInputsInventory,
+ itemOutputsInventory,
+ specialSlotInventory,
+ fluidInputsInventory,
+ fluidOutputsInventory,
+ progressSupplier,
+ windowOffset);
+ addRecipeSpecificDrawable(
+ builder,
+ windowOffset,
+ () -> projectTexture,
+ new Pos2d(124, 28),
+ new Size(18, 18));
+ return builder;
+ }
+
+ @Override
+ public List<Pos2d> getItemInputPositions(int itemInputCount) {
+ return UIHelper.getGridPositions(itemInputCount, 16, 28, 3);
+ }
+
+ @Override
+ public List<Pos2d> getFluidInputPositions(int fluidInputCount) {
+ return UIHelper.getGridPositions(fluidInputCount, 88, 28, 1);
+ }
+
+ @Override
+ protected List<String> handleNEIItemInputTooltip(List<String> currentTip,
+ GT_NEI_DefaultHandler.FixedPositionedStack pStack) {
+ super.handleNEIItemOutputTooltip(currentTip, pStack);
+ if (pStack.item != null && pStack.item.getItem() instanceof GT_FluidDisplayItem) return currentTip;
+ currentTip.add(GRAY + translateToLocal("Item Count: ") + formatNumbers(pStack.realStackSize));
+ return currentTip;
+ }
+
+ @Override
+ public void drawNEIOverlays(GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) {
+ for (PositionedStack stack : neiCachedRecipe.mInputs) {
+ if (stack instanceof GT_NEI_DefaultHandler.FixedPositionedStack && stack.item != null
+ && !(stack.item.getItem() instanceof GT_FluidDisplayItem)) {
+ int stackSize = ((GT_NEI_DefaultHandler.FixedPositionedStack) stack).realStackSize;
+ String displayString;
+ if (stack.item.stackSize > 9999) {
+ displayString = ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize);
+ } else {
+ displayString = String.valueOf(stackSize);
+ }
+ drawNEIOverlayText(displayString, stack, 0xffffff, 0.5f, true, Alignment.BottomRight);
+ }
+ }
+ if (neiCachedRecipe.mRecipe instanceof GT_FakeSpaceProjectRecipe) {
+ ISpaceProject project = SpaceProjectManager
+ .getProject(((GT_FakeSpaceProjectRecipe) neiCachedRecipe.mRecipe).projectName);
+ if (project != null) {
+ projectTexture = project.getTexture();
+ GuiDraw.drawStringC(
+ EnumChatFormatting.BOLD + project.getLocalizedName(),
+ 85,
+ 0,
+ 0x404040,
+ false);
+ }
+ }
+ }
+
+ @Override
+ public void addProgressBarUI(ModularWindow.Builder builder, Supplier<Float> progressSupplier,
+ Pos2d windowOffset) {
+ int bar1Width = 17;
+ int bar2Width = 18;
+ builder.widget(
+ new ProgressBar().setTexture(GT_UITextures.PROGRESSBAR_ASSEMBLY_LINE_1, 17)
+ .setDirection(ProgressBar.Direction.RIGHT)
+ .setProgress(
+ () -> progressSupplier.get() * ((float) (bar1Width + bar2Width) / bar1Width))
+ .setSynced(false, false).setPos(new Pos2d(70, 28).add(windowOffset))
+ .setSize(bar1Width, 72));
+ builder.widget(
+ new ProgressBar().setTexture(GT_UITextures.PROGRESSBAR_ASSEMBLY_LINE_2, 18)
+ .setDirection(ProgressBar.Direction.RIGHT)
+ .setProgress(
+ () -> (progressSupplier.get() - ((float) bar1Width / (bar1Width + bar2Width)))
+ * ((float) (bar1Width + bar2Width) / bar2Width))
+ .setSynced(false, false).setPos(new Pos2d(106, 28).add(windowOffset))
+ .setSize(bar2Width, 72));
+ }
+ }.useModularUI(true).setRenderRealStackSizes(false).setUsualFluidInputCount(4).setNEIBackgroundOffset(2, 23)
+ .setLogoPos(152, 83);
+
public static class TranscendentPlasmaMixerRecipeMap extends GT_Recipe_Map {
public TranscendentPlasmaMixerRecipeMap(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName,
@@ -2624,6 +2755,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
public boolean useComparatorForNEI;
/**
+ * Whether to render the actual size of stacks or a size of 1.
+ */
+ public boolean renderRealStackSizes = true;
+
+ /**
* Initialises a new type of Recipe Handler.
*
* @param aRecipeList a List you specify as Recipe List. Usually just an ArrayList with a
@@ -2712,6 +2848,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
return this;
}
+ public GT_Recipe_Map setRenderRealStackSizes(boolean renderRealStackSizes) {
+ this.renderRealStackSizes = renderRealStackSizes;
+ return this;
+ }
+
public GT_Recipe_Map useModularUI(boolean use) {
this.useModularUI = use;
return this;
@@ -3362,6 +3503,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
builder.widget(new DrawableWidget().setDrawable(logo).setSize(logoSize).setPos(logoPos.add(windowOffset)));
}
+ public void addRecipeSpecificDrawable(ModularWindow.Builder builder, Pos2d windowOffset,
+ Supplier<IDrawable> supplier, Pos2d pos, Size size) {
+ builder.widget(new DrawableWidget().setDrawable(supplier).setSize(size).setPos(pos.add(windowOffset)));
+ }
+
/**
* Overriding this method allows custom NEI stack placement
*/