Infusion REI display

This commit is contained in:
Aleksey 2020-11-10 23:12:46 +03:00
parent ea4b9b726b
commit cd88d69cf3
14 changed files with 626 additions and 439 deletions

View file

@ -1,90 +1,92 @@
package ru.betterend.compat; package ru.betterend.compat.rei;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Collections; import java.util.List;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.NotNull;
import com.google.common.collect.Lists;
import com.google.common.collect.Lists;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntList;
import me.shedaniel.math.Point; import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle; import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.TransferRecipeCategory; import me.shedaniel.rei.api.TransferRecipeCategory;
import me.shedaniel.rei.api.widgets.Widgets; import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.entries.RecipeEntry; import me.shedaniel.rei.gui.entries.RecipeEntry;
import me.shedaniel.rei.gui.entries.SimpleRecipeEntry; import me.shedaniel.rei.gui.entries.SimpleRecipeEntry;
import me.shedaniel.rei.gui.widget.Widget; import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.text.TranslatableText; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier; import net.minecraft.text.TranslatableText;
import ru.betterend.recipe.builders.AlloyingRecipe; import net.minecraft.util.Identifier;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.LangUtil; import ru.betterend.recipe.builders.AlloyingRecipe;
import ru.betterend.registry.EndBlocks;
public class REIAlloyingCategory implements TransferRecipeCategory<REIAlloyingDisplay> { import ru.betterend.util.LangUtil;
@Override public class REIAlloyingCategory implements TransferRecipeCategory<REIAlloyingDisplay> {
public @NotNull Identifier getIdentifier() {
return AlloyingRecipe.ID; @Override
} public @NotNull Identifier getIdentifier() {
return AlloyingRecipe.ID;
@Override }
public @NotNull String getCategoryName() {
return LangUtil.translate(EndBlocks.END_STONE_SMELTER.getTranslationKey()); @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 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); @Override
double smeltTime = display.getSmeltTime(); public @NotNull List<Widget> setupDisplay(REIAlloyingDisplay display, Rectangle bounds) {
DecimalFormat df = new DecimalFormat("###.##"); Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
List<Widget> widgets = Lists.newArrayList(); double smeltTime = display.getSmeltTime();
widgets.add(Widgets.createRecipeBase(bounds)); DecimalFormat df = new DecimalFormat("###.##");
widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9))); List<Widget> widgets = Lists.newArrayList();
widgets.add(Widgets.createBurningFire(new Point(startPoint.x - 9, startPoint.y + 20)).animationDurationMS(10000)); widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5), widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9)));
new TranslatableText("category.rei.cooking.time&xp", df.format(display.getXp()), df.format(smeltTime / 20D))).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); widgets.add(Widgets.createBurningFire(new Point(startPoint.x - 9, startPoint.y + 20)).animationDurationMS(10000));
widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(smeltTime)); widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5),
List<List<EntryStack>> inputEntries = display.getInputEntries(); new TranslatableText("category.rei.cooking.time&xp", df.format(display.getXp()), df.format(smeltTime / 20D))).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
widgets.add(Widgets.createSlot(new Point(startPoint.x - 20, startPoint.y + 1)).entries(inputEntries.get(0)).markInput()); widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(smeltTime));
if (inputEntries.size() > 1) { List<List<EntryStack>> inputEntries = display.getInputEntries();
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(inputEntries.get(1)).markInput()); widgets.add(Widgets.createSlot(new Point(startPoint.x - 20, startPoint.y + 1)).entries(inputEntries.get(0)).markInput());
} else { if (inputEntries.size() > 1) {
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(Lists.newArrayList()).markInput()); 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 + 61, startPoint.y + 9)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput()); widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(Lists.newArrayList()).markInput());
return widgets; }
} 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) { @Override
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27); public void renderRedSlots(MatrixStack matrices, List<Widget> widgets, Rectangle bounds, REIAlloyingDisplay display,
matrices.push(); IntList redSlots) {
matrices.translate(0, 0, 400); Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
if (redSlots.contains(0)) { matrices.push();
DrawableHelper.fill(matrices, startPoint.x - 20, startPoint.y + 1, startPoint.x - 20 + 16, startPoint.y + 1 + 16, 1090453504); matrices.translate(0, 0, 400);
DrawableHelper.fill(matrices, startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16, startPoint.y + 1 + 16, 1090453504); if (redSlots.contains(0)) {
} DrawableHelper.fill(matrices, startPoint.x - 20, startPoint.y + 1, startPoint.x - 20 + 16, startPoint.y + 1 + 16, 1090453504);
matrices.pop(); 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(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getResultingEntries()); @Override
} public @NotNull RecipeEntry getSimpleRenderer(REIAlloyingDisplay recipe) {
return SimpleRecipeEntry.from(recipe.getInputEntries(), recipe.getResultingEntries());
@Override }
public int getDisplayHeight() {
return 49; @Override
} public int getDisplayHeight() {
} return 49;
}
}

