diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java index 8ce60f9a7..5d6268da4 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java @@ -94,8 +94,8 @@ public class WrapperFactory implements IWrapperFactory } } - // MC 1.18, 1.19, 1.20 - #if POST_MC_1_17_1 + // MC 1.16, 1.18, 1.19, 1.20 + #if POST_MC_1_17_1 || MC_1_16_5 else if (objectArray.length == 2) { // correct number of parameters from the API @@ -143,8 +143,8 @@ public class WrapperFactory implements IWrapperFactory "Chunk wrapper creation failed. \n" + "Expected parameters: \n"); - // MC 1.18, 1.19, 1.20 - #if POST_MC_1_17_1 + // MC 1.16, 1.18, 1.19, 1.20 + #if POST_MC_1_17_1 || MC_1_16_5 message.append("["+ChunkAccess.class.getName()+"], \n"); message.append("["+LevelReader.class.getName()+"]. \n"); #else diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java index 7ad737834..42f93c439 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java @@ -152,16 +152,16 @@ public class ChunkWrapper implements IChunkWrapper //if (wrappedLevel != null) return wrappedLevel.getBiome(new DhBlockPos(x + getMinX(), y, z + getMinZ())); #if PRE_MC_1_17_1 - return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome( - x >> 2, y >> 2, z >> 2)); + return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome( + relX >> 2, relY >> 2, relZ >> 2)); #elif PRE_MC_1_18_2 - return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome( - QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z))); + return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome( + QuartPos.fromBlock(relX), QuartPos.fromBlock(relY), QuartPos.fromBlock(relZ))); #elif PRE_MC_1_18_2 - return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome( - QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z))); + return BiomeWrapper.getBiomeWrapper(this.chunk.getNoiseBiome( + QuartPos.fromBlock(relX), QuartPos.fromBlock(relY), QuartPos.fromBlock(relZ))); #else //Now returns a Holder instead of Biome - return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome( + return BiomeWrapper.getBiomeWrapper(this.chunk.getNoiseBiome( QuartPos.fromBlock(relX), QuartPos.fromBlock(relY), QuartPos.fromBlock(relZ))); #endif } @@ -369,7 +369,8 @@ public class ChunkWrapper implements IChunkWrapper #endif // Should be called after client light updates are triggered. - private static boolean updateClientLightReady(ChunkAccess chunk, boolean oldValue) { + private static boolean updateClientLightReady(ChunkAccess chunk, boolean oldValue) + { if (chunk instanceof LevelChunk && ((LevelChunk)chunk).getLevel() instanceof ClientLevel) { LevelChunk levelChunk = (LevelChunk)chunk; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/ThreadedParameters.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/ThreadedParameters.java index 73e087202..5984cf514 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/ThreadedParameters.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/ThreadedParameters.java @@ -88,7 +88,7 @@ public final class ThreadedParameters } - #if PRE_MC_1_19_2 + #if POST_MC_1_18_2 public void recreateStructureCheck() { if (previousGlobalParameters != null) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java index 29aa8453d..91b14cac6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java @@ -14,23 +14,28 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.concurrent.ConcurrentLinkedQueue; -public class RegionFileStorageExternalCache implements AutoCloseable { +public class RegionFileStorageExternalCache implements AutoCloseable +{ public final RegionFileStorage storage; public static final int MAX_CACHE_SIZE = 16; @Override - public void close() throws IOException { + public void close() throws IOException + { RegionFileCache cache; - while ((cache = regionFileCache.poll()) != null) { + while ((cache = this.regionFileCache.poll()) != null) + { cache.file.close(); } } - static class RegionFileCache { + static class RegionFileCache + { public final long pos; public final RegionFile file; - public RegionFileCache(long pos, RegionFile file) { + public RegionFileCache(long pos, RegionFile file) + { this.pos = pos; this.file = file; } @@ -38,9 +43,7 @@ public class RegionFileStorageExternalCache implements AutoCloseable { public ConcurrentLinkedQueue regionFileCache = new ConcurrentLinkedQueue<>(); - public RegionFileStorageExternalCache(RegionFileStorage storage) { - this.storage = storage; - } + public RegionFileStorageExternalCache(RegionFileStorage storage) { this.storage = storage; } @Nullable public RegionFile getRegionFile(ChunkPos pos) throws IOException @@ -53,7 +56,12 @@ public class RegionFileStorageExternalCache implements AutoCloseable { { try { - rFile = this.storage.regionCache.getOrDefault(posLong, null); + #if MC_1_16_5 + rFile = this.storage.getRegionFile(pos); + #else + rFile = this.storage.regionCache.getOrDefault(posLong, null); + #endif + break; } catch (ArrayIndexOutOfBoundsException e) @@ -77,18 +85,29 @@ public class RegionFileStorageExternalCache implements AutoCloseable { } // Otherwise, check if file exist, and if so, add it to the cache - Path p = storage.folder; - if (!Files.exists(p)) + Path storageFolderPath; + #if MC_1_16_5 + storageFolderPath = this.storage.folder.toPath(); + #else + storageFolderPath = this.storage.folder; + #endif + + if (!Files.exists(storageFolderPath)) { return null; } - Path rFilePath = p.resolve("r." + pos.getRegionX() + "." + pos.getRegionZ() + ".mca"); - rFile = new RegionFile(rFilePath, p, false); - regionFileCache.add(new RegionFileCache(ChunkPos.asLong(pos.getRegionX(), pos.getRegionZ()), rFile)); - while (regionFileCache.size() > MAX_CACHE_SIZE) + Path regionFilePath = storageFolderPath.resolve("r." + pos.getRegionX() + "." + pos.getRegionZ() + ".mca"); + #if MC_1_16_5 + rFile = new RegionFile(regionFilePath.toFile(), storageFolderPath.toFile(), false); + #else + rFile = new RegionFile(regionFilePath, storageFolderPath, false); + #endif + + this.regionFileCache.add(new RegionFileCache(ChunkPos.asLong(pos.getRegionX(), pos.getRegionZ()), rFile)); + while (this.regionFileCache.size() > MAX_CACHE_SIZE) { - regionFileCache.poll().file.close(); + this.regionFileCache.poll().file.close(); } return rFile; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java index dbf5a0a86..9521cd0c5 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java @@ -50,13 +50,17 @@ import net.minecraft.world.level.StructureManager; #if POST_MC_1_18_2 import net.minecraft.world.level.levelgen.structure.StructureCheck; #endif + import net.minecraft.world.level.levelgen.structure.StructureStart; -#if PRE_MC_1_19_2 -public class WorldGenStructFeatManager extends StructureFeatureManager { -#else -public class WorldGenStructFeatManager extends StructureManager { - #endif +#if PRE_MC_1_18_2 +import net.minecraft.world.level.levelgen.feature.StructureFeature; +#endif + + + +public class WorldGenStructFeatManager extends #if PRE_MC_1_19_2 StructureFeatureManager #else StructureManager #endif +{ final WorldGenLevel genLevel; #if PRE_MC_1_19_4 diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepLight.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepLight.java index 5c2a28f95..07f71e661 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepLight.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepLight.java @@ -29,7 +29,11 @@ import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.ProtoChunk; +#if PRE_MC_1_17_1 +import net.minecraft.world.level.lighting.LevelLightEngine; +#else import net.minecraft.world.level.lighting.LightEventListener; +#endif public final class StepLight { /** diff --git a/common/src/main/resources/1_16.distanthorizons.accesswidener b/common/src/main/resources/1_16.distanthorizons.accesswidener index b545945d5..54b5f8f63 100644 --- a/common/src/main/resources/1_16.distanthorizons.accesswidener +++ b/common/src/main/resources/1_16.distanthorizons.accesswidener @@ -35,6 +35,10 @@ accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSecti # lod generation from save file accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/minecraft/util/thread/BlockableEventLoop; accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag; +accessible method net/minecraft/world/level/chunk/storage/RegionFileStorage getRegionFile (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/storage/RegionFile; +accessible field net/minecraft/world/level/chunk/storage/RegionFileStorage folder Ljava/io/File; +accessible field net/minecraft/world/level/chunk/storage/ChunkStorage worker Lnet/minecraft/world/level/chunk/storage/IOWorker; +accessible field net/minecraft/world/level/chunk/storage/IOWorker storage Lnet/minecraft/world/level/chunk/storage/RegionFileStorage; # grabbing textures accessible field net/minecraft/client/renderer/block/model/BakedQuad sprite Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;