A little bit refactoring
This commit is contained in:
parent
ed777b5955
commit
42f04b9614
9 changed files with 10 additions and 10 deletions
|
@ -0,0 +1,89 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
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.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.LangUtil;
|
||||
|
||||
public class REIAlloyingCategory implements TransferRecipeCategory<REIAlloyingDisplay> {
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getIdentifier() {
|
||||
return AlloyingRecipe.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getCategoryName() {
|
||||
return LangUtil.translate(EndBlocks.END_STONE_SMELTER.getTranslationKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EntryStack getLogo() {
|
||||
return REIPlugin.END_STONE_SMELTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Widget> setupDisplay(REIAlloyingDisplay display, Rectangle bounds) {
|
||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
|
||||
double smeltTime = display.getSmeltTime();
|
||||
DecimalFormat df = new DecimalFormat("###.##");
|
||||
List<Widget> 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),
|
||||
new TranslatableText("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<List<EntryStack>> 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());
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRedSlots(MatrixStack matrices, List<Widget> widgets, Rectangle bounds, REIAlloyingDisplay display,
|
||||
IntList redSlots) {
|
||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
|
||||
matrices.push();
|
||||
matrices.translate(0, 0, 400);
|
||||
if (redSlots.contains(0)) {
|
||||
DrawableHelper.fill(matrices, startPoint.x - 20, startPoint.y + 1, startPoint.x - 20 + 16, startPoint.y + 1 + 16, 1090453504);
|
||||
DrawableHelper.fill(matrices, startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16, startPoint.y + 1 + 16, 1090453504);
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RecipeEntry getSimpleRenderer(REIAlloyingDisplay recipe) {
|
||||
return SimpleRecipeEntry.from(recipe.getInputEntries(), recipe.getResultingEntries());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 49;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.TransferRecipeDisplay;
|
||||
import me.shedaniel.rei.server.ContainerInfo;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.recipe.BlastingRecipe;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
|
||||
public class REIAlloyingDisplay implements TransferRecipeDisplay {
|
||||
|
||||
private static List<EntryStack> fuel;
|
||||
|
||||
private Recipe<?> recipe;
|
||||
private List<List<EntryStack>> input;
|
||||
private List<EntryStack> output;
|
||||
private float xp;
|
||||
private double smeltTime;
|
||||
|
||||
public REIAlloyingDisplay(AlloyingRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
|
||||
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
|
||||
this.xp = recipe.getExperience();
|
||||
this.smeltTime = recipe.getSmeltTime();
|
||||
}
|
||||
|
||||
public REIAlloyingDisplay(BlastingRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
|
||||
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
|
||||
this.xp = recipe.getExperience();
|
||||
this.smeltTime = recipe.getCookTime();
|
||||
}
|
||||
|
||||
public static List<EntryStack> getFuel() {
|
||||
return fuel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<Identifier> getRecipeLocation() {
|
||||
return Optional.ofNullable(recipe).map(Recipe::getId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getInputEntries() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getResultingEntries() {
|
||||
return Collections.singletonList(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getRecipeCategory() {
|
||||
return AlloyingRecipe.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getRequiredEntries() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
public float getXp() {
|
||||
return this.xp;
|
||||
}
|
||||
|
||||
public double getSmeltTime() {
|
||||
return this.smeltTime;
|
||||
}
|
||||
|
||||
public Optional<Recipe<?>> getOptionalRecipe() {
|
||||
return Optional.ofNullable(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo, ScreenHandler container) {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
static {
|
||||
fuel = EndStoneSmelterBlockEntity.availableFuels().keySet().stream()
|
||||
.map(Item::getDefaultStack).map(EntryStack::create)
|
||||
.map(e -> e.setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, stack -> Collections.singletonList(new TranslatableText("category.rei.smelting.fuel")
|
||||
.formatted(Formatting.YELLOW)))).collect(Collectors.toList());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
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.block.Blocks;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.util.LangUtil;
|
||||
|
||||
public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay> {
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getIdentifier() {
|
||||
return REIPlugin.SMITHING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getCategoryName() {
|
||||
return LangUtil.translate(Blocks.ANVIL.getTranslationKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EntryStack getLogo() {
|
||||
return REIPlugin.ANVIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Widget> setupDisplay(REIAnvilDisplay display, Rectangle bounds) {
|
||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
|
||||
List<Widget> 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 + 4)));
|
||||
List<List<EntryStack>> inputEntries = display.getInputEntries();
|
||||
widgets.add(Widgets.createArrow(new Point(x + 24, y + 3)));
|
||||
widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + bounds.height - 12),
|
||||
new TranslatableText("category.rei.damage.amount&dmg", display.getDamage())).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
|
||||
widgets.add(Widgets.createSlot(new Point(x - 20, y + 3)).entries(inputEntries.get(0)).markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(x + 1, y + 3)).entries(inputEntries.get(1)).markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(x + 61, y + 4)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput());
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRedSlots(MatrixStack matrices, List<Widget> widgets, Rectangle bounds, REIAnvilDisplay display,
|
||||
IntList redSlots) {
|
||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
|
||||
matrices.push();
|
||||
matrices.translate(0, 0, 400);
|
||||
if (redSlots.contains(0)) {
|
||||
DrawableHelper.fill(matrices, startPoint.x - 20, startPoint.y + 3, startPoint.x - 20 + 16, startPoint.y + 3 + 16, 1090453504);
|
||||
DrawableHelper.fill(matrices, startPoint.x + 1, startPoint.y + 3, startPoint.x + 1 + 16, startPoint.y + 3 + 16, 1090453504);
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RecipeEntry getSimpleRenderer(REIAnvilDisplay recipe) {
|
||||
return SimpleRecipeEntry.from(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getResultingEntries());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 49;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.TransferRecipeDisplay;
|
||||
import me.shedaniel.rei.server.ContainerInfo;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.recipe.builders.AnvilSmithingRecipe;
|
||||
|
||||
public class REIAnvilDisplay implements TransferRecipeDisplay {
|
||||
|
||||
private AnvilSmithingRecipe recipe;
|
||||
private List<List<EntryStack>> input;
|
||||
private List<EntryStack> output;
|
||||
|
||||
public REIAnvilDisplay(AnvilSmithingRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
|
||||
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return this.recipe.getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<Identifier> getRecipeLocation() {
|
||||
return Optional.ofNullable(recipe).map(Recipe::getId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getInputEntries() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getResultingEntries() {
|
||||
return Collections.singletonList(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getRecipeCategory() {
|
||||
return REIPlugin.SMITHING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getRequiredEntries() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo,
|
||||
ScreenHandler container) {
|
||||
return this.input;
|
||||
}
|
||||
}
|
14
src/main/java/ru/betterend/integration/rei/REIContainer.java
Normal file
14
src/main/java/ru/betterend/integration/rei/REIContainer.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import me.shedaniel.rei.plugin.containers.CraftingContainerInfoWrapper;
|
||||
import me.shedaniel.rei.server.ContainerInfoHandler;
|
||||
import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
|
||||
public class REIContainer implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ContainerInfoHandler.registerContainerInfo(AlloyingRecipe.ID, CraftingContainerInfoWrapper.create(EndStoneSmelterScreenHandler.class));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
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.util.math.MatrixStack;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.LangUtil;
|
||||
|
||||
public class REIInfusionCategory implements TransferRecipeCategory<REIInfusionDisplay> {
|
||||
|
||||
private final static Identifier BACKGROUND = BetterEnd.makeID("textures/gui/rei_infusion.png");
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getIdentifier() {
|
||||
return InfusionRecipe.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getCategoryName() {
|
||||
return LangUtil.translate(EndBlocks.INFUSION_PEDESTAL.getTranslationKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EntryStack getLogo() {
|
||||
return REIPlugin.INFUSION_RITUAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RecipeEntry getSimpleRenderer(REIInfusionDisplay recipe) {
|
||||
return SimpleRecipeEntry.from(recipe.getInputEntries(), recipe.getResultingEntries());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Widget> setupDisplay(REIInfusionDisplay display, Rectangle bounds) {
|
||||
Point centerPoint = new Point(bounds.getCenterX() - 34, bounds.getCenterY() - 2);
|
||||
List<Widget> widgets = Lists.newArrayList();
|
||||
widgets.add(Widgets.createRecipeBase(bounds));
|
||||
List<List<EntryStack>> inputEntries = display.getInputEntries();
|
||||
List<List<EntryStack>> outputEntries = display.getResultingEntries();
|
||||
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), new TranslatableText("category.rei.infusion.time&val", display.getInfusionTime()))
|
||||
.noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRedSlots(MatrixStack matrices, List<Widget> widgets, Rectangle bounds,
|
||||
REIInfusionDisplay display, IntList redSlots) {}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 104;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.TransferRecipeDisplay;
|
||||
import me.shedaniel.rei.server.ContainerInfo;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||
|
||||
public class REIInfusionDisplay implements TransferRecipeDisplay {
|
||||
|
||||
private final InfusionRecipe recipe;
|
||||
private final List<List<EntryStack>> input;
|
||||
private final List<EntryStack> output;
|
||||
private final int time;
|
||||
|
||||
public REIInfusionDisplay(InfusionRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
this.input = Lists.newArrayList();
|
||||
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
|
||||
this.time = recipe.getInfusionTime();
|
||||
|
||||
recipe.getPreviewInputs().forEach(ingredient -> {
|
||||
input.add(EntryStack.ofIngredient(ingredient));
|
||||
});
|
||||
}
|
||||
|
||||
public int getInfusionTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<Identifier> getRecipeLocation() {
|
||||
return Optional.ofNullable(recipe).map(Recipe::getId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getInputEntries() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getResultingEntries() {
|
||||
return Collections.singletonList(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getRecipeCategory() {
|
||||
return AlloyingRecipe.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getRequiredEntries() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo, ScreenHandler container) {
|
||||
return this.input;
|
||||
}
|
||||
}
|
56
src/main/java/ru/betterend/integration/rei/REIPlugin.java
Normal file
56
src/main/java/ru/betterend/integration/rei/REIPlugin.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeHelper;
|
||||
import me.shedaniel.rei.api.plugins.REIPluginV0;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.recipe.BlastingRecipe;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
import ru.betterend.recipe.builders.AnvilSmithingRecipe;
|
||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class REIPlugin implements REIPluginV0 {
|
||||
|
||||
public final static Identifier PLUGIN_ID = BetterEnd.makeID("rei_plugin");
|
||||
public final static Identifier ALLOYING = AlloyingRecipe.ID;
|
||||
public final static Identifier SMITHING = AnvilSmithingRecipe.ID;
|
||||
public final static Identifier INFUSION = InfusionRecipe.ID;
|
||||
|
||||
public final static EntryStack END_STONE_SMELTER = EntryStack.create(EndBlocks.END_STONE_SMELTER);
|
||||
public final static EntryStack INFUSION_RITUAL = EntryStack.create(EndBlocks.INFUSION_PEDESTAL);
|
||||
public final static EntryStack ANVIL = EntryStack.create(Blocks.ANVIL);
|
||||
|
||||
@Override
|
||||
public Identifier getPluginIdentifier() {
|
||||
return PLUGIN_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipeDisplays(RecipeHelper recipeHelper) {
|
||||
recipeHelper.registerRecipes(ALLOYING, AlloyingRecipe.class, REIAlloyingDisplay::new);
|
||||
recipeHelper.registerRecipes(ALLOYING, BlastingRecipe.class, REIAlloyingDisplay::new);
|
||||
recipeHelper.registerRecipes(SMITHING, AnvilSmithingRecipe.class, REIAnvilDisplay::new);
|
||||
recipeHelper.registerRecipes(INFUSION, InfusionRecipe.class, REIInfusionDisplay::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOthers(RecipeHelper recipeHelper) {
|
||||
recipeHelper.registerWorkingStations(ALLOYING, END_STONE_SMELTER);
|
||||
recipeHelper.registerWorkingStations(INFUSION, INFUSION_RITUAL);
|
||||
recipeHelper.registerWorkingStations(SMITHING, ANVIL);
|
||||
recipeHelper.removeAutoCraftButton(SMITHING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPluginCategories(RecipeHelper recipeHelper) {
|
||||
recipeHelper.registerCategories(new REIAlloyingCategory(),
|
||||
new REIInfusionCategory(),
|
||||
new REIAnvilCategory());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue