Fix compiling for older MC versions
This commit is contained in:
+5
@@ -33,9 +33,14 @@ import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
#if MC_VER >= MC_1_18_2
|
||||
import net.minecraft.world.level.chunk.storage.ChunkScanAccess;
|
||||
#endif
|
||||
|
||||
#if MC_VER < MC_1_19_2
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
#elif MC_VER < MC_1_19_2
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
#else
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
||||
#endif
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public final class ThreadWorldGenParams
|
||||
this.level = param.level;
|
||||
|
||||
#if MC_VER < MC_1_18_2
|
||||
this.structFeat = new WorldGenStructFeatManager(param.worldGenSettings, this.level);
|
||||
this.structFeatManager = new WorldGenStructFeatManager(param.worldGenSettings, this.level);
|
||||
#elif MC_VER < MC_1_19_2
|
||||
this.structCheck = this.createStructureCheck(param);
|
||||
#else
|
||||
|
||||
+22
-11
@@ -20,6 +20,7 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
@@ -56,6 +57,11 @@ import net.minecraft.world.level.chunk.storage.ChunkSerializer;
|
||||
#else
|
||||
#endif
|
||||
|
||||
#if MC_VER < MC_1_21_9
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
#else
|
||||
#endif
|
||||
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
#if MC_VER >= MC_1_18_2
|
||||
import net.minecraft.world.level.levelgen.blending.BlendingData;
|
||||
@@ -168,7 +174,7 @@ public class ChunkCompoundTagParser
|
||||
{
|
||||
return null;
|
||||
}
|
||||
#elif MC_VER < MC_1_19_2
|
||||
#elif MC_VER < MC_1_20_6
|
||||
if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK)
|
||||
{
|
||||
return null;
|
||||
@@ -376,7 +382,7 @@ public class ChunkCompoundTagParser
|
||||
|
||||
Registry<Biome> biomeRegistry = getBiomeRegistry(level);
|
||||
|
||||
#if MC_VER < MC_1_18_2
|
||||
#if MC_VER < MC_1_19_2
|
||||
Codec<PalettedContainer<Biome>> biomeCodec;
|
||||
#else
|
||||
Codec<PalettedContainer<Holder<Biome>>> biomeCodec;
|
||||
@@ -401,12 +407,13 @@ public class ChunkCompoundTagParser
|
||||
biomeTag = CompoundTagUtil.getCompoundTag(tagSection, "biomes");
|
||||
}
|
||||
|
||||
if (biomeTag != null)
|
||||
if (biomeTag != null
|
||||
&& !biomeTag.isEmpty())
|
||||
{
|
||||
#if MC_VER < MC_1_20_6
|
||||
biomeContainer = biomeCodec.parse(NbtOps.INSTANCE, biomeTag)
|
||||
.promotePartial(string -> logBiomeDeserializationWarning(chunkPos, sectionYIndex, (String) string))
|
||||
.getOrThrow(false, (message) -> logParsingWarningOnce(message));
|
||||
#if MC_VER < MC_1_20_6
|
||||
biomeContainer = new PalettedContainer<Holder<Biome>>(
|
||||
biomeRegistry.asHolderIdMap(),
|
||||
biomeRegistry.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES);
|
||||
#else
|
||||
biomeContainer = biomeCodec.parse(NbtOps.INSTANCE, biomeTag)
|
||||
.promotePartial(string -> logBiomeDeserializationWarning(chunkPos, sectionYIndex, (String) string))
|
||||
@@ -448,9 +455,11 @@ public class ChunkCompoundTagParser
|
||||
|
||||
private static Codec<PalettedContainer<BlockState>> getBlockStateCodec(LevelAccessor level)
|
||||
{
|
||||
#if MC_VER <= MC_1_18_2
|
||||
#if MC_VER < MC_1_18_2
|
||||
return null; // unused for older MC versions
|
||||
#elif MC_VER < MC_1_19_2
|
||||
return PalettedContainer.codec(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState());
|
||||
#elif MC_VER <= MC_1_19_2
|
||||
#elif MC_VER <= MC_1_21_8
|
||||
return PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState());
|
||||
#else
|
||||
return PalettedContainerFactory.create(level.registryAccess()).blockStatesContainerCodec();
|
||||
@@ -471,13 +480,15 @@ public class ChunkCompoundTagParser
|
||||
#endif
|
||||
}
|
||||
private static
|
||||
#if MC_VER < MC_1_18_2 Codec<PalettedContainer<Biome>>
|
||||
#if MC_VER < MC_1_19_2 Codec<PalettedContainer<Biome>>
|
||||
#else Codec<PalettedContainer<Holder<Biome>>>
|
||||
#endif
|
||||
getBiomeCodec(LevelAccessor level, Registry<Biome> biomeRegistry)
|
||||
{
|
||||
#if MC_VER < MC_1_18_2
|
||||
Codec<PalettedContainer<Biome>> biomeCodec = PalettedContainer.codec(
|
||||
return null; // unused for older MC versions
|
||||
#elif MC_VER < MC_1_19_2
|
||||
return PalettedContainer.codec(
|
||||
biomeRegistry, biomeRegistry.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomeRegistry.getOrThrow(Biomes.PLAINS));
|
||||
#elif MC_VER < MC_1_19_2
|
||||
return PalettedContainer.codec(
|
||||
|
||||
+21
-2
@@ -11,16 +11,16 @@ import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.ChunkLightStorage;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.PalettedContainerFactory;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.chunk.UpgradeData;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.storage.IOWorker;
|
||||
import net.minecraft.world.level.chunk.storage.RegionFileStorage;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -31,6 +31,25 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
#if MC_VER <= MC_1_17_1
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
#elif MC_VER <= MC_1_19_2
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.core.Registry;
|
||||
#elif MC_VER <= MC_1_19_4
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
#elif MC_VER <= MC_1_20_6
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
#elif MC_VER <= MC_1_21_10
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
#else
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.PalettedContainerFactory;
|
||||
#endif
|
||||
|
||||
public class ChunkFileReader implements AutoCloseable
|
||||
{
|
||||
|
||||
|
||||
+9
-4
@@ -23,7 +23,12 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.TicketType;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
|
||||
#if MC_VER <= MC_1_20_4
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
#else
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
#endif
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -220,7 +225,7 @@ public class InternalServerGenerator
|
||||
|
||||
#if MC_VER < MC_1_21_5
|
||||
int chunkLevel = 33; // 33 is equivalent to FULL Chunk
|
||||
level.getChunkSource().distanceManager.addTicket(DH_SERVER_GEN_TICKET, pos, chunkLevel, pos);
|
||||
level.getChunkSource().distanceManager.addTicket(DH_SERVER_GEN_TICKET, chunkPos, chunkLevel, chunkPos);
|
||||
#else
|
||||
level.getChunkSource().addTicketWithRadius(DH_SERVER_GEN_TICKET, chunkPos, 0);
|
||||
#endif
|
||||
@@ -235,13 +240,13 @@ public class InternalServerGenerator
|
||||
}
|
||||
|
||||
#if MC_VER <= MC_1_20_4
|
||||
return chunkHolder.getOrScheduleFuture(ChunkStatus.FEATURES, level.getChunkSource().chunkMap)
|
||||
return chunkHolder.getOrScheduleFuture(ChunkStatus.FULL, level.getChunkSource().chunkMap)
|
||||
.thenApply(result -> result.left().orElseThrow(() -> new RuntimeException(result.right().get().toString()))); // can throw if the server is shutting down
|
||||
#elif MC_VER <= MC_1_20_6
|
||||
return chunkHolder.getOrScheduleFuture(ChunkStatus.FEATURES, level.getChunkSource().chunkMap)
|
||||
return chunkHolder.getOrScheduleFuture(ChunkStatus.FULL, level.getChunkSource().chunkMap)
|
||||
.thenApply(result -> result.orElseThrow(() -> new RuntimeException(result.toString()))); // can throw if the server is shutting down
|
||||
#else
|
||||
return chunkHolder.scheduleChunkGenerationTask(ChunkStatus.FEATURES, level.getChunkSource().chunkMap)
|
||||
return chunkHolder.scheduleChunkGenerationTask(ChunkStatus.FULL, level.getChunkSource().chunkMap)
|
||||
.thenApply(result -> result.orElseThrow(() -> new RuntimeException(result.getError()))); // can throw if the server is shutting down
|
||||
#endif
|
||||
|
||||
|
||||
+11
-11
@@ -74,32 +74,32 @@ public final class StepBiomes extends AbstractWorldGenStep
|
||||
|
||||
|
||||
#if MC_VER < MC_1_18_2
|
||||
this.environment.params.generator.createBiomes(this.environment.params.biomes, chunk);
|
||||
this.environment.globalParams.generator.createBiomes(this.environment.globalParams.biomes, chunk);
|
||||
#elif MC_VER < MC_1_19_2
|
||||
chunk = this.environment.confirmFutureWasRunSynchronously(
|
||||
this.environment.params.generator.createBiomes(
|
||||
this.environment.params.biomes,
|
||||
this.environment.globalParams.generator.createBiomes(
|
||||
this.environment.globalParams.biomes,
|
||||
Runnable::run,
|
||||
Blender.of(worldGenRegion),
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion),
|
||||
tParams.structFeatManager.forWorldGenRegion(worldGenRegion),
|
||||
chunk)
|
||||
);
|
||||
#elif MC_VER < MC_1_19_4
|
||||
chunk = this.environment.confirmFutureWasRunSynchronously(
|
||||
this.environment.params.generator.createBiomes(
|
||||
this.environment.params.biomes,
|
||||
this.environment.globalParams.generator.createBiomes(
|
||||
this.environment.globalParams.biomes,
|
||||
Runnable::run,
|
||||
this.environment.params.randomState, Blender.of(worldGenRegion),
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion),
|
||||
this.environment.globalParams.randomState, Blender.of(worldGenRegion),
|
||||
tParams.structFeatManager.forWorldGenRegion(worldGenRegion),
|
||||
chunk)
|
||||
);
|
||||
#elif MC_VER < MC_1_21_1
|
||||
chunk = this.environment.confirmFutureWasRunSynchronously(
|
||||
this.environment.params.generator.createBiomes(
|
||||
this.environment.globalParams.generator.createBiomes(
|
||||
Runnable::run,
|
||||
this.environment.params.randomState,
|
||||
this.environment.globalParams.randomState,
|
||||
Blender.of(worldGenRegion),
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion),
|
||||
tParams.structFeatManager.forWorldGenRegion(worldGenRegion),
|
||||
chunk)
|
||||
);
|
||||
#else
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ public final class StepFeatures extends AbstractWorldGenStep
|
||||
{
|
||||
#if MC_VER < MC_1_18_2
|
||||
worldGenRegion.setOverrideCenter(chunk.getPos());
|
||||
environment.params.generator.applyBiomeDecoration(worldGenRegion, tParams.structFeat);
|
||||
environment.globalParams.generator.applyBiomeDecoration(worldGenRegion, tParams.structFeatManager);
|
||||
#else
|
||||
if (worldGenRegion.hasChunk(chunkWrapper.getChunkPos().getX(), chunkWrapper.getChunkPos().getZ()))
|
||||
{
|
||||
|
||||
+8
-8
@@ -73,27 +73,27 @@ public final class StepNoise extends AbstractWorldGenStep
|
||||
ChunkAccess chunk = chunkWrapper.getChunk();
|
||||
|
||||
#if MC_VER < MC_1_17_1
|
||||
this.environment.params.generator.fillFromNoise(worldGenRegion, tParams.structFeat, chunk);
|
||||
this.environment.globalParams.generator.fillFromNoise(worldGenRegion, tParams.structFeatManager, chunk);
|
||||
#elif MC_VER < MC_1_18_2
|
||||
chunk = this.environment.confirmFutureWasRunSynchronously(
|
||||
this.environment.params.generator.fillFromNoise(
|
||||
this.environment.globalParams.generator.fillFromNoise(
|
||||
Runnable::run,
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion),
|
||||
tParams.structFeatManager.forWorldGenRegion(worldGenRegion),
|
||||
chunk));
|
||||
#elif MC_VER < MC_1_19_2
|
||||
chunk = this.environment.confirmFutureWasRunSynchronously(
|
||||
this.environment.params.generator.fillFromNoise(
|
||||
this.environment.globalParams.generator.fillFromNoise(
|
||||
Runnable::run,
|
||||
Blender.of(worldGenRegion),
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion),
|
||||
tParams.structFeatManager.forWorldGenRegion(worldGenRegion),
|
||||
chunk));
|
||||
#elif MC_VER < MC_1_21_1
|
||||
chunk = this.environment.confirmFutureWasRunSynchronously(
|
||||
this.environment.params.generator.fillFromNoise(
|
||||
this.environment.globalParams.generator.fillFromNoise(
|
||||
Runnable::run,
|
||||
Blender.of(worldGenRegion),
|
||||
this.environment.params.randomState,
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion),
|
||||
this.environment.globalParams.randomState,
|
||||
tParams.structFeatManager.forWorldGenRegion(worldGenRegion),
|
||||
chunk));
|
||||
#else
|
||||
chunk = this.environment.confirmFutureWasRunSynchronously(
|
||||
|
||||
+9
-9
@@ -74,9 +74,9 @@ public final class StepStructureStart extends AbstractWorldGenStep
|
||||
// TODO should be put in wrapped environment so we can skip some other world gen steps
|
||||
// SURFACE wouldn't need structure generation either
|
||||
#if MC_VER < MC_1_19_2
|
||||
if (!this.environment.params.worldGenSettings.generateFeatures())
|
||||
if (!this.environment.globalParams.worldGenSettings.generateFeatures())
|
||||
#elif MC_VER < MC_1_19_4
|
||||
if (!this.environment.params.worldGenSettings.generateStructures())
|
||||
if (!this.environment.globalParams.worldGenSettings.generateStructures())
|
||||
#else
|
||||
if (!this.environment.globalParams.worldOptions.generateStructures())
|
||||
#endif
|
||||
@@ -95,15 +95,15 @@ public final class StepStructureStart extends AbstractWorldGenStep
|
||||
STRUCTURE_PLACEMENT_LOCK.lock();
|
||||
|
||||
#if MC_VER < MC_1_19_2
|
||||
this.environment.params.generator.createStructures(this.environment.params.registry, tParams.structFeat, chunk, this.environment.params.structures,
|
||||
this.environment.params.worldSeed);
|
||||
this.environment.globalParams.generator.createStructures(this.environment.globalParams.registry, tParams.structFeatManager, chunk, this.environment.globalParams.structures,
|
||||
this.environment.globalParams.worldSeed);
|
||||
#elif MC_VER < MC_1_19_4
|
||||
this.environment.params.generator.createStructures(this.environment.params.registry, this.environment.params.randomState, tParams.structFeat, chunk, this.environment.params.structures,
|
||||
this.environment.params.worldSeed);
|
||||
this.environment.globalParams.generator.createStructures(this.environment.globalParams.registry, this.environment.globalParams.randomState, tParams.structFeatManager, chunk, this.environment.globalParams.structures,
|
||||
this.environment.globalParams.worldSeed);
|
||||
#elif MC_VER <= MC_1_21_3
|
||||
this.environment.params.generator.createStructures(this.environment.params.registry,
|
||||
this.environment.params.level.getChunkSource().getGeneratorState(),
|
||||
tParams.structFeat, chunk, this.environment.params.structures);
|
||||
this.environment.globalParams.generator.createStructures(this.environment.globalParams.registry,
|
||||
this.environment.globalParams.level.getChunkSource().getGeneratorState(),
|
||||
tParams.structFeatManager, chunk, this.environment.globalParams.structures);
|
||||
#else
|
||||
this.environment.globalParams.generator.createStructures(this.environment.globalParams.registry,
|
||||
this.environment.globalParams.level.getChunkSource().getGeneratorState(),
|
||||
|
||||
+2
-2
@@ -70,9 +70,9 @@ public final class StepSurface extends AbstractWorldGenStep
|
||||
ChunkAccess chunk = chunkWrapper.getChunk();
|
||||
|
||||
#if MC_VER < MC_1_18_2
|
||||
this.environment.params.generator.buildSurfaceAndBedrock(worldGenRegion, chunk);
|
||||
this.environment.globalParams.generator.buildSurfaceAndBedrock(worldGenRegion, chunk);
|
||||
#elif MC_VER < MC_1_19_2
|
||||
this.environment.params.generator.buildSurface(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
|
||||
this.environment.globalParams.generator.buildSurface(worldGenRegion, tParams.structFeatManager.forWorldGenRegion(worldGenRegion), chunk);
|
||||
#else
|
||||
this.environment.globalParams.generator.buildSurface(worldGenRegion, tParams.structFeatManager.forWorldGenRegion(worldGenRegion), this.environment.globalParams.randomState, chunk);
|
||||
#endif
|
||||
|
||||
+9
@@ -25,6 +25,15 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import net.minecraft.Util;
|
||||
|
||||
#if MC_VER < MC_1_21_3
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.function.Supplier;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is needed for DH's world gen so we can run
|
||||
* world gen on our own threads instead of using MC thread pools.
|
||||
|
||||
Reference in New Issue
Block a user