View file

@ -1,111 +1,111 @@
package ru.betterend.compat; package ru.betterend.compat.rei;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.TransferRecipeDisplay; import me.shedaniel.rei.api.TransferRecipeDisplay;
import me.shedaniel.rei.server.ContainerInfo; import me.shedaniel.rei.server.ContainerInfo;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.recipe.BlastingRecipe; import net.minecraft.recipe.BlastingRecipe;
import net.minecraft.recipe.Recipe; import net.minecraft.recipe.Recipe;
import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandler;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity; import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
import ru.betterend.recipe.builders.AlloyingRecipe; import ru.betterend.recipe.builders.AlloyingRecipe;
public class REIAlloyingDisplay implements TransferRecipeDisplay { public class REIAlloyingDisplay implements TransferRecipeDisplay {
private static List<EntryStack> fuel; private static List<EntryStack> fuel;
private Recipe<?> recipe; private Recipe<?> recipe;
private List<List<EntryStack>> input; private List<List<EntryStack>> input;
private List<EntryStack> output; private List<EntryStack> output;
private float xp; private float xp;
private double smeltTime; private double smeltTime;
public REIAlloyingDisplay(AlloyingRecipe recipe) { public REIAlloyingDisplay(AlloyingRecipe recipe) {
this.recipe = recipe; this.recipe = recipe;
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs()); this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput())); this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
this.xp = recipe.getExperience(); this.xp = recipe.getExperience();
this.smeltTime = recipe.getSmeltTime(); this.smeltTime = recipe.getSmeltTime();
} }
public REIAlloyingDisplay(BlastingRecipe recipe) { public REIAlloyingDisplay(BlastingRecipe recipe) {
this.recipe = recipe; this.recipe = recipe;
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs()); this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput())); this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
this.xp = recipe.getExperience(); this.xp = recipe.getExperience();
this.smeltTime = recipe.getCookTime(); this.smeltTime = recipe.getCookTime();
} }
public static List<EntryStack> getFuel() { public static List<EntryStack> getFuel() {
return fuel; return fuel;
} }
@Override @Override
public @NotNull Optional<Identifier> getRecipeLocation() { public @NotNull Optional<Identifier> getRecipeLocation() {
return Optional.ofNullable(recipe).map(Recipe::getId); return Optional.ofNullable(recipe).map(Recipe::getId);
} }
@Override @Override
public @NotNull List<List<EntryStack>> getInputEntries() { public @NotNull List<List<EntryStack>> getInputEntries() {
return this.input; return this.input;
} }
@Override @Override
public @NotNull List<List<EntryStack>> getResultingEntries() { public @NotNull List<List<EntryStack>> getResultingEntries() {
return Collections.singletonList(output); return Collections.singletonList(output);
} }
@Override @Override
public @NotNull Identifier getRecipeCategory() { public @NotNull Identifier getRecipeCategory() {
return AlloyingRecipe.ID; return AlloyingRecipe.ID;
} }
@Override @Override
public @NotNull List<List<EntryStack>> getRequiredEntries() { public @NotNull List<List<EntryStack>> getRequiredEntries() {
return this.input; return this.input;
} }
public float getXp() { public float getXp() {
return this.xp; return this.xp;
} }
public double getSmeltTime() { public double getSmeltTime() {
return this.smeltTime; return this.smeltTime;
} }
public Optional<Recipe<?>> getOptionalRecipe() { public Optional<Recipe<?>> getOptionalRecipe() {
return Optional.ofNullable(recipe); return Optional.ofNullable(recipe);
} }
@Override @Override
public int getWidth() { public int getWidth() {
return 2; return 2;
} }
@Override @Override
public int getHeight() { public int getHeight() {
return 1; return 1;
} }
@Override @Override
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo, ScreenHandler container) { public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo, ScreenHandler container) {
return this.input; return this.input;
} }
static { static {
fuel = EndStoneSmelterBlockEntity.availableFuels().keySet().stream() fuel = EndStoneSmelterBlockEntity.availableFuels().keySet().stream()
.map(Item::getDefaultStack).map(EntryStack::create) .map(Item::getDefaultStack).map(EntryStack::create)
.map(e -> e.setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, stack -> Collections.singletonList(new TranslatableText("category.rei.smelting.fuel") .map(e -> e.setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, stack -> Collections.singletonList(new TranslatableText("category.rei.smelting.fuel")
.formatted(Formatting.YELLOW)))).collect(Collectors.toList()); .formatted(Formatting.YELLOW)))).collect(Collectors.toList());
} }
} }

