diff --git a/build.gradle b/build.gradle index 0bd809d..054e578 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,16 @@ plugins { - id "fabric-loom" version "1.10.5" + id "fabric-loom" version "1.15-SNAPSHOT" 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,7 +25,7 @@ repositories { dependencies { // Main minecraft("com.mojang:minecraft:${project.minecraft_version}") - mappings("net.fabricmc:yarn:${project.yarn_mappings}:v2") + mappings loom.officialMojangMappings() modImplementation("net.fabricmc:fabric-loader:${project.loader_version}") // Fabric API @@ -39,16 +43,24 @@ processResources { } } +tasks.withType(JavaCompile).configureEach { + it.options.release = 21 +} + java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() + sourceCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21 } -tasks.withType(JavaCompile) { - options.release = 21 - options.encoding = "UTF-8" -} - jar { - from "LICENSE" + inputs.property "archivesName", project.base.archivesName + + from("LICENSE") { + rename { "${it}_${inputs.properties.archivesName}"} + } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 5b24aad..ccb2733 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 = 1.21.11 +loader_version = 0.18.4 +fabric_version = 0.141.3+1.21.11 -plasmid_version = 0.6.3+1.21.4 \ No newline at end of file +plasmid_version = 0.6.7-SNAPSHOT+1.21.11 \ 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..78019db 100644 --- a/src/main/java/io/github/haykam821/anvildrop/Main.java +++ b/src/main/java/io/github/haykam821/anvildrop/Main.java @@ -3,7 +3,7 @@ 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; public class Main implements ModInitializer { @@ -18,6 +18,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..d37d2ee 100644 --- a/src/main/java/io/github/haykam821/anvildrop/game/AnvilDropConfig.java +++ b/src/main/java/io/github/haykam821/anvildrop/game/AnvilDropConfig.java @@ -6,23 +6,21 @@ 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 xyz.nucleoid.plasmid.api.game.common.config.WaitingLobbyConfig; public class AnvilDropConfig { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> { - 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), - 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), - Codec.INT.optionalFieldOf("stack_height", 0).forGetter(AnvilDropConfig::getStackHeight), - Codec.BOOL.optionalFieldOf("breaking", false).forGetter(AnvilDropConfig::isBreaking) - ).apply(instance, AnvilDropConfig::new); - }); + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + AnvilDropMapConfig.CODEC.fieldOf("map").forGetter(AnvilDropConfig::getMapConfig), + WaitingLobbyConfig.CODEC.fieldOf("players").forGetter(AnvilDropConfig::getPlayerConfig), + IntProvider.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), + Codec.INT.optionalFieldOf("stack_height", 0).forGetter(AnvilDropConfig::getStackHeight), + Codec.BOOL.optionalFieldOf("breaking", false).forGetter(AnvilDropConfig::isBreaking) + ).apply(instance, AnvilDropConfig::new)); private final AnvilDropMapConfig mapConfig; private final WaitingLobbyConfig playerConfig; 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..de30b50 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; 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,30 +43,26 @@ public BlockBounds getPlatformBounds() { return this.platformBounds; } - public Box getBox() { + public AABB getBox() { return this.box; } - public void clearAnvils(ServerWorld world) { - 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); - } - world.setBlockState(pos, CLEAR_STATE); - } + public void clearAnvils(ServerLevel world) { + for (BlockPos pos : this.clearBounds) { + if (this.config.isBreaking() && !world.isEmptyBlock(pos)) { + world.destroyBlock(pos.atY(0), false); + } + world.setBlockAndUpdate(pos, CLEAR_STATE); + } } - public void dropAnvils(ServerWorld world) { - 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); - } - } + public void dropAnvils(ServerLevel world) { + for (BlockPos pos : this.dropBounds) { + if (world.getRandom().nextDouble() < this.config.getChance()) { + BlockState state = world.getRandom().nextBoolean() ? ANVIL_STATE : ALTERNATE_ANVIL_STATE; + world.setBlock(pos, state, 0); + } + } } public ChunkGenerator createGenerator(MinecraftServer server) { 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..903364c 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); @@ -67,14 +67,11 @@ private BlockState getBlockState(BlockPos pos, BlockBounds bounds, AnvilDropMapC } public void build(BlockBounds bounds, MapTemplate template, AnvilDropMapConfig mapConfig) { - Iterator iterator = bounds.iterator(); - while (iterator.hasNext()) { - BlockPos pos = iterator.next(); - - BlockState state = this.getBlockState(pos, bounds, mapConfig); - if (state != null) { - template.setBlockState(pos, state); - } - } + for (BlockPos pos : bounds) { + BlockState state = this.getBlockState(pos, bounds, mapConfig); + if (state != null) { + template.setBlockState(pos, state); + } + } } } \ No newline at end of file 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..37ca072 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,15 @@ 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.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 +30,7 @@ import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent; public class AnvilDropActivePhase { - private final ServerWorld world; + private final ServerLevel world; private final GameSpace gameSpace; private final AnvilDropMap map; private final AnvilDropConfig config; @@ -41,7 +41,7 @@ public class AnvilDropActivePhase { private int rounds = 0; private boolean anvilsDropping = false; - public AnvilDropActivePhase(GameSpace gameSpace, ServerWorld world, AnvilDropMap map, AnvilDropConfig config, Set players) { + public AnvilDropActivePhase(GameSpace gameSpace, ServerLevel world, AnvilDropMap map, AnvilDropConfig config, Set players) { this.world = world; this.gameSpace = gameSpace; this.map = map; @@ -60,7 +60,7 @@ 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 world, 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); @@ -84,25 +84,25 @@ private void enable() { for (PlayerRef playerRef : this.players) { playerRef.ifOnline(this.world, player -> { this.updateRoundsExperienceLevel(player); - player.changeGameMode(GameMode.ADVENTURE); + player.setGameMode(GameType.ADVENTURE); AnvilDropActivePhase.spawn(this.world, 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); } } - 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); } } @@ -136,7 +136,7 @@ private void tick() { while (playerIterator.hasNext()) { PlayerRef playerRef = playerIterator.next(); playerRef.ifOnline(this.world, player -> { - if (!this.map.getBox().contains(player.getPos())) { + 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,32 +147,32 @@ 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.displayClientMessage(endingMessage, false); } - this.ticksUntilClose = this.config.getTicksUntilClose().get(this.world.getRandom()); + this.ticksUntilClose = this.config.getTicksUntilClose().sample(this.world.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); + Player winner = winnerRef.getEntity(this.world); + 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) { @@ -182,19 +182,19 @@ private JoinAcceptorResult onAcceptPlayers(JoinAcceptor acceptor) { }); } - 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.displayClientMessage(message, false); } if (remove) { @@ -203,11 +203,11 @@ 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 { @@ -217,23 +217,23 @@ private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source } 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..4993654 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,10 +3,10 @@ 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 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.RuntimeWorldConfig; import xyz.nucleoid.plasmid.api.game.GameOpenContext; import xyz.nucleoid.plasmid.api.game.GameOpenProcedure; @@ -23,11 +23,11 @@ public class AnvilDropWaitingPhase { private final GameSpace gameSpace; - private final ServerWorld world; + private final ServerLevel world; private final AnvilDropMap map; private final AnvilDropConfig config; - public AnvilDropWaitingPhase(GameSpace gameSpace, ServerWorld world, AnvilDropMap map, AnvilDropConfig config) { + public AnvilDropWaitingPhase(GameSpace gameSpace, ServerLevel world, AnvilDropMap map, AnvilDropConfig config) { this.gameSpace = gameSpace; this.world = world; this.map = map; @@ -56,9 +56,7 @@ 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.world, AnvilDropActivePhase.getSpawnPos(this.map)).thenRunForEach(player -> player.setGameMode(GameType.ADVENTURE)); } private GameResult requestStart() { @@ -66,7 +64,7 @@ private GameResult requestStart() { return GameResult.ok(); } - private EventResult onPlayerDeath(ServerPlayerEntity player, DamageSource source) { + private EventResult onPlayerDeath(ServerPlayer player, DamageSource source) { AnvilDropActivePhase.spawn(this.world, this.map, player); return EventResult.DENY; } 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,