[Change] Disabled EMI for now

This commit is contained in:
Frank 2023-12-18 12:02:26 +01:00
parent f974b31f48
commit feba29172b
5 changed files with 602 additions and 602 deletions

View file

@ -1,117 +1,117 @@
package org.betterx.bclib.integration.emi; package org.betterx.bclib.integration.emi;
import net.minecraft.client.Minecraft; //import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; //import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.network.chat.Component; //import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; //import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container; //import net.minecraft.world.Container;
import net.minecraft.world.item.crafting.Ingredient; //import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe; //import net.minecraft.world.item.crafting.Recipe;
//
import dev.emi.emi.api.recipe.EmiRecipe; //import dev.emi.emi.api.recipe.EmiRecipe;
import dev.emi.emi.api.recipe.EmiRecipeCategory; //import dev.emi.emi.api.recipe.EmiRecipeCategory;
import dev.emi.emi.api.render.EmiTexture; //import dev.emi.emi.api.render.EmiTexture;
import dev.emi.emi.api.stack.EmiIngredient; //import dev.emi.emi.api.stack.EmiIngredient;
import dev.emi.emi.api.stack.EmiStack; //import dev.emi.emi.api.stack.EmiStack;
import dev.emi.emi.api.widget.WidgetHolder; //import dev.emi.emi.api.widget.WidgetHolder;
//
import java.util.List; //import java.util.List;
//
public abstract class EMIAbstractAlloyingRecipe<C extends Container, T extends Recipe<C>> implements EmiRecipe { //public abstract class EMIAbstractAlloyingRecipe<C extends Container, T extends Recipe<C>> implements EmiRecipe {
private final ResourceLocation id; // private final ResourceLocation id;
private final List<EmiIngredient> input; // private final List<EmiIngredient> input;
private final List<EmiStack> output; // private final List<EmiStack> output;
protected final T recipe; // protected final T recipe;
//
private final int fuelMultiplier; // private final int fuelMultiplier;
private final boolean infiniBurn; // private final boolean infiniBurn;
//
public EMIAbstractAlloyingRecipe(T recipe, ResourceLocation id, int fuelMultiplier, boolean infiniBurn) { // public EMIAbstractAlloyingRecipe(T recipe, ResourceLocation id, int fuelMultiplier, boolean infiniBurn) {
this.recipe = recipe; // this.recipe = recipe;
this.id = id; // this.id = id;
this.input = List.of( // this.input = List.of(
EmiIngredient.of(recipe.getIngredients().get(0)), // EmiIngredient.of(recipe.getIngredients().get(0)),
recipe.getIngredients().size() > 1 // recipe.getIngredients().size() > 1
? EmiIngredient.of(recipe.getIngredients().get(1)) // ? EmiIngredient.of(recipe.getIngredients().get(1))
: EmiIngredient.of(Ingredient.EMPTY) // : EmiIngredient.of(Ingredient.EMPTY)
); // );
//
this.output = List.of(EmiStack.of(recipe.getResultItem(Minecraft.getInstance().level.registryAccess()))); // this.output = List.of(EmiStack.of(recipe.getResultItem(Minecraft.getInstance().level.registryAccess())));
this.fuelMultiplier = fuelMultiplier; // this.fuelMultiplier = fuelMultiplier;
this.infiniBurn = infiniBurn; // this.infiniBurn = infiniBurn;
} // }
//
protected abstract int getSmeltTime(); // protected abstract int getSmeltTime();
protected abstract float getExperience(); // protected abstract float getExperience();
//
//
@Override // @Override
public EmiRecipeCategory getCategory() { // public EmiRecipeCategory getCategory() {
return EMIPlugin.END_ALLOYING_CATEGORY; // return EMIPlugin.END_ALLOYING_CATEGORY;
} // }
//
@Override // @Override
public ResourceLocation getId() { // public ResourceLocation getId() {
return id; // return id;
} // }
//
@Override // @Override
public List<EmiIngredient> getInputs() { // public List<EmiIngredient> getInputs() {
return input; // return input;
} // }
//
@Override // @Override
public List<EmiStack> getOutputs() { // public List<EmiStack> getOutputs() {
return output; // return output;
} // }
//
protected int getXOffset() { // protected int getXOffset() {
return 22; // return 22;
} // }
//
@Override // @Override
public int getDisplayWidth() { // public int getDisplayWidth() {
return 82 + getXOffset(); // return 82 + getXOffset();
} // }
//
@Override // @Override
public int getDisplayHeight() { // public int getDisplayHeight() {
return 38; // return 38;
} // }
//
@Override // @Override
public void addWidgets(WidgetHolder widgets) { // public void addWidgets(WidgetHolder widgets) {
// Add an arrow texture to indicate processing // // Add an arrow texture to indicate processing
widgets.addFillingArrow(24 + getXOffset(), 5, 50 * getSmeltTime()) // widgets.addFillingArrow(24 + getXOffset(), 5, 50 * getSmeltTime())
.tooltip((mx, my) -> List.of(ClientTooltipComponent.create(Component.translatable( // .tooltip((mx, my) -> List.of(ClientTooltipComponent.create(Component.translatable(
"emi.cooking.time", // "emi.cooking.time",
new Object[]{(float) getSmeltTime() / 20.0F} // new Object[]{(float) getSmeltTime() / 20.0F}
).getVisualOrderText()))); // ).getVisualOrderText())));
//
if (this.infiniBurn) { // if (this.infiniBurn) {
widgets.addTexture(EmiTexture.FULL_FLAME, 1, 24); // widgets.addTexture(EmiTexture.FULL_FLAME, 1, 24);
} else { // } else {
widgets.addTexture(EmiTexture.EMPTY_FLAME, 1, 24); // widgets.addTexture(EmiTexture.EMPTY_FLAME, 1, 24);
widgets.addAnimatedTexture(EmiTexture.FULL_FLAME, 1, 24, 4000 / this.fuelMultiplier, false, true, true); // widgets.addAnimatedTexture(EmiTexture.FULL_FLAME, 1, 24, 4000 / this.fuelMultiplier, false, true, true);
} // }
//
// Adds an input slot on the left // // Adds an input slot on the left
widgets.addSlot(input.get(0), 0, 4); // widgets.addSlot(input.get(0), 0, 4);
widgets.addSlot((input.size() > 1) ? input.get(1) : null, 20, 4); // widgets.addSlot((input.size() > 1) ? input.get(1) : null, 20, 4);
widgets.addText( // widgets.addText(
Component.translatable("emi.cooking.experience", getExperience()).getVisualOrderText(), // Component.translatable("emi.cooking.experience", getExperience()).getVisualOrderText(),
24 + getXOffset(), 28, 0xFFFFFFFF, true // 24 + getXOffset(), 28, 0xFFFFFFFF, true
); // );
//
// Adds an output slot on the right // // Adds an output slot on the right
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context // // Note that output slots need to call `recipeContext` to inform EMI about their recipe context
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more // // This includes being able to resolve recipe trees, favorite stacks with recipe context, and more
widgets.addSlot(output.get(0), 56 + getXOffset(), 0).large(true).recipeContext(this); // widgets.addSlot(output.get(0), 56 + getXOffset(), 0).large(true).recipeContext(this);
} // }
//
@Override // @Override
public boolean supportsRecipeTree() { // public boolean supportsRecipeTree() {
return true; // return true;
} // }
} //}

