From 1da7b409dd2abb420239858ae11ba16ca73be494 Mon Sep 17 00:00:00 2001 From: Ocelot Date: Thu, 2 Jan 2025 16:51:38 -0700 Subject: [PATCH] Fixed crash with sodium in production --- .../client/necromancer/SkeletonParent.java | 9 ++- .../render/NecromancerEntityRenderLayer.java | 3 +- .../render/NecromancerEntityRenderer.java | 22 +++++--- .../api/client/necromancer/render/Skin.java | 4 +- .../necromancer/render/mesh/CubeMesh.java | 20 +++---- .../client/necromancer/render/mesh/Mesh.java | 2 +- .../foundry/veil/api/client/util/UIUtils.java | 51 ++--------------- .../dynamicbuffer/LevelRendererMixin.java | 2 +- .../client/pipeline/GameRendererMixin.java | 2 +- .../client/pipeline/LevelRendererMixin.java | 2 +- .../mixin/client/pipeline/MinecraftMixin.java | 2 +- .../pipeline/ParticleRenderTypeMixin.java | 2 +- .../client/pipeline/VertexBufferMixin.java | 2 +- .../mixin/client/pipeline/WindowMixin.java | 4 +- .../veil/mixin/debug/MinecraftMixin.java | 4 +- .../fabric/mixin/client/MinecraftMixin.java | 2 +- .../compat/iris/IrisRenderTargetMixin.java | 12 ++-- .../compat/sodium/BlockRendererMixin.java | 2 +- .../compat/sodium/ChunkMeshFormatsMixin.java | 2 +- .../sodium/ChunkVertexConsumerMixin.java | 4 +- .../sodium/DefaultFluidRendererMixin.java | 2 +- .../sodium/DefaultShaderInterfaceMixin.java | 2 +- .../sodium/RenderSectionManagerAccessor.java | 2 +- .../sodium/ShaderChunkRendererMixin.java | 56 +++++++++---------- .../resource/ModNioResourcePackMixin.java | 2 +- 25 files changed, 93 insertions(+), 124 deletions(-) diff --git a/common/src/main/java/foundry/veil/api/client/necromancer/SkeletonParent.java b/common/src/main/java/foundry/veil/api/client/necromancer/SkeletonParent.java index 0938f7c2..a2ba6336 100644 --- a/common/src/main/java/foundry/veil/api/client/necromancer/SkeletonParent.java +++ b/common/src/main/java/foundry/veil/api/client/necromancer/SkeletonParent.java @@ -3,10 +3,13 @@ import foundry.veil.api.client.necromancer.animation.Animator; -public interface SkeletonParent

, S extends Skeleton

