From 056aaa1edafa7bf5a4e4d1b38fc3300b882d6851 Mon Sep 17 00:00:00 2001 From: Patbox <39821509+Patbox@users.noreply.github.com> Date: Mon, 20 Jun 2022 21:34:02 +0200 Subject: [PATCH] Update to 1.19 --- build.gradle | 25 +++++-- gradle.properties | 8 +-- .../xyz/nucleoid/fantasy/RuntimeWorld.java | 3 +- .../fantasy/util/FilteredRegistry.java | 15 +++- .../fantasy/util/VoidChunkGenerator.java | 72 ++++++++++++------- .../data/fantasy/dimension_type/default.json | 2 + src/main/resources/fabric.mod.json | 4 +- .../nucleoid/fantasy/FantasyInitializer.java | 20 ------ .../fantasy/test/FantasyInitializer.java | 27 +++++++ 9 files changed, 118 insertions(+), 58 deletions(-) delete mode 100644 src/testmod/java/xyz/nucleoid/fantasy/FantasyInitializer.java create mode 100644 src/testmod/java/xyz/nucleoid/fantasy/test/FantasyInitializer.java diff --git a/build.gradle b/build.gradle index 939176b..332a28e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.11-SNAPSHOT' + id 'fabric-loom' version '0.12-SNAPSHOT' id 'maven-publish' } @@ -10,9 +10,6 @@ archivesBaseName = project.archives_base_name version = project.mod_version + "+" + project.minecraft_version group = project.maven_group -loom { - accessWidenerPath = file("src/main/resources/fantasy.accesswidener") -} sourceSets { testmod { @@ -21,8 +18,26 @@ sourceSets { } } +loom { + runs { + testmodClient { + client() + name = "Testmod Client" + source sourceSets.testmod + } + testmodServer { + server() + name = "Testmod Server" + source sourceSets.testmod + } + } + + accessWidenerPath = file("src/main/resources/fantasy.accesswidener") +} + repositories { maven { url = "https://maven.gegy.dev/" } + maven { url = "https://maven.nucleoid.xyz/" } } dependencies { @@ -32,6 +47,8 @@ dependencies { modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modLocalRuntime "eu.pb4:polymer-reg-sync-manipulator:0.0.1+1.19" + testmodImplementation sourceSets.main.output } diff --git a/gradle.properties b/gradle.properties index d3feb55..2afe731 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,9 +2,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties -minecraft_version=1.18.2 -yarn_mappings=1.18.2+build.1 -loader_version=0.13.3 +minecraft_version=1.19 +yarn_mappings=1.19+build.4 +loader_version=0.14.7 # Mod Properties mod_version=0.4.5 @@ -12,4 +12,4 @@ maven_group=xyz.nucleoid archives_base_name=fantasy # Dependencies -fabric_version=0.47.8+1.18.2 +fabric_version=0.56.1+1.19 diff --git a/src/main/java/xyz/nucleoid/fantasy/RuntimeWorld.java b/src/main/java/xyz/nucleoid/fantasy/RuntimeWorld.java index 7d3a0fc..4109395 100644 --- a/src/main/java/xyz/nucleoid/fantasy/RuntimeWorld.java +++ b/src/main/java/xyz/nucleoid/fantasy/RuntimeWorld.java @@ -20,9 +20,8 @@ class RuntimeWorld extends ServerWorld { server, Util.getMainWorkerExecutor(), ((MinecraftServerAccess) server).getSession(), new RuntimeWorldProperties(server.getSaveProperties(), config), registryKey, - config.createDimensionOptions(server).getDimensionTypeSupplier(), + config.createDimensionOptions(server), VoidWorldProgressListener.INSTANCE, - config.getGenerator(), false, BiomeAccess.hashSeed(config.getSeed()), ImmutableList.of(), diff --git a/src/main/java/xyz/nucleoid/fantasy/util/FilteredRegistry.java b/src/main/java/xyz/nucleoid/fantasy/util/FilteredRegistry.java index 312d473..fad264e 100644 --- a/src/main/java/xyz/nucleoid/fantasy/util/FilteredRegistry.java +++ b/src/main/java/xyz/nucleoid/fantasy/util/FilteredRegistry.java @@ -2,6 +2,7 @@ import com.google.common.collect.Iterators; import com.mojang.datafixers.util.Pair; +import com.mojang.serialization.DataResult; import com.mojang.serialization.Lifecycle; import net.minecraft.tag.TagKey; import net.minecraft.util.Identifier; @@ -96,8 +97,13 @@ public Set, T>> getEntrySet() { } @Override - public Optional> getRandom(Random random) { - return this.getRandom(random); + public Set> getKeys() { + return null; + } + + @Override + public Optional> getRandom(net.minecraft.util.math.random.Random random) { + return Optional.empty(); } @Override @@ -120,6 +126,11 @@ public RegistryEntry getOrCreateEntry(RegistryKey key) { return this.source.getOrCreateEntry(key); } + @Override + public DataResult> getOrCreateEntryDataResult(RegistryKey key) { + return null; + } + @Override public RegistryEntry.Reference createEntry(T value) { return null; diff --git a/src/main/java/xyz/nucleoid/fantasy/util/VoidChunkGenerator.java b/src/main/java/xyz/nucleoid/fantasy/util/VoidChunkGenerator.java index 66b87d5..e757999 100644 --- a/src/main/java/xyz/nucleoid/fantasy/util/VoidChunkGenerator.java +++ b/src/main/java/xyz/nucleoid/fantasy/util/VoidChunkGenerator.java @@ -1,12 +1,18 @@ package xyz.nucleoid.fantasy.util; +import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Codec; import com.mojang.serialization.Lifecycle; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.block.BlockState; -import net.minecraft.structure.StructureManager; +import net.minecraft.entity.SpawnGroup; +import net.minecraft.server.world.ServerWorld; import net.minecraft.structure.StructureSet; +import net.minecraft.structure.StructureTemplateManager; +import net.minecraft.util.collection.Pool; +import net.minecraft.util.dynamic.CodecHolder; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; import net.minecraft.util.registry.*; import net.minecraft.world.ChunkRegion; import net.minecraft.world.HeightLimitView; @@ -14,6 +20,7 @@ import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeKeys; +import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.biome.source.BiomeAccess; import net.minecraft.world.biome.source.FixedBiomeSource; import net.minecraft.world.biome.source.util.MultiNoiseUtil; @@ -23,7 +30,11 @@ import net.minecraft.world.gen.chunk.Blender; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.VerticalBlockSample; +import net.minecraft.world.gen.chunk.placement.ConcentricRingsStructurePlacement; import net.minecraft.world.gen.densityfunction.DensityFunction; +import net.minecraft.world.gen.noise.NoiseConfig; +import net.minecraft.world.gen.structure.Structure; +import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.List; @@ -70,8 +81,8 @@ public double maxValue() { } @Override - public Codec getCodec() { - return Codec.unit(this); + public CodecHolder getCodec() { + return CodecHolder.of(Codec.unit(this)); } }; @@ -101,47 +112,53 @@ protected Codec getCodec() { } @Override - public ChunkGenerator withSeed(long seed) { - return this; + public void carve(ChunkRegion chunkRegion, long seed, NoiseConfig noiseConfig, BiomeAccess world, StructureAccessor structureAccessor, Chunk chunk, GenerationStep.Carver carverStep) { + } @Override - public MultiNoiseUtil.MultiNoiseSampler getMultiNoiseSampler() { - return EMPTY_SAMPLER; + public void addStructureReferences(StructureWorldAccess world, StructureAccessor accessor, Chunk chunk) { } @Override - public void carve(ChunkRegion chunkRegion, long seed, BiomeAccess biomeAccess, StructureAccessor structureAccessor, Chunk chunk, GenerationStep.Carver generationStep) { - + public CompletableFuture populateNoise(Executor executor, Blender blender, NoiseConfig noiseConfig, StructureAccessor structureAccessor, Chunk chunk) { + return CompletableFuture.completedFuture(chunk); } @Override - public void setStructureStarts(DynamicRegistryManager registryManager, StructureAccessor accessor, Chunk chunk, StructureManager manager, long seed) { + public int getSeaLevel() { + return 0; } @Override - public void addStructureReferences(StructureWorldAccess world, StructureAccessor accessor, Chunk chunk) { + public int getMinimumY() { + return 0; } @Override - public CompletableFuture populateNoise(Executor executor, Blender blender, StructureAccessor structureAccessor, Chunk chunk) { - return CompletableFuture.completedFuture(chunk); + public int getHeight(int x, int z, Heightmap.Type heightmap, HeightLimitView world, NoiseConfig noiseConfig) { + return 0; } @Override - public int getSeaLevel() { - return 0; + public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView world, NoiseConfig noiseConfig) { + return EMPTY_SAMPLE; } @Override - public int getMinimumY() { - return 0; + public void getDebugHudText(List text, NoiseConfig noiseConfig, BlockPos pos) { + } @Override public void generateFeatures(StructureWorldAccess world, Chunk chunk, StructureAccessor structureAccessor) { } + @Override + public void buildSurface(ChunkRegion region, StructureAccessor structures, NoiseConfig noiseConfig, Chunk chunk) { + + } + @Override public void populateEntities(ChunkRegion region) { } @@ -151,23 +168,30 @@ public int getWorldHeight() { return 0; } + @Nullable @Override - public int getHeight(int x, int z, Heightmap.Type heightmap, HeightLimitView world) { - return 0; + public Pair> locateStructure(ServerWorld world, RegistryEntryList structures, BlockPos center, int radius, boolean skipReferencedStructures) { + return null; } @Override - public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView world) { - return EMPTY_SAMPLE; + public boolean shouldStructureGenerateInRange(RegistryEntry structureSet, NoiseConfig noiseConfig, long seed, int chunkX, int chunkZ, int chunkRange) { + return false; } @Override - public void getDebugHudText(List text, BlockPos pos) { - + public Pool getEntitySpawnList(RegistryEntry biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos) { + return Pool.empty(); } @Override - public void buildSurface(ChunkRegion region, StructureAccessor structures, Chunk chunk) { + public void setStructureStarts(DynamicRegistryManager registryManager, NoiseConfig noiseConfig, StructureAccessor structureAccessor, Chunk chunk, StructureTemplateManager structureTemplateManager, long seed) { } + + @Nullable + @Override + public List getConcentricRingsStartChunks(ConcentricRingsStructurePlacement structurePlacement, NoiseConfig noiseConfig) { + return null; + } } diff --git a/src/main/resources/data/fantasy/dimension_type/default.json b/src/main/resources/data/fantasy/dimension_type/default.json index 8e82889..71aa996 100644 --- a/src/main/resources/data/fantasy/dimension_type/default.json +++ b/src/main/resources/data/fantasy/dimension_type/default.json @@ -6,6 +6,8 @@ "respawn_anchor_works": false, "has_raids": true, "min_y": 0, + "monster_spawn_block_light_limit": 0, + "monster_spawn_light_level": 0, "height": 256, "natural": true, "coordinate_scale": 1.0, diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1cd1356..0eea21c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -19,8 +19,8 @@ } }, "depends": { - "fabricloader": ">=0.11.3", - "minecraft": "1.18.x", + "fabricloader": ">=0.14.0", + "minecraft": "1.19.x", "fabric-lifecycle-events-v1": "*", "java": ">=17" } diff --git a/src/testmod/java/xyz/nucleoid/fantasy/FantasyInitializer.java b/src/testmod/java/xyz/nucleoid/fantasy/FantasyInitializer.java deleted file mode 100644 index 47c9db4..0000000 --- a/src/testmod/java/xyz/nucleoid/fantasy/FantasyInitializer.java +++ /dev/null @@ -1,20 +0,0 @@ -package xyz.nucleoid.fantasy; - -import com.mojang.brigadier.CommandDispatcher; -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import xyz.nucleoid.fantasy.util.VoidChunkGenerator; - -public final class FantasyInitializer implements ModInitializer { - @Override - public void onInitialize() { - CommandRegistrationCallback.EVENT.register(FantasyInitializer::registerCommands); - } - - private static void registerCommands(CommandDispatcher dispatcher, boolean b) { - - } -} diff --git a/src/testmod/java/xyz/nucleoid/fantasy/test/FantasyInitializer.java b/src/testmod/java/xyz/nucleoid/fantasy/test/FantasyInitializer.java new file mode 100644 index 0000000..9ab5d64 --- /dev/null +++ b/src/testmod/java/xyz/nucleoid/fantasy/test/FantasyInitializer.java @@ -0,0 +1,27 @@ +package xyz.nucleoid.fantasy.test; + +import com.mojang.brigadier.CommandDispatcher; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; +import xyz.nucleoid.fantasy.Fantasy; +import xyz.nucleoid.fantasy.RuntimeWorldConfig; +import xyz.nucleoid.fantasy.util.VoidChunkGenerator; + +public final class FantasyInitializer implements ModInitializer { + @Override + public void onInitialize() { + ServerLifecycleEvents.SERVER_STARTED.register((s) -> { + Fantasy.get(s).openTemporaryWorld(new RuntimeWorldConfig().setGenerator(new VoidChunkGenerator(s.getRegistryManager().get(Registry.BIOME_KEY).getEntry(0).get()))); + Fantasy.get(s).getOrOpenPersistentWorld( + new Identifier("fantasytest:test"), + new RuntimeWorldConfig() + .setGenerator(s.getOverworld().getChunkManager().getChunkGenerator()) + ); + }); + } + +}