diff --git a/.gitignore b/.gitignore index 13f683911..91cac5b18 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,13 @@ bin lib +target +testing .settings .classpath .project +.directory *.iml .idea -target - diff --git a/LICENSE.txt b/LICENSE.txt index cff88880f..e69695f57 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (C) 2013-2014 Steveice10 +Copyright (C) 2013-2015 Steveice10 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index 4c4e612f1..efa01c1c7 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,14 @@ -

MCProtocolLib

-========== - - - -About MCProtocolLib --------- - +# MCProtocolLib MCProtocolLib is a simple library for communicating with a Minecraft client/server. It aims to allow people to make custom bots, clients, or servers for Minecraft easily. +## Example Code +See example/org/spacehq/mc/protocol/test -Example Code --------- - -See example/org/spacehq/mc/protocol/test/Test.java - - -Building the Source --------- - +## Building the Source MCProtocolLib uses Maven to manage dependencies. Simply run 'mvn clean install' in the source's directory. -Snapshots (if any exist) can be downloaded [here](http://repo.spacehq.org/content/repositories/snapshots/org/spacehq/mcprotocollib). -Releases (if any exist) can be downloaded [here](http://repo.spacehq.org/content/repositories/release/org/spacehq/mcprotocollib). - -License ---------- +Builds can be downloaded **[here](http://build.spacehq.org/job/MCProtocolLib)**. -MCProtocolLib is licensed under the [MIT license](http://www.opensource.org/licenses/mit-license.html). +## License +MCProtocolLib is licensed under the **[MIT license](http://www.opensource.org/licenses/mit-license.html)**. diff --git a/example/org/spacehq/mc/protocol/test/MinecraftProtocolTest.java b/example/org/spacehq/mc/protocol/test/MinecraftProtocolTest.java new file mode 100644 index 000000000..b22d1e59d --- /dev/null +++ b/example/org/spacehq/mc/protocol/test/MinecraftProtocolTest.java @@ -0,0 +1,183 @@ +package org.spacehq.mc.protocol.test; + +import org.spacehq.mc.auth.GameProfile; +import org.spacehq.mc.auth.exception.AuthenticationException; +import org.spacehq.mc.protocol.MinecraftProtocol; +import org.spacehq.mc.protocol.ProtocolConstants; +import org.spacehq.mc.protocol.ProtocolMode; +import org.spacehq.mc.protocol.ServerLoginHandler; +import org.spacehq.mc.protocol.data.game.values.entity.player.GameMode; +import org.spacehq.mc.protocol.data.game.values.setting.Difficulty; +import org.spacehq.mc.protocol.data.game.values.world.WorldType; +import org.spacehq.mc.protocol.data.message.ChatColor; +import org.spacehq.mc.protocol.data.message.ChatFormat; +import org.spacehq.mc.protocol.data.message.Message; +import org.spacehq.mc.protocol.data.message.MessageStyle; +import org.spacehq.mc.protocol.data.message.TextMessage; +import org.spacehq.mc.protocol.data.message.TranslationMessage; +import org.spacehq.mc.protocol.data.status.PlayerInfo; +import org.spacehq.mc.protocol.data.status.ServerStatusInfo; +import org.spacehq.mc.protocol.data.status.VersionInfo; +import org.spacehq.mc.protocol.data.status.handler.ServerInfoBuilder; +import org.spacehq.mc.protocol.data.status.handler.ServerInfoHandler; +import org.spacehq.mc.protocol.data.status.handler.ServerPingTimeHandler; +import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket; +import org.spacehq.packetlib.Client; +import org.spacehq.packetlib.Server; +import org.spacehq.packetlib.Session; +import org.spacehq.packetlib.event.server.ServerAdapter; +import org.spacehq.packetlib.event.server.SessionAddedEvent; +import org.spacehq.packetlib.event.server.SessionRemovedEvent; +import org.spacehq.packetlib.event.session.DisconnectedEvent; +import org.spacehq.packetlib.event.session.PacketReceivedEvent; +import org.spacehq.packetlib.event.session.SessionAdapter; +import org.spacehq.packetlib.tcp.TcpSessionFactory; + +import java.net.Proxy; +import java.util.Arrays; + +public class MinecraftProtocolTest { + private static final boolean SPAWN_SERVER = true; + private static final boolean VERIFY_USERS = false; + private static final String HOST = "127.0.0.1"; + private static final int PORT = 25565; + private static final Proxy PROXY = Proxy.NO_PROXY; + private static final Proxy AUTH_PROXY = Proxy.NO_PROXY; + private static final String USERNAME = "Username"; + private static final String PASSWORD = "Password"; + + public static void main(String[] args) { + if(SPAWN_SERVER) { + Server server = new Server(HOST, PORT, MinecraftProtocol.class, new TcpSessionFactory(PROXY)); + server.setGlobalFlag(ProtocolConstants.AUTH_PROXY_KEY, AUTH_PROXY); + server.setGlobalFlag(ProtocolConstants.VERIFY_USERS_KEY, VERIFY_USERS); + server.setGlobalFlag(ProtocolConstants.SERVER_INFO_BUILDER_KEY, new ServerInfoBuilder() { + @Override + public ServerStatusInfo buildInfo(Session session) { + return new ServerStatusInfo(new VersionInfo(ProtocolConstants.GAME_VERSION, ProtocolConstants.PROTOCOL_VERSION), new PlayerInfo(100, 0, new GameProfile[0]), new TextMessage("Hello world!"), null); + } + }); + + server.setGlobalFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY, new ServerLoginHandler() { + @Override + public void loggedIn(Session session) { + session.send(new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, 0, Difficulty.PEACEFUL, 10, WorldType.DEFAULT, false)); + } + }); + + server.setGlobalFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD, 100); + server.addListener(new ServerAdapter() { + @Override + public void sessionAdded(SessionAddedEvent event) { + event.getSession().addListener(new SessionAdapter() { + @Override + public void packetReceived(PacketReceivedEvent event) { + if(event.getPacket() instanceof ClientChatPacket) { + ClientChatPacket packet = event.getPacket(); + GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY); + System.out.println(profile.getName() + ": " + packet.getMessage()); + Message msg = new TextMessage("Hello, ").setStyle(new MessageStyle().setColor(ChatColor.GREEN)); + Message name = new TextMessage(profile.getName()).setStyle(new MessageStyle().setColor(ChatColor.AQUA).addFormat(ChatFormat.UNDERLINED)); + Message end = new TextMessage("!"); + msg.addExtra(name); + msg.addExtra(end); + event.getSession().send(new ServerChatPacket(msg)); + } + } + }); + } + + @Override + public void sessionRemoved(SessionRemovedEvent event) { + MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); + if(protocol.getMode() == ProtocolMode.GAME) { + System.out.println("Closing server."); + event.getServer().close(); + } + } + }); + + server.bind(); + } + + status(); + login(); + } + + private static void status() { + MinecraftProtocol protocol = new MinecraftProtocol(ProtocolMode.STATUS); + Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(PROXY)); + client.getSession().setFlag(ProtocolConstants.AUTH_PROXY_KEY, AUTH_PROXY); + client.getSession().setFlag(ProtocolConstants.SERVER_INFO_HANDLER_KEY, new ServerInfoHandler() { + @Override + public void handle(Session session, ServerStatusInfo info) { + System.out.println("Version: " + info.getVersionInfo().getVersionName() + ", " + info.getVersionInfo().getProtocolVersion()); + System.out.println("Player Count: " + info.getPlayerInfo().getOnlinePlayers() + " / " + info.getPlayerInfo().getMaxPlayers()); + System.out.println("Players: " + Arrays.toString(info.getPlayerInfo().getPlayers())); + System.out.println("Description: " + info.getDescription().getFullText()); + System.out.println("Icon: " + info.getIcon()); + } + }); + + client.getSession().setFlag(ProtocolConstants.SERVER_PING_TIME_HANDLER_KEY, new ServerPingTimeHandler() { + @Override + public void handle(Session session, long pingTime) { + System.out.println("Server ping took " + pingTime + "ms"); + } + }); + + client.getSession().connect(); + while(client.getSession().isConnected()) { + try { + Thread.sleep(5); + } catch(InterruptedException e) { + e.printStackTrace(); + } + } + } + + private static void login() { + MinecraftProtocol protocol = null; + if(VERIFY_USERS) { + try { + protocol = new MinecraftProtocol(USERNAME, PASSWORD, false); + System.out.println("Successfully authenticated user."); + } catch(AuthenticationException e) { + e.printStackTrace(); + return; + } + } else { + protocol = new MinecraftProtocol(USERNAME); + } + + Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(PROXY)); + client.getSession().addListener(new SessionAdapter() { + @Override + public void packetReceived(PacketReceivedEvent event) { + if(event.getPacket() instanceof ServerJoinGamePacket) { + event.getSession().send(new ClientChatPacket("Hello, this is a test of MCProtocolLib.")); + } else if(event.getPacket() instanceof ServerChatPacket) { + Message message = event.getPacket().getMessage(); + System.out.println("Received Message: " + message.getFullText()); + if(message instanceof TranslationMessage) { + System.out.println("Received Translation Components: " + Arrays.toString(((TranslationMessage) message).getTranslationParams())); + } + + event.getSession().disconnect("Finished"); + } + } + + @Override + public void disconnected(DisconnectedEvent event) { + System.out.println("Disconnected: " + Message.fromString(event.getReason()).getFullText()); + if(event.getCause() != null) { + event.getCause().printStackTrace(); + } + } + }); + + client.getSession().connect(); + } +} diff --git a/example/org/spacehq/mc/protocol/test/Test.java b/example/org/spacehq/mc/protocol/test/Test.java deleted file mode 100644 index a1e37e16f..000000000 --- a/example/org/spacehq/mc/protocol/test/Test.java +++ /dev/null @@ -1,177 +0,0 @@ -package org.spacehq.mc.protocol.test; - -import org.spacehq.mc.auth.GameProfile; -import org.spacehq.mc.auth.exception.AuthenticationException; -import org.spacehq.mc.protocol.MinecraftProtocol; -import org.spacehq.mc.protocol.ProtocolConstants; -import org.spacehq.mc.protocol.ProtocolMode; -import org.spacehq.mc.protocol.ServerLoginHandler; -import org.spacehq.mc.protocol.data.game.values.entity.player.GameMode; -import org.spacehq.mc.protocol.data.game.values.setting.Difficulty; -import org.spacehq.mc.protocol.data.game.values.world.WorldType; -import org.spacehq.mc.protocol.data.message.*; -import org.spacehq.mc.protocol.data.status.PlayerInfo; -import org.spacehq.mc.protocol.data.status.ServerStatusInfo; -import org.spacehq.mc.protocol.data.status.VersionInfo; -import org.spacehq.mc.protocol.data.status.handler.ServerInfoBuilder; -import org.spacehq.mc.protocol.data.status.handler.ServerInfoHandler; -import org.spacehq.mc.protocol.data.status.handler.ServerPingTimeHandler; -import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket; -import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; -import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket; -import org.spacehq.packetlib.Client; -import org.spacehq.packetlib.Server; -import org.spacehq.packetlib.Session; -import org.spacehq.packetlib.event.server.ServerAdapter; -import org.spacehq.packetlib.event.server.SessionAddedEvent; -import org.spacehq.packetlib.event.server.SessionRemovedEvent; -import org.spacehq.packetlib.event.session.DisconnectedEvent; -import org.spacehq.packetlib.event.session.PacketReceivedEvent; -import org.spacehq.packetlib.event.session.SessionAdapter; -import org.spacehq.packetlib.tcp.TcpSessionFactory; - -import java.net.Proxy; -import java.util.Arrays; - -public class Test { - - private static final boolean SPAWN_SERVER = true; - private static final boolean VERIFY_USERS = false; - private static final String HOST = "127.0.0.1"; - private static final int PORT = 25565; - private static final Proxy PROXY = Proxy.NO_PROXY; - private static final Proxy AUTH_PROXY = Proxy.NO_PROXY; - private static final String USERNAME = "Username"; - private static final String PASSWORD = "Password"; - - public static void main(String[] args) { - if(SPAWN_SERVER) { - Server server = new Server(HOST, PORT, MinecraftProtocol.class, new TcpSessionFactory(PROXY)); - server.setGlobalFlag(ProtocolConstants.AUTH_PROXY_KEY, AUTH_PROXY); - server.setGlobalFlag(ProtocolConstants.VERIFY_USERS_KEY, VERIFY_USERS); - server.setGlobalFlag(ProtocolConstants.SERVER_INFO_BUILDER_KEY, new ServerInfoBuilder() { - @Override - public ServerStatusInfo buildInfo(Session session) { - return new ServerStatusInfo(new VersionInfo(ProtocolConstants.GAME_VERSION, ProtocolConstants.PROTOCOL_VERSION), new PlayerInfo(100, 0, new GameProfile[0]), new TextMessage("Hello world!"), null); - } - }); - - server.setGlobalFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY, new ServerLoginHandler() { - @Override - public void loggedIn(Session session) { - session.send(new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, 0, Difficulty.PEACEFUL, 10, WorldType.DEFAULT, false)); - } - }); - - server.setGlobalFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD, 100); - server.addListener(new ServerAdapter() { - @Override - public void sessionAdded(SessionAddedEvent event) { - event.getSession().addListener(new SessionAdapter() { - @Override - public void packetReceived(PacketReceivedEvent event) { - if(event.getPacket() instanceof ClientChatPacket) { - ClientChatPacket packet = event.getPacket(); - GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY); - System.out.println(profile.getName() + ": " + packet.getMessage()); - Message msg = new TextMessage("Hello, ").setStyle(new MessageStyle().setColor(ChatColor.GREEN)); - Message name = new TextMessage(profile.getName()).setStyle(new MessageStyle().setColor(ChatColor.AQUA).addFormat(ChatFormat.UNDERLINED)); - Message end = new TextMessage("!"); - msg.addExtra(name); - msg.addExtra(end); - event.getSession().send(new ServerChatPacket(msg)); - } - } - }); - } - - @Override - public void sessionRemoved(SessionRemovedEvent event) { - MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); - if(protocol.getMode() == ProtocolMode.GAME) { - System.out.println("Closing server."); - event.getServer().close(); - } - } - }); - - server.bind(); - } - - status(); - login(); - } - - private static void status() { - MinecraftProtocol protocol = new MinecraftProtocol(ProtocolMode.STATUS); - Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(PROXY)); - client.getSession().setFlag(ProtocolConstants.AUTH_PROXY_KEY, AUTH_PROXY); - client.getSession().setFlag(ProtocolConstants.SERVER_INFO_HANDLER_KEY, new ServerInfoHandler() { - @Override - public void handle(Session session, ServerStatusInfo info) { - System.out.println("Version: " + info.getVersionInfo().getVersionName() + ", " + info.getVersionInfo().getProtocolVersion()); - System.out.println("Player Count: " + info.getPlayerInfo().getOnlinePlayers() + " / " + info.getPlayerInfo().getMaxPlayers()); - System.out.println("Players: " + Arrays.toString(info.getPlayerInfo().getPlayers())); - System.out.println("Description: " + info.getDescription().getFullText()); - System.out.println("Icon: " + info.getIcon()); - } - }); - - client.getSession().setFlag(ProtocolConstants.SERVER_PING_TIME_HANDLER_KEY, new ServerPingTimeHandler() { - @Override - public void handle(Session session, long pingTime) { - System.out.println("Server ping took " + pingTime + "ms"); - } - }); - - client.getSession().connect(); - while(client.getSession().isConnected()) { - try { - Thread.sleep(5); - } catch(InterruptedException e) { - e.printStackTrace(); - } - } - } - - private static void login() { - MinecraftProtocol protocol = null; - if(VERIFY_USERS) { - try { - protocol = new MinecraftProtocol(USERNAME, PASSWORD, false); - System.out.println("Successfully authenticated user."); - } catch(AuthenticationException e) { - e.printStackTrace(); - return; - } - } else { - protocol = new MinecraftProtocol(USERNAME); - } - - Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(PROXY)); - client.getSession().addListener(new SessionAdapter() { - @Override - public void packetReceived(PacketReceivedEvent event) { - if(event.getPacket() instanceof ServerJoinGamePacket) { - event.getSession().send(new ClientChatPacket("Hello, this is a test of MCProtocolLib.")); - } else if(event.getPacket() instanceof ServerChatPacket) { - Message message = event.getPacket().getMessage(); - System.out.println("Received Message: " + message.getFullText()); - if(message instanceof TranslationMessage) { - System.out.println("Received Translation Components: " + Arrays.toString(((TranslationMessage) message).getTranslationParams())); - } - - event.getSession().disconnect("Finished"); - } - } - - @Override - public void disconnected(DisconnectedEvent event) { - System.out.println("Disconnected: " + Message.fromString(event.getReason()).getFullText()); - } - }); - - client.getSession().connect(); - } - -} diff --git a/pom.xml b/pom.xml index e9dd6baee..a6266d47c 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,16 @@ A library for communicating with a Minecraft client or server. http://github.com/Steveice10/MCProtocolLib/ + + scm:git:git@github.com:Steveice10/MCProtocolLib.git + scm:git:git@github.com:Steveice10/MCProtocolLib.git + git@github.com:Steveice10/MCProtocolLib/ + + + + UTF-8 + + MIT @@ -19,17 +29,19 @@ - - scm:git:git@github.com:Steveice10/MCProtocolLib.git - scm:git:git@github.com:Steveice10/MCProtocolLib.git - git@github.com:Steveice10/MCProtocolLib/ - + + + steveice10 + Steveice10 + Steveice10@gmail.com + + spacehq spacehq-releases - http://repo.spacehq.org/content/repositories/release/ + http://repo.spacehq.org/content/repositories/releases/ spacehq @@ -38,18 +50,10 @@ - - - steveice10 - Steveice10 - Steveice10@gmail.com - - - spacehq-releases - http://repo.spacehq.org/content/repositories/release/ + http://repo.spacehq.org/content/repositories/releases/ spacehq-snapshots @@ -57,22 +61,17 @@ - - UTF-8 - - - org.spacehq opennbt - 1.4 + 1.0 compile org.spacehq packetlib - 1.0-SNAPSHOT + 1.0 compile @@ -89,23 +88,21 @@ org.apache.maven.plugins maven-compiler-plugin - 2.3.2 + 2.5.1 1.6 1.6 - org.apache.maven.plugins maven-jar-plugin - 2.3.2 + 2.6 - org.apache.maven.plugins maven-shade-plugin - 1.5 + 2.4.1 package @@ -115,6 +112,7 @@ + ${project.build.directory}/dependency-reduced-pom.xml *:* diff --git a/src/main/java/org/spacehq/mc/protocol/ClientListener.java b/src/main/java/org/spacehq/mc/protocol/ClientListener.java index b921dce62..854bf288c 100644 --- a/src/main/java/org/spacehq/mc/protocol/ClientListener.java +++ b/src/main/java/org/spacehq/mc/protocol/ClientListener.java @@ -36,100 +36,100 @@ public class ClientListener extends SessionAdapter { - private SecretKey key; + private SecretKey key; - @Override - public void packetReceived(PacketReceivedEvent event) { - MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); - if(protocol.getMode() == ProtocolMode.LOGIN) { - if(event.getPacket() instanceof EncryptionRequestPacket) { - EncryptionRequestPacket packet = event.getPacket(); - this.key = CryptUtil.generateSharedKey(); + @Override + public void packetReceived(PacketReceivedEvent event) { + MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); + if(protocol.getMode() == ProtocolMode.LOGIN) { + if(event.getPacket() instanceof EncryptionRequestPacket) { + EncryptionRequestPacket packet = event.getPacket(); + this.key = CryptUtil.generateSharedKey(); - Proxy proxy = event.getSession().getFlag(ProtocolConstants.AUTH_PROXY_KEY); - if(proxy == null) { - proxy = Proxy.NO_PROXY; - } + Proxy proxy = event.getSession().getFlag(ProtocolConstants.AUTH_PROXY_KEY); + if(proxy == null) { + proxy = Proxy.NO_PROXY; + } - GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY); - String serverHash = new BigInteger(CryptUtil.getServerIdHash(packet.getServerId(), packet.getPublicKey(), this.key)).toString(16); - String accessToken = event.getSession().getFlag(ProtocolConstants.ACCESS_TOKEN_KEY); - try { - new SessionService(proxy).joinServer(profile, accessToken, serverHash); - } catch(AuthenticationUnavailableException e) { - event.getSession().disconnect("Login failed: Authentication service unavailable."); - return; - } catch(InvalidCredentialsException e) { - event.getSession().disconnect("Login failed: Invalid login session."); - return; - } catch(AuthenticationException e) { - event.getSession().disconnect("Login failed: Authentication error: " + e.getMessage()); - return; - } + GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY); + String serverHash = new BigInteger(CryptUtil.getServerIdHash(packet.getServerId(), packet.getPublicKey(), this.key)).toString(16); + String accessToken = event.getSession().getFlag(ProtocolConstants.ACCESS_TOKEN_KEY); + try { + new SessionService(proxy).joinServer(profile, accessToken, serverHash); + } catch(AuthenticationUnavailableException e) { + event.getSession().disconnect("Login failed: Authentication service unavailable."); + return; + } catch(InvalidCredentialsException e) { + event.getSession().disconnect("Login failed: Invalid login session."); + return; + } catch(AuthenticationException e) { + event.getSession().disconnect("Login failed: Authentication error: " + e.getMessage()); + return; + } - event.getSession().send(new EncryptionResponsePacket(this.key, packet.getPublicKey(), packet.getVerifyToken())); - } else if(event.getPacket() instanceof LoginSuccessPacket) { - LoginSuccessPacket packet = event.getPacket(); - event.getSession().setFlag(ProtocolConstants.PROFILE_KEY, packet.getProfile()); - protocol.setMode(ProtocolMode.GAME, true, event.getSession()); - } else if(event.getPacket() instanceof LoginDisconnectPacket) { - LoginDisconnectPacket packet = event.getPacket(); - event.getSession().disconnect(packet.getReason().getFullText()); - } else if(event.getPacket() instanceof LoginSetCompressionPacket) { - event.getSession().setCompressionThreshold(event.getPacket().getThreshold()); - } - } else if(protocol.getMode() == ProtocolMode.STATUS) { - if(event.getPacket() instanceof StatusResponsePacket) { - ServerStatusInfo info = event.getPacket().getInfo(); - ServerInfoHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_INFO_HANDLER_KEY); - if(handler != null) { - handler.handle(event.getSession(), info); - } + event.getSession().send(new EncryptionResponsePacket(this.key, packet.getPublicKey(), packet.getVerifyToken())); + } else if(event.getPacket() instanceof LoginSuccessPacket) { + LoginSuccessPacket packet = event.getPacket(); + event.getSession().setFlag(ProtocolConstants.PROFILE_KEY, packet.getProfile()); + protocol.setMode(ProtocolMode.GAME, true, event.getSession()); + } else if(event.getPacket() instanceof LoginDisconnectPacket) { + LoginDisconnectPacket packet = event.getPacket(); + event.getSession().disconnect(packet.getReason().getFullText()); + } else if(event.getPacket() instanceof LoginSetCompressionPacket) { + event.getSession().setCompressionThreshold(event.getPacket().getThreshold()); + } + } else if(protocol.getMode() == ProtocolMode.STATUS) { + if(event.getPacket() instanceof StatusResponsePacket) { + ServerStatusInfo info = event.getPacket().getInfo(); + ServerInfoHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_INFO_HANDLER_KEY); + if(handler != null) { + handler.handle(event.getSession(), info); + } - event.getSession().send(new StatusPingPacket(System.currentTimeMillis())); - } else if(event.getPacket() instanceof StatusPongPacket) { - long time = System.currentTimeMillis() - event.getPacket().getPingTime(); - ServerPingTimeHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_PING_TIME_HANDLER_KEY); - if(handler != null) { - handler.handle(event.getSession(), time); - } + event.getSession().send(new StatusPingPacket(System.currentTimeMillis())); + } else if(event.getPacket() instanceof StatusPongPacket) { + long time = System.currentTimeMillis() - event.getPacket().getPingTime(); + ServerPingTimeHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_PING_TIME_HANDLER_KEY); + if(handler != null) { + handler.handle(event.getSession(), time); + } - event.getSession().disconnect("Finished"); - } - } else if(protocol.getMode() == ProtocolMode.GAME) { - if(event.getPacket() instanceof ServerKeepAlivePacket) { - event.getSession().send(new ClientKeepAlivePacket(event.getPacket().getPingId())); - } else if(event.getPacket() instanceof ServerDisconnectPacket) { - event.getSession().disconnect(event.getPacket().getReason().getFullText()); - } else if(event.getPacket() instanceof ServerSetCompressionPacket) { - event.getSession().setCompressionThreshold(event.getPacket().getThreshold()); - } - } - } + event.getSession().disconnect("Finished"); + } + } else if(protocol.getMode() == ProtocolMode.GAME) { + if(event.getPacket() instanceof ServerKeepAlivePacket) { + event.getSession().send(new ClientKeepAlivePacket(event.getPacket().getPingId())); + } else if(event.getPacket() instanceof ServerDisconnectPacket) { + event.getSession().disconnect(event.getPacket().getReason().getFullText()); + } else if(event.getPacket() instanceof ServerSetCompressionPacket) { + event.getSession().setCompressionThreshold(event.getPacket().getThreshold()); + } + } + } - @Override - public void packetSent(PacketSentEvent event) { - MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); - if(protocol.getMode() == ProtocolMode.LOGIN && event.getPacket() instanceof EncryptionResponsePacket) { - protocol.enableEncryption(this.key); - } - } + @Override + public void packetSent(PacketSentEvent event) { + MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); + if(protocol.getMode() == ProtocolMode.LOGIN && event.getPacket() instanceof EncryptionResponsePacket) { + protocol.enableEncryption(this.key); + } + } - @Override - public void connected(ConnectedEvent event) { - MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); - if(protocol.getMode() == ProtocolMode.LOGIN) { - GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY); - protocol.setMode(ProtocolMode.HANDSHAKE, true, event.getSession()); - event.getSession().send(new HandshakePacket(ProtocolConstants.PROTOCOL_VERSION, event.getSession().getHost(), event.getSession().getPort(), HandshakeIntent.LOGIN)); - protocol.setMode(ProtocolMode.LOGIN, true, event.getSession()); - event.getSession().send(new LoginStartPacket(profile != null ? profile.getName() : "")); - } else if(protocol.getMode() == ProtocolMode.STATUS) { - protocol.setMode(ProtocolMode.HANDSHAKE, true, event.getSession()); - event.getSession().send(new HandshakePacket(ProtocolConstants.PROTOCOL_VERSION, event.getSession().getHost(), event.getSession().getPort(), HandshakeIntent.STATUS)); - protocol.setMode(ProtocolMode.STATUS, true, event.getSession()); - event.getSession().send(new StatusQueryPacket()); - } - } + @Override + public void connected(ConnectedEvent event) { + MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); + if(protocol.getMode() == ProtocolMode.LOGIN) { + GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY); + protocol.setMode(ProtocolMode.HANDSHAKE, true, event.getSession()); + event.getSession().send(new HandshakePacket(ProtocolConstants.PROTOCOL_VERSION, event.getSession().getHost(), event.getSession().getPort(), HandshakeIntent.LOGIN)); + protocol.setMode(ProtocolMode.LOGIN, true, event.getSession()); + event.getSession().send(new LoginStartPacket(profile != null ? profile.getName() : "")); + } else if(protocol.getMode() == ProtocolMode.STATUS) { + protocol.setMode(ProtocolMode.HANDSHAKE, true, event.getSession()); + event.getSession().send(new HandshakePacket(ProtocolConstants.PROTOCOL_VERSION, event.getSession().getHost(), event.getSession().getPort(), HandshakeIntent.STATUS)); + protocol.setMode(ProtocolMode.STATUS, true, event.getSession()); + event.getSession().send(new StatusQueryPacket()); + } + } } diff --git a/src/main/java/org/spacehq/mc/protocol/MinecraftProtocol.java b/src/main/java/org/spacehq/mc/protocol/MinecraftProtocol.java index b2faab015..b5123463a 100644 --- a/src/main/java/org/spacehq/mc/protocol/MinecraftProtocol.java +++ b/src/main/java/org/spacehq/mc/protocol/MinecraftProtocol.java @@ -4,22 +4,106 @@ import org.spacehq.mc.auth.UserAuthentication; import org.spacehq.mc.auth.exception.AuthenticationException; import org.spacehq.mc.protocol.packet.handshake.client.HandshakePacket; -import org.spacehq.mc.protocol.packet.ingame.client.*; +import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket; +import org.spacehq.mc.protocol.packet.ingame.client.ClientKeepAlivePacket; +import org.spacehq.mc.protocol.packet.ingame.client.ClientPluginMessagePacket; +import org.spacehq.mc.protocol.packet.ingame.client.ClientRequestPacket; +import org.spacehq.mc.protocol.packet.ingame.client.ClientResourcePackStatusPacket; +import org.spacehq.mc.protocol.packet.ingame.client.ClientSettingsPacket; +import org.spacehq.mc.protocol.packet.ingame.client.ClientTabCompletePacket; +import org.spacehq.mc.protocol.packet.ingame.client.player.ClientChangeHeldItemPacket; +import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerAbilitiesPacket; +import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket; import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerInteractEntityPacket; +import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket; +import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket; +import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionPacket; +import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket; +import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerRotationPacket; +import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerStatePacket; +import org.spacehq.mc.protocol.packet.ingame.client.player.ClientSpectatePacket; +import org.spacehq.mc.protocol.packet.ingame.client.player.ClientSteerVehiclePacket; import org.spacehq.mc.protocol.packet.ingame.client.player.ClientSwingArmPacket; -import org.spacehq.mc.protocol.packet.ingame.client.player.*; -import org.spacehq.mc.protocol.packet.ingame.client.window.*; +import org.spacehq.mc.protocol.packet.ingame.client.window.ClientCloseWindowPacket; +import org.spacehq.mc.protocol.packet.ingame.client.window.ClientConfirmTransactionPacket; +import org.spacehq.mc.protocol.packet.ingame.client.window.ClientCreativeInventoryActionPacket; +import org.spacehq.mc.protocol.packet.ingame.client.window.ClientEnchantItemPacket; +import org.spacehq.mc.protocol.packet.ingame.client.window.ClientWindowActionPacket; import org.spacehq.mc.protocol.packet.ingame.client.world.ClientUpdateSignPacket; -import org.spacehq.mc.protocol.packet.ingame.server.*; -import org.spacehq.mc.protocol.packet.ingame.server.entity.*; -import org.spacehq.mc.protocol.packet.ingame.server.entity.player.*; -import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.*; +import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerCombatPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerDifficultyPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerDisconnectPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerKeepAlivePacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerPlayerListDataPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerPlayerListEntryPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerResourcePackSendPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerRespawnPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerSetCompressionPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerStatisticsPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerSwitchCameraPacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerTabCompletePacket; +import org.spacehq.mc.protocol.packet.ingame.server.ServerTitlePacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerAnimationPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerCollectItemPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerDestroyEntitiesPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityAttachPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityEffectPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityEquipmentPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityHeadLookPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityMetadataPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityMovementPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityNBTUpdatePacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityPositionPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityPositionRotationPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityPropertiesPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityRemoveEffectPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityRotationPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityStatusPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityTeleportPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityVelocityPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerChangeHeldItemPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerAbilitiesPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerUseBedPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerSetExperiencePacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerUpdateHealthPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnExpOrbPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnGlobalEntityPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnMobPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnObjectPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPaintingPacket; +import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPlayerPacket; import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket; import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket; import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket; import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket; -import org.spacehq.mc.protocol.packet.ingame.server.window.*; -import org.spacehq.mc.protocol.packet.ingame.server.world.*; +import org.spacehq.mc.protocol.packet.ingame.server.window.ServerCloseWindowPacket; +import org.spacehq.mc.protocol.packet.ingame.server.window.ServerConfirmTransactionPacket; +import org.spacehq.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket; +import org.spacehq.mc.protocol.packet.ingame.server.window.ServerSetSlotPacket; +import org.spacehq.mc.protocol.packet.ingame.server.window.ServerWindowItemsPacket; +import org.spacehq.mc.protocol.packet.ingame.server.window.ServerWindowPropertyPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerBlockBreakAnimPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerBlockValuePacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerChunkDataPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerExplosionPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerMapDataPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerMultiBlockChangePacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerMultiChunkDataPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerOpenTileEntityEditorPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerPlaySoundPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerSpawnParticlePacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerSpawnPositionPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerUpdateSignPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerUpdateTileEntityPacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket; +import org.spacehq.mc.protocol.packet.ingame.server.world.ServerWorldBorderPacket; import org.spacehq.mc.protocol.packet.login.client.EncryptionResponsePacket; import org.spacehq.mc.protocol.packet.login.client.LoginStartPacket; import org.spacehq.mc.protocol.packet.login.server.EncryptionRequestPacket; @@ -46,414 +130,409 @@ public class MinecraftProtocol extends PacketProtocol { - private ProtocolMode mode = ProtocolMode.HANDSHAKE; - private PacketHeader header = new DefaultPacketHeader(); - private AESEncryption encrypt; - - private GameProfile profile; - private String accessToken = ""; - private ClientListener clientListener; - - @SuppressWarnings("unused") - private MinecraftProtocol() { - } - - public MinecraftProtocol(ProtocolMode mode) { - if(mode != ProtocolMode.LOGIN && mode != ProtocolMode.STATUS) { - throw new IllegalArgumentException("Only login and status modes are permitted."); - } - - this.mode = mode; - if(mode == ProtocolMode.LOGIN) { - this.profile = new GameProfile((UUID) null, "Player"); - } - - this.clientListener = new ClientListener(); - } - - public MinecraftProtocol(String username) { - this(ProtocolMode.LOGIN); - this.profile = new GameProfile((UUID) null, username); - } - - public MinecraftProtocol(String username, String password) throws AuthenticationException { - this(username, password, false); - } - - public MinecraftProtocol(String username, String using, boolean token) throws AuthenticationException { - this(username, using, token, Proxy.NO_PROXY); - } - - public MinecraftProtocol(String username, String using, boolean token, Proxy authProxy) throws AuthenticationException { - this(ProtocolMode.LOGIN); - String clientToken = UUID.randomUUID().toString(); - UserAuthentication auth = new UserAuthentication(clientToken, authProxy); - auth.setUsername(username); - if(token) { - auth.setAccessToken(using); - } else { - auth.setPassword(using); - } - - auth.login(); - this.profile = auth.getSelectedProfile(); - this.accessToken = auth.getAccessToken(); - } - - public MinecraftProtocol(GameProfile profile, String accessToken) { - this(ProtocolMode.LOGIN); - this.profile = profile; - this.accessToken = accessToken; - - } - - public GameProfile getProfile() { - return this.profile; - } - - public String getAccessToken() { - return this.accessToken; - } - - @Override - public boolean needsPacketSizer() { - return true; - } - - @Override - public boolean needsPacketEncryptor() { - return true; - } - - @Override - public PacketHeader getPacketHeader() { - return this.header; - } - - @Override - public PacketEncryption getEncryption() { - return this.encrypt; - } - - @Override - public void newClientSession(Client client, Session session) { - if(this.profile != null) { - session.setFlag(ProtocolConstants.PROFILE_KEY, this.profile); - session.setFlag(ProtocolConstants.ACCESS_TOKEN_KEY, this.accessToken); - } - - this.setMode(this.mode, true, session); - session.addListener(this.clientListener); - } - - @Override - public void newServerSession(Server server, Session session) { - this.setMode(ProtocolMode.HANDSHAKE, false, session); - session.addListener(new ServerListener()); - } - - protected void enableEncryption(Key key) { - try { - this.encrypt = new AESEncryption(key); - } catch(GeneralSecurityException e) { - throw new Error("Failed to enable protocol encryption.", e); - } - } - - public ProtocolMode getMode() { - return this.mode; - } - - protected void setMode(ProtocolMode mode, boolean client, Session session) { - this.clearPackets(); - switch(mode) { - case HANDSHAKE: - if(client) { - this.initClientHandshake(session); - } else { - this.initServerHandshake(session); - } - - break; - case LOGIN: - if(client) { - this.initClientLogin(session); - } else { - this.initServerLogin(session); - } - - break; - case GAME: - if(client) { - this.initClientGame(session); - } else { - this.initServerGame(session); - } - - break; - case STATUS: - if(client) { - this.initClientStatus(session); - } else { - this.initServerStatus(session); - } - - break; - } - - this.mode = mode; - } - - private void initClientHandshake(Session session) { - this.registerOutgoing(0, HandshakePacket.class); - } - - private void initServerHandshake(Session session) { - this.registerIncoming(0, HandshakePacket.class); - } - - private void initClientLogin(Session session) { - this.registerIncoming(0, LoginDisconnectPacket.class); - this.registerIncoming(1, EncryptionRequestPacket.class); - this.registerIncoming(2, LoginSuccessPacket.class); - this.registerIncoming(3, LoginSetCompressionPacket.class); - - this.registerOutgoing(0, LoginStartPacket.class); - this.registerOutgoing(1, EncryptionResponsePacket.class); - } - - private void initServerLogin(Session session) { - this.registerIncoming(0, LoginStartPacket.class); - this.registerIncoming(1, EncryptionResponsePacket.class); - - this.registerOutgoing(0, LoginDisconnectPacket.class); - this.registerOutgoing(1, EncryptionRequestPacket.class); - this.registerOutgoing(2, LoginSuccessPacket.class); - this.registerOutgoing(3, LoginSetCompressionPacket.class); - } - - private void initClientGame(Session session) { - this.registerIncoming(0, ServerKeepAlivePacket.class); - this.registerIncoming(1, ServerJoinGamePacket.class); - this.registerIncoming(2, ServerChatPacket.class); - this.registerIncoming(3, ServerUpdateTimePacket.class); - this.registerIncoming(4, ServerEntityEquipmentPacket.class); - this.registerIncoming(5, ServerSpawnPositionPacket.class); - this.registerIncoming(6, ServerUpdateHealthPacket.class); - this.registerIncoming(7, ServerRespawnPacket.class); - this.registerIncoming(8, ServerPlayerPositionRotationPacket.class); - this.registerIncoming(9, ServerChangeHeldItemPacket.class); - this.registerIncoming(10, ServerPlayerUseBedPacket.class); - this.registerIncoming(11, ServerAnimationPacket.class); - this.registerIncoming(12, ServerSpawnPlayerPacket.class); - this.registerIncoming(13, ServerCollectItemPacket.class); - this.registerIncoming(14, ServerSpawnObjectPacket.class); - this.registerIncoming(15, ServerSpawnMobPacket.class); - this.registerIncoming(16, ServerSpawnPaintingPacket.class); - this.registerIncoming(17, ServerSpawnExpOrbPacket.class); - this.registerIncoming(18, ServerEntityVelocityPacket.class); - this.registerIncoming(19, ServerDestroyEntitiesPacket.class); - this.registerIncoming(20, ServerEntityMovementPacket.class); - this.registerIncoming(21, ServerEntityPositionPacket.class); - this.registerIncoming(22, ServerEntityRotationPacket.class); - this.registerIncoming(23, ServerEntityPositionRotationPacket.class); - this.registerIncoming(24, ServerEntityTeleportPacket.class); - this.registerIncoming(25, ServerEntityHeadLookPacket.class); - this.registerIncoming(26, ServerEntityStatusPacket.class); - this.registerIncoming(27, ServerEntityAttachPacket.class); - this.registerIncoming(28, ServerEntityMetadataPacket.class); - this.registerIncoming(29, ServerEntityEffectPacket.class); - this.registerIncoming(30, ServerEntityRemoveEffectPacket.class); - this.registerIncoming(31, ServerSetExperiencePacket.class); - this.registerIncoming(32, ServerEntityPropertiesPacket.class); - this.registerIncoming(33, ServerChunkDataPacket.class); - this.registerIncoming(34, ServerMultiBlockChangePacket.class); - this.registerIncoming(35, ServerBlockChangePacket.class); - this.registerIncoming(36, ServerBlockValuePacket.class); - this.registerIncoming(37, ServerBlockBreakAnimPacket.class); - this.registerIncoming(38, ServerMultiChunkDataPacket.class); - this.registerIncoming(39, ServerExplosionPacket.class); - this.registerIncoming(40, ServerPlayEffectPacket.class); - this.registerIncoming(41, ServerPlaySoundPacket.class); - this.registerIncoming(42, ServerSpawnParticlePacket.class); - this.registerIncoming(43, ServerNotifyClientPacket.class); - this.registerIncoming(44, ServerSpawnGlobalEntityPacket.class); - this.registerIncoming(45, ServerOpenWindowPacket.class); - this.registerIncoming(46, ServerCloseWindowPacket.class); - this.registerIncoming(47, ServerSetSlotPacket.class); - this.registerIncoming(48, ServerWindowItemsPacket.class); - this.registerIncoming(49, ServerWindowPropertyPacket.class); - this.registerIncoming(50, ServerConfirmTransactionPacket.class); - this.registerIncoming(51, ServerUpdateSignPacket.class); - this.registerIncoming(52, ServerMapDataPacket.class); - this.registerIncoming(53, ServerUpdateTileEntityPacket.class); - this.registerIncoming(54, ServerOpenTileEntityEditorPacket.class); - this.registerIncoming(55, ServerStatisticsPacket.class); - this.registerIncoming(56, ServerPlayerListEntryPacket.class); - this.registerIncoming(57, ServerPlayerAbilitiesPacket.class); - this.registerIncoming(58, ServerTabCompletePacket.class); - this.registerIncoming(59, ServerScoreboardObjectivePacket.class); - this.registerIncoming(60, ServerUpdateScorePacket.class); - this.registerIncoming(61, ServerDisplayScoreboardPacket.class); - this.registerIncoming(62, ServerTeamPacket.class); - this.registerIncoming(63, ServerPluginMessagePacket.class); - this.registerIncoming(64, ServerDisconnectPacket.class); - this.registerIncoming(65, ServerDifficultyPacket.class); - this.registerIncoming(66, ServerCombatPacket.class); - this.registerIncoming(67, ServerSwitchCameraPacket.class); - this.registerIncoming(68, ServerWorldBorderPacket.class); - this.registerIncoming(69, ServerTitlePacket.class); - this.registerIncoming(70, ServerSetCompressionPacket.class); - this.registerIncoming(71, ServerPlayerListDataPacket.class); - this.registerIncoming(72, ServerResourcePackSendPacket.class); - this.registerIncoming(73, ServerEntityNBTUpdatePacket.class); - - this.registerOutgoing(0, ClientKeepAlivePacket.class); - this.registerOutgoing(1, ClientChatPacket.class); - this.registerOutgoing(2, ClientPlayerInteractEntityPacket.class); - this.registerOutgoing(3, ClientPlayerMovementPacket.class); - this.registerOutgoing(4, ClientPlayerPositionPacket.class); - this.registerOutgoing(5, ClientPlayerRotationPacket.class); - this.registerOutgoing(6, ClientPlayerPositionRotationPacket.class); - this.registerOutgoing(7, ClientPlayerActionPacket.class); - this.registerOutgoing(8, ClientPlayerPlaceBlockPacket.class); - this.registerOutgoing(9, ClientChangeHeldItemPacket.class); - this.registerOutgoing(10, ClientSwingArmPacket.class); - this.registerOutgoing(11, ClientPlayerStatePacket.class); - this.registerOutgoing(12, ClientSteerVehiclePacket.class); - this.registerOutgoing(13, ClientCloseWindowPacket.class); - this.registerOutgoing(14, ClientWindowActionPacket.class); - this.registerOutgoing(15, ClientConfirmTransactionPacket.class); - this.registerOutgoing(16, ClientCreativeInventoryActionPacket.class); - this.registerOutgoing(17, ClientEnchantItemPacket.class); - this.registerOutgoing(18, ClientUpdateSignPacket.class); - this.registerOutgoing(19, ClientPlayerAbilitiesPacket.class); - this.registerOutgoing(20, ClientTabCompletePacket.class); - this.registerOutgoing(21, ClientSettingsPacket.class); - this.registerOutgoing(22, ClientRequestPacket.class); - this.registerOutgoing(23, ClientPluginMessagePacket.class); - this.registerOutgoing(24, ClientSpectatePacket.class); - this.registerOutgoing(25, ClientResourcePackStatusPacket.class); - } - - private void initServerGame(Session session) { - this.registerIncoming(0, ClientKeepAlivePacket.class); - this.registerIncoming(1, ClientChatPacket.class); - this.registerIncoming(2, ClientPlayerInteractEntityPacket.class); - this.registerIncoming(3, ClientPlayerMovementPacket.class); - this.registerIncoming(4, ClientPlayerPositionPacket.class); - this.registerIncoming(5, ClientPlayerRotationPacket.class); - this.registerIncoming(6, ClientPlayerPositionRotationPacket.class); - this.registerIncoming(7, ClientPlayerActionPacket.class); - this.registerIncoming(8, ClientPlayerPlaceBlockPacket.class); - this.registerIncoming(9, ClientChangeHeldItemPacket.class); - this.registerIncoming(10, ClientSwingArmPacket.class); - this.registerIncoming(11, ClientPlayerStatePacket.class); - this.registerIncoming(12, ClientSteerVehiclePacket.class); - this.registerIncoming(13, ClientCloseWindowPacket.class); - this.registerIncoming(14, ClientWindowActionPacket.class); - this.registerIncoming(15, ClientConfirmTransactionPacket.class); - this.registerIncoming(16, ClientCreativeInventoryActionPacket.class); - this.registerIncoming(17, ClientEnchantItemPacket.class); - this.registerIncoming(18, ClientUpdateSignPacket.class); - this.registerIncoming(19, ClientPlayerAbilitiesPacket.class); - this.registerIncoming(20, ClientTabCompletePacket.class); - this.registerIncoming(21, ClientSettingsPacket.class); - this.registerIncoming(22, ClientRequestPacket.class); - this.registerIncoming(23, ClientPluginMessagePacket.class); - this.registerIncoming(24, ClientSpectatePacket.class); - this.registerIncoming(25, ClientResourcePackStatusPacket.class); - - this.registerOutgoing(0, ServerKeepAlivePacket.class); - this.registerOutgoing(1, ServerJoinGamePacket.class); - this.registerOutgoing(2, ServerChatPacket.class); - this.registerOutgoing(3, ServerUpdateTimePacket.class); - this.registerOutgoing(4, ServerEntityEquipmentPacket.class); - this.registerOutgoing(5, ServerSpawnPositionPacket.class); - this.registerOutgoing(6, ServerUpdateHealthPacket.class); - this.registerOutgoing(7, ServerRespawnPacket.class); - this.registerOutgoing(8, ServerPlayerPositionRotationPacket.class); - this.registerOutgoing(9, ServerChangeHeldItemPacket.class); - this.registerOutgoing(10, ServerPlayerUseBedPacket.class); - this.registerOutgoing(11, ServerAnimationPacket.class); - this.registerOutgoing(12, ServerSpawnPlayerPacket.class); - this.registerOutgoing(13, ServerCollectItemPacket.class); - this.registerOutgoing(14, ServerSpawnObjectPacket.class); - this.registerOutgoing(15, ServerSpawnMobPacket.class); - this.registerOutgoing(16, ServerSpawnPaintingPacket.class); - this.registerOutgoing(17, ServerSpawnExpOrbPacket.class); - this.registerOutgoing(18, ServerEntityVelocityPacket.class); - this.registerOutgoing(19, ServerDestroyEntitiesPacket.class); - this.registerOutgoing(20, ServerEntityMovementPacket.class); - this.registerOutgoing(21, ServerEntityPositionPacket.class); - this.registerOutgoing(22, ServerEntityRotationPacket.class); - this.registerOutgoing(23, ServerEntityPositionRotationPacket.class); - this.registerOutgoing(24, ServerEntityTeleportPacket.class); - this.registerOutgoing(25, ServerEntityHeadLookPacket.class); - this.registerOutgoing(26, ServerEntityStatusPacket.class); - this.registerOutgoing(27, ServerEntityAttachPacket.class); - this.registerOutgoing(28, ServerEntityMetadataPacket.class); - this.registerOutgoing(29, ServerEntityEffectPacket.class); - this.registerOutgoing(30, ServerEntityRemoveEffectPacket.class); - this.registerOutgoing(31, ServerSetExperiencePacket.class); - this.registerOutgoing(32, ServerEntityPropertiesPacket.class); - this.registerOutgoing(33, ServerChunkDataPacket.class); - this.registerOutgoing(34, ServerMultiBlockChangePacket.class); - this.registerOutgoing(35, ServerBlockChangePacket.class); - this.registerOutgoing(36, ServerBlockValuePacket.class); - this.registerOutgoing(37, ServerBlockBreakAnimPacket.class); - this.registerOutgoing(38, ServerMultiChunkDataPacket.class); - this.registerOutgoing(39, ServerExplosionPacket.class); - this.registerOutgoing(40, ServerPlayEffectPacket.class); - this.registerOutgoing(41, ServerPlaySoundPacket.class); - this.registerOutgoing(42, ServerSpawnParticlePacket.class); - this.registerOutgoing(43, ServerNotifyClientPacket.class); - this.registerOutgoing(44, ServerSpawnGlobalEntityPacket.class); - this.registerOutgoing(45, ServerOpenWindowPacket.class); - this.registerOutgoing(46, ServerCloseWindowPacket.class); - this.registerOutgoing(47, ServerSetSlotPacket.class); - this.registerOutgoing(48, ServerWindowItemsPacket.class); - this.registerOutgoing(49, ServerWindowPropertyPacket.class); - this.registerOutgoing(50, ServerConfirmTransactionPacket.class); - this.registerOutgoing(51, ServerUpdateSignPacket.class); - this.registerOutgoing(52, ServerMapDataPacket.class); - this.registerOutgoing(53, ServerUpdateTileEntityPacket.class); - this.registerOutgoing(54, ServerOpenTileEntityEditorPacket.class); - this.registerOutgoing(55, ServerStatisticsPacket.class); - this.registerOutgoing(56, ServerPlayerListEntryPacket.class); - this.registerOutgoing(57, ServerPlayerAbilitiesPacket.class); - this.registerOutgoing(58, ServerTabCompletePacket.class); - this.registerOutgoing(59, ServerScoreboardObjectivePacket.class); - this.registerOutgoing(60, ServerUpdateScorePacket.class); - this.registerOutgoing(61, ServerDisplayScoreboardPacket.class); - this.registerOutgoing(62, ServerTeamPacket.class); - this.registerOutgoing(63, ServerPluginMessagePacket.class); - this.registerOutgoing(64, ServerDisconnectPacket.class); - this.registerOutgoing(65, ServerDifficultyPacket.class); - this.registerOutgoing(66, ServerCombatPacket.class); - this.registerOutgoing(67, ServerSwitchCameraPacket.class); - this.registerOutgoing(68, ServerWorldBorderPacket.class); - this.registerOutgoing(69, ServerTitlePacket.class); - this.registerOutgoing(70, ServerSetCompressionPacket.class); - this.registerOutgoing(71, ServerPlayerListDataPacket.class); - this.registerOutgoing(72, ServerResourcePackSendPacket.class); - this.registerOutgoing(73, ServerEntityNBTUpdatePacket.class); - } - - private void initClientStatus(Session session) { - this.registerIncoming(0, StatusResponsePacket.class); - this.registerIncoming(1, StatusPongPacket.class); - - this.registerOutgoing(0, StatusQueryPacket.class); - this.registerOutgoing(1, StatusPingPacket.class); - } - - private void initServerStatus(Session session) { - this.registerIncoming(0, StatusQueryPacket.class); - this.registerIncoming(1, StatusPingPacket.class); - - this.registerOutgoing(0, StatusResponsePacket.class); - this.registerOutgoing(1, StatusPongPacket.class); - } + private ProtocolMode mode = ProtocolMode.HANDSHAKE; + private PacketHeader header = new DefaultPacketHeader(); + private AESEncryption encrypt; + + private GameProfile profile; + private String accessToken = ""; + private ClientListener clientListener; + + @SuppressWarnings("unused") + private MinecraftProtocol() { + } + + public MinecraftProtocol(ProtocolMode mode) { + if(mode != ProtocolMode.LOGIN && mode != ProtocolMode.STATUS) { + throw new IllegalArgumentException("Only login and status modes are permitted."); + } + + this.mode = mode; + if(mode == ProtocolMode.LOGIN) { + this.profile = new GameProfile((UUID) null, "Player"); + } + + this.clientListener = new ClientListener(); + } + + public MinecraftProtocol(String username) { + this(ProtocolMode.LOGIN); + this.profile = new GameProfile((UUID) null, username); + } + + public MinecraftProtocol(String username, String password) throws AuthenticationException { + this(username, password, false); + } + + public MinecraftProtocol(String username, String using, boolean token) throws AuthenticationException { + this(username, using, token, Proxy.NO_PROXY); + } + + public MinecraftProtocol(String username, String using, boolean token, Proxy authProxy) throws AuthenticationException { + this(ProtocolMode.LOGIN); + String clientToken = UUID.randomUUID().toString(); + UserAuthentication auth = new UserAuthentication(clientToken, authProxy); + auth.setUsername(username); + if(token) { + auth.setAccessToken(using); + } else { + auth.setPassword(using); + } + + auth.login(); + this.profile = auth.getSelectedProfile(); + this.accessToken = auth.getAccessToken(); + } + + public MinecraftProtocol(GameProfile profile, String accessToken) { + this(ProtocolMode.LOGIN); + this.profile = profile; + this.accessToken = accessToken; + + } + + public GameProfile getProfile() { + return this.profile; + } + + public String getAccessToken() { + return this.accessToken; + } + + @Override + public String getSRVRecordPrefix() { + return "_minecraft"; + } + + @Override + public PacketHeader getPacketHeader() { + return this.header; + } + + @Override + public PacketEncryption getEncryption() { + return this.encrypt; + } + + @Override + public void newClientSession(Client client, Session session) { + if(this.profile != null) { + session.setFlag(ProtocolConstants.PROFILE_KEY, this.profile); + session.setFlag(ProtocolConstants.ACCESS_TOKEN_KEY, this.accessToken); + } + + this.setMode(this.mode, true, session); + session.addListener(this.clientListener); + } + + @Override + public void newServerSession(Server server, Session session) { + this.setMode(ProtocolMode.HANDSHAKE, false, session); + session.addListener(new ServerListener()); + } + + protected void enableEncryption(Key key) { + try { + this.encrypt = new AESEncryption(key); + } catch(GeneralSecurityException e) { + throw new Error("Failed to enable protocol encryption.", e); + } + } + + public ProtocolMode getMode() { + return this.mode; + } + + protected void setMode(ProtocolMode mode, boolean client, Session session) { + this.clearPackets(); + switch(mode) { + case HANDSHAKE: + if(client) { + this.initClientHandshake(session); + } else { + this.initServerHandshake(session); + } + + break; + case LOGIN: + if(client) { + this.initClientLogin(session); + } else { + this.initServerLogin(session); + } + + break; + case GAME: + if(client) { + this.initClientGame(session); + } else { + this.initServerGame(session); + } + + break; + case STATUS: + if(client) { + this.initClientStatus(session); + } else { + this.initServerStatus(session); + } + + break; + } + + this.mode = mode; + } + + private void initClientHandshake(Session session) { + this.registerOutgoing(0, HandshakePacket.class); + } + + private void initServerHandshake(Session session) { + this.registerIncoming(0, HandshakePacket.class); + } + + private void initClientLogin(Session session) { + this.registerIncoming(0, LoginDisconnectPacket.class); + this.registerIncoming(1, EncryptionRequestPacket.class); + this.registerIncoming(2, LoginSuccessPacket.class); + this.registerIncoming(3, LoginSetCompressionPacket.class); + + this.registerOutgoing(0, LoginStartPacket.class); + this.registerOutgoing(1, EncryptionResponsePacket.class); + } + + private void initServerLogin(Session session) { + this.registerIncoming(0, LoginStartPacket.class); + this.registerIncoming(1, EncryptionResponsePacket.class); + + this.registerOutgoing(0, LoginDisconnectPacket.class); + this.registerOutgoing(1, EncryptionRequestPacket.class); + this.registerOutgoing(2, LoginSuccessPacket.class); + this.registerOutgoing(3, LoginSetCompressionPacket.class); + } + + private void initClientGame(Session session) { + this.registerIncoming(0, ServerKeepAlivePacket.class); + this.registerIncoming(1, ServerJoinGamePacket.class); + this.registerIncoming(2, ServerChatPacket.class); + this.registerIncoming(3, ServerUpdateTimePacket.class); + this.registerIncoming(4, ServerEntityEquipmentPacket.class); + this.registerIncoming(5, ServerSpawnPositionPacket.class); + this.registerIncoming(6, ServerUpdateHealthPacket.class); + this.registerIncoming(7, ServerRespawnPacket.class); + this.registerIncoming(8, ServerPlayerPositionRotationPacket.class); + this.registerIncoming(9, ServerChangeHeldItemPacket.class); + this.registerIncoming(10, ServerPlayerUseBedPacket.class); + this.registerIncoming(11, ServerAnimationPacket.class); + this.registerIncoming(12, ServerSpawnPlayerPacket.class); + this.registerIncoming(13, ServerCollectItemPacket.class); + this.registerIncoming(14, ServerSpawnObjectPacket.class); + this.registerIncoming(15, ServerSpawnMobPacket.class); + this.registerIncoming(16, ServerSpawnPaintingPacket.class); + this.registerIncoming(17, ServerSpawnExpOrbPacket.class); + this.registerIncoming(18, ServerEntityVelocityPacket.class); + this.registerIncoming(19, ServerDestroyEntitiesPacket.class); + this.registerIncoming(20, ServerEntityMovementPacket.class); + this.registerIncoming(21, ServerEntityPositionPacket.class); + this.registerIncoming(22, ServerEntityRotationPacket.class); + this.registerIncoming(23, ServerEntityPositionRotationPacket.class); + this.registerIncoming(24, ServerEntityTeleportPacket.class); + this.registerIncoming(25, ServerEntityHeadLookPacket.class); + this.registerIncoming(26, ServerEntityStatusPacket.class); + this.registerIncoming(27, ServerEntityAttachPacket.class); + this.registerIncoming(28, ServerEntityMetadataPacket.class); + this.registerIncoming(29, ServerEntityEffectPacket.class); + this.registerIncoming(30, ServerEntityRemoveEffectPacket.class); + this.registerIncoming(31, ServerSetExperiencePacket.class); + this.registerIncoming(32, ServerEntityPropertiesPacket.class); + this.registerIncoming(33, ServerChunkDataPacket.class); + this.registerIncoming(34, ServerMultiBlockChangePacket.class); + this.registerIncoming(35, ServerBlockChangePacket.class); + this.registerIncoming(36, ServerBlockValuePacket.class); + this.registerIncoming(37, ServerBlockBreakAnimPacket.class); + this.registerIncoming(38, ServerMultiChunkDataPacket.class); + this.registerIncoming(39, ServerExplosionPacket.class); + this.registerIncoming(40, ServerPlayEffectPacket.class); + this.registerIncoming(41, ServerPlaySoundPacket.class); + this.registerIncoming(42, ServerSpawnParticlePacket.class); + this.registerIncoming(43, ServerNotifyClientPacket.class); + this.registerIncoming(44, ServerSpawnGlobalEntityPacket.class); + this.registerIncoming(45, ServerOpenWindowPacket.class); + this.registerIncoming(46, ServerCloseWindowPacket.class); + this.registerIncoming(47, ServerSetSlotPacket.class); + this.registerIncoming(48, ServerWindowItemsPacket.class); + this.registerIncoming(49, ServerWindowPropertyPacket.class); + this.registerIncoming(50, ServerConfirmTransactionPacket.class); + this.registerIncoming(51, ServerUpdateSignPacket.class); + this.registerIncoming(52, ServerMapDataPacket.class); + this.registerIncoming(53, ServerUpdateTileEntityPacket.class); + this.registerIncoming(54, ServerOpenTileEntityEditorPacket.class); + this.registerIncoming(55, ServerStatisticsPacket.class); + this.registerIncoming(56, ServerPlayerListEntryPacket.class); + this.registerIncoming(57, ServerPlayerAbilitiesPacket.class); + this.registerIncoming(58, ServerTabCompletePacket.class); + this.registerIncoming(59, ServerScoreboardObjectivePacket.class); + this.registerIncoming(60, ServerUpdateScorePacket.class); + this.registerIncoming(61, ServerDisplayScoreboardPacket.class); + this.registerIncoming(62, ServerTeamPacket.class); + this.registerIncoming(63, ServerPluginMessagePacket.class); + this.registerIncoming(64, ServerDisconnectPacket.class); + this.registerIncoming(65, ServerDifficultyPacket.class); + this.registerIncoming(66, ServerCombatPacket.class); + this.registerIncoming(67, ServerSwitchCameraPacket.class); + this.registerIncoming(68, ServerWorldBorderPacket.class); + this.registerIncoming(69, ServerTitlePacket.class); + this.registerIncoming(70, ServerSetCompressionPacket.class); + this.registerIncoming(71, ServerPlayerListDataPacket.class); + this.registerIncoming(72, ServerResourcePackSendPacket.class); + this.registerIncoming(73, ServerEntityNBTUpdatePacket.class); + + this.registerOutgoing(0, ClientKeepAlivePacket.class); + this.registerOutgoing(1, ClientChatPacket.class); + this.registerOutgoing(2, ClientPlayerInteractEntityPacket.class); + this.registerOutgoing(3, ClientPlayerMovementPacket.class); + this.registerOutgoing(4, ClientPlayerPositionPacket.class); + this.registerOutgoing(5, ClientPlayerRotationPacket.class); + this.registerOutgoing(6, ClientPlayerPositionRotationPacket.class); + this.registerOutgoing(7, ClientPlayerActionPacket.class); + this.registerOutgoing(8, ClientPlayerPlaceBlockPacket.class); + this.registerOutgoing(9, ClientChangeHeldItemPacket.class); + this.registerOutgoing(10, ClientSwingArmPacket.class); + this.registerOutgoing(11, ClientPlayerStatePacket.class); + this.registerOutgoing(12, ClientSteerVehiclePacket.class); + this.registerOutgoing(13, ClientCloseWindowPacket.class); + this.registerOutgoing(14, ClientWindowActionPacket.class); + this.registerOutgoing(15, ClientConfirmTransactionPacket.class); + this.registerOutgoing(16, ClientCreativeInventoryActionPacket.class); + this.registerOutgoing(17, ClientEnchantItemPacket.class); + this.registerOutgoing(18, ClientUpdateSignPacket.class); + this.registerOutgoing(19, ClientPlayerAbilitiesPacket.class); + this.registerOutgoing(20, ClientTabCompletePacket.class); + this.registerOutgoing(21, ClientSettingsPacket.class); + this.registerOutgoing(22, ClientRequestPacket.class); + this.registerOutgoing(23, ClientPluginMessagePacket.class); + this.registerOutgoing(24, ClientSpectatePacket.class); + this.registerOutgoing(25, ClientResourcePackStatusPacket.class); + } + + private void initServerGame(Session session) { + this.registerIncoming(0, ClientKeepAlivePacket.class); + this.registerIncoming(1, ClientChatPacket.class); + this.registerIncoming(2, ClientPlayerInteractEntityPacket.class); + this.registerIncoming(3, ClientPlayerMovementPacket.class); + this.registerIncoming(4, ClientPlayerPositionPacket.class); + this.registerIncoming(5, ClientPlayerRotationPacket.class); + this.registerIncoming(6, ClientPlayerPositionRotationPacket.class); + this.registerIncoming(7, ClientPlayerActionPacket.class); + this.registerIncoming(8, ClientPlayerPlaceBlockPacket.class); + this.registerIncoming(9, ClientChangeHeldItemPacket.class); + this.registerIncoming(10, ClientSwingArmPacket.class); + this.registerIncoming(11, ClientPlayerStatePacket.class); + this.registerIncoming(12, ClientSteerVehiclePacket.class); + this.registerIncoming(13, ClientCloseWindowPacket.class); + this.registerIncoming(14, ClientWindowActionPacket.class); + this.registerIncoming(15, ClientConfirmTransactionPacket.class); + this.registerIncoming(16, ClientCreativeInventoryActionPacket.class); + this.registerIncoming(17, ClientEnchantItemPacket.class); + this.registerIncoming(18, ClientUpdateSignPacket.class); + this.registerIncoming(19, ClientPlayerAbilitiesPacket.class); + this.registerIncoming(20, ClientTabCompletePacket.class); + this.registerIncoming(21, ClientSettingsPacket.class); + this.registerIncoming(22, ClientRequestPacket.class); + this.registerIncoming(23, ClientPluginMessagePacket.class); + this.registerIncoming(24, ClientSpectatePacket.class); + this.registerIncoming(25, ClientResourcePackStatusPacket.class); + + this.registerOutgoing(0, ServerKeepAlivePacket.class); + this.registerOutgoing(1, ServerJoinGamePacket.class); + this.registerOutgoing(2, ServerChatPacket.class); + this.registerOutgoing(3, ServerUpdateTimePacket.class); + this.registerOutgoing(4, ServerEntityEquipmentPacket.class); + this.registerOutgoing(5, ServerSpawnPositionPacket.class); + this.registerOutgoing(6, ServerUpdateHealthPacket.class); + this.registerOutgoing(7, ServerRespawnPacket.class); + this.registerOutgoing(8, ServerPlayerPositionRotationPacket.class); + this.registerOutgoing(9, ServerChangeHeldItemPacket.class); + this.registerOutgoing(10, ServerPlayerUseBedPacket.class); + this.registerOutgoing(11, ServerAnimationPacket.class); + this.registerOutgoing(12, ServerSpawnPlayerPacket.class); + this.registerOutgoing(13, ServerCollectItemPacket.class); + this.registerOutgoing(14, ServerSpawnObjectPacket.class); + this.registerOutgoing(15, ServerSpawnMobPacket.class); + this.registerOutgoing(16, ServerSpawnPaintingPacket.class); + this.registerOutgoing(17, ServerSpawnExpOrbPacket.class); + this.registerOutgoing(18, ServerEntityVelocityPacket.class); + this.registerOutgoing(19, ServerDestroyEntitiesPacket.class); + this.registerOutgoing(20, ServerEntityMovementPacket.class); + this.registerOutgoing(21, ServerEntityPositionPacket.class); + this.registerOutgoing(22, ServerEntityRotationPacket.class); + this.registerOutgoing(23, ServerEntityPositionRotationPacket.class); + this.registerOutgoing(24, ServerEntityTeleportPacket.class); + this.registerOutgoing(25, ServerEntityHeadLookPacket.class); + this.registerOutgoing(26, ServerEntityStatusPacket.class); + this.registerOutgoing(27, ServerEntityAttachPacket.class); + this.registerOutgoing(28, ServerEntityMetadataPacket.class); + this.registerOutgoing(29, ServerEntityEffectPacket.class); + this.registerOutgoing(30, ServerEntityRemoveEffectPacket.class); + this.registerOutgoing(31, ServerSetExperiencePacket.class); + this.registerOutgoing(32, ServerEntityPropertiesPacket.class); + this.registerOutgoing(33, ServerChunkDataPacket.class); + this.registerOutgoing(34, ServerMultiBlockChangePacket.class); + this.registerOutgoing(35, ServerBlockChangePacket.class); + this.registerOutgoing(36, ServerBlockValuePacket.class); + this.registerOutgoing(37, ServerBlockBreakAnimPacket.class); + this.registerOutgoing(38, ServerMultiChunkDataPacket.class); + this.registerOutgoing(39, ServerExplosionPacket.class); + this.registerOutgoing(40, ServerPlayEffectPacket.class); + this.registerOutgoing(41, ServerPlaySoundPacket.class); + this.registerOutgoing(42, ServerSpawnParticlePacket.class); + this.registerOutgoing(43, ServerNotifyClientPacket.class); + this.registerOutgoing(44, ServerSpawnGlobalEntityPacket.class); + this.registerOutgoing(45, ServerOpenWindowPacket.class); + this.registerOutgoing(46, ServerCloseWindowPacket.class); + this.registerOutgoing(47, ServerSetSlotPacket.class); + this.registerOutgoing(48, ServerWindowItemsPacket.class); + this.registerOutgoing(49, ServerWindowPropertyPacket.class); + this.registerOutgoing(50, ServerConfirmTransactionPacket.class); + this.registerOutgoing(51, ServerUpdateSignPacket.class); + this.registerOutgoing(52, ServerMapDataPacket.class); + this.registerOutgoing(53, ServerUpdateTileEntityPacket.class); + this.registerOutgoing(54, ServerOpenTileEntityEditorPacket.class); + this.registerOutgoing(55, ServerStatisticsPacket.class); + this.registerOutgoing(56, ServerPlayerListEntryPacket.class); + this.registerOutgoing(57, ServerPlayerAbilitiesPacket.class); + this.registerOutgoing(58, ServerTabCompletePacket.class); + this.registerOutgoing(59, ServerScoreboardObjectivePacket.class); + this.registerOutgoing(60, ServerUpdateScorePacket.class); + this.registerOutgoing(61, ServerDisplayScoreboardPacket.class); + this.registerOutgoing(62, ServerTeamPacket.class); + this.registerOutgoing(63, ServerPluginMessagePacket.class); + this.registerOutgoing(64, ServerDisconnectPacket.class); + this.registerOutgoing(65, ServerDifficultyPacket.class); + this.registerOutgoing(66, ServerCombatPacket.class); + this.registerOutgoing(67, ServerSwitchCameraPacket.class); + this.registerOutgoing(68, ServerWorldBorderPacket.class); + this.registerOutgoing(69, ServerTitlePacket.class); + this.registerOutgoing(70, ServerSetCompressionPacket.class); + this.registerOutgoing(71, ServerPlayerListDataPacket.class); + this.registerOutgoing(72, ServerResourcePackSendPacket.class); + this.registerOutgoing(73, ServerEntityNBTUpdatePacket.class); + } + + private void initClientStatus(Session session) { + this.registerIncoming(0, StatusResponsePacket.class); + this.registerIncoming(1, StatusPongPacket.class); + + this.registerOutgoing(0, StatusQueryPacket.class); + this.registerOutgoing(1, StatusPingPacket.class); + } + + private void initServerStatus(Session session) { + this.registerIncoming(0, StatusQueryPacket.class); + this.registerIncoming(1, StatusPingPacket.class); + + this.registerOutgoing(0, StatusResponsePacket.class); + this.registerOutgoing(1, StatusPongPacket.class); + } } diff --git a/src/main/java/org/spacehq/mc/protocol/ProtocolConstants.java b/src/main/java/org/spacehq/mc/protocol/ProtocolConstants.java index 03c055227..09fb42a3b 100644 --- a/src/main/java/org/spacehq/mc/protocol/ProtocolConstants.java +++ b/src/main/java/org/spacehq/mc/protocol/ProtocolConstants.java @@ -2,24 +2,24 @@ public class ProtocolConstants { - // General Constants - public static final String GAME_VERSION = "1.8"; - public static final int PROTOCOL_VERSION = 47; + // General Constants + public static final String GAME_VERSION = "1.8"; + public static final int PROTOCOL_VERSION = 47; - // General Key Constants - public static final String PROFILE_KEY = "profile"; - public static final String AUTH_PROXY_KEY = "auth-proxy"; + // General Key Constants + public static final String PROFILE_KEY = "profile"; + public static final String AUTH_PROXY_KEY = "auth-proxy"; - // Client Key Constants - public static final String ACCESS_TOKEN_KEY = "access-token"; - public static final String SERVER_INFO_HANDLER_KEY = "server-info-handler"; - public static final String SERVER_PING_TIME_HANDLER_KEY = "server-ping-time-handler"; + // Client Key Constants + public static final String ACCESS_TOKEN_KEY = "access-token"; + public static final String SERVER_INFO_HANDLER_KEY = "server-info-handler"; + public static final String SERVER_PING_TIME_HANDLER_KEY = "server-ping-time-handler"; - // Server Key Constants - public static final String VERIFY_USERS_KEY = "verify-users"; - public static final String SERVER_INFO_BUILDER_KEY = "info-builder"; - public static final String SERVER_LOGIN_HANDLER_KEY = "login-handler"; - public static final String PING_KEY = "ping"; - public static final String SERVER_COMPRESSION_THRESHOLD = "compression-threshold"; + // Server Key Constants + public static final String VERIFY_USERS_KEY = "verify-users"; + public static final String SERVER_INFO_BUILDER_KEY = "info-builder"; + public static final String SERVER_LOGIN_HANDLER_KEY = "login-handler"; + public static final String PING_KEY = "ping"; + public static final String SERVER_COMPRESSION_THRESHOLD = "compression-threshold"; } diff --git a/src/main/java/org/spacehq/mc/protocol/ProtocolMode.java b/src/main/java/org/spacehq/mc/protocol/ProtocolMode.java index 9fc9f1f41..3b44490fc 100644 --- a/src/main/java/org/spacehq/mc/protocol/ProtocolMode.java +++ b/src/main/java/org/spacehq/mc/protocol/ProtocolMode.java @@ -2,9 +2,9 @@ public enum ProtocolMode { - HANDSHAKE, - LOGIN, - GAME, - STATUS; + HANDSHAKE, + LOGIN, + GAME, + STATUS; } diff --git a/src/main/java/org/spacehq/mc/protocol/ServerListener.java b/src/main/java/org/spacehq/mc/protocol/ServerListener.java index 16c389d33..ded9abcfd 100644 --- a/src/main/java/org/spacehq/mc/protocol/ServerListener.java +++ b/src/main/java/org/spacehq/mc/protocol/ServerListener.java @@ -37,182 +37,182 @@ public class ServerListener extends SessionAdapter { - private static KeyPair pair = CryptUtil.generateKeyPair(); - - private byte verifyToken[] = new byte[4]; - private String serverId = ""; - private String username = ""; - - private long lastPingTime = 0; - private int lastPingId = 0; - - public ServerListener() { - new Random().nextBytes(this.verifyToken); - } - - @Override - public void connected(ConnectedEvent event) { - event.getSession().setFlag(ProtocolConstants.PING_KEY, 0); - } - - @Override - public void packetReceived(PacketReceivedEvent event) { - MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); - if(protocol.getMode() == ProtocolMode.HANDSHAKE) { - if(event.getPacket() instanceof HandshakePacket) { - HandshakePacket packet = event.getPacket(); - switch(packet.getIntent()) { - case STATUS: - protocol.setMode(ProtocolMode.STATUS, false, event.getSession()); - break; - case LOGIN: - protocol.setMode(ProtocolMode.LOGIN, false, event.getSession()); - if(packet.getProtocolVersion() > ProtocolConstants.PROTOCOL_VERSION) { - event.getSession().disconnect("Outdated server! I'm still on " + ProtocolConstants.GAME_VERSION + "."); - } else if(packet.getProtocolVersion() < ProtocolConstants.PROTOCOL_VERSION) { - event.getSession().disconnect("Outdated client! Please use " + ProtocolConstants.GAME_VERSION + "."); - } - - break; - default: - throw new UnsupportedOperationException("Invalid client intent: " + packet.getIntent()); - } - } - } - - if(protocol.getMode() == ProtocolMode.LOGIN) { - if(event.getPacket() instanceof LoginStartPacket) { - this.username = event.getPacket().getUsername(); - boolean verify = event.getSession().hasFlag(ProtocolConstants.VERIFY_USERS_KEY) ? event.getSession().getFlag(ProtocolConstants.VERIFY_USERS_KEY) : true; - if(verify) { - event.getSession().send(new EncryptionRequestPacket(this.serverId, pair.getPublic(), this.verifyToken)); - } else { - GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.username).getBytes()), this.username); - int threshold = event.getSession().getFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD); - event.getSession().send(new LoginSetCompressionPacket(threshold)); - event.getSession().setCompressionThreshold(threshold); - event.getSession().send(new LoginSuccessPacket(profile)); - event.getSession().setFlag(ProtocolConstants.PROFILE_KEY, profile); - protocol.setMode(ProtocolMode.GAME, false, event.getSession()); - ServerLoginHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY); - if(handler != null) { - handler.loggedIn(event.getSession()); - } - - new Thread(new KeepAlive(event.getSession())).start(); - } - } else if(event.getPacket() instanceof EncryptionResponsePacket) { - EncryptionResponsePacket packet = event.getPacket(); - PrivateKey privateKey = pair.getPrivate(); - if(!Arrays.equals(this.verifyToken, packet.getVerifyToken(privateKey))) { - throw new IllegalStateException("Invalid nonce!"); - } else { - SecretKey key = packet.getSecretKey(privateKey); - protocol.enableEncryption(key); - new UserAuthThread(event.getSession(), key).start(); - } - } - } - - if(protocol.getMode() == ProtocolMode.STATUS) { - if(event.getPacket() instanceof StatusQueryPacket) { - ServerInfoBuilder builder = event.getSession().getFlag(ProtocolConstants.SERVER_INFO_BUILDER_KEY); - if(builder == null) { - event.getSession().disconnect("No server info builder set."); - } - - ServerStatusInfo info = builder.buildInfo(event.getSession()); - event.getSession().send(new StatusResponsePacket(info)); - } else if(event.getPacket() instanceof StatusPingPacket) { - event.getSession().send(new StatusPongPacket(event.getPacket().getPingTime())); - } - } - - if(protocol.getMode() == ProtocolMode.GAME) { - if(event.getPacket() instanceof ClientKeepAlivePacket) { - ClientKeepAlivePacket packet = event.getPacket(); - if(packet.getPingId() == this.lastPingId) { - long time = System.currentTimeMillis() - this.lastPingTime; - event.getSession().setFlag(ProtocolConstants.PING_KEY, time); - } - } - } - } - - @Override - public void disconnecting(DisconnectingEvent event) { - MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); - if(protocol.getMode() == ProtocolMode.LOGIN) { - event.getSession().send(new LoginDisconnectPacket(event.getReason())); - } else if(protocol.getMode() == ProtocolMode.GAME) { - event.getSession().send(new ServerDisconnectPacket(event.getReason())); - } - } - - private class UserAuthThread extends Thread { - private Session session; - private SecretKey key; - - public UserAuthThread(Session session, SecretKey key) { - this.key = key; - this.session = session; - } - - @Override - public void run() { - MinecraftProtocol protocol = (MinecraftProtocol) this.session.getPacketProtocol(); - try { - Proxy proxy = this.session.getFlag(ProtocolConstants.AUTH_PROXY_KEY); - if(proxy == null) { - proxy = Proxy.NO_PROXY; - } - - String serverHash = new BigInteger(CryptUtil.getServerIdHash(serverId, pair.getPublic(), this.key)).toString(16); - SessionService service = new SessionService(proxy); - GameProfile profile = service.hasJoinedServer(new GameProfile((UUID) null, username), serverHash); - if(profile != null) { - int threshold = this.session.getFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD); - this.session.send(new LoginSetCompressionPacket(threshold)); - this.session.setCompressionThreshold(threshold); - this.session.send(new LoginSuccessPacket(profile)); - this.session.setFlag(ProtocolConstants.PROFILE_KEY, profile); - protocol.setMode(ProtocolMode.GAME, false, this.session); - ServerLoginHandler handler = this.session.getFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY); - if(handler != null) { - handler.loggedIn(this.session); - } - - new Thread(new KeepAlive(this.session)).start(); - } else { - this.session.disconnect("Failed to verify username!"); - } - } catch(AuthenticationUnavailableException e) { - this.session.disconnect("Authentication servers are down. Please try again later, sorry!"); - } - } - } - - private class KeepAlive implements Runnable { - private Session session; - - public KeepAlive(Session session) { - this.session = session; - } - - @Override - public void run() { - while(this.session.isConnected()) { - lastPingTime = System.currentTimeMillis(); - lastPingId = (int) lastPingTime; - this.session.send(new ServerKeepAlivePacket(lastPingId)); - - try { - Thread.sleep(2000); - } catch(InterruptedException e) { - break; - } - } - } - } + private static KeyPair pair = CryptUtil.generateKeyPair(); + + private byte verifyToken[] = new byte[4]; + private String serverId = ""; + private String username = ""; + + private long lastPingTime = 0; + private int lastPingId = 0; + + public ServerListener() { + new Random().nextBytes(this.verifyToken); + } + + @Override + public void connected(ConnectedEvent event) { + event.getSession().setFlag(ProtocolConstants.PING_KEY, 0); + } + + @Override + public void packetReceived(PacketReceivedEvent event) { + MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); + if(protocol.getMode() == ProtocolMode.HANDSHAKE) { + if(event.getPacket() instanceof HandshakePacket) { + HandshakePacket packet = event.getPacket(); + switch(packet.getIntent()) { + case STATUS: + protocol.setMode(ProtocolMode.STATUS, false, event.getSession()); + break; + case LOGIN: + protocol.setMode(ProtocolMode.LOGIN, false, event.getSession()); + if(packet.getProtocolVersion() > ProtocolConstants.PROTOCOL_VERSION) { + event.getSession().disconnect("Outdated server! I'm still on " + ProtocolConstants.GAME_VERSION + "."); + } else if(packet.getProtocolVersion() < ProtocolConstants.PROTOCOL_VERSION) { + event.getSession().disconnect("Outdated client! Please use " + ProtocolConstants.GAME_VERSION + "."); + } + + break; + default: + throw new UnsupportedOperationException("Invalid client intent: " + packet.getIntent()); + } + } + } + + if(protocol.getMode() == ProtocolMode.LOGIN) { + if(event.getPacket() instanceof LoginStartPacket) { + this.username = event.getPacket().getUsername(); + boolean verify = event.getSession().hasFlag(ProtocolConstants.VERIFY_USERS_KEY) ? event.getSession().getFlag(ProtocolConstants.VERIFY_USERS_KEY) : true; + if(verify) { + event.getSession().send(new EncryptionRequestPacket(this.serverId, pair.getPublic(), this.verifyToken)); + } else { + GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.username).getBytes()), this.username); + int threshold = event.getSession().getFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD); + event.getSession().send(new LoginSetCompressionPacket(threshold)); + event.getSession().setCompressionThreshold(threshold); + event.getSession().send(new LoginSuccessPacket(profile)); + event.getSession().setFlag(ProtocolConstants.PROFILE_KEY, profile); + protocol.setMode(ProtocolMode.GAME, false, event.getSession()); + ServerLoginHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY); + if(handler != null) { + handler.loggedIn(event.getSession()); + } + + new Thread(new KeepAlive(event.getSession())).start(); + } + } else if(event.getPacket() instanceof EncryptionResponsePacket) { + EncryptionResponsePacket packet = event.getPacket(); + PrivateKey privateKey = pair.getPrivate(); + if(!Arrays.equals(this.verifyToken, packet.getVerifyToken(privateKey))) { + throw new IllegalStateException("Invalid nonce!"); + } else { + SecretKey key = packet.getSecretKey(privateKey); + protocol.enableEncryption(key); + new UserAuthThread(event.getSession(), key).start(); + } + } + } + + if(protocol.getMode() == ProtocolMode.STATUS) { + if(event.getPacket() instanceof StatusQueryPacket) { + ServerInfoBuilder builder = event.getSession().getFlag(ProtocolConstants.SERVER_INFO_BUILDER_KEY); + if(builder == null) { + event.getSession().disconnect("No server info builder set."); + } + + ServerStatusInfo info = builder.buildInfo(event.getSession()); + event.getSession().send(new StatusResponsePacket(info)); + } else if(event.getPacket() instanceof StatusPingPacket) { + event.getSession().send(new StatusPongPacket(event.getPacket().getPingTime())); + } + } + + if(protocol.getMode() == ProtocolMode.GAME) { + if(event.getPacket() instanceof ClientKeepAlivePacket) { + ClientKeepAlivePacket packet = event.getPacket(); + if(packet.getPingId() == this.lastPingId) { + long time = System.currentTimeMillis() - this.lastPingTime; + event.getSession().setFlag(ProtocolConstants.PING_KEY, time); + } + } + } + } + + @Override + public void disconnecting(DisconnectingEvent event) { + MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol(); + if(protocol.getMode() == ProtocolMode.LOGIN) { + event.getSession().send(new LoginDisconnectPacket(event.getReason())); + } else if(protocol.getMode() == ProtocolMode.GAME) { + event.getSession().send(new ServerDisconnectPacket(event.getReason())); + } + } + + private class UserAuthThread extends Thread { + private Session session; + private SecretKey key; + + public UserAuthThread(Session session, SecretKey key) { + this.key = key; + this.session = session; + } + + @Override + public void run() { + MinecraftProtocol protocol = (MinecraftProtocol) this.session.getPacketProtocol(); + try { + Proxy proxy = this.session.getFlag(ProtocolConstants.AUTH_PROXY_KEY); + if(proxy == null) { + proxy = Proxy.NO_PROXY; + } + + String serverHash = new BigInteger(CryptUtil.getServerIdHash(serverId, pair.getPublic(), this.key)).toString(16); + SessionService service = new SessionService(proxy); + GameProfile profile = service.hasJoinedServer(new GameProfile((UUID) null, username), serverHash); + if(profile != null) { + int threshold = this.session.getFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD); + this.session.send(new LoginSetCompressionPacket(threshold)); + this.session.setCompressionThreshold(threshold); + this.session.send(new LoginSuccessPacket(profile)); + this.session.setFlag(ProtocolConstants.PROFILE_KEY, profile); + protocol.setMode(ProtocolMode.GAME, false, this.session); + ServerLoginHandler handler = this.session.getFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY); + if(handler != null) { + handler.loggedIn(this.session); + } + + new Thread(new KeepAlive(this.session)).start(); + } else { + this.session.disconnect("Failed to verify username!"); + } + } catch(AuthenticationUnavailableException e) { + this.session.disconnect("Authentication servers are down. Please try again later, sorry!"); + } + } + } + + private class KeepAlive implements Runnable { + private Session session; + + public KeepAlive(Session session) { + this.session = session; + } + + @Override + public void run() { + while(this.session.isConnected()) { + lastPingTime = System.currentTimeMillis(); + lastPingId = (int) lastPingTime; + this.session.send(new ServerKeepAlivePacket(lastPingId)); + + try { + Thread.sleep(2000); + } catch(InterruptedException e) { + break; + } + } + } + } } diff --git a/src/main/java/org/spacehq/mc/protocol/ServerLoginHandler.java b/src/main/java/org/spacehq/mc/protocol/ServerLoginHandler.java index cbed438b3..8d7cf780f 100644 --- a/src/main/java/org/spacehq/mc/protocol/ServerLoginHandler.java +++ b/src/main/java/org/spacehq/mc/protocol/ServerLoginHandler.java @@ -4,6 +4,6 @@ public interface ServerLoginHandler { - public void loggedIn(Session session); + public void loggedIn(Session session); } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/Chunk.java b/src/main/java/org/spacehq/mc/protocol/data/game/Chunk.java index e37c51c0b..52bd8d86c 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/Chunk.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/Chunk.java @@ -2,62 +2,62 @@ public class Chunk { - private ShortArray3d blocks; - private NibbleArray3d blocklight; - private NibbleArray3d skylight; - - public Chunk(boolean skylight) { - this(new ShortArray3d(4096), new NibbleArray3d(4096), skylight ? new NibbleArray3d(4096) : null); - } - - public Chunk(ShortArray3d blocks, NibbleArray3d blocklight, NibbleArray3d skylight) { - this.blocks = blocks; - this.blocklight = blocklight; - this.skylight = skylight; - } - - public ShortArray3d getBlocks() { - return this.blocks; - } - - public NibbleArray3d getBlockLight() { - return this.blocklight; - } - - public NibbleArray3d getSkyLight() { - return this.skylight; - } - - public boolean isEmpty() { - for(short block : this.blocks.getData()) { - if(block != 0) { - return false; - } - } - - return true; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Chunk chunk = (Chunk) o; - - if (!blocklight.equals(chunk.blocklight)) return false; - if (!blocks.equals(chunk.blocks)) return false; - if (skylight != null ? !skylight.equals(chunk.skylight) : chunk.skylight != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = blocks.hashCode(); - result = 31 * result + blocklight.hashCode(); - result = 31 * result + (skylight != null ? skylight.hashCode() : 0); - return result; - } + private ShortArray3d blocks; + private NibbleArray3d blocklight; + private NibbleArray3d skylight; + + public Chunk(boolean skylight) { + this(new ShortArray3d(4096), new NibbleArray3d(4096), skylight ? new NibbleArray3d(4096) : null); + } + + public Chunk(ShortArray3d blocks, NibbleArray3d blocklight, NibbleArray3d skylight) { + this.blocks = blocks; + this.blocklight = blocklight; + this.skylight = skylight; + } + + public ShortArray3d getBlocks() { + return this.blocks; + } + + public NibbleArray3d getBlockLight() { + return this.blocklight; + } + + public NibbleArray3d getSkyLight() { + return this.skylight; + } + + public boolean isEmpty() { + for(short block : this.blocks.getData()) { + if(block != 0) { + return false; + } + } + + return true; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + Chunk chunk = (Chunk) o; + + if(!blocklight.equals(chunk.blocklight)) return false; + if(!blocks.equals(chunk.blocks)) return false; + if(skylight != null ? !skylight.equals(chunk.skylight) : chunk.skylight != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = blocks.hashCode(); + result = 31 * result + blocklight.hashCode(); + result = 31 * result + (skylight != null ? skylight.hashCode() : 0); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/EntityMetadata.java b/src/main/java/org/spacehq/mc/protocol/data/game/EntityMetadata.java index 3d51e6413..405fce755 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/EntityMetadata.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/EntityMetadata.java @@ -4,48 +4,48 @@ public class EntityMetadata { - private int id; - private MetadataType type; - private Object value; - - public EntityMetadata(int id, MetadataType type, Object value) { - this.id = id; - this.type = type; - this.value = value; - } - - public int getId() { - return this.id; - } - - public MetadataType getType() { - return this.type; - } - - public Object getValue() { - return this.value; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - EntityMetadata metadata = (EntityMetadata) o; - - if (id != metadata.id) return false; - if (type != metadata.type) return false; - if (!value.equals(metadata.value)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id; - result = 31 * result + type.hashCode(); - result = 31 * result + value.hashCode(); - return result; - } + private int id; + private MetadataType type; + private Object value; + + public EntityMetadata(int id, MetadataType type, Object value) { + this.id = id; + this.type = type; + this.value = value; + } + + public int getId() { + return this.id; + } + + public MetadataType getType() { + return this.type; + } + + public Object getValue() { + return this.value; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + EntityMetadata metadata = (EntityMetadata) o; + + if(id != metadata.id) return false; + if(type != metadata.type) return false; + if(!value.equals(metadata.value)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = id; + result = 31 * result + type.hashCode(); + result = 31 * result + value.hashCode(); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/ItemStack.java b/src/main/java/org/spacehq/mc/protocol/data/game/ItemStack.java index 59bdd1ee4..ab2734eb6 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/ItemStack.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/ItemStack.java @@ -4,68 +4,68 @@ public class ItemStack { - private int id; - private int amount; - private int data; - private CompoundTag nbt; - - public ItemStack(int id) { - this(id, 1); - } - - public ItemStack(int id, int amount) { - this(id, amount, 0); - } - - public ItemStack(int id, int amount, int data) { - this(id, amount, data, null); - } - - public ItemStack(int id, int amount, int data, CompoundTag nbt) { - this.id = id; - this.amount = amount; - this.data = data; - this.nbt = nbt; - } - - public int getId() { - return this.id; - } - - public int getAmount() { - return this.amount; - } - - public int getData() { - return this.data; - } - - public CompoundTag getNBT() { - return this.nbt; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ItemStack itemStack = (ItemStack) o; - - if (amount != itemStack.amount) return false; - if (data != itemStack.data) return false; - if (id != itemStack.id) return false; - if (nbt != null ? !nbt.equals(itemStack.nbt) : itemStack.nbt != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = id; - result = 31 * result + amount; - result = 31 * result + data; - result = 31 * result + (nbt != null ? nbt.hashCode() : 0); - return result; - } + private int id; + private int amount; + private int data; + private CompoundTag nbt; + + public ItemStack(int id) { + this(id, 1); + } + + public ItemStack(int id, int amount) { + this(id, amount, 0); + } + + public ItemStack(int id, int amount, int data) { + this(id, amount, data, null); + } + + public ItemStack(int id, int amount, int data, CompoundTag nbt) { + this.id = id; + this.amount = amount; + this.data = data; + this.nbt = nbt; + } + + public int getId() { + return this.id; + } + + public int getAmount() { + return this.amount; + } + + public int getData() { + return this.data; + } + + public CompoundTag getNBT() { + return this.nbt; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + ItemStack itemStack = (ItemStack) o; + + if(amount != itemStack.amount) return false; + if(data != itemStack.data) return false; + if(id != itemStack.id) return false; + if(nbt != null ? !nbt.equals(itemStack.nbt) : itemStack.nbt != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = id; + result = 31 * result + amount; + result = 31 * result + data; + result = 31 * result + (nbt != null ? nbt.hashCode() : 0); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/NibbleArray3d.java b/src/main/java/org/spacehq/mc/protocol/data/game/NibbleArray3d.java index c73c41b1a..b53d4b741 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/NibbleArray3d.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/NibbleArray3d.java @@ -4,65 +4,65 @@ public class NibbleArray3d { - private byte[] data; + private byte[] data; - public NibbleArray3d(int size) { - this.data = new byte[size >> 1]; - } + public NibbleArray3d(int size) { + this.data = new byte[size >> 1]; + } - public NibbleArray3d(byte[] array) { - this.data = array; - } + public NibbleArray3d(byte[] array) { + this.data = array; + } - public byte[] getData() { - return this.data; - } + public byte[] getData() { + return this.data; + } - public int get(int x, int y, int z) { - int key = y << 8 | z << 4 | x; - int index = key >> 1; - int part = key & 1; - return part == 0 ? this.data[index] & 15 : this.data[index] >> 4 & 15; - } + public int get(int x, int y, int z) { + int key = y << 8 | z << 4 | x; + int index = key >> 1; + int part = key & 1; + return part == 0 ? this.data[index] & 15 : this.data[index] >> 4 & 15; + } - public void set(int x, int y, int z, int val) { - int key = y << 8 | z << 4 | x; - int index = key >> 1; - int part = key & 1; - if(part == 0) { - this.data[index] = (byte) (this.data[index] & 240 | val & 15); - } else { - this.data[index] = (byte) (this.data[index] & 15 | (val & 15) << 4); - } - } + public void set(int x, int y, int z, int val) { + int key = y << 8 | z << 4 | x; + int index = key >> 1; + int part = key & 1; + if(part == 0) { + this.data[index] = (byte) (this.data[index] & 240 | val & 15); + } else { + this.data[index] = (byte) (this.data[index] & 15 | (val & 15) << 4); + } + } - public void fill(int val) { - for(int index = 0; index < this.data.length << 1; index++) { - int ind = index >> 1; - int part = index & 1; - if(part == 0) { - this.data[ind] = (byte) (this.data[ind] & 240 | val & 15); - } else { - this.data[ind] = (byte) (this.data[ind] & 15 | (val & 15) << 4); - } - } - } + public void fill(int val) { + for(int index = 0; index < this.data.length << 1; index++) { + int ind = index >> 1; + int part = index & 1; + if(part == 0) { + this.data[ind] = (byte) (this.data[ind] & 240 | val & 15); + } else { + this.data[ind] = (byte) (this.data[ind] & 15 | (val & 15) << 4); + } + } + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - NibbleArray3d that = (NibbleArray3d) o; + NibbleArray3d that = (NibbleArray3d) o; - if (!Arrays.equals(data, that.data)) return false; + if(!Arrays.equals(data, that.data)) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return Arrays.hashCode(data); - } + @Override + public int hashCode() { + return Arrays.hashCode(data); + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/Position.java b/src/main/java/org/spacehq/mc/protocol/data/game/Position.java index 1950c4c20..37a1dce4e 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/Position.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/Position.java @@ -2,48 +2,48 @@ public class Position { - private int x; - private int y; - private int z; - - public Position(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - public int getX() { - return this.x; - } - - public int getY() { - return this.y; - } - - public int getZ() { - return this.z; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Position position = (Position) o; - - if (x != position.x) return false; - if (y != position.y) return false; - if (z != position.z) return false; - - return true; - } - - @Override - public int hashCode() { - int result = x; - result = 31 * result + y; - result = 31 * result + z; - return result; - } + private int x; + private int y; + private int z; + + public Position(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public int getX() { + return this.x; + } + + public int getY() { + return this.y; + } + + public int getZ() { + return this.z; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + Position position = (Position) o; + + if(x != position.x) return false; + if(y != position.y) return false; + if(z != position.z) return false; + + return true; + } + + @Override + public int hashCode() { + int result = x; + result = 31 * result + y; + result = 31 * result + z; + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/Rotation.java b/src/main/java/org/spacehq/mc/protocol/data/game/Rotation.java index 93516504a..533f90ecc 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/Rotation.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/Rotation.java @@ -1,52 +1,52 @@ package org.spacehq.mc.protocol.data.game; public class Rotation { - private float pitch; - private float yaw; - private float roll; - - public Rotation() { - this(0, 0, 0); - } - - public Rotation(float pitch, float yaw, float roll) { - this.pitch = pitch; - this.yaw = yaw; - this.roll = roll; - } - - public float getPitch() { - return this.pitch; - } - - public float getYaw() { - return this.yaw; - } - - public float getRoll() { - return this.roll; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Rotation rotation = (Rotation) o; - - if (Float.compare(rotation.pitch, pitch) != 0) return false; - if (Float.compare(rotation.roll, roll) != 0) return false; - if (Float.compare(rotation.yaw, yaw) != 0) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (pitch != +0.0f ? Float.floatToIntBits(pitch) : 0); - result = 31 * result + (yaw != +0.0f ? Float.floatToIntBits(yaw) : 0); - result = 31 * result + (roll != +0.0f ? Float.floatToIntBits(roll) : 0); - return result; - } + private float pitch; + private float yaw; + private float roll; + + public Rotation() { + this(0, 0, 0); + } + + public Rotation(float pitch, float yaw, float roll) { + this.pitch = pitch; + this.yaw = yaw; + this.roll = roll; + } + + public float getPitch() { + return this.pitch; + } + + public float getYaw() { + return this.yaw; + } + + public float getRoll() { + return this.roll; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + Rotation rotation = (Rotation) o; + + if(Float.compare(rotation.pitch, pitch) != 0) return false; + if(Float.compare(rotation.roll, roll) != 0) return false; + if(Float.compare(rotation.yaw, yaw) != 0) return false; + + return true; + } + + @Override + public int hashCode() { + int result = (pitch != +0.0f ? Float.floatToIntBits(pitch) : 0); + result = 31 * result + (yaw != +0.0f ? Float.floatToIntBits(yaw) : 0); + result = 31 * result + (roll != +0.0f ? Float.floatToIntBits(roll) : 0); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/ShortArray3d.java b/src/main/java/org/spacehq/mc/protocol/data/game/ShortArray3d.java index 86dd5116b..7d50248cf 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/ShortArray3d.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/ShortArray3d.java @@ -4,67 +4,67 @@ public class ShortArray3d { - private short[] data; + private short[] data; - public ShortArray3d(int size) { - this.data = new short[size]; - } + public ShortArray3d(int size) { + this.data = new short[size]; + } - public ShortArray3d(short[] array) { - this.data = array; - } + public ShortArray3d(short[] array) { + this.data = array; + } - public short[] getData() { - return this.data; - } + public short[] getData() { + return this.data; + } - public int get(int x, int y, int z) { - return this.data[y << 8 | z << 4 | x] & 0xFFFF; - } + public int get(int x, int y, int z) { + return this.data[y << 8 | z << 4 | x] & 0xFFFF; + } - public void set(int x, int y, int z, int val) { - this.data[y << 8 | z << 4 | x] = (short) val; - } + public void set(int x, int y, int z, int val) { + this.data[y << 8 | z << 4 | x] = (short) val; + } - public int getBlock(int x, int y, int z) { - return this.get(x, y, z) >> 4; - } + public int getBlock(int x, int y, int z) { + return this.get(x, y, z) >> 4; + } - public void setBlock(int x, int y, int z, int block) { - this.set(x, y, z, block << 4 | this.getData(x, y, z)); - } + public void setBlock(int x, int y, int z, int block) { + this.set(x, y, z, block << 4 | this.getData(x, y, z)); + } - public int getData(int x, int y, int z) { - return this.get(x, y, z) & 0xF; - } + public int getData(int x, int y, int z) { + return this.get(x, y, z) & 0xF; + } - public void setData(int x, int y, int z, int data) { - this.set(x, y, z, this.getBlock(x, y, z) << 4 | data); - } + public void setData(int x, int y, int z, int data) { + this.set(x, y, z, this.getBlock(x, y, z) << 4 | data); + } - public void setBlockAndData(int x, int y, int z, int block, int data) { - this.set(x, y, z, block << 4 | data); - } + public void setBlockAndData(int x, int y, int z, int block, int data) { + this.set(x, y, z, block << 4 | data); + } - public void fill(int val) { - Arrays.fill(this.data, (short) val); - } + public void fill(int val) { + Arrays.fill(this.data, (short) val); + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - ShortArray3d that = (ShortArray3d) o; + ShortArray3d that = (ShortArray3d) o; - if (!Arrays.equals(data, that.data)) return false; + if(!Arrays.equals(data, that.data)) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return Arrays.hashCode(data); - } + @Override + public int hashCode() { + return Arrays.hashCode(data); + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/attribute/Attribute.java b/src/main/java/org/spacehq/mc/protocol/data/game/attribute/Attribute.java index 2203c8cb5..0b021abdc 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/attribute/Attribute.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/attribute/Attribute.java @@ -7,57 +7,57 @@ public class Attribute { - private AttributeType type; - private double value; - private List modifiers; - - public Attribute(AttributeType type) { - this(type, type.getDefault()); - } - - public Attribute(AttributeType type, double value) { - this(type, value, new ArrayList()); - } - - public Attribute(AttributeType type, double value, List modifiers) { - this.type = type; - this.value = value; - this.modifiers = modifiers; - } - - public AttributeType getType() { - return this.type; - } - - public double getValue() { - return this.value; - } - - public List getModifiers() { - return new ArrayList(this.modifiers); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Attribute attribute = (Attribute) o; - - if (Double.compare(attribute.value, value) != 0) return false; - if (!modifiers.equals(attribute.modifiers)) return false; - if (type != attribute.type) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - long temp = Double.doubleToLongBits(value); - result = 31 * result + (int) (temp ^ (temp >>> 32)); - result = 31 * result + modifiers.hashCode(); - return result; - } + private AttributeType type; + private double value; + private List modifiers; + + public Attribute(AttributeType type) { + this(type, type.getDefault()); + } + + public Attribute(AttributeType type, double value) { + this(type, value, new ArrayList()); + } + + public Attribute(AttributeType type, double value, List modifiers) { + this.type = type; + this.value = value; + this.modifiers = modifiers; + } + + public AttributeType getType() { + return this.type; + } + + public double getValue() { + return this.value; + } + + public List getModifiers() { + return new ArrayList(this.modifiers); + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + Attribute attribute = (Attribute) o; + + if(Double.compare(attribute.value, value) != 0) return false; + if(!modifiers.equals(attribute.modifiers)) return false; + if(type != attribute.type) return false; + + return true; + } + + @Override + public int hashCode() { + int result = type.hashCode(); + long temp = Double.doubleToLongBits(value); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + result = 31 * result + modifiers.hashCode(); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/attribute/AttributeModifier.java b/src/main/java/org/spacehq/mc/protocol/data/game/attribute/AttributeModifier.java index 937f6d05c..f1f20126a 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/attribute/AttributeModifier.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/attribute/AttributeModifier.java @@ -8,62 +8,62 @@ public class AttributeModifier { - private ModifierType type; - private UUID uuid; - private double amount; - private ModifierOperation operation; - - public AttributeModifier(ModifierType type, double amount, ModifierOperation operation) { - this.type = type; - this.uuid = MagicValues.value(UUID.class, type); - this.amount = amount; - this.operation = operation; - } - - public AttributeModifier(UUID uuid, double amount, ModifierOperation operation) { - this.type = MagicValues.key(ModifierType.class, uuid); - this.uuid = uuid; - this.amount = amount; - this.operation = operation; - } - - public ModifierType getType() { - return this.type; - } - - public UUID getUUID() { - return this.uuid; - } - - public double getAmount() { - return this.amount; - } - - public ModifierOperation getOperation() { - return this.operation; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - AttributeModifier that = (AttributeModifier) o; - - if (Double.compare(that.amount, amount) != 0) return false; - if (operation != that.operation) return false; - if (type != that.type) return false; - - return true; - } - - @Override - public int hashCode() { - int result = type.hashCode(); - long temp = Double.doubleToLongBits(amount); - result = 31 * result + (int) (temp ^ (temp >>> 32)); - result = 31 * result + operation.hashCode(); - return result; - } + private ModifierType type; + private UUID uuid; + private double amount; + private ModifierOperation operation; + + public AttributeModifier(ModifierType type, double amount, ModifierOperation operation) { + this.type = type; + this.uuid = MagicValues.value(UUID.class, type); + this.amount = amount; + this.operation = operation; + } + + public AttributeModifier(UUID uuid, double amount, ModifierOperation operation) { + this.type = MagicValues.key(ModifierType.class, uuid); + this.uuid = uuid; + this.amount = amount; + this.operation = operation; + } + + public ModifierType getType() { + return this.type; + } + + public UUID getUUID() { + return this.uuid; + } + + public double getAmount() { + return this.amount; + } + + public ModifierOperation getOperation() { + return this.operation; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + AttributeModifier that = (AttributeModifier) o; + + if(Double.compare(that.amount, amount) != 0) return false; + if(operation != that.operation) return false; + if(type != that.type) return false; + + return true; + } + + @Override + public int hashCode() { + int result = type.hashCode(); + long temp = Double.doubleToLongBits(amount); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + result = 31 * result + operation.hashCode(); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/ClientRequest.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/ClientRequest.java index 33e5a947b..3deab79f1 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/ClientRequest.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/ClientRequest.java @@ -2,8 +2,8 @@ public enum ClientRequest { - RESPAWN, - STATS, - OPEN_INVENTORY_ACHIEVEMENT; + RESPAWN, + STATS, + OPEN_INVENTORY_ACHIEVEMENT; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/Face.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/Face.java index e93942e63..dee38751f 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/Face.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/Face.java @@ -2,12 +2,12 @@ public enum Face { - BOTTOM, - TOP, - EAST, - WEST, - NORTH, - SOUTH, - INVALID; + BOTTOM, + TOP, + EAST, + WEST, + NORTH, + SOUTH, + INVALID; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/HandshakeIntent.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/HandshakeIntent.java index 6f61b9370..8ad193e52 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/HandshakeIntent.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/HandshakeIntent.java @@ -2,7 +2,7 @@ public enum HandshakeIntent { - STATUS, - LOGIN; + STATUS, + LOGIN; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/MagicValues.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/MagicValues.java index 1edd7c65d..d483dc913 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/MagicValues.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/MagicValues.java @@ -1,13 +1,45 @@ package org.spacehq.mc.protocol.data.game.values; -import org.spacehq.mc.protocol.data.game.values.entity.*; -import org.spacehq.mc.protocol.data.game.values.entity.player.*; -import org.spacehq.mc.protocol.data.game.values.scoreboard.*; +import org.spacehq.mc.protocol.data.game.values.entity.Art; +import org.spacehq.mc.protocol.data.game.values.entity.AttributeType; +import org.spacehq.mc.protocol.data.game.values.entity.Effect; +import org.spacehq.mc.protocol.data.game.values.entity.EntityStatus; +import org.spacehq.mc.protocol.data.game.values.entity.GlobalEntityType; +import org.spacehq.mc.protocol.data.game.values.entity.HangingDirection; +import org.spacehq.mc.protocol.data.game.values.entity.MetadataType; +import org.spacehq.mc.protocol.data.game.values.entity.MinecartType; +import org.spacehq.mc.protocol.data.game.values.entity.MobType; +import org.spacehq.mc.protocol.data.game.values.entity.ModifierOperation; +import org.spacehq.mc.protocol.data.game.values.entity.ModifierType; +import org.spacehq.mc.protocol.data.game.values.entity.ObjectType; +import org.spacehq.mc.protocol.data.game.values.entity.player.Animation; +import org.spacehq.mc.protocol.data.game.values.entity.player.BlockBreakStage; +import org.spacehq.mc.protocol.data.game.values.entity.player.CombatState; +import org.spacehq.mc.protocol.data.game.values.entity.player.GameMode; +import org.spacehq.mc.protocol.data.game.values.entity.player.InteractAction; +import org.spacehq.mc.protocol.data.game.values.entity.player.PlayerAction; +import org.spacehq.mc.protocol.data.game.values.entity.player.PlayerState; +import org.spacehq.mc.protocol.data.game.values.entity.player.PositionElement; +import org.spacehq.mc.protocol.data.game.values.scoreboard.NameTagVisibility; +import org.spacehq.mc.protocol.data.game.values.scoreboard.ObjectiveAction; +import org.spacehq.mc.protocol.data.game.values.scoreboard.ScoreType; +import org.spacehq.mc.protocol.data.game.values.scoreboard.ScoreboardAction; +import org.spacehq.mc.protocol.data.game.values.scoreboard.ScoreboardPosition; +import org.spacehq.mc.protocol.data.game.values.scoreboard.TeamAction; +import org.spacehq.mc.protocol.data.game.values.scoreboard.TeamColor; import org.spacehq.mc.protocol.data.game.values.setting.ChatVisibility; import org.spacehq.mc.protocol.data.game.values.setting.Difficulty; import org.spacehq.mc.protocol.data.game.values.statistic.Achievement; import org.spacehq.mc.protocol.data.game.values.statistic.GenericStatistic; -import org.spacehq.mc.protocol.data.game.values.window.*; +import org.spacehq.mc.protocol.data.game.values.window.ClickItemParam; +import org.spacehq.mc.protocol.data.game.values.window.CreativeGrabParam; +import org.spacehq.mc.protocol.data.game.values.window.DropItemParam; +import org.spacehq.mc.protocol.data.game.values.window.FillStackParam; +import org.spacehq.mc.protocol.data.game.values.window.MoveToHotbarParam; +import org.spacehq.mc.protocol.data.game.values.window.ShiftClickItemParam; +import org.spacehq.mc.protocol.data.game.values.window.SpreadItemParam; +import org.spacehq.mc.protocol.data.game.values.window.WindowAction; +import org.spacehq.mc.protocol.data.game.values.window.WindowType; import org.spacehq.mc.protocol.data.game.values.window.property.AnvilProperty; import org.spacehq.mc.protocol.data.game.values.window.property.BrewingStandProperty; import org.spacehq.mc.protocol.data.game.values.window.property.EnchantmentTableProperty; @@ -17,7 +49,12 @@ import org.spacehq.mc.protocol.data.game.values.world.WorldBorderAction; import org.spacehq.mc.protocol.data.game.values.world.WorldType; import org.spacehq.mc.protocol.data.game.values.world.block.UpdatedTileType; -import org.spacehq.mc.protocol.data.game.values.world.block.value.*; +import org.spacehq.mc.protocol.data.game.values.world.block.value.ChestValueType; +import org.spacehq.mc.protocol.data.game.values.world.block.value.GenericBlockValueType; +import org.spacehq.mc.protocol.data.game.values.world.block.value.MobSpawnerValueType; +import org.spacehq.mc.protocol.data.game.values.world.block.value.NoteBlockValueType; +import org.spacehq.mc.protocol.data.game.values.world.block.value.PistonValue; +import org.spacehq.mc.protocol.data.game.values.world.block.value.PistonValueType; import org.spacehq.mc.protocol.data.game.values.world.effect.ParticleEffect; import org.spacehq.mc.protocol.data.game.values.world.effect.SmokeEffectData; import org.spacehq.mc.protocol.data.game.values.world.effect.SoundEffect; @@ -30,870 +67,870 @@ public class MagicValues { - private static final Map, Object> values = new HashMap, Object>(); - - static { - register(AttributeType.MAX_HEALTH, "generic.maxHealth"); - register(AttributeType.FOLLOW_RANGE, "generic.followRange"); - register(AttributeType.KNOCKBACK_RESISTANCE, "generic.knockbackResistance"); - register(AttributeType.MOVEMENT_SPEED, "generic.movementSpeed"); - register(AttributeType.ATTACK_DAMAGE, "generic.attackDamage"); - register(AttributeType.HORSE_JUMP_STRENGTH, "horse.jumpStrength"); - register(AttributeType.ZOMBIE_SPAWN_REINFORCEMENTS_CHANCE, "zombie.spawnReinforcements"); - - register(ModifierType.CREATURE_FLEE_SPEED_BONUS, UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A")); - register(ModifierType.ENDERMAN_ATTACK_SPEED_BOOST, UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0")); - register(ModifierType.SPRINT_SPEED_BOOST, UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D")); - register(ModifierType.PIGZOMBIE_ATTACK_SPEED_BOOST, UUID.fromString("49455A49-7EC5-45BA-B886-3B90B23A1718")); - register(ModifierType.WITCH_DRINKING_SPEED_PENALTY, UUID.fromString("5CD17E52-A79A-43D3-A529-90FDE04B181E")); - register(ModifierType.ZOMBIE_BABY_SPEED_BOOST, UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836")); - register(ModifierType.ITEM_MODIFIER, UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF")); - register(ModifierType.SPEED_POTION_MODIFIER, UUID.fromString("91AEAA56-376B-4498-935B-2F7F68070635")); - register(ModifierType.HEALTH_BOOST_POTION_MODIFIER, UUID.fromString("5D6F0BA2-1186-46AC-B896-C61C5CEE99CC")); - register(ModifierType.SLOW_POTION_MODIFIER, UUID.fromString("7107DE5E-7CE8-4030-940E-514C1F160890")); - register(ModifierType.STRENGTH_POTION_MODIFIER, UUID.fromString("648D7064-6A60-4F59-8ABE-C2C23A6DD7A9")); - register(ModifierType.WEAKNESS_POTION_MODIFIER, UUID.fromString("22653B89-116E-49DC-9B6B-9971489B5BE5")); - - register(ModifierOperation.ADD, 0); - register(ModifierOperation.ADD_MULTIPLIED, 1); - register(ModifierOperation.MULTIPLY, 2); - - register(MetadataType.BYTE, 0); - register(MetadataType.SHORT, 1); - register(MetadataType.INT, 2); - register(MetadataType.FLOAT, 3); - register(MetadataType.STRING, 4); - register(MetadataType.ITEM, 5); - register(MetadataType.POSITION, 6); - register(MetadataType.ROTATION, 7); - - register(HandshakeIntent.STATUS, 1); - register(HandshakeIntent.LOGIN, 2); - - register(ClientRequest.RESPAWN, 0); - register(ClientRequest.STATS, 1); - register(ClientRequest.OPEN_INVENTORY_ACHIEVEMENT, 2); - - register(ChatVisibility.FULL, 0); - register(ChatVisibility.SYSTEM, 1); - register(ChatVisibility.HIDDEN, 2); - - register(PlayerState.START_SNEAKING, 0); - register(PlayerState.STOP_SNEAKING, 1); - register(PlayerState.LEAVE_BED, 2); - register(PlayerState.START_SPRINTING, 3); - register(PlayerState.STOP_SPRINTING, 4); - register(PlayerState.RIDING_JUMP, 5); - register(PlayerState.OPEN_INVENTORY, 6); - - register(InteractAction.INTERACT, 0); - register(InteractAction.ATTACK, 1); - register(InteractAction.INTERACT_AT, 2); - - register(PlayerAction.START_DIGGING, 0); - register(PlayerAction.CANCEL_DIGGING, 1); - register(PlayerAction.FINISH_DIGGING, 2); - register(PlayerAction.DROP_ITEM_STACK, 3); - register(PlayerAction.DROP_ITEM, 4); - register(PlayerAction.RELEASE_USE_ITEM, 5); - - register(Face.BOTTOM, 0); - register(Face.TOP, 1); - register(Face.EAST, 2); - register(Face.WEST, 3); - register(Face.NORTH, 4); - register(Face.SOUTH, 5); - register(Face.INVALID, 255); - - register(WindowAction.CLICK_ITEM, 0); - register(WindowAction.SHIFT_CLICK_ITEM, 1); - register(WindowAction.MOVE_TO_HOTBAR_SLOT, 2); - register(WindowAction.CREATIVE_GRAB_MAX_STACK, 3); - register(WindowAction.DROP_ITEM, 4); - register(WindowAction.SPREAD_ITEM, 5); - register(WindowAction.FILL_STACK, 6); - - register(ClickItemParam.LEFT_CLICK, 0); - register(ClickItemParam.RIGHT_CLICK, 1); - - register(ShiftClickItemParam.LEFT_CLICK, 0); - register(ShiftClickItemParam.RIGHT_CLICK, 1); - - register(MoveToHotbarParam.SLOT_1, 0); - register(MoveToHotbarParam.SLOT_2, 1); - register(MoveToHotbarParam.SLOT_3, 2); - register(MoveToHotbarParam.SLOT_4, 3); - register(MoveToHotbarParam.SLOT_5, 4); - register(MoveToHotbarParam.SLOT_6, 5); - register(MoveToHotbarParam.SLOT_7, 6); - register(MoveToHotbarParam.SLOT_8, 7); - register(MoveToHotbarParam.SLOT_9, 8); - - register(CreativeGrabParam.GRAB, 2); - - register(DropItemParam.LEFT_CLICK_OUTSIDE_NOT_HOLDING, 0); - register(DropItemParam.RIGHT_CLICK_OUTSIDE_NOT_HOLDING, 1); - register(DropItemParam.DROP_FROM_SELECTED, 2); - register(DropItemParam.DROP_SELECTED_STACK, 3); - - register(SpreadItemParam.LEFT_MOUSE_BEGIN_DRAG, 0); - register(SpreadItemParam.LEFT_MOUSE_ADD_SLOT, 1); - register(SpreadItemParam.LEFT_MOUSE_END_DRAG, 2); - register(SpreadItemParam.RIGHT_MOUSE_BEGIN_DRAG, 4); - register(SpreadItemParam.RIGHT_MOUSE_ADD_SLOT, 5); - register(SpreadItemParam.RIGHT_MOUSE_END_DRAG, 6); - - register(FillStackParam.FILL, 0); - - register(MessageType.CHAT, 0); - register(MessageType.SYSTEM, 1); - register(MessageType.NOTIFICATION, 2); - - register(CombatState.ENTER_COMBAT, 0); - register(CombatState.END_COMBAT, 1); - register(CombatState.ENTITY_DEAD, 2); - - register(GameMode.SURVIVAL, 0); - register(GameMode.CREATIVE, 1); - register(GameMode.ADVENTURE, 2); - register(GameMode.SPECTATOR, 3); - - register(Difficulty.PEACEFUL, 0); - register(Difficulty.EASY, 1); - register(Difficulty.NORMAL, 2); - register(Difficulty.HARD, 3); - - register(WorldType.DEFAULT, "default"); - register(WorldType.FLAT, "flat"); - register(WorldType.LARGE_BIOMES, "largebiomes"); - register(WorldType.AMPLIFIED, "amplified"); - register(WorldType.CUSTOMIZED, "customized"); - register(WorldType.DEBUG, "debug_all_block_states"); - register(WorldType.DEFAULT_1_1, "default_1_1"); - - register(Animation.SWING_ARM, 0); - register(Animation.DAMAGE, 1); - register(Animation.LEAVE_BED, 2); - register(Animation.EAT_FOOD, 3); - register(Animation.CRITICAL_HIT, 4); - register(Animation.ENCHANTMENT_CRITICAL_HIT, 5); - - register(Effect.SPEED, 1); - register(Effect.SLOWNESS, 2); - register(Effect.DIG_SPEED, 3); - register(Effect.DIG_SLOWNESS, 4); - register(Effect.DAMAGE_BOOST, 5); - register(Effect.HEAL, 6); - register(Effect.DAMAGE, 7); - register(Effect.JUMP_BOOST, 8); - register(Effect.CONFUSION, 9); - register(Effect.REGENERATION, 10); - register(Effect.RESISTANCE, 11); - register(Effect.FIRE_RESISTANCE, 12); - register(Effect.WATER_BREATHING, 13); - register(Effect.INVISIBILITY, 14); - register(Effect.BLINDNESS, 15); - register(Effect.NIGHT_VISION, 16); - register(Effect.HUNGER, 17); - register(Effect.WEAKNESS, 18); - register(Effect.POISON, 19); - register(Effect.WITHER_EFFECT, 20); - register(Effect.HEALTH_BOOST, 21); - register(Effect.ABSORPTION, 22); - register(Effect.SATURATION, 23); - - register(EntityStatus.HURT_OR_MINECART_SPAWNER_DELAY_RESET, 1); - register(EntityStatus.LIVING_HURT, 2); - register(EntityStatus.DEAD, 3); - register(EntityStatus.IRON_GOLEM_THROW, 4); - register(EntityStatus.TAMING, 6); - register(EntityStatus.TAMED, 7); - register(EntityStatus.WOLF_SHAKING, 8); - register(EntityStatus.FINISHED_EATING, 9); - register(EntityStatus.SHEEP_GRAZING_OR_TNT_CART_EXPLODING, 10); - register(EntityStatus.IRON_GOLEM_ROSE, 11); - register(EntityStatus.VILLAGER_HEARTS, 12); - register(EntityStatus.VILLAGER_ANGRY, 13); - register(EntityStatus.VILLAGER_HAPPY, 14); - register(EntityStatus.WITCH_MAGIC_PARTICLES, 15); - register(EntityStatus.ZOMBIE_VILLAGER_SHAKING, 16); - register(EntityStatus.FIREWORK_EXPLODING, 17); - register(EntityStatus.ANIMAL_HEARTS, 18); - register(EntityStatus.RESET_SQUID_ROTATION, 19); - register(EntityStatus.EXPLOSION_PARTICLE, 20); - register(EntityStatus.GUARDIAN_SOUND, 21); - register(EntityStatus.ENABLE_REDUCED_DEBUG, 22); - register(EntityStatus.DISABLE_REDUCED_DEBUG, 23); - - register(PositionElement.X, 0); - register(PositionElement.Y, 1); - register(PositionElement.Z, 2); - register(PositionElement.PITCH, 3); - register(PositionElement.YAW, 4); - - register(GlobalEntityType.LIGHTNING_BOLT, 1); - - register(MobType.ARMOR_STAND, 30); - register(MobType.CREEPER, 50); - register(MobType.SKELETON, 51); - register(MobType.SPIDER, 52); - register(MobType.GIANT_ZOMBIE, 53); - register(MobType.ZOMBIE, 54); - register(MobType.SLIME, 55); - register(MobType.GHAST, 56); - register(MobType.ZOMBIE_PIGMAN, 57); - register(MobType.ENDERMAN, 58); - register(MobType.CAVE_SPIDER, 59); - register(MobType.SILVERFISH, 60); - register(MobType.BLAZE, 61); - register(MobType.MAGMA_CUBE, 62); - register(MobType.ENDER_DRAGON, 63); - register(MobType.WITHER, 64); - register(MobType.BAT, 65); - register(MobType.WITCH, 66); - register(MobType.ENDERMITE, 67); - register(MobType.GUARDIAN, 68); - register(MobType.PIG, 90); - register(MobType.SHEEP, 91); - register(MobType.COW, 92); - register(MobType.CHICKEN, 93); - register(MobType.SQUID, 94); - register(MobType.WOLF, 95); - register(MobType.MOOSHROOM, 96); - register(MobType.SNOWMAN, 97); - register(MobType.OCELOT, 98); - register(MobType.IRON_GOLEM, 99); - register(MobType.HORSE, 100); - register(MobType.RABBIT, 101); - register(MobType.VILLAGER, 120); - - register(ObjectType.BOAT, 1); - register(ObjectType.ITEM, 2); - register(ObjectType.MINECART, 10); - register(ObjectType.PRIMED_TNT, 50); - register(ObjectType.ENDER_CRYSTAL, 51); - register(ObjectType.ARROW, 60); - register(ObjectType.SNOWBALL, 61); - register(ObjectType.EGG, 62); - register(ObjectType.GHAST_FIREBALL, 63); - register(ObjectType.BLAZE_FIREBALL, 64); - register(ObjectType.ENDER_PEARL, 65); - register(ObjectType.WITHER_HEAD_PROJECTILE, 66); - register(ObjectType.FALLING_BLOCK, 70); - register(ObjectType.ITEM_FRAME, 71); - register(ObjectType.EYE_OF_ENDER, 72); - register(ObjectType.POTION, 73); - register(ObjectType.FALLING_DRAGON_EGG, 74); - register(ObjectType.EXP_BOTTLE, 75); - register(ObjectType.FIREWORK_ROCKET, 76); - register(ObjectType.LEASH_KNOT, 77); - register(ObjectType.ARMOR_STAND, 78); - register(ObjectType.FISH_HOOK, 90); - - register(MinecartType.NORMAL, 0); - register(MinecartType.CHEST, 1); - register(MinecartType.POWERED, 2); - register(MinecartType.TNT, 3); - register(MinecartType.MOB_SPAWNER, 4); - register(MinecartType.HOPPER, 5); - register(MinecartType.COMMAND_BLOCK, 6); - - register(HangingDirection.SOUTH, 0); - register(HangingDirection.WEST, 1); - register(HangingDirection.NORTH, 2); - register(HangingDirection.EAST, 3); - - register(Art.KEBAB, "Kebab"); - register(Art.AZTEC, "Aztec"); - register(Art.ALBAN, "Alban"); - register(Art.AZTEC2, "Aztec2"); - register(Art.BOMB, "Bomb"); - register(Art.PLANT, "Plant"); - register(Art.WASTELAND, "Wasteland"); - register(Art.POOL, "Pool"); - register(Art.COURBET, "Courbet"); - register(Art.SEA, "Sea"); - register(Art.SUNSET, "Sunset"); - register(Art.CREEBET, "Creebet"); - register(Art.WANDERER, "Wanderer"); - register(Art.GRAHAM, "Graham"); - register(Art.MATCH, "Match"); - register(Art.BUST, "Bust"); - register(Art.STAGE, "Stage"); - register(Art.VOID, "Void"); - register(Art.SKULL_AND_ROSES, "SkullAndRoses"); - register(Art.WITHER, "Wither"); - register(Art.FIGHTERS, "Fighters"); - register(Art.POINTER, "Pointer"); - register(Art.PIG_SCENE, "Pigscene"); - register(Art.BURNING_SKULL, "BurningSkull"); - register(Art.SKELETON, "Skeleton"); - register(Art.DONKEY_KONG, "DonkeyKong"); - - register(ScoreboardPosition.PLAYER_LIST, 0); - register(ScoreboardPosition.SIDEBAR, 1); - register(ScoreboardPosition.BELOW_NAME, 2); - register(ScoreboardPosition.SIDEBAR_TEAM_BLACK, 3); - register(ScoreboardPosition.SIDEBAR_TEAM_DARK_BLUE, 4); - register(ScoreboardPosition.SIDEBAR_TEAM_DARK_GREEN, 5); - register(ScoreboardPosition.SIDEBAR_TEAM_DARK_AQUA, 6); - register(ScoreboardPosition.SIDEBAR_TEAM_DARK_RED, 7); - register(ScoreboardPosition.SIDEBAR_TEAM_DARK_PURPLE, 8); - register(ScoreboardPosition.SIDEBAR_TEAM_GOLD, 9); - register(ScoreboardPosition.SIDEBAR_TEAM_GRAY, 10); - register(ScoreboardPosition.SIDEBAR_TEAM_DARK_GRAY, 11); - register(ScoreboardPosition.SIDEBAR_TEAM_BLUE, 12); - register(ScoreboardPosition.SIDEBAR_TEAM_GREEN, 13); - register(ScoreboardPosition.SIDEBAR_TEAM_AQUA, 14); - register(ScoreboardPosition.SIDEBAR_TEAM_RED, 15); - register(ScoreboardPosition.SIDEBAR_TEAM_LIGHT_PURPLE, 16); - register(ScoreboardPosition.SIDEBAR_TEAM_YELLOW, 17); - register(ScoreboardPosition.SIDEBAR_TEAM_WHITE, 18); - - register(ObjectiveAction.ADD, 0); - register(ObjectiveAction.REMOVE, 1); - register(ObjectiveAction.UPDATE, 2); - - register(TeamAction.CREATE, 0); - register(TeamAction.REMOVE, 1); - register(TeamAction.UPDATE, 2); - register(TeamAction.ADD_PLAYER, 3); - register(TeamAction.REMOVE_PLAYER, 4); - - register(ScoreboardAction.ADD_OR_UPDATE, 0); - register(ScoreboardAction.REMOVE, 1); - - register(WindowType.GENERIC_INVENTORY, "minecraft:container"); - register(WindowType.ANVIL, "minecraft:anvil"); - register(WindowType.BEACON, "minecraft:beacon"); - register(WindowType.BREWING_STAND, "minecraft:brewing_stand"); - register(WindowType.CHEST, "minecraft:chest"); - register(WindowType.CRAFTING_TABLE, "minecraft:crafting_table"); - register(WindowType.DISPENSER, "minecraft:dispenser"); - register(WindowType.DROPPER, "minecraft:dropper"); - register(WindowType.ENCHANTING_TABLE, "minecraft:enchanting_table"); - register(WindowType.FURNACE, "minecraft:furnace"); - register(WindowType.HOPPER, "minecraft:hopper"); - register(WindowType.VILLAGER, "minecraft:villager"); - register(WindowType.HORSE, "EntityHorse"); - - register(BrewingStandProperty.BREW_TIME, 0); - - register(EnchantmentTableProperty.LEVEL_SLOT_1, 0); - register(EnchantmentTableProperty.LEVEL_SLOT_2, 1); - register(EnchantmentTableProperty.LEVEL_SLOT_3, 2); - register(EnchantmentTableProperty.XP_SEED, 3); - register(EnchantmentTableProperty.ENCHANTMENT_SLOT_1, 4); - register(EnchantmentTableProperty.ENCHANTMENT_SLOT_2, 5); - register(EnchantmentTableProperty.ENCHANTMENT_SLOT_3, 6); - - register(FurnaceProperty.BURN_TIME, 0); - register(FurnaceProperty.CURRENT_ITEM_BURN_TIME, 1); - register(FurnaceProperty.COOK_TIME, 2); - register(FurnaceProperty.TOTAL_COOK_TIME, 3); - - register(AnvilProperty.MAXIMUM_COST, 0); - - register(BlockBreakStage.RESET, -1); - register(BlockBreakStage.STAGE_1, 0); - register(BlockBreakStage.STAGE_2, 1); - register(BlockBreakStage.STAGE_3, 2); - register(BlockBreakStage.STAGE_4, 3); - register(BlockBreakStage.STAGE_5, 4); - register(BlockBreakStage.STAGE_6, 5); - register(BlockBreakStage.STAGE_7, 6); - register(BlockBreakStage.STAGE_8, 7); - register(BlockBreakStage.STAGE_9, 8); - register(BlockBreakStage.STAGE_10, 9); - register(BlockBreakStage.RESET, 255); - - register(UpdatedTileType.MOB_SPAWNER, 1); - register(UpdatedTileType.COMMAND_BLOCK, 2); - register(UpdatedTileType.BEACON, 3); - register(UpdatedTileType.SKULL, 4); - register(UpdatedTileType.FLOWER_POT, 5); - register(UpdatedTileType.BANNER, 6); - - register(ClientNotification.INVALID_BED, 0); - register(ClientNotification.START_RAIN, 1); - register(ClientNotification.STOP_RAIN, 2); - register(ClientNotification.CHANGE_GAMEMODE, 3); - register(ClientNotification.ENTER_CREDITS, 4); - register(ClientNotification.DEMO_MESSAGE, 5); - register(ClientNotification.ARROW_HIT_PLAYER, 6); - register(ClientNotification.RAIN_STRENGTH, 7); - register(ClientNotification.THUNDER_STRENGTH, 8); - - register(DemoMessageValue.WELCOME, 0); - register(DemoMessageValue.MOVEMENT_CONTROLS, 101); - register(DemoMessageValue.JUMP_CONTROL, 102); - register(DemoMessageValue.INVENTORY_CONTROL, 103); - - register(Achievement.OPEN_INVENTORY, "achievement.openInventory"); - register(Achievement.GET_WOOD, "achievement.mineWood"); - register(Achievement.MAKE_WORKBENCH, "achievement.buildWorkBench"); - register(Achievement.MAKE_PICKAXE, "achievement.buildPickaxe"); - register(Achievement.MAKE_FURNACE, "achievement.buildFurnace"); - register(Achievement.GET_IRON, "achievement.acquireIron"); - register(Achievement.MAKE_HOE, "achievement.buildHoe"); - register(Achievement.MAKE_BREAD, "achievement.makeBread"); - register(Achievement.MAKE_CAKE, "achievement.bakeCake"); - register(Achievement.MAKE_IRON_PICKAXE, "achievement.buildBetterPickaxe"); - register(Achievement.COOK_FISH, "achievement.cookFish"); - register(Achievement.RIDE_MINECART_1000_BLOCKS, "achievement.onARail"); - register(Achievement.MAKE_SWORD, "achievement.buildSword"); - register(Achievement.KILL_ENEMY, "achievement.killEnemy"); - register(Achievement.KILL_COW, "achievement.killCow"); - register(Achievement.FLY_PIG, "achievement.flyPig"); - register(Achievement.SNIPE_SKELETON, "achievement.snipeSkeleton"); - register(Achievement.GET_DIAMONDS, "achievement.diamonds"); - register(Achievement.GIVE_DIAMONDS, "achievement.diamondsToYou"); - register(Achievement.ENTER_PORTAL, "achievement.portal"); - register(Achievement.ATTACKED_BY_GHAST, "achievement.ghast"); - register(Achievement.GET_BLAZE_ROD, "achievement.blazeRod"); - register(Achievement.MAKE_POTION, "achievement.potion"); - register(Achievement.GO_TO_THE_END, "achievement.theEnd"); - register(Achievement.DEFEAT_ENDER_DRAGON, "achievement.theEnd2"); - register(Achievement.DEAL_18_OR_MORE_DAMAGE, "achievement.overkill"); - register(Achievement.MAKE_BOOKCASE, "achievement.bookcase"); - register(Achievement.BREED_COW, "achievement.breedCow"); - register(Achievement.SPAWN_WITHER, "achievement.spawnWither"); - register(Achievement.KILL_WITHER, "achievement.killWither"); - register(Achievement.MAKE_FULL_BEACON, "achievement.fullBeacon"); - register(Achievement.EXPLORE_ALL_BIOMES, "achievement.exploreAllBiomes"); - - register(GenericStatistic.TIMES_LEFT_GAME, "stat.leaveGame"); - register(GenericStatistic.MINUTES_PLAYED, "stat.playOneMinute"); - register(GenericStatistic.BLOCKS_WALKED, "stat.walkOneCm"); - register(GenericStatistic.BLOCKS_SWAM, "stat.swimOneCm"); - register(GenericStatistic.BLOCKS_FALLEN, "stat.fallOneCm"); - register(GenericStatistic.BLOCKS_CLIMBED, "stat.climbOneCm"); - register(GenericStatistic.BLOCKS_FLOWN, "stat.flyOneCm"); - register(GenericStatistic.BLOCKS_DOVE, "stat.diveOneCm"); - register(GenericStatistic.BLOCKS_TRAVELLED_IN_MINECART, "stat.minecartOneCm"); - register(GenericStatistic.BLOCKS_TRAVELLED_IN_BOAT, "stat.boatOneCm"); - register(GenericStatistic.BLOCKS_RODE_ON_PIG, "stat.pigOneCm"); - register(GenericStatistic.BLOCKS_RODE_ON_HORSE, "stat.horseOneCm"); - register(GenericStatistic.TIMES_JUMPED, "stat.jump"); - register(GenericStatistic.TIMES_DROPPED_ITEMS, "stat.drop"); - register(GenericStatistic.TIMES_DEALT_DAMAGE, "stat.damageDealt"); - register(GenericStatistic.DAMAGE_TAKEN, "stat.damageTaken"); - register(GenericStatistic.DEATHS, "stat.deaths"); - register(GenericStatistic.MOB_KILLS, "stat.mobKills"); - register(GenericStatistic.ANIMALS_BRED, "stat.animalsBred"); - register(GenericStatistic.PLAYERS_KILLED, "stat.playerKills"); - register(GenericStatistic.FISH_CAUGHT, "stat.fishCaught"); - register(GenericStatistic.JUNK_FISHED, "stat.junkFished"); - register(GenericStatistic.TREASURE_FISHED, "stat.treasureFished"); - - register(Particle.EXPLOSION_NORMAL, 0); - register(Particle.EXPLOSION_LARGE, 1); - register(Particle.EXPLOSION_HUGE, 2); - register(Particle.FIREWORKS_SPARK, 3); - register(Particle.WATER_BUBBLE, 4); - register(Particle.WATER_SPLASH, 5); - register(Particle.WATER_WAKE, 6); - register(Particle.SUSPENDED, 7); - register(Particle.SUSPENDED_DEPTH, 8); - register(Particle.CRIT, 9); - register(Particle.CRIT_MAGIC, 10); - register(Particle.SMOKE_NORMAL, 11); - register(Particle.SMOKE_LARGE, 12); - register(Particle.SPELL, 13); - register(Particle.SPELL_INSTANT, 14); - register(Particle.SPELL_MOB, 15); - register(Particle.SPELL_MOB_AMBIENT, 16); - register(Particle.SPELL_WITCH, 17); - register(Particle.DRIP_WATER, 18); - register(Particle.DRIP_LAVA, 19); - register(Particle.VILLAGER_ANGRY, 20); - register(Particle.VILLAGER_HAPPY, 21); - register(Particle.TOWN_AURA, 22); - register(Particle.NOTE, 23); - register(Particle.PORTAL, 24); - register(Particle.ENCHANTMENT_TABLE, 25); - register(Particle.FLAME, 26); - register(Particle.LAVA, 27); - register(Particle.FOOTSTEP, 28); - register(Particle.CLOUD, 29); - register(Particle.REDSTONE, 30); - register(Particle.SNOWBALL, 31); - register(Particle.SNOW_SHOVEL, 32); - register(Particle.SLIME, 33); - register(Particle.HEART, 34); - register(Particle.BARRIER, 35); - register(Particle.ICON_CRACK, 36); - register(Particle.BLOCK_CRACK, 37); - register(Particle.BLOCK_DUST, 38); - register(Particle.WATER_DROP, 39); - register(Particle.ITEM_TAKE, 40); - register(Particle.MOB_APPEARANCE, 41); - - register(GenericSound.CLICK, "random.click"); - register(GenericSound.FIZZ, "random.fizz"); - register(GenericSound.FIRE_AMBIENT, "fire.fire"); - register(GenericSound.IGNITE_FIRE, "fire.ignite"); - register(GenericSound.WATER_AMBIENT, "liquid.water"); - register(GenericSound.LAVA_AMBIENT, "liquid.lava"); - register(GenericSound.LAVA_POP, "liquid.lavapop"); - register(GenericSound.HARP, "note.harp"); - register(GenericSound.BASS_DRUM, "note.bd"); - register(GenericSound.SNARE_DRUM, "note.snare"); - register(GenericSound.HI_HAT, "note.hat"); - register(GenericSound.DOUBLE_BASS, "note.bassattack"); - register(GenericSound.PISTON_EXTEND, "tile.piston.out"); - register(GenericSound.PISTON_RETRACT, "tile.piston.in"); - register(GenericSound.PORTAL_AMBIENT, "portal.portal"); - register(GenericSound.TNT_PRIMED, "game.tnt.primed"); - register(GenericSound.BOW_HIT, "random.bowhit"); - register(GenericSound.COLLECT_ITEM, "random.pop"); - register(GenericSound.COLLECT_EXP, "random.orb"); - register(GenericSound.SUCCESSFUL_HIT, "random.successful_hit"); - register(GenericSound.FIREWORK_BLAST, "fireworks.blast"); - register(GenericSound.FIREWORK_LARGE_BLAST, "fireworks.largeBlast"); - register(GenericSound.FIREWORK_FAR_BLAST, "fireworks.blast_far"); - register(GenericSound.FIREWORK_FAR_LARGE_BLAST, "fireworks.largeBlast_far"); - register(GenericSound.FIREWORK_TWINKLE, "fireworks.twinkle"); - register(GenericSound.FIREWORK_FAR_TWINKLE, "fireworks.twinkle_far"); - register(GenericSound.RAIN_AMBIENT, "ambient.weather.rain"); - register(GenericSound.WITHER_SPAWN, "mob.wither.spawn"); - register(GenericSound.ENDER_DRAGON_DEATH, "mob.enderdragon.end"); - register(GenericSound.FIRE_PROJECTILE, "random.bow"); - register(GenericSound.DOOR_OPEN, "random.door_open"); - register(GenericSound.DOOR_CLOSE, "random.door_close"); - register(GenericSound.GHAST_CHARGE, "mob.ghast.charge"); - register(GenericSound.GHAST_FIRE, "mob.ghast.fireball"); - register(GenericSound.POUND_WOODEN_DOOR, "mob.zombie.wood"); - register(GenericSound.POUND_METAL_DOOR, "mob.zombie.metal"); - register(GenericSound.BREAK_WOODEN_DOOR, "mob.zombie.woodbreak"); - register(GenericSound.WITHER_SHOOT, "mob.wither.shoot"); - register(GenericSound.BAT_TAKE_OFF, "mob.bat.takeoff"); - register(GenericSound.INFECT_VILLAGER, "mob.zombie.infect"); - register(GenericSound.DISINFECT_VILLAGER, "mob.zombie.unfect"); - register(GenericSound.ANVIL_BREAK, "random.anvil_break"); - register(GenericSound.ANVIL_USE, "random.anvil_use"); - register(GenericSound.ANVIL_LAND, "random.anvil_land"); - register(GenericSound.BREAK_SPLASH_POTION, "game.potion.smash"); - register(GenericSound.THORNS_DAMAGE, "damage.thorns"); - register(GenericSound.EXPLOSION, "random.explode"); - register(GenericSound.CAVE_AMBIENT, "ambient.cave.cave"); - register(GenericSound.OPEN_CHEST, "random.chestopen"); - register(GenericSound.CLOSE_CHEST, "random.chestclosed"); - register(GenericSound.DIG_STONE, "dig.stone"); - register(GenericSound.DIG_WOOD, "dig.wood"); - register(GenericSound.DIG_GRAVEL, "dig.gravel"); - register(GenericSound.DIG_GRASS, "dig.grass"); - register(GenericSound.DIG_CLOTH, "dig.cloth"); - register(GenericSound.DIG_SAND, "dig.sand"); - register(GenericSound.DIG_SNOW, "dig.snow"); - register(GenericSound.DIG_GLASS, "dig.glass"); - register(GenericSound.ANVIL_STEP, "step.anvil"); - register(GenericSound.LADDER_STEP, "step.ladder"); - register(GenericSound.STONE_STEP, "step.stone"); - register(GenericSound.WOOD_STEP, "step.wood"); - register(GenericSound.GRAVEL_STEP, "step.gravel"); - register(GenericSound.GRASS_STEP, "step.grass"); - register(GenericSound.CLOTH_STEP, "step.cloth"); - register(GenericSound.SAND_STEP, "step.sand"); - register(GenericSound.SNOW_STEP, "step.snow"); - register(GenericSound.BURP, "random.burp"); - register(GenericSound.SADDLE_HORSE, "mob.horse.leather"); - register(GenericSound.ENDER_DRAGON_FLAP_WINGS, "mob.enderdragon.wings"); - register(GenericSound.THUNDER_AMBIENT, "ambient.weather.thunder"); - register(GenericSound.LAUNCH_FIREWORKS, "fireworks.launch"); - register(GenericSound.CREEPER_PRIMED, "creeper.primed"); - register(GenericSound.ENDERMAN_STARE, "mob.endermen.stare"); - register(GenericSound.ENDERMAN_TELEPORT, "mob.endermen.portal"); - register(GenericSound.IRON_GOLEM_THROW, "mob.irongolem.throw"); - register(GenericSound.IRON_GOLEM_WALK, "mob.irongolem.walk"); - register(GenericSound.ZOMBIE_PIGMAN_ANGRY, "mob.zombiepig.zpigangry"); - register(GenericSound.SILVERFISH_STEP, "mob.silverfish.step"); - register(GenericSound.SKELETON_STEP, "mob.skeleton.step"); - register(GenericSound.SPIDER_STEP, "mob.spider.step"); - register(GenericSound.ZOMBIE_STEP, "mob.zombie.step"); - register(GenericSound.ZOMBIE_CURE, "mob.zombie.remedy"); - register(GenericSound.CHICKEN_LAY_EGG, "mob.chicken.plop"); - register(GenericSound.CHICKEN_STEP, "mob.chicken.step"); - register(GenericSound.COW_STEP, "mob.cow.step"); - register(GenericSound.HORSE_EATING, "eating"); - register(GenericSound.HORSE_LAND, "mob.horse.land"); - register(GenericSound.HORSE_WEAR_ARMOR, "mob.horse.armor"); - register(GenericSound.HORSE_GALLOP, "mob.horse.gallop"); - register(GenericSound.HORSE_BREATHE, "mob.horse.breathe"); - register(GenericSound.HORSE_WOOD_STEP, "mob.horse.wood"); - register(GenericSound.HORSE_SOFT_STEP, "mob.horse.soft"); - register(GenericSound.HORSE_JUMP, "mob.horse.jump"); - register(GenericSound.SHEAR_SHEEP, "mob.sheep.shear"); - register(GenericSound.PIG_STEP, "mob.pig.step"); - register(GenericSound.SHEEP_STEP, "mob.sheep.step"); - register(GenericSound.VILLAGER_YES, "mob.villager.yes"); - register(GenericSound.VILLAGER_NO, "mob.villager.no"); - register(GenericSound.WOLF_STEP, "mob.wolf.step"); - register(GenericSound.WOLF_SHAKE, "mob.wolf.shake"); - register(GenericSound.DRINK, "random.drink"); - register(GenericSound.EAT, "random.eat"); - register(GenericSound.LEVEL_UP, "random.levelup"); - register(GenericSound.FISH_HOOK_SPLASH, "random.splash"); - register(GenericSound.ITEM_BREAK, "random.break"); - register(GenericSound.SWIM, "game.neutral.swim"); - register(GenericSound.SPLASH, "game.neutral.swim.splash"); - register(GenericSound.HURT, "game.neutral.hurt"); - register(GenericSound.DEATH, "game.neutral.die"); - register(GenericSound.BIG_FALL, "game.neutral.hurt.fall.big"); - register(GenericSound.SMALL_FALL, "game.neutral.hurt.fall.small"); - register(GenericSound.MOB_SWIM, "game.hostile.swim"); - register(GenericSound.MOB_SPLASH, "game.hostile.swim.splash"); - register(GenericSound.PLAYER_SWIM, "game.player.swim"); - register(GenericSound.PLAYER_SPLASH, "game.player.swim.splash"); - register(GenericSound.ENDER_DRAGON_GROWL, "mob.enderdragon.growl"); - register(GenericSound.WITHER_IDLE, "mob.wither.idle"); - register(GenericSound.BLAZE_BREATHE, "mob.blaze.breathe"); - register(GenericSound.ENDERMAN_SCREAM, "mob.endermen.scream"); - register(GenericSound.ENDERMAN_IDLE, "mob.endermen.idle"); - register(GenericSound.GHAST_MOAN, "mob.ghast.moan"); - register(GenericSound.ZOMBIE_PIGMAN_IDLE, "mob.zombiepig.zpig"); - register(GenericSound.SILVERFISH_IDLE, "mob.silverfish.say"); - register(GenericSound.SKELETON_IDLE, "mob.skeleton.say"); - register(GenericSound.SPIDER_IDLE, "mob.spider.say"); - register(GenericSound.WITCH_IDLE, "mob.witch.idle"); - register(GenericSound.ZOMBIE_IDLE, "mob.zombie.say"); - register(GenericSound.BAT_IDLE, "mob.bat.idle"); - register(GenericSound.CHICKEN_IDLE, "mob.chicken.say"); - register(GenericSound.COW_IDLE, "mob.cow.say"); - register(GenericSound.HORSE_IDLE, "mob.horse.idle"); - register(GenericSound.DONKEY_IDLE, "mob.horse.donkey.idle"); - register(GenericSound.ZOMBIE_HORSE_IDLE, "mob.horse.zombie.idle"); - register(GenericSound.SKELETON_HORSE_IDLE, "mob.horse.skeleton.idle"); - register(GenericSound.OCELOT_PURR, "mob.cat.purr"); - register(GenericSound.OCELOT_PURR_MEOW, "mob.cat.purreow"); - register(GenericSound.OCELOT_MEOW, "mob.cat.meow"); - register(GenericSound.PIG_IDLE, "mob.pig.say"); - register(GenericSound.SHEEP_IDLE, "mob.sheep.say"); - register(GenericSound.VILLAGER_HAGGLE, "mob.villager.haggle"); - register(GenericSound.VILLAGER_IDLE, "mob.villager.idle"); - register(GenericSound.WOLF_GROWL, "mob.wolf.growl"); - register(GenericSound.WOLF_PANT, "mob.wolf.panting"); - register(GenericSound.WOLF_WHINE, "mob.wolf.whine"); - register(GenericSound.WOLF_BARK, "mob.wolf.bark"); - register(GenericSound.MOB_BIG_FALL, "game.hostile.hurt.fall.big"); - register(GenericSound.MOB_SMALL_FALL, "game.hostile.hurt.fall.small"); - register(GenericSound.PLAYER_BIG_FALL, "game.player.hurt.fall.big"); - register(GenericSound.PLAYER_SMALL_FALL, "game.player.hurt.fall.small"); - register(GenericSound.ENDER_DRAGON_HURT, "mob.enderdragon.hit"); - register(GenericSound.WITHER_HURT, "mob.wither.hurt"); - register(GenericSound.WITHER_DEATH, "mob.wither.death"); - register(GenericSound.BLAZE_HURT, "mob.blaze.hit"); - register(GenericSound.BLAZE_DEATH, "mob.blaze.death"); - register(GenericSound.CREEPER_HURT, "mob.creeper.say"); - register(GenericSound.CREEPER_DEATH, "mob.creeper.death"); - register(GenericSound.ENDERMAN_HURT, "mob.endermen.hit"); - register(GenericSound.ENDERMAN_DEATH, "mob.endermen.death"); - register(GenericSound.GHAST_HURT, "mob.ghast.scream"); - register(GenericSound.GHAST_DEATH, "mob.ghast.death"); - register(GenericSound.IRON_GOLEM_HURT, "mob.irongolem.hit"); - register(GenericSound.IRON_GOLEM_DEATH, "mob.irongolem.death"); - register(GenericSound.MOB_HURT, "game.hostile.hurt"); - register(GenericSound.MOB_DEATH, "game.hostile.die"); - register(GenericSound.ZOMBIE_PIGMAN_HURT, "mob.zombiepig.zpighurt"); - register(GenericSound.ZOMBIE_PIGMAN_DEATH, "mob.zombiepig.zpigdeath"); - register(GenericSound.SILVERFISH_HURT, "mob.silverfish.hit"); - register(GenericSound.SILVERFISH_DEATH, "mob.silverfish.kill"); - register(GenericSound.SKELETON_HURT, "mob.skeleton.hurt"); - register(GenericSound.SKELETON_DEATH, "mob.skeleton.death"); - register(GenericSound.SLIME, "mob.slime.small"); - register(GenericSound.BIG_SLIME, "mob.slime.big"); - register(GenericSound.SPIDER_DEATH, "mob.spider.death"); - register(GenericSound.WITCH_HURT, "mob.witch.hurt"); - register(GenericSound.WITCH_DEATH, "mob.witch.death"); - register(GenericSound.ZOMBIE_HURT, "mob.zombie.hurt"); - register(GenericSound.ZOMBIE_DEATH, "mob.zombie.death"); - register(GenericSound.PLAYER_HURT, "game.player.hurt"); - register(GenericSound.PLAYER_DEATH, "game.player.die"); - register(GenericSound.WOLF_HURT, "mob.wolf.hurt"); - register(GenericSound.WOLF_DEATH, "mob.wolf.death"); - register(GenericSound.VILLAGER_HURT, "mob.villager.hit"); - register(GenericSound.VILLAGER_DEATH, "mob.villager.death"); - register(GenericSound.PIG_DEATH, "mob.pig.death"); - register(GenericSound.OCELOT_HURT, "mob.cat.hitt"); - register(GenericSound.HORSE_HURT, "mob.horse.hit"); - register(GenericSound.DONKEY_HURT, "mob.horse.donkey.hit"); - register(GenericSound.ZOMBIE_HORSE_HURT, "mob.horse.zombie.hit"); - register(GenericSound.SKELETON_HORSE_HURT, "mob.horse.skeleton.hit"); - register(GenericSound.HORSE_DEATH, "mob.horse.death"); - register(GenericSound.DONKEY_DEATH, "mob.horse.donkey.death"); - register(GenericSound.ZOMBIE_HORSE_DEATH, "mob.horse.zombie.death"); - register(GenericSound.SKELETON_HORSE_DEATH, "mob.horse.skeleton.death"); - register(GenericSound.COW_HURT, "mob.cow.hurt"); - register(GenericSound.CHICKEN_HURT, "mob.chicken.hurt"); - register(GenericSound.BAT_HURT, "mob.bat.hurt"); - register(GenericSound.BAT_DEATH, "mob.bat.death"); - register(GenericSound.RABBIT_HURT, "mob.rabbit.hurt"); - register(GenericSound.RABBIT_HOP, "mob.rabbit.hop"); - register(GenericSound.RABBIT_IDLE, "mob.rabbit.idle"); - register(GenericSound.RABBIT_DEATH, "mob.rabbit.death"); - register(GenericSound.MOB_ATTACK, "mob.attack"); - - register(NoteBlockValueType.HARP, 0); - register(NoteBlockValueType.DOUBLE_BASS, 1); - register(NoteBlockValueType.SNARE_DRUM, 2); - register(NoteBlockValueType.HI_HAT, 3); - register(NoteBlockValueType.BASS_DRUM, 4); - - register(PistonValueType.PUSHING, 0); - register(PistonValueType.PULLING, 1); - - register(MobSpawnerValueType.RESET_DELAY, 1); - - register(ChestValueType.VIEWING_PLAYER_COUNT, 1); - - register(GenericBlockValueType.GENERIC, 1); - - register(PistonValue.DOWN, 0); - register(PistonValue.UP, 1); - register(PistonValue.SOUTH, 2); - register(PistonValue.WEST, 3); - register(PistonValue.NORTH, 4); - register(PistonValue.EAST, 5); - - register(SoundEffect.CLICK, 1000); - register(SoundEffect.EMPTY_DISPENSER_CLICK, 1001); - register(SoundEffect.FIRE_PROJECTILE, 1002); - register(SoundEffect.DOOR, 1003); - register(SoundEffect.FIZZLE, 1004); - register(SoundEffect.PLAY_RECORD, 1005); - register(SoundEffect.GHAST_CHARGE, 1007); - register(SoundEffect.GHAST_FIRE, 1008); - register(SoundEffect.BLAZE_FIRE, 1009); - register(SoundEffect.POUND_WOODEN_DOOR, 1010); - register(SoundEffect.POUND_METAL_DOOR, 1011); - register(SoundEffect.BREAK_WOODEN_DOOR, 1012); - register(SoundEffect.WITHER_SPAWN, 1013); - register(SoundEffect.WITHER_SHOOT, 1014); - register(SoundEffect.BAT_TAKE_OFF, 1015); - register(SoundEffect.INFECT_VILLAGER, 1016); - register(SoundEffect.DISINFECT_VILLAGER, 1017); - register(SoundEffect.ENDER_DRAGON_DEATH, 1018); - register(SoundEffect.ANVIL_BREAK, 1020); - register(SoundEffect.ANVIL_USE, 1021); - register(SoundEffect.ANVIL_LAND, 1022); - - register(ParticleEffect.SMOKE, 2000); - register(ParticleEffect.BREAK_BLOCK, 2001); - register(ParticleEffect.BREAK_SPLASH_POTION, 2002); - register(ParticleEffect.BREAK_EYE_OF_ENDER, 2003); - register(ParticleEffect.MOB_SPAWN, 2004); - register(ParticleEffect.BONEMEAL_GROW, 2005); - register(ParticleEffect.HARD_LANDING_DUST, 2006); - - register(SmokeEffectData.SOUTH_EAST, 0); - register(SmokeEffectData.SOUTH, 1); - register(SmokeEffectData.SOUTH_WEST, 2); - register(SmokeEffectData.EAST, 3); - register(SmokeEffectData.UP, 4); - register(SmokeEffectData.WEST, 5); - register(SmokeEffectData.NORTH_EAST, 6); - register(SmokeEffectData.NORTH, 7); - register(SmokeEffectData.NORTH_WEST, 8); - - register(NameTagVisibility.ALWAYS, "always"); - register(NameTagVisibility.NEVER, "never"); - register(NameTagVisibility.HIDE_FOR_OTHER_TEAMS, "hideForOtherTeams"); - register(NameTagVisibility.HIDE_FOR_OWN_TEAM, "hideForOwnTeam"); - - register(TeamColor.NONE, -1); - register(TeamColor.BLACK, 0); - register(TeamColor.DARK_BLUE, 1); - register(TeamColor.DARK_GREEN, 2); - register(TeamColor.DARK_AQUA, 3); - register(TeamColor.DARK_RED, 4); - register(TeamColor.DARK_PURPLE, 5); - register(TeamColor.GOLD, 6); - register(TeamColor.GRAY, 7); - register(TeamColor.DARK_GRAY, 8); - register(TeamColor.BLUE, 9); - register(TeamColor.GREEN, 10); - register(TeamColor.AQUA, 11); - register(TeamColor.RED, 12); - register(TeamColor.LIGHT_PURPLE, 13); - register(TeamColor.YELLOW, 14); - register(TeamColor.WHITE, 15); - - register(ScoreType.INTEGER, "integer"); - register(ScoreType.HEARTS, "hearts"); - - register(WorldBorderAction.SET_SIZE, 0); - register(WorldBorderAction.LERP_SIZE, 1); - register(WorldBorderAction.SET_CENTER, 2); - register(WorldBorderAction.INITIALIZE, 3); - register(WorldBorderAction.SET_WARNING_TIME, 4); - register(WorldBorderAction.SET_WARNING_BLOCKS, 5); - - register(PlayerListEntryAction.ADD_PLAYER, 0); - register(PlayerListEntryAction.UPDATE_GAMEMODE, 1); - register(PlayerListEntryAction.UPDATE_LATENCY, 2); - register(PlayerListEntryAction.UPDATE_DISPLAY_NAME, 3); - register(PlayerListEntryAction.REMOVE_PLAYER, 4); - - register(TitleAction.TITLE, 0); - register(TitleAction.SUBTITLE, 1); - register(TitleAction.TIMES, 2); - register(TitleAction.CLEAR, 3); - register(TitleAction.RESET, 4); - - register(ResourcePackStatus.SUCCESSFULLY_LOADED, 0); - register(ResourcePackStatus.DECLINED, 1); - register(ResourcePackStatus.FAILED_DOWNLOAD, 2); - register(ResourcePackStatus.ACCEPTED, 3); - } - - private static void register(Enum key, Object value) { - values.put(key, value); - } - - @SuppressWarnings({ "unchecked" }) - public static > T key(Class keyType, Object value) { - for(Enum key : values.keySet()) { - Object val = values.get(key); - if(keyType.isAssignableFrom(key.getClass())) { - if(val == value || val.equals(value)) { - return (T) key; - } else if(Number.class.isAssignableFrom(val.getClass()) && Number.class.isAssignableFrom(value.getClass())) { - Number num = (Number) val; - Number num2 = (Number) value; - if(num.doubleValue() == num2.doubleValue()) { - return (T) key; - } - } - } - } - - return null; - } - - @SuppressWarnings("unchecked") - public static T value(Class valueType, Enum key) { - Object val = values.get(key); - if(val != null) { - if(valueType.isAssignableFrom(val.getClass())) { - return (T) val; - } else if(Number.class.isAssignableFrom(val.getClass())) { - if(valueType == Byte.class) { - return (T) (Object) ((Number) val).byteValue(); - } else if(valueType == Short.class) { - return (T) (Object) ((Number) val).shortValue(); - } else if(valueType == Integer.class) { - return (T) (Object) ((Number) val).intValue(); - } else if(valueType == Long.class) { - return (T) (Object) ((Number) val).longValue(); - } else if(valueType == Float.class) { - return (T) (Object) ((Number) val).floatValue(); - } else if(valueType == Double.class) { - return (T) (Object) ((Number) val).doubleValue(); - } - } - } - - return null; - } + private static final Map, Object> values = new HashMap, Object>(); + + static { + register(AttributeType.MAX_HEALTH, "generic.maxHealth"); + register(AttributeType.FOLLOW_RANGE, "generic.followRange"); + register(AttributeType.KNOCKBACK_RESISTANCE, "generic.knockbackResistance"); + register(AttributeType.MOVEMENT_SPEED, "generic.movementSpeed"); + register(AttributeType.ATTACK_DAMAGE, "generic.attackDamage"); + register(AttributeType.HORSE_JUMP_STRENGTH, "horse.jumpStrength"); + register(AttributeType.ZOMBIE_SPAWN_REINFORCEMENTS_CHANCE, "zombie.spawnReinforcements"); + + register(ModifierType.CREATURE_FLEE_SPEED_BONUS, UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A")); + register(ModifierType.ENDERMAN_ATTACK_SPEED_BOOST, UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0")); + register(ModifierType.SPRINT_SPEED_BOOST, UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D")); + register(ModifierType.PIGZOMBIE_ATTACK_SPEED_BOOST, UUID.fromString("49455A49-7EC5-45BA-B886-3B90B23A1718")); + register(ModifierType.WITCH_DRINKING_SPEED_PENALTY, UUID.fromString("5CD17E52-A79A-43D3-A529-90FDE04B181E")); + register(ModifierType.ZOMBIE_BABY_SPEED_BOOST, UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836")); + register(ModifierType.ITEM_MODIFIER, UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF")); + register(ModifierType.SPEED_POTION_MODIFIER, UUID.fromString("91AEAA56-376B-4498-935B-2F7F68070635")); + register(ModifierType.HEALTH_BOOST_POTION_MODIFIER, UUID.fromString("5D6F0BA2-1186-46AC-B896-C61C5CEE99CC")); + register(ModifierType.SLOW_POTION_MODIFIER, UUID.fromString("7107DE5E-7CE8-4030-940E-514C1F160890")); + register(ModifierType.STRENGTH_POTION_MODIFIER, UUID.fromString("648D7064-6A60-4F59-8ABE-C2C23A6DD7A9")); + register(ModifierType.WEAKNESS_POTION_MODIFIER, UUID.fromString("22653B89-116E-49DC-9B6B-9971489B5BE5")); + + register(ModifierOperation.ADD, 0); + register(ModifierOperation.ADD_MULTIPLIED, 1); + register(ModifierOperation.MULTIPLY, 2); + + register(MetadataType.BYTE, 0); + register(MetadataType.SHORT, 1); + register(MetadataType.INT, 2); + register(MetadataType.FLOAT, 3); + register(MetadataType.STRING, 4); + register(MetadataType.ITEM, 5); + register(MetadataType.POSITION, 6); + register(MetadataType.ROTATION, 7); + + register(HandshakeIntent.STATUS, 1); + register(HandshakeIntent.LOGIN, 2); + + register(ClientRequest.RESPAWN, 0); + register(ClientRequest.STATS, 1); + register(ClientRequest.OPEN_INVENTORY_ACHIEVEMENT, 2); + + register(ChatVisibility.FULL, 0); + register(ChatVisibility.SYSTEM, 1); + register(ChatVisibility.HIDDEN, 2); + + register(PlayerState.START_SNEAKING, 0); + register(PlayerState.STOP_SNEAKING, 1); + register(PlayerState.LEAVE_BED, 2); + register(PlayerState.START_SPRINTING, 3); + register(PlayerState.STOP_SPRINTING, 4); + register(PlayerState.RIDING_JUMP, 5); + register(PlayerState.OPEN_INVENTORY, 6); + + register(InteractAction.INTERACT, 0); + register(InteractAction.ATTACK, 1); + register(InteractAction.INTERACT_AT, 2); + + register(PlayerAction.START_DIGGING, 0); + register(PlayerAction.CANCEL_DIGGING, 1); + register(PlayerAction.FINISH_DIGGING, 2); + register(PlayerAction.DROP_ITEM_STACK, 3); + register(PlayerAction.DROP_ITEM, 4); + register(PlayerAction.RELEASE_USE_ITEM, 5); + + register(Face.BOTTOM, 0); + register(Face.TOP, 1); + register(Face.EAST, 2); + register(Face.WEST, 3); + register(Face.NORTH, 4); + register(Face.SOUTH, 5); + register(Face.INVALID, 255); + + register(WindowAction.CLICK_ITEM, 0); + register(WindowAction.SHIFT_CLICK_ITEM, 1); + register(WindowAction.MOVE_TO_HOTBAR_SLOT, 2); + register(WindowAction.CREATIVE_GRAB_MAX_STACK, 3); + register(WindowAction.DROP_ITEM, 4); + register(WindowAction.SPREAD_ITEM, 5); + register(WindowAction.FILL_STACK, 6); + + register(ClickItemParam.LEFT_CLICK, 0); + register(ClickItemParam.RIGHT_CLICK, 1); + + register(ShiftClickItemParam.LEFT_CLICK, 0); + register(ShiftClickItemParam.RIGHT_CLICK, 1); + + register(MoveToHotbarParam.SLOT_1, 0); + register(MoveToHotbarParam.SLOT_2, 1); + register(MoveToHotbarParam.SLOT_3, 2); + register(MoveToHotbarParam.SLOT_4, 3); + register(MoveToHotbarParam.SLOT_5, 4); + register(MoveToHotbarParam.SLOT_6, 5); + register(MoveToHotbarParam.SLOT_7, 6); + register(MoveToHotbarParam.SLOT_8, 7); + register(MoveToHotbarParam.SLOT_9, 8); + + register(CreativeGrabParam.GRAB, 2); + + register(DropItemParam.LEFT_CLICK_OUTSIDE_NOT_HOLDING, 0); + register(DropItemParam.RIGHT_CLICK_OUTSIDE_NOT_HOLDING, 1); + register(DropItemParam.DROP_FROM_SELECTED, 2); + register(DropItemParam.DROP_SELECTED_STACK, 3); + + register(SpreadItemParam.LEFT_MOUSE_BEGIN_DRAG, 0); + register(SpreadItemParam.LEFT_MOUSE_ADD_SLOT, 1); + register(SpreadItemParam.LEFT_MOUSE_END_DRAG, 2); + register(SpreadItemParam.RIGHT_MOUSE_BEGIN_DRAG, 4); + register(SpreadItemParam.RIGHT_MOUSE_ADD_SLOT, 5); + register(SpreadItemParam.RIGHT_MOUSE_END_DRAG, 6); + + register(FillStackParam.FILL, 0); + + register(MessageType.CHAT, 0); + register(MessageType.SYSTEM, 1); + register(MessageType.NOTIFICATION, 2); + + register(CombatState.ENTER_COMBAT, 0); + register(CombatState.END_COMBAT, 1); + register(CombatState.ENTITY_DEAD, 2); + + register(GameMode.SURVIVAL, 0); + register(GameMode.CREATIVE, 1); + register(GameMode.ADVENTURE, 2); + register(GameMode.SPECTATOR, 3); + + register(Difficulty.PEACEFUL, 0); + register(Difficulty.EASY, 1); + register(Difficulty.NORMAL, 2); + register(Difficulty.HARD, 3); + + register(WorldType.DEFAULT, "default"); + register(WorldType.FLAT, "flat"); + register(WorldType.LARGE_BIOMES, "largebiomes"); + register(WorldType.AMPLIFIED, "amplified"); + register(WorldType.CUSTOMIZED, "customized"); + register(WorldType.DEBUG, "debug_all_block_states"); + register(WorldType.DEFAULT_1_1, "default_1_1"); + + register(Animation.SWING_ARM, 0); + register(Animation.DAMAGE, 1); + register(Animation.LEAVE_BED, 2); + register(Animation.EAT_FOOD, 3); + register(Animation.CRITICAL_HIT, 4); + register(Animation.ENCHANTMENT_CRITICAL_HIT, 5); + + register(Effect.SPEED, 1); + register(Effect.SLOWNESS, 2); + register(Effect.DIG_SPEED, 3); + register(Effect.DIG_SLOWNESS, 4); + register(Effect.DAMAGE_BOOST, 5); + register(Effect.HEAL, 6); + register(Effect.DAMAGE, 7); + register(Effect.JUMP_BOOST, 8); + register(Effect.CONFUSION, 9); + register(Effect.REGENERATION, 10); + register(Effect.RESISTANCE, 11); + register(Effect.FIRE_RESISTANCE, 12); + register(Effect.WATER_BREATHING, 13); + register(Effect.INVISIBILITY, 14); + register(Effect.BLINDNESS, 15); + register(Effect.NIGHT_VISION, 16); + register(Effect.HUNGER, 17); + register(Effect.WEAKNESS, 18); + register(Effect.POISON, 19); + register(Effect.WITHER_EFFECT, 20); + register(Effect.HEALTH_BOOST, 21); + register(Effect.ABSORPTION, 22); + register(Effect.SATURATION, 23); + + register(EntityStatus.HURT_OR_MINECART_SPAWNER_DELAY_RESET, 1); + register(EntityStatus.LIVING_HURT, 2); + register(EntityStatus.DEAD, 3); + register(EntityStatus.IRON_GOLEM_THROW, 4); + register(EntityStatus.TAMING, 6); + register(EntityStatus.TAMED, 7); + register(EntityStatus.WOLF_SHAKING, 8); + register(EntityStatus.FINISHED_EATING, 9); + register(EntityStatus.SHEEP_GRAZING_OR_TNT_CART_EXPLODING, 10); + register(EntityStatus.IRON_GOLEM_ROSE, 11); + register(EntityStatus.VILLAGER_HEARTS, 12); + register(EntityStatus.VILLAGER_ANGRY, 13); + register(EntityStatus.VILLAGER_HAPPY, 14); + register(EntityStatus.WITCH_MAGIC_PARTICLES, 15); + register(EntityStatus.ZOMBIE_VILLAGER_SHAKING, 16); + register(EntityStatus.FIREWORK_EXPLODING, 17); + register(EntityStatus.ANIMAL_HEARTS, 18); + register(EntityStatus.RESET_SQUID_ROTATION, 19); + register(EntityStatus.EXPLOSION_PARTICLE, 20); + register(EntityStatus.GUARDIAN_SOUND, 21); + register(EntityStatus.ENABLE_REDUCED_DEBUG, 22); + register(EntityStatus.DISABLE_REDUCED_DEBUG, 23); + + register(PositionElement.X, 0); + register(PositionElement.Y, 1); + register(PositionElement.Z, 2); + register(PositionElement.PITCH, 3); + register(PositionElement.YAW, 4); + + register(GlobalEntityType.LIGHTNING_BOLT, 1); + + register(MobType.ARMOR_STAND, 30); + register(MobType.CREEPER, 50); + register(MobType.SKELETON, 51); + register(MobType.SPIDER, 52); + register(MobType.GIANT_ZOMBIE, 53); + register(MobType.ZOMBIE, 54); + register(MobType.SLIME, 55); + register(MobType.GHAST, 56); + register(MobType.ZOMBIE_PIGMAN, 57); + register(MobType.ENDERMAN, 58); + register(MobType.CAVE_SPIDER, 59); + register(MobType.SILVERFISH, 60); + register(MobType.BLAZE, 61); + register(MobType.MAGMA_CUBE, 62); + register(MobType.ENDER_DRAGON, 63); + register(MobType.WITHER, 64); + register(MobType.BAT, 65); + register(MobType.WITCH, 66); + register(MobType.ENDERMITE, 67); + register(MobType.GUARDIAN, 68); + register(MobType.PIG, 90); + register(MobType.SHEEP, 91); + register(MobType.COW, 92); + register(MobType.CHICKEN, 93); + register(MobType.SQUID, 94); + register(MobType.WOLF, 95); + register(MobType.MOOSHROOM, 96); + register(MobType.SNOWMAN, 97); + register(MobType.OCELOT, 98); + register(MobType.IRON_GOLEM, 99); + register(MobType.HORSE, 100); + register(MobType.RABBIT, 101); + register(MobType.VILLAGER, 120); + + register(ObjectType.BOAT, 1); + register(ObjectType.ITEM, 2); + register(ObjectType.MINECART, 10); + register(ObjectType.PRIMED_TNT, 50); + register(ObjectType.ENDER_CRYSTAL, 51); + register(ObjectType.ARROW, 60); + register(ObjectType.SNOWBALL, 61); + register(ObjectType.EGG, 62); + register(ObjectType.GHAST_FIREBALL, 63); + register(ObjectType.BLAZE_FIREBALL, 64); + register(ObjectType.ENDER_PEARL, 65); + register(ObjectType.WITHER_HEAD_PROJECTILE, 66); + register(ObjectType.FALLING_BLOCK, 70); + register(ObjectType.ITEM_FRAME, 71); + register(ObjectType.EYE_OF_ENDER, 72); + register(ObjectType.POTION, 73); + register(ObjectType.FALLING_DRAGON_EGG, 74); + register(ObjectType.EXP_BOTTLE, 75); + register(ObjectType.FIREWORK_ROCKET, 76); + register(ObjectType.LEASH_KNOT, 77); + register(ObjectType.ARMOR_STAND, 78); + register(ObjectType.FISH_HOOK, 90); + + register(MinecartType.NORMAL, 0); + register(MinecartType.CHEST, 1); + register(MinecartType.POWERED, 2); + register(MinecartType.TNT, 3); + register(MinecartType.MOB_SPAWNER, 4); + register(MinecartType.HOPPER, 5); + register(MinecartType.COMMAND_BLOCK, 6); + + register(HangingDirection.SOUTH, 0); + register(HangingDirection.WEST, 1); + register(HangingDirection.NORTH, 2); + register(HangingDirection.EAST, 3); + + register(Art.KEBAB, "Kebab"); + register(Art.AZTEC, "Aztec"); + register(Art.ALBAN, "Alban"); + register(Art.AZTEC2, "Aztec2"); + register(Art.BOMB, "Bomb"); + register(Art.PLANT, "Plant"); + register(Art.WASTELAND, "Wasteland"); + register(Art.POOL, "Pool"); + register(Art.COURBET, "Courbet"); + register(Art.SEA, "Sea"); + register(Art.SUNSET, "Sunset"); + register(Art.CREEBET, "Creebet"); + register(Art.WANDERER, "Wanderer"); + register(Art.GRAHAM, "Graham"); + register(Art.MATCH, "Match"); + register(Art.BUST, "Bust"); + register(Art.STAGE, "Stage"); + register(Art.VOID, "Void"); + register(Art.SKULL_AND_ROSES, "SkullAndRoses"); + register(Art.WITHER, "Wither"); + register(Art.FIGHTERS, "Fighters"); + register(Art.POINTER, "Pointer"); + register(Art.PIG_SCENE, "Pigscene"); + register(Art.BURNING_SKULL, "BurningSkull"); + register(Art.SKELETON, "Skeleton"); + register(Art.DONKEY_KONG, "DonkeyKong"); + + register(ScoreboardPosition.PLAYER_LIST, 0); + register(ScoreboardPosition.SIDEBAR, 1); + register(ScoreboardPosition.BELOW_NAME, 2); + register(ScoreboardPosition.SIDEBAR_TEAM_BLACK, 3); + register(ScoreboardPosition.SIDEBAR_TEAM_DARK_BLUE, 4); + register(ScoreboardPosition.SIDEBAR_TEAM_DARK_GREEN, 5); + register(ScoreboardPosition.SIDEBAR_TEAM_DARK_AQUA, 6); + register(ScoreboardPosition.SIDEBAR_TEAM_DARK_RED, 7); + register(ScoreboardPosition.SIDEBAR_TEAM_DARK_PURPLE, 8); + register(ScoreboardPosition.SIDEBAR_TEAM_GOLD, 9); + register(ScoreboardPosition.SIDEBAR_TEAM_GRAY, 10); + register(ScoreboardPosition.SIDEBAR_TEAM_DARK_GRAY, 11); + register(ScoreboardPosition.SIDEBAR_TEAM_BLUE, 12); + register(ScoreboardPosition.SIDEBAR_TEAM_GREEN, 13); + register(ScoreboardPosition.SIDEBAR_TEAM_AQUA, 14); + register(ScoreboardPosition.SIDEBAR_TEAM_RED, 15); + register(ScoreboardPosition.SIDEBAR_TEAM_LIGHT_PURPLE, 16); + register(ScoreboardPosition.SIDEBAR_TEAM_YELLOW, 17); + register(ScoreboardPosition.SIDEBAR_TEAM_WHITE, 18); + + register(ObjectiveAction.ADD, 0); + register(ObjectiveAction.REMOVE, 1); + register(ObjectiveAction.UPDATE, 2); + + register(TeamAction.CREATE, 0); + register(TeamAction.REMOVE, 1); + register(TeamAction.UPDATE, 2); + register(TeamAction.ADD_PLAYER, 3); + register(TeamAction.REMOVE_PLAYER, 4); + + register(ScoreboardAction.ADD_OR_UPDATE, 0); + register(ScoreboardAction.REMOVE, 1); + + register(WindowType.GENERIC_INVENTORY, "minecraft:container"); + register(WindowType.ANVIL, "minecraft:anvil"); + register(WindowType.BEACON, "minecraft:beacon"); + register(WindowType.BREWING_STAND, "minecraft:brewing_stand"); + register(WindowType.CHEST, "minecraft:chest"); + register(WindowType.CRAFTING_TABLE, "minecraft:crafting_table"); + register(WindowType.DISPENSER, "minecraft:dispenser"); + register(WindowType.DROPPER, "minecraft:dropper"); + register(WindowType.ENCHANTING_TABLE, "minecraft:enchanting_table"); + register(WindowType.FURNACE, "minecraft:furnace"); + register(WindowType.HOPPER, "minecraft:hopper"); + register(WindowType.VILLAGER, "minecraft:villager"); + register(WindowType.HORSE, "EntityHorse"); + + register(BrewingStandProperty.BREW_TIME, 0); + + register(EnchantmentTableProperty.LEVEL_SLOT_1, 0); + register(EnchantmentTableProperty.LEVEL_SLOT_2, 1); + register(EnchantmentTableProperty.LEVEL_SLOT_3, 2); + register(EnchantmentTableProperty.XP_SEED, 3); + register(EnchantmentTableProperty.ENCHANTMENT_SLOT_1, 4); + register(EnchantmentTableProperty.ENCHANTMENT_SLOT_2, 5); + register(EnchantmentTableProperty.ENCHANTMENT_SLOT_3, 6); + + register(FurnaceProperty.BURN_TIME, 0); + register(FurnaceProperty.CURRENT_ITEM_BURN_TIME, 1); + register(FurnaceProperty.COOK_TIME, 2); + register(FurnaceProperty.TOTAL_COOK_TIME, 3); + + register(AnvilProperty.MAXIMUM_COST, 0); + + register(BlockBreakStage.RESET, -1); + register(BlockBreakStage.STAGE_1, 0); + register(BlockBreakStage.STAGE_2, 1); + register(BlockBreakStage.STAGE_3, 2); + register(BlockBreakStage.STAGE_4, 3); + register(BlockBreakStage.STAGE_5, 4); + register(BlockBreakStage.STAGE_6, 5); + register(BlockBreakStage.STAGE_7, 6); + register(BlockBreakStage.STAGE_8, 7); + register(BlockBreakStage.STAGE_9, 8); + register(BlockBreakStage.STAGE_10, 9); + register(BlockBreakStage.RESET, 255); + + register(UpdatedTileType.MOB_SPAWNER, 1); + register(UpdatedTileType.COMMAND_BLOCK, 2); + register(UpdatedTileType.BEACON, 3); + register(UpdatedTileType.SKULL, 4); + register(UpdatedTileType.FLOWER_POT, 5); + register(UpdatedTileType.BANNER, 6); + + register(ClientNotification.INVALID_BED, 0); + register(ClientNotification.START_RAIN, 1); + register(ClientNotification.STOP_RAIN, 2); + register(ClientNotification.CHANGE_GAMEMODE, 3); + register(ClientNotification.ENTER_CREDITS, 4); + register(ClientNotification.DEMO_MESSAGE, 5); + register(ClientNotification.ARROW_HIT_PLAYER, 6); + register(ClientNotification.RAIN_STRENGTH, 7); + register(ClientNotification.THUNDER_STRENGTH, 8); + + register(DemoMessageValue.WELCOME, 0); + register(DemoMessageValue.MOVEMENT_CONTROLS, 101); + register(DemoMessageValue.JUMP_CONTROL, 102); + register(DemoMessageValue.INVENTORY_CONTROL, 103); + + register(Achievement.OPEN_INVENTORY, "achievement.openInventory"); + register(Achievement.GET_WOOD, "achievement.mineWood"); + register(Achievement.MAKE_WORKBENCH, "achievement.buildWorkBench"); + register(Achievement.MAKE_PICKAXE, "achievement.buildPickaxe"); + register(Achievement.MAKE_FURNACE, "achievement.buildFurnace"); + register(Achievement.GET_IRON, "achievement.acquireIron"); + register(Achievement.MAKE_HOE, "achievement.buildHoe"); + register(Achievement.MAKE_BREAD, "achievement.makeBread"); + register(Achievement.MAKE_CAKE, "achievement.bakeCake"); + register(Achievement.MAKE_IRON_PICKAXE, "achievement.buildBetterPickaxe"); + register(Achievement.COOK_FISH, "achievement.cookFish"); + register(Achievement.RIDE_MINECART_1000_BLOCKS, "achievement.onARail"); + register(Achievement.MAKE_SWORD, "achievement.buildSword"); + register(Achievement.KILL_ENEMY, "achievement.killEnemy"); + register(Achievement.KILL_COW, "achievement.killCow"); + register(Achievement.FLY_PIG, "achievement.flyPig"); + register(Achievement.SNIPE_SKELETON, "achievement.snipeSkeleton"); + register(Achievement.GET_DIAMONDS, "achievement.diamonds"); + register(Achievement.GIVE_DIAMONDS, "achievement.diamondsToYou"); + register(Achievement.ENTER_PORTAL, "achievement.portal"); + register(Achievement.ATTACKED_BY_GHAST, "achievement.ghast"); + register(Achievement.GET_BLAZE_ROD, "achievement.blazeRod"); + register(Achievement.MAKE_POTION, "achievement.potion"); + register(Achievement.GO_TO_THE_END, "achievement.theEnd"); + register(Achievement.DEFEAT_ENDER_DRAGON, "achievement.theEnd2"); + register(Achievement.DEAL_18_OR_MORE_DAMAGE, "achievement.overkill"); + register(Achievement.MAKE_BOOKCASE, "achievement.bookcase"); + register(Achievement.BREED_COW, "achievement.breedCow"); + register(Achievement.SPAWN_WITHER, "achievement.spawnWither"); + register(Achievement.KILL_WITHER, "achievement.killWither"); + register(Achievement.MAKE_FULL_BEACON, "achievement.fullBeacon"); + register(Achievement.EXPLORE_ALL_BIOMES, "achievement.exploreAllBiomes"); + + register(GenericStatistic.TIMES_LEFT_GAME, "stat.leaveGame"); + register(GenericStatistic.MINUTES_PLAYED, "stat.playOneMinute"); + register(GenericStatistic.BLOCKS_WALKED, "stat.walkOneCm"); + register(GenericStatistic.BLOCKS_SWAM, "stat.swimOneCm"); + register(GenericStatistic.BLOCKS_FALLEN, "stat.fallOneCm"); + register(GenericStatistic.BLOCKS_CLIMBED, "stat.climbOneCm"); + register(GenericStatistic.BLOCKS_FLOWN, "stat.flyOneCm"); + register(GenericStatistic.BLOCKS_DOVE, "stat.diveOneCm"); + register(GenericStatistic.BLOCKS_TRAVELLED_IN_MINECART, "stat.minecartOneCm"); + register(GenericStatistic.BLOCKS_TRAVELLED_IN_BOAT, "stat.boatOneCm"); + register(GenericStatistic.BLOCKS_RODE_ON_PIG, "stat.pigOneCm"); + register(GenericStatistic.BLOCKS_RODE_ON_HORSE, "stat.horseOneCm"); + register(GenericStatistic.TIMES_JUMPED, "stat.jump"); + register(GenericStatistic.TIMES_DROPPED_ITEMS, "stat.drop"); + register(GenericStatistic.TIMES_DEALT_DAMAGE, "stat.damageDealt"); + register(GenericStatistic.DAMAGE_TAKEN, "stat.damageTaken"); + register(GenericStatistic.DEATHS, "stat.deaths"); + register(GenericStatistic.MOB_KILLS, "stat.mobKills"); + register(GenericStatistic.ANIMALS_BRED, "stat.animalsBred"); + register(GenericStatistic.PLAYERS_KILLED, "stat.playerKills"); + register(GenericStatistic.FISH_CAUGHT, "stat.fishCaught"); + register(GenericStatistic.JUNK_FISHED, "stat.junkFished"); + register(GenericStatistic.TREASURE_FISHED, "stat.treasureFished"); + + register(Particle.EXPLOSION_NORMAL, 0); + register(Particle.EXPLOSION_LARGE, 1); + register(Particle.EXPLOSION_HUGE, 2); + register(Particle.FIREWORKS_SPARK, 3); + register(Particle.WATER_BUBBLE, 4); + register(Particle.WATER_SPLASH, 5); + register(Particle.WATER_WAKE, 6); + register(Particle.SUSPENDED, 7); + register(Particle.SUSPENDED_DEPTH, 8); + register(Particle.CRIT, 9); + register(Particle.CRIT_MAGIC, 10); + register(Particle.SMOKE_NORMAL, 11); + register(Particle.SMOKE_LARGE, 12); + register(Particle.SPELL, 13); + register(Particle.SPELL_INSTANT, 14); + register(Particle.SPELL_MOB, 15); + register(Particle.SPELL_MOB_AMBIENT, 16); + register(Particle.SPELL_WITCH, 17); + register(Particle.DRIP_WATER, 18); + register(Particle.DRIP_LAVA, 19); + register(Particle.VILLAGER_ANGRY, 20); + register(Particle.VILLAGER_HAPPY, 21); + register(Particle.TOWN_AURA, 22); + register(Particle.NOTE, 23); + register(Particle.PORTAL, 24); + register(Particle.ENCHANTMENT_TABLE, 25); + register(Particle.FLAME, 26); + register(Particle.LAVA, 27); + register(Particle.FOOTSTEP, 28); + register(Particle.CLOUD, 29); + register(Particle.REDSTONE, 30); + register(Particle.SNOWBALL, 31); + register(Particle.SNOW_SHOVEL, 32); + register(Particle.SLIME, 33); + register(Particle.HEART, 34); + register(Particle.BARRIER, 35); + register(Particle.ICON_CRACK, 36); + register(Particle.BLOCK_CRACK, 37); + register(Particle.BLOCK_DUST, 38); + register(Particle.WATER_DROP, 39); + register(Particle.ITEM_TAKE, 40); + register(Particle.MOB_APPEARANCE, 41); + + register(GenericSound.CLICK, "random.click"); + register(GenericSound.FIZZ, "random.fizz"); + register(GenericSound.FIRE_AMBIENT, "fire.fire"); + register(GenericSound.IGNITE_FIRE, "fire.ignite"); + register(GenericSound.WATER_AMBIENT, "liquid.water"); + register(GenericSound.LAVA_AMBIENT, "liquid.lava"); + register(GenericSound.LAVA_POP, "liquid.lavapop"); + register(GenericSound.HARP, "note.harp"); + register(GenericSound.BASS_DRUM, "note.bd"); + register(GenericSound.SNARE_DRUM, "note.snare"); + register(GenericSound.HI_HAT, "note.hat"); + register(GenericSound.DOUBLE_BASS, "note.bassattack"); + register(GenericSound.PISTON_EXTEND, "tile.piston.out"); + register(GenericSound.PISTON_RETRACT, "tile.piston.in"); + register(GenericSound.PORTAL_AMBIENT, "portal.portal"); + register(GenericSound.TNT_PRIMED, "game.tnt.primed"); + register(GenericSound.BOW_HIT, "random.bowhit"); + register(GenericSound.COLLECT_ITEM, "random.pop"); + register(GenericSound.COLLECT_EXP, "random.orb"); + register(GenericSound.SUCCESSFUL_HIT, "random.successful_hit"); + register(GenericSound.FIREWORK_BLAST, "fireworks.blast"); + register(GenericSound.FIREWORK_LARGE_BLAST, "fireworks.largeBlast"); + register(GenericSound.FIREWORK_FAR_BLAST, "fireworks.blast_far"); + register(GenericSound.FIREWORK_FAR_LARGE_BLAST, "fireworks.largeBlast_far"); + register(GenericSound.FIREWORK_TWINKLE, "fireworks.twinkle"); + register(GenericSound.FIREWORK_FAR_TWINKLE, "fireworks.twinkle_far"); + register(GenericSound.RAIN_AMBIENT, "ambient.weather.rain"); + register(GenericSound.WITHER_SPAWN, "mob.wither.spawn"); + register(GenericSound.ENDER_DRAGON_DEATH, "mob.enderdragon.end"); + register(GenericSound.FIRE_PROJECTILE, "random.bow"); + register(GenericSound.DOOR_OPEN, "random.door_open"); + register(GenericSound.DOOR_CLOSE, "random.door_close"); + register(GenericSound.GHAST_CHARGE, "mob.ghast.charge"); + register(GenericSound.GHAST_FIRE, "mob.ghast.fireball"); + register(GenericSound.POUND_WOODEN_DOOR, "mob.zombie.wood"); + register(GenericSound.POUND_METAL_DOOR, "mob.zombie.metal"); + register(GenericSound.BREAK_WOODEN_DOOR, "mob.zombie.woodbreak"); + register(GenericSound.WITHER_SHOOT, "mob.wither.shoot"); + register(GenericSound.BAT_TAKE_OFF, "mob.bat.takeoff"); + register(GenericSound.INFECT_VILLAGER, "mob.zombie.infect"); + register(GenericSound.DISINFECT_VILLAGER, "mob.zombie.unfect"); + register(GenericSound.ANVIL_BREAK, "random.anvil_break"); + register(GenericSound.ANVIL_USE, "random.anvil_use"); + register(GenericSound.ANVIL_LAND, "random.anvil_land"); + register(GenericSound.BREAK_SPLASH_POTION, "game.potion.smash"); + register(GenericSound.THORNS_DAMAGE, "damage.thorns"); + register(GenericSound.EXPLOSION, "random.explode"); + register(GenericSound.CAVE_AMBIENT, "ambient.cave.cave"); + register(GenericSound.OPEN_CHEST, "random.chestopen"); + register(GenericSound.CLOSE_CHEST, "random.chestclosed"); + register(GenericSound.DIG_STONE, "dig.stone"); + register(GenericSound.DIG_WOOD, "dig.wood"); + register(GenericSound.DIG_GRAVEL, "dig.gravel"); + register(GenericSound.DIG_GRASS, "dig.grass"); + register(GenericSound.DIG_CLOTH, "dig.cloth"); + register(GenericSound.DIG_SAND, "dig.sand"); + register(GenericSound.DIG_SNOW, "dig.snow"); + register(GenericSound.DIG_GLASS, "dig.glass"); + register(GenericSound.ANVIL_STEP, "step.anvil"); + register(GenericSound.LADDER_STEP, "step.ladder"); + register(GenericSound.STONE_STEP, "step.stone"); + register(GenericSound.WOOD_STEP, "step.wood"); + register(GenericSound.GRAVEL_STEP, "step.gravel"); + register(GenericSound.GRASS_STEP, "step.grass"); + register(GenericSound.CLOTH_STEP, "step.cloth"); + register(GenericSound.SAND_STEP, "step.sand"); + register(GenericSound.SNOW_STEP, "step.snow"); + register(GenericSound.BURP, "random.burp"); + register(GenericSound.SADDLE_HORSE, "mob.horse.leather"); + register(GenericSound.ENDER_DRAGON_FLAP_WINGS, "mob.enderdragon.wings"); + register(GenericSound.THUNDER_AMBIENT, "ambient.weather.thunder"); + register(GenericSound.LAUNCH_FIREWORKS, "fireworks.launch"); + register(GenericSound.CREEPER_PRIMED, "creeper.primed"); + register(GenericSound.ENDERMAN_STARE, "mob.endermen.stare"); + register(GenericSound.ENDERMAN_TELEPORT, "mob.endermen.portal"); + register(GenericSound.IRON_GOLEM_THROW, "mob.irongolem.throw"); + register(GenericSound.IRON_GOLEM_WALK, "mob.irongolem.walk"); + register(GenericSound.ZOMBIE_PIGMAN_ANGRY, "mob.zombiepig.zpigangry"); + register(GenericSound.SILVERFISH_STEP, "mob.silverfish.step"); + register(GenericSound.SKELETON_STEP, "mob.skeleton.step"); + register(GenericSound.SPIDER_STEP, "mob.spider.step"); + register(GenericSound.ZOMBIE_STEP, "mob.zombie.step"); + register(GenericSound.ZOMBIE_CURE, "mob.zombie.remedy"); + register(GenericSound.CHICKEN_LAY_EGG, "mob.chicken.plop"); + register(GenericSound.CHICKEN_STEP, "mob.chicken.step"); + register(GenericSound.COW_STEP, "mob.cow.step"); + register(GenericSound.HORSE_EATING, "eating"); + register(GenericSound.HORSE_LAND, "mob.horse.land"); + register(GenericSound.HORSE_WEAR_ARMOR, "mob.horse.armor"); + register(GenericSound.HORSE_GALLOP, "mob.horse.gallop"); + register(GenericSound.HORSE_BREATHE, "mob.horse.breathe"); + register(GenericSound.HORSE_WOOD_STEP, "mob.horse.wood"); + register(GenericSound.HORSE_SOFT_STEP, "mob.horse.soft"); + register(GenericSound.HORSE_JUMP, "mob.horse.jump"); + register(GenericSound.SHEAR_SHEEP, "mob.sheep.shear"); + register(GenericSound.PIG_STEP, "mob.pig.step"); + register(GenericSound.SHEEP_STEP, "mob.sheep.step"); + register(GenericSound.VILLAGER_YES, "mob.villager.yes"); + register(GenericSound.VILLAGER_NO, "mob.villager.no"); + register(GenericSound.WOLF_STEP, "mob.wolf.step"); + register(GenericSound.WOLF_SHAKE, "mob.wolf.shake"); + register(GenericSound.DRINK, "random.drink"); + register(GenericSound.EAT, "random.eat"); + register(GenericSound.LEVEL_UP, "random.levelup"); + register(GenericSound.FISH_HOOK_SPLASH, "random.splash"); + register(GenericSound.ITEM_BREAK, "random.break"); + register(GenericSound.SWIM, "game.neutral.swim"); + register(GenericSound.SPLASH, "game.neutral.swim.splash"); + register(GenericSound.HURT, "game.neutral.hurt"); + register(GenericSound.DEATH, "game.neutral.die"); + register(GenericSound.BIG_FALL, "game.neutral.hurt.fall.big"); + register(GenericSound.SMALL_FALL, "game.neutral.hurt.fall.small"); + register(GenericSound.MOB_SWIM, "game.hostile.swim"); + register(GenericSound.MOB_SPLASH, "game.hostile.swim.splash"); + register(GenericSound.PLAYER_SWIM, "game.player.swim"); + register(GenericSound.PLAYER_SPLASH, "game.player.swim.splash"); + register(GenericSound.ENDER_DRAGON_GROWL, "mob.enderdragon.growl"); + register(GenericSound.WITHER_IDLE, "mob.wither.idle"); + register(GenericSound.BLAZE_BREATHE, "mob.blaze.breathe"); + register(GenericSound.ENDERMAN_SCREAM, "mob.endermen.scream"); + register(GenericSound.ENDERMAN_IDLE, "mob.endermen.idle"); + register(GenericSound.GHAST_MOAN, "mob.ghast.moan"); + register(GenericSound.ZOMBIE_PIGMAN_IDLE, "mob.zombiepig.zpig"); + register(GenericSound.SILVERFISH_IDLE, "mob.silverfish.say"); + register(GenericSound.SKELETON_IDLE, "mob.skeleton.say"); + register(GenericSound.SPIDER_IDLE, "mob.spider.say"); + register(GenericSound.WITCH_IDLE, "mob.witch.idle"); + register(GenericSound.ZOMBIE_IDLE, "mob.zombie.say"); + register(GenericSound.BAT_IDLE, "mob.bat.idle"); + register(GenericSound.CHICKEN_IDLE, "mob.chicken.say"); + register(GenericSound.COW_IDLE, "mob.cow.say"); + register(GenericSound.HORSE_IDLE, "mob.horse.idle"); + register(GenericSound.DONKEY_IDLE, "mob.horse.donkey.idle"); + register(GenericSound.ZOMBIE_HORSE_IDLE, "mob.horse.zombie.idle"); + register(GenericSound.SKELETON_HORSE_IDLE, "mob.horse.skeleton.idle"); + register(GenericSound.OCELOT_PURR, "mob.cat.purr"); + register(GenericSound.OCELOT_PURR_MEOW, "mob.cat.purreow"); + register(GenericSound.OCELOT_MEOW, "mob.cat.meow"); + register(GenericSound.PIG_IDLE, "mob.pig.say"); + register(GenericSound.SHEEP_IDLE, "mob.sheep.say"); + register(GenericSound.VILLAGER_HAGGLE, "mob.villager.haggle"); + register(GenericSound.VILLAGER_IDLE, "mob.villager.idle"); + register(GenericSound.WOLF_GROWL, "mob.wolf.growl"); + register(GenericSound.WOLF_PANT, "mob.wolf.panting"); + register(GenericSound.WOLF_WHINE, "mob.wolf.whine"); + register(GenericSound.WOLF_BARK, "mob.wolf.bark"); + register(GenericSound.MOB_BIG_FALL, "game.hostile.hurt.fall.big"); + register(GenericSound.MOB_SMALL_FALL, "game.hostile.hurt.fall.small"); + register(GenericSound.PLAYER_BIG_FALL, "game.player.hurt.fall.big"); + register(GenericSound.PLAYER_SMALL_FALL, "game.player.hurt.fall.small"); + register(GenericSound.ENDER_DRAGON_HURT, "mob.enderdragon.hit"); + register(GenericSound.WITHER_HURT, "mob.wither.hurt"); + register(GenericSound.WITHER_DEATH, "mob.wither.death"); + register(GenericSound.BLAZE_HURT, "mob.blaze.hit"); + register(GenericSound.BLAZE_DEATH, "mob.blaze.death"); + register(GenericSound.CREEPER_HURT, "mob.creeper.say"); + register(GenericSound.CREEPER_DEATH, "mob.creeper.death"); + register(GenericSound.ENDERMAN_HURT, "mob.endermen.hit"); + register(GenericSound.ENDERMAN_DEATH, "mob.endermen.death"); + register(GenericSound.GHAST_HURT, "mob.ghast.scream"); + register(GenericSound.GHAST_DEATH, "mob.ghast.death"); + register(GenericSound.IRON_GOLEM_HURT, "mob.irongolem.hit"); + register(GenericSound.IRON_GOLEM_DEATH, "mob.irongolem.death"); + register(GenericSound.MOB_HURT, "game.hostile.hurt"); + register(GenericSound.MOB_DEATH, "game.hostile.die"); + register(GenericSound.ZOMBIE_PIGMAN_HURT, "mob.zombiepig.zpighurt"); + register(GenericSound.ZOMBIE_PIGMAN_DEATH, "mob.zombiepig.zpigdeath"); + register(GenericSound.SILVERFISH_HURT, "mob.silverfish.hit"); + register(GenericSound.SILVERFISH_DEATH, "mob.silverfish.kill"); + register(GenericSound.SKELETON_HURT, "mob.skeleton.hurt"); + register(GenericSound.SKELETON_DEATH, "mob.skeleton.death"); + register(GenericSound.SLIME, "mob.slime.small"); + register(GenericSound.BIG_SLIME, "mob.slime.big"); + register(GenericSound.SPIDER_DEATH, "mob.spider.death"); + register(GenericSound.WITCH_HURT, "mob.witch.hurt"); + register(GenericSound.WITCH_DEATH, "mob.witch.death"); + register(GenericSound.ZOMBIE_HURT, "mob.zombie.hurt"); + register(GenericSound.ZOMBIE_DEATH, "mob.zombie.death"); + register(GenericSound.PLAYER_HURT, "game.player.hurt"); + register(GenericSound.PLAYER_DEATH, "game.player.die"); + register(GenericSound.WOLF_HURT, "mob.wolf.hurt"); + register(GenericSound.WOLF_DEATH, "mob.wolf.death"); + register(GenericSound.VILLAGER_HURT, "mob.villager.hit"); + register(GenericSound.VILLAGER_DEATH, "mob.villager.death"); + register(GenericSound.PIG_DEATH, "mob.pig.death"); + register(GenericSound.OCELOT_HURT, "mob.cat.hitt"); + register(GenericSound.HORSE_HURT, "mob.horse.hit"); + register(GenericSound.DONKEY_HURT, "mob.horse.donkey.hit"); + register(GenericSound.ZOMBIE_HORSE_HURT, "mob.horse.zombie.hit"); + register(GenericSound.SKELETON_HORSE_HURT, "mob.horse.skeleton.hit"); + register(GenericSound.HORSE_DEATH, "mob.horse.death"); + register(GenericSound.DONKEY_DEATH, "mob.horse.donkey.death"); + register(GenericSound.ZOMBIE_HORSE_DEATH, "mob.horse.zombie.death"); + register(GenericSound.SKELETON_HORSE_DEATH, "mob.horse.skeleton.death"); + register(GenericSound.COW_HURT, "mob.cow.hurt"); + register(GenericSound.CHICKEN_HURT, "mob.chicken.hurt"); + register(GenericSound.BAT_HURT, "mob.bat.hurt"); + register(GenericSound.BAT_DEATH, "mob.bat.death"); + register(GenericSound.RABBIT_HURT, "mob.rabbit.hurt"); + register(GenericSound.RABBIT_HOP, "mob.rabbit.hop"); + register(GenericSound.RABBIT_IDLE, "mob.rabbit.idle"); + register(GenericSound.RABBIT_DEATH, "mob.rabbit.death"); + register(GenericSound.MOB_ATTACK, "mob.attack"); + + register(NoteBlockValueType.HARP, 0); + register(NoteBlockValueType.DOUBLE_BASS, 1); + register(NoteBlockValueType.SNARE_DRUM, 2); + register(NoteBlockValueType.HI_HAT, 3); + register(NoteBlockValueType.BASS_DRUM, 4); + + register(PistonValueType.PUSHING, 0); + register(PistonValueType.PULLING, 1); + + register(MobSpawnerValueType.RESET_DELAY, 1); + + register(ChestValueType.VIEWING_PLAYER_COUNT, 1); + + register(GenericBlockValueType.GENERIC, 1); + + register(PistonValue.DOWN, 0); + register(PistonValue.UP, 1); + register(PistonValue.SOUTH, 2); + register(PistonValue.WEST, 3); + register(PistonValue.NORTH, 4); + register(PistonValue.EAST, 5); + + register(SoundEffect.CLICK, 1000); + register(SoundEffect.EMPTY_DISPENSER_CLICK, 1001); + register(SoundEffect.FIRE_PROJECTILE, 1002); + register(SoundEffect.DOOR, 1003); + register(SoundEffect.FIZZLE, 1004); + register(SoundEffect.PLAY_RECORD, 1005); + register(SoundEffect.GHAST_CHARGE, 1007); + register(SoundEffect.GHAST_FIRE, 1008); + register(SoundEffect.BLAZE_FIRE, 1009); + register(SoundEffect.POUND_WOODEN_DOOR, 1010); + register(SoundEffect.POUND_METAL_DOOR, 1011); + register(SoundEffect.BREAK_WOODEN_DOOR, 1012); + register(SoundEffect.WITHER_SPAWN, 1013); + register(SoundEffect.WITHER_SHOOT, 1014); + register(SoundEffect.BAT_TAKE_OFF, 1015); + register(SoundEffect.INFECT_VILLAGER, 1016); + register(SoundEffect.DISINFECT_VILLAGER, 1017); + register(SoundEffect.ENDER_DRAGON_DEATH, 1018); + register(SoundEffect.ANVIL_BREAK, 1020); + register(SoundEffect.ANVIL_USE, 1021); + register(SoundEffect.ANVIL_LAND, 1022); + + register(ParticleEffect.SMOKE, 2000); + register(ParticleEffect.BREAK_BLOCK, 2001); + register(ParticleEffect.BREAK_SPLASH_POTION, 2002); + register(ParticleEffect.BREAK_EYE_OF_ENDER, 2003); + register(ParticleEffect.MOB_SPAWN, 2004); + register(ParticleEffect.BONEMEAL_GROW, 2005); + register(ParticleEffect.HARD_LANDING_DUST, 2006); + + register(SmokeEffectData.SOUTH_EAST, 0); + register(SmokeEffectData.SOUTH, 1); + register(SmokeEffectData.SOUTH_WEST, 2); + register(SmokeEffectData.EAST, 3); + register(SmokeEffectData.UP, 4); + register(SmokeEffectData.WEST, 5); + register(SmokeEffectData.NORTH_EAST, 6); + register(SmokeEffectData.NORTH, 7); + register(SmokeEffectData.NORTH_WEST, 8); + + register(NameTagVisibility.ALWAYS, "always"); + register(NameTagVisibility.NEVER, "never"); + register(NameTagVisibility.HIDE_FOR_OTHER_TEAMS, "hideForOtherTeams"); + register(NameTagVisibility.HIDE_FOR_OWN_TEAM, "hideForOwnTeam"); + + register(TeamColor.NONE, -1); + register(TeamColor.BLACK, 0); + register(TeamColor.DARK_BLUE, 1); + register(TeamColor.DARK_GREEN, 2); + register(TeamColor.DARK_AQUA, 3); + register(TeamColor.DARK_RED, 4); + register(TeamColor.DARK_PURPLE, 5); + register(TeamColor.GOLD, 6); + register(TeamColor.GRAY, 7); + register(TeamColor.DARK_GRAY, 8); + register(TeamColor.BLUE, 9); + register(TeamColor.GREEN, 10); + register(TeamColor.AQUA, 11); + register(TeamColor.RED, 12); + register(TeamColor.LIGHT_PURPLE, 13); + register(TeamColor.YELLOW, 14); + register(TeamColor.WHITE, 15); + + register(ScoreType.INTEGER, "integer"); + register(ScoreType.HEARTS, "hearts"); + + register(WorldBorderAction.SET_SIZE, 0); + register(WorldBorderAction.LERP_SIZE, 1); + register(WorldBorderAction.SET_CENTER, 2); + register(WorldBorderAction.INITIALIZE, 3); + register(WorldBorderAction.SET_WARNING_TIME, 4); + register(WorldBorderAction.SET_WARNING_BLOCKS, 5); + + register(PlayerListEntryAction.ADD_PLAYER, 0); + register(PlayerListEntryAction.UPDATE_GAMEMODE, 1); + register(PlayerListEntryAction.UPDATE_LATENCY, 2); + register(PlayerListEntryAction.UPDATE_DISPLAY_NAME, 3); + register(PlayerListEntryAction.REMOVE_PLAYER, 4); + + register(TitleAction.TITLE, 0); + register(TitleAction.SUBTITLE, 1); + register(TitleAction.TIMES, 2); + register(TitleAction.CLEAR, 3); + register(TitleAction.RESET, 4); + + register(ResourcePackStatus.SUCCESSFULLY_LOADED, 0); + register(ResourcePackStatus.DECLINED, 1); + register(ResourcePackStatus.FAILED_DOWNLOAD, 2); + register(ResourcePackStatus.ACCEPTED, 3); + } + + private static void register(Enum key, Object value) { + values.put(key, value); + } + + @SuppressWarnings({ "unchecked" }) + public static > T key(Class keyType, Object value) { + for(Enum key : values.keySet()) { + Object val = values.get(key); + if(keyType.isAssignableFrom(key.getClass())) { + if(val == value || val.equals(value)) { + return (T) key; + } else if(Number.class.isAssignableFrom(val.getClass()) && Number.class.isAssignableFrom(value.getClass())) { + Number num = (Number) val; + Number num2 = (Number) value; + if(num.doubleValue() == num2.doubleValue()) { + return (T) key; + } + } + } + } + + return null; + } + + @SuppressWarnings("unchecked") + public static T value(Class valueType, Enum key) { + Object val = values.get(key); + if(val != null) { + if(valueType.isAssignableFrom(val.getClass())) { + return (T) val; + } else if(Number.class.isAssignableFrom(val.getClass())) { + if(valueType == Byte.class) { + return (T) (Object) ((Number) val).byteValue(); + } else if(valueType == Short.class) { + return (T) (Object) ((Number) val).shortValue(); + } else if(valueType == Integer.class) { + return (T) (Object) ((Number) val).intValue(); + } else if(valueType == Long.class) { + return (T) (Object) ((Number) val).longValue(); + } else if(valueType == Float.class) { + return (T) (Object) ((Number) val).floatValue(); + } else if(valueType == Double.class) { + return (T) (Object) ((Number) val).doubleValue(); + } + } + } + + return null; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/MessageType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/MessageType.java index d3a2224f8..a2a465fba 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/MessageType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/MessageType.java @@ -2,8 +2,8 @@ public enum MessageType { - CHAT, - SYSTEM, - NOTIFICATION; + CHAT, + SYSTEM, + NOTIFICATION; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/PlayerListEntry.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/PlayerListEntry.java index af5632ec8..8ed690bd8 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/PlayerListEntry.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/PlayerListEntry.java @@ -5,76 +5,76 @@ import org.spacehq.mc.protocol.data.message.Message; public class PlayerListEntry { - private GameProfile profile; - - private GameMode gameMode; - private int ping; - private Message displayName; - - public PlayerListEntry(GameProfile profile, GameMode gameMode, int ping, Message displayName) { - this.profile = profile; - this.gameMode = gameMode; - this.ping = ping; - this.displayName = displayName; - } - - public PlayerListEntry(GameProfile profile, GameMode gameMode) { - this.profile = profile; - this.gameMode = gameMode; - } - - public PlayerListEntry(GameProfile profile, int ping) { - this.profile = profile; - this.ping = ping; - } - - public PlayerListEntry(GameProfile profile, Message displayName) { - this.profile = profile; - this.displayName = displayName; - } - - public PlayerListEntry(GameProfile profile) { - this.profile = profile; - } - - public GameProfile getProfile() { - return this.profile; - } - - public GameMode getGameMode() { - return this.gameMode; - } - - public int getPing() { - return this.ping; - } - - public Message getDisplayName() { - return this.displayName; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - PlayerListEntry entry = (PlayerListEntry) o; - - if (ping != entry.ping) return false; - if (displayName != null ? !displayName.equals(entry.displayName) : entry.displayName != null) return false; - if (gameMode != entry.gameMode) return false; - if (!profile.equals(entry.profile)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = profile.hashCode(); - result = 31 * result + (gameMode != null ? gameMode.hashCode() : 0); - result = 31 * result + ping; - result = 31 * result + (displayName != null ? displayName.hashCode() : 0); - return result; - } + private GameProfile profile; + + private GameMode gameMode; + private int ping; + private Message displayName; + + public PlayerListEntry(GameProfile profile, GameMode gameMode, int ping, Message displayName) { + this.profile = profile; + this.gameMode = gameMode; + this.ping = ping; + this.displayName = displayName; + } + + public PlayerListEntry(GameProfile profile, GameMode gameMode) { + this.profile = profile; + this.gameMode = gameMode; + } + + public PlayerListEntry(GameProfile profile, int ping) { + this.profile = profile; + this.ping = ping; + } + + public PlayerListEntry(GameProfile profile, Message displayName) { + this.profile = profile; + this.displayName = displayName; + } + + public PlayerListEntry(GameProfile profile) { + this.profile = profile; + } + + public GameProfile getProfile() { + return this.profile; + } + + public GameMode getGameMode() { + return this.gameMode; + } + + public int getPing() { + return this.ping; + } + + public Message getDisplayName() { + return this.displayName; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + PlayerListEntry entry = (PlayerListEntry) o; + + if(ping != entry.ping) return false; + if(displayName != null ? !displayName.equals(entry.displayName) : entry.displayName != null) return false; + if(gameMode != entry.gameMode) return false; + if(!profile.equals(entry.profile)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = profile.hashCode(); + result = 31 * result + (gameMode != null ? gameMode.hashCode() : 0); + result = 31 * result + ping; + result = 31 * result + (displayName != null ? displayName.hashCode() : 0); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/PlayerListEntryAction.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/PlayerListEntryAction.java index 14a55e4f2..3cb42aafe 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/PlayerListEntryAction.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/PlayerListEntryAction.java @@ -1,9 +1,9 @@ package org.spacehq.mc.protocol.data.game.values; public enum PlayerListEntryAction { - ADD_PLAYER, - UPDATE_GAMEMODE, - UPDATE_LATENCY, - UPDATE_DISPLAY_NAME, - REMOVE_PLAYER; + ADD_PLAYER, + UPDATE_GAMEMODE, + UPDATE_LATENCY, + UPDATE_DISPLAY_NAME, + REMOVE_PLAYER; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/ResourcePackStatus.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/ResourcePackStatus.java index 90029b644..e127aaf76 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/ResourcePackStatus.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/ResourcePackStatus.java @@ -1,8 +1,8 @@ package org.spacehq.mc.protocol.data.game.values; public enum ResourcePackStatus { - SUCCESSFULLY_LOADED, - DECLINED, - FAILED_DOWNLOAD, - ACCEPTED; + SUCCESSFULLY_LOADED, + DECLINED, + FAILED_DOWNLOAD, + ACCEPTED; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/TitleAction.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/TitleAction.java index c98dac80c..9bf56a3ae 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/TitleAction.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/TitleAction.java @@ -1,9 +1,9 @@ package org.spacehq.mc.protocol.data.game.values; public enum TitleAction { - TITLE, - SUBTITLE, - TIMES, - CLEAR, - RESET; + TITLE, + SUBTITLE, + TIMES, + CLEAR, + RESET; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/Art.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/Art.java index bdd605757..6a38795bc 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/Art.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/Art.java @@ -2,31 +2,31 @@ public enum Art { - KEBAB, - AZTEC, - ALBAN, - AZTEC2, - BOMB, - PLANT, - WASTELAND, - POOL, - COURBET, - SEA, - SUNSET, - CREEBET, - WANDERER, - GRAHAM, - MATCH, - BUST, - STAGE, - VOID, - SKULL_AND_ROSES, - WITHER, - FIGHTERS, - POINTER, - PIG_SCENE, - BURNING_SKULL, - SKELETON, - DONKEY_KONG; + KEBAB, + AZTEC, + ALBAN, + AZTEC2, + BOMB, + PLANT, + WASTELAND, + POOL, + COURBET, + SEA, + SUNSET, + CREEBET, + WANDERER, + GRAHAM, + MATCH, + BUST, + STAGE, + VOID, + SKULL_AND_ROSES, + WITHER, + FIGHTERS, + POINTER, + PIG_SCENE, + BURNING_SKULL, + SKELETON, + DONKEY_KONG; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/AttributeType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/AttributeType.java index c524cdd3f..10ad13ae5 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/AttributeType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/AttributeType.java @@ -2,34 +2,34 @@ public enum AttributeType { - MAX_HEALTH(20, 0, Double.MAX_VALUE), - FOLLOW_RANGE(32, 0, 2048), - KNOCKBACK_RESISTANCE(0, 0, 1), - MOVEMENT_SPEED(0.699999988079071, 0, Double.MAX_VALUE), - ATTACK_DAMAGE(2, 0, Double.MAX_VALUE), - HORSE_JUMP_STRENGTH(0.7, 0, 2), - ZOMBIE_SPAWN_REINFORCEMENTS_CHANCE(0, 0, 1); - - private double def; - private double min; - private double max; - - private AttributeType(double def, double min, double max) { - this.def = def; - this.min = min; - this.max = max; - } - - public double getDefault() { - return this.def; - } - - public double getMin() { - return this.min; - } - - public double getMax() { - return this.max; - } + MAX_HEALTH(20, 0, Double.MAX_VALUE), + FOLLOW_RANGE(32, 0, 2048), + KNOCKBACK_RESISTANCE(0, 0, 1), + MOVEMENT_SPEED(0.699999988079071, 0, Double.MAX_VALUE), + ATTACK_DAMAGE(2, 0, Double.MAX_VALUE), + HORSE_JUMP_STRENGTH(0.7, 0, 2), + ZOMBIE_SPAWN_REINFORCEMENTS_CHANCE(0, 0, 1); + + private double def; + private double min; + private double max; + + private AttributeType(double def, double min, double max) { + this.def = def; + this.min = min; + this.max = max; + } + + public double getDefault() { + return this.def; + } + + public double getMin() { + return this.min; + } + + public double getMax() { + return this.max; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/Effect.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/Effect.java index 1f7ac6d22..b38c7e5f2 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/Effect.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/Effect.java @@ -2,28 +2,28 @@ public enum Effect { - SPEED, - SLOWNESS, - DIG_SPEED, - DIG_SLOWNESS, - DAMAGE_BOOST, - HEAL, - DAMAGE, - JUMP_BOOST, - CONFUSION, - REGENERATION, - RESISTANCE, - FIRE_RESISTANCE, - WATER_BREATHING, - INVISIBILITY, - BLINDNESS, - NIGHT_VISION, - HUNGER, - WEAKNESS, - POISON, - WITHER_EFFECT, - HEALTH_BOOST, - ABSORPTION, - SATURATION; + SPEED, + SLOWNESS, + DIG_SPEED, + DIG_SLOWNESS, + DAMAGE_BOOST, + HEAL, + DAMAGE, + JUMP_BOOST, + CONFUSION, + REGENERATION, + RESISTANCE, + FIRE_RESISTANCE, + WATER_BREATHING, + INVISIBILITY, + BLINDNESS, + NIGHT_VISION, + HUNGER, + WEAKNESS, + POISON, + WITHER_EFFECT, + HEALTH_BOOST, + ABSORPTION, + SATURATION; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/EntityStatus.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/EntityStatus.java index e83d23534..9a58f6cbb 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/EntityStatus.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/EntityStatus.java @@ -2,27 +2,27 @@ public enum EntityStatus { - HURT_OR_MINECART_SPAWNER_DELAY_RESET, - LIVING_HURT, - DEAD, - IRON_GOLEM_THROW, - TAMING, - TAMED, - WOLF_SHAKING, - FINISHED_EATING, - SHEEP_GRAZING_OR_TNT_CART_EXPLODING, - IRON_GOLEM_ROSE, - VILLAGER_HEARTS, - VILLAGER_ANGRY, - VILLAGER_HAPPY, - WITCH_MAGIC_PARTICLES, - ZOMBIE_VILLAGER_SHAKING, - FIREWORK_EXPLODING, - ANIMAL_HEARTS, - RESET_SQUID_ROTATION, - EXPLOSION_PARTICLE, - GUARDIAN_SOUND, - ENABLE_REDUCED_DEBUG, - DISABLE_REDUCED_DEBUG; + HURT_OR_MINECART_SPAWNER_DELAY_RESET, + LIVING_HURT, + DEAD, + IRON_GOLEM_THROW, + TAMING, + TAMED, + WOLF_SHAKING, + FINISHED_EATING, + SHEEP_GRAZING_OR_TNT_CART_EXPLODING, + IRON_GOLEM_ROSE, + VILLAGER_HEARTS, + VILLAGER_ANGRY, + VILLAGER_HAPPY, + WITCH_MAGIC_PARTICLES, + ZOMBIE_VILLAGER_SHAKING, + FIREWORK_EXPLODING, + ANIMAL_HEARTS, + RESET_SQUID_ROTATION, + EXPLOSION_PARTICLE, + GUARDIAN_SOUND, + ENABLE_REDUCED_DEBUG, + DISABLE_REDUCED_DEBUG; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/FallingBlockData.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/FallingBlockData.java index de3477b11..1e0e650d7 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/FallingBlockData.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/FallingBlockData.java @@ -2,40 +2,40 @@ public class FallingBlockData implements ObjectData { - private int id; - private int metadata; + private int id; + private int metadata; - public FallingBlockData(int id, int metadata) { - this.id = id; - this.metadata = metadata; - } + public FallingBlockData(int id, int metadata) { + this.id = id; + this.metadata = metadata; + } - public int getId() { - return this.id; - } + public int getId() { + return this.id; + } - public int getMetadata() { - return this.metadata; - } + public int getMetadata() { + return this.metadata; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - FallingBlockData that = (FallingBlockData) o; + FallingBlockData that = (FallingBlockData) o; - if (id != that.id) return false; - if (metadata != that.metadata) return false; + if(id != that.id) return false; + if(metadata != that.metadata) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - int result = id; - result = 31 * result + metadata; - return result; - } + @Override + public int hashCode() { + int result = id; + result = 31 * result + metadata; + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/GlobalEntityType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/GlobalEntityType.java index b0af04d8b..db44856bb 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/GlobalEntityType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/GlobalEntityType.java @@ -2,6 +2,6 @@ public enum GlobalEntityType { - LIGHTNING_BOLT; + LIGHTNING_BOLT; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/HangingDirection.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/HangingDirection.java index 77da0c0ac..c03b4f153 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/HangingDirection.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/HangingDirection.java @@ -2,9 +2,9 @@ public enum HangingDirection implements ObjectData { - SOUTH, - WEST, - NORTH, - EAST; + SOUTH, + WEST, + NORTH, + EAST; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MetadataType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MetadataType.java index 14478ad34..0a137ca61 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MetadataType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MetadataType.java @@ -2,13 +2,13 @@ public enum MetadataType { - BYTE, - SHORT, - INT, - FLOAT, - STRING, - ITEM, - POSITION, - ROTATION; + BYTE, + SHORT, + INT, + FLOAT, + STRING, + ITEM, + POSITION, + ROTATION; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MinecartType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MinecartType.java index 6adec6e6e..7fe418e0c 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MinecartType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MinecartType.java @@ -2,12 +2,12 @@ public enum MinecartType implements ObjectData { - NORMAL, - CHEST, - POWERED, - TNT, - MOB_SPAWNER, - HOPPER, - COMMAND_BLOCK; + NORMAL, + CHEST, + POWERED, + TNT, + MOB_SPAWNER, + HOPPER, + COMMAND_BLOCK; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MobType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MobType.java index 6a32070e2..df52a97ba 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MobType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/MobType.java @@ -2,38 +2,38 @@ public enum MobType { - ARMOR_STAND, - CREEPER, - SKELETON, - SPIDER, - GIANT_ZOMBIE, - ZOMBIE, - SLIME, - GHAST, - ZOMBIE_PIGMAN, - ENDERMAN, - CAVE_SPIDER, - SILVERFISH, - BLAZE, - MAGMA_CUBE, - ENDER_DRAGON, - WITHER, - BAT, - WITCH, - ENDERMITE, - GUARDIAN, - PIG, - SHEEP, - COW, - CHICKEN, - SQUID, - WOLF, - MOOSHROOM, - SNOWMAN, - OCELOT, - IRON_GOLEM, - HORSE, - RABBIT, - VILLAGER; + ARMOR_STAND, + CREEPER, + SKELETON, + SPIDER, + GIANT_ZOMBIE, + ZOMBIE, + SLIME, + GHAST, + ZOMBIE_PIGMAN, + ENDERMAN, + CAVE_SPIDER, + SILVERFISH, + BLAZE, + MAGMA_CUBE, + ENDER_DRAGON, + WITHER, + BAT, + WITCH, + ENDERMITE, + GUARDIAN, + PIG, + SHEEP, + COW, + CHICKEN, + SQUID, + WOLF, + MOOSHROOM, + SNOWMAN, + OCELOT, + IRON_GOLEM, + HORSE, + RABBIT, + VILLAGER; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ModifierOperation.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ModifierOperation.java index 17208a920..d8fa68302 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ModifierOperation.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ModifierOperation.java @@ -2,8 +2,8 @@ public enum ModifierOperation { - ADD, - ADD_MULTIPLIED, - MULTIPLY; + ADD, + ADD_MULTIPLIED, + MULTIPLY; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ModifierType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ModifierType.java index 8d00b135b..ea49af794 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ModifierType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ModifierType.java @@ -2,17 +2,17 @@ public enum ModifierType { - CREATURE_FLEE_SPEED_BONUS, - ENDERMAN_ATTACK_SPEED_BOOST, - SPRINT_SPEED_BOOST, - PIGZOMBIE_ATTACK_SPEED_BOOST, - WITCH_DRINKING_SPEED_PENALTY, - ZOMBIE_BABY_SPEED_BOOST, - ITEM_MODIFIER, - SPEED_POTION_MODIFIER, - HEALTH_BOOST_POTION_MODIFIER, - SLOW_POTION_MODIFIER, - STRENGTH_POTION_MODIFIER, - WEAKNESS_POTION_MODIFIER; + CREATURE_FLEE_SPEED_BONUS, + ENDERMAN_ATTACK_SPEED_BOOST, + SPRINT_SPEED_BOOST, + PIGZOMBIE_ATTACK_SPEED_BOOST, + WITCH_DRINKING_SPEED_PENALTY, + ZOMBIE_BABY_SPEED_BOOST, + ITEM_MODIFIER, + SPEED_POTION_MODIFIER, + HEALTH_BOOST_POTION_MODIFIER, + SLOW_POTION_MODIFIER, + STRENGTH_POTION_MODIFIER, + WEAKNESS_POTION_MODIFIER; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ObjectType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ObjectType.java index 59aaf0213..20770ce18 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ObjectType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ObjectType.java @@ -2,27 +2,27 @@ public enum ObjectType { - BOAT, - ITEM, - MINECART, - PRIMED_TNT, - ENDER_CRYSTAL, - ARROW, - SNOWBALL, - EGG, - GHAST_FIREBALL, - BLAZE_FIREBALL, - ENDER_PEARL, - WITHER_HEAD_PROJECTILE, - FALLING_BLOCK, - ITEM_FRAME, - EYE_OF_ENDER, - POTION, - FALLING_DRAGON_EGG, - EXP_BOTTLE, - FIREWORK_ROCKET, - LEASH_KNOT, - ARMOR_STAND, - FISH_HOOK; + BOAT, + ITEM, + MINECART, + PRIMED_TNT, + ENDER_CRYSTAL, + ARROW, + SNOWBALL, + EGG, + GHAST_FIREBALL, + BLAZE_FIREBALL, + ENDER_PEARL, + WITHER_HEAD_PROJECTILE, + FALLING_BLOCK, + ITEM_FRAME, + EYE_OF_ENDER, + POTION, + FALLING_DRAGON_EGG, + EXP_BOTTLE, + FIREWORK_ROCKET, + LEASH_KNOT, + ARMOR_STAND, + FISH_HOOK; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ProjectileData.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ProjectileData.java index 3f7948bf3..2594a3442 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ProjectileData.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/ProjectileData.java @@ -2,31 +2,31 @@ public class ProjectileData implements ObjectData { - private int ownerId; + private int ownerId; - public ProjectileData(int ownerId) { - this.ownerId = ownerId; - } + public ProjectileData(int ownerId) { + this.ownerId = ownerId; + } - public int getOwnerId() { - return this.ownerId; - } + public int getOwnerId() { + return this.ownerId; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - ProjectileData that = (ProjectileData) o; + ProjectileData that = (ProjectileData) o; - if (ownerId != that.ownerId) return false; + if(ownerId != that.ownerId) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return ownerId; - } + @Override + public int hashCode() { + return ownerId; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/SplashPotionData.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/SplashPotionData.java index 705976ea4..ec644d010 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/SplashPotionData.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/SplashPotionData.java @@ -2,31 +2,31 @@ public class SplashPotionData implements ObjectData { - private int potionData; + private int potionData; - public SplashPotionData(int potionData) { - this.potionData = potionData; - } + public SplashPotionData(int potionData) { + this.potionData = potionData; + } - public int getPotionData() { - return this.potionData; - } + public int getPotionData() { + return this.potionData; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - SplashPotionData that = (SplashPotionData) o; + SplashPotionData that = (SplashPotionData) o; - if (potionData != that.potionData) return false; + if(potionData != that.potionData) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return potionData; - } + @Override + public int hashCode() { + return potionData; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/Animation.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/Animation.java index c41d48eae..dac552576 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/Animation.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/Animation.java @@ -2,11 +2,11 @@ public enum Animation { - SWING_ARM, - DAMAGE, - LEAVE_BED, - EAT_FOOD, - CRITICAL_HIT, - ENCHANTMENT_CRITICAL_HIT; + SWING_ARM, + DAMAGE, + LEAVE_BED, + EAT_FOOD, + CRITICAL_HIT, + ENCHANTMENT_CRITICAL_HIT; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/BlockBreakStage.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/BlockBreakStage.java index 7522de808..2f4e5052d 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/BlockBreakStage.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/BlockBreakStage.java @@ -2,16 +2,16 @@ public enum BlockBreakStage { - STAGE_1, - STAGE_2, - STAGE_3, - STAGE_4, - STAGE_5, - STAGE_6, - STAGE_7, - STAGE_8, - STAGE_9, - STAGE_10, - RESET; + STAGE_1, + STAGE_2, + STAGE_3, + STAGE_4, + STAGE_5, + STAGE_6, + STAGE_7, + STAGE_8, + STAGE_9, + STAGE_10, + RESET; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/CombatState.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/CombatState.java index ae519aa6e..4af015fe1 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/CombatState.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/CombatState.java @@ -2,8 +2,8 @@ public enum CombatState { - ENTER_COMBAT, - END_COMBAT, - ENTITY_DEAD; + ENTER_COMBAT, + END_COMBAT, + ENTITY_DEAD; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/GameMode.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/GameMode.java index 25166fea3..f69d5b21d 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/GameMode.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/GameMode.java @@ -4,9 +4,9 @@ public enum GameMode implements ClientNotificationValue { - SURVIVAL, - CREATIVE, - ADVENTURE, - SPECTATOR; + SURVIVAL, + CREATIVE, + ADVENTURE, + SPECTATOR; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/InteractAction.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/InteractAction.java index 5ac082766..10b50377d 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/InteractAction.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/InteractAction.java @@ -2,8 +2,8 @@ public enum InteractAction { - INTERACT, - ATTACK, - INTERACT_AT; + INTERACT, + ATTACK, + INTERACT_AT; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PlayerAction.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PlayerAction.java index bb6b9f6d0..ee87462fc 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PlayerAction.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PlayerAction.java @@ -2,11 +2,11 @@ public enum PlayerAction { - START_DIGGING, - CANCEL_DIGGING, - FINISH_DIGGING, - DROP_ITEM_STACK, - DROP_ITEM, - RELEASE_USE_ITEM; + START_DIGGING, + CANCEL_DIGGING, + FINISH_DIGGING, + DROP_ITEM_STACK, + DROP_ITEM, + RELEASE_USE_ITEM; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PlayerState.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PlayerState.java index fbdb3f757..9aa168261 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PlayerState.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PlayerState.java @@ -2,12 +2,12 @@ public enum PlayerState { - START_SNEAKING, - STOP_SNEAKING, - LEAVE_BED, - START_SPRINTING, - STOP_SPRINTING, - RIDING_JUMP, - OPEN_INVENTORY; + START_SNEAKING, + STOP_SNEAKING, + LEAVE_BED, + START_SPRINTING, + STOP_SPRINTING, + RIDING_JUMP, + OPEN_INVENTORY; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PositionElement.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PositionElement.java index b20d8339f..bd3c912a2 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PositionElement.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/player/PositionElement.java @@ -2,10 +2,10 @@ public enum PositionElement { - X, - Y, - Z, - PITCH, - YAW; + X, + Y, + Z, + PITCH, + YAW; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/NameTagVisibility.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/NameTagVisibility.java index aaa8195ef..8e145a245 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/NameTagVisibility.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/NameTagVisibility.java @@ -2,9 +2,9 @@ public enum NameTagVisibility { - ALWAYS, - NEVER, - HIDE_FOR_OTHER_TEAMS, - HIDE_FOR_OWN_TEAM; + ALWAYS, + NEVER, + HIDE_FOR_OTHER_TEAMS, + HIDE_FOR_OWN_TEAM; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ObjectiveAction.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ObjectiveAction.java index ffe7408ff..e360fba3c 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ObjectiveAction.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ObjectiveAction.java @@ -2,8 +2,8 @@ public enum ObjectiveAction { - ADD, - REMOVE, - UPDATE; + ADD, + REMOVE, + UPDATE; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreType.java index 6b3f23a6e..e5f412401 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreType.java @@ -2,7 +2,7 @@ public enum ScoreType { - INTEGER, - HEARTS; + INTEGER, + HEARTS; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreboardAction.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreboardAction.java index e7813e024..e545afab5 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreboardAction.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreboardAction.java @@ -2,7 +2,7 @@ public enum ScoreboardAction { - ADD_OR_UPDATE, - REMOVE; + ADD_OR_UPDATE, + REMOVE; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreboardPosition.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreboardPosition.java index 58f425c23..49d529877 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreboardPosition.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/ScoreboardPosition.java @@ -2,25 +2,25 @@ public enum ScoreboardPosition { - PLAYER_LIST, - SIDEBAR, - BELOW_NAME, + PLAYER_LIST, + SIDEBAR, + BELOW_NAME, - SIDEBAR_TEAM_BLACK, - SIDEBAR_TEAM_DARK_BLUE, - SIDEBAR_TEAM_DARK_GREEN, - SIDEBAR_TEAM_DARK_AQUA, - SIDEBAR_TEAM_DARK_RED, - SIDEBAR_TEAM_DARK_PURPLE, - SIDEBAR_TEAM_GOLD, - SIDEBAR_TEAM_GRAY, - SIDEBAR_TEAM_DARK_GRAY, - SIDEBAR_TEAM_BLUE, - SIDEBAR_TEAM_GREEN, - SIDEBAR_TEAM_AQUA, - SIDEBAR_TEAM_RED, - SIDEBAR_TEAM_LIGHT_PURPLE, - SIDEBAR_TEAM_YELLOW, - SIDEBAR_TEAM_WHITE; + SIDEBAR_TEAM_BLACK, + SIDEBAR_TEAM_DARK_BLUE, + SIDEBAR_TEAM_DARK_GREEN, + SIDEBAR_TEAM_DARK_AQUA, + SIDEBAR_TEAM_DARK_RED, + SIDEBAR_TEAM_DARK_PURPLE, + SIDEBAR_TEAM_GOLD, + SIDEBAR_TEAM_GRAY, + SIDEBAR_TEAM_DARK_GRAY, + SIDEBAR_TEAM_BLUE, + SIDEBAR_TEAM_GREEN, + SIDEBAR_TEAM_AQUA, + SIDEBAR_TEAM_RED, + SIDEBAR_TEAM_LIGHT_PURPLE, + SIDEBAR_TEAM_YELLOW, + SIDEBAR_TEAM_WHITE; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/TeamAction.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/TeamAction.java index 7e464759f..eb0db877d 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/TeamAction.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/TeamAction.java @@ -2,10 +2,10 @@ public enum TeamAction { - CREATE, - REMOVE, - UPDATE, - ADD_PLAYER, - REMOVE_PLAYER; + CREATE, + REMOVE, + UPDATE, + ADD_PLAYER, + REMOVE_PLAYER; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/TeamColor.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/TeamColor.java index 1eb0ab0e8..18c86e8a9 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/TeamColor.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/scoreboard/TeamColor.java @@ -2,22 +2,22 @@ public enum TeamColor { - NONE, - BLACK, - DARK_BLUE, - DARK_GREEN, - DARK_AQUA, - DARK_RED, - DARK_PURPLE, - GOLD, - GRAY, - DARK_GRAY, - BLUE, - GREEN, - AQUA, - RED, - LIGHT_PURPLE, - YELLOW, - WHITE; + NONE, + BLACK, + DARK_BLUE, + DARK_GREEN, + DARK_AQUA, + DARK_RED, + DARK_PURPLE, + GOLD, + GRAY, + DARK_GRAY, + BLUE, + GREEN, + AQUA, + RED, + LIGHT_PURPLE, + YELLOW, + WHITE; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/ChatVisibility.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/ChatVisibility.java index a2ebea3b5..8ce8c22c4 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/ChatVisibility.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/ChatVisibility.java @@ -2,8 +2,8 @@ public enum ChatVisibility { - FULL, - SYSTEM, - HIDDEN; + FULL, + SYSTEM, + HIDDEN; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/Difficulty.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/Difficulty.java index 25aa07395..440646303 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/Difficulty.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/Difficulty.java @@ -2,9 +2,9 @@ public enum Difficulty { - PEACEFUL, - EASY, - NORMAL, - HARD; + PEACEFUL, + EASY, + NORMAL, + HARD; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/SkinPart.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/SkinPart.java index 64e537f08..85eaa07f8 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/SkinPart.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/setting/SkinPart.java @@ -2,12 +2,12 @@ public enum SkinPart { - CAPE, - JACKET, - LEFT_SLEEVE, - RIGHT_SLEEVE, - LEFT_PANTS_LEG, - RIGHT_PANTS_LEG, - HAT; + CAPE, + JACKET, + LEFT_SLEEVE, + RIGHT_SLEEVE, + LEFT_PANTS_LEG, + RIGHT_PANTS_LEG, + HAT; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/Achievement.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/Achievement.java index 4e4567f4a..dcc65b5ce 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/Achievement.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/Achievement.java @@ -2,37 +2,37 @@ public enum Achievement implements Statistic { - OPEN_INVENTORY, - GET_WOOD, - MAKE_WORKBENCH, - MAKE_PICKAXE, - MAKE_FURNACE, - GET_IRON, - MAKE_HOE, - MAKE_BREAD, - MAKE_CAKE, - MAKE_IRON_PICKAXE, - COOK_FISH, - RIDE_MINECART_1000_BLOCKS, - MAKE_SWORD, - KILL_ENEMY, - KILL_COW, - FLY_PIG, - SNIPE_SKELETON, - GET_DIAMONDS, - GIVE_DIAMONDS, - ENTER_PORTAL, - ATTACKED_BY_GHAST, - GET_BLAZE_ROD, - MAKE_POTION, - GO_TO_THE_END, - DEFEAT_ENDER_DRAGON, - DEAL_18_OR_MORE_DAMAGE, - MAKE_BOOKCASE, - BREED_COW, - SPAWN_WITHER, - KILL_WITHER, - MAKE_FULL_BEACON, - EXPLORE_ALL_BIOMES; + OPEN_INVENTORY, + GET_WOOD, + MAKE_WORKBENCH, + MAKE_PICKAXE, + MAKE_FURNACE, + GET_IRON, + MAKE_HOE, + MAKE_BREAD, + MAKE_CAKE, + MAKE_IRON_PICKAXE, + COOK_FISH, + RIDE_MINECART_1000_BLOCKS, + MAKE_SWORD, + KILL_ENEMY, + KILL_COW, + FLY_PIG, + SNIPE_SKELETON, + GET_DIAMONDS, + GIVE_DIAMONDS, + ENTER_PORTAL, + ATTACKED_BY_GHAST, + GET_BLAZE_ROD, + MAKE_POTION, + GO_TO_THE_END, + DEFEAT_ENDER_DRAGON, + DEAL_18_OR_MORE_DAMAGE, + MAKE_BOOKCASE, + BREED_COW, + SPAWN_WITHER, + KILL_WITHER, + MAKE_FULL_BEACON, + EXPLORE_ALL_BIOMES; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/BreakBlockStatistic.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/BreakBlockStatistic.java index a88e991b9..349095ba7 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/BreakBlockStatistic.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/BreakBlockStatistic.java @@ -2,14 +2,14 @@ public class BreakBlockStatistic implements Statistic { - private int id; + private int id; - public BreakBlockStatistic(int id) { - this.id = id; - } + public BreakBlockStatistic(int id) { + this.id = id; + } - public int getId() { - return this.id; - } + public int getId() { + return this.id; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/BreakItemStatistic.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/BreakItemStatistic.java index c4332cac4..969aa80fa 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/BreakItemStatistic.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/BreakItemStatistic.java @@ -2,31 +2,31 @@ public class BreakItemStatistic implements Statistic { - private int id; + private int id; - public BreakItemStatistic(int id) { - this.id = id; - } + public BreakItemStatistic(int id) { + this.id = id; + } - public int getId() { - return this.id; - } + public int getId() { + return this.id; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - BreakItemStatistic that = (BreakItemStatistic) o; + BreakItemStatistic that = (BreakItemStatistic) o; - if (id != that.id) return false; + if(id != that.id) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return id; - } + @Override + public int hashCode() { + return id; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/CraftItemStatistic.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/CraftItemStatistic.java index c9ad0788d..1ca448b0a 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/CraftItemStatistic.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/CraftItemStatistic.java @@ -2,31 +2,31 @@ public class CraftItemStatistic implements Statistic { - private int id; + private int id; - public CraftItemStatistic(int id) { - this.id = id; - } + public CraftItemStatistic(int id) { + this.id = id; + } - public int getId() { - return this.id; - } + public int getId() { + return this.id; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - CraftItemStatistic that = (CraftItemStatistic) o; + CraftItemStatistic that = (CraftItemStatistic) o; - if (id != that.id) return false; + if(id != that.id) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return id; - } + @Override + public int hashCode() { + return id; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/GenericStatistic.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/GenericStatistic.java index 33a3ea1d7..776d3b09a 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/GenericStatistic.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/GenericStatistic.java @@ -2,28 +2,28 @@ public enum GenericStatistic implements Statistic { - TIMES_LEFT_GAME, - MINUTES_PLAYED, - BLOCKS_WALKED, - BLOCKS_SWAM, - BLOCKS_FALLEN, - BLOCKS_CLIMBED, - BLOCKS_FLOWN, - BLOCKS_DOVE, - BLOCKS_TRAVELLED_IN_MINECART, - BLOCKS_TRAVELLED_IN_BOAT, - BLOCKS_RODE_ON_PIG, - BLOCKS_RODE_ON_HORSE, - TIMES_JUMPED, - TIMES_DROPPED_ITEMS, - TIMES_DEALT_DAMAGE, - DAMAGE_TAKEN, - DEATHS, - MOB_KILLS, - ANIMALS_BRED, - PLAYERS_KILLED, - FISH_CAUGHT, - JUNK_FISHED, - TREASURE_FISHED; + TIMES_LEFT_GAME, + MINUTES_PLAYED, + BLOCKS_WALKED, + BLOCKS_SWAM, + BLOCKS_FALLEN, + BLOCKS_CLIMBED, + BLOCKS_FLOWN, + BLOCKS_DOVE, + BLOCKS_TRAVELLED_IN_MINECART, + BLOCKS_TRAVELLED_IN_BOAT, + BLOCKS_RODE_ON_PIG, + BLOCKS_RODE_ON_HORSE, + TIMES_JUMPED, + TIMES_DROPPED_ITEMS, + TIMES_DEALT_DAMAGE, + DAMAGE_TAKEN, + DEATHS, + MOB_KILLS, + ANIMALS_BRED, + PLAYERS_KILLED, + FISH_CAUGHT, + JUNK_FISHED, + TREASURE_FISHED; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/UseItemStatistic.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/UseItemStatistic.java index 5e65d33c7..a617f10d2 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/UseItemStatistic.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/statistic/UseItemStatistic.java @@ -2,31 +2,31 @@ public class UseItemStatistic implements Statistic { - private int id; + private int id; - public UseItemStatistic(int id) { - this.id = id; - } + public UseItemStatistic(int id) { + this.id = id; + } - public int getId() { - return this.id; - } + public int getId() { + return this.id; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - UseItemStatistic that = (UseItemStatistic) o; + UseItemStatistic that = (UseItemStatistic) o; - if (id != that.id) return false; + if(id != that.id) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return id; - } + @Override + public int hashCode() { + return id; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/ClickItemParam.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/ClickItemParam.java index c6eb585cf..4d969f477 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/ClickItemParam.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/ClickItemParam.java @@ -3,7 +3,7 @@ public enum ClickItemParam implements WindowActionParam { - LEFT_CLICK, - RIGHT_CLICK; + LEFT_CLICK, + RIGHT_CLICK; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/CreativeGrabParam.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/CreativeGrabParam.java index 14f25fdb5..e36759ca5 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/CreativeGrabParam.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/CreativeGrabParam.java @@ -3,6 +3,6 @@ public enum CreativeGrabParam implements WindowActionParam { - GRAB; + GRAB; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/DropItemParam.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/DropItemParam.java index 3b2049347..0e76f68c7 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/DropItemParam.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/DropItemParam.java @@ -3,9 +3,9 @@ public enum DropItemParam implements WindowActionParam { - DROP_FROM_SELECTED, - DROP_SELECTED_STACK, - LEFT_CLICK_OUTSIDE_NOT_HOLDING, - RIGHT_CLICK_OUTSIDE_NOT_HOLDING; + DROP_FROM_SELECTED, + DROP_SELECTED_STACK, + LEFT_CLICK_OUTSIDE_NOT_HOLDING, + RIGHT_CLICK_OUTSIDE_NOT_HOLDING; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/FillStackParam.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/FillStackParam.java index b15ba8af6..1d9fad4f5 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/FillStackParam.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/FillStackParam.java @@ -3,6 +3,6 @@ public enum FillStackParam implements WindowActionParam { - FILL; + FILL; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/MoveToHotbarParam.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/MoveToHotbarParam.java index dd98b04f3..1490b4cc7 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/MoveToHotbarParam.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/MoveToHotbarParam.java @@ -3,14 +3,14 @@ public enum MoveToHotbarParam implements WindowActionParam { - SLOT_1, - SLOT_2, - SLOT_3, - SLOT_4, - SLOT_5, - SLOT_6, - SLOT_7, - SLOT_8, - SLOT_9; + SLOT_1, + SLOT_2, + SLOT_3, + SLOT_4, + SLOT_5, + SLOT_6, + SLOT_7, + SLOT_8, + SLOT_9; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/ShiftClickItemParam.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/ShiftClickItemParam.java index e12c0f8a5..788acbe4e 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/ShiftClickItemParam.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/ShiftClickItemParam.java @@ -3,7 +3,7 @@ public enum ShiftClickItemParam implements WindowActionParam { - LEFT_CLICK, - RIGHT_CLICK; + LEFT_CLICK, + RIGHT_CLICK; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/SpreadItemParam.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/SpreadItemParam.java index a7320becc..691000570 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/SpreadItemParam.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/SpreadItemParam.java @@ -3,11 +3,11 @@ public enum SpreadItemParam implements WindowActionParam { - LEFT_MOUSE_BEGIN_DRAG, - LEFT_MOUSE_ADD_SLOT, - LEFT_MOUSE_END_DRAG, - RIGHT_MOUSE_BEGIN_DRAG, - RIGHT_MOUSE_ADD_SLOT, - RIGHT_MOUSE_END_DRAG; + LEFT_MOUSE_BEGIN_DRAG, + LEFT_MOUSE_ADD_SLOT, + LEFT_MOUSE_END_DRAG, + RIGHT_MOUSE_BEGIN_DRAG, + RIGHT_MOUSE_ADD_SLOT, + RIGHT_MOUSE_END_DRAG; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/WindowAction.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/WindowAction.java index 36fc87e32..16df514a0 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/WindowAction.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/WindowAction.java @@ -2,12 +2,12 @@ public enum WindowAction { - CLICK_ITEM, - SHIFT_CLICK_ITEM, - MOVE_TO_HOTBAR_SLOT, - CREATIVE_GRAB_MAX_STACK, - DROP_ITEM, - SPREAD_ITEM, - FILL_STACK; + CLICK_ITEM, + SHIFT_CLICK_ITEM, + MOVE_TO_HOTBAR_SLOT, + CREATIVE_GRAB_MAX_STACK, + DROP_ITEM, + SPREAD_ITEM, + FILL_STACK; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/WindowType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/WindowType.java index 30d702eb7..d56f0979d 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/WindowType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/WindowType.java @@ -2,18 +2,18 @@ public enum WindowType { - GENERIC_INVENTORY, - ANVIL, - BEACON, - BREWING_STAND, - CHEST, - CRAFTING_TABLE, - DISPENSER, - DROPPER, - ENCHANTING_TABLE, - FURNACE, - HOPPER, - VILLAGER, - HORSE; + GENERIC_INVENTORY, + ANVIL, + BEACON, + BREWING_STAND, + CHEST, + CRAFTING_TABLE, + DISPENSER, + DROPPER, + ENCHANTING_TABLE, + FURNACE, + HOPPER, + VILLAGER, + HORSE; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/property/EnchantmentTableProperty.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/property/EnchantmentTableProperty.java index 8a18280e6..02eb29f04 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/window/property/EnchantmentTableProperty.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/window/property/EnchantmentTableProperty.java @@ -27,25 +27,29 @@ public enum EnchantmentTableProperty implements WindowProperty { /** * The enchantment for slot 1. + * * @see #getEnchantment(int, int) */ ENCHANTMENT_SLOT_1, /** * The enchantment for slot 2. + * * @see #getEnchantment(int, int) */ ENCHANTMENT_SLOT_2, /** * The enchantment for slot 3. + * * @see #getEnchantment(int, int) */ ENCHANTMENT_SLOT_3; /** * Packs enchantment type and level into one integer as used for the ENCHANTMENT_SLOT_X properties. - * @param type Id of the enchantment + * + * @param type Id of the enchantment * @param level Level of the enchantment * @return Packed value * @see #getEnchantmentType(int) @@ -57,6 +61,7 @@ public static int getEnchantment(int type, int level) { /** * Unpacks the enchantment type from one integer as used for the ENCHANTMENT_SLOT_X properties. + * * @param enchantmentInfo Packed value * @return Id of the enchantment * @see #getEnchantment(int, int) @@ -67,6 +72,7 @@ public static int getEnchantmentType(int enchantmentInfo) { /** * Unpacks the enchantment level from one integer as used for the ENCHANTMENT_SLOT_X properties. + * * @param enchantmentInfo Packed value * @return Level of the enchantment * @see #getEnchantment(int, int) diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/CustomSound.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/CustomSound.java index 305917e6b..fa916fef3 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/CustomSound.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/CustomSound.java @@ -2,31 +2,31 @@ public class CustomSound implements Sound { - private String name; + private String name; - public CustomSound(String name) { - this.name = name; - } + public CustomSound(String name) { + this.name = name; + } - public String getName() { - return this.name; - } + public String getName() { + return this.name; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - CustomSound that = (CustomSound) o; + CustomSound that = (CustomSound) o; - if (!name.equals(that.name)) return false; + if(!name.equals(that.name)) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return name.hashCode(); - } + @Override + public int hashCode() { + return name.hashCode(); + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/GenericSound.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/GenericSound.java index 3441aa987..9ec2600b4 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/GenericSound.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/GenericSound.java @@ -2,208 +2,208 @@ public enum GenericSound implements Sound { - CLICK, - FIZZ, - FIRE_AMBIENT, - IGNITE_FIRE, - WATER_AMBIENT, - LAVA_AMBIENT, - LAVA_POP, - HARP, - BASS_DRUM, - SNARE_DRUM, - HI_HAT, - DOUBLE_BASS, - PISTON_EXTEND, - PISTON_RETRACT, - PORTAL_AMBIENT, - TNT_PRIMED, - BOW_HIT, - COLLECT_ITEM, - COLLECT_EXP, - SUCCESSFUL_HIT, - FIREWORK_BLAST, - FIREWORK_LARGE_BLAST, - FIREWORK_FAR_BLAST, - FIREWORK_FAR_LARGE_BLAST, - FIREWORK_TWINKLE, - FIREWORK_FAR_TWINKLE, - RAIN_AMBIENT, - WITHER_SPAWN, - ENDER_DRAGON_DEATH, - FIRE_PROJECTILE, - DOOR_OPEN, - DOOR_CLOSE, - GHAST_CHARGE, - GHAST_FIRE, - POUND_WOODEN_DOOR, - POUND_METAL_DOOR, - BREAK_WOODEN_DOOR, - WITHER_SHOOT, - BAT_TAKE_OFF, - INFECT_VILLAGER, - DISINFECT_VILLAGER, - ANVIL_BREAK, - ANVIL_USE, - ANVIL_LAND, - BREAK_SPLASH_POTION, - THORNS_DAMAGE, - EXPLOSION, - CAVE_AMBIENT, - OPEN_CHEST, - CLOSE_CHEST, - DIG_STONE, - DIG_WOOD, - DIG_GRAVEL, - DIG_GRASS, - DIG_CLOTH, - DIG_SAND, - DIG_SNOW, - DIG_GLASS, - ANVIL_STEP, - LADDER_STEP, - STONE_STEP, - WOOD_STEP, - GRAVEL_STEP, - GRASS_STEP, - CLOTH_STEP, - SAND_STEP, - SNOW_STEP, - BURP, - SADDLE_HORSE, - ENDER_DRAGON_FLAP_WINGS, - THUNDER_AMBIENT, - LAUNCH_FIREWORKS, - CREEPER_PRIMED, - ENDERMAN_STARE, - ENDERMAN_TELEPORT, - IRON_GOLEM_THROW, - IRON_GOLEM_WALK, - ZOMBIE_PIGMAN_ANGRY, - SILVERFISH_STEP, - SKELETON_STEP, - SPIDER_STEP, - ZOMBIE_STEP, - ZOMBIE_CURE, - CHICKEN_LAY_EGG, - CHICKEN_STEP, - COW_STEP, - HORSE_EATING, - HORSE_LAND, - HORSE_WEAR_ARMOR, - HORSE_GALLOP, - HORSE_BREATHE, - HORSE_WOOD_STEP, - HORSE_SOFT_STEP, - HORSE_JUMP, - SHEAR_SHEEP, - PIG_STEP, - SHEEP_STEP, - VILLAGER_YES, - VILLAGER_NO, - WOLF_STEP, - WOLF_SHAKE, - DRINK, - EAT, - LEVEL_UP, - FISH_HOOK_SPLASH, - ITEM_BREAK, - SWIM, - SPLASH, - HURT, - DEATH, - BIG_FALL, - SMALL_FALL, - MOB_SWIM, - MOB_SPLASH, - PLAYER_SWIM, - PLAYER_SPLASH, - ENDER_DRAGON_GROWL, - WITHER_IDLE, - BLAZE_BREATHE, - ENDERMAN_SCREAM, - ENDERMAN_IDLE, - GHAST_MOAN, - ZOMBIE_PIGMAN_IDLE, - SILVERFISH_IDLE, - SKELETON_IDLE, - SPIDER_IDLE, - WITCH_IDLE, - ZOMBIE_IDLE, - BAT_IDLE, - CHICKEN_IDLE, - COW_IDLE, - HORSE_IDLE, - DONKEY_IDLE, - ZOMBIE_HORSE_IDLE, - SKELETON_HORSE_IDLE, - OCELOT_PURR, - OCELOT_PURR_MEOW, - OCELOT_MEOW, - PIG_IDLE, - SHEEP_IDLE, - VILLAGER_HAGGLE, - VILLAGER_IDLE, - WOLF_GROWL, - WOLF_PANT, - WOLF_WHINE, - WOLF_BARK, - MOB_BIG_FALL, - MOB_SMALL_FALL, - PLAYER_BIG_FALL, - PLAYER_SMALL_FALL, - ENDER_DRAGON_HURT, - WITHER_HURT, - WITHER_DEATH, - BLAZE_HURT, - BLAZE_DEATH, - CREEPER_HURT, - CREEPER_DEATH, - ENDERMAN_HURT, - ENDERMAN_DEATH, - GHAST_HURT, - GHAST_DEATH, - IRON_GOLEM_HURT, - IRON_GOLEM_DEATH, - MOB_HURT, - MOB_DEATH, - ZOMBIE_PIGMAN_HURT, - ZOMBIE_PIGMAN_DEATH, - SILVERFISH_HURT, - SILVERFISH_DEATH, - SKELETON_HURT, - SKELETON_DEATH, - SLIME, - BIG_SLIME, - SPIDER_DEATH, - WITCH_HURT, - WITCH_DEATH, - ZOMBIE_HURT, - ZOMBIE_DEATH, - PLAYER_HURT, - PLAYER_DEATH, - WOLF_HURT, - WOLF_DEATH, - VILLAGER_HURT, - VILLAGER_DEATH, - PIG_DEATH, - OCELOT_HURT, - HORSE_HURT, - DONKEY_HURT, - ZOMBIE_HORSE_HURT, - SKELETON_HORSE_HURT, - HORSE_DEATH, - DONKEY_DEATH, - ZOMBIE_HORSE_DEATH, - SKELETON_HORSE_DEATH, - COW_HURT, - CHICKEN_HURT, - BAT_HURT, - BAT_DEATH, - RABBIT_IDLE, - RABBIT_HOP, - RABBIT_HURT, - RABBIT_DEATH, - MOB_ATTACK; + CLICK, + FIZZ, + FIRE_AMBIENT, + IGNITE_FIRE, + WATER_AMBIENT, + LAVA_AMBIENT, + LAVA_POP, + HARP, + BASS_DRUM, + SNARE_DRUM, + HI_HAT, + DOUBLE_BASS, + PISTON_EXTEND, + PISTON_RETRACT, + PORTAL_AMBIENT, + TNT_PRIMED, + BOW_HIT, + COLLECT_ITEM, + COLLECT_EXP, + SUCCESSFUL_HIT, + FIREWORK_BLAST, + FIREWORK_LARGE_BLAST, + FIREWORK_FAR_BLAST, + FIREWORK_FAR_LARGE_BLAST, + FIREWORK_TWINKLE, + FIREWORK_FAR_TWINKLE, + RAIN_AMBIENT, + WITHER_SPAWN, + ENDER_DRAGON_DEATH, + FIRE_PROJECTILE, + DOOR_OPEN, + DOOR_CLOSE, + GHAST_CHARGE, + GHAST_FIRE, + POUND_WOODEN_DOOR, + POUND_METAL_DOOR, + BREAK_WOODEN_DOOR, + WITHER_SHOOT, + BAT_TAKE_OFF, + INFECT_VILLAGER, + DISINFECT_VILLAGER, + ANVIL_BREAK, + ANVIL_USE, + ANVIL_LAND, + BREAK_SPLASH_POTION, + THORNS_DAMAGE, + EXPLOSION, + CAVE_AMBIENT, + OPEN_CHEST, + CLOSE_CHEST, + DIG_STONE, + DIG_WOOD, + DIG_GRAVEL, + DIG_GRASS, + DIG_CLOTH, + DIG_SAND, + DIG_SNOW, + DIG_GLASS, + ANVIL_STEP, + LADDER_STEP, + STONE_STEP, + WOOD_STEP, + GRAVEL_STEP, + GRASS_STEP, + CLOTH_STEP, + SAND_STEP, + SNOW_STEP, + BURP, + SADDLE_HORSE, + ENDER_DRAGON_FLAP_WINGS, + THUNDER_AMBIENT, + LAUNCH_FIREWORKS, + CREEPER_PRIMED, + ENDERMAN_STARE, + ENDERMAN_TELEPORT, + IRON_GOLEM_THROW, + IRON_GOLEM_WALK, + ZOMBIE_PIGMAN_ANGRY, + SILVERFISH_STEP, + SKELETON_STEP, + SPIDER_STEP, + ZOMBIE_STEP, + ZOMBIE_CURE, + CHICKEN_LAY_EGG, + CHICKEN_STEP, + COW_STEP, + HORSE_EATING, + HORSE_LAND, + HORSE_WEAR_ARMOR, + HORSE_GALLOP, + HORSE_BREATHE, + HORSE_WOOD_STEP, + HORSE_SOFT_STEP, + HORSE_JUMP, + SHEAR_SHEEP, + PIG_STEP, + SHEEP_STEP, + VILLAGER_YES, + VILLAGER_NO, + WOLF_STEP, + WOLF_SHAKE, + DRINK, + EAT, + LEVEL_UP, + FISH_HOOK_SPLASH, + ITEM_BREAK, + SWIM, + SPLASH, + HURT, + DEATH, + BIG_FALL, + SMALL_FALL, + MOB_SWIM, + MOB_SPLASH, + PLAYER_SWIM, + PLAYER_SPLASH, + ENDER_DRAGON_GROWL, + WITHER_IDLE, + BLAZE_BREATHE, + ENDERMAN_SCREAM, + ENDERMAN_IDLE, + GHAST_MOAN, + ZOMBIE_PIGMAN_IDLE, + SILVERFISH_IDLE, + SKELETON_IDLE, + SPIDER_IDLE, + WITCH_IDLE, + ZOMBIE_IDLE, + BAT_IDLE, + CHICKEN_IDLE, + COW_IDLE, + HORSE_IDLE, + DONKEY_IDLE, + ZOMBIE_HORSE_IDLE, + SKELETON_HORSE_IDLE, + OCELOT_PURR, + OCELOT_PURR_MEOW, + OCELOT_MEOW, + PIG_IDLE, + SHEEP_IDLE, + VILLAGER_HAGGLE, + VILLAGER_IDLE, + WOLF_GROWL, + WOLF_PANT, + WOLF_WHINE, + WOLF_BARK, + MOB_BIG_FALL, + MOB_SMALL_FALL, + PLAYER_BIG_FALL, + PLAYER_SMALL_FALL, + ENDER_DRAGON_HURT, + WITHER_HURT, + WITHER_DEATH, + BLAZE_HURT, + BLAZE_DEATH, + CREEPER_HURT, + CREEPER_DEATH, + ENDERMAN_HURT, + ENDERMAN_DEATH, + GHAST_HURT, + GHAST_DEATH, + IRON_GOLEM_HURT, + IRON_GOLEM_DEATH, + MOB_HURT, + MOB_DEATH, + ZOMBIE_PIGMAN_HURT, + ZOMBIE_PIGMAN_DEATH, + SILVERFISH_HURT, + SILVERFISH_DEATH, + SKELETON_HURT, + SKELETON_DEATH, + SLIME, + BIG_SLIME, + SPIDER_DEATH, + WITCH_HURT, + WITCH_DEATH, + ZOMBIE_HURT, + ZOMBIE_DEATH, + PLAYER_HURT, + PLAYER_DEATH, + WOLF_HURT, + WOLF_DEATH, + VILLAGER_HURT, + VILLAGER_DEATH, + PIG_DEATH, + OCELOT_HURT, + HORSE_HURT, + DONKEY_HURT, + ZOMBIE_HORSE_HURT, + SKELETON_HORSE_HURT, + HORSE_DEATH, + DONKEY_DEATH, + ZOMBIE_HORSE_DEATH, + SKELETON_HORSE_DEATH, + COW_HURT, + CHICKEN_HURT, + BAT_HURT, + BAT_DEATH, + RABBIT_IDLE, + RABBIT_HOP, + RABBIT_HURT, + RABBIT_DEATH, + MOB_ATTACK; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/Particle.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/Particle.java index 363b04084..8f3cdf0a8 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/Particle.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/Particle.java @@ -1,60 +1,60 @@ package org.spacehq.mc.protocol.data.game.values.world; public enum Particle { - EXPLOSION_NORMAL, - EXPLOSION_LARGE, - EXPLOSION_HUGE, - FIREWORKS_SPARK, - WATER_BUBBLE, - WATER_SPLASH, - WATER_WAKE, - SUSPENDED, - SUSPENDED_DEPTH, - CRIT, - CRIT_MAGIC, - SMOKE_NORMAL, - SMOKE_LARGE, - SPELL, - SPELL_INSTANT, - SPELL_MOB, - SPELL_MOB_AMBIENT, - SPELL_WITCH, - DRIP_WATER, - DRIP_LAVA, - VILLAGER_ANGRY, - VILLAGER_HAPPY, - TOWN_AURA, - NOTE, - PORTAL, - ENCHANTMENT_TABLE, - FLAME, - LAVA, - FOOTSTEP, - CLOUD, - REDSTONE, - SNOWBALL, - SNOW_SHOVEL, - SLIME, - HEART, - BARRIER, - ICON_CRACK(2), - BLOCK_CRACK(1), - BLOCK_DUST(1), - WATER_DROP, - ITEM_TAKE, - MOB_APPEARANCE; + EXPLOSION_NORMAL, + EXPLOSION_LARGE, + EXPLOSION_HUGE, + FIREWORKS_SPARK, + WATER_BUBBLE, + WATER_SPLASH, + WATER_WAKE, + SUSPENDED, + SUSPENDED_DEPTH, + CRIT, + CRIT_MAGIC, + SMOKE_NORMAL, + SMOKE_LARGE, + SPELL, + SPELL_INSTANT, + SPELL_MOB, + SPELL_MOB_AMBIENT, + SPELL_WITCH, + DRIP_WATER, + DRIP_LAVA, + VILLAGER_ANGRY, + VILLAGER_HAPPY, + TOWN_AURA, + NOTE, + PORTAL, + ENCHANTMENT_TABLE, + FLAME, + LAVA, + FOOTSTEP, + CLOUD, + REDSTONE, + SNOWBALL, + SNOW_SHOVEL, + SLIME, + HEART, + BARRIER, + ICON_CRACK(2), + BLOCK_CRACK(1), + BLOCK_DUST(1), + WATER_DROP, + ITEM_TAKE, + MOB_APPEARANCE; - private int dataLength; + private int dataLength; - private Particle() { - this(0); - } + private Particle() { + this(0); + } - private Particle(int dataLength) { - this.dataLength = dataLength; - } + private Particle(int dataLength) { + this.dataLength = dataLength; + } - public int getDataLength() { - return this.dataLength; - } + public int getDataLength() { + return this.dataLength; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/WorldBorderAction.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/WorldBorderAction.java index b40477c26..ab9ff354e 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/WorldBorderAction.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/WorldBorderAction.java @@ -1,10 +1,10 @@ package org.spacehq.mc.protocol.data.game.values.world; public enum WorldBorderAction { - SET_SIZE, - LERP_SIZE, - SET_CENTER, - INITIALIZE, - SET_WARNING_TIME, - SET_WARNING_BLOCKS; + SET_SIZE, + LERP_SIZE, + SET_CENTER, + INITIALIZE, + SET_WARNING_TIME, + SET_WARNING_BLOCKS; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/WorldType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/WorldType.java index 38db02ecd..2ffd57890 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/WorldType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/WorldType.java @@ -2,12 +2,12 @@ public enum WorldType { - DEFAULT, - FLAT, - LARGE_BIOMES, - AMPLIFIED, - CUSTOMIZED, - DEBUG, - DEFAULT_1_1; + DEFAULT, + FLAT, + LARGE_BIOMES, + AMPLIFIED, + CUSTOMIZED, + DEBUG, + DEFAULT_1_1; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/BlockChangeRecord.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/BlockChangeRecord.java index 65eb3b172..770563765 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/BlockChangeRecord.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/BlockChangeRecord.java @@ -4,40 +4,40 @@ public class BlockChangeRecord { - private Position position; - private int block; + private Position position; + private int block; - public BlockChangeRecord(Position position, int block) { - this.position = position; - this.block = block; - } + public BlockChangeRecord(Position position, int block) { + this.position = position; + this.block = block; + } - public Position getPosition() { - return this.position; - } + public Position getPosition() { + return this.position; + } - public int getBlock() { - return this.block; - } + public int getBlock() { + return this.block; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - BlockChangeRecord record = (BlockChangeRecord) o; + BlockChangeRecord record = (BlockChangeRecord) o; - if (block != record.block) return false; - if (!position.equals(record.position)) return false; + if(block != record.block) return false; + if(!position.equals(record.position)) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - int result = position.hashCode(); - result = 31 * result + block; - return result; - } + @Override + public int hashCode() { + int result = position.hashCode(); + result = 31 * result + block; + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/ExplodedBlockRecord.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/ExplodedBlockRecord.java index 3c652519c..e6a52d69a 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/ExplodedBlockRecord.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/ExplodedBlockRecord.java @@ -2,48 +2,48 @@ public class ExplodedBlockRecord { - private int x; - private int y; - private int z; - - public ExplodedBlockRecord(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - public int getX() { - return this.x; - } - - public int getY() { - return this.y; - } - - public int getZ() { - return this.z; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ExplodedBlockRecord that = (ExplodedBlockRecord) o; - - if (x != that.x) return false; - if (y != that.y) return false; - if (z != that.z) return false; - - return true; - } - - @Override - public int hashCode() { - int result = x; - result = 31 * result + y; - result = 31 * result + z; - return result; - } + private int x; + private int y; + private int z; + + public ExplodedBlockRecord(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public int getX() { + return this.x; + } + + public int getY() { + return this.y; + } + + public int getZ() { + return this.z; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + ExplodedBlockRecord that = (ExplodedBlockRecord) o; + + if(x != that.x) return false; + if(y != that.y) return false; + if(z != that.z) return false; + + return true; + } + + @Override + public int hashCode() { + int result = x; + result = 31 * result + y; + result = 31 * result + z; + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/UpdatedTileType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/UpdatedTileType.java index e3d8d99c9..dba182f86 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/UpdatedTileType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/UpdatedTileType.java @@ -2,11 +2,11 @@ public enum UpdatedTileType { - MOB_SPAWNER, - COMMAND_BLOCK, - BEACON, - SKULL, - FLOWER_POT, - BANNER; + MOB_SPAWNER, + COMMAND_BLOCK, + BEACON, + SKULL, + FLOWER_POT, + BANNER; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/ChestValue.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/ChestValue.java index 6feaedc11..83c2e602b 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/ChestValue.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/ChestValue.java @@ -2,31 +2,31 @@ public class ChestValue implements BlockValue { - private int viewers; + private int viewers; - public ChestValue(int viewers) { - this.viewers = viewers; - } + public ChestValue(int viewers) { + this.viewers = viewers; + } - public int getViewers() { - return this.viewers; - } + public int getViewers() { + return this.viewers; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - ChestValue that = (ChestValue) o; + ChestValue that = (ChestValue) o; - if (viewers != that.viewers) return false; + if(viewers != that.viewers) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return viewers; - } + @Override + public int hashCode() { + return viewers; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/ChestValueType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/ChestValueType.java index 0a1e42f59..5e763773a 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/ChestValueType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/ChestValueType.java @@ -2,6 +2,6 @@ public enum ChestValueType implements BlockValueType { - VIEWING_PLAYER_COUNT; + VIEWING_PLAYER_COUNT; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/GenericBlockValue.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/GenericBlockValue.java index bc0e17340..d5cbc1f27 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/GenericBlockValue.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/GenericBlockValue.java @@ -2,31 +2,31 @@ public class GenericBlockValue implements BlockValue { - private int value; + private int value; - public GenericBlockValue(int value) { - this.value = value; - } + public GenericBlockValue(int value) { + this.value = value; + } - public int getValue() { - return this.value; - } + public int getValue() { + return this.value; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - GenericBlockValue that = (GenericBlockValue) o; + GenericBlockValue that = (GenericBlockValue) o; - if (value != that.value) return false; + if(value != that.value) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return value; - } + @Override + public int hashCode() { + return value; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/GenericBlockValueType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/GenericBlockValueType.java index 3106e758a..d50c6b123 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/GenericBlockValueType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/GenericBlockValueType.java @@ -2,6 +2,6 @@ public enum GenericBlockValueType implements BlockValueType { - GENERIC; + GENERIC; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/MobSpawnerValueType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/MobSpawnerValueType.java index 64a8a0608..7351a3ab8 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/MobSpawnerValueType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/MobSpawnerValueType.java @@ -2,6 +2,6 @@ public enum MobSpawnerValueType implements BlockValueType { - RESET_DELAY; + RESET_DELAY; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/NoteBlockValue.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/NoteBlockValue.java index 49ff567b5..68fa1eecc 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/NoteBlockValue.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/NoteBlockValue.java @@ -2,35 +2,35 @@ public class NoteBlockValue implements BlockValue { - private int pitch; + private int pitch; - public NoteBlockValue(int pitch) { - if(pitch < 0 || pitch > 24) { - throw new IllegalArgumentException("Pitch must be between 0 and 24."); - } + public NoteBlockValue(int pitch) { + if(pitch < 0 || pitch > 24) { + throw new IllegalArgumentException("Pitch must be between 0 and 24."); + } - this.pitch = pitch; - } + this.pitch = pitch; + } - public int getPitch() { - return this.pitch; - } + public int getPitch() { + return this.pitch; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - NoteBlockValue that = (NoteBlockValue) o; + NoteBlockValue that = (NoteBlockValue) o; - if (pitch != that.pitch) return false; + if(pitch != that.pitch) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return pitch; - } + @Override + public int hashCode() { + return pitch; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/NoteBlockValueType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/NoteBlockValueType.java index 5106b0000..ddaea8b60 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/NoteBlockValueType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/NoteBlockValueType.java @@ -2,10 +2,10 @@ public enum NoteBlockValueType implements BlockValueType { - HARP, - DOUBLE_BASS, - SNARE_DRUM, - HI_HAT, - BASS_DRUM; + HARP, + DOUBLE_BASS, + SNARE_DRUM, + HI_HAT, + BASS_DRUM; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/PistonValue.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/PistonValue.java index ff9d43937..596a440f4 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/PistonValue.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/PistonValue.java @@ -2,11 +2,11 @@ public enum PistonValue implements BlockValue { - DOWN, - UP, - SOUTH, - WEST, - NORTH, - EAST; + DOWN, + UP, + SOUTH, + WEST, + NORTH, + EAST; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/PistonValueType.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/PistonValueType.java index 0a1118911..3e5204328 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/PistonValueType.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/block/value/PistonValueType.java @@ -2,7 +2,7 @@ public enum PistonValueType implements BlockValueType { - PUSHING, - PULLING; + PUSHING, + PULLING; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/BreakBlockEffectData.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/BreakBlockEffectData.java index fd021c79f..92f54a7da 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/BreakBlockEffectData.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/BreakBlockEffectData.java @@ -2,31 +2,31 @@ public class BreakBlockEffectData implements WorldEffectData { - private int blockId; + private int blockId; - public BreakBlockEffectData(int blockId) { - this.blockId = blockId; - } + public BreakBlockEffectData(int blockId) { + this.blockId = blockId; + } - public int getBlockId() { - return this.blockId; - } + public int getBlockId() { + return this.blockId; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - BreakBlockEffectData that = (BreakBlockEffectData) o; + BreakBlockEffectData that = (BreakBlockEffectData) o; - if (blockId != that.blockId) return false; + if(blockId != that.blockId) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return blockId; - } + @Override + public int hashCode() { + return blockId; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/BreakPotionEffectData.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/BreakPotionEffectData.java index 2a096b39f..02a04e102 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/BreakPotionEffectData.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/BreakPotionEffectData.java @@ -2,31 +2,31 @@ public class BreakPotionEffectData implements WorldEffectData { - private int potionId; + private int potionId; - public BreakPotionEffectData(int potionId) { - this.potionId = potionId; - } + public BreakPotionEffectData(int potionId) { + this.potionId = potionId; + } - public int getPotionId() { - return this.potionId; - } + public int getPotionId() { + return this.potionId; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - BreakPotionEffectData that = (BreakPotionEffectData) o; + BreakPotionEffectData that = (BreakPotionEffectData) o; - if (potionId != that.potionId) return false; + if(potionId != that.potionId) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return potionId; - } + @Override + public int hashCode() { + return potionId; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/HardLandingEffectData.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/HardLandingEffectData.java index 95a6895eb..2dd77a205 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/HardLandingEffectData.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/HardLandingEffectData.java @@ -2,31 +2,31 @@ public class HardLandingEffectData implements WorldEffectData { - private int damagingDistance; + private int damagingDistance; - public HardLandingEffectData(int damagingDistance) { - this.damagingDistance = damagingDistance; - } + public HardLandingEffectData(int damagingDistance) { + this.damagingDistance = damagingDistance; + } - public int getDamagingDistance() { - return this.damagingDistance; - } + public int getDamagingDistance() { + return this.damagingDistance; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - HardLandingEffectData that = (HardLandingEffectData) o; + HardLandingEffectData that = (HardLandingEffectData) o; - if (damagingDistance != that.damagingDistance) return false; + if(damagingDistance != that.damagingDistance) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return damagingDistance; - } + @Override + public int hashCode() { + return damagingDistance; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/ParticleEffect.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/ParticleEffect.java index 4dd2aa9b6..7af918aaa 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/ParticleEffect.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/ParticleEffect.java @@ -2,12 +2,12 @@ public enum ParticleEffect implements WorldEffect { - SMOKE, - BREAK_BLOCK, - BREAK_SPLASH_POTION, - BREAK_EYE_OF_ENDER, - MOB_SPAWN, - BONEMEAL_GROW, - HARD_LANDING_DUST; + SMOKE, + BREAK_BLOCK, + BREAK_SPLASH_POTION, + BREAK_EYE_OF_ENDER, + MOB_SPAWN, + BONEMEAL_GROW, + HARD_LANDING_DUST; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/RecordEffectData.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/RecordEffectData.java index ea88fabee..d298e4ca8 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/RecordEffectData.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/RecordEffectData.java @@ -2,31 +2,31 @@ public class RecordEffectData implements WorldEffectData { - private int recordId; + private int recordId; - public RecordEffectData(int recordId) { - this.recordId = recordId; - } + public RecordEffectData(int recordId) { + this.recordId = recordId; + } - public int getRecordId() { - return this.recordId; - } + public int getRecordId() { + return this.recordId; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - RecordEffectData that = (RecordEffectData) o; + RecordEffectData that = (RecordEffectData) o; - if (recordId != that.recordId) return false; + if(recordId != that.recordId) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return recordId; - } + @Override + public int hashCode() { + return recordId; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/SmokeEffectData.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/SmokeEffectData.java index 2af4ce158..c9e69cf88 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/SmokeEffectData.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/SmokeEffectData.java @@ -2,14 +2,14 @@ public enum SmokeEffectData implements WorldEffectData { - SOUTH_EAST, - SOUTH, - SOUTH_WEST, - EAST, - UP, - WEST, - NORTH_EAST, - NORTH, - NORTH_WEST; + SOUTH_EAST, + SOUTH, + SOUTH_WEST, + EAST, + UP, + WEST, + NORTH_EAST, + NORTH, + NORTH_WEST; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/SoundEffect.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/SoundEffect.java index 719391383..eccf52e79 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/SoundEffect.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/effect/SoundEffect.java @@ -2,26 +2,26 @@ public enum SoundEffect implements WorldEffect { - CLICK, - EMPTY_DISPENSER_CLICK, - FIRE_PROJECTILE, - DOOR, - FIZZLE, - PLAY_RECORD, - GHAST_CHARGE, - GHAST_FIRE, - BLAZE_FIRE, - POUND_WOODEN_DOOR, - POUND_METAL_DOOR, - BREAK_WOODEN_DOOR, - WITHER_SPAWN, - WITHER_SHOOT, - BAT_TAKE_OFF, - INFECT_VILLAGER, - DISINFECT_VILLAGER, - ENDER_DRAGON_DEATH, - ANVIL_BREAK, - ANVIL_USE, - ANVIL_LAND; + CLICK, + EMPTY_DISPENSER_CLICK, + FIRE_PROJECTILE, + DOOR, + FIZZLE, + PLAY_RECORD, + GHAST_CHARGE, + GHAST_FIRE, + BLAZE_FIRE, + POUND_WOODEN_DOOR, + POUND_METAL_DOOR, + BREAK_WOODEN_DOOR, + WITHER_SPAWN, + WITHER_SHOOT, + BAT_TAKE_OFF, + INFECT_VILLAGER, + DISINFECT_VILLAGER, + ENDER_DRAGON_DEATH, + ANVIL_BREAK, + ANVIL_USE, + ANVIL_LAND; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/map/MapData.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/map/MapData.java index cd80b8cca..74adce77c 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/map/MapData.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/map/MapData.java @@ -3,64 +3,64 @@ import java.util.Arrays; public class MapData { - private int columns; - private int rows; - private int x; - private int y; - private byte data[]; + private int columns; + private int rows; + private int x; + private int y; + private byte data[]; - public MapData(int columns, int rows, int x, int y, byte data[]) { - this.columns = columns; - this.rows = rows; - this.x = x; - this.y = y; - this.data = data; - } + public MapData(int columns, int rows, int x, int y, byte data[]) { + this.columns = columns; + this.rows = rows; + this.x = x; + this.y = y; + this.data = data; + } - public int getColumns() { - return this.columns; - } + public int getColumns() { + return this.columns; + } - public int getRows() { - return this.rows; - } + public int getRows() { + return this.rows; + } - public int getX() { - return this.x; - } + public int getX() { + return this.x; + } - public int getY() { - return this.y; - } + public int getY() { + return this.y; + } - public byte[] getData() { - return this.data; - } + public byte[] getData() { + return this.data; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - MapData mapData = (MapData) o; + MapData mapData = (MapData) o; - if (columns != mapData.columns) return false; - if (rows != mapData.rows) return false; - if (x != mapData.x) return false; - if (y != mapData.y) return false; - if (!Arrays.equals(data, mapData.data)) return false; + if(columns != mapData.columns) return false; + if(rows != mapData.rows) return false; + if(x != mapData.x) return false; + if(y != mapData.y) return false; + if(!Arrays.equals(data, mapData.data)) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - int result = columns; - result = 31 * result + rows; - result = 31 * result + x; - result = 31 * result + y; - result = 31 * result + Arrays.hashCode(data); - return result; - } + @Override + public int hashCode() { + int result = columns; + result = 31 * result + rows; + result = 31 * result + x; + result = 31 * result + y; + result = 31 * result + Arrays.hashCode(data); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/map/MapPlayer.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/map/MapPlayer.java index b4a0254f6..8ab6fc776 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/map/MapPlayer.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/map/MapPlayer.java @@ -2,56 +2,56 @@ public class MapPlayer { - private int centerX; - private int centerZ; - private int iconSize; - private int iconRotation; - - public MapPlayer(int centerX, int centerZ, int iconSize, int iconRotation) { - this.centerX = centerX; - this.centerZ = centerZ; - this.iconSize = iconSize; - this.iconRotation = iconRotation; - } - - public int getCenterX() { - return this.centerX; - } - - public int getCenterZ() { - return this.centerZ; - } - - public int getIconSize() { - return this.iconSize; - } - - public int getIconRotation() { - return this.iconRotation; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MapPlayer mapPlayer = (MapPlayer) o; - - if (centerX != mapPlayer.centerX) return false; - if (centerZ != mapPlayer.centerZ) return false; - if (iconRotation != mapPlayer.iconRotation) return false; - if (iconSize != mapPlayer.iconSize) return false; - - return true; - } - - @Override - public int hashCode() { - int result = centerX; - result = 31 * result + centerZ; - result = 31 * result + iconSize; - result = 31 * result + iconRotation; - return result; - } + private int centerX; + private int centerZ; + private int iconSize; + private int iconRotation; + + public MapPlayer(int centerX, int centerZ, int iconSize, int iconRotation) { + this.centerX = centerX; + this.centerZ = centerZ; + this.iconSize = iconSize; + this.iconRotation = iconRotation; + } + + public int getCenterX() { + return this.centerX; + } + + public int getCenterZ() { + return this.centerZ; + } + + public int getIconSize() { + return this.iconSize; + } + + public int getIconRotation() { + return this.iconRotation; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + MapPlayer mapPlayer = (MapPlayer) o; + + if(centerX != mapPlayer.centerX) return false; + if(centerZ != mapPlayer.centerZ) return false; + if(iconRotation != mapPlayer.iconRotation) return false; + if(iconSize != mapPlayer.iconSize) return false; + + return true; + } + + @Override + public int hashCode() { + int result = centerX; + result = 31 * result + centerZ; + result = 31 * result + iconSize; + result = 31 * result + iconRotation; + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/ClientNotification.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/ClientNotification.java index 5de68a99d..5273725c6 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/ClientNotification.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/ClientNotification.java @@ -2,14 +2,14 @@ public enum ClientNotification { - INVALID_BED, - START_RAIN, - STOP_RAIN, - CHANGE_GAMEMODE, - ENTER_CREDITS, - DEMO_MESSAGE, - ARROW_HIT_PLAYER, - RAIN_STRENGTH, - THUNDER_STRENGTH; + INVALID_BED, + START_RAIN, + STOP_RAIN, + CHANGE_GAMEMODE, + ENTER_CREDITS, + DEMO_MESSAGE, + ARROW_HIT_PLAYER, + RAIN_STRENGTH, + THUNDER_STRENGTH; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/DemoMessageValue.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/DemoMessageValue.java index 9db952a0a..4ed5b71d9 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/DemoMessageValue.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/DemoMessageValue.java @@ -2,9 +2,9 @@ public enum DemoMessageValue implements ClientNotificationValue { - WELCOME, - MOVEMENT_CONTROLS, - JUMP_CONTROL, - INVENTORY_CONTROL; + WELCOME, + MOVEMENT_CONTROLS, + JUMP_CONTROL, + INVENTORY_CONTROL; } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/RainStrengthValue.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/RainStrengthValue.java index 1e90fc78d..c5c344e75 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/RainStrengthValue.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/RainStrengthValue.java @@ -2,39 +2,39 @@ public class RainStrengthValue implements ClientNotificationValue { - private float strength; + private float strength; - public RainStrengthValue(float strength) { - if(strength > 1) { - strength = 1; - } + public RainStrengthValue(float strength) { + if(strength > 1) { + strength = 1; + } - if(strength < 0) { - strength = 0; - } + if(strength < 0) { + strength = 0; + } - this.strength = strength; - } + this.strength = strength; + } - public float getStrength() { - return this.strength; - } + public float getStrength() { + return this.strength; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - RainStrengthValue that = (RainStrengthValue) o; + RainStrengthValue that = (RainStrengthValue) o; - if (Float.compare(that.strength, strength) != 0) return false; + if(Float.compare(that.strength, strength) != 0) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return (strength != +0.0f ? Float.floatToIntBits(strength) : 0); - } + @Override + public int hashCode() { + return (strength != +0.0f ? Float.floatToIntBits(strength) : 0); + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/ThunderStrengthValue.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/ThunderStrengthValue.java index 9d59db43e..a6b40913e 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/ThunderStrengthValue.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/world/notify/ThunderStrengthValue.java @@ -2,39 +2,39 @@ public class ThunderStrengthValue implements ClientNotificationValue { - private float strength; + private float strength; - public ThunderStrengthValue(float strength) { - if(strength > 1) { - strength = 1; - } + public ThunderStrengthValue(float strength) { + if(strength > 1) { + strength = 1; + } - if(strength < 0) { - strength = 0; - } + if(strength < 0) { + strength = 0; + } - this.strength = strength; - } + this.strength = strength; + } - public float getStrength() { - return this.strength; - } + public float getStrength() { + return this.strength; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - ThunderStrengthValue that = (ThunderStrengthValue) o; + ThunderStrengthValue that = (ThunderStrengthValue) o; - if (Float.compare(that.strength, strength) != 0) return false; + if(Float.compare(that.strength, strength) != 0) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - return (strength != +0.0f ? Float.floatToIntBits(strength) : 0); - } + @Override + public int hashCode() { + return (strength != +0.0f ? Float.floatToIntBits(strength) : 0); + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/message/ChatColor.java b/src/main/java/org/spacehq/mc/protocol/data/message/ChatColor.java index d041455e9..c1b825ff9 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/message/ChatColor.java +++ b/src/main/java/org/spacehq/mc/protocol/data/message/ChatColor.java @@ -2,38 +2,38 @@ public enum ChatColor { - BLACK, - DARK_BLUE, - DARK_GREEN, - DARK_AQUA, - DARK_RED, - DARK_PURPLE, - GOLD, - GRAY, - DARK_GRAY, - BLUE, - GREEN, - AQUA, - RED, - LIGHT_PURPLE, - YELLOW, - WHITE, - RESET; + BLACK, + DARK_BLUE, + DARK_GREEN, + DARK_AQUA, + DARK_RED, + DARK_PURPLE, + GOLD, + GRAY, + DARK_GRAY, + BLUE, + GREEN, + AQUA, + RED, + LIGHT_PURPLE, + YELLOW, + WHITE, + RESET; - @Override - public String toString() { - return this.name().toLowerCase(); - } + @Override + public String toString() { + return this.name().toLowerCase(); + } - public static ChatColor byName(String name) { - name = name.toLowerCase(); - for(ChatColor color : values()) { - if(color.toString().equals(name)) { - return color; - } - } + public static ChatColor byName(String name) { + name = name.toLowerCase(); + for(ChatColor color : values()) { + if(color.toString().equals(name)) { + return color; + } + } - return null; - } + return null; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/message/ChatFormat.java b/src/main/java/org/spacehq/mc/protocol/data/message/ChatFormat.java index 877b09005..59e453940 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/message/ChatFormat.java +++ b/src/main/java/org/spacehq/mc/protocol/data/message/ChatFormat.java @@ -2,26 +2,26 @@ public enum ChatFormat { - BOLD, - UNDERLINED, - STRIKETHROUGH, - ITALIC, - OBFUSCATED; + BOLD, + UNDERLINED, + STRIKETHROUGH, + ITALIC, + OBFUSCATED; - @Override - public String toString() { - return this.name().toLowerCase(); - } + @Override + public String toString() { + return this.name().toLowerCase(); + } - public static ChatFormat byName(String name) { - name = name.toLowerCase(); - for(ChatFormat format : values()) { - if(format.toString().equals(name)) { - return format; - } - } + public static ChatFormat byName(String name) { + name = name.toLowerCase(); + for(ChatFormat format : values()) { + if(format.toString().equals(name)) { + return format; + } + } - return null; - } + return null; + } } \ No newline at end of file diff --git a/src/main/java/org/spacehq/mc/protocol/data/message/ClickAction.java b/src/main/java/org/spacehq/mc/protocol/data/message/ClickAction.java index 394cbe6dc..f3139f6e2 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/message/ClickAction.java +++ b/src/main/java/org/spacehq/mc/protocol/data/message/ClickAction.java @@ -2,25 +2,25 @@ public enum ClickAction { - RUN_COMMAND, - SUGGEST_COMMAND, - OPEN_URL, - OPEN_FILE; + RUN_COMMAND, + SUGGEST_COMMAND, + OPEN_URL, + OPEN_FILE; - @Override - public String toString() { - return this.name().toLowerCase(); - } + @Override + public String toString() { + return this.name().toLowerCase(); + } - public static ClickAction byName(String name) { - name = name.toLowerCase(); - for(ClickAction action : values()) { - if(action.toString().equals(name)) { - return action; - } - } + public static ClickAction byName(String name) { + name = name.toLowerCase(); + for(ClickAction action : values()) { + if(action.toString().equals(name)) { + return action; + } + } - return null; - } + return null; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/message/ClickEvent.java b/src/main/java/org/spacehq/mc/protocol/data/message/ClickEvent.java index 891391ef2..49b2a3e4f 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/message/ClickEvent.java +++ b/src/main/java/org/spacehq/mc/protocol/data/message/ClickEvent.java @@ -2,45 +2,45 @@ public class ClickEvent implements Cloneable { - private ClickAction action; - private String value; - - public ClickEvent(ClickAction action, String value) { - this.action = action; - this.value = value; - } - - public ClickAction getAction() { - return this.action; - } - - public String getValue() { - return this.value; - } - - @Override - public ClickEvent clone() { - return new ClickEvent(this.action, this.value); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ClickEvent that = (ClickEvent) o; - - if (action != that.action) return false; - if (!value.equals(that.value)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = action.hashCode(); - result = 31 * result + value.hashCode(); - return result; - } + private ClickAction action; + private String value; + + public ClickEvent(ClickAction action, String value) { + this.action = action; + this.value = value; + } + + public ClickAction getAction() { + return this.action; + } + + public String getValue() { + return this.value; + } + + @Override + public ClickEvent clone() { + return new ClickEvent(this.action, this.value); + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + ClickEvent that = (ClickEvent) o; + + if(action != that.action) return false; + if(!value.equals(that.value)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = action.hashCode(); + result = 31 * result + value.hashCode(); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/message/HoverAction.java b/src/main/java/org/spacehq/mc/protocol/data/message/HoverAction.java index 75912596e..b6a54da03 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/message/HoverAction.java +++ b/src/main/java/org/spacehq/mc/protocol/data/message/HoverAction.java @@ -2,25 +2,25 @@ public enum HoverAction { - SHOW_TEXT, - SHOW_ITEM, - SHOW_ACHIEVEMENT, - SHOW_ENTITY; + SHOW_TEXT, + SHOW_ITEM, + SHOW_ACHIEVEMENT, + SHOW_ENTITY; - @Override - public String toString() { - return this.name().toLowerCase(); - } + @Override + public String toString() { + return this.name().toLowerCase(); + } - public static HoverAction byName(String name) { - name = name.toLowerCase(); - for(HoverAction action : values()) { - if(action.toString().equals(name)) { - return action; - } - } + public static HoverAction byName(String name) { + name = name.toLowerCase(); + for(HoverAction action : values()) { + if(action.toString().equals(name)) { + return action; + } + } - return null; - } + return null; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/message/HoverEvent.java b/src/main/java/org/spacehq/mc/protocol/data/message/HoverEvent.java index d3181dca4..8961571fe 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/message/HoverEvent.java +++ b/src/main/java/org/spacehq/mc/protocol/data/message/HoverEvent.java @@ -2,45 +2,45 @@ public class HoverEvent implements Cloneable { - private HoverAction action; - private Message value; - - public HoverEvent(HoverAction action, Message value) { - this.action = action; - this.value = value; - } - - public HoverAction getAction() { - return this.action; - } - - public Message getValue() { - return this.value; - } - - @Override - public HoverEvent clone() { - return new HoverEvent(this.action, this.value.clone()); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - HoverEvent that = (HoverEvent) o; - - if (action != that.action) return false; - if (!value.equals(that.value)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = action.hashCode(); - result = 31 * result + value.hashCode(); - return result; - } + private HoverAction action; + private Message value; + + public HoverEvent(HoverAction action, Message value) { + this.action = action; + this.value = value; + } + + public HoverAction getAction() { + return this.action; + } + + public Message getValue() { + return this.value; + } + + @Override + public HoverEvent clone() { + return new HoverEvent(this.action, this.value.clone()); + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + HoverEvent that = (HoverEvent) o; + + if(action != that.action) return false; + if(!value.equals(that.value)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = action.hashCode(); + result = 31 * result + value.hashCode(); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/message/Message.java b/src/main/java/org/spacehq/mc/protocol/data/message/Message.java index 544b2afba..2f0dbf8b7 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/message/Message.java +++ b/src/main/java/org/spacehq/mc/protocol/data/message/Message.java @@ -10,213 +10,213 @@ public abstract class Message implements Cloneable { - private MessageStyle style = new MessageStyle(); - private List extra = new ArrayList(); - - public abstract String getText(); - - public String getFullText() { - StringBuilder build = new StringBuilder(this.getText()); - for(Message msg : this.extra) { - build.append(msg.getFullText()); - } - - return build.toString(); - } - - public MessageStyle getStyle() { - return this.style; - } - - public List getExtra() { - return new ArrayList(this.extra); - } - - public Message setStyle(MessageStyle style) { - this.style = style; - return this; - } - - public Message setExtra(List extra) { - this.extra = new ArrayList(extra); - for(Message msg : this.extra) { - msg.getStyle().setParent(this.style); - } - - return this; - } - - public Message addExtra(Message message) { - this.extra.add(message); - message.getStyle().setParent(this.style); - return this; - } - - public Message removeExtra(Message message) { - this.extra.remove(message); - message.getStyle().setParent(null); - return this; - } - - public Message clearExtra() { - for(Message msg : this.extra) { - msg.getStyle().setParent(null); - } - - this.extra.clear(); - return this; - } - - @Override - public String toString() { - return this.getFullText(); - } - - @Override - public abstract Message clone(); - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Message message = (Message) o; - - if (!extra.equals(message.extra)) return false; - if (!style.equals(message.style)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = style.hashCode(); - result = 31 * result + extra.hashCode(); - return result; - } - - public String toJsonString() { - return this.toJson().toString(); - } - - public JsonElement toJson() { - JsonObject json = new JsonObject(); - json.addProperty("color", this.style.getColor().toString()); - for(ChatFormat format : this.style.getFormats()) { - json.addProperty(format.toString(), true); - } - - if(this.style.getClickEvent() != null) { - JsonObject click = new JsonObject(); - click.addProperty("action", this.style.getClickEvent().getAction().toString()); - click.addProperty("value", this.style.getClickEvent().getValue()); - json.add("clickEvent", click); - } - - if(this.style.getHoverEvent() != null) { - JsonObject hover = new JsonObject(); - hover.addProperty("action", this.style.getHoverEvent().getAction().toString()); - hover.add("value", this.style.getHoverEvent().getValue().toJson()); - json.add("hoverEvent", hover); - } - - if(this.style.getInsertion() != null) { - json.addProperty("insertion", this.style.getInsertion()); - } - - if(this.extra.size() > 0) { - JsonArray extra = new JsonArray(); - for(Message msg : this.extra) { - extra.add(msg.toJson()); - } - - json.add("extra", extra); - } - - return json; - } - - public static Message fromString(String str) { - try { - return fromJson(new JsonParser().parse(str)); - } catch(Exception e) { - return new TextMessage(str); - } - } - - public static Message fromJson(JsonElement e) { - if(e.isJsonPrimitive()) { - return new TextMessage(e.getAsString()); - } else if(e.isJsonObject()) { - JsonObject json = e.getAsJsonObject(); - Message msg = null; - if(json.has("text")) { - msg = new TextMessage(json.get("text").getAsString()); - } else if(json.has("translate")) { - Message with[] = new Message[0]; - if(json.has("with")) { - JsonArray withJson = json.get("with").getAsJsonArray(); - with = new Message[withJson.size()]; - for(int index = 0; index < withJson.size(); index++) { - JsonElement el = withJson.get(index); - if(el.isJsonPrimitive()) { - with[index] = new TextMessage(el.getAsString()); - } else { - with[index] = Message.fromJson(el.getAsJsonObject()); - } - } - } - - msg = new TranslationMessage(json.get("translate").getAsString(), with); - } else { - throw new IllegalArgumentException("Unknown message type in json: " + json.toString()); - } - - MessageStyle style = new MessageStyle(); - if(json.has("color")) { - style.setColor(ChatColor.byName(json.get("color").getAsString())); - } - - for(ChatFormat format : ChatFormat.values()) { - if(json.has(format.toString()) && json.get(format.toString()).getAsBoolean()) { - style.addFormat(format); - } - } - - if(json.has("clickEvent")) { - JsonObject click = json.get("clickEvent").getAsJsonObject(); - style.setClickEvent(new ClickEvent(ClickAction.byName(click.get("action").getAsString()), click.get("value").getAsString())); - } - - if(json.has("hoverEvent")) { - JsonObject hover = json.get("hoverEvent").getAsJsonObject(); - style.setHoverEvent(new HoverEvent(HoverAction.byName(hover.get("action").getAsString()), Message.fromJson(hover.get("value")))); - } - - if(json.has("insertion")) { - style.setInsertion(json.get("insertion").getAsString()); - } - - msg.setStyle(style); - if(json.has("extra")) { - JsonArray extraJson = json.get("extra").getAsJsonArray(); - List extra = new ArrayList(); - for(int index = 0; index < extraJson.size(); index++) { - JsonElement el = extraJson.get(index); - if(el.isJsonPrimitive()) { - extra.add(new TextMessage(el.getAsString())); - } else { - extra.add(Message.fromJson(el.getAsJsonObject())); - } - } - - msg.setExtra(extra); - } - - return msg; - } else { - throw new IllegalArgumentException("Cannot convert " + e.getClass().getSimpleName() + " to a message."); - } - } + private MessageStyle style = new MessageStyle(); + private List extra = new ArrayList(); + + public abstract String getText(); + + public String getFullText() { + StringBuilder build = new StringBuilder(this.getText()); + for(Message msg : this.extra) { + build.append(msg.getFullText()); + } + + return build.toString(); + } + + public MessageStyle getStyle() { + return this.style; + } + + public List getExtra() { + return new ArrayList(this.extra); + } + + public Message setStyle(MessageStyle style) { + this.style = style; + return this; + } + + public Message setExtra(List extra) { + this.extra = new ArrayList(extra); + for(Message msg : this.extra) { + msg.getStyle().setParent(this.style); + } + + return this; + } + + public Message addExtra(Message message) { + this.extra.add(message); + message.getStyle().setParent(this.style); + return this; + } + + public Message removeExtra(Message message) { + this.extra.remove(message); + message.getStyle().setParent(null); + return this; + } + + public Message clearExtra() { + for(Message msg : this.extra) { + msg.getStyle().setParent(null); + } + + this.extra.clear(); + return this; + } + + @Override + public String toString() { + return this.getFullText(); + } + + @Override + public abstract Message clone(); + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + Message message = (Message) o; + + if(!extra.equals(message.extra)) return false; + if(!style.equals(message.style)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = style.hashCode(); + result = 31 * result + extra.hashCode(); + return result; + } + + public String toJsonString() { + return this.toJson().toString(); + } + + public JsonElement toJson() { + JsonObject json = new JsonObject(); + json.addProperty("color", this.style.getColor().toString()); + for(ChatFormat format : this.style.getFormats()) { + json.addProperty(format.toString(), true); + } + + if(this.style.getClickEvent() != null) { + JsonObject click = new JsonObject(); + click.addProperty("action", this.style.getClickEvent().getAction().toString()); + click.addProperty("value", this.style.getClickEvent().getValue()); + json.add("clickEvent", click); + } + + if(this.style.getHoverEvent() != null) { + JsonObject hover = new JsonObject(); + hover.addProperty("action", this.style.getHoverEvent().getAction().toString()); + hover.add("value", this.style.getHoverEvent().getValue().toJson()); + json.add("hoverEvent", hover); + } + + if(this.style.getInsertion() != null) { + json.addProperty("insertion", this.style.getInsertion()); + } + + if(this.extra.size() > 0) { + JsonArray extra = new JsonArray(); + for(Message msg : this.extra) { + extra.add(msg.toJson()); + } + + json.add("extra", extra); + } + + return json; + } + + public static Message fromString(String str) { + try { + return fromJson(new JsonParser().parse(str)); + } catch(Exception e) { + return new TextMessage(str); + } + } + + public static Message fromJson(JsonElement e) { + if(e.isJsonPrimitive()) { + return new TextMessage(e.getAsString()); + } else if(e.isJsonObject()) { + JsonObject json = e.getAsJsonObject(); + Message msg = null; + if(json.has("text")) { + msg = new TextMessage(json.get("text").getAsString()); + } else if(json.has("translate")) { + Message with[] = new Message[0]; + if(json.has("with")) { + JsonArray withJson = json.get("with").getAsJsonArray(); + with = new Message[withJson.size()]; + for(int index = 0; index < withJson.size(); index++) { + JsonElement el = withJson.get(index); + if(el.isJsonPrimitive()) { + with[index] = new TextMessage(el.getAsString()); + } else { + with[index] = Message.fromJson(el.getAsJsonObject()); + } + } + } + + msg = new TranslationMessage(json.get("translate").getAsString(), with); + } else { + throw new IllegalArgumentException("Unknown message type in json: " + json.toString()); + } + + MessageStyle style = new MessageStyle(); + if(json.has("color")) { + style.setColor(ChatColor.byName(json.get("color").getAsString())); + } + + for(ChatFormat format : ChatFormat.values()) { + if(json.has(format.toString()) && json.get(format.toString()).getAsBoolean()) { + style.addFormat(format); + } + } + + if(json.has("clickEvent")) { + JsonObject click = json.get("clickEvent").getAsJsonObject(); + style.setClickEvent(new ClickEvent(ClickAction.byName(click.get("action").getAsString()), click.get("value").getAsString())); + } + + if(json.has("hoverEvent")) { + JsonObject hover = json.get("hoverEvent").getAsJsonObject(); + style.setHoverEvent(new HoverEvent(HoverAction.byName(hover.get("action").getAsString()), Message.fromJson(hover.get("value")))); + } + + if(json.has("insertion")) { + style.setInsertion(json.get("insertion").getAsString()); + } + + msg.setStyle(style); + if(json.has("extra")) { + JsonArray extraJson = json.get("extra").getAsJsonArray(); + List extra = new ArrayList(); + for(int index = 0; index < extraJson.size(); index++) { + JsonElement el = extraJson.get(index); + if(el.isJsonPrimitive()) { + extra.add(new TextMessage(el.getAsString())); + } else { + extra.add(Message.fromJson(el.getAsJsonObject())); + } + } + + msg.setExtra(extra); + } + + return msg; + } else { + throw new IllegalArgumentException("Cannot convert " + e.getClass().getSimpleName() + " to a message."); + } + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/message/MessageStyle.java b/src/main/java/org/spacehq/mc/protocol/data/message/MessageStyle.java index 9db92f94d..80b05f59c 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/message/MessageStyle.java +++ b/src/main/java/org/spacehq/mc/protocol/data/message/MessageStyle.java @@ -5,128 +5,128 @@ public class MessageStyle implements Cloneable { - private static final MessageStyle DEFAULT = new MessageStyle(); - - private ChatColor color = ChatColor.WHITE; - private List formats = new ArrayList(); - private ClickEvent click; - private HoverEvent hover; - private String insertion; - private MessageStyle parent = DEFAULT; - - public boolean isDefault() { - return this.equals(DEFAULT); - } - - public ChatColor getColor() { - return this.color; - } - - public List getFormats() { - return new ArrayList(this.formats); - } - - public ClickEvent getClickEvent() { - return this.click; - } - - public HoverEvent getHoverEvent() { - return this.hover; - } - - public String getInsertion() { - return this.insertion; - } - - public MessageStyle getParent() { - return this.parent; - } - - public MessageStyle setColor(ChatColor color) { - this.color = color; - return this; - } - - public MessageStyle setFormats(List formats) { - this.formats = new ArrayList(formats); - return this; - } - - public MessageStyle addFormat(ChatFormat format) { - this.formats.add(format); - return this; - } - - public MessageStyle removeFormat(ChatFormat format) { - this.formats.remove(format); - return this; - } - - public MessageStyle clearFormats() { - this.formats.clear(); - return this; - } - - public MessageStyle setClickEvent(ClickEvent event) { - this.click = event; - return this; - } - - public MessageStyle setHoverEvent(HoverEvent event) { - this.hover = event; - return this; - } - - public MessageStyle setInsertion(String insertion) { - this.insertion = insertion; - return this; - } - - protected MessageStyle setParent(MessageStyle parent) { - if(parent == null) { - parent = DEFAULT; - } - - this.parent = parent; - return this; - } - - @Override - public String toString() { - return "MessageStyle{color=" + this.color + ",formats=" + this.formats + ",clickEvent=" + this.click + ",hoverEvent=" + this.hover + ",insertion=" + this.insertion + "}"; - } - - @Override - public MessageStyle clone() { - return new MessageStyle().setParent(this.parent).setColor(this.color).setFormats(this.formats).setClickEvent(this.click != null ? this.click.clone() : null).setHoverEvent(this.hover != null ? this.hover.clone() : null).setInsertion(this.insertion); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MessageStyle style = (MessageStyle) o; - - if (click != null ? !click.equals(style.click) : style.click != null) return false; - if (color != style.color) return false; - if (!formats.equals(style.formats)) return false; - if (hover != null ? !hover.equals(style.hover) : style.hover != null) return false; - if (insertion != null ? !insertion.equals(style.insertion) : style.insertion != null) return false; - if (!parent.equals(style.parent)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = color != null ? color.hashCode() : 0; - result = 31 * result + formats.hashCode(); - result = 31 * result + (click != null ? click.hashCode() : 0); - result = 31 * result + (hover != null ? hover.hashCode() : 0); - result = 31 * result + (insertion != null ? insertion.hashCode() : 0); - result = 31 * result + parent.hashCode(); - return result; - } + private static final MessageStyle DEFAULT = new MessageStyle(); + + private ChatColor color = ChatColor.WHITE; + private List formats = new ArrayList(); + private ClickEvent click; + private HoverEvent hover; + private String insertion; + private MessageStyle parent = DEFAULT; + + public boolean isDefault() { + return this.equals(DEFAULT); + } + + public ChatColor getColor() { + return this.color; + } + + public List getFormats() { + return new ArrayList(this.formats); + } + + public ClickEvent getClickEvent() { + return this.click; + } + + public HoverEvent getHoverEvent() { + return this.hover; + } + + public String getInsertion() { + return this.insertion; + } + + public MessageStyle getParent() { + return this.parent; + } + + public MessageStyle setColor(ChatColor color) { + this.color = color; + return this; + } + + public MessageStyle setFormats(List formats) { + this.formats = new ArrayList(formats); + return this; + } + + public MessageStyle addFormat(ChatFormat format) { + this.formats.add(format); + return this; + } + + public MessageStyle removeFormat(ChatFormat format) { + this.formats.remove(format); + return this; + } + + public MessageStyle clearFormats() { + this.formats.clear(); + return this; + } + + public MessageStyle setClickEvent(ClickEvent event) { + this.click = event; + return this; + } + + public MessageStyle setHoverEvent(HoverEvent event) { + this.hover = event; + return this; + } + + public MessageStyle setInsertion(String insertion) { + this.insertion = insertion; + return this; + } + + protected MessageStyle setParent(MessageStyle parent) { + if(parent == null) { + parent = DEFAULT; + } + + this.parent = parent; + return this; + } + + @Override + public String toString() { + return "MessageStyle{color=" + this.color + ",formats=" + this.formats + ",clickEvent=" + this.click + ",hoverEvent=" + this.hover + ",insertion=" + this.insertion + "}"; + } + + @Override + public MessageStyle clone() { + return new MessageStyle().setParent(this.parent).setColor(this.color).setFormats(this.formats).setClickEvent(this.click != null ? this.click.clone() : null).setHoverEvent(this.hover != null ? this.hover.clone() : null).setInsertion(this.insertion); + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + MessageStyle style = (MessageStyle) o; + + if(click != null ? !click.equals(style.click) : style.click != null) return false; + if(color != style.color) return false; + if(!formats.equals(style.formats)) return false; + if(hover != null ? !hover.equals(style.hover) : style.hover != null) return false; + if(insertion != null ? !insertion.equals(style.insertion) : style.insertion != null) return false; + if(!parent.equals(style.parent)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = color != null ? color.hashCode() : 0; + result = 31 * result + formats.hashCode(); + result = 31 * result + (click != null ? click.hashCode() : 0); + result = 31 * result + (hover != null ? hover.hashCode() : 0); + result = 31 * result + (insertion != null ? insertion.hashCode() : 0); + result = 31 * result + parent.hashCode(); + return result; + } } \ No newline at end of file diff --git a/src/main/java/org/spacehq/mc/protocol/data/message/TextMessage.java b/src/main/java/org/spacehq/mc/protocol/data/message/TextMessage.java index 77374f35e..86c849dc9 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/message/TextMessage.java +++ b/src/main/java/org/spacehq/mc/protocol/data/message/TextMessage.java @@ -6,56 +6,56 @@ public class TextMessage extends Message { - private String text; - - public TextMessage(String text) { - this.text = text; - } - - @Override - public String getText() { - return this.text; - } - - @Override - public TextMessage clone() { - return (TextMessage) new TextMessage(this.getText()).setStyle(this.getStyle().clone()).setExtra(this.getExtra()); - } - - @Override - public JsonElement toJson() { - if(this.getStyle().isDefault() && this.getExtra().isEmpty()) { - return new JsonPrimitive(this.text); - } else { - JsonElement e = super.toJson(); - if(e.isJsonObject()) { - JsonObject json = e.getAsJsonObject(); - json.addProperty("text", this.text); - return json; - } else { - return e; - } - } - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - - TextMessage that = (TextMessage) o; - - if (!text.equals(that.text)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + text.hashCode(); - return result; - } + private String text; + + public TextMessage(String text) { + this.text = text; + } + + @Override + public String getText() { + return this.text; + } + + @Override + public TextMessage clone() { + return (TextMessage) new TextMessage(this.getText()).setStyle(this.getStyle().clone()).setExtra(this.getExtra()); + } + + @Override + public JsonElement toJson() { + if(this.getStyle().isDefault() && this.getExtra().isEmpty()) { + return new JsonPrimitive(this.text); + } else { + JsonElement e = super.toJson(); + if(e.isJsonObject()) { + JsonObject json = e.getAsJsonObject(); + json.addProperty("text", this.text); + return json; + } else { + return e; + } + } + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + if(!super.equals(o)) return false; + + TextMessage that = (TextMessage) o; + + if(!text.equals(that.text)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + text.hashCode(); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/message/TranslationMessage.java b/src/main/java/org/spacehq/mc/protocol/data/message/TranslationMessage.java index 25fbcdfb6..2f30e2b52 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/message/TranslationMessage.java +++ b/src/main/java/org/spacehq/mc/protocol/data/message/TranslationMessage.java @@ -8,89 +8,89 @@ public class TranslationMessage extends Message { - private String translationKey; - private Message translationParams[]; - - public TranslationMessage(String translationKey, Message... translationParams) { - this.translationKey = translationKey; - this.translationParams = translationParams; - this.translationParams = this.getTranslationParams(); - for(Message param : this.translationParams) { - param.getStyle().setParent(this.getStyle()); - } - } - - public String getTranslationKey() { - return this.translationKey; - } - - public Message[] getTranslationParams() { - Message copy[] = Arrays.copyOf(this.translationParams, this.translationParams.length); - for(int index = 0; index < copy.length; index++) { - copy[index] = copy[index].clone(); - } - - return copy; - } - - @Override - public Message setStyle(MessageStyle style) { - super.setStyle(style); - for(Message param : this.translationParams) { - param.getStyle().setParent(this.getStyle()); - } - - return this; - } - - @Override - public String getText() { - return this.translationKey; - } - - @Override - public TranslationMessage clone() { - return (TranslationMessage) new TranslationMessage(this.getTranslationKey(), this.getTranslationParams()).setStyle(this.getStyle().clone()).setExtra(this.getExtra()); - } - - @Override - public JsonElement toJson() { - JsonElement e = super.toJson(); - if(e.isJsonObject()) { - JsonObject json = e.getAsJsonObject(); - json.addProperty("translate", this.translationKey); - JsonArray params = new JsonArray(); - for(Message param : this.translationParams) { - params.add(param.toJson()); - } - - json.add("with", params); - return json; - } else { - return e; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - - TranslationMessage that = (TranslationMessage) o; - - if (!translationKey.equals(that.translationKey)) return false; - if (!Arrays.equals(translationParams, that.translationParams)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + translationKey.hashCode(); - result = 31 * result + Arrays.hashCode(translationParams); - return result; - } + private String translationKey; + private Message translationParams[]; + + public TranslationMessage(String translationKey, Message... translationParams) { + this.translationKey = translationKey; + this.translationParams = translationParams; + this.translationParams = this.getTranslationParams(); + for(Message param : this.translationParams) { + param.getStyle().setParent(this.getStyle()); + } + } + + public String getTranslationKey() { + return this.translationKey; + } + + public Message[] getTranslationParams() { + Message copy[] = Arrays.copyOf(this.translationParams, this.translationParams.length); + for(int index = 0; index < copy.length; index++) { + copy[index] = copy[index].clone(); + } + + return copy; + } + + @Override + public Message setStyle(MessageStyle style) { + super.setStyle(style); + for(Message param : this.translationParams) { + param.getStyle().setParent(this.getStyle()); + } + + return this; + } + + @Override + public String getText() { + return this.translationKey; + } + + @Override + public TranslationMessage clone() { + return (TranslationMessage) new TranslationMessage(this.getTranslationKey(), this.getTranslationParams()).setStyle(this.getStyle().clone()).setExtra(this.getExtra()); + } + + @Override + public JsonElement toJson() { + JsonElement e = super.toJson(); + if(e.isJsonObject()) { + JsonObject json = e.getAsJsonObject(); + json.addProperty("translate", this.translationKey); + JsonArray params = new JsonArray(); + for(Message param : this.translationParams) { + params.add(param.toJson()); + } + + json.add("with", params); + return json; + } else { + return e; + } + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + if(!super.equals(o)) return false; + + TranslationMessage that = (TranslationMessage) o; + + if(!translationKey.equals(that.translationKey)) return false; + if(!Arrays.equals(translationParams, that.translationParams)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + translationKey.hashCode(); + result = 31 * result + Arrays.hashCode(translationParams); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/status/PlayerInfo.java b/src/main/java/org/spacehq/mc/protocol/data/status/PlayerInfo.java index 2065746e2..b41647e57 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/status/PlayerInfo.java +++ b/src/main/java/org/spacehq/mc/protocol/data/status/PlayerInfo.java @@ -6,48 +6,48 @@ public class PlayerInfo { - private int max; - private int online; - private GameProfile players[]; - - public PlayerInfo(int max, int online, GameProfile players[]) { - this.max = max; - this.online = online; - this.players = players; - } - - public int getMaxPlayers() { - return this.max; - } - - public int getOnlinePlayers() { - return this.online; - } - - public GameProfile[] getPlayers() { - return this.players; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - PlayerInfo that = (PlayerInfo) o; - - if (max != that.max) return false; - if (online != that.online) return false; - if (!Arrays.equals(players, that.players)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = max; - result = 31 * result + online; - result = 31 * result + Arrays.hashCode(players); - return result; - } + private int max; + private int online; + private GameProfile players[]; + + public PlayerInfo(int max, int online, GameProfile players[]) { + this.max = max; + this.online = online; + this.players = players; + } + + public int getMaxPlayers() { + return this.max; + } + + public int getOnlinePlayers() { + return this.online; + } + + public GameProfile[] getPlayers() { + return this.players; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + PlayerInfo that = (PlayerInfo) o; + + if(max != that.max) return false; + if(online != that.online) return false; + if(!Arrays.equals(players, that.players)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = max; + result = 31 * result + online; + result = 31 * result + Arrays.hashCode(players); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/status/ServerStatusInfo.java b/src/main/java/org/spacehq/mc/protocol/data/status/ServerStatusInfo.java index 524f8bdd3..ac58ce461 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/status/ServerStatusInfo.java +++ b/src/main/java/org/spacehq/mc/protocol/data/status/ServerStatusInfo.java @@ -6,56 +6,56 @@ public class ServerStatusInfo { - private VersionInfo version; - private PlayerInfo players; - private Message description; - private BufferedImage icon; - - public ServerStatusInfo(VersionInfo version, PlayerInfo players, Message description, BufferedImage icon) { - this.version = version; - this.players = players; - this.description = description; - this.icon = icon; - } - - public VersionInfo getVersionInfo() { - return this.version; - } - - public PlayerInfo getPlayerInfo() { - return this.players; - } - - public Message getDescription() { - return this.description; - } - - public BufferedImage getIcon() { - return this.icon; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ServerStatusInfo that = (ServerStatusInfo) o; - - if (!description.equals(that.description)) return false; - if (icon != null ? !icon.equals(that.icon) : that.icon != null) return false; - if (!players.equals(that.players)) return false; - if (!version.equals(that.version)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = version.hashCode(); - result = 31 * result + players.hashCode(); - result = 31 * result + description.hashCode(); - result = 31 * result + (icon != null ? icon.hashCode() : 0); - return result; - } + private VersionInfo version; + private PlayerInfo players; + private Message description; + private BufferedImage icon; + + public ServerStatusInfo(VersionInfo version, PlayerInfo players, Message description, BufferedImage icon) { + this.version = version; + this.players = players; + this.description = description; + this.icon = icon; + } + + public VersionInfo getVersionInfo() { + return this.version; + } + + public PlayerInfo getPlayerInfo() { + return this.players; + } + + public Message getDescription() { + return this.description; + } + + public BufferedImage getIcon() { + return this.icon; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + ServerStatusInfo that = (ServerStatusInfo) o; + + if(!description.equals(that.description)) return false; + if(icon != null ? !icon.equals(that.icon) : that.icon != null) return false; + if(!players.equals(that.players)) return false; + if(!version.equals(that.version)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = version.hashCode(); + result = 31 * result + players.hashCode(); + result = 31 * result + description.hashCode(); + result = 31 * result + (icon != null ? icon.hashCode() : 0); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/status/VersionInfo.java b/src/main/java/org/spacehq/mc/protocol/data/status/VersionInfo.java index f2ab1c3de..76047b28d 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/status/VersionInfo.java +++ b/src/main/java/org/spacehq/mc/protocol/data/status/VersionInfo.java @@ -2,40 +2,40 @@ public class VersionInfo { - private String name; - private int protocol; + private String name; + private int protocol; - public VersionInfo(String name, int protocol) { - this.name = name; - this.protocol = protocol; - } + public VersionInfo(String name, int protocol) { + this.name = name; + this.protocol = protocol; + } - public String getVersionName() { - return this.name; - } + public String getVersionName() { + return this.name; + } - public int getProtocolVersion() { - return this.protocol; - } + public int getProtocolVersion() { + return this.protocol; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - VersionInfo that = (VersionInfo) o; + VersionInfo that = (VersionInfo) o; - if (protocol != that.protocol) return false; - if (!name.equals(that.name)) return false; + if(protocol != that.protocol) return false; + if(!name.equals(that.name)) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - int result = name.hashCode(); - result = 31 * result + protocol; - return result; - } + @Override + public int hashCode() { + int result = name.hashCode(); + result = 31 * result + protocol; + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerInfoBuilder.java b/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerInfoBuilder.java index d1ca541a6..74a529024 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerInfoBuilder.java +++ b/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerInfoBuilder.java @@ -5,6 +5,6 @@ public interface ServerInfoBuilder { - public ServerStatusInfo buildInfo(Session session); + public ServerStatusInfo buildInfo(Session session); } diff --git a/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerInfoHandler.java b/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerInfoHandler.java index 4a7b1a55c..c6a471ff1 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerInfoHandler.java +++ b/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerInfoHandler.java @@ -6,6 +6,6 @@ public interface ServerInfoHandler { - public void handle(Session session, ServerStatusInfo info); + public void handle(Session session, ServerStatusInfo info); } diff --git a/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerPingTimeHandler.java b/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerPingTimeHandler.java index c08970268..9435167a9 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerPingTimeHandler.java +++ b/src/main/java/org/spacehq/mc/protocol/data/status/handler/ServerPingTimeHandler.java @@ -4,6 +4,6 @@ public interface ServerPingTimeHandler { - public void handle(Session session, long pingTime); + public void handle(Session session, long pingTime); } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/handshake/client/HandshakePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/handshake/client/HandshakePacket.java index 842320b16..97bee128a 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/handshake/client/HandshakePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/handshake/client/HandshakePacket.java @@ -10,57 +10,57 @@ public class HandshakePacket implements Packet { - private int protocolVersion; - private String hostname; - private int port; - private HandshakeIntent intent; + private int protocolVersion; + private String hostname; + private int port; + private HandshakeIntent intent; - @SuppressWarnings("unused") - private HandshakePacket() { - } + @SuppressWarnings("unused") + private HandshakePacket() { + } - public HandshakePacket(int protocolVersion, String hostname, int port, HandshakeIntent intent) { - this.protocolVersion = protocolVersion; - this.hostname = hostname; - this.port = port; - this.intent = intent; - } + public HandshakePacket(int protocolVersion, String hostname, int port, HandshakeIntent intent) { + this.protocolVersion = protocolVersion; + this.hostname = hostname; + this.port = port; + this.intent = intent; + } - public int getProtocolVersion() { - return this.protocolVersion; - } + public int getProtocolVersion() { + return this.protocolVersion; + } - public String getHostName() { - return this.hostname; - } + public String getHostName() { + return this.hostname; + } - public int getPort() { - return this.port; - } + public int getPort() { + return this.port; + } - public HandshakeIntent getIntent() { - return this.intent; - } + public HandshakeIntent getIntent() { + return this.intent; + } - @Override - public void read(NetInput in) throws IOException { - this.protocolVersion = in.readVarInt(); - this.hostname = in.readString(); - this.port = in.readUnsignedShort(); - this.intent = MagicValues.key(HandshakeIntent.class, in.readVarInt()); - } + @Override + public void read(NetInput in) throws IOException { + this.protocolVersion = in.readVarInt(); + this.hostname = in.readString(); + this.port = in.readUnsignedShort(); + this.intent = MagicValues.key(HandshakeIntent.class, in.readVarInt()); + } - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.protocolVersion); - out.writeString(this.hostname); - out.writeShort(this.port); - out.writeVarInt(MagicValues.value(Integer.class, this.intent)); - } + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.protocolVersion); + out.writeString(this.hostname); + out.writeShort(this.port); + out.writeVarInt(MagicValues.value(Integer.class, this.intent)); + } - @Override - public boolean isPriority() { - return true; - } + @Override + public boolean isPriority() { + return true; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientChatPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientChatPacket.java index 24e5d506f..09e698e3e 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientChatPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientChatPacket.java @@ -8,33 +8,33 @@ public class ClientChatPacket implements Packet { - private String message; - - @SuppressWarnings("unused") - private ClientChatPacket() { - } - - public ClientChatPacket(String message) { - this.message = message; - } - - public String getMessage() { - return this.message; - } - - @Override - public void read(NetInput in) throws IOException { - this.message = in.readString(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.message); - } - - @Override - public boolean isPriority() { - return false; - } + private String message; + + @SuppressWarnings("unused") + private ClientChatPacket() { + } + + public ClientChatPacket(String message) { + this.message = message; + } + + public String getMessage() { + return this.message; + } + + @Override + public void read(NetInput in) throws IOException { + this.message = in.readString(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.message); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientKeepAlivePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientKeepAlivePacket.java index 24ae7a01f..2cc2cedd7 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientKeepAlivePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientKeepAlivePacket.java @@ -8,33 +8,33 @@ public class ClientKeepAlivePacket implements Packet { - private int id; - - @SuppressWarnings("unused") - private ClientKeepAlivePacket() { - } - - public ClientKeepAlivePacket(int id) { - this.id = id; - } - - public int getPingId() { - return this.id; - } - - @Override - public void read(NetInput in) throws IOException { - this.id = in.readVarInt(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.id); - } - - @Override - public boolean isPriority() { - return false; - } + private int id; + + @SuppressWarnings("unused") + private ClientKeepAlivePacket() { + } + + public ClientKeepAlivePacket(int id) { + this.id = id; + } + + public int getPingId() { + return this.id; + } + + @Override + public void read(NetInput in) throws IOException { + this.id = in.readVarInt(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.id); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientPluginMessagePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientPluginMessagePacket.java index eb2c44a1e..58566bf30 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientPluginMessagePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientPluginMessagePacket.java @@ -8,41 +8,41 @@ public class ClientPluginMessagePacket implements Packet { - private String channel; - private byte data[]; - - @SuppressWarnings("unused") - private ClientPluginMessagePacket() { - } - - public ClientPluginMessagePacket(String channel, byte data[]) { - this.channel = channel; - this.data = data; - } - - public String getChannel() { - return this.channel; - } - - public byte[] getData() { - return this.data; - } - - @Override - public void read(NetInput in) throws IOException { - this.channel = in.readString(); - this.data = in.readBytes(in.available()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.channel); - out.writeBytes(this.data); - } - - @Override - public boolean isPriority() { - return false; - } + private String channel; + private byte data[]; + + @SuppressWarnings("unused") + private ClientPluginMessagePacket() { + } + + public ClientPluginMessagePacket(String channel, byte data[]) { + this.channel = channel; + this.data = data; + } + + public String getChannel() { + return this.channel; + } + + public byte[] getData() { + return this.data; + } + + @Override + public void read(NetInput in) throws IOException { + this.channel = in.readString(); + this.data = in.readBytes(in.available()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.channel); + out.writeBytes(this.data); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientRequestPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientRequestPacket.java index aa59750aa..1dfbf30e0 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientRequestPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientRequestPacket.java @@ -10,33 +10,33 @@ public class ClientRequestPacket implements Packet { - private ClientRequest request; - - @SuppressWarnings("unused") - private ClientRequestPacket() { - } - - public ClientRequestPacket(ClientRequest request) { - this.request = request; - } - - public ClientRequest getRequest() { - return this.request; - } - - @Override - public void read(NetInput in) throws IOException { - this.request = MagicValues.key(ClientRequest.class, in.readUnsignedByte()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(MagicValues.value(Integer.class, this.request)); - } - - @Override - public boolean isPriority() { - return false; - } + private ClientRequest request; + + @SuppressWarnings("unused") + private ClientRequestPacket() { + } + + public ClientRequestPacket(ClientRequest request) { + this.request = request; + } + + public ClientRequest getRequest() { + return this.request; + } + + @Override + public void read(NetInput in) throws IOException { + this.request = MagicValues.key(ClientRequest.class, in.readUnsignedByte()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(MagicValues.value(Integer.class, this.request)); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientResourcePackStatusPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientResourcePackStatusPacket.java index 753eb662f..d06a0c8b4 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientResourcePackStatusPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientResourcePackStatusPacket.java @@ -9,40 +9,40 @@ import java.io.IOException; public class ClientResourcePackStatusPacket implements Packet { - private String hash; - private ResourcePackStatus status; - - @SuppressWarnings("unused") - private ClientResourcePackStatusPacket() { - } - - public ClientResourcePackStatusPacket(String hash, ResourcePackStatus status) { - this.hash = hash; - this.status = status; - } - - public String getHash() { - return this.hash; - } - - public ResourcePackStatus getStatus() { - return this.status; - } - - @Override - public void read(NetInput in) throws IOException { - this.hash = in.readString(); - this.status = MagicValues.key(ResourcePackStatus.class, in.readVarInt()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.hash); - out.writeVarInt(MagicValues.value(Integer.class, this.status)); - } - - @Override - public boolean isPriority() { - return false; - } + private String hash; + private ResourcePackStatus status; + + @SuppressWarnings("unused") + private ClientResourcePackStatusPacket() { + } + + public ClientResourcePackStatusPacket(String hash, ResourcePackStatus status) { + this.hash = hash; + this.status = status; + } + + public String getHash() { + return this.hash; + } + + public ResourcePackStatus getStatus() { + return this.status; + } + + @Override + public void read(NetInput in) throws IOException { + this.hash = in.readString(); + this.status = MagicValues.key(ResourcePackStatus.class, in.readVarInt()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.hash); + out.writeVarInt(MagicValues.value(Integer.class, this.status)); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientSettingsPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientSettingsPacket.java index 72c5ceecc..5d1c5e25b 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientSettingsPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientSettingsPacket.java @@ -14,77 +14,77 @@ public class ClientSettingsPacket implements Packet { - private String locale; - private int renderDistance; - private ChatVisibility chatVisibility; - private boolean chatColors; - private List visibleParts; - - @SuppressWarnings("unused") - private ClientSettingsPacket() { - } - - public ClientSettingsPacket(String locale, int renderDistance, ChatVisibility chatVisibility, boolean chatColors, SkinPart... visibleParts) { - this.locale = locale; - this.renderDistance = renderDistance; - this.chatVisibility = chatVisibility; - this.chatColors = chatColors; - this.visibleParts = Arrays.asList(visibleParts); - } - - public String getLocale() { - return this.locale; - } - - public int getRenderDistance() { - return this.renderDistance; - } - - public ChatVisibility getChatVisibility() { - return this.chatVisibility; - } - - public boolean getUseChatColors() { - return this.chatColors; - } - - public List getVisibleParts() { - return this.visibleParts; - } - - @Override - public void read(NetInput in) throws IOException { - this.locale = in.readString(); - this.renderDistance = in.readByte(); - this.chatVisibility = MagicValues.key(ChatVisibility.class, in.readByte()); - this.chatColors = in.readBoolean(); - this.visibleParts = new ArrayList(); - int flags = in.readUnsignedByte(); - for(SkinPart part : SkinPart.values()) { - int bit = 1 << part.ordinal(); - if((flags & bit) == bit) { - this.visibleParts.add(part); - } - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.locale); - out.writeByte(this.renderDistance); - out.writeByte(MagicValues.value(Integer.class, this.chatVisibility)); - out.writeBoolean(this.chatColors); - int flags = 0; - for(SkinPart part : this.visibleParts) { - flags |= 1 << part.ordinal(); - } - - out.writeByte(flags); - } - - @Override - public boolean isPriority() { - return false; - } + private String locale; + private int renderDistance; + private ChatVisibility chatVisibility; + private boolean chatColors; + private List visibleParts; + + @SuppressWarnings("unused") + private ClientSettingsPacket() { + } + + public ClientSettingsPacket(String locale, int renderDistance, ChatVisibility chatVisibility, boolean chatColors, SkinPart... visibleParts) { + this.locale = locale; + this.renderDistance = renderDistance; + this.chatVisibility = chatVisibility; + this.chatColors = chatColors; + this.visibleParts = Arrays.asList(visibleParts); + } + + public String getLocale() { + return this.locale; + } + + public int getRenderDistance() { + return this.renderDistance; + } + + public ChatVisibility getChatVisibility() { + return this.chatVisibility; + } + + public boolean getUseChatColors() { + return this.chatColors; + } + + public List getVisibleParts() { + return this.visibleParts; + } + + @Override + public void read(NetInput in) throws IOException { + this.locale = in.readString(); + this.renderDistance = in.readByte(); + this.chatVisibility = MagicValues.key(ChatVisibility.class, in.readByte()); + this.chatColors = in.readBoolean(); + this.visibleParts = new ArrayList(); + int flags = in.readUnsignedByte(); + for(SkinPart part : SkinPart.values()) { + int bit = 1 << part.ordinal(); + if((flags & bit) == bit) { + this.visibleParts.add(part); + } + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.locale); + out.writeByte(this.renderDistance); + out.writeByte(MagicValues.value(Integer.class, this.chatVisibility)); + out.writeBoolean(this.chatColors); + int flags = 0; + for(SkinPart part : this.visibleParts) { + flags |= 1 << part.ordinal(); + } + + out.writeByte(flags); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientTabCompletePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientTabCompletePacket.java index 10383c366..9207dd0c7 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientTabCompletePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/ClientTabCompletePacket.java @@ -10,44 +10,44 @@ public class ClientTabCompletePacket implements Packet { - private String text; - private Position position; - - @SuppressWarnings("unused") - private ClientTabCompletePacket() { - } - - public ClientTabCompletePacket(String text) { - this(text, null); - } - - public ClientTabCompletePacket(String text, Position position) { - this.text = text; - this.position = position; - } - - public String getText() { - return this.text; - } - - @Override - public void read(NetInput in) throws IOException { - this.text = in.readString(); - this.position = in.readBoolean() ? NetUtil.readPosition(in) : null; - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.text); - out.writeBoolean(this.position != null); - if(this.position != null) { - NetUtil.writePosition(out, this.position); - } - } - - @Override - public boolean isPriority() { - return false; - } + private String text; + private Position position; + + @SuppressWarnings("unused") + private ClientTabCompletePacket() { + } + + public ClientTabCompletePacket(String text) { + this(text, null); + } + + public ClientTabCompletePacket(String text, Position position) { + this.text = text; + this.position = position; + } + + public String getText() { + return this.text; + } + + @Override + public void read(NetInput in) throws IOException { + this.text = in.readString(); + this.position = in.readBoolean() ? NetUtil.readPosition(in) : null; + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.text); + out.writeBoolean(this.position != null); + if(this.position != null) { + NetUtil.writePosition(out, this.position); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientChangeHeldItemPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientChangeHeldItemPacket.java index e8660cbe4..bbe705e61 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientChangeHeldItemPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientChangeHeldItemPacket.java @@ -8,33 +8,33 @@ public class ClientChangeHeldItemPacket implements Packet { - private int slot; - - @SuppressWarnings("unused") - private ClientChangeHeldItemPacket() { - } - - public ClientChangeHeldItemPacket(int slot) { - this.slot = slot; - } - - public int getSlot() { - return this.slot; - } - - @Override - public void read(NetInput in) throws IOException { - this.slot = in.readShort(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeShort(this.slot); - } - - @Override - public boolean isPriority() { - return false; - } + private int slot; + + @SuppressWarnings("unused") + private ClientChangeHeldItemPacket() { + } + + public ClientChangeHeldItemPacket(int slot) { + this.slot = slot; + } + + public int getSlot() { + return this.slot; + } + + @Override + public void read(NetInput in) throws IOException { + this.slot = in.readShort(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeShort(this.slot); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerAbilitiesPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerAbilitiesPacket.java index 0a756d270..0a9150128 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerAbilitiesPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerAbilitiesPacket.java @@ -8,88 +8,88 @@ public class ClientPlayerAbilitiesPacket implements Packet { - private boolean invincible; - private boolean canFly; - private boolean flying; - private boolean creative; - private float flySpeed; - private float walkSpeed; - - @SuppressWarnings("unused") - private ClientPlayerAbilitiesPacket() { - } - - public ClientPlayerAbilitiesPacket(boolean invincible, boolean canFly, boolean flying, boolean creative, float flySpeed, float walkSpeed) { - this.invincible = invincible; - this.canFly = canFly; - this.flying = flying; - this.creative = creative; - this.flySpeed = flySpeed; - this.walkSpeed = walkSpeed; - } - - public boolean getInvincible() { - return this.invincible; - } - - public boolean getCanFly() { - return this.canFly; - } - - public boolean getFlying() { - return this.flying; - } - - public boolean getCreative() { - return this.creative; - } - - public float getFlySpeed() { - return this.flySpeed; - } - - public float getWalkSpeed() { - return this.walkSpeed; - } - - @Override - public void read(NetInput in) throws IOException { - byte flags = in.readByte(); - this.invincible = (flags & 1) > 0; - this.canFly = (flags & 2) > 0; - this.flying = (flags & 4) > 0; - this.creative = (flags & 8) > 0; - this.flySpeed = in.readFloat(); - this.walkSpeed = in.readFloat(); - } - - @Override - public void write(NetOutput out) throws IOException { - byte flags = 0; - if(this.invincible) { - flags = (byte) (flags | 1); - } - - if(this.canFly) { - flags = (byte) (flags | 2); - } - - if(this.flying) { - flags = (byte) (flags | 4); - } - - if(this.creative) { - flags = (byte) (flags | 8); - } - - out.writeByte(flags); - out.writeFloat(this.flySpeed); - out.writeFloat(this.walkSpeed); - } - - @Override - public boolean isPriority() { - return false; - } + private boolean invincible; + private boolean canFly; + private boolean flying; + private boolean creative; + private float flySpeed; + private float walkSpeed; + + @SuppressWarnings("unused") + private ClientPlayerAbilitiesPacket() { + } + + public ClientPlayerAbilitiesPacket(boolean invincible, boolean canFly, boolean flying, boolean creative, float flySpeed, float walkSpeed) { + this.invincible = invincible; + this.canFly = canFly; + this.flying = flying; + this.creative = creative; + this.flySpeed = flySpeed; + this.walkSpeed = walkSpeed; + } + + public boolean getInvincible() { + return this.invincible; + } + + public boolean getCanFly() { + return this.canFly; + } + + public boolean getFlying() { + return this.flying; + } + + public boolean getCreative() { + return this.creative; + } + + public float getFlySpeed() { + return this.flySpeed; + } + + public float getWalkSpeed() { + return this.walkSpeed; + } + + @Override + public void read(NetInput in) throws IOException { + byte flags = in.readByte(); + this.invincible = (flags & 1) > 0; + this.canFly = (flags & 2) > 0; + this.flying = (flags & 4) > 0; + this.creative = (flags & 8) > 0; + this.flySpeed = in.readFloat(); + this.walkSpeed = in.readFloat(); + } + + @Override + public void write(NetOutput out) throws IOException { + byte flags = 0; + if(this.invincible) { + flags = (byte) (flags | 1); + } + + if(this.canFly) { + flags = (byte) (flags | 2); + } + + if(this.flying) { + flags = (byte) (flags | 4); + } + + if(this.creative) { + flags = (byte) (flags | 8); + } + + out.writeByte(flags); + out.writeFloat(this.flySpeed); + out.writeFloat(this.walkSpeed); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerActionPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerActionPacket.java index ca1bdb3f5..71ba1168c 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerActionPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerActionPacket.java @@ -13,49 +13,49 @@ public class ClientPlayerActionPacket implements Packet { - private PlayerAction action; - private Position position; - private Face face; - - @SuppressWarnings("unused") - private ClientPlayerActionPacket() { - } - - public ClientPlayerActionPacket(PlayerAction action, Position position, Face face) { - this.action = action; - this.position = position; - this.face = face; - } - - public PlayerAction getAction() { - return this.action; - } - - public Position getPosition() { - return this.position; - } - - public Face getFace() { - return this.face; - } - - @Override - public void read(NetInput in) throws IOException { - this.action = MagicValues.key(PlayerAction.class, in.readUnsignedByte()); - this.position = NetUtil.readPosition(in); - this.face = MagicValues.key(Face.class, in.readUnsignedByte()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(MagicValues.value(Integer.class, this.action)); - NetUtil.writePosition(out, this.position); - out.writeByte(MagicValues.value(Integer.class, this.face)); - } - - @Override - public boolean isPriority() { - return false; - } + private PlayerAction action; + private Position position; + private Face face; + + @SuppressWarnings("unused") + private ClientPlayerActionPacket() { + } + + public ClientPlayerActionPacket(PlayerAction action, Position position, Face face) { + this.action = action; + this.position = position; + this.face = face; + } + + public PlayerAction getAction() { + return this.action; + } + + public Position getPosition() { + return this.position; + } + + public Face getFace() { + return this.face; + } + + @Override + public void read(NetInput in) throws IOException { + this.action = MagicValues.key(PlayerAction.class, in.readUnsignedByte()); + this.position = NetUtil.readPosition(in); + this.face = MagicValues.key(Face.class, in.readUnsignedByte()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(MagicValues.value(Integer.class, this.action)); + NetUtil.writePosition(out, this.position); + out.writeByte(MagicValues.value(Integer.class, this.face)); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerInteractEntityPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerInteractEntityPacket.java index 14b467e6f..ab81a716f 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerInteractEntityPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerInteractEntityPacket.java @@ -10,62 +10,62 @@ public class ClientPlayerInteractEntityPacket implements Packet { - private int entityId; - private InteractAction action; + private int entityId; + private InteractAction action; - private float targetX; - private float targetY; - private float targetZ; + private float targetX; + private float targetY; + private float targetZ; - @SuppressWarnings("unused") - private ClientPlayerInteractEntityPacket() { - } + @SuppressWarnings("unused") + private ClientPlayerInteractEntityPacket() { + } - public ClientPlayerInteractEntityPacket(int entityId, InteractAction action) { - this(entityId, action, 0, 0, 0); - } + public ClientPlayerInteractEntityPacket(int entityId, InteractAction action) { + this(entityId, action, 0, 0, 0); + } - public ClientPlayerInteractEntityPacket(int entityId, InteractAction action, float targetX, float targetY, float targetZ) { - this.entityId = entityId; - this.action = action; - this.targetX = targetX; - this.targetY = targetY; - this.targetZ = targetZ; - } + public ClientPlayerInteractEntityPacket(int entityId, InteractAction action, float targetX, float targetY, float targetZ) { + this.entityId = entityId; + this.action = action; + this.targetX = targetX; + this.targetY = targetY; + this.targetZ = targetZ; + } - public int getEntityId() { - return this.entityId; - } + public int getEntityId() { + return this.entityId; + } - public InteractAction getAction() { - return this.action; - } + public InteractAction getAction() { + return this.action; + } - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.action = MagicValues.key(InteractAction.class, in.readVarInt()); - if(this.action == InteractAction.INTERACT_AT) { - this.targetX = in.readFloat(); - this.targetY = in.readFloat(); - this.targetZ = in.readFloat(); - } - } + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.action = MagicValues.key(InteractAction.class, in.readVarInt()); + if(this.action == InteractAction.INTERACT_AT) { + this.targetX = in.readFloat(); + this.targetY = in.readFloat(); + this.targetZ = in.readFloat(); + } + } - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeVarInt(MagicValues.value(Integer.class, this.action)); - if(this.action == InteractAction.INTERACT_AT) { - out.writeFloat(this.targetX); - out.writeFloat(this.targetY); - out.writeFloat(this.targetZ); - } - } + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeVarInt(MagicValues.value(Integer.class, this.action)); + if(this.action == InteractAction.INTERACT_AT) { + out.writeFloat(this.targetX); + out.writeFloat(this.targetY); + out.writeFloat(this.targetZ); + } + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerMovementPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerMovementPacket.java index a59ae105d..57f63b157 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerMovementPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerMovementPacket.java @@ -8,82 +8,82 @@ public class ClientPlayerMovementPacket implements Packet { - protected double x; - protected double y; - protected double z; - protected float yaw; - protected float pitch; - protected boolean onGround; - - protected boolean pos = false; - protected boolean rot = false; - - protected ClientPlayerMovementPacket() { - } - - public ClientPlayerMovementPacket(boolean onGround) { - this.onGround = onGround; - } - - public double getX() { - return this.x; - } - - public double getY() { - return this.y; - } - - public double getZ() { - return this.z; - } - - public double getYaw() { - return this.yaw; - } - - public double getPitch() { - return this.pitch; - } - - public boolean isOnGround() { - return this.onGround; - } - - @Override - public void read(NetInput in) throws IOException { - if(this.pos) { - this.x = in.readDouble(); - this.y = in.readDouble(); - this.z = in.readDouble(); - } - - if(this.rot) { - this.yaw = in.readFloat(); - this.pitch = in.readFloat(); - } - - this.onGround = in.readBoolean(); - } - - @Override - public void write(NetOutput out) throws IOException { - if(this.pos) { - out.writeDouble(this.x); - out.writeDouble(this.y); - out.writeDouble(this.z); - } - - if(this.rot) { - out.writeFloat(this.yaw); - out.writeFloat(this.pitch); - } - - out.writeBoolean(this.onGround); - } - - @Override - public boolean isPriority() { - return false; - } + protected double x; + protected double y; + protected double z; + protected float yaw; + protected float pitch; + protected boolean onGround; + + protected boolean pos = false; + protected boolean rot = false; + + protected ClientPlayerMovementPacket() { + } + + public ClientPlayerMovementPacket(boolean onGround) { + this.onGround = onGround; + } + + public double getX() { + return this.x; + } + + public double getY() { + return this.y; + } + + public double getZ() { + return this.z; + } + + public double getYaw() { + return this.yaw; + } + + public double getPitch() { + return this.pitch; + } + + public boolean isOnGround() { + return this.onGround; + } + + @Override + public void read(NetInput in) throws IOException { + if(this.pos) { + this.x = in.readDouble(); + this.y = in.readDouble(); + this.z = in.readDouble(); + } + + if(this.rot) { + this.yaw = in.readFloat(); + this.pitch = in.readFloat(); + } + + this.onGround = in.readBoolean(); + } + + @Override + public void write(NetOutput out) throws IOException { + if(this.pos) { + out.writeDouble(this.x); + out.writeDouble(this.y); + out.writeDouble(this.z); + } + + if(this.rot) { + out.writeFloat(this.yaw); + out.writeFloat(this.pitch); + } + + out.writeBoolean(this.onGround); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPlaceBlockPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPlaceBlockPacket.java index c8dbcae24..119d45882 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPlaceBlockPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPlaceBlockPacket.java @@ -13,73 +13,73 @@ public class ClientPlayerPlaceBlockPacket implements Packet { - private Position position; - private Face face; - private ItemStack held; - private float cursorX; - private float cursorY; - private float cursorZ; - - @SuppressWarnings("unused") - private ClientPlayerPlaceBlockPacket() { - } - - public ClientPlayerPlaceBlockPacket(Position position, Face face, ItemStack held, float cursorX, float cursorY, float cursorZ) { - this.position = position; - this.face = face; - this.held = held; - this.cursorX = cursorX; - this.cursorY = cursorY; - this.cursorZ = cursorZ; - } - - public Position getPosition() { - return this.position; - } - - public Face getFace() { - return this.face; - } - - public ItemStack getHeldItem() { - return this.held; - } - - public float getCursorX() { - return this.cursorX; - } - - public float getCursorY() { - return this.cursorY; - } - - public float getCursorZ() { - return this.cursorZ; - } - - @Override - public void read(NetInput in) throws IOException { - this.position = NetUtil.readPosition(in); - this.face = MagicValues.key(Face.class, in.readUnsignedByte()); - this.held = NetUtil.readItem(in); - this.cursorX = in.readByte() / 16f; - this.cursorY = in.readByte() / 16f; - this.cursorZ = in.readByte() / 16f; - } - - @Override - public void write(NetOutput out) throws IOException { - NetUtil.writePosition(out, this.position); - out.writeByte(MagicValues.value(Integer.class, this.face)); - NetUtil.writeItem(out, this.held); - out.writeByte((int) (this.cursorX * 16)); - out.writeByte((int) (this.cursorY * 16)); - out.writeByte((int) (this.cursorZ * 16)); - } - - @Override - public boolean isPriority() { - return false; - } + private Position position; + private Face face; + private ItemStack held; + private float cursorX; + private float cursorY; + private float cursorZ; + + @SuppressWarnings("unused") + private ClientPlayerPlaceBlockPacket() { + } + + public ClientPlayerPlaceBlockPacket(Position position, Face face, ItemStack held, float cursorX, float cursorY, float cursorZ) { + this.position = position; + this.face = face; + this.held = held; + this.cursorX = cursorX; + this.cursorY = cursorY; + this.cursorZ = cursorZ; + } + + public Position getPosition() { + return this.position; + } + + public Face getFace() { + return this.face; + } + + public ItemStack getHeldItem() { + return this.held; + } + + public float getCursorX() { + return this.cursorX; + } + + public float getCursorY() { + return this.cursorY; + } + + public float getCursorZ() { + return this.cursorZ; + } + + @Override + public void read(NetInput in) throws IOException { + this.position = NetUtil.readPosition(in); + this.face = MagicValues.key(Face.class, in.readUnsignedByte()); + this.held = NetUtil.readItem(in); + this.cursorX = in.readByte() / 16f; + this.cursorY = in.readByte() / 16f; + this.cursorZ = in.readByte() / 16f; + } + + @Override + public void write(NetOutput out) throws IOException { + NetUtil.writePosition(out, this.position); + out.writeByte(MagicValues.value(Integer.class, this.face)); + NetUtil.writeItem(out, this.held); + out.writeByte((int) (this.cursorX * 16)); + out.writeByte((int) (this.cursorY * 16)); + out.writeByte((int) (this.cursorZ * 16)); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPositionPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPositionPacket.java index 9972e1cbf..ef55bbd95 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPositionPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPositionPacket.java @@ -2,16 +2,16 @@ public class ClientPlayerPositionPacket extends ClientPlayerMovementPacket { - protected ClientPlayerPositionPacket() { - this.pos = true; - } + protected ClientPlayerPositionPacket() { + this.pos = true; + } - public ClientPlayerPositionPacket(boolean onGround, double x, double y, double z) { - super(onGround); - this.pos = true; - this.x = x; - this.y = y; - this.z = z; - } + public ClientPlayerPositionPacket(boolean onGround, double x, double y, double z) { + super(onGround); + this.pos = true; + this.x = x; + this.y = y; + this.z = z; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPositionRotationPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPositionRotationPacket.java index dc0a6f51e..de1b01e07 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPositionRotationPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerPositionRotationPacket.java @@ -2,20 +2,20 @@ public class ClientPlayerPositionRotationPacket extends ClientPlayerMovementPacket { - protected ClientPlayerPositionRotationPacket() { - this.pos = true; - this.rot = true; - } + protected ClientPlayerPositionRotationPacket() { + this.pos = true; + this.rot = true; + } - public ClientPlayerPositionRotationPacket(boolean onGround, double x, double y, double z, float yaw, float pitch) { - super(onGround); - this.pos = true; - this.rot = true; - this.x = x; - this.y = y; - this.z = z; - this.yaw = yaw; - this.pitch = pitch; - } + public ClientPlayerPositionRotationPacket(boolean onGround, double x, double y, double z, float yaw, float pitch) { + super(onGround); + this.pos = true; + this.rot = true; + this.x = x; + this.y = y; + this.z = z; + this.yaw = yaw; + this.pitch = pitch; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerRotationPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerRotationPacket.java index c2c52a97f..f38e84196 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerRotationPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerRotationPacket.java @@ -2,15 +2,15 @@ public class ClientPlayerRotationPacket extends ClientPlayerMovementPacket { - protected ClientPlayerRotationPacket() { - this.rot = true; - } + protected ClientPlayerRotationPacket() { + this.rot = true; + } - public ClientPlayerRotationPacket(boolean onGround, float yaw, float pitch) { - super(onGround); - this.rot = true; - this.yaw = yaw; - this.pitch = pitch; - } + public ClientPlayerRotationPacket(boolean onGround, float yaw, float pitch) { + super(onGround); + this.rot = true; + this.yaw = yaw; + this.pitch = pitch; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerStatePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerStatePacket.java index c2737b03c..15dea0f93 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerStatePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientPlayerStatePacket.java @@ -10,53 +10,53 @@ public class ClientPlayerStatePacket implements Packet { - private int entityId; - private PlayerState state; - private int jumpBoost; - - @SuppressWarnings("unused") - private ClientPlayerStatePacket() { - } - - public ClientPlayerStatePacket(int entityId, PlayerState state) { - this(entityId, state, 0); - } - - public ClientPlayerStatePacket(int entityId, PlayerState state, int jumpBoost) { - this.entityId = entityId; - this.state = state; - this.jumpBoost = jumpBoost; - } - - public int getEntityId() { - return this.entityId; - } - - public PlayerState getState() { - return this.state; - } - - public int getJumpBoost() { - return this.jumpBoost; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.state = MagicValues.key(PlayerState.class, in.readUnsignedByte()); - this.jumpBoost = in.readVarInt(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeByte(MagicValues.value(Integer.class, this.state)); - out.writeVarInt(this.jumpBoost); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private PlayerState state; + private int jumpBoost; + + @SuppressWarnings("unused") + private ClientPlayerStatePacket() { + } + + public ClientPlayerStatePacket(int entityId, PlayerState state) { + this(entityId, state, 0); + } + + public ClientPlayerStatePacket(int entityId, PlayerState state, int jumpBoost) { + this.entityId = entityId; + this.state = state; + this.jumpBoost = jumpBoost; + } + + public int getEntityId() { + return this.entityId; + } + + public PlayerState getState() { + return this.state; + } + + public int getJumpBoost() { + return this.jumpBoost; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.state = MagicValues.key(PlayerState.class, in.readUnsignedByte()); + this.jumpBoost = in.readVarInt(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeByte(MagicValues.value(Integer.class, this.state)); + out.writeVarInt(this.jumpBoost); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSpectatePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSpectatePacket.java index 7f6735de4..3d06d3e32 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSpectatePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSpectatePacket.java @@ -8,32 +8,32 @@ import java.util.UUID; public class ClientSpectatePacket implements Packet { - private UUID target; - - @SuppressWarnings("unused") - private ClientSpectatePacket() { - } - - public ClientSpectatePacket(UUID target) { - this.target = target; - } - - public UUID getTarget() { - return this.target; - } - - @Override - public void read(NetInput in) throws IOException { - this.target = in.readUUID(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeUUID(this.target); - } - - @Override - public boolean isPriority() { - return false; - } + private UUID target; + + @SuppressWarnings("unused") + private ClientSpectatePacket() { + } + + public ClientSpectatePacket(UUID target) { + this.target = target; + } + + public UUID getTarget() { + return this.target; + } + + @Override + public void read(NetInput in) throws IOException { + this.target = in.readUUID(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeUUID(this.target); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSteerVehiclePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSteerVehiclePacket.java index fea5d9b59..cded4ba01 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSteerVehiclePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSteerVehiclePacket.java @@ -8,66 +8,66 @@ public class ClientSteerVehiclePacket implements Packet { - private float sideways; - private float forward; - private boolean jump; - private boolean dismount; - - @SuppressWarnings("unused") - private ClientSteerVehiclePacket() { - } - - public ClientSteerVehiclePacket(float sideways, float forward, boolean jump, boolean dismount) { - this.sideways = sideways; - this.forward = forward; - this.jump = jump; - this.dismount = dismount; - } - - public float getSideways() { - return this.sideways; - } - - public float getForward() { - return this.forward; - } - - public boolean getJumping() { - return this.jump; - } - - public boolean getDismounting() { - return this.dismount; - } - - @Override - public void read(NetInput in) throws IOException { - this.sideways = in.readFloat(); - this.forward = in.readFloat(); - int flags = in.readUnsignedByte(); - this.jump = (flags & 1) > 0; - this.dismount = (flags & 2) > 0; - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeFloat(this.sideways); - out.writeFloat(this.forward); - byte flags = 0; - if(this.jump) { - flags = (byte) (flags | 1); - } - - if(this.dismount) { - flags = (byte) (flags | 2); - } - - out.writeByte(flags); - } - - @Override - public boolean isPriority() { - return false; - } + private float sideways; + private float forward; + private boolean jump; + private boolean dismount; + + @SuppressWarnings("unused") + private ClientSteerVehiclePacket() { + } + + public ClientSteerVehiclePacket(float sideways, float forward, boolean jump, boolean dismount) { + this.sideways = sideways; + this.forward = forward; + this.jump = jump; + this.dismount = dismount; + } + + public float getSideways() { + return this.sideways; + } + + public float getForward() { + return this.forward; + } + + public boolean getJumping() { + return this.jump; + } + + public boolean getDismounting() { + return this.dismount; + } + + @Override + public void read(NetInput in) throws IOException { + this.sideways = in.readFloat(); + this.forward = in.readFloat(); + int flags = in.readUnsignedByte(); + this.jump = (flags & 1) > 0; + this.dismount = (flags & 2) > 0; + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeFloat(this.sideways); + out.writeFloat(this.forward); + byte flags = 0; + if(this.jump) { + flags = (byte) (flags | 1); + } + + if(this.dismount) { + flags = (byte) (flags | 2); + } + + out.writeByte(flags); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSwingArmPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSwingArmPacket.java index a804ab5e7..319e01f8d 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSwingArmPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/player/ClientSwingArmPacket.java @@ -8,20 +8,20 @@ public class ClientSwingArmPacket implements Packet { - public ClientSwingArmPacket() { - } + public ClientSwingArmPacket() { + } - @Override - public void read(NetInput in) throws IOException { - } + @Override + public void read(NetInput in) throws IOException { + } - @Override - public void write(NetOutput out) throws IOException { - } + @Override + public void write(NetOutput out) throws IOException { + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientCloseWindowPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientCloseWindowPacket.java index f693834d4..ee450ef51 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientCloseWindowPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientCloseWindowPacket.java @@ -8,33 +8,33 @@ public class ClientCloseWindowPacket implements Packet { - private int windowId; - - @SuppressWarnings("unused") - private ClientCloseWindowPacket() { - } - - public ClientCloseWindowPacket(int windowId) { - this.windowId = windowId; - } - - public int getWindowId() { - return this.windowId; - } - - @Override - public void read(NetInput in) throws IOException { - this.windowId = in.readByte(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(this.windowId); - } - - @Override - public boolean isPriority() { - return false; - } + private int windowId; + + @SuppressWarnings("unused") + private ClientCloseWindowPacket() { + } + + public ClientCloseWindowPacket(int windowId) { + this.windowId = windowId; + } + + public int getWindowId() { + return this.windowId; + } + + @Override + public void read(NetInput in) throws IOException { + this.windowId = in.readByte(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.windowId); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientConfirmTransactionPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientConfirmTransactionPacket.java index 97ef3dead..dce1782fd 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientConfirmTransactionPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientConfirmTransactionPacket.java @@ -8,49 +8,49 @@ public class ClientConfirmTransactionPacket implements Packet { - private int windowId; - private int actionId; - private boolean accepted; - - @SuppressWarnings("unused") - private ClientConfirmTransactionPacket() { - } - - public ClientConfirmTransactionPacket(int windowId, int actionId, boolean accepted) { - this.windowId = windowId; - this.actionId = actionId; - this.accepted = accepted; - } - - public int getWindowId() { - return this.windowId; - } - - public int getActionId() { - return this.actionId; - } - - public boolean getAccepted() { - return this.accepted; - } - - @Override - public void read(NetInput in) throws IOException { - this.windowId = in.readByte(); - this.actionId = in.readShort(); - this.accepted = in.readBoolean(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(this.windowId); - out.writeShort(this.actionId); - out.writeBoolean(this.accepted); - } - - @Override - public boolean isPriority() { - return false; - } + private int windowId; + private int actionId; + private boolean accepted; + + @SuppressWarnings("unused") + private ClientConfirmTransactionPacket() { + } + + public ClientConfirmTransactionPacket(int windowId, int actionId, boolean accepted) { + this.windowId = windowId; + this.actionId = actionId; + this.accepted = accepted; + } + + public int getWindowId() { + return this.windowId; + } + + public int getActionId() { + return this.actionId; + } + + public boolean getAccepted() { + return this.accepted; + } + + @Override + public void read(NetInput in) throws IOException { + this.windowId = in.readByte(); + this.actionId = in.readShort(); + this.accepted = in.readBoolean(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.windowId); + out.writeShort(this.actionId); + out.writeBoolean(this.accepted); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientCreativeInventoryActionPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientCreativeInventoryActionPacket.java index e25444a5c..a5097ddf5 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientCreativeInventoryActionPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientCreativeInventoryActionPacket.java @@ -10,41 +10,41 @@ public class ClientCreativeInventoryActionPacket implements Packet { - private int slot; - private ItemStack clicked; - - @SuppressWarnings("unused") - private ClientCreativeInventoryActionPacket() { - } - - public ClientCreativeInventoryActionPacket(int slot, ItemStack clicked) { - this.slot = slot; - this.clicked = clicked; - } - - public int getSlot() { - return this.slot; - } - - public ItemStack getClickedItem() { - return this.clicked; - } - - @Override - public void read(NetInput in) throws IOException { - this.slot = in.readShort(); - this.clicked = NetUtil.readItem(in); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeShort(this.slot); - NetUtil.writeItem(out, this.clicked); - } - - @Override - public boolean isPriority() { - return false; - } + private int slot; + private ItemStack clicked; + + @SuppressWarnings("unused") + private ClientCreativeInventoryActionPacket() { + } + + public ClientCreativeInventoryActionPacket(int slot, ItemStack clicked) { + this.slot = slot; + this.clicked = clicked; + } + + public int getSlot() { + return this.slot; + } + + public ItemStack getClickedItem() { + return this.clicked; + } + + @Override + public void read(NetInput in) throws IOException { + this.slot = in.readShort(); + this.clicked = NetUtil.readItem(in); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeShort(this.slot); + NetUtil.writeItem(out, this.clicked); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientEnchantItemPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientEnchantItemPacket.java index c06082d09..eae703995 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientEnchantItemPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientEnchantItemPacket.java @@ -8,41 +8,41 @@ public class ClientEnchantItemPacket implements Packet { - private int windowId; - private int enchantment; - - @SuppressWarnings("unused") - private ClientEnchantItemPacket() { - } - - public ClientEnchantItemPacket(int windowId, int enchantment) { - this.windowId = windowId; - this.enchantment = enchantment; - } - - public int getWindowId() { - return this.windowId; - } - - public int getEnchantment() { - return this.enchantment; - } - - @Override - public void read(NetInput in) throws IOException { - this.windowId = in.readByte(); - this.enchantment = in.readByte(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(this.windowId); - out.writeByte(this.enchantment); - } - - @Override - public boolean isPriority() { - return false; - } + private int windowId; + private int enchantment; + + @SuppressWarnings("unused") + private ClientEnchantItemPacket() { + } + + public ClientEnchantItemPacket(int windowId, int enchantment) { + this.windowId = windowId; + this.enchantment = enchantment; + } + + public int getWindowId() { + return this.windowId; + } + + public int getEnchantment() { + return this.enchantment; + } + + @Override + public void read(NetInput in) throws IOException { + this.windowId = in.readByte(); + this.enchantment = in.readByte(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.windowId); + out.writeByte(this.enchantment); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientWindowActionPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientWindowActionPacket.java index 8c4df9aa3..41d227908 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientWindowActionPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/window/ClientWindowActionPacket.java @@ -2,7 +2,15 @@ import org.spacehq.mc.protocol.data.game.ItemStack; import org.spacehq.mc.protocol.data.game.values.MagicValues; -import org.spacehq.mc.protocol.data.game.values.window.*; +import org.spacehq.mc.protocol.data.game.values.window.ClickItemParam; +import org.spacehq.mc.protocol.data.game.values.window.CreativeGrabParam; +import org.spacehq.mc.protocol.data.game.values.window.DropItemParam; +import org.spacehq.mc.protocol.data.game.values.window.FillStackParam; +import org.spacehq.mc.protocol.data.game.values.window.MoveToHotbarParam; +import org.spacehq.mc.protocol.data.game.values.window.ShiftClickItemParam; +import org.spacehq.mc.protocol.data.game.values.window.SpreadItemParam; +import org.spacehq.mc.protocol.data.game.values.window.WindowAction; +import org.spacehq.mc.protocol.data.game.values.window.WindowActionParam; import org.spacehq.mc.protocol.util.NetUtil; import org.spacehq.packetlib.io.NetInput; import org.spacehq.packetlib.io.NetOutput; @@ -12,105 +20,105 @@ public class ClientWindowActionPacket implements Packet { - private int windowId; - private int slot; - private WindowActionParam param; - private int actionId; - private WindowAction action; - private ItemStack clicked; - - @SuppressWarnings("unused") - private ClientWindowActionPacket() { - } - - public ClientWindowActionPacket(int windowId, int actionId, int slot, ItemStack clicked, WindowAction action, WindowActionParam param) { - this.windowId = windowId; - this.actionId = actionId; - this.slot = slot; - this.clicked = clicked; - this.action = action; - this.param = param; - } - - public int getWindowId() { - return this.windowId; - } - - public int getActionId() { - return this.actionId; - } - - public int getSlot() { - return this.slot; - } - - public ItemStack getClickedItem() { - return this.clicked; - } - - public WindowAction getAction() { - return this.action; - } - - public WindowActionParam getParam() { - return this.param; - } - - @Override - public void read(NetInput in) throws IOException { - this.windowId = in.readByte(); - this.slot = in.readShort(); - byte param = in.readByte(); - this.actionId = in.readShort(); - this.action = MagicValues.key(WindowAction.class, in.readByte()); - this.clicked = NetUtil.readItem(in); - if(this.action == WindowAction.CLICK_ITEM) { - this.param = MagicValues.key(ClickItemParam.class, param); - } else if(this.action == WindowAction.SHIFT_CLICK_ITEM) { - this.param = MagicValues.key(ShiftClickItemParam.class, param); - } else if(this.action == WindowAction.MOVE_TO_HOTBAR_SLOT) { - this.param = MagicValues.key(MoveToHotbarParam.class, param); - } else if(this.action == WindowAction.CREATIVE_GRAB_MAX_STACK) { - this.param = MagicValues.key(CreativeGrabParam.class, param); - } else if(this.action == WindowAction.DROP_ITEM) { - this.param = MagicValues.key(DropItemParam.class, param + (this.slot != -999 ? 2 : 0)); - } else if(this.action == WindowAction.SPREAD_ITEM) { - this.param = MagicValues.key(SpreadItemParam.class, param); - } else if(this.action == WindowAction.FILL_STACK) { - this.param = MagicValues.key(FillStackParam.class, param); - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(this.windowId); - out.writeShort(this.slot); - int param = 0; - if(this.action == WindowAction.CLICK_ITEM) { - param = MagicValues.value(Integer.class, (Enum) this.param); - } else if(this.action == WindowAction.SHIFT_CLICK_ITEM) { - param = MagicValues.value(Integer.class, (Enum) this.param); - } else if(this.action == WindowAction.MOVE_TO_HOTBAR_SLOT) { - param = MagicValues.value(Integer.class, (Enum) this.param); - } else if(this.action == WindowAction.CREATIVE_GRAB_MAX_STACK) { - param = MagicValues.value(Integer.class, (Enum) this.param); - } else if(this.action == WindowAction.DROP_ITEM) { - param = MagicValues.value(Integer.class, (Enum) this.param) + (this.slot != -999 ? 2 : 0); - } else if(this.action == WindowAction.SPREAD_ITEM) { - param = MagicValues.value(Integer.class, (Enum) this.param); - } else if(this.action == WindowAction.FILL_STACK) { - param = MagicValues.value(Integer.class, (Enum) this.param); - } - - out.writeByte(param); - out.writeShort(this.actionId); - out.writeByte(MagicValues.value(Integer.class, this.action)); - NetUtil.writeItem(out, this.clicked); - } - - @Override - public boolean isPriority() { - return false; - } + private int windowId; + private int slot; + private WindowActionParam param; + private int actionId; + private WindowAction action; + private ItemStack clicked; + + @SuppressWarnings("unused") + private ClientWindowActionPacket() { + } + + public ClientWindowActionPacket(int windowId, int actionId, int slot, ItemStack clicked, WindowAction action, WindowActionParam param) { + this.windowId = windowId; + this.actionId = actionId; + this.slot = slot; + this.clicked = clicked; + this.action = action; + this.param = param; + } + + public int getWindowId() { + return this.windowId; + } + + public int getActionId() { + return this.actionId; + } + + public int getSlot() { + return this.slot; + } + + public ItemStack getClickedItem() { + return this.clicked; + } + + public WindowAction getAction() { + return this.action; + } + + public WindowActionParam getParam() { + return this.param; + } + + @Override + public void read(NetInput in) throws IOException { + this.windowId = in.readByte(); + this.slot = in.readShort(); + byte param = in.readByte(); + this.actionId = in.readShort(); + this.action = MagicValues.key(WindowAction.class, in.readByte()); + this.clicked = NetUtil.readItem(in); + if(this.action == WindowAction.CLICK_ITEM) { + this.param = MagicValues.key(ClickItemParam.class, param); + } else if(this.action == WindowAction.SHIFT_CLICK_ITEM) { + this.param = MagicValues.key(ShiftClickItemParam.class, param); + } else if(this.action == WindowAction.MOVE_TO_HOTBAR_SLOT) { + this.param = MagicValues.key(MoveToHotbarParam.class, param); + } else if(this.action == WindowAction.CREATIVE_GRAB_MAX_STACK) { + this.param = MagicValues.key(CreativeGrabParam.class, param); + } else if(this.action == WindowAction.DROP_ITEM) { + this.param = MagicValues.key(DropItemParam.class, param + (this.slot != -999 ? 2 : 0)); + } else if(this.action == WindowAction.SPREAD_ITEM) { + this.param = MagicValues.key(SpreadItemParam.class, param); + } else if(this.action == WindowAction.FILL_STACK) { + this.param = MagicValues.key(FillStackParam.class, param); + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.windowId); + out.writeShort(this.slot); + int param = 0; + if(this.action == WindowAction.CLICK_ITEM) { + param = MagicValues.value(Integer.class, (Enum) this.param); + } else if(this.action == WindowAction.SHIFT_CLICK_ITEM) { + param = MagicValues.value(Integer.class, (Enum) this.param); + } else if(this.action == WindowAction.MOVE_TO_HOTBAR_SLOT) { + param = MagicValues.value(Integer.class, (Enum) this.param); + } else if(this.action == WindowAction.CREATIVE_GRAB_MAX_STACK) { + param = MagicValues.value(Integer.class, (Enum) this.param); + } else if(this.action == WindowAction.DROP_ITEM) { + param = MagicValues.value(Integer.class, (Enum) this.param) + (this.slot != -999 ? 2 : 0); + } else if(this.action == WindowAction.SPREAD_ITEM) { + param = MagicValues.value(Integer.class, (Enum) this.param); + } else if(this.action == WindowAction.FILL_STACK) { + param = MagicValues.value(Integer.class, (Enum) this.param); + } + + out.writeByte(param); + out.writeShort(this.actionId); + out.writeByte(MagicValues.value(Integer.class, this.action)); + NetUtil.writeItem(out, this.clicked); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/world/ClientUpdateSignPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/world/ClientUpdateSignPacket.java index 471f80dcb..883d4d5a7 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/world/ClientUpdateSignPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/client/world/ClientUpdateSignPacket.java @@ -10,50 +10,50 @@ public class ClientUpdateSignPacket implements Packet { - private Position position; - private String lines[]; - - @SuppressWarnings("unused") - private ClientUpdateSignPacket() { - } - - public ClientUpdateSignPacket(Position position, String lines[]) { - if(lines.length != 4) { - throw new IllegalArgumentException("Lines must contain exactly 4 strings!"); - } - - this.position = position; - this.lines = lines; - } - - public Position getPosition() { - return this.position; - } - - public String[] getLines() { - return this.lines; - } - - @Override - public void read(NetInput in) throws IOException { - this.position = NetUtil.readPosition(in); - this.lines = new String[4]; - for(int count = 0; count < this.lines.length; count++) { - this.lines[count] = in.readString(); - } - } - - @Override - public void write(NetOutput out) throws IOException { - NetUtil.writePosition(out, this.position); - for(String line : this.lines) { - out.writeString(line); - } - } - - @Override - public boolean isPriority() { - return false; - } + private Position position; + private String lines[]; + + @SuppressWarnings("unused") + private ClientUpdateSignPacket() { + } + + public ClientUpdateSignPacket(Position position, String lines[]) { + if(lines.length != 4) { + throw new IllegalArgumentException("Lines must contain exactly 4 strings!"); + } + + this.position = position; + this.lines = lines; + } + + public Position getPosition() { + return this.position; + } + + public String[] getLines() { + return this.lines; + } + + @Override + public void read(NetInput in) throws IOException { + this.position = NetUtil.readPosition(in); + this.lines = new String[4]; + for(int count = 0; count < this.lines.length; count++) { + this.lines[count] = in.readString(); + } + } + + @Override + public void write(NetOutput out) throws IOException { + NetUtil.writePosition(out, this.position); + for(String line : this.lines) { + out.writeString(line); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerChatPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerChatPacket.java index 761b64787..c7d3a32d8 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerChatPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerChatPacket.java @@ -11,53 +11,53 @@ public class ServerChatPacket implements Packet { - private Message message; - private MessageType type; - - @SuppressWarnings("unused") - private ServerChatPacket() { - } - - public ServerChatPacket(String text) { - this(Message.fromString(text)); - } - - public ServerChatPacket(Message message) { - this(message, MessageType.SYSTEM); - } - - public ServerChatPacket(String text, MessageType type) { - this(Message.fromString(text), type); - } - - public ServerChatPacket(Message message, MessageType type) { - this.message = message; - this.type = type; - } - - public Message getMessage() { - return this.message; - } - - public MessageType getType() { - return this.type; - } - - @Override - public void read(NetInput in) throws IOException { - this.message = Message.fromString(in.readString()); - this.type = MagicValues.key(MessageType.class, in.readByte()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.message.toJsonString()); - out.writeByte(MagicValues.value(Integer.class, this.type)); - } - - @Override - public boolean isPriority() { - return false; - } + private Message message; + private MessageType type; + + @SuppressWarnings("unused") + private ServerChatPacket() { + } + + public ServerChatPacket(String text) { + this(Message.fromString(text)); + } + + public ServerChatPacket(Message message) { + this(message, MessageType.SYSTEM); + } + + public ServerChatPacket(String text, MessageType type) { + this(Message.fromString(text), type); + } + + public ServerChatPacket(Message message, MessageType type) { + this.message = message; + this.type = type; + } + + public Message getMessage() { + return this.message; + } + + public MessageType getType() { + return this.type; + } + + @Override + public void read(NetInput in) throws IOException { + this.message = Message.fromString(in.readString()); + this.type = MagicValues.key(MessageType.class, in.readByte()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.message.toJsonString()); + out.writeByte(MagicValues.value(Integer.class, this.type)); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerCombatPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerCombatPacket.java index f2a635704..1d6198ad3 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerCombatPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerCombatPacket.java @@ -10,78 +10,78 @@ public class ServerCombatPacket implements Packet { - private CombatState state; - private int entityId; - private int duration; - private int playerId; - private String message; - - public ServerCombatPacket() { - this.state = CombatState.ENTER_COMBAT; - } - - public ServerCombatPacket(int entityId, int duration) { - this.state = CombatState.END_COMBAT; - this.entityId = entityId; - this.duration = duration; - } - - public ServerCombatPacket(int entityId, int playerId, String message) { - this.state = CombatState.ENTITY_DEAD; - this.entityId = entityId; - this.playerId = playerId; - this.message = message; - } - - public CombatState getCombatState() { - return this.state; - } - - public int getEntityId() { - return this.entityId; - } - - public int getDuration() { - return this.duration; - } - - public int getPlayerId() { - return this.playerId; - } - - public String getMessage() { - return this.message; - } - - @Override - public void read(NetInput in) throws IOException { - this.state = MagicValues.key(CombatState.class, in.readVarInt()); - if(this.state == CombatState.END_COMBAT) { - this.duration = in.readVarInt(); - this.entityId = in.readInt(); - } else if(this.state == CombatState.ENTITY_DEAD) { - this.playerId = in.readVarInt(); - this.entityId = in.readInt(); - this.message = in.readString(); - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(MagicValues.value(Integer.class, this.state)); - if(this.state == CombatState.END_COMBAT) { - out.writeVarInt(this.duration); - out.writeInt(this.entityId); - } else if(this.state == CombatState.ENTITY_DEAD) { - out.writeVarInt(this.playerId); - out.writeInt(this.entityId); - out.writeString(this.message); - } - } - - @Override - public boolean isPriority() { - return false; - } + private CombatState state; + private int entityId; + private int duration; + private int playerId; + private String message; + + public ServerCombatPacket() { + this.state = CombatState.ENTER_COMBAT; + } + + public ServerCombatPacket(int entityId, int duration) { + this.state = CombatState.END_COMBAT; + this.entityId = entityId; + this.duration = duration; + } + + public ServerCombatPacket(int entityId, int playerId, String message) { + this.state = CombatState.ENTITY_DEAD; + this.entityId = entityId; + this.playerId = playerId; + this.message = message; + } + + public CombatState getCombatState() { + return this.state; + } + + public int getEntityId() { + return this.entityId; + } + + public int getDuration() { + return this.duration; + } + + public int getPlayerId() { + return this.playerId; + } + + public String getMessage() { + return this.message; + } + + @Override + public void read(NetInput in) throws IOException { + this.state = MagicValues.key(CombatState.class, in.readVarInt()); + if(this.state == CombatState.END_COMBAT) { + this.duration = in.readVarInt(); + this.entityId = in.readInt(); + } else if(this.state == CombatState.ENTITY_DEAD) { + this.playerId = in.readVarInt(); + this.entityId = in.readInt(); + this.message = in.readString(); + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(MagicValues.value(Integer.class, this.state)); + if(this.state == CombatState.END_COMBAT) { + out.writeVarInt(this.duration); + out.writeInt(this.entityId); + } else if(this.state == CombatState.ENTITY_DEAD) { + out.writeVarInt(this.playerId); + out.writeInt(this.entityId); + out.writeString(this.message); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerDifficultyPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerDifficultyPacket.java index 3cd972acd..cc819b99d 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerDifficultyPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerDifficultyPacket.java @@ -10,33 +10,33 @@ public class ServerDifficultyPacket implements Packet { - private Difficulty difficulty; - - @SuppressWarnings("unused") - private ServerDifficultyPacket() { - } - - public ServerDifficultyPacket(Difficulty difficulty) { - this.difficulty = difficulty; - } - - public Difficulty getDifficulty() { - return this.difficulty; - } - - @Override - public void read(NetInput in) throws IOException { - this.difficulty = MagicValues.key(Difficulty.class, in.readUnsignedByte()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(MagicValues.value(Integer.class, this.difficulty)); - } - - @Override - public boolean isPriority() { - return false; - } + private Difficulty difficulty; + + @SuppressWarnings("unused") + private ServerDifficultyPacket() { + } + + public ServerDifficultyPacket(Difficulty difficulty) { + this.difficulty = difficulty; + } + + public Difficulty getDifficulty() { + return this.difficulty; + } + + @Override + public void read(NetInput in) throws IOException { + this.difficulty = MagicValues.key(Difficulty.class, in.readUnsignedByte()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(MagicValues.value(Integer.class, this.difficulty)); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerDisconnectPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerDisconnectPacket.java index ef41974de..88bafb589 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerDisconnectPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerDisconnectPacket.java @@ -9,37 +9,37 @@ public class ServerDisconnectPacket implements Packet { - private Message message; - - @SuppressWarnings("unused") - private ServerDisconnectPacket() { - } - - public ServerDisconnectPacket(String text) { - this(Message.fromString(text)); - } - - public ServerDisconnectPacket(Message message) { - this.message = message; - } - - public Message getReason() { - return this.message; - } - - @Override - public void read(NetInput in) throws IOException { - this.message = Message.fromString(in.readString()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.message.toJsonString()); - } - - @Override - public boolean isPriority() { - return true; - } + private Message message; + + @SuppressWarnings("unused") + private ServerDisconnectPacket() { + } + + public ServerDisconnectPacket(String text) { + this(Message.fromString(text)); + } + + public ServerDisconnectPacket(Message message) { + this.message = message; + } + + public Message getReason() { + return this.message; + } + + @Override + public void read(NetInput in) throws IOException { + this.message = Message.fromString(in.readString()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.message.toJsonString()); + } + + @Override + public boolean isPriority() { + return true; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java index ffe5dca2f..978e720b5 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java @@ -12,95 +12,95 @@ public class ServerJoinGamePacket implements Packet { - private int entityId; - private boolean hardcore; - private GameMode gamemode; - private int dimension; - private Difficulty difficulty; - private int maxPlayers; - private WorldType worldType; - private boolean reducedDebugInfo; - - @SuppressWarnings("unused") - private ServerJoinGamePacket() { - } - - public ServerJoinGamePacket(int entityId, boolean hardcore, GameMode gamemode, int dimension, Difficulty difficulty, int maxPlayers, WorldType worldType, boolean reducedDebugInfo) { - this.entityId = entityId; - this.hardcore = hardcore; - this.gamemode = gamemode; - this.dimension = dimension; - this.difficulty = difficulty; - this.maxPlayers = maxPlayers; - this.worldType = worldType; - this.reducedDebugInfo = reducedDebugInfo; - } - - public int getEntityId() { - return this.entityId; - } - - public boolean getHardcore() { - return this.hardcore; - } - - public GameMode getGameMode() { - return this.gamemode; - } - - public int getDimension() { - return this.dimension; - } - - public Difficulty getDifficulty() { - return this.difficulty; - } - - public int getMaxPlayers() { - return this.maxPlayers; - } - - public WorldType getWorldType() { - return this.worldType; - } - - public boolean getReducedDebugInfo() { - return this.reducedDebugInfo; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readInt(); - int gamemode = in.readUnsignedByte(); - this.hardcore = (gamemode & 8) == 8; - gamemode &= -9; - this.gamemode = MagicValues.key(GameMode.class, gamemode); - this.dimension = in.readByte(); - this.difficulty = MagicValues.key(Difficulty.class, in.readUnsignedByte()); - this.maxPlayers = in.readUnsignedByte(); - this.worldType = MagicValues.key(WorldType.class, in.readString().toLowerCase()); - this.reducedDebugInfo = in.readBoolean(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeInt(this.entityId); - int gamemode = MagicValues.value(Integer.class, this.gamemode); - if(this.hardcore) { - gamemode |= 8; - } - - out.writeByte(gamemode); - out.writeByte(this.dimension); - out.writeByte(MagicValues.value(Integer.class, this.difficulty)); - out.writeByte(this.maxPlayers); - out.writeString(MagicValues.value(String.class, this.worldType)); - out.writeBoolean(this.reducedDebugInfo); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private boolean hardcore; + private GameMode gamemode; + private int dimension; + private Difficulty difficulty; + private int maxPlayers; + private WorldType worldType; + private boolean reducedDebugInfo; + + @SuppressWarnings("unused") + private ServerJoinGamePacket() { + } + + public ServerJoinGamePacket(int entityId, boolean hardcore, GameMode gamemode, int dimension, Difficulty difficulty, int maxPlayers, WorldType worldType, boolean reducedDebugInfo) { + this.entityId = entityId; + this.hardcore = hardcore; + this.gamemode = gamemode; + this.dimension = dimension; + this.difficulty = difficulty; + this.maxPlayers = maxPlayers; + this.worldType = worldType; + this.reducedDebugInfo = reducedDebugInfo; + } + + public int getEntityId() { + return this.entityId; + } + + public boolean getHardcore() { + return this.hardcore; + } + + public GameMode getGameMode() { + return this.gamemode; + } + + public int getDimension() { + return this.dimension; + } + + public Difficulty getDifficulty() { + return this.difficulty; + } + + public int getMaxPlayers() { + return this.maxPlayers; + } + + public WorldType getWorldType() { + return this.worldType; + } + + public boolean getReducedDebugInfo() { + return this.reducedDebugInfo; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readInt(); + int gamemode = in.readUnsignedByte(); + this.hardcore = (gamemode & 8) == 8; + gamemode &= -9; + this.gamemode = MagicValues.key(GameMode.class, gamemode); + this.dimension = in.readByte(); + this.difficulty = MagicValues.key(Difficulty.class, in.readUnsignedByte()); + this.maxPlayers = in.readUnsignedByte(); + this.worldType = MagicValues.key(WorldType.class, in.readString().toLowerCase()); + this.reducedDebugInfo = in.readBoolean(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeInt(this.entityId); + int gamemode = MagicValues.value(Integer.class, this.gamemode); + if(this.hardcore) { + gamemode |= 8; + } + + out.writeByte(gamemode); + out.writeByte(this.dimension); + out.writeByte(MagicValues.value(Integer.class, this.difficulty)); + out.writeByte(this.maxPlayers); + out.writeString(MagicValues.value(String.class, this.worldType)); + out.writeBoolean(this.reducedDebugInfo); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerKeepAlivePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerKeepAlivePacket.java index 5b150e730..67b6c2937 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerKeepAlivePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerKeepAlivePacket.java @@ -8,33 +8,33 @@ public class ServerKeepAlivePacket implements Packet { - private int id; - - @SuppressWarnings("unused") - private ServerKeepAlivePacket() { - } - - public ServerKeepAlivePacket(int id) { - this.id = id; - } - - public int getPingId() { - return this.id; - } - - @Override - public void read(NetInput in) throws IOException { - this.id = in.readVarInt(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.id); - } - - @Override - public boolean isPriority() { - return false; - } + private int id; + + @SuppressWarnings("unused") + private ServerKeepAlivePacket() { + } + + public ServerKeepAlivePacket(int id) { + this.id = id; + } + + public int getPingId() { + return this.id; + } + + @Override + public void read(NetInput in) throws IOException { + this.id = in.readVarInt(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.id); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListDataPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListDataPacket.java index 02dec8358..44c255e2b 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListDataPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListDataPacket.java @@ -8,40 +8,40 @@ import java.io.IOException; public class ServerPlayerListDataPacket implements Packet { - private Message header; - private Message footer; - - @SuppressWarnings("unused") - private ServerPlayerListDataPacket() { - } - - public ServerPlayerListDataPacket(Message header, Message footer) { - this.header = header; - this.footer = footer; - } - - public Message getHeader() { - return this.header; - } - - public Message getFooter() { - return this.footer; - } - - @Override - public void read(NetInput in) throws IOException { - this.header = Message.fromString(in.readString()); - this.footer = Message.fromString(in.readString()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.header.toJsonString()); - out.writeString(this.footer.toJsonString()); - } - - @Override - public boolean isPriority() { - return false; - } + private Message header; + private Message footer; + + @SuppressWarnings("unused") + private ServerPlayerListDataPacket() { + } + + public ServerPlayerListDataPacket(Message header, Message footer) { + this.header = header; + this.footer = footer; + } + + public Message getHeader() { + return this.header; + } + + public Message getFooter() { + return this.footer; + } + + @Override + public void read(NetInput in) throws IOException { + this.header = Message.fromString(in.readString()); + this.footer = Message.fromString(in.readString()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.header.toJsonString()); + out.writeString(this.footer.toJsonString()); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java index 24b66be96..3538a1b05 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java @@ -15,135 +15,135 @@ import java.util.UUID; public class ServerPlayerListEntryPacket implements Packet { - private PlayerListEntryAction action; - private PlayerListEntry entries[]; - - @SuppressWarnings("unused") - private ServerPlayerListEntryPacket() { - } - - public ServerPlayerListEntryPacket(PlayerListEntryAction action, PlayerListEntry entries[]) { - this.action = action; - this.entries = entries; - } - - public PlayerListEntryAction getAction() { - return this.action; - } - - public PlayerListEntry[] getEntries() { - return this.entries; - } - - @Override - public void read(NetInput in) throws IOException { - this.action = MagicValues.key(PlayerListEntryAction.class, in.readVarInt()); - this.entries = new PlayerListEntry[in.readVarInt()]; - for(int count = 0; count < this.entries.length; count++) { - UUID uuid = in.readUUID(); - GameProfile profile; - if(this.action == PlayerListEntryAction.ADD_PLAYER) { - profile = new GameProfile(uuid, in.readString()); - } else { - profile = new GameProfile(uuid, null); - } - - PlayerListEntry entry = null; - switch(this.action) { - case ADD_PLAYER: - int properties = in.readVarInt(); - for(int index = 0; index < properties; index++) { - String propertyName = in.readString(); - String value = in.readString(); - String signature = null; - if(in.readBoolean()) { - signature = in.readString(); - } - - profile.getProperties().put(propertyName, new Property(propertyName, value, signature)); - } - - GameMode gameMode = MagicValues.key(GameMode.class, in.readVarInt()); - int ping = in.readVarInt(); - Message displayName = null; - if(in.readBoolean()) { - displayName = Message.fromString(in.readString()); - } - - entry = new PlayerListEntry(profile, gameMode, ping, displayName); - break; - case UPDATE_GAMEMODE: - GameMode mode = MagicValues.key(GameMode.class, in.readVarInt()); - entry = new PlayerListEntry(profile, mode); - break; - case UPDATE_LATENCY: - int png = in.readVarInt(); - entry = new PlayerListEntry(profile, png); - break; - case UPDATE_DISPLAY_NAME: - Message disp = null; - if(in.readBoolean()) { - disp = Message.fromString(in.readString()); - } - - entry = new PlayerListEntry(profile, disp); - case REMOVE_PLAYER: - entry = new PlayerListEntry(profile); - break; - } - - this.entries[count] = entry; - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(MagicValues.value(Integer.class, this.action)); - out.writeVarInt(this.entries.length); - for(PlayerListEntry entry : this.entries) { - out.writeUUID(entry.getProfile().getId()); - switch(this.action) { - case ADD_PLAYER: - out.writeString(entry.getProfile().getName()); - out.writeVarInt(entry.getProfile().getProperties().size()); - for(Property property : entry.getProfile().getProperties().values()) { - out.writeString(property.getName()); - out.writeString(property.getValue()); - out.writeBoolean(property.hasSignature()); - if(property.hasSignature()) { - out.writeString(property.getSignature()); - } - } - - out.writeVarInt(MagicValues.value(Integer.class, entry.getGameMode())); - out.writeVarInt(entry.getPing()); - out.writeBoolean(entry.getDisplayName() != null); - if(entry.getDisplayName() != null) { - out.writeString(entry.getDisplayName().toJsonString()); - } - - break; - case UPDATE_GAMEMODE: - out.writeVarInt(MagicValues.value(Integer.class, entry.getGameMode())); - break; - case UPDATE_LATENCY: - out.writeVarInt(entry.getPing()); - break; - case UPDATE_DISPLAY_NAME: - out.writeBoolean(entry.getDisplayName() != null); - if(entry.getDisplayName() != null) { - out.writeString(entry.getDisplayName().toJsonString()); - } - - break; - case REMOVE_PLAYER: - break; - } - } - } - - @Override - public boolean isPriority() { - return false; - } + private PlayerListEntryAction action; + private PlayerListEntry entries[]; + + @SuppressWarnings("unused") + private ServerPlayerListEntryPacket() { + } + + public ServerPlayerListEntryPacket(PlayerListEntryAction action, PlayerListEntry entries[]) { + this.action = action; + this.entries = entries; + } + + public PlayerListEntryAction getAction() { + return this.action; + } + + public PlayerListEntry[] getEntries() { + return this.entries; + } + + @Override + public void read(NetInput in) throws IOException { + this.action = MagicValues.key(PlayerListEntryAction.class, in.readVarInt()); + this.entries = new PlayerListEntry[in.readVarInt()]; + for(int count = 0; count < this.entries.length; count++) { + UUID uuid = in.readUUID(); + GameProfile profile; + if(this.action == PlayerListEntryAction.ADD_PLAYER) { + profile = new GameProfile(uuid, in.readString()); + } else { + profile = new GameProfile(uuid, null); + } + + PlayerListEntry entry = null; + switch(this.action) { + case ADD_PLAYER: + int properties = in.readVarInt(); + for(int index = 0; index < properties; index++) { + String propertyName = in.readString(); + String value = in.readString(); + String signature = null; + if(in.readBoolean()) { + signature = in.readString(); + } + + profile.getProperties().put(propertyName, new Property(propertyName, value, signature)); + } + + GameMode gameMode = MagicValues.key(GameMode.class, in.readVarInt()); + int ping = in.readVarInt(); + Message displayName = null; + if(in.readBoolean()) { + displayName = Message.fromString(in.readString()); + } + + entry = new PlayerListEntry(profile, gameMode, ping, displayName); + break; + case UPDATE_GAMEMODE: + GameMode mode = MagicValues.key(GameMode.class, in.readVarInt()); + entry = new PlayerListEntry(profile, mode); + break; + case UPDATE_LATENCY: + int png = in.readVarInt(); + entry = new PlayerListEntry(profile, png); + break; + case UPDATE_DISPLAY_NAME: + Message disp = null; + if(in.readBoolean()) { + disp = Message.fromString(in.readString()); + } + + entry = new PlayerListEntry(profile, disp); + case REMOVE_PLAYER: + entry = new PlayerListEntry(profile); + break; + } + + this.entries[count] = entry; + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(MagicValues.value(Integer.class, this.action)); + out.writeVarInt(this.entries.length); + for(PlayerListEntry entry : this.entries) { + out.writeUUID(entry.getProfile().getId()); + switch(this.action) { + case ADD_PLAYER: + out.writeString(entry.getProfile().getName()); + out.writeVarInt(entry.getProfile().getProperties().size()); + for(Property property : entry.getProfile().getProperties().values()) { + out.writeString(property.getName()); + out.writeString(property.getValue()); + out.writeBoolean(property.hasSignature()); + if(property.hasSignature()) { + out.writeString(property.getSignature()); + } + } + + out.writeVarInt(MagicValues.value(Integer.class, entry.getGameMode())); + out.writeVarInt(entry.getPing()); + out.writeBoolean(entry.getDisplayName() != null); + if(entry.getDisplayName() != null) { + out.writeString(entry.getDisplayName().toJsonString()); + } + + break; + case UPDATE_GAMEMODE: + out.writeVarInt(MagicValues.value(Integer.class, entry.getGameMode())); + break; + case UPDATE_LATENCY: + out.writeVarInt(entry.getPing()); + break; + case UPDATE_DISPLAY_NAME: + out.writeBoolean(entry.getDisplayName() != null); + if(entry.getDisplayName() != null) { + out.writeString(entry.getDisplayName().toJsonString()); + } + + break; + case REMOVE_PLAYER: + break; + } + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPluginMessagePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPluginMessagePacket.java index 11cb713da..68d870124 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPluginMessagePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPluginMessagePacket.java @@ -8,41 +8,41 @@ public class ServerPluginMessagePacket implements Packet { - private String channel; - private byte data[]; - - @SuppressWarnings("unused") - private ServerPluginMessagePacket() { - } - - public ServerPluginMessagePacket(String channel, byte data[]) { - this.channel = channel; - this.data = data; - } - - public String getChannel() { - return this.channel; - } - - public byte[] getData() { - return this.data; - } - - @Override - public void read(NetInput in) throws IOException { - this.channel = in.readString(); - this.data = in.readBytes(in.available()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.channel); - out.writeBytes(this.data); - } - - @Override - public boolean isPriority() { - return false; - } + private String channel; + private byte data[]; + + @SuppressWarnings("unused") + private ServerPluginMessagePacket() { + } + + public ServerPluginMessagePacket(String channel, byte data[]) { + this.channel = channel; + this.data = data; + } + + public String getChannel() { + return this.channel; + } + + public byte[] getData() { + return this.data; + } + + @Override + public void read(NetInput in) throws IOException { + this.channel = in.readString(); + this.data = in.readBytes(in.available()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.channel); + out.writeBytes(this.data); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerResourcePackSendPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerResourcePackSendPacket.java index 840f10ff1..544ef13fa 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerResourcePackSendPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerResourcePackSendPacket.java @@ -7,40 +7,40 @@ import java.io.IOException; public class ServerResourcePackSendPacket implements Packet { - private String url; - private String hash; - - @SuppressWarnings("unused") - private ServerResourcePackSendPacket() { - } - - public ServerResourcePackSendPacket(String url, String hash) { - this.url = url; - this.hash = hash; - } - - public String getUrl() { - return this.url; - } - - public String getHash() { - return this.hash; - } - - @Override - public void read(NetInput in) throws IOException { - this.url = in.readString(); - this.hash = in.readString(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.url); - out.writeString(this.hash); - } - - @Override - public boolean isPriority() { - return false; - } + private String url; + private String hash; + + @SuppressWarnings("unused") + private ServerResourcePackSendPacket() { + } + + public ServerResourcePackSendPacket(String url, String hash) { + this.url = url; + this.hash = hash; + } + + public String getUrl() { + return this.url; + } + + public String getHash() { + return this.hash; + } + + @Override + public void read(NetInput in) throws IOException { + this.url = in.readString(); + this.hash = in.readString(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.url); + out.writeString(this.hash); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerRespawnPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerRespawnPacket.java index 29500608e..dfab23543 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerRespawnPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerRespawnPacket.java @@ -12,57 +12,57 @@ public class ServerRespawnPacket implements Packet { - private int dimension; - private Difficulty difficulty; - private GameMode gamemode; - private WorldType worldType; + private int dimension; + private Difficulty difficulty; + private GameMode gamemode; + private WorldType worldType; - @SuppressWarnings("unused") - private ServerRespawnPacket() { - } + @SuppressWarnings("unused") + private ServerRespawnPacket() { + } - public ServerRespawnPacket(int dimension, Difficulty difficulty, GameMode gamemode, WorldType worldType) { - this.dimension = dimension; - this.difficulty = difficulty; - this.gamemode = gamemode; - this.worldType = worldType; - } + public ServerRespawnPacket(int dimension, Difficulty difficulty, GameMode gamemode, WorldType worldType) { + this.dimension = dimension; + this.difficulty = difficulty; + this.gamemode = gamemode; + this.worldType = worldType; + } - public int getDimension() { - return this.dimension; - } + public int getDimension() { + return this.dimension; + } - public Difficulty getDifficulty() { - return this.difficulty; - } + public Difficulty getDifficulty() { + return this.difficulty; + } - public GameMode getGameMode() { - return this.gamemode; - } + public GameMode getGameMode() { + return this.gamemode; + } - public WorldType getWorldType() { - return this.worldType; - } + public WorldType getWorldType() { + return this.worldType; + } - @Override - public void read(NetInput in) throws IOException { - this.dimension = in.readInt(); - this.difficulty = MagicValues.key(Difficulty.class, in.readUnsignedByte()); - this.gamemode = MagicValues.key(GameMode.class, in.readUnsignedByte()); - this.worldType = MagicValues.key(WorldType.class, in.readString().toLowerCase()); - } + @Override + public void read(NetInput in) throws IOException { + this.dimension = in.readInt(); + this.difficulty = MagicValues.key(Difficulty.class, in.readUnsignedByte()); + this.gamemode = MagicValues.key(GameMode.class, in.readUnsignedByte()); + this.worldType = MagicValues.key(WorldType.class, in.readString().toLowerCase()); + } - @Override - public void write(NetOutput out) throws IOException { - out.writeInt(this.dimension); - out.writeByte(MagicValues.value(Integer.class, this.difficulty)); - out.writeByte(MagicValues.value(Integer.class, this.gamemode)); - out.writeString(MagicValues.value(String.class, this.worldType)); - } + @Override + public void write(NetOutput out) throws IOException { + out.writeInt(this.dimension); + out.writeByte(MagicValues.value(Integer.class, this.difficulty)); + out.writeByte(MagicValues.value(Integer.class, this.gamemode)); + out.writeString(MagicValues.value(String.class, this.worldType)); + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerSetCompressionPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerSetCompressionPacket.java index 59e9dca07..18b698834 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerSetCompressionPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerSetCompressionPacket.java @@ -7,32 +7,32 @@ import java.io.IOException; public class ServerSetCompressionPacket implements Packet { - private int threshold; - - @SuppressWarnings("unused") - private ServerSetCompressionPacket() { - } - - public ServerSetCompressionPacket(int threshold) { - this.threshold = threshold; - } - - public int getThreshold() { - return this.threshold; - } - - @Override - public void read(NetInput in) throws IOException { - this.threshold = in.readVarInt(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.threshold); - } - - @Override - public boolean isPriority() { - return true; - } + private int threshold; + + @SuppressWarnings("unused") + private ServerSetCompressionPacket() { + } + + public ServerSetCompressionPacket(int threshold) { + this.threshold = threshold; + } + + public int getThreshold() { + return this.threshold; + } + + @Override + public void read(NetInput in) throws IOException { + this.threshold = in.readVarInt(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.threshold); + } + + @Override + public boolean isPriority() { + return true; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerStatisticsPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerStatisticsPacket.java index 6e1e7ac9f..ae1f224b8 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerStatisticsPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerStatisticsPacket.java @@ -1,7 +1,13 @@ package org.spacehq.mc.protocol.packet.ingame.server; import org.spacehq.mc.protocol.data.game.values.MagicValues; -import org.spacehq.mc.protocol.data.game.values.statistic.*; +import org.spacehq.mc.protocol.data.game.values.statistic.Achievement; +import org.spacehq.mc.protocol.data.game.values.statistic.BreakBlockStatistic; +import org.spacehq.mc.protocol.data.game.values.statistic.BreakItemStatistic; +import org.spacehq.mc.protocol.data.game.values.statistic.CraftItemStatistic; +import org.spacehq.mc.protocol.data.game.values.statistic.GenericStatistic; +import org.spacehq.mc.protocol.data.game.values.statistic.Statistic; +import org.spacehq.mc.protocol.data.game.values.statistic.UseItemStatistic; import org.spacehq.packetlib.io.NetInput; import org.spacehq.packetlib.io.NetOutput; import org.spacehq.packetlib.packet.Packet; @@ -12,76 +18,76 @@ public class ServerStatisticsPacket implements Packet { - private static final String CRAFT_ITEM_PREFIX = "stats.craftItem."; - private static final String BREAK_BLOCK_PREFIX = "stats.mineBlock."; - private static final String USE_ITEM_PREFIX = "stats.useItem."; - private static final String BREAK_ITEM_PREFIX = "stats.breakItem."; + private static final String CRAFT_ITEM_PREFIX = "stats.craftItem."; + private static final String BREAK_BLOCK_PREFIX = "stats.mineBlock."; + private static final String USE_ITEM_PREFIX = "stats.useItem."; + private static final String BREAK_ITEM_PREFIX = "stats.breakItem."; - private Map statistics = new HashMap(); + private Map statistics = new HashMap(); - @SuppressWarnings("unused") - private ServerStatisticsPacket() { - } + @SuppressWarnings("unused") + private ServerStatisticsPacket() { + } - public ServerStatisticsPacket(Map statistics) { - this.statistics = statistics; - } + public ServerStatisticsPacket(Map statistics) { + this.statistics = statistics; + } - public Map getStatistics() { - return this.statistics; - } + public Map getStatistics() { + return this.statistics; + } - @Override - public void read(NetInput in) throws IOException { - int length = in.readVarInt(); - for(int index = 0; index < length; index++) { - String value = in.readString(); - Statistic statistic = null; - if(value.startsWith("achievement.")) { - statistic = MagicValues.key(Achievement.class, value); - } else if(value.startsWith(CRAFT_ITEM_PREFIX)) { - statistic = new CraftItemStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1))); - } else if(value.startsWith(BREAK_BLOCK_PREFIX)) { - statistic = new BreakBlockStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1))); - } else if(value.startsWith(USE_ITEM_PREFIX)) { - statistic = new UseItemStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1))); - } else if(value.startsWith(BREAK_ITEM_PREFIX)) { - statistic = new BreakItemStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1))); - } else { - statistic = MagicValues.key(GenericStatistic.class, value); - } + @Override + public void read(NetInput in) throws IOException { + int length = in.readVarInt(); + for(int index = 0; index < length; index++) { + String value = in.readString(); + Statistic statistic = null; + if(value.startsWith("achievement.")) { + statistic = MagicValues.key(Achievement.class, value); + } else if(value.startsWith(CRAFT_ITEM_PREFIX)) { + statistic = new CraftItemStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1))); + } else if(value.startsWith(BREAK_BLOCK_PREFIX)) { + statistic = new BreakBlockStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1))); + } else if(value.startsWith(USE_ITEM_PREFIX)) { + statistic = new UseItemStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1))); + } else if(value.startsWith(BREAK_ITEM_PREFIX)) { + statistic = new BreakItemStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1))); + } else { + statistic = MagicValues.key(GenericStatistic.class, value); + } - this.statistics.put(statistic, in.readVarInt()); - } - } + this.statistics.put(statistic, in.readVarInt()); + } + } - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.statistics.size()); - for(Statistic statistic : this.statistics.keySet()) { - String value = ""; - if(statistic instanceof Achievement) { - value = MagicValues.value(String.class, (Achievement) statistic); - } else if(statistic instanceof CraftItemStatistic) { - value = CRAFT_ITEM_PREFIX + ((CraftItemStatistic) statistic).getId(); - } else if(statistic instanceof BreakBlockStatistic) { - value = BREAK_BLOCK_PREFIX + ((CraftItemStatistic) statistic).getId(); - } else if(statistic instanceof UseItemStatistic) { - value = USE_ITEM_PREFIX + ((CraftItemStatistic) statistic).getId(); - } else if(statistic instanceof BreakItemStatistic) { - value = BREAK_ITEM_PREFIX + ((CraftItemStatistic) statistic).getId(); - } else if(statistic instanceof GenericStatistic) { - value = MagicValues.value(String.class, (GenericStatistic) statistic); - } + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.statistics.size()); + for(Statistic statistic : this.statistics.keySet()) { + String value = ""; + if(statistic instanceof Achievement) { + value = MagicValues.value(String.class, (Achievement) statistic); + } else if(statistic instanceof CraftItemStatistic) { + value = CRAFT_ITEM_PREFIX + ((CraftItemStatistic) statistic).getId(); + } else if(statistic instanceof BreakBlockStatistic) { + value = BREAK_BLOCK_PREFIX + ((CraftItemStatistic) statistic).getId(); + } else if(statistic instanceof UseItemStatistic) { + value = USE_ITEM_PREFIX + ((CraftItemStatistic) statistic).getId(); + } else if(statistic instanceof BreakItemStatistic) { + value = BREAK_ITEM_PREFIX + ((CraftItemStatistic) statistic).getId(); + } else if(statistic instanceof GenericStatistic) { + value = MagicValues.value(String.class, (GenericStatistic) statistic); + } - out.writeString(value); - out.writeVarInt(this.statistics.get(statistic)); - } - } + out.writeString(value); + out.writeVarInt(this.statistics.get(statistic)); + } + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerSwitchCameraPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerSwitchCameraPacket.java index 4041c0024..9c89ecbc4 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerSwitchCameraPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerSwitchCameraPacket.java @@ -8,33 +8,33 @@ public class ServerSwitchCameraPacket implements Packet { - private int cameraEntityId; - - @SuppressWarnings("unused") - private ServerSwitchCameraPacket() { - } - - public ServerSwitchCameraPacket(int cameraEntityId) { - this.cameraEntityId = cameraEntityId; - } - - public int getCameraEntityId() { - return this.cameraEntityId; - } - - @Override - public void read(NetInput in) throws IOException { - this.cameraEntityId = in.readVarInt(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.cameraEntityId); - } - - @Override - public boolean isPriority() { - return false; - } + private int cameraEntityId; + + @SuppressWarnings("unused") + private ServerSwitchCameraPacket() { + } + + public ServerSwitchCameraPacket(int cameraEntityId) { + this.cameraEntityId = cameraEntityId; + } + + public int getCameraEntityId() { + return this.cameraEntityId; + } + + @Override + public void read(NetInput in) throws IOException { + this.cameraEntityId = in.readVarInt(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.cameraEntityId); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerTabCompletePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerTabCompletePacket.java index 481ca0875..c4dee06c0 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerTabCompletePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerTabCompletePacket.java @@ -8,39 +8,39 @@ public class ServerTabCompletePacket implements Packet { - private String matches[]; - - @SuppressWarnings("unused") - private ServerTabCompletePacket() { - } - - public ServerTabCompletePacket(String matches[]) { - this.matches = matches; - } - - public String[] getMatches() { - return this.matches; - } - - @Override - public void read(NetInput in) throws IOException { - this.matches = new String[in.readVarInt()]; - for(int index = 0; index < this.matches.length; index++) { - this.matches[index] = in.readString(); - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.matches.length); - for(String match : this.matches) { - out.writeString(match); - } - } - - @Override - public boolean isPriority() { - return false; - } + private String matches[]; + + @SuppressWarnings("unused") + private ServerTabCompletePacket() { + } + + public ServerTabCompletePacket(String matches[]) { + this.matches = matches; + } + + public String[] getMatches() { + return this.matches; + } + + @Override + public void read(NetInput in) throws IOException { + this.matches = new String[in.readVarInt()]; + for(int index = 0; index < this.matches.length; index++) { + this.matches[index] = in.readString(); + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.matches.length); + for(String match : this.matches) { + out.writeString(match); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerTitlePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerTitlePacket.java index e3cdd2352..eae7db914 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerTitlePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerTitlePacket.java @@ -10,119 +10,119 @@ import java.io.IOException; public class ServerTitlePacket implements Packet { - private TitleAction action; - - private Message title; - - private Message subtitle; - - private int fadeIn; - private int stay; - private int fadeOut; - - @SuppressWarnings("unused") - private ServerTitlePacket() { - } - - public ServerTitlePacket(String title, boolean sub) { - this(Message.fromString(title), sub); - } - - public ServerTitlePacket(Message title, boolean sub) { - if(sub) { - this.action = TitleAction.SUBTITLE; - this.subtitle = title; - } else { - this.action = TitleAction.TITLE; - this.title = title; - } - } - - public ServerTitlePacket(int fadeIn, int stay, int fadeOut) { - this.action = TitleAction.TIMES; - this.fadeIn = fadeIn; - this.stay = stay; - this.fadeOut = fadeOut; - } - - public ServerTitlePacket(boolean clear) { - if(clear) { - this.action = TitleAction.CLEAR; - } else { - this.action = TitleAction.RESET; - } - } - - public TitleAction getAction() { - return this.action; - } - - public Message getTitle() { - return this.title; - } - - public Message getSubtitle() { - return this.subtitle; - } - - public int getFadeIn() { - return this.fadeIn; - } - - public int getStay() { - return this.stay; - } - - public int getFadeOut() { - return this.fadeOut; - } - - @Override - public void read(NetInput in) throws IOException { - this.action = MagicValues.key(TitleAction.class, in.readVarInt()); - switch(this.action) { - case TITLE: - this.title = Message.fromString(in.readString()); - break; - case SUBTITLE: - this.subtitle = Message.fromString(in.readString()); - break; - case TIMES: - this.fadeIn = in.readInt(); - this.stay = in.readInt(); - this.fadeOut = in.readInt(); - break; - case CLEAR: - break; - case RESET: - break; - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(MagicValues.value(Integer.class, this.action)); - switch(this.action) { - case TITLE: - out.writeString(this.title.toJsonString()); - break; - case SUBTITLE: - out.writeString(this.subtitle.toJsonString()); - break; - case TIMES: - out.writeInt(this.fadeIn); - out.writeInt(this.stay); - out.writeInt(this.fadeOut); - break; - case CLEAR: - break; - case RESET: - break; - } - } - - @Override - public boolean isPriority() { - return false; - } + private TitleAction action; + + private Message title; + + private Message subtitle; + + private int fadeIn; + private int stay; + private int fadeOut; + + @SuppressWarnings("unused") + private ServerTitlePacket() { + } + + public ServerTitlePacket(String title, boolean sub) { + this(Message.fromString(title), sub); + } + + public ServerTitlePacket(Message title, boolean sub) { + if(sub) { + this.action = TitleAction.SUBTITLE; + this.subtitle = title; + } else { + this.action = TitleAction.TITLE; + this.title = title; + } + } + + public ServerTitlePacket(int fadeIn, int stay, int fadeOut) { + this.action = TitleAction.TIMES; + this.fadeIn = fadeIn; + this.stay = stay; + this.fadeOut = fadeOut; + } + + public ServerTitlePacket(boolean clear) { + if(clear) { + this.action = TitleAction.CLEAR; + } else { + this.action = TitleAction.RESET; + } + } + + public TitleAction getAction() { + return this.action; + } + + public Message getTitle() { + return this.title; + } + + public Message getSubtitle() { + return this.subtitle; + } + + public int getFadeIn() { + return this.fadeIn; + } + + public int getStay() { + return this.stay; + } + + public int getFadeOut() { + return this.fadeOut; + } + + @Override + public void read(NetInput in) throws IOException { + this.action = MagicValues.key(TitleAction.class, in.readVarInt()); + switch(this.action) { + case TITLE: + this.title = Message.fromString(in.readString()); + break; + case SUBTITLE: + this.subtitle = Message.fromString(in.readString()); + break; + case TIMES: + this.fadeIn = in.readInt(); + this.stay = in.readInt(); + this.fadeOut = in.readInt(); + break; + case CLEAR: + break; + case RESET: + break; + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(MagicValues.value(Integer.class, this.action)); + switch(this.action) { + case TITLE: + out.writeString(this.title.toJsonString()); + break; + case SUBTITLE: + out.writeString(this.subtitle.toJsonString()); + break; + case TIMES: + out.writeInt(this.fadeIn); + out.writeInt(this.stay); + out.writeInt(this.fadeOut); + break; + case CLEAR: + break; + case RESET: + break; + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerAnimationPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerAnimationPacket.java index dd9444e8c..1be2d9fc8 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerAnimationPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerAnimationPacket.java @@ -10,41 +10,41 @@ public class ServerAnimationPacket implements Packet { - private int entityId; - private Animation animation; - - @SuppressWarnings("unused") - private ServerAnimationPacket() { - } - - public ServerAnimationPacket(int entityId, Animation animation) { - this.entityId = entityId; - this.animation = animation; - } - - public int getEntityId() { - return this.entityId; - } - - public Animation getAnimation() { - return this.animation; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.animation = MagicValues.key(Animation.class, in.readByte()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeByte(MagicValues.value(Integer.class, this.animation)); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private Animation animation; + + @SuppressWarnings("unused") + private ServerAnimationPacket() { + } + + public ServerAnimationPacket(int entityId, Animation animation) { + this.entityId = entityId; + this.animation = animation; + } + + public int getEntityId() { + return this.entityId; + } + + public Animation getAnimation() { + return this.animation; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.animation = MagicValues.key(Animation.class, in.readByte()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeByte(MagicValues.value(Integer.class, this.animation)); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerCollectItemPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerCollectItemPacket.java index 07357fda2..7bdba6ce0 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerCollectItemPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerCollectItemPacket.java @@ -8,41 +8,41 @@ public class ServerCollectItemPacket implements Packet { - private int collectedEntityId; - private int collectorEntityId; - - @SuppressWarnings("unused") - private ServerCollectItemPacket() { - } - - public ServerCollectItemPacket(int collectedEntityId, int collectorEntityId) { - this.collectedEntityId = collectedEntityId; - this.collectorEntityId = collectorEntityId; - } - - public int getCollectedEntityId() { - return this.collectedEntityId; - } - - public int getCollectorEntityId() { - return this.collectorEntityId; - } - - @Override - public void read(NetInput in) throws IOException { - this.collectedEntityId = in.readVarInt(); - this.collectorEntityId = in.readVarInt(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.collectedEntityId); - out.writeVarInt(this.collectorEntityId); - } - - @Override - public boolean isPriority() { - return false; - } + private int collectedEntityId; + private int collectorEntityId; + + @SuppressWarnings("unused") + private ServerCollectItemPacket() { + } + + public ServerCollectItemPacket(int collectedEntityId, int collectorEntityId) { + this.collectedEntityId = collectedEntityId; + this.collectorEntityId = collectorEntityId; + } + + public int getCollectedEntityId() { + return this.collectedEntityId; + } + + public int getCollectorEntityId() { + return this.collectorEntityId; + } + + @Override + public void read(NetInput in) throws IOException { + this.collectedEntityId = in.readVarInt(); + this.collectorEntityId = in.readVarInt(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.collectedEntityId); + out.writeVarInt(this.collectorEntityId); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerDestroyEntitiesPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerDestroyEntitiesPacket.java index 816f563c2..25311612e 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerDestroyEntitiesPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerDestroyEntitiesPacket.java @@ -8,39 +8,39 @@ public class ServerDestroyEntitiesPacket implements Packet { - private int entityIds[]; - - @SuppressWarnings("unused") - private ServerDestroyEntitiesPacket() { - } - - public ServerDestroyEntitiesPacket(int... entityIds) { - this.entityIds = entityIds; - } - - public int[] getEntityIds() { - return this.entityIds; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityIds = new int[in.readVarInt()]; - for(int index = 0; index < this.entityIds.length; index++) { - this.entityIds[index] = in.readVarInt(); - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityIds.length); - for(int entityId : this.entityIds) { - out.writeVarInt(entityId); - } - } - - @Override - public boolean isPriority() { - return false; - } + private int entityIds[]; + + @SuppressWarnings("unused") + private ServerDestroyEntitiesPacket() { + } + + public ServerDestroyEntitiesPacket(int... entityIds) { + this.entityIds = entityIds; + } + + public int[] getEntityIds() { + return this.entityIds; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityIds = new int[in.readVarInt()]; + for(int index = 0; index < this.entityIds.length; index++) { + this.entityIds[index] = in.readVarInt(); + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityIds.length); + for(int entityId : this.entityIds) { + out.writeVarInt(entityId); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityAttachPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityAttachPacket.java index d7588c35d..aac850aa9 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityAttachPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityAttachPacket.java @@ -8,49 +8,49 @@ public class ServerEntityAttachPacket implements Packet { - private int entityId; - private int attachedToId; - private boolean leash; - - @SuppressWarnings("unused") - private ServerEntityAttachPacket() { - } - - public ServerEntityAttachPacket(int entityId, int attachedToId, boolean leash) { - this.entityId = entityId; - this.attachedToId = attachedToId; - this.leash = leash; - } - - public int getEntityId() { - return this.entityId; - } - - public int getAttachedToId() { - return this.attachedToId; - } - - public boolean getLeash() { - return this.leash; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readInt(); - this.attachedToId = in.readInt(); - this.leash = in.readBoolean(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeInt(this.entityId); - out.writeInt(this.attachedToId); - out.writeBoolean(this.leash); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private int attachedToId; + private boolean leash; + + @SuppressWarnings("unused") + private ServerEntityAttachPacket() { + } + + public ServerEntityAttachPacket(int entityId, int attachedToId, boolean leash) { + this.entityId = entityId; + this.attachedToId = attachedToId; + this.leash = leash; + } + + public int getEntityId() { + return this.entityId; + } + + public int getAttachedToId() { + return this.attachedToId; + } + + public boolean getLeash() { + return this.leash; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readInt(); + this.attachedToId = in.readInt(); + this.leash = in.readBoolean(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeInt(this.entityId); + out.writeInt(this.attachedToId); + out.writeBoolean(this.leash); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityEffectPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityEffectPacket.java index 30ba25349..6ca2c07d6 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityEffectPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityEffectPacket.java @@ -10,65 +10,65 @@ public class ServerEntityEffectPacket implements Packet { - private int entityId; - private Effect effect; - private int amplifier; - private int duration; - private boolean hideParticles; + private int entityId; + private Effect effect; + private int amplifier; + private int duration; + private boolean hideParticles; - @SuppressWarnings("unused") - private ServerEntityEffectPacket() { - } + @SuppressWarnings("unused") + private ServerEntityEffectPacket() { + } - public ServerEntityEffectPacket(int entityId, Effect effect, int amplifier, int duration, boolean hideParticles) { - this.entityId = entityId; - this.effect = effect; - this.amplifier = amplifier; - this.duration = duration; - this.hideParticles = hideParticles; - } + public ServerEntityEffectPacket(int entityId, Effect effect, int amplifier, int duration, boolean hideParticles) { + this.entityId = entityId; + this.effect = effect; + this.amplifier = amplifier; + this.duration = duration; + this.hideParticles = hideParticles; + } - public int getEntityId() { - return this.entityId; - } + public int getEntityId() { + return this.entityId; + } - public Effect getEffect() { - return this.effect; - } + public Effect getEffect() { + return this.effect; + } - public int getAmplifier() { - return this.amplifier; - } + public int getAmplifier() { + return this.amplifier; + } - public int getDuration() { - return this.duration; - } + public int getDuration() { + return this.duration; + } - public boolean getHideParticles() { - return this.hideParticles; - } + public boolean getHideParticles() { + return this.hideParticles; + } - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.effect = MagicValues.key(Effect.class, in.readByte()); - this.amplifier = in.readByte(); - this.duration = in.readVarInt(); - this.hideParticles = in.readBoolean(); - } + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.effect = MagicValues.key(Effect.class, in.readByte()); + this.amplifier = in.readByte(); + this.duration = in.readVarInt(); + this.hideParticles = in.readBoolean(); + } - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeByte(MagicValues.value(Integer.class, this.effect)); - out.writeByte(this.amplifier); - out.writeVarInt(this.duration); - out.writeBoolean(this.hideParticles); - } + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeByte(MagicValues.value(Integer.class, this.effect)); + out.writeByte(this.amplifier); + out.writeVarInt(this.duration); + out.writeBoolean(this.hideParticles); + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityEquipmentPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityEquipmentPacket.java index 078beecbc..d1e45dab3 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityEquipmentPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityEquipmentPacket.java @@ -10,49 +10,49 @@ public class ServerEntityEquipmentPacket implements Packet { - private int entityId; - private int slot; - private ItemStack item; - - @SuppressWarnings("unused") - private ServerEntityEquipmentPacket() { - } - - public ServerEntityEquipmentPacket(int entityId, int slot, ItemStack item) { - this.entityId = entityId; - this.slot = slot; - this.item = item; - } - - public int getEntityId() { - return this.entityId; - } - - public int getSlot() { - return this.slot; - } - - public ItemStack getItem() { - return this.item; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.slot = in.readShort(); - this.item = NetUtil.readItem(in); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeShort(this.slot); - NetUtil.writeItem(out, this.item); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private int slot; + private ItemStack item; + + @SuppressWarnings("unused") + private ServerEntityEquipmentPacket() { + } + + public ServerEntityEquipmentPacket(int entityId, int slot, ItemStack item) { + this.entityId = entityId; + this.slot = slot; + this.item = item; + } + + public int getEntityId() { + return this.entityId; + } + + public int getSlot() { + return this.slot; + } + + public ItemStack getItem() { + return this.item; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.slot = in.readShort(); + this.item = NetUtil.readItem(in); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeShort(this.slot); + NetUtil.writeItem(out, this.item); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityHeadLookPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityHeadLookPacket.java index 8cee31bfe..c89868d8e 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityHeadLookPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityHeadLookPacket.java @@ -8,41 +8,41 @@ public class ServerEntityHeadLookPacket implements Packet { - private int entityId; - private float headYaw; - - @SuppressWarnings("unused") - private ServerEntityHeadLookPacket() { - } - - public ServerEntityHeadLookPacket(int entityId, float headYaw) { - this.entityId = entityId; - this.headYaw = headYaw; - } - - public int getEntityId() { - return this.entityId; - } - - public float getHeadYaw() { - return this.headYaw; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.headYaw = in.readByte() * 360 / 256f; - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeByte((byte) (this.headYaw * 256 / 360)); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private float headYaw; + + @SuppressWarnings("unused") + private ServerEntityHeadLookPacket() { + } + + public ServerEntityHeadLookPacket(int entityId, float headYaw) { + this.entityId = entityId; + this.headYaw = headYaw; + } + + public int getEntityId() { + return this.entityId; + } + + public float getHeadYaw() { + return this.headYaw; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.headYaw = in.readByte() * 360 / 256f; + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeByte((byte) (this.headYaw * 256 / 360)); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityMetadataPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityMetadataPacket.java index f55967f3a..c10d95069 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityMetadataPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityMetadataPacket.java @@ -10,41 +10,41 @@ public class ServerEntityMetadataPacket implements Packet { - private int entityId; - private EntityMetadata metadata[]; - - @SuppressWarnings("unused") - private ServerEntityMetadataPacket() { - } - - public ServerEntityMetadataPacket(int entityId, EntityMetadata metadata[]) { - this.entityId = entityId; - this.metadata = metadata; - } - - public int getEntityId() { - return this.entityId; - } - - public EntityMetadata[] getMetadata() { - return this.metadata; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.metadata = NetUtil.readEntityMetadata(in); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - NetUtil.writeEntityMetadata(out, this.metadata); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private EntityMetadata metadata[]; + + @SuppressWarnings("unused") + private ServerEntityMetadataPacket() { + } + + public ServerEntityMetadataPacket(int entityId, EntityMetadata metadata[]) { + this.entityId = entityId; + this.metadata = metadata; + } + + public int getEntityId() { + return this.entityId; + } + + public EntityMetadata[] getMetadata() { + return this.metadata; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.metadata = NetUtil.readEntityMetadata(in); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + NetUtil.writeEntityMetadata(out, this.metadata); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityMovementPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityMovementPacket.java index e11b3c3d3..c9fba9931 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityMovementPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityMovementPacket.java @@ -8,90 +8,90 @@ public class ServerEntityMovementPacket implements Packet { - protected int entityId; - protected double moveX; - protected double moveY; - protected double moveZ; - protected float yaw; - protected float pitch; - private boolean onGround; - - protected boolean pos = false; - protected boolean rot = false; - - protected ServerEntityMovementPacket() { - } - - public ServerEntityMovementPacket(int entityId, boolean onGround) { - this.entityId = entityId; - this.onGround = onGround; - } - - public int getEntityId() { - return this.entityId; - } - - public double getMovementX() { - return this.moveX; - } - - public double getMovementY() { - return this.moveY; - } - - public double getMovementZ() { - return this.moveZ; - } - - public float getYaw() { - return this.yaw; - } - - public float getPitch() { - return this.pitch; - } - - public boolean isOnGround() { - return this.onGround; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - if(this.pos) { - this.moveX = in.readByte() / 32D; - this.moveY = in.readByte() / 32D; - this.moveZ = in.readByte() / 32D; - } - - if(this.rot) { - this.yaw = in.readByte() * 360 / 256f; - this.pitch = in.readByte() * 360 / 256f; - } - - this.onGround = in.readBoolean(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - if(this.pos) { - out.writeByte((int) (this.moveX * 32)); - out.writeByte((int) (this.moveY * 32)); - out.writeByte((int) (this.moveZ * 32)); - } - - if(this.rot) { - out.writeByte((byte) (this.yaw * 256 / 360)); - out.writeByte((byte) (this.pitch * 256 / 360)); - } - - out.writeBoolean(this.onGround); - } - - @Override - public boolean isPriority() { - return false; - } + protected int entityId; + protected double moveX; + protected double moveY; + protected double moveZ; + protected float yaw; + protected float pitch; + private boolean onGround; + + protected boolean pos = false; + protected boolean rot = false; + + protected ServerEntityMovementPacket() { + } + + public ServerEntityMovementPacket(int entityId, boolean onGround) { + this.entityId = entityId; + this.onGround = onGround; + } + + public int getEntityId() { + return this.entityId; + } + + public double getMovementX() { + return this.moveX; + } + + public double getMovementY() { + return this.moveY; + } + + public double getMovementZ() { + return this.moveZ; + } + + public float getYaw() { + return this.yaw; + } + + public float getPitch() { + return this.pitch; + } + + public boolean isOnGround() { + return this.onGround; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + if(this.pos) { + this.moveX = in.readByte() / 32D; + this.moveY = in.readByte() / 32D; + this.moveZ = in.readByte() / 32D; + } + + if(this.rot) { + this.yaw = in.readByte() * 360 / 256f; + this.pitch = in.readByte() * 360 / 256f; + } + + this.onGround = in.readBoolean(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + if(this.pos) { + out.writeByte((int) (this.moveX * 32)); + out.writeByte((int) (this.moveY * 32)); + out.writeByte((int) (this.moveZ * 32)); + } + + if(this.rot) { + out.writeByte((byte) (this.yaw * 256 / 360)); + out.writeByte((byte) (this.pitch * 256 / 360)); + } + + out.writeBoolean(this.onGround); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityNBTUpdatePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityNBTUpdatePacket.java index 16cbf8c24..3b2dd56d1 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityNBTUpdatePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityNBTUpdatePacket.java @@ -9,40 +9,40 @@ import java.io.IOException; public class ServerEntityNBTUpdatePacket implements Packet { - private int entityId; - private CompoundTag tag; - - @SuppressWarnings("unused") - private ServerEntityNBTUpdatePacket() { - } - - public ServerEntityNBTUpdatePacket(int entityId, CompoundTag tag) { - this.entityId = entityId; - this.tag = tag; - } - - public int getEntityId() { - return this.entityId; - } - - public CompoundTag getTag() { - return this.tag; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.tag = NetUtil.readNBT(in); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - NetUtil.writeNBT(out, this.tag); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private CompoundTag tag; + + @SuppressWarnings("unused") + private ServerEntityNBTUpdatePacket() { + } + + public ServerEntityNBTUpdatePacket(int entityId, CompoundTag tag) { + this.entityId = entityId; + this.tag = tag; + } + + public int getEntityId() { + return this.entityId; + } + + public CompoundTag getTag() { + return this.tag; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.tag = NetUtil.readNBT(in); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + NetUtil.writeNBT(out, this.tag); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPositionPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPositionPacket.java index 39cf3cde2..9f9685267 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPositionPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPositionPacket.java @@ -2,16 +2,16 @@ public class ServerEntityPositionPacket extends ServerEntityMovementPacket { - protected ServerEntityPositionPacket() { - this.pos = true; - } + protected ServerEntityPositionPacket() { + this.pos = true; + } - public ServerEntityPositionPacket(int entityId, double moveX, double moveY, double moveZ, boolean onGround) { - super(entityId, onGround); - this.pos = true; - this.moveX = moveX; - this.moveY = moveY; - this.moveZ = moveZ; - } + public ServerEntityPositionPacket(int entityId, double moveX, double moveY, double moveZ, boolean onGround) { + super(entityId, onGround); + this.pos = true; + this.moveX = moveX; + this.moveY = moveY; + this.moveZ = moveZ; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPositionRotationPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPositionRotationPacket.java index 7711e60f6..3efa97ec0 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPositionRotationPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPositionRotationPacket.java @@ -2,20 +2,20 @@ public class ServerEntityPositionRotationPacket extends ServerEntityMovementPacket { - protected ServerEntityPositionRotationPacket() { - this.pos = true; - this.rot = true; - } + protected ServerEntityPositionRotationPacket() { + this.pos = true; + this.rot = true; + } - public ServerEntityPositionRotationPacket(int entityId, double moveX, double moveY, double moveZ, float yaw, float pitch, boolean onGround) { - super(entityId, onGround); - this.pos = true; - this.rot = true; - this.moveX = moveX; - this.moveY = moveY; - this.moveZ = moveZ; - this.yaw = yaw; - this.pitch = pitch; - } + public ServerEntityPositionRotationPacket(int entityId, double moveX, double moveY, double moveZ, float yaw, float pitch, boolean onGround) { + super(entityId, onGround); + this.pos = true; + this.rot = true; + this.moveX = moveX; + this.moveY = moveY; + this.moveZ = moveZ; + this.yaw = yaw; + this.pitch = pitch; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPropertiesPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPropertiesPacket.java index 8f8907f42..b72886647 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPropertiesPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityPropertiesPacket.java @@ -15,63 +15,63 @@ public class ServerEntityPropertiesPacket implements Packet { - private int entityId; - private List attributes; + private int entityId; + private List attributes; - @SuppressWarnings("unused") - private ServerEntityPropertiesPacket() { - } + @SuppressWarnings("unused") + private ServerEntityPropertiesPacket() { + } - public ServerEntityPropertiesPacket(int entityId, List attributes) { - this.entityId = entityId; - this.attributes = attributes; - } + public ServerEntityPropertiesPacket(int entityId, List attributes) { + this.entityId = entityId; + this.attributes = attributes; + } - public int getEntityId() { - return this.entityId; - } + public int getEntityId() { + return this.entityId; + } - public List getAttributes() { - return this.attributes; - } + public List getAttributes() { + return this.attributes; + } - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.attributes = new ArrayList(); - int length = in.readInt(); - for(int index = 0; index < length; index++) { - String key = in.readString(); - double value = in.readDouble(); - List modifiers = new ArrayList(); - int len = in.readVarInt(); - for(int ind = 0; ind < len; ind++) { - modifiers.add(new AttributeModifier(in.readUUID(), in.readDouble(), MagicValues.key(ModifierOperation.class, in.readByte()))); - } + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.attributes = new ArrayList(); + int length = in.readInt(); + for(int index = 0; index < length; index++) { + String key = in.readString(); + double value = in.readDouble(); + List modifiers = new ArrayList(); + int len = in.readVarInt(); + for(int ind = 0; ind < len; ind++) { + modifiers.add(new AttributeModifier(in.readUUID(), in.readDouble(), MagicValues.key(ModifierOperation.class, in.readByte()))); + } - this.attributes.add(new Attribute(MagicValues.key(AttributeType.class, key), value, modifiers)); - } - } + this.attributes.add(new Attribute(MagicValues.key(AttributeType.class, key), value, modifiers)); + } + } - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeInt(this.attributes.size()); - for(Attribute attribute : this.attributes) { - out.writeString(MagicValues.value(String.class, attribute.getType())); - out.writeDouble(attribute.getValue()); - out.writeVarInt(attribute.getModifiers().size()); - for(AttributeModifier modifier : attribute.getModifiers()) { - out.writeUUID(modifier.getUUID()); - out.writeDouble(modifier.getAmount()); - out.writeByte(MagicValues.value(Integer.class, modifier.getOperation())); - } - } - } + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeInt(this.attributes.size()); + for(Attribute attribute : this.attributes) { + out.writeString(MagicValues.value(String.class, attribute.getType())); + out.writeDouble(attribute.getValue()); + out.writeVarInt(attribute.getModifiers().size()); + for(AttributeModifier modifier : attribute.getModifiers()) { + out.writeUUID(modifier.getUUID()); + out.writeDouble(modifier.getAmount()); + out.writeByte(MagicValues.value(Integer.class, modifier.getOperation())); + } + } + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityRemoveEffectPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityRemoveEffectPacket.java index 61efb4bc5..42bcf3e6b 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityRemoveEffectPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityRemoveEffectPacket.java @@ -10,41 +10,41 @@ public class ServerEntityRemoveEffectPacket implements Packet { - private int entityId; - private Effect effect; - - @SuppressWarnings("unused") - private ServerEntityRemoveEffectPacket() { - } - - public ServerEntityRemoveEffectPacket(int entityId, Effect effect) { - this.entityId = entityId; - this.effect = effect; - } - - public int getEntityId() { - return this.entityId; - } - - public Effect getEffect() { - return this.effect; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.effect = MagicValues.key(Effect.class, in.readByte()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeByte(MagicValues.value(Integer.class, this.effect)); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private Effect effect; + + @SuppressWarnings("unused") + private ServerEntityRemoveEffectPacket() { + } + + public ServerEntityRemoveEffectPacket(int entityId, Effect effect) { + this.entityId = entityId; + this.effect = effect; + } + + public int getEntityId() { + return this.entityId; + } + + public Effect getEffect() { + return this.effect; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.effect = MagicValues.key(Effect.class, in.readByte()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeByte(MagicValues.value(Integer.class, this.effect)); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityRotationPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityRotationPacket.java index badf66310..37e471fd2 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityRotationPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityRotationPacket.java @@ -2,15 +2,15 @@ public class ServerEntityRotationPacket extends ServerEntityMovementPacket { - protected ServerEntityRotationPacket() { - this.rot = true; - } + protected ServerEntityRotationPacket() { + this.rot = true; + } - public ServerEntityRotationPacket(int entityId, float yaw, float pitch, boolean onGround) { - super(entityId, onGround); - this.rot = true; - this.yaw = yaw; - this.pitch = pitch; - } + public ServerEntityRotationPacket(int entityId, float yaw, float pitch, boolean onGround) { + super(entityId, onGround); + this.rot = true; + this.yaw = yaw; + this.pitch = pitch; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityStatusPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityStatusPacket.java index 13a40f89c..017f9d703 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityStatusPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityStatusPacket.java @@ -10,41 +10,41 @@ public class ServerEntityStatusPacket implements Packet { - protected int entityId; - protected EntityStatus status; - - @SuppressWarnings("unused") - private ServerEntityStatusPacket() { - } - - public ServerEntityStatusPacket(int entityId, EntityStatus status) { - this.entityId = entityId; - this.status = status; - } - - public int getEntityId() { - return this.entityId; - } - - public EntityStatus getStatus() { - return this.status; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readInt(); - this.status = MagicValues.key(EntityStatus.class, in.readByte()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeInt(this.entityId); - out.writeByte(MagicValues.value(Integer.class, this.status)); - } - - @Override - public boolean isPriority() { - return false; - } + protected int entityId; + protected EntityStatus status; + + @SuppressWarnings("unused") + private ServerEntityStatusPacket() { + } + + public ServerEntityStatusPacket(int entityId, EntityStatus status) { + this.entityId = entityId; + this.status = status; + } + + public int getEntityId() { + return this.entityId; + } + + public EntityStatus getStatus() { + return this.status; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readInt(); + this.status = MagicValues.key(EntityStatus.class, in.readByte()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeInt(this.entityId); + out.writeByte(MagicValues.value(Integer.class, this.status)); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityTeleportPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityTeleportPacket.java index 0cc86d7c3..597a86649 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityTeleportPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityTeleportPacket.java @@ -8,81 +8,81 @@ public class ServerEntityTeleportPacket implements Packet { - private int entityId; - private double x; - private double y; - private double z; - private float yaw; - private float pitch; - private boolean onGround; - - @SuppressWarnings("unused") - private ServerEntityTeleportPacket() { - } - - public ServerEntityTeleportPacket(int entityId, double x, double y, double z, float yaw, float pitch, boolean onGround) { - this.entityId = entityId; - this.x = x; - this.y = y; - this.z = z; - this.yaw = yaw; - this.pitch = pitch; - this.onGround = onGround; - } - - public int getEntityId() { - return this.entityId; - } - - public double getX() { - return this.x; - } - - public double getY() { - return this.y; - } - - public double getZ() { - return this.z; - } - - public float getYaw() { - return this.yaw; - } - - public float getPitch() { - return this.pitch; - } - - public boolean isOnGround() { - return this.onGround; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.x = in.readInt() / 32D; - this.y = in.readInt() / 32D; - this.z = in.readInt() / 32D; - this.yaw = in.readByte() * 360 / 256f; - this.pitch = in.readByte() * 360 / 256f; - this.onGround = in.readBoolean(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeInt((int) (this.x * 32)); - out.writeInt((int) (this.y * 32)); - out.writeInt((int) (this.z * 32)); - out.writeByte((byte) (this.yaw * 256 / 360)); - out.writeByte((byte) (this.pitch * 256 / 360)); - out.writeBoolean(this.onGround); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private double x; + private double y; + private double z; + private float yaw; + private float pitch; + private boolean onGround; + + @SuppressWarnings("unused") + private ServerEntityTeleportPacket() { + } + + public ServerEntityTeleportPacket(int entityId, double x, double y, double z, float yaw, float pitch, boolean onGround) { + this.entityId = entityId; + this.x = x; + this.y = y; + this.z = z; + this.yaw = yaw; + this.pitch = pitch; + this.onGround = onGround; + } + + public int getEntityId() { + return this.entityId; + } + + public double getX() { + return this.x; + } + + public double getY() { + return this.y; + } + + public double getZ() { + return this.z; + } + + public float getYaw() { + return this.yaw; + } + + public float getPitch() { + return this.pitch; + } + + public boolean isOnGround() { + return this.onGround; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.x = in.readInt() / 32D; + this.y = in.readInt() / 32D; + this.z = in.readInt() / 32D; + this.yaw = in.readByte() * 360 / 256f; + this.pitch = in.readByte() * 360 / 256f; + this.onGround = in.readBoolean(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeInt((int) (this.x * 32)); + out.writeInt((int) (this.y * 32)); + out.writeInt((int) (this.z * 32)); + out.writeByte((byte) (this.yaw * 256 / 360)); + out.writeByte((byte) (this.pitch * 256 / 360)); + out.writeBoolean(this.onGround); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityVelocityPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityVelocityPacket.java index 390be1b03..e5ee8ebd7 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityVelocityPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/ServerEntityVelocityPacket.java @@ -8,57 +8,57 @@ public class ServerEntityVelocityPacket implements Packet { - private int entityId; - private double motX; - private double motY; - private double motZ; + private int entityId; + private double motX; + private double motY; + private double motZ; - @SuppressWarnings("unused") - private ServerEntityVelocityPacket() { - } + @SuppressWarnings("unused") + private ServerEntityVelocityPacket() { + } - public ServerEntityVelocityPacket(int entityId, double motX, double motY, double motZ) { - this.entityId = entityId; - this.motX = motX; - this.motY = motY; - this.motZ = motZ; - } + public ServerEntityVelocityPacket(int entityId, double motX, double motY, double motZ) { + this.entityId = entityId; + this.motX = motX; + this.motY = motY; + this.motZ = motZ; + } - public int getEntityId() { - return this.entityId; - } + public int getEntityId() { + return this.entityId; + } - public double getMotionX() { - return this.motX; - } + public double getMotionX() { + return this.motX; + } - public double getMotionY() { - return this.motY; - } + public double getMotionY() { + return this.motY; + } - public double getMotionZ() { - return this.motZ; - } + public double getMotionZ() { + return this.motZ; + } - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.motX = in.readShort() / 8000D; - this.motY = in.readShort() / 8000D; - this.motZ = in.readShort() / 8000D; - } + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.motX = in.readShort() / 8000D; + this.motY = in.readShort() / 8000D; + this.motZ = in.readShort() / 8000D; + } - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeShort((int) (this.motX * 8000)); - out.writeShort((int) (this.motY * 8000)); - out.writeShort((int) (this.motZ * 8000)); - } + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeShort((int) (this.motX * 8000)); + out.writeShort((int) (this.motY * 8000)); + out.writeShort((int) (this.motZ * 8000)); + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerChangeHeldItemPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerChangeHeldItemPacket.java index 93b025d5c..e9bee304d 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerChangeHeldItemPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerChangeHeldItemPacket.java @@ -8,33 +8,33 @@ public class ServerChangeHeldItemPacket implements Packet { - private int slot; - - @SuppressWarnings("unused") - private ServerChangeHeldItemPacket() { - } - - public ServerChangeHeldItemPacket(int slot) { - this.slot = slot; - } - - public int getSlot() { - return this.slot; - } - - @Override - public void read(NetInput in) throws IOException { - this.slot = in.readByte(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(this.slot); - } - - @Override - public boolean isPriority() { - return false; - } + private int slot; + + @SuppressWarnings("unused") + private ServerChangeHeldItemPacket() { + } + + public ServerChangeHeldItemPacket(int slot) { + this.slot = slot; + } + + public int getSlot() { + return this.slot; + } + + @Override + public void read(NetInput in) throws IOException { + this.slot = in.readByte(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.slot); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerAbilitiesPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerAbilitiesPacket.java index 3ea6b93b6..ea0f64e73 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerAbilitiesPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerAbilitiesPacket.java @@ -8,88 +8,88 @@ public class ServerPlayerAbilitiesPacket implements Packet { - private boolean invincible; - private boolean canFly; - private boolean flying; - private boolean creative; - private float flySpeed; - private float walkSpeed; - - @SuppressWarnings("unused") - private ServerPlayerAbilitiesPacket() { - } - - public ServerPlayerAbilitiesPacket(boolean invincible, boolean canFly, boolean flying, boolean creative, float flySpeed, float walkSpeed) { - this.invincible = invincible; - this.canFly = canFly; - this.flying = flying; - this.creative = creative; - this.flySpeed = flySpeed; - this.walkSpeed = walkSpeed; - } - - public boolean getInvincible() { - return this.invincible; - } - - public boolean getCanFly() { - return this.canFly; - } - - public boolean getFlying() { - return this.flying; - } - - public boolean getCreative() { - return this.creative; - } - - public float getFlySpeed() { - return this.flySpeed; - } - - public float getWalkSpeed() { - return this.walkSpeed; - } - - @Override - public void read(NetInput in) throws IOException { - byte flags = in.readByte(); - this.invincible = (flags & 1) > 0; - this.canFly = (flags & 2) > 0; - this.flying = (flags & 4) > 0; - this.creative = (flags & 8) > 0; - this.flySpeed = in.readFloat(); - this.walkSpeed = in.readFloat(); - } - - @Override - public void write(NetOutput out) throws IOException { - byte flags = 0; - if(this.invincible) { - flags = (byte) (flags | 1); - } - - if(this.canFly) { - flags = (byte) (flags | 2); - } - - if(this.flying) { - flags = (byte) (flags | 4); - } - - if(this.creative) { - flags = (byte) (flags | 8); - } - - out.writeByte(flags); - out.writeFloat(this.flySpeed); - out.writeFloat(this.walkSpeed); - } - - @Override - public boolean isPriority() { - return false; - } + private boolean invincible; + private boolean canFly; + private boolean flying; + private boolean creative; + private float flySpeed; + private float walkSpeed; + + @SuppressWarnings("unused") + private ServerPlayerAbilitiesPacket() { + } + + public ServerPlayerAbilitiesPacket(boolean invincible, boolean canFly, boolean flying, boolean creative, float flySpeed, float walkSpeed) { + this.invincible = invincible; + this.canFly = canFly; + this.flying = flying; + this.creative = creative; + this.flySpeed = flySpeed; + this.walkSpeed = walkSpeed; + } + + public boolean getInvincible() { + return this.invincible; + } + + public boolean getCanFly() { + return this.canFly; + } + + public boolean getFlying() { + return this.flying; + } + + public boolean getCreative() { + return this.creative; + } + + public float getFlySpeed() { + return this.flySpeed; + } + + public float getWalkSpeed() { + return this.walkSpeed; + } + + @Override + public void read(NetInput in) throws IOException { + byte flags = in.readByte(); + this.invincible = (flags & 1) > 0; + this.canFly = (flags & 2) > 0; + this.flying = (flags & 4) > 0; + this.creative = (flags & 8) > 0; + this.flySpeed = in.readFloat(); + this.walkSpeed = in.readFloat(); + } + + @Override + public void write(NetOutput out) throws IOException { + byte flags = 0; + if(this.invincible) { + flags = (byte) (flags | 1); + } + + if(this.canFly) { + flags = (byte) (flags | 2); + } + + if(this.flying) { + flags = (byte) (flags | 4); + } + + if(this.creative) { + flags = (byte) (flags | 8); + } + + out.writeByte(flags); + out.writeFloat(this.flySpeed); + out.writeFloat(this.walkSpeed); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerPositionRotationPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerPositionRotationPacket.java index 080311f2f..788f70b0e 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerPositionRotationPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerPositionRotationPacket.java @@ -13,89 +13,89 @@ public class ServerPlayerPositionRotationPacket implements Packet { - private double x; - private double y; - private double z; - private float yaw; - private float pitch; - private List relative; - - @SuppressWarnings("unused") - private ServerPlayerPositionRotationPacket() { - } - - public ServerPlayerPositionRotationPacket(double x, double y, double z, float yaw, float pitch) { - this(x, y, z, yaw, pitch, new PositionElement[0]); - } - - public ServerPlayerPositionRotationPacket(double x, double y, double z, float yaw, float pitch, PositionElement... relative) { - this.x = x; - this.y = y; - this.z = z; - this.yaw = yaw; - this.pitch = pitch; - this.relative = Arrays.asList(relative); - } - - public double getX() { - return this.x; - } - - public double getY() { - return this.y; - } - - public double getZ() { - return this.z; - } - - public float getYaw() { - return this.yaw; - } - - public float getPitch() { - return this.pitch; - } - - public List getRelativeElements() { - return this.relative; - } - - @Override - public void read(NetInput in) throws IOException { - this.x = in.readDouble(); - this.y = in.readDouble(); - this.z = in.readDouble(); - this.yaw = in.readFloat(); - this.pitch = in.readFloat(); - this.relative = new ArrayList(); - int flags = in.readUnsignedByte(); - for(PositionElement element : PositionElement.values()) { - int bit = 1 << MagicValues.value(Integer.class, element); - if((flags & bit) == bit) { - this.relative.add(element); - } - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeDouble(this.x); - out.writeDouble(this.y); - out.writeDouble(this.z); - out.writeFloat(this.yaw); - out.writeFloat(this.pitch); - int flags = 0; - for(PositionElement element : this.relative) { - flags |= 1 << MagicValues.value(Integer.class, element); - } - - out.writeByte(flags); - } - - @Override - public boolean isPriority() { - return false; - } + private double x; + private double y; + private double z; + private float yaw; + private float pitch; + private List relative; + + @SuppressWarnings("unused") + private ServerPlayerPositionRotationPacket() { + } + + public ServerPlayerPositionRotationPacket(double x, double y, double z, float yaw, float pitch) { + this(x, y, z, yaw, pitch, new PositionElement[0]); + } + + public ServerPlayerPositionRotationPacket(double x, double y, double z, float yaw, float pitch, PositionElement... relative) { + this.x = x; + this.y = y; + this.z = z; + this.yaw = yaw; + this.pitch = pitch; + this.relative = Arrays.asList(relative); + } + + public double getX() { + return this.x; + } + + public double getY() { + return this.y; + } + + public double getZ() { + return this.z; + } + + public float getYaw() { + return this.yaw; + } + + public float getPitch() { + return this.pitch; + } + + public List getRelativeElements() { + return this.relative; + } + + @Override + public void read(NetInput in) throws IOException { + this.x = in.readDouble(); + this.y = in.readDouble(); + this.z = in.readDouble(); + this.yaw = in.readFloat(); + this.pitch = in.readFloat(); + this.relative = new ArrayList(); + int flags = in.readUnsignedByte(); + for(PositionElement element : PositionElement.values()) { + int bit = 1 << MagicValues.value(Integer.class, element); + if((flags & bit) == bit) { + this.relative.add(element); + } + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeDouble(this.x); + out.writeDouble(this.y); + out.writeDouble(this.z); + out.writeFloat(this.yaw); + out.writeFloat(this.pitch); + int flags = 0; + for(PositionElement element : this.relative) { + flags |= 1 << MagicValues.value(Integer.class, element); + } + + out.writeByte(flags); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerUseBedPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerUseBedPacket.java index 783a5ea1e..e95889915 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerUseBedPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerPlayerUseBedPacket.java @@ -10,41 +10,41 @@ public class ServerPlayerUseBedPacket implements Packet { - private int entityId; - private Position position; - - @SuppressWarnings("unused") - private ServerPlayerUseBedPacket() { - } - - public ServerPlayerUseBedPacket(int entityId, Position position) { - this.entityId = entityId; - this.position = position; - } - - public int getEntityId() { - return this.entityId; - } - - public Position getPosition() { - return this.position; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.position = NetUtil.readPosition(in); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - NetUtil.writePosition(out, this.position); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private Position position; + + @SuppressWarnings("unused") + private ServerPlayerUseBedPacket() { + } + + public ServerPlayerUseBedPacket(int entityId, Position position) { + this.entityId = entityId; + this.position = position; + } + + public int getEntityId() { + return this.entityId; + } + + public Position getPosition() { + return this.position; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.position = NetUtil.readPosition(in); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + NetUtil.writePosition(out, this.position); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerSetExperiencePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerSetExperiencePacket.java index 1acb0dafd..7995c5721 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerSetExperiencePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerSetExperiencePacket.java @@ -8,49 +8,49 @@ public class ServerSetExperiencePacket implements Packet { - private float experience; - private int level; - private int totalExperience; - - @SuppressWarnings("unused") - private ServerSetExperiencePacket() { - } - - public ServerSetExperiencePacket(float experience, int level, int totalExperience) { - this.experience = experience; - this.level = level; - this.totalExperience = totalExperience; - } - - public float getSlot() { - return this.experience; - } - - public int getLevel() { - return this.level; - } - - public int getTotalExperience() { - return this.totalExperience; - } - - @Override - public void read(NetInput in) throws IOException { - this.experience = in.readFloat(); - this.level = in.readVarInt(); - this.totalExperience = in.readVarInt(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeFloat(this.experience); - out.writeVarInt(this.level); - out.writeVarInt(this.totalExperience); - } - - @Override - public boolean isPriority() { - return false; - } + private float experience; + private int level; + private int totalExperience; + + @SuppressWarnings("unused") + private ServerSetExperiencePacket() { + } + + public ServerSetExperiencePacket(float experience, int level, int totalExperience) { + this.experience = experience; + this.level = level; + this.totalExperience = totalExperience; + } + + public float getSlot() { + return this.experience; + } + + public int getLevel() { + return this.level; + } + + public int getTotalExperience() { + return this.totalExperience; + } + + @Override + public void read(NetInput in) throws IOException { + this.experience = in.readFloat(); + this.level = in.readVarInt(); + this.totalExperience = in.readVarInt(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeFloat(this.experience); + out.writeVarInt(this.level); + out.writeVarInt(this.totalExperience); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerUpdateHealthPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerUpdateHealthPacket.java index 349f7ef65..d1a25ed78 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerUpdateHealthPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/player/ServerUpdateHealthPacket.java @@ -8,49 +8,49 @@ public class ServerUpdateHealthPacket implements Packet { - private float health; - private int food; - private float saturation; - - @SuppressWarnings("unused") - private ServerUpdateHealthPacket() { - } - - public ServerUpdateHealthPacket(float health, int food, float saturation) { - this.health = health; - this.food = food; - this.saturation = saturation; - } - - public float getHealth() { - return this.health; - } - - public int getFood() { - return this.food; - } - - public float getSaturation() { - return this.saturation; - } - - @Override - public void read(NetInput in) throws IOException { - this.health = in.readFloat(); - this.food = in.readVarInt(); - this.saturation = in.readFloat(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeFloat(this.health); - out.writeVarInt(this.food); - out.writeFloat(this.saturation); - } - - @Override - public boolean isPriority() { - return false; - } + private float health; + private int food; + private float saturation; + + @SuppressWarnings("unused") + private ServerUpdateHealthPacket() { + } + + public ServerUpdateHealthPacket(float health, int food, float saturation) { + this.health = health; + this.food = food; + this.saturation = saturation; + } + + public float getHealth() { + return this.health; + } + + public int getFood() { + return this.food; + } + + public float getSaturation() { + return this.saturation; + } + + @Override + public void read(NetInput in) throws IOException { + this.health = in.readFloat(); + this.food = in.readVarInt(); + this.saturation = in.readFloat(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeFloat(this.health); + out.writeVarInt(this.food); + out.writeFloat(this.saturation); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnExpOrbPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnExpOrbPacket.java index 728fbcd56..66e73d97e 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnExpOrbPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnExpOrbPacket.java @@ -8,65 +8,65 @@ public class ServerSpawnExpOrbPacket implements Packet { - private int entityId; - private double x; - private double y; - private double z; - private int exp; + private int entityId; + private double x; + private double y; + private double z; + private int exp; - @SuppressWarnings("unused") - private ServerSpawnExpOrbPacket() { - } + @SuppressWarnings("unused") + private ServerSpawnExpOrbPacket() { + } - public ServerSpawnExpOrbPacket(int entityId, double x, double y, double z, int exp) { - this.entityId = entityId; - this.x = x; - this.y = y; - this.z = z; - this.exp = exp; - } + public ServerSpawnExpOrbPacket(int entityId, double x, double y, double z, int exp) { + this.entityId = entityId; + this.x = x; + this.y = y; + this.z = z; + this.exp = exp; + } - public int getEntityId() { - return this.entityId; - } + public int getEntityId() { + return this.entityId; + } - public double getX() { - return this.x; - } + public double getX() { + return this.x; + } - public double getY() { - return this.y; - } + public double getY() { + return this.y; + } - public double getZ() { - return this.z; - } + public double getZ() { + return this.z; + } - public int getExp() { - return this.exp; - } + public int getExp() { + return this.exp; + } - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.x = in.readInt() / 32D; - this.y = in.readInt() / 32D; - this.z = in.readInt() / 32D; - this.exp = in.readShort(); - } + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.x = in.readInt() / 32D; + this.y = in.readInt() / 32D; + this.z = in.readInt() / 32D; + this.exp = in.readShort(); + } - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeInt((int) (this.x * 32)); - out.writeInt((int) (this.y * 32)); - out.writeInt((int) (this.z * 32)); - out.writeShort(this.exp); - } + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeInt((int) (this.x * 32)); + out.writeInt((int) (this.y * 32)); + out.writeInt((int) (this.z * 32)); + out.writeShort(this.exp); + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnGlobalEntityPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnGlobalEntityPacket.java index 4ac9c80c4..a6b946c29 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnGlobalEntityPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnGlobalEntityPacket.java @@ -10,65 +10,65 @@ public class ServerSpawnGlobalEntityPacket implements Packet { - private int entityId; - private GlobalEntityType type; - private int x; - private int y; - private int z; + private int entityId; + private GlobalEntityType type; + private int x; + private int y; + private int z; - @SuppressWarnings("unused") - private ServerSpawnGlobalEntityPacket() { - } + @SuppressWarnings("unused") + private ServerSpawnGlobalEntityPacket() { + } - public ServerSpawnGlobalEntityPacket(int entityId, GlobalEntityType type, int x, int y, int z) { - this.entityId = entityId; - this.type = type; - this.x = x; - this.y = y; - this.z = z; - } + public ServerSpawnGlobalEntityPacket(int entityId, GlobalEntityType type, int x, int y, int z) { + this.entityId = entityId; + this.type = type; + this.x = x; + this.y = y; + this.z = z; + } - public int getEntityId() { - return this.entityId; - } + public int getEntityId() { + return this.entityId; + } - public GlobalEntityType getType() { - return this.type; - } + public GlobalEntityType getType() { + return this.type; + } - public int getX() { - return this.x; - } + public int getX() { + return this.x; + } - public int getY() { - return this.y; - } + public int getY() { + return this.y; + } - public int getZ() { - return this.z; - } + public int getZ() { + return this.z; + } - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.type = MagicValues.key(GlobalEntityType.class, in.readByte()); - this.x = in.readInt(); - this.y = in.readInt(); - this.z = in.readInt(); - } + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.type = MagicValues.key(GlobalEntityType.class, in.readByte()); + this.x = in.readInt(); + this.y = in.readInt(); + this.z = in.readInt(); + } - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeByte(MagicValues.value(Integer.class, this.type)); - out.writeInt(this.x); - out.writeInt(this.y); - out.writeInt(this.z); - } + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeByte(MagicValues.value(Integer.class, this.type)); + out.writeInt(this.x); + out.writeInt(this.y); + out.writeInt(this.z); + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnMobPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnMobPacket.java index 59f5c053f..8ca80f2ea 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnMobPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnMobPacket.java @@ -12,121 +12,121 @@ public class ServerSpawnMobPacket implements Packet { - private int entityId; - private MobType type; - private double x; - private double y; - private double z; - private float pitch; - private float yaw; - private float headYaw; - private double motX; - private double motY; - private double motZ; - private EntityMetadata metadata[]; - - @SuppressWarnings("unused") - private ServerSpawnMobPacket() { - } - - public ServerSpawnMobPacket(int entityId, MobType type, double x, double y, double z, float yaw, float pitch, float headYaw, double motX, double motY, double motZ, EntityMetadata metadata[]) { - this.entityId = entityId; - this.type = type; - this.x = x; - this.y = y; - this.z = z; - this.yaw = yaw; - this.pitch = pitch; - this.headYaw = headYaw; - this.motX = motX; - this.motY = motY; - this.motZ = motZ; - this.metadata = metadata; - } - - public int getEntityId() { - return this.entityId; - } - - public MobType getType() { - return this.type; - } - - public double getX() { - return this.x; - } - - public double getY() { - return this.y; - } - - public double getZ() { - return this.z; - } - - public float getYaw() { - return this.yaw; - } - - public float getPitch() { - return this.pitch; - } - - public float getHeadYaw() { - return this.headYaw; - } - - public double getMotionX() { - return this.motX; - } - - public double getMotionY() { - return this.motY; - } - - public double getMotionZ() { - return this.motZ; - } - - public EntityMetadata[] getMetadata() { - return this.metadata; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.type = MagicValues.key(MobType.class, in.readByte()); - this.x = in.readInt() / 32D; - this.y = in.readInt() / 32D; - this.z = in.readInt() / 32D; - this.yaw = in.readByte() * 360 / 256f; - this.pitch = in.readByte() * 360 / 256f; - this.headYaw = in.readByte() * 360 / 256f; - this.motX = in.readShort() / 8000D; - this.motY = in.readShort() / 8000D; - this.motZ = in.readShort() / 8000D; - this.metadata = NetUtil.readEntityMetadata(in); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeByte(MagicValues.value(Integer.class, this.type)); - out.writeInt((int) (this.x * 32)); - out.writeInt((int) (this.y * 32)); - out.writeInt((int) (this.z * 32)); - out.writeByte((byte) (this.yaw * 256 / 360)); - out.writeByte((byte) (this.pitch * 256 / 360)); - out.writeByte((byte) (this.headYaw * 256 / 360)); - out.writeShort((int) (this.motX * 8000)); - out.writeShort((int) (this.motY * 8000)); - out.writeShort((int) (this.motZ * 8000)); - NetUtil.writeEntityMetadata(out, this.metadata); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private MobType type; + private double x; + private double y; + private double z; + private float pitch; + private float yaw; + private float headYaw; + private double motX; + private double motY; + private double motZ; + private EntityMetadata metadata[]; + + @SuppressWarnings("unused") + private ServerSpawnMobPacket() { + } + + public ServerSpawnMobPacket(int entityId, MobType type, double x, double y, double z, float yaw, float pitch, float headYaw, double motX, double motY, double motZ, EntityMetadata metadata[]) { + this.entityId = entityId; + this.type = type; + this.x = x; + this.y = y; + this.z = z; + this.yaw = yaw; + this.pitch = pitch; + this.headYaw = headYaw; + this.motX = motX; + this.motY = motY; + this.motZ = motZ; + this.metadata = metadata; + } + + public int getEntityId() { + return this.entityId; + } + + public MobType getType() { + return this.type; + } + + public double getX() { + return this.x; + } + + public double getY() { + return this.y; + } + + public double getZ() { + return this.z; + } + + public float getYaw() { + return this.yaw; + } + + public float getPitch() { + return this.pitch; + } + + public float getHeadYaw() { + return this.headYaw; + } + + public double getMotionX() { + return this.motX; + } + + public double getMotionY() { + return this.motY; + } + + public double getMotionZ() { + return this.motZ; + } + + public EntityMetadata[] getMetadata() { + return this.metadata; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.type = MagicValues.key(MobType.class, in.readByte()); + this.x = in.readInt() / 32D; + this.y = in.readInt() / 32D; + this.z = in.readInt() / 32D; + this.yaw = in.readByte() * 360 / 256f; + this.pitch = in.readByte() * 360 / 256f; + this.headYaw = in.readByte() * 360 / 256f; + this.motX = in.readShort() / 8000D; + this.motY = in.readShort() / 8000D; + this.motZ = in.readShort() / 8000D; + this.metadata = NetUtil.readEntityMetadata(in); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeByte(MagicValues.value(Integer.class, this.type)); + out.writeInt((int) (this.x * 32)); + out.writeInt((int) (this.y * 32)); + out.writeInt((int) (this.z * 32)); + out.writeByte((byte) (this.yaw * 256 / 360)); + out.writeByte((byte) (this.pitch * 256 / 360)); + out.writeByte((byte) (this.headYaw * 256 / 360)); + out.writeShort((int) (this.motX * 8000)); + out.writeShort((int) (this.motY * 8000)); + out.writeShort((int) (this.motZ * 8000)); + NetUtil.writeEntityMetadata(out, this.metadata); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnObjectPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnObjectPacket.java index 5a4cf0e0d..75ab443dc 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnObjectPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnObjectPacket.java @@ -1,7 +1,13 @@ package org.spacehq.mc.protocol.packet.ingame.server.entity.spawn; import org.spacehq.mc.protocol.data.game.values.MagicValues; -import org.spacehq.mc.protocol.data.game.values.entity.*; +import org.spacehq.mc.protocol.data.game.values.entity.FallingBlockData; +import org.spacehq.mc.protocol.data.game.values.entity.HangingDirection; +import org.spacehq.mc.protocol.data.game.values.entity.MinecartType; +import org.spacehq.mc.protocol.data.game.values.entity.ObjectData; +import org.spacehq.mc.protocol.data.game.values.entity.ObjectType; +import org.spacehq.mc.protocol.data.game.values.entity.ProjectileData; +import org.spacehq.mc.protocol.data.game.values.entity.SplashPotionData; import org.spacehq.packetlib.io.NetInput; import org.spacehq.packetlib.io.NetOutput; import org.spacehq.packetlib.packet.Packet; @@ -10,162 +16,162 @@ public class ServerSpawnObjectPacket implements Packet { - private int entityId; - private ObjectType type; - private double x; - private double y; - private double z; - private float pitch; - private float yaw; - private ObjectData data; - private double motX; - private double motY; - private double motZ; - - @SuppressWarnings("unused") - private ServerSpawnObjectPacket() { - } - - public ServerSpawnObjectPacket(int entityId, ObjectType type, double x, double y, double z, float yaw, float pitch) { - this(entityId, type, null, x, y, z, yaw, pitch, 0, 0, 0); - } - - public ServerSpawnObjectPacket(int entityId, ObjectType type, ObjectData data, double x, double y, double z, float yaw, float pitch) { - this(entityId, type, data, x, y, z, yaw, pitch, 0, 0, 0); - } - - public ServerSpawnObjectPacket(int entityId, ObjectType type, double x, double y, double z, float yaw, float pitch, double motX, double motY, double motZ) { - this(entityId, type, new ObjectData() { - }, x, y, z, yaw, pitch, motX, motY, motZ); - } - - public ServerSpawnObjectPacket(int entityId, ObjectType type, ObjectData data, double x, double y, double z, float yaw, float pitch, double motX, double motY, double motZ) { - this.entityId = entityId; - this.type = type; - this.data = data; - this.x = x; - this.y = y; - this.z = z; - this.yaw = yaw; - this.pitch = pitch; - this.motX = motX; - this.motY = motY; - this.motZ = motZ; - } - - public int getEntityId() { - return this.entityId; - } - - public ObjectType getType() { - return this.type; - } - - public ObjectData getData() { - return this.data; - } - - public double getX() { - return this.x; - } - - public double getY() { - return this.y; - } - - public double getZ() { - return this.z; - } - - public float getYaw() { - return this.yaw; - } - - public float getPitch() { - return this.pitch; - } - - public double getMotionX() { - return this.motX; - } - - public double getMotionY() { - return this.motY; - } - - public double getMotionZ() { - return this.motZ; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.type = MagicValues.key(ObjectType.class, in.readByte()); - this.x = in.readInt() / 32D; - this.y = in.readInt() / 32D; - this.z = in.readInt() / 32D; - this.pitch = in.readByte() * 360 / 256f; - this.yaw = in.readByte() * 360 / 256f; - int data = in.readInt(); - if(data > 0) { - if(this.type == ObjectType.MINECART) { - this.data = MagicValues.key(MinecartType.class, data); - } else if(this.type == ObjectType.ITEM_FRAME) { - this.data = MagicValues.key(HangingDirection.class, data); - } else if(this.type == ObjectType.FALLING_BLOCK) { - this.data = new FallingBlockData(data & 65535, data >> 16); - } else if(this.type == ObjectType.POTION) { - this.data = new SplashPotionData(data); - } else if(this.type == ObjectType.ARROW || this.type == ObjectType.BLAZE_FIREBALL || this.type == ObjectType.FISH_HOOK || this.type == ObjectType.GHAST_FIREBALL || this.type == ObjectType.WITHER_HEAD_PROJECTILE) { - this.data = new ProjectileData(data); - } else { - this.data = new ObjectData() { - }; - } - - this.motX = in.readShort() / 8000D; - this.motY = in.readShort() / 8000D; - this.motZ = in.readShort() / 8000D; - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeByte(MagicValues.value(Integer.class, this.type)); - out.writeInt((int) (this.x * 32)); - out.writeInt((int) (this.y * 32)); - out.writeInt((int) (this.z * 32)); - out.writeByte((byte) (this.pitch * 256 / 360)); - out.writeByte((byte) (this.yaw * 256 / 360)); - int data = 0; - if(this.data != null) { - if(this.data instanceof MinecartType) { - data = MagicValues.value(Integer.class, (Enum) this.data); - } else if(this.data instanceof HangingDirection) { - data = MagicValues.value(Integer.class, (Enum) this.data); - } else if(this.data instanceof FallingBlockData) { - data = ((FallingBlockData) this.data).getId() | ((FallingBlockData) this.data).getMetadata() << 16; - } else if(this.data instanceof SplashPotionData) { - data = ((SplashPotionData) this.data).getPotionData(); - } else if(this.data instanceof ProjectileData) { - data = ((ProjectileData) this.data).getOwnerId(); - } else { - data = 1; - } - } - - out.writeInt(data); - if(data > 0) { - out.writeShort((int) (this.motX * 8000)); - out.writeShort((int) (this.motY * 8000)); - out.writeShort((int) (this.motZ * 8000)); - } - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private ObjectType type; + private double x; + private double y; + private double z; + private float pitch; + private float yaw; + private ObjectData data; + private double motX; + private double motY; + private double motZ; + + @SuppressWarnings("unused") + private ServerSpawnObjectPacket() { + } + + public ServerSpawnObjectPacket(int entityId, ObjectType type, double x, double y, double z, float yaw, float pitch) { + this(entityId, type, null, x, y, z, yaw, pitch, 0, 0, 0); + } + + public ServerSpawnObjectPacket(int entityId, ObjectType type, ObjectData data, double x, double y, double z, float yaw, float pitch) { + this(entityId, type, data, x, y, z, yaw, pitch, 0, 0, 0); + } + + public ServerSpawnObjectPacket(int entityId, ObjectType type, double x, double y, double z, float yaw, float pitch, double motX, double motY, double motZ) { + this(entityId, type, new ObjectData() { + }, x, y, z, yaw, pitch, motX, motY, motZ); + } + + public ServerSpawnObjectPacket(int entityId, ObjectType type, ObjectData data, double x, double y, double z, float yaw, float pitch, double motX, double motY, double motZ) { + this.entityId = entityId; + this.type = type; + this.data = data; + this.x = x; + this.y = y; + this.z = z; + this.yaw = yaw; + this.pitch = pitch; + this.motX = motX; + this.motY = motY; + this.motZ = motZ; + } + + public int getEntityId() { + return this.entityId; + } + + public ObjectType getType() { + return this.type; + } + + public ObjectData getData() { + return this.data; + } + + public double getX() { + return this.x; + } + + public double getY() { + return this.y; + } + + public double getZ() { + return this.z; + } + + public float getYaw() { + return this.yaw; + } + + public float getPitch() { + return this.pitch; + } + + public double getMotionX() { + return this.motX; + } + + public double getMotionY() { + return this.motY; + } + + public double getMotionZ() { + return this.motZ; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.type = MagicValues.key(ObjectType.class, in.readByte()); + this.x = in.readInt() / 32D; + this.y = in.readInt() / 32D; + this.z = in.readInt() / 32D; + this.pitch = in.readByte() * 360 / 256f; + this.yaw = in.readByte() * 360 / 256f; + int data = in.readInt(); + if(data > 0) { + if(this.type == ObjectType.MINECART) { + this.data = MagicValues.key(MinecartType.class, data); + } else if(this.type == ObjectType.ITEM_FRAME) { + this.data = MagicValues.key(HangingDirection.class, data); + } else if(this.type == ObjectType.FALLING_BLOCK) { + this.data = new FallingBlockData(data & 65535, data >> 16); + } else if(this.type == ObjectType.POTION) { + this.data = new SplashPotionData(data); + } else if(this.type == ObjectType.ARROW || this.type == ObjectType.BLAZE_FIREBALL || this.type == ObjectType.FISH_HOOK || this.type == ObjectType.GHAST_FIREBALL || this.type == ObjectType.WITHER_HEAD_PROJECTILE) { + this.data = new ProjectileData(data); + } else { + this.data = new ObjectData() { + }; + } + + this.motX = in.readShort() / 8000D; + this.motY = in.readShort() / 8000D; + this.motZ = in.readShort() / 8000D; + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeByte(MagicValues.value(Integer.class, this.type)); + out.writeInt((int) (this.x * 32)); + out.writeInt((int) (this.y * 32)); + out.writeInt((int) (this.z * 32)); + out.writeByte((byte) (this.pitch * 256 / 360)); + out.writeByte((byte) (this.yaw * 256 / 360)); + int data = 0; + if(this.data != null) { + if(this.data instanceof MinecartType) { + data = MagicValues.value(Integer.class, (Enum) this.data); + } else if(this.data instanceof HangingDirection) { + data = MagicValues.value(Integer.class, (Enum) this.data); + } else if(this.data instanceof FallingBlockData) { + data = ((FallingBlockData) this.data).getId() | ((FallingBlockData) this.data).getMetadata() << 16; + } else if(this.data instanceof SplashPotionData) { + data = ((SplashPotionData) this.data).getPotionData(); + } else if(this.data instanceof ProjectileData) { + data = ((ProjectileData) this.data).getOwnerId(); + } else { + data = 1; + } + } + + out.writeInt(data); + if(data > 0) { + out.writeShort((int) (this.motX * 8000)); + out.writeShort((int) (this.motY * 8000)); + out.writeShort((int) (this.motZ * 8000)); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPaintingPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPaintingPacket.java index 4fac494eb..eb3ca721d 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPaintingPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPaintingPacket.java @@ -13,57 +13,57 @@ public class ServerSpawnPaintingPacket implements Packet { - private int entityId; - private Art art; - private Position position; - private HangingDirection direction; + private int entityId; + private Art art; + private Position position; + private HangingDirection direction; - @SuppressWarnings("unused") - private ServerSpawnPaintingPacket() { - } + @SuppressWarnings("unused") + private ServerSpawnPaintingPacket() { + } - public ServerSpawnPaintingPacket(int entityId, Art art, Position position, HangingDirection direction) { - this.entityId = entityId; - this.art = art; - this.position = position; - this.direction = direction; - } + public ServerSpawnPaintingPacket(int entityId, Art art, Position position, HangingDirection direction) { + this.entityId = entityId; + this.art = art; + this.position = position; + this.direction = direction; + } - public int getEntityId() { - return this.entityId; - } + public int getEntityId() { + return this.entityId; + } - public Art getArt() { - return this.art; - } + public Art getArt() { + return this.art; + } - public Position getPosition() { - return this.position; - } + public Position getPosition() { + return this.position; + } - public HangingDirection getDirection() { - return this.direction; - } + public HangingDirection getDirection() { + return this.direction; + } - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.art = MagicValues.key(Art.class, in.readString()); - this.position = NetUtil.readPosition(in); - this.direction = MagicValues.key(HangingDirection.class, in.readUnsignedByte()); - } + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.art = MagicValues.key(Art.class, in.readString()); + this.position = NetUtil.readPosition(in); + this.direction = MagicValues.key(HangingDirection.class, in.readUnsignedByte()); + } - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeString(MagicValues.value(String.class, this.art)); - NetUtil.writePosition(out, this.position); - out.writeByte(MagicValues.value(Integer.class, this.direction)); - } + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeString(MagicValues.value(String.class, this.art)); + NetUtil.writePosition(out, this.position); + out.writeByte(MagicValues.value(Integer.class, this.direction)); + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPlayerPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPlayerPacket.java index 177b23b42..cfda9a489 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPlayerPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPlayerPacket.java @@ -11,97 +11,97 @@ public class ServerSpawnPlayerPacket implements Packet { - private int entityId; - private UUID uuid; - private double x; - private double y; - private double z; - private float yaw; - private float pitch; - private int currentItem; - private EntityMetadata metadata[]; - - @SuppressWarnings("unused") - private ServerSpawnPlayerPacket() { - } - - public ServerSpawnPlayerPacket(int entityId, UUID uuid, double x, double y, double z, float yaw, float pitch, int currentItem, EntityMetadata metadata[]) { - this.entityId = entityId; - this.uuid = uuid; - this.x = x; - this.y = y; - this.z = z; - this.yaw = yaw; - this.pitch = pitch; - this.currentItem = currentItem; - this.metadata = metadata; - } - - public int getEntityId() { - return this.entityId; - } - - public UUID getUUID() { - return this.uuid; - } - - public double getX() { - return this.x; - } - - public double getY() { - return this.y; - } - - public double getZ() { - return this.z; - } - - public float getYaw() { - return this.yaw; - } - - public float getPitch() { - return this.pitch; - } - - public int getCurrentItem() { - return this.currentItem; - } - - public EntityMetadata[] getMetadata() { - return this.metadata; - } - - @Override - public void read(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.uuid = in.readUUID(); - this.x = in.readInt() / 32D; - this.y = in.readInt() / 32D; - this.z = in.readInt() / 32D; - this.yaw = in.readByte() * 360 / 256f; - this.pitch = in.readByte() * 360 / 256f; - this.currentItem = in.readShort(); - this.metadata = NetUtil.readEntityMetadata(in); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeUUID(this.uuid); - out.writeInt((int) (this.x * 32)); - out.writeInt((int) (this.y * 32)); - out.writeInt((int) (this.z * 32)); - out.writeByte((byte) (this.yaw * 256 / 360)); - out.writeByte((byte) (this.pitch * 256 / 360)); - out.writeShort(this.currentItem); - NetUtil.writeEntityMetadata(out, this.metadata); - } - - @Override - public boolean isPriority() { - return false; - } + private int entityId; + private UUID uuid; + private double x; + private double y; + private double z; + private float yaw; + private float pitch; + private int currentItem; + private EntityMetadata metadata[]; + + @SuppressWarnings("unused") + private ServerSpawnPlayerPacket() { + } + + public ServerSpawnPlayerPacket(int entityId, UUID uuid, double x, double y, double z, float yaw, float pitch, int currentItem, EntityMetadata metadata[]) { + this.entityId = entityId; + this.uuid = uuid; + this.x = x; + this.y = y; + this.z = z; + this.yaw = yaw; + this.pitch = pitch; + this.currentItem = currentItem; + this.metadata = metadata; + } + + public int getEntityId() { + return this.entityId; + } + + public UUID getUUID() { + return this.uuid; + } + + public double getX() { + return this.x; + } + + public double getY() { + return this.y; + } + + public double getZ() { + return this.z; + } + + public float getYaw() { + return this.yaw; + } + + public float getPitch() { + return this.pitch; + } + + public int getCurrentItem() { + return this.currentItem; + } + + public EntityMetadata[] getMetadata() { + return this.metadata; + } + + @Override + public void read(NetInput in) throws IOException { + this.entityId = in.readVarInt(); + this.uuid = in.readUUID(); + this.x = in.readInt() / 32D; + this.y = in.readInt() / 32D; + this.z = in.readInt() / 32D; + this.yaw = in.readByte() * 360 / 256f; + this.pitch = in.readByte() * 360 / 256f; + this.currentItem = in.readShort(); + this.metadata = NetUtil.readEntityMetadata(in); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.entityId); + out.writeUUID(this.uuid); + out.writeInt((int) (this.x * 32)); + out.writeInt((int) (this.y * 32)); + out.writeInt((int) (this.z * 32)); + out.writeByte((byte) (this.yaw * 256 / 360)); + out.writeByte((byte) (this.pitch * 256 / 360)); + out.writeShort(this.currentItem); + NetUtil.writeEntityMetadata(out, this.metadata); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerDisplayScoreboardPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerDisplayScoreboardPacket.java index 8d8cedd48..7ed4fad71 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerDisplayScoreboardPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerDisplayScoreboardPacket.java @@ -10,41 +10,41 @@ public class ServerDisplayScoreboardPacket implements Packet { - private ScoreboardPosition position; - private String name; - - @SuppressWarnings("unused") - private ServerDisplayScoreboardPacket() { - } - - public ServerDisplayScoreboardPacket(ScoreboardPosition position, String name) { - this.position = position; - this.name = name; - } - - public ScoreboardPosition getPosition() { - return this.position; - } - - public String getScoreboardName() { - return this.name; - } - - @Override - public void read(NetInput in) throws IOException { - this.position = MagicValues.key(ScoreboardPosition.class, in.readByte()); - this.name = in.readString(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(MagicValues.value(Integer.class, this.position)); - out.writeString(this.name); - } - - @Override - public boolean isPriority() { - return false; - } + private ScoreboardPosition position; + private String name; + + @SuppressWarnings("unused") + private ServerDisplayScoreboardPacket() { + } + + public ServerDisplayScoreboardPacket(ScoreboardPosition position, String name) { + this.position = position; + this.name = name; + } + + public ScoreboardPosition getPosition() { + return this.position; + } + + public String getScoreboardName() { + return this.name; + } + + @Override + public void read(NetInput in) throws IOException { + this.position = MagicValues.key(ScoreboardPosition.class, in.readByte()); + this.name = in.readString(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(MagicValues.value(Integer.class, this.position)); + out.writeString(this.name); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerScoreboardObjectivePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerScoreboardObjectivePacket.java index aa1f60e9b..f48020df2 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerScoreboardObjectivePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerScoreboardObjectivePacket.java @@ -11,70 +11,70 @@ public class ServerScoreboardObjectivePacket implements Packet { - private String name; - private ObjectiveAction action; - private String displayName; - private ScoreType type; - - @SuppressWarnings("unused") - private ServerScoreboardObjectivePacket() { - } - - public ServerScoreboardObjectivePacket(String name) { - this.name = name; - this.action = ObjectiveAction.REMOVE; - } - - public ServerScoreboardObjectivePacket(String name, ObjectiveAction action, String displayName, ScoreType type) { - if(action != ObjectiveAction.ADD && action != ObjectiveAction.UPDATE) { - throw new IllegalArgumentException("(name, action, displayName) constructor only valid for adding and updating objectives."); - } - - this.name = name; - this.action = action; - this.displayName = displayName; - this.type = type; - } - - public String getName() { - return this.name; - } - - public ObjectiveAction getAction() { - return this.action; - } - - public String getDisplayName() { - return this.displayName; - } - - public ScoreType getType() { - return this.type; - } - - @Override - public void read(NetInput in) throws IOException { - this.name = in.readString(); - this.action = MagicValues.key(ObjectiveAction.class, in.readByte()); - if(this.action == ObjectiveAction.ADD || this.action == ObjectiveAction.UPDATE) { - this.displayName = in.readString(); - this.type = MagicValues.key(ScoreType.class, in.readString()); - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.name); - out.writeByte(MagicValues.value(Integer.class, this.action)); - if(this.action == ObjectiveAction.ADD || this.action == ObjectiveAction.UPDATE) { - out.writeString(this.displayName); - out.writeString(MagicValues.value(String.class, this.type)); - } - } - - @Override - public boolean isPriority() { - return false; - } + private String name; + private ObjectiveAction action; + private String displayName; + private ScoreType type; + + @SuppressWarnings("unused") + private ServerScoreboardObjectivePacket() { + } + + public ServerScoreboardObjectivePacket(String name) { + this.name = name; + this.action = ObjectiveAction.REMOVE; + } + + public ServerScoreboardObjectivePacket(String name, ObjectiveAction action, String displayName, ScoreType type) { + if(action != ObjectiveAction.ADD && action != ObjectiveAction.UPDATE) { + throw new IllegalArgumentException("(name, action, displayName) constructor only valid for adding and updating objectives."); + } + + this.name = name; + this.action = action; + this.displayName = displayName; + this.type = type; + } + + public String getName() { + return this.name; + } + + public ObjectiveAction getAction() { + return this.action; + } + + public String getDisplayName() { + return this.displayName; + } + + public ScoreType getType() { + return this.type; + } + + @Override + public void read(NetInput in) throws IOException { + this.name = in.readString(); + this.action = MagicValues.key(ObjectiveAction.class, in.readByte()); + if(this.action == ObjectiveAction.ADD || this.action == ObjectiveAction.UPDATE) { + this.displayName = in.readString(); + this.type = MagicValues.key(ScoreType.class, in.readString()); + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.name); + out.writeByte(MagicValues.value(Integer.class, this.action)); + if(this.action == ObjectiveAction.ADD || this.action == ObjectiveAction.UPDATE) { + out.writeString(this.displayName); + out.writeString(MagicValues.value(String.class, this.type)); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerTeamPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerTeamPacket.java index b98c55440..91a1e6a55 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerTeamPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerTeamPacket.java @@ -12,157 +12,157 @@ public class ServerTeamPacket implements Packet { - private String name; - private TeamAction action; - private String displayName; - private String prefix; - private String suffix; - private boolean friendlyFire; - private boolean seeFriendlyInvisibles; - private NameTagVisibility nameTagVisibility; - private TeamColor color; - private String players[]; - - @SuppressWarnings("unused") - private ServerTeamPacket() { - } - - public ServerTeamPacket(String name) { - this.name = name; - this.action = TeamAction.REMOVE; - } - - public ServerTeamPacket(String name, TeamAction action, String players[]) { - if(action != TeamAction.ADD_PLAYER && action != TeamAction.REMOVE_PLAYER) { - throw new IllegalArgumentException("(name, action, players) constructor only valid for adding and removing players."); - } - - this.name = name; - this.action = action; - this.players = players; - } - - public ServerTeamPacket(String name, String displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles, NameTagVisibility nameTagVisibility, TeamColor color) { - this.name = name; - this.displayName = displayName; - this.prefix = prefix; - this.suffix = suffix; - this.friendlyFire = friendlyFire; - this.seeFriendlyInvisibles = seeFriendlyInvisibles; - this.nameTagVisibility = nameTagVisibility; - this.color = color; - this.action = TeamAction.UPDATE; - } - - public ServerTeamPacket(String name, String displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles, NameTagVisibility nameTagVisibility, TeamColor color, String players[]) { - this.name = name; - this.displayName = displayName; - this.prefix = prefix; - this.suffix = suffix; - this.friendlyFire = friendlyFire; - this.seeFriendlyInvisibles = seeFriendlyInvisibles; - this.nameTagVisibility = nameTagVisibility; - this.color = color; - this.players = players; - this.action = TeamAction.CREATE; - } - - public String getTeamName() { - return this.name; - } - - public TeamAction getAction() { - return this.action; - } - - public String getDisplayName() { - return this.displayName; - } - - public String getPrefix() { - return this.prefix; - } - - public String getSuffix() { - return this.suffix; - } - - public boolean getFriendlyFire() { - return this.friendlyFire; - } - - public boolean getSeeFriendlyInvisibles() { - return seeFriendlyInvisibles; - } - - public NameTagVisibility getNameTagVisibility() { - return this.nameTagVisibility; - } - - public TeamColor getColor() { - return this.color; - } - - public String[] getPlayers() { - return this.players; - } - - @Override - public void read(NetInput in) throws IOException { - this.name = in.readString(); - this.action = MagicValues.key(TeamAction.class, in.readByte()); - if(this.action == TeamAction.CREATE || this.action == TeamAction.UPDATE) { - this.displayName = in.readString(); - this.prefix = in.readString(); - this.suffix = in.readString(); - byte flags = in.readByte(); - this.friendlyFire = (flags & 0x1) != 0; - this.seeFriendlyInvisibles = (flags & 0x2) != 0; - this.nameTagVisibility = MagicValues.key(NameTagVisibility.class, in.readString()); - this.color = MagicValues.key(TeamColor.class, in.readByte()); - } - - if(this.action == TeamAction.CREATE || this.action == TeamAction.ADD_PLAYER || this.action == TeamAction.REMOVE_PLAYER) { - this.players = new String[in.readVarInt()]; - for(int index = 0; index < this.players.length; index++) { - this.players[index] = in.readString(); - } - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.name); - out.writeByte(MagicValues.value(Integer.class, this.action)); - if(this.action == TeamAction.CREATE || this.action == TeamAction.UPDATE) { - out.writeString(this.displayName); - out.writeString(this.prefix); - out.writeString(this.suffix); - byte flags = 0; - if (this.friendlyFire) { - flags |= 0x1; - } - if (this.seeFriendlyInvisibles) { - flags |= 0x2; - } - out.writeByte(flags); - out.writeString(MagicValues.value(String.class, this.nameTagVisibility)); - out.writeByte(MagicValues.value(Integer.class, this.color)); - } - - if(this.action == TeamAction.CREATE || this.action == TeamAction.ADD_PLAYER || this.action == TeamAction.REMOVE_PLAYER) { - out.writeVarInt(this.players.length); - for(String player : this.players) { - if(player != null) { - out.writeString(player); - } - } - } - } - - @Override - public boolean isPriority() { - return false; - } + private String name; + private TeamAction action; + private String displayName; + private String prefix; + private String suffix; + private boolean friendlyFire; + private boolean seeFriendlyInvisibles; + private NameTagVisibility nameTagVisibility; + private TeamColor color; + private String players[]; + + @SuppressWarnings("unused") + private ServerTeamPacket() { + } + + public ServerTeamPacket(String name) { + this.name = name; + this.action = TeamAction.REMOVE; + } + + public ServerTeamPacket(String name, TeamAction action, String players[]) { + if(action != TeamAction.ADD_PLAYER && action != TeamAction.REMOVE_PLAYER) { + throw new IllegalArgumentException("(name, action, players) constructor only valid for adding and removing players."); + } + + this.name = name; + this.action = action; + this.players = players; + } + + public ServerTeamPacket(String name, String displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles, NameTagVisibility nameTagVisibility, TeamColor color) { + this.name = name; + this.displayName = displayName; + this.prefix = prefix; + this.suffix = suffix; + this.friendlyFire = friendlyFire; + this.seeFriendlyInvisibles = seeFriendlyInvisibles; + this.nameTagVisibility = nameTagVisibility; + this.color = color; + this.action = TeamAction.UPDATE; + } + + public ServerTeamPacket(String name, String displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles, NameTagVisibility nameTagVisibility, TeamColor color, String players[]) { + this.name = name; + this.displayName = displayName; + this.prefix = prefix; + this.suffix = suffix; + this.friendlyFire = friendlyFire; + this.seeFriendlyInvisibles = seeFriendlyInvisibles; + this.nameTagVisibility = nameTagVisibility; + this.color = color; + this.players = players; + this.action = TeamAction.CREATE; + } + + public String getTeamName() { + return this.name; + } + + public TeamAction getAction() { + return this.action; + } + + public String getDisplayName() { + return this.displayName; + } + + public String getPrefix() { + return this.prefix; + } + + public String getSuffix() { + return this.suffix; + } + + public boolean getFriendlyFire() { + return this.friendlyFire; + } + + public boolean getSeeFriendlyInvisibles() { + return seeFriendlyInvisibles; + } + + public NameTagVisibility getNameTagVisibility() { + return this.nameTagVisibility; + } + + public TeamColor getColor() { + return this.color; + } + + public String[] getPlayers() { + return this.players; + } + + @Override + public void read(NetInput in) throws IOException { + this.name = in.readString(); + this.action = MagicValues.key(TeamAction.class, in.readByte()); + if(this.action == TeamAction.CREATE || this.action == TeamAction.UPDATE) { + this.displayName = in.readString(); + this.prefix = in.readString(); + this.suffix = in.readString(); + byte flags = in.readByte(); + this.friendlyFire = (flags & 0x1) != 0; + this.seeFriendlyInvisibles = (flags & 0x2) != 0; + this.nameTagVisibility = MagicValues.key(NameTagVisibility.class, in.readString()); + this.color = MagicValues.key(TeamColor.class, in.readByte()); + } + + if(this.action == TeamAction.CREATE || this.action == TeamAction.ADD_PLAYER || this.action == TeamAction.REMOVE_PLAYER) { + this.players = new String[in.readVarInt()]; + for(int index = 0; index < this.players.length; index++) { + this.players[index] = in.readString(); + } + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.name); + out.writeByte(MagicValues.value(Integer.class, this.action)); + if(this.action == TeamAction.CREATE || this.action == TeamAction.UPDATE) { + out.writeString(this.displayName); + out.writeString(this.prefix); + out.writeString(this.suffix); + byte flags = 0; + if(this.friendlyFire) { + flags |= 0x1; + } + if(this.seeFriendlyInvisibles) { + flags |= 0x2; + } + out.writeByte(flags); + out.writeString(MagicValues.value(String.class, this.nameTagVisibility)); + out.writeByte(MagicValues.value(Integer.class, this.color)); + } + + if(this.action == TeamAction.CREATE || this.action == TeamAction.ADD_PLAYER || this.action == TeamAction.REMOVE_PLAYER) { + out.writeVarInt(this.players.length); + for(String player : this.players) { + if(player != null) { + out.writeString(player); + } + } + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerUpdateScorePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerUpdateScorePacket.java index 8f40686d2..7b8305614 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerUpdateScorePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/scoreboard/ServerUpdateScorePacket.java @@ -10,67 +10,67 @@ public class ServerUpdateScorePacket implements Packet { - private String entry; - private ScoreboardAction action; - private String objective; - private int value; + private String entry; + private ScoreboardAction action; + private String objective; + private int value; - @SuppressWarnings("unused") - private ServerUpdateScorePacket() { - } + @SuppressWarnings("unused") + private ServerUpdateScorePacket() { + } - public ServerUpdateScorePacket(String entry, String objective) { - this.entry = entry; - this.objective = objective; - this.action = ScoreboardAction.REMOVE; - } + public ServerUpdateScorePacket(String entry, String objective) { + this.entry = entry; + this.objective = objective; + this.action = ScoreboardAction.REMOVE; + } - public ServerUpdateScorePacket(String entry, String objective, int value) { - this.entry = entry; - this.objective = objective; - this.value = value; - this.action = ScoreboardAction.ADD_OR_UPDATE; - } + public ServerUpdateScorePacket(String entry, String objective, int value) { + this.entry = entry; + this.objective = objective; + this.value = value; + this.action = ScoreboardAction.ADD_OR_UPDATE; + } - public String getEntry() { - return this.entry; - } + public String getEntry() { + return this.entry; + } - public ScoreboardAction getAction() { - return this.action; - } + public ScoreboardAction getAction() { + return this.action; + } - public String getObjective() { - return this.objective; - } + public String getObjective() { + return this.objective; + } - public int getValue() { - return this.value; - } + public int getValue() { + return this.value; + } - @Override - public void read(NetInput in) throws IOException { - this.entry = in.readString(); - this.action = MagicValues.key(ScoreboardAction.class, in.readByte()); - this.objective = in.readString(); - if(this.action == ScoreboardAction.ADD_OR_UPDATE) { - this.value = in.readVarInt(); - } - } + @Override + public void read(NetInput in) throws IOException { + this.entry = in.readString(); + this.action = MagicValues.key(ScoreboardAction.class, in.readByte()); + this.objective = in.readString(); + if(this.action == ScoreboardAction.ADD_OR_UPDATE) { + this.value = in.readVarInt(); + } + } - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.entry); - out.writeByte(MagicValues.value(Integer.class, this.action)); - out.writeString(this.objective); - if(this.action == ScoreboardAction.ADD_OR_UPDATE) { - out.writeVarInt(this.value); - } - } + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.entry); + out.writeByte(MagicValues.value(Integer.class, this.action)); + out.writeString(this.objective); + if(this.action == ScoreboardAction.ADD_OR_UPDATE) { + out.writeVarInt(this.value); + } + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerCloseWindowPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerCloseWindowPacket.java index 17a2f3597..3471936c0 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerCloseWindowPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerCloseWindowPacket.java @@ -8,33 +8,33 @@ public class ServerCloseWindowPacket implements Packet { - private int windowId; - - @SuppressWarnings("unused") - private ServerCloseWindowPacket() { - } - - public ServerCloseWindowPacket(int windowId) { - this.windowId = windowId; - } - - public int getWindowId() { - return this.windowId; - } - - @Override - public void read(NetInput in) throws IOException { - this.windowId = in.readUnsignedByte(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(this.windowId); - } - - @Override - public boolean isPriority() { - return false; - } + private int windowId; + + @SuppressWarnings("unused") + private ServerCloseWindowPacket() { + } + + public ServerCloseWindowPacket(int windowId) { + this.windowId = windowId; + } + + public int getWindowId() { + return this.windowId; + } + + @Override + public void read(NetInput in) throws IOException { + this.windowId = in.readUnsignedByte(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.windowId); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerConfirmTransactionPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerConfirmTransactionPacket.java index 5e6a4ef5a..4e4c33f84 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerConfirmTransactionPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerConfirmTransactionPacket.java @@ -8,49 +8,49 @@ public class ServerConfirmTransactionPacket implements Packet { - private int windowId; - private int actionId; - private boolean accepted; - - @SuppressWarnings("unused") - private ServerConfirmTransactionPacket() { - } - - public ServerConfirmTransactionPacket(int windowId, int actionId, boolean accepted) { - this.windowId = windowId; - this.actionId = actionId; - this.accepted = accepted; - } - - public int getWindowId() { - return this.windowId; - } - - public int getActionId() { - return this.actionId; - } - - public boolean getAccepted() { - return this.accepted; - } - - @Override - public void read(NetInput in) throws IOException { - this.windowId = in.readUnsignedByte(); - this.actionId = in.readShort(); - this.accepted = in.readBoolean(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(this.windowId); - out.writeShort(this.actionId); - out.writeBoolean(this.accepted); - } - - @Override - public boolean isPriority() { - return false; - } + private int windowId; + private int actionId; + private boolean accepted; + + @SuppressWarnings("unused") + private ServerConfirmTransactionPacket() { + } + + public ServerConfirmTransactionPacket(int windowId, int actionId, boolean accepted) { + this.windowId = windowId; + this.actionId = actionId; + this.accepted = accepted; + } + + public int getWindowId() { + return this.windowId; + } + + public int getActionId() { + return this.actionId; + } + + public boolean getAccepted() { + return this.accepted; + } + + @Override + public void read(NetInput in) throws IOException { + this.windowId = in.readUnsignedByte(); + this.actionId = in.readShort(); + this.accepted = in.readBoolean(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.windowId); + out.writeShort(this.actionId); + out.writeBoolean(this.accepted); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerOpenWindowPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerOpenWindowPacket.java index 41040e4a1..856866118 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerOpenWindowPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerOpenWindowPacket.java @@ -10,73 +10,73 @@ public class ServerOpenWindowPacket implements Packet { - private int windowId; - private WindowType type; - private String name; - private int slots; - private int ownerEntityId; - - @SuppressWarnings("unused") - private ServerOpenWindowPacket() { - } - - public ServerOpenWindowPacket(int windowId, WindowType type, String name, int slots) { - this(windowId, type, name, slots, 0); - } - - public ServerOpenWindowPacket(int windowId, WindowType type, String name, int slots, int ownerEntityId) { - this.windowId = windowId; - this.type = type; - this.name = name; - this.slots = slots; - this.ownerEntityId = ownerEntityId; - } - - public int getWindowId() { - return this.windowId; - } - - public WindowType getType() { - return this.type; - } - - public String getName() { - return this.name; - } - - public int getSlots() { - return this.slots; - } - - public int getOwnerEntityId() { - return this.ownerEntityId; - } - - @Override - public void read(NetInput in) throws IOException { - this.windowId = in.readUnsignedByte(); - this.type = MagicValues.key(WindowType.class, in.readString()); - this.name = in.readString(); - this.slots = in.readUnsignedByte(); - if(this.type == WindowType.HORSE) { - this.ownerEntityId = in.readInt(); - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(this.windowId); - out.writeString(MagicValues.value(String.class, this.type)); - out.writeString(this.name); - out.writeByte(this.slots); - if(this.type == WindowType.HORSE) { - out.writeInt(this.ownerEntityId); - } - } - - @Override - public boolean isPriority() { - return false; - } + private int windowId; + private WindowType type; + private String name; + private int slots; + private int ownerEntityId; + + @SuppressWarnings("unused") + private ServerOpenWindowPacket() { + } + + public ServerOpenWindowPacket(int windowId, WindowType type, String name, int slots) { + this(windowId, type, name, slots, 0); + } + + public ServerOpenWindowPacket(int windowId, WindowType type, String name, int slots, int ownerEntityId) { + this.windowId = windowId; + this.type = type; + this.name = name; + this.slots = slots; + this.ownerEntityId = ownerEntityId; + } + + public int getWindowId() { + return this.windowId; + } + + public WindowType getType() { + return this.type; + } + + public String getName() { + return this.name; + } + + public int getSlots() { + return this.slots; + } + + public int getOwnerEntityId() { + return this.ownerEntityId; + } + + @Override + public void read(NetInput in) throws IOException { + this.windowId = in.readUnsignedByte(); + this.type = MagicValues.key(WindowType.class, in.readString()); + this.name = in.readString(); + this.slots = in.readUnsignedByte(); + if(this.type == WindowType.HORSE) { + this.ownerEntityId = in.readInt(); + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.windowId); + out.writeString(MagicValues.value(String.class, this.type)); + out.writeString(this.name); + out.writeByte(this.slots); + if(this.type == WindowType.HORSE) { + out.writeInt(this.ownerEntityId); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerSetSlotPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerSetSlotPacket.java index d2dc9ecf9..ec4b4d7d7 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerSetSlotPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerSetSlotPacket.java @@ -10,49 +10,49 @@ public class ServerSetSlotPacket implements Packet { - private int windowId; - private int slot; - private ItemStack item; - - @SuppressWarnings("unused") - private ServerSetSlotPacket() { - } - - public ServerSetSlotPacket(int windowId, int slot, ItemStack item) { - this.windowId = windowId; - this.slot = slot; - this.item = item; - } - - public int getWindowId() { - return this.windowId; - } - - public int getSlot() { - return this.slot; - } - - public ItemStack getItem() { - return this.item; - } - - @Override - public void read(NetInput in) throws IOException { - this.windowId = in.readUnsignedByte(); - this.slot = in.readShort(); - this.item = NetUtil.readItem(in); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(this.windowId); - out.writeShort(this.slot); - NetUtil.writeItem(out, this.item); - } - - @Override - public boolean isPriority() { - return false; - } + private int windowId; + private int slot; + private ItemStack item; + + @SuppressWarnings("unused") + private ServerSetSlotPacket() { + } + + public ServerSetSlotPacket(int windowId, int slot, ItemStack item) { + this.windowId = windowId; + this.slot = slot; + this.item = item; + } + + public int getWindowId() { + return this.windowId; + } + + public int getSlot() { + return this.slot; + } + + public ItemStack getItem() { + return this.item; + } + + @Override + public void read(NetInput in) throws IOException { + this.windowId = in.readUnsignedByte(); + this.slot = in.readShort(); + this.item = NetUtil.readItem(in); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.windowId); + out.writeShort(this.slot); + NetUtil.writeItem(out, this.item); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowItemsPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowItemsPacket.java index ff2e21155..a5afa8033 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowItemsPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowItemsPacket.java @@ -10,47 +10,47 @@ public class ServerWindowItemsPacket implements Packet { - private int windowId; - private ItemStack items[]; - - @SuppressWarnings("unused") - private ServerWindowItemsPacket() { - } - - public ServerWindowItemsPacket(int windowId, ItemStack items[]) { - this.windowId = windowId; - this.items = items; - } - - public int getWindowId() { - return this.windowId; - } - - public ItemStack[] getItems() { - return this.items; - } - - @Override - public void read(NetInput in) throws IOException { - this.windowId = in.readUnsignedByte(); - this.items = new ItemStack[in.readShort()]; - for(int index = 0; index < this.items.length; index++) { - this.items[index] = NetUtil.readItem(in); - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(this.windowId); - out.writeShort(this.items.length); - for(ItemStack item : this.items) { - NetUtil.writeItem(out, item); - } - } - - @Override - public boolean isPriority() { - return false; - } + private int windowId; + private ItemStack items[]; + + @SuppressWarnings("unused") + private ServerWindowItemsPacket() { + } + + public ServerWindowItemsPacket(int windowId, ItemStack items[]) { + this.windowId = windowId; + this.items = items; + } + + public int getWindowId() { + return this.windowId; + } + + public ItemStack[] getItems() { + return this.items; + } + + @Override + public void read(NetInput in) throws IOException { + this.windowId = in.readUnsignedByte(); + this.items = new ItemStack[in.readShort()]; + for(int index = 0; index < this.items.length; index++) { + this.items[index] = NetUtil.readItem(in); + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.windowId); + out.writeShort(this.items.length); + for(ItemStack item : this.items) { + NetUtil.writeItem(out, item); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowPropertyPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowPropertyPacket.java index e9395e449..f687af737 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowPropertyPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/window/ServerWindowPropertyPacket.java @@ -10,59 +10,59 @@ public class ServerWindowPropertyPacket implements Packet { - private int windowId; - private int property; - private int value; + private int windowId; + private int property; + private int value; - @SuppressWarnings("unused") - private ServerWindowPropertyPacket() { - } + @SuppressWarnings("unused") + private ServerWindowPropertyPacket() { + } - public ServerWindowPropertyPacket(int windowId, int property, int value) { - this.windowId = windowId; - this.property = property; - this.value = value; - } + public ServerWindowPropertyPacket(int windowId, int property, int value) { + this.windowId = windowId; + this.property = property; + this.value = value; + } - public & WindowProperty> ServerWindowPropertyPacket(int windowId, T property, int value) { - this.windowId = windowId; - this.property = MagicValues.value(Integer.class, property); - this.value = value; - } + public & WindowProperty> ServerWindowPropertyPacket(int windowId, T property, int value) { + this.windowId = windowId; + this.property = MagicValues.value(Integer.class, property); + this.value = value; + } - public int getWindowId() { - return this.windowId; - } + public int getWindowId() { + return this.windowId; + } - public int getRawProperty() { - return this.property; - } + public int getRawProperty() { + return this.property; + } - public & WindowProperty> T getProperty(Class type) { - return MagicValues.key(type, value); - } + public & WindowProperty> T getProperty(Class type) { + return MagicValues.key(type, value); + } - public int getValue() { - return this.value; - } + public int getValue() { + return this.value; + } - @Override - public void read(NetInput in) throws IOException { - this.windowId = in.readUnsignedByte(); - this.property = in.readShort(); - this.value = in.readShort(); - } + @Override + public void read(NetInput in) throws IOException { + this.windowId = in.readUnsignedByte(); + this.property = in.readShort(); + this.value = in.readShort(); + } - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(this.windowId); - out.writeShort(this.property); - out.writeShort(this.value); - } + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.windowId); + out.writeShort(this.property); + out.writeShort(this.value); + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java index 69848b55b..32bade811 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockBreakAnimPacket.java @@ -12,52 +12,52 @@ public class ServerBlockBreakAnimPacket implements Packet { - private int breakerEntityId; - private Position position; - private BlockBreakStage stage; - - @SuppressWarnings("unused") - private ServerBlockBreakAnimPacket() { - } - - public ServerBlockBreakAnimPacket(int breakerEntityId, Position position, BlockBreakStage stage) { - this.breakerEntityId = breakerEntityId; - this.position = position; - this.stage = stage; - } - - public int getBreakerEntityId() { - return this.breakerEntityId; - } - - public Position getPosition() { - return this.position; - } - - public BlockBreakStage getStage() { - return this.stage; - } - - @Override - public void read(NetInput in) throws IOException { - this.breakerEntityId = in.readVarInt(); - this.position = NetUtil.readPosition(in); - this.stage = MagicValues.key(BlockBreakStage.class, in.readUnsignedByte()); - if (this.stage == null) { - this.stage = BlockBreakStage.RESET; - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.breakerEntityId); - NetUtil.writePosition(out, this.position); - out.writeByte(MagicValues.value(Integer.class, this.stage)); - } - - @Override - public boolean isPriority() { - return false; - } + private int breakerEntityId; + private Position position; + private BlockBreakStage stage; + + @SuppressWarnings("unused") + private ServerBlockBreakAnimPacket() { + } + + public ServerBlockBreakAnimPacket(int breakerEntityId, Position position, BlockBreakStage stage) { + this.breakerEntityId = breakerEntityId; + this.position = position; + this.stage = stage; + } + + public int getBreakerEntityId() { + return this.breakerEntityId; + } + + public Position getPosition() { + return this.position; + } + + public BlockBreakStage getStage() { + return this.stage; + } + + @Override + public void read(NetInput in) throws IOException { + this.breakerEntityId = in.readVarInt(); + this.position = NetUtil.readPosition(in); + this.stage = MagicValues.key(BlockBreakStage.class, in.readUnsignedByte()); + if(this.stage == null) { + this.stage = BlockBreakStage.RESET; + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.breakerEntityId); + NetUtil.writePosition(out, this.position); + out.writeByte(MagicValues.value(Integer.class, this.stage)); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockChangePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockChangePacket.java index ac25021cc..92b94d2d1 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockChangePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockChangePacket.java @@ -10,34 +10,34 @@ public class ServerBlockChangePacket implements Packet { - private BlockChangeRecord record; - - @SuppressWarnings("unused") - private ServerBlockChangePacket() { - } - - public ServerBlockChangePacket(BlockChangeRecord record) { - this.record = record; - } - - public BlockChangeRecord getRecord() { - return this.record; - } - - @Override - public void read(NetInput in) throws IOException { - this.record = new BlockChangeRecord(NetUtil.readPosition(in), in.readVarInt()); - } - - @Override - public void write(NetOutput out) throws IOException { - NetUtil.writePosition(out, this.record.getPosition()); - out.writeVarInt(this.record.getBlock()); - } - - @Override - public boolean isPriority() { - return false; - } + private BlockChangeRecord record; + + @SuppressWarnings("unused") + private ServerBlockChangePacket() { + } + + public ServerBlockChangePacket(BlockChangeRecord record) { + this.record = record; + } + + public BlockChangeRecord getRecord() { + return this.record; + } + + @Override + public void read(NetInput in) throws IOException { + this.record = new BlockChangeRecord(NetUtil.readPosition(in), in.readVarInt()); + } + + @Override + public void write(NetOutput out) throws IOException { + NetUtil.writePosition(out, this.record.getPosition()); + out.writeVarInt(this.record.getBlock()); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java index 954a53f22..01a30efa9 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java @@ -2,7 +2,18 @@ import org.spacehq.mc.protocol.data.game.Position; import org.spacehq.mc.protocol.data.game.values.MagicValues; -import org.spacehq.mc.protocol.data.game.values.world.block.value.*; +import org.spacehq.mc.protocol.data.game.values.world.block.value.BlockValue; +import org.spacehq.mc.protocol.data.game.values.world.block.value.BlockValueType; +import org.spacehq.mc.protocol.data.game.values.world.block.value.ChestValue; +import org.spacehq.mc.protocol.data.game.values.world.block.value.ChestValueType; +import org.spacehq.mc.protocol.data.game.values.world.block.value.GenericBlockValue; +import org.spacehq.mc.protocol.data.game.values.world.block.value.GenericBlockValueType; +import org.spacehq.mc.protocol.data.game.values.world.block.value.MobSpawnerValue; +import org.spacehq.mc.protocol.data.game.values.world.block.value.MobSpawnerValueType; +import org.spacehq.mc.protocol.data.game.values.world.block.value.NoteBlockValue; +import org.spacehq.mc.protocol.data.game.values.world.block.value.NoteBlockValueType; +import org.spacehq.mc.protocol.data.game.values.world.block.value.PistonValue; +import org.spacehq.mc.protocol.data.game.values.world.block.value.PistonValueType; import org.spacehq.mc.protocol.util.NetUtil; import org.spacehq.packetlib.io.NetInput; import org.spacehq.packetlib.io.NetOutput; @@ -12,115 +23,115 @@ public class ServerBlockValuePacket implements Packet { - private static final int NOTE_BLOCK = 25; - private static final int STICKY_PISTON = 29; - private static final int PISTON = 33; - private static final int MOB_SPAWNER = 52; - private static final int CHEST = 54; - private static final int ENDER_CHEST = 130; - private static final int TRAPPED_CHEST = 146; - - private Position position; - private BlockValueType type; - private BlockValue value; - private int blockId; - - @SuppressWarnings("unused") - private ServerBlockValuePacket() { - } - - public ServerBlockValuePacket(Position position, BlockValueType type, BlockValue value, int blockId) { - this.position = position; - this.type = type; - this.value = value; - this.blockId = blockId; - } - - public Position getPosition() { - return this.position; - } - - public BlockValueType getType() { - return this.type; - } - - public BlockValue getValue() { - return this.value; - } - - public int getBlockId() { - return this.blockId; - } - - @Override - public void read(NetInput in) throws IOException { - this.position = NetUtil.readPosition(in); - int type = in.readUnsignedByte(); - if(this.blockId == NOTE_BLOCK) { - this.type = MagicValues.key(NoteBlockValueType.class, type); - } else if(this.blockId == STICKY_PISTON || this.blockId == PISTON) { - this.type = MagicValues.key(PistonValueType.class, type); - } else if(this.blockId == MOB_SPAWNER) { - this.type = MagicValues.key(MobSpawnerValueType.class, type); - } else if(this.blockId == CHEST || this.blockId == ENDER_CHEST || this.blockId == TRAPPED_CHEST) { - this.type = MagicValues.key(ChestValueType.class, type); - } else { - this.type = MagicValues.key(GenericBlockValueType.class, type); - } - - int value = in.readUnsignedByte(); - if(this.blockId == NOTE_BLOCK) { - this.value = new NoteBlockValue(value); - } else if(this.blockId == STICKY_PISTON || this.blockId == PISTON) { - this.value = MagicValues.key(PistonValue.class, value); - } else if(this.blockId == MOB_SPAWNER) { - this.value = new MobSpawnerValue(); - } else if(this.blockId == CHEST || this.blockId == ENDER_CHEST || this.blockId == TRAPPED_CHEST) { - this.value = new ChestValue(value); - } else { - this.value = new GenericBlockValue(value); - } - - this.blockId = in.readVarInt() & 4095; - } - - @Override - public void write(NetOutput out) throws IOException { - NetUtil.writePosition(out, this.position); - int type = 0; - if(this.type instanceof NoteBlockValueType) { - type = MagicValues.value(Integer.class, (NoteBlockValueType) this.type); - } else if(this.type instanceof PistonValueType) { - type = MagicValues.value(Integer.class, (PistonValueType) this.type); - } else if(this.type instanceof MobSpawnerValueType) { - type = MagicValues.value(Integer.class, (MobSpawnerValueType) this.type); - } else if(this.type instanceof ChestValueType) { - type = MagicValues.value(Integer.class, (ChestValueType) this.type); - } else if(this.type instanceof GenericBlockValueType) { - type = MagicValues.value(Integer.class, (GenericBlockValueType) this.type); - } - - out.writeByte(type); - int val = 0; - if(this.value instanceof NoteBlockValue) { - val = ((NoteBlockValue) this.value).getPitch(); - } else if(this.value instanceof PistonValue) { - val = MagicValues.value(Integer.class, (PistonValue) this.value); - } else if(this.value instanceof MobSpawnerValue) { - val = 0; - } else if(this.value instanceof ChestValue) { - val = ((ChestValue) this.value).getViewers(); - } else if(this.value instanceof GenericBlockValue) { - val = ((GenericBlockValue) this.value).getValue(); - } - - out.writeByte(val); - out.writeVarInt(this.blockId & 4095); - } - - @Override - public boolean isPriority() { - return false; - } + private static final int NOTE_BLOCK = 25; + private static final int STICKY_PISTON = 29; + private static final int PISTON = 33; + private static final int MOB_SPAWNER = 52; + private static final int CHEST = 54; + private static final int ENDER_CHEST = 130; + private static final int TRAPPED_CHEST = 146; + + private Position position; + private BlockValueType type; + private BlockValue value; + private int blockId; + + @SuppressWarnings("unused") + private ServerBlockValuePacket() { + } + + public ServerBlockValuePacket(Position position, BlockValueType type, BlockValue value, int blockId) { + this.position = position; + this.type = type; + this.value = value; + this.blockId = blockId; + } + + public Position getPosition() { + return this.position; + } + + public BlockValueType getType() { + return this.type; + } + + public BlockValue getValue() { + return this.value; + } + + public int getBlockId() { + return this.blockId; + } + + @Override + public void read(NetInput in) throws IOException { + this.position = NetUtil.readPosition(in); + int type = in.readUnsignedByte(); + if(this.blockId == NOTE_BLOCK) { + this.type = MagicValues.key(NoteBlockValueType.class, type); + } else if(this.blockId == STICKY_PISTON || this.blockId == PISTON) { + this.type = MagicValues.key(PistonValueType.class, type); + } else if(this.blockId == MOB_SPAWNER) { + this.type = MagicValues.key(MobSpawnerValueType.class, type); + } else if(this.blockId == CHEST || this.blockId == ENDER_CHEST || this.blockId == TRAPPED_CHEST) { + this.type = MagicValues.key(ChestValueType.class, type); + } else { + this.type = MagicValues.key(GenericBlockValueType.class, type); + } + + int value = in.readUnsignedByte(); + if(this.blockId == NOTE_BLOCK) { + this.value = new NoteBlockValue(value); + } else if(this.blockId == STICKY_PISTON || this.blockId == PISTON) { + this.value = MagicValues.key(PistonValue.class, value); + } else if(this.blockId == MOB_SPAWNER) { + this.value = new MobSpawnerValue(); + } else if(this.blockId == CHEST || this.blockId == ENDER_CHEST || this.blockId == TRAPPED_CHEST) { + this.value = new ChestValue(value); + } else { + this.value = new GenericBlockValue(value); + } + + this.blockId = in.readVarInt() & 4095; + } + + @Override + public void write(NetOutput out) throws IOException { + NetUtil.writePosition(out, this.position); + int type = 0; + if(this.type instanceof NoteBlockValueType) { + type = MagicValues.value(Integer.class, (NoteBlockValueType) this.type); + } else if(this.type instanceof PistonValueType) { + type = MagicValues.value(Integer.class, (PistonValueType) this.type); + } else if(this.type instanceof MobSpawnerValueType) { + type = MagicValues.value(Integer.class, (MobSpawnerValueType) this.type); + } else if(this.type instanceof ChestValueType) { + type = MagicValues.value(Integer.class, (ChestValueType) this.type); + } else if(this.type instanceof GenericBlockValueType) { + type = MagicValues.value(Integer.class, (GenericBlockValueType) this.type); + } + + out.writeByte(type); + int val = 0; + if(this.value instanceof NoteBlockValue) { + val = ((NoteBlockValue) this.value).getPitch(); + } else if(this.value instanceof PistonValue) { + val = MagicValues.value(Integer.class, (PistonValue) this.value); + } else if(this.value instanceof MobSpawnerValue) { + val = 0; + } else if(this.value instanceof ChestValue) { + val = ((ChestValue) this.value).getViewers(); + } else if(this.value instanceof GenericBlockValue) { + val = ((GenericBlockValue) this.value).getValue(); + } + + out.writeByte(val); + out.writeVarInt(this.blockId & 4095); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerChunkDataPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerChunkDataPacket.java index 013a6924a..2ad65c51f 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerChunkDataPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerChunkDataPacket.java @@ -12,119 +12,119 @@ public class ServerChunkDataPacket implements Packet { - private int x; - private int z; - private Chunk chunks[]; - private byte biomeData[]; - - @SuppressWarnings("unused") - private ServerChunkDataPacket() { - } - - /** - * Convenience constructor for creating a packet to unload chunks. - * - * @param x X of the chunk column. - * @param z Z of the chunk column. - */ - public ServerChunkDataPacket(int x, int z) { - this(x, z, new Chunk[16], new byte[256]); - } - - /** - * Constructs a ServerChunkDataPacket for updating chunks. - * - * @param x X of the chunk column. - * @param z Z of the chunk column. - * @param chunks Array of chunks in the column. Length must be 16 but can contain null values. - * @throws IllegalArgumentException If the chunk array length is not 16 or skylight arrays exist in some but not all chunks. - */ - public ServerChunkDataPacket(int x, int z, Chunk chunks[]) { - this(x, z, chunks, null); - } - - /** - * Constructs a ServerChunkDataPacket for updating a full column of chunks. - * - * @param x X of the chunk column. - * @param z Z of the chunk column. - * @param chunks Array of chunks in the column. Length must be 16 but can contain null values. - * @param biomeData Array of biome data for the column. - * @throws IllegalArgumentException If the chunk array length is not 16 or skylight arrays exist in some but not all chunks. - */ - public ServerChunkDataPacket(int x, int z, Chunk chunks[], byte biomeData[]) { - if(chunks.length != 16) { - throw new IllegalArgumentException("Chunks length must be 16."); - } - - boolean noSkylight = false; - boolean skylight = false; - for(int index = 0; index < chunks.length; index++) { - if(chunks[index] != null) { - if(chunks[index].getSkyLight() == null) { - noSkylight = true; - } else { - skylight = true; - } - } - } - - if(noSkylight && skylight) { - throw new IllegalArgumentException("Either all chunks must have skylight values or none must have them."); - } - - this.x = x; - this.z = z; - this.chunks = chunks; - this.biomeData = biomeData; - } - - public int getX() { - return this.x; - } - - public int getZ() { - return this.z; - } - - public Chunk[] getChunks() { - return this.chunks; - } - - public byte[] getBiomeData() { - return this.biomeData; - } - - public boolean isFullChunk() { - return this.biomeData != null; - } - - @Override - public void read(NetInput in) throws IOException { - this.x = in.readInt(); - this.z = in.readInt(); - boolean fullChunk = in.readBoolean(); - int chunkMask = in.readUnsignedShort(); - byte data[] = in.readBytes(in.readVarInt()); - ParsedChunkData chunkData = NetUtil.dataToChunks(new NetworkChunkData(chunkMask, fullChunk, false, data), true); - this.chunks = chunkData.getChunks(); - this.biomeData = chunkData.getBiomes(); - } - - @Override - public void write(NetOutput out) throws IOException { - NetworkChunkData data = NetUtil.chunksToData(new ParsedChunkData(this.chunks, this.biomeData)); - out.writeInt(this.x); - out.writeInt(this.z); - out.writeBoolean(data.isFullChunk()); - out.writeShort(data.getMask()); - out.writeVarInt(data.getData().length); - out.writeBytes(data.getData(), data.getData().length); - } - - @Override - public boolean isPriority() { - return false; - } + private int x; + private int z; + private Chunk chunks[]; + private byte biomeData[]; + + @SuppressWarnings("unused") + private ServerChunkDataPacket() { + } + + /** + * Convenience constructor for creating a packet to unload chunks. + * + * @param x X of the chunk column. + * @param z Z of the chunk column. + */ + public ServerChunkDataPacket(int x, int z) { + this(x, z, new Chunk[16], new byte[256]); + } + + /** + * Constructs a ServerChunkDataPacket for updating chunks. + * + * @param x X of the chunk column. + * @param z Z of the chunk column. + * @param chunks Array of chunks in the column. Length must be 16 but can contain null values. + * @throws IllegalArgumentException If the chunk array length is not 16 or skylight arrays exist in some but not all chunks. + */ + public ServerChunkDataPacket(int x, int z, Chunk chunks[]) { + this(x, z, chunks, null); + } + + /** + * Constructs a ServerChunkDataPacket for updating a full column of chunks. + * + * @param x X of the chunk column. + * @param z Z of the chunk column. + * @param chunks Array of chunks in the column. Length must be 16 but can contain null values. + * @param biomeData Array of biome data for the column. + * @throws IllegalArgumentException If the chunk array length is not 16 or skylight arrays exist in some but not all chunks. + */ + public ServerChunkDataPacket(int x, int z, Chunk chunks[], byte biomeData[]) { + if(chunks.length != 16) { + throw new IllegalArgumentException("Chunks length must be 16."); + } + + boolean noSkylight = false; + boolean skylight = false; + for(int index = 0; index < chunks.length; index++) { + if(chunks[index] != null) { + if(chunks[index].getSkyLight() == null) { + noSkylight = true; + } else { + skylight = true; + } + } + } + + if(noSkylight && skylight) { + throw new IllegalArgumentException("Either all chunks must have skylight values or none must have them."); + } + + this.x = x; + this.z = z; + this.chunks = chunks; + this.biomeData = biomeData; + } + + public int getX() { + return this.x; + } + + public int getZ() { + return this.z; + } + + public Chunk[] getChunks() { + return this.chunks; + } + + public byte[] getBiomeData() { + return this.biomeData; + } + + public boolean isFullChunk() { + return this.biomeData != null; + } + + @Override + public void read(NetInput in) throws IOException { + this.x = in.readInt(); + this.z = in.readInt(); + boolean fullChunk = in.readBoolean(); + int chunkMask = in.readUnsignedShort(); + byte data[] = in.readBytes(in.readVarInt()); + ParsedChunkData chunkData = NetUtil.dataToChunks(new NetworkChunkData(chunkMask, fullChunk, false, data), true); + this.chunks = chunkData.getChunks(); + this.biomeData = chunkData.getBiomes(); + } + + @Override + public void write(NetOutput out) throws IOException { + NetworkChunkData data = NetUtil.chunksToData(new ParsedChunkData(this.chunks, this.biomeData)); + out.writeInt(this.x); + out.writeInt(this.z); + out.writeBoolean(data.isFullChunk()); + out.writeShort(data.getMask()); + out.writeVarInt(data.getData().length); + out.writeBytes(data.getData(), data.getData().length); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerExplosionPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerExplosionPacket.java index 519fb688e..4a2fef851 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerExplosionPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerExplosionPacket.java @@ -11,100 +11,100 @@ public class ServerExplosionPacket implements Packet { - private float x; - private float y; - private float z; - private float radius; - private List exploded; - private float pushX; - private float pushY; - private float pushZ; - - @SuppressWarnings("unused") - private ServerExplosionPacket() { - } - - public ServerExplosionPacket(float x, float y, float z, float radius, List exploded, float pushX, float pushY, float pushZ) { - this.x = x; - this.y = y; - this.z = z; - this.radius = radius; - this.exploded = exploded; - this.pushX = pushX; - this.pushY = pushY; - this.pushZ = pushZ; - } - - public float getX() { - return this.x; - } - - public float getY() { - return this.y; - } - - public float getZ() { - return this.z; - } - - public float getRadius() { - return this.radius; - } - - public List getExploded() { - return this.exploded; - } - - public float getPushX() { - return this.pushX; - } - - public float getPushY() { - return this.pushY; - } - - public float getPushZ() { - return this.pushZ; - } - - @Override - public void read(NetInput in) throws IOException { - this.x = in.readFloat(); - this.y = in.readFloat(); - this.z = in.readFloat(); - this.radius = in.readFloat(); - this.exploded = new ArrayList(); - int length = in.readInt(); - for(int count = 0; count < length; count++) { - this.exploded.add(new ExplodedBlockRecord(in.readByte(), in.readByte(), in.readByte())); - } - - this.pushX = in.readFloat(); - this.pushY = in.readFloat(); - this.pushZ = in.readFloat(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeFloat(this.x); - out.writeFloat(this.y); - out.writeFloat(this.z); - out.writeFloat(this.radius); - out.writeInt(this.exploded.size()); - for(ExplodedBlockRecord record : this.exploded) { - out.writeByte(record.getX()); - out.writeByte(record.getY()); - out.writeByte(record.getZ()); - } - - out.writeFloat(this.pushX); - out.writeFloat(this.pushY); - out.writeFloat(this.pushZ); - } - - @Override - public boolean isPriority() { - return false; - } + private float x; + private float y; + private float z; + private float radius; + private List exploded; + private float pushX; + private float pushY; + private float pushZ; + + @SuppressWarnings("unused") + private ServerExplosionPacket() { + } + + public ServerExplosionPacket(float x, float y, float z, float radius, List exploded, float pushX, float pushY, float pushZ) { + this.x = x; + this.y = y; + this.z = z; + this.radius = radius; + this.exploded = exploded; + this.pushX = pushX; + this.pushY = pushY; + this.pushZ = pushZ; + } + + public float getX() { + return this.x; + } + + public float getY() { + return this.y; + } + + public float getZ() { + return this.z; + } + + public float getRadius() { + return this.radius; + } + + public List getExploded() { + return this.exploded; + } + + public float getPushX() { + return this.pushX; + } + + public float getPushY() { + return this.pushY; + } + + public float getPushZ() { + return this.pushZ; + } + + @Override + public void read(NetInput in) throws IOException { + this.x = in.readFloat(); + this.y = in.readFloat(); + this.z = in.readFloat(); + this.radius = in.readFloat(); + this.exploded = new ArrayList(); + int length = in.readInt(); + for(int count = 0; count < length; count++) { + this.exploded.add(new ExplodedBlockRecord(in.readByte(), in.readByte(), in.readByte())); + } + + this.pushX = in.readFloat(); + this.pushY = in.readFloat(); + this.pushZ = in.readFloat(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeFloat(this.x); + out.writeFloat(this.y); + out.writeFloat(this.z); + out.writeFloat(this.radius); + out.writeInt(this.exploded.size()); + for(ExplodedBlockRecord record : this.exploded) { + out.writeByte(record.getX()); + out.writeByte(record.getY()); + out.writeByte(record.getZ()); + } + + out.writeFloat(this.pushX); + out.writeFloat(this.pushY); + out.writeFloat(this.pushZ); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMapDataPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMapDataPacket.java index 744d30261..8d0b7d026 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMapDataPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMapDataPacket.java @@ -1,6 +1,7 @@ package org.spacehq.mc.protocol.packet.ingame.server.world; -import org.spacehq.mc.protocol.data.game.values.world.map.*; +import org.spacehq.mc.protocol.data.game.values.world.map.MapData; +import org.spacehq.mc.protocol.data.game.values.world.map.MapPlayer; import org.spacehq.packetlib.io.NetInput; import org.spacehq.packetlib.io.NetOutput; import org.spacehq.packetlib.packet.Packet; @@ -9,94 +10,94 @@ public class ServerMapDataPacket implements Packet { - private int mapId; - private byte scale; - private MapPlayer players[]; - - private MapData data; - - @SuppressWarnings("unused") - private ServerMapDataPacket() { - } - - public ServerMapDataPacket(int mapId, byte scale, MapPlayer players[]) { - this(mapId, scale, players, null); - } - - public ServerMapDataPacket(int mapId, byte scale, MapPlayer players[], MapData data) { - this.mapId = mapId; - this.scale = scale; - this.players = players; - this.data = data; - } - - public int getMapId() { - return this.mapId; - } - - public byte getScale() { - return this.scale; - } - - public MapPlayer[] getPlayers() { - return this.players; - } - - public MapData getData() { - return this.data; - } - - @Override - public void read(NetInput in) throws IOException { - this.mapId = in.readVarInt(); - this.scale = in.readByte(); - this.players = new MapPlayer[in.readVarInt()]; - for(int index = 0; index < this.players.length; index++) { - int data = in.readUnsignedByte(); - int size = (data >> 4) & 15; - int rotation = data & 15; - int x = in.readUnsignedByte(); - int z = in.readUnsignedByte(); - this.players[index] = new MapPlayer(x, z, size, rotation); - } - - int columns = in.readUnsignedByte(); - if(columns > 0) { - int rows = in.readUnsignedByte(); - int x = in.readUnsignedByte(); - int y = in.readUnsignedByte(); - byte data[] = in.readBytes(in.readVarInt()); - this.data = new MapData(columns, rows, x, y, data); - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.mapId); - out.writeByte(this.scale); - out.writeVarInt(this.players.length); - for(int index = 0; index < this.players.length; index++) { - MapPlayer player = this.players[index]; - out.writeByte((player.getIconSize() & 15) << 4 | player.getIconRotation() & 15); - out.writeByte(player.getCenterX()); - out.writeByte(player.getCenterZ()); - } - - if(this.data != null && this.data.getColumns() != 0) { - out.writeByte(this.data.getColumns()); - out.writeByte(this.data.getRows()); - out.writeByte(this.data.getX()); - out.writeByte(this.data.getY()); - out.writeVarInt(this.data.getData().length); - out.writeBytes(this.data.getData()); - } else { - out.writeByte(0); - } - } - - @Override - public boolean isPriority() { - return false; - } + private int mapId; + private byte scale; + private MapPlayer players[]; + + private MapData data; + + @SuppressWarnings("unused") + private ServerMapDataPacket() { + } + + public ServerMapDataPacket(int mapId, byte scale, MapPlayer players[]) { + this(mapId, scale, players, null); + } + + public ServerMapDataPacket(int mapId, byte scale, MapPlayer players[], MapData data) { + this.mapId = mapId; + this.scale = scale; + this.players = players; + this.data = data; + } + + public int getMapId() { + return this.mapId; + } + + public byte getScale() { + return this.scale; + } + + public MapPlayer[] getPlayers() { + return this.players; + } + + public MapData getData() { + return this.data; + } + + @Override + public void read(NetInput in) throws IOException { + this.mapId = in.readVarInt(); + this.scale = in.readByte(); + this.players = new MapPlayer[in.readVarInt()]; + for(int index = 0; index < this.players.length; index++) { + int data = in.readUnsignedByte(); + int size = (data >> 4) & 15; + int rotation = data & 15; + int x = in.readUnsignedByte(); + int z = in.readUnsignedByte(); + this.players[index] = new MapPlayer(x, z, size, rotation); + } + + int columns = in.readUnsignedByte(); + if(columns > 0) { + int rows = in.readUnsignedByte(); + int x = in.readUnsignedByte(); + int y = in.readUnsignedByte(); + byte data[] = in.readBytes(in.readVarInt()); + this.data = new MapData(columns, rows, x, y, data); + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.mapId); + out.writeByte(this.scale); + out.writeVarInt(this.players.length); + for(int index = 0; index < this.players.length; index++) { + MapPlayer player = this.players[index]; + out.writeByte((player.getIconSize() & 15) << 4 | player.getIconRotation() & 15); + out.writeByte(player.getCenterX()); + out.writeByte(player.getCenterZ()); + } + + if(this.data != null && this.data.getColumns() != 0) { + out.writeByte(this.data.getColumns()); + out.writeByte(this.data.getRows()); + out.writeByte(this.data.getX()); + out.writeByte(this.data.getY()); + out.writeVarInt(this.data.getData().length); + out.writeBytes(this.data.getData()); + } else { + out.writeByte(0); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMultiBlockChangePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMultiBlockChangePacket.java index ed2f06e5d..bb925766c 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMultiBlockChangePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMultiBlockChangePacket.java @@ -10,55 +10,55 @@ public class ServerMultiBlockChangePacket implements Packet { - private BlockChangeRecord records[]; + private BlockChangeRecord records[]; - @SuppressWarnings("unused") - private ServerMultiBlockChangePacket() { - } + @SuppressWarnings("unused") + private ServerMultiBlockChangePacket() { + } - public ServerMultiBlockChangePacket(BlockChangeRecord... records) { - if(records == null || records.length == 0) { - throw new IllegalArgumentException("Records must contain at least 1 value."); - } + public ServerMultiBlockChangePacket(BlockChangeRecord... records) { + if(records == null || records.length == 0) { + throw new IllegalArgumentException("Records must contain at least 1 value."); + } - this.records = records; - } + this.records = records; + } - public BlockChangeRecord[] getRecords() { - return this.records; - } + public BlockChangeRecord[] getRecords() { + return this.records; + } - @Override - public void read(NetInput in) throws IOException { - int chunkX = in.readInt(); - int chunkZ = in.readInt(); - this.records = new BlockChangeRecord[in.readVarInt()]; - for(int index = 0; index < this.records.length; index++) { - short pos = in.readShort(); - int block = in.readVarInt(); - int x = (chunkX << 4) + (pos >> 12 & 15); - int y = pos & 255; - int z = (chunkZ << 4) + (pos >> 8 & 15); - this.records[index] = new BlockChangeRecord(new Position(x, y, z), block); - } - } + @Override + public void read(NetInput in) throws IOException { + int chunkX = in.readInt(); + int chunkZ = in.readInt(); + this.records = new BlockChangeRecord[in.readVarInt()]; + for(int index = 0; index < this.records.length; index++) { + short pos = in.readShort(); + int block = in.readVarInt(); + int x = (chunkX << 4) + (pos >> 12 & 15); + int y = pos & 255; + int z = (chunkZ << 4) + (pos >> 8 & 15); + this.records[index] = new BlockChangeRecord(new Position(x, y, z), block); + } + } - @Override - public void write(NetOutput out) throws IOException { - int chunkX = this.records[0].getPosition().getX() >> 4; - int chunkZ = this.records[0].getPosition().getZ() >> 4; - out.writeInt(chunkX); - out.writeInt(chunkZ); - out.writeVarInt(this.records.length); - for(BlockChangeRecord record : this.records) { - out.writeShort((record.getPosition().getX() - (chunkX << 4)) << 12 | (record.getPosition().getZ() - (chunkZ << 4)) << 8 | record.getPosition().getY()); - out.writeVarInt(record.getBlock()); - } - } + @Override + public void write(NetOutput out) throws IOException { + int chunkX = this.records[0].getPosition().getX() >> 4; + int chunkZ = this.records[0].getPosition().getZ() >> 4; + out.writeInt(chunkX); + out.writeInt(chunkZ); + out.writeVarInt(this.records.length); + for(BlockChangeRecord record : this.records) { + out.writeShort((record.getPosition().getX() - (chunkX << 4)) << 12 | (record.getPosition().getZ() - (chunkZ << 4)) << 8 | record.getPosition().getY()); + out.writeVarInt(record.getBlock()); + } + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMultiChunkDataPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMultiChunkDataPacket.java index ea6d921dc..110abf4ed 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMultiChunkDataPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerMultiChunkDataPacket.java @@ -12,127 +12,127 @@ public class ServerMultiChunkDataPacket implements Packet { - private int x[]; - private int z[]; - private Chunk chunks[][]; - private byte biomeData[][]; - - @SuppressWarnings("unused") - private ServerMultiChunkDataPacket() { - } - - public ServerMultiChunkDataPacket(int x[], int z[], Chunk chunks[][], byte biomeData[][]) { - if(biomeData == null) { - throw new IllegalArgumentException("BiomeData cannot be null."); - } - - if(x.length != chunks.length || z.length != chunks.length) { - throw new IllegalArgumentException("X, Z, and Chunk arrays must be equal in length."); - } - - boolean noSkylight = false; - boolean skylight = false; - for(int index = 0; index < chunks.length; index++) { - Chunk column[] = chunks[index]; - if(column.length != 16) { - throw new IllegalArgumentException("Chunk columns must contain 16 chunks each."); - } - - for(int y = 0; y < column.length; y++) { - if(column[y] != null) { - if(column[y].getSkyLight() == null) { - noSkylight = true; - } else { - skylight = true; - } - } - } - } - - if(noSkylight && skylight) { - throw new IllegalArgumentException("Either all chunks must have skylight values or none must have them."); - } - - this.x = x; - this.z = z; - this.chunks = chunks; - this.biomeData = biomeData; - } - - public int getColumns() { - return this.chunks.length; - } - - public int getX(int column) { - return this.x[column]; - } - - public int getZ(int column) { - return this.z[column]; - } - - public Chunk[] getChunks(int column) { - return this.chunks[column]; - } - - public byte[] getBiomeData(int column) { - return this.biomeData[column]; - } - - @Override - public void read(NetInput in) throws IOException { - boolean skylight = in.readBoolean(); - int columns = in.readVarInt(); - this.x = new int[columns]; - this.z = new int[columns]; - this.chunks = new Chunk[columns][]; - this.biomeData = new byte[columns][]; - NetworkChunkData[] data = new NetworkChunkData[columns]; - for(int column = 0; column < columns; column++) { - this.x[column] = in.readInt(); - this.z[column] = in.readInt(); - int mask = in.readUnsignedShort(); - int chunks = Integer.bitCount(mask); - int length = (chunks * ((4096 * 2) + 2048)) + (skylight ? chunks * 2048 : 0) + 256; - byte dat[] = new byte[length]; - data[column] = new NetworkChunkData(mask, true, skylight, dat); - } - - for(int column = 0; column < columns; column++) { - in.readBytes(data[column].getData()); - ParsedChunkData chunkData = NetUtil.dataToChunks(data[column], false); - this.chunks[column] = chunkData.getChunks(); - this.biomeData[column] = chunkData.getBiomes(); - } - } - - @Override - public void write(NetOutput out) throws IOException { - boolean skylight = false; - NetworkChunkData data[] = new NetworkChunkData[this.chunks.length]; - for(int column = 0; column < this.chunks.length; column++) { - data[column] = NetUtil.chunksToData(new ParsedChunkData(this.chunks[column], this.biomeData[column])); - if(data[column].hasSkyLight()) { - skylight = true; - } - } - - out.writeBoolean(skylight); - out.writeVarInt(this.chunks.length); - for(int column = 0; column < this.x.length; column++) { - out.writeInt(this.x[column]); - out.writeInt(this.z[column]); - out.writeShort(data[column].getMask()); - } - - for(int column = 0; column < this.x.length; column++) { - out.writeBytes(data[column].getData()); - } - } - - @Override - public boolean isPriority() { - return false; - } + private int x[]; + private int z[]; + private Chunk chunks[][]; + private byte biomeData[][]; + + @SuppressWarnings("unused") + private ServerMultiChunkDataPacket() { + } + + public ServerMultiChunkDataPacket(int x[], int z[], Chunk chunks[][], byte biomeData[][]) { + if(biomeData == null) { + throw new IllegalArgumentException("BiomeData cannot be null."); + } + + if(x.length != chunks.length || z.length != chunks.length) { + throw new IllegalArgumentException("X, Z, and Chunk arrays must be equal in length."); + } + + boolean noSkylight = false; + boolean skylight = false; + for(int index = 0; index < chunks.length; index++) { + Chunk column[] = chunks[index]; + if(column.length != 16) { + throw new IllegalArgumentException("Chunk columns must contain 16 chunks each."); + } + + for(int y = 0; y < column.length; y++) { + if(column[y] != null) { + if(column[y].getSkyLight() == null) { + noSkylight = true; + } else { + skylight = true; + } + } + } + } + + if(noSkylight && skylight) { + throw new IllegalArgumentException("Either all chunks must have skylight values or none must have them."); + } + + this.x = x; + this.z = z; + this.chunks = chunks; + this.biomeData = biomeData; + } + + public int getColumns() { + return this.chunks.length; + } + + public int getX(int column) { + return this.x[column]; + } + + public int getZ(int column) { + return this.z[column]; + } + + public Chunk[] getChunks(int column) { + return this.chunks[column]; + } + + public byte[] getBiomeData(int column) { + return this.biomeData[column]; + } + + @Override + public void read(NetInput in) throws IOException { + boolean skylight = in.readBoolean(); + int columns = in.readVarInt(); + this.x = new int[columns]; + this.z = new int[columns]; + this.chunks = new Chunk[columns][]; + this.biomeData = new byte[columns][]; + NetworkChunkData[] data = new NetworkChunkData[columns]; + for(int column = 0; column < columns; column++) { + this.x[column] = in.readInt(); + this.z[column] = in.readInt(); + int mask = in.readUnsignedShort(); + int chunks = Integer.bitCount(mask); + int length = (chunks * ((4096 * 2) + 2048)) + (skylight ? chunks * 2048 : 0) + 256; + byte dat[] = new byte[length]; + data[column] = new NetworkChunkData(mask, true, skylight, dat); + } + + for(int column = 0; column < columns; column++) { + in.readBytes(data[column].getData()); + ParsedChunkData chunkData = NetUtil.dataToChunks(data[column], false); + this.chunks[column] = chunkData.getChunks(); + this.biomeData[column] = chunkData.getBiomes(); + } + } + + @Override + public void write(NetOutput out) throws IOException { + boolean skylight = false; + NetworkChunkData data[] = new NetworkChunkData[this.chunks.length]; + for(int column = 0; column < this.chunks.length; column++) { + data[column] = NetUtil.chunksToData(new ParsedChunkData(this.chunks[column], this.biomeData[column])); + if(data[column].hasSkyLight()) { + skylight = true; + } + } + + out.writeBoolean(skylight); + out.writeVarInt(this.chunks.length); + for(int column = 0; column < this.x.length; column++) { + out.writeInt(this.x[column]); + out.writeInt(this.z[column]); + out.writeShort(data[column].getMask()); + } + + for(int column = 0; column < this.x.length; column++) { + out.writeBytes(data[column].getData()); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerNotifyClientPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerNotifyClientPacket.java index 46a9c39c5..f9f671892 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerNotifyClientPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerNotifyClientPacket.java @@ -2,7 +2,11 @@ import org.spacehq.mc.protocol.data.game.values.MagicValues; import org.spacehq.mc.protocol.data.game.values.entity.player.GameMode; -import org.spacehq.mc.protocol.data.game.values.world.notify.*; +import org.spacehq.mc.protocol.data.game.values.world.notify.ClientNotification; +import org.spacehq.mc.protocol.data.game.values.world.notify.ClientNotificationValue; +import org.spacehq.mc.protocol.data.game.values.world.notify.DemoMessageValue; +import org.spacehq.mc.protocol.data.game.values.world.notify.RainStrengthValue; +import org.spacehq.mc.protocol.data.game.values.world.notify.ThunderStrengthValue; import org.spacehq.packetlib.io.NetInput; import org.spacehq.packetlib.io.NetOutput; import org.spacehq.packetlib.packet.Packet; @@ -11,67 +15,67 @@ public class ServerNotifyClientPacket implements Packet { - private ClientNotification notification; - private ClientNotificationValue value; - - @SuppressWarnings("unused") - private ServerNotifyClientPacket() { - } - - public ServerNotifyClientPacket(ClientNotification notification, ClientNotificationValue value) { - this.notification = notification; - this.value = value; - } - - public ClientNotification getNotification() { - return this.notification; - } - - public ClientNotificationValue getValue() { - return this.value; - } - - @Override - public void read(NetInput in) throws IOException { - this.notification = MagicValues.key(ClientNotification.class, in.readUnsignedByte()); - float value = in.readFloat(); - if(this.notification == ClientNotification.CHANGE_GAMEMODE) { - this.value = MagicValues.key(GameMode.class, (int) value); - } else if(this.notification == ClientNotification.DEMO_MESSAGE) { - this.value = MagicValues.key(DemoMessageValue.class, (int) value); - } else if(this.notification == ClientNotification.RAIN_STRENGTH) { - this.value = new RainStrengthValue(value); - } else if(this.notification == ClientNotification.THUNDER_STRENGTH) { - this.value = new ThunderStrengthValue(value); - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeByte(MagicValues.value(Integer.class, this.notification)); - float value = 0; - if(this.value instanceof GameMode) { - value = MagicValues.value(Integer.class, (Enum) this.value); - } - - if(this.value instanceof DemoMessageValue) { - value = MagicValues.value(Integer.class, (Enum) this.value); - } - - if(this.value instanceof RainStrengthValue) { - value = ((RainStrengthValue) this.value).getStrength(); - } - - if(this.value instanceof ThunderStrengthValue) { - value = ((ThunderStrengthValue) this.value).getStrength(); - } - - out.writeFloat(value); - } - - @Override - public boolean isPriority() { - return false; - } + private ClientNotification notification; + private ClientNotificationValue value; + + @SuppressWarnings("unused") + private ServerNotifyClientPacket() { + } + + public ServerNotifyClientPacket(ClientNotification notification, ClientNotificationValue value) { + this.notification = notification; + this.value = value; + } + + public ClientNotification getNotification() { + return this.notification; + } + + public ClientNotificationValue getValue() { + return this.value; + } + + @Override + public void read(NetInput in) throws IOException { + this.notification = MagicValues.key(ClientNotification.class, in.readUnsignedByte()); + float value = in.readFloat(); + if(this.notification == ClientNotification.CHANGE_GAMEMODE) { + this.value = MagicValues.key(GameMode.class, (int) value); + } else if(this.notification == ClientNotification.DEMO_MESSAGE) { + this.value = MagicValues.key(DemoMessageValue.class, (int) value); + } else if(this.notification == ClientNotification.RAIN_STRENGTH) { + this.value = new RainStrengthValue(value); + } else if(this.notification == ClientNotification.THUNDER_STRENGTH) { + this.value = new ThunderStrengthValue(value); + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(MagicValues.value(Integer.class, this.notification)); + float value = 0; + if(this.value instanceof GameMode) { + value = MagicValues.value(Integer.class, (Enum) this.value); + } + + if(this.value instanceof DemoMessageValue) { + value = MagicValues.value(Integer.class, (Enum) this.value); + } + + if(this.value instanceof RainStrengthValue) { + value = ((RainStrengthValue) this.value).getStrength(); + } + + if(this.value instanceof ThunderStrengthValue) { + value = ((ThunderStrengthValue) this.value).getStrength(); + } + + out.writeFloat(value); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerOpenTileEntityEditorPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerOpenTileEntityEditorPacket.java index f9a6d1367..eaa77ecd5 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerOpenTileEntityEditorPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerOpenTileEntityEditorPacket.java @@ -10,33 +10,33 @@ public class ServerOpenTileEntityEditorPacket implements Packet { - private Position position; - - @SuppressWarnings("unused") - private ServerOpenTileEntityEditorPacket() { - } - - public ServerOpenTileEntityEditorPacket(Position position) { - this.position = position; - } - - public Position getPosition() { - return this.position; - } - - @Override - public void read(NetInput in) throws IOException { - this.position = NetUtil.readPosition(in); - } - - @Override - public void write(NetOutput out) throws IOException { - NetUtil.writePosition(out, this.position); - } - - @Override - public boolean isPriority() { - return false; - } + private Position position; + + @SuppressWarnings("unused") + private ServerOpenTileEntityEditorPacket() { + } + + public ServerOpenTileEntityEditorPacket(Position position) { + this.position = position; + } + + public Position getPosition() { + return this.position; + } + + @Override + public void read(NetInput in) throws IOException { + this.position = NetUtil.readPosition(in); + } + + @Override + public void write(NetOutput out) throws IOException { + NetUtil.writePosition(out, this.position); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlayEffectPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlayEffectPacket.java index 0002bfcdb..8e8cd28d2 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlayEffectPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlayEffectPacket.java @@ -2,7 +2,15 @@ import org.spacehq.mc.protocol.data.game.Position; import org.spacehq.mc.protocol.data.game.values.MagicValues; -import org.spacehq.mc.protocol.data.game.values.world.effect.*; +import org.spacehq.mc.protocol.data.game.values.world.effect.BreakBlockEffectData; +import org.spacehq.mc.protocol.data.game.values.world.effect.BreakPotionEffectData; +import org.spacehq.mc.protocol.data.game.values.world.effect.HardLandingEffectData; +import org.spacehq.mc.protocol.data.game.values.world.effect.ParticleEffect; +import org.spacehq.mc.protocol.data.game.values.world.effect.RecordEffectData; +import org.spacehq.mc.protocol.data.game.values.world.effect.SmokeEffectData; +import org.spacehq.mc.protocol.data.game.values.world.effect.SoundEffect; +import org.spacehq.mc.protocol.data.game.values.world.effect.WorldEffect; +import org.spacehq.mc.protocol.data.game.values.world.effect.WorldEffectData; import org.spacehq.mc.protocol.util.NetUtil; import org.spacehq.packetlib.io.NetInput; import org.spacehq.packetlib.io.NetOutput; @@ -12,99 +20,99 @@ public class ServerPlayEffectPacket implements Packet { - private WorldEffect effect; - private Position position; - private WorldEffectData data; - private boolean broadcast; - - @SuppressWarnings("unused") - private ServerPlayEffectPacket() { - } - - public ServerPlayEffectPacket(WorldEffect effect, Position position, WorldEffectData data) { - this(effect, position, data, false); - } - - public ServerPlayEffectPacket(WorldEffect effect, Position position, WorldEffectData data, boolean broadcast) { - this.effect = effect; - this.position = position; - this.data = data; - this.broadcast = broadcast; - } - - public WorldEffect getEffect() { - return this.effect; - } - - public Position getPosition() { - return this.position; - } - - public WorldEffectData getData() { - return this.data; - } - - public boolean getBroadcast() { - return this.broadcast; - } - - @Override - public void read(NetInput in) throws IOException { - int id = in.readInt(); - if(id >= 2000) { - this.effect = MagicValues.key(ParticleEffect.class, id); - } else { - this.effect = MagicValues.key(SoundEffect.class, id); - } - - this.position = NetUtil.readPosition(in); - int value = in.readInt(); - if(this.effect == SoundEffect.PLAY_RECORD) { - this.data = new RecordEffectData(value); - } else if(this.effect == ParticleEffect.SMOKE) { - this.data = MagicValues.key(SmokeEffectData.class, value); - } else if(this.effect == ParticleEffect.BREAK_BLOCK) { - this.data = new BreakBlockEffectData(value); - } else if(this.effect == ParticleEffect.BREAK_SPLASH_POTION) { - this.data = new BreakPotionEffectData(value); - } else if(this.effect == ParticleEffect.HARD_LANDING_DUST) { - this.data = new HardLandingEffectData(value); - } - - this.broadcast = in.readBoolean(); - } - - @Override - public void write(NetOutput out) throws IOException { - int id = 0; - if(this.effect instanceof ParticleEffect) { - id = MagicValues.value(Integer.class, (ParticleEffect) this.effect); - } else if(this.effect instanceof SoundEffect) { - id = MagicValues.value(Integer.class, (SoundEffect) this.effect); - } - - out.writeInt(id); - NetUtil.writePosition(out, this.position); - int value = 0; - if(this.data instanceof RecordEffectData) { - value = ((RecordEffectData) this.data).getRecordId(); - } else if(this.data instanceof SmokeEffectData) { - value = MagicValues.value(Integer.class, (SmokeEffectData) this.data); - } else if(this.data instanceof BreakBlockEffectData) { - value = ((BreakBlockEffectData) this.data).getBlockId(); - } else if(this.data instanceof BreakPotionEffectData) { - value = ((BreakPotionEffectData) this.data).getPotionId(); - } else if(this.data instanceof HardLandingEffectData) { - value = ((HardLandingEffectData) this.data).getDamagingDistance(); - } - - out.writeInt(value); - out.writeBoolean(this.broadcast); - } - - @Override - public boolean isPriority() { - return false; - } + private WorldEffect effect; + private Position position; + private WorldEffectData data; + private boolean broadcast; + + @SuppressWarnings("unused") + private ServerPlayEffectPacket() { + } + + public ServerPlayEffectPacket(WorldEffect effect, Position position, WorldEffectData data) { + this(effect, position, data, false); + } + + public ServerPlayEffectPacket(WorldEffect effect, Position position, WorldEffectData data, boolean broadcast) { + this.effect = effect; + this.position = position; + this.data = data; + this.broadcast = broadcast; + } + + public WorldEffect getEffect() { + return this.effect; + } + + public Position getPosition() { + return this.position; + } + + public WorldEffectData getData() { + return this.data; + } + + public boolean getBroadcast() { + return this.broadcast; + } + + @Override + public void read(NetInput in) throws IOException { + int id = in.readInt(); + if(id >= 2000) { + this.effect = MagicValues.key(ParticleEffect.class, id); + } else { + this.effect = MagicValues.key(SoundEffect.class, id); + } + + this.position = NetUtil.readPosition(in); + int value = in.readInt(); + if(this.effect == SoundEffect.PLAY_RECORD) { + this.data = new RecordEffectData(value); + } else if(this.effect == ParticleEffect.SMOKE) { + this.data = MagicValues.key(SmokeEffectData.class, value); + } else if(this.effect == ParticleEffect.BREAK_BLOCK) { + this.data = new BreakBlockEffectData(value); + } else if(this.effect == ParticleEffect.BREAK_SPLASH_POTION) { + this.data = new BreakPotionEffectData(value); + } else if(this.effect == ParticleEffect.HARD_LANDING_DUST) { + this.data = new HardLandingEffectData(value); + } + + this.broadcast = in.readBoolean(); + } + + @Override + public void write(NetOutput out) throws IOException { + int id = 0; + if(this.effect instanceof ParticleEffect) { + id = MagicValues.value(Integer.class, (ParticleEffect) this.effect); + } else if(this.effect instanceof SoundEffect) { + id = MagicValues.value(Integer.class, (SoundEffect) this.effect); + } + + out.writeInt(id); + NetUtil.writePosition(out, this.position); + int value = 0; + if(this.data instanceof RecordEffectData) { + value = ((RecordEffectData) this.data).getRecordId(); + } else if(this.data instanceof SmokeEffectData) { + value = MagicValues.value(Integer.class, (SmokeEffectData) this.data); + } else if(this.data instanceof BreakBlockEffectData) { + value = ((BreakBlockEffectData) this.data).getBlockId(); + } else if(this.data instanceof BreakPotionEffectData) { + value = ((BreakPotionEffectData) this.data).getPotionId(); + } else if(this.data instanceof HardLandingEffectData) { + value = ((HardLandingEffectData) this.data).getDamagingDistance(); + } + + out.writeInt(value); + out.writeBoolean(this.broadcast); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlaySoundPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlaySoundPacket.java index ef7e709ae..afce8ffc7 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlaySoundPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerPlaySoundPacket.java @@ -12,94 +12,94 @@ public class ServerPlaySoundPacket implements Packet { - private Sound sound; - private double x; - private double y; - private double z; - private float volume; - private float pitch; - - @SuppressWarnings("unused") - private ServerPlaySoundPacket() { - } - - public ServerPlaySoundPacket(Sound sound, double x, double y, double z, float volume, float pitch) { - this.sound = sound; - this.x = x; - this.y = y; - this.z = z; - this.volume = volume; - this.pitch = pitch; - } - - public Sound getSound() { - return this.sound; - } - - public double getX() { - return this.x; - } - - public double getY() { - return this.y; - } - - public double getZ() { - return this.z; - } - - public float getVolume() { - return this.volume; - } - - public float getPitch() { - return this.pitch; - } - - @Override - public void read(NetInput in) throws IOException { - String value = in.readString(); - this.sound = MagicValues.key(GenericSound.class, value); - if(this.sound == null) { - this.sound = new CustomSound(value); - } - - this.x = in.readInt() / 8D; - this.y = in.readInt() / 8D; - this.z = in.readInt() / 8D; - this.volume = in.readFloat(); - this.pitch = in.readUnsignedByte() / 63f; - } - - @Override - public void write(NetOutput out) throws IOException { - String value = ""; - if(this.sound instanceof CustomSound) { - value = ((CustomSound) this.sound).getName(); - } else if(this.sound instanceof GenericSound) { - value = MagicValues.value(String.class, (GenericSound) this.sound); - } - - out.writeString(value); - out.writeInt((int) (this.x * 8)); - out.writeInt((int) (this.y * 8)); - out.writeInt((int) (this.z * 8)); - out.writeFloat(this.volume); - int pitch = (int) (this.pitch * 63); - if(pitch > 255) { - pitch = 255; - } - - if(pitch < 0) { - pitch = 0; - } - - out.writeByte(pitch); - } - - @Override - public boolean isPriority() { - return false; - } + private Sound sound; + private double x; + private double y; + private double z; + private float volume; + private float pitch; + + @SuppressWarnings("unused") + private ServerPlaySoundPacket() { + } + + public ServerPlaySoundPacket(Sound sound, double x, double y, double z, float volume, float pitch) { + this.sound = sound; + this.x = x; + this.y = y; + this.z = z; + this.volume = volume; + this.pitch = pitch; + } + + public Sound getSound() { + return this.sound; + } + + public double getX() { + return this.x; + } + + public double getY() { + return this.y; + } + + public double getZ() { + return this.z; + } + + public float getVolume() { + return this.volume; + } + + public float getPitch() { + return this.pitch; + } + + @Override + public void read(NetInput in) throws IOException { + String value = in.readString(); + this.sound = MagicValues.key(GenericSound.class, value); + if(this.sound == null) { + this.sound = new CustomSound(value); + } + + this.x = in.readInt() / 8D; + this.y = in.readInt() / 8D; + this.z = in.readInt() / 8D; + this.volume = in.readFloat(); + this.pitch = in.readUnsignedByte() / 63f; + } + + @Override + public void write(NetOutput out) throws IOException { + String value = ""; + if(this.sound instanceof CustomSound) { + value = ((CustomSound) this.sound).getName(); + } else if(this.sound instanceof GenericSound) { + value = MagicValues.value(String.class, (GenericSound) this.sound); + } + + out.writeString(value); + out.writeInt((int) (this.x * 8)); + out.writeInt((int) (this.y * 8)); + out.writeInt((int) (this.z * 8)); + out.writeFloat(this.volume); + int pitch = (int) (this.pitch * 63); + if(pitch > 255) { + pitch = 255; + } + + if(pitch < 0) { + pitch = 0; + } + + out.writeByte(pitch); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerSpawnParticlePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerSpawnParticlePacket.java index a2b00483c..65ace6db3 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerSpawnParticlePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerSpawnParticlePacket.java @@ -9,120 +9,120 @@ import java.io.IOException; public class ServerSpawnParticlePacket implements Packet { - private Particle particle; - private boolean longDistance; - private float x; - private float y; - private float z; - private float offsetX; - private float offsetY; - private float offsetZ; - private float velocityOffset; - private int amount; - private int data[]; - - @SuppressWarnings("unused") - private ServerSpawnParticlePacket() { - } - - public ServerSpawnParticlePacket(Particle particle, boolean longDistance, float x, float y, float z, float offsetX, float offsetY, float offsetZ, float velocityOffset, int amount, int... data) { - this.particle = particle; - this.longDistance = longDistance; - this.x = x; - this.y = y; - this.z = z; - this.offsetX = offsetX; - this.offsetY = offsetY; - this.offsetZ = offsetZ; - this.velocityOffset = velocityOffset; - this.amount = amount; - this.data = data; - if(this.data.length != particle.getDataLength()) { - throw new IllegalArgumentException("Data array length must be equal to particle's data length."); - } - } - - public Particle getParticle() { - return this.particle; - } - - public boolean isLongDistance() { - return this.longDistance; - } - - public float getX() { - return this.x; - } - - public float getY() { - return this.y; - } - - public float getZ() { - return this.z; - } - - public float getOffsetX() { - return this.offsetX; - } - - public float getOffsetY() { - return this.offsetY; - } - - public float getOffsetZ() { - return this.offsetZ; - } - - public float getVelocityOffset() { - return this.velocityOffset; - } - - public int getAmount() { - return this.amount; - } - - public int[] getData() { - return this.data; - } - - @Override - public void read(NetInput in) throws IOException { - this.particle = MagicValues.key(Particle.class, in.readInt()); - this.longDistance = in.readBoolean(); - this.x = in.readFloat(); - this.y = in.readFloat(); - this.z = in.readFloat(); - this.offsetX = in.readFloat(); - this.offsetY = in.readFloat(); - this.offsetZ = in.readFloat(); - this.velocityOffset = in.readFloat(); - this.amount = in.readInt(); - this.data = new int[this.particle.getDataLength()]; - for(int index = 0; index < this.data.length; index++) { - this.data[index] = in.readVarInt(); - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeInt(MagicValues.value(Integer.class, this.particle)); - out.writeBoolean(this.longDistance); - out.writeFloat(this.x); - out.writeFloat(this.y); - out.writeFloat(this.z); - out.writeFloat(this.offsetX); - out.writeFloat(this.offsetY); - out.writeFloat(this.offsetZ); - out.writeFloat(this.velocityOffset); - out.writeInt(this.amount); - for(int index = 0; index < this.particle.getDataLength(); index++) { - out.writeVarInt(this.data[index]); - } - } - - @Override - public boolean isPriority() { - return false; - } + private Particle particle; + private boolean longDistance; + private float x; + private float y; + private float z; + private float offsetX; + private float offsetY; + private float offsetZ; + private float velocityOffset; + private int amount; + private int data[]; + + @SuppressWarnings("unused") + private ServerSpawnParticlePacket() { + } + + public ServerSpawnParticlePacket(Particle particle, boolean longDistance, float x, float y, float z, float offsetX, float offsetY, float offsetZ, float velocityOffset, int amount, int... data) { + this.particle = particle; + this.longDistance = longDistance; + this.x = x; + this.y = y; + this.z = z; + this.offsetX = offsetX; + this.offsetY = offsetY; + this.offsetZ = offsetZ; + this.velocityOffset = velocityOffset; + this.amount = amount; + this.data = data; + if(this.data.length != particle.getDataLength()) { + throw new IllegalArgumentException("Data array length must be equal to particle's data length."); + } + } + + public Particle getParticle() { + return this.particle; + } + + public boolean isLongDistance() { + return this.longDistance; + } + + public float getX() { + return this.x; + } + + public float getY() { + return this.y; + } + + public float getZ() { + return this.z; + } + + public float getOffsetX() { + return this.offsetX; + } + + public float getOffsetY() { + return this.offsetY; + } + + public float getOffsetZ() { + return this.offsetZ; + } + + public float getVelocityOffset() { + return this.velocityOffset; + } + + public int getAmount() { + return this.amount; + } + + public int[] getData() { + return this.data; + } + + @Override + public void read(NetInput in) throws IOException { + this.particle = MagicValues.key(Particle.class, in.readInt()); + this.longDistance = in.readBoolean(); + this.x = in.readFloat(); + this.y = in.readFloat(); + this.z = in.readFloat(); + this.offsetX = in.readFloat(); + this.offsetY = in.readFloat(); + this.offsetZ = in.readFloat(); + this.velocityOffset = in.readFloat(); + this.amount = in.readInt(); + this.data = new int[this.particle.getDataLength()]; + for(int index = 0; index < this.data.length; index++) { + this.data[index] = in.readVarInt(); + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeInt(MagicValues.value(Integer.class, this.particle)); + out.writeBoolean(this.longDistance); + out.writeFloat(this.x); + out.writeFloat(this.y); + out.writeFloat(this.z); + out.writeFloat(this.offsetX); + out.writeFloat(this.offsetY); + out.writeFloat(this.offsetZ); + out.writeFloat(this.velocityOffset); + out.writeInt(this.amount); + for(int index = 0; index < this.particle.getDataLength(); index++) { + out.writeVarInt(this.data[index]); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerSpawnPositionPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerSpawnPositionPacket.java index 685b18896..755c5196e 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerSpawnPositionPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerSpawnPositionPacket.java @@ -10,33 +10,33 @@ public class ServerSpawnPositionPacket implements Packet { - private Position position; - - @SuppressWarnings("unused") - private ServerSpawnPositionPacket() { - } - - public ServerSpawnPositionPacket(Position position) { - this.position = position; - } - - public Position getPosition() { - return this.position; - } - - @Override - public void read(NetInput in) throws IOException { - this.position = NetUtil.readPosition(in); - } - - @Override - public void write(NetOutput out) throws IOException { - NetUtil.writePosition(out, this.position); - } - - @Override - public boolean isPriority() { - return false; - } + private Position position; + + @SuppressWarnings("unused") + private ServerSpawnPositionPacket() { + } + + public ServerSpawnPositionPacket(Position position) { + this.position = position; + } + + public Position getPosition() { + return this.position; + } + + @Override + public void read(NetInput in) throws IOException { + this.position = NetUtil.readPosition(in); + } + + @Override + public void write(NetOutput out) throws IOException { + NetUtil.writePosition(out, this.position); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateSignPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateSignPacket.java index c398b2be6..cf16f8f4a 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateSignPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateSignPacket.java @@ -10,62 +10,62 @@ import java.io.IOException; public class ServerUpdateSignPacket implements Packet { - private Position position; - private Message lines[]; + private Position position; + private Message lines[]; - @SuppressWarnings("unused") - private ServerUpdateSignPacket() { - } + @SuppressWarnings("unused") + private ServerUpdateSignPacket() { + } - public ServerUpdateSignPacket(Position position, String lines[]) { - this(position, toMessages(lines)); - } + public ServerUpdateSignPacket(Position position, String lines[]) { + this(position, toMessages(lines)); + } - public ServerUpdateSignPacket(Position position, Message lines[]) { - if(lines.length != 4) { - throw new IllegalArgumentException("Lines must contain exactly 4 strings!"); - } + public ServerUpdateSignPacket(Position position, Message lines[]) { + if(lines.length != 4) { + throw new IllegalArgumentException("Lines must contain exactly 4 strings!"); + } - this.position = position; - this.lines = lines; - } + this.position = position; + this.lines = lines; + } - public Position getPosition() { - return this.position; - } + public Position getPosition() { + return this.position; + } - public Message[] getLines() { - return this.lines; - } + public Message[] getLines() { + return this.lines; + } - @Override - public void read(NetInput in) throws IOException { - this.position = NetUtil.readPosition(in); - this.lines = new Message[4]; - for(int count = 0; count < this.lines.length; count++) { - this.lines[count] = Message.fromString(in.readString()); - } - } + @Override + public void read(NetInput in) throws IOException { + this.position = NetUtil.readPosition(in); + this.lines = new Message[4]; + for(int count = 0; count < this.lines.length; count++) { + this.lines[count] = Message.fromString(in.readString()); + } + } - @Override - public void write(NetOutput out) throws IOException { - NetUtil.writePosition(out, this.position); - for(Message line : this.lines) { - out.writeString(line.toJsonString()); - } - } + @Override + public void write(NetOutput out) throws IOException { + NetUtil.writePosition(out, this.position); + for(Message line : this.lines) { + out.writeString(line.toJsonString()); + } + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } - private static Message[] toMessages(String lines[]) { - Message messages[] = new Message[lines.length]; - for(int index = 0; index < lines.length; index++) { - messages[index] = Message.fromString(lines[index]); - } + private static Message[] toMessages(String lines[]) { + Message messages[] = new Message[lines.length]; + for(int index = 0; index < lines.length; index++) { + messages[index] = Message.fromString(lines[index]); + } - return messages; - } + return messages; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateTileEntityPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateTileEntityPacket.java index d142bcf6f..c96c94b5b 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateTileEntityPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateTileEntityPacket.java @@ -13,49 +13,49 @@ public class ServerUpdateTileEntityPacket implements Packet { - private Position position; - private UpdatedTileType type; - private CompoundTag nbt; - - @SuppressWarnings("unused") - private ServerUpdateTileEntityPacket() { - } - - public ServerUpdateTileEntityPacket(int breakerEntityId, Position position, UpdatedTileType type, CompoundTag nbt) { - this.position = position; - this.type = type; - this.nbt = nbt; - } - - public Position getPosition() { - return this.position; - } - - public UpdatedTileType getType() { - return this.type; - } - - public CompoundTag getNBT() { - return this.nbt; - } - - @Override - public void read(NetInput in) throws IOException { - this.position = NetUtil.readPosition(in); - this.type = MagicValues.key(UpdatedTileType.class, in.readUnsignedByte()); - this.nbt = NetUtil.readNBT(in); - } - - @Override - public void write(NetOutput out) throws IOException { - NetUtil.writePosition(out, this.position); - out.writeByte(MagicValues.value(Integer.class, this.type)); - NetUtil.writeNBT(out, this.nbt); - } - - @Override - public boolean isPriority() { - return false; - } + private Position position; + private UpdatedTileType type; + private CompoundTag nbt; + + @SuppressWarnings("unused") + private ServerUpdateTileEntityPacket() { + } + + public ServerUpdateTileEntityPacket(int breakerEntityId, Position position, UpdatedTileType type, CompoundTag nbt) { + this.position = position; + this.type = type; + this.nbt = nbt; + } + + public Position getPosition() { + return this.position; + } + + public UpdatedTileType getType() { + return this.type; + } + + public CompoundTag getNBT() { + return this.nbt; + } + + @Override + public void read(NetInput in) throws IOException { + this.position = NetUtil.readPosition(in); + this.type = MagicValues.key(UpdatedTileType.class, in.readUnsignedByte()); + this.nbt = NetUtil.readNBT(in); + } + + @Override + public void write(NetOutput out) throws IOException { + NetUtil.writePosition(out, this.position); + out.writeByte(MagicValues.value(Integer.class, this.type)); + NetUtil.writeNBT(out, this.nbt); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateTimePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateTimePacket.java index d6cfa7b0a..1b7917513 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateTimePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerUpdateTimePacket.java @@ -8,41 +8,41 @@ public class ServerUpdateTimePacket implements Packet { - private long age; - private long time; - - @SuppressWarnings("unused") - private ServerUpdateTimePacket() { - } - - public ServerUpdateTimePacket(long age, long time) { - this.age = age; - this.time = time; - } - - public long getWorldAge() { - return this.age; - } - - public long getTime() { - return this.time; - } - - @Override - public void read(NetInput in) throws IOException { - this.age = in.readLong(); - this.time = in.readLong(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeLong(this.age); - out.writeLong(this.time); - } - - @Override - public boolean isPriority() { - return false; - } + private long age; + private long time; + + @SuppressWarnings("unused") + private ServerUpdateTimePacket() { + } + + public ServerUpdateTimePacket(long age, long time) { + this.age = age; + this.time = time; + } + + public long getWorldAge() { + return this.age; + } + + public long getTime() { + return this.time; + } + + @Override + public void read(NetInput in) throws IOException { + this.age = in.readLong(); + this.time = in.readLong(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeLong(this.age); + out.writeLong(this.time); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java index 00fb6d3a0..9a7931e7c 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java @@ -10,166 +10,166 @@ public class ServerWorldBorderPacket implements Packet { - private WorldBorderAction action; - - private double radius; - - private double oldRadius; - private double newRadius; - private long speed; - - private double centerX; - private double centerY; - - private int portalTeleportBoundary; - - private int warningTime; - - private int warningBlocks; - - @SuppressWarnings("unused") - private ServerWorldBorderPacket() { - } - - public ServerWorldBorderPacket(double radius) { - this.action = WorldBorderAction.SET_SIZE; - this.radius = radius; - } - - public ServerWorldBorderPacket(double oldRadius, double newRadius, long speed) { - this.action = WorldBorderAction.LERP_SIZE; - this.oldRadius = oldRadius; - this.newRadius = newRadius; - this.speed = speed; - } - - public ServerWorldBorderPacket(double centerX, double centerY) { - this.action = WorldBorderAction.SET_CENTER; - this.centerX = centerX; - this.centerY = centerY; - } - - public ServerWorldBorderPacket(double centerX, double centerY, double oldRadius, double newRadius, long speed, int portalTeleportBoundary, int warningTime, int warningBlocks) { - this.action = WorldBorderAction.INITIALIZE; - this.centerX = centerX; - this.centerY = centerY; - this.oldRadius = oldRadius; - this.newRadius = newRadius; - this.speed = speed; - this.portalTeleportBoundary = portalTeleportBoundary; - this.warningTime = warningTime; - this.warningBlocks = warningBlocks; - } - - public ServerWorldBorderPacket(int warning, boolean time) { - if(time) { - this.action = WorldBorderAction.SET_WARNING_TIME; - this.warningTime = warning; - } else { - this.action = WorldBorderAction.SET_WARNING_BLOCKS; - this.warningBlocks = warning; - } - } - - public WorldBorderAction getAction() { - return this.action; - } - - public double getRadius() { - return this.radius; - } - - public double getOldRadius() { - return this.oldRadius; - } - - public double getNewRadius() { - return this.newRadius; - } - - public long getSpeed() { - return this.speed; - } - - public double getCenterX() { - return this.centerX; - } - - public double getCenterY() { - return this.centerY; - } - - public int getPortalTeleportBoundary() { - return this.portalTeleportBoundary; - } - - public int getWarningTime() { - return this.warningTime; - } - - public int getWarningBlocks() { - return this.warningBlocks; - } - - @Override - public void read(NetInput in) throws IOException { - this.action = MagicValues.key(WorldBorderAction.class, in.readVarInt()); - if(this.action == WorldBorderAction.SET_SIZE) { - this.radius = in.readDouble(); - } else if(this.action == WorldBorderAction.LERP_SIZE) { - this.oldRadius = in.readDouble(); - this.newRadius = in.readDouble(); - this.speed = in.readVarLong(); - } else if(this.action == WorldBorderAction.SET_CENTER) { - this.centerX = in.readDouble(); - this.centerY = in.readDouble(); - } else if(this.action == WorldBorderAction.INITIALIZE) { - this.centerX = in.readDouble(); - this.centerY = in.readDouble(); - this.oldRadius = in.readDouble(); - this.newRadius = in.readDouble(); - this.speed = in.readVarLong(); - this.portalTeleportBoundary = in.readVarInt(); - this.warningTime = in.readVarInt(); - this.warningBlocks = in.readVarInt(); - } else if(this.action == WorldBorderAction.SET_WARNING_TIME) { - this.warningTime = in.readVarInt(); - } else if(this.action == WorldBorderAction.SET_WARNING_BLOCKS) { - this.warningBlocks = in.readVarInt(); - } - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(MagicValues.value(Integer.class, this.action)); - if(this.action == WorldBorderAction.SET_SIZE) { - out.writeDouble(this.radius); - } else if(this.action == WorldBorderAction.LERP_SIZE) { - out.writeDouble(this.oldRadius); - out.writeDouble(this.newRadius); - out.writeVarLong(this.speed); - } else if(this.action == WorldBorderAction.SET_CENTER) { - out.writeDouble(this.centerX); - out.writeDouble(this.centerY); - } else if(this.action == WorldBorderAction.INITIALIZE) { - out.writeDouble(this.centerX); - out.writeDouble(this.centerY); - out.writeDouble(this.oldRadius); - out.writeDouble(this.newRadius); - out.writeVarLong(this.speed); - out.writeVarInt(this.portalTeleportBoundary); - out.writeVarInt(this.warningTime); - out.writeVarInt(this.warningBlocks); - } else if(this.action == WorldBorderAction.SET_WARNING_TIME) { - out.writeVarInt(this.warningTime); - } else if(this.action == WorldBorderAction.SET_WARNING_BLOCKS) { - out.writeVarInt(this.warningBlocks); - } - } - - @Override - public boolean isPriority() { - return false; - } + private WorldBorderAction action; + + private double radius; + + private double oldRadius; + private double newRadius; + private long speed; + + private double centerX; + private double centerY; + + private int portalTeleportBoundary; + + private int warningTime; + + private int warningBlocks; + + @SuppressWarnings("unused") + private ServerWorldBorderPacket() { + } + + public ServerWorldBorderPacket(double radius) { + this.action = WorldBorderAction.SET_SIZE; + this.radius = radius; + } + + public ServerWorldBorderPacket(double oldRadius, double newRadius, long speed) { + this.action = WorldBorderAction.LERP_SIZE; + this.oldRadius = oldRadius; + this.newRadius = newRadius; + this.speed = speed; + } + + public ServerWorldBorderPacket(double centerX, double centerY) { + this.action = WorldBorderAction.SET_CENTER; + this.centerX = centerX; + this.centerY = centerY; + } + + public ServerWorldBorderPacket(double centerX, double centerY, double oldRadius, double newRadius, long speed, int portalTeleportBoundary, int warningTime, int warningBlocks) { + this.action = WorldBorderAction.INITIALIZE; + this.centerX = centerX; + this.centerY = centerY; + this.oldRadius = oldRadius; + this.newRadius = newRadius; + this.speed = speed; + this.portalTeleportBoundary = portalTeleportBoundary; + this.warningTime = warningTime; + this.warningBlocks = warningBlocks; + } + + public ServerWorldBorderPacket(int warning, boolean time) { + if(time) { + this.action = WorldBorderAction.SET_WARNING_TIME; + this.warningTime = warning; + } else { + this.action = WorldBorderAction.SET_WARNING_BLOCKS; + this.warningBlocks = warning; + } + } + + public WorldBorderAction getAction() { + return this.action; + } + + public double getRadius() { + return this.radius; + } + + public double getOldRadius() { + return this.oldRadius; + } + + public double getNewRadius() { + return this.newRadius; + } + + public long getSpeed() { + return this.speed; + } + + public double getCenterX() { + return this.centerX; + } + + public double getCenterY() { + return this.centerY; + } + + public int getPortalTeleportBoundary() { + return this.portalTeleportBoundary; + } + + public int getWarningTime() { + return this.warningTime; + } + + public int getWarningBlocks() { + return this.warningBlocks; + } + + @Override + public void read(NetInput in) throws IOException { + this.action = MagicValues.key(WorldBorderAction.class, in.readVarInt()); + if(this.action == WorldBorderAction.SET_SIZE) { + this.radius = in.readDouble(); + } else if(this.action == WorldBorderAction.LERP_SIZE) { + this.oldRadius = in.readDouble(); + this.newRadius = in.readDouble(); + this.speed = in.readVarLong(); + } else if(this.action == WorldBorderAction.SET_CENTER) { + this.centerX = in.readDouble(); + this.centerY = in.readDouble(); + } else if(this.action == WorldBorderAction.INITIALIZE) { + this.centerX = in.readDouble(); + this.centerY = in.readDouble(); + this.oldRadius = in.readDouble(); + this.newRadius = in.readDouble(); + this.speed = in.readVarLong(); + this.portalTeleportBoundary = in.readVarInt(); + this.warningTime = in.readVarInt(); + this.warningBlocks = in.readVarInt(); + } else if(this.action == WorldBorderAction.SET_WARNING_TIME) { + this.warningTime = in.readVarInt(); + } else if(this.action == WorldBorderAction.SET_WARNING_BLOCKS) { + this.warningBlocks = in.readVarInt(); + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(MagicValues.value(Integer.class, this.action)); + if(this.action == WorldBorderAction.SET_SIZE) { + out.writeDouble(this.radius); + } else if(this.action == WorldBorderAction.LERP_SIZE) { + out.writeDouble(this.oldRadius); + out.writeDouble(this.newRadius); + out.writeVarLong(this.speed); + } else if(this.action == WorldBorderAction.SET_CENTER) { + out.writeDouble(this.centerX); + out.writeDouble(this.centerY); + } else if(this.action == WorldBorderAction.INITIALIZE) { + out.writeDouble(this.centerX); + out.writeDouble(this.centerY); + out.writeDouble(this.oldRadius); + out.writeDouble(this.newRadius); + out.writeVarLong(this.speed); + out.writeVarInt(this.portalTeleportBoundary); + out.writeVarInt(this.warningTime); + out.writeVarInt(this.warningBlocks); + } else if(this.action == WorldBorderAction.SET_WARNING_TIME) { + out.writeVarInt(this.warningTime); + } else if(this.action == WorldBorderAction.SET_WARNING_BLOCKS) { + out.writeVarInt(this.warningBlocks); + } + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/login/client/EncryptionResponsePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/login/client/EncryptionResponsePacket.java index 5c77c7519..26655a425 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/login/client/EncryptionResponsePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/login/client/EncryptionResponsePacket.java @@ -12,43 +12,43 @@ public class EncryptionResponsePacket implements Packet { - private byte sharedKey[]; - private byte verifyToken[]; - - @SuppressWarnings("unused") - private EncryptionResponsePacket() { - } - - public EncryptionResponsePacket(SecretKey secretKey, PublicKey publicKey, byte verifyToken[]) { - this.sharedKey = CryptUtil.encryptData(publicKey, secretKey.getEncoded()); - this.verifyToken = CryptUtil.encryptData(publicKey, verifyToken); - } - - public SecretKey getSecretKey(PrivateKey privateKey) { - return CryptUtil.decryptSharedKey(privateKey, this.sharedKey); - } - - public byte[] getVerifyToken(PrivateKey privateKey) { - return CryptUtil.decryptData(privateKey, this.verifyToken); - } - - @Override - public void read(NetInput in) throws IOException { - this.sharedKey = in.readBytes(in.readVarInt()); - this.verifyToken = in.readBytes(in.readVarInt()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.sharedKey.length); - out.writeBytes(this.sharedKey); - out.writeVarInt(this.verifyToken.length); - out.writeBytes(this.verifyToken); - } - - @Override - public boolean isPriority() { - return true; - } + private byte sharedKey[]; + private byte verifyToken[]; + + @SuppressWarnings("unused") + private EncryptionResponsePacket() { + } + + public EncryptionResponsePacket(SecretKey secretKey, PublicKey publicKey, byte verifyToken[]) { + this.sharedKey = CryptUtil.encryptData(publicKey, secretKey.getEncoded()); + this.verifyToken = CryptUtil.encryptData(publicKey, verifyToken); + } + + public SecretKey getSecretKey(PrivateKey privateKey) { + return CryptUtil.decryptSharedKey(privateKey, this.sharedKey); + } + + public byte[] getVerifyToken(PrivateKey privateKey) { + return CryptUtil.decryptData(privateKey, this.verifyToken); + } + + @Override + public void read(NetInput in) throws IOException { + this.sharedKey = in.readBytes(in.readVarInt()); + this.verifyToken = in.readBytes(in.readVarInt()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.sharedKey.length); + out.writeBytes(this.sharedKey); + out.writeVarInt(this.verifyToken.length); + out.writeBytes(this.verifyToken); + } + + @Override + public boolean isPriority() { + return true; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/login/client/LoginStartPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/login/client/LoginStartPacket.java index 418600bd8..acc992a24 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/login/client/LoginStartPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/login/client/LoginStartPacket.java @@ -8,33 +8,33 @@ public class LoginStartPacket implements Packet { - private String username; - - @SuppressWarnings("unused") - private LoginStartPacket() { - } - - public LoginStartPacket(String username) { - this.username = username; - } - - public String getUsername() { - return this.username; - } - - @Override - public void read(NetInput in) throws IOException { - this.username = in.readString(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.username); - } - - @Override - public boolean isPriority() { - return true; - } + private String username; + + @SuppressWarnings("unused") + private LoginStartPacket() { + } + + public LoginStartPacket(String username) { + this.username = username; + } + + public String getUsername() { + return this.username; + } + + @Override + public void read(NetInput in) throws IOException { + this.username = in.readString(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.username); + } + + @Override + public boolean isPriority() { + return true; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/login/server/EncryptionRequestPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/login/server/EncryptionRequestPacket.java index 5d08671ff..fa017b712 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/login/server/EncryptionRequestPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/login/server/EncryptionRequestPacket.java @@ -10,52 +10,52 @@ public class EncryptionRequestPacket implements Packet { - private String serverId; - private PublicKey publicKey; - private byte verifyToken[]; - - @SuppressWarnings("unused") - private EncryptionRequestPacket() { - } - - public EncryptionRequestPacket(String serverId, PublicKey publicKey, byte verifyToken[]) { - this.serverId = serverId; - this.publicKey = publicKey; - this.verifyToken = verifyToken; - } - - public String getServerId() { - return this.serverId; - } - - public PublicKey getPublicKey() { - return this.publicKey; - } - - public byte[] getVerifyToken() { - return this.verifyToken; - } - - @Override - public void read(NetInput in) throws IOException { - this.serverId = in.readString(); - this.publicKey = CryptUtil.decodePublicKey(in.readBytes(in.readVarInt())); - this.verifyToken = in.readBytes(in.readVarInt()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.serverId); - byte encoded[] = this.publicKey.getEncoded(); - out.writeVarInt(encoded.length); - out.writeBytes(encoded); - out.writeVarInt(this.verifyToken.length); - out.writeBytes(this.verifyToken); - } - - @Override - public boolean isPriority() { - return true; - } + private String serverId; + private PublicKey publicKey; + private byte verifyToken[]; + + @SuppressWarnings("unused") + private EncryptionRequestPacket() { + } + + public EncryptionRequestPacket(String serverId, PublicKey publicKey, byte verifyToken[]) { + this.serverId = serverId; + this.publicKey = publicKey; + this.verifyToken = verifyToken; + } + + public String getServerId() { + return this.serverId; + } + + public PublicKey getPublicKey() { + return this.publicKey; + } + + public byte[] getVerifyToken() { + return this.verifyToken; + } + + @Override + public void read(NetInput in) throws IOException { + this.serverId = in.readString(); + this.publicKey = CryptUtil.decodePublicKey(in.readBytes(in.readVarInt())); + this.verifyToken = in.readBytes(in.readVarInt()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.serverId); + byte encoded[] = this.publicKey.getEncoded(); + out.writeVarInt(encoded.length); + out.writeBytes(encoded); + out.writeVarInt(this.verifyToken.length); + out.writeBytes(this.verifyToken); + } + + @Override + public boolean isPriority() { + return true; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginDisconnectPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginDisconnectPacket.java index 4532c0ade..1c0e25f2e 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginDisconnectPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginDisconnectPacket.java @@ -9,37 +9,37 @@ public class LoginDisconnectPacket implements Packet { - private Message message; - - @SuppressWarnings("unused") - private LoginDisconnectPacket() { - } - - public LoginDisconnectPacket(String text) { - this(Message.fromString(text)); - } - - public LoginDisconnectPacket(Message message) { - this.message = message; - } - - public Message getReason() { - return this.message; - } - - @Override - public void read(NetInput in) throws IOException { - this.message = Message.fromString(in.readString()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.message.toJsonString()); - } - - @Override - public boolean isPriority() { - return true; - } + private Message message; + + @SuppressWarnings("unused") + private LoginDisconnectPacket() { + } + + public LoginDisconnectPacket(String text) { + this(Message.fromString(text)); + } + + public LoginDisconnectPacket(Message message) { + this.message = message; + } + + public Message getReason() { + return this.message; + } + + @Override + public void read(NetInput in) throws IOException { + this.message = Message.fromString(in.readString()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.message.toJsonString()); + } + + @Override + public boolean isPriority() { + return true; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginSetCompressionPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginSetCompressionPacket.java index 496f14c0b..dc277ab94 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginSetCompressionPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginSetCompressionPacket.java @@ -7,32 +7,32 @@ import java.io.IOException; public class LoginSetCompressionPacket implements Packet { - private int threshold; - - @SuppressWarnings("unused") - private LoginSetCompressionPacket() { - } - - public LoginSetCompressionPacket(int threshold) { - this.threshold = threshold; - } - - public int getThreshold() { - return this.threshold; - } - - @Override - public void read(NetInput in) throws IOException { - this.threshold = in.readVarInt(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.threshold); - } - - @Override - public boolean isPriority() { - return true; - } + private int threshold; + + @SuppressWarnings("unused") + private LoginSetCompressionPacket() { + } + + public LoginSetCompressionPacket(int threshold) { + this.threshold = threshold; + } + + public int getThreshold() { + return this.threshold; + } + + @Override + public void read(NetInput in) throws IOException { + this.threshold = in.readVarInt(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.threshold); + } + + @Override + public boolean isPriority() { + return true; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginSuccessPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginSuccessPacket.java index d5b28738c..eb4569237 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginSuccessPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/login/server/LoginSuccessPacket.java @@ -9,34 +9,34 @@ public class LoginSuccessPacket implements Packet { - private GameProfile profile; - - @SuppressWarnings("unused") - private LoginSuccessPacket() { - } - - public LoginSuccessPacket(GameProfile profile) { - this.profile = profile; - } - - public GameProfile getProfile() { - return this.profile; - } - - @Override - public void read(NetInput in) throws IOException { - this.profile = new GameProfile(in.readString(), in.readString()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(this.profile.getIdAsString()); - out.writeString(this.profile.getName()); - } - - @Override - public boolean isPriority() { - return true; - } + private GameProfile profile; + + @SuppressWarnings("unused") + private LoginSuccessPacket() { + } + + public LoginSuccessPacket(GameProfile profile) { + this.profile = profile; + } + + public GameProfile getProfile() { + return this.profile; + } + + @Override + public void read(NetInput in) throws IOException { + this.profile = new GameProfile(in.readString(), in.readString()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.profile.getIdAsString()); + out.writeString(this.profile.getName()); + } + + @Override + public boolean isPriority() { + return true; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/status/client/StatusPingPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/status/client/StatusPingPacket.java index fe9dd52b1..0165d5428 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/status/client/StatusPingPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/status/client/StatusPingPacket.java @@ -8,33 +8,33 @@ public class StatusPingPacket implements Packet { - private long time; - - @SuppressWarnings("unused") - private StatusPingPacket() { - } - - public StatusPingPacket(long time) { - this.time = time; - } - - public long getPingTime() { - return this.time; - } - - @Override - public void read(NetInput in) throws IOException { - this.time = in.readLong(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeLong(this.time); - } - - @Override - public boolean isPriority() { - return false; - } + private long time; + + @SuppressWarnings("unused") + private StatusPingPacket() { + } + + public StatusPingPacket(long time) { + this.time = time; + } + + public long getPingTime() { + return this.time; + } + + @Override + public void read(NetInput in) throws IOException { + this.time = in.readLong(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeLong(this.time); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/status/client/StatusQueryPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/status/client/StatusQueryPacket.java index f0ab17293..b3610b600 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/status/client/StatusQueryPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/status/client/StatusQueryPacket.java @@ -8,20 +8,20 @@ public class StatusQueryPacket implements Packet { - public StatusQueryPacket() { - } + public StatusQueryPacket() { + } - @Override - public void read(NetInput in) throws IOException { - } + @Override + public void read(NetInput in) throws IOException { + } - @Override - public void write(NetOutput out) throws IOException { - } + @Override + public void write(NetOutput out) throws IOException { + } - @Override - public boolean isPriority() { - return false; - } + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/status/server/StatusPongPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/status/server/StatusPongPacket.java index 67b328d54..c00d6140e 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/status/server/StatusPongPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/status/server/StatusPongPacket.java @@ -8,33 +8,33 @@ public class StatusPongPacket implements Packet { - private long time; - - @SuppressWarnings("unused") - private StatusPongPacket() { - } - - public StatusPongPacket(long time) { - this.time = time; - } - - public long getPingTime() { - return this.time; - } - - @Override - public void read(NetInput in) throws IOException { - this.time = in.readLong(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeLong(this.time); - } - - @Override - public boolean isPriority() { - return false; - } + private long time; + + @SuppressWarnings("unused") + private StatusPongPacket() { + } + + public StatusPongPacket(long time) { + this.time = time; + } + + public long getPingTime() { + return this.time; + } + + @Override + public void read(NetInput in) throws IOException { + this.time = in.readLong(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeLong(this.time); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/packet/status/server/StatusResponsePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/status/server/StatusResponsePacket.java index ecf3e2e32..93c208dd5 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/status/server/StatusResponsePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/status/server/StatusResponsePacket.java @@ -22,111 +22,111 @@ public class StatusResponsePacket implements Packet { - private ServerStatusInfo info; - - @SuppressWarnings("unused") - private StatusResponsePacket() { - } - - public StatusResponsePacket(ServerStatusInfo info) { - this.info = info; - } - - public ServerStatusInfo getInfo() { - return this.info; - } - - @Override - public void read(NetInput in) throws IOException { - JsonObject obj = new Gson().fromJson(in.readString(), JsonObject.class); - JsonObject ver = obj.get("version").getAsJsonObject(); - VersionInfo version = new VersionInfo(ver.get("name").getAsString(), ver.get("protocol").getAsInt()); - JsonObject plrs = obj.get("players").getAsJsonObject(); - GameProfile profiles[] = new GameProfile[0]; - if(plrs.has("sample")) { - JsonArray prof = plrs.get("sample").getAsJsonArray(); - if(prof.size() > 0) { - profiles = new GameProfile[prof.size()]; - for(int index = 0; index < prof.size(); index++) { - JsonObject o = prof.get(index).getAsJsonObject(); - profiles[index] = new GameProfile(o.get("id").getAsString(), o.get("name").getAsString()); - } - } - } - - PlayerInfo players = new PlayerInfo(plrs.get("max").getAsInt(), plrs.get("online").getAsInt(), profiles); - JsonElement desc = obj.get("description"); - Message description = Message.fromJson(desc); - BufferedImage icon = null; - if(obj.has("favicon")) { - icon = this.stringToIcon(obj.get("favicon").getAsString()); - } - - this.info = new ServerStatusInfo(version, players, description, icon); - } - - @Override - public void write(NetOutput out) throws IOException { - JsonObject obj = new JsonObject(); - JsonObject ver = new JsonObject(); - ver.addProperty("name", this.info.getVersionInfo().getVersionName()); - ver.addProperty("protocol", this.info.getVersionInfo().getProtocolVersion()); - JsonObject plrs = new JsonObject(); - plrs.addProperty("max", this.info.getPlayerInfo().getMaxPlayers()); - plrs.addProperty("online", this.info.getPlayerInfo().getOnlinePlayers()); - if(this.info.getPlayerInfo().getPlayers().length > 0) { - JsonArray array = new JsonArray(); - for(GameProfile profile : this.info.getPlayerInfo().getPlayers()) { - JsonObject o = new JsonObject(); - o.addProperty("name", profile.getName()); - o.addProperty("id", profile.getIdAsString()); - array.add(o); - } - - plrs.add("sample", array); - } - - obj.add("version", ver); - obj.add("players", plrs); - obj.add("description", this.info.getDescription().toJson()); - if(this.info.getIcon() != null) { - obj.addProperty("favicon", this.iconToString(this.info.getIcon())); - } - - out.writeString(obj.toString()); - } - - private BufferedImage stringToIcon(String str) throws IOException { - if(str.startsWith("data:image/png;base64,")) { - str = str.substring("data:image/png;base64,".length()); - } - - byte bytes[] = Base64.decode(str.getBytes("UTF-8")); - ByteArrayInputStream in = new ByteArrayInputStream(bytes); - BufferedImage icon = ImageIO.read(in); - in.close(); - if(icon != null && (icon.getWidth() != 64 || icon.getHeight() != 64)) { - throw new IOException("Icon must be 64x64."); - } - - return icon; - } - - private String iconToString(BufferedImage icon) throws IOException { - if(icon.getWidth() != 64 || icon.getHeight() != 64) { - throw new IOException("Icon must be 64x64."); - } - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - ImageIO.write(icon, "PNG", out); - out.close(); - byte encoded[] = Base64.encode(out.toByteArray()); - return "data:image/png;base64," + new String(encoded, "UTF-8"); - } - - @Override - public boolean isPriority() { - return false; - } + private ServerStatusInfo info; + + @SuppressWarnings("unused") + private StatusResponsePacket() { + } + + public StatusResponsePacket(ServerStatusInfo info) { + this.info = info; + } + + public ServerStatusInfo getInfo() { + return this.info; + } + + @Override + public void read(NetInput in) throws IOException { + JsonObject obj = new Gson().fromJson(in.readString(), JsonObject.class); + JsonObject ver = obj.get("version").getAsJsonObject(); + VersionInfo version = new VersionInfo(ver.get("name").getAsString(), ver.get("protocol").getAsInt()); + JsonObject plrs = obj.get("players").getAsJsonObject(); + GameProfile profiles[] = new GameProfile[0]; + if(plrs.has("sample")) { + JsonArray prof = plrs.get("sample").getAsJsonArray(); + if(prof.size() > 0) { + profiles = new GameProfile[prof.size()]; + for(int index = 0; index < prof.size(); index++) { + JsonObject o = prof.get(index).getAsJsonObject(); + profiles[index] = new GameProfile(o.get("id").getAsString(), o.get("name").getAsString()); + } + } + } + + PlayerInfo players = new PlayerInfo(plrs.get("max").getAsInt(), plrs.get("online").getAsInt(), profiles); + JsonElement desc = obj.get("description"); + Message description = Message.fromJson(desc); + BufferedImage icon = null; + if(obj.has("favicon")) { + icon = this.stringToIcon(obj.get("favicon").getAsString()); + } + + this.info = new ServerStatusInfo(version, players, description, icon); + } + + @Override + public void write(NetOutput out) throws IOException { + JsonObject obj = new JsonObject(); + JsonObject ver = new JsonObject(); + ver.addProperty("name", this.info.getVersionInfo().getVersionName()); + ver.addProperty("protocol", this.info.getVersionInfo().getProtocolVersion()); + JsonObject plrs = new JsonObject(); + plrs.addProperty("max", this.info.getPlayerInfo().getMaxPlayers()); + plrs.addProperty("online", this.info.getPlayerInfo().getOnlinePlayers()); + if(this.info.getPlayerInfo().getPlayers().length > 0) { + JsonArray array = new JsonArray(); + for(GameProfile profile : this.info.getPlayerInfo().getPlayers()) { + JsonObject o = new JsonObject(); + o.addProperty("name", profile.getName()); + o.addProperty("id", profile.getIdAsString()); + array.add(o); + } + + plrs.add("sample", array); + } + + obj.add("version", ver); + obj.add("players", plrs); + obj.add("description", this.info.getDescription().toJson()); + if(this.info.getIcon() != null) { + obj.addProperty("favicon", this.iconToString(this.info.getIcon())); + } + + out.writeString(obj.toString()); + } + + private BufferedImage stringToIcon(String str) throws IOException { + if(str.startsWith("data:image/png;base64,")) { + str = str.substring("data:image/png;base64,".length()); + } + + byte bytes[] = Base64.decode(str.getBytes("UTF-8")); + ByteArrayInputStream in = new ByteArrayInputStream(bytes); + BufferedImage icon = ImageIO.read(in); + in.close(); + if(icon != null && (icon.getWidth() != 64 || icon.getHeight() != 64)) { + throw new IOException("Icon must be 64x64."); + } + + return icon; + } + + private String iconToString(BufferedImage icon) throws IOException { + if(icon.getWidth() != 64 || icon.getHeight() != 64) { + throw new IOException("Icon must be 64x64."); + } + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ImageIO.write(icon, "PNG", out); + out.close(); + byte encoded[] = Base64.encode(out.toByteArray()); + return "data:image/png;base64," + new String(encoded, "UTF-8"); + } + + @Override + public boolean isPriority() { + return false; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/util/CryptUtil.java b/src/main/java/org/spacehq/mc/protocol/util/CryptUtil.java index 6c5a185e3..fe751a0aa 100644 --- a/src/main/java/org/spacehq/mc/protocol/util/CryptUtil.java +++ b/src/main/java/org/spacehq/mc/protocol/util/CryptUtil.java @@ -6,80 +6,88 @@ import javax.crypto.spec.SecretKeySpec; import java.io.IOException; import java.io.UnsupportedEncodingException; -import java.security.*; +import java.security.GeneralSecurityException; +import java.security.Key; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.PublicKey; import java.security.spec.X509EncodedKeySpec; public class CryptUtil { - public static SecretKey generateSharedKey() { - try { - KeyGenerator gen = KeyGenerator.getInstance("AES"); - gen.init(128); - return gen.generateKey(); - } catch(NoSuchAlgorithmException e) { - throw new Error("Failed to generate shared key.", e); - } - } + public static SecretKey generateSharedKey() { + try { + KeyGenerator gen = KeyGenerator.getInstance("AES"); + gen.init(128); + return gen.generateKey(); + } catch(NoSuchAlgorithmException e) { + throw new Error("Failed to generate shared key.", e); + } + } - public static KeyPair generateKeyPair() { - try { - KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA"); - gen.initialize(1024); - return gen.generateKeyPair(); - } catch(NoSuchAlgorithmException e) { - throw new Error("Failed to generate key pair.", e); - } - } + public static KeyPair generateKeyPair() { + try { + KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA"); + gen.initialize(1024); + return gen.generateKeyPair(); + } catch(NoSuchAlgorithmException e) { + throw new Error("Failed to generate key pair.", e); + } + } - public static PublicKey decodePublicKey(byte bytes[]) throws IOException { - try { - return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(bytes)); - } catch(GeneralSecurityException e) { - throw new IOException("Could not decrypt public key.", e); - } - } + public static PublicKey decodePublicKey(byte bytes[]) throws IOException { + try { + return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(bytes)); + } catch(GeneralSecurityException e) { + throw new IOException("Could not decrypt public key.", e); + } + } - public static SecretKey decryptSharedKey(PrivateKey privateKey, byte[] sharedKey) { - return new SecretKeySpec(decryptData(privateKey, sharedKey), "AES"); - } + public static SecretKey decryptSharedKey(PrivateKey privateKey, byte[] sharedKey) { + return new SecretKeySpec(decryptData(privateKey, sharedKey), "AES"); + } - public static byte[] encryptData(Key key, byte[] data) { - return runEncryption(1, key, data); - } + public static byte[] encryptData(Key key, byte[] data) { + return runEncryption(1, key, data); + } - public static byte[] decryptData(Key key, byte[] data) { - return runEncryption(2, key, data); - } + public static byte[] decryptData(Key key, byte[] data) { + return runEncryption(2, key, data); + } - private static byte[] runEncryption(int mode, Key key, byte[] data) { - try { - Cipher cipher = Cipher.getInstance(key.getAlgorithm()); - cipher.init(mode, key); - return cipher.doFinal(data); - } catch(GeneralSecurityException e) { - throw new Error("Failed to run encryption.", e); - } - } + private static byte[] runEncryption(int mode, Key key, byte[] data) { + try { + Cipher cipher = Cipher.getInstance(key.getAlgorithm()); + cipher.init(mode, key); + return cipher.doFinal(data); + } catch(GeneralSecurityException e) { + throw new Error("Failed to run encryption.", e); + } + } - public static byte[] getServerIdHash(String serverId, PublicKey publicKey, SecretKey secretKey) { - try { - return encrypt("SHA-1", new byte[][] { serverId.getBytes("ISO_8859_1"), secretKey.getEncoded(), publicKey.getEncoded() }); - } catch(UnsupportedEncodingException e) { - throw new Error("Failed to generate server id hash.", e); - } - } + public static byte[] getServerIdHash(String serverId, PublicKey publicKey, SecretKey secretKey) { + try { + return encrypt("SHA-1", new byte[][] { serverId.getBytes("ISO_8859_1"), secretKey.getEncoded(), publicKey.getEncoded() }); + } catch(UnsupportedEncodingException e) { + throw new Error("Failed to generate server id hash.", e); + } + } - private static byte[] encrypt(String encryption, byte[]... data) { - try { - MessageDigest digest = MessageDigest.getInstance(encryption); - for(byte array[] : data) { - digest.update(array); - } + private static byte[] encrypt(String encryption, byte[]... data) { + try { + MessageDigest digest = MessageDigest.getInstance(encryption); + for(byte array[] : data) { + digest.update(array); + } - return digest.digest(); - } catch(NoSuchAlgorithmException e) { - throw new Error("Failed to encrypt data.", e); - } - } + return digest.digest(); + } catch(NoSuchAlgorithmException e) { + throw new Error("Failed to encrypt data.", e); + } + } } diff --git a/src/main/java/org/spacehq/mc/protocol/util/NetUtil.java b/src/main/java/org/spacehq/mc/protocol/util/NetUtil.java index 4cc7103ee..91cfcaf6c 100644 --- a/src/main/java/org/spacehq/mc/protocol/util/NetUtil.java +++ b/src/main/java/org/spacehq/mc/protocol/util/NetUtil.java @@ -1,6 +1,12 @@ package org.spacehq.mc.protocol.util; -import org.spacehq.mc.protocol.data.game.*; +import org.spacehq.mc.protocol.data.game.Chunk; +import org.spacehq.mc.protocol.data.game.EntityMetadata; +import org.spacehq.mc.protocol.data.game.ItemStack; +import org.spacehq.mc.protocol.data.game.NibbleArray3d; +import org.spacehq.mc.protocol.data.game.Position; +import org.spacehq.mc.protocol.data.game.Rotation; +import org.spacehq.mc.protocol.data.game.ShortArray3d; import org.spacehq.mc.protocol.data.game.values.MagicValues; import org.spacehq.mc.protocol.data.game.values.entity.MetadataType; import org.spacehq.opennbt.NBTIO; @@ -8,7 +14,11 @@ import org.spacehq.packetlib.io.NetInput; import org.spacehq.packetlib.io.NetOutput; -import java.io.*; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.ShortBuffer; @@ -17,327 +27,327 @@ public class NetUtil { - private static final int[] EXPONENTS_OF_TWO = new int[] { 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; - - private static final int POSITION_X_SIZE = 1 + lastExponentOfTwo(nextPowerOfTwo(30000000)); - private static final int POSITION_Z_SIZE = POSITION_X_SIZE; - private static final int POSITION_Y_SIZE = 64 - POSITION_X_SIZE - POSITION_Z_SIZE; - private static final int POSITION_Y_SHIFT = POSITION_Z_SIZE; - private static final int POSITION_X_SHIFT = POSITION_Y_SHIFT + POSITION_Y_SIZE; - private static final long POSITION_X_MASK = (1L << POSITION_X_SIZE) - 1; - private static final long POSITION_Y_MASK = (1L << POSITION_Y_SIZE) - 1; - private static final long POSITION_Z_MASK = (1L << POSITION_Z_SIZE) - 1; - - private static int nextPowerOfTwo(int i) { - int minusOne = i - 1; - minusOne |= minusOne >> 1; - minusOne |= minusOne >> 2; - minusOne |= minusOne >> 4; - minusOne |= minusOne >> 8; - minusOne |= minusOne >> 16; - return minusOne + 1; - } - - private static boolean isPowerOfTwo(int i) { - return i != 0 && (i & i - 1) == 0; - } - - private static int nextExponentOfTwo(int i) { - int power = isPowerOfTwo(i) ? i : nextPowerOfTwo(i); - return EXPONENTS_OF_TWO[(int) (power * 125613361L >> 27) & 31]; - } - - public static int lastExponentOfTwo(int i) { - return nextExponentOfTwo(i) - (isPowerOfTwo(i) ? 0 : 1); - } - - public static CompoundTag readNBT(NetInput in) throws IOException { - byte b = in.readByte(); - if(b == 0) { - return null; - } else { - return (CompoundTag) NBTIO.readTag(new DataInputStream(new NetInputStream(in, b))); - } - } - - public static void writeNBT(NetOutput out, CompoundTag tag) throws IOException { - if(tag == null) { - out.writeByte(0); - } else { - NBTIO.writeTag(new DataOutputStream(new NetOutputStream(out)), tag); - } - } - - public static Position readPosition(NetInput in) throws IOException { - long val = in.readLong(); - int x = (int) (val << 64 - POSITION_X_SHIFT - POSITION_X_SIZE >> 64 - POSITION_X_SIZE); - int y = (int) (val << 64 - POSITION_Y_SHIFT - POSITION_Y_SIZE >> 64 - POSITION_Y_SIZE); - int z = (int) (val << 64 - POSITION_Z_SIZE >> 64 - POSITION_Z_SIZE); - return new Position(x, y, z); - } - - public static void writePosition(NetOutput out, Position pos) throws IOException { - out.writeLong((pos.getX() & POSITION_X_MASK) << POSITION_X_SHIFT | (pos.getY() & POSITION_Y_MASK) << POSITION_Y_SHIFT | (pos.getZ() & POSITION_Z_MASK)); - } - - public static ItemStack readItem(NetInput in) throws IOException { - short item = in.readShort(); - if(item < 0) { - return null; - } else { - return new ItemStack(item, in.readByte(), in.readShort(), readNBT(in)); - } - } - - public static void writeItem(NetOutput out, ItemStack item) throws IOException { - if(item == null) { - out.writeShort(-1); - } else { - out.writeShort(item.getId()); - out.writeByte(item.getAmount()); - out.writeShort(item.getData()); - writeNBT(out, item.getNBT()); - } - } - - public static EntityMetadata[] readEntityMetadata(NetInput in) throws IOException { - List ret = new ArrayList(); - byte b; - while((b = in.readByte()) != 127) { - int typeId = (b & 0xE0) >> 5; - int id = b & 0x1F; - MetadataType type = MagicValues.key(MetadataType.class, typeId); - Object value = null; - switch(type) { - case BYTE: - value = in.readByte(); - break; - case SHORT: - value = in.readShort(); - break; - case INT: - value = in.readInt(); - break; - case FLOAT: - value = in.readFloat(); - break; - case STRING: - value = in.readString(); - break; - case ITEM: - value = readItem(in); - break; - case POSITION: - value = new Position(in.readInt(), in.readInt(), in.readInt()); - break; - case ROTATION: - value = new Rotation(in.readFloat(), in.readFloat(), in.readFloat()); - break; - default: - throw new IOException("Unknown metadata type id: " + typeId); - } - - ret.add(new EntityMetadata(id, type, value)); - } - - return ret.toArray(new EntityMetadata[ret.size()]); - } - - public static void writeEntityMetadata(NetOutput out, EntityMetadata[] metadata) throws IOException { - for(EntityMetadata meta : metadata) { - int id = MagicValues.value(Integer.class, meta.getType()) << 5 | meta.getId() & 0x1F; - out.writeByte(id); - switch(meta.getType()) { - case BYTE: - out.writeByte((Byte) meta.getValue()); - break; - case SHORT: - out.writeShort((Short) meta.getValue()); - break; - case INT: - out.writeInt((Integer) meta.getValue()); - break; - case FLOAT: - out.writeFloat((Float) meta.getValue()); - break; - case STRING: - out.writeString((String) meta.getValue()); - break; - case ITEM: - writeItem(out, (ItemStack) meta.getValue()); - break; - case POSITION: - Position pos = (Position) meta.getValue(); - out.writeInt(pos.getX()); - out.writeInt(pos.getY()); - out.writeInt(pos.getZ()); - break; - case ROTATION: - Rotation rot = (Rotation) meta.getValue(); - out.writeFloat(rot.getPitch()); - out.writeFloat(rot.getYaw()); - out.writeFloat(rot.getRoll()); - break; - default: - throw new IOException("Unmapped metadata type: " + meta.getType()); - } - } - - out.writeByte(127); - } - - public static ParsedChunkData dataToChunks(NetworkChunkData data, boolean checkForSky) { - Chunk chunks[] = new Chunk[16]; - int pos = 0; - int expected = 0; - boolean sky = false; - ShortBuffer buf = ByteBuffer.wrap(data.getData()).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer(); - // 0 = Calculate expected length and determine if the packet has skylight. - // 1 = Create chunks from mask and get blocks. - // 2 = Get block light. - // 3 = Get sky light. - for(int pass = 0; pass < 4; pass++) { - for(int ind = 0; ind < 16; ind++) { - if((data.getMask() & 1 << ind) != 0) { - if(pass == 0) { - // Block length + Blocklight length - expected += (4096 * 2) + 2048; - } - - if(pass == 1) { - chunks[ind] = new Chunk(sky || data.hasSkyLight()); - ShortArray3d blocks = chunks[ind].getBlocks(); - buf.position(pos / 2); - buf.get(blocks.getData(), 0, blocks.getData().length); - pos += blocks.getData().length * 2; - } - - if(pass == 2) { - NibbleArray3d blocklight = chunks[ind].getBlockLight(); - System.arraycopy(data.getData(), pos, blocklight.getData(), 0, blocklight.getData().length); - pos += blocklight.getData().length; - } - - if(pass == 3 && (sky || data.hasSkyLight())) { - NibbleArray3d skylight = chunks[ind].getSkyLight(); - System.arraycopy(data.getData(), pos, skylight.getData(), 0, skylight.getData().length); - pos += skylight.getData().length; - } - } - } - - if(pass == 0) { - // If we have more data than blocks and blocklight combined, there must be skylight data as well. - if(data.getData().length >= expected) { - sky = checkForSky; - } - } - } - - byte biomeData[] = null; - if(data.isFullChunk()) { - biomeData = new byte[256]; - System.arraycopy(data.getData(), pos, biomeData, 0, biomeData.length); - pos += biomeData.length; - } - - return new ParsedChunkData(chunks, biomeData); - } - - public static NetworkChunkData chunksToData(ParsedChunkData chunks) { - int chunkMask = 0; - boolean fullChunk = chunks.getBiomes() != null; - boolean sky = false; - int length = fullChunk ? chunks.getBiomes().length : 0; - byte[] data = null; - int pos = 0; - ShortBuffer buf = null; - // 0 = Determine length and masks. - // 1 = Add blocks. - // 2 = Add block light. - // 3 = Add sky light. - for(int pass = 0; pass < 4; pass++) { - for(int ind = 0; ind < chunks.getChunks().length; ++ind) { - Chunk chunk = chunks.getChunks()[ind]; - if(chunk != null && (!fullChunk || !chunk.isEmpty())) { - if(pass == 0) { - chunkMask |= 1 << ind; - length += chunk.getBlocks().getData().length * 2; - length += chunk.getBlockLight().getData().length; - if(chunk.getSkyLight() != null) { - length += chunk.getSkyLight().getData().length; - } - } - - if(pass == 1) { - short blocks[] = chunk.getBlocks().getData(); - buf.position(pos / 2); - buf.put(blocks, 0, blocks.length); - pos += blocks.length * 2; - } - - if(pass == 2) { - byte blocklight[] = chunk.getBlockLight().getData(); - System.arraycopy(blocklight, 0, data, pos, blocklight.length); - pos += blocklight.length; - } - - if(pass == 3 && chunk.getSkyLight() != null) { - byte skylight[] = chunk.getSkyLight().getData(); - System.arraycopy(skylight, 0, data, pos, skylight.length); - pos += skylight.length; - sky = true; - } - } - } - - if(pass == 0) { - data = new byte[length]; - buf = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer(); - } - } - - // Add biomes. - if(fullChunk) { - System.arraycopy(chunks.getBiomes(), 0, data, pos, chunks.getBiomes().length); - pos += chunks.getBiomes().length; - } - - return new NetworkChunkData(chunkMask, fullChunk, sky, data); - } - - private static class NetInputStream extends InputStream { - private NetInput in; - private boolean readFirst; - private byte firstByte; - - public NetInputStream(NetInput in, byte firstByte) { - this.in = in; - this.firstByte = firstByte; - } - - @Override - public int read() throws IOException { - if(!this.readFirst) { - this.readFirst = true; - return this.firstByte; - } else { - return this.in.readUnsignedByte(); - } - } - } - - private static class NetOutputStream extends OutputStream { - private NetOutput out; - - public NetOutputStream(NetOutput out) { - this.out = out; - } - - @Override - public void write(int b) throws IOException { - this.out.writeByte(b); - } - } + private static final int[] EXPONENTS_OF_TWO = new int[] { 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; + + private static final int POSITION_X_SIZE = 1 + lastExponentOfTwo(nextPowerOfTwo(30000000)); + private static final int POSITION_Z_SIZE = POSITION_X_SIZE; + private static final int POSITION_Y_SIZE = 64 - POSITION_X_SIZE - POSITION_Z_SIZE; + private static final int POSITION_Y_SHIFT = POSITION_Z_SIZE; + private static final int POSITION_X_SHIFT = POSITION_Y_SHIFT + POSITION_Y_SIZE; + private static final long POSITION_X_MASK = (1L << POSITION_X_SIZE) - 1; + private static final long POSITION_Y_MASK = (1L << POSITION_Y_SIZE) - 1; + private static final long POSITION_Z_MASK = (1L << POSITION_Z_SIZE) - 1; + + private static int nextPowerOfTwo(int i) { + int minusOne = i - 1; + minusOne |= minusOne >> 1; + minusOne |= minusOne >> 2; + minusOne |= minusOne >> 4; + minusOne |= minusOne >> 8; + minusOne |= minusOne >> 16; + return minusOne + 1; + } + + private static boolean isPowerOfTwo(int i) { + return i != 0 && (i & i - 1) == 0; + } + + private static int nextExponentOfTwo(int i) { + int power = isPowerOfTwo(i) ? i : nextPowerOfTwo(i); + return EXPONENTS_OF_TWO[(int) (power * 125613361L >> 27) & 31]; + } + + public static int lastExponentOfTwo(int i) { + return nextExponentOfTwo(i) - (isPowerOfTwo(i) ? 0 : 1); + } + + public static CompoundTag readNBT(NetInput in) throws IOException { + byte b = in.readByte(); + if(b == 0) { + return null; + } else { + return (CompoundTag) NBTIO.readTag(new DataInputStream(new NetInputStream(in, b))); + } + } + + public static void writeNBT(NetOutput out, CompoundTag tag) throws IOException { + if(tag == null) { + out.writeByte(0); + } else { + NBTIO.writeTag(new DataOutputStream(new NetOutputStream(out)), tag); + } + } + + public static Position readPosition(NetInput in) throws IOException { + long val = in.readLong(); + int x = (int) (val << 64 - POSITION_X_SHIFT - POSITION_X_SIZE >> 64 - POSITION_X_SIZE); + int y = (int) (val << 64 - POSITION_Y_SHIFT - POSITION_Y_SIZE >> 64 - POSITION_Y_SIZE); + int z = (int) (val << 64 - POSITION_Z_SIZE >> 64 - POSITION_Z_SIZE); + return new Position(x, y, z); + } + + public static void writePosition(NetOutput out, Position pos) throws IOException { + out.writeLong((pos.getX() & POSITION_X_MASK) << POSITION_X_SHIFT | (pos.getY() & POSITION_Y_MASK) << POSITION_Y_SHIFT | (pos.getZ() & POSITION_Z_MASK)); + } + + public static ItemStack readItem(NetInput in) throws IOException { + short item = in.readShort(); + if(item < 0) { + return null; + } else { + return new ItemStack(item, in.readByte(), in.readShort(), readNBT(in)); + } + } + + public static void writeItem(NetOutput out, ItemStack item) throws IOException { + if(item == null) { + out.writeShort(-1); + } else { + out.writeShort(item.getId()); + out.writeByte(item.getAmount()); + out.writeShort(item.getData()); + writeNBT(out, item.getNBT()); + } + } + + public static EntityMetadata[] readEntityMetadata(NetInput in) throws IOException { + List ret = new ArrayList(); + byte b; + while((b = in.readByte()) != 127) { + int typeId = (b & 0xE0) >> 5; + int id = b & 0x1F; + MetadataType type = MagicValues.key(MetadataType.class, typeId); + Object value = null; + switch(type) { + case BYTE: + value = in.readByte(); + break; + case SHORT: + value = in.readShort(); + break; + case INT: + value = in.readInt(); + break; + case FLOAT: + value = in.readFloat(); + break; + case STRING: + value = in.readString(); + break; + case ITEM: + value = readItem(in); + break; + case POSITION: + value = new Position(in.readInt(), in.readInt(), in.readInt()); + break; + case ROTATION: + value = new Rotation(in.readFloat(), in.readFloat(), in.readFloat()); + break; + default: + throw new IOException("Unknown metadata type id: " + typeId); + } + + ret.add(new EntityMetadata(id, type, value)); + } + + return ret.toArray(new EntityMetadata[ret.size()]); + } + + public static void writeEntityMetadata(NetOutput out, EntityMetadata[] metadata) throws IOException { + for(EntityMetadata meta : metadata) { + int id = MagicValues.value(Integer.class, meta.getType()) << 5 | meta.getId() & 0x1F; + out.writeByte(id); + switch(meta.getType()) { + case BYTE: + out.writeByte((Byte) meta.getValue()); + break; + case SHORT: + out.writeShort((Short) meta.getValue()); + break; + case INT: + out.writeInt((Integer) meta.getValue()); + break; + case FLOAT: + out.writeFloat((Float) meta.getValue()); + break; + case STRING: + out.writeString((String) meta.getValue()); + break; + case ITEM: + writeItem(out, (ItemStack) meta.getValue()); + break; + case POSITION: + Position pos = (Position) meta.getValue(); + out.writeInt(pos.getX()); + out.writeInt(pos.getY()); + out.writeInt(pos.getZ()); + break; + case ROTATION: + Rotation rot = (Rotation) meta.getValue(); + out.writeFloat(rot.getPitch()); + out.writeFloat(rot.getYaw()); + out.writeFloat(rot.getRoll()); + break; + default: + throw new IOException("Unmapped metadata type: " + meta.getType()); + } + } + + out.writeByte(127); + } + + public static ParsedChunkData dataToChunks(NetworkChunkData data, boolean checkForSky) { + Chunk chunks[] = new Chunk[16]; + int pos = 0; + int expected = 0; + boolean sky = false; + ShortBuffer buf = ByteBuffer.wrap(data.getData()).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer(); + // 0 = Calculate expected length and determine if the packet has skylight. + // 1 = Create chunks from mask and get blocks. + // 2 = Get block light. + // 3 = Get sky light. + for(int pass = 0; pass < 4; pass++) { + for(int ind = 0; ind < 16; ind++) { + if((data.getMask() & 1 << ind) != 0) { + if(pass == 0) { + // Block length + Blocklight length + expected += (4096 * 2) + 2048; + } + + if(pass == 1) { + chunks[ind] = new Chunk(sky || data.hasSkyLight()); + ShortArray3d blocks = chunks[ind].getBlocks(); + buf.position(pos / 2); + buf.get(blocks.getData(), 0, blocks.getData().length); + pos += blocks.getData().length * 2; + } + + if(pass == 2) { + NibbleArray3d blocklight = chunks[ind].getBlockLight(); + System.arraycopy(data.getData(), pos, blocklight.getData(), 0, blocklight.getData().length); + pos += blocklight.getData().length; + } + + if(pass == 3 && (sky || data.hasSkyLight())) { + NibbleArray3d skylight = chunks[ind].getSkyLight(); + System.arraycopy(data.getData(), pos, skylight.getData(), 0, skylight.getData().length); + pos += skylight.getData().length; + } + } + } + + if(pass == 0) { + // If we have more data than blocks and blocklight combined, there must be skylight data as well. + if(data.getData().length >= expected) { + sky = checkForSky; + } + } + } + + byte biomeData[] = null; + if(data.isFullChunk()) { + biomeData = new byte[256]; + System.arraycopy(data.getData(), pos, biomeData, 0, biomeData.length); + pos += biomeData.length; + } + + return new ParsedChunkData(chunks, biomeData); + } + + public static NetworkChunkData chunksToData(ParsedChunkData chunks) { + int chunkMask = 0; + boolean fullChunk = chunks.getBiomes() != null; + boolean sky = false; + int length = fullChunk ? chunks.getBiomes().length : 0; + byte[] data = null; + int pos = 0; + ShortBuffer buf = null; + // 0 = Determine length and masks. + // 1 = Add blocks. + // 2 = Add block light. + // 3 = Add sky light. + for(int pass = 0; pass < 4; pass++) { + for(int ind = 0; ind < chunks.getChunks().length; ++ind) { + Chunk chunk = chunks.getChunks()[ind]; + if(chunk != null && (!fullChunk || !chunk.isEmpty())) { + if(pass == 0) { + chunkMask |= 1 << ind; + length += chunk.getBlocks().getData().length * 2; + length += chunk.getBlockLight().getData().length; + if(chunk.getSkyLight() != null) { + length += chunk.getSkyLight().getData().length; + } + } + + if(pass == 1) { + short blocks[] = chunk.getBlocks().getData(); + buf.position(pos / 2); + buf.put(blocks, 0, blocks.length); + pos += blocks.length * 2; + } + + if(pass == 2) { + byte blocklight[] = chunk.getBlockLight().getData(); + System.arraycopy(blocklight, 0, data, pos, blocklight.length); + pos += blocklight.length; + } + + if(pass == 3 && chunk.getSkyLight() != null) { + byte skylight[] = chunk.getSkyLight().getData(); + System.arraycopy(skylight, 0, data, pos, skylight.length); + pos += skylight.length; + sky = true; + } + } + } + + if(pass == 0) { + data = new byte[length]; + buf = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer(); + } + } + + // Add biomes. + if(fullChunk) { + System.arraycopy(chunks.getBiomes(), 0, data, pos, chunks.getBiomes().length); + pos += chunks.getBiomes().length; + } + + return new NetworkChunkData(chunkMask, fullChunk, sky, data); + } + + private static class NetInputStream extends InputStream { + private NetInput in; + private boolean readFirst; + private byte firstByte; + + public NetInputStream(NetInput in, byte firstByte) { + this.in = in; + this.firstByte = firstByte; + } + + @Override + public int read() throws IOException { + if(!this.readFirst) { + this.readFirst = true; + return this.firstByte; + } else { + return this.in.readUnsignedByte(); + } + } + } + + private static class NetOutputStream extends OutputStream { + private NetOutput out; + + public NetOutputStream(NetOutput out) { + this.out = out; + } + + @Override + public void write(int b) throws IOException { + this.out.writeByte(b); + } + } } diff --git a/src/main/java/org/spacehq/mc/protocol/util/NetworkChunkData.java b/src/main/java/org/spacehq/mc/protocol/util/NetworkChunkData.java index 20ee28fe4..c7c8c6e9b 100644 --- a/src/main/java/org/spacehq/mc/protocol/util/NetworkChunkData.java +++ b/src/main/java/org/spacehq/mc/protocol/util/NetworkChunkData.java @@ -2,54 +2,54 @@ public class NetworkChunkData { - private int mask; - private boolean fullChunk; - private boolean sky; - private byte data[]; - - public NetworkChunkData(int mask, boolean fullChunk, boolean sky, byte data[]) { - this.mask = mask; - this.fullChunk = fullChunk; - this.sky = sky; - this.data = data; - } - - public int getMask() { - return this.mask; - } - - public boolean isFullChunk() { - return this.fullChunk; - } - - public boolean hasSkyLight() { - return this.sky; - } - - public byte[] getData() { - return this.data; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - NetworkChunkData that = (NetworkChunkData) o; - - if (fullChunk != that.fullChunk) return false; - if (mask != that.mask) return false; - if (sky != that.sky) return false; - - return true; - } - - @Override - public int hashCode() { - int result = mask; - result = 31 * result + (fullChunk ? 1 : 0); - result = 31 * result + (sky ? 1 : 0); - return result; - } + private int mask; + private boolean fullChunk; + private boolean sky; + private byte data[]; + + public NetworkChunkData(int mask, boolean fullChunk, boolean sky, byte data[]) { + this.mask = mask; + this.fullChunk = fullChunk; + this.sky = sky; + this.data = data; + } + + public int getMask() { + return this.mask; + } + + public boolean isFullChunk() { + return this.fullChunk; + } + + public boolean hasSkyLight() { + return this.sky; + } + + public byte[] getData() { + return this.data; + } + + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; + + NetworkChunkData that = (NetworkChunkData) o; + + if(fullChunk != that.fullChunk) return false; + if(mask != that.mask) return false; + if(sky != that.sky) return false; + + return true; + } + + @Override + public int hashCode() { + int result = mask; + result = 31 * result + (fullChunk ? 1 : 0); + result = 31 * result + (sky ? 1 : 0); + return result; + } } diff --git a/src/main/java/org/spacehq/mc/protocol/util/ParsedChunkData.java b/src/main/java/org/spacehq/mc/protocol/util/ParsedChunkData.java index f76058a1c..c328b96b3 100644 --- a/src/main/java/org/spacehq/mc/protocol/util/ParsedChunkData.java +++ b/src/main/java/org/spacehq/mc/protocol/util/ParsedChunkData.java @@ -6,40 +6,40 @@ public class ParsedChunkData { - private Chunk chunks[]; - private byte biomes[]; + private Chunk chunks[]; + private byte biomes[]; - public ParsedChunkData(Chunk chunks[], byte biomes[]) { - this.chunks = chunks; - this.biomes = biomes; - } + public ParsedChunkData(Chunk chunks[], byte biomes[]) { + this.chunks = chunks; + this.biomes = biomes; + } - public Chunk[] getChunks() { - return this.chunks; - } + public Chunk[] getChunks() { + return this.chunks; + } - public byte[] getBiomes() { - return this.biomes; - } + public byte[] getBiomes() { + return this.biomes; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if(this == o) return true; + if(o == null || getClass() != o.getClass()) return false; - ParsedChunkData that = (ParsedChunkData) o; + ParsedChunkData that = (ParsedChunkData) o; - if (!Arrays.equals(biomes, that.biomes)) return false; - if (!Arrays.equals(chunks, that.chunks)) return false; + if(!Arrays.equals(biomes, that.biomes)) return false; + if(!Arrays.equals(chunks, that.chunks)) return false; - return true; - } + return true; + } - @Override - public int hashCode() { - int result = Arrays.hashCode(chunks); - result = 31 * result + (biomes != null ? Arrays.hashCode(biomes) : 0); - return result; - } + @Override + public int hashCode() { + int result = Arrays.hashCode(chunks); + result = 31 * result + (biomes != null ? Arrays.hashCode(biomes) : 0); + return result; + } }