From 9be6c5634909c479fc4507aa7651f97435ae8857 Mon Sep 17 00:00:00 2001 From: haykam821 <24855774+haykam821@users.noreply.github.com> Date: Fri, 5 Jan 2024 14:50:55 -0500 Subject: [PATCH] Update minigame to Minecraft 1.19.3 --- build.gradle | 2 +- gradle.properties | 10 +-- .../io/github/haykam821/deathswap/Main.java | 5 +- .../deathswap/block/BarrierAirBlock.java | 2 +- .../deathswap/game/DeathSwapTimer.java | 18 +++-- .../deathswap/game/EliminationCollector.java | 3 +- .../game/map/DeathSwapChunkGenerator.java | 65 +++++++++---------- .../deathswap/game/map/DeathSwapMap.java | 10 ++- .../game/map/DeathSwapMapConfig.java | 33 +++++----- .../game/phase/DeathSwapActivePhase.java | 14 ++-- .../game/phase/DeathSwapWaitingPhase.java | 6 +- .../mixin/ThreadedAnvilChunkStorageMixin.java | 32 +++++++++ .../deathswap/games/amplified_death_swap.json | 4 +- .../deathswap/games/caves_death_swap.json | 12 ---- .../data/deathswap/games/death_swap.json | 4 +- .../data/deathswap/games/end_death_swap.json | 4 +- .../games/floating_islands_death_swap.json | 12 ---- .../deathswap/games/nether_death_swap.json | 4 +- .../games/tiny_amplified_death_swap.json | 4 +- .../games/tiny_caves_death_swap.json | 14 ---- .../data/deathswap/games/tiny_death_swap.json | 4 +- .../deathswap/games/tiny_end_death_swap.json | 4 +- .../tiny_floating_islands_death_swap.json | 14 ---- .../games/tiny_nether_death_swap.json | 4 +- .../resources/data/deathswap/lang/en_us.json | 4 -- src/main/resources/deathswap.mixin.json | 11 ++++ src/main/resources/fabric.mod.json | 3 + 27 files changed, 147 insertions(+), 155 deletions(-) create mode 100644 src/main/java/io/github/haykam821/deathswap/mixin/ThreadedAnvilChunkStorageMixin.java delete mode 100644 src/main/resources/data/deathswap/games/caves_death_swap.json delete mode 100644 src/main/resources/data/deathswap/games/floating_islands_death_swap.json delete mode 100644 src/main/resources/data/deathswap/games/tiny_caves_death_swap.json delete mode 100644 src/main/resources/data/deathswap/games/tiny_floating_islands_death_swap.json create mode 100644 src/main/resources/deathswap.mixin.json diff --git a/build.gradle b/build.gradle index 1c93225..5205ff0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id "fabric-loom" version "0.11.32" + id "fabric-loom" version "1.4.6" id "maven-publish" } diff --git a/gradle.properties b/gradle.properties index 4aa9351..199698c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ mod_version = 1.0.0 org.gradle.jvmargs = -Xmx1G # Versions -minecraft_version = 1.18.2 -yarn_mappings = 1.18.2+build.3 -loader_version = 0.13.3 -fabric_version = 0.50.0+1.18.2 +minecraft_version = 1.19.3 +yarn_mappings = 1.19.3+build.5 +loader_version = 0.15.3 +fabric_version = 0.76.1+1.19.3 -plasmid_version = 0.5+1.18.2-SNAPSHOT \ No newline at end of file +plasmid_version = 0.5+1.19.3-SNAPSHOT \ No newline at end of file diff --git a/src/main/java/io/github/haykam821/deathswap/Main.java b/src/main/java/io/github/haykam821/deathswap/Main.java index e1590f6..0f991a0 100644 --- a/src/main/java/io/github/haykam821/deathswap/Main.java +++ b/src/main/java/io/github/haykam821/deathswap/Main.java @@ -7,8 +7,9 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.Block; import net.minecraft.block.Blocks; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import xyz.nucleoid.plasmid.game.GameType; public class Main implements ModInitializer { @@ -22,6 +23,6 @@ public class Main implements ModInitializer { @Override public void onInitialize() { - Registry.register(Registry.BLOCK, BARRIER_AIR_ID, BARRIER_AIR); + Registry.register(Registries.BLOCK, BARRIER_AIR_ID, BARRIER_AIR); } } diff --git a/src/main/java/io/github/haykam821/deathswap/block/BarrierAirBlock.java b/src/main/java/io/github/haykam821/deathswap/block/BarrierAirBlock.java index 2140331..6dd4b53 100644 --- a/src/main/java/io/github/haykam821/deathswap/block/BarrierAirBlock.java +++ b/src/main/java/io/github/haykam821/deathswap/block/BarrierAirBlock.java @@ -1,6 +1,6 @@ package io.github.haykam821.deathswap.block; -import eu.pb4.polymer.api.block.PolymerBlock; +import eu.pb4.polymer.core.api.block.PolymerBlock; import net.minecraft.block.AirBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/src/main/java/io/github/haykam821/deathswap/game/DeathSwapTimer.java b/src/main/java/io/github/haykam821/deathswap/game/DeathSwapTimer.java index f86d106..f083836 100644 --- a/src/main/java/io/github/haykam821/deathswap/game/DeathSwapTimer.java +++ b/src/main/java/io/github/haykam821/deathswap/game/DeathSwapTimer.java @@ -12,9 +12,7 @@ import net.minecraft.SharedConstants; import net.minecraft.entity.boss.BossBar; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import net.minecraft.util.math.Vec3d; import xyz.nucleoid.plasmid.game.common.GlobalWidgets; @@ -26,7 +24,7 @@ public class DeathSwapTimer { private static final BossBar.Color WARNING_COLOR = BossBar.Color.YELLOW; private static final Formatting NO_SWAP_FORMATTING = Formatting.GREEN; private static final Formatting WARNING_FORMATTING = Formatting.YELLOW; - private static final Text NO_SWAP_TITLE = new TranslatableText("text.deathswap.timer.no_swap"); + private static final Text NO_SWAP_TITLE = Text.translatable("text.deathswap.timer.no_swap"); private static final DecimalFormat MINUTES_FORMAT = new DecimalFormat("#.#", new DecimalFormatSymbols(Locale.ROOT)); private final DeathSwapActivePhase phase; @@ -75,7 +73,7 @@ private void swap() { Vec3d position = positions.get(index); player.teleport(position.getX(), position.getY(), position.getZ()); - Text message = new TranslatableText("text.deathswap.timer.swap", previousPlayer.getDisplayName()).formatted(NO_SWAP_FORMATTING); + Text message = Text.translatable("text.deathswap.timer.swap", previousPlayer.getDisplayName()).formatted(NO_SWAP_FORMATTING); player.sendMessage(message, true); previousPlayer = player; @@ -108,14 +106,14 @@ private Text getWarning() { double minutes = seconds / 60d; if (minutes > 1.05) { - return new TranslatableText("text.deathswap.timer.warning.minutes", MINUTES_FORMAT.format(minutes)); + return Text.translatable("text.deathswap.timer.warning.minutes", MINUTES_FORMAT.format(minutes)); } else { - return new TranslatableText("text.deathswap.timer.warning.minute"); + return Text.translatable("text.deathswap.timer.warning.minute"); } } else if (seconds == 1) { - return new TranslatableText("text.deathswap.timer.warning.second"); + return Text.translatable("text.deathswap.timer.warning.second"); } else { - return new TranslatableText("text.deathswap.timer.warning.seconds", seconds); + return Text.translatable("text.deathswap.timer.warning.seconds", seconds); } } @@ -124,7 +122,7 @@ private void setBarTitle(Text customText, Formatting formatting) { } private Text getBarTitle(Text customText, Formatting formatting) { - Text gameName = new TranslatableText("gameType.deathswap.death_swap").formatted(Formatting.BOLD); - return new LiteralText("").append(gameName).append(" - ").append(customText).formatted(formatting); + Text gameName = Text.translatable("gameType.deathswap.death_swap").formatted(Formatting.BOLD); + return Text.empty().append(gameName).append(" - ").append(customText).formatted(formatting); } } diff --git a/src/main/java/io/github/haykam821/deathswap/game/EliminationCollector.java b/src/main/java/io/github/haykam821/deathswap/game/EliminationCollector.java index fc84c5d..faa7c77 100644 --- a/src/main/java/io/github/haykam821/deathswap/game/EliminationCollector.java +++ b/src/main/java/io/github/haykam821/deathswap/game/EliminationCollector.java @@ -8,7 +8,6 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import xyz.nucleoid.plasmid.game.player.PlayerIterable; import xyz.nucleoid.plasmid.util.PlayerRef; @@ -100,7 +99,7 @@ public String toString() { } private static Text createText(String keySuffix, Formatting formatting, boolean title, Object... args) { - return new TranslatableText("text.deathswap.elimination_collector." + keySuffix, args).styled(style -> { + return Text.translatable("text.deathswap.elimination_collector." + keySuffix, args).styled(style -> { return style.withFormatting(formatting).withBold(title); }); } diff --git a/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapChunkGenerator.java b/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapChunkGenerator.java index efbfcda..898f37c 100644 --- a/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapChunkGenerator.java +++ b/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapChunkGenerator.java @@ -1,6 +1,5 @@ package io.github.haykam821.deathswap.game.map; -import java.util.Random; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; @@ -8,24 +7,22 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; +import net.minecraft.util.math.random.Random; import net.minecraft.world.ChunkRegion; import net.minecraft.world.HeightLimitView; import net.minecraft.world.Heightmap; import net.minecraft.world.StructureWorldAccess; -import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.source.BiomeAccess; import net.minecraft.world.biome.source.BiomeSource; -import net.minecraft.world.biome.source.util.MultiNoiseUtil.MultiNoiseSampler; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.GenerationStep.Carver; -import net.minecraft.world.gen.GeneratorOptions; import net.minecraft.world.gen.StructureAccessor; import net.minecraft.world.gen.chunk.Blender; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGeneratorSettings; +import net.minecraft.world.gen.chunk.NoiseChunkGenerator; import net.minecraft.world.gen.chunk.VerticalBlockSample; +import net.minecraft.world.gen.noise.NoiseConfig; import xyz.nucleoid.plasmid.game.world.generator.GameChunkGenerator; public final class DeathSwapChunkGenerator extends GameChunkGenerator { @@ -33,13 +30,18 @@ public final class DeathSwapChunkGenerator extends GameChunkGenerator { private final ChunkGenerator chunkGenerator; public DeathSwapChunkGenerator(MinecraftServer server, DeathSwapMapConfig mapConfig) { - super(server); + super(mapConfig.getDimensionOptions().chunkGenerator().getBiomeSource()); + this.mapConfig = mapConfig; + this.chunkGenerator = mapConfig.getDimensionOptions().chunkGenerator(); + } - long seed = server.getOverworld().getRandom().nextLong(); + public ChunkGeneratorSettings getSettings() { + if (this.chunkGenerator instanceof NoiseChunkGenerator noiseChunkGenerator) { + return noiseChunkGenerator.getSettings().value(); + } - RegistryKey chunkGeneratorSettingsKey = RegistryKey.of(Registry.CHUNK_GENERATOR_SETTINGS_KEY, mapConfig.getChunkGeneratorSettingsId()); - this.chunkGenerator = GeneratorOptions.createGenerator(server.getRegistryManager(), seed, chunkGeneratorSettingsKey); + return null; } private boolean isChunkPosWithinArea(ChunkPos chunkPos) { @@ -51,11 +53,11 @@ private boolean isChunkWithinArea(Chunk chunk) { } @Override - public CompletableFuture populateBiomes(Registry registry, Executor executor, Blender blender, StructureAccessor structures, Chunk chunk) { + public CompletableFuture populateBiomes(Executor executor, NoiseConfig noiseConfig, Blender blender, StructureAccessor structures, Chunk chunk) { if (this.isChunkWithinArea(chunk)) { - return this.chunkGenerator.populateBiomes(registry, executor, blender, structures, chunk); + return this.chunkGenerator.populateBiomes(executor, noiseConfig, blender, structures, chunk); } else { - return super.populateBiomes(registry, executor, blender, structures, chunk); + return super.populateBiomes(executor, noiseConfig, blender, structures, chunk); } } @@ -73,22 +75,17 @@ public void populateEntities(ChunkRegion region) { } @Override - public MultiNoiseSampler getMultiNoiseSampler() { - return this.chunkGenerator.getMultiNoiseSampler(); - } - - @Override - public CompletableFuture populateNoise(Executor executor, Blender blender, StructureAccessor structures, Chunk chunk) { + public CompletableFuture populateNoise(Executor executor, Blender blender, NoiseConfig noiseConfig, StructureAccessor structures, Chunk chunk) { if (this.isChunkWithinArea(chunk)) { - return this.chunkGenerator.populateNoise(executor, blender, structures, chunk); + return this.chunkGenerator.populateNoise(executor, blender, noiseConfig, structures, chunk); } - return super.populateNoise(executor, blender, structures, chunk); + return super.populateNoise(executor, blender, noiseConfig, structures, chunk); } @Override - public void buildSurface(ChunkRegion region, StructureAccessor structures, Chunk chunk) { + public void buildSurface(ChunkRegion region, StructureAccessor structures, NoiseConfig noiseConfig, Chunk chunk) { if (this.isChunkWithinArea(chunk)) { - this.chunkGenerator.buildSurface(region, structures, chunk); + this.chunkGenerator.buildSurface(region, structures, noiseConfig, chunk); } } @@ -123,7 +120,7 @@ private void generateWalls(int chunkX, int chunkZ, BlockPos originPos, Chunk chu // Top for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { - pos.set(x + originX, chunk.getTopY(), z + originZ); + pos.set(x + originX, topY, z + originZ); chunk.setBlockState(pos, this.getTopBarrierState(random, pos), false); } } @@ -170,17 +167,17 @@ private void generateWalls(int chunkX, int chunkZ, BlockPos originPos, Chunk chu } private BlockState getTopBarrierState(Random random, BlockPos pos) { - return this.mapConfig.getTopBarrier().getBlockState(random, pos); + return this.mapConfig.getTopBarrier().get(random, pos); } private BlockState getBarrierState(Random random, BlockPos pos) { - return this.mapConfig.getBarrier().getBlockState(random, pos); + return this.mapConfig.getBarrier().get(random, pos); } @Override - public void carve(ChunkRegion region, long seed, BiomeAccess access, StructureAccessor structures, Chunk chunk, Carver carver) { + public void carve(ChunkRegion region, long seed, NoiseConfig noiseConfig, BiomeAccess access, StructureAccessor structures, Chunk chunk, Carver carver) { if (this.isChunkWithinArea(chunk)) { - this.chunkGenerator.carve(region, seed, access, structures, chunk, carver); + this.chunkGenerator.carve(region, seed, noiseConfig, access, structures, chunk, carver); } } @@ -200,18 +197,18 @@ public int getWorldHeight() { } @Override - public int getHeight(int x, int z, Heightmap.Type heightmapType, HeightLimitView world) { + public int getHeight(int x, int z, Heightmap.Type heightmapType, HeightLimitView world, NoiseConfig noiseConfig) { if (this.isChunkPosWithinArea(new ChunkPos(x >> 4, z >> 4))) { - return this.chunkGenerator.getHeight(x, z, heightmapType, world); + return this.chunkGenerator.getHeight(x, z, heightmapType, world, noiseConfig); } - return super.getHeight(x, z, heightmapType, world); + return super.getHeight(x, z, heightmapType, world, noiseConfig); } @Override - public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView world) { + public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView world, NoiseConfig noiseConfig) { if (this.isChunkPosWithinArea(new ChunkPos(x >> 4, z >> 4))) { - return this.chunkGenerator.getColumnSample(x, z, world); + return this.chunkGenerator.getColumnSample(x, z, world, noiseConfig); } - return super.getColumnSample(x, z, world); + return super.getColumnSample(x, z, world, noiseConfig); } } diff --git a/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapMap.java b/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapMap.java index 65d05d9..ce8e512 100644 --- a/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapMap.java +++ b/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapMap.java @@ -1,7 +1,9 @@ package io.github.haykam821.deathswap.game.map; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockBox; +import net.minecraft.world.Heightmap; import net.minecraft.world.dimension.DimensionType; public final class DeathSwapMap { @@ -13,8 +15,8 @@ public DeathSwapMap(MinecraftServer server, DeathSwapMapConfig mapConfig, Dimens this.mapConfig = mapConfig; this.chunkGenerator = new DeathSwapChunkGenerator(server, this.mapConfig); - int minY = dimensionType.getMinimumY(); - int maxY = minY + dimensionType.getHeight(); + int minY = dimensionType.minY(); + int maxY = minY + dimensionType.height(); this.box = new BlockBox(1, minY + 1, 1, mapConfig.getX() * 16 - 2, maxY - 1, mapConfig.getZ() * 16 - 2); } @@ -26,4 +28,8 @@ public DeathSwapChunkGenerator getChunkGenerator() { public BlockBox getBox() { return this.box; } + + public int getSurfaceY(ServerWorld world, int x, int z) { + return this.chunkGenerator.getHeight(x, z, Heightmap.Type.WORLD_SURFACE, world, world.getChunkManager().getNoiseConfig()); + } } diff --git a/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapMapConfig.java b/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapMapConfig.java index e1edbb9..93abe61 100644 --- a/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapMapConfig.java +++ b/src/main/java/io/github/haykam821/deathswap/game/map/DeathSwapMapConfig.java @@ -5,16 +5,20 @@ import io.github.haykam821.deathswap.Main; import net.minecraft.block.Blocks; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.RegistryEntry; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.entry.RegistryFixedCodec; +import net.minecraft.world.dimension.DimensionOptions; +import net.minecraft.world.dimension.DimensionOptionsRegistryHolder; +import net.minecraft.world.gen.WorldPreset; import net.minecraft.world.gen.stateprovider.BlockStateProvider; public class DeathSwapMapConfig { public static final Codec CODEC = RecordCodecBuilder.create(instance -> { return instance.group( - DimensionType.REGISTRY_CODEC.fieldOf("dimension_type").forGetter(DeathSwapMapConfig::getDimensionType), - Identifier.CODEC.fieldOf("settings").forGetter(DeathSwapMapConfig::getChunkGeneratorSettingsId), + RegistryFixedCodec.of(RegistryKeys.WORLD_PRESET).fieldOf("preset").forGetter(mapConfig -> mapConfig.worldPreset), + RegistryKey.createCodec(RegistryKeys.DIMENSION).optionalFieldOf("dimension_options", DimensionOptions.OVERWORLD).forGetter(mapConfig -> mapConfig.dimensionOptions), BlockStateProvider.TYPE_CODEC.optionalFieldOf("barrier", BlockStateProvider.of(Blocks.BARRIER)).forGetter(DeathSwapMapConfig::getBarrier), BlockStateProvider.TYPE_CODEC.optionalFieldOf("top_barrier", BlockStateProvider.of(Main.BARRIER_AIR)).forGetter(DeathSwapMapConfig::getTopBarrier), Codec.INT.optionalFieldOf("x", 32).forGetter(DeathSwapMapConfig::getX), @@ -22,28 +26,25 @@ public class DeathSwapMapConfig { ).apply(instance, DeathSwapMapConfig::new); }); - private final RegistryEntry dimensionType; - private final Identifier chunkGeneratorSettingsId; + private final RegistryEntry worldPreset; + private final RegistryKey dimensionOptions; private final BlockStateProvider barrier; private final BlockStateProvider topBarrier; private final int x; private final int z; - public DeathSwapMapConfig(RegistryEntry dimensionType, Identifier chunkGeneratorSettingsId, BlockStateProvider barrier, BlockStateProvider topBarrier, int x, int z) { - this.dimensionType = dimensionType; - this.chunkGeneratorSettingsId = chunkGeneratorSettingsId; + public DeathSwapMapConfig(RegistryEntry worldPreset, RegistryKey dimensionOptions, BlockStateProvider barrier, BlockStateProvider topBarrier, int x, int z) { + this.worldPreset = worldPreset; + this.dimensionOptions = dimensionOptions; this.barrier = barrier; this.topBarrier = topBarrier; this.x = x; this.z = z; } - public RegistryEntry getDimensionType() { - return this.dimensionType; - } - - public Identifier getChunkGeneratorSettingsId() { - return this.chunkGeneratorSettingsId; + public DimensionOptions getDimensionOptions() { + DimensionOptionsRegistryHolder registryHolder = this.worldPreset.value().createDimensionsRegistryHolder(); + return registryHolder.dimensions().get(this.dimensionOptions); } public BlockStateProvider getBarrier() { diff --git a/src/main/java/io/github/haykam821/deathswap/game/phase/DeathSwapActivePhase.java b/src/main/java/io/github/haykam821/deathswap/game/phase/DeathSwapActivePhase.java index 4e48837..b4e6336 100644 --- a/src/main/java/io/github/haykam821/deathswap/game/phase/DeathSwapActivePhase.java +++ b/src/main/java/io/github/haykam821/deathswap/game/phase/DeathSwapActivePhase.java @@ -15,14 +15,12 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.text.MutableText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.ActionResult; import net.minecraft.util.Formatting; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameMode; import net.minecraft.world.GameRules; -import net.minecraft.world.Heightmap; import xyz.nucleoid.plasmid.game.GameCloseReason; import xyz.nucleoid.plasmid.game.GameSpace; import xyz.nucleoid.plasmid.game.common.GlobalWidgets; @@ -127,7 +125,7 @@ public void onRemovePlayer(ServerPlayerEntity player) { @Override public ActionResult onDeath(ServerPlayerEntity player, DamageSource source) { if (this.players.contains(player) && this.world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES)) { - Text message = player.getDamageTracker().getDeathMessage().shallowCopy().formatted(Formatting.RED); + Text message = player.getDamageTracker().getDeathMessage().copy().formatted(Formatting.RED); this.gameSpace.getPlayers().sendMessage(message); } this.eliminate(player, true); @@ -156,9 +154,9 @@ public EliminationCollector getEliminationCollector() { private MutableText getEndingMessage() { if (this.players.size() == 1) { ServerPlayerEntity winner = this.players.iterator().next(); - return new TranslatableText("text.deathswap.win", winner.getDisplayName()); + return Text.translatable("text.deathswap.win", winner.getDisplayName()); } - return new TranslatableText("text.deathswap.win.none"); + return Text.translatable("text.deathswap.win.none"); } private boolean eliminate(ServerPlayerEntity player, boolean remove) { @@ -184,7 +182,7 @@ private boolean eliminate(ServerPlayerEntity player, String suffix, boolean remo } private void sendEliminateMessage(ServerPlayerEntity player, String suffix) { - Text message = new TranslatableText("text.deathswap.eliminated" + suffix, player.getDisplayName()).formatted(Formatting.RED); + Text message = Text.translatable("text.deathswap.eliminated" + suffix, player.getDisplayName()).formatted(Formatting.RED); this.gameSpace.getPlayers().sendMessage(message); } @@ -200,7 +198,7 @@ public static void spawn(ServerWorld world, DeathSwapMap map, DeathSwapMapConfig int x = MathHelper.nextInt(world.getRandom(), map.getBox().getMinX(), map.getBox().getMaxX()); int z = MathHelper.nextInt(world.getRandom(), map.getBox().getMinZ(), map.getBox().getMaxZ()); - int surfaceY = map.getChunkGenerator().getHeight(x, z, Heightmap.Type.WORLD_SURFACE, world); + int surfaceY = map.getSurfaceY(world, x, z); float yaw = DeathSwapActivePhase.getSpawnYaw(world); player.teleport(world, x + 0.5, surfaceY, z + 0.5, yaw, 0); @@ -210,7 +208,7 @@ public static Vec3d getCenterPos(ServerWorld world, DeathSwapMap map, DeathSwapM int x = mapConfig.getX() * 8; int z = mapConfig.getZ() * 8; - int surfaceY = map.getChunkGenerator().getHeight(x, z, Heightmap.Type.WORLD_SURFACE, world); + int surfaceY = map.getSurfaceY(world, x, z); return new Vec3d(x + 0.5, surfaceY, z + 0.5); } diff --git a/src/main/java/io/github/haykam821/deathswap/game/phase/DeathSwapWaitingPhase.java b/src/main/java/io/github/haykam821/deathswap/game/phase/DeathSwapWaitingPhase.java index 02415bd..268d753 100644 --- a/src/main/java/io/github/haykam821/deathswap/game/phase/DeathSwapWaitingPhase.java +++ b/src/main/java/io/github/haykam821/deathswap/game/phase/DeathSwapWaitingPhase.java @@ -4,12 +4,13 @@ import io.github.haykam821.deathswap.game.map.DeathSwapMap; import net.minecraft.entity.Entity; import net.minecraft.entity.damage.DamageSource; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.EntityHitResult; -import net.minecraft.util.registry.RegistryEntry; +import net.minecraft.util.math.random.RandomSeed; import net.minecraft.world.Difficulty; import net.minecraft.world.GameMode; import net.minecraft.world.GameRules; @@ -45,10 +46,11 @@ public DeathSwapWaitingPhase(GameSpace gameSpace, ServerWorld world, DeathSwapMa public static GameOpenProcedure open(GameOpenContext context) { DeathSwapConfig config = context.config(); - RegistryEntry dimensionType = config.getMapConfig().getDimensionType(); + RegistryEntry dimensionType = config.getMapConfig().getDimensionOptions().dimensionTypeEntry(); DeathSwapMap map = new DeathSwapMap(context.server(), config.getMapConfig(), dimensionType.value()); RuntimeWorldConfig worldConfig = new RuntimeWorldConfig() + .setSeed(RandomSeed.getSeed()) .setDimensionType(dimensionType) .setGenerator(map.getChunkGenerator()) .setGameRule(GameRules.DO_MOB_SPAWNING, true) diff --git a/src/main/java/io/github/haykam821/deathswap/mixin/ThreadedAnvilChunkStorageMixin.java b/src/main/java/io/github/haykam821/deathswap/mixin/ThreadedAnvilChunkStorageMixin.java new file mode 100644 index 0000000..87dd51f --- /dev/null +++ b/src/main/java/io/github/haykam821/deathswap/mixin/ThreadedAnvilChunkStorageMixin.java @@ -0,0 +1,32 @@ +package io.github.haykam821.deathswap.mixin; + +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.Redirect; + +import io.github.haykam821.deathswap.game.map.DeathSwapChunkGenerator; +import net.minecraft.server.world.ThreadedAnvilChunkStorage; +import net.minecraft.world.gen.chunk.ChunkGenerator; +import net.minecraft.world.gen.chunk.ChunkGeneratorSettings; + +@Mixin(ThreadedAnvilChunkStorage.class) +public class ThreadedAnvilChunkStorageMixin { + @Shadow + @Final + private ChunkGenerator chunkGenerator; + + @Redirect(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/gen/chunk/ChunkGeneratorSettings;createMissingSettings()Lnet/minecraft/world/gen/chunk/ChunkGeneratorSettings;")) + private ChunkGeneratorSettings useBeaconBreakersChunkGeneratorSettings() { + if (this.chunkGenerator instanceof DeathSwapChunkGenerator deathSwapChunkGenerator) { + ChunkGeneratorSettings settings = deathSwapChunkGenerator.getSettings(); + + if (settings != null) { + return settings; + } + } + + return ChunkGeneratorSettings.createMissingSettings(); + } +} diff --git a/src/main/resources/data/deathswap/games/amplified_death_swap.json b/src/main/resources/data/deathswap/games/amplified_death_swap.json index 69f9f69..97302cf 100644 --- a/src/main/resources/data/deathswap/games/amplified_death_swap.json +++ b/src/main/resources/data/deathswap/games/amplified_death_swap.json @@ -1,8 +1,8 @@ { "type": "deathswap:death_swap", "map": { - "dimension_type": "minecraft:overworld", - "settings": "minecraft:amplified" + "dimension_options": "minecraft:overworld", + "preset": "minecraft:amplified" }, "players": { "min": 1, diff --git a/src/main/resources/data/deathswap/games/caves_death_swap.json b/src/main/resources/data/deathswap/games/caves_death_swap.json deleted file mode 100644 index 17f018f..0000000 --- a/src/main/resources/data/deathswap/games/caves_death_swap.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "deathswap:death_swap", - "map": { - "dimension_type": "minecraft:overworld_caves", - "settings": "minecraft:caves" - }, - "players": { - "min": 1, - "max": 32, - "threshold": 4 - } -} diff --git a/src/main/resources/data/deathswap/games/death_swap.json b/src/main/resources/data/deathswap/games/death_swap.json index f1a8f2e..43af60f 100644 --- a/src/main/resources/data/deathswap/games/death_swap.json +++ b/src/main/resources/data/deathswap/games/death_swap.json @@ -1,8 +1,8 @@ { "type": "deathswap:death_swap", "map": { - "dimension_type": "minecraft:overworld", - "settings": "minecraft:overworld" + "dimension_options": "minecraft:overworld", + "preset": "minecraft:normal" }, "players": { "min": 1, diff --git a/src/main/resources/data/deathswap/games/end_death_swap.json b/src/main/resources/data/deathswap/games/end_death_swap.json index 9f2f430..0af657b 100644 --- a/src/main/resources/data/deathswap/games/end_death_swap.json +++ b/src/main/resources/data/deathswap/games/end_death_swap.json @@ -1,8 +1,8 @@ { "type": "deathswap:death_swap", "map": { - "dimension_type": "minecraft:the_end", - "settings": "minecraft:end" + "dimension_options": "minecraft:the_end", + "preset": "minecraft:normal" }, "players": { "min": 1, diff --git a/src/main/resources/data/deathswap/games/floating_islands_death_swap.json b/src/main/resources/data/deathswap/games/floating_islands_death_swap.json deleted file mode 100644 index 326ba06..0000000 --- a/src/main/resources/data/deathswap/games/floating_islands_death_swap.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "deathswap:death_swap", - "map": { - "dimension_type": "minecraft:overworld", - "settings": "minecraft:floating_islands" - }, - "players": { - "min": 1, - "max": 32, - "threshold": 4 - } -} diff --git a/src/main/resources/data/deathswap/games/nether_death_swap.json b/src/main/resources/data/deathswap/games/nether_death_swap.json index 95f47ec..6308e3a 100644 --- a/src/main/resources/data/deathswap/games/nether_death_swap.json +++ b/src/main/resources/data/deathswap/games/nether_death_swap.json @@ -1,8 +1,8 @@ { "type": "deathswap:death_swap", "map": { - "dimension_type": "minecraft:the_nether", - "settings": "minecraft:nether" + "dimension_options": "minecraft:the_nether", + "preset": "minecraft:normal" }, "players": { "min": 1, diff --git a/src/main/resources/data/deathswap/games/tiny_amplified_death_swap.json b/src/main/resources/data/deathswap/games/tiny_amplified_death_swap.json index ee8ea37..d2ef411 100644 --- a/src/main/resources/data/deathswap/games/tiny_amplified_death_swap.json +++ b/src/main/resources/data/deathswap/games/tiny_amplified_death_swap.json @@ -1,8 +1,8 @@ { "type": "deathswap:death_swap", "map": { - "dimension_type": "minecraft:overworld", - "settings": "minecraft:amplified", + "dimension_options": "minecraft:overworld", + "preset": "minecraft:amplified", "x": 10, "z": 10 }, diff --git a/src/main/resources/data/deathswap/games/tiny_caves_death_swap.json b/src/main/resources/data/deathswap/games/tiny_caves_death_swap.json deleted file mode 100644 index aaf4ffa..0000000 --- a/src/main/resources/data/deathswap/games/tiny_caves_death_swap.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "deathswap:death_swap", - "map": { - "dimension_type": "minecraft:overworld_caves", - "settings": "minecraft:caves", - "x": 10, - "z": 10 - }, - "players": { - "min": 1, - "max": 32, - "threshold": 4 - } -} diff --git a/src/main/resources/data/deathswap/games/tiny_death_swap.json b/src/main/resources/data/deathswap/games/tiny_death_swap.json index 295f5b7..e223673 100644 --- a/src/main/resources/data/deathswap/games/tiny_death_swap.json +++ b/src/main/resources/data/deathswap/games/tiny_death_swap.json @@ -1,8 +1,8 @@ { "type": "deathswap:death_swap", "map": { - "dimension_type": "minecraft:overworld", - "settings": "minecraft:overworld", + "dimension_options": "minecraft:overworld", + "preset": "minecraft:normal", "x": 10, "z": 10 }, diff --git a/src/main/resources/data/deathswap/games/tiny_end_death_swap.json b/src/main/resources/data/deathswap/games/tiny_end_death_swap.json index 2819889..7612852 100644 --- a/src/main/resources/data/deathswap/games/tiny_end_death_swap.json +++ b/src/main/resources/data/deathswap/games/tiny_end_death_swap.json @@ -1,8 +1,8 @@ { "type": "deathswap:death_swap", "map": { - "dimension_type": "minecraft:the_end", - "settings": "minecraft:end", + "dimension_options": "minecraft:the_end", + "preset": "minecraft:normal", "x": 10, "z": 10 }, diff --git a/src/main/resources/data/deathswap/games/tiny_floating_islands_death_swap.json b/src/main/resources/data/deathswap/games/tiny_floating_islands_death_swap.json deleted file mode 100644 index 0de8201..0000000 --- a/src/main/resources/data/deathswap/games/tiny_floating_islands_death_swap.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "deathswap:death_swap", - "map": { - "dimension_type": "minecraft:overworld", - "settings": "minecraft:floating_islands", - "x": 10, - "z": 10 - }, - "players": { - "min": 1, - "max": 32, - "threshold": 4 - } -} diff --git a/src/main/resources/data/deathswap/games/tiny_nether_death_swap.json b/src/main/resources/data/deathswap/games/tiny_nether_death_swap.json index 85a53e3..a5e58ea 100644 --- a/src/main/resources/data/deathswap/games/tiny_nether_death_swap.json +++ b/src/main/resources/data/deathswap/games/tiny_nether_death_swap.json @@ -1,8 +1,8 @@ { "type": "deathswap:death_swap", "map": { - "dimension_type": "minecraft:the_nether", - "settings": "minecraft:nether", + "dimension_options": "minecraft:the_nether", + "preset": "minecraft:normal", "x": 10, "z": 10 }, diff --git a/src/main/resources/data/deathswap/lang/en_us.json b/src/main/resources/data/deathswap/lang/en_us.json index e3589e0..1c97239 100644 --- a/src/main/resources/data/deathswap/lang/en_us.json +++ b/src/main/resources/data/deathswap/lang/en_us.json @@ -1,16 +1,12 @@ { "block.deathswap.barrier_air": "Barrier Air", "game.deathswap.amplified_death_swap": "Amplified Death Swap", - "game.deathswap.caves_death_swap": "Caves Death Swap", "game.deathswap.death_swap": "Death Swap", "game.deathswap.end_death_swap": "End Death Swap", - "game.deathswap.floating_islands_death_swap": "Floating Islands Death Swap", "game.deathswap.nether_death_swap": "Nether Death Swap", "game.deathswap.tiny_amplified_death_swap": "Tiny Amplified Death Swap", - "game.deathswap.tiny_caves_death_swap": "Tiny Caves Death Swap", "game.deathswap.tiny_death_swap": "Tiny Death Swap", "game.deathswap.tiny_end_death_swap": "Tiny End Death Swap", - "game.deathswap.tiny_floating_islands_death_swap": "Tiny Floating Islands Death Swap", "game.deathswap.tiny_nether_death_swap": "Tiny Nether Death Swap", "gameType.deathswap.death_swap": "Death Swap", "text.deathswap.eliminated": "%s has been eliminated!", diff --git a/src/main/resources/deathswap.mixin.json b/src/main/resources/deathswap.mixin.json new file mode 100644 index 0000000..a071534 --- /dev/null +++ b/src/main/resources/deathswap.mixin.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "io.github.haykam821.deathswap.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "ThreadedAnvilChunkStorageMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 89258da..6d539b3 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -16,6 +16,9 @@ "io.github.haykam821.deathswap.Main" ] }, + "mixins": [ + "deathswap.mixin.json" + ], "license": "MIT", "icon": "assets/deathswap/icon.png", "depends": {