From eaf85fdf763ab19216c40ecd8021d87320494145 Mon Sep 17 00:00:00 2001 From: MCTian-mi <35869948+MCTian-mi@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:50:45 +0800 Subject: [PATCH] fix: use a separate recipemap for it --- .../api/recipes/SuSyRecipeMaps.java | 7 ++++ .../common/item/armor/JetWingpack.java | 40 ++++++++++++------- .../resources/assets/susy/lang/en_us.lang | 1 + 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java b/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java index 1d7dd2f91..65126c386 100644 --- a/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java +++ b/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java @@ -331,6 +331,13 @@ public class SuSyRecipeMaps { .setSlotOverlay(true, false, GuiTextures.FURNACE_OVERLAY_2) .setSound(GTSoundEvents.FURNACE); + + public static final RecipeMap JET_WINGPACK_FUELS = new RecipeMap<>("jet_wingpack_fuels", 0, 0, 1, 0, new NoEnergyRecipeBuilder(), false) + .setSlotOverlay(false, false, GuiTextures.DARK_CANISTER_OVERLAY) + .setProgressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR, ProgressWidget.MoveType.HORIZONTAL) + .setSound(GTSoundEvents.TURBINE) + .allowEmptyOutput(); + public static void init(){ RecipeMaps.SIFTER_RECIPES.setMaxFluidInputs(1); RecipeMaps.SIFTER_RECIPES.setMaxFluidOutputs(1); diff --git a/src/main/java/supersymmetry/common/item/armor/JetWingpack.java b/src/main/java/supersymmetry/common/item/armor/JetWingpack.java index eac88401b..35a406cde 100644 --- a/src/main/java/supersymmetry/common/item/armor/JetWingpack.java +++ b/src/main/java/supersymmetry/common/item/armor/JetWingpack.java @@ -8,8 +8,7 @@ import gregtech.api.items.armor.ArmorUtils; import gregtech.api.items.metaitem.stats.*; import gregtech.api.recipes.Recipe; -import gregtech.api.recipes.RecipeMaps; -import gregtech.api.unification.material.Materials; +import gregtech.api.recipes.ingredients.GTRecipeInput; import gregtech.api.util.GTUtility; import gregtech.api.util.GradientUtil; import gregtech.api.util.input.KeyBind; @@ -29,6 +28,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandlerItem; @@ -40,6 +40,7 @@ import org.jetbrains.annotations.Nullable; import supersymmetry.api.capability.IElytraFlyingProvider; import supersymmetry.api.capability.SuSyCapabilities; +import supersymmetry.api.recipes.SuSyRecipeMaps; import supersymmetry.api.util.ElytraFlyingUtils; import supersymmetry.client.renderer.handler.JetWingpackModel; @@ -47,15 +48,16 @@ import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.function.Function; public class JetWingpack extends ArmorLogicSuite implements IItemHUDProvider { public static final int TANK_CAPACITY = 32000; - public static final Function COMBUSTION_FUEL_BURN_TIME = fluidStack -> { - Recipe recipe = RecipeMaps.GAS_TURBINE_FUELS.findRecipe( - Integer.MAX_VALUE, + public static final Function FUEL_BURN_TIME = fluidStack -> { + Recipe recipe = SuSyRecipeMaps.JET_WINGPACK_FUELS.findRecipe( + GTValues.V[GTValues.MV], Collections.emptyList(), Collections.singletonList(fluidStack)); return recipe != null ? recipe.getDuration() : 0; @@ -197,7 +199,7 @@ protected boolean drainFuel(@NotNull ItemStack stack, int amount, boolean simula FluidStack fuelStack = fluidHandler.drain(amount, false); if (fuelStack == null) return false; - int burnTime = COMBUSTION_FUEL_BURN_TIME.apply(fuelStack); + int burnTime = FUEL_BURN_TIME.apply(fuelStack); if (burnTime <= 0) return false; if (!simulate) { @@ -245,12 +247,11 @@ public ICapabilityProvider createProvider(ItemStack itemStack) { // Yeah, this is a bit bloat... public class JetWingpackBehaviour implements IItemDurabilityManager, IItemCapabilityProvider, IItemBehaviour, ISubItemHandler { - private static final IFilter JETPACK_FUEL_FILTER = new IFilter<>() { + private static final IFilter JET_WINGPACK_FUEL_FILTER = new IFilter<>() { @Override public boolean test(@NotNull FluidStack fluidStack) { - return RecipeMaps.COMBUSTION_GENERATOR_FUELS.find(Collections.emptyList(), - Collections.singletonList(fluidStack), (Objects::nonNull)) != null; + return FUEL_BURN_TIME.apply(fluidStack) > 0; } @Override @@ -285,7 +286,7 @@ public Pair getDurabilityColorsForDisplay(ItemStack itemStack) { @Override public ICapabilityProvider createProvider(ItemStack itemStack) { return new GTFluidHandlerItemStack(itemStack, maxCapacity) - .setFilter(JETPACK_FUEL_FILTER); + .setFilter(JET_WINGPACK_FUEL_FILTER); } @Override @@ -313,11 +314,22 @@ public String getItemSubType(ItemStack itemStack) { @Override public void getSubItems(ItemStack itemStack, CreativeTabs creativeTab, NonNullList subItems) { ItemStack copy = itemStack.copy(); - IFluidHandlerItem fluidHandlerItem = copy - .getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); + IFluidHandlerItem fluidHandlerItem = copy.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); if (fluidHandlerItem != null) { - fluidHandlerItem.fill(Materials.Diesel.getFluid(TANK_CAPACITY), true); - subItems.add(copy); + Optional firstRecipe = SuSyRecipeMaps.JET_WINGPACK_FUELS.getRecipeList().stream().findFirst(); + firstRecipe.ifPresent(recipe -> { + Optional inputFluidStack = recipe.getFluidInputs().stream() + .map(GTRecipeInput::getInputFluidStack) + .filter(Objects::nonNull) + .findFirst(); + inputFluidStack.ifPresent(stack -> { + Fluid fluid = stack.getFluid(); + if (fluid != null && stack.amount > 0) { + fluidHandlerItem.fill(new FluidStack(fluid, maxCapacity), true); + subItems.add(copy); + } + }); + }); } else { subItems.add(itemStack); } diff --git a/src/main/resources/assets/susy/lang/en_us.lang b/src/main/resources/assets/susy/lang/en_us.lang index 462f5a662..77e5d6c79 100644 --- a/src/main/resources/assets/susy/lang/en_us.lang +++ b/src/main/resources/assets/susy/lang/en_us.lang @@ -722,6 +722,7 @@ recipemap.large_steam_turbine.name=Large Steam Turbine recipemap.primitive_smelter.name=Primitive Smelting recipemap.large_fluid_pump.name=Large Fluid Pump recipemap.sieve_distillation.name=Fractional Distillation +recipemap.jet_wingpack_fuels.name=Jet Wingpack Fuels gregtech.multiblock.primitive_mud_pump.description=The Primitive Mud Pump is a Steam Era multiblock that collects mud once per second, but only if it is in a river biome, and when the controller is between Y = 64 and Y = 80 (Inclusive). It can use a Pump, ULV, or LV Output Hatch. gregtech.multiblock.ocean_pumper.description=The Ocean Pumper is an electrically powered multiblock that collects a base amount of 8,000 L Seawater per second (at MV), but only if it is in an ocean biome, and when the controller is between Y = 70 and Y = 75 (Inclusive). It needs an output hatch, a maintenance hatch, and an energy input hatch.