[Fix] Broken with EMI > 1.0 (quiqueck/BCLib#96)

This commit is contained in:
Frank 2023-06-07 22:48:48 +02:00
parent bbdde47017
commit fa8603c7e1
6 changed files with 20 additions and 31 deletions

View file

@ -35,8 +35,8 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modCompileOnly "com.terraformersmc:modmenu:${project.modmenu_version}"
modCompileOnly "dev.emi:emi:${emi_version}"
//modImplementation "dev.emi:emi:${emi_version}"
modCompileOnly "dev.emi:emi-fabric:${emi_version}:api"
modLocalRuntime "dev.emi:emi-fabric:${emi_version}"
}
processResources {

View file

@ -17,4 +17,4 @@ maven_group=org.betterx.bclib
archives_base_name=bclib
# Dependencies
modmenu_version=4.1.2
emi_version=0.6.3+1.19.2
emi_version=1.0.2+1.19.2

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,7 @@ 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 +93,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

@ -6,7 +6,6 @@ import org.betterx.bclib.util.RomanNumeral;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.math.Matrix4f;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
@ -15,8 +14,6 @@ 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 +77,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;
}
}

View file

@ -54,6 +54,9 @@
"1.19.2"
]
},
"breaks": {
"emi": "<1.0.0"
},
"custom": {
"bclib": {
"downloads": {