mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-27 01:55:41 -05:00
Update vertex consumer after BLOCK_OUTLINE
event (#3940)
This commit is contained in:
parent
5bd9f1bc81
commit
df16efd0d6
1 changed files with 9 additions and 4 deletions
|
@ -25,6 +25,7 @@ import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.At.Shift;
|
import org.spongepowered.asm.mixin.injection.At.Shift;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
@ -123,13 +124,17 @@ public abstract class WorldRendererMixin {
|
||||||
if (!WorldRenderEvents.BLOCK_OUTLINE.invoker().onBlockOutline(context, context)) {
|
if (!WorldRenderEvents.BLOCK_OUTLINE.invoker().onBlockOutline(context, context)) {
|
||||||
ci.cancel();
|
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(
|
@Inject(
|
||||||
method = "render",
|
method = "render",
|
||||||
at = @At(
|
at = @At(
|
||||||
|
|
Loading…
Reference in a new issue