View file

@ -1,32 +1,32 @@
package org.betterx.bclib.integration.emi; package org.betterx.bclib.integration.emi;
import org.betterx.bclib.BCLib; //import org.betterx.bclib.BCLib;
import org.betterx.bclib.recipes.AlloyingRecipe; //import org.betterx.bclib.recipes.AlloyingRecipe;
//
import net.minecraft.world.Container; //import net.minecraft.world.Container;
import net.minecraft.world.item.crafting.RecipeManager; //import net.minecraft.world.item.crafting.RecipeManager;
//
import dev.emi.emi.api.EmiRegistry; //import dev.emi.emi.api.EmiRegistry;
//
public class EMIAlloyingRecipe extends EMIAbstractAlloyingRecipe<Container, AlloyingRecipe> { //public class EMIAlloyingRecipe extends EMIAbstractAlloyingRecipe<Container, AlloyingRecipe> {
public EMIAlloyingRecipe(AlloyingRecipe recipe) { // public EMIAlloyingRecipe(AlloyingRecipe recipe) {
super(recipe, recipe.getId(), 1, false); // super(recipe, recipe.getId(), 1, false);
} // }
//
@Override // @Override
protected int getSmeltTime() { // protected int getSmeltTime() {
return recipe.getSmeltTime(); // return recipe.getSmeltTime();
} // }
//
@Override // @Override
protected float getExperience() { // protected float getExperience() {
return recipe.getExperience(); // return recipe.getExperience();
} // }
//
static void addAllRecipes(EmiRegistry emiRegistry, RecipeManager manager) { // static void addAllRecipes(EmiRegistry emiRegistry, RecipeManager manager) {
EMIPlugin.addAllRecipes( // EMIPlugin.addAllRecipes(
emiRegistry, manager, BCLib.LOGGER, // emiRegistry, manager, BCLib.LOGGER,
AlloyingRecipe.TYPE, EMIAlloyingRecipe::new // AlloyingRecipe.TYPE, EMIAlloyingRecipe::new
); // );
} // }
} //}

View file

