Remove PRE and POST preprocessor MC versions

This commit is contained in:
James Seibel
2023-12-11 07:45:54 -06:00
parent fee1c98a34
commit 2bb2f5a233
75 changed files with 368 additions and 381 deletions
@@ -205,7 +205,7 @@ public class FabricClientProxy
#if MC_1_16_5
SeamlessOverdraw.applyLegacyProjectionMatrix(matrixFloatArray);
#elif PRE_MC_1_19_4
#elif MC_1_16 || MC_1_17 || MC_1_18 || MC_1_19_2
renderContext.projectionMatrix().load(FloatBuffer.wrap(matrixFloatArray));
#else
renderContext.projectionMatrix().set(matrixFloatArray);
@@ -59,7 +59,7 @@ public class FabricMain
if (Config.Client.Advanced.Graphics.Fog.disableVanillaFog.get() && SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("bclib"))
ModAccessorInjector.INSTANCE.get(IBCLibAccessor.class).setRenderCustomFog(false); // Remove BCLib's fog
#if POST_MC_1_20_1
#if MC_1_20_2 || MC_1_20_4
if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("sodium"))
ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class).setFogOcclusion(false); // FIXME: This is a tmp fix for sodium 0.5.0, and 0.5.1. This is fixed in sodium 0.5.2
#endif
@@ -118,7 +118,7 @@ public class FabricMain
ModAccessorInjector.INSTANCE.bind(IBCLibAccessor.class, new BCLibAccessor());
}
#if MC_1_16_5 || MC_1_18_2 || MC_1_19_2 || MC_1_19_4 || MC_1_20_1
#if MC_1_16_5 || MC_1_18 || MC_1_19 || MC_1_20_1
// 1.17.1 won't support this since there isn't a matching Iris version
if (modChecker.isModLoaded("iris"))
{
@@ -24,7 +24,7 @@ import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.core.api.internal.ClientApi;
import com.seibel.distanthorizons.core.api.internal.SharedApi;
import net.minecraft.client.multiplayer.ClientLevel;
#if POST_MC_1_18_2
#if MC_1_19 || MC_1_20
#endif
import net.minecraft.world.level.chunk.LevelChunk;
import org.spongepowered.asm.mixin.Mixin;
@@ -44,14 +44,14 @@ public class MixinClientLevel
// //Moved to MixinClientPacketListener
// @Inject(method = "<init>", at = @At("TAIL"))
// private void loadWorldEvent(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey,
// #if POST_MC_1_18_2 Holder holder, #else DimensionType dimensionType, #endif int i,
// #if POST_MC_1_18_2 int j, #endif Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci)
// #if MC_1_19 || MC_1_20 Holder holder, #else DimensionType dimensionType, #endif int i,
// #if MC_1_19 || MC_1_20 int j, #endif Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci)
// {
// ClientApi.INSTANCE.clientLevelLoadEvent(WorldWrapper.getWorldWrapper((ClientLevel)(Object)this));
// }
// Moved to overriding the enableChunkLight(...) method over at ClientPacketListener for 1.20+
#if POST_MC_1_18_2 && PRE_MC_1_20_1 // Only the setLightReady is only available after 1.18. This ensures the light data is ready.
#if (MC_1_19 || MC_1_20) && (MC_1_16 || MC_1_17 || MC_1_18 || MC_1_19) // Only the setLightReady is only available after 1.18. This ensures the light data is ready.
@Inject(method = "setLightReady", at = @At("HEAD"))
private void onChunkLightReady(int x, int z, CallbackInfo ci)
{
@@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
#if POST_MC_1_20_1
#if MC_1_20_2 || MC_1_20_4
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import net.minecraft.world.level.chunk.LevelChunk;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
@@ -31,7 +31,7 @@ public class MixinClientPacketListener
@Inject(method = "handleRespawn", at = @At("RETURN"))
void onHandleRespawnEnd(CallbackInfo ci) { ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(this.level)); }
#if PRE_MC_1_19_4
#if MC_1_16 || MC_1_17 || MC_1_18 || MC_1_19_2
@Inject(method = "cleanup", at = @At("HEAD"))
#else
@Inject(method = "close", at = @At("HEAD"))
@@ -45,7 +45,7 @@ public class MixinClientPacketListener
ClientApi.INSTANCE.onClientOnlyDisconnected();
}
#if POST_MC_1_20_1
#if MC_1_20_2 || MC_1_20_4
@Inject(method = "enableChunkLight", at = @At("TAIL"))
void onEnableChunkLight(LevelChunk chunk, int x, int z, CallbackInfo ci)
{
@@ -35,7 +35,7 @@ import net.minecraft.client.renderer.FogRenderer.FogMode;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
#if PRE_MC_1_17_1
#if MC_1_16
import net.minecraft.world.level.material.FluidState;
#else
import net.minecraft.world.level.material.FogType;
@@ -50,14 +50,14 @@ public class MixinFogRenderer
private static final float A_EVEN_LARGER_VALUE = 42069420694206942069.F;
@Inject(at = @At("RETURN"), method = "setupFog")
#if PRE_MC_1_19_2
#if MC_1_16 || MC_1_17 || MC_1_18
private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, CallbackInfo callback)
{
#else
private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, float g, CallbackInfo callback)
{
#endif
#if PRE_MC_1_17_1
#if MC_1_16
FluidState fluidState = camera.getFluidInCamera();
boolean cameraNotInFluid = fluidState.isEmpty();
#else
@@ -71,7 +71,7 @@ public class MixinFogRenderer
&& !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial()
&& Config.Client.Advanced.Graphics.Fog.disableVanillaFog.get())
{
#if PRE_MC_1_17_1
#if MC_1_16
RenderSystem.fogStart(A_REALLY_REALLY_BIG_VALUE);
RenderSystem.fogEnd(A_EVEN_LARGER_VALUE);
#else
@@ -16,7 +16,7 @@ public class MixinGameRenderer
private static final Logger LOGGER = LogManager.getLogger(MixinGameRenderer.class.getSimpleName());
#if POST_MC_1_17_1
#if MC_1_18 || MC_1_19 || MC_1_20
// FIXME: This I think will dup multiple renderStartupEvent calls...
@Inject(method = {"reloadShaders", "preloadUiShader"}, at = @At("TAIL"))
public void onStartupShaders(CallbackInfo ci)
@@ -20,7 +20,7 @@
package com.seibel.distanthorizons.fabric.mixins.client;
import com.mojang.blaze3d.vertex.PoseStack;
#if PRE_MC_1_19_4
#if MC_1_16 || MC_1_17 || MC_1_18 || MC_1_19_2
import com.mojang.math.Matrix4f;
#else
import net.minecraft.client.Camera;
@@ -67,7 +67,7 @@ public class MixinLevelRenderer
// Inject rendering at first call to renderChunkLayer
// HEAD or RETURN
#if PRE_MC_1_17_1
#if MC_1_16
@Inject(at = @At("RETURN"), method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;F)V")
private void renderSky(PoseStack matrixStackIn, float partialTicks, CallbackInfo callback)
{
@@ -84,17 +84,17 @@ public class MixinLevelRenderer
}
#endif
#if PRE_MC_1_17_1
#if MC_1_16
@Inject(at = @At("HEAD"),
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDD)V",
cancellable = true)
private void renderChunkLayer(RenderType renderType, PoseStack matrixStackIn, double xIn, double yIn, double zIn, CallbackInfo callback)
#elif PRE_MC_1_19_4
#elif MC_1_16 || MC_1_17 || MC_1_18 || MC_1_19_2
@Inject(at = @At("HEAD"),
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V",
cancellable = true)
private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback)
#elif PRE_MC_1_20_2
#elif MC_1_16 || MC_1_17 || MC_1_18 || MC_1_19 || MC_1_20_1
@Inject(at = @At("HEAD"),
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V",
cancellable = true)
@@ -113,10 +113,10 @@ public class MixinLevelRenderer
}
}
#if PRE_MC_1_19_4
#if MC_1_16 || MC_1_17 || MC_1_18 || MC_1_19_2
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"), method = "renderLevel")
public void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
#elif PRE_MC_1_20_1
#elif MC_1_16 || MC_1_17 || MC_1_18 || MC_1_19
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"), method = "renderLevel")
public void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
#else
@@ -25,7 +25,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Minecraft.class)
public class MixinMinecraft
{
#if PRE_MC_1_20_2
#if MC_1_16 || MC_1_17 || MC_1_18 || MC_1_19 || MC_1_20_1
#if MC_1_20_1
@Redirect(
method = "Lnet/minecraft/client/Minecraft;setInitialScreen(Lcom/mojang/realmsclient/client/RealmsClient;Lnet/minecraft/server/packs/resources/ReloadInstance;Lnet/minecraft/client/main/GameConfig$QuickPlayData;)V",
@@ -61,7 +61,7 @@ public class MixinMinecraft
}
#endif
#if POST_MC_1_20_2
#if MC_1_20_4
@Redirect(
method = "Lnet/minecraft/client/Minecraft;onGameLoadFinished(Lnet/minecraft/client/Minecraft$GameLoadCookie;)V",
at = @At(value = "INVOKE", target = "Ljava/lang/Runnable;run()V")
@@ -26,7 +26,7 @@ import com.seibel.distanthorizons.core.config.Config;
import net.minecraft.client.gui.screens.OptionsScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
#if PRE_MC_1_19_2
#if MC_1_16 || MC_1_17 || MC_1_18
import net.minecraft.network.chat.TranslatableComponent;
#endif
import net.minecraft.resources.ResourceLocation;
@@ -57,7 +57,7 @@ public class MixinOptionsScreen extends Screen
private void lodconfig$init(CallbackInfo ci)
{
if (Config.Client.optionsButton.get())
this. #if PRE_MC_1_17_1 addButton #else addRenderableWidget #endif
this. #if MC_1_16 addButton #else addRenderableWidget #endif
(new TexturedButtonWidget(
// Where the button is on the screen
this.width / 2 - 180, this.height / 6 - 12,
@@ -71,7 +71,7 @@ public class MixinOptionsScreen extends Screen
// For now it goes to the client option by default
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(GetConfigScreen.getScreen(this)),
// Add a title to the utton
#if PRE_MC_1_19_2
#if MC_1_16 || MC_1_17 || MC_1_18
new TranslatableComponent(ModInfo.ID + ".title")));
#else
Component.translatable(ModInfo.ID + ".title")));
@@ -31,7 +31,7 @@ import org.spongepowered.asm.mixin.Mixin;
@Deprecated // TODO: Not sure if this is needed anymore
public class MixinServerLevel
{
// #if PRE_MC_1_17_1
// #if MC_1_16
// @Inject(method = "save", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;save(Z)V", shift = At.Shift.AFTER))
// private void saveWorldEvent(ProgressListener progressListener, boolean bl, boolean bl2, CallbackInfo ci) {
// Main.client_proxy.worldSaveEvent();
@@ -2,7 +2,7 @@ package com.seibel.distanthorizons.fabric.mixins.mods.sodium;
/* Removed since DH now uses Indium so we can use the Fabric rendering API instead
#if POST_MC_1_20_1
#if MC_1_20_2 || MC_1_20_4
// Sodium 0.5
import com.mojang.blaze3d.vertex.PoseStack;
import com.seibel.distanthorizons.core.api.internal.ClientApi;
@@ -55,7 +55,7 @@ public class MixinSodiumRenderer
}
#elif POST_MC_1_17_1
#elif MC_1_18 || MC_1_19 || MC_1_20
// Sodium 0.3 to 0.4
import com.seibel.distanthorizons.core.api.internal.ClientApi;
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
@@ -22,7 +22,7 @@ package com.seibel.distanthorizons.fabric.mixins.server;
import org.spongepowered.asm.mixin.Mixin;
import net.minecraft.world.level.chunk.ChunkGenerator;
#if PRE_MC_1_18_2
#if MC_1_16 || MC_1_17
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -37,7 +37,7 @@ public class MixinChunkMap
// MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks)
// this logic should prevent that from happening
#if MC_1_16_5 || MC_1_17_1
#if MC_1_16_5 || MC_1_17
if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect())
{
return;
@@ -55,7 +55,7 @@ public class MixinChunkMap
//==================//
// some chunks may be missing their biomes, which cause issues when attempting to save them
#if MC_1_16_5 || MC_1_17_1
#if MC_1_16_5 || MC_1_17
if (chunk.getBiomes() == null)
{
return;
@@ -50,7 +50,7 @@ public class MixinUtilBackgroundThread
}
}
#if POST_MC_1_17_1
#if MC_1_18 || MC_1_19 || MC_1_20
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Runnable;",
at = @At("HEAD"), cancellable = true)
private static void overrideUtil$wrapThreadWithTaskName(String string, Runnable r, CallbackInfoReturnable<Runnable> ci)
@@ -62,7 +62,7 @@ public class MixinUtilBackgroundThread
}
}
#endif
#if POST_MC_1_18_2
#if MC_1_19 || MC_1_20
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/util/function/Supplier;)Ljava/util/function/Supplier;",
at = @At("HEAD"), cancellable = true)
private static void overrideUtil$wrapThreadWithTaskNameForSupplier(String string, Supplier<?> r, CallbackInfoReturnable<Supplier<?>> ci)
@@ -22,7 +22,7 @@ package com.seibel.distanthorizons.fabric.mixins.server.unsafe;
import org.spongepowered.asm.mixin.Mixin;
//FIXME: Is this still needed?
#if POST_MC_1_18_2
#if MC_1_19 || MC_1_20
import net.minecraft.util.ThreadingDetector;
import org.spongepowered.asm.mixin.Mutable;
@@ -1,8 +1,8 @@
package com.seibel.distanthorizons.fabric.wrappers.modAccessor;
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IBCLibAccessor;
#if MC_1_16_5 || MC_1_17_1 || MC_1_20_4 // These versions either don't have BCLib, or the implementation is different
#elif MC_1_18_2
#if MC_1_16_5 || MC_1_17 || MC_1_20_4 // These versions either don't have BCLib, or the implementation is different
#elif MC_1_18
import ru.bclib.config.ClientConfig;
import ru.bclib.config.Configs;
#else
@@ -17,7 +17,7 @@ public class BCLibAccessor implements IBCLibAccessor
public void setRenderCustomFog(boolean newValue)
{
#if !(MC_1_16_5 || MC_1_17_1 || MC_1_20_4) // These versions either don't have BCLib, or the implementation is different
#if !(MC_1_16_5 || MC_1_17 || MC_1_20_4) // These versions either don't have BCLib, or the implementation is different
// Change the value of CUSTOM_FOG_RENDERING in the bclib client config
// This disabled fog from rendering within bclib
@@ -19,7 +19,7 @@
package com.seibel.distanthorizons.fabric.wrappers.modAccessor;
#if MC_1_16_5 || MC_1_18_2 || MC_1_19_2 || MC_1_19_4 || MC_1_20_1
#if MC_1_16_5 || MC_1_18 || MC_1_19 || MC_1_20_1
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
import net.coderbot.iris.Iris;
@@ -33,7 +33,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.ISodiumAcce
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
import net.minecraft.client.Minecraft;
#if PRE_MC_1_17_1
#if MC_1_16
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.world.entity.Entity;
@@ -60,21 +60,21 @@ public class SodiumAccessor implements ISodiumAccessor
return "Sodium-Fabric";
}
#if POST_MC_1_17_1
#if MC_1_18 || MC_1_19 || MC_1_20
@Override
public HashSet<DhChunkPos> getNormalRenderedChunks()
{
SodiumWorldRenderer renderer = SodiumWorldRenderer.instance();
LevelHeightAccessor height = Minecraft.getInstance().level;
#if POST_MC_1_20_1
#if MC_1_20_2 || MC_1_20_4
// TODO: This is just a tmp solution, use a proper solution later
return MC_RENDER.getMaximumRenderedChunks().stream().filter((DhChunkPos chunk) -> {
return (renderer.isBoxVisible(
chunk.getMinBlockX() + 1, height.getMinBuildHeight() + 1, chunk.getMinBlockZ() + 1,
chunk.getMinBlockX() + 15, height.getMaxBuildHeight() - 1, chunk.getMinBlockZ() + 15));
}).collect(Collectors.toCollection(HashSet::new));
#elif POST_MC_1_18_2
#elif MC_1_19 || MC_1_20
// 0b11 = Lighted chunk & loaded chunk
return renderer.getChunkTracker().getChunks(0b00).filter(
(long l) -> {
@@ -134,7 +134,7 @@ public class SodiumAccessor implements ISodiumAccessor
@Override
public void setFogOcclusion(boolean b)
{
#if POST_MC_1_20_1
#if MC_1_20_2 || MC_1_20_4
me.jellysquid.mods.sodium.client.SodiumClientMod.options().performance.useFogOcclusion = b;
#endif
}