Added Infusion Recipes to EMI (quiqueck/BetterEnd#51)

This commit is contained in:
Frank 2022-07-29 01:04:00 +02:00
parent 30ecd31fab
commit 805c797866
5 changed files with 42 additions and 18 deletions

View file

@ -2,9 +2,11 @@ package org.betterx.bclib.integration.emi;
import org.betterx.bclib.recipes.AlloyingRecipe; import org.betterx.bclib.recipes.AlloyingRecipe;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.item.crafting.RecipeManager;
import dev.emi.emi.EmiPort;
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;
@ -16,17 +18,23 @@ import dev.emi.emi.api.widget.WidgetHolder;
import java.util.List; import java.util.List;
public class EMIAlloyingRecipe implements EmiRecipe { public class EMIAlloyingRecipe implements EmiRecipe {
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 AlloyingRecipe recipe;
private final int fuelMultiplier;
private final boolean infiniBurn;
public EMIAlloyingRecipe(AlloyingRecipe recipe) { public EMIAlloyingRecipe(AlloyingRecipe recipe) {
this.id = recipe.getId(); this.recipe = recipe;
this.input = List.of( this.input = List.of(
EmiIngredient.of(recipe.getIngredients().get(0)), EmiIngredient.of(recipe.getIngredients().get(0)),
EmiIngredient.of(recipe.getIngredients().get(1)) EmiIngredient.of(recipe.getIngredients().get(1))
); );
this.output = List.of(EmiStack.of(recipe.getResultItem())); this.output = List.of(EmiStack.of(recipe.getResultItem()));
fuelMultiplier = 1;
infiniBurn = false;
} }
static void addAllRecipes(EmiRegistry emiRegistry, RecipeManager manager) { static void addAllRecipes(EmiRegistry emiRegistry, RecipeManager manager) {
@ -42,7 +50,7 @@ public class EMIAlloyingRecipe implements EmiRecipe {
@Override @Override
public ResourceLocation getId() { public ResourceLocation getId() {
return id; return recipe.getId();
} }
@Override @Override
@ -57,27 +65,43 @@ public class EMIAlloyingRecipe implements EmiRecipe {
@Override @Override
public int getDisplayWidth() { public int getDisplayWidth() {
return 96; return 82 + 22;
} }
@Override @Override
public int getDisplayHeight() { public int getDisplayHeight() {
return 18; 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.addTexture(EmiTexture.EMPTY_ARROW, 46, 1); widgets.addFillingArrow(46, 5, 50 * this.recipe.getSmeltTime()).tooltip((mx, my) -> {
return List.of(ClientTooltipComponent.create(EmiPort.ordered(EmiPort.translatable(
"emi.cooking.time",
new Object[]{(float) this.recipe.getSmeltTime() / 20.0F}
))));
});
if (this.infiniBurn) {
widgets.addTexture(EmiTexture.FULL_FLAME, 1, 24);
} else {
widgets.addTexture(EmiTexture.EMPTY_FLAME, 1, 24);
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, 0); widgets.addSlot(input.get(0), 0, 4);
widgets.addSlot(input.get(1), 20, 0); widgets.addSlot(input.get(1), 20, 4);
widgets.addText(EmiPort.ordered(EmiPort.translatable(
"emi.cooking.experience",
new Object[]{this.recipe.getExperience()}
)), 46, 28, -1, 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), 78, 0).recipeContext(this); widgets.addSlot(output.get(0), 78, 0).output(true).recipeContext(this);
} }
@Override @Override

View file

@ -70,27 +70,27 @@ public class EMIAnvilRecipe implements EmiRecipe {
@Override @Override
public int getDisplayWidth() { public int getDisplayWidth() {
return 96; return 104;
} }
@Override @Override
public int getDisplayHeight() { public int getDisplayHeight() {
return 18; 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, 1); 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, 0); widgetHolder.addSlot(input.get(0), 0, 4);
widgetHolder.addSlot(input.get(1), 20, 0); 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).recipeContext(this); widgetHolder.addSlot(output.get(0), 78, 0).output(true).recipeContext(this);
} }
@Override @Override

View file

@ -19,7 +19,7 @@ import java.util.Comparator;
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 MY_SPRITE_SHEET = BCLib.makeID( public static final ResourceLocation BCL_SIMPLIFIED_SPRITES = BCLib.makeID(
"textures/gui/widgets.png" "textures/gui/widgets.png"
); );
@ -30,7 +30,7 @@ public class EMIPlugin implements EmiPlugin {
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(MY_SPRITE_SHEET, 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() {

View file

@ -36,7 +36,7 @@ public class RenderHelper {
Matrix4f transform = poseStack.last().pose(); Matrix4f transform = poseStack.last().pose();
innerHLine(transform, x0, x1, y0, color1); innerHLine(transform, x0, x1, y0, color1);
innerVLine(transform, x0, y0 + 1, y1, color1); innerVLine(transform, x0, y0 + 1, y1, color1);
innerHLine(transform, x0 + 1, x1, y1, color1); innerHLine(transform, x0 + 1, x1, y1, color2);
innerVLine(transform, x1, y0 + 1, y1 - 1, color2); innerVLine(transform, x1, y0 + 1, y1 - 1, color2);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 285 B

Before After
Before After