View file

@ -1,84 +1,84 @@
package ru.betterend.compat; package ru.betterend.compat.rei;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import me.shedaniel.math.Point; import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle; import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.TransferRecipeCategory; import me.shedaniel.rei.api.TransferRecipeCategory;
import me.shedaniel.rei.api.widgets.Widgets; import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.entries.RecipeEntry; import me.shedaniel.rei.gui.entries.RecipeEntry;
import me.shedaniel.rei.gui.entries.SimpleRecipeEntry; import me.shedaniel.rei.gui.entries.SimpleRecipeEntry;
import me.shedaniel.rei.gui.widget.Widget; import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import ru.betterend.util.LangUtil; import ru.betterend.util.LangUtil;
public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay> { public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay> {
@Override @Override
public @NotNull Identifier getIdentifier() { public @NotNull Identifier getIdentifier() {
return REIPlugin.SMITHING; return REIPlugin.SMITHING;
} }
@Override @Override
public @NotNull String getCategoryName() { public @NotNull String getCategoryName() {
return LangUtil.translate(Blocks.ANVIL.getTranslationKey()); return LangUtil.translate(Blocks.ANVIL.getTranslationKey());
} }
@Override @Override
public @NotNull EntryStack getLogo() { public @NotNull EntryStack getLogo() {
return REIPlugin.ANVIL; return REIPlugin.ANVIL;
} }
@Override @Override
public @NotNull List<Widget> setupDisplay(REIAnvilDisplay display, Rectangle bounds) { public @NotNull List<Widget> setupDisplay(REIAnvilDisplay display, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10); Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
List<Widget> widgets = Lists.newArrayList(); List<Widget> widgets = Lists.newArrayList();
widgets.add(Widgets.createRecipeBase(bounds)); widgets.add(Widgets.createRecipeBase(bounds));
int x = startPoint.x + 10; int x = startPoint.x + 10;
int y = startPoint.y; int y = startPoint.y;
widgets.add(Widgets.createResultSlotBackground(new Point(x + 61, y + 4))); widgets.add(Widgets.createResultSlotBackground(new Point(x + 61, y + 4)));
List<List<EntryStack>> inputEntries = display.getInputEntries(); List<List<EntryStack>> inputEntries = display.getInputEntries();
widgets.add(Widgets.createArrow(new Point(x + 24, y + 3))); 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), 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)); 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 - 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 + 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()); widgets.add(Widgets.createSlot(new Point(x + 61, y + 4)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput());
return widgets; return widgets;
} }
@Override @Override
public void renderRedSlots(MatrixStack matrices, List<Widget> widgets, Rectangle bounds, REIAnvilDisplay display, public void renderRedSlots(MatrixStack matrices, List<Widget> widgets, Rectangle bounds, REIAnvilDisplay display,
IntList redSlots) { IntList redSlots) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27); Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
matrices.push(); matrices.push();
matrices.translate(0, 0, 400); matrices.translate(0, 0, 400);
if (redSlots.contains(0)) { 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 - 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); DrawableHelper.fill(matrices, startPoint.x + 1, startPoint.y + 3, startPoint.x + 1 + 16, startPoint.y + 3 + 16, 1090453504);
} }
matrices.pop(); matrices.pop();
} }
@Override @Override
public @NotNull RecipeEntry getSimpleRenderer(REIAnvilDisplay recipe) { public @NotNull RecipeEntry getSimpleRenderer(REIAnvilDisplay recipe) {
return SimpleRecipeEntry.from(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getResultingEntries()); return SimpleRecipeEntry.from(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getResultingEntries());
} }
@Override @Override
public int getDisplayHeight() { public int getDisplayHeight() {
return 49; return 49;
} }
} }

