From 5bec2aa4ac3a311dd17521c82ce2e297b1f66106 Mon Sep 17 00:00:00 2001 From: supsm Date: Sun, 26 Feb 2023 12:17:33 -0800 Subject: [PATCH 1/2] fix chisels n bits compatibility (#407) --- .../canvas/mixin/MixinModelBlockRenderer.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java b/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java index c00164baa..c4c5144bb 100644 --- a/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java +++ b/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java @@ -21,11 +21,14 @@ package grondag.canvas.mixin; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import grondag.canvas.apiimpl.rendercontext.CanvasBlockRenderContext; import net.minecraft.client.renderer.block.ModelBlockRenderer; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; @@ -33,19 +36,13 @@ import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; -import grondag.canvas.apiimpl.rendercontext.CanvasBlockRenderContext; - -// WIP: change this an inject with cancel so that mods that hook in here don't break directly - esp C&B // WIP: move hooks upstream so that multi-consumer is available in more cases @Mixin(ModelBlockRenderer.class) public abstract class MixinModelBlockRenderer { - /** - * @author grondag - * @reason performance; less bad than inject and cancel at head - */ - @Overwrite - public void tesselateBlock(BlockAndTintGetter blockView, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, VertexConsumer buffer, boolean checkSides, RandomSource randomSource, long seed, int overlay) { + @Inject(at = @At("HEAD"), method = "tesselateBlock", cancellable = true) + public void beforeTesselateBlock(BlockAndTintGetter blockView, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, VertexConsumer buffer, boolean checkSides, RandomSource randomSource, long seed, int overlay, CallbackInfo ci) { // PERF: try to avoid threadlocal lookup here CanvasBlockRenderContext.get().render((ModelBlockRenderer) (Object) this, blockView, model, state, pos, poseStack, buffer, checkSides, seed, overlay); + ci.cancel(); } } From e42ace3058f983c97d4397914ddb9cfd4190b51e Mon Sep 17 00:00:00 2001 From: supsm Date: Mon, 1 May 2023 18:25:19 -0700 Subject: [PATCH 2/2] fix import order --- .../java/grondag/canvas/mixin/MixinModelBlockRenderer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java b/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java index c4c5144bb..111d10b7b 100644 --- a/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java +++ b/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java @@ -28,7 +28,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import grondag.canvas.apiimpl.rendercontext.CanvasBlockRenderContext; import net.minecraft.client.renderer.block.ModelBlockRenderer; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; @@ -36,6 +35,8 @@ import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; +import grondag.canvas.apiimpl.rendercontext.CanvasBlockRenderContext; + // WIP: move hooks upstream so that multi-consumer is available in more cases @Mixin(ModelBlockRenderer.class) public abstract class MixinModelBlockRenderer {