From e0d44ef54e52601b75224f0a5e92108af072d8b6 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 8 Jun 2022 18:53:42 +0200 Subject: [PATCH] Re-Enabled REI --- build.gradle | 5 +- gradle.properties | 2 +- .../integration/rei/REIAlloyingCategory.java | 172 +++++++------- .../integration/rei/REIAlloyingDisplay.java | 214 ++++++++--------- .../rei/REIAlloyingFuelCategory.java | 211 ++++++++--------- .../rei/REIAlloyingFuelDisplay.java | 54 ++--- .../integration/rei/REIAnvilCategory.java | 180 +++++++------- .../integration/rei/REIAnvilDisplay.java | 126 +++++----- .../integration/rei/REIBlastingDisplay.java | 18 +- .../integration/rei/REIInfusionCategory.java | 222 +++++++++--------- .../integration/rei/REIInfusionDisplay.java | 126 +++++----- .../betterend/integration/rei/REIPlugin.java | 212 ++++++++--------- src/main/resources/fabric.mod.json | 2 +- 13 files changed, 770 insertions(+), 774 deletions(-) diff --git a/build.gradle b/build.gradle index 4690fd86..acbcea3f 100644 --- a/build.gradle +++ b/build.gradle @@ -46,9 +46,8 @@ dependencies { } else { modImplementation "com.github.quiqueck:BCLib:${project.bclib_version}" } - - // useOptional "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" - //useOptional "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}" + useOptional "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" + useOptional "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}" } def useOptional(String dep) { diff --git a/gradle.properties b/gradle.properties index a5ccca28..81f2db51 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,4 +20,4 @@ archives_base_name=better-end patchouli_version = 55-FABRIC-SNAPSHOT bclib_version = 1.19-SNAPSHOT -rei_version = 9.0.458 +rei_version = 9.0.472 diff --git a/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingCategory.java b/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingCategory.java index 90df9739..4abd640f 100644 --- a/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingCategory.java +++ b/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingCategory.java @@ -1,86 +1,86 @@ -//package org.betterx.betterend.integration.rei; -// -// -//import net.minecraft.network.chat.Component; -// -//import com.google.common.collect.Lists; -//import me.shedaniel.math.Point; -//import me.shedaniel.math.Rectangle; -//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.EntryIngredient; -//import me.shedaniel.rei.api.common.entry.EntryStack; -//import org.betterx.betterend.registry.EndBlocks; -// -//import java.text.DecimalFormat; -//import java.util.List; -//import org.jetbrains.annotations.NotNull; -// -//public class REIAlloyingCategory implements DisplayCategory { -// private final EntryStack ICON; -// -// REIAlloyingCategory(EntryStack icon) { -// ICON = icon; -// } -// -// @Override -// public @NotNull CategoryIdentifier getCategoryIdentifier() { -// return REIPlugin.ALLOYING; -// } -// -// @Override -// public @NotNull Component getTitle() { -// return Component.translatable(EndBlocks.END_STONE_SMELTER.getDescriptionId()); -// } -// -// @Override -// public @NotNull EntryStack getIcon() { -// return ICON; -// } -// -// @Override -// public @NotNull List setupDisplay(REIAlloyingDisplay display, Rectangle bounds) { -// Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10); -// double smeltTime = display.getSmeltTime(); -// DecimalFormat df = new DecimalFormat("###.##"); -// List widgets = Lists.newArrayList(); -// widgets.add(Widgets.createRecipeBase(bounds)); -// widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9))); -// widgets.add(Widgets.createBurningFire(new Point(startPoint.x - 9, startPoint.y + 20)) -// .animationDurationMS(10000)); -// widgets.add(Widgets.createLabel( -// new Point(bounds.x + bounds.width - 5, bounds.y + 5), -// Component.translatable("category.rei.cooking.time&xp", -// df.format(display.getXp()), -// df.format(smeltTime / 20D) -// ) -// ).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); -// widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)) -// .animationDurationTicks(smeltTime)); -// 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.getOutputEntries().get(0)) -// .disableBackground() -// .markOutput()); -// return widgets; -// } -// -// @Override -// public int getDisplayHeight() { -// return 49; -// } -//} \ No newline at end of file +package org.betterx.betterend.integration.rei; + + +import net.minecraft.network.chat.Component; + +import com.google.common.collect.Lists; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +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.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; +import org.betterx.betterend.registry.EndBlocks; + +import java.text.DecimalFormat; +import java.util.List; +import org.jetbrains.annotations.NotNull; + +public class REIAlloyingCategory implements DisplayCategory { + private final EntryStack ICON; + + REIAlloyingCategory(EntryStack icon) { + ICON = icon; + } + + @Override + public @NotNull CategoryIdentifier getCategoryIdentifier() { + return REIPlugin.ALLOYING; + } + + @Override + public @NotNull Component getTitle() { + return Component.translatable(EndBlocks.END_STONE_SMELTER.getDescriptionId()); + } + + @Override + public @NotNull EntryStack getIcon() { + return ICON; + } + + @Override + public @NotNull List setupDisplay(REIAlloyingDisplay display, Rectangle bounds) { + Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10); + double smeltTime = display.getSmeltTime(); + DecimalFormat df = new DecimalFormat("###.##"); + List widgets = Lists.newArrayList(); + widgets.add(Widgets.createRecipeBase(bounds)); + widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9))); + widgets.add(Widgets.createBurningFire(new Point(startPoint.x - 9, startPoint.y + 20)) + .animationDurationMS(10000)); + widgets.add(Widgets.createLabel( + new Point(bounds.x + bounds.width - 5, bounds.y + 5), + Component.translatable("category.rei.cooking.time&xp", + df.format(display.getXp()), + df.format(smeltTime / 20D) + ) + ).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); + widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)) + .animationDurationTicks(smeltTime)); + 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.getOutputEntries().get(0)) + .disableBackground() + .markOutput()); + return widgets; + } + + @Override + public int getDisplayHeight() { + return 49; + } +} \ No newline at end of file diff --git a/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingDisplay.java b/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingDisplay.java index 103e4b76..85b2a2c5 100644 --- a/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingDisplay.java +++ b/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingDisplay.java @@ -1,107 +1,107 @@ -//package org.betterx.betterend.integration.rei; -// -//import net.minecraft.ChatFormatting; -//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 me.shedaniel.rei.api.common.category.CategoryIdentifier; -//import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay; -//import me.shedaniel.rei.api.common.display.basic.BasicDisplay; -//import me.shedaniel.rei.api.common.entry.EntryStack; -//import me.shedaniel.rei.api.common.util.EntryIngredients; -//import me.shedaniel.rei.api.common.util.EntryStacks; -//import org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity; -//import org.betterx.betterend.recipe.builders.AlloyingRecipe; -// -//import java.util.Collections; -//import java.util.List; -//import java.util.Optional; -//import java.util.stream.Collectors; -//import org.jetbrains.annotations.NotNull; -// -//public class REIAlloyingDisplay extends BasicDisplay implements SimpleGridMenuDisplay { -// -// private static List fuel; -// -// private Recipe recipe; -// private float xp; -// private double smeltTime; -// -// -// public REIAlloyingDisplay(AlloyingRecipe recipe) { -// this(recipe, recipe.getExperience(), recipe.getSmeltTime()); -// } -// -// protected REIAlloyingDisplay(Recipe recipe, float xp, double smeltTime) { -// super( -// EntryIngredients.ofIngredients(recipe.getIngredients()), -// Collections.singletonList(EntryIngredients.of(recipe.getResultItem())) -// ); -// this.recipe = recipe; -// this.xp = xp; -// this.smeltTime = smeltTime; -// } -// -// -// public static List getFuel() { -// return fuel; -// } -// -// @Override -// public @NotNull Optional getDisplayLocation() { -// return Optional.ofNullable(recipe).map(Recipe::getId); -// } -// -// @Override -// public CategoryIdentifier getCategoryIdentifier() { -// return REIPlugin.ALLOYING; -// } -// -// // @Override -// // public @NotNull List> getRequiredEntries() { -// // return this.input; -// // } -// -// public float getXp() { -// return this.xp; -// } -// -// public double getSmeltTime() { -// return this.smeltTime; -// } -// -// public Optional> getOptionalRecipe() { -// return Optional.ofNullable(recipe); -// } -// -// @Override -// public int getWidth() { -// return 2; -// } -// -// @Override -// public int getHeight() { -// return 1; -// } -// -// // @Override -// // public List> getOrganisedInputEntries(ContainerInfo containerInfo, AbstractContainerMenu container) { -// // return this.input; -// // } -// -// static { -// fuel = EndStoneSmelterBlockEntity.availableFuels() -// .keySet() -// .stream() -// .map(Item::getDefaultInstance) -// .map(EntryStacks::of) -// .map(e -> e.setting( -// EntryStack.Settings.TOOLTIP_APPEND_EXTRA, -// stack -> Collections.singletonList(Component.translatable( -// "category.rei.smelting.fuel").withStyle(ChatFormatting.YELLOW)) -// )) -// .collect(Collectors.toList()); -// } -//} \ No newline at end of file +package org.betterx.betterend.integration.rei; + +import net.minecraft.ChatFormatting; +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 me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay; +import me.shedaniel.rei.api.common.display.basic.BasicDisplay; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import me.shedaniel.rei.api.common.util.EntryStacks; +import org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity; +import org.betterx.betterend.recipe.builders.AlloyingRecipe; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import org.jetbrains.annotations.NotNull; + +public class REIAlloyingDisplay extends BasicDisplay implements SimpleGridMenuDisplay { + + private static List fuel; + + private Recipe recipe; + private float xp; + private double smeltTime; + + + public REIAlloyingDisplay(AlloyingRecipe recipe) { + this(recipe, recipe.getExperience(), recipe.getSmeltTime()); + } + + protected REIAlloyingDisplay(Recipe recipe, float xp, double smeltTime) { + super( + EntryIngredients.ofIngredients(recipe.getIngredients()), + Collections.singletonList(EntryIngredients.of(recipe.getResultItem())) + ); + this.recipe = recipe; + this.xp = xp; + this.smeltTime = smeltTime; + } + + + public static List getFuel() { + return fuel; + } + + @Override + public @NotNull Optional getDisplayLocation() { + return Optional.ofNullable(recipe).map(Recipe::getId); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return REIPlugin.ALLOYING; + } + + // @Override + // public @NotNull List> getRequiredEntries() { + // return this.input; + // } + + public float getXp() { + return this.xp; + } + + public double getSmeltTime() { + return this.smeltTime; + } + + public Optional> getOptionalRecipe() { + return Optional.ofNullable(recipe); + } + + @Override + public int getWidth() { + return 2; + } + + @Override + public int getHeight() { + return 1; + } + + // @Override + // public List> getOrganisedInputEntries(ContainerInfo containerInfo, AbstractContainerMenu container) { + // return this.input; + // } + + static { + fuel = EndStoneSmelterBlockEntity.availableFuels() + .keySet() + .stream() + .map(Item::getDefaultInstance) + .map(EntryStacks::of) + .map(e -> e.setting( + EntryStack.Settings.TOOLTIP_APPEND_EXTRA, + stack -> Collections.singletonList(Component.translatable( + "category.rei.smelting.fuel").withStyle(ChatFormatting.YELLOW)) + )) + .collect(Collectors.toList()); + } +} \ No newline at end of file diff --git a/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingFuelCategory.java b/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingFuelCategory.java index ea2536f7..27a04d50 100644 --- a/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingFuelCategory.java +++ b/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingFuelCategory.java @@ -1,107 +1,104 @@ -//package org.betterx.betterend.integration.rei; -// -//import net.minecraft.client.Minecraft; -//import net.minecraft.network.chat.Component; -//import net.minecraft.world.item.Items; -// -//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 java.text.DecimalFormat; -//import java.util.List; -//import org.jetbrains.annotations.NotNull; -//import org.jetbrains.annotations.Nullable; -// -//public class REIAlloyingFuelCategory implements DisplayCategory { -// private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##"); -// -// @Override -// public @NotNull CategoryIdentifier getCategoryIdentifier() { -// return REIPlugin.ALLOYING_FUEL; -// } -// -// @Override -// public @NotNull Component getTitle() { -// return Component.translatable("category.rei.fuel"); -// } -// -// @Override -// public int getDisplayHeight() { -// return 49; -// } -// -// @Override -// public @NotNull EntryStack getIcon() { -// return EntryStacks.of(Items.LAVA_BUCKET); -// } -// -// @Override -// 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(); -// widgets.add(Widgets.createRecipeBase(bounds)); -// widgets.add(Widgets.createLabel( -// new Point(bounds.x + 26, bounds.getMaxY() - 15), -// Component.translatable("category.rei.fuel.time", burnTime) -// ).color(0xFF404040, 0xFFBBBBBB).noShadow().leftAligned()); -// widgets.add(Widgets.createBurningFire(new Point(bounds.x + 6, startPoint.y + 1)) -// .animationDurationTicks(recipeDisplay.getFuelTime())); -// widgets.add(Widgets.createSlot(new Point(bounds.x + 6, startPoint.y + 18)) -// .entries(recipeDisplay.getInputEntries().get(0)) -// .markInput()); -// return widgets; -// } -// -// @Override -// public DisplayRenderer getDisplayRenderer(REIAlloyingFuelDisplay recipe) { -// Slot slot = Widgets.createSlot(new Point(0, 0)) -// .entries(recipe.getInputEntries().get(0)) -// .disableBackground() -// .disableHighlight(); -// String burnItems = DECIMAL_FORMAT.format(recipe.getFuelTime() / 200d); -// return new DisplayRenderer() { -// private Component text = Component.translatable( -// "category.rei.fuel.time_short.items", -// burnItems -// ); -// -// @Override -// public int getHeight() { -// return 22; -// } -// -// @Nullable -// @Override -// public Tooltip getTooltip(Point point) { -// if (slot.containsMouse(point)) return slot.getCurrentTooltip(point); -// return null; -// } -// -// @Override -// public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { -// slot.setZ(getZ() + 50); -// slot.getBounds().setLocation(bounds.x + 4, bounds.y + 2); -// slot.render(matrices, mouseX, mouseY, delta); -// Minecraft.getInstance().font.drawShadow( -// matrices, -// text.getVisualOrderText(), -// bounds.x + 25, -// bounds.y + 8, -// -1 -// ); -// } -// }; -// } -//} \ No newline at end of file +package org.betterx.betterend.integration.rei; + +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.Items; + +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.*; +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 java.text.DecimalFormat; +import java.util.List; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class REIAlloyingFuelCategory implements DisplayCategory { + private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##"); + + @Override + public @NotNull CategoryIdentifier getCategoryIdentifier() { + return REIPlugin.ALLOYING_FUEL; + } + + @Override + public @NotNull Component getTitle() { + return Component.translatable("category.rei.fuel"); + } + + @Override + public int getDisplayHeight() { + return 49; + } + + @Override + public @NotNull EntryStack getIcon() { + return EntryStacks.of(Items.LAVA_BUCKET); + } + + @Override + 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(); + widgets.add(Widgets.createRecipeBase(bounds)); + widgets.add(Widgets.createLabel( + new Point(bounds.x + 26, bounds.getMaxY() - 15), + Component.translatable("category.rei.fuel.time", burnTime) + ).color(0xFF404040, 0xFFBBBBBB).noShadow().leftAligned()); + widgets.add(Widgets.createBurningFire(new Point(bounds.x + 6, startPoint.y + 1)) + .animationDurationTicks(recipeDisplay.getFuelTime())); + widgets.add(Widgets.createSlot(new Point(bounds.x + 6, startPoint.y + 18)) + .entries(recipeDisplay.getInputEntries().get(0)) + .markInput()); + return widgets; + } + + @Override + public DisplayRenderer getDisplayRenderer(REIAlloyingFuelDisplay recipe) { + Slot slot = Widgets.createSlot(new Point(0, 0)) + .entries(recipe.getInputEntries().get(0)) + .disableBackground() + .disableHighlight(); + String burnItems = DECIMAL_FORMAT.format(recipe.getFuelTime() / 200d); + return new DisplayRenderer() { + private Component text = Component.translatable( + "category.rei.fuel.time_short.items", + burnItems + ); + + @Override + public int getHeight() { + return 22; + } + + @Nullable + @Override + public Tooltip getTooltip(TooltipContext ctx) { + if (slot.containsMouse(ctx.getPoint())) return slot.getCurrentTooltip(ctx); + return null; + } + + @Override + public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { + slot.setZ(getZ() + 50); + slot.getBounds().setLocation(bounds.x + 4, bounds.y + 2); + slot.render(matrices, mouseX, mouseY, delta); + Minecraft.getInstance().font.drawShadow( + matrices, + text.getVisualOrderText(), + bounds.x + 25, + bounds.y + 8, + -1 + ); + } + }; + } +} \ No newline at end of file diff --git a/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingFuelDisplay.java b/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingFuelDisplay.java index ec7c1cf4..02f974d8 100644 --- a/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingFuelDisplay.java +++ b/src/main/java/org/betterx/betterend/integration/rei/REIAlloyingFuelDisplay.java @@ -1,27 +1,27 @@ -//package org.betterx.betterend.integration.rei; -// -//import me.shedaniel.rei.api.common.category.CategoryIdentifier; -//import me.shedaniel.rei.api.common.display.basic.BasicDisplay; -//import me.shedaniel.rei.api.common.entry.EntryIngredient; -// -//import java.util.Collections; -//import java.util.List; -// -//public class REIAlloyingFuelDisplay extends BasicDisplay { -// private final int fuelTime; -// -// public REIAlloyingFuelDisplay(List fuel, int fuelTime) { -// super(fuel, Collections.emptyList()); -// this.fuelTime = fuelTime; -// } -// -// @Override -// public CategoryIdentifier getCategoryIdentifier() { -// return REIPlugin.ALLOYING_FUEL; -// } -// -// public int getFuelTime() { -// return fuelTime; -// } -// -//} +package org.betterx.betterend.integration.rei; + +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.basic.BasicDisplay; +import me.shedaniel.rei.api.common.entry.EntryIngredient; + +import java.util.Collections; +import java.util.List; + +public class REIAlloyingFuelDisplay extends BasicDisplay { + private final int fuelTime; + + public REIAlloyingFuelDisplay(List fuel, int fuelTime) { + super(fuel, Collections.emptyList()); + this.fuelTime = fuelTime; + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return REIPlugin.ALLOYING_FUEL; + } + + public int getFuelTime() { + return fuelTime; + } + +} diff --git a/src/main/java/org/betterx/betterend/integration/rei/REIAnvilCategory.java b/src/main/java/org/betterx/betterend/integration/rei/REIAnvilCategory.java index 00b02b29..c6ebdc5c 100644 --- a/src/main/java/org/betterx/betterend/integration/rei/REIAnvilCategory.java +++ b/src/main/java/org/betterx/betterend/integration/rei/REIAnvilCategory.java @@ -1,90 +1,90 @@ -//package org.betterx.betterend.integration.rei; -// -//import net.minecraft.network.chat.Component; -//import net.minecraft.world.item.BlockItem; -//import net.minecraft.world.item.ItemStack; -//import net.minecraft.world.level.block.Block; -//import net.minecraft.world.level.block.Blocks; -// -//import com.google.common.collect.Lists; -//import me.shedaniel.math.Point; -//import me.shedaniel.math.Rectangle; -//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.EntryIngredient; -//import me.shedaniel.rei.api.common.entry.EntryStack; -//import org.betterx.betterend.blocks.basis.EndAnvilBlock; -// -//import java.util.Arrays; -//import java.util.List; -//import java.util.stream.Collectors; -//import org.jetbrains.annotations.NotNull; -// -//public class REIAnvilCategory implements DisplayCategory { -// private final EntryStack[] ANVILS; -// -// REIAnvilCategory(EntryStack[] anvils) { -// ANVILS = anvils; -// } -// -// @Override -// public CategoryIdentifier getCategoryIdentifier() { -// return REIPlugin.SMITHING; -// } -// -// @Override -// public @NotNull Component getTitle() { -// return Component.translatable(Blocks.ANVIL.getDescriptionId()); -// } -// -// @Override -// public @NotNull EntryStack getIcon() { -// return ANVILS[0]; -// } -// -// -// @Override -// public @NotNull List setupDisplay(REIAnvilDisplay display, Rectangle bounds) { -// Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10); -// List widgets = Lists.newArrayList(); -// widgets.add(Widgets.createRecipeBase(bounds)); -// int x = startPoint.x + 10; -// int y = startPoint.y; -// widgets.add(Widgets.createResultSlotBackground(new Point(x + 61, y + 5))); -// List inputEntries = display.getInputEntries(); -// EntryIngredient materials = inputEntries.get(1); -// int anvilLevel = display.getAnvilLevel(); -// List> anvils = Arrays.stream(ANVILS).filter(anvil -> { -// Object value = anvil.getValue(); -// if (value instanceof ItemStack) { -// value = ((ItemStack) value).getItem(); -// } -// Block block = ((BlockItem) value).getBlock(); -// if (block instanceof EndAnvilBlock) { -// return ((EndAnvilBlock) block).getCraftingLevel() >= anvilLevel; -// } -// return anvilLevel == 1; -// }).collect(Collectors.toList()); -// widgets.add(Widgets.createArrow(new Point(x + 24, y + 4))); -// widgets.add(Widgets.createLabel( -// new Point(bounds.x + bounds.width - 7, bounds.y + bounds.height - 15), -// Component.translatable("category.rei.damage.amount&dmg", display.getDamage()) -// ).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); -// widgets.add(Widgets.createSlot(new Point(x - 20, y + 4)).entries(materials).markInput()); -// widgets.add(Widgets.createSlot(new Point(x + 1, y + 4)).entries(inputEntries.get(0)).markInput()); -// widgets.add(Widgets.createSlot(new Point(x + 61, y + 5)) -// .entries(display.getOutputEntries().get(0)) -// .disableBackground() -// .markOutput()); -// widgets.add(Widgets.createSlot(new Point(x - 9, y + 25)).entries(anvils)); -// -// return widgets; -// } -// -// @Override -// public int getDisplayHeight() { -// return 60; -// } -//} \ No newline at end of file +package org.betterx.betterend.integration.rei; + +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; + +import com.google.common.collect.Lists; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +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.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; +import org.betterx.betterend.blocks.basis.EndAnvilBlock; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import org.jetbrains.annotations.NotNull; + +public class REIAnvilCategory implements DisplayCategory { + private final EntryStack[] ANVILS; + + REIAnvilCategory(EntryStack[] anvils) { + ANVILS = anvils; + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return REIPlugin.SMITHING; + } + + @Override + public @NotNull Component getTitle() { + return Component.translatable(Blocks.ANVIL.getDescriptionId()); + } + + @Override + public @NotNull EntryStack getIcon() { + return ANVILS[0]; + } + + + @Override + public @NotNull List setupDisplay(REIAnvilDisplay display, Rectangle bounds) { + Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10); + List widgets = Lists.newArrayList(); + widgets.add(Widgets.createRecipeBase(bounds)); + int x = startPoint.x + 10; + int y = startPoint.y; + widgets.add(Widgets.createResultSlotBackground(new Point(x + 61, y + 5))); + List inputEntries = display.getInputEntries(); + EntryIngredient materials = inputEntries.get(1); + int anvilLevel = display.getAnvilLevel(); + List> anvils = Arrays.stream(ANVILS).filter(anvil -> { + Object value = anvil.getValue(); + if (value instanceof ItemStack) { + value = ((ItemStack) value).getItem(); + } + Block block = ((BlockItem) value).getBlock(); + if (block instanceof EndAnvilBlock) { + return ((EndAnvilBlock) block).getCraftingLevel() >= anvilLevel; + } + return anvilLevel == 1; + }).collect(Collectors.toList()); + widgets.add(Widgets.createArrow(new Point(x + 24, y + 4))); + widgets.add(Widgets.createLabel( + new Point(bounds.x + bounds.width - 7, bounds.y + bounds.height - 15), + Component.translatable("category.rei.damage.amount&dmg", display.getDamage()) + ).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); + widgets.add(Widgets.createSlot(new Point(x - 20, y + 4)).entries(materials).markInput()); + widgets.add(Widgets.createSlot(new Point(x + 1, y + 4)).entries(inputEntries.get(0)).markInput()); + widgets.add(Widgets.createSlot(new Point(x + 61, y + 5)) + .entries(display.getOutputEntries().get(0)) + .disableBackground() + .markOutput()); + widgets.add(Widgets.createSlot(new Point(x - 9, y + 25)).entries(anvils)); + + return widgets; + } + + @Override + public int getDisplayHeight() { + return 60; + } +} \ No newline at end of file diff --git a/src/main/java/org/betterx/betterend/integration/rei/REIAnvilDisplay.java b/src/main/java/org/betterx/betterend/integration/rei/REIAnvilDisplay.java index f690084b..83c6e62a 100644 --- a/src/main/java/org/betterx/betterend/integration/rei/REIAnvilDisplay.java +++ b/src/main/java/org/betterx/betterend/integration/rei/REIAnvilDisplay.java @@ -1,63 +1,63 @@ -//package org.betterx.betterend.integration.rei; -// -//import net.minecraft.resources.ResourceLocation; -//import net.minecraft.world.item.ItemStack; -//import net.minecraft.world.item.crafting.Recipe; -// -//import me.shedaniel.rei.api.common.category.CategoryIdentifier; -//import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay; -//import me.shedaniel.rei.api.common.display.basic.BasicDisplay; -//import me.shedaniel.rei.api.common.util.EntryIngredients; -//import org.betterx.bclib.recipes.AnvilRecipe; -// -//import java.util.Collections; -//import java.util.Optional; -//import org.jetbrains.annotations.NotNull; -// -//public class REIAnvilDisplay extends BasicDisplay implements SimpleGridMenuDisplay { -// -// private final AnvilRecipe recipe; -// -// public REIAnvilDisplay(AnvilRecipe recipe) { -// super( -// EntryIngredients.ofIngredients(recipe.getIngredients()), -// Collections.singletonList(EntryIngredients.of(recipe.getResultItem())) -// ); -// this.recipe = recipe; -// -// inputs.get(1).forEach(entryStack -> { -// if (entryStack.getValue() instanceof ItemStack itemStack) { -// itemStack.setCount(recipe.getInputCount()); -// } -// }); -// } -// -// public int getDamage() { -// return recipe.getDamage(); -// } -// -// public int getAnvilLevel() { -// return recipe.getAnvilLevel(); -// } -// -// @Override -// public @NotNull Optional getDisplayLocation() { -// return Optional.ofNullable(recipe).map(Recipe::getId); -// } -// -// @Override -// public CategoryIdentifier getCategoryIdentifier() { -// return REIPlugin.SMITHING; -// } -// -// @Override -// public int getWidth() { -// return 2; -// } -// -// @Override -// public int getHeight() { -// return 1; -// } -//} -// +package org.betterx.betterend.integration.rei; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; + +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay; +import me.shedaniel.rei.api.common.display.basic.BasicDisplay; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import org.betterx.bclib.recipes.AnvilRecipe; + +import java.util.Collections; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +public class REIAnvilDisplay extends BasicDisplay implements SimpleGridMenuDisplay { + + private final AnvilRecipe recipe; + + public REIAnvilDisplay(AnvilRecipe recipe) { + super( + EntryIngredients.ofIngredients(recipe.getIngredients()), + Collections.singletonList(EntryIngredients.of(recipe.getResultItem())) + ); + this.recipe = recipe; + + inputs.get(1).forEach(entryStack -> { + if (entryStack.getValue() instanceof ItemStack itemStack) { + itemStack.setCount(recipe.getInputCount()); + } + }); + } + + public int getDamage() { + return recipe.getDamage(); + } + + public int getAnvilLevel() { + return recipe.getAnvilLevel(); + } + + @Override + public @NotNull Optional getDisplayLocation() { + return Optional.ofNullable(recipe).map(Recipe::getId); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return REIPlugin.SMITHING; + } + + @Override + public int getWidth() { + return 2; + } + + @Override + public int getHeight() { + return 1; + } +} + diff --git a/src/main/java/org/betterx/betterend/integration/rei/REIBlastingDisplay.java b/src/main/java/org/betterx/betterend/integration/rei/REIBlastingDisplay.java index 8cdc9317..2d752276 100644 --- a/src/main/java/org/betterx/betterend/integration/rei/REIBlastingDisplay.java +++ b/src/main/java/org/betterx/betterend/integration/rei/REIBlastingDisplay.java @@ -1,9 +1,9 @@ -//package org.betterx.betterend.integration.rei; -// -//import net.minecraft.world.item.crafting.BlastingRecipe; -// -//public class REIBlastingDisplay extends REIAlloyingDisplay { -// public REIBlastingDisplay(BlastingRecipe recipe) { -// super(recipe, recipe.getExperience(), recipe.getCookingTime()); -// } -//} \ No newline at end of file +package org.betterx.betterend.integration.rei; + +import net.minecraft.world.item.crafting.BlastingRecipe; + +public class REIBlastingDisplay extends REIAlloyingDisplay { + public REIBlastingDisplay(BlastingRecipe recipe) { + super(recipe, recipe.getExperience(), recipe.getCookingTime()); + } +} \ No newline at end of file diff --git a/src/main/java/org/betterx/betterend/integration/rei/REIInfusionCategory.java b/src/main/java/org/betterx/betterend/integration/rei/REIInfusionCategory.java index f3b44248..b1d3eab6 100644 --- a/src/main/java/org/betterx/betterend/integration/rei/REIInfusionCategory.java +++ b/src/main/java/org/betterx/betterend/integration/rei/REIInfusionCategory.java @@ -1,111 +1,111 @@ -//package org.betterx.betterend.integration.rei; -// -//import net.minecraft.network.chat.Component; -//import net.minecraft.resources.ResourceLocation; -// -//import com.google.common.collect.Lists; -//import me.shedaniel.math.Point; -//import me.shedaniel.math.Rectangle; -//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.EntryIngredient; -//import me.shedaniel.rei.api.common.entry.EntryStack; -//import org.betterx.betterend.BetterEnd; -//import org.betterx.betterend.registry.EndBlocks; -// -//import java.util.ArrayList; -//import java.util.List; -//import org.jetbrains.annotations.NotNull; -// -//public class REIInfusionCategory implements DisplayCategory { -// -// private final static ResourceLocation BACKGROUND = BetterEnd.makeID("textures/gui/rei_infusion.png"); -// private final EntryStack ICON; -// -// REIInfusionCategory(EntryStack icon) { -// ICON = icon; -// } -// -// @Override -// public @NotNull CategoryIdentifier getCategoryIdentifier() { -// return REIPlugin.INFUSION; -// } -// -// @Override -// public @NotNull Component getTitle() { -// return Component.translatable(EndBlocks.INFUSION_PEDESTAL.getDescriptionId()); -// } -// -// @Override -// public @NotNull EntryStack getIcon() { -// return ICON; -// } -// -// @Override -// public @NotNull List setupDisplay(REIInfusionDisplay display, Rectangle bounds) { -// Point centerPoint = new Point(bounds.getCenterX() - 34, bounds.getCenterY() - 2); -// List widgets = Lists.newArrayList(); -// widgets.add(Widgets.createRecipeBase(bounds)); -// List inputEntries = display.getInputEntries(); -// List outputEntries = display.getOutputEntries(); -// if (inputEntries.size() < 9) { -// List newList = new ArrayList(9); -// newList.addAll(inputEntries); -// for (int i = inputEntries.size(); i < 9; i++) { -// newList.add(EntryIngredient.empty()); -// } -// inputEntries = newList; -// } -// widgets.add(Widgets.createTexturedWidget(BACKGROUND, bounds.x, bounds.y, 0, 0, 150, 104, 150, 104)); -// widgets.add(Widgets.createSlot(centerPoint).entries(inputEntries.get(0)).disableBackground().markInput()); -// widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y - 28)) -// .entries(inputEntries.get(1)) -// .disableBackground() -// .markInput()); -// widgets.add(Widgets.createSlot(new Point(centerPoint.x + 28, centerPoint.y)) -// .entries(inputEntries.get(3)) -// .disableBackground() -// .markInput()); -// widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y + 28)) -// .entries(inputEntries.get(5)) -// .disableBackground() -// .markInput()); -// widgets.add(Widgets.createSlot(new Point(centerPoint.x - 28, centerPoint.y)) -// .entries(inputEntries.get(7)) -// .disableBackground() -// .markInput()); -// widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y - 24)) -// .entries(inputEntries.get(2)) -// .disableBackground() -// .markInput()); -// widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y + 24)) -// .entries(inputEntries.get(4)) -// .disableBackground() -// .markInput()); -// widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y + 24)) -// .entries(inputEntries.get(6)) -// .disableBackground() -// .markInput()); -// widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y - 24)) -// .entries(inputEntries.get(8)) -// .disableBackground() -// .markInput()); -// widgets.add(Widgets.createSlot(new Point(centerPoint.x + 80, centerPoint.y)) -// .entries(outputEntries.get(0)) -// .disableBackground() -// .markOutput()); -// widgets.add(Widgets.createLabel( -// new Point(bounds.getMaxX() - 5, bounds.y + 6), -// Component.translatable("category.rei.infusion.time&val", display.getInfusionTime()) -// ).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); -// return widgets; -// } -// -// @Override -// public int getDisplayHeight() { -// return 104; -// } -//} -// +package org.betterx.betterend.integration.rei; + +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; + +import com.google.common.collect.Lists; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +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.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; +import org.betterx.betterend.BetterEnd; +import org.betterx.betterend.registry.EndBlocks; + +import java.util.ArrayList; +import java.util.List; +import org.jetbrains.annotations.NotNull; + +public class REIInfusionCategory implements DisplayCategory { + + private final static ResourceLocation BACKGROUND = BetterEnd.makeID("textures/gui/rei_infusion.png"); + private final EntryStack ICON; + + REIInfusionCategory(EntryStack icon) { + ICON = icon; + } + + @Override + public @NotNull CategoryIdentifier getCategoryIdentifier() { + return REIPlugin.INFUSION; + } + + @Override + public @NotNull Component getTitle() { + return Component.translatable(EndBlocks.INFUSION_PEDESTAL.getDescriptionId()); + } + + @Override + public @NotNull EntryStack getIcon() { + return ICON; + } + + @Override + public @NotNull List setupDisplay(REIInfusionDisplay display, Rectangle bounds) { + Point centerPoint = new Point(bounds.getCenterX() - 34, bounds.getCenterY() - 2); + List widgets = Lists.newArrayList(); + widgets.add(Widgets.createRecipeBase(bounds)); + List inputEntries = display.getInputEntries(); + List outputEntries = display.getOutputEntries(); + if (inputEntries.size() < 9) { + List newList = new ArrayList(9); + newList.addAll(inputEntries); + for (int i = inputEntries.size(); i < 9; i++) { + newList.add(EntryIngredient.empty()); + } + inputEntries = newList; + } + widgets.add(Widgets.createTexturedWidget(BACKGROUND, bounds.x, bounds.y, 0, 0, 150, 104, 150, 104)); + widgets.add(Widgets.createSlot(centerPoint).entries(inputEntries.get(0)).disableBackground().markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y - 28)) + .entries(inputEntries.get(1)) + .disableBackground() + .markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x + 28, centerPoint.y)) + .entries(inputEntries.get(3)) + .disableBackground() + .markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y + 28)) + .entries(inputEntries.get(5)) + .disableBackground() + .markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x - 28, centerPoint.y)) + .entries(inputEntries.get(7)) + .disableBackground() + .markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y - 24)) + .entries(inputEntries.get(2)) + .disableBackground() + .markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y + 24)) + .entries(inputEntries.get(4)) + .disableBackground() + .markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y + 24)) + .entries(inputEntries.get(6)) + .disableBackground() + .markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y - 24)) + .entries(inputEntries.get(8)) + .disableBackground() + .markInput()); + widgets.add(Widgets.createSlot(new Point(centerPoint.x + 80, centerPoint.y)) + .entries(outputEntries.get(0)) + .disableBackground() + .markOutput()); + widgets.add(Widgets.createLabel( + new Point(bounds.getMaxX() - 5, bounds.y + 6), + Component.translatable("category.rei.infusion.time&val", display.getInfusionTime()) + ).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); + return widgets; + } + + @Override + public int getDisplayHeight() { + return 104; + } +} + diff --git a/src/main/java/org/betterx/betterend/integration/rei/REIInfusionDisplay.java b/src/main/java/org/betterx/betterend/integration/rei/REIInfusionDisplay.java index e6cd9a93..07e24ba1 100644 --- a/src/main/java/org/betterx/betterend/integration/rei/REIInfusionDisplay.java +++ b/src/main/java/org/betterx/betterend/integration/rei/REIInfusionDisplay.java @@ -1,63 +1,63 @@ -//package org.betterx.betterend.integration.rei; -// -//import net.minecraft.resources.ResourceLocation; -//import net.minecraft.world.item.crafting.Recipe; -// -//import me.shedaniel.rei.api.common.category.CategoryIdentifier; -//import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay; -//import me.shedaniel.rei.api.common.display.basic.BasicDisplay; -//import me.shedaniel.rei.api.common.util.EntryIngredients; -//import org.betterx.betterend.recipe.builders.InfusionRecipe; -// -//import java.util.Collections; -//import java.util.Optional; -//import org.jetbrains.annotations.NotNull; -// -//public class REIInfusionDisplay extends BasicDisplay implements SimpleGridMenuDisplay { -// -// private final InfusionRecipe recipe; -// private final int time; -// -// public REIInfusionDisplay(InfusionRecipe recipe) { -// super( -// EntryIngredients.ofIngredients(recipe.getIngredients()), -// Collections.singletonList(EntryIngredients.of(recipe.getResultItem())) -// ); -// this.recipe = recipe; -// this.time = recipe.getInfusionTime(); -// } -// -// public int getInfusionTime() { -// return this.time; -// } -// -// @Override -// public @NotNull Optional getDisplayLocation() { -// return Optional.ofNullable(recipe).map(Recipe::getId); -// } -// -// @Override -// public CategoryIdentifier getCategoryIdentifier() { -// return REIPlugin.INFUSION; -// } -// -// // @Override -// // public @NotNull List> getRequiredEntries() { -// // return this.input; -// // } -// -// @Override -// public int getWidth() { -// return 0; -// } -// -// @Override -// public int getHeight() { -// return 0; -// } -// -// // @Override -// // public List> getOrganisedInputEntries(ContainerInfo containerInfo, AbstractContainerMenu container) { -// // return this.input; -// //} -//} +package org.betterx.betterend.integration.rei; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.Recipe; + +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay; +import me.shedaniel.rei.api.common.display.basic.BasicDisplay; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import org.betterx.betterend.recipe.builders.InfusionRecipe; + +import java.util.Collections; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +public class REIInfusionDisplay extends BasicDisplay implements SimpleGridMenuDisplay { + + private final InfusionRecipe recipe; + private final int time; + + public REIInfusionDisplay(InfusionRecipe recipe) { + super( + EntryIngredients.ofIngredients(recipe.getIngredients()), + Collections.singletonList(EntryIngredients.of(recipe.getResultItem())) + ); + this.recipe = recipe; + this.time = recipe.getInfusionTime(); + } + + public int getInfusionTime() { + return this.time; + } + + @Override + public @NotNull Optional getDisplayLocation() { + return Optional.ofNullable(recipe).map(Recipe::getId); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return REIPlugin.INFUSION; + } + + // @Override + // public @NotNull List> getRequiredEntries() { + // return this.input; + // } + + @Override + public int getWidth() { + return 0; + } + + @Override + public int getHeight() { + return 0; + } + + // @Override + // public List> getOrganisedInputEntries(ContainerInfo containerInfo, AbstractContainerMenu container) { + // return this.input; + //} +} diff --git a/src/main/java/org/betterx/betterend/integration/rei/REIPlugin.java b/src/main/java/org/betterx/betterend/integration/rei/REIPlugin.java index 4ff5940b..420de164 100644 --- a/src/main/java/org/betterx/betterend/integration/rei/REIPlugin.java +++ b/src/main/java/org/betterx/betterend/integration/rei/REIPlugin.java @@ -1,106 +1,106 @@ -//package org.betterx.betterend.integration.rei; -// -//import net.minecraft.resources.ResourceLocation; -//import net.minecraft.world.item.ItemStack; -//import net.minecraft.world.item.crafting.BlastingRecipe; -//import net.minecraft.world.item.crafting.RecipeType; -//import net.minecraft.world.level.block.Blocks; -// -//import net.fabricmc.fabric.api.registry.FuelRegistry; -//import net.fabricmc.fabric.impl.content.registry.FuelRegistryImpl; -// -//import com.google.common.collect.Lists; -//import me.shedaniel.rei.api.client.plugins.REIClientPlugin; -//import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; -//import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; -//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 me.shedaniel.rei.api.common.util.EntryIngredients; -//import me.shedaniel.rei.api.common.util.EntryStacks; -//import me.shedaniel.rei.plugin.common.BuiltinPlugin; -//import org.betterx.bclib.blocks.BaseFurnaceBlock; -//import org.betterx.bclib.recipes.AnvilRecipe; -//import org.betterx.betterend.BetterEnd; -//import org.betterx.betterend.blocks.basis.EndAnvilBlock; -//import org.betterx.betterend.recipe.builders.AlloyingRecipe; -//import org.betterx.betterend.recipe.builders.InfusionRecipe; -//import org.betterx.betterend.registry.EndBlocks; -// -//import java.util.Collections; -//import java.util.List; -//import java.util.stream.Collectors; -// -// -////https://github.com/shedaniel/RoughlyEnoughItems/blob/6.x-1.17/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java -//public class REIPlugin implements REIClientPlugin { -// public final static ResourceLocation PLUGIN_ID = BetterEnd.makeID("rei_plugin"); -// public final static CategoryIdentifier ALLOYING_FUEL = CategoryIdentifier.of( -// BetterEnd.MOD_ID, -// "alloying_fuel" -// ); -// public final static CategoryIdentifier ALLOYING = CategoryIdentifier.of( -// BetterEnd.MOD_ID, -// AlloyingRecipe.GROUP -// ); -// public final static CategoryIdentifier SMITHING = CategoryIdentifier.of( -// BetterEnd.MOD_ID, -// AnvilRecipe.ID.getPath() -// ); -// public final static CategoryIdentifier INFUSION = CategoryIdentifier.of( -// BetterEnd.MOD_ID, -// InfusionRecipe.GROUP -// ); -// -// @Override -// public void registerDisplays(DisplayRegistry registry) { -// registry.registerRecipeFiller(AlloyingRecipe.class, AlloyingRecipe.TYPE, REIAlloyingDisplay::new); -// registry.registerRecipeFiller(BlastingRecipe.class, RecipeType.BLASTING, REIBlastingDisplay::new); -// registry.registerRecipeFiller(AnvilRecipe.class, AnvilRecipe.TYPE, REIAnvilDisplay::new); -// registry.registerRecipeFiller(InfusionRecipe.class, InfusionRecipe.TYPE, REIInfusionDisplay::new); -// -// //TODO: Migrate to 1.18/1.18.2 -// if (FuelRegistry.INSTANCE instanceof FuelRegistryImpl fabricImpl) { -// fabricImpl.getFuelTimes().forEach((item, time) -> { -// if (time >= 2000) { -// final List list = Collections.singletonList(EntryIngredients.of(item)); -// registry.add(new REIAlloyingFuelDisplay(list, time)); -// } -// }); -// } -// } -// -// @Override -// public void registerCategories(CategoryRegistry registry) { -// EntryStack endStoneSmelter = EntryStacks.of(EndBlocks.END_STONE_SMELTER); -// EntryStack infusionRitual = EntryStacks.of(EndBlocks.INFUSION_PEDESTAL); -// List> anvils = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks() -// .stream() -// .filter(EndAnvilBlock.class::isInstance) -// .collect(Collectors.toList()))); -// anvils.add(0, EntryStacks.of(Blocks.ANVIL)); -// List> ITEM_FURNACES = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks() -// .stream() -// .filter(BaseFurnaceBlock.class::isInstance) -// .collect(Collectors.toList()))); -// EntryStack[] anvilsArray = anvils.toArray(new EntryStack[0]); -// EntryStack[] ITEM_FURNACESArray = ITEM_FURNACES.toArray(new EntryStack[0]); -// -// registry.add( -// new REIAlloyingFuelCategory(), -// new REIAlloyingCategory(endStoneSmelter), -// new REIInfusionCategory(infusionRitual), -// new REIAnvilCategory(anvilsArray) -// ); -// -// registry.addWorkstations(ALLOYING_FUEL, endStoneSmelter); -// registry.addWorkstations(ALLOYING, endStoneSmelter); -// registry.addWorkstations(INFUSION, infusionRitual); -// registry.addWorkstations(SMITHING, anvilsArray); -// registry.removePlusButton(ALLOYING_FUEL); -// registry.removePlusButton(SMITHING); -// -// registry.addWorkstations(BuiltinPlugin.SMELTING, ITEM_FURNACESArray); -// registry.addWorkstations(BuiltinPlugin.FUEL, ITEM_FURNACESArray); -// } -//} \ No newline at end of file +package org.betterx.betterend.integration.rei; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.BlastingRecipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.block.Blocks; + +import net.fabricmc.fabric.api.registry.FuelRegistry; +import net.fabricmc.fabric.impl.content.registry.FuelRegistryImpl; + +import com.google.common.collect.Lists; +import me.shedaniel.rei.api.client.plugins.REIClientPlugin; +import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; +import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; +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 me.shedaniel.rei.api.common.util.EntryIngredients; +import me.shedaniel.rei.api.common.util.EntryStacks; +import me.shedaniel.rei.plugin.common.BuiltinPlugin; +import org.betterx.bclib.blocks.BaseFurnaceBlock; +import org.betterx.bclib.recipes.AnvilRecipe; +import org.betterx.betterend.BetterEnd; +import org.betterx.betterend.blocks.basis.EndAnvilBlock; +import org.betterx.betterend.recipe.builders.AlloyingRecipe; +import org.betterx.betterend.recipe.builders.InfusionRecipe; +import org.betterx.betterend.registry.EndBlocks; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + + +//https://github.com/shedaniel/RoughlyEnoughItems/blob/6.x-1.17/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java +public class REIPlugin implements REIClientPlugin { + public final static ResourceLocation PLUGIN_ID = BetterEnd.makeID("rei_plugin"); + public final static CategoryIdentifier ALLOYING_FUEL = CategoryIdentifier.of( + BetterEnd.MOD_ID, + "alloying_fuel" + ); + public final static CategoryIdentifier ALLOYING = CategoryIdentifier.of( + BetterEnd.MOD_ID, + AlloyingRecipe.GROUP + ); + public final static CategoryIdentifier SMITHING = CategoryIdentifier.of( + BetterEnd.MOD_ID, + AnvilRecipe.ID.getPath() + ); + public final static CategoryIdentifier INFUSION = CategoryIdentifier.of( + BetterEnd.MOD_ID, + InfusionRecipe.GROUP + ); + + @Override + public void registerDisplays(DisplayRegistry registry) { + registry.registerRecipeFiller(AlloyingRecipe.class, AlloyingRecipe.TYPE, REIAlloyingDisplay::new); + registry.registerRecipeFiller(BlastingRecipe.class, RecipeType.BLASTING, REIBlastingDisplay::new); + registry.registerRecipeFiller(AnvilRecipe.class, AnvilRecipe.TYPE, REIAnvilDisplay::new); + registry.registerRecipeFiller(InfusionRecipe.class, InfusionRecipe.TYPE, REIInfusionDisplay::new); + + //TODO: Migrate to 1.18/1.18.2 + if (FuelRegistry.INSTANCE instanceof FuelRegistryImpl fabricImpl) { + fabricImpl.getFuelTimes().forEach((item, time) -> { + if (time >= 2000) { + final List list = Collections.singletonList(EntryIngredients.of(item)); + registry.add(new REIAlloyingFuelDisplay(list, time)); + } + }); + } + } + + @Override + public void registerCategories(CategoryRegistry registry) { + EntryStack endStoneSmelter = EntryStacks.of(EndBlocks.END_STONE_SMELTER); + EntryStack infusionRitual = EntryStacks.of(EndBlocks.INFUSION_PEDESTAL); + List> anvils = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks() + .stream() + .filter(EndAnvilBlock.class::isInstance) + .collect(Collectors.toList()))); + anvils.add(0, EntryStacks.of(Blocks.ANVIL)); + List> ITEM_FURNACES = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks() + .stream() + .filter(BaseFurnaceBlock.class::isInstance) + .collect(Collectors.toList()))); + EntryStack[] anvilsArray = anvils.toArray(new EntryStack[0]); + EntryStack[] ITEM_FURNACESArray = ITEM_FURNACES.toArray(new EntryStack[0]); + + registry.add( + new REIAlloyingFuelCategory(), + new REIAlloyingCategory(endStoneSmelter), + new REIInfusionCategory(infusionRitual), + new REIAnvilCategory(anvilsArray) + ); + + registry.addWorkstations(ALLOYING_FUEL, endStoneSmelter); + registry.addWorkstations(ALLOYING, endStoneSmelter); + registry.addWorkstations(INFUSION, infusionRitual); + registry.addWorkstations(SMITHING, anvilsArray); + registry.removePlusButton(ALLOYING_FUEL); + registry.removePlusButton(SMITHING); + + registry.addWorkstations(BuiltinPlugin.SMELTING, ITEM_FURNACESArray); + registry.addWorkstations(BuiltinPlugin.FUEL, ITEM_FURNACESArray); + } +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 93715689..47b99d2f 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -28,7 +28,7 @@ "client": [ "org.betterx.betterend.client.BetterEndClient" ], - "rei_plugins_disabled": [ + "rei_plugins": [ "org.betterx.betterend.integration.rei.REIPlugin" ] },