REI anvil recipes display improvement
This commit is contained in:
parent
4480d72344
commit
775e2f6a8e
4 changed files with 51 additions and 16 deletions
|
@ -2,7 +2,10 @@ package ru.betterend.integration.rei;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -21,6 +24,7 @@ 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.blocks.basis.EndAnvilBlock;
|
||||
import ru.betterend.util.LangUtil;
|
||||
|
||||
public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay> {
|
||||
|
@ -37,7 +41,7 @@ public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay>
|
|||
|
||||
@Override
|
||||
public @NotNull EntryStack getLogo() {
|
||||
return REIPlugin.ANVIL;
|
||||
return REIPlugin.ANVILS.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,16 +51,26 @@ public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay>
|
|||
widgets.add(Widgets.createRecipeBase(bounds));
|
||||
int x = startPoint.x + 10;
|
||||
int y = startPoint.y;
|
||||
widgets.add(Widgets.createResultSlotBackground(new Point(x + 61, y + 4)));
|
||||
widgets.add(Widgets.createResultSlotBackground(new Point(x + 61, y + 5)));
|
||||
List<List<EntryStack>> inputEntries = display.getInputEntries();
|
||||
List<EntryStack> materials = inputEntries.get(1);
|
||||
int anvilLevel = display.getAnvilLevel();
|
||||
List<EntryStack> anvils = REIPlugin.ANVILS.stream().filter(anvil -> {
|
||||
Block block = ((BlockItem) anvil.getItem()).getBlock();
|
||||
if (block instanceof EndAnvilBlock) {
|
||||
return ((EndAnvilBlock) block).getCraftingLevel() >= anvilLevel;
|
||||
}
|
||||
return anvilLevel == 1;
|
||||
}).collect(Collectors.toList());
|
||||
materials.forEach(entryStack -> entryStack.setAmount(display.getInputCount()));
|
||||
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.createArrow(new Point(x + 24, y + 4)));
|
||||
widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 7, bounds.y + bounds.height - 15),
|
||||
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(materials).markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(x + 1, y + 3)).entries(inputEntries.get(0)).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 - 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.getResultingEntries().get(0)).disableBackground().markOutput());
|
||||
widgets.add(Widgets.createSlot(new Point(x - 9, y + 25)).entries(anvils));
|
||||
|
||||
return widgets;
|
||||
}
|
||||
|
||||
|
@ -80,7 +94,7 @@ public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay>
|
|||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 49;
|
||||
return 60;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,11 +27,15 @@ public class REIAnvilDisplay implements TransferRecipeDisplay {
|
|||
}
|
||||
|
||||
public int getDamage() {
|
||||
return this.recipe.getDamage();
|
||||
return recipe.getDamage();
|
||||
}
|
||||
|
||||
public int getInputCount() {
|
||||
return this.recipe.getInputCount();
|
||||
return recipe.getInputCount();
|
||||
}
|
||||
|
||||
public int getAnvilLevel() {
|
||||
return recipe.getAnvilLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +60,7 @@ public class REIAnvilDisplay implements TransferRecipeDisplay {
|
|||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getRequiredEntries() {
|
||||
return this.input;
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,6 +76,6 @@ public class REIAnvilDisplay implements TransferRecipeDisplay {
|
|||
@Override
|
||||
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo,
|
||||
ScreenHandler container) {
|
||||
return this.input;
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,29 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
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.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.recipe.BlastingRecipe;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
import ru.betterend.recipe.builders.AnvilRecipe;
|
||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class REIPlugin implements REIPluginV0 {
|
||||
|
@ -24,7 +35,7 @@ public class REIPlugin implements REIPluginV0 {
|
|||
|
||||
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);
|
||||
public final static List<EntryStack> ANVILS;
|
||||
|
||||
@Override
|
||||
public Identifier getPluginIdentifier() {
|
||||
|
@ -43,7 +54,7 @@ public class REIPlugin implements REIPluginV0 {
|
|||
public void registerOthers(RecipeHelper recipeHelper) {
|
||||
recipeHelper.registerWorkingStations(ALLOYING, END_STONE_SMELTER);
|
||||
recipeHelper.registerWorkingStations(INFUSION, INFUSION_RITUAL);
|
||||
recipeHelper.registerWorkingStations(SMITHING, ANVIL);
|
||||
recipeHelper.registerWorkingStations(SMITHING, ANVILS.toArray(new EntryStack[]{}));
|
||||
recipeHelper.removeAutoCraftButton(SMITHING);
|
||||
}
|
||||
|
||||
|
@ -53,4 +64,10 @@ public class REIPlugin implements REIPluginV0 {
|
|||
new REIInfusionCategory(),
|
||||
new REIAnvilCategory());
|
||||
}
|
||||
|
||||
static {
|
||||
ANVILS = Lists.newArrayList(EntryStack.ofItems(EndItems.getModBlocks().stream()
|
||||
.filter(item -> ((BlockItem) item).getBlock() instanceof EndAnvilBlock).collect(Collectors.toList())));
|
||||
ANVILS.add(0, EntryStack.create(Blocks.ANVIL));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue