Infusion REI display
This commit is contained in:
parent
ea4b9b726b
commit
cd88d69cf3
14 changed files with 626 additions and 439 deletions
|
@ -1,7 +1,6 @@
|
|||
package ru.betterend.compat;
|
||||
package ru.betterend.compat.rei;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -9,6 +8,7 @@ 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;
|
||||
|
@ -17,10 +17,12 @@ 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;
|
||||
|
@ -80,7 +82,7 @@ public class REIAlloyingCategory implements TransferRecipeCategory<REIAlloyingDi
|
|||
|
||||
@Override
|
||||
public @NotNull RecipeEntry getSimpleRenderer(REIAlloyingDisplay recipe) {
|
||||
return SimpleRecipeEntry.from(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getResultingEntries());
|
||||
return SimpleRecipeEntry.from(recipe.getInputEntries(), recipe.getResultingEntries());
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,4 +1,4 @@
|
|||
package ru.betterend.compat;
|
||||
package ru.betterend.compat.rei;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package ru.betterend.compat;
|
||||
package ru.betterend.compat.rei;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package ru.betterend.compat;
|
||||
package ru.betterend.compat.rei;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package ru.betterend.compat;
|
||||
package ru.betterend.compat.rei;
|
||||
|
||||
import me.shedaniel.rei.plugin.containers.CraftingContainerInfoWrapper;
|
||||
import me.shedaniel.rei.server.ContainerInfoHandler;
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package ru.betterend.compat;
|
||||
package ru.betterend.compat.rei;
|
||||
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeHelper;
|
||||
|
@ -11,6 +11,7 @@ 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)
|
||||
|
@ -19,8 +20,10 @@ 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
|
||||
|
@ -33,11 +36,13 @@ public class REIPlugin implements REIPluginV0 {
|
|||
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);
|
||||
}
|
||||
|
@ -45,6 +50,7 @@ public class REIPlugin implements REIPluginV0 {
|
|||
@Override
|
||||
public void registerPluginCategories(RecipeHelper recipeHelper) {
|
||||
recipeHelper.registerCategories(new REIAlloyingCategory(),
|
||||
new REIInfusionCategory(),
|
||||
new REIAnvilCategory());
|
||||
}
|
||||
}
|
|
@ -18,12 +18,12 @@ public class InfusionRecipes {
|
|||
.build();
|
||||
|
||||
InfusionRecipe.Builder.create("eternal_crystal")
|
||||
.setInput(EndItems.CRYSTAL_SHARDS)
|
||||
.setInput(Items.END_CRYSTAL)
|
||||
.setOutput(EndItems.ETERNAL_CRYSTAL)
|
||||
.addCatalyst(0, Items.END_CRYSTAL)
|
||||
.addCatalyst(2, Items.END_CRYSTAL)
|
||||
.addCatalyst(4, Items.END_CRYSTAL)
|
||||
.addCatalyst(6, Items.END_CRYSTAL)
|
||||
.addCatalyst(0, EndItems.CRYSTAL_SHARDS)
|
||||
.addCatalyst(2, EndItems.CRYSTAL_SHARDS)
|
||||
.addCatalyst(4, EndItems.CRYSTAL_SHARDS)
|
||||
.addCatalyst(6, EndItems.CRYSTAL_SHARDS)
|
||||
.addCatalyst(1, EndItems.ENDER_DUST)
|
||||
.addCatalyst(3, EndItems.ENDER_DUST)
|
||||
.addCatalyst(5, EndItems.ENDER_DUST)
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.recipe.RecipeSerializer;
|
|||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -69,6 +70,16 @@ public class InfusionRecipe implements Recipe<InfusionRitual> {
|
|||
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
|
||||
public ItemStack getOutput() {
|
||||
return this.output;
|
||||
|
|
|
@ -120,12 +120,15 @@ public class InfusionRitual implements Inventory {
|
|||
double ty = target.getY() + 1.75;
|
||||
double tz = target.getZ() + 0.5;
|
||||
for (PedestalBlockEntity catalyst : catalysts) {
|
||||
BlockPos start = catalyst.getPos().up();
|
||||
double sx = start.getX() + 0.5;
|
||||
double sy = start.getY() + 0.25;
|
||||
double sz = start.getZ() + 0.5;
|
||||
ItemStackParticleEffect catalystParticle = new ItemStackParticleEffect(ParticleTypes.ITEM, catalyst.getStack(0));
|
||||
world.spawnParticles(catalystParticle, sx, sy, sz, 0, tx - sx, ty - sy, tz - sz, 0.125);
|
||||
ItemStack stack = catalyst.getStack(0);
|
||||
if (!stack.isEmpty()) {
|
||||
BlockPos start = catalyst.getPos();
|
||||
double sx = start.getX() + 0.5;
|
||||
double sy = start.getY() + 1.25;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
{
|
||||
"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.dust_wastelands": "Dust Wastelands",
|
||||
"biome.betterend.chorus_forest": "Chorus Forest",
|
||||
|
@ -102,8 +105,6 @@
|
|||
"block.betterend.aurora_crystal": "Aurora Crystal",
|
||||
"item.betterend.crystal_shards": "Crystal Shards",
|
||||
|
||||
"category.rei.damage.amount&dmg": "Tool damage: %s",
|
||||
|
||||
"block.betterend.pythadendron_sapling": "Pythadendron Sapling",
|
||||
"block.betterend.pythadendron_bark": "Pythadendron Bark",
|
||||
"block.betterend.pythadendron_barrel": "Pythadendron Barrel",
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
{
|
||||
"itemGroup.betterend.items": "Улучшенный Край",
|
||||
|
||||
"category.rei.damage.amount&dmg": "Износ инструмента: %s",
|
||||
"category.rei.infusion.time&val": "Время наполнения: %s",
|
||||
|
||||
"biome.betterend.foggy_mushroomland": "Туманное гриболесье",
|
||||
"biome.betterend.dust_wastelands": "Пыльные пустоши",
|
||||
"biome.betterend.chorus_forest": "Хорусовый лес",
|
||||
|
@ -102,8 +105,6 @@
|
|||
"block.betterend.aurora_crystal": "Кристалл авроры",
|
||||
"item.betterend.crystal_shards": "Осколки кристаллов",
|
||||
|
||||
"category.rei.damage.amount&dmg": "Износ инструмента: %s",
|
||||
|
||||
"block.betterend.pythadendron_sapling": "Саженец пифадендрона",
|
||||
"block.betterend.pythadendron_bark": "Кора пифадендрона",
|
||||
"block.betterend.pythadendron_barrel": "Бочка из пифадендрона",
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
"ru.betterend.client.BetterEndClient"
|
||||
],
|
||||
"rei_plugins": [
|
||||
"ru.betterend.compat.REIPlugin"
|
||||
"ru.betterend.compat.rei.REIPlugin"
|
||||
],
|
||||
"rei_containers": [
|
||||
"ru.betterend.compat.REIContainer"
|
||||
"ru.betterend.compat.rei.REIContainer"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue