Update vertex consumer after BLOCK_OUTLINE event (#3940)

This commit is contained in:
Martijn van den Brand 2024-07-14 15:02:42 +01:00 committed by GitHub
parent 5bd9f1bc81
commit df16efd0d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,6 +25,7 @@ import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.block.BlockState;
@ -123,13 +124,17 @@ public abstract class WorldRendererMixin {
if (!WorldRenderEvents.BLOCK_OUTLINE.invoker().onBlockOutline(context, context)) {
ci.cancel();
}
// The immediate mode VertexConsumers use a shared buffer, so we have to make sure that the immediate mode VCP
// can accept block outline lines rendered to the existing vertexConsumer by the vanilla block overlay.
context.consumers().getBuffer(RenderLayer.getLines());
}
}
@SuppressWarnings("ConstantConditions")
@ModifyVariable(method = "drawBlockOutline", at = @At("HEAD"))
private VertexConsumer resetBlockOutlineBuffer(VertexConsumer vertexConsumer) {
// The original VertexConsumer may have been ended during the block outlines event, so we
// have to re-request it to prevent a crash when the vanilla block overlay is submitted.
return context.consumers().getBuffer(RenderLayer.getLines());
}
@Inject(
method = "render",
at = @At(