, A extends Animator> { +public interface SkeletonParent

, S extends Skeleton

> { + void setSkeleton(S skeleton); - void setAnimator(A animator); + + void setAnimator(Animator animator); S getSkeleton(); - A getAnimator(); + + Animator getAnimator(); } diff --git a/common/src/main/java/foundry/veil/api/client/necromancer/render/NecromancerEntityRenderLayer.java b/common/src/main/java/foundry/veil/api/client/necromancer/render/NecromancerEntityRenderLayer.java index c7f30959..5bac861c 100644 --- a/common/src/main/java/foundry/veil/api/client/necromancer/render/NecromancerEntityRenderLayer.java +++ b/common/src/main/java/foundry/veil/api/client/necromancer/render/NecromancerEntityRenderLayer.java @@ -6,7 +6,8 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.world.entity.Entity; -public abstract class NecromancerEntityRenderLayer> { +public abstract class NecromancerEntityRenderLayer, M extends Skeleton> { + public NecromancerEntityRenderer renderer; public NecromancerEntityRenderLayer(NecromancerEntityRenderer pRenderer) { diff --git a/common/src/main/java/foundry/veil/api/client/necromancer/render/NecromancerEntityRenderer.java b/common/src/main/java/foundry/veil/api/client/necromancer/render/NecromancerEntityRenderer.java index 1355f7b4..17c36800 100644 --- a/common/src/main/java/foundry/veil/api/client/necromancer/render/NecromancerEntityRenderer.java +++ b/common/src/main/java/foundry/veil/api/client/necromancer/render/NecromancerEntityRenderer.java @@ -21,7 +21,8 @@ import java.util.function.BiFunction; import java.util.function.Function; -public abstract class NecromancerEntityRenderer> extends EntityRenderer { +public abstract class NecromancerEntityRenderer, M extends Skeleton> extends EntityRenderer { + final Function skeletonFactory; final BiFunction> animatorFactory; final List> layers; @@ -42,13 +43,14 @@ public void addLayer(NecromancerEntityRenderLayer layer) { } public void setupEntity(T entity) { - M skeleton = skeletonFactory.apply(entity); + M skeleton = this.skeletonFactory.apply(entity); entity.setSkeleton(skeleton); - entity.setAnimator(animatorFactory.apply(entity, skeleton)); + entity.setAnimator(this.animatorFactory.apply(entity, skeleton)); } public abstract Skin getSkin(T parent); + @Override public void render(T pEntity, float pEntityYaw, float pPartialTicks, PoseStack poseStack, MultiBufferSource pBuffer, int pPackedLight) { poseStack.pushPose(); float scale = 1.0F / 16.0F; @@ -61,15 +63,17 @@ public void render(T pEntity, float pEntityYaw, float pPartialTicks, PoseStack p boolean shouldRender = !invisible; RenderType rendertype = this.getRenderType(pEntity, this.getTextureLocation(pEntity)); - M skeleton = (M) pEntity.getSkeleton(); + M skeleton = pEntity.getSkeleton(); Skin skin = this.getSkin(pEntity); - if (shouldRender && skeleton != null && skin != null ) { - renderSkin(pEntity, skeleton, skin, pEntity.tickCount, pPartialTicks, poseStack, pBuffer.getBuffer(rendertype), pPackedLight, this.getOverlayCoords(pEntity), 1, 1, 1, 1); + if (shouldRender && skeleton != null && skin != null) { + this.renderSkin(pEntity, skeleton, skin, pEntity.tickCount, pPartialTicks, poseStack, pBuffer.getBuffer(rendertype), pPackedLight, this.getOverlayCoords(pEntity), 1, 1, 1, 1); } if (!pEntity.isSpectator() && rendertype != null && skeleton != null) { - for (NecromancerEntityRenderLayer layer : this.layers) layer.render(poseStack, pBuffer, pPackedLight, pEntity, skeleton, pPartialTicks); + for (NecromancerEntityRenderLayer layer : this.layers) { + layer.render(poseStack, pBuffer, pPackedLight, pEntity, skeleton, pPartialTicks); + } } poseStack.popPose(); @@ -88,7 +92,9 @@ public void renderSkin(T entity, M skeleton, Skin skin, int ticksExisted, flo protected RenderType getRenderType(T pLivingEntity, boolean visible, boolean spectator, boolean glowing) { ResourceLocation texture = this.getTextureLocation(pLivingEntity); - if (!visible) return null; + if (!visible) { + return null; + } return this.getRenderType(pLivingEntity, texture); } } diff --git a/common/src/main/java/foundry/veil/api/client/necromancer/render/Skin.java b/common/src/main/java/foundry/veil/api/client/necromancer/render/Skin.java index 4527d067..7fab006c 100644 --- a/common/src/main/java/foundry/veil/api/client/necromancer/render/Skin.java +++ b/common/src/main/java/foundry/veil/api/client/necromancer/render/Skin.java @@ -20,11 +20,11 @@ public Skin() { } public void addMesh(String boneID, Mesh mesh) { - meshes.put(boneID, mesh); + this.meshes.put(boneID, mesh); } public Mesh getMesh(Bone bone) { - return meshes.getOrDefault(bone.identifier, Mesh.EMPTY); + return this.meshes.getOrDefault(bone.identifier, Mesh.EMPTY); } public void render(T skeleton, int ticksExisted, float partialTick, PoseStack pPoseStack, VertexConsumer pVertexConsumer, int pPackedLight, int pPackedOverlay, float pRed, float pGreen, float pBlue, float pAlpha) { diff --git a/common/src/main/java/foundry/veil/api/client/necromancer/render/mesh/CubeMesh.java b/common/src/main/java/foundry/veil/api/client/necromancer/render/mesh/CubeMesh.java index 1ca7558b..89590bdb 100644 --- a/common/src/main/java/foundry/veil/api/client/necromancer/render/mesh/CubeMesh.java +++ b/common/src/main/java/foundry/veil/api/client/necromancer/render/mesh/CubeMesh.java @@ -23,7 +23,7 @@ public CubeMesh(int textureWidth, int textureHeight) { super(); this.textureWidth = textureWidth; this.textureHeight = textureHeight; - faces = new ArrayList<>(); + this.faces = new ArrayList<>(); } public Face[] addCube(float xSize, float ySize, float zSize, float xOffset, float yOffset, float zOffset, float xInflate, float yInflate, float zInflate, float uOffset, float vOffset) { @@ -68,21 +68,21 @@ public Face[] addCube(float xSize, float ySize, float zSize, float xOffset, floa float v1 = vOffset + Mth.floor(zSize); float v2 = vOffset + Mth.floor(zSize) + Mth.floor(ySize); - Face[] cubeFaces = {new Face(xoz, ooz, ooo, xoo, u3, v0, u2, v1, textureWidth, textureHeight, mirrored, Direction.UP), - new Face(xyo, oyo, oyz, xyz, u2, v1, u1, v0, textureWidth, textureHeight, mirrored, Direction.DOWN), - new Face(ooo, ooz, oyz, oyo, u4, v2, u2, v1, textureWidth, textureHeight, mirrored, Direction.EAST), - new Face(xoz, xoo, xyo, xyz, u1, v2, u0, v1, textureWidth, textureHeight, mirrored, Direction.WEST), - new Face(ooz, xoz, xyz, oyz, u5, v2, u4, v1, textureWidth, textureHeight, mirrored, Direction.NORTH), - new Face(xoo, ooo, oyo, xyo, u2, v2, u1, v1, textureWidth, textureHeight, mirrored, Direction.SOUTH)}; + Face[] cubeFaces = {new Face(xoz, ooz, ooo, xoo, u3, v0, u2, v1, this.textureWidth, this.textureHeight, mirrored, Direction.UP), + new Face(xyo, oyo, oyz, xyz, u2, v1, u1, v0, this.textureWidth, this.textureHeight, mirrored, Direction.DOWN), + new Face(ooo, ooz, oyz, oyo, u4, v2, u2, v1, this.textureWidth, this.textureHeight, mirrored, Direction.EAST), + new Face(xoz, xoo, xyo, xyz, u1, v2, u0, v1, this.textureWidth, this.textureHeight, mirrored, Direction.WEST), + new Face(ooz, xoz, xyz, oyz, u5, v2, u4, v1, this.textureWidth, this.textureHeight, mirrored, Direction.NORTH), + new Face(xoo, ooo, oyo, xyo, u2, v2, u1, v1, this.textureWidth, this.textureHeight, mirrored, Direction.SOUTH)}; - Collections.addAll(faces, cubeFaces); + Collections.addAll(this.faces, cubeFaces); return cubeFaces; } public Face addTri(float x1, float y1, float z1, float u1, float v1, float x2, float y2, float z2, float u2, float v2, float x3, float y3, float z3, float u3, float v3, float normalX, float normalY, float normalZ) { Face face = new Face(new Vertex[]{new Vertex(x1, y1, z1), new Vertex(x2, y2, z2), new Vertex(x2, y2, z2)}, new UV[]{new UV(u1, v1), new UV(u2, v2), new UV(u3, v3)}, new Vector3f(normalX, normalY, normalZ)); - faces.add(face); + this.faces.add(face); return face; } @@ -95,7 +95,7 @@ public Face addFace(float normalX, float normalY, float normalZ, FaceVertex... v uvArray[i] = new UV(vertex.u() / (float)this.textureWidth, vertex.v() / (float)this.textureHeight); } Face face = new Face(vertArray, uvArray, new Vector3f(normalX, normalY, normalZ)); - faces.add(face); + this.faces.add(face); return face; } diff --git a/common/src/main/java/foundry/veil/api/client/necromancer/render/mesh/Mesh.java b/common/src/main/java/foundry/veil/api/client/necromancer/render/mesh/Mesh.java index 3312b14b..deab330f 100644 --- a/common/src/main/java/foundry/veil/api/client/necromancer/render/mesh/Mesh.java +++ b/common/src/main/java/foundry/veil/api/client/necromancer/render/mesh/Mesh.java @@ -16,7 +16,7 @@ public void render(PoseStack pPoseStack, VertexConsumer pVertexConsumer, int pPa protected record Vertex(float x, float y, float z) {} protected record UV(float u, float v) {} - protected static class Face { + public static class Face { protected final Vertex[] vertices; protected final UV[] uvs; protected final Vector3f normal; diff --git a/common/src/main/java/foundry/veil/api/client/util/UIUtils.java b/common/src/main/java/foundry/veil/api/client/util/UIUtils.java index e151d679..5efdb3ed 100644 --- a/common/src/main/java/foundry/veil/api/client/util/UIUtils.java +++ b/common/src/main/java/foundry/veil/api/client/util/UIUtils.java @@ -1,7 +1,5 @@ package foundry.veil.api.client.util; -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import com.mojang.datafixers.util.Either; @@ -13,9 +11,6 @@ import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraft.client.resources.model.BakedModel; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; @@ -23,15 +18,12 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.inventory.tooltip.TooltipComponent; -import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; -import org.joml.Matrix4fStack; import java.util.ArrayList; import java.util.List; -import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -45,8 +37,7 @@ public static void drawHoverText(Tooltippable tooltippable, float pticks, final return; } - List list = gatherTooltipComponents(stack, textLines, - stack.getTooltipImage(), mouseX, screenWidth, screenHeight, font, font); + List list = gatherTooltipComponents(stack, textLines, stack.getTooltipImage().orElse(null), mouseX, screenWidth, screenHeight, font, font); // RenderSystem.disableRescaleNormal(); RenderSystem.disableDepthTest(); int tooltipTextWidth = 0; @@ -198,13 +189,14 @@ public static void tryRenderGuiItem(@Nullable LivingEntity $$0, ItemStack $$1, f tryRenderGuiItem($$0, $$1, $$2, $$3, $$4, 0); } - public static List gatherTooltipComponents(ItemStack stack, List textElements, Optional itemComponent, int mouseX, int screenWidth, int screenHeight, @Nullable Font forcedFont, Font fallbackFont) { + public static List gatherTooltipComponents(ItemStack stack, List textElements, @Nullable TooltipComponent itemComponent, int mouseX, int screenWidth, int screenHeight, @Nullable Font forcedFont, Font fallbackFont) { Font font = forcedFont != null ? forcedFont : fallbackFont; List> elements = textElements.stream() .map((Function>) Either::left) .collect(Collectors.toCollection(ArrayList::new)); - itemComponent.ifPresent(c -> elements.add(1, Either.right(c))); - + if (itemComponent != null) { + elements.add(1, Either.right(itemComponent)); + } // text wrapping int tooltipTextWidth = elements.stream() @@ -317,37 +309,4 @@ public static void tryRenderGuiItem(LivingEntity $$0, ItemStack $$1, float $$2, // Minecraft.getInstance().getItemRenderer().blitOffset = $$6.isGui3d() ? Minecraft.getInstance().getItemRenderer().blitOffset - 50.0F - (float) $$5 : Minecraft.getInstance().getItemRenderer().blitOffset - 50.0F; // } } - - public static void renderGuiItem(ItemStack stack, float x, float y, BakedModel bakedModel) { - Minecraft.getInstance().getTextureManager().getTexture(TextureAtlas.LOCATION_BLOCKS).setFilter(false, false); - RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS); - RenderSystem.enableBlend(); - RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - Matrix4fStack $$4 = RenderSystem.getModelViewStack(); - $$4.pushMatrix(); -// $$4.translate((double) x, (double) y, (double) (100.0F + Minecraft.getInstance().getItemRenderer().blitOffset)); - $$4.translate(8, 8, 0); - $$4.scale(1.0F, -1.0F, 1.0F); - $$4.scale(16.0F, 16.0F, 16.0F); - RenderSystem.applyModelViewMatrix(); - PoseStack $$5 = new PoseStack(); - MultiBufferSource.BufferSource $$6 = Minecraft.getInstance().renderBuffers().bufferSource(); - boolean $$7 = !bakedModel.usesBlockLight(); - if ($$7) { - Lighting.setupForFlatItems(); - } else { - Lighting.setupFor3DItems(); - } - - Minecraft.getInstance().getItemRenderer().render(stack, ItemDisplayContext.GUI, false, $$5, $$6, 15728880, OverlayTexture.NO_OVERLAY, bakedModel); - $$6.endBatch(); - RenderSystem.enableDepthTest(); - if ($$7) { - Lighting.setupFor3DItems(); - } - - $$4.popMatrix(); - RenderSystem.applyModelViewMatrix(); - } } diff --git a/common/src/main/java/foundry/veil/mixin/client/dynamicbuffer/LevelRendererMixin.java b/common/src/main/java/foundry/veil/mixin/client/dynamicbuffer/LevelRendererMixin.java index 9cf6cdab..c49205a1 100644 --- a/common/src/main/java/foundry/veil/mixin/client/dynamicbuffer/LevelRendererMixin.java +++ b/common/src/main/java/foundry/veil/mixin/client/dynamicbuffer/LevelRendererMixin.java @@ -39,7 +39,7 @@ public void endOpaque(CallbackInfo ci) { VeilRenderSystem.renderer().getDynamicBufferManger().setEnabled(false); } - @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;long2ObjectEntrySet()Lit/unimi/dsi/fastutil/objects/ObjectSet;", shift = At.Shift.BEFORE)) + @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;long2ObjectEntrySet()Lit/unimi/dsi/fastutil/objects/ObjectSet;", shift = At.Shift.BEFORE, remap = false)) public void beginTranslucent(CallbackInfo ci) { VeilRenderSystem.renderer().getDynamicBufferManger().setEnabled(true); } diff --git a/common/src/main/java/foundry/veil/mixin/client/pipeline/GameRendererMixin.java b/common/src/main/java/foundry/veil/mixin/client/pipeline/GameRendererMixin.java index a613e40c..5731a682 100644 --- a/common/src/main/java/foundry/veil/mixin/client/pipeline/GameRendererMixin.java +++ b/common/src/main/java/foundry/veil/mixin/client/pipeline/GameRendererMixin.java @@ -90,7 +90,7 @@ public void unbindGuiCamera(CallbackInfo ci) { VeilRenderSystem.renderer().getGuiInfo().unbind(); } - @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;clear(IZ)V", shift = At.Shift.BEFORE)) + @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;clear(IZ)V", shift = At.Shift.BEFORE, remap = false)) public void bindFirstPerson(CallbackInfo ci) { VeilFirstPersonRenderer.bind(); } diff --git a/common/src/main/java/foundry/veil/mixin/client/pipeline/LevelRendererMixin.java b/common/src/main/java/foundry/veil/mixin/client/pipeline/LevelRendererMixin.java index f17fa960..9d902e7d 100644 --- a/common/src/main/java/foundry/veil/mixin/client/pipeline/LevelRendererMixin.java +++ b/common/src/main/java/foundry/veil/mixin/client/pipeline/LevelRendererMixin.java @@ -102,7 +102,7 @@ public void setRainBlend(CallbackInfo ci) { } // Add custom world border shader - @ModifyArg(method = "renderWorldBorder", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShader(Ljava/util/function/Supplier;)V")) + @ModifyArg(method = "renderWorldBorder", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShader(Ljava/util/function/Supplier;)V", remap = false)) public Supplier setWorldBorderShader(Supplier supplier) { return VeilVanillaShaders::getWorldborder; } diff --git a/common/src/main/java/foundry/veil/mixin/client/pipeline/MinecraftMixin.java b/common/src/main/java/foundry/veil/mixin/client/pipeline/MinecraftMixin.java index 2da6db34..342e10bb 100644 --- a/common/src/main/java/foundry/veil/mixin/client/pipeline/MinecraftMixin.java +++ b/common/src/main/java/foundry/veil/mixin/client/pipeline/MinecraftMixin.java @@ -12,7 +12,7 @@ public class MinecraftMixin { @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/pipeline/RenderTarget;bindWrite(Z)V"), slice = @Slice( - from = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;clear(IZ)V"), + from = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;clear(IZ)V", remap = false), to = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;render(Lnet/minecraft/client/DeltaTracker;Z)V"))) public void beginFrame(CallbackInfo ci) { VeilRenderSystem.beginFrame(); diff --git a/common/src/main/java/foundry/veil/mixin/client/pipeline/ParticleRenderTypeMixin.java b/common/src/main/java/foundry/veil/mixin/client/pipeline/ParticleRenderTypeMixin.java index 70201d49..f570e4b4 100644 --- a/common/src/main/java/foundry/veil/mixin/client/pipeline/ParticleRenderTypeMixin.java +++ b/common/src/main/java/foundry/veil/mixin/client/pipeline/ParticleRenderTypeMixin.java @@ -14,7 +14,7 @@ public class ParticleRenderTypeMixin { * * @author Ocelot */ - @Redirect(method = "begin", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;defaultBlendFunc()V")) + @Redirect(method = "begin", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;defaultBlendFunc()V", remap = false)) public void changeBlendFunction() { RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); } diff --git a/common/src/main/java/foundry/veil/mixin/client/pipeline/VertexBufferMixin.java b/common/src/main/java/foundry/veil/mixin/client/pipeline/VertexBufferMixin.java index 18d087c2..f480d7db 100644 --- a/common/src/main/java/foundry/veil/mixin/client/pipeline/VertexBufferMixin.java +++ b/common/src/main/java/foundry/veil/mixin/client/pipeline/VertexBufferMixin.java @@ -85,7 +85,7 @@ public void drawPatches(CallbackInfo ci) { } } - @ModifyArg(method = "draw", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;drawElements(III)V"), index = 0) + @ModifyArg(method = "draw", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;drawElements(III)V", remap = false), index = 0) public int modifyDrawMode(int glMode) { return this.veil$getDrawMode(glMode); } diff --git a/common/src/main/java/foundry/veil/mixin/client/pipeline/WindowMixin.java b/common/src/main/java/foundry/veil/mixin/client/pipeline/WindowMixin.java index a1494ffb..20782dc8 100644 --- a/common/src/main/java/foundry/veil/mixin/client/pipeline/WindowMixin.java +++ b/common/src/main/java/foundry/veil/mixin/client/pipeline/WindowMixin.java @@ -10,13 +10,13 @@ @Mixin(Window.class) public class WindowMixin { - @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwWindowHint(II)V", ordinal = 2), index = 1) + @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwWindowHint(II)V", ordinal = 2, remap = false), index = 1) public int captureMajorVersion(int hint, @Share("majorGLVersion") LocalIntRef majorGLVersion) { majorGLVersion.set(hint); return hint; } - @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwWindowHint(II)V", ordinal = 3), index = 1) + @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwWindowHint(II)V", ordinal = 3, remap = false), index = 1) public int captureMinorVersion(int hint, @Share("majorGLVersion") LocalIntRef majorGLVersion) { return majorGLVersion.get() == 3 ? Math.max(3, hint) : hint; } diff --git a/common/src/main/java/foundry/veil/mixin/debug/MinecraftMixin.java b/common/src/main/java/foundry/veil/mixin/debug/MinecraftMixin.java index d2cad666..7d9f4e25 100644 --- a/common/src/main/java/foundry/veil/mixin/debug/MinecraftMixin.java +++ b/common/src/main/java/foundry/veil/mixin/debug/MinecraftMixin.java @@ -9,12 +9,12 @@ @Mixin(Minecraft.class) public class MinecraftMixin { - @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;initRenderer(IZ)V"), index = 0) + @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;initRenderer(IZ)V", remap = false), index = 0) private int modifyDebugVerbosity(int debugVerbosity) { return Veil.DEBUG ? 100 : debugVerbosity; } - @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;initRenderer(IZ)V"), index = 1) + @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;initRenderer(IZ)V", remap = false), index = 1) private boolean modifySynchronousDebug(boolean synchronous) { return synchronous || Veil.DEBUG; } diff --git a/fabric/src/main/java/foundry/veil/fabric/mixin/client/MinecraftMixin.java b/fabric/src/main/java/foundry/veil/fabric/mixin/client/MinecraftMixin.java index 777afc27..fa849e29 100644 --- a/fabric/src/main/java/foundry/veil/fabric/mixin/client/MinecraftMixin.java +++ b/fabric/src/main/java/foundry/veil/fabric/mixin/client/MinecraftMixin.java @@ -28,7 +28,7 @@ public void init(CallbackInfo ci) { FabricVeilRegisterFixedBuffersEvent.EVENT.invoker().onRegisterFixedBuffers(FabricRenderTypeStageHandler::register); } - @Inject(method = "", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setupDefaultState(IIII)V")) + @Inject(method = "", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setupDefaultState(IIII)V", remap = false)) public void registerBlockLayers(CallbackInfo ci) { ImmutableList.Builder blockLayers = ImmutableList.builder(); FabricVeilRegisterBlockLayersEvent.EVENT.invoker().onRegisterBlockLayers(renderType -> { diff --git a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/iris/IrisRenderTargetMixin.java b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/iris/IrisRenderTargetMixin.java index 822530fe..37f9c001 100644 --- a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/iris/IrisRenderTargetMixin.java +++ b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/iris/IrisRenderTargetMixin.java @@ -9,22 +9,22 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -@Mixin(RenderTarget.class) +@Mixin(value = RenderTarget.class, remap = false) public abstract class IrisRenderTargetMixin implements IrisRenderTargetExtension { - @Shadow(remap = false) + @Shadow private String name; - @Shadow(remap = false) + @Shadow public abstract int getMainTexture(); - @Shadow(remap = false) + @Shadow public abstract int getAltTexture(); - @Shadow(remap = false) + @Shadow public abstract int getWidth(); - @Shadow(remap = false) + @Shadow public abstract int getHeight(); @Shadow diff --git a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/BlockRendererMixin.java b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/BlockRendererMixin.java index a7a52b45..1ea5d5e3 100644 --- a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/BlockRendererMixin.java +++ b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/BlockRendererMixin.java @@ -16,7 +16,7 @@ @Mixin(BlockRenderer.class) public class BlockRendererMixin { - @Shadow + @Shadow(remap = false) @Final private ChunkVertexEncoder.Vertex[] vertices; diff --git a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ChunkMeshFormatsMixin.java b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ChunkMeshFormatsMixin.java index 255642aa..dd6b0ddc 100644 --- a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ChunkMeshFormatsMixin.java +++ b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ChunkMeshFormatsMixin.java @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ChunkMeshFormats.class) +@Mixin(value = ChunkMeshFormats.class, remap = false) public class ChunkMeshFormatsMixin { @Mutable diff --git a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ChunkVertexConsumerMixin.java b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ChunkVertexConsumerMixin.java index 355d4065..fd674db4 100644 --- a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ChunkVertexConsumerMixin.java +++ b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ChunkVertexConsumerMixin.java @@ -15,11 +15,11 @@ @Mixin(ChunkVertexConsumer.class) public class ChunkVertexConsumerMixin { - @Shadow + @Shadow(remap = false) @Final private ChunkVertexEncoder.Vertex[] vertices; - @Shadow + @Shadow(remap = false) private int vertexIndex; @Inject(method = "setNormal", at = @At("HEAD")) diff --git a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/DefaultFluidRendererMixin.java b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/DefaultFluidRendererMixin.java index 30167cbd..cc1729da 100644 --- a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/DefaultFluidRendererMixin.java +++ b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/DefaultFluidRendererMixin.java @@ -20,7 +20,7 @@ @Mixin(DefaultFluidRenderer.class) public class DefaultFluidRendererMixin { - @Shadow + @Shadow(remap = false) @Final private ChunkVertexEncoder.Vertex[] vertices; diff --git a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/DefaultShaderInterfaceMixin.java b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/DefaultShaderInterfaceMixin.java index 5c3aa57e..82386c27 100644 --- a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/DefaultShaderInterfaceMixin.java +++ b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/DefaultShaderInterfaceMixin.java @@ -18,7 +18,7 @@ public class DefaultShaderInterfaceMixin { @Unique private VeilNormalUniform veil$uniformNormalMatrix; - @Inject(method = "", at = @At("TAIL")) + @Inject(method = "", at = @At("TAIL"), remap = false) private void init(ShaderBindingContext context, ChunkShaderOptions options, CallbackInfo ci) { this.veil$uniformNormalMatrix = context.bindUniformOptional("VeilNormalMatrix", VeilNormalUniform::new); } diff --git a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/RenderSectionManagerAccessor.java b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/RenderSectionManagerAccessor.java index 3047d691..67060ae3 100644 --- a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/RenderSectionManagerAccessor.java +++ b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/RenderSectionManagerAccessor.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -@Mixin(RenderSectionManager.class) +@Mixin(value = RenderSectionManager.class, remap = false) public interface RenderSectionManagerAccessor { @Accessor diff --git a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ShaderChunkRendererMixin.java b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ShaderChunkRendererMixin.java index 8cc503f2..5c08bdf0 100644 --- a/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ShaderChunkRendererMixin.java +++ b/fabric/src/main/java/foundry/veil/fabric/mixin/compat/sodium/ShaderChunkRendererMixin.java @@ -37,7 +37,7 @@ @Mixin(ShaderChunkRenderer.class) public abstract class ShaderChunkRendererMixin implements ShaderChunkRendererExtension { - @Shadow + @Shadow(remap = false) @Final private Map> programs; @@ -64,8 +64,8 @@ public void updateActiveProgram(ChunkShaderOptions options, CallbackInfoReturnab ((ChunkShaderOptionsExtension) (Object) options).veil$setActiveBuffers(this.veil$activeBuffers); } - @WrapOperation(method = "createShader", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/gl/shader/ShaderLoader;loadShader(Lnet/caffeinemc/mods/sodium/client/gl/shader/ShaderType;Lnet/minecraft/resources/ResourceLocation;Lnet/caffeinemc/mods/sodium/client/gl/shader/ShaderConstants;)Lnet/caffeinemc/mods/sodium/client/gl/shader/GlShader;"), require = 2, remap = false) - public GlShader createShader(ShaderType type, ResourceLocation name, ShaderConstants constants, Operation original) { + @WrapOperation(method = "createShader", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/gl/shader/ShaderLoader;loadShader(Lnet/caffeinemc/mods/sodium/client/gl/shader/ShaderType;Lnet/minecraft/resources/ResourceLocation;Lnet/caffeinemc/mods/sodium/client/gl/shader/ShaderConstants;)Lnet/caffeinemc/mods/sodium/client/gl/shader/GlShader;", remap = true), require = 2, remap = false) + private GlShader createShader(ShaderType type, ResourceLocation name, ShaderConstants constants, Operation original) { if (this.veil$shaderSource != null) { String source = this.veil$shaderSource.get(type); if (source != null) { @@ -76,7 +76,7 @@ public GlShader createShader(ShaderType type, ResourceLocation name, ShaderConst } @Unique - private void veil$doRecompile(Queue keys, int activeBuffers) { + private void recompile(Queue keys, int activeBuffers) { if (this.scheduler != null) { this.scheduler.cancel(); } @@ -132,9 +132,30 @@ public GlShader createShader(ShaderType type, ResourceLocation name, ShaderConst }, VeilRenderSystem.renderThreadExecutor()); } + @SuppressWarnings("RedundantOperationOnEmptyContainer") + @Unique + private Queue getActiveKeys(int activeBuffers) { + Queue keys = new ConcurrentLinkedDeque<>(); + for (ChunkShaderOptions key : this.programs.keySet()) { + boolean unique = true; + for (ChunkShaderOptions options : keys) { + if (options.fog() == key.fog() && options.pass() == key.pass() && options.vertexType() == key.vertexType()) { + unique = false; + break; + } + } + if (unique) { + ChunkShaderOptions options = new ChunkShaderOptions(key.fog(), key.pass(), key.vertexType()); + ((ChunkShaderOptionsExtension) (Object) options).veil$setActiveBuffers(activeBuffers); + keys.add(options); + } + } + return keys; + } + @Override public void veil$recompile() { - this.veil$doRecompile(this.veil$getActiveKeys(this.veil$activeBuffers), this.veil$activeBuffers); + this.recompile(this.getActiveKeys(this.veil$activeBuffers), this.veil$activeBuffers); } @Override @@ -147,38 +168,17 @@ public GlShader createShader(ShaderType type, ResourceLocation name, ShaderConst this.scheduler.cancel(); } - Queue keys = this.veil$getActiveKeys(activeBuffers); + Queue keys = this.getActiveKeys(activeBuffers); keys.removeIf(this.programs::containsKey); if (keys.isEmpty()) { return; } - this.veil$doRecompile(keys, activeBuffers); + this.recompile(keys, activeBuffers); } @Override public Map> veil$getPrograms() { return this.programs; } - - @SuppressWarnings("RedundantOperationOnEmptyContainer") - @Unique - private Queue veil$getActiveKeys(int activeBuffers) { - Queue keys = new ConcurrentLinkedDeque<>(); - for (ChunkShaderOptions key : this.programs.keySet()) { - boolean unique = true; - for (ChunkShaderOptions options : keys) { - if (options.fog() == key.fog() && options.pass() == key.pass() && options.vertexType() == key.vertexType()) { - unique = false; - break; - } - } - if (unique) { - ChunkShaderOptions options = new ChunkShaderOptions(key.fog(), key.pass(), key.vertexType()); - ((ChunkShaderOptionsExtension) (Object) options).veil$setActiveBuffers(activeBuffers); - keys.add(options); - } - } - return keys; - } } diff --git a/fabric/src/main/java/foundry/veil/fabric/mixin/resource/ModNioResourcePackMixin.java b/fabric/src/main/java/foundry/veil/fabric/mixin/resource/ModNioResourcePackMixin.java index 07d4400e..933670ac 100644 --- a/fabric/src/main/java/foundry/veil/fabric/mixin/resource/ModNioResourcePackMixin.java +++ b/fabric/src/main/java/foundry/veil/fabric/mixin/resource/ModNioResourcePackMixin.java @@ -25,7 +25,7 @@ import java.util.Set; import java.util.stream.Stream; -@Mixin(ModNioResourcePack.class) +@Mixin(value = ModNioResourcePack.class, remap = false) public abstract class ModNioResourcePackMixin implements ModResourcePack, PackResourcesExtension { @Shadow