diff --git a/src/main/java/ru/betterend/integration/rei/REIAlloyingCategory.java b/src/main/java/ru/betterend/integration/rei/REIAlloyingCategory.java index 507cfc15..ea8adbb0 100644 --- a/src/main/java/ru/betterend/integration/rei/REIAlloyingCategory.java +++ b/src/main/java/ru/betterend/integration/rei/REIAlloyingCategory.java @@ -1,43 +1,42 @@ package ru.betterend.integration.rei; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.vertex.PoseStack; +import it.unimi.dsi.fastutil.ints.IntList; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.DisplayRenderer; +import me.shedaniel.rei.api.client.gui.SimpleDisplayRenderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.TransferDisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import org.jetbrains.annotations.NotNull; +import ru.betterend.recipe.builders.AlloyingRecipe; +import ru.betterend.registry.EndBlocks; + import java.text.DecimalFormat; import java.util.List; -import org.jetbrains.annotations.NotNull; - -import com.google.common.collect.Lists; -import com.mojang.blaze3d.vertex.PoseStack; - -import it.unimi.dsi.fastutil.ints.IntList; -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.EntryStack; -import me.shedaniel.rei.api.TransferRecipeCategory; -import me.shedaniel.rei.api.widgets.Widgets; -import me.shedaniel.rei.gui.entries.RecipeEntry; -import me.shedaniel.rei.gui.entries.SimpleRecipeEntry; -import me.shedaniel.rei.gui.widget.Widget; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.resources.ResourceLocation; -import ru.betterend.recipe.builders.AlloyingRecipe; -import ru.betterend.registry.EndBlocks; -import ru.betterend.util.LangUtil; - -public class REIAlloyingCategory implements TransferRecipeCategory { +public class REIAlloyingCategory implements TransferDisplayCategory { @Override - public @NotNull ResourceLocation getIdentifier() { + public @NotNull CategoryIdentifier getCategoryIdentifier() { return AlloyingRecipe.ID; } @Override - public @NotNull String getCategoryName() { - return LangUtil.translate(EndBlocks.END_STONE_SMELTER.getDescriptionId()); + public @NotNull Component getTitle() { + return new TranslatableComponent(EndBlocks.END_STONE_SMELTER.getDescriptionId()); } @Override - public @NotNull EntryStack getLogo() { + public @NotNull EntryStack getIcon() { return REIPlugin.END_STONE_SMELTER; } @@ -53,14 +52,14 @@ public class REIAlloyingCategory implements TransferRecipeCategory> inputEntries = display.getInputEntries(); + List inputEntries = display.getInputEntries(); widgets.add(Widgets.createSlot(new Point(startPoint.x - 20, startPoint.y + 1)).entries(inputEntries.get(0)).markInput()); if (inputEntries.size() > 1) { widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(inputEntries.get(1)).markInput()); } else { widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(Lists.newArrayList()).markInput()); } - widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput()); + widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput()); return widgets; } @@ -78,8 +77,8 @@ public class REIAlloyingCategory implements TransferRecipeCategory fuel; private Recipe recipe; - private List> input; - private List output; private float xp; private double smeltTime; + + public REIAlloyingDisplay(AlloyingRecipe recipe) { + super( + EntryIngredients.ofIngredients(recipe.getIngredients()), + Collections.singletonList(EntryIngredients.of(recipe.getResultItem())) + ); this.recipe = recipe; - this.input = EntryStack.ofIngredients(recipe.getIngredients()); - this.output = Collections.singletonList(EntryStack.create(recipe.getResultItem())); this.xp = recipe.getExperience(); this.smeltTime = recipe.getSmeltTime(); } public REIAlloyingDisplay(BlastingRecipe recipe) { + super( + EntryIngredients.ofIngredients(recipe.getIngredients()), + Collections.singletonList(EntryIngredients.of(recipe.getResultItem())) + ); this.recipe = recipe; - this.input = EntryStack.ofIngredients(recipe.getIngredients()); - this.output = Collections.singletonList(EntryStack.create(recipe.getResultItem())); this.xp = recipe.getExperience(); this.smeltTime = recipe.getCookingTime(); } @@ -51,29 +56,19 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay { } @Override - public @NotNull Optional getRecipeLocation() { + public @NotNull Optional getDisplayLocation() { return Optional.ofNullable(recipe).map(Recipe::getId); } - - @Override - public @NotNull List> getInputEntries() { - return this.input; - } - - @Override - public @NotNull List> getResultingEntries() { - return Collections.singletonList(output); - } @Override - public @NotNull ResourceLocation getRecipeCategory() { + public CategoryIdentifier getCategoryIdentifier() { return AlloyingRecipe.ID; } - @Override - public @NotNull List> getRequiredEntries() { - return this.input; - } + // @Override + // public @NotNull List> getRequiredEntries() { + // return this.input; + // } public float getXp() { return this.xp; @@ -97,14 +92,14 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay { return 1; } - @Override - public List> getOrganisedInputEntries(ContainerInfo containerInfo, AbstractContainerMenu container) { - return this.input; - } + // @Override + // public List> getOrganisedInputEntries(ContainerInfo containerInfo, AbstractContainerMenu container) { + // return this.input; + // } static { fuel = EndStoneSmelterBlockEntity.availableFuels().keySet().stream() - .map(Item::getDefaultInstance).map(EntryStack::create) + .map(Item::getDefaultInstance).map(EntryStacks::of) .map(e -> e.setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, stack -> Collections.singletonList(new TranslatableComponent("category.rei.smelting.fuel") .withStyle(ChatFormatting.YELLOW)))).collect(Collectors.toList()); } diff --git a/src/main/java/ru/betterend/integration/rei/REIAlloyingFuelCategory.java b/src/main/java/ru/betterend/integration/rei/REIAlloyingFuelCategory.java index 8b7a552a..930d3e3e 100644 --- a/src/main/java/ru/betterend/integration/rei/REIAlloyingFuelCategory.java +++ b/src/main/java/ru/betterend/integration/rei/REIAlloyingFuelCategory.java @@ -1,40 +1,39 @@ package ru.betterend.integration.rei; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.DisplayRenderer; +import me.shedaniel.rei.api.client.gui.widgets.Slot; +import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.item.Items; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.text.DecimalFormat; import java.util.List; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import com.google.common.collect.Lists; -import com.mojang.blaze3d.vertex.PoseStack; - -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.EntryStack; -import me.shedaniel.rei.api.RecipeCategory; -import me.shedaniel.rei.api.widgets.Slot; -import me.shedaniel.rei.api.widgets.Tooltip; -import me.shedaniel.rei.api.widgets.Widgets; -import me.shedaniel.rei.gui.entries.RecipeEntry; -import me.shedaniel.rei.gui.widget.Widget; -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.language.I18n; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Items; - -public class REIAlloyingFuelCategory implements RecipeCategory { +public class REIAlloyingFuelCategory implements DisplayCategory { private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##"); @Override - public @NotNull ResourceLocation getIdentifier() { + public @NotNull CategoryIdentifier getCategoryIdentifier() { return REIPlugin.ALLOYING_FUEL; } @Override - public @NotNull String getCategoryName() { - return I18n.get("category.rei.fuel"); + public @NotNull Component getTitle() { + return new TranslatableComponent("category.rei.fuel"); } @Override @@ -43,12 +42,12 @@ public class REIAlloyingFuelCategory implements RecipeCategory setupDisplay(REIAlloyingFuelDisplay recipeDisplay, Rectangle bounds) { + public List setupDisplay(REIAlloyingFuelDisplay recipeDisplay, Rectangle bounds) { Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 17); String burnTime = DECIMAL_FORMAT.format(recipeDisplay.getFuelTime()); List widgets = Lists.newArrayList(); @@ -61,10 +60,10 @@ public class REIAlloyingFuelCategory implements RecipeCategory fuel, CompoundTag tag) { + this(fuel, tag.getInt("fuelTime")); + } + + public REIAlloyingFuelDisplay(List fuel, int fuelTime) { + super(fuel, Collections.emptyList()); this.fuelTime = fuelTime; } + /*public REIAlloyingFuelDisplay(EntryStack fuel, int fuelTime) { + this.fuel = fuel; + this.fuelTime = fuelTime; + }*/ @Override - public @NotNull List> getInputEntries() { - return Collections.singletonList(Collections.singletonList(fuel)); - } - - @Override - public @NotNull List> getResultingEntries() { - return Collections.emptyList(); - } - - @Override - public @NotNull ResourceLocation getRecipeCategory() { + public CategoryIdentifier getCategoryIdentifier() { return REIPlugin.ALLOYING_FUEL; }