Made new branch with 1.18 and 1.17 combined (still work in progress)

This commit is contained in:
coolGi2007
2022-04-01 17:26:43 +10:30
parent 0bddc2dcac
commit 5fa3e3cb7f
24 changed files with 360 additions and 58 deletions
+38 -17
View File
@@ -5,6 +5,7 @@ image: gradle:eclipse-temurin
stages: stages:
- build_18_1 - build_18_1
- build_18_2 - build_18_2
- build_17_1
variables: variables:
# Pull core when building # Pull core when building
@@ -41,23 +42,43 @@ build_18_1:
# 1.18.2 build # 1.18.2 build
build_18_2: build_18_2:
stage: build_18_2 stage: build_18_2
script: script:
- ./gradlew deleteMerged --gradle-user-home cache/; - ./gradlew deleteMerged --gradle-user-home cache/;
- ./gradlew build -PmcVer=1.18.2 --gradle-user-home cache/; - ./gradlew build -PmcVer=1.18.2 --gradle-user-home cache/;
- ./gradlew merge --gradle-user-home cache/; - ./gradlew merge --gradle-user-home cache/;
image: eclipse-temurin:17 image: eclipse-temurin:17
artifacts: artifacts:
name: "Merged_NightlyBuild_1_18_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" name: "Merged_NightlyBuild_1_18_2-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
paths: paths:
- Merged - Merged
expire_in: 1 day expire_in: 1 day
cache: cache:
key: "gradleCache" key: "gradleCache"
policy: pull-push policy: pull-push
paths: paths:
- .gradle - .gradle
- cache/ - 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 # unused deployment stage
+37
View File
@@ -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
+1 -1
View File
@@ -1,4 +1,4 @@
# 1.18.1 version based stuff # 1.18.1 version
minecraft_version=1.18.1 minecraft_version=1.18.1
java_version = 17 java_version = 17
+1 -1
View File
@@ -13,8 +13,8 @@ fabric_api_version=0.48.0+1.18.2
lithium_version=mc1.18.2-0.7.9 lithium_version=mc1.18.2-0.7.9
sodium_version=3669187 sodium_version=3669187
iris_version=1.18.x-v1.2.2 iris_version=1.18.x-v1.2.2
immersive_portals_version = v1.0.4-1.18
bclib_version=0 bclib_version=0
immersive_portals_version = v1.0.4-1.18
# Fabric mod run # Fabric mod run
# 0 = Don't enable and don't run # 0 = Don't enable and don't run
+11
View File
@@ -16,6 +16,11 @@ If you want to see a quick demo, check out a video covering the mod here:
### Versions ### 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\ Architectury version: 3.4-SNAPSHOT\
Java Compiler plugin: Manifold Preprocessor Java Compiler plugin: Manifold Preprocessor
@@ -31,6 +36,12 @@ Fabric version: 0.13.3\
Fabric API version: 0.46.6+1.18\ Fabric API version: 0.46.6+1.18\
Modmenu version: 3.0.1 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:\ Notes:\
This version has been confirmed to work in IDE and Retail Minecraft.\ This version has been confirmed to work in IDE and Retail Minecraft.\
+2
View File
@@ -192,6 +192,8 @@ allprojects { p ->
if (p != project(":core")) { if (p != project(":core")) {
options.compilerArgs += ['-Xplugin:Manifold'] options.compilerArgs += ['-Xplugin:Manifold']
options.release = rootProject.java_version as Integer options.release = rootProject.java_version as Integer
// } else if (p == project(":core")) {
// options.release = 8;
} }
} }
@@ -44,6 +44,8 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter {
return parent.getBiome(pos).value(); return parent.getBiome(pos).value();
#elif MC_VERSION_1_18_1 #elif MC_VERSION_1_18_1
return parent.getBiome(pos); return parent.getBiome(pos);
#elif MC_VERSION_1_17_1
return parent.getBiome(pos);
#endif #endif
} }
@@ -72,7 +74,11 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter {
@Override @Override
public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) { public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) {
BlockTintCache blockTintCache = this.tintCaches.get(colorResolver); BlockTintCache blockTintCache = this.tintCaches.get(colorResolver);
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
return blockTintCache.getColor(blockPos); 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 @Override
@@ -74,6 +74,9 @@ public class ChunkWrapper implements IChunkWrapper
#elif MC_VERSION_1_18_1 #elif MC_VERSION_1_18_1
return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome( return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome(
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z))); 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 #endif
} }
@@ -154,11 +157,14 @@ public class ChunkWrapper implements IChunkWrapper
@Override @Override
public boolean isLightCorrect(){ 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) { if (chunk instanceof LevelChunk) {
return ((LevelChunk) chunk).isClientLightReady(); return ((LevelChunk) chunk).isClientLightReady();
} }
return chunk.isLightCorrect(); return chunk.isLightCorrect();
#endif
} }
public boolean isWaterLogged(int x, int y, int z) public boolean isWaterLogged(int x, int y, int z)
@@ -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.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.util.LodUtil;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.LightTexture;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
@@ -130,7 +131,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
@Override @Override
public int getRenderDistance() public int getRenderDistance()
{ {
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
return MC.options.getEffectiveRenderDistance(); return MC.options.getEffectiveRenderDistance();
#elif MC_VERSION_1_17_1
return MC.options.renderDistance;
#endif
} }
@Override @Override
@@ -190,15 +195,24 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
if (!usingBackupGetVanillaRenderedChunks) { if (!usingBackupGetVanillaRenderedChunks) {
try { try {
LevelRenderer levelRenderer = MC.levelRenderer; LevelRenderer levelRenderer = MC.levelRenderer;
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
LinkedHashSet<LevelRenderer.RenderChunkInfo> chunks = levelRenderer.renderChunkStorage.get().renderChunks; LinkedHashSet<LevelRenderer.RenderChunkInfo> chunks = levelRenderer.renderChunkStorage.get().renderChunks;
#elif MC_VERSION_1_17_1
ObjectArrayList<LevelRenderer.RenderChunkInfo> chunks = levelRenderer.renderChunks;
#endif
return (chunks.stream().map((chunk) -> { return (chunks.stream().map((chunk) -> {
#if MC_VERSION_1_18_2 #if MC_VERSION_1_18_2
AABB chunkBoundingBox = chunk.chunk.getBoundingBox(); AABB chunkBoundingBox = chunk.chunk.getBoundingBox();
#elif MC_VERSION_1_18_1 #elif MC_VERSION_1_17_1 || MC_VERSION_1_18_1
AABB chunkBoundingBox = chunk.chunk.bb; AABB chunkBoundingBox = chunk.chunk.bb;
#endif #endif
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16), return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16),
Math.floorDiv((int) chunkBoundingBox.minZ, 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))); }).collect(Collectors.toCollection(HashSet::new)));
} catch (LinkageError e) { } catch (LinkageError e) {
try { try {
@@ -368,7 +368,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
} }
if (chunkData == null) 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 else
{ {
@@ -376,7 +376,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
return ChunkLoader.read(level, lightEngine, chunkPos, chunkData); return ChunkLoader.read(level, lightEngine, chunkPos, chunkData);
} catch (Exception e) { } catch (Exception e) {
LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, 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... // Continue...
} }
if (target == null) if (target == null)
target = new ProtoChunk(chunkPos, UpgradeData.EMPTY, params.level, target = new ProtoChunk(chunkPos, UpgradeData.EMPTY, params.level
params.biomes, null); #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1, params.biomes, null #endif);
return target; return target;
}; };
@@ -474,19 +474,23 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
} }
boolean isFull = target.getStatus() == ChunkStatus.FULL || target instanceof LevelChunk; boolean isFull = target.getStatus() == ChunkStatus.FULL || target instanceof LevelChunk;
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
boolean isPartial = target.isOldNoiseGeneration(); boolean isPartial = target.isOldNoiseGeneration();
#endif
if (isFull) if (isFull)
{ {
LOAD_LOGGER.info("Detected full existing chunk at {}", target.getPos()); LOAD_LOGGER.info("Detected full existing chunk at {}", target.getPos());
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk, params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
new LodBuilderConfig(DistanceGenerationMode.FULL), true, e.genAllDetails); new LodBuilderConfig(DistanceGenerationMode.FULL), true, e.genAllDetails);
} }
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
else if (isPartial) else if (isPartial)
{ {
LOAD_LOGGER.info("Detected old existing chunk at {}", target.getPos()); LOAD_LOGGER.info("Detected old existing chunk at {}", target.getPos());
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk, params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
new LodBuilderConfig(generationMode), true, e.genAllDetails); new LodBuilderConfig(generationMode), true, e.genAllDetails);
} }
#endif
else if (target.getStatus() == ChunkStatus.EMPTY && generationMode == DistanceGenerationMode.NONE) else if (target.getStatus() == ChunkStatus.EMPTY && generationMode == DistanceGenerationMode.NONE)
{ {
params.lodBuilder.generateLodNodeFromChunk(params.lodDim,wrappedChunk, params.lodBuilder.generateLodNodeFromChunk(params.lodDim,wrappedChunk,
@@ -571,10 +575,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
{ {
if (p instanceof ProtoChunk) if (p instanceof ProtoChunk)
((ProtoChunk) p).setLightCorrect(true); ((ProtoChunk) p).setLightCorrect(true);
#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2
if (p instanceof LevelChunk) { if (p instanceof LevelChunk) {
((LevelChunk) p).setLightCorrect(true); ((LevelChunk) p).setLightCorrect(true);
((LevelChunk) p).setClientLightReady(true); ((LevelChunk) p).setClientLightReady(true);
} }
#endif
}); });
break; break;
} }
@@ -13,7 +13,9 @@ import net.minecraft.server.level.ThreadedLevelLightEngine;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.biome.BiomeManager;
import net.minecraft.world.level.chunk.ChunkGenerator; 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; import net.minecraft.world.level.chunk.storage.ChunkScanAccess;
#endif
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import net.minecraft.world.level.storage.WorldData; import net.minecraft.world.level.storage.WorldData;
@@ -22,7 +24,9 @@ public final class GlobalParameters
{ {
public final ChunkGenerator generator; public final ChunkGenerator generator;
public final StructureManager structures; public final StructureManager structures;
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
public final BiomeManager biomeManager; public final BiomeManager biomeManager;
#endif
public final WorldGenSettings worldGenSettings; public final WorldGenSettings worldGenSettings;
public final ThreadedLevelLightEngine lightEngine; public final ThreadedLevelLightEngine lightEngine;
public final LodBuilder lodBuilder; public final LodBuilder lodBuilder;
@@ -30,7 +34,9 @@ public final class GlobalParameters
public final Registry<Biome> biomes; public final Registry<Biome> biomes;
public final RegistryAccess registry; public final RegistryAccess registry;
public final long worldSeed; public final long worldSeed;
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
public final ChunkScanAccess chunkScanner; public final ChunkScanAccess chunkScanner;
#endif
public final ServerLevel level; // TODO: Figure out a way to remove this. Maybe ClientLevel also works? public final ServerLevel level; // TODO: Figure out a way to remove this. Maybe ClientLevel also works?
public final DataFixer fixerUpper; public final DataFixer fixerUpper;
@@ -46,10 +52,14 @@ public final class GlobalParameters
registry = server.registryAccess(); registry = server.registryAccess();
biomes = registry.registryOrThrow(Registry.BIOME_REGISTRY); biomes = registry.registryOrThrow(Registry.BIOME_REGISTRY);
worldSeed = worldGenSettings.seed(); worldSeed = worldGenSettings.seed();
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
biomeManager = new BiomeManager(level, BiomeManager.obfuscateSeed(worldSeed)); biomeManager = new BiomeManager(level, BiomeManager.obfuscateSeed(worldSeed));
#endif
structures = server.getStructureManager(); structures = server.getStructureManager();
generator = level.getChunkSource().getGenerator(); generator = level.getChunkSource().getGenerator();
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
chunkScanner = level.getChunkSource().chunkScanner(); chunkScanner = level.getChunkSource().chunkScanner();
#endif
fixerUpper = server.getFixerUpper(); fixerUpper = server.getFixerUpper();
} }
} }
@@ -7,14 +7,20 @@ import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.WorldGenStruct
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.levelgen.WorldGenSettings; 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; import net.minecraft.world.level.levelgen.structure.StructureCheck;
#endif
public final class ThreadedParameters public final class ThreadedParameters
{ {
private static final ThreadLocal<ThreadedParameters> localParam = new ThreadLocal<ThreadedParameters>(); private static final ThreadLocal<ThreadedParameters> localParam = new ThreadLocal<ThreadedParameters>();
final ServerLevel level; final ServerLevel level;
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
public WorldGenStructFeatManager structFeat = null; public WorldGenStructFeatManager structFeat = null;
public final StructureCheck structCheck; public final StructureCheck structCheck;
#elif MC_VERSION_1_17_1
public WorldGenStructFeatManager structFeat = null;
#endif
boolean isValid = true; boolean isValid = true;
public final PerfCalculator perf = new PerfCalculator(); public final PerfCalculator perf = new PerfCalculator();
@@ -35,14 +41,23 @@ public final class ThreadedParameters
private ThreadedParameters(GlobalParameters param) private ThreadedParameters(GlobalParameters param)
{ {
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
level = param.level; level = param.level;
structCheck = new StructureCheck(param.chunkScanner, param.registry, param.structures, structCheck = new StructureCheck(param.chunkScanner, param.registry, param.structures,
param.level.dimension(), param.generator, level, param.generator.getBiomeSource(), param.worldSeed, param.level.dimension(), param.generator, level, param.generator.getBiomeSource(), param.worldSeed,
param.fixerUpper); 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) 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); structFeat = new WorldGenStructFeatManager(param.worldGenSettings, genLevel, structCheck);
#elif MC_VERSION_1_17_1
structFeat = new WorldGenStructFeatManager(param.worldGenSettings, genLevel);
#endif
} }
} }
@@ -28,40 +28,37 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtOps;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.*;
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.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biomes; import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.*;
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.levelgen.Heightmap; 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.blending.BlendingData;
import net.minecraft.world.level.levelgen.feature.StructureFeature; import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.structure.StructureStart; import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext; 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.lighting.LevelLightEngine;
import net.minecraft.world.level.material.Fluid; 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; import org.apache.logging.log4j.Logger;
public class ChunkLoader public class ChunkLoader
{ {
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
private static final Codec<PalettedContainer<BlockState>> BLOCK_STATE_CODEC = PalettedContainer.codec(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState()); private static final Codec<PalettedContainer<BlockState>> 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 TAG_UPGRADE_DATA = "UpgradeData";
private static final String BLOCK_TICKS_TAG = "block_ticks"; private static final String BLOCK_TICKS_TAG = "block_ticks";
private static final String FLUID_TICKS_TAG = "fluid_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) private static BlendingData readBlendingData(CompoundTag chunkData)
{ {
BlendingData blendingData = null; BlendingData blendingData = null;
@@ -73,10 +70,13 @@ public class ChunkLoader
} }
return blendingData; return blendingData;
} }
#endif
private static LevelChunkSection[] readSections(LevelAccessor level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData) private static LevelChunkSection[] readSections(LevelAccessor level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData)
{ {
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
Registry<Biome> biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); Registry<Biome> biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
#endif
#if MC_VERSION_1_18_1 #if MC_VERSION_1_18_1
Codec<PalettedContainer<Biome>> biomeCodec = PalettedContainer.codec( Codec<PalettedContainer<Biome>> biomeCodec = PalettedContainer.codec(
biomes, biomes.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getOrThrow(Biomes.PLAINS)); biomes, biomes.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getOrThrow(Biomes.PLAINS));
@@ -92,10 +92,17 @@ public class ChunkLoader
boolean hasSkyLight = level.dimensionType().hasSkyLight(); boolean hasSkyLight = level.dimensionType().hasSkyLight();
ListTag tagSections = chunkData.getList("sections", 10); 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) for (int j = 0; j < tagSections.size(); ++j)
{ {
CompoundTag tagSection = tagSections.getCompound(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); int sectionId = level.getSectionIndexFromSectionY(sectionYPos);
if (sectionId >= 0 && sectionId < chunkSections.length) 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); lightEngine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, sectionYPos), new DataLayer(tagSection.getByteArray("BlockLight")), true);
if (hasSkyLight && tagSection.contains("SkyLight", 7)) if (hasSkyLight && tagSection.contains("SkyLight", 7))
lightEngine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, sectionYPos), new DataLayer(tagSection.getByteArray("SkyLight")), true); 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; return chunkSections;
} }
@@ -248,6 +273,7 @@ public class ChunkLoader
} }
#endif #endif
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
private static void readStructures(WorldGenLevel level, LevelChunk chunk, CompoundTag chunkData) private static void readStructures(WorldGenLevel level, LevelChunk chunk, CompoundTag chunkData)
{ {
CompoundTag tagStructures = chunkData.getCompound("structures"); CompoundTag tagStructures = chunkData.getCompound("structures");
@@ -255,7 +281,8 @@ public class ChunkLoader
unpackStructureStart(StructurePieceSerializationContext.fromLevel(level.getLevel()), tagStructures, level.getSeed())); unpackStructureStart(StructurePieceSerializationContext.fromLevel(level.getLevel()), tagStructures, level.getSeed()));
chunk.setAllReferences(unpackStructureReferences(#if MC_VERSION_1_18_2 level.registryAccess() ,#endif chunk.getPos(), tagStructures)); chunk.setAllReferences(unpackStructureReferences(#if MC_VERSION_1_18_2 level.registryAccess() ,#endif chunk.getPos(), tagStructures));
} }
#endif
private static void readPostPocessings(LevelChunk chunk, CompoundTag chunkData) private static void readPostPocessings(LevelChunk chunk, CompoundTag chunkData)
{ {
ListTag tagPostProcessings = chunkData.getList("PostProcessing", 9); ListTag tagPostProcessings = chunkData.getList("PostProcessing", 9);
@@ -272,18 +299,33 @@ public class ChunkLoader
public static ChunkStatus.ChunkType readChunkType(CompoundTag compoundTag) public static ChunkStatus.ChunkType readChunkType(CompoundTag compoundTag)
{ {
return ChunkStatus.byName(compoundTag.getString("Status")).getChunkType(); 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) 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")); ChunkPos actualPos = new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos"));
if (!Objects.equals(chunkPos, actualPos)) if (!Objects.equals(chunkPos, actualPos))
{ {
LOGGER.error("Chunk file at {} is in the wrong location; Ignoring. (Expected {}, got {})", (Object) chunkPos, (Object) chunkPos, (Object) actualPos); LOGGER.error("Chunk file at {} is in the wrong location; Ignoring. (Expected {}, got {})", (Object) chunkPos, (Object) chunkPos, (Object) actualPos);
return null; return null;
} }
#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2
ChunkStatus.ChunkType chunkType = readChunkType(chunkData); ChunkStatus.ChunkType chunkType = readChunkType(chunkData);
BlendingData blendingData = readBlendingData(chunkData); BlendingData blendingData = readBlendingData(chunkData);
if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK && (blendingData == null || !blendingData.oldNoise())) if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK && (blendingData == null || !blendingData.oldNoise()))
@@ -307,11 +349,46 @@ public class ChunkLoader
// Make chunk // Make chunk
LevelChunk chunk = new LevelChunk((Level) level, chunkPos, upgradeData, blockTicks, fluidTicks, inhabitedTime, chunkSections, null, blendingData); 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<Block> blockTicks = tagLevel.contains("TileTicks", 9)
? ChunkTickList.create(tagLevel.getList("TileTicks", 10), Registry.BLOCK::getKey, Registry.BLOCK::get)
: new ProtoTickList<Block>(block -> (block == null || block.defaultBlockState().isAir()), chunkPos,
tagLevel.getList("ToBeTicked", 9), level);
TickList<Fluid> liquidTicks = tagLevel.contains("LiquidTicks", 9)
? ChunkTickList.create(tagLevel.getList("LiquidTicks", 10), Registry.FLUID::getKey, Registry.FLUID::get)
: new ProtoTickList<Fluid>(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 // Set some states after object creation
chunk.setLightCorrect(isLightOn); #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2
readHeightmaps(chunk, chunkData);
readStructures(level, chunk, chunkData); 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); readPostPocessings(chunk, chunkData);
return chunk; return chunk;
} }
@@ -48,6 +48,15 @@ public class LightedWorldGenRegion extends WorldGenRegion {
private final ChunkPos firstPos; private final ChunkPos firstPos;
private final List<ChunkAccess> cache; private final List<ChunkAccess> cache;
Long2ObjectOpenHashMap<ChunkAccess> chunkMap = new Long2ObjectOpenHashMap<ChunkAccess>(); Long2ObjectOpenHashMap<ChunkAccess> chunkMap = new Long2ObjectOpenHashMap<ChunkAccess>();
#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, public LightedWorldGenRegion(ServerLevel serverLevel, WorldGenLevelLightEngine lightEngine,
List<ChunkAccess> list, ChunkStatus chunkStatus, int i, List<ChunkAccess> list, ChunkStatus chunkStatus, int i,
@@ -80,12 +89,14 @@ public class LightedWorldGenRegion extends WorldGenRegion {
if (k > this.writeRadius || l > this.writeRadius) { if (k > this.writeRadius || l > this.writeRadius) {
return false; return false;
} }
#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2
if (center.isUpgrading()) { if (center.isUpgrading()) {
LevelHeightAccessor levelHeightAccessor = center.getHeightAccessorForGeneration(); LevelHeightAccessor levelHeightAccessor = center.getHeightAccessorForGeneration();
if (blockPos.getY() < levelHeightAccessor.getMinBuildHeight() || blockPos.getY() >= levelHeightAccessor.getMaxBuildHeight()) { if (blockPos.getY() < levelHeightAccessor.getMinBuildHeight() || blockPos.getY() >= levelHeightAccessor.getMaxBuildHeight()) {
return false; return false;
} }
} }
#endif
return true; return true;
} }
@@ -172,7 +183,7 @@ public class LightedWorldGenRegion extends WorldGenRegion {
public ChunkAccess getChunk(int i, int j, ChunkStatus chunkStatus, boolean bl) { public ChunkAccess getChunk(int i, int j, ChunkStatus chunkStatus, boolean bl) {
ChunkAccess chunk = getChunkAccess(i, j, chunkStatus, bl); ChunkAccess chunk = getChunkAccess(i, j, chunkStatus, bl);
if (chunk instanceof LevelChunk) { 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; return chunk;
} }
@@ -244,7 +255,11 @@ public class LightedWorldGenRegion extends WorldGenRegion {
public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver)
{ {
BlockTintCache blockTintCache = (BlockTintCache) this.tintCaches.get(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); return blockTintCache.getColor(blockPos);
#endif
} }
private Biome _getBiome(BlockPos pos) { private Biome _getBiome(BlockPos pos) {
@@ -125,9 +125,16 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
LevelChunkSection[] levelChunkSections = chunkAccess.getSections(); LevelChunkSection[] levelChunkSections = chunkAccess.getSections();
for (int i = 0; i < chunkAccess.getSectionsCount(); ++i) { for (int i = 0; i < chunkAccess.getSectionsCount(); ++i) {
LevelChunkSection levelChunkSection = levelChunkSections[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; if (levelChunkSection.hasOnlyAir()) continue;
int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i); int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i);
updateSectionStatus(SectionPos.of(chunkPos, j), false); updateSectionStatus(SectionPos.of(chunkPos, j), false);
#endif
} }
enableLightSources(chunkPos, true); enableLightSources(chunkPos, true);
if (needLightBlockUpdate) { if (needLightBlockUpdate) {
@@ -6,6 +6,7 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Stream;
import com.google.common.collect.ImmutableList; 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.WorldGenSettings;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.levelgen.feature.StructureFeature; 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; import net.minecraft.world.level.levelgen.structure.StructureCheck;
#endif
import net.minecraft.world.level.levelgen.structure.StructureStart; import net.minecraft.world.level.levelgen.structure.StructureStart;
public class WorldGenStructFeatManager extends StructureFeatureManager { public class WorldGenStructFeatManager extends StructureFeatureManager {
final WorldGenLevel genLevel; final WorldGenLevel genLevel;
WorldGenSettings worldGenSettings; WorldGenSettings worldGenSettings;
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
StructureCheck structureCheck; StructureCheck structureCheck;
public WorldGenStructFeatManager(WorldGenSettings worldGenSettings, public WorldGenStructFeatManager(WorldGenSettings worldGenSettings,
WorldGenLevel genLevel, StructureCheck structureCheck) { WorldGenLevel genLevel, StructureCheck structureCheck) {
super(genLevel, worldGenSettings, structureCheck); super(genLevel, worldGenSettings, structureCheck);
this.genLevel = genLevel; this.genLevel = genLevel;
this.worldGenSettings = worldGenSettings; 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 @Override
public WorldGenStructFeatManager forWorldGenRegion(WorldGenRegion worldGenRegion) { public WorldGenStructFeatManager forWorldGenRegion(WorldGenRegion worldGenRegion) {
if (worldGenRegion == genLevel) if (worldGenRegion == genLevel)
return this; return this;
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
return new WorldGenStructFeatManager(worldGenSettings, worldGenRegion, structureCheck); 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) { 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); return genLevel.getChunk(x, z, status, false);
} }
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
@Override @Override
public boolean hasAnyStructureAt(BlockPos blockPos) { public boolean hasAnyStructureAt(BlockPos blockPos) {
SectionPos sectionPos = SectionPos.of(blockPos); SectionPos sectionPos = SectionPos.of(blockPos);
@@ -56,10 +75,28 @@ public class WorldGenStructFeatManager extends StructureFeatureManager {
if (chunk == null) return false; if (chunk == null) return false;
return chunk.hasAnyStructureReferences(); return chunk.hasAnyStructureReferences();
} }
#endif
#if MC_VERSION_1_17_1
#if MC_VERSION_1_18_1 @Override
public Stream<? extends StructureStart<?>> 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 @Override
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public List<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos, public List<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos,
@@ -83,8 +120,8 @@ public class WorldGenStructFeatManager extends StructureFeatureManager {
} }
return builder.build(); return builder.build();
} }
#elif MC_VERSION_1_18_2
#elif MC_VERSION_1_18_2
@Override @Override
public List<StructureStart> startsForFeature(SectionPos sectionPos, Predicate<ConfiguredStructureFeature<?, ?>> predicate) { public List<StructureStart> startsForFeature(SectionPos sectionPos, Predicate<ConfiguredStructureFeature<?, ?>> predicate) {
ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES); ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES);
@@ -17,7 +17,9 @@ import net.minecraft.world.level.chunk.ProtoChunk;
import net.minecraft.world.level.levelgen.DebugLevelSource; import net.minecraft.world.level.levelgen.DebugLevelSource;
import net.minecraft.world.level.levelgen.FlatLevelSource; import net.minecraft.world.level.levelgen.FlatLevelSource;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; 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; import net.minecraft.world.level.levelgen.blending.Blender;
#endif
public final class StepBiomes { public final class StepBiomes {
/** /**
@@ -48,8 +50,12 @@ public final class StepBiomes {
for (ChunkAccess chunk : chunksToDo) { for (ChunkAccess chunk : chunksToDo) {
// System.out.println("StepBiomes: "+chunk.getPos()); // 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), chunk = environment.joinSync(environment.params.generator.createBiomes(environment.params.biomes, Runnable::run, Blender.of(worldGenRegion),
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
#elif MC_VERSION_1_17_1
environment.params.generator.createBiomes(environment.params.biomes, chunk);
#endif
} }
} }
} }
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment; import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters; 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 com.seibel.lod.core.util.gridList.ArrayGridList;
import net.minecraft.ReportedException; 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.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.ProtoChunk; 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; import net.minecraft.world.level.levelgen.blending.Blender;
#endif
public final class StepFeatures { public final class StepFeatures {
/** /**
@@ -29,7 +32,7 @@ public final class StepFeatures {
public final ChunkStatus STATUS = ChunkStatus.FEATURES; public final ChunkStatus STATUS = ChunkStatus.FEATURES;
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion, public void generateGroup(ThreadedParameters tParams, LightedWorldGenRegion worldGenRegion,
ArrayGridList<ChunkAccess> chunks) { ArrayGridList<ChunkAccess> chunks) {
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>(); ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
@@ -41,9 +44,14 @@ public final class StepFeatures {
for (ChunkAccess chunk : chunksToDo) { for (ChunkAccess chunk : chunksToDo) {
try { try {
#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1
environment.params.generator.applyBiomeDecoration(worldGenRegion, chunk, environment.params.generator.applyBiomeDecoration(worldGenRegion, chunk,
tParams.structFeat.forWorldGenRegion(worldGenRegion)); tParams.structFeat.forWorldGenRegion(worldGenRegion));
Blender.generateBorderTicks(worldGenRegion, chunk); 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) { } catch (ReportedException e) {
e.printStackTrace(); e.printStackTrace();
// FIXME: Features concurrent modification issue. Something about cocobeans just // FIXME: Features concurrent modification issue. Something about cocobeans just
@@ -52,7 +52,9 @@ public final class StepLight {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2
if (chunk instanceof LevelChunk) ((LevelChunk)chunk).setClientLightReady(true); if (chunk instanceof LevelChunk) ((LevelChunk)chunk).setClientLightReady(true);
#endif
chunk.setLightCorrect(true); chunk.setLightCorrect(true);
} }
lightEngine.runUpdates(Integer.MAX_VALUE, true, true); lightEngine.runUpdates(Integer.MAX_VALUE, true, true);
@@ -19,7 +19,9 @@ import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.chunk.ProtoChunk;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseSettings; 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; import net.minecraft.world.level.levelgen.blending.Blender;
#endif
public final class StepNoise { public final class StepNoise {
/** /**
@@ -50,8 +52,13 @@ public final class StepNoise {
for (ChunkAccess chunk : chunksToDo) { for (ChunkAccess chunk : chunksToDo) {
// System.out.println("StepNoise: "+chunk.getPos()); // 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), chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion),
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); 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
} }
} }
} }
@@ -53,6 +53,8 @@ public final class StepStructureStart {
// System.out.println("StepStructureStart: "+chunk.getPos()); // System.out.println("StepStructureStart: "+chunk.getPos());
environment.params.generator.createStructures(environment.params.registry, tParams.structFeat, chunk, environment.params.structures, environment.params.generator.createStructures(environment.params.registry, tParams.structFeat, chunk, environment.params.structures,
environment.params.worldSeed); environment.params.worldSeed);
#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2
try { try {
tParams.structCheck.onStructureLoad(chunk.getPos(), chunk.getAllStarts()); tParams.structCheck.onStructureLoad(chunk.getPos(), chunk.getAllStarts());
} catch (ArrayIndexOutOfBoundsException e) { } 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 // TODO: Figure out in the future why this happens even though I am using new structFeat
throw new StepStructureStart.StructStartCorruptedException(e); throw new StepStructureStart.StructStartCorruptedException(e);
} }
#endif
} }
} }
} }
@@ -39,8 +39,11 @@ public final class StepSurface {
for (ChunkAccess chunk : chunksToDo) { for (ChunkAccess chunk : chunksToDo) {
// System.out.println("StepSurface: "+chunk.getPos()); // System.out.println("StepSurface: "+chunk.getPos());
environment.params.generator.buildSurface(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), #if MC_VERSION_1_17_1
chunk); 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
} }
} }
} }
+10 -1
View File
@@ -8,9 +8,18 @@ accessible field com/mojang/blaze3d/vertex/VertexBuffer indexCount I
accessible field com/mojang/blaze3d/vertex/VertexBuffer vertextBufferId I accessible field com/mojang/blaze3d/vertex/VertexBuffer vertextBufferId I
accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)D 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 # 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 field net/minecraft/client/renderer/LevelRenderer renderChunkStorage Ljava/util/concurrent/atomic/AtomicReference;
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkStorage accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkStorage
#endif
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk; 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 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/biome/Biome biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory;
# accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder; # 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/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 accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
+1 -1
View File
@@ -18,4 +18,4 @@ toml_version=3.6.4
manifold_version=2022.1.7 manifold_version=2022.1.7
##### FOR IDE SUPPORT AND TELL IDE TO USE CERTIAN MC VERSION: SWITCH THIS: ##### FOR IDE SUPPORT AND TELL IDE TO USE CERTIAN MC VERSION: SWITCH THIS:
mcVer=1.18.2 mcVer=1.17.1