|
| 1 | +package net.vulkanmod.mixin.render.clouds; |
| 2 | + |
| 3 | +import com.mojang.blaze3d.vertex.*; |
| 4 | +import net.minecraft.client.multiplayer.ClientLevel; |
| 5 | +import net.minecraft.client.renderer.*; |
| 6 | +import net.minecraft.resources.ResourceLocation; |
| 7 | +import net.minecraft.server.packs.resources.ResourceManager; |
| 8 | +import net.vulkanmod.render.sky.CloudRenderer; |
| 9 | +import org.jetbrains.annotations.Nullable; |
| 10 | +import org.joml.Matrix4f; |
| 11 | +import org.spongepowered.asm.mixin.*; |
| 12 | +import org.spongepowered.asm.mixin.injection.At; |
| 13 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 14 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 15 | + |
| 16 | +@Mixin(LevelRenderer.class) |
| 17 | +public abstract class LevelRendererM { |
| 18 | + |
| 19 | + @Shadow private int ticks; |
| 20 | + @Shadow private @Nullable ClientLevel level; |
| 21 | + @Shadow @Final protected static ResourceLocation CLOUDS_LOCATION; |
| 22 | + |
| 23 | + @Unique |
| 24 | + private CloudRenderer cloudRenderer; |
| 25 | + |
| 26 | + /** |
| 27 | + * @author |
| 28 | + * @reason |
| 29 | + */ |
| 30 | + @Overwrite |
| 31 | + public void renderClouds(PoseStack poseStack, Matrix4f modelView, Matrix4f projection, float partialTicks, double camX, double camY, double camZ) { |
| 32 | + if (this.cloudRenderer == null) { |
| 33 | + this.cloudRenderer = new CloudRenderer(CLOUDS_LOCATION); |
| 34 | + } |
| 35 | + |
| 36 | + this.cloudRenderer.renderClouds(this.level, poseStack, modelView, projection, this.ticks, partialTicks, camX, camY, camZ); |
| 37 | + } |
| 38 | + |
| 39 | + @Inject(method = "allChanged", at = @At("RETURN")) |
| 40 | + private void onAllChanged(CallbackInfo ci) { |
| 41 | + if (this.cloudRenderer != null) { |
| 42 | + this.cloudRenderer.reset(); |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + @Inject(method = "onResourceManagerReload", at = @At("RETURN")) |
| 47 | + private void onReload(ResourceManager resourceManager, CallbackInfo ci) { |
| 48 | + if (this.cloudRenderer != null) { |
| 49 | + this.cloudRenderer.loadTexture(CLOUDS_LOCATION); |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | +} |
0 commit comments