From 4a5a30a11c80d15453bdb326b114e358ee4bd718 Mon Sep 17 00:00:00 2001 From: Uraneptus Date: Wed, 23 Oct 2024 22:23:20 +0200 Subject: [PATCH] first bit of 1.21.3 port --- Fabric/build.gradle | 6 +++--- Fabric/src/main/resources/fabric.mod.json | 4 ++-- .../src/main/resources/META-INF/neoforge.mods.toml | 4 ++-- .../src/main/java/vazkii/neat/HealthBarRenderer.java | 10 ++++++---- Xplat/src/main/java/vazkii/neat/NeatRenderType.java | 3 ++- .../java/vazkii/neat/mixin/EntityRendererMixin.java | 12 +++++++++--- .../java/vazkii/neat/mixin/LevelRendererMixin.java | 2 +- gradle.properties | 8 +++++--- gradle/wrapper/gradle-wrapper.properties | 2 +- scripts/upload_releases.sh | 4 ++-- 10 files changed, 33 insertions(+), 22 deletions(-) diff --git a/Fabric/build.gradle b/Fabric/build.gradle index fd46494..8f4516d 100644 --- a/Fabric/build.gradle +++ b/Fabric/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.7.2' + id 'fabric-loom' version '1.8.9' } version = "${mc_version}-${build_number}-FABRIC" @@ -31,8 +31,8 @@ dependencies { minecraft "com.mojang:minecraft:${mc_version}" mappings loom.officialMojangMappings() - modImplementation "net.fabricmc:fabric-loader:0.16.0" - modImplementation "net.fabricmc.fabric-api:fabric-api:0.100.8+1.21" + modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}" compileOnly project(":Xplat") diff --git a/Fabric/src/main/resources/fabric.mod.json b/Fabric/src/main/resources/fabric.mod.json index 93f3af6..bea1404 100644 --- a/Fabric/src/main/resources/fabric.mod.json +++ b/Fabric/src/main/resources/fabric.mod.json @@ -32,8 +32,8 @@ "accessWidener": "neat.accesswidener", "depends": { - "fabricloader": ">=0.15.11", + "fabricloader": ">=0.16.7", "fabric": ">=0.100", - "minecraft": ">=1.21" + "minecraft": ">=1.21.2" } } diff --git a/NeoForge/src/main/resources/META-INF/neoforge.mods.toml b/NeoForge/src/main/resources/META-INF/neoforge.mods.toml index 1065e84..e2e5c8b 100644 --- a/NeoForge/src/main/resources/META-INF/neoforge.mods.toml +++ b/NeoForge/src/main/resources/META-INF/neoforge.mods.toml @@ -13,12 +13,12 @@ description="Minimalistic Functional Unit Plates for the modern Minecrafter" [[dependencies.neat]] modId="neoforge" type="required" -versionRange="[21.0.143,)" +versionRange="[21.2.0-beta,)" [[dependencies.neat]] modId="minecraft" type="required" -versionRange="[1.21,)" +versionRange="[1.21.2,)" [[mixins]] config="neat.mixins.json" diff --git a/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java b/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java index e82efa7..64fa480 100644 --- a/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java +++ b/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java @@ -9,6 +9,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.state.EntityRenderState; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; @@ -54,7 +55,7 @@ private static Entity getEntityLookedAt(Entity e) { for (Entity entity : entitiesInBoundingBox) { Entity lookedEntity = null; if (entity.isPickable()) { - AABB collisionBox = entity.getBoundingBoxForCulling(); + AABB collisionBox = entity.getBoundingBox(); Optional interceptPosition = collisionBox.clip(positionVector, reachVector); if (collisionBox.contains(positionVector)) { @@ -206,8 +207,8 @@ private static boolean shouldShowPlate(LivingEntity living, Entity cameraEntity) return visible; } - public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSource buffers, - Camera camera, EntityRenderer entityRenderer, + public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSource buffers, + Camera camera, EntityRenderer entityRenderer, float partialTicks, double x, double y, double z) { final Minecraft mc = Minecraft.getInstance(); if (!(entity instanceof LivingEntity living)) { @@ -230,7 +231,8 @@ public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSou final float nameLen = mc.font.width(name) * textScale; final float halfSize = Math.max(NeatConfig.instance.plateSize(), nameLen / 2.0F + 10.0F); - Vec3 vec3 = entityRenderer.getRenderOffset(entity, partialTicks); + S renderState = entityRenderer.createRenderState(); + Vec3 vec3 = entityRenderer.getRenderOffset(renderState); double d2 = x + vec3.x(); double d3 = y + vec3.y(); double d0 = z + vec3.z(); diff --git a/Xplat/src/main/java/vazkii/neat/NeatRenderType.java b/Xplat/src/main/java/vazkii/neat/NeatRenderType.java index 2c5b7bc..b76a4a5 100644 --- a/Xplat/src/main/java/vazkii/neat/NeatRenderType.java +++ b/Xplat/src/main/java/vazkii/neat/NeatRenderType.java @@ -6,6 +6,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.TriState; import vazkii.neat.mixin.AccessorRenderType; import static com.mojang.blaze3d.vertex.DefaultVertexFormat.*; @@ -23,7 +24,7 @@ private NeatRenderType(String string, Runnable r, Runnable r1) { private static RenderType getHealthBarType() { RenderType.CompositeState renderTypeState = RenderType.CompositeState.builder() .setShaderState(POSITION_COLOR_TEX_LIGHTMAP_SHADER) - .setTextureState(new TextureStateShard(NeatRenderType.HEALTH_BAR_TEXTURE, false, false)) + .setTextureState(new TextureStateShard(NeatRenderType.HEALTH_BAR_TEXTURE, TriState.FALSE, false)) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setCullState(NO_CULL) .setLightmapState(LIGHTMAP) diff --git a/Xplat/src/main/java/vazkii/neat/mixin/EntityRendererMixin.java b/Xplat/src/main/java/vazkii/neat/mixin/EntityRendererMixin.java index daf36e9..b4813f3 100644 --- a/Xplat/src/main/java/vazkii/neat/mixin/EntityRendererMixin.java +++ b/Xplat/src/main/java/vazkii/neat/mixin/EntityRendererMixin.java @@ -3,13 +3,17 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.EntityRenderDispatcher; import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.state.EntityRenderState; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -21,9 +25,11 @@ @Mixin(EntityRenderer.class) public class EntityRendererMixin { - @Inject(method = "render(Lnet/minecraft/world/entity/Entity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;renderNameTag(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/network/chat/Component;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;IF)V"), cancellable = true) - private void neat_disableNameTag(Entity entity, float $$1, float $$2, PoseStack $$3, MultiBufferSource $$4, int $$5, CallbackInfo ci) { - if (NeatConfig.instance.disableNameTag() && (!NeatConfig.instance.disableNameTagIfHealthbar() || neat$allowNameTagDisable(entity))) { + @Shadow @Final protected EntityRenderDispatcher entityRenderDispatcher; + + @Inject(method = "render(Lnet/minecraft/client/renderer/entity/state/EntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;renderNameTag(Lnet/minecraft/client/renderer/entity/state/EntityRenderState;Lnet/minecraft/network/chat/Component;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V"), cancellable = true) + private void neat_disableNameTag(EntityRenderState renderState, PoseStack $$1, MultiBufferSource $$2, int $$3, CallbackInfo ci) { + if (NeatConfig.instance.disableNameTag() /*&& (!NeatConfig.instance.disableNameTagIfHealthbar() TODO || neat$allowNameTagDisable(renderState)))*/) { ci.cancel(); } } diff --git a/Xplat/src/main/java/vazkii/neat/mixin/LevelRendererMixin.java b/Xplat/src/main/java/vazkii/neat/mixin/LevelRendererMixin.java index 60716b7..b0f551b 100644 --- a/Xplat/src/main/java/vazkii/neat/mixin/LevelRendererMixin.java +++ b/Xplat/src/main/java/vazkii/neat/mixin/LevelRendererMixin.java @@ -31,7 +31,7 @@ public class LevelRendererMixin { @Inject( method = "renderEntity(Lnet/minecraft/world/entity/Entity;DDDFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;)V", at = @At( - value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;render(Lnet/minecraft/world/entity/Entity;DDDFFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", + value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;render(Lnet/minecraft/world/entity/Entity;DDDFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", shift = At.Shift.AFTER ) ) diff --git a/gradle.properties b/gradle.properties index a67fe9f..b40c676 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,8 +8,10 @@ org.gradle.jvmargs=-Xmx2G \ --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED group=vazkii.neat -neoforge_version=21.1.63 +neoforge_version=21.3.0-beta +fabric_loader_version=0.16.7 +fabric_api_version=0.106.1+1.21.3 mod_id=neat -build_number=41 +build_number=42 mod_name=Neat -mc_version=1.21 +mc_version=1.21.3 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0d18421..e1adfb4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/scripts/upload_releases.sh b/scripts/upload_releases.sh index 741f604..2d14c97 100755 --- a/scripts/upload_releases.sh +++ b/scripts/upload_releases.sh @@ -24,7 +24,7 @@ function release_github() { gh release upload "${TAGNAME}" "${FABRIC_JAR}.asc#Fabric Signature" echo >&2 'Uploading NeoForge Jar and Signature to GitHub' gh release upload "${TAGNAME}" "${NEOFORGE_JAR}#NeoForge Jar" - gh release upload "${TAGNAME}" "${NEOFORGE_JAR}.asc#Forge Signature" + gh release upload "${TAGNAME}" "${NEOFORGE_JAR}.asc#NeoForge Signature" } function release_modrinth() { @@ -142,7 +142,7 @@ $CURSEFORGE_GAME_VERSION]" -F "file=@$FABRIC_JAR" # TODO: Upload the asc as an 'Additional file' - echo >&2 'Uploading Forge Jar to CurseForge' + echo >&2 'Uploading NeoForge Jar to CurseForge' local CURSEFORGE_NEOFORGE_SPEC CURSEFORGE_NEOFORGE_SPEC=$(cat <