From 97be59a7b6b990e8a68b69424904ed465a1faabe Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Mon, 16 Mar 2026 22:14:20 +0100 Subject: feat(): support 26.1 --- build.gradle | 13 +- gradle.properties | 7 +- .../anhgelus/molehunt/client/MolehuntClient.java | 16 +-- .../client/mixin/NoCustomizableSkinOverlay.java | 14 +- .../anhgelus/molehunt/client/mixin/NoNametags.java | 22 ++- .../molehunt/client/mixin/NoPlayerListHud.java | 6 +- .../anhgelus/molehunt/client/mixin/NoSkin.java | 21 +-- .../java/world/anhgelus/molehunt/Molehunt.java | 94 ++++++------- .../world/anhgelus/molehunt/config/Config.java | 26 ++-- .../anhgelus/molehunt/config/ConfigPayload.java | 26 ++-- .../java/world/anhgelus/molehunt/game/Game.java | 155 +++++++++++---------- .../world/anhgelus/molehunt/game/GamePayload.java | 22 +-- .../molehunt/mixin/NoJoinLeaveMessage.java | 16 +-- .../anhgelus/molehunt/mixin/NoMsgCommand.java | 8 +- .../world/anhgelus/molehunt/mixin/NoPortals.java | 12 +- 15 files changed, 227 insertions(+), 231 deletions(-) diff --git a/build.gradle b/build.gradle index d34a196..f453021 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.15-SNAPSHOT' + id 'net.fabricmc.fabric-loom' version '1.15-SNAPSHOT' id 'maven-publish' } @@ -32,11 +32,10 @@ repositories { dependencies { // To change the versions see the gradle.properties file 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. This is technically optional, but you probably want it anyway. - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" } processResources { @@ -53,15 +52,15 @@ processResources { } tasks.withType(JavaCompile).configureEach { - it.options.release = 21 + it.options.release = 25 it.options.encoding = "UTF-8" } java { withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_25 + targetCompatibility = JavaVersion.VERSION_25 } jar { diff --git a/gradle.properties b/gradle.properties index 958a1c5..9f0cb56 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,13 +2,12 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.21.11 -yarn_mappings=1.21.11+build.4 +minecraft_version=26.1-pre-2 loader_version=0.18.4 # Mod Properties -mod_version=1.2.1 +mod_version=1.3.0 maven_group=world.anhgelus archives_base_name=Molehunt # Dependencies # check this on https://modmuss50.me/fabric.html -fabric_version=0.141.3+1.21.11 +fabric_version=0.143.14+26.1 diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java index 03198ee..b0ef344 100644 --- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java +++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java @@ -3,7 +3,7 @@ package world.anhgelus.molehunt.client; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -import net.minecraft.entity.player.PlayerModelPart; +import net.minecraft.world.entity.player.PlayerModelPart; import world.anhgelus.molehunt.config.ConfigPayload; import world.anhgelus.molehunt.game.GamePayload; @@ -28,13 +28,13 @@ public class MolehuntClient implements ClientModInitializer { ClientLifecycleEvents.CLIENT_STARTED.register(client -> { var options = client.options; - options.setPlayerModelPart(PlayerModelPart.CAPE, true); - options.setPlayerModelPart(PlayerModelPart.HAT, true); - options.setPlayerModelPart(PlayerModelPart.JACKET, true); - options.setPlayerModelPart(PlayerModelPart.LEFT_SLEEVE, true); - options.setPlayerModelPart(PlayerModelPart.RIGHT_SLEEVE, true); - options.setPlayerModelPart(PlayerModelPart.LEFT_PANTS_LEG, true); - options.setPlayerModelPart(PlayerModelPart.RIGHT_PANTS_LEG, true); + options.setModelPart(PlayerModelPart.CAPE, true); + options.setModelPart(PlayerModelPart.HAT, true); + options.setModelPart(PlayerModelPart.JACKET, true); + options.setModelPart(PlayerModelPart.LEFT_SLEEVE, true); + options.setModelPart(PlayerModelPart.RIGHT_SLEEVE, true); + options.setModelPart(PlayerModelPart.LEFT_PANTS_LEG, true); + options.setModelPart(PlayerModelPart.RIGHT_PANTS_LEG, true); }); } diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java index c2c0ab0..af299ea 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java @@ -1,7 +1,7 @@ package world.anhgelus.molehunt.client.mixin; -import net.minecraft.client.option.GameOptions; -import net.minecraft.entity.player.PlayerModelPart; +import net.minecraft.client.Options; +import net.minecraft.world.entity.player.PlayerModelPart; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -9,16 +9,16 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import world.anhgelus.molehunt.client.MolehuntClient; -@Mixin(GameOptions.class) +@Mixin(Options.class) public abstract class NoCustomizableSkinOverlay { @Shadow - private void setPlayerModelPart(PlayerModelPart part, boolean enabled) {} + public void setModelPart(PlayerModelPart part, boolean enabled) {} - @Inject(at = @At("HEAD"), method = "setPlayerModelPart", cancellable = true) + @Inject(at = @At("HEAD"), method = "setModelPart", cancellable = true) public void togglePlayerModelPart(PlayerModelPart part, boolean enabled, CallbackInfo ci) { if (MolehuntClient.showSkins()) return; - setPlayerModelPart(part, true); - ((GameOptions) (Object) this).sendClientSettings(); + setModelPart(part, true); + ((Options) (Object) this).broadcastOptions(); ci.cancel(); } } diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java index 555fb00..937f45e 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java @@ -1,24 +1,20 @@ package world.anhgelus.molehunt.client.mixin; -import net.minecraft.client.render.command.OrderedRenderCommandQueue; -import net.minecraft.client.render.entity.EntityRenderer; -import net.minecraft.client.render.entity.state.EntityRenderState; -import net.minecraft.client.render.state.CameraRenderState; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.state.EntityRenderState; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import world.anhgelus.molehunt.client.MolehuntClient; @Mixin(EntityRenderer.class) public class NoNametags { - @Inject(at = @At("HEAD"), method = "render", cancellable = true) - private void renderLabelOrNot(S state, MatrixStack matrices, OrderedRenderCommandQueue queue, CameraRenderState cameraState, CallbackInfo ci) { - if (EntityType.PLAYER != state.entityType || MolehuntClient.showNameTags() || !MolehuntClient.gameStarted()) return; - ci.cancel(); + @Inject(at = @At("HEAD"), method = "shouldShowName", cancellable = true) + private void renderLabelOrNot(T entity, double distanceToCameraSq, CallbackInfoReturnable cir) { + if (!(entity instanceof Player) || MolehuntClient.showNameTags() || !MolehuntClient.gameStarted()) return; + cir.setReturnValue(false); } } \ No newline at end of file diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java index 4473b12..c235b00 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java @@ -1,15 +1,15 @@ package world.anhgelus.molehunt.client.mixin; -import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.gui.components.PlayerTabOverlay; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import world.anhgelus.molehunt.client.MolehuntClient; -@Mixin(PlayerListHud.class) +@Mixin(PlayerTabOverlay.class) public class NoPlayerListHud { - @Inject(at = @At("HEAD"), method = "render", cancellable = true) + @Inject(at = @At("HEAD"), method = "setVisible", cancellable = true) public void render(CallbackInfo ci) { if (MolehuntClient.showTab() || !MolehuntClient.gameStarted()) return; ci.cancel(); diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java index b6b67cc..fd5a8a1 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java @@ -1,10 +1,10 @@ package world.anhgelus.molehunt.client.mixin; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.entity.player.PlayerSkinType; -import net.minecraft.entity.player.SkinTextures; -import net.minecraft.util.AssetInfo; -import net.minecraft.util.Identifier; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.core.ClientAsset; +import net.minecraft.resources.Identifier; +import net.minecraft.world.entity.player.PlayerModelType; +import net.minecraft.world.entity.player.PlayerSkin; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,16 +12,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import world.anhgelus.molehunt.Molehunt; import world.anhgelus.molehunt.client.MolehuntClient; -@Mixin(AbstractClientPlayerEntity.class) +@Mixin(AbstractClientPlayer.class) public class NoSkin { @Inject(at = @At("HEAD"), method = "getSkin", cancellable = true) - public void getSkin(CallbackInfoReturnable cir) { + public void getSkin(CallbackInfoReturnable cir) { if (MolehuntClient.showSkins() || !MolehuntClient.gameStarted()) return; - cir.setReturnValue(SkinTextures.create( - new AssetInfo.TextureAssetInfo(Identifier.of(Molehunt.MOD_ID, "skin")), + cir.setReturnValue(new PlayerSkin( + new ClientAsset.ResourceTexture(Identifier.fromNamespaceAndPath(Molehunt.MOD_ID, "skin")), null, null, - PlayerSkinType.WIDE + PlayerModelType.WIDE, + true )); } } diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java index d5df320..984f906 100644 --- a/src/main/java/world/anhgelus/molehunt/Molehunt.java +++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java @@ -13,17 +13,17 @@ import net.fabricmc.fabric.api.message.v1.ServerMessageEvents; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket; +import net.minecraft.ChatFormatting; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.command.CommandManager; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.util.Identifier; -import net.minecraft.world.GameMode; -import net.minecraft.world.rule.GameRule; -import net.minecraft.world.rule.GameRuleCategory; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.GameType; +import net.minecraft.world.level.gamerules.GameRule; +import net.minecraft.world.level.gamerules.GameRuleCategory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import world.anhgelus.molehunt.config.Config; @@ -35,7 +35,7 @@ import world.anhgelus.molehunt.game.GamePayload; import java.util.HashMap; import java.util.UUID; -import static net.minecraft.server.command.CommandManager.literal; +import static net.minecraft.commands.Commands.literal; public class Molehunt implements ModInitializer { @@ -49,61 +49,61 @@ public class Molehunt implements ModInitializer { public static final GameRule GAME_DURATION = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("game_duration", 90)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.of(MOD_ID, "gameDurationMinutes")); + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "gameDurationMinutes")); public static final GameRule MOLE_PERCENTAGE = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("mole_percentage", 25)) .range(0, 100) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.of(MOD_ID, "molePercentage")); + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "molePercentage")); public static final GameRule MOLE_COUNT = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("mole_count", -1)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.of(MOD_ID, "moleCount")); + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "moleCount")); public static final GameRule SHOW_NAMETAGS = GameRuleBuilder .forBoolean(CONFIG_FILE.getOrDefault("show_nametags", false)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.of(MOD_ID, "showNametags")); + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showNametags")); public static final GameRule SHOW_TAB = GameRuleBuilder .forBoolean(CONFIG_FILE.getOrDefault("show_tab", false)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.of(MOD_ID, "showTab")); + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showTab")); public static final GameRule SHOW_SKINS = GameRuleBuilder .forBoolean(CONFIG_FILE.getOrDefault("show_skins", false)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.of(MOD_ID, "showSkins")); + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showSkins")); public static final GameRule INITIAL_WORLD_SIZE = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("initial_world_size", 600)) .minValue(0) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.of(MOD_ID, "initialWorldSize")); + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "initialWorldSize")); public static final GameRule FINAL_WORLD_SIZE = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("final_world_size", 100)) .minValue(0) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.of(MOD_ID, "finalWorldSize")); + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "finalWorldSize")); public static final GameRule MOVING_STARTING_TIME_OFFSET = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("border_moving_starting_time_offset", 30)) .minValue(0) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.of(MOD_ID, "borderMovingStartingTimeOffsetMinutes")); + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "borderMovingStartingTimeOffsetMinutes")); public static final GameRule ENABLE_PORTALS = GameRuleBuilder .forBoolean(CONFIG_FILE.getOrDefault("enable_portals", false)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.of(MOD_ID, "enablePortals")); + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "enablePortals")); public static final GameRule FOOD_ON_START = GameRuleBuilder .forBoolean(CONFIG_FILE.getOrDefault("food_on_start", true)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.of(MOD_ID, "foodOnStart")); + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "foodOnStart")); public Game game; @@ -126,26 +126,26 @@ public class Molehunt implements ModInitializer { final var command = literal("molehunt"); command.then(literal("start") - .requires(CommandManager.requirePermissionLevel(CommandManager.GAMEMASTERS_CHECK)) + .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) .executes(context -> { game = new Game(context.getSource().getServer()); game.start(); return Command.SINGLE_SUCCESS; })); - command.then(literal("timer").requires(ServerCommandSource::isExecutedByPlayer).then( + command.then(literal("timer").requires(CommandSourceStack::isPlayer).then( literal("show").executes(context -> { var player = context.getSource().getPlayer(); assert player != null; - timerVisibility.put(player.getUuid(), true); - context.getSource().sendFeedback(() -> Text.translatable("commands.molehunt.timer.show"), false); + timerVisibility.put(player.getUUID(), true); + context.getSource().sendSuccess(() -> Component.translatable("commands.molehunt.timer.show"), false); if (game == null || !game.started()) { - player.networkHandler.sendPacket(new OverlayMessageS2CPacket( - Text.translatable("commands.molehunt.error.game_not_started").formatted(Formatting.RED) + player.connection.send(new ClientboundSetActionBarTextPacket( + Component.translatable("commands.molehunt.error.game_not_started").withStyle(ChatFormatting.RED) )); } else { - player.networkHandler.sendPacket(new OverlayMessageS2CPacket(Text.of(game.getRemainingText()))); + player.connection.send(new ClientboundSetActionBarTextPacket(Component.translationArg(game.getRemainingText()))); } return Command.SINGLE_SUCCESS; @@ -155,16 +155,16 @@ public class Molehunt implements ModInitializer { var player = context.getSource().getPlayer(); assert player != null; - timerVisibility.put(player.getUuid(), false); - context.getSource().sendFeedback(() -> Text.translatable("commands.molehunt.timer.hide"), false); + timerVisibility.put(player.getUUID(), false); + context.getSource().sendSuccess(() -> Component.translatable("commands.molehunt.timer.hide"), false); return Command.SINGLE_SUCCESS; }) )); command.then(literal("role") - .requires(ServerCommandSource::isExecutedByPlayer) + .requires(CommandSourceStack::isPlayer) .executes(context -> { if (game == null || !game.started()) { - throw (new SimpleCommandExceptionType(Text.translatable("commands.molehunt.error.game_not_started"))).create(); + throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create(); } final var source = context.getSource(); @@ -172,30 +172,30 @@ public class Molehunt implements ModInitializer { assert player != null; if (game.isMole(player)) { - source.sendFeedback( - () -> Text.translatable("commands.molehunt.role.mole") + source.sendSuccess( + () -> Component.translatable("commands.molehunt.role.mole") .append("\n\n") - .append(Text.translatable("commands.molehunt.role.mole.list", game.getMolesAsString())), + .append(Component.translatable("commands.molehunt.role.mole.list", game.getMolesAsString())), false); } else if (player.isSpectator()) { - source.sendFeedback( - () -> Text.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size()), + source.sendSuccess( + () -> Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size()), false); } else { - source.sendFeedback( - () -> Text.translatable("commands.molehunt.role.survivor") + source.sendSuccess( + () -> Component.translatable("commands.molehunt.role.survivor") .append("\n\n") - .append(Text.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size())), + .append(Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size())), false); } return Command.SINGLE_SUCCESS; })); command.then(literal("stop") - .requires(CommandManager.requirePermissionLevel(CommandManager.GAMEMASTERS_CHECK)) + .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) .executes(context -> { if (game == null || !game.started()) { - throw (new SimpleCommandExceptionType(Text.translatable("commands.molehunt.error.game_not_started"))).create(); + throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create(); } game.stop(); @@ -210,7 +210,7 @@ public class Molehunt implements ModInitializer { ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) -> false); ServerLivingEntityEvents.AFTER_DEATH.register((entity, damageSource) -> { - if (!(entity instanceof ServerPlayerEntity) || game == null) return; + if (!(entity instanceof ServerPlayer) || game == null) return; if (!game.started()) return; if (game.wonByMoles()) game.end(); }); @@ -218,7 +218,7 @@ public class Molehunt implements ModInitializer { ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, alive) -> { if (game == null) return; if (!game.started()) return; - newPlayer.changeGameMode(GameMode.SPECTATOR); + newPlayer.setGameMode(GameType.SPECTATOR); }); ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { @@ -232,7 +232,7 @@ public class Molehunt implements ModInitializer { ); }); - PayloadTypeRegistry.playS2C().register(ConfigPayload.ID, ConfigPayload.CODEC); - PayloadTypeRegistry.playS2C().register(GamePayload.ID, GamePayload.CODEC); + PayloadTypeRegistry.clientboundPlay().register(ConfigPayload.ID, ConfigPayload.CODEC); + PayloadTypeRegistry.clientboundPlay().register(GamePayload.ID, GamePayload.CODEC); } } diff --git a/src/main/java/world/anhgelus/molehunt/config/Config.java b/src/main/java/world/anhgelus/molehunt/config/Config.java index 08c3850..c9d04af 100644 --- a/src/main/java/world/anhgelus/molehunt/config/Config.java +++ b/src/main/java/world/anhgelus/molehunt/config/Config.java @@ -16,56 +16,56 @@ public class Config { public void sendConfigPayload() { final var payload = new ConfigPayload(nametagsEnabled(), skinsEnabled(), tabEnabled()); - server.getPlayerManager().getPlayerList().forEach(p -> ServerPlayNetworking.send(p, payload)); + server.getPlayerList().getPlayers().forEach(p -> ServerPlayNetworking.send(p, payload)); } public void sendConfigPayload(boolean showNametags, boolean showSkins, boolean showTab) { final var payload = new ConfigPayload(showNametags, showSkins, showTab); - server.getPlayerManager().getPlayerList().forEach(p -> ServerPlayNetworking.send(p, payload)); + server.getPlayerList().getPlayers().forEach(p -> ServerPlayNetworking.send(p, payload)); } public int getGameDuration() { - return server.getOverworld().getGameRules().getValue(Molehunt.GAME_DURATION); + return server.overworld().getGameRules().get(Molehunt.GAME_DURATION); } public int getMolePercentage() { - return server.getOverworld().getGameRules().getValue(Molehunt.MOLE_PERCENTAGE); + return server.overworld().getGameRules().get(Molehunt.MOLE_PERCENTAGE); } public int getMoleCount() { - return server.getOverworld().getGameRules().getValue(Molehunt.MOLE_COUNT); + return server.overworld().getGameRules().get(Molehunt.MOLE_COUNT); } public boolean nametagsEnabled() { - return server.getOverworld().getGameRules().getValue(Molehunt.SHOW_NAMETAGS); + return server.overworld().getGameRules().get(Molehunt.SHOW_NAMETAGS); } public boolean skinsEnabled() { - return server.getOverworld().getGameRules().getValue(Molehunt.SHOW_SKINS); + return server.overworld().getGameRules().get(Molehunt.SHOW_SKINS); } public boolean tabEnabled() { - return server.getOverworld().getGameRules().getValue(Molehunt.SHOW_TAB); + return server.overworld().getGameRules().get(Molehunt.SHOW_TAB); } public int getInitialWorldSize() { - return server.getOverworld().getGameRules().getValue(Molehunt.INITIAL_WORLD_SIZE); + return server.overworld().getGameRules().get(Molehunt.INITIAL_WORLD_SIZE); } public int getFinalWorldSize() { - return server.getOverworld().getGameRules().getValue(Molehunt.FINAL_WORLD_SIZE); + return server.overworld().getGameRules().get(Molehunt.FINAL_WORLD_SIZE); } public int getBorderShrinkingStartingTimeOffset() { - return server.getOverworld().getGameRules().getValue(Molehunt.MOVING_STARTING_TIME_OFFSET); + return server.overworld().getGameRules().get(Molehunt.MOVING_STARTING_TIME_OFFSET); } public boolean portalsEnabled() { - return server.getOverworld().getGameRules().getValue(Molehunt.ENABLE_PORTALS); + return server.overworld().getGameRules().get(Molehunt.ENABLE_PORTALS); } public boolean foodOnStart() { - return server.getOverworld().getGameRules().getValue(Molehunt.FOOD_ON_START); + return server.overworld().getGameRules().get(Molehunt.FOOD_ON_START); } public static SimpleConfig configFile(String fileName) { diff --git a/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java b/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java index b43bd1b..4c8fcdb 100644 --- a/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java +++ b/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java @@ -1,25 +1,25 @@ package world.anhgelus.molehunt.config; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.util.Identifier; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.Identifier; import world.anhgelus.molehunt.Molehunt; -public record ConfigPayload(boolean showNametags, boolean showSkins, boolean showTab) implements CustomPayload { - public static final Identifier CONFIG_PACKET_ID = Identifier.of(Molehunt.MOD_ID, "config"); +public record ConfigPayload(boolean showNametags, boolean showSkins, boolean showTab) implements CustomPacketPayload { + public static final Identifier CONFIG_PACKET_ID = Identifier.fromNamespaceAndPath(Molehunt.MOD_ID, "config"); - public static final CustomPayload.Id ID = new CustomPayload.Id<>(CONFIG_PACKET_ID); - public static final PacketCodec CODEC = PacketCodec.tuple( - PacketCodecs.BOOLEAN, ConfigPayload::showNametags, - PacketCodecs.BOOLEAN, ConfigPayload::showSkins, - PacketCodecs.BOOLEAN, ConfigPayload::showTab, + public static final CustomPacketPayload.Type ID = new CustomPacketPayload.Type<>(CONFIG_PACKET_ID); + public static final StreamCodec CODEC = StreamCodec.composite( + ByteBufCodecs.BOOL, ConfigPayload::showNametags, + ByteBufCodecs.BOOL, ConfigPayload::showSkins, + ByteBufCodecs.BOOL, ConfigPayload::showTab, ConfigPayload::new ); @Override - public Id getId() { + public Type type() { return ID; } } diff --git a/src/main/java/world/anhgelus/molehunt/game/Game.java b/src/main/java/world/anhgelus/molehunt/game/Game.java index 98fe2b8..d95d211 100644 --- a/src/main/java/world/anhgelus/molehunt/game/Game.java +++ b/src/main/java/world/anhgelus/molehunt/game/Game.java @@ -1,19 +1,19 @@ package world.anhgelus.molehunt.game; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket; -import net.minecraft.network.packet.s2c.play.SubtitleS2CPacket; -import net.minecraft.network.packet.s2c.play.TitleFadeS2CPacket; -import net.minecraft.network.packet.s2c.play.TitleS2CPacket; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket; +import net.minecraft.network.protocol.game.ClientboundSetSubtitleTextPacket; +import net.minecraft.network.protocol.game.ClientboundSetTitleTextPacket; +import net.minecraft.network.protocol.game.ClientboundSetTitlesAnimationPacket; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; -import net.minecraft.world.GameMode; -import net.minecraft.world.rule.GameRules; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.GameType; +import net.minecraft.world.level.gamerules.GameRules; import world.anhgelus.molehunt.Molehunt; import world.anhgelus.molehunt.timer.TickTask; import world.anhgelus.molehunt.timer.TimerAccess; @@ -25,12 +25,12 @@ import java.util.stream.Collectors; public class Game { - public final int defaultTime = Molehunt.CONFIG.getGameDuration() * 60; + public final int DEFAULT_TIME = Molehunt.CONFIG.getGameDuration() * 60; private final MinecraftServer server; private final List moles = new ArrayList<>(); - private final TitleFadeS2CPacket timing = new TitleFadeS2CPacket(20, 40, 20); - private int remaining = defaultTime; + private final ClientboundSetTitlesAnimationPacket timing = new ClientboundSetTitlesAnimationPacket(20, 40, 20); private boolean started = false; + private int remaining = DEFAULT_TIME; public Game(MinecraftServer server) { this.server = server; @@ -38,33 +38,32 @@ public class Game { public void start() { final int n = Molehunt.CONFIG.getMoleCount() < 0 - ? Math.floorDiv(server.getCurrentPlayerCount(), Math.floorDiv(100, Molehunt.CONFIG.getMolePercentage())) + ? Math.floorDiv(server.getPlayerCount(), Math.floorDiv(100, Molehunt.CONFIG.getMolePercentage())) : Molehunt.CONFIG.getMoleCount(); - final var playerManager = server.getPlayerManager(); + final var playerManager = server.getPlayerList(); - final var players = new ArrayList<>(playerManager.getPlayerList()); + final var players = new ArrayList<>(playerManager.getPlayers()); for (int i = 0; i < n && !players.isEmpty(); i++) { final var r = ThreadLocalRandom.current().nextInt(0, players.size()); final var mole = players.get(r); - if (mole == null) throw new IllegalStateException("Mole is null!"); - moles.add(mole.getUuid()); + moles.add(mole.getUUID()); players.remove(r); } - final var gamerules = server.getOverworld().getGameRules(); + final var gamerules = server.overworld().getGameRules(); // immutable gamerules - gamerules.setValue(GameRules.SHOW_DEATH_MESSAGES, false, server); - gamerules.setValue(GameRules.ANNOUNCE_ADVANCEMENTS, false, server); + gamerules.set(GameRules.SHOW_DEATH_MESSAGES, false, server); + gamerules.set(GameRules.SHOW_ADVANCEMENT_MESSAGES, false, server); // gamerules for the start - gamerules.setValue(GameRules.DO_IMMEDIATE_RESPAWN, true, server); + gamerules.set(GameRules.IMMEDIATE_RESPAWN, true, server); final var timer = TimerAccess.getTimerFromOverworld(server); - final var worldBorder = server.getOverworld().getWorldBorder(); + final var worldBorder = server.overworld().getWorldBorder(); worldBorder.setSize(Molehunt.CONFIG.getInitialWorldSize()); if (Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset() < Molehunt.CONFIG.getGameDuration()) { - timer.dds_runTask(new TickTask(() -> worldBorder.interpolateSize( + timer.dds_runTask(new TickTask(() -> worldBorder.lerpSizeBetween( Molehunt.CONFIG.getInitialWorldSize(), Molehunt.CONFIG.getFinalWorldSize(), (long) (Molehunt.CONFIG.getGameDuration() - Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset()) * 60 * 1000, @@ -72,54 +71,56 @@ public class Game { ), (long) Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset() * 60 * 1000)); } - final var title = new TitleS2CPacket(Text.translatable("molehunt.game.start.suspense")); - playerManager.getPlayerList().forEach(p -> { - p.getInventory().clear(); - p.kill(p.getEntityWorld()); - p.networkHandler.sendPacket(timing); - p.networkHandler.sendPacket(title); - p.changeGameMode(GameMode.SURVIVAL); - if (Molehunt.CONFIG.foodOnStart()) p.giveItemStack(new ItemStack(Items.COOKED_BEEF, 64)); + final var title = new ClientboundSetTitleTextPacket(Component.translatable("molehunt.game.start.suspense")); + playerManager.getPlayers().forEach(p -> { + p.getInventory().clearContent(); + p.kill(p.level()); + p.connection.send(timing); + p.connection.send(title); + p.setGameMode(GameType.SURVIVAL); + if (Molehunt.CONFIG.foodOnStart()) p.addItem(new ItemStack(Items.COOKED_BEEF, 64)); }); - server.setDefaultGameMode(GameMode.SPECTATOR); + server.setDefaultGameType(GameType.SPECTATOR); timer.dds_runTask(new TickTask(() -> { - playerManager.getPlayerList().forEach(p -> { - p.networkHandler.sendPacket(timing); - if (moles.contains(p.getUuid())) { - p.networkHandler.sendPacket(new TitleS2CPacket(Text.translatable("molehunt.game.start.mole.title"))); - p.networkHandler.sendPacket(new SubtitleS2CPacket(Text.translatable("molehunt.game.start.mole.subtitle"))); + playerManager.getPlayers().forEach(p -> { + p.connection.send(timing); + if (moles.contains(p.getUUID())) { + p.connection.send(new ClientboundSetTitleTextPacket(Component.translatable("molehunt.game.start.mole.title"))); + p.connection.send(new ClientboundSetSubtitleTextPacket(Component.translatable("molehunt.game.start.mole.subtitle"))); } else { - p.networkHandler.sendPacket(new TitleS2CPacket(Text.translatable("molehunt.game.start.survivor.title"))); - p.networkHandler.sendPacket(new SubtitleS2CPacket(Text.translatable("molehunt.game.start.survivor.subtitle"))); + p.connection.send(new ClientboundSetTitleTextPacket(Component.translatable("molehunt.game.start.survivor.title"))); + p.connection.send(new ClientboundSetSubtitleTextPacket(Component.translatable("molehunt.game.start.survivor.subtitle"))); } // reset health and food level p.setHealth(p.getMaxHealth()); - p.getHungerManager().setFoodLevel(20); - p.getHungerManager().setSaturationLevel(5.0f); + p.getFoodData().setFoodLevel(20); + p.getFoodData().setSaturation(5.0f); }); // reset gamerules after the start - gamerules.setValue(GameRules.DO_IMMEDIATE_RESPAWN, false, server); + gamerules.set(GameRules.IMMEDIATE_RESPAWN, false, server); // reset time and weather - server.getOverworld().setTimeOfDay(0); - server.getOverworld().resetWeather(); + final var overworld = server.overworld(); + server.clockManager() + .setTotalTicks(overworld.getLevel().dimensionType().defaultClock().orElseThrow(), 0); + overworld.resetWeatherCycle(); changeState(true); timer.dds_runTask(new TickTask(() -> { remaining--; - playerManager.getPlayerList().forEach(player -> { - if (Molehunt.timerVisibility.getOrDefault(player.getUuid(), true)) { - player.networkHandler.sendPacket(new OverlayMessageS2CPacket(Text.of(getRemainingText()))); + playerManager.getPlayers().forEach(player -> { + if (Molehunt.timerVisibility.getOrDefault(player.getUUID(), true)) { + player.connection.send(new ClientboundSetActionBarTextPacket(Component.translationArg(getRemainingText()))); } }); - playerManager.sendToAll(timing); + playerManager.broadcastAll(timing); if (remaining == 0) end(); }, 5 * 1000, 1000)); }, 4 * 1000)); } public void stop() { - server.getPlayerManager().broadcast(Text.translatable("commands.molehunt.stop.success"), false); + server.getPlayerList().broadcastSystemMessage(Component.translatable("commands.molehunt.stop.success"), false); end(); } @@ -127,39 +128,40 @@ public class Game { final var timer = TimerAccess.getTimerFromOverworld(server); timer.dds_cancel(); - final var worldBorder = server.getOverworld().getWorldBorder(); + final var worldBorder = server.overworld().getWorldBorder(); // Stops the border shrinking. worldBorder.setSize(worldBorder.getSize()); changeState(false); - final var pm = server.getPlayerManager(); - final var winnerSuspense = new TitleS2CPacket(Text.translatable("molehunt.game.end.suspense.title")); - pm.getPlayerList().forEach(p -> { - p.networkHandler.sendPacket(timing); - p.networkHandler.sendPacket(winnerSuspense); - p.changeGameMode(GameMode.CREATIVE); + final var pm = server.getPlayerList(); + final var winnerSuspense = new ClientboundSetTitleTextPacket(Component.translatable("molehunt.game.end.suspense.title")); + pm.getPlayers().forEach(p -> { + p.connection.send(timing); + p.connection.send(winnerSuspense); + p.setGameMode(GameType.CREATIVE); }); + timer.dds_runTask(new TickTask(() -> { - TitleS2CPacket winner; + ClientboundSetTitleTextPacket winner; if (wonByMoles()) { - winner = new TitleS2CPacket(Text.translatable("molehunt.game.end.winners.moles.title")); + winner = new ClientboundSetTitleTextPacket(Component.translatable("molehunt.game.end.winners.moles.title")); } else { - winner = new TitleS2CPacket(Text.translatable("molehunt.game.end.winners.survivors.title")); + winner = new ClientboundSetTitleTextPacket(Component.translatable("molehunt.game.end.winners.survivors.title")); } - pm.sendToAll(new SubtitleS2CPacket(Text.translatable("molehunt.game.end.winners.subtitle", getMolesAsString()))); - pm.sendToAll(winner); - pm.sendToAll(timing); + pm.broadcastAll(new ClientboundSetSubtitleTextPacket(Component.translatable("molehunt.game.end.winners.subtitle", getMolesAsString()))); + pm.broadcastAll(winner); + pm.broadcastAll(timing); moles.clear(); }, 4 * 1000)); } - public Text getRemainingText() { - return Text.of("§c" + TimeUtils.generateShortString(remaining)); + public Component getRemainingText() { + return Component.nullToEmpty("§c" + TimeUtils.generateShortString(remaining)); } - public List getMoles() { + public List getMoles() { return moles.stream() - .map(uuid -> server.getPlayerManager().getPlayer(uuid)) + .map(uuid -> server.getPlayerList().getPlayer(uuid)) .filter(Objects::nonNull) .filter(p -> !p.isSpectator()) .toList(); @@ -167,23 +169,22 @@ public class Game { public String getMolesAsString() { return getMoles().stream() - .map(PlayerEntity::getDisplayName) - .filter(Objects::nonNull) + .map(Player::getDisplayName) .map(Object::toString) .collect(Collectors.joining(", ")); } - public boolean isMole(ServerPlayerEntity player) { - return moles.contains(player.getUuid()); + public boolean isMole(ServerPlayer player) { + return moles.contains(player.getUUID()); } public boolean wonByMoles() { return new HashSet<>(moles).containsAll( - server.getPlayerManager() - .getPlayerList() + server.getPlayerList() + .getPlayers() .stream() .filter(p -> !p.isSpectator() && !p.isCreative()) - .map(Entity::getUuid) + .map(Entity::getUUID) .toList() ); } @@ -195,6 +196,6 @@ public class Game { private void changeState(boolean hasStarted) { started = hasStarted; final var payload = new GamePayload(hasStarted); - server.getPlayerManager().getPlayerList().forEach(p -> ServerPlayNetworking.send(p, payload)); + server.getPlayerList().getPlayers().forEach(p -> ServerPlayNetworking.send(p, payload)); } } diff --git a/src/main/java/world/anhgelus/molehunt/game/GamePayload.java b/src/main/java/world/anhgelus/molehunt/game/GamePayload.java index 66e3209..f611385 100644 --- a/src/main/java/world/anhgelus/molehunt/game/GamePayload.java +++ b/src/main/java/world/anhgelus/molehunt/game/GamePayload.java @@ -1,23 +1,23 @@ package world.anhgelus.molehunt.game; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.util.Identifier; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.Identifier; import world.anhgelus.molehunt.Molehunt; -public record GamePayload(boolean gameLaunched) implements CustomPayload { - public static final Identifier GAME_PACKET_ID = Identifier.of(Molehunt.MOD_ID, "game"); +public record GamePayload(boolean gameLaunched) implements CustomPacketPayload { + public static final Identifier GAME_PACKET_ID = Identifier.fromNamespaceAndPath(Molehunt.MOD_ID, "game"); - public static final CustomPayload.Id ID = new CustomPayload.Id<>(GAME_PACKET_ID); - public static final PacketCodec CODEC = PacketCodec.tuple( - PacketCodecs.BOOLEAN, GamePayload::gameLaunched, + public static final CustomPacketPayload.Type ID = new CustomPacketPayload.Type<>(GAME_PACKET_ID); + public static final StreamCodec CODEC = StreamCodec.composite( + ByteBufCodecs.BOOL, GamePayload::gameLaunched, GamePayload::new ); @Override - public Id getId() { + public Type type() { return ID; } } diff --git a/src/main/java/world/anhgelus/molehunt/mixin/NoJoinLeaveMessage.java b/src/main/java/world/anhgelus/molehunt/mixin/NoJoinLeaveMessage.java index a82a21e..0771981 100644 --- a/src/main/java/world/anhgelus/molehunt/mixin/NoJoinLeaveMessage.java +++ b/src/main/java/world/anhgelus/molehunt/mixin/NoJoinLeaveMessage.java @@ -1,18 +1,18 @@ package world.anhgelus.molehunt.mixin; -import net.minecraft.server.PlayerManager; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; +import net.minecraft.server.players.PlayerList; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(PlayerManager.class) +@Mixin(PlayerList.class) public class NoJoinLeaveMessage { - @Inject(at = @At("HEAD"), method = "broadcast*", cancellable = true) - public void broadcastNoJoinLeaveMessage(Text message, boolean overlay, CallbackInfo ci) { - final var content = message.getContent().toString(); - if (content.startsWith("translation{key='multiplayer.player.joined")) ci.cancel(); - else if (content.startsWith("translation{key='multiplayer.player.left")) ci.cancel(); + @Inject(at = @At("HEAD"), method = "broadcastSystemMessage*", cancellable = true) + public void broadcastNoJoinLeaveMessage(final Component message, final boolean overlay, CallbackInfo ci) { + final var content = message.getContents().toString(); + if (content.startsWith("translation{key='multiplayer.player.joined") || + content.startsWith("translation{key='multiplayer.player.left")) ci.cancel(); } } diff --git a/src/main/java/world/anhgelus/molehunt/mixin/NoMsgCommand.java b/src/main/java/world/anhgelus/molehunt/mixin/NoMsgCommand.java index 2727143..b68773e 100644 --- a/src/main/java/world/anhgelus/molehunt/mixin/NoMsgCommand.java +++ b/src/main/java/world/anhgelus/molehunt/mixin/NoMsgCommand.java @@ -1,17 +1,17 @@ package world.anhgelus.molehunt.mixin; import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.server.command.MessageCommand; -import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.server.commands.MsgCommand; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(MessageCommand.class) +@Mixin(MsgCommand.class) public class NoMsgCommand { @Inject(at = @At("HEAD"), method = "register", cancellable = true) - private static void register(CommandDispatcher dispatcher, CallbackInfo ci) { + private static void register(CommandDispatcher dispatcher, CallbackInfo ci) { ci.cancel(); } } diff --git a/src/main/java/world/anhgelus/molehunt/mixin/NoPortals.java b/src/main/java/world/anhgelus/molehunt/mixin/NoPortals.java index a71e6d1..74504fe 100644 --- a/src/main/java/world/anhgelus/molehunt/mixin/NoPortals.java +++ b/src/main/java/world/anhgelus/molehunt/mixin/NoPortals.java @@ -1,18 +1,18 @@ package world.anhgelus.molehunt.mixin; -import net.minecraft.entity.Entity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.world.dimension.PortalManager; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.PortalProcessor; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import world.anhgelus.molehunt.Molehunt; -@Mixin(PortalManager.class) +@Mixin(PortalProcessor.class) public class NoPortals { - @Inject(at = @At("HEAD"), method = "tick", cancellable = true) - public void disableTick(ServerWorld world, Entity entity, boolean canUsePortals, CallbackInfoReturnable cir) { + @Inject(at = @At("HEAD"), method = "processPortalTeleportation", cancellable = true) + public void disableTick(ServerLevel world, Entity entity, boolean canUsePortals, CallbackInfoReturnable cir) { if (Molehunt.CONFIG == null || Molehunt.CONFIG.portalsEnabled()) return; cir.setReturnValue(false); } -- cgit v1.2.3