From a12092c1a1a1dc077d684730c395779653a30c96 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 14 Jun 2024 07:36:25 -0500 Subject: [PATCH] Add fabric 1.21 support --- .../common/wrappers/WrapperFactory.java | 12 ++--- .../common/wrappers/block/BiomeWrapper.java | 4 ++ .../wrappers/block/BlockStateWrapper.java | 4 ++ .../common/wrappers/chunk/ChunkWrapper.java | 10 ++++ .../common/wrappers/gui/ClassicConfigGUI.java | 8 ++- .../wrappers/gui/updater/UpdateModScreen.java | 16 +++++- .../MinecraftDedicatedServerWrapper.java | 16 +++--- .../minecraft/MinecraftRenderWrapper.java | 2 +- .../BatchGenerationEnvironment.java | 19 +++++-- .../mimicObject/ChunkLoader.java | 17 ++++-- .../mimicObject/DhGenerationChunkHolder.java | 23 ++++++++ .../mimicObject/DhLitWorldGenRegion.java | 32 +++++++++-- .../worldGeneration/step/StepBiomes.java | 26 ++++++--- .../worldGeneration/step/StepFeatures.java | 12 ++--- .../worldGeneration/step/StepNoise.java | 23 +++++--- .../step/StepStructureReference.java | 12 +++-- .../step/StepStructureStart.java | 6 ++- .../worldGeneration/step/StepSurface.java | 13 +++-- coreSubProjects | 2 +- .../fabric/FabricClientProxy.java | 7 ++- .../mixins/client/MixinLevelRenderer.java | 7 ++- .../mixins/client/MixinOptionsScreen.java | 23 +++++--- .../wrappers/modAccessor/BCLibAccessor.java | 5 +- gradle.properties | 4 +- versionProperties/1.21.properties | 54 +++++++++++++++++++ 25 files changed, 290 insertions(+), 67 deletions(-) create mode 100644 common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhGenerationChunkHolder.java create mode 100644 versionProperties/1.21.properties diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java index 7b885fc5f..115243c1d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java @@ -130,7 +130,7 @@ public class WrapperFactory implements IWrapperFactory } } - #if MC_VER <= MC_1_20_6 + #if MC_VER <= MC_1_21 else if (objectArray.length == 2) { // correct number of parameters from the API @@ -195,7 +195,7 @@ public class WrapperFactory implements IWrapperFactory { String[] expectedClassNames; - #if MC_VER <= MC_1_20_6 + #if MC_VER <= MC_1_21 expectedClassNames = new String[] { ChunkAccess.class.getName(), @@ -243,7 +243,7 @@ public class WrapperFactory implements IWrapperFactory Biome biome = (Biome) objectArray[0]; return BiomeWrapper.getBiomeWrapper(biome, coreLevelWrapper); - #elif MC_VER <= MC_1_20_6 + #elif MC_VER <= MC_1_21 if (!(objectArray[0] instanceof Holder) || !(((Holder) objectArray[0]).value() instanceof Biome)) { throw new ClassCastException(createBiomeWrapperErrorMessage(objectArray)); @@ -266,7 +266,7 @@ public class WrapperFactory implements IWrapperFactory #if MC_VER < MC_1_18_2 expectedClassNames = new String[] { Biome.class.getName() }; - #elif MC_VER <= MC_1_20_6 + #elif MC_VER <= MC_1_21 expectedClassNames = new String[] { Holder.class.getName()+"<"+Biome.class.getName()+">" }; #else // See preprocessor comment in createChunkWrapper() for full documentation @@ -287,7 +287,7 @@ public class WrapperFactory implements IWrapperFactory - #if MC_VER <= MC_1_20_6 + #if MC_VER <= MC_1_21 if (objectArray.length != 1) { throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray)); @@ -314,7 +314,7 @@ public class WrapperFactory implements IWrapperFactory #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 expectedClassNames = new String[] { Biome.class.getName() }; - #elif MC_VER <= MC_1_20_6 + #elif MC_VER <= MC_1_21 expectedClassNames = new String[] { Holder.class.getName()+"<"+Biome.class.getName()+">" }; #else // See preprocessor comment in createChunkWrapper() for full documentation diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java index f7282de12..5f1b205b0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java @@ -293,7 +293,11 @@ public class BiomeWrapper implements IBiomeWrapper ResourceLocation resourceLocation; try { + #if MC_VER < MC_1_21 resourceLocation = new ResourceLocation(resourceLocationString.substring(0, separatorIndex), resourceLocationString.substring(separatorIndex + 1)); + #else + resourceLocation = ResourceLocation.fromNamespaceAndPath(resourceLocationString.substring(0, separatorIndex), resourceLocationString.substring(separatorIndex + 1)); + #endif } catch (Exception e) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 4a40c6e1f..52b30b922 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -380,7 +380,11 @@ public class BlockStateWrapper implements IBlockStateWrapper ResourceLocation resourceLocation; try { + #if MC_VER < MC_1_21 resourceLocation = new ResourceLocation(resourceStateString.substring(0, separatorIndex), resourceStateString.substring(separatorIndex + 1)); + #else + resourceLocation = ResourceLocation.fromNamespaceAndPath(resourceStateString.substring(0, separatorIndex), resourceStateString.substring(separatorIndex + 1)); + #endif } catch (Exception e) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java index 321d02050..07f65dfca 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java @@ -292,6 +292,16 @@ public class ChunkWrapper implements IChunkWrapper public ChunkAccess getChunk() { return this.chunk; } + public ChunkStatus getStatus() { return getStatus(this.getChunk()); } + public static ChunkStatus getStatus(ChunkAccess chunk) + { + #if MC_VER < MC_1_21 + return chunk.getStatus(); + #else + return chunk.getPersistedStatus(); + #endif + } + @Override public int getMaxBlockX() { return this.chunk.getPos().getMaxBlockX(); } @Override diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java index 228c4a218..ffb8d9412 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java @@ -255,7 +255,13 @@ public class ClassicConfigGUI // texture UV Offset 0, 0, // Some textuary stuff - 0, new ResourceLocation(ModInfo.ID, "textures/gui/changelog.png"), 20, 20, + 0, + #if MC_VER < MC_1_21 + new ResourceLocation(ModInfo.ID, "textures/gui/changelog.png"), + #else + ResourceLocation.fromNamespaceAndPath(ModInfo.ID, "textures/gui/changelog.png"), + #endif + 20, 20, // Create the button and tell it where to go (buttonWidget) -> { ChangelogScreen changelogScreen = new ChangelogScreen(this); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java index 01ac2bb2f..f4d52e9d6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java @@ -75,7 +75,13 @@ public class UpdateModScreen extends DhScreen // Offset 0, 0, // Some textuary stuff - 0, new ResourceLocation(ModInfo.ID, "logo.png"), 130, 65, + 0, + #if MC_VER < MC_1_21 + new ResourceLocation(ModInfo.ID, "logo.png"), + #else + ResourceLocation.fromNamespaceAndPath(ModInfo.ID, "logo.png"), + #endif + 130, 65, // Create the button and tell it where to go // For now it goes to the client option by default (buttonWidget) -> System.out.println("Nice, you found an easter egg :)"), // TODO: Add a proper easter egg to pressing the logo (maybe with confetti) @@ -100,7 +106,13 @@ public class UpdateModScreen extends DhScreen // Offset 0, 0, // Some textuary stuff - 0, new ResourceLocation(ModInfo.ID, "textures/gui/changelog.png"), 20, 20, + 0, + #if MC_VER < MC_1_21 + new ResourceLocation(ModInfo.ID, "textures/gui/changelog.png"), + #else + ResourceLocation.fromNamespaceAndPath(ModInfo.ID, "textures/gui/changelog.png"), + #endif + 20, 20, // Create the button and tell it where to go (buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(new ChangelogScreen(this, this.newVersionID)), // TODO: Add a proper easter egg to pressing the logo (maybe with confetti) // Add a title to the button diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftDedicatedServerWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftDedicatedServerWrapper.java index af701e598..bf09dc1bd 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftDedicatedServerWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftDedicatedServerWrapper.java @@ -12,16 +12,20 @@ public class MinecraftDedicatedServerWrapper implements IMinecraftSharedWrapper private MinecraftDedicatedServerWrapper() { } public DedicatedServer dedicatedServer = null; @Override - public boolean isDedicatedServer() - { - return true; - } + public boolean isDedicatedServer() { return true; } @Override public File getInstallationDirectory() { - if (dedicatedServer == null) + if (this.dedicatedServer == null) + { throw new IllegalStateException("Trying to get Installation Direction before Dedicated server complete initialization!"); - return dedicatedServer.getServerDirectory(); + } + + #if MC_VER < MC_1_21 + return this.dedicatedServer.getServerDirectory(); + #else + return this.dedicatedServer.getServerDirectory().toFile(); + #endif } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java index a4651ae75..eba3ef2e9 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -215,7 +215,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper #if MC_VER < MC_1_17_1 Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getBlockPosition(), MC.getFrameTime()); #else - Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getFrameTime()); + Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getTimer().getRealtimeDeltaTicks()); #endif return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 4f459eeb9..a3cf7bc3e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -440,9 +440,18 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv }; totalChunks = new ArrayGridList<>(refSize, (x, z) -> emptyChunkGeneratorFunc.generate(x + refPosX, z + refPosZ)); + int radius = refSize / 2; + int centerX = refPosX + radius; + int centerZ = refPosZ + radius; + + ChunkAccess centerChunk = totalChunks.stream().filter(chunk -> chunk.getPos().x == centerX && chunk.getPos().z == centerZ).findFirst().get(); + genEvent.refreshTimeout(); - region = new DhLitWorldGenRegion(this.params.level, dummyLightEngine, totalChunks, - ChunkStatus.STRUCTURE_STARTS, refSize / 2, emptyChunkGeneratorFunc); + region = new DhLitWorldGenRegion( + centerX, centerZ, + centerChunk, + this.params.level, dummyLightEngine, totalChunks, + ChunkStatus.STRUCTURE_STARTS, radius, emptyChunkGeneratorFunc); adaptor.setRegion(region); genEvent.threadedParam.makeStructFeat(region, this.params); @@ -513,7 +522,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv throw new RuntimeException("The generated chunk somehow has isLightCorrect() returning false"); } - boolean isFull = target.getStatus() == ChunkStatus.FULL || target instanceof LevelChunk; + boolean isFull = ChunkWrapper.getStatus(target) == ChunkStatus.FULL || target instanceof LevelChunk; #if MC_VER >= MC_1_18_2 boolean isPartial = target.isOldNoiseGeneration(); #endif @@ -529,7 +538,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv genEvent.resultConsumer.accept(wrappedChunk); } #endif - else if (target.getStatus() == ChunkStatus.EMPTY) + else if (ChunkWrapper.getStatus(target) == ChunkStatus.EMPTY) { genEvent.resultConsumer.accept(wrappedChunk); } @@ -727,7 +736,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv for (int i = 0; i < chunksToGenerate.size(); i++) // regular for loop since enhanced for loops increase GC pressure slightly { ChunkWrapper chunkWrapper = chunksToGenerate.get(i); - if (chunkWrapper.getChunk().getStatus() != ChunkStatus.EMPTY) + if (chunkWrapper.getStatus() != ChunkStatus.EMPTY) { iChunkWrapperList.add(chunkWrapper); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java index 1a7ce278b..f69efe3b8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java @@ -85,6 +85,9 @@ import net.minecraft.world.level.material.Fluids; #if MC_VER == MC_1_20_6 import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraft.world.level.chunk.status.ChunkType; +#elif MC_VER == MC_1_21 +import net.minecraft.world.level.chunk.status.ChunkStatus; +import net.minecraft.world.level.chunk.status.ChunkType; #endif import net.minecraft.world.level.material.Fluid; @@ -286,7 +289,11 @@ public class ChunkLoader blockStateContainer = tagSection.contains("block_states", 10) ? BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, tagSection.getCompound("block_states")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)) - #if MC_VER < MC_1_20_6 .getOrThrow(false, LOGGER::error) #else .getOrThrow((message) -> (RuntimeException) LOGGER.errorAndThrow(message, null)) #endif + #if MC_VER < MC_1_20_6 + .getOrThrow(false, LOGGER::error) + #else + .getOrThrow((message) -> (RuntimeException) LOGGER.errorAndThrow(message, null)) + #endif : new PalettedContainer(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES); #if MC_VER < MC_1_18_2 @@ -297,7 +304,11 @@ public class ChunkLoader biomeContainer = tagSection.contains("biomes", 10) ? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, i, (String) string)) - #if MC_VER < MC_1_20_6 .getOrThrow(false, LOGGER::error) #else .getOrThrow((message) -> (RuntimeException) LOGGER.errorAndThrow(message, null)) #endif + #if MC_VER < MC_1_20_6 + .getOrThrow(false, LOGGER::error) + #else + .getOrThrow((message) -> (RuntimeException) LOGGER.errorAndThrow(message, null)) + #endif : new PalettedContainer>(biomes.asHolderIdMap(), biomes.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES); #endif @@ -312,7 +323,7 @@ public class ChunkLoader } return chunkSections; } - private static #if MC_VER < MC_1_20_6 ChunkStatus.ChunkType #else ChunkType #endif readChunkType(CompoundTag tagLevel) + private static #if MC_VER < MC_1_21 ChunkType #else ChunkType #endif readChunkType(CompoundTag tagLevel) { ChunkStatus chunkStatus = ChunkStatus.byName(tagLevel.getString("Status")); if (chunkStatus != null) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhGenerationChunkHolder.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhGenerationChunkHolder.java new file mode 100644 index 000000000..519938ce8 --- /dev/null +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhGenerationChunkHolder.java @@ -0,0 +1,23 @@ +package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject; + +#if MC_VER >= MC_1_21 + +import net.minecraft.server.level.GenerationChunkHolder; +import net.minecraft.world.level.ChunkPos; + +public class DhGenerationChunkHolder extends GenerationChunkHolder +{ + + public DhGenerationChunkHolder(ChunkPos pos) + { + super(pos); + } + + @Override + public int getTicketLevel() { return 0; } + @Override + public int getQueueLevel() { return 0; } + +} + +#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java index 8ee62a90f..ce4fd28a2 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java @@ -20,14 +20,17 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject; import java.lang.invoke.MethodHandles; +import java.util.EnumSet; import java.util.List; import java.util.concurrent.locks.ReentrantLock; +import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.util.LodUtil; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.SpawnerBlock; +import net.minecraft.world.level.chunk.status.*; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -59,7 +62,12 @@ import net.minecraft.world.level.lighting.LevelLightEngine; #if MC_VER <= MC_1_20_4 import net.minecraft.world.level.chunk.ChunkStatus; #else -import net.minecraft.world.level.chunk.status.ChunkStatus; +#endif + +#if MC_VER == MC_1_21 +import net.minecraft.util.StaticCache2D; +import com.google.common.collect.ImmutableList; +import net.minecraft.server.level.GenerationChunkHolder; #endif @@ -112,11 +120,29 @@ public class DhLitWorldGenRegion extends WorldGenRegion public DhLitWorldGenRegion( + int centerChunkX, int centerChunkZ, + ChunkAccess centerChunk, ServerLevel serverLevel, DummyLightEngine lightEngine, List chunkList, ChunkStatus chunkStatus, int writeRadius, BatchGenerationEnvironment.IEmptyChunkGeneratorFunc generator) { - super(serverLevel, chunkList #if MC_VER >= MC_1_17_1 , chunkStatus, writeRadius #endif ); + #if MC_VER == MC_1_16 + super(serverLevel, chunkList); + #elif MC_VER < MC_1_21 + super(serverLevel, chunkList, chunkStatus, writeRadius); + #else + super(serverLevel, + StaticCache2D.create( + centerChunkX, centerChunkZ, + writeRadius * 2, (x,z) -> new DhGenerationChunkHolder(new ChunkPos(x, z))), + new ChunkStep(chunkStatus, + // reverse is needed because MC uses the index of the chunkStatus to determine how many items are in the list instead of the actual list count + new ChunkDependencies(ImmutableList.copyOf(ChunkStatus.getStatusList()).reverse()), + new ChunkDependencies(ImmutableList.copyOf(ChunkStatus.getStatusList()).reverse()), + writeRadius, (WorldGenContext var1, ChunkStep var2, StaticCache2D var3, ChunkAccess var4) -> null), + centerChunk); + + #endif this.firstPos = chunkList.get(0).getPos(); this.generator = generator; this.lightEngine = lightEngine; @@ -280,7 +306,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion private ChunkAccess getChunkAccess(int chunkX, int chunkZ, ChunkStatus chunkStatus, boolean returnNonNull) { ChunkAccess chunk = this.superHasChunk(chunkX, chunkZ) ? this.superGetChunk(chunkX, chunkZ) : null; - if (chunk != null && chunk.getStatus().isOrAfter(chunkStatus)) + if (chunk != null && ChunkWrapper.getStatus(chunk).isOrAfter(chunkStatus)) { return chunk; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java index d52fdc447..7fdce78f0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java @@ -56,29 +56,39 @@ public final class StepBiomes List chunkWrappers) { - ArrayList chunksToDo = new ArrayList(); + ArrayList chunksToDo = new ArrayList<>(); for (ChunkWrapper chunkWrapper : chunkWrappers) { ChunkAccess chunk = chunkWrapper.getChunk(); - if (chunk.getStatus().isOrAfter(STATUS)) continue; - ((ProtoChunk) chunk).setStatus(STATUS); - chunksToDo.add(chunk); + if (!chunkWrapper.getStatus().isOrAfter(STATUS)) + { + #if MC_VER < MC_1_21 + ((ProtoChunk) chunk).setStatus(STATUS); + #else + ((ProtoChunk) chunk).setPersistedStatus(STATUS); + #endif + + chunksToDo.add(chunk); + } } for (ChunkAccess chunk : chunksToDo) { // System.out.println("StepBiomes: "+chunk.getPos()); #if MC_VER < MC_1_18_2 - environment.params.generator.createBiomes(environment.params.biomes, chunk); + this.environment.params.generator.createBiomes(this.environment.params.biomes, chunk); #elif MC_VER < MC_1_19_2 - chunk = environment.joinSync(environment.params.generator.createBiomes(environment.params.biomes, Runnable::run, Blender.of(worldGenRegion), + chunk = this.environment.joinSync(this.environment.params.generator.createBiomes(this.environment.params.biomes, Runnable::run, Blender.of(worldGenRegion), tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); #elif MC_VER < MC_1_19_4 - chunk = environment.joinSync(environment.params.generator.createBiomes(environment.params.biomes, Runnable::run, environment.params.randomState, Blender.of(worldGenRegion), + chunk = this.environment.joinSync(this.environment.params.generator.createBiomes(this.environment.params.biomes, Runnable::run, this.environment.params.randomState, Blender.of(worldGenRegion), + tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); + #elif MC_VER < MC_1_21 + chunk = this.environment.joinSync(this.environment.params.generator.createBiomes(Runnable::run, this.environment.params.randomState, Blender.of(worldGenRegion), tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); #else - chunk = environment.joinSync(environment.params.generator.createBiomes(Runnable::run, environment.params.randomState, Blender.of(worldGenRegion), + chunk = this.environment.joinSync(this.environment.params.generator.createBiomes(this.environment.params.randomState, Blender.of(worldGenRegion), tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java index 4f6618e1f..5ae538825 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java @@ -59,14 +59,14 @@ public final class StepFeatures for (ChunkWrapper chunkWrapper : chunkWrappers) { ChunkAccess chunk = chunkWrapper.getChunk(); - if (chunk.getStatus().isOrAfter(STATUS)) - { - continue; - } - - if (chunk instanceof ProtoChunk) + if (!chunkWrapper.getStatus().isOrAfter(STATUS) + && chunk instanceof ProtoChunk) { + #if MC_VER < MC_1_21 ((ProtoChunk) chunk).setStatus(STATUS); + #else + ((ProtoChunk) chunk).setPersistedStatus(STATUS); + #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java index a99958aac..47b524cd5 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java @@ -58,13 +58,21 @@ public final class StepNoise List chunkWrappers) { - ArrayList chunksToDo = new ArrayList(); + ArrayList chunksToDo = new ArrayList<>(); for (ChunkWrapper chunkWrapper : chunkWrappers) { ChunkAccess chunk = chunkWrapper.getChunk(); - if (chunk.getStatus().isOrAfter(STATUS)) continue; + if (chunkWrapper.getStatus().isOrAfter(STATUS)) + { + continue; + } + + #if MC_VER < MC_1_21 ((ProtoChunk) chunk).setStatus(STATUS); + #else + ((ProtoChunk) chunk).setPersistedStatus(STATUS); + #endif chunksToDo.add(chunk); } @@ -72,15 +80,18 @@ public final class StepNoise { // System.out.println("StepNoise: "+chunk.getPos()); #if MC_VER < MC_1_17_1 - environment.params.generator.fillFromNoise(worldGenRegion, tParams.structFeat, chunk); + this.environment.params.generator.fillFromNoise(worldGenRegion, tParams.structFeat, chunk); #elif MC_VER < MC_1_18_2 - chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run, + chunk = this.environment.joinSync(this.environment.params.generator.fillFromNoise(Runnable::run, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); #elif MC_VER < MC_1_19_2 - chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion), + chunk = this.environment.joinSync(this.environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion), + tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); + #elif MC_VER < MC_1_21 + chunk = this.environment.joinSync(this.environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion), this.environment.params.randomState, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); #else - chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion), environment.params.randomState, + chunk = this.environment.joinSync(this.environment.params.generator.fillFromNoise(Blender.of(worldGenRegion), this.environment.params.randomState, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); #endif UncheckedInterruptedException.throwIfInterrupted(); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java index 3894c522d..e90819967 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java @@ -59,9 +59,15 @@ public final class StepStructureReference for (ChunkWrapper chunkWrapper : chunkWrappers) { ChunkAccess chunk = chunkWrapper.getChunk(); - if (chunk.getStatus().isOrAfter(STATUS)) continue; - ((ProtoChunk) chunk).setStatus(STATUS); - chunksToDo.add(chunk); + if (!chunkWrapper.getStatus().isOrAfter(STATUS)) + { + #if MC_VER < MC_1_21 + ((ProtoChunk) chunk).setStatus(STATUS); + #else + ((ProtoChunk) chunk).setPersistedStatus(STATUS); + #endif + chunksToDo.add(chunk); + } } for (ChunkAccess chunk : chunksToDo) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java index 24e9c90b5..8c53a0c12 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java @@ -76,9 +76,13 @@ public final class StepStructureStart for (ChunkWrapper chunkWrapper : chunkWrappers) { ChunkAccess chunk = chunkWrapper.getChunk(); - if (!chunk.getStatus().isOrAfter(STATUS)) + if (!chunkWrapper.getStatus().isOrAfter(STATUS)) { + #if MC_VER < MC_1_21 ((ProtoChunk) chunk).setStatus(STATUS); + #else + ((ProtoChunk) chunk).setPersistedStatus(STATUS); + #endif chunksToDo.add(chunk); } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java index 384611a2f..0e61d70a2 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java @@ -58,9 +58,16 @@ public final class StepSurface for (ChunkWrapper chunkWrapper : chunkWrappers) { ChunkAccess chunk = chunkWrapper.getChunk(); - if (chunk.getStatus().isOrAfter(STATUS)) continue; - ((ProtoChunk) chunk).setStatus(STATUS); - chunksToDo.add(chunk); + if (!chunkWrapper.getStatus().isOrAfter(STATUS)) + { + #if MC_VER < MC_1_21 + ((ProtoChunk) chunk).setStatus(STATUS); + #else + ((ProtoChunk) chunk).setPersistedStatus(STATUS); + #endif + + chunksToDo.add(chunk); + } } for (ChunkAccess chunk : chunksToDo) diff --git a/coreSubProjects b/coreSubProjects index 54c2213eb..7b153a8aa 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 54c2213eb61879492ac29b1bf4646fcc6020af55 +Subproject commit 7b153a8aadc703209b58b8760d1dd879fdfbca4e diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index cb2153586..71e35cd76 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -208,7 +208,12 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy this.clientApi.renderLods(ClientLevelWrapper.getWrapper(renderContext.world()), modelViewMatrix, projectionMatrix, - renderContext.tickDelta()); + #if MC_VER < MC_1_21 + renderContext.tickDelta() + #else + renderContext.tickCounter().getGameTimeDeltaTicks() + #endif + ); }); // Debug keyboard event diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java index 34767a843..12bbb0421 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java @@ -120,7 +120,12 @@ public class MixinLevelRenderer ClientApi.INSTANCE.renderDeferredLods(ClientLevelWrapper.getWrapper(this.level), mcModelViewMatrix, mcProjectionMatrix, - Minecraft.getInstance().getFrameTime()); + #if MC_VER < MC_1_21 + Minecraft.getInstance().getFrameTime() + #else + Minecraft.getInstance().getTimer().getRealtimeDeltaTicks() + #endif + ); } // FIXME completely disables rendering when sodium is installed diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java index 7c4116b6d..d638536f7 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java @@ -23,16 +23,13 @@ import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen; import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget; import com.seibel.distanthorizons.coreapi.ModInfo; import com.seibel.distanthorizons.core.config.Config; -import net.minecraft.client.gui.screens.OptionsScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; #if MC_VER < MC_1_19_2 import net.minecraft.network.chat.TranslatableComponent; #endif import net.minecraft.resources.ResourceLocation; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -41,11 +38,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; -#if MC_VER == MC_1_20_6 +#if MC_VER >= MC_1_20_6 import net.minecraft.client.gui.layouts.LinearLayout; import net.minecraft.client.gui.layouts.HeaderAndFooterLayout; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Shadow; #endif +#if MC_VER < MC_1_21 +import net.minecraft.client.gui.screens.OptionsScreen; +#else +import net.minecraft.client.gui.screens.options.OptionsScreen; +#endif + + /** * Adds a button to the menu to goto the config * @@ -57,13 +63,18 @@ public class MixinOptionsScreen extends Screen { /** Texture used for the config opening button */ @Unique - private static final ResourceLocation ICON_TEXTURE = new ResourceLocation(ModInfo.ID, "textures/gui/button.png"); + private static final ResourceLocation ICON_TEXTURE = + #if MC_VER < MC_1_21 + new ResourceLocation(ModInfo.ID, "textures/gui/button.png"); + #else + ResourceLocation.fromNamespaceAndPath(ModInfo.ID, "textures/gui/button.png"); + #endif @Unique private TexturedButtonWidget optionsButton = null; - #if MC_VER == MC_1_20_6 + #if MC_VER >= MC_1_20_6 @Shadow @Final protected HeaderAndFooterLayout layout; diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/BCLibAccessor.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/BCLibAccessor.java index ed9c55488..06efa7741 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/BCLibAccessor.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/BCLibAccessor.java @@ -5,7 +5,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IBCLibAcces #elif MC_VER == MC_1_18_2 import ru.bclib.config.ClientConfig; import ru.bclib.config.Configs; -#else +#elif MC_VER < MC_1_21 import org.betterx.bclib.config.ClientConfig; import org.betterx.bclib.config.Configs; #endif @@ -17,7 +17,8 @@ public class BCLibAccessor implements IBCLibAccessor public void setRenderCustomFog(boolean newValue) { - #if !(MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 || MC_VER == MC_1_20_4 || MC_VER == MC_1_20_6) // These versions either don't have BCLib, or the implementation is different + // only some MC versions have BCLib and require this fix + #if (MC_VER > MC_1_17_1 && MC_VER < MC_1_20_4) // Change the value of CUSTOM_FOG_RENDERING in the bclib client config // This disabled fog from rendering within bclib diff --git a/gradle.properties b/gradle.properties index b66ef5dbd..6da075fb9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,7 +18,7 @@ mod_issues=https://gitlab.com/jeseibel/distant-horizons/-/issues mod_discord=https://discord.gg/xAB8G4cENx # Global Plugin Versions -manifold_version=2024.1.15 +manifold_version=2023.1.17 # 2023.1.17 can be used if there are mystery Java compiler issues nightconfig_version=3.6.6 lz4_version=1.8.0 @@ -49,7 +49,7 @@ versionStr= # This defines what MC version Intellij will use for the preprocessor # and what version is used automatically by build and run commands -mcVer=1.20.6 +mcVer=1.21 # Defines the maximum amount of memory Minecraft is allowed when run in a development environment #minecraftMemoryJavaArg="-Xmx4G" diff --git a/versionProperties/1.21.properties b/versionProperties/1.21.properties new file mode 100644 index 000000000..e16886c23 --- /dev/null +++ b/versionProperties/1.21.properties @@ -0,0 +1,54 @@ +# 1.21 version +java_version=21 +minecraft_version=1.21 +parchment_version=1.20.6:2024.05.01 +compatible_minecraft_versions=["1.21.0"] +accessWidenerVersion=1_20_6 +builds_for=fabric +# neoforge +# forge is broken due to gradle/build script issues + +# Fabric loader +fabric_loader_version=0.15.11 +fabric_api_version=0.100.1+1.21 + # Fabric mod versions + modmenu_version=11.0.0-beta.1 + starlight_version_fabric= + phosphor_version_fabric= + lithium_version= + sodium_version=mc1.21-0.5.9 + iris_version=1.7.1+1.21 + bclib_version= + immersive_portals_version= + canvas_version= + + fabric_incompatibility_list={ "iris": "<=1.6.20" } + fabric_recommend_list={} + + # Fabric mod run + # 0 = Don't enable and don't run + # 1 = Can be referenced in code but doesn't run + # 2 = Can be referenced in code and runs in client + enable_starlight=0 + enable_phosphor=0 + enable_sodium=1 + enable_lithium=0 + enable_iris=1 + enable_bclib=0 + enable_immersive_portals=0 + enable_canvas=0 + +# (Neo)Forge loader +forge_version=50.0.19 +neoforge_version=20.6.70-beta + # (Neo)Forge mod versions + starlight_version_forge= + terraforged_version= + + # (Neo)Forge mod run + # 0 = Don't enable and don't run + # 1 = Can be referenced in code but doesn't run + # 2 = Can be referenced in code and runs in client + enable_starlight_forge=0 + enable_terraforged=0 + enable_terrafirmacraft=0