@ -1,111 +1,111 @@
package org.betterx.bclib.integration.emi; package org.betterx.bclib.integration.emi;
import org.betterx.bclib.BCLib; //import org.betterx.bclib.BCLib;
import org.betterx.bclib.recipes.AnvilRecipe; //import org.betterx.bclib.recipes.AnvilRecipe;
//
import net.minecraft.client.Minecraft; //import net.minecraft.client.Minecraft;
import net.minecraft.core.Holder; //import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation; //import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item; //import net.minecraft.world.item.Item;
import net.minecraft.world.item.crafting.Ingredient; //import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeManager; //import net.minecraft.world.item.crafting.RecipeManager;
//
import dev.emi.emi.api.EmiRegistry; //import dev.emi.emi.api.EmiRegistry;
import dev.emi.emi.api.recipe.EmiRecipe; //import dev.emi.emi.api.recipe.EmiRecipe;
import dev.emi.emi.api.recipe.EmiRecipeCategory; //import dev.emi.emi.api.recipe.EmiRecipeCategory;
import dev.emi.emi.api.render.EmiTexture; //import dev.emi.emi.api.render.EmiTexture;
import dev.emi.emi.api.stack.EmiIngredient; //import dev.emi.emi.api.stack.EmiIngredient;
import dev.emi.emi.api.stack.EmiStack; //import dev.emi.emi.api.stack.EmiStack;
import dev.emi.emi.api.widget.WidgetHolder; //import dev.emi.emi.api.widget.WidgetHolder;
//
import java.util.List; //import java.util.List;
import java.util.stream.StreamSupport; //import java.util.stream.StreamSupport;
import org.jetbrains.annotations.Nullable; //import org.jetbrains.annotations.Nullable;
//
public class EMIAnvilRecipe implements EmiRecipe { //public class EMIAnvilRecipe implements EmiRecipe {
private final ResourceLocation id; // private final ResourceLocation id;
private final List<EmiIngredient> input; // private final List<EmiIngredient> input;
private final List<EmiStack> output; // private final List<EmiStack> output;
private final EmiRecipeCategory category; // private final EmiRecipeCategory category;
//
public EMIAnvilRecipe(AnvilRecipe recipe, Item hammer) { // public EMIAnvilRecipe(AnvilRecipe recipe, Item hammer) {
this.id = new ResourceLocation( // this.id = new ResourceLocation(
"emi", // "emi",
recipe.getId().getNamespace() + "/" + recipe.getId().getPath() + "/anvil/" + hammer.getDescriptionId() // recipe.getId().getNamespace() + "/" + recipe.getId().getPath() + "/anvil/" + hammer.getDescriptionId()
); // );
this.input = List.of( // this.input = List.of(
EmiIngredient.of(recipe.getMainIngredient(), recipe.getInputCount()), // EmiIngredient.of(recipe.getMainIngredient(), recipe.getInputCount()),
EmiIngredient.of(Ingredient.of(hammer)) // EmiIngredient.of(Ingredient.of(hammer))
); // );
this.output = List.of(EmiStack.of(recipe.getResultItem(Minecraft.getInstance().level.registryAccess()))); // this.output = List.of(EmiStack.of(recipe.getResultItem(Minecraft.getInstance().level.registryAccess())));
this.category = EMIPlugin.getAnvilCategoryForLevel(recipe.getAnvilLevel()); // this.category = EMIPlugin.getAnvilCategoryForLevel(recipe.getAnvilLevel());
} // }
//
static void addAllRecipes(EmiRegistry emiRegistry, RecipeManager manager) { // static void addAllRecipes(EmiRegistry emiRegistry, RecipeManager manager) {
Iterable<Holder<Item>> hammers = AnvilRecipe.getAllHammers(); // Iterable<Holder<Item>> hammers = AnvilRecipe.getAllHammers();
EMIPlugin.addAllRecipes( // EMIPlugin.addAllRecipes(
emiRegistry, manager, BCLib.LOGGER, // emiRegistry, manager, BCLib.LOGGER,
AnvilRecipe.TYPE, // AnvilRecipe.TYPE,
recipe -> StreamSupport.stream(hammers.spliterator(), false) // recipe -> StreamSupport.stream(hammers.spliterator(), false)
.map(Holder::value) // .map(Holder::value)
.filter(recipe::canUse) // .filter(recipe::canUse)
.toList(), // .toList(),
EMIAnvilRecipe::new // EMIAnvilRecipe::new
); // );
} // }
//
@Override // @Override
public EmiRecipeCategory getCategory() { // public EmiRecipeCategory getCategory() {
return category; // return category;
} // }
//
@Override // @Override
public @Nullable ResourceLocation getId() { // public @Nullable ResourceLocation getId() {
return id; // return id;
} // }
//
@Override // @Override
public List<EmiIngredient> getInputs() { // public List<EmiIngredient> getInputs() {
return input; // return input;
} // }
//
@Override // @Override
public List<EmiStack> getOutputs() { // public List<EmiStack> getOutputs() {
return output; // return output;
} // }
//
@Override // @Override
public int getDisplayWidth() { // public int getDisplayWidth() {
return 104; // return 104;
} // }
//
@Override // @Override
public int getDisplayHeight() { // public int getDisplayHeight() {
return 26; // return 26;
} // }
//
@Override // @Override
public void addWidgets(WidgetHolder widgetHolder) { // public void addWidgets(WidgetHolder widgetHolder) {
// Add an arrow texture to indicate processing // // Add an arrow texture to indicate processing
widgetHolder.addTexture(EmiTexture.EMPTY_ARROW, 46, 5); // widgetHolder.addTexture(EmiTexture.EMPTY_ARROW, 46, 5);
//
// Adds an input slot on the left // // Adds an input slot on the left
widgetHolder.addSlot(input.get(0), 0, 4); // widgetHolder.addSlot(input.get(0), 0, 4);
widgetHolder.addSlot(input.get(1), 20, 4).catalyst(true); // widgetHolder.addSlot(input.get(1), 20, 4).catalyst(true);
//
// Adds an output slot on the right // // Adds an output slot on the right
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context // // Note that output slots need to call `recipeContext` to inform EMI about their recipe context
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more // // This includes being able to resolve recipe trees, favorite stacks with recipe context, and more
widgetHolder.addSlot(output.get(0), 78, 0).large(true).recipeContext(this); // widgetHolder.addSlot(output.get(0), 78, 0).large(true).recipeContext(this);
} // }
//
@Override // @Override
public List<EmiIngredient> getCatalysts() { // public List<EmiIngredient> getCatalysts() {
return List.of(input.get(1)); // return List.of(input.get(1));
} // }
//
@Override // @Override
public boolean supportsRecipeTree() { // public boolean supportsRecipeTree() {
return true; // return true;
} // }
} //}

