Skip to content

Commit

Permalink
fix: use a separate recipemap for it
Browse files Browse the repository at this point in the history
  • Loading branch information
MCTian-mi committed Dec 9, 2024
1 parent eb08eb3 commit eaf85fd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
7 changes: 7 additions & 0 deletions src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ public class SuSyRecipeMaps {
.setSlotOverlay(true, false, GuiTextures.FURNACE_OVERLAY_2)
.setSound(GTSoundEvents.FURNACE);


public static final RecipeMap<NoEnergyRecipeBuilder> 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);
Expand Down
40 changes: 26 additions & 14 deletions src/main/java/supersymmetry/common/item/armor/JetWingpack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -40,22 +40,24 @@
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;

import java.awt.*;
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<FluidStack, Integer> COMBUSTION_FUEL_BURN_TIME = fluidStack -> {
Recipe recipe = RecipeMaps.GAS_TURBINE_FUELS.findRecipe(
Integer.MAX_VALUE,
public static final Function<FluidStack, Integer> 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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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<FluidStack> JETPACK_FUEL_FILTER = new IFilter<>() {
private static final IFilter<FluidStack> 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
Expand Down Expand Up @@ -285,7 +286,7 @@ public Pair<Color, Color> getDurabilityColorsForDisplay(ItemStack itemStack) {
@Override
public ICapabilityProvider createProvider(ItemStack itemStack) {
return new GTFluidHandlerItemStack(itemStack, maxCapacity)
.setFilter(JETPACK_FUEL_FILTER);
.setFilter(JET_WINGPACK_FUEL_FILTER);
}

@Override
Expand Down Expand Up @@ -313,11 +314,22 @@ public String getItemSubType(ItemStack itemStack) {
@Override
public void getSubItems(ItemStack itemStack, CreativeTabs creativeTab, NonNullList<ItemStack> 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<Recipe> firstRecipe = SuSyRecipeMaps.JET_WINGPACK_FUELS.getRecipeList().stream().findFirst();
firstRecipe.ifPresent(recipe -> {
Optional<FluidStack> 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);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/susy/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit eaf85fd

Please sign in to comment.