[Change] Upgraded EMI

This commit is contained in:
Frank 2023-12-27 14:58:11 +01:00
parent b3c2b6fd6d
commit e120ed33ab
3 changed files with 19 additions and 27 deletions

View file

@ -1,12 +1,11 @@
package org.betterx.bclib.integration.emi;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe;
import dev.emi.emi.EmiPort;
import dev.emi.emi.api.recipe.EmiRecipe;
import dev.emi.emi.api.recipe.EmiRecipeCategory;
import dev.emi.emi.api.render.EmiTexture;
@ -81,12 +80,11 @@ public abstract class EMIAbstractAlloyingRecipe<C extends Container, T extends R
@Override
public void addWidgets(WidgetHolder widgets) {
// Add an arrow texture to indicate processing
widgets.addFillingArrow(24 + getXOffset(), 5, 50 * getSmeltTime()).tooltip((mx, my) -> {
return List.of(ClientTooltipComponent.create(EmiPort.ordered(EmiPort.translatable(
"emi.cooking.time",
new Object[]{(float) getSmeltTime() / 20.0F}
))));
});
widgets.addFillingArrow(24 + getXOffset(), 5, 50 * getSmeltTime())
.tooltip((mx, my) -> List.of(ClientTooltipComponent.create(Component.translatable(
"emi.cooking.time",
new Object[]{(float) getSmeltTime() / 20.0F}
).getVisualOrderText())));
if (this.infiniBurn) {
widgets.addTexture(EmiTexture.FULL_FLAME, 1, 24);
@ -99,14 +97,14 @@ public abstract class EMIAbstractAlloyingRecipe<C extends Container, T extends R
widgets.addSlot(input.get(0), 0, 4);
widgets.addSlot((input.size() > 1) ? input.get(1) : null, 20, 4);
widgets.addText(
EmiPort.ordered(EmiPort.translatable("emi.cooking.experience", getExperience())),
Component.translatable("emi.cooking.experience", getExperience()).getVisualOrderText(),
24 + getXOffset(), 28, 0xFFFFFFFF, true
);
// Adds an output slot on the right
// 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
widgets.addSlot(output.get(0), 56 + getXOffset(), 0).output(true).recipeContext(this);
widgets.addSlot(output.get(0), 56 + getXOffset(), 0).large(true).recipeContext(this);
}
@Override

View file

@ -95,7 +95,7 @@ public class EMIAnvilRecipe implements EmiRecipe {
// Adds an output slot on the right
// 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
widgetHolder.addSlot(output.get(0), 78, 0).output(true).recipeContext(this);
widgetHolder.addSlot(output.get(0), 78, 0).large(true).recipeContext(this);
}
@Override

View file

@ -10,12 +10,11 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
import com.google.common.collect.Lists;
import dev.emi.emi.EmiPort;
import dev.emi.emi.EmiUtil;
import dev.emi.emi.api.recipe.EmiRecipe;
import dev.emi.emi.api.recipe.EmiRecipeCategory;
import dev.emi.emi.api.render.EmiRenderable;
@ -80,24 +79,19 @@ public class EMIAnvilRecipeCategory extends EmiRecipeCategory {
bufferSource.endBatch();
}
@Override
public List<ClientTooltipComponent> getTooltip() {
List<ClientTooltipComponent> list = Lists.newArrayList();
if (titleLines.isEmpty()) {
list.add(ClientTooltipComponent.create(EmiPort.ordered(EmiPort.translatable(EmiUtil.translateId(
"emi.category.",
this.getId()
)))));
} else {
List<ClientTooltipComponent> list = super.getTooltip();
if (!titleLines.isEmpty()) {
List<ClientTooltipComponent> newList = Lists.newArrayList();
for (var line : titleLines)
list.add(ClientTooltipComponent.create(line));
newList.add(ClientTooltipComponent.create(line));
if (list.size() > 0) list.remove(0);
newList.addAll(list);
return newList;
}
list.add(ClientTooltipComponent.create(EmiPort.ordered(EmiPort.literal(
EmiUtil.getModName(this.getId()
.getNamespace()),
new ChatFormatting[]{ChatFormatting.BLUE, ChatFormatting.ITALIC}
))));
return list;
}
}