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

This commit is contained in:
Frank 2023-06-07 22:48:48 +02:00
parent 8bff8a8b25
commit 38c36a762c
5 changed files with 9 additions and 99 deletions

View file

@ -79,8 +79,8 @@ dependencies {
//needed for trinkets, otherwise BetterEnd would require users to install trinkets
modApi "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}"
modCompileOnly "dev.emi:trinkets:${project.trinkets_version}"
modCompileOnly "dev.emi:emi:${emi_version}"
//modRuntimeOnly "dev.emi:emi:${emi_version}"
modCompileOnly "dev.emi:emi-fabric:${emi_version}:api"
modLocalRuntime "dev.emi:emi-fabric:${emi_version}"
}
processResources {

View file

@ -19,9 +19,9 @@ archives_base_name=better-end
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
patchouli_version=1.19-73-FABRIC
bclib_version=2.1.6
bclib_version=2.1.7
rei_version=9.1.500
jei_version=11.1.0.235
emi_version=0.6.3+1.19.2
emi_version=1.0.2+1.19.2
trinkets_version=3.4.0
cca_version=5.0.0-beta.1

View file

@ -17,6 +17,7 @@ import dev.emi.emi.api.recipe.EmiRecipeCategory;
import dev.emi.emi.api.render.EmiTexture;
import dev.emi.emi.api.stack.EmiIngredient;
import dev.emi.emi.api.stack.EmiStack;
import dev.emi.emi.api.widget.SlotWidget;
import dev.emi.emi.api.widget.WidgetHolder;
import java.util.List;
@ -104,13 +105,13 @@ public class EMIInfusionRecipe implements EmiRecipe {
widgets.addTexture(EmiTexture.EMPTY_ARROW, right + 10, cy - 8);
// Adds an input slot on the left
widgets.add(new TransparentSlotWidget(input.get(0), cx - halfSize, cy - halfSize));
widgets.add(new SlotWidget(input.get(0), cx - halfSize, cy - halfSize));
FormattedCharSequence str = FormattedCharSequence.forward("N", Style.EMPTY);
widgets.addText(str, cx - Minecraft.getInstance().font.width(str) / 2, 4, ColorUtil.WHITE, true);
double a = Math.PI;
for (int i = 1; i < input.size(); i++) {
widgets.add(new TransparentSlotWidget(
widgets.add(new SlotWidget(
input.get(i),
cx - halfSize + (int) (Math.sin(a) * radius),
cy - halfSize + (int) (Math.cos(a) * radius)
@ -121,7 +122,7 @@ public class EMIInfusionRecipe 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
widgets.addSlot(output.get(0), right + 40, cy - (halfSize + 4)).output(true).recipeContext(this);
widgets.addSlot(output.get(0), right + 40, cy - (halfSize + 4)).large(true).recipeContext(this);
}
@Override

View file

@ -1,91 +0,0 @@
package org.betterx.betterend.integration.emi;
import org.betterx.ui.layout.components.render.RenderHelper;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.renderer.GameRenderer;
import dev.emi.emi.EmiRenderHelper;
import dev.emi.emi.api.render.EmiRender;
import dev.emi.emi.api.stack.EmiIngredient;
import dev.emi.emi.api.widget.Bounds;
import dev.emi.emi.api.widget.SlotWidget;
import dev.emi.emi.config.EmiConfig;
public class TransparentSlotWidget extends SlotWidget {
public TransparentSlotWidget(EmiIngredient stack, int x, int y) {
super(stack, x, y);
}
@Override
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
Bounds bounds = this.getBounds();
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
int width = bounds.width();
int height = bounds.height();
if (this.drawBack) {
if (this.textureId != null) {
RenderSystem.setShaderTexture(0, this.textureId);
GuiComponent.blit(
matrices,
bounds.x(), bounds.y(), width, height,
this.u, this.v, width, height, 256, 256
);
} else {
renderSlot(matrices);
}
}
// if (this.getRecipe() == null
// && EmiClient.availableForCrafting.containsKey(this.getStack())
// && !this.getStack().isEmpty()
// && !(Boolean) EmiClient.availableForCrafting.get(this.getStack())) {
// GuiComponent.fill(
// matrices,
// bounds.x(), bounds.y(),
// bounds.x() + bounds.width(), bounds.y() + bounds.height(),
// 0x44FF0000
// );
// }
int xOff = (width - 16) / 2;
int yOff = (height - 16) / 2;
this.getStack().render(matrices, bounds.x() + xOff, bounds.y() + yOff, delta);
if (this.catalyst) {
EmiRender.renderCatalystIcon(this.getStack(), matrices, this.x + xOff, this.y + yOff);
}
if (EmiConfig.showHoverOverlay && bounds.contains(mouseX, mouseY)) {
EmiRenderHelper.drawSlotHightlight(
matrices,
bounds.x() + 1, bounds.y() + 1,
bounds.width() - 2, bounds.height() - 2
);
}
}
public void renderSlot(PoseStack matrices) {
Bounds bounds = this.getBounds();
int width = bounds.width();
int height = bounds.height();
GuiComponent.fill(matrices, bounds.x(), bounds.y(), bounds.x() + width, bounds.y() + height, 0xB08b8b8b);
RenderHelper.outline(
matrices,
bounds.x(),
bounds.y(),
bounds.x() + width,
bounds.y() + height,
0xFA373737,
0xFAFFFFFF
);
RenderHelper.vLine(matrices, bounds.x() + width - 1, bounds.y(), bounds.y(), 0xFA8B8B8B);
RenderHelper.hLine(matrices, bounds.x(), bounds.x(), bounds.y() + bounds.height() - 1, 0xFA8B8B8B);
}
}

View file

@ -55,7 +55,7 @@
"bclib": "2.1.x"
},
"breaks": {
"bclib": "<2.1.6"
"bclib": "<2.1.7"
},
"suggests": {
"byg": ">=2.0.0",