Use WorldRenderEvents if available (#680)

* Use WorldRenderEvents if available

Fixes an issue when Canvas is installed

* Improve code

* Depend only on fabric-rendering-v1

* Use fabricApi.module
This commit is contained in:
ramidzkh authored and GitHub committed 2021-01-26 01:19:44 -04:00
1 parent a83548876a
commit 566d2a7bca
5 files changed
+50 -6

No files matched your search

@@ -2,6 +2,7 @@ package carpet.mixins;
import carpet.network.CarpetClient;
import carpet.script.utils.ShapesRenderer;
import carpet.utils.FabricAPIHooks;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BufferBuilderStorage;
@@ -28,7 +29,7 @@ public class WorldRenderer_scarpetRenderMixin
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/debug/DebugRenderer;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;DDD)V"))
private void renderScarpetThings(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci)
{
if (CarpetClient.shapes != null)
if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null)
{
RenderSystem.pushMatrix();
CarpetClient.shapes.render(camera, tickDelta);