refactoring and cleanup
This commit is contained in:
+3
-1
@@ -63,7 +63,7 @@ public class McObjectConverter
|
|||||||
FloatBuffer buffer = FloatBuffer.allocate(16);
|
FloatBuffer buffer = FloatBuffer.allocate(16);
|
||||||
storeMatrix(mcMatrix, buffer);
|
storeMatrix(mcMatrix, buffer);
|
||||||
Mat4f matrix = new Mat4f(buffer);
|
Mat4f matrix = new Mat4f(buffer);
|
||||||
#if MC_VER < MC_1_19_4 && MC_VER > MC_1_12_2
|
#if MC_VER > MC_1_12_2 && MC_VER < MC_1_19_4
|
||||||
matrix.transpose(); // In 1.19.3 and later, we no longer need to transpose it
|
matrix.transpose(); // In 1.19.3 and later, we no longer need to transpose it
|
||||||
#endif
|
#endif
|
||||||
return matrix;
|
return matrix;
|
||||||
@@ -109,7 +109,9 @@ public class McObjectConverter
|
|||||||
static
|
static
|
||||||
{
|
{
|
||||||
EDhDirection[] lodDirs = EDhDirection.values();
|
EDhDirection[] lodDirs = EDhDirection.values();
|
||||||
|
|
||||||
directions = new #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[lodDirs.length];
|
directions = new #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[lodDirs.length];
|
||||||
|
|
||||||
lodDirections = new EDhDirection[lodDirs.length];
|
lodDirections = new EDhDirection[lodDirs.length];
|
||||||
for (EDhDirection lodDir : lodDirs)
|
for (EDhDirection lodDir : lodDirs)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
@@ -170,6 +170,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
#else
|
#else
|
||||||
super.init();
|
super.init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!this.reload)
|
if (!this.reload)
|
||||||
{
|
{
|
||||||
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
||||||
|
|||||||
+10
-3
@@ -143,8 +143,13 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif;
|
#if MC_VER <= MC_1_12_2
|
||||||
return (server != null) ? server.#if MC_VER <= MC_1_12_2 serverName #else name #endif : "NULL";
|
ServerData server = MINECRAFT.getCurrentServerData();
|
||||||
|
return (server != null) ? server.serverName : "NULL";
|
||||||
|
#else
|
||||||
|
ServerData server = MINECRAFT.getCurrentServer();
|
||||||
|
return (server != null) ? server.name : "NULL";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@@ -382,11 +387,13 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
|
|
||||||
public void disableVanillaChunkFadeIn()
|
public void disableVanillaChunkFadeIn()
|
||||||
{
|
{
|
||||||
LOGGER.info("Disabling vanilla chunk fade in... This is done to prevent vanilla chunks from flashing on the Distant Horizons boarder when moving (which is distracting).");
|
String message = "Disabling vanilla chunk fade in... This is done to prevent vanilla chunks from flashing on the Distant Horizons boarder when moving (which is distracting).";
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10
|
||||||
// chunk fade in was added MC 1.21.11
|
// chunk fade in was added MC 1.21.11
|
||||||
#else
|
#else
|
||||||
|
LOGGER.info(message);
|
||||||
|
|
||||||
MINECRAFT.options.chunkSectionFadeInTime().set(0.0);
|
MINECRAFT.options.chunkSectionFadeInTime().set(0.0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-14
@@ -173,26 +173,27 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
else if (MC.player.getActivePotionMap() == null)
|
if (MC.player.getActivePotionMap() == null)
|
||||||
#else
|
|
||||||
else if (MC.player.getActiveEffectsMap() == null)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return MC.player.getActivePotionEffect(MobEffects.BLINDNESS) != null;
|
||||||
|
#else
|
||||||
|
if (MC.player.getActiveEffectsMap() == null)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
return false;
|
||||||
return MC.player.getActivePotionEffect(MobEffects.BLINDNESS) != null;
|
|
||||||
#else
|
|
||||||
return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null
|
|
||||||
#if MC_VER >= MC_1_19_2
|
|
||||||
|| MC.player.getActiveEffectsMap().get(MobEffects.DARKNESS) != null // Deep dark effect
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null
|
||||||
|
#if MC_VER >= MC_1_19_2
|
||||||
|
|| MC.player.getActiveEffectsMap().get(MobEffects.DARKNESS) != null // Deep dark effect
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+4
@@ -35,6 +35,8 @@ public class ProfilerWrapper implements IProfilerWrapper
|
|||||||
public ProfilerFiller profiler;
|
public ProfilerFiller profiler;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
public ProfilerWrapper(Profiler newProfiler)
|
public ProfilerWrapper(Profiler newProfiler)
|
||||||
#else
|
#else
|
||||||
@@ -42,6 +44,8 @@ public class ProfilerWrapper implements IProfilerWrapper
|
|||||||
#endif
|
#endif
|
||||||
{ this.profiler = newProfiler; }
|
{ this.profiler = newProfiler; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IProfileBlock push(String newSection)
|
public IProfileBlock push(String newSection)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
@@ -107,6 +107,7 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper
|
|||||||
#else
|
#else
|
||||||
ServerLevel level = ((IMixinServerPlayer) this.getServerPlayer()).distantHorizons$getDimensionChangeDestination();
|
ServerLevel level = ((IMixinServerPlayer) this.getServerPlayer()).distantHorizons$getDimensionChangeDestination();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (level == null)
|
if (level == null)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
|
|||||||
+44
-12
@@ -6,6 +6,7 @@ import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
|
|||||||
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.block.ClientBlockStateColorCache;
|
import com.seibel.distanthorizons.common.wrappers.block.ClientBlockStateColorCache;
|
||||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.level.*;
|
import com.seibel.distanthorizons.core.level.*;
|
||||||
@@ -76,17 +77,31 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
* where, upon world closure, some levels aren't shutdown/removed properly
|
* where, upon world closure, some levels aren't shutdown/removed properly
|
||||||
* and/or for servers were the level object isn't consistent
|
* and/or for servers were the level object isn't consistent
|
||||||
*/
|
*/
|
||||||
private static final Map<#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif, WeakReference<ClientLevelWrapper>> LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL = Collections.synchronizedMap(new WeakHashMap<>());
|
private static final Map<
|
||||||
|
#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif,
|
||||||
|
WeakReference<ClientLevelWrapper>> LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL = Collections.synchronizedMap(new WeakHashMap<>());
|
||||||
private static final IKeyedClientLevelManager KEYED_CLIENT_LEVEL_MANAGER = SingletonInjector.INSTANCE.get(IKeyedClientLevelManager.class);
|
private static final IKeyedClientLevelManager KEYED_CLIENT_LEVEL_MANAGER = SingletonInjector.INSTANCE.get(IKeyedClientLevelManager.class);
|
||||||
|
|
||||||
private static final Minecraft MINECRAFT = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif;
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private static final Minecraft MINECRAFT = Minecraft.getMinecraft();
|
||||||
|
#else
|
||||||
|
private static final Minecraft MINECRAFT = Minecraft.getInstance();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private final WorldClient level;
|
||||||
|
private final ConcurrentHashMap<IBlockState, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>();
|
||||||
|
#else
|
||||||
|
private final ClientLevel level;
|
||||||
|
private final ConcurrentHashMap<BlockState, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>();
|
||||||
|
#endif
|
||||||
|
|
||||||
private final #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level;
|
|
||||||
private final ConcurrentHashMap<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
/** cached method reference to reduce GC overhead */
|
/** cached method reference to reduce GC overhead */
|
||||||
private final Function<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> createCachedBlockColorCacheFunc
|
private final Function<
|
||||||
= (blockState) -> new ClientBlockStateColorCache(blockState, this);
|
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif,
|
||||||
|
ClientBlockStateColorCache> createCachedBlockColorCacheFunc
|
||||||
|
= (blockState) -> new ClientBlockStateColorCache(blockState, this);
|
||||||
|
|
||||||
|
|
||||||
private boolean cloudColorFailLogged = false;
|
private boolean cloudColorFailLogged = false;
|
||||||
@@ -117,7 +132,9 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
* IE rendering.
|
* IE rendering.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static IClientLevelWrapper getWrapperIfDifferent(@Nullable IClientLevelWrapper levelWrapper, @NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level)
|
public static IClientLevelWrapper getWrapperIfDifferent(
|
||||||
|
@Nullable IClientLevelWrapper levelWrapper,
|
||||||
|
@NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level)
|
||||||
{
|
{
|
||||||
if (KEYED_CLIENT_LEVEL_MANAGER.isEnabled() && KEYED_CLIENT_LEVEL_MANAGER.getServerKeyedLevel() != levelWrapper)
|
if (KEYED_CLIENT_LEVEL_MANAGER.isEnabled() && KEYED_CLIENT_LEVEL_MANAGER.getServerKeyedLevel() != levelWrapper)
|
||||||
{
|
{
|
||||||
@@ -135,10 +152,13 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static IClientLevelWrapper getWrapper(@NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level) { return getWrapper(level, false); }
|
public static IClientLevelWrapper getWrapper(
|
||||||
|
@NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level)
|
||||||
|
{ return getWrapper(level, false); }
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static IClientLevelWrapper getWrapper(@Nullable #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level, boolean bypassLevelKeyManager)
|
public static IClientLevelWrapper getWrapper(
|
||||||
|
@Nullable #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level, boolean bypassLevelKeyManager)
|
||||||
{
|
{
|
||||||
if (!bypassLevelKeyManager)
|
if (!bypassLevelKeyManager)
|
||||||
{
|
{
|
||||||
@@ -197,7 +217,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
WorldServer[] serverLevels = MINECRAFT.getIntegratedServer().worlds;
|
WorldServer[] serverLevels = MINECRAFT.getIntegratedServer().worlds;
|
||||||
#else
|
#else
|
||||||
Iterable<#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif> serverLevels = MINECRAFT.getSingleplayerServer().getAllLevels();
|
Iterable<ServerLevel> serverLevels = MINECRAFT.getSingleplayerServer().getAllLevels();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// attempt to find the server level with the same dimension type
|
// attempt to find the server level with the same dimension type
|
||||||
@@ -457,10 +477,20 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
public Color getCloudColor(float tickDelta)
|
public Color getCloudColor(float tickDelta)
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_21_3
|
#if MC_VER < MC_1_21_3
|
||||||
#if MC_VER <= MC_1_12_2 Vec3d #else Vec3 #endif colorVec3 = null;
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
Vec3d colorVec3 = null;
|
||||||
|
#else
|
||||||
|
Vec3 colorVec3 = null;
|
||||||
|
#endif
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
colorVec3 = this.level.#if MC_VER <= MC_1_12_2 getCloudColour #else getCloudColor #endif (tickDelta);
|
#if MC_VER <= MC_1_12_2
|
||||||
|
colorVec3 = this.level.getCloudColour(tickDelta);
|
||||||
|
#else
|
||||||
|
colorVec3 = this.level.getCloudColor(tickDelta);
|
||||||
|
#endif
|
||||||
|
|
||||||
return new Color((float)colorVec3.x, (float)colorVec3.y, (float)colorVec3.z);
|
return new Color((float)colorVec3.x, (float)colorVec3.y, (float)colorVec3.z);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -544,4 +574,6 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -198,6 +198,7 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
this.updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.dhServerLevel.getServerLevelWrapper());
|
this.updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.dhServerLevel.getServerLevelWrapper());
|
||||||
this.globalParams = new GlobalWorldGenParams(dhServerLevel);
|
this.globalParams = new GlobalWorldGenParams(dhServerLevel);
|
||||||
this.internalServerGenerator = new InternalServerGenerator(this.globalParams, this.dhServerLevel);
|
this.internalServerGenerator = new InternalServerGenerator(this.globalParams, this.dhServerLevel);
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
#if MC_VER > MC_1_12_2
|
||||||
this.chunkFileReader = new ChunkFileReader(this.globalParams);
|
this.chunkFileReader = new ChunkFileReader(this.globalParams);
|
||||||
|
|
||||||
@@ -327,8 +328,11 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
//================//
|
//================//
|
||||||
// variable setup //
|
// variable setup //
|
||||||
//================//
|
//================//
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
|
// MC 1.12 can only run world gen on the main thread
|
||||||
this.internalServerGenerator.generateChunksViaInternalServer(genEvent);
|
this.internalServerGenerator.generateChunksViaInternalServer(genEvent);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
int borderSize = MAX_WORLD_GEN_CHUNK_BORDER_NEEDED;
|
int borderSize = MAX_WORLD_GEN_CHUNK_BORDER_NEEDED;
|
||||||
// genEvent.size - 1 converts the even width size to an odd number for MC compatability
|
// genEvent.size - 1 converts the even width size to an odd number for MC compatability
|
||||||
|
|||||||
Reference in New Issue
Block a user