diff --git a/build.gradle b/build.gradle index 0a5ab592..26fcc2f6 100644 --- a/build.gradle +++ b/build.gradle @@ -109,6 +109,7 @@ subprojects { name = 'tterrag maven' url = 'https://maven.tterrag.com/' } + maven { url = "https://modmaven.dev/" } // Twilight Forest maven { url = "https://api.modrinth.com/maven" } // LazyDFU, Suggestion Tweaker, Create Big Cannons maven { url = "https://maven.shedaniel.me/" } // Cloth Config, REI maven { url "https://maven.architectury.dev/" } diff --git a/forge/build.gradle b/forge/build.gradle index 91998b06..bd1df6b3 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -67,6 +67,9 @@ dependencies { //modCompileOnly("curse.maven:rubidium-574856:4024781") modCompileOnly("maven.modrinth:embeddium:${embeddium_version}") + // Twilight Forest + modImplementation("teamtwilight:twilightforest:${twilightforest_version}:universal") + // Create compat modImplementation("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false } modImplementation("com.jozufozu.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}") diff --git a/forge/gradle.properties b/forge/gradle.properties index 99ddb012..fba90cc9 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -10,6 +10,9 @@ cloth_config_version = 11.1.106 create_version = 0.5.1.e-22 flywheel_version = 0.6.10-7 registrate_version = MC1.20-1.3.3 + +# https://modmaven.dev/teamtwilight/twilightforest/ +twilightforest_version = 4.3.2145 cc_tweaked_version = 1.109.0-forge #Extra # https://modrinth.com/mod/tis3d/version/MC1.19.2-forge-1.7.4 diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/ChunkGeneratorTwilightMixin.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/ChunkGeneratorTwilightMixin.java new file mode 100644 index 00000000..4a2502a3 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/ChunkGeneratorTwilightMixin.java @@ -0,0 +1,79 @@ +package org.valkyrienskies.mod.forge.mixin.compat.twilightforest; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderSet; +import net.minecraft.core.RegistryAccess; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.WorldGenRegion; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.LevelHeightAccessor; +import net.minecraft.world.level.NoiseColumn; +import net.minecraft.world.level.StructureManager; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkGeneratorStructureState; +import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; +import net.minecraft.world.level.levelgen.NoiseSettings; +import net.minecraft.world.level.levelgen.RandomState; +import net.minecraft.world.level.levelgen.blending.Blender; +import net.minecraft.world.level.levelgen.structure.Structure; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +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 org.valkyrienskies.mod.common.VS2ChunkAllocator; +import twilightforest.world.components.chunkgenerators.ChunkGeneratorTwilight; + +@Mixin(ChunkGeneratorTwilight.class) +public class ChunkGeneratorTwilightMixin { + @Shadow + @Final + protected Holder noiseGeneratorSettings; + + @Inject(method = "getBaseColumn", at = @At("HEAD"), cancellable = true) + private void preGetBaseColumn(int x, int y, LevelHeightAccessor level, RandomState random, CallbackInfoReturnable cir) { + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(x, y)) { + final NoiseSettings ns = this.noiseGeneratorSettings.value().noiseSettings(); + final int k = Math.max(ns.minY(), level.getMinBuildHeight()); + cir.setReturnValue(new NoiseColumn(k, new BlockState[0])); + } + } + + @Inject(method = "buildSurface", at = @At("HEAD"), cancellable = true) + private void preBuildSurface(WorldGenRegion world, StructureManager manager, RandomState random, ChunkAccess chunk, CallbackInfo ci) { + final ChunkPos chunkPos = chunk.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + ci.cancel(); + } + } + + @Inject(method = "fillFromNoise", at = @At("HEAD"), cancellable = true) + private void preFillFromNoise(Executor executor, Blender blender, RandomState random, StructureManager structureManager, ChunkAccess chunk, CallbackInfoReturnable> cir) { + final ChunkPos chunkPos = chunk.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + cir.setReturnValue(CompletableFuture.completedFuture(chunk)); + } + } + + @Inject(method = "createStructures", at = @At("HEAD"), cancellable = true) + private void preCreateStructures(RegistryAccess access, ChunkGeneratorStructureState state, StructureManager manager, ChunkAccess chunk, StructureTemplateManager templateManager, CallbackInfo ci) { + final ChunkPos chunkPos = chunk.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + ci.cancel(); + } + } + + @Inject(method = "findNearestMapStructure", at = @At("HEAD"), cancellable = true) + private void preFindNearestMapStructure(ServerLevel level, HolderSet targetStructures, BlockPos pos, int searchRadius, boolean skipKnownStructures, CallbackInfoReturnable cir) { + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(pos.getX() >> 4, pos.getZ() >> 4)) { + cir.setReturnValue(null); + } + } +} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/README.MD b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/README.MD new file mode 100644 index 00000000..0c5ecd12 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/README.MD @@ -0,0 +1,7 @@ +Just a smidgen of compatibility code for twilight forest + +- ChunkGeneratorTwilightMixin + - Fixes world generation not being cancelled within the shipyard in the + twilight forest. TF uses its own ChunkGenerator implementation but it has + all the same methods as the vanilla NoiseBasedChunkGenerator so the same + mixins work. diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 07125e96..f98e1c0f 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -14,6 +14,7 @@ "compat.tfc.MixinTFCChunkGenerator", "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", + "compat.twilightforest.ChunkGeneratorTwilightMixin", "feature.forge_interact.MixinIForgePlayer", "feature.water_in_ships_entity.MixinEntity", "feature.shipyard_entities.MixinPersistentEntitySectionManager",