Remove usage of REI internals (#3019)

Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
shedaniel 2022-08-05 03:15:54 +08:00 committed by GitHub
parent 88d448c3a5
commit 554a63dbba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 39 deletions

View file

@ -253,8 +253,13 @@ def modCompat(Map args) {
modCompat( modCompat(
name: "rei", name: "rei",
runtime: [
// "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}",
// "dev.architectury:architectury-fabric:6.+" // Support for 1.19.1
],
compile: [ compile: [
"me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}",
"me.shedaniel:RoughlyEnoughItems-default-plugin-fabric:${project.rei_version}"
], ],
sourceSet: sourceSets.client, sourceSet: sourceSets.client,
) )

View file

@ -13,5 +13,5 @@ fapi_version=0.58.4+1.19.1
# Dependencies # Dependencies
energy_version=2.2.0 energy_version=2.2.0
rei_version=9.0.491 rei_version=9.1.520
jei_version=11.0.0.206 jei_version=11.0.0.206

View file

@ -27,7 +27,6 @@ package techreborn.client.compat.rei;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import dev.architectury.event.CompoundEventResult; import dev.architectury.event.CompoundEventResult;
import dev.architectury.fluid.FluidStack; import dev.architectury.fluid.FluidStack;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle; import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.entry.renderer.AbstractEntryRenderer; import me.shedaniel.rei.api.client.entry.renderer.AbstractEntryRenderer;
import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer;
@ -48,7 +47,6 @@ import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry; import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry;
import me.shedaniel.rei.api.common.fluid.FluidSupportProvider; import me.shedaniel.rei.api.common.fluid.FluidSupportProvider;
import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.impl.client.gui.widget.EntryWidget;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
@ -214,7 +212,7 @@ public class ReiPlugin implements REIClientPlugin {
private void registerFluidGeneratorDisplays(DisplayRegistry registry, EFluidGenerator generator, Machine machine) { private void registerFluidGeneratorDisplays(DisplayRegistry registry, EFluidGenerator generator, Machine machine) {
Identifier identifier = new Identifier(TechReborn.MOD_ID, machine.name); Identifier identifier = new Identifier(TechReborn.MOD_ID, machine.name);
GeneratorRecipeHelper.getFluidRecipesForGenerator(generator).getRecipes().forEach(recipe -> GeneratorRecipeHelper.getFluidRecipesForGenerator(generator).getRecipes().forEach(recipe ->
registry.add(new FluidGeneratorRecipeDisplay(recipe, identifier)) registry.add(new FluidGeneratorRecipeDisplay(recipe, identifier))
); );
} }
@ -285,16 +283,8 @@ public class ReiPlugin implements REIClientPlugin {
} }
public static Widget createEnergyDisplay(Rectangle bounds, double energy, EntryAnimation animation, Function<TooltipContext, Tooltip> tooltipBuilder) { public static Widget createEnergyDisplay(Rectangle bounds, double energy, EntryAnimation animation, Function<TooltipContext, Tooltip> tooltipBuilder) {
return new EnergyEntryWidget(bounds, animation).entry( return Widgets.createSlot(bounds).entry(
ClientEntryStacks.of(new AbstractRenderer() { ClientEntryStacks.of(new EnergyEntryRenderer(animation, tooltipBuilder))
@Override
public void render(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {}
@Override
public @Nullable Tooltip getTooltip(TooltipContext context) {
return tooltipBuilder.apply(context);
}
})
).notFavoritesInteractable(); ).notFavoritesInteractable();
} }
@ -304,40 +294,40 @@ public class ReiPlugin implements REIClientPlugin {
return Widgets.createSlot(bounds).entry(copy); return Widgets.createSlot(bounds).entry(copy);
} }
private static class EnergyEntryWidget extends EntryWidget { private static class EnergyEntryRenderer extends AbstractRenderer {
private EntryAnimation animation; private final EntryAnimation animation;
private final Function<TooltipContext, Tooltip> tooltipBuilder;
protected EnergyEntryWidget(Rectangle rectangle, EntryAnimation animation) { protected EnergyEntryRenderer(EntryAnimation animation, Function<TooltipContext, Tooltip> tooltipBuilder) {
super(new Point(rectangle.x, rectangle.y));
this.getBounds().setBounds(rectangle);
this.animation = animation; this.animation = animation;
this.tooltipBuilder = tooltipBuilder;
} }
@Override @Override
protected void drawBackground(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
if (background) { int width = bounds.width + 2;
Rectangle bounds = getBounds(); int height = bounds.height + 2;
int width = bounds.width; int innerHeight = height - 2;
int height = bounds.height;
int innerHeight = height - 2;
PowerSystem.EnergySystem displayPower = PowerSystem.getDisplayPower(); PowerSystem.EnergySystem displayPower = PowerSystem.getDisplayPower();
RenderSystem.setShaderTexture(0, GuiBuilder.defaultTextureSheet); RenderSystem.setShaderTexture(0, GuiBuilder.defaultTextureSheet);
drawTexture(matrices, bounds.x, bounds.y, displayPower.xBar - 15, displayPower.yBar - 1, width, height); drawTexture(matrices, bounds.x - 1, bounds.y - 1, displayPower.xBar - 15, displayPower.yBar - 1, width, height);
int innerDisplayHeight; int innerDisplayHeight;
if (animation.animationType != EntryAnimationType.NONE) { if (animation.animationType != EntryAnimationType.NONE) {
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight)); innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight));
if (animation.animationType == EntryAnimationType.DOWNWARDS) if (animation.animationType == EntryAnimationType.DOWNWARDS)
innerDisplayHeight = innerHeight - innerDisplayHeight; innerDisplayHeight = innerHeight - innerDisplayHeight;
} else innerDisplayHeight = innerHeight; } else innerDisplayHeight = innerHeight;
drawTexture(matrices, bounds.x + 1, bounds.y + 1 + innerHeight - innerDisplayHeight, displayPower.xBar, innerHeight + displayPower.yBar - innerDisplayHeight, width - 2, innerDisplayHeight); drawTexture(matrices, bounds.x, bounds.y + innerHeight - innerDisplayHeight, displayPower.xBar, innerHeight + displayPower.yBar - innerDisplayHeight, width - 2, innerDisplayHeight);
}
} }
@Override @Override
protected void drawCurrentEntry(MatrixStack matrices, int mouseX, int mouseY, float delta) {} @Nullable
public Tooltip getTooltip(TooltipContext context) {
return this.tooltipBuilder.apply(context);
}
} }
private static class FluidStackRenderer extends AbstractEntryRenderer<FluidStack> { private static class FluidStackRenderer extends AbstractEntryRenderer<FluidStack> {
private final EntryAnimation animation; private final EntryAnimation animation;
private final EntryRenderer<FluidStack> parent; private final EntryRenderer<FluidStack> parent;