View file

@ -1,183 +1,183 @@
package org.betterx.bclib.integration.emi; package org.betterx.bclib.integration.emi;
import org.betterx.bclib.blocks.LeveledAnvilBlock; //import org.betterx.bclib.blocks.LeveledAnvilBlock;
import org.betterx.bclib.util.RomanNumeral; //import org.betterx.bclib.util.RomanNumeral;
//
import com.mojang.blaze3d.vertex.Tesselator; //import com.mojang.blaze3d.vertex.Tesselator;
import net.minecraft.client.Minecraft; //import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font; //import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics; //import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; //import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.client.renderer.MultiBufferSource; //import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.resources.ResourceLocation; //import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence; //import net.minecraft.util.FormattedCharSequence;
//
import com.google.common.collect.Lists; //import com.google.common.collect.Lists;
import dev.emi.emi.api.recipe.EmiRecipe; //import dev.emi.emi.api.recipe.EmiRecipe;
import dev.emi.emi.api.recipe.EmiRecipeCategory; //import dev.emi.emi.api.recipe.EmiRecipeCategory;
import dev.emi.emi.api.render.EmiRenderable; //import dev.emi.emi.api.render.EmiRenderable;
import dev.emi.emi.api.render.EmiTexture; //import dev.emi.emi.api.render.EmiTexture;
import org.joml.Matrix4f; //import org.joml.Matrix4f;
//
import java.util.Comparator; //import java.util.Comparator;
import java.util.List; //import java.util.List;
//
public class EMIAnvilRecipeCategory extends EmiRecipeCategory { //public class EMIAnvilRecipeCategory extends EmiRecipeCategory {
private final int anvilLevel; // private final int anvilLevel;
private final List<FormattedCharSequence> titleLines; // private final List<FormattedCharSequence> titleLines;
//
//
public EMIAnvilRecipeCategory(ResourceLocation id, EmiRenderable icon, int anvilLevel) { // public EMIAnvilRecipeCategory(ResourceLocation id, EmiRenderable icon, int anvilLevel) {
super(id, icon); // super(id, icon);
this.anvilLevel = anvilLevel; // this.anvilLevel = anvilLevel;
titleLines = LeveledAnvilBlock.getNamesForLevel(anvilLevel); // titleLines = LeveledAnvilBlock.getNamesForLevel(anvilLevel);
} // }
//
public EMIAnvilRecipeCategory(ResourceLocation id, EmiRenderable icon, EmiRenderable simplified, int anvilLevel) { // public EMIAnvilRecipeCategory(ResourceLocation id, EmiRenderable icon, EmiRenderable simplified, int anvilLevel) {
super(id, icon, simplified); // super(id, icon, simplified);
this.anvilLevel = anvilLevel; // this.anvilLevel = anvilLevel;
titleLines = LeveledAnvilBlock.getNamesForLevel(anvilLevel); // titleLines = LeveledAnvilBlock.getNamesForLevel(anvilLevel);
} // }
//
public EMIAnvilRecipeCategory( // public EMIAnvilRecipeCategory(
ResourceLocation id, // ResourceLocation id,
EmiRenderable icon, EmiTexture simplified, // EmiRenderable icon, EmiTexture simplified,
Comparator<EmiRecipe> sorter, // Comparator<EmiRecipe> sorter,
int anvilLevel // int anvilLevel
) { // ) {
super(id, icon, simplified, sorter); // super(id, icon, simplified, sorter);
this.anvilLevel = anvilLevel; // this.anvilLevel = anvilLevel;
titleLines = LeveledAnvilBlock.getNamesForLevel(anvilLevel); // titleLines = LeveledAnvilBlock.getNamesForLevel(anvilLevel);
//
//
} // }
//
@Override // @Override
public void renderSimplified(GuiGraphics guiGraphics, int x, int y, float delta) { // public void renderSimplified(GuiGraphics guiGraphics, int x, int y, float delta) {
super.renderSimplified(guiGraphics, x, y, delta); // super.renderSimplified(guiGraphics, x, y, delta);
final Font font = Minecraft.getInstance().font; // final Font font = Minecraft.getInstance().font;
final String content = RomanNumeral.toRoman(anvilLevel); // final String content = RomanNumeral.toRoman(anvilLevel);
//
final MultiBufferSource.BufferSource bufferSource = MultiBufferSource // final MultiBufferSource.BufferSource bufferSource = MultiBufferSource
.immediate(Tesselator.getInstance().getBuilder()); // .immediate(Tesselator.getInstance().getBuilder());
final int xx = x + 19 - 2 - font.width(content); // final int xx = x + 19 - 2 - font.width(content);
final int yy = y + 6 + 3; // final int yy = y + 6 + 3;
final Matrix4f matrix = guiGraphics.pose().last().pose(); // final Matrix4f matrix = guiGraphics.pose().last().pose();
//
font.drawInBatch( // font.drawInBatch(
content, // content,
xx - 1, // xx - 1,
yy - 1, // yy - 1,
0xFF000000, // 0xFF000000,
false, // false,
matrix, // matrix,
bufferSource, // bufferSource,
Font.DisplayMode.NORMAL, // Font.DisplayMode.NORMAL,
0, // 0,
0xF000F0 // 0xF000F0
); // );
font.drawInBatch( // font.drawInBatch(
content, // content,
xx, // xx,
yy - 1, // yy - 1,
0xFF000000, // 0xFF000000,
false, // false,
matrix, // matrix,
bufferSource, // bufferSource,
Font.DisplayMode.NORMAL, // Font.DisplayMode.NORMAL,
0, // 0,
0xF000F0 // 0xF000F0
); // );
font.drawInBatch( // font.drawInBatch(
content, // content,
xx + 1, // xx + 1,
yy - 1, // yy - 1,
0xFF000000, // 0xFF000000,
false, // false,
matrix, // matrix,
bufferSource, // bufferSource,
Font.DisplayMode.NORMAL, // Font.DisplayMode.NORMAL,
0, // 0,
0xF000F0 // 0xF000F0
); // );
font.drawInBatch( // font.drawInBatch(
content, // content,
xx - 1, // xx - 1,
yy, // yy,
0xFF000000, // 0xFF000000,
false, // false,
matrix, // matrix,
bufferSource, // bufferSource,
Font.DisplayMode.NORMAL, // Font.DisplayMode.NORMAL,
0, // 0,
0xF000F0 // 0xF000F0
); // );
font.drawInBatch( // font.drawInBatch(
content, // content,
xx + 1, // xx + 1,
yy, // yy,
0xFF000000, // 0xFF000000,
false, // false,
matrix, // matrix,
bufferSource, // bufferSource,
Font.DisplayMode.NORMAL, // Font.DisplayMode.NORMAL,
0, // 0,
0xF000F0 // 0xF000F0
); // );
font.drawInBatch( // font.drawInBatch(
content, // content,
xx - 1, // xx - 1,
yy + 1, // yy + 1,
0xFF000000, // 0xFF000000,
false, // false,
matrix, // matrix,
bufferSource, // bufferSource,
Font.DisplayMode.NORMAL, // Font.DisplayMode.NORMAL,
0, // 0,
0xF000F0 // 0xF000F0
); // );
font.drawInBatch( // font.drawInBatch(
content, // content,
xx + 1, // xx + 1,
yy + 1, // yy + 1,
0xFF000000, // 0xFF000000,
false, // false,
matrix, // matrix,
bufferSource, // bufferSource,
Font.DisplayMode.NORMAL, // Font.DisplayMode.NORMAL,
0, // 0,
0xF000F0 // 0xF000F0
); // );
font.drawInBatch( // font.drawInBatch(
content, // content,
xx, // xx,
yy + 1, // yy + 1,
0xFF000000, // 0xFF000000,
false, // false,
matrix, // matrix,
bufferSource, // bufferSource,
Font.DisplayMode.NORMAL, // Font.DisplayMode.NORMAL,
0, // 0,
0xF000F0 // 0xF000F0
); // );
//
font.drawInBatch(content, xx, yy, 0xFFFFFFFF, true, matrix, bufferSource, Font.DisplayMode.NORMAL, 0, 0xF000F0); // font.drawInBatch(content, xx, yy, 0xFFFFFFFF, true, matrix, bufferSource, Font.DisplayMode.NORMAL, 0, 0xF000F0);
bufferSource.endBatch(); // bufferSource.endBatch();
} // }
//
@Override // @Override
public List<ClientTooltipComponent> getTooltip() { // public List<ClientTooltipComponent> getTooltip() {
List<ClientTooltipComponent> list = super.getTooltip(); // List<ClientTooltipComponent> list = super.getTooltip();
if (!titleLines.isEmpty()) { // if (!titleLines.isEmpty()) {
List<ClientTooltipComponent> newList = Lists.newArrayList(); // List<ClientTooltipComponent> newList = Lists.newArrayList();
for (var line : titleLines) // for (var line : titleLines)
newList.add(ClientTooltipComponent.create(line)); // newList.add(ClientTooltipComponent.create(line));
//
if (list.size() > 0) list.remove(0); // if (list.size() > 0) list.remove(0);
newList.addAll(list); // newList.addAll(list);
return newList; // return newList;
} // }
//
return list; // return list;
} // }
} //}