View file

@ -1,73 +1,73 @@
package ru.betterend.compat; package ru.betterend.compat.rei;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.TransferRecipeDisplay; import me.shedaniel.rei.api.TransferRecipeDisplay;
import me.shedaniel.rei.server.ContainerInfo; import me.shedaniel.rei.server.ContainerInfo;
import net.minecraft.recipe.Recipe; import net.minecraft.recipe.Recipe;
import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandler;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import ru.betterend.recipe.builders.AnvilSmithingRecipe; import ru.betterend.recipe.builders.AnvilSmithingRecipe;
public class REIAnvilDisplay implements TransferRecipeDisplay { public class REIAnvilDisplay implements TransferRecipeDisplay {
private AnvilSmithingRecipe recipe; private AnvilSmithingRecipe recipe;
private List<List<EntryStack>> input; private List<List<EntryStack>> input;
private List<EntryStack> output; private List<EntryStack> output;
public REIAnvilDisplay(AnvilSmithingRecipe recipe) { public REIAnvilDisplay(AnvilSmithingRecipe recipe) {
this.recipe = recipe; this.recipe = recipe;
this.input = EntryStack.ofIngredients(recipe.getPreviewInputs()); this.input = EntryStack.ofIngredients(recipe.getPreviewInputs());
this.output = Collections.singletonList(EntryStack.create(recipe.getOutput())); this.output = Collections.singletonList(EntryStack.create(recipe.getOutput()));
} }
public int getDamage() { public int getDamage() {
return this.recipe.getDamage(); return this.recipe.getDamage();
} }
@Override @Override
public @NotNull Optional<Identifier> getRecipeLocation() { public @NotNull Optional<Identifier> getRecipeLocation() {
return Optional.ofNullable(recipe).map(Recipe::getId); return Optional.ofNullable(recipe).map(Recipe::getId);
} }
@Override @Override
public @NotNull List<List<EntryStack>> getInputEntries() { public @NotNull List<List<EntryStack>> getInputEntries() {
return this.input; return this.input;
} }
@Override @Override
public @NotNull List<List<EntryStack>> getResultingEntries() { public @NotNull List<List<EntryStack>> getResultingEntries() {
return Collections.singletonList(output); return Collections.singletonList(output);
} }
@Override @Override
public @NotNull Identifier getRecipeCategory() { public @NotNull Identifier getRecipeCategory() {
return REIPlugin.SMITHING; return REIPlugin.SMITHING;
} }
@Override @Override
public @NotNull List<List<EntryStack>> getRequiredEntries() { public @NotNull List<List<EntryStack>> getRequiredEntries() {
return this.input; return this.input;
} }
@Override @Override
public int getWidth() { public int getWidth() {
return 2; return 2;
} }
@Override @Override
public int getHeight() { public int getHeight() {
return 1; return 1;
} }
@Override @Override
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo, public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo,
ScreenHandler container) { ScreenHandler container) {
return this.input; return this.input;
} }
} }

View file

@ -1,14 +1,14 @@
package ru.betterend.compat; package ru.betterend.compat.rei;
import me.shedaniel.rei.plugin.containers.CraftingContainerInfoWrapper; import me.shedaniel.rei.plugin.containers.CraftingContainerInfoWrapper;
import me.shedaniel.rei.server.ContainerInfoHandler; import me.shedaniel.rei.server.ContainerInfoHandler;
import ru.betterend.client.gui.EndStoneSmelterScreenHandler; import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
import ru.betterend.recipe.builders.AlloyingRecipe; import ru.betterend.recipe.builders.AlloyingRecipe;
public class REIContainer implements Runnable { public class REIContainer implements Runnable {
@Override @Override
public void run() { public void run() {
ContainerInfoHandler.registerContainerInfo(AlloyingRecipe.ID, CraftingContainerInfoWrapper.create(EndStoneSmelterScreenHandler.class)); ContainerInfoHandler.registerContainerInfo(AlloyingRecipe.ID, CraftingContainerInfoWrapper.create(EndStoneSmelterScreenHandler.class));
} }
} }

