diff --git a/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java b/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java index c00164baa..111d10b7b 100644 --- a/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java +++ b/src/main/java/grondag/canvas/mixin/MixinModelBlockRenderer.java @@ -21,7 +21,9 @@ 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; @@ -35,17 +37,13 @@ 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(); } }