From 5fa3e3cb7f0f8e85a875cd724a3a3dc4d31cbd15 Mon Sep 17 00:00:00 2001 From: coolGi2007 Date: Fri, 1 Apr 2022 17:26:43 +1030 Subject: [PATCH] Made new branch with 1.18 and 1.17 combined (still work in progress) --- .gitlab-ci.yml | 55 +++++--- 1.17.1.properties | 37 ++++++ 1.18.1.properties | 2 +- 1.18.2.properties | 2 +- Readme.md | 11 ++ build.gradle | 2 + .../block/TintGetterOverrideSmooth.java | 6 + .../common/wrappers/chunk/ChunkWrapper.java | 8 +- .../minecraft/MinecraftRenderWrapper.java | 22 +++- .../BatchGenerationEnvironment.java | 14 ++- .../worldGeneration/GlobalParameters.java | 10 ++ .../worldGeneration/ThreadedParameters.java | 15 +++ .../mimicObject/ChunkLoader.java | 119 ++++++++++++++---- .../mimicObject/LightedWorldGenRegion.java | 17 ++- .../mimicObject/WorldGenLevelLightEngine.java | 7 ++ .../WorldGenStructFeatManager.java | 43 ++++++- .../worldGeneration/step/StepBiomes.java | 6 + .../worldGeneration/step/StepFeatures.java | 10 +- .../worldGeneration/step/StepLight.java | 2 + .../worldGeneration/step/StepNoise.java | 7 ++ .../step/StepStructureStart.java | 3 + .../worldGeneration/step/StepSurface.java | 7 +- common/src/main/resources/lod.accesswidener | 11 +- gradle.properties | 2 +- 24 files changed, 360 insertions(+), 58 deletions(-) create mode 100644 1.17.1.properties diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4e51f20f9..f3f3f1b80 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,7 @@ image: gradle:eclipse-temurin stages: - build_18_1 - build_18_2 + - build_17_1 variables: # Pull core when building @@ -41,23 +42,43 @@ build_18_1: # 1.18.2 build build_18_2: - stage: build_18_2 - script: - - ./gradlew deleteMerged --gradle-user-home cache/; - - ./gradlew build -PmcVer=1.18.2 --gradle-user-home cache/; - - ./gradlew merge --gradle-user-home cache/; - image: eclipse-temurin:17 - artifacts: - name: "Merged_NightlyBuild_1_18_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" - paths: - - Merged - expire_in: 1 day - cache: - key: "gradleCache" - policy: pull-push - paths: - - .gradle - - cache/ + stage: build_18_2 + script: + - ./gradlew deleteMerged --gradle-user-home cache/; + - ./gradlew build -PmcVer=1.18.2 --gradle-user-home cache/; + - ./gradlew merge --gradle-user-home cache/; + image: eclipse-temurin:17 + artifacts: + name: "Merged_NightlyBuild_1_18_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" + paths: + - Merged + expire_in: 1 day + cache: + key: "gradleCache" + policy: pull-push + paths: + - .gradle + - cache/ + +# 1.17.1 build +build_17_1: + stage: build_17_1 + script: + - ./gradlew deleteMerged --gradle-user-home cache/; + - ./gradlew build -PmcVer=1.17.1 --gradle-user-home cache/; + - ./gradlew merge --gradle-user-home cache/; + image: eclipse-temurin:16 + artifacts: + name: "Merged_NightlyBuild_1_18_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" + paths: + - Merged + expire_in: 1 day + cache: + key: "gradleCache" + policy: pull-push + paths: + - .gradle + - cache/ # unused deployment stage diff --git a/1.17.1.properties b/1.17.1.properties new file mode 100644 index 000000000..21b0424a0 --- /dev/null +++ b/1.17.1.properties @@ -0,0 +1,37 @@ +# 1.18.1 version + +minecraft_version=1.17.1 +java_version=17 + +# Fabric loader +fabric_loader_version=0.13.2 +fabric_api_version=0.46.1+1.17 + # Fabric mod versions + modmenu_version=2.0.14 + starlight_version_fabric=3442770 + lithium_version=mc1.17.1-0.7.5 + sodium_version=3605275 + iris_version=1.17.x-v1.1.4 + bclib_version= + immersive_portals_version = 0.14-1.17 + + # Fabric mod run + # 0 = Dont enable and dont run + # 1 = Can be refranced in code but dosnt run + # 2 = Can be refranced in code and runs in client + enable_starlight=0 + enable_lithium=0 + enable_sodium=1 + enable_iris=0 + enable_bclib=0 + +# Forge loader +forge_version=37.1.1 + # Forge mod versions + starlight_version_forge=3457784 + + # Forge mod run + # 0 = Dont enable and dont run + # 1 = Can be refranced in code but dosnt run + # 2 = Can be refranced in code and runs in client + enable_starlight_forge=0 diff --git a/1.18.1.properties b/1.18.1.properties index 5fd17ffb0..520c2305a 100644 --- a/1.18.1.properties +++ b/1.18.1.properties @@ -1,4 +1,4 @@ -# 1.18.1 version based stuff +# 1.18.1 version minecraft_version=1.18.1 java_version = 17 diff --git a/1.18.2.properties b/1.18.2.properties index daf7e8ff3..22e50f368 100644 --- a/1.18.2.properties +++ b/1.18.2.properties @@ -13,8 +13,8 @@ fabric_api_version=0.48.0+1.18.2 lithium_version=mc1.18.2-0.7.9 sodium_version=3669187 iris_version=1.18.x-v1.2.2 - immersive_portals_version = v1.0.4-1.18 bclib_version=0 + immersive_portals_version = v1.0.4-1.18 # Fabric mod run # 0 = Don't enable and don't run diff --git a/Readme.md b/Readme.md index 2bf0d9f2e..4c8263247 100644 --- a/Readme.md +++ b/Readme.md @@ -16,6 +16,11 @@ If you want to see a quick demo, check out a video covering the mod here: ### Versions +This branch is for these versions of Minecraft +- 1.18.2 +- 1.18.1 & 1.18 +- 1.17.1 & 1.17 + Architectury version: 3.4-SNAPSHOT\ Java Compiler plugin: Manifold Preprocessor @@ -31,6 +36,12 @@ Fabric version: 0.13.3\ Fabric API version: 0.46.6+1.18\ Modmenu version: 3.0.1 +#### 1.17.1 mods +Forge version: 37.1.1\ +Fabric version: 0.13.2\ +Fabric API version: 0.46.1+1.17\ +Modmenu version: 2.0.14 + Notes:\ This version has been confirmed to work in IDE and Retail Minecraft.\ diff --git a/build.gradle b/build.gradle index 52f3fda27..63fe5915c 100644 --- a/build.gradle +++ b/build.gradle @@ -192,6 +192,8 @@ allprojects { p -> if (p != project(":core")) { options.compilerArgs += ['-Xplugin:Manifold'] options.release = rootProject.java_version as Integer +// } else if (p == project(":core")) { +// options.release = 8; } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideSmooth.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideSmooth.java index 760f35aad..91120c9e4 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideSmooth.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideSmooth.java @@ -44,6 +44,8 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter { return parent.getBiome(pos).value(); #elif MC_VERSION_1_18_1 return parent.getBiome(pos); + #elif MC_VERSION_1_17_1 + return parent.getBiome(pos); #endif } @@ -72,7 +74,11 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter { @Override public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) { BlockTintCache blockTintCache = this.tintCaches.get(colorResolver); + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 return blockTintCache.getColor(blockPos); + #elif MC_VERSION_1_17_1 + return blockTintCache.getColor(blockPos, null); //FIXME[1.17.1]: Replace this null with something else + #endif } @Override diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java index 512be61bd..f44b8ff41 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java @@ -74,6 +74,9 @@ public class ChunkWrapper implements IChunkWrapper #elif MC_VERSION_1_18_1 return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome( QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z))); + #elif MC_VERSION_1_17_1 + return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome( + QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z))); #endif } @@ -154,11 +157,14 @@ public class ChunkWrapper implements IChunkWrapper @Override public boolean isLightCorrect(){ - //return true; + #if MC_VERSION_1_17_1 + return true; + #elif MC_VERSION_1_18_2 || MC_VERSION_1_18_1 if (chunk instanceof LevelChunk) { return ((LevelChunk) chunk).isClientLightReady(); } return chunk.isLightCorrect(); + #endif } public boolean isWaterLogged(int x, int y, int z) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java index 370d605d8..594e0b8f3 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -15,6 +15,7 @@ import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.util.LodUtil; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.client.renderer.LightTexture; import com.mojang.math.Vector3f; @@ -130,7 +131,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getRenderDistance() { + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 return MC.options.getEffectiveRenderDistance(); + #elif MC_VERSION_1_17_1 + return MC.options.renderDistance; + #endif } @Override @@ -190,15 +195,24 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper if (!usingBackupGetVanillaRenderedChunks) { try { LevelRenderer levelRenderer = MC.levelRenderer; + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 LinkedHashSet chunks = levelRenderer.renderChunkStorage.get().renderChunks; + #elif MC_VERSION_1_17_1 + ObjectArrayList chunks = levelRenderer.renderChunks; + #endif return (chunks.stream().map((chunk) -> { - #if MC_VERSION_1_18_2 + #if MC_VERSION_1_18_2 AABB chunkBoundingBox = chunk.chunk.getBoundingBox(); - #elif MC_VERSION_1_18_1 - AABB chunkBoundingBox = chunk.chunk.bb; - #endif + #elif MC_VERSION_1_17_1 || MC_VERSION_1_18_1 + AABB chunkBoundingBox = chunk.chunk.bb; + #endif + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16), Math.floorDiv((int) chunkBoundingBox.minZ, 16)); + #elif MC_VERSION_1_17_1 + return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16), + Math.floorDiv((int) chunkBoundingBox.minZ, 16)); + #endif }).collect(Collectors.toCollection(HashSet::new))); } catch (LinkageError e) { try { diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 81797f64e..d95b322c2 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -368,7 +368,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } if (chunkData == null) { - return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null); + return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif); } else { @@ -376,7 +376,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv return ChunkLoader.read(level, lightEngine, chunkPos, chunkData); } catch (Exception e) { LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e); - return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null); + return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif); } } @@ -414,8 +414,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv // Continue... } if (target == null) - target = new ProtoChunk(chunkPos, UpgradeData.EMPTY, params.level, - params.biomes, null); + target = new ProtoChunk(chunkPos, UpgradeData.EMPTY, params.level + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1, params.biomes, null #endif); return target; }; @@ -474,19 +474,23 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } boolean isFull = target.getStatus() == ChunkStatus.FULL || target instanceof LevelChunk; + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 boolean isPartial = target.isOldNoiseGeneration(); + #endif if (isFull) { LOAD_LOGGER.info("Detected full existing chunk at {}", target.getPos()); params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk, new LodBuilderConfig(DistanceGenerationMode.FULL), true, e.genAllDetails); } + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 else if (isPartial) { LOAD_LOGGER.info("Detected old existing chunk at {}", target.getPos()); params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk, new LodBuilderConfig(generationMode), true, e.genAllDetails); } + #endif else if (target.getStatus() == ChunkStatus.EMPTY && generationMode == DistanceGenerationMode.NONE) { params.lodBuilder.generateLodNodeFromChunk(params.lodDim,wrappedChunk, @@ -571,10 +575,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv { if (p instanceof ProtoChunk) ((ProtoChunk) p).setLightCorrect(true); + #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 if (p instanceof LevelChunk) { ((LevelChunk) p).setLightCorrect(true); ((LevelChunk) p).setClientLightReady(true); } + #endif }); break; } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java index 9d604028b..56b875353 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java @@ -13,7 +13,9 @@ import net.minecraft.server.level.ThreadedLevelLightEngine; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.chunk.ChunkGenerator; +#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 import net.minecraft.world.level.chunk.storage.ChunkScanAccess; +#endif import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager; import net.minecraft.world.level.storage.WorldData; @@ -22,7 +24,9 @@ public final class GlobalParameters { public final ChunkGenerator generator; public final StructureManager structures; + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 public final BiomeManager biomeManager; + #endif public final WorldGenSettings worldGenSettings; public final ThreadedLevelLightEngine lightEngine; public final LodBuilder lodBuilder; @@ -30,7 +34,9 @@ public final class GlobalParameters public final Registry biomes; public final RegistryAccess registry; public final long worldSeed; + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 public final ChunkScanAccess chunkScanner; + #endif public final ServerLevel level; // TODO: Figure out a way to remove this. Maybe ClientLevel also works? public final DataFixer fixerUpper; @@ -46,10 +52,14 @@ public final class GlobalParameters registry = server.registryAccess(); biomes = registry.registryOrThrow(Registry.BIOME_REGISTRY); worldSeed = worldGenSettings.seed(); + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 biomeManager = new BiomeManager(level, BiomeManager.obfuscateSeed(worldSeed)); + #endif structures = server.getStructureManager(); generator = level.getChunkSource().getGenerator(); + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 chunkScanner = level.getChunkSource().chunkScanner(); + #endif fixerUpper = server.getFixerUpper(); } } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java index dc34cd3ed..61bbb66e5 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java @@ -7,14 +7,20 @@ import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.WorldGenStruct import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.levelgen.WorldGenSettings; +#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 import net.minecraft.world.level.levelgen.structure.StructureCheck; +#endif public final class ThreadedParameters { private static final ThreadLocal localParam = new ThreadLocal(); final ServerLevel level; + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 public WorldGenStructFeatManager structFeat = null; public final StructureCheck structCheck; + #elif MC_VERSION_1_17_1 + public WorldGenStructFeatManager structFeat = null; + #endif boolean isValid = true; public final PerfCalculator perf = new PerfCalculator(); @@ -35,14 +41,23 @@ public final class ThreadedParameters private ThreadedParameters(GlobalParameters param) { + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 level = param.level; structCheck = new StructureCheck(param.chunkScanner, param.registry, param.structures, param.level.dimension(), param.generator, level, param.generator.getBiomeSource(), param.worldSeed, param.fixerUpper); + #elif MC_VERSION_1_17_1 + level = param.level; + structFeat = new WorldGenStructFeatManager(level, param.worldGenSettings); + #endif } public void makeStructFeat(WorldGenLevel genLevel, GlobalParameters param) { + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 structFeat = new WorldGenStructFeatManager(param.worldGenSettings, genLevel, structCheck); + #elif MC_VERSION_1_17_1 + structFeat = new WorldGenStructFeatManager(param.worldGenSettings, genLevel); + #endif } } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java index b17ee8d7f..ff9216f3e 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java @@ -28,40 +28,37 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtOps; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.LightLayer; -import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.*; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biomes; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.chunk.ChunkStatus; -import net.minecraft.world.level.chunk.DataLayer; -import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraft.world.level.chunk.LevelChunkSection; -import net.minecraft.world.level.chunk.PalettedContainer; -import net.minecraft.world.level.chunk.UpgradeData; +import net.minecraft.world.level.chunk.*; import net.minecraft.world.level.levelgen.Heightmap; +#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 import net.minecraft.world.level.levelgen.blending.BlendingData; import net.minecraft.world.level.levelgen.feature.StructureFeature; import net.minecraft.world.level.levelgen.structure.StructureStart; import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext; +import net.minecraft.world.ticks.LevelChunkTicks; +#endif import net.minecraft.world.level.lighting.LevelLightEngine; import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.ticks.LevelChunkTicks; +import net.minecraft.world.level.material.Fluids; import org.apache.logging.log4j.Logger; public class ChunkLoader { + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 private static final Codec> BLOCK_STATE_CODEC = PalettedContainer.codec(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState()); - private static final ConfigBasedLogger LOGGER = BatchGenerationEnvironment.LOAD_LOGGER; private static final String TAG_UPGRADE_DATA = "UpgradeData"; private static final String BLOCK_TICKS_TAG = "block_ticks"; private static final String FLUID_TICKS_TAG = "fluid_ticks"; - + #endif + private static final ConfigBasedLogger LOGGER = BatchGenerationEnvironment.LOAD_LOGGER; + + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 private static BlendingData readBlendingData(CompoundTag chunkData) { BlendingData blendingData = null; @@ -73,10 +70,13 @@ public class ChunkLoader } return blendingData; } + #endif private static LevelChunkSection[] readSections(LevelAccessor level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData) { + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 Registry biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); + #endif #if MC_VERSION_1_18_1 Codec> biomeCodec = PalettedContainer.codec( biomes, biomes.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getOrThrow(Biomes.PLAINS)); @@ -92,10 +92,17 @@ public class ChunkLoader boolean hasSkyLight = level.dimensionType().hasSkyLight(); ListTag tagSections = chunkData.getList("sections", 10); + #if MC_VERSION_1_17_1 + boolean bl2 = level.dimensionType().hasSkyLight(); + if (isLightOn) + lightEngine.retainData(chunkPos, true); + #endif for (int j = 0; j < tagSections.size(); ++j) { CompoundTag tagSection = tagSections.getCompound(j); - byte sectionYPos = tagSection.getByte("Y"); + int sectionYPos = tagSection.getByte("Y"); + + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 int sectionId = level.getSectionIndexFromSectionY(sectionYPos); if (sectionId >= 0 && sectionId < chunkSections.length) { @@ -131,6 +138,24 @@ public class ChunkLoader lightEngine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, sectionYPos), new DataLayer(tagSection.getByteArray("BlockLight")), true); if (hasSkyLight && tagSection.contains("SkyLight", 7)) lightEngine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, sectionYPos), new DataLayer(tagSection.getByteArray("SkyLight")), true); + #elif MC_VERSION_1_17_1 + if (tagSection.contains("Palette", 9) && tagSection.contains("BlockStates", 12)) { + LevelChunkSection levelChunkSection = new LevelChunkSection(sectionYPos << 4); + levelChunkSection.getStates().read(tagSection.getList("Palette", 10), + tagSection.getLongArray("BlockStates")); + levelChunkSection.recalcBlockCounts(); + if (!levelChunkSection.isEmpty()) + chunkSections[level.getSectionIndexFromSectionY(sectionYPos)] = levelChunkSection; + } + if (isLightOn) { + if (tagSection.contains("BlockLight", 7)) + lightEngine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, sectionYPos), + new DataLayer(tagSection.getByteArray("BlockLight")), true); + if (bl2 && tagSection.contains("SkyLight", 7)) + lightEngine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, sectionYPos), + new DataLayer(tagSection.getByteArray("SkyLight")), true); + } + #endif } return chunkSections; } @@ -248,6 +273,7 @@ public class ChunkLoader } #endif + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 private static void readStructures(WorldGenLevel level, LevelChunk chunk, CompoundTag chunkData) { CompoundTag tagStructures = chunkData.getCompound("structures"); @@ -255,7 +281,8 @@ public class ChunkLoader unpackStructureStart(StructurePieceSerializationContext.fromLevel(level.getLevel()), tagStructures, level.getSeed())); chunk.setAllReferences(unpackStructureReferences(#if MC_VERSION_1_18_2 level.registryAccess() ,#endif chunk.getPos(), tagStructures)); } - + #endif + private static void readPostPocessings(LevelChunk chunk, CompoundTag chunkData) { ListTag tagPostProcessings = chunkData.getList("PostProcessing", 9); @@ -272,18 +299,33 @@ public class ChunkLoader public static ChunkStatus.ChunkType readChunkType(CompoundTag compoundTag) { return ChunkStatus.byName(compoundTag.getString("Status")).getChunkType(); + + // TODO Check if we should use the lines underneath to return or use the thing above +// ChunkStatus chunkStatus = ChunkStatus.byName(tagLevel.getString("Status")); +// if (chunkStatus != null) { +// return chunkStatus.getChunkType(); +// } +// return ChunkStatus.ChunkType.PROTOCHUNK; } public static LevelChunk read(WorldGenLevel level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData) { - + #if MC_VERSION_1_17_1 + CompoundTag tagLevel = chunkData.getCompound("Level"); + + ChunkStatus.ChunkType chunkType = readChunkType(tagLevel); + if (chunkType != ChunkStatus.ChunkType.LEVELCHUNK) + return null; + #endif + ChunkPos actualPos = new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos")); if (!Objects.equals(chunkPos, actualPos)) { LOGGER.error("Chunk file at {} is in the wrong location; Ignoring. (Expected {}, got {})", (Object) chunkPos, (Object) chunkPos, (Object) actualPos); return null; } - + + #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 ChunkStatus.ChunkType chunkType = readChunkType(chunkData); BlendingData blendingData = readBlendingData(chunkData); if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK && (blendingData == null || !blendingData.oldNoise())) @@ -307,11 +349,46 @@ public class ChunkLoader // Make chunk LevelChunk chunk = new LevelChunk((Level) level, chunkPos, upgradeData, blockTicks, fluidTicks, inhabitedTime, chunkSections, null, blendingData); - + #elif MC_VERSION_1_17_1 + // ====================== Read params for making the LevelChunk + // ============================ + ChunkBiomeContainer chunkBiomeContainer = new ChunkBiomeContainer( + level.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), level, chunkPos, + level.getLevel().getChunkSource().getGenerator().getBiomeSource(), + tagLevel.contains("Biomes", 11) ? tagLevel.getIntArray("Biomes") : null); + + UpgradeData upgradeData = tagLevel.contains("UpgradeData", 10) + ? new UpgradeData(tagLevel.getCompound("UpgradeData"), level) + : UpgradeData.EMPTY; + + TickList blockTicks = tagLevel.contains("TileTicks", 9) + ? ChunkTickList.create(tagLevel.getList("TileTicks", 10), Registry.BLOCK::getKey, Registry.BLOCK::get) + : new ProtoTickList(block -> (block == null || block.defaultBlockState().isAir()), chunkPos, + tagLevel.getList("ToBeTicked", 9), level); + + TickList liquidTicks = tagLevel.contains("LiquidTicks", 9) + ? ChunkTickList.create(tagLevel.getList("LiquidTicks", 10), Registry.FLUID::getKey, Registry.FLUID::get) + : new ProtoTickList(fluid -> (fluid == null || fluid == Fluids.EMPTY), chunkPos, + tagLevel.getList("LiquidsToBeTicked", 9), level); + + long inhabitedTime = tagLevel.getLong("InhabitedTime"); + + LevelChunkSection[] levelChunkSections = readSections(level, lightEngine, chunkPos, tagLevel); + + // ======================== Make the chunk + // =========================================== + LevelChunk chunk = new LevelChunk(level.getLevel(), chunkPos, chunkBiomeContainer, upgradeData, blockTicks, + liquidTicks, inhabitedTime, levelChunkSections, null); + #endif + // Set some states after object creation - chunk.setLightCorrect(isLightOn); - readHeightmaps(chunk, chunkData); + #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 readStructures(level, chunk, chunkData); + chunk.setLightCorrect(isLightOn); + #elif MC_VERSION_1_17_1 + chunk.setLightCorrect(tagLevel.getBoolean("isLightOn")); + #endif + readHeightmaps(chunk, chunkData); readPostPocessings(chunk, chunkData); return chunk; } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java index b06baf39b..64421016e 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java @@ -48,6 +48,15 @@ public class LightedWorldGenRegion extends WorldGenRegion { private final ChunkPos firstPos; private final List cache; Long2ObjectOpenHashMap chunkMap = new Long2ObjectOpenHashMap(); + #if MC_VERSION_1_17_1 + private ChunkPos overrideCenterPos = null; + + public void setOverrideCenter(ChunkPos pos) {overrideCenterPos = pos;} + @Override + public ChunkPos getCenter() { + return overrideCenterPos==null ? super.getCenter() : overrideCenterPos; + } + #endif public LightedWorldGenRegion(ServerLevel serverLevel, WorldGenLevelLightEngine lightEngine, List list, ChunkStatus chunkStatus, int i, @@ -80,12 +89,14 @@ public class LightedWorldGenRegion extends WorldGenRegion { if (k > this.writeRadius || l > this.writeRadius) { return false; } + #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 if (center.isUpgrading()) { LevelHeightAccessor levelHeightAccessor = center.getHeightAccessorForGeneration(); if (blockPos.getY() < levelHeightAccessor.getMinBuildHeight() || blockPos.getY() >= levelHeightAccessor.getMaxBuildHeight()) { return false; } } + #endif return true; } @@ -172,7 +183,7 @@ public class LightedWorldGenRegion extends WorldGenRegion { public ChunkAccess getChunk(int i, int j, ChunkStatus chunkStatus, boolean bl) { ChunkAccess chunk = getChunkAccess(i, j, chunkStatus, bl); if (chunk instanceof LevelChunk) { - chunk = new ImposterProtoChunk((LevelChunk) chunk, true); + chunk = new ImposterProtoChunk((LevelChunk) chunk #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2, true #endif); } return chunk; } @@ -244,7 +255,11 @@ public class LightedWorldGenRegion extends WorldGenRegion { public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) { BlockTintCache blockTintCache = (BlockTintCache) this.tintCaches.get(colorResolver); + #if MC_VERSION_1_17_1 + return blockTintCache.getColor(blockPos, null); // FIXME[1.17.1]: Replace this null with something else + #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 return blockTintCache.getColor(blockPos); + #endif } private Biome _getBiome(BlockPos pos) { diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java index a08564854..0990f18c2 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java @@ -125,9 +125,16 @@ public class WorldGenLevelLightEngine extends LevelLightEngine { LevelChunkSection[] levelChunkSections = chunkAccess.getSections(); for (int i = 0; i < chunkAccess.getSectionsCount(); ++i) { LevelChunkSection levelChunkSection = levelChunkSections[i]; + #if MC_VERSION_1_17_1 + if (!LevelChunkSection.isEmpty(levelChunkSection)) { + int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i); + updateSectionStatus(SectionPos.of(chunkPos, j), false); + } + #elif MC_VERSION_1_18_1 || MC_VERSION_1_18_1 if (levelChunkSection.hasOnlyAir()) continue; int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i); updateSectionStatus(SectionPos.of(chunkPos, j), false); + #endif } enableLightSources(chunkPos, true); if (needLightBlockUpdate) { diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java index 349e18291..1ce3eeefe 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.Objects; import java.util.function.Consumer; import java.util.function.Predicate; +import java.util.stream.Stream; import com.google.common.collect.ImmutableList; @@ -23,25 +24,42 @@ import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; import net.minecraft.world.level.levelgen.feature.StructureFeature; +#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 import net.minecraft.world.level.levelgen.structure.StructureCheck; +#endif import net.minecraft.world.level.levelgen.structure.StructureStart; public class WorldGenStructFeatManager extends StructureFeatureManager { final WorldGenLevel genLevel; WorldGenSettings worldGenSettings; + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 StructureCheck structureCheck; public WorldGenStructFeatManager(WorldGenSettings worldGenSettings, WorldGenLevel genLevel, StructureCheck structureCheck) { + super(genLevel, worldGenSettings, structureCheck); this.genLevel = genLevel; this.worldGenSettings = worldGenSettings; } + #elif MC_VERSION_1_17_1 + public WorldGenStructFeatManager(WorldGenSettings worldGenSettings, + WorldGenLevel genLevel) { + + super(genLevel, worldGenSettings); + this.genLevel = genLevel; + this.worldGenSettings = worldGenSettings; + } + #endif @Override public WorldGenStructFeatManager forWorldGenRegion(WorldGenRegion worldGenRegion) { if (worldGenRegion == genLevel) return this; + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 return new WorldGenStructFeatManager(worldGenSettings, worldGenRegion, structureCheck); + #elif MC_VERSION_1_17_1 + return new WorldGenStructFeatManager(worldGenSettings, worldGenRegion); + #endif } private ChunkAccess _getChunk(int x, int z, ChunkStatus status) { @@ -49,6 +67,7 @@ public class WorldGenStructFeatManager extends StructureFeatureManager { return genLevel.getChunk(x, z, status, false); } + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 @Override public boolean hasAnyStructureAt(BlockPos blockPos) { SectionPos sectionPos = SectionPos.of(blockPos); @@ -56,10 +75,28 @@ public class WorldGenStructFeatManager extends StructureFeatureManager { if (chunk == null) return false; return chunk.hasAnyStructureReferences(); } + #endif - - #if MC_VERSION_1_18_1 + #if MC_VERSION_1_17_1 + @Override + public Stream> startsForFeature(SectionPos sectionPos2, + StructureFeature structureFeature) { + if (genLevel == null) + return Stream.empty(); + ChunkAccess chunk = genLevel.getChunk(sectionPos2.x(), sectionPos2.z(), ChunkStatus.STRUCTURE_REFERENCES, + false); + if (chunk == null) + return Stream.empty(); + return chunk.getReferencesForFeature(structureFeature).stream().map(pos -> { + SectionPos sectPos = SectionPos.of(ChunkPos.getX(pos), 0, ChunkPos.getZ(pos)); + ChunkAccess startChunk = genLevel.getChunk(sectPos.x(), sectPos.z(), ChunkStatus.STRUCTURE_STARTS, false); + if (startChunk == null) + return null; + return this.getStartForFeature(sectPos, structureFeature, startChunk); + }).filter(structureStart -> structureStart != null && structureStart.isValid()); + } + #elif MC_VERSION_1_18_1 @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public List> startsForFeature(SectionPos sectionPos, @@ -83,8 +120,8 @@ public class WorldGenStructFeatManager extends StructureFeatureManager { } return builder.build(); } - #elif MC_VERSION_1_18_2 + #elif MC_VERSION_1_18_2 @Override public List startsForFeature(SectionPos sectionPos, Predicate> predicate) { ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES); diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepBiomes.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepBiomes.java index 3538c81b7..279cc12de 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepBiomes.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepBiomes.java @@ -17,7 +17,9 @@ import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.levelgen.DebugLevelSource; import net.minecraft.world.level.levelgen.FlatLevelSource; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; +#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 import net.minecraft.world.level.levelgen.blending.Blender; +#endif public final class StepBiomes { /** @@ -48,8 +50,12 @@ public final class StepBiomes { for (ChunkAccess chunk : chunksToDo) { // System.out.println("StepBiomes: "+chunk.getPos()); + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 chunk = environment.joinSync(environment.params.generator.createBiomes(environment.params.biomes, Runnable::run, Blender.of(worldGenRegion), tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); + #elif MC_VERSION_1_17_1 + environment.params.generator.createBiomes(environment.params.biomes, chunk); + #endif } } } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java index a17fa172e..2936af1bc 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment; import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters; +import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion; import com.seibel.lod.core.util.gridList.ArrayGridList; import net.minecraft.ReportedException; @@ -11,7 +12,9 @@ import net.minecraft.server.level.WorldGenRegion; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.ProtoChunk; +#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 import net.minecraft.world.level.levelgen.blending.Blender; +#endif public final class StepFeatures { /** @@ -29,7 +32,7 @@ public final class StepFeatures { public final ChunkStatus STATUS = ChunkStatus.FEATURES; - public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion, + public void generateGroup(ThreadedParameters tParams, LightedWorldGenRegion worldGenRegion, ArrayGridList chunks) { ArrayList chunksToDo = new ArrayList(); @@ -41,9 +44,14 @@ public final class StepFeatures { for (ChunkAccess chunk : chunksToDo) { try { + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 environment.params.generator.applyBiomeDecoration(worldGenRegion, chunk, tParams.structFeat.forWorldGenRegion(worldGenRegion)); Blender.generateBorderTicks(worldGenRegion, chunk); + #elif MC_VERSION_1_17_1 + worldGenRegion.setOverrideCenter(chunk.getPos()); + environment.params.generator.applyBiomeDecoration(worldGenRegion, tParams.structFeat); + #endif } catch (ReportedException e) { e.printStackTrace(); // FIXME: Features concurrent modification issue. Something about cocobeans just diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java index 90ef6ef5b..c52d01dee 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java @@ -52,7 +52,9 @@ public final class StepLight { } catch (Exception e) { e.printStackTrace(); } + #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 if (chunk instanceof LevelChunk) ((LevelChunk)chunk).setClientLightReady(true); + #endif chunk.setLightCorrect(true); } lightEngine.runUpdates(Integer.MAX_VALUE, true, true); diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepNoise.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepNoise.java index 4229e355a..62f5171d2 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepNoise.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepNoise.java @@ -19,7 +19,9 @@ import net.minecraft.world.level.chunk.LevelChunkSection; import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; import net.minecraft.world.level.levelgen.NoiseSettings; +#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 import net.minecraft.world.level.levelgen.blending.Blender; +#endif public final class StepNoise { /** @@ -50,8 +52,13 @@ public final class StepNoise { for (ChunkAccess chunk : chunksToDo) { // System.out.println("StepNoise: "+chunk.getPos()); + #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion), tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); + #elif MC_VERSION_1_17_1 + chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run, + tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); + #endif } } } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepStructureStart.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepStructureStart.java index 9a06f7a97..8d1d4ba85 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepStructureStart.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepStructureStart.java @@ -53,6 +53,8 @@ public final class StepStructureStart { // System.out.println("StepStructureStart: "+chunk.getPos()); environment.params.generator.createStructures(environment.params.registry, tParams.structFeat, chunk, environment.params.structures, environment.params.worldSeed); + + #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 try { tParams.structCheck.onStructureLoad(chunk.getPos(), chunk.getAllStarts()); } catch (ArrayIndexOutOfBoundsException e) { @@ -61,6 +63,7 @@ public final class StepStructureStart { // TODO: Figure out in the future why this happens even though I am using new structFeat throw new StepStructureStart.StructStartCorruptedException(e); } + #endif } } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepSurface.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepSurface.java index aee2e2eb0..8c01f2953 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepSurface.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepSurface.java @@ -39,8 +39,11 @@ public final class StepSurface { for (ChunkAccess chunk : chunksToDo) { // System.out.println("StepSurface: "+chunk.getPos()); - environment.params.generator.buildSurface(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), - chunk); + #if MC_VERSION_1_17_1 + environment.params.generator.buildSurfaceAndBedrock(worldGenRegion, chunk); + #elif MC_VERSION_1_18_1 || MC_VERSION_1_18_2 + environment.params.generator.buildSurface(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk); + #endif } } } \ No newline at end of file diff --git a/common/src/main/resources/lod.accesswidener b/common/src/main/resources/lod.accesswidener index 564f2d77b..0d79812fe 100644 --- a/common/src/main/resources/lod.accesswidener +++ b/common/src/main/resources/lod.accesswidener @@ -8,9 +8,18 @@ accessible field com/mojang/blaze3d/vertex/VertexBuffer indexCount I accessible field com/mojang/blaze3d/vertex/VertexBuffer vertextBufferId I accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)D +#if MC_VERSION_1_17_1 +# pre-render setup +accessible field net/minecraft/client/renderer/LevelRenderer renderChunks Lit/unimi/dsi/fastutil/objects/ObjectArrayList; +accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo +accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk; +#endif + # used for grabbing vanilla rendered chunks +#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 accessible field net/minecraft/client/renderer/LevelRenderer renderChunkStorage Ljava/util/concurrent/atomic/AtomicReference; accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkStorage +#endif accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk; @@ -24,7 +33,7 @@ accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings; accessible field net/minecraft/world/level/biome/Biome biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory; # accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder; -accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doFill (Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;II)Lnet/minecraft/world/level/chunk/ChunkAccess; +#accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doFill (Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;II)Lnet/minecraft/world/level/chunk/ChunkAccess; #accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doCreateBiomes (Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V diff --git a/gradle.properties b/gradle.properties index 1188a0d96..297c34e5f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,4 @@ toml_version=3.6.4 manifold_version=2022.1.7 ##### FOR IDE SUPPORT AND TELL IDE TO USE CERTIAN MC VERSION: SWITCH THIS: -mcVer=1.18.2 \ No newline at end of file +mcVer=1.17.1 \ No newline at end of file