Fix compile errors with 1.12.2.
This commit is contained in:
-37
@@ -77,43 +77,6 @@ public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
// world events //
|
||||
//==============//
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientLevelLoadEvent(WorldEvent.Load event)
|
||||
{
|
||||
LOGGER.info("level load");
|
||||
|
||||
World level = event.getWorld();
|
||||
if (!(level instanceof WorldClient clientLevel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel, true);
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(clientLevelWrapper);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientLevelUnloadEvent(WorldEvent.Unload event)
|
||||
{
|
||||
LOGGER.info("level unload");
|
||||
|
||||
World level = event.getWorld();
|
||||
if (!(level instanceof WorldClient clientLevel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel);
|
||||
ClientApi.INSTANCE.clientLevelUnloadEvent(clientLevelWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
// chunk events //
|
||||
//==============//
|
||||
|
||||
+1
-3
@@ -26,7 +26,6 @@ import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
@@ -61,9 +60,8 @@ public class MixinEntityRenderer
|
||||
return;
|
||||
}
|
||||
|
||||
IClientLevelWrapper clientLevel = mc.getWrappedClientLevel();
|
||||
MinecraftRenderWrapper renderWrapper = (MinecraftRenderWrapper)SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||
renderWrapper.setLightmapId(lightmapTexture.getGlTextureId(), clientLevel);
|
||||
renderWrapper.setLightmapId(lightmapTexture.getGlTextureId());
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "setupFog")
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package com.seibel.distanthorizons.common.commonMixins;
|
||||
|
||||
#if MC_VER > MC_1_12_2
|
||||
import com.seibel.distanthorizons.common.wrappers.modAccessor.ImmersivePortalsAccessorCommon;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
||||
@@ -36,3 +37,4 @@ public class MixinImmersivePortalsRenderStatesCommon
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
-1
@@ -10,7 +10,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRen
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IImmersivePortalsAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
#else
|
||||
|
||||
+11
-4
@@ -9,6 +9,7 @@ import net.minecraft.client.multiplayer.WorldClient;
|
||||
#else
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
#endif
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -33,7 +34,7 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
||||
private final Map<String, KeyInfo> keysByDimensionName = new ConcurrentHashMap<>();
|
||||
|
||||
/** Cache for already keyed level wrappers to maintain object identity. */
|
||||
private final Map<ClientLevel, IServerKeyedClientLevel> keyedLevelsCache = Collections.synchronizedMap(new WeakHashMap<>());
|
||||
private final Map<#if MC_VER > MC_1_12_2 ClientLevel #else WorldClient #endif, IServerKeyedClientLevel> keyedLevelsCache = Collections.synchronizedMap(new WeakHashMap<>());
|
||||
|
||||
/** Allows to keep level manager enabled between loading different keyed levels */
|
||||
private volatile boolean enabled = false;
|
||||
@@ -61,11 +62,15 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
||||
@Nullable
|
||||
public IServerKeyedClientLevel getServerKeyedLevel()
|
||||
{
|
||||
#if MC_VER > MC_1_12_2
|
||||
return this.getServerKeyedLevel(Minecraft.getInstance().level);
|
||||
#else
|
||||
return this.getServerKeyedLevel(Minecraft.getMinecraft().world);
|
||||
#endif
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IServerKeyedClientLevel getServerKeyedLevel(@Nullable ClientLevel level)
|
||||
public IServerKeyedClientLevel getServerKeyedLevel(@Nullable #if MC_VER > MC_1_12_2 ClientLevel #else WorldClient #endif level)
|
||||
{
|
||||
if (level == null)
|
||||
{
|
||||
@@ -131,7 +136,9 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
||||
synchronized (this.keyedLevelsCache)
|
||||
{
|
||||
this.keyedLevelsCache.keySet().removeIf(level -> {
|
||||
#if MC_VER <= MC_1_21_10
|
||||
#if MC_VER <= MC_1_12_2
|
||||
String levelDim = level.provider.getDimensionType().getName();
|
||||
#elif MC_VER <= MC_1_21_10
|
||||
String levelDim = level.dimension().location().toString();
|
||||
#else
|
||||
String levelDim = level.dimension().identifier().toString();
|
||||
@@ -142,7 +149,7 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
||||
|
||||
// 4. Return the keyed wrapper for whatever level the core passed us,
|
||||
// but only if it matches the dimension we just keyed.
|
||||
return this.getServerKeyedLevel((ClientLevel) clientLevel.getWrappedMcObject());
|
||||
return this.getServerKeyedLevel((#if MC_VER > MC_1_12_2 ClientLevel #else WorldClient #endif) clientLevel.getWrappedMcObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+22
-5
@@ -20,6 +20,7 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.minecraft;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
#if MC_VER > MC_1_12_2
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
@@ -52,6 +53,9 @@ import net.minecraft.profiler.Profiler;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
#else
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.client.CloudStatus;
|
||||
@@ -62,9 +66,9 @@ import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
#endif
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
#if MC_VER < MC_1_19_2 && MC_VER > MC_1_12_2
|
||||
@@ -81,7 +85,9 @@ import net.minecraft.client.GraphicsStatus;
|
||||
#else
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_21_10
|
||||
#if MC_VER <= MC_1_12_2
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
#elif MC_VER <= MC_1_21_10
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
#else
|
||||
import net.minecraft.resources.Identifier;
|
||||
@@ -89,7 +95,7 @@ import net.minecraft.resources.Identifier;
|
||||
|
||||
#if MC_VER > MC_1_19_2
|
||||
import net.minecraft.core.registries.Registries;
|
||||
#else
|
||||
#elif MC_VER > MC_1_12_2
|
||||
import net.minecraft.core.Registry;
|
||||
#endif
|
||||
|
||||
@@ -628,7 +634,12 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
public IServerLevelWrapper getWrappedServerLevel(String levelKey)
|
||||
{
|
||||
if (!hasSinglePlayerServer()) return null;
|
||||
#if MC_VER <= MC_1_21_10
|
||||
#if MC_VER <= MC_1_12_2
|
||||
DimensionType levelID = null;
|
||||
try {
|
||||
levelID = DimensionType.byName(levelKey);
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
#elif MC_VER <= MC_1_21_10
|
||||
ResourceLocation levelID = ResourceLocation.tryParse(levelKey);
|
||||
#else
|
||||
Identifier levelID = Identifier.tryParse(levelKey);
|
||||
@@ -637,11 +648,17 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
|
||||
#if MC_VER > MC_1_19_2
|
||||
ResourceKey<Level> resourceKey = ResourceKey.create(Registries.DIMENSION, levelID);
|
||||
#else
|
||||
#elif MC_VER > MC_1_12_2
|
||||
ResourceKey<Level> resourceKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, levelID);
|
||||
#else
|
||||
int dimensionID = Arrays.stream(DimensionManager.getDimensions(levelID)).findFirst().orElse(0); //TODO Maybe 1.12 should use the dimension number as the level key instead?
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
WorldServer level = MINECRAFT.getIntegratedServer().getWorld(dimensionID);
|
||||
#else
|
||||
ServerLevel level = MINECRAFT.getSingleplayerServer().getLevel(resourceKey);
|
||||
#endif
|
||||
return ServerLevelWrapper.getWrapper(level);
|
||||
}
|
||||
|
||||
|
||||
+27
-7
@@ -3,13 +3,21 @@ package com.seibel.distanthorizons.common.wrappers.minecraft;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
#if MC_VER <= MC_1_21_10
|
||||
#if MC_VER > MC_1_12_2
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
#else
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
#elif MC_VER <= MC_1_21_10
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
#else
|
||||
import net.minecraft.resources.Identifier;
|
||||
@@ -17,11 +25,12 @@ import net.minecraft.resources.Identifier;
|
||||
|
||||
#if MC_VER > MC_1_19_2
|
||||
import net.minecraft.core.registries.Registries;
|
||||
#else
|
||||
#elif MC_VER > MC_1_12_2
|
||||
import net.minecraft.core.Registry;
|
||||
#endif
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class MinecraftServerWrapper implements IMinecraftSharedWrapper
|
||||
{
|
||||
@@ -85,7 +94,12 @@ public class MinecraftServerWrapper implements IMinecraftSharedWrapper
|
||||
@Override
|
||||
public IServerLevelWrapper getWrappedServerLevel(String levelKey)
|
||||
{
|
||||
#if MC_VER <= MC_1_21_10
|
||||
#if MC_VER <= MC_1_12_2
|
||||
DimensionType levelID = null;
|
||||
try {
|
||||
levelID = DimensionType.byName(levelKey);
|
||||
} catch (IllegalArgumentException e) {}
|
||||
#elif MC_VER <= MC_1_21_10
|
||||
ResourceLocation levelID = ResourceLocation.tryParse(levelKey);
|
||||
#else
|
||||
Identifier levelID = Identifier.tryParse(levelKey);
|
||||
@@ -94,11 +108,17 @@ public class MinecraftServerWrapper implements IMinecraftSharedWrapper
|
||||
|
||||
#if MC_VER > MC_1_19_2
|
||||
ResourceKey<Level> resourceKey = ResourceKey.create(Registries.DIMENSION, levelID);
|
||||
#else
|
||||
#elif MC_VER > MC_1_12_2
|
||||
ResourceKey<Level> resourceKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, levelID);
|
||||
#else
|
||||
int dimensionID = Arrays.stream(DimensionManager.getDimensions(levelID)).findFirst().orElse(0);
|
||||
#endif
|
||||
|
||||
#if MC_VER > MC_1_12_2
|
||||
ServerLevel level = dedicatedServer.getLevel(resourceKey);
|
||||
#else
|
||||
WorldServer level = dedicatedServer.getWorld(dimensionID);
|
||||
#endif
|
||||
return ServerLevelWrapper.getWrapper(level);
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.common.wrappers.modAccessor;
|
||||
|
||||
#if MC_VER > MC_1_12_2
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
@@ -131,3 +131,5 @@ public abstract class ImmersivePortalsAccessorCommon extends ImmersivePortalsAbs
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+7
-3
@@ -152,9 +152,13 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
}
|
||||
}
|
||||
|
||||
private static #if MC_VER > MC_1_12_2 ClientLevel #else WorldClient #endif clientLevel() {
|
||||
return #if MC_VER > MC_1_12_2 MINECRAFT.level #else MINECRAFT.world #endif;
|
||||
}
|
||||
|
||||
public static void tickCleanup()
|
||||
{
|
||||
if (MINECRAFT.level == null)
|
||||
if (clientLevel() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -169,7 +173,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
{
|
||||
ClientLevelWrapper wrapper = ref.get();
|
||||
if (wrapper != null
|
||||
&& wrapper.level != MINECRAFT.level)
|
||||
&& wrapper.level != clientLevel())
|
||||
{
|
||||
// We use the synchronized getter to prevent race conditions with markAccessed()
|
||||
if (currentTime - wrapper.getLastAccessTime() > timeout)
|
||||
@@ -186,7 +190,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
// to ensure atomicity with respect to markAccessed()
|
||||
synchronized(wrapper)
|
||||
{
|
||||
if (wrapper.level != MINECRAFT.level
|
||||
if (wrapper.level != clientLevel()
|
||||
&& currentTime - wrapper.getLastAccessTime() > timeout)
|
||||
{
|
||||
LOGGER.debug("Unloading level [" + wrapper.getDhIdentifier() + "] due to inactivity");
|
||||
|
||||
+1
-1
Submodule coreSubProjects updated: 592b050937...1908a0ccbf
Reference in New Issue
Block a user