Skip to content

Commit

Permalink
Merge pull request IrisShaders#1096 from IMS212/trunk-loader012
Browse files Browse the repository at this point in the history
Update to Fabric Loader 0.12.12, use Mixin 0.8.4
  • Loading branch information
coderbot16 authored Dec 16, 2021
2 parents 2da5749 + f37398d commit df68123
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 34 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.jvmargs=-Xmx2G
minecraft_version=1.16.5
fabric_version=0.32.0+1.16

loader_version=0.12.5
loader_version=0.12.12

# Sodium Properties
# If the Modrinth maven is unavailable or Sodium is not available for whatever reason,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,23 @@
package net.coderbot.iris.mixin.texunits;

import com.mojang.blaze3d.vertex.BufferVertexConsumer;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.coderbot.iris.texunits.TextureUnit;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(BufferVertexConsumer.class)
@Environment(EnvType.CLIENT)
public interface MixinBufferVertexConsumer {
// Note: the below code doesn't work due to https://github.com/FabricMC/Mixin/issues/34
/*@ModifyConstant(method = "overlay(II)Lnet/minecraft/client/render/VertexConsumer;", constant = @Constant(intValue = 1), require = 1)
@ModifyConstant(method = "overlayCoords", constant = @Constant(intValue = 1), require = 1)
default int iris$fixOverlayIndex(int index) {
return TextureUnit.OVERLAY.getSamplerId();
}

@ModifyConstant(method = "light(II)Lnet/minecraft/client/render/VertexConsumer;", constant = @Constant(intValue = 2), require = 1)
@ModifyConstant(method = "uv2", constant = @Constant(intValue = 2), require = 1)
default int iris$fixLightIndex(int index) {
return TextureUnit.LIGHTMAP.getSamplerId();
}*/

/**
* @reason FabricMC Mixin does not support injections into interfaces
* @author coderbot16
*/
@Overwrite
default VertexConsumer overlayCoords(int u, int v) {
return ((BufferVertexConsumer) this).uvShort((short) u, (short) v, TextureUnit.OVERLAY.getSamplerId());
}

/**
* @reason FabricMC Mixin does not support injections into interfaces
* @author coderbot16
*/
@Overwrite
default VertexConsumer uv2(int u, int v) {
return ((BufferVertexConsumer) this).uvShort((short) u, (short) v, TextureUnit.LIGHTMAP.getSamplerId());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.coderbot.iris.mixin.vertices.block_rendering;

import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.PoseStack;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.vertices.BlockSensitiveBufferBuilder;
Expand All @@ -10,6 +12,8 @@
import net.minecraft.client.renderer.chunk.RenderChunkRegion;
import net.minecraft.client.renderer.chunk.VisGraph;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -18,8 +22,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.PoseStack;

import java.util.Iterator;
import java.util.Random;
import java.util.Set;
Expand All @@ -29,7 +32,7 @@
*
* Uses a priority of 999 so that we apply before Indigo's mixins.
*/
@Mixin(targets = "net.minecraft.client.renderer.chunk.ChunkRenderDispatcher$RenderChunk$RebuildTask", priority = 999, remap = true)
@Mixin(targets = "net.minecraft.client.renderer.chunk.ChunkRenderDispatcher$RenderChunk$RebuildTask", priority = 999)
public class MixinChunkRebuildTask {
private static final String RENDER = "compile(FFFLnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$CompiledChunk;Lnet/minecraft/client/renderer/ChunkBufferBuilderPack;)Ljava/util/Set;";

Expand All @@ -54,8 +57,8 @@ private short resolveBlockId(BlockState state) {
return (short) blockStateIds.getOrDefault(state, -1);
}

@Inject(method = RENDER, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderLiquid(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/level/material/FluidState;)Z"), locals = LocalCapture.CAPTURE_FAILHARD, remap = true)
private void iris$onRenderLiquid(float cameraX, float cameraY, float cameraZ, ChunkRenderDispatcher.CompiledChunk data, ChunkBufferBuilderPack buffers, CallbackInfoReturnable<Set> cir, int i, BlockPos blockPos, BlockPos blockPos2, VisGraph chunkOcclusionDataBuilder, Set set, RenderChunkRegion chunkRendererRegion, PoseStack poseStack, Random random, BlockRenderDispatcher blockRenderManager, Iterator var15, BlockPos blockPos3, BlockState blockState, FluidState fluidState, RenderType renderType, BufferBuilder bufferBuilder2) {
@Inject(method = RENDER, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderLiquid(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/level/material/FluidState;)Z"), locals = LocalCapture.CAPTURE_FAILHARD)
private void iris$onRenderLiquid(float cameraX, float cameraY, float cameraZ, ChunkRenderDispatcher.CompiledChunk data, ChunkBufferBuilderPack buffers, CallbackInfoReturnable<Set<BlockEntity>> cir, int i, BlockPos blockPos, BlockPos blockPos2, VisGraph chunkOcclusionDataBuilder, Set<BlockEntity> set, RenderChunkRegion chunkRendererRegion, PoseStack poseStack, Random random, BlockRenderDispatcher blockRenderManager, Iterator<BlockPos> var15, BlockPos blockPos3, BlockState blockState, Block block, FluidState fluidState, RenderType renderType, BufferBuilder bufferBuilder2) {
if (bufferBuilder2 instanceof BlockSensitiveBufferBuilder) {
lastBufferBuilder = ((BlockSensitiveBufferBuilder) bufferBuilder2);
// All fluids have a ShadersMod render type of 1, to match behavior of Minecraft 1.7 and earlier.
Expand All @@ -65,15 +68,15 @@ private short resolveBlockId(BlockState state) {
}

@Inject(method = RENDER, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderLiquid(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/level/material/FluidState;)Z", shift = At.Shift.AFTER))
private void iris$finishRenderingLiquid(float cameraX, float cameraY, float cameraZ, ChunkRenderDispatcher.CompiledChunk data, ChunkBufferBuilderPack buffers, CallbackInfoReturnable<Set> cir) {
private void iris$finishRenderingLiquid(float cameraX, float cameraY, float cameraZ, ChunkRenderDispatcher.CompiledChunk data, ChunkBufferBuilderPack buffers, CallbackInfoReturnable<Set<BlockEntity>> cir) {
if (lastBufferBuilder != null) {
lastBufferBuilder.endBlock();
lastBufferBuilder = null;
}
}

@Inject(method = RENDER, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBatched(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;ZLjava/util/Random;)Z"), locals = LocalCapture.CAPTURE_FAILHARD)
private void iris$onRenderBlock(float cameraX, float cameraY, float cameraZ, ChunkRenderDispatcher.CompiledChunk data, ChunkBufferBuilderPack buffers, CallbackInfoReturnable<Set> cir, int i, BlockPos blockPos, BlockPos blockPos2, VisGraph chunkOcclusionDataBuilder, Set set, RenderChunkRegion chunkRendererRegion, PoseStack poseStack, Random random, BlockRenderDispatcher blockRenderManager, Iterator var15, BlockPos blockPos3, BlockState blockState, RenderType renderType2, BufferBuilder bufferBuilder2) {
private void iris$onRenderBlock(float cameraX, float cameraY, float cameraZ, ChunkRenderDispatcher.CompiledChunk data, ChunkBufferBuilderPack buffers, CallbackInfoReturnable<Set<BlockEntity>> cir, int i, BlockPos blockPos, BlockPos blockPos2, VisGraph chunkOcclusionDataBuilder, Set<BlockEntity> set, RenderChunkRegion chunkRendererRegion, PoseStack poseStack, Random random, BlockRenderDispatcher blockRenderManager, Iterator<BlockPos> var15, BlockPos blockPos3, BlockState blockState, Block block, FluidState fluidState, RenderType renderType2, BufferBuilder bufferBuilder2) {
if (bufferBuilder2 instanceof BlockSensitiveBufferBuilder) {
lastBufferBuilder = ((BlockSensitiveBufferBuilder) bufferBuilder2);
// TODO: Resolve render types for normal blocks?
Expand All @@ -82,7 +85,7 @@ private short resolveBlockId(BlockState state) {
}

@Inject(method = RENDER, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBatched(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;ZLjava/util/Random;)Z", shift = At.Shift.AFTER))
private void iris$finishRenderingBlock(float cameraX, float cameraY, float cameraZ, ChunkRenderDispatcher.CompiledChunk data, ChunkBufferBuilderPack buffers, CallbackInfoReturnable<Set> cir) {
private void iris$finishRenderingBlock(float cameraX, float cameraY, float cameraZ, ChunkRenderDispatcher.CompiledChunk data, ChunkBufferBuilderPack buffers, CallbackInfoReturnable<Set<BlockEntity>> cir) {
if (lastBufferBuilder != null) {
lastBufferBuilder.endBlock();
lastBufferBuilder = null;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"accessWidener" : "iris.accesswidener",

"depends": {
"fabricloader": ">=0.7.4",
"fabricloader": ">=0.12.3",
"minecraft": "1.16.5",
"fabric-resource-loader-v0": ">=0.3.2",
"fabric-key-binding-api-v1": ">=1.0.1"
Expand Down

0 comments on commit df68123

Please sign in to comment.