diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0aac695..7284c5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: with: cache: gradle distribution: microsoft - java-version: 21 + java-version: 25 - name: Build with Gradle run: gradle build - name: Upload Artifacts diff --git a/build.gradle b/build.gradle index 0bd809d..70a2d5f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,15 @@ plugins { - id "fabric-loom" version "1.10.5" + id "net.fabricmc.fabric-loom" version "1.15+" id "maven-publish" } -archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group +base { + archivesName = project.archives_base_name +} + repositories { maven { name = "Fabric" @@ -21,14 +24,13 @@ repositories { dependencies { // Main minecraft("com.mojang:minecraft:${project.minecraft_version}") - mappings("net.fabricmc:yarn:${project.yarn_mappings}:v2") - modImplementation("net.fabricmc:fabric-loader:${project.loader_version}") + implementation("net.fabricmc:fabric-loader:${project.loader_version}") // Fabric API - modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}") + implementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}") // Plasmid - modImplementation("xyz.nucleoid:plasmid:${project.plasmid_version}") + implementation("xyz.nucleoid:plasmid:${project.plasmid_version}") } processResources { @@ -40,12 +42,12 @@ processResources { } java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_25 + targetCompatibility = JavaVersion.VERSION_25 } tasks.withType(JavaCompile) { - options.release = 21 + options.release = 25 options.encoding = "UTF-8" } diff --git a/gradle.properties b/gradle.properties index 5b24aad..58dd4e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,8 @@ mod_version = 1.0.0 org.gradle.jvmargs = -Xmx1G # Versions -minecraft_version = 1.21.4 -yarn_mappings = 1.21.4+build.8 -loader_version = 0.16.14 -fabric_version = 0.119.2+1.21.4 +minecraft_version = 26.2 +loader_version = 0.19.2 +fabric_version = 0.145.2+26.2 -plasmid_version = 0.6.3+1.21.4 \ No newline at end of file +plasmid_version = 0.7.2-SNAPSHOT+26.2 \ No newline at end of file diff --git a/src/main/java/io/github/haykam821/anvildrop/Main.java b/src/main/java/io/github/haykam821/anvildrop/Main.java index 7fd87da..3743c34 100644 --- a/src/main/java/io/github/haykam821/anvildrop/Main.java +++ b/src/main/java/io/github/haykam821/anvildrop/Main.java @@ -3,14 +3,15 @@ import io.github.haykam821.anvildrop.game.AnvilDropConfig; import io.github.haykam821.anvildrop.game.phase.AnvilDropWaitingPhase; import net.fabricmc.api.ModInitializer; -import net.minecraft.util.Identifier; +import net.minecraft.resources.Identifier; import xyz.nucleoid.plasmid.api.game.GameType; +import xyz.nucleoid.plasmid.api.game.GameTypes; public class Main implements ModInitializer { private static final String MOD_ID = "anvildrop"; private static final Identifier ANVIL_DROP_ID = Main.identifier("anvil_drop"); - public static final GameType ANVIL_DROP_TYPE = GameType.register(ANVIL_DROP_ID, AnvilDropConfig.CODEC, AnvilDropWaitingPhase::open); + public static final GameType ANVIL_DROP_TYPE = GameTypes.register(ANVIL_DROP_ID, AnvilDropConfig.CODEC, AnvilDropWaitingPhase::open); @Override public void onInitialize() { @@ -18,6 +19,6 @@ public void onInitialize() { } public static Identifier identifier(String path) { - return Identifier.of(MOD_ID, path); + return Identifier.fromNamespaceAndPath(MOD_ID, path); } } \ No newline at end of file diff --git a/src/main/java/io/github/haykam821/anvildrop/game/AnvilDropConfig.java b/src/main/java/io/github/haykam821/anvildrop/game/AnvilDropConfig.java index a312e03..c45ef9e 100644 --- a/src/main/java/io/github/haykam821/anvildrop/game/AnvilDropConfig.java +++ b/src/main/java/io/github/haykam821/anvildrop/game/AnvilDropConfig.java @@ -6,8 +6,9 @@ import io.github.haykam821.anvildrop.game.map.AnvilDropMapConfig; import net.minecraft.SharedConstants; -import net.minecraft.util.math.intprovider.ConstantIntProvider; -import net.minecraft.util.math.intprovider.IntProvider; +import net.minecraft.util.valueproviders.ConstantInt; +import net.minecraft.util.valueproviders.IntProvider; +import net.minecraft.util.valueproviders.IntProviders; import xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig; public class AnvilDropConfig { @@ -15,7 +16,7 @@ public class AnvilDropConfig { return instance.group( AnvilDropMapConfig.CODEC.fieldOf("map").forGetter(AnvilDropConfig::getMapConfig), WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(AnvilDropConfig::getPlayerConfig), - IntProvider.NON_NEGATIVE_CODEC.optionalFieldOf("ticks_until_close", ConstantIntProvider.create(SharedConstants.TICKS_PER_SECOND * 5)).forGetter(AnvilDropConfig::getTicksUntilClose), + IntProviders.NON_NEGATIVE_CODEC.optionalFieldOf("ticks_until_close", ConstantInt.of(SharedConstants.TICKS_PER_SECOND * 5)).forGetter(AnvilDropConfig::getTicksUntilClose), Codec.INT.optionalFieldOf("delay", 20 * 2).forGetter(AnvilDropConfig::getDelay), Codec.DOUBLE.optionalFieldOf("chance", 0.4).forGetter(AnvilDropConfig::getChance), Codec.INT.optionalFieldOf("drop_height", 15).forGetter(AnvilDropConfig::getDropHeight), diff --git a/src/main/java/io/github/haykam821/anvildrop/game/map/AnvilDropMap.java b/src/main/java/io/github/haykam821/anvildrop/game/map/AnvilDropMap.java index baee792..abef828 100644 --- a/src/main/java/io/github/haykam821/anvildrop/game/map/AnvilDropMap.java +++ b/src/main/java/io/github/haykam821/anvildrop/game/map/AnvilDropMap.java @@ -3,28 +3,28 @@ import java.util.Iterator; import io.github.haykam821.anvildrop.game.AnvilDropConfig; -import net.minecraft.block.AnvilBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.world.level.block.AnvilBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.Direction; -import net.minecraft.world.gen.chunk.ChunkGenerator; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.AABB; +import net.minecraft.core.Direction; +import net.minecraft.world.level.chunk.ChunkGenerator; import xyz.nucleoid.map_templates.BlockBounds; import xyz.nucleoid.map_templates.MapTemplate; -import xyz.nucleoid.plasmid.api.game.world.generator.TemplateChunkGenerator; +import xyz.nucleoid.plasmid.api.game.level.generator.TemplateChunkGenerator; public class AnvilDropMap { - private static final BlockState CLEAR_STATE = Blocks.AIR.getDefaultState(); - private static final BlockState ANVIL_STATE = Blocks.ANVIL.getDefaultState(); - private static final BlockState ALTERNATE_ANVIL_STATE = Blocks.ANVIL.getDefaultState().with(AnvilBlock.FACING, Direction.EAST); + private static final BlockState CLEAR_STATE = Blocks.AIR.defaultBlockState(); + private static final BlockState ANVIL_STATE = Blocks.ANVIL.defaultBlockState(); + private static final BlockState ALTERNATE_ANVIL_STATE = Blocks.ANVIL.defaultBlockState().setValue(AnvilBlock.FACING, Direction.EAST); private final MapTemplate template; private final AnvilDropConfig config; private final BlockBounds platformBounds; - private final Box box; + private final AABB box; private final BlockBounds clearBounds; private final BlockBounds dropBounds; @@ -33,7 +33,7 @@ public AnvilDropMap(MapTemplate template, AnvilDropConfig config, BlockBounds pl this.config = config; this.platformBounds = platformBounds; - this.box = this.platformBounds.asBox().expand(-1, -0.5, -1); + this.box = this.platformBounds.asBox().inflate(-1, -0.5, -1); this.clearBounds = clearBounds; this.dropBounds = dropBounds; @@ -43,28 +43,28 @@ public BlockBounds getPlatformBounds() { return this.platformBounds; } - public Box getBox() { + public AABB getBox() { return this.box; } - public void clearAnvils(ServerWorld world) { + public void clearAnvils(ServerLevel level) { Iterator iterator = this.clearBounds.iterator(); while (iterator.hasNext()) { BlockPos pos = iterator.next(); - if (this.config.isBreaking() && !world.isAir(pos)) { - world.breakBlock(pos.withY(0), false); + if (this.config.isBreaking() && !level.isEmptyBlock(pos)) { + level.destroyBlock(pos.atY(0), false); } - world.setBlockState(pos, CLEAR_STATE); + level.setBlockAndUpdate(pos, CLEAR_STATE); } } - public void dropAnvils(ServerWorld world) { + public void dropAnvils(ServerLevel level) { Iterator iterator = this.dropBounds.iterator(); while (iterator.hasNext()) { BlockPos pos = iterator.next(); - if (world.getRandom().nextDouble() < this.config.getChance()) { - BlockState state = world.getRandom().nextBoolean() ? ANVIL_STATE : ALTERNATE_ANVIL_STATE; - world.setBlockState(pos, state, 0); + if (level.getRandom().nextDouble() < this.config.getChance()) { + BlockState state = level.getRandom().nextBoolean() ? ANVIL_STATE : ALTERNATE_ANVIL_STATE; + level.setBlock(pos, state, 0); } } } diff --git a/src/main/java/io/github/haykam821/anvildrop/game/map/AnvilDropMapBuilder.java b/src/main/java/io/github/haykam821/anvildrop/game/map/AnvilDropMapBuilder.java index 2e4ccba..2d76e0d 100644 --- a/src/main/java/io/github/haykam821/anvildrop/game/map/AnvilDropMapBuilder.java +++ b/src/main/java/io/github/haykam821/anvildrop/game/map/AnvilDropMapBuilder.java @@ -3,18 +3,18 @@ import java.util.Iterator; import io.github.haykam821.anvildrop.game.AnvilDropConfig; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.core.BlockPos; import xyz.nucleoid.map_templates.BlockBounds; import xyz.nucleoid.map_templates.MapTemplate; public class AnvilDropMapBuilder { - private static final BlockState FLOOR = Blocks.SMOOTH_STONE.getDefaultState(); - private static final BlockState FLOOR_OUTLINE = Blocks.NETHERITE_BLOCK.getDefaultState(); - private static final BlockState WALL = Blocks.END_STONE_BRICK_WALL.getDefaultState(); - private static final BlockState WALL_TOP = Blocks.BIRCH_SLAB.getDefaultState(); - private static final BlockState BARRIER = Blocks.BARRIER.getDefaultState(); + private static final BlockState FLOOR = Blocks.SMOOTH_STONE.defaultBlockState(); + private static final BlockState FLOOR_OUTLINE = Blocks.NETHERITE_BLOCK.defaultBlockState(); + private static final BlockState WALL = Blocks.END_STONE_BRICK_WALL.defaultBlockState(); + private static final BlockState WALL_TOP = Blocks.BIRCH_SLAB.defaultBlockState(); + private static final BlockState BARRIER = Blocks.BARRIER.defaultBlockState(); private final AnvilDropConfig config; @@ -26,7 +26,7 @@ public AnvilDropMap create() { MapTemplate template = MapTemplate.createEmpty(); AnvilDropMapConfig mapConfig = this.config.getMapConfig(); - BlockBounds bounds = BlockBounds.of(BlockPos.ORIGIN, new BlockPos(mapConfig.getX() + 1, this.config.getStackHeight() + 3, mapConfig.getZ() + 1)); + BlockBounds bounds = BlockBounds.of(BlockPos.ZERO, new BlockPos(mapConfig.getX() + 1, this.config.getStackHeight() + 3, mapConfig.getZ() + 1)); this.build(bounds, template, mapConfig); BlockBounds clearBounds = createInnerBounds(mapConfig, this.config.getStackHeight() + 1); diff --git a/src/main/java/io/github/haykam821/anvildrop/game/phase/AnvilDropActivePhase.java b/src/main/java/io/github/haykam821/anvildrop/game/phase/AnvilDropActivePhase.java index 4d70d48..91f59f2 100644 --- a/src/main/java/io/github/haykam821/anvildrop/game/phase/AnvilDropActivePhase.java +++ b/src/main/java/io/github/haykam821/anvildrop/game/phase/AnvilDropActivePhase.java @@ -6,15 +6,17 @@ import io.github.haykam821.anvildrop.game.AnvilDropConfig; import io.github.haykam821.anvildrop.game.map.AnvilDropMap; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.registry.tag.DamageTypeTags; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.GameMode; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.player.Player; +import net.minecraft.tags.DamageTypeTags; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.network.chat.Component; +import net.minecraft.ChatFormatting; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.GameType; import xyz.nucleoid.plasmid.api.game.GameActivity; import xyz.nucleoid.plasmid.api.game.GameCloseReason; import xyz.nucleoid.plasmid.api.game.GameSpace; @@ -30,7 +32,7 @@ import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent; public class AnvilDropActivePhase { - private final ServerWorld world; + private final ServerLevel level; private final GameSpace gameSpace; private final AnvilDropMap map; private final AnvilDropConfig config; @@ -41,8 +43,8 @@ public class AnvilDropActivePhase { private int rounds = 0; private boolean anvilsDropping = false; - public AnvilDropActivePhase(GameSpace gameSpace, ServerWorld world, AnvilDropMap map, AnvilDropConfig config, Set players) { - this.world = world; + public AnvilDropActivePhase(GameSpace gameSpace, ServerLevel level, AnvilDropMap map, AnvilDropConfig config, Set players) { + this.level = level; this.gameSpace = gameSpace; this.map = map; this.config = config; @@ -60,9 +62,9 @@ public static void setRules(GameActivity activity) { activity.deny(GameRuleType.PVP); } - public static void open(GameSpace gameSpace, ServerWorld world, AnvilDropMap map, AnvilDropConfig config) { + public static void open(GameSpace gameSpace, ServerLevel level, AnvilDropMap map, AnvilDropConfig config) { Set players = gameSpace.getPlayers().participants().stream().map(PlayerRef::of).collect(Collectors.toSet()); - AnvilDropActivePhase phase = new AnvilDropActivePhase(gameSpace, world, map, config, players); + AnvilDropActivePhase phase = new AnvilDropActivePhase(gameSpace, level, map, config, players); gameSpace.setActivity(activity -> { AnvilDropActivePhase.setRules(activity); @@ -82,27 +84,27 @@ private void enable() { this.singleplayer = this.players.size() == 1; for (PlayerRef playerRef : this.players) { - playerRef.ifOnline(this.world, player -> { + playerRef.ifOnline(this.level, player -> { this.updateRoundsExperienceLevel(player); - player.changeGameMode(GameMode.ADVENTURE); - AnvilDropActivePhase.spawn(this.world, this.map, player); + player.setGameMode(GameType.ADVENTURE); + AnvilDropActivePhase.spawn(this.level, this.map, player); }); } - for (ServerPlayerEntity player : this.gameSpace.getPlayers().spectators()) { + for (ServerPlayer player : this.gameSpace.getPlayers().spectators()) { this.updateRoundsExperienceLevel(player); this.setSpectator(player); - AnvilDropActivePhase.spawn(this.world, this.map, player); + AnvilDropActivePhase.spawn(this.level, this.map, player); } } - private void updateRoundsExperienceLevel(ServerPlayerEntity player) { - player.setExperienceLevel(this.rounds + 1); + private void updateRoundsExperienceLevel(ServerPlayer player) { + player.setExperienceLevels(this.rounds + 1); } private void setRounds(int rounds) { this.rounds = rounds; - for (ServerPlayerEntity player : this.gameSpace.getPlayers()) { + for (ServerPlayer player : this.gameSpace.getPlayers()) { this.updateRoundsExperienceLevel(player); } } @@ -124,9 +126,9 @@ private void tick() { this.ticksUntilSwitch = this.config.getDelay(); if (this.anvilsDropping) { - this.map.dropAnvils(this.world); + this.map.dropAnvils(this.level); } else { - this.map.clearAnvils(this.world); + this.map.clearAnvils(this.level); this.setRounds(this.rounds + 1); } } @@ -135,8 +137,8 @@ private void tick() { Iterator playerIterator = this.players.iterator(); while (playerIterator.hasNext()) { PlayerRef playerRef = playerIterator.next(); - playerRef.ifOnline(this.world, player -> { - if (!this.map.getBox().contains(player.getPos())) { + playerRef.ifOnline(this.level, player -> { + if (!this.map.getBox().contains(player.position())) { this.eliminate(player, player.getY() < this.map.getBox().minY ? ".hole_in_floor" : ".out_of_bounds", false); playerIterator.remove(); } @@ -147,54 +149,54 @@ private void tick() { if (this.players.size() < 2) { if (this.players.size() == 1 && this.singleplayer) return; - Text endingMessage = this.getEndingMessage(); - for (ServerPlayerEntity player : this.gameSpace.getPlayers()) { - player.sendMessage(endingMessage, false); + Component endingMessage = this.getEndingMessage(); + for (ServerPlayer player : this.gameSpace.getPlayers()) { + player.sendSystemMessage(endingMessage, false); } - - this.ticksUntilClose = this.config.getTicksUntilClose().get(this.world.getRandom()); + this.gameSpace.getPlayers().playSound(SoundEvents.PLAYER_LEVELUP, SoundSource.UI, 1, 1); + this.ticksUntilClose = this.config.getTicksUntilClose().sample(this.level.getRandom()); } } - private Text getEndingMessage() { + private Component getEndingMessage() { if (this.players.size() == 1) { PlayerRef winnerRef = this.players.iterator().next(); - if (winnerRef.isOnline(this.world)) { - PlayerEntity winner = winnerRef.getEntity(this.world); - return Text.translatable("text.anvildrop.win", winner.getDisplayName(), this.rounds).formatted(Formatting.GOLD); + if (winnerRef.isOnline(this.level)) { + Player winner = winnerRef.getEntity(this.level); + return Component.translatable("text.anvildrop.win", winner.getDisplayName(), this.rounds).withStyle(ChatFormatting.GOLD); } } - return Text.translatable("text.anvildrop.no_winners", this.rounds).formatted(Formatting.GOLD); + return Component.translatable("text.anvildrop.no_winners", this.rounds).withStyle(ChatFormatting.GOLD); } private boolean isGameEnding() { return this.ticksUntilClose >= 0; } - private void setSpectator(ServerPlayerEntity player) { - player.changeGameMode(GameMode.SPECTATOR); + private void setSpectator(ServerPlayer player) { + player.setGameMode(GameType.SPECTATOR); } private JoinAcceptorResult onAcceptPlayers(JoinAcceptor acceptor) { - return acceptor.teleport(this.world, AnvilDropActivePhase.getSpawnPos(this.map)).thenRunForEach(player -> { + return acceptor.teleport(this.level, AnvilDropActivePhase.getSpawnPos(this.map)).thenRunForEach(player -> { this.updateRoundsExperienceLevel(player); this.setSpectator(player); }); } - private void removePlayer(ServerPlayerEntity player) { + private void removePlayer(ServerPlayer player) { this.eliminate(player, true); } - private void eliminate(ServerPlayerEntity eliminatedPlayer, String suffix, boolean remove) { + private void eliminate(ServerPlayer eliminatedPlayer, String suffix, boolean remove) { if (this.isGameEnding()) return; PlayerRef eliminatedRef = PlayerRef.of(eliminatedPlayer); if (!this.players.contains(eliminatedRef)) return; - Text message = Text.translatable("text.anvildrop.eliminated" + suffix, eliminatedPlayer.getDisplayName()).formatted(Formatting.RED); - for (ServerPlayerEntity player : this.gameSpace.getPlayers()) { - player.sendMessage(message, false); + Component message = Component.translatable("text.anvildrop.eliminated" + suffix, eliminatedPlayer.getDisplayName()).withStyle(ChatFormatting.RED); + for (ServerPlayer player : this.gameSpace.getPlayers()) { + player.sendSystemMessage(message, false); } if (remove) { @@ -203,37 +205,37 @@ private void eliminate(ServerPlayerEntity eliminatedPlayer, String suffix, boole this.setSpectator(eliminatedPlayer); } - private void eliminate(ServerPlayerEntity eliminatedPlayer, boolean remove) { + private void eliminate(ServerPlayer eliminatedPlayer, boolean remove) { this.eliminate(eliminatedPlayer, "", remove); } - private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) { + private EventResult onPlayerDeath(ServerPlayer player, DamageSource source) { if (this.players.contains(PlayerRef.of(player))) { this.eliminate(player, true); } else { - AnvilDropActivePhase.spawn(this.world, this.map, player); + AnvilDropActivePhase.spawn(this.level, this.map, player); } return EventResult.DENY; } private static boolean isEliminatingDamageSource(DamageSource source) { - return source.isIn(DamageTypeTags.DAMAGES_HELMET); + return source.is(DamageTypeTags.DAMAGES_HELMET); } - private EventResult onPlayerDamage(ServerPlayerEntity player, DamageSource source, float amount) { + private EventResult onPlayerDamage(ServerPlayer player, DamageSource source, float amount) { if (AnvilDropActivePhase.isEliminatingDamageSource(source) && this.players.contains(PlayerRef.of(player))) { this.eliminate(player, ".falling_anvil", true); } return EventResult.ALLOW; } - public static void spawn(ServerWorld world, AnvilDropMap map, ServerPlayerEntity player) { - Vec3d spawnPos = AnvilDropActivePhase.getSpawnPos(map); - player.teleport(world, spawnPos.getX(), spawnPos.getY(), spawnPos.getZ(), Set.of(), 0, 0, true); + public static void spawn(ServerLevel world, AnvilDropMap map, ServerPlayer player) { + Vec3 spawnPos = AnvilDropActivePhase.getSpawnPos(map); + player.teleportTo(world, spawnPos.x(), spawnPos.y(), spawnPos.z(), Set.of(), 0, 0, true); } - protected static Vec3d getSpawnPos(AnvilDropMap map) { - Vec3d center = map.getPlatformBounds().center(); - return new Vec3d(center.getX(), map.getPlatformBounds().min().getY() + 1, center.getZ()); + protected static Vec3 getSpawnPos(AnvilDropMap map) { + Vec3 center = map.getPlatformBounds().center(); + return new Vec3(center.x(), map.getPlatformBounds().min().getY() + 1, center.z()); } } \ No newline at end of file diff --git a/src/main/java/io/github/haykam821/anvildrop/game/phase/AnvilDropWaitingPhase.java b/src/main/java/io/github/haykam821/anvildrop/game/phase/AnvilDropWaitingPhase.java index 69bc7ad..4ae7bd5 100644 --- a/src/main/java/io/github/haykam821/anvildrop/game/phase/AnvilDropWaitingPhase.java +++ b/src/main/java/io/github/haykam821/anvildrop/game/phase/AnvilDropWaitingPhase.java @@ -3,11 +3,11 @@ import io.github.haykam821.anvildrop.game.AnvilDropConfig; import io.github.haykam821.anvildrop.game.map.AnvilDropMap; import io.github.haykam821.anvildrop.game.map.AnvilDropMapBuilder; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.world.GameMode; -import xyz.nucleoid.fantasy.RuntimeWorldConfig; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.GameType; +import xyz.nucleoid.fantasy.RuntimeLevelConfig; import xyz.nucleoid.plasmid.api.game.GameOpenContext; import xyz.nucleoid.plasmid.api.game.GameOpenProcedure; import xyz.nucleoid.plasmid.api.game.GameResult; @@ -23,13 +23,13 @@ public class AnvilDropWaitingPhase { private final GameSpace gameSpace; - private final ServerWorld world; + private final ServerLevel level; private final AnvilDropMap map; private final AnvilDropConfig config; - public AnvilDropWaitingPhase(GameSpace gameSpace, ServerWorld world, AnvilDropMap map, AnvilDropConfig config) { + public AnvilDropWaitingPhase(GameSpace gameSpace, ServerLevel level, AnvilDropMap map, AnvilDropConfig config) { this.gameSpace = gameSpace; - this.world = world; + this.level = level; this.map = map; this.config = config; } @@ -38,11 +38,11 @@ public static GameOpenProcedure open(GameOpenContext context) { AnvilDropMapBuilder mapBuilder = new AnvilDropMapBuilder(context.config()); AnvilDropMap map = mapBuilder.create(); - RuntimeWorldConfig worldConfig = new RuntimeWorldConfig() + RuntimeLevelConfig levelConfig = new RuntimeLevelConfig() .setGenerator(map.createGenerator(context.server())); - return context.openWithWorld(worldConfig, (game, world) -> { - AnvilDropWaitingPhase phase = new AnvilDropWaitingPhase(game.getGameSpace(), world, map, context.config()); + return context.openWithLevel(levelConfig, (game, level) -> { + AnvilDropWaitingPhase phase = new AnvilDropWaitingPhase(game.getGameSpace(), level, map, context.config()); GameWaitingLobby.addTo(game, context.config().getPlayerConfig()); AnvilDropActivePhase.setRules(game); @@ -56,18 +56,18 @@ public static GameOpenProcedure open(GameOpenContext context) { } private JoinAcceptorResult onAcceptPlayers(JoinAcceptor acceptor) { - return acceptor.teleport(this.world, AnvilDropActivePhase.getSpawnPos(this.map)).thenRunForEach(player -> { - player.changeGameMode(GameMode.ADVENTURE); + return acceptor.teleport(this.level, AnvilDropActivePhase.getSpawnPos(this.map)).thenRunForEach(player -> { + player.setGameMode(GameType.ADVENTURE); }); } private GameResult requestStart() { - AnvilDropActivePhase.open(this.gameSpace, this.world, this.map, this.config); + AnvilDropActivePhase.open(this.gameSpace, this.level, this.map, this.config); return GameResult.ok(); } - private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) { - AnvilDropActivePhase.spawn(this.world, this.map, player); + private EventResult onPlayerDeath(ServerPlayer player, DamageSource source) { + AnvilDropActivePhase.spawn(this.level, this.map, player); return EventResult.DENY; } } \ No newline at end of file diff --git a/src/main/resources/data/anvildrop/plasmid/game/small_stacking_anvil_drop.json b/src/main/resources/data/anvildrop/plasmid/game/small_stacking_anvil_drop.json index 8c1b2c9..60b312d 100644 --- a/src/main/resources/data/anvildrop/plasmid/game/small_stacking_anvil_drop.json +++ b/src/main/resources/data/anvildrop/plasmid/game/small_stacking_anvil_drop.json @@ -1,6 +1,6 @@ { "type": "anvildrop:anvil_drop", - "icon": "minecraft:chain", + "icon": "minecraft:iron_chain", "stack_height": 8, "map": { "x": 18, diff --git a/src/main/resources/data/anvildrop/plasmid/game/standard_stacking_anvil_drop.json b/src/main/resources/data/anvildrop/plasmid/game/standard_stacking_anvil_drop.json index 11601c8..1905afe 100644 --- a/src/main/resources/data/anvildrop/plasmid/game/standard_stacking_anvil_drop.json +++ b/src/main/resources/data/anvildrop/plasmid/game/standard_stacking_anvil_drop.json @@ -1,6 +1,6 @@ { "type": "anvildrop:anvil_drop", - "icon": "minecraft:chain", + "icon": "minecraft:iron_chain", "stack_height": 8, "map": { "x": 36,