diff --git a/build.gradle b/build.gradle index 6904011..9796df3 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,8 @@ description = 'ChomeNS Bot' java.sourceCompatibility = JavaVersion.VERSION_17 repositories { + mavenLocal() + mavenCentral() maven { @@ -28,12 +30,10 @@ repositories { maven { url = uri('https://repo.maven.apache.org/maven2/') } - - mavenLocal() } dependencies { - implementation 'com.github.steveice10:mcprotocollib:1.20-2-SNAPSHOT' + implementation 'com.github.steveice10:mcprotocollib:1.20.2-1-SNAPSHOT' implementation 'net.kyori:adventure-text-serializer-ansi:4.14.0' implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.google.guava:guava:31.1-jre' diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java index b343f03..ad7f990 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java @@ -5,8 +5,8 @@ import com.github.steveice10.mc.protocol.MinecraftProtocol; import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference; import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility; import com.github.steveice10.mc.protocol.data.game.setting.SkinPart; +import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundClientInformationPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket; -import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientInformationPacket; import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundGameProfilePacket; import com.github.steveice10.packetlib.Session; import com.github.steveice10.packetlib.event.session.*; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/PlayersPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/PlayersPlugin.java index 15d8f45..7b38601 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/PlayersPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/PlayersPlugin.java @@ -1,5 +1,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins; +import com.github.steveice10.mc.auth.data.GameProfile; import com.github.steveice10.mc.protocol.data.game.PlayerListEntry; import com.github.steveice10.mc.protocol.data.game.PlayerListEntryAction; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; @@ -91,7 +92,11 @@ public class PlayersPlugin extends Bot.Listener { public PlayerEntry getBotEntry () { return getEntry(bot.username); } private PlayerEntry getEntry (PlayerListEntry other) { - return getEntry(other.getProfile().getId()); + final GameProfile gameProfile = other.getProfile(); + + if (gameProfile == null) return null; + + return getEntry(gameProfile.getId()); } private void initializeChat (PlayerListEntry newEntry) { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/PositionPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/PositionPlugin.java index 5f15a69..334d7b5 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/PositionPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/PositionPlugin.java @@ -5,7 +5,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.Client import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityRotPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundRemoveEntitiesPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddPlayerPacket; +import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket; import com.github.steveice10.packetlib.Session; @@ -54,7 +54,7 @@ public class PositionPlugin extends Bot.Listener { else if (packet instanceof ClientboundMoveEntityRotPacket) packetReceived((ClientboundMoveEntityRotPacket) packet); else if (packet instanceof ClientboundMoveEntityPosPacket) packetReceived((ClientboundMoveEntityPosPacket) packet); else if (packet instanceof ClientboundMoveEntityPosRotPacket) packetReceived((ClientboundMoveEntityPosRotPacket) packet); - else if (packet instanceof ClientboundAddPlayerPacket) packetReceived((ClientboundAddPlayerPacket) packet); + else if (packet instanceof ClientboundAddEntityPacket) packetReceived((ClientboundAddEntityPacket) packet); else if (packet instanceof ClientboundRemoveEntitiesPacket) packetReceived((ClientboundRemoveEntitiesPacket) packet); } @@ -65,7 +65,7 @@ public class PositionPlugin extends Bot.Listener { for (Listener listener : listeners) { listener.positionChange(position); } } - public void packetReceived (ClientboundAddPlayerPacket packet) { + public void packetReceived (ClientboundAddEntityPacket packet) { final PlayerEntry entry = bot.players.getEntry(packet.getUuid()); if (entry == null) return; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java index 2bf9d9d..0842e91 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java @@ -129,7 +129,7 @@ public class SelfCarePlugin extends Bot.Listener { public void packetReceived (ClientboundLoginPacket packet) { this.entityId = packet.getEntityId(); - this.gamemode = packet.getGameMode(); + this.gamemode = packet.getCommonPlayerSpawnInfo().getGameMode(); cspy = false; vanish = false; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java index 09fdd1e..c6b6289 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java @@ -1,8 +1,8 @@ package land.chipmunk.chayapak.chomens_bot.plugins; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket; +import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundCustomPayloadPacket; +import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundCustomPayloadPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket; -import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket; import com.github.steveice10.packetlib.Session; import com.github.steveice10.packetlib.event.session.DisconnectedEvent; import com.github.steveice10.packetlib.packet.Packet; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/WorldPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/WorldPlugin.java index f64d9cd..afa810e 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/WorldPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/WorldPlugin.java @@ -1,5 +1,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins; +import com.github.steveice10.mc.protocol.packet.configuration.clientbound.ClientboundRegistryDataPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundRespawnPacket; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; @@ -13,6 +14,8 @@ import java.util.LinkedHashMap; import java.util.List; public class WorldPlugin extends Bot.Listener { + private final Bot bot; + public int minY = 0; public int maxY = 256; @@ -21,6 +24,8 @@ public class WorldPlugin extends Bot.Listener { private final List listeners = new ArrayList<>(); public WorldPlugin (Bot bot) { + this.bot = bot; + bot.addListener(this); } @@ -28,6 +33,7 @@ public class WorldPlugin extends Bot.Listener { public void packetReceived(Session session, Packet packet) { if (packet instanceof ClientboundLoginPacket) packetReceived((ClientboundLoginPacket) packet); else if (packet instanceof ClientboundRespawnPacket) packetReceived((ClientboundRespawnPacket) packet); + else if (packet instanceof ClientboundRegistryDataPacket) packetReceived((ClientboundRegistryDataPacket) packet); } @SuppressWarnings("unchecked") @@ -48,14 +54,16 @@ public class WorldPlugin extends Bot.Listener { for (Listener listener : listeners) listener.worldChanged(dimension); } - public void packetReceived (ClientboundLoginPacket packet) { + public void packetReceived (ClientboundRegistryDataPacket packet) { registry = packet.getRegistry(); + } - worldChanged(packet.getDimension()); + public void packetReceived (ClientboundLoginPacket packet) { + worldChanged(packet.getCommonPlayerSpawnInfo().getDimension()); } public void packetReceived (ClientboundRespawnPacket packet) { - worldChanged(packet.getDimension()); + worldChanged(packet.getCommonPlayerSpawnInfo().getDimension()); } public static class Listener {