diff --git a/build.gradle b/build.gradle index 2bc0483..6d975d9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.2-SNAPSHOT' + id 'fabric-loom' version '1.7-SNAPSHOT' } version = project.mod_version @@ -41,8 +41,8 @@ processResources { } tasks.withType(JavaCompile).configureEach { - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. - it.options.release = 17 + // Minecraft 1.20.6 upwards uses Java 21. + it.options.release = 21 } java { @@ -51,8 +51,8 @@ java { // If you remove this line, sources will not be generated. withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { diff --git a/gradle.properties b/gradle.properties index 28ac164..99b6e73 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,14 +4,14 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.20 -yarn_mappings=1.20+build.1 -loader_version=0.14.21 +minecraft_version=1.21.1 +yarn_mappings=1.21.1+build.3 +loader_version=0.16.5 # Dependencies -fabric_version=0.83.0+1.20 +fabric_version=0.104.0+1.21.1 # Mod Properties -mod_version = 1.1.12 +mod_version = 1.1.13 maven_group = protosky archives_base_name = protosky diff --git a/src/main/java/protosky/WorldGenUtils.java b/src/main/java/protosky/WorldGenUtils.java index 7722e3d..e4dfff4 100644 --- a/src/main/java/protosky/WorldGenUtils.java +++ b/src/main/java/protosky/WorldGenUtils.java @@ -19,8 +19,6 @@ import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.*; -import net.minecraft.world.chunk.light.LightingProvider; -import protosky.mixins.ProtoChunkAccessor; import java.util.Map; import java.util.Optional; @@ -82,12 +80,12 @@ public static void genSpawnPlatform(Chunk chunk, ServerWorld world) { // Get structure for this dimension if (world.getRegistryKey() == World.OVERWORLD) { - Optional op = man.getTemplate(new Identifier("protosky:spawn_overworld")); + Optional op = man.getTemplate(Identifier.of("protosky", "spawn_overworld")); if (op.isPresent()) { s = op.get(); } } else if (world.getRegistryKey() == World.NETHER) { - Optional op = man.getTemplate(new Identifier("protosky:spawn_nether")); + Optional op = man.getTemplate(Identifier.of("protosky", "spawn_nether")); if (op.isPresent()) { s = op.get(); } diff --git a/src/main/java/protosky/mixins/ChunkStatusMixin.java b/src/main/java/protosky/mixins/ChunkGeneratingMixin.java similarity index 59% rename from src/main/java/protosky/mixins/ChunkStatusMixin.java rename to src/main/java/protosky/mixins/ChunkGeneratingMixin.java index b6295c1..d994821 100644 --- a/src/main/java/protosky/mixins/ChunkStatusMixin.java +++ b/src/main/java/protosky/mixins/ChunkGeneratingMixin.java @@ -1,54 +1,38 @@ package protosky.mixins; -import com.mojang.datafixers.util.Either; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.server.world.ServerLightingProvider; import net.minecraft.server.world.ServerWorld; -import net.minecraft.structure.StructureStart; -import net.minecraft.structure.StructureTemplateManager; -import net.minecraft.util.Identifier; +import net.minecraft.util.collection.BoundedRegionArray; import net.minecraft.world.ChunkRegion; import net.minecraft.world.Heightmap; import net.minecraft.world.World; +import net.minecraft.world.chunk.AbstractChunkHolder; import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.chunk.ProtoChunk; -import net.minecraft.world.gen.chunk.Blender; +import net.minecraft.world.chunk.ChunkGenerating; +import net.minecraft.world.chunk.ChunkGenerationContext; +import net.minecraft.world.chunk.ChunkGenerationStep; import net.minecraft.world.gen.chunk.ChunkGenerator; -import net.minecraft.world.gen.structure.Structure; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import protosky.WorldGenUtils; import protosky.stuctures.PillarHelper; import protosky.stuctures.StructureHelper; import java.util.EnumSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.function.Function; -import static protosky.ProtoSkySettings.LOGGER; - -@Mixin(ChunkStatus.class) -public abstract class ChunkStatusMixin { - @Inject(method = "method_51375", at = @At("HEAD"), cancellable = true) - //This is under ChunkStatus FEATURES. To find the inject method you need to read the bytecode. In Idea click View -> Show Bytecode - // In there search for "features" (you need the quotes). +@Mixin(ChunkGenerating.class) +public abstract class ChunkGeneratingMixin { + @Inject(method = "generateFeatures", at = @At("HEAD"), cancellable = true) //This is where blocks structures should get placed, now it's where the structures ProtoSky needs get placed. - private static void FEATURES(ChunkStatus targetStatus, ServerWorld world, ChunkGenerator generator, List chunks, Chunk chunk, CallbackInfo ci) { + private static void onGenerateFeatures(ChunkGenerationContext context, ChunkGenerationStep step, BoundedRegionArray chunks, Chunk chunk, CallbackInfoReturnable> cir) { + ServerWorld world = context.world(); + ChunkGenerator generator = context.generator(); Heightmap.populateHeightmaps(chunk, EnumSet.of(Heightmap.Type.MOTION_BLOCKING, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, Heightmap.Type.OCEAN_FLOOR, Heightmap.Type.WORLD_SURFACE)); - ChunkRegion chunkRegion = new ChunkRegion(world, chunks, targetStatus, 1); + ChunkRegion chunkRegion = new ChunkRegion(world, chunks, step, chunk); //This would normally generate structures, the blocks, not the bounding boxes. - //generator.generateFeatures(chunkRegion, chunk, world.getStructureAccessor().forRegion(chunkRegion)); - //StructureHelper.handleStructures(chunkRegion, chunk, world.getStructureAccessor().forRegion(chunkRegion), generator, false); + //context.generator().generateFeatures(chunkRegion, chunk, world.getStructureAccessor().forRegion(chunkRegion)); //Blender.tickLeavesAndFluids(chunkRegion, chunk); //Generate do the structures then delete blocks while in the end to remove the end cities @@ -69,14 +53,13 @@ private static void FEATURES(ChunkStatus targetStatus, ServerWorld world, ChunkG //This generates all the structures StructureHelper.handleStructures(chunkRegion, chunk, world.getStructureAccessor().forRegion(chunkRegion), generator, false); } - ci.cancel(); + cir.setReturnValue(CompletableFuture.completedFuture(chunk)); } - @Inject(method = "method_20614", at = @At("HEAD"), cancellable = false) - //This is under ChunkStatus INITIALIZE_LIGHT. To find the inject method you need to read the bytecode. In Idea click View -> Show Bytecode - // In there search for "initialize_light" (you need the quotes). + + @Inject(method = "initializeLight", at = @At("HEAD"), cancellable = false) //We need to move the heightmaps down to y = 0 after structures have been generated because some rely on the heightmap to move. //This used to be in the unused 'HEIGHTMAPS' status, but in 1.20 this was removed. Now we're using INITIALIZE_LIGHT. - private static void INITIALIZE_LIGHT(ChunkStatus targetStatus, Executor executor, ServerWorld world, ChunkGenerator generator, StructureTemplateManager structureTemplateManager, ServerLightingProvider lightingProvider, Function fullChunkConverter, List chunks, Chunk chunk, CallbackInfoReturnable cir) { + private static void onInitializeLight(ChunkGenerationContext context, ChunkGenerationStep step, BoundedRegionArray chunks, Chunk chunk, CallbackInfoReturnable> cir) { //Move the heightmaps down to y-64 //This gets done here not above in FEATURES because there are multiple threads that generate features. One thread // may place a structure in a chunk then move the heightmap down to y=-64 when a second structure in the chunk on @@ -88,13 +71,11 @@ private static void INITIALIZE_LIGHT(ChunkStatus targetStatus, Executor executor //ci.cancel(); } - @Inject(method = "method_17033", at = @At("HEAD"), cancellable = true) - //This is under ChunkStatus SPAWN. To find the inject method you need to read the bytecode. In Idea click View -> Show Bytecode - // In there search for "spawn" (you need the quotes). + @Inject(method = "generateEntities", at = @At("HEAD"), cancellable = true) //Spawning entities is skipped here. Even without this nothing would happen because entities from structures never // get generated because that is skipped above and non-structure entities have no blocks to spawn on so they don't spawn. // This is just an optimization - private static void SPAWN(ChunkStatus targetStatus, ServerWorld world, ChunkGenerator generator, List chunks, Chunk chunk, CallbackInfo ci) { - ci.cancel(); + private static void onGenerateEntities(ChunkGenerationContext context, ChunkGenerationStep step, BoundedRegionArray chunks, Chunk chunk, CallbackInfoReturnable> cir) { + cir.setReturnValue(CompletableFuture.completedFuture(chunk)); } } \ No newline at end of file diff --git a/src/main/java/protosky/stuctures/StructureHelper.java b/src/main/java/protosky/stuctures/StructureHelper.java index 54b26f2..e56a815 100644 --- a/src/main/java/protosky/stuctures/StructureHelper.java +++ b/src/main/java/protosky/stuctures/StructureHelper.java @@ -161,14 +161,14 @@ private static synchronized void fixRaceCondition(WorldAccess world) { StructurePieceInvoker pieceInvoker = (StructurePieceInvoker) structurePiece; - final Identifier TOP_TEMPLATE = new Identifier("igloo/top"); - final Identifier MIDDLE_TEMPLATE = new Identifier("igloo/middle"); - final Identifier BOTTOM_TEMPLATE = new Identifier("igloo/bottom"); + final Identifier TOP_TEMPLATE = Identifier.ofVanilla("igloo/top"); + final Identifier MIDDLE_TEMPLATE = Identifier.ofVanilla("igloo/middle"); + final Identifier BOTTOM_TEMPLATE = Identifier.ofVanilla("igloo/bottom"); final Map OFFSETS_FROM_TOP = ImmutableMap.of( TOP_TEMPLATE, BlockPos.ORIGIN, MIDDLE_TEMPLATE, new BlockPos(2, -3, 4), BOTTOM_TEMPLATE, new BlockPos(0, -3, -2) ); - Identifier identifier = new Identifier(simplePieceInvoker.getTemplateIdString()); + Identifier identifier = Identifier.of(simplePieceInvoker.getTemplateIdString()); StructurePlacementData structurePlacementData = iglooGeneratorPieceInvoker.invokeCreatePlacementData(simplePieceInvoker.getPlacementData().getRotation(), identifier); BlockPos blockPos = OFFSETS_FROM_TOP.get(identifier); diff --git a/src/main/resources/mixins.protosky.json b/src/main/resources/mixins.protosky.json index a9fffe6..ba28ff5 100644 --- a/src/main/resources/mixins.protosky.json +++ b/src/main/resources/mixins.protosky.json @@ -3,7 +3,7 @@ "package": "protosky.mixins", "compatibilityLevel": "JAVA_17", "mixins": [ - "ChunkStatusMixin", + "ChunkGeneratingMixin", "EnderDragonFightMixin", "ProtoChunkAccessor", "StructurePieceAccessor",