View file

@ -0,0 +1,82 @@
package ru.betterend.compat.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.recipe.builders.InfusionRecipe;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.LangUtil;
public class REIInfusionCategory implements TransferRecipeCategory<REIInfusionDisplay> {
@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() - 36, bounds.getCenterY() - 4);
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.createSlot(centerPoint).entries(inputEntries.get(0)).markInput());
widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y - 28)).entries(inputEntries.get(1)).markInput());
widgets.add(Widgets.createSlot(new Point(centerPoint.x + 28, centerPoint.y)).entries(inputEntries.get(3)).markInput());
widgets.add(Widgets.createSlot(new Point(centerPoint.x, centerPoint.y + 28)).entries(inputEntries.get(5)).markInput());
widgets.add(Widgets.createSlot(new Point(centerPoint.x - 28, centerPoint.y)).entries(inputEntries.get(7)).markInput());
widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y - 24)).entries(inputEntries.get(2)).markInput());
widgets.add(Widgets.createSlot(new Point(centerPoint.x + 24, centerPoint.y + 24)).entries(inputEntries.get(4)).markInput());
widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y + 24)).entries(inputEntries.get(6)).markInput());
widgets.add(Widgets.createSlot(new Point(centerPoint.x - 24, centerPoint.y - 24)).entries(inputEntries.get(8)).markInput());
widgets.add(Widgets.createArrow(new Point(centerPoint.x + 48, centerPoint.y)));
widgets.add(Widgets.createResultSlotBackground(new Point(centerPoint.x + 80, centerPoint.y)));
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;
}
}

View file

@ -0,0 +1,81 @@
package ru.betterend.compat.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;
}
}

View file

@ -1,50 +1,56 @@
package ru.betterend.compat; package ru.betterend.compat.rei;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeHelper; import me.shedaniel.rei.api.RecipeHelper;
import me.shedaniel.rei.api.plugins.REIPluginV0; import me.shedaniel.rei.api.plugins.REIPluginV0;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.recipe.BlastingRecipe; import net.minecraft.recipe.BlastingRecipe;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
import ru.betterend.recipe.builders.AlloyingRecipe; import ru.betterend.recipe.builders.AlloyingRecipe;
import ru.betterend.recipe.builders.AnvilSmithingRecipe; import ru.betterend.recipe.builders.AnvilSmithingRecipe;
import ru.betterend.registry.EndBlocks; import ru.betterend.recipe.builders.InfusionRecipe;
import ru.betterend.registry.EndBlocks;
@Environment(EnvType.CLIENT)
public class REIPlugin implements REIPluginV0 { @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 PLUGIN_ID = BetterEnd.makeID("rei_plugin");
public final static Identifier SMITHING = AnvilSmithingRecipe.ID; public final static Identifier ALLOYING = AlloyingRecipe.ID;
public final static Identifier SMITHING = AnvilSmithingRecipe.ID;
public final static EntryStack END_STONE_SMELTER = EntryStack.create(EndBlocks.END_STONE_SMELTER); public final static Identifier INFUSION = InfusionRecipe.ID;
public final static EntryStack ANVIL = EntryStack.create(Blocks.ANVIL);
public final static EntryStack END_STONE_SMELTER = EntryStack.create(EndBlocks.END_STONE_SMELTER);
@Override public final static EntryStack INFUSION_RITUAL = EntryStack.create(EndBlocks.INFUSION_PEDESTAL);
public Identifier getPluginIdentifier() { public final static EntryStack ANVIL = EntryStack.create(Blocks.ANVIL);
return PLUGIN_ID;
} @Override
public Identifier getPluginIdentifier() {
@Override return PLUGIN_ID;
public void registerRecipeDisplays(RecipeHelper recipeHelper) { }
recipeHelper.registerRecipes(ALLOYING, AlloyingRecipe.class, REIAlloyingDisplay::new);
recipeHelper.registerRecipes(ALLOYING, BlastingRecipe.class, REIAlloyingDisplay::new); @Override
recipeHelper.registerRecipes(SMITHING, AnvilSmithingRecipe.class, REIAnvilDisplay::new); public void registerRecipeDisplays(RecipeHelper recipeHelper) {
} recipeHelper.registerRecipes(ALLOYING, AlloyingRecipe.class, REIAlloyingDisplay::new);
recipeHelper.registerRecipes(ALLOYING, BlastingRecipe.class, REIAlloyingDisplay::new);
@Override recipeHelper.registerRecipes(SMITHING, AnvilSmithingRecipe.class, REIAnvilDisplay::new);
public void registerOthers(RecipeHelper recipeHelper) { recipeHelper.registerRecipes(INFUSION, InfusionRecipe.class, REIInfusionDisplay::new);
recipeHelper.registerWorkingStations(ALLOYING, END_STONE_SMELTER); }
recipeHelper.registerWorkingStations(SMITHING, ANVIL);
recipeHelper.removeAutoCraftButton(SMITHING); @Override
} public void registerOthers(RecipeHelper recipeHelper) {
recipeHelper.registerWorkingStations(ALLOYING, END_STONE_SMELTER);
@Override recipeHelper.registerWorkingStations(INFUSION, INFUSION_RITUAL);
public void registerPluginCategories(RecipeHelper recipeHelper) { recipeHelper.registerWorkingStations(SMITHING, ANVIL);
recipeHelper.registerCategories(new REIAlloyingCategory(), recipeHelper.removeAutoCraftButton(SMITHING);
new REIAnvilCategory()); }
}
} @Override
public void registerPluginCategories(RecipeHelper recipeHelper) {
recipeHelper.registerCategories(new REIAlloyingCategory(),
new REIInfusionCategory(),
new REIAnvilCategory());
}
}