View file

@ -1,170 +1,170 @@
package org.betterx.bclib.integration.emi; package org.betterx.bclib.integration.emi;
import org.betterx.bclib.BCLib; //import org.betterx.bclib.BCLib;
import org.betterx.bclib.blocks.LeveledAnvilBlock; //import org.betterx.bclib.blocks.LeveledAnvilBlock;
import org.betterx.bclib.interfaces.AlloyingRecipeWorkstation; //import org.betterx.bclib.interfaces.AlloyingRecipeWorkstation;
import org.betterx.worlds.together.util.Logger; //import org.betterx.worlds.together.util.Logger;
//
import net.minecraft.resources.ResourceLocation; //import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container; //import net.minecraft.world.Container;
import net.minecraft.world.item.crafting.Recipe; //import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeManager; //import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.item.crafting.RecipeType; //import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.block.Blocks; //import net.minecraft.world.level.block.Blocks;
//
import dev.emi.emi.api.EmiPlugin; //import dev.emi.emi.api.EmiPlugin;
import dev.emi.emi.api.EmiRegistry; //import dev.emi.emi.api.EmiRegistry;
import dev.emi.emi.api.recipe.EmiRecipe; //import dev.emi.emi.api.recipe.EmiRecipe;
import dev.emi.emi.api.recipe.EmiRecipeCategory; //import dev.emi.emi.api.recipe.EmiRecipeCategory;
import dev.emi.emi.api.render.EmiTexture; //import dev.emi.emi.api.render.EmiTexture;
import dev.emi.emi.api.stack.EmiStack; //import dev.emi.emi.api.stack.EmiStack;
//
import java.util.Comparator; //import java.util.Comparator;
import java.util.List; //import java.util.List;
import java.util.function.BiFunction; //import java.util.function.BiFunction;
import java.util.function.Function; //import java.util.function.Function;
//
public class EMIPlugin implements EmiPlugin { //public class EMIPlugin implements EmiPlugin {
private static boolean didInit = false; // private static boolean didInit = false;
private static int maxAnvilLevel = 1; // private static int maxAnvilLevel = 1;
public static final ResourceLocation BCL_SIMPLIFIED_SPRITES = BCLib.makeID( // public static final ResourceLocation BCL_SIMPLIFIED_SPRITES = BCLib.makeID(
"textures/gui/widgets.png" // "textures/gui/widgets.png"
); // );
//
public static EmiStack END_ALLOYING_WORKSTATION; // public static EmiStack END_ALLOYING_WORKSTATION;
public static EmiRecipeCategory END_ALLOYING_CATEGORY; // public static EmiRecipeCategory END_ALLOYING_CATEGORY;
//
public static EmiRecipeCategory[] ANVIL_CATEGORIES; // public static EmiRecipeCategory[] ANVIL_CATEGORIES;
public static EmiStack[] ANVIL_WORKSTATIONS; // public static EmiStack[] ANVIL_WORKSTATIONS;
//
public static EmiTexture getSprite(int u, int v) { // public static EmiTexture getSprite(int u, int v) {
return new EmiTexture(BCL_SIMPLIFIED_SPRITES, u, v, 16, 16, 16, 16, 32, 32); // return new EmiTexture(BCL_SIMPLIFIED_SPRITES, u, v, 16, 16, 16, 16, 32, 32);
} // }
//
public void lazyInit() { // public void lazyInit() {
if (!didInit) { // if (!didInit) {
didInit = true; // didInit = true;
lazyInitAlloyingCategory(); // lazyInitAlloyingCategory();
lazyInitAnvilCategories(); // lazyInitAnvilCategories();
} // }
} // }
//
private void lazyInitAlloyingCategory() { // private void lazyInitAlloyingCategory() {
var workstations = AlloyingRecipeWorkstation.getWorkstationIcon(); // var workstations = AlloyingRecipeWorkstation.getWorkstationIcon();
if (!workstations.is(Blocks.BARRIER.asItem())) { // if (!workstations.is(Blocks.BARRIER.asItem())) {
END_ALLOYING_WORKSTATION = EmiStack.of(workstations); // END_ALLOYING_WORKSTATION = EmiStack.of(workstations);
//
END_ALLOYING_CATEGORY = new EmiRecipeCategory( // END_ALLOYING_CATEGORY = new EmiRecipeCategory(
BCLib.makeID("alloying"), // BCLib.makeID("alloying"),
END_ALLOYING_WORKSTATION, // END_ALLOYING_WORKSTATION,
getSprite(16, 0) // getSprite(16, 0)
); // );
} // }
} // }
//
//
private void lazyInitAnvilCategories() { // private void lazyInitAnvilCategories() {
if (ANVIL_CATEGORIES == null) { // if (ANVIL_CATEGORIES == null) {
maxAnvilLevel = Math.max(1, LeveledAnvilBlock // maxAnvilLevel = Math.max(1, LeveledAnvilBlock
.getAnvils() // .getAnvils()
.stream() // .stream()
.map(LeveledAnvilBlock::getAnvilCraftingLevel) // .map(LeveledAnvilBlock::getAnvilCraftingLevel)
.reduce(0, Math::max) // .reduce(0, Math::max)
); // );
//
ANVIL_CATEGORIES = new EmiRecipeCategory[maxAnvilLevel + 1]; // ANVIL_CATEGORIES = new EmiRecipeCategory[maxAnvilLevel + 1];
ANVIL_WORKSTATIONS = new EmiStack[maxAnvilLevel + 1]; // ANVIL_WORKSTATIONS = new EmiStack[maxAnvilLevel + 1];
//
for (int anvilLevel = 0; anvilLevel <= maxAnvilLevel; anvilLevel++) { // for (int anvilLevel = 0; anvilLevel <= maxAnvilLevel; anvilLevel++) {
int finalAnvilLevel = anvilLevel; // int finalAnvilLevel = anvilLevel;
ANVIL_WORKSTATIONS[anvilLevel] = EmiStack.of(LeveledAnvilBlock // ANVIL_WORKSTATIONS[anvilLevel] = EmiStack.of(LeveledAnvilBlock
.getAnvils() // .getAnvils()
.stream() // .stream()
.filter(b -> LeveledAnvilBlock.canHandle(b, finalAnvilLevel)) // .filter(b -> LeveledAnvilBlock.canHandle(b, finalAnvilLevel))
.sorted(Comparator.comparingInt(LeveledAnvilBlock::getAnvilCraftingLevel)) // .sorted(Comparator.comparingInt(LeveledAnvilBlock::getAnvilCraftingLevel))
.findFirst().orElse(Blocks.BARRIER) // .findFirst().orElse(Blocks.BARRIER)
); // );
ANVIL_CATEGORIES[anvilLevel] = new EMIAnvilRecipeCategory( // ANVIL_CATEGORIES[anvilLevel] = new EMIAnvilRecipeCategory(
BCLib.makeID("anvil_" + anvilLevel), // BCLib.makeID("anvil_" + anvilLevel),
ANVIL_WORKSTATIONS[anvilLevel], // ANVIL_WORKSTATIONS[anvilLevel],
getSprite(0, 0), // getSprite(0, 0),
anvilLevel // anvilLevel
); // );
//
if (anvilLevel > 0 && ANVIL_WORKSTATIONS[anvilLevel].isEqual(ANVIL_WORKSTATIONS[anvilLevel - 1])) { // if (anvilLevel > 0 && ANVIL_WORKSTATIONS[anvilLevel].isEqual(ANVIL_WORKSTATIONS[anvilLevel - 1])) {
ANVIL_WORKSTATIONS[anvilLevel - 1] = ANVIL_WORKSTATIONS[anvilLevel]; // ANVIL_WORKSTATIONS[anvilLevel - 1] = ANVIL_WORKSTATIONS[anvilLevel];
ANVIL_CATEGORIES[anvilLevel - 1] = ANVIL_CATEGORIES[anvilLevel]; // ANVIL_CATEGORIES[anvilLevel - 1] = ANVIL_CATEGORIES[anvilLevel];
} // }
} // }
} // }
} // }
//
//
@Override // @Override
public void register(EmiRegistry emiRegistry) { // public void register(EmiRegistry emiRegistry) {
lazyInit(); // lazyInit();
final RecipeManager manager = emiRegistry.getRecipeManager(); // final RecipeManager manager = emiRegistry.getRecipeManager();
//
if (END_ALLOYING_CATEGORY != null && END_ALLOYING_WORKSTATION != null) { // if (END_ALLOYING_CATEGORY != null && END_ALLOYING_WORKSTATION != null) {
emiRegistry.addCategory(END_ALLOYING_CATEGORY); // emiRegistry.addCategory(END_ALLOYING_CATEGORY);
emiRegistry.addWorkstation(END_ALLOYING_CATEGORY, END_ALLOYING_WORKSTATION); // emiRegistry.addWorkstation(END_ALLOYING_CATEGORY, END_ALLOYING_WORKSTATION);
//
EMIAlloyingRecipe.addAllRecipes(emiRegistry, manager); // EMIAlloyingRecipe.addAllRecipes(emiRegistry, manager);
} // }
//
if (ANVIL_CATEGORIES != null && ANVIL_WORKSTATIONS != null && ANVIL_CATEGORIES.length > 0) { // if (ANVIL_CATEGORIES != null && ANVIL_WORKSTATIONS != null && ANVIL_CATEGORIES.length > 0) {
for (int i = 0; i <= maxAnvilLevel; i++) { // for (int i = 0; i <= maxAnvilLevel; i++) {
emiRegistry.addCategory(ANVIL_CATEGORIES[i]); // emiRegistry.addCategory(ANVIL_CATEGORIES[i]);
emiRegistry.addWorkstation(ANVIL_CATEGORIES[i], ANVIL_WORKSTATIONS[i]); // emiRegistry.addWorkstation(ANVIL_CATEGORIES[i], ANVIL_WORKSTATIONS[i]);
} // }
EMIAnvilRecipe.addAllRecipes(emiRegistry, manager); // EMIAnvilRecipe.addAllRecipes(emiRegistry, manager);
} // }
} // }
//
public static <C extends Container, T extends Recipe<C>, E extends EmiRecipe> void addAllRecipes( // public static <C extends Container, T extends Recipe<C>, E extends EmiRecipe> void addAllRecipes(
EmiRegistry emiRegistry, // EmiRegistry emiRegistry,
RecipeManager manager, // RecipeManager manager,
Logger logger, // Logger logger,
RecipeType<T> recipeType, // RecipeType<T> recipeType,
Function<T, E> createRecipe // Function<T, E> createRecipe
) { // ) {
addAllRecipes( // addAllRecipes(
emiRegistry, // emiRegistry,
manager, // manager,
logger, // logger,
recipeType, // recipeType,
(_ignored) -> null, // (_ignored) -> null,
(recipe, _ignored) -> createRecipe.apply(recipe) // (recipe, _ignored) -> createRecipe.apply(recipe)
); // );
} // }
//
public static <C extends Container, T extends Recipe<C>, E extends EmiRecipe, V> void addAllRecipes( // public static <C extends Container, T extends Recipe<C>, E extends EmiRecipe, V> void addAllRecipes(
EmiRegistry emiRegistry, // EmiRegistry emiRegistry,
RecipeManager manager, // RecipeManager manager,
Logger logger, // Logger logger,
RecipeType<T> recipeType, // RecipeType<T> recipeType,
Function<T, List<V>> variantSupplier, // Function<T, List<V>> variantSupplier,
BiFunction<T, V, E> createRecipe // BiFunction<T, V, E> createRecipe
) { // ) {
for (T recipe : manager.getAllRecipesFor(recipeType)) { // for (T recipe : manager.getAllRecipesFor(recipeType)) {
List<V> variants = variantSupplier.apply(recipe); // List<V> variants = variantSupplier.apply(recipe);
if (variants == null) { // if (variants == null) {
emiRegistry.addRecipe(createRecipe.apply(recipe, null)); // emiRegistry.addRecipe(createRecipe.apply(recipe, null));
} else { // } else {
for (V variantData : variants) { // for (V variantData : variants) {
try { // try {
emiRegistry.addRecipe(createRecipe.apply(recipe, variantData)); // emiRegistry.addRecipe(createRecipe.apply(recipe, variantData));
} catch (Exception e) { // } catch (Exception e) {
logger.error("Exception when parsing vanilla recipe " + recipe.getId(), e); // logger.error("Exception when parsing vanilla recipe " + recipe.getId(), e);
} // }
} // }
} // }
} // }
} // }
//
//
static EmiRecipeCategory getAnvilCategoryForLevel(int anvilLevel) { // static EmiRecipeCategory getAnvilCategoryForLevel(int anvilLevel) {
anvilLevel = Math.max(0, Math.min(ANVIL_CATEGORIES.length - 1, anvilLevel)); // anvilLevel = Math.max(0, Math.min(ANVIL_CATEGORIES.length - 1, anvilLevel));
return ANVIL_CATEGORIES[anvilLevel]; // return ANVIL_CATEGORIES[anvilLevel];
} // }
} //}