diff --git a/src/main/java/appeng/core/AppEngClient.java b/src/main/java/appeng/core/AppEngClient.java index 0aef9796540..4cac65dd2eb 100644 --- a/src/main/java/appeng/core/AppEngClient.java +++ b/src/main/java/appeng/core/AppEngClient.java @@ -49,6 +49,7 @@ import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent; import net.neoforged.neoforge.client.event.RegisterClientTooltipComponentFactoriesEvent; import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; +import net.neoforged.neoforge.client.event.RegisterDimensionSpecialEffectsEvent; import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; import net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent; import net.neoforged.neoforge.common.NeoForge; @@ -94,6 +95,8 @@ import appeng.init.client.InitStackRenderHandlers; import appeng.items.storage.StorageCellTooltipComponent; import appeng.siteexport.SiteExporter; +import appeng.spatial.SpatialStorageDimensionIds; +import appeng.spatial.SpatialStorageSkyProperties; import appeng.util.InteractionUtil; import appeng.util.Platform; @@ -129,6 +132,7 @@ public AppEngClient() { modEventBus.addListener(this::registerEntityRenderers); modEventBus.addListener(this::registerEntityLayerDefinitions); modEventBus.addListener(this::registerHotkeys); + modEventBus.addListener(this::registerDimensionSpecialEffects); BlockAttackHook.install(); RenderBlockOutlineHook.install(); @@ -158,6 +162,12 @@ public AppEngClient() { }); } + private void registerDimensionSpecialEffects(RegisterDimensionSpecialEffectsEvent event) { + event.register( + SpatialStorageDimensionIds.DIMENSION_TYPE_ID.location(), + SpatialStorageSkyProperties.INSTANCE); + } + private void registerClientCommands() { NeoForge.EVENT_BUS.addListener((RegisterClientCommandsEvent evt) -> { var dispatcher = evt.getDispatcher(); diff --git a/src/main/java/appeng/mixins/spatial/SkyPropertiesMixin.java b/src/main/java/appeng/mixins/spatial/SkyPropertiesMixin.java deleted file mode 100644 index b31af6d5f56..00000000000 --- a/src/main/java/appeng/mixins/spatial/SkyPropertiesMixin.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2021, TeamAppliedEnergistics, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -package appeng.mixins.spatial; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import net.minecraft.client.renderer.DimensionSpecialEffects; -import net.minecraft.resources.ResourceLocation; - -import it.unimi.dsi.fastutil.objects.Object2ObjectMap; - -import appeng.spatial.SpatialStorageDimensionIds; -import appeng.spatial.SpatialStorageSkyProperties; - -@Mixin(DimensionSpecialEffects.class) -public class SkyPropertiesMixin { - - @Shadow - private static Object2ObjectMap EFFECTS/* BY_IDENTIFIER */; - - @Inject(method = "", at = @At("TAIL")) - private static void init(CallbackInfo ci) { - EFFECTS.put(SpatialStorageDimensionIds.SKY_PROPERTIES_ID, SpatialStorageSkyProperties.INSTANCE); - } - -} diff --git a/src/main/java/appeng/mixins/spatial/SkyRenderMixin.java b/src/main/java/appeng/mixins/spatial/SkyRenderMixin.java deleted file mode 100644 index 7a5392ce5b4..00000000000 --- a/src/main/java/appeng/mixins/spatial/SkyRenderMixin.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2021, TeamAppliedEnergistics, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -package appeng.mixins.spatial; - -import com.mojang.blaze3d.vertex.PoseStack; - -import org.joml.Matrix4f; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import net.minecraft.client.Camera; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.LevelRenderer; - -import appeng.client.render.SpatialSkyRender; -import appeng.spatial.SpatialStorageDimensionIds; - -@Mixin(value = LevelRenderer.class) -public class SkyRenderMixin { - - @Shadow - private Minecraft minecraft; - - @SuppressWarnings("ConstantConditions") - @Inject(method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;Lorg/joml/Matrix4f;FLnet/minecraft/client/Camera;ZLjava/lang/Runnable;)V", at = @At("HEAD"), cancellable = true) - public void renderSky(PoseStack poseStack, Matrix4f matrix, float f, Camera camera, boolean bl, Runnable runnable, - CallbackInfo ci) { - if (minecraft.level.dimension() == SpatialStorageDimensionIds.WORLD_ID) { - SpatialSkyRender.getInstance().render(poseStack, matrix); - ci.cancel(); - } - } -} diff --git a/src/main/java/appeng/spatial/SpatialStorageSkyProperties.java b/src/main/java/appeng/spatial/SpatialStorageSkyProperties.java index 3cd73e1e87b..f6819c8d585 100644 --- a/src/main/java/appeng/spatial/SpatialStorageSkyProperties.java +++ b/src/main/java/appeng/spatial/SpatialStorageSkyProperties.java @@ -18,14 +18,21 @@ package appeng.spatial; +import com.mojang.blaze3d.vertex.PoseStack; + import org.jetbrains.annotations.Nullable; +import org.joml.Matrix4f; +import net.minecraft.client.Camera; +import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.DimensionSpecialEffects; import net.minecraft.client.renderer.DimensionSpecialEffects.SkyType; import net.minecraft.world.phys.Vec3; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; +import appeng.client.render.SpatialSkyRender; + /** * Defines properties for how the sky in the spatial storage level is rendered. */ @@ -38,20 +45,33 @@ public class SpatialStorageSkyProperties { SkyType.NONE /* we use a custom render mixin */, true, false) { @Override - public Vec3 getBrightnessDependentFogColor(Vec3 p_230494_1_, float p_230494_2_) { + public Vec3 getBrightnessDependentFogColor(Vec3 fogColor, float brightness) { return Vec3.ZERO; } @Override - public boolean isFoggyAt(int p_230493_1_, int p_230493_2_) { + public boolean isFoggyAt(int x, int y) { return false; } @Nullable @Override - public float[] getSunriseColor(float p_230492_1_, float p_230492_2_) { + public float[] getSunriseColor(float timeOfDay, float partialTicks) { return null; } + + @Override + public boolean renderSky(ClientLevel level, int ticks, float partialTick, PoseStack poseStack, Camera camera, + Matrix4f projectionMatrix, boolean isFoggy, Runnable setupFog) { + SpatialSkyRender.getInstance().render(poseStack, projectionMatrix); + return true; + } + + @Override + public boolean renderClouds(ClientLevel level, int ticks, float partialTick, PoseStack poseStack, double camX, + double camY, double camZ, Matrix4f projectionMatrix) { + return true; // Disables clouds + } }; } diff --git a/src/main/resources/ae2.mixins.json b/src/main/resources/ae2.mixins.json index 721e9a4eebc..ee443cd28e2 100644 --- a/src/main/resources/ae2.mixins.json +++ b/src/main/resources/ae2.mixins.json @@ -17,8 +17,6 @@ "UnbreakingMixin" ], "client": [ - "spatial.SkyRenderMixin", - "spatial.SkyPropertiesMixin", "unlitquad.ModelManagerMixin", "unlitquad.BlockModelMixin", "unlitquad.BlockPartFaceDeserializerMixin",