From 30b9306be09444a83b698e5e11b3169a11839b9d Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 6 Dec 2023 10:25:25 -0500 Subject: [PATCH 1/5] Switch target to Embeddium --- build.gradle | 3 ++- gradlew | 0 .../sodium/mixin/vertex_format/MixinRegionChunkRenderer.java | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 gradlew diff --git a/build.gradle b/build.gradle index 29f4e3961b..a48e755c63 100644 --- a/build.gradle +++ b/build.gradle @@ -40,6 +40,7 @@ repositories { includeGroup "maven.modrinth" } } + maven { url "https://maven.blamejared.com/" } maven { url "https://maven.su5ed.dev/releases" } @@ -51,7 +52,7 @@ dependencies { forge "net.minecraftforge:forge:${minecraft_version}-${forge_version}" //modCompileOnly "maven.modrinth:rubidium:0.7.1" - modCompileOnly "me.jellysquid.mods:rubidium-upstream:0.7.1+git.1cdb739" + modCompileOnly "org.embeddedt:embeddium-1.20.1:0.2.12-git.149aa28+mc1.20.1" } processResources { diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/src/main/java/net/coderbot/iris/compat/sodium/mixin/vertex_format/MixinRegionChunkRenderer.java b/src/main/java/net/coderbot/iris/compat/sodium/mixin/vertex_format/MixinRegionChunkRenderer.java index 3ab5cf1e6a..7ff6cb207e 100644 --- a/src/main/java/net/coderbot/iris/compat/sodium/mixin/vertex_format/MixinRegionChunkRenderer.java +++ b/src/main/java/net/coderbot/iris/compat/sodium/mixin/vertex_format/MixinRegionChunkRenderer.java @@ -29,11 +29,14 @@ public MixinRegionChunkRenderer(RenderDevice device, ChunkVertexType vertexType) } @Redirect(remap = false, method = "createRegionTessellation", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/gl/tessellation/TessellationBinding;forVertexBuffer(Lme/jellysquid/mods/sodium/client/gl/buffer/GlBuffer;[Lme/jellysquid/mods/sodium/client/gl/attribute/GlVertexAttributeBinding;)Lme/jellysquid/mods/sodium/client/gl/tessellation/TessellationBinding;")) + @SuppressWarnings({"rawtypes", "unchecked"}) private TessellationBinding iris$onInit(GlBuffer buffer, GlVertexAttributeBinding[] attributes) { if (!BlockRenderingSettings.INSTANCE.shouldUseExtendedVertexFormat()) { return TessellationBinding.forVertexBuffer(buffer, attributes); } + GlVertexFormat vertexFormat = this.vertexFormat; + attributes = new GlVertexAttributeBinding[]{ new GlVertexAttributeBinding(IrisChunkShaderBindingPoints.ATTRIBUTE_POSITION_ID, vertexFormat.getAttribute(IrisChunkMeshAttributes.POSITION_MATERIAL_MESH)), From 7f98d88af46e998f0ceb4c7110bc508458635732 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:48:25 -0500 Subject: [PATCH 2/5] Fix some render type code --- .../mixin/fantastic/MixinStationaryItemParticle.java | 10 ++++++++-- .../iris/mixin/fantastic/MixinTerrainParticle.java | 9 +++++++-- .../java/net/coderbot/iris/pipeline/HandRenderer.java | 7 ++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/coderbot/iris/mixin/fantastic/MixinStationaryItemParticle.java b/src/main/java/net/coderbot/iris/mixin/fantastic/MixinStationaryItemParticle.java index 9538905fc7..27998c8264 100644 --- a/src/main/java/net/coderbot/iris/mixin/fantastic/MixinStationaryItemParticle.java +++ b/src/main/java/net/coderbot/iris/mixin/fantastic/MixinStationaryItemParticle.java @@ -1,12 +1,17 @@ package net.coderbot.iris.mixin.fantastic; import net.coderbot.iris.fantastic.IrisParticleRenderTypes; +import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.BlockMarker; import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.world.item.BlockItem; import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.client.ChunkRenderTypeSet; +import net.minecraftforge.client.model.data.ModelData; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -21,9 +26,10 @@ public class MixinStationaryItemParticle { @Inject(method = "", at = @At("RETURN")) private void iris$resolveTranslucency(ClientLevel clientLevel, double d, double e, double f, BlockState blockState, CallbackInfo ci) { - RenderType type = ItemBlockRenderTypes.getChunkRenderType(blockState); + BakedModel model = Minecraft.getInstance().getBlockRenderer().getBlockModel(blockState); + ChunkRenderTypeSet types = model.getRenderTypes(blockState, clientLevel.random, ModelData.EMPTY); - if (type == RenderType.solid() || type == RenderType.cutout() || type == RenderType.cutoutMipped()) { + if (types.contains(RenderType.solid()) || types.contains(RenderType.cutout()) || types.contains(RenderType.cutoutMipped())) { isOpaque = true; } } diff --git a/src/main/java/net/coderbot/iris/mixin/fantastic/MixinTerrainParticle.java b/src/main/java/net/coderbot/iris/mixin/fantastic/MixinTerrainParticle.java index cab2287dd6..6d37b2b9bd 100644 --- a/src/main/java/net/coderbot/iris/mixin/fantastic/MixinTerrainParticle.java +++ b/src/main/java/net/coderbot/iris/mixin/fantastic/MixinTerrainParticle.java @@ -1,13 +1,17 @@ package net.coderbot.iris.mixin.fantastic; import net.coderbot.iris.fantastic.IrisParticleRenderTypes; +import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.particle.TerrainParticle; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.client.ChunkRenderTypeSet; +import net.minecraftforge.client.model.data.ModelData; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -22,9 +26,10 @@ public class MixinTerrainParticle { @Inject(method = "(Lnet/minecraft/client/multiplayer/ClientLevel;DDDDDDLnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;)V", at = @At("RETURN")) private void iris$resolveTranslucency(ClientLevel level, double x, double y, double z, double velocityX, double velocityY, double velocityZ, BlockState blockState, BlockPos blockPos, CallbackInfo ci) { - RenderType type = ItemBlockRenderTypes.getChunkRenderType(blockState); + BakedModel model = Minecraft.getInstance().getBlockRenderer().getBlockModel(blockState); + ChunkRenderTypeSet types = model.getRenderTypes(blockState, level.random, ModelData.EMPTY); - if (type == RenderType.solid() || type == RenderType.cutout() || type == RenderType.cutoutMipped()) { + if (types.contains(RenderType.solid()) || types.contains(RenderType.cutout()) || types.contains(RenderType.cutoutMipped())) { isOpaque = true; } } diff --git a/src/main/java/net/coderbot/iris/pipeline/HandRenderer.java b/src/main/java/net/coderbot/iris/pipeline/HandRenderer.java index adfda3b805..7f801aad9f 100644 --- a/src/main/java/net/coderbot/iris/pipeline/HandRenderer.java +++ b/src/main/java/net/coderbot/iris/pipeline/HandRenderer.java @@ -1,6 +1,9 @@ package net.coderbot.iris.pipeline; import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.client.model.data.ModelData; import org.joml.Matrix4f; import net.coderbot.batchedentityrendering.impl.FullyBufferedMultiBufferSource; import net.coderbot.iris.mixin.GameRendererAccessor; @@ -60,7 +63,9 @@ public boolean isHandTranslucent(InteractionHand hand) { Item item = Minecraft.getInstance().player.getItemBySlot(hand == InteractionHand.OFF_HAND ? EquipmentSlot.OFFHAND : EquipmentSlot.MAINHAND).getItem(); if (item instanceof BlockItem) { - return ItemBlockRenderTypes.getChunkRenderType(((BlockItem) item).getBlock().defaultBlockState()) == RenderType.translucent(); + BlockState state = ((BlockItem) item).getBlock().defaultBlockState(); + BakedModel model = Minecraft.getInstance().getBlockRenderer().getBlockModel(state); + return model.getRenderTypes(state, Minecraft.getInstance().level.random, ModelData.EMPTY).contains(RenderType.translucent()); } return false; From d5332bf5bd2ecd4186acc88722182b41ba1c36f0 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:40:39 -0500 Subject: [PATCH 3/5] Correct particle sort order --- .../mixin/fantastic/MixinParticleEngine.java | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/coderbot/iris/mixin/fantastic/MixinParticleEngine.java b/src/main/java/net/coderbot/iris/mixin/fantastic/MixinParticleEngine.java index e1167b9eac..cdfc80210b 100644 --- a/src/main/java/net/coderbot/iris/mixin/fantastic/MixinParticleEngine.java +++ b/src/main/java/net/coderbot/iris/mixin/fantastic/MixinParticleEngine.java @@ -1,6 +1,7 @@ package net.coderbot.iris.mixin.fantastic; -import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import net.coderbot.iris.fantastic.ParticleRenderingPhase; @@ -23,10 +24,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Queue; +import java.util.*; import java.util.function.Supplier; /** @@ -63,10 +61,10 @@ public class MixinParticleEngine implements PhasedParticleEngine { @Final private Map> particles; - private static final List OPAQUE_PARTICLE_RENDER_TYPES; + private static final Set OPAQUE_PARTICLE_RENDER_TYPES; static { - OPAQUE_PARTICLE_RENDER_TYPES = ImmutableList.of( + OPAQUE_PARTICLE_RENDER_TYPES = ImmutableSet.of( ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_LIT, ParticleRenderType.CUSTOM, @@ -81,20 +79,13 @@ public class MixinParticleEngine implements PhasedParticleEngine { @Redirect(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/culling/Frustum;)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/particle/ParticleEngine;particles:Ljava/util/Map;")) private Map> iris$selectParticlesToRender(ParticleEngine instance) { - Map> toRender = new HashMap<>(particles); if (phase == ParticleRenderingPhase.TRANSLUCENT) { - // Remove all known opaque particle texture sheets. - for(ParticleRenderType type : OPAQUE_PARTICLE_RENDER_TYPES) - toRender.remove(type); - - return toRender; + return Maps.filterKeys(particles, type -> !OPAQUE_PARTICLE_RENDER_TYPES.contains(type)); } else if (phase == ParticleRenderingPhase.OPAQUE) { - // Render only opaque particle sheets - toRender.remove(ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT); - return toRender; + return Maps.filterKeys(particles, type -> !type.equals(ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT)); } else { // Don't override particle rendering - return toRender; + return particles; } } From 826d31b5177b6ee55781ec15dba72403363c2c72 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 6 Dec 2023 14:24:44 -0500 Subject: [PATCH 4/5] Fix some parity issues with Forge --- .../iris/block_rendering/BlockMaterialMapping.java | 7 ++++--- .../iris/block_rendering/BlockRenderingSettings.java | 7 ++++--- .../iris/mixin/MixinItemBlockRenderTypes.java | 9 +++++---- .../iris/mixin/texture/MixinTextureManager.java | 2 +- .../vertices/block_rendering/MixinClientLevel.java | 11 ++++++++++- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/coderbot/iris/block_rendering/BlockMaterialMapping.java b/src/main/java/net/coderbot/iris/block_rendering/BlockMaterialMapping.java index 90f0d63c73..8f46aa0f41 100644 --- a/src/main/java/net/coderbot/iris/block_rendering/BlockMaterialMapping.java +++ b/src/main/java/net/coderbot/iris/block_rendering/BlockMaterialMapping.java @@ -17,6 +17,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.Property; +import net.minecraftforge.client.ChunkRenderTypeSet; import java.util.HashMap; import java.util.List; @@ -35,15 +36,15 @@ public static Object2IntMap createBlockStateIdMap(Int2ObjectMap createBlockTypeMap(Map blockPropertiesMap) { - Map blockTypeIds = new Reference2ReferenceOpenHashMap<>(); + public static Map createBlockTypeMap(Map blockPropertiesMap) { + Map blockTypeIds = new Reference2ReferenceOpenHashMap<>(); blockPropertiesMap.forEach((id, blockType) -> { ResourceLocation resourceLocation = new ResourceLocation(id.getNamespace(), id.getName()); Block block = BuiltInRegistries.BLOCK.get(resourceLocation); - blockTypeIds.put(block, convertBlockToRenderType(blockType)); + blockTypeIds.put(block, ChunkRenderTypeSet.of(convertBlockToRenderType(blockType))); }); return blockTypeIds; diff --git a/src/main/java/net/coderbot/iris/block_rendering/BlockRenderingSettings.java b/src/main/java/net/coderbot/iris/block_rendering/BlockRenderingSettings.java index b99729bf5b..6b57c32ddc 100644 --- a/src/main/java/net/coderbot/iris/block_rendering/BlockRenderingSettings.java +++ b/src/main/java/net/coderbot/iris/block_rendering/BlockRenderingSettings.java @@ -6,6 +6,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.client.ChunkRenderTypeSet; import org.jetbrains.annotations.Nullable; import java.util.Map; @@ -15,7 +16,7 @@ public class BlockRenderingSettings { private boolean reloadRequired; private Object2IntMap blockStateIds; - private Map blockTypeIds; + private Map blockTypeIds; private Object2IntFunction entityIds; private Object2IntFunction itemIds; private float ambientOcclusionLevel; @@ -53,7 +54,7 @@ public Object2IntMap getBlockStateIds() { } @Nullable - public Map getBlockTypeIds() { + public Map getBlockTypeIds() { return blockTypeIds; } @@ -77,7 +78,7 @@ public void setBlockStateIds(Object2IntMap blockStateIds) { this.blockStateIds = blockStateIds; } - public void setBlockTypeIds(Map blockTypeIds) { + public void setBlockTypeIds(Map blockTypeIds) { if (this.blockTypeIds != null && this.blockTypeIds.equals(blockTypeIds)) { return; } diff --git a/src/main/java/net/coderbot/iris/mixin/MixinItemBlockRenderTypes.java b/src/main/java/net/coderbot/iris/mixin/MixinItemBlockRenderTypes.java index 8cc8f48970..cc2b639540 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinItemBlockRenderTypes.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinItemBlockRenderTypes.java @@ -5,6 +5,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.client.ChunkRenderTypeSet; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -14,11 +15,11 @@ @Mixin(ItemBlockRenderTypes.class) public class MixinItemBlockRenderTypes { - @Inject(method = "getChunkRenderType", at = @At("HEAD"), cancellable = true) - private static void iris$setCustomRenderType(BlockState arg, CallbackInfoReturnable cir) { - Map idMap = BlockRenderingSettings.INSTANCE.getBlockTypeIds(); + @Inject(method = "getRenderLayers", at = @At("HEAD"), cancellable = true, remap = false) + private static void iris$setCustomRenderType(BlockState arg, CallbackInfoReturnable cir) { + Map idMap = BlockRenderingSettings.INSTANCE.getBlockTypeIds(); if (idMap != null) { - RenderType type = idMap.get(arg.getBlock()); + ChunkRenderTypeSet type = idMap.get(arg.getBlock()); if (type != null) { cir.setReturnValue(type); } diff --git a/src/main/java/net/coderbot/iris/mixin/texture/MixinTextureManager.java b/src/main/java/net/coderbot/iris/mixin/texture/MixinTextureManager.java index e461d8efb2..cdec52e140 100644 --- a/src/main/java/net/coderbot/iris/mixin/texture/MixinTextureManager.java +++ b/src/main/java/net/coderbot/iris/mixin/texture/MixinTextureManager.java @@ -15,7 +15,7 @@ @Mixin(TextureManager.class) public class MixinTextureManager { - @Inject(method = "m_244739_", at = @At("TAIL")) + @Inject(method = "method_18167", at = @At("TAIL")) private void iris$onTailReloadLambda(ResourceManager resourceManager, Executor applyExecutor, CompletableFuture future, Void void1, CallbackInfo ci) { TextureFormatLoader.reload(resourceManager); PBRTextureManager.INSTANCE.clear(); diff --git a/src/main/java/net/coderbot/iris/mixin/vertices/block_rendering/MixinClientLevel.java b/src/main/java/net/coderbot/iris/mixin/vertices/block_rendering/MixinClientLevel.java index 2aa3ac674a..ce0b4628fa 100644 --- a/src/main/java/net/coderbot/iris/mixin/vertices/block_rendering/MixinClientLevel.java +++ b/src/main/java/net/coderbot/iris/mixin/vertices/block_rendering/MixinClientLevel.java @@ -12,7 +12,7 @@ */ @Mixin(ClientLevel.class) public class MixinClientLevel { - @ModifyVariable(method = "getShade", at = @At("HEAD"), argsOnly = true) + @ModifyVariable(method = "getShade(Lnet/minecraft/core/Direction;Z)F", at = @At("HEAD"), argsOnly = true) private boolean iris$maybeDisableDirectionalShading(boolean shaded) { if (BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading()) { return false; @@ -20,4 +20,13 @@ public class MixinClientLevel { return shaded; } } + + @ModifyVariable(method = "getShade(FFFZ)F", at = @At("HEAD"), argsOnly = true, remap = false) + private boolean iris$maybeDisableDirectionalShadingForge(boolean shaded) { + if (BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading()) { + return false; + } else { + return shaded; + } + } } From a6bf4847900c6bccad809d602fa9a6cbf015405e Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 6 Dec 2023 14:39:15 -0500 Subject: [PATCH 5/5] Fix TextureManager mixin now being broken in production --- .../net/coderbot/iris/mixin/texture/MixinTextureManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/coderbot/iris/mixin/texture/MixinTextureManager.java b/src/main/java/net/coderbot/iris/mixin/texture/MixinTextureManager.java index cdec52e140..271081df8a 100644 --- a/src/main/java/net/coderbot/iris/mixin/texture/MixinTextureManager.java +++ b/src/main/java/net/coderbot/iris/mixin/texture/MixinTextureManager.java @@ -15,7 +15,7 @@ @Mixin(TextureManager.class) public class MixinTextureManager { - @Inject(method = "method_18167", at = @At("TAIL")) + @Inject(method = { "method_18167", "m_244739_", "lambda$reload$5" }, at = @At("TAIL"), remap = false) private void iris$onTailReloadLambda(ResourceManager resourceManager, Executor applyExecutor, CompletableFuture future, Void void1, CallbackInfo ci) { TextureFormatLoader.reload(resourceManager); PBRTextureManager.INSTANCE.clear();