Fixed some Recipe related issues

This commit is contained in:
Frank 2023-12-19 15:06:48 +01:00
parent 9a758565d7
commit 951a6d110c
8 changed files with 170 additions and 144 deletions

View file

@ -8,7 +8,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay;
@ -25,21 +25,27 @@ import org.jetbrains.annotations.NotNull;
public class REIAlloyingDisplay extends BasicDisplay implements SimpleGridMenuDisplay {
private static final List<EntryStack> fuel;
private static final List<EntryStack<?>> fuel;
private final Recipe<?> recipe;
private final RecipeHolder<?> recipe;
private final float xp;
private final double smeltTime;
public REIAlloyingDisplay(AlloyingRecipe recipe) {
this(recipe, recipe.getExperience(), recipe.getSmeltTime());
public REIAlloyingDisplay(RecipeHolder<AlloyingRecipe> recipe) {
this(recipe, recipe.value().getExperience(), recipe.value().getSmeltTime());
}
protected REIAlloyingDisplay(Recipe<?> recipe, float xp, double smeltTime) {
protected REIAlloyingDisplay(RecipeHolder<?> recipe, float xp, double smeltTime) {
super(
EntryIngredients.ofIngredients(recipe.getIngredients()),
Collections.singletonList(EntryIngredients.of(recipe.getResultItem(Minecraft.getInstance().level.registryAccess())))
EntryIngredients.ofIngredients(recipe.value().getIngredients()),
Collections.singletonList(
EntryIngredients.of(
recipe
.value()
.getResultItem(Minecraft.getInstance().level.registryAccess())
)
)
);
this.recipe = recipe;
this.xp = xp;
@ -47,13 +53,13 @@ public class REIAlloyingDisplay extends BasicDisplay implements SimpleGridMenuDi
}
public static List<EntryStack> getFuel() {
public static List<EntryStack<?>> getFuel() {
return fuel;
}
@Override
public @NotNull Optional<ResourceLocation> getDisplayLocation() {
return Optional.ofNullable(recipe).map(Recipe::getId);
return Optional.ofNullable(recipe).map(RecipeHolder::id);
}
@Override
@ -74,10 +80,6 @@ public class REIAlloyingDisplay extends BasicDisplay implements SimpleGridMenuDi
return this.smeltTime;
}
public Optional<Recipe<?>> getOptionalRecipe() {
return Optional.ofNullable(recipe);
}
@Override
public int getWidth() {
return 2;

View file

@ -5,7 +5,7 @@ import org.betterx.bclib.recipes.AnvilRecipe;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay;
@ -18,33 +18,37 @@ import org.jetbrains.annotations.NotNull;
public class REIAnvilDisplay extends BasicDisplay implements SimpleGridMenuDisplay {
private final AnvilRecipe recipe;
private final RecipeHolder<AnvilRecipe> recipe;
public REIAnvilDisplay(AnvilRecipe recipe) {
public REIAnvilDisplay(RecipeHolder<AnvilRecipe> recipe) {
super(
EntryIngredients.ofIngredients(recipe.getIngredients()),
Collections.singletonList(EntryIngredients.of(recipe.getResultItem(Minecraft.getInstance().level.registryAccess())))
EntryIngredients.ofIngredients(recipe.value().getIngredients()),
Collections.singletonList(
EntryIngredients.of(
recipe.value().getResultItem(Minecraft.getInstance().level.registryAccess())
)
)
);
this.recipe = recipe;
inputs.get(1).forEach(entryStack -> {
if (entryStack.getValue() instanceof ItemStack itemStack) {
itemStack.setCount(recipe.getInputCount());
itemStack.setCount(recipe.value().getInputCount());
}
});
}
public int getDamage() {
return recipe.getDamage();
return recipe.value().getDamage();
}
public int getAnvilLevel() {
return recipe.getAnvilLevel();
return recipe.value().getAnvilLevel();
}
@Override
public @NotNull Optional<ResourceLocation> getDisplayLocation() {
return Optional.ofNullable(recipe).map(Recipe::getId);
return Optional.ofNullable(recipe).map(RecipeHolder::id);
}
@Override

View file

@ -1,9 +1,10 @@
package org.betterx.betterend.integration.rei;
import net.minecraft.world.item.crafting.BlastingRecipe;
import net.minecraft.world.item.crafting.RecipeHolder;
public class REIBlastingDisplay extends REIAlloyingDisplay {
public REIBlastingDisplay(BlastingRecipe recipe) {
super(recipe, recipe.getExperience(), recipe.getCookingTime());
public REIBlastingDisplay(RecipeHolder<BlastingRecipe> recipe) {
super(recipe, recipe.value().getExperience(), recipe.value().getCookingTime());
}
}

View file

@ -4,7 +4,7 @@ import org.betterx.betterend.recipe.builders.InfusionRecipe;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay;
@ -17,16 +17,20 @@ import org.jetbrains.annotations.NotNull;
public class REIInfusionDisplay extends BasicDisplay implements SimpleGridMenuDisplay {
private final InfusionRecipe recipe;
private final RecipeHolder<InfusionRecipe> recipe;
private final int time;
public REIInfusionDisplay(InfusionRecipe recipe) {
public REIInfusionDisplay(RecipeHolder<InfusionRecipe> recipe) {
super(
EntryIngredients.ofIngredients(recipe.getIngredients()),
Collections.singletonList(EntryIngredients.of(recipe.getResultItem(Minecraft.getInstance().level.registryAccess())))
EntryIngredients.ofIngredients(recipe.value().getIngredients()),
Collections.singletonList(
EntryIngredients.of(
recipe.value().getResultItem(Minecraft.getInstance().level.registryAccess())
)
)
);
this.recipe = recipe;
this.time = recipe.getInfusionTime();
this.time = recipe.value().getInfusionTime();
}
public int getInfusionTime() {
@ -35,7 +39,7 @@ public class REIInfusionDisplay extends BasicDisplay implements SimpleGridMenuDi
@Override
public @NotNull Optional<ResourceLocation> getDisplayLocation() {
return Optional.ofNullable(recipe).map(Recipe::getId);
return Optional.ofNullable(recipe).map(RecipeHolder::id);
}
@Override