View file

@ -18,12 +18,12 @@ public class InfusionRecipes {
.build(); .build();
InfusionRecipe.Builder.create("eternal_crystal") InfusionRecipe.Builder.create("eternal_crystal")
.setInput(EndItems.CRYSTAL_SHARDS) .setInput(Items.END_CRYSTAL)
.setOutput(EndItems.ETERNAL_CRYSTAL) .setOutput(EndItems.ETERNAL_CRYSTAL)
.addCatalyst(0, Items.END_CRYSTAL) .addCatalyst(0, EndItems.CRYSTAL_SHARDS)
.addCatalyst(2, Items.END_CRYSTAL) .addCatalyst(2, EndItems.CRYSTAL_SHARDS)
.addCatalyst(4, Items.END_CRYSTAL) .addCatalyst(4, EndItems.CRYSTAL_SHARDS)
.addCatalyst(6, Items.END_CRYSTAL) .addCatalyst(6, EndItems.CRYSTAL_SHARDS)
.addCatalyst(1, EndItems.ENDER_DUST) .addCatalyst(1, EndItems.ENDER_DUST)
.addCatalyst(3, EndItems.ENDER_DUST) .addCatalyst(3, EndItems.ENDER_DUST)
.addCatalyst(5, EndItems.ENDER_DUST) .addCatalyst(5, EndItems.ENDER_DUST)

View file

@ -14,6 +14,7 @@ import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.RecipeType; import net.minecraft.recipe.RecipeType;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper; import net.minecraft.util.JsonHelper;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -68,6 +69,16 @@ public class InfusionRecipe implements Recipe<InfusionRitual> {
public boolean fits(int width, int height) { public boolean fits(int width, int height) {
return true; return true;
} }
@Override
public DefaultedList<Ingredient> getPreviewInputs() {
DefaultedList<Ingredient> defaultedList = DefaultedList.of();
defaultedList.add(input);
for (Ingredient catalyst : catalysts) {
defaultedList.add(catalyst);
}
return defaultedList;
}
@Override @Override
public ItemStack getOutput() { public ItemStack getOutput() {

View file

@ -120,12 +120,15 @@ public class InfusionRitual implements Inventory {
double ty = target.getY() + 1.75; double ty = target.getY() + 1.75;
double tz = target.getZ() + 0.5; double tz = target.getZ() + 0.5;
for (PedestalBlockEntity catalyst : catalysts) { for (PedestalBlockEntity catalyst : catalysts) {
BlockPos start = catalyst.getPos().up(); ItemStack stack = catalyst.getStack(0);
double sx = start.getX() + 0.5; if (!stack.isEmpty()) {
double sy = start.getY() + 0.25; BlockPos start = catalyst.getPos();
double sz = start.getZ() + 0.5; double sx = start.getX() + 0.5;
ItemStackParticleEffect catalystParticle = new ItemStackParticleEffect(ParticleTypes.ITEM, catalyst.getStack(0)); double sy = start.getY() + 1.25;
world.spawnParticles(catalystParticle, sx, sy, sz, 0, tx - sx, ty - sy, tz - sz, 0.125); double sz = start.getZ() + 0.5;
ItemStackParticleEffect catalystParticle = new ItemStackParticleEffect(ParticleTypes.ITEM, stack);
world.spawnParticles(catalystParticle, sx, sy, sz, 0, tx - sx, ty - sy, tz - sz, 0.125);
}
} }
} }

View file

@ -1,6 +1,9 @@
{ {
"itemGroup.betterend.items": "Better End", "itemGroup.betterend.items": "Better End",
"category.rei.damage.amount&dmg": "Tool damage: %s",
"category.rei.infusion.time&val": "Infusion Time: %s",
"biome.betterend.foggy_mushroomland": "Foggy Mushroomland", "biome.betterend.foggy_mushroomland": "Foggy Mushroomland",
"biome.betterend.dust_wastelands": "Dust Wastelands", "biome.betterend.dust_wastelands": "Dust Wastelands",
"biome.betterend.chorus_forest": "Chorus Forest", "biome.betterend.chorus_forest": "Chorus Forest",
@ -102,8 +105,6 @@
"block.betterend.aurora_crystal": "Aurora Crystal", "block.betterend.aurora_crystal": "Aurora Crystal",
"item.betterend.crystal_shards": "Crystal Shards", "item.betterend.crystal_shards": "Crystal Shards",
"category.rei.damage.amount&dmg": "Tool damage: %s",
"block.betterend.pythadendron_sapling": "Pythadendron Sapling", "block.betterend.pythadendron_sapling": "Pythadendron Sapling",
"block.betterend.pythadendron_bark": "Pythadendron Bark", "block.betterend.pythadendron_bark": "Pythadendron Bark",
"block.betterend.pythadendron_barrel": "Pythadendron Barrel", "block.betterend.pythadendron_barrel": "Pythadendron Barrel",

View file

@ -1,6 +1,9 @@
{ {
"itemGroup.betterend.items": "Улучшенный Край", "itemGroup.betterend.items": "Улучшенный Край",
"category.rei.damage.amount&dmg": "Износ инструмента: %s",
"category.rei.infusion.time&val": "Время наполнения: %s",
"biome.betterend.foggy_mushroomland": "Туманное гриболесье", "biome.betterend.foggy_mushroomland": "Туманное гриболесье",
"biome.betterend.dust_wastelands": "Пыльные пустоши", "biome.betterend.dust_wastelands": "Пыльные пустоши",
"biome.betterend.chorus_forest": "Хорусовый лес", "biome.betterend.chorus_forest": "Хорусовый лес",
@ -102,8 +105,6 @@
"block.betterend.aurora_crystal": "Кристалл авроры", "block.betterend.aurora_crystal": "Кристалл авроры",
"item.betterend.crystal_shards": "Осколки кристаллов", "item.betterend.crystal_shards": "Осколки кристаллов",
"category.rei.damage.amount&dmg": "Износ инструмента: %s",
"block.betterend.pythadendron_sapling": "Саженец пифадендрона", "block.betterend.pythadendron_sapling": "Саженец пифадендрона",
"block.betterend.pythadendron_bark": "Кора пифадендрона", "block.betterend.pythadendron_bark": "Кора пифадендрона",
"block.betterend.pythadendron_barrel": "Бочка из пифадендрона", "block.betterend.pythadendron_barrel": "Бочка из пифадендрона",

View file

@ -26,10 +26,10 @@
"ru.betterend.client.BetterEndClient" "ru.betterend.client.BetterEndClient"
], ],
"rei_plugins": [ "rei_plugins": [
"ru.betterend.compat.REIPlugin" "ru.betterend.compat.rei.REIPlugin"
], ],
"rei_containers": [ "rei_containers": [
"ru.betterend.compat.REIContainer" "ru.betterend.compat.rei.REIContainer"
] ]
}, },
"mixins": [ "mixins": [