From 478c7f771bf935d49bd74e2170fbed21bf1da2a2 Mon Sep 17 00:00:00 2001 From: glisco Date: Sun, 8 Dec 2024 19:12:49 +0100 Subject: [PATCH] 1.21.4 --- gradle.properties | 18 +++++----- owo-ui.xsd | 5 ++- .../JsonDataLoaderMixin.java | 22 +++---------- .../ServerRecipeManagerAccessor.java | 15 +++++++++ .../owo/ui/component/BlockComponent.java | 33 +++++++++---------- .../owo/ui/component/EntityComponent.java | 2 +- .../owo/ui/component/ItemComponent.java | 30 ++++++++--------- .../owo/ui/component/TextAreaComponent.java | 2 +- .../owo/ui/util/NinePatchTexture.java | 3 +- src/main/resources/owo.mixins.json | 1 + .../io/wispforest/uwu/rei/UiCategory.java | 13 ++++++++ 11 files changed, 78 insertions(+), 66 deletions(-) create mode 100644 src/main/java/io/wispforest/owo/mixin/recipe_remainders/ServerRecipeManagerAccessor.java diff --git a/gradle.properties b/gradle.properties index e7ea2e6b..cbdfb862 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,28 +2,28 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_base_version=1.21.2 -minecraft_version=1.21.2 -yarn_mappings=1.21.2+build.1 -loader_version=0.16.7 +minecraft_base_version=1.21.4 +minecraft_version=1.21.4 +yarn_mappings=1.21.4+build.1 +loader_version=0.16.9 # Mod Properties mod_version=0.12.18 maven_group=io.wispforest archives_base_name=owo-lib # Dependencies -fabric_version=0.106.1+1.21.2 +fabric_version=0.111.0+1.21.4 # https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-fabric/ -rei_version=15.0.728 +rei_version=17.0.792 # https://maven.terraformersmc.com/releases/dev/emi/emi-fabric/ -emi_version=1.1.6+1.20.6 +emi_version=1.1.18+1.21.1 # https://search.maven.org/artifact/blue.endless/jankson jankson_version=1.2.2 # https://maven.terraformersmc.com/releases/com/terraformersmc/modmenu -modmenu_version=12.0.0-beta.1 +modmenu_version=13.0.0-beta.1 # https://maven.nucleoid.xyz/xyz/nucleoid/server-translations-api/ -stapi_version=2.3.1+1.21-pre2 +stapi_version=2.4.0+1.21.2-rc1 diff --git a/owo-ui.xsd b/owo-ui.xsd index 0a645957..9c6f62be 100644 --- a/owo-ui.xsd +++ b/owo-ui.xsd @@ -1,5 +1,8 @@ - + diff --git a/src/main/java/io/wispforest/owo/mixin/recipe_remainders/JsonDataLoaderMixin.java b/src/main/java/io/wispforest/owo/mixin/recipe_remainders/JsonDataLoaderMixin.java index 1c741821..6c156132 100644 --- a/src/main/java/io/wispforest/owo/mixin/recipe_remainders/JsonDataLoaderMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/recipe_remainders/JsonDataLoaderMixin.java @@ -11,38 +11,24 @@ import io.wispforest.owo.util.RecipeRemainderStorage; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.recipe.Recipe; -import net.minecraft.recipe.RecipeEntry; -import net.minecraft.recipe.RecipeType; -import net.minecraft.recipe.input.RecipeInput; -import net.minecraft.registry.RegistryKeys; import net.minecraft.resource.JsonDataLoader; -import net.minecraft.resource.ResourceManager; +import net.minecraft.resource.ResourceFinder; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; -import net.minecraft.util.collection.DefaultedList; -import net.minecraft.util.profiler.Profiler; -import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.io.Reader; import java.util.HashMap; -import java.util.Map; -import java.util.Optional; @Mixin(JsonDataLoader.class) public abstract class JsonDataLoaderMixin { - @WrapOperation(method = "load", at = @At(value = "INVOKE", target = "Lcom/google/gson/JsonParser;parseReader(Ljava/io/Reader;)Lcom/google/gson/JsonElement;")) - private static JsonElement deserializeRecipeSpecificRemainders(Reader jsonReader, Operation original, @Local(argsOnly = true) String dataType, @Local(ordinal = 1) Identifier recipeId) { + @WrapOperation(method = "load(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/resource/ResourceFinder;Lcom/mojang/serialization/DynamicOps;Lcom/mojang/serialization/Codec;Ljava/util/Map;)V", at = @At(value = "INVOKE", target = "Lcom/google/gson/JsonParser;parseReader(Ljava/io/Reader;)Lcom/google/gson/JsonElement;")) + private static JsonElement deserializeRecipeSpecificRemainders(Reader jsonReader, Operation original, @Local(argsOnly = true) ResourceFinder finder, @Local(ordinal = 1) Identifier recipeId) { var element = original.call(jsonReader); - if (dataType.equals(RegistryKeys.getPath(RegistryKeys.RECIPE)) && element instanceof JsonObject json) { + if (ServerRecipeManagerAccessor.owo$getFinder() == finder && element instanceof JsonObject json) { if (json.has("owo:remainders")) { var remainders = new HashMap(); diff --git a/src/main/java/io/wispforest/owo/mixin/recipe_remainders/ServerRecipeManagerAccessor.java b/src/main/java/io/wispforest/owo/mixin/recipe_remainders/ServerRecipeManagerAccessor.java new file mode 100644 index 00000000..04a9ada3 --- /dev/null +++ b/src/main/java/io/wispforest/owo/mixin/recipe_remainders/ServerRecipeManagerAccessor.java @@ -0,0 +1,15 @@ +package io.wispforest.owo.mixin.recipe_remainders; + +import net.minecraft.recipe.ServerRecipeManager; +import net.minecraft.resource.ResourceFinder; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ServerRecipeManager.class) +public interface ServerRecipeManagerAccessor { + + @Accessor("FINDER") + static ResourceFinder owo$getFinder() { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/java/io/wispforest/owo/ui/component/BlockComponent.java b/src/main/java/io/wispforest/owo/ui/component/BlockComponent.java index 9801df17..c2b44637 100644 --- a/src/main/java/io/wispforest/owo/ui/component/BlockComponent.java +++ b/src/main/java/io/wispforest/owo/ui/component/BlockComponent.java @@ -47,27 +47,24 @@ public void draw(OwoUIDrawContext context, int mouseX, int mouseY, float partial context.getMatrices().translate(-.5, -.5, -.5); - // TODO: [1.21.2-Porting] Figure out if this is still needed or not - //RenderSystem.runAsFancy(() -> { - final var vertexConsumers = client.getBufferBuilders().getEntityVertexConsumers(); - if (this.state.getRenderType() != BlockRenderType.ENTITYBLOCK_ANIMATED) { - this.client.getBlockRenderManager().renderBlockAsEntity( - this.state, context.getMatrices(), vertexConsumers, - LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV - ); - } + final var vertexConsumers = client.getBufferBuilders().getEntityVertexConsumers(); + if (this.state.getRenderType() != BlockRenderType.INVISIBLE) { + this.client.getBlockRenderManager().renderBlockAsEntity( + this.state, context.getMatrices(), vertexConsumers, + LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV + ); + } - if (this.entity != null) { - var медведь = this.client.getBlockEntityRenderDispatcher().get(this.entity); - if (медведь != null) { - медведь.render(entity, partialTicks, context.getMatrices(), vertexConsumers, LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV); - } + if (this.entity != null) { + var медведь = this.client.getBlockEntityRenderDispatcher().get(this.entity); + if (медведь != null) { + медведь.render(entity, partialTicks, context.getMatrices(), vertexConsumers, LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV); } + } - RenderSystem.setShaderLights(new Vector3f(-1.5f, -.5f, 0), new Vector3f(0, -1, 0)); - vertexConsumers.draw(); - DiffuseLighting.enableGuiDepthLighting(); - //}); + RenderSystem.setShaderLights(new Vector3f(-1.5f, -.5f, 0), new Vector3f(0, -1, 0)); + vertexConsumers.draw(); + DiffuseLighting.enableGuiDepthLighting(); context.getMatrices().pop(); } diff --git a/src/main/java/io/wispforest/owo/ui/component/EntityComponent.java b/src/main/java/io/wispforest/owo/ui/component/EntityComponent.java index 9c925988..1148e8b4 100644 --- a/src/main/java/io/wispforest/owo/ui/component/EntityComponent.java +++ b/src/main/java/io/wispforest/owo/ui/component/EntityComponent.java @@ -267,7 +267,7 @@ profile, new WorldSession(TelemetrySender.NOOP, false, Duration.ZERO, ""), this.skinTextures = DefaultSkinHelper.getSkinTextures(completeProfile); this.client.getSkinProvider().fetchSkinTextures(completeProfile).thenAccept(textures -> { - this.skinTextures = textures; + textures.ifPresent($ -> this.skinTextures = $); }); }); } diff --git a/src/main/java/io/wispforest/owo/ui/component/ItemComponent.java b/src/main/java/io/wispforest/owo/ui/component/ItemComponent.java index 6a7586ac..742ee36c 100644 --- a/src/main/java/io/wispforest/owo/ui/component/ItemComponent.java +++ b/src/main/java/io/wispforest/owo/ui/component/ItemComponent.java @@ -12,22 +12,21 @@ import net.fabricmc.fabric.api.client.rendering.v1.TooltipComponentCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.tooltip.TooltipComponent; +import net.minecraft.client.item.ItemModelManager; import net.minecraft.client.render.DiffuseLighting; import net.minecraft.client.render.LightmapTextureManager; import net.minecraft.client.render.OverlayTexture; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.item.ModelTransformationMode; +import net.minecraft.client.render.item.ItemRenderState; import net.minecraft.command.argument.ItemStringReader; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.ModelTransformationMode; import net.minecraft.item.tooltip.TooltipType; import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryWrapper; import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix4f; import org.w3c.dom.Element; import java.util.ArrayList; @@ -38,17 +37,15 @@ public class ItemComponent extends BaseComponent { - protected static final Matrix4f ITEM_SCALING = new Matrix4f().scaling(16, -16, 16); + protected static final ItemRenderState ITEM_RENDER_STATE = new ItemRenderState(); - protected final VertexConsumerProvider.Immediate entityBuffers; - protected final ItemRenderer itemRenderer; + protected final ItemModelManager itemModelManager; protected ItemStack stack; protected boolean showOverlay = false; protected boolean setTooltipFromStack = false; protected ItemComponent(ItemStack stack) { - this.entityBuffers = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(); - this.itemRenderer = MinecraftClient.getInstance().getItemRenderer(); + this.itemModelManager = MinecraftClient.getInstance().getItemModelManager(); this.stack = stack; } @@ -64,8 +61,11 @@ protected int determineVerticalContentSize(Sizing sizing) { @Override public void draw(OwoUIDrawContext context, int mouseX, int mouseY, float partialTicks, float delta) { - final boolean notSideLit = !this.itemRenderer.getModel(this.stack, null, null, 0).isSideLit(); + this.itemModelManager.update(ITEM_RENDER_STATE, this.stack, ModelTransformationMode.GUI, false, null, null, 0); + + final boolean notSideLit = !ITEM_RENDER_STATE.isSideLit(); if (notSideLit) { + context.draw(); DiffuseLighting.disableGuiDepthLighting(); } @@ -80,16 +80,12 @@ public void draw(OwoUIDrawContext context, int mouseX, int mouseY, float partial matrices.translate(8.0, 8.0, 0.0); // Vanilla scaling and y inversion - if (notSideLit) { - matrices.scale(16, -16, 16); - } else { - matrices.multiplyPositionMatrix(ITEM_SCALING); - } + matrices.scale(16, -16, 16); var client = MinecraftClient.getInstance(); - this.itemRenderer.renderItem(this.stack, ModelTransformationMode.GUI, LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV, matrices, entityBuffers, client.world, 0); - this.entityBuffers.draw(); + ITEM_RENDER_STATE.render(matrices, context.vertexConsumers(), LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV); + context.draw(); // Clean up matrices.pop(); diff --git a/src/main/java/io/wispforest/owo/ui/component/TextAreaComponent.java b/src/main/java/io/wispforest/owo/ui/component/TextAreaComponent.java index 98886fff..5885ce7e 100644 --- a/src/main/java/io/wispforest/owo/ui/component/TextAreaComponent.java +++ b/src/main/java/io/wispforest/owo/ui/component/TextAreaComponent.java @@ -117,7 +117,7 @@ public void inflate(Size space) { int cursor = this.editBox.getCursor(); int selection = ((EditBoxAccessor) this.editBox).owo$getSelectionEnd(); - ((EditBoxAccessor) this.editBox).owo$setWidth(this.width() - this.getPaddingDoubled() - 9); + ((EditBoxAccessor) this.editBox).owo$setWidth(this.width() - this.getPadding() - 9); this.editBox.setText(this.getText()); super.inflate(space); diff --git a/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java b/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java index 5905b898..9a0e629a 100644 --- a/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java +++ b/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java @@ -11,6 +11,7 @@ import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; import net.minecraft.client.render.RenderLayer; import net.minecraft.resource.JsonDataLoader; +import net.minecraft.resource.ResourceFinder; import net.minecraft.resource.ResourceManager; import net.minecraft.util.Identifier; import net.minecraft.util.profiler.Profiler; @@ -258,7 +259,7 @@ public static class MetadataLoader extends JsonDataLoader impl private static final Map LOADED_TEXTURES = new HashMap<>(); public MetadataLoader() { - super(CodecUtils.toCodec(NinePatchTexture.ENDEC), "nine_patch_textures"); + super(CodecUtils.toCodec(NinePatchTexture.ENDEC), ResourceFinder.json("nine_patch_textures")); } @Override diff --git a/src/main/resources/owo.mixins.json b/src/main/resources/owo.mixins.json index 041202b3..0921bc47 100644 --- a/src/main/resources/owo.mixins.json +++ b/src/main/resources/owo.mixins.json @@ -36,6 +36,7 @@ "offline.WorldSaveHandlerMixin", "recipe_remainders.CraftingResultSlotMixin", "recipe_remainders.JsonDataLoaderMixin", + "recipe_remainders.ServerRecipeManagerAccessor", "registry.ReferenceAccessor", "registry.SimpleRegistryMixin", "text.LanguageMixin", diff --git a/src/testmod/java/io/wispforest/uwu/rei/UiCategory.java b/src/testmod/java/io/wispforest/uwu/rei/UiCategory.java index 22dfc33b..1adf4ccc 100644 --- a/src/testmod/java/io/wispforest/uwu/rei/UiCategory.java +++ b/src/testmod/java/io/wispforest/uwu/rei/UiCategory.java @@ -14,15 +14,18 @@ import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.display.DisplaySerializer; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; import net.minecraft.item.Items; import net.minecraft.text.Text; import net.minecraft.util.Identifier; +import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.List; +import java.util.Optional; public class UiCategory implements DisplayCategory { @@ -92,5 +95,15 @@ public List getOutputEntries() { public CategoryIdentifier getCategoryIdentifier() { return ID; } + + @Override + public Optional getDisplayLocation() { + return Optional.empty(); + } + + @Override + public @Nullable DisplaySerializer getSerializer() { + return null; + } } }