Merge pull request #164 from finalchild/1.9.4

MC 1.9.4 support
This commit is contained in:
Steven Smith 2016-05-21 08:12:22 -07:00
commit b460ac6534
9 changed files with 291 additions and 440 deletions

View file

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.spacehq</groupId> <groupId>org.spacehq</groupId>
<artifactId>mcprotocollib</artifactId> <artifactId>mcprotocollib</artifactId>
<version>1.9.2-SNAPSHOT</version> <version>1.9.4-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>MCProtocolLib</name> <name>MCProtocolLib</name>

View file

@ -2,8 +2,8 @@ package org.spacehq.mc.protocol;
public class MinecraftConstants { public class MinecraftConstants {
// General Constants // General Constants
public static final String GAME_VERSION = "1.9.2"; public static final String GAME_VERSION = "1.9.4";
public static final int PROTOCOL_VERSION = 109; public static final int PROTOCOL_VERSION = 110;
// General Key Constants // General Key Constants
public static final String PROFILE_KEY = "profile"; public static final String PROFILE_KEY = "profile";

View file

@ -5,113 +5,20 @@ import org.spacehq.mc.auth.exception.request.RequestException;
import org.spacehq.mc.auth.service.AuthenticationService; import org.spacehq.mc.auth.service.AuthenticationService;
import org.spacehq.mc.protocol.data.SubProtocol; import org.spacehq.mc.protocol.data.SubProtocol;
import org.spacehq.mc.protocol.packet.handshake.client.HandshakePacket; import org.spacehq.mc.protocol.packet.handshake.client.HandshakePacket;
import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket; import org.spacehq.mc.protocol.packet.ingame.client.*;
import org.spacehq.mc.protocol.packet.ingame.client.ClientKeepAlivePacket; import org.spacehq.mc.protocol.packet.ingame.client.player.*;
import org.spacehq.mc.protocol.packet.ingame.client.ClientPluginMessagePacket; import org.spacehq.mc.protocol.packet.ingame.client.window.*;
import org.spacehq.mc.protocol.packet.ingame.client.ClientRequestPacket; import org.spacehq.mc.protocol.packet.ingame.client.world.*;
import org.spacehq.mc.protocol.packet.ingame.client.ClientResourcePackStatusPacket; import org.spacehq.mc.protocol.packet.ingame.server.*;
import org.spacehq.mc.protocol.packet.ingame.client.ClientSettingsPacket; import org.spacehq.mc.protocol.packet.ingame.server.entity.*;
import org.spacehq.mc.protocol.packet.ingame.client.ClientTabCompletePacket; import org.spacehq.mc.protocol.packet.ingame.server.entity.player.*;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerAbilitiesPacket; import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.*;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket;
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.ClientPlayerSwingArmPacket;
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientTeleportConfirmPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
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.ClientSpectatePacket;
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientSteerBoatPacket;
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientSteerVehiclePacket;
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientUpdateSignPacket;
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientVehicleMovePacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerBossBarPacket;
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.ServerSetCooldownPacket;
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.ServerEntityAnimationPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityAttachPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityCollectItemPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityDestroyPacket;
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.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.ServerEntitySetPassengersPacket;
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.ServerVehicleMovePacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerAbilitiesPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerChangeHeldItemPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerSetExperiencePacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerUseBedPacket;
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.ServerDisplayScoreboardPacket;
import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket; 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.ServerTeamPacket;
import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket; import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket;
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerCloseWindowPacket; import org.spacehq.mc.protocol.packet.ingame.server.window.*;
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerConfirmTransactionPacket; import org.spacehq.mc.protocol.packet.ingame.server.world.*;
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.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.ServerPlayBuiltinSoundPacket;
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.ServerUnloadChunkPacket;
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.EncryptionResponsePacket;
import org.spacehq.mc.protocol.packet.login.client.LoginStartPacket; import org.spacehq.mc.protocol.packet.login.client.LoginStartPacket;
import org.spacehq.mc.protocol.packet.login.server.EncryptionRequestPacket; import org.spacehq.mc.protocol.packet.login.server.EncryptionRequestPacket;
@ -149,12 +56,12 @@ public class MinecraftProtocol extends PacketProtocol {
} }
public MinecraftProtocol(SubProtocol subProtocol) { public MinecraftProtocol(SubProtocol subProtocol) {
if(subProtocol != SubProtocol.LOGIN && subProtocol != SubProtocol.STATUS) { if (subProtocol != SubProtocol.LOGIN && subProtocol != SubProtocol.STATUS) {
throw new IllegalArgumentException("Only login and status modes are permitted."); throw new IllegalArgumentException("Only login and status modes are permitted.");
} }
this.subProtocol = subProtocol; this.subProtocol = subProtocol;
if(subProtocol == SubProtocol.LOGIN) { if (subProtocol == SubProtocol.LOGIN) {
this.profile = new GameProfile((UUID) null, "Player"); this.profile = new GameProfile((UUID) null, "Player");
} }
} }
@ -177,7 +84,7 @@ public class MinecraftProtocol extends PacketProtocol {
String clientToken = UUID.randomUUID().toString(); String clientToken = UUID.randomUUID().toString();
AuthenticationService auth = new AuthenticationService(clientToken, authProxy); AuthenticationService auth = new AuthenticationService(clientToken, authProxy);
auth.setUsername(username); auth.setUsername(username);
if(token) { if (token) {
auth.setAccessToken(using); auth.setAccessToken(using);
} else { } else {
auth.setPassword(using); auth.setPassword(using);
@ -219,7 +126,7 @@ public class MinecraftProtocol extends PacketProtocol {
@Override @Override
public void newClientSession(Client client, Session session) { public void newClientSession(Client client, Session session) {
if(this.profile != null) { if (this.profile != null) {
session.setFlag(MinecraftConstants.PROFILE_KEY, this.profile); session.setFlag(MinecraftConstants.PROFILE_KEY, this.profile);
session.setFlag(MinecraftConstants.ACCESS_TOKEN_KEY, this.accessToken); session.setFlag(MinecraftConstants.ACCESS_TOKEN_KEY, this.accessToken);
} }
@ -237,7 +144,7 @@ public class MinecraftProtocol extends PacketProtocol {
protected void enableEncryption(Key key) { protected void enableEncryption(Key key) {
try { try {
this.encrypt = new AESEncryption(key); this.encrypt = new AESEncryption(key);
} catch(GeneralSecurityException e) { } catch (GeneralSecurityException e) {
throw new Error("Failed to enable protocol encryption.", e); throw new Error("Failed to enable protocol encryption.", e);
} }
} }
@ -248,9 +155,9 @@ public class MinecraftProtocol extends PacketProtocol {
protected void setSubProtocol(SubProtocol subProtocol, boolean client, Session session) { protected void setSubProtocol(SubProtocol subProtocol, boolean client, Session session) {
this.clearPackets(); this.clearPackets();
switch(subProtocol) { switch (subProtocol) {
case HANDSHAKE: case HANDSHAKE:
if(client) { if (client) {
this.initClientHandshake(session); this.initClientHandshake(session);
} else { } else {
this.initServerHandshake(session); this.initServerHandshake(session);
@ -258,7 +165,7 @@ public class MinecraftProtocol extends PacketProtocol {
break; break;
case LOGIN: case LOGIN:
if(client) { if (client) {
this.initClientLogin(session); this.initClientLogin(session);
} else { } else {
this.initServerLogin(session); this.initServerLogin(session);
@ -266,7 +173,7 @@ public class MinecraftProtocol extends PacketProtocol {
break; break;
case GAME: case GAME:
if(client) { if (client) {
this.initClientGame(session); this.initClientGame(session);
} else { } else {
this.initServerGame(session); this.initServerGame(session);
@ -274,7 +181,7 @@ public class MinecraftProtocol extends PacketProtocol {
break; break;
case STATUS: case STATUS:
if(client) { if (client) {
this.initClientStatus(session); this.initClientStatus(session);
} else { } else {
this.initServerStatus(session); this.initServerStatus(session);
@ -295,260 +202,258 @@ public class MinecraftProtocol extends PacketProtocol {
} }
private void initClientLogin(Session session) { private void initClientLogin(Session session) {
this.registerIncoming(0, LoginDisconnectPacket.class); this.registerIncoming(0x00, LoginDisconnectPacket.class);
this.registerIncoming(1, EncryptionRequestPacket.class); this.registerIncoming(0x01, EncryptionRequestPacket.class);
this.registerIncoming(2, LoginSuccessPacket.class); this.registerIncoming(0x02, LoginSuccessPacket.class);
this.registerIncoming(3, LoginSetCompressionPacket.class); this.registerIncoming(0x03, LoginSetCompressionPacket.class);
this.registerOutgoing(0, LoginStartPacket.class); this.registerOutgoing(0x00, LoginStartPacket.class);
this.registerOutgoing(1, EncryptionResponsePacket.class); this.registerOutgoing(0x01, EncryptionResponsePacket.class);
} }
private void initServerLogin(Session session) { private void initServerLogin(Session session) {
this.registerIncoming(0, LoginStartPacket.class); this.registerIncoming(0x00, LoginStartPacket.class);
this.registerIncoming(1, EncryptionResponsePacket.class); this.registerIncoming(0x01, EncryptionResponsePacket.class);
this.registerOutgoing(0, LoginDisconnectPacket.class); this.registerOutgoing(0x00, LoginDisconnectPacket.class);
this.registerOutgoing(1, EncryptionRequestPacket.class); this.registerOutgoing(0x01, EncryptionRequestPacket.class);
this.registerOutgoing(2, LoginSuccessPacket.class); this.registerOutgoing(0x02, LoginSuccessPacket.class);
this.registerOutgoing(3, LoginSetCompressionPacket.class); this.registerOutgoing(0x03, LoginSetCompressionPacket.class);
} }
private void initClientGame(Session session) { private void initClientGame(Session session) {
this.registerIncoming(0, ServerSpawnObjectPacket.class); this.registerIncoming(0x00, ServerSpawnObjectPacket.class);
this.registerIncoming(1, ServerSpawnExpOrbPacket.class); this.registerIncoming(0x01, ServerSpawnExpOrbPacket.class);
this.registerIncoming(2, ServerSpawnGlobalEntityPacket.class); this.registerIncoming(0x02, ServerSpawnGlobalEntityPacket.class);
this.registerIncoming(3, ServerSpawnMobPacket.class); this.registerIncoming(0x03, ServerSpawnMobPacket.class);
this.registerIncoming(4, ServerSpawnPaintingPacket.class); this.registerIncoming(0x04, ServerSpawnPaintingPacket.class);
this.registerIncoming(5, ServerSpawnPlayerPacket.class); this.registerIncoming(0x05, ServerSpawnPlayerPacket.class);
this.registerIncoming(6, ServerEntityAnimationPacket.class); this.registerIncoming(0x06, ServerEntityAnimationPacket.class);
this.registerIncoming(7, ServerStatisticsPacket.class); this.registerIncoming(0x07, ServerStatisticsPacket.class);
this.registerIncoming(8, ServerBlockBreakAnimPacket.class); this.registerIncoming(0x08, ServerBlockBreakAnimPacket.class);
this.registerIncoming(9, ServerUpdateTileEntityPacket.class); this.registerIncoming(0x09, ServerUpdateTileEntityPacket.class);
this.registerIncoming(10, ServerBlockValuePacket.class); this.registerIncoming(0x0A, ServerBlockValuePacket.class);
this.registerIncoming(11, ServerBlockChangePacket.class); this.registerIncoming(0x0B, ServerBlockChangePacket.class);
this.registerIncoming(12, ServerBossBarPacket.class); this.registerIncoming(0x0C, ServerBossBarPacket.class);
this.registerIncoming(13, ServerDifficultyPacket.class); this.registerIncoming(0x0D, ServerDifficultyPacket.class);
this.registerIncoming(14, ServerTabCompletePacket.class); this.registerIncoming(0x0E, ServerTabCompletePacket.class);
this.registerIncoming(15, ServerChatPacket.class); this.registerIncoming(0x0F, ServerChatPacket.class);
this.registerIncoming(16, ServerMultiBlockChangePacket.class); this.registerIncoming(0x10, ServerMultiBlockChangePacket.class);
this.registerIncoming(17, ServerConfirmTransactionPacket.class); this.registerIncoming(0x11, ServerConfirmTransactionPacket.class);
this.registerIncoming(18, ServerCloseWindowPacket.class); this.registerIncoming(0x12, ServerCloseWindowPacket.class);
this.registerIncoming(19, ServerOpenWindowPacket.class); this.registerIncoming(0x13, ServerOpenWindowPacket.class);
this.registerIncoming(20, ServerWindowItemsPacket.class); this.registerIncoming(0x14, ServerWindowItemsPacket.class);
this.registerIncoming(21, ServerWindowPropertyPacket.class); this.registerIncoming(0x15, ServerWindowPropertyPacket.class);
this.registerIncoming(22, ServerSetSlotPacket.class); this.registerIncoming(0x16, ServerSetSlotPacket.class);
this.registerIncoming(23, ServerSetCooldownPacket.class); this.registerIncoming(0x17, ServerSetCooldownPacket.class);
this.registerIncoming(24, ServerPluginMessagePacket.class); this.registerIncoming(0x18, ServerPluginMessagePacket.class);
this.registerIncoming(25, ServerPlaySoundPacket.class); this.registerIncoming(0x19, ServerPlaySoundPacket.class);
this.registerIncoming(26, ServerDisconnectPacket.class); this.registerIncoming(0x1A, ServerDisconnectPacket.class);
this.registerIncoming(27, ServerEntityStatusPacket.class); this.registerIncoming(0x1B, ServerEntityStatusPacket.class);
this.registerIncoming(28, ServerExplosionPacket.class); this.registerIncoming(0x1C, ServerExplosionPacket.class);
this.registerIncoming(29, ServerUnloadChunkPacket.class); this.registerIncoming(0x1D, ServerUnloadChunkPacket.class);
this.registerIncoming(30, ServerNotifyClientPacket.class); this.registerIncoming(0x1E, ServerNotifyClientPacket.class);
this.registerIncoming(31, ServerKeepAlivePacket.class); this.registerIncoming(0x1F, ServerKeepAlivePacket.class);
this.registerIncoming(32, ServerChunkDataPacket.class); this.registerIncoming(0x20, ServerChunkDataPacket.class);
this.registerIncoming(33, ServerPlayEffectPacket.class); this.registerIncoming(0x21, ServerPlayEffectPacket.class);
this.registerIncoming(34, ServerSpawnParticlePacket.class); this.registerIncoming(0x22, ServerSpawnParticlePacket.class);
this.registerIncoming(35, ServerJoinGamePacket.class); this.registerIncoming(0x23, ServerJoinGamePacket.class);
this.registerIncoming(36, ServerMapDataPacket.class); this.registerIncoming(0x24, ServerMapDataPacket.class);
this.registerIncoming(37, ServerEntityPositionPacket.class); this.registerIncoming(0x25, ServerEntityPositionPacket.class);
this.registerIncoming(38, ServerEntityPositionRotationPacket.class); this.registerIncoming(0x26, ServerEntityPositionRotationPacket.class);
this.registerIncoming(39, ServerEntityRotationPacket.class); this.registerIncoming(0x27, ServerEntityRotationPacket.class);
this.registerIncoming(40, ServerEntityMovementPacket.class); this.registerIncoming(0x28, ServerEntityMovementPacket.class);
this.registerIncoming(41, ServerVehicleMovePacket.class); this.registerIncoming(0x29, ServerVehicleMovePacket.class);
this.registerIncoming(42, ServerOpenTileEntityEditorPacket.class); this.registerIncoming(0x2A, ServerOpenTileEntityEditorPacket.class);
this.registerIncoming(43, ServerPlayerAbilitiesPacket.class); this.registerIncoming(0x2B, ServerPlayerAbilitiesPacket.class);
this.registerIncoming(44, ServerCombatPacket.class); this.registerIncoming(0x2C, ServerCombatPacket.class);
this.registerIncoming(45, ServerPlayerListEntryPacket.class); this.registerIncoming(0x2D, ServerPlayerListEntryPacket.class);
this.registerIncoming(46, ServerPlayerPositionRotationPacket.class); this.registerIncoming(0x2E, ServerPlayerPositionRotationPacket.class);
this.registerIncoming(47, ServerPlayerUseBedPacket.class); this.registerIncoming(0x2F, ServerPlayerUseBedPacket.class);
this.registerIncoming(48, ServerEntityDestroyPacket.class); this.registerIncoming(0x30, ServerEntityDestroyPacket.class);
this.registerIncoming(49, ServerEntityRemoveEffectPacket.class); this.registerIncoming(0x31, ServerEntityRemoveEffectPacket.class);
this.registerIncoming(50, ServerResourcePackSendPacket.class); this.registerIncoming(0x32, ServerResourcePackSendPacket.class);
this.registerIncoming(51, ServerRespawnPacket.class); this.registerIncoming(0x33, ServerRespawnPacket.class);
this.registerIncoming(52, ServerEntityHeadLookPacket.class); this.registerIncoming(0x34, ServerEntityHeadLookPacket.class);
this.registerIncoming(53, ServerWorldBorderPacket.class); this.registerIncoming(0x35, ServerWorldBorderPacket.class);
this.registerIncoming(54, ServerSwitchCameraPacket.class); this.registerIncoming(0x36, ServerSwitchCameraPacket.class);
this.registerIncoming(55, ServerPlayerChangeHeldItemPacket.class); this.registerIncoming(0x37, ServerPlayerChangeHeldItemPacket.class);
this.registerIncoming(56, ServerDisplayScoreboardPacket.class); this.registerIncoming(0x38, ServerDisplayScoreboardPacket.class);
this.registerIncoming(57, ServerEntityMetadataPacket.class); this.registerIncoming(0x39, ServerEntityMetadataPacket.class);
this.registerIncoming(58, ServerEntityAttachPacket.class); this.registerIncoming(0x3A, ServerEntityAttachPacket.class);
this.registerIncoming(59, ServerEntityVelocityPacket.class); this.registerIncoming(0x3B, ServerEntityVelocityPacket.class);
this.registerIncoming(60, ServerEntityEquipmentPacket.class); this.registerIncoming(0x3C, ServerEntityEquipmentPacket.class);
this.registerIncoming(61, ServerPlayerSetExperiencePacket.class); this.registerIncoming(0x3D, ServerPlayerSetExperiencePacket.class);
this.registerIncoming(62, ServerPlayerHealthPacket.class); this.registerIncoming(0x3E, ServerPlayerHealthPacket.class);
this.registerIncoming(63, ServerScoreboardObjectivePacket.class); this.registerIncoming(0x3F, ServerScoreboardObjectivePacket.class);
this.registerIncoming(64, ServerEntitySetPassengersPacket.class); this.registerIncoming(0x40, ServerEntitySetPassengersPacket.class);
this.registerIncoming(65, ServerTeamPacket.class); this.registerIncoming(0x41, ServerTeamPacket.class);
this.registerIncoming(66, ServerUpdateScorePacket.class); this.registerIncoming(0x42, ServerUpdateScorePacket.class);
this.registerIncoming(67, ServerSpawnPositionPacket.class); this.registerIncoming(0x43, ServerSpawnPositionPacket.class);
this.registerIncoming(68, ServerUpdateTimePacket.class); this.registerIncoming(0x44, ServerUpdateTimePacket.class);
this.registerIncoming(69, ServerTitlePacket.class); this.registerIncoming(0x45, ServerTitlePacket.class);
this.registerIncoming(70, ServerUpdateSignPacket.class); this.registerIncoming(0x46, ServerPlayBuiltinSoundPacket.class);
this.registerIncoming(71, ServerPlayBuiltinSoundPacket.class); this.registerIncoming(0x47, ServerPlayerListDataPacket.class);
this.registerIncoming(72, ServerPlayerListDataPacket.class); this.registerIncoming(0x48, ServerEntityCollectItemPacket.class);
this.registerIncoming(73, ServerEntityCollectItemPacket.class); this.registerIncoming(0x49, ServerEntityTeleportPacket.class);
this.registerIncoming(74, ServerEntityTeleportPacket.class); this.registerIncoming(0x4A, ServerEntityPropertiesPacket.class);
this.registerIncoming(75, ServerEntityPropertiesPacket.class); this.registerIncoming(0x4B, ServerEntityEffectPacket.class);
this.registerIncoming(76, ServerEntityEffectPacket.class);
this.registerOutgoing(0, ClientTeleportConfirmPacket.class); this.registerOutgoing(0x00, ClientTeleportConfirmPacket.class);
this.registerOutgoing(1, ClientTabCompletePacket.class); this.registerOutgoing(0x01, ClientTabCompletePacket.class);
this.registerOutgoing(2, ClientChatPacket.class); this.registerOutgoing(0x02, ClientChatPacket.class);
this.registerOutgoing(3, ClientRequestPacket.class); this.registerOutgoing(0x03, ClientRequestPacket.class);
this.registerOutgoing(4, ClientSettingsPacket.class); this.registerOutgoing(0x04, ClientSettingsPacket.class);
this.registerOutgoing(5, ClientConfirmTransactionPacket.class); this.registerOutgoing(0x05, ClientConfirmTransactionPacket.class);
this.registerOutgoing(6, ClientEnchantItemPacket.class); this.registerOutgoing(0x06, ClientEnchantItemPacket.class);
this.registerOutgoing(7, ClientWindowActionPacket.class); this.registerOutgoing(0x07, ClientWindowActionPacket.class);
this.registerOutgoing(8, ClientCloseWindowPacket.class); this.registerOutgoing(0x08, ClientCloseWindowPacket.class);
this.registerOutgoing(9, ClientPluginMessagePacket.class); this.registerOutgoing(0x09, ClientPluginMessagePacket.class);
this.registerOutgoing(10, ClientPlayerInteractEntityPacket.class); this.registerOutgoing(0x0A, ClientPlayerInteractEntityPacket.class);
this.registerOutgoing(11, ClientKeepAlivePacket.class); this.registerOutgoing(0x0B, ClientKeepAlivePacket.class);
this.registerOutgoing(12, ClientPlayerPositionPacket.class); this.registerOutgoing(0x0C, ClientPlayerPositionPacket.class);
this.registerOutgoing(13, ClientPlayerPositionRotationPacket.class); this.registerOutgoing(0x0D, ClientPlayerPositionRotationPacket.class);
this.registerOutgoing(14, ClientPlayerRotationPacket.class); this.registerOutgoing(0x0E, ClientPlayerRotationPacket.class);
this.registerOutgoing(15, ClientPlayerMovementPacket.class); this.registerOutgoing(0x0F, ClientPlayerMovementPacket.class);
this.registerOutgoing(16, ClientVehicleMovePacket.class); this.registerOutgoing(0x10, ClientVehicleMovePacket.class);
this.registerOutgoing(17, ClientSteerBoatPacket.class); this.registerOutgoing(0x11, ClientSteerBoatPacket.class);
this.registerOutgoing(18, ClientPlayerAbilitiesPacket.class); this.registerOutgoing(0x12, ClientPlayerAbilitiesPacket.class);
this.registerOutgoing(19, ClientPlayerActionPacket.class); this.registerOutgoing(0x13, ClientPlayerActionPacket.class);
this.registerOutgoing(20, ClientPlayerStatePacket.class); this.registerOutgoing(0x14, ClientPlayerStatePacket.class);
this.registerOutgoing(21, ClientSteerVehiclePacket.class); this.registerOutgoing(0x15, ClientSteerVehiclePacket.class);
this.registerOutgoing(22, ClientResourcePackStatusPacket.class); this.registerOutgoing(0x16, ClientResourcePackStatusPacket.class);
this.registerOutgoing(23, ClientPlayerChangeHeldItemPacket.class); this.registerOutgoing(0x17, ClientPlayerChangeHeldItemPacket.class);
this.registerOutgoing(24, ClientCreativeInventoryActionPacket.class); this.registerOutgoing(0x18, ClientCreativeInventoryActionPacket.class);
this.registerOutgoing(25, ClientUpdateSignPacket.class); this.registerOutgoing(0x19, ClientUpdateSignPacket.class);
this.registerOutgoing(26, ClientPlayerSwingArmPacket.class); this.registerOutgoing(0x1A, ClientPlayerSwingArmPacket.class);
this.registerOutgoing(27, ClientSpectatePacket.class); this.registerOutgoing(0x1B, ClientSpectatePacket.class);
this.registerOutgoing(28, ClientPlayerPlaceBlockPacket.class); this.registerOutgoing(0x1C, ClientPlayerPlaceBlockPacket.class);
this.registerOutgoing(29, ClientPlayerUseItemPacket.class); this.registerOutgoing(0x1D, ClientPlayerUseItemPacket.class);
} }
private void initServerGame(Session session) { private void initServerGame(Session session) {
this.registerIncoming(0, ClientTeleportConfirmPacket.class); this.registerIncoming(0x00, ClientTeleportConfirmPacket.class);
this.registerIncoming(1, ClientTabCompletePacket.class); this.registerIncoming(0x01, ClientTabCompletePacket.class);
this.registerIncoming(2, ClientChatPacket.class); this.registerIncoming(0x02, ClientChatPacket.class);
this.registerIncoming(3, ClientRequestPacket.class); this.registerIncoming(0x03, ClientRequestPacket.class);
this.registerIncoming(4, ClientSettingsPacket.class); this.registerIncoming(0x04, ClientSettingsPacket.class);
this.registerIncoming(5, ClientConfirmTransactionPacket.class); this.registerIncoming(0x05, ClientConfirmTransactionPacket.class);
this.registerIncoming(6, ClientEnchantItemPacket.class); this.registerIncoming(0x06, ClientEnchantItemPacket.class);
this.registerIncoming(7, ClientWindowActionPacket.class); this.registerIncoming(0x07, ClientWindowActionPacket.class);
this.registerIncoming(8, ClientCloseWindowPacket.class); this.registerIncoming(0x08, ClientCloseWindowPacket.class);
this.registerIncoming(9, ClientPluginMessagePacket.class); this.registerIncoming(0x09, ClientPluginMessagePacket.class);
this.registerIncoming(10, ClientPlayerInteractEntityPacket.class); this.registerIncoming(0x0A, ClientPlayerInteractEntityPacket.class);
this.registerIncoming(11, ClientKeepAlivePacket.class); this.registerIncoming(0x0B, ClientKeepAlivePacket.class);
this.registerIncoming(12, ClientPlayerPositionPacket.class); this.registerIncoming(0x0C, ClientPlayerPositionPacket.class);
this.registerIncoming(13, ClientPlayerPositionRotationPacket.class); this.registerIncoming(0x0D, ClientPlayerPositionRotationPacket.class);
this.registerIncoming(14, ClientPlayerRotationPacket.class); this.registerIncoming(0x0E, ClientPlayerRotationPacket.class);
this.registerIncoming(15, ClientPlayerMovementPacket.class); this.registerIncoming(0x0F, ClientPlayerMovementPacket.class);
this.registerIncoming(16, ClientVehicleMovePacket.class); this.registerIncoming(0x10, ClientVehicleMovePacket.class);
this.registerIncoming(17, ClientSteerBoatPacket.class); this.registerIncoming(0x11, ClientSteerBoatPacket.class);
this.registerIncoming(18, ClientPlayerAbilitiesPacket.class); this.registerIncoming(0x12, ClientPlayerAbilitiesPacket.class);
this.registerIncoming(19, ClientPlayerActionPacket.class); this.registerIncoming(0x13, ClientPlayerActionPacket.class);
this.registerIncoming(20, ClientPlayerStatePacket.class); this.registerIncoming(0x14, ClientPlayerStatePacket.class);
this.registerIncoming(21, ClientSteerVehiclePacket.class); this.registerIncoming(0x15, ClientSteerVehiclePacket.class);
this.registerIncoming(22, ClientResourcePackStatusPacket.class); this.registerIncoming(0x16, ClientResourcePackStatusPacket.class);
this.registerIncoming(23, ClientPlayerChangeHeldItemPacket.class); this.registerIncoming(0x17, ClientPlayerChangeHeldItemPacket.class);
this.registerIncoming(24, ClientCreativeInventoryActionPacket.class); this.registerIncoming(0x18, ClientCreativeInventoryActionPacket.class);
this.registerIncoming(25, ClientUpdateSignPacket.class); this.registerIncoming(0x19, ClientUpdateSignPacket.class);
this.registerIncoming(26, ClientPlayerSwingArmPacket.class); this.registerIncoming(0x1A, ClientPlayerSwingArmPacket.class);
this.registerIncoming(27, ClientSpectatePacket.class); this.registerIncoming(0x1B, ClientSpectatePacket.class);
this.registerIncoming(28, ClientPlayerPlaceBlockPacket.class); this.registerIncoming(0x1C, ClientPlayerPlaceBlockPacket.class);
this.registerIncoming(29, ClientPlayerUseItemPacket.class); this.registerIncoming(0x1D, ClientPlayerUseItemPacket.class);
this.registerOutgoing(0, ServerSpawnObjectPacket.class); this.registerOutgoing(0x00, ServerSpawnObjectPacket.class);
this.registerOutgoing(1, ServerSpawnExpOrbPacket.class); this.registerOutgoing(0x01, ServerSpawnExpOrbPacket.class);
this.registerOutgoing(2, ServerSpawnGlobalEntityPacket.class); this.registerOutgoing(0x02, ServerSpawnGlobalEntityPacket.class);
this.registerOutgoing(3, ServerSpawnMobPacket.class); this.registerOutgoing(0x03, ServerSpawnMobPacket.class);
this.registerOutgoing(4, ServerSpawnPaintingPacket.class); this.registerOutgoing(0x04, ServerSpawnPaintingPacket.class);
this.registerOutgoing(5, ServerSpawnPlayerPacket.class); this.registerOutgoing(0x05, ServerSpawnPlayerPacket.class);
this.registerOutgoing(6, ServerEntityAnimationPacket.class); this.registerOutgoing(0x06, ServerEntityAnimationPacket.class);
this.registerOutgoing(7, ServerStatisticsPacket.class); this.registerOutgoing(0x07, ServerStatisticsPacket.class);
this.registerOutgoing(8, ServerBlockBreakAnimPacket.class); this.registerOutgoing(0x08, ServerBlockBreakAnimPacket.class);
this.registerOutgoing(9, ServerUpdateTileEntityPacket.class); this.registerOutgoing(0x09, ServerUpdateTileEntityPacket.class);
this.registerOutgoing(10, ServerBlockValuePacket.class); this.registerOutgoing(0x0A, ServerBlockValuePacket.class);
this.registerOutgoing(11, ServerBlockChangePacket.class); this.registerOutgoing(0x0B, ServerBlockChangePacket.class);
this.registerOutgoing(12, ServerBossBarPacket.class); this.registerOutgoing(0x0C, ServerBossBarPacket.class);
this.registerOutgoing(13, ServerDifficultyPacket.class); this.registerOutgoing(0x0D, ServerDifficultyPacket.class);
this.registerOutgoing(14, ServerTabCompletePacket.class); this.registerOutgoing(0x0E, ServerTabCompletePacket.class);
this.registerOutgoing(15, ServerChatPacket.class); this.registerOutgoing(0x0F, ServerChatPacket.class);
this.registerOutgoing(16, ServerMultiBlockChangePacket.class); this.registerOutgoing(0x10, ServerMultiBlockChangePacket.class);
this.registerOutgoing(17, ServerConfirmTransactionPacket.class); this.registerOutgoing(0x11, ServerConfirmTransactionPacket.class);
this.registerOutgoing(18, ServerCloseWindowPacket.class); this.registerOutgoing(0x12, ServerCloseWindowPacket.class);
this.registerOutgoing(19, ServerOpenWindowPacket.class); this.registerOutgoing(0x13, ServerOpenWindowPacket.class);
this.registerOutgoing(20, ServerWindowItemsPacket.class); this.registerOutgoing(0x14, ServerWindowItemsPacket.class);
this.registerOutgoing(21, ServerWindowPropertyPacket.class); this.registerOutgoing(0x15, ServerWindowPropertyPacket.class);
this.registerOutgoing(22, ServerSetSlotPacket.class); this.registerOutgoing(0x16, ServerSetSlotPacket.class);
this.registerOutgoing(23, ServerSetCooldownPacket.class); this.registerOutgoing(0x17, ServerSetCooldownPacket.class);
this.registerOutgoing(24, ServerPluginMessagePacket.class); this.registerOutgoing(0x18, ServerPluginMessagePacket.class);
this.registerOutgoing(25, ServerPlaySoundPacket.class); this.registerOutgoing(0x19, ServerPlaySoundPacket.class);
this.registerOutgoing(26, ServerDisconnectPacket.class); this.registerOutgoing(0x1A, ServerDisconnectPacket.class);
this.registerOutgoing(27, ServerEntityStatusPacket.class); this.registerOutgoing(0x1B, ServerEntityStatusPacket.class);
this.registerOutgoing(28, ServerExplosionPacket.class); this.registerOutgoing(0x1C, ServerExplosionPacket.class);
this.registerOutgoing(29, ServerUnloadChunkPacket.class); this.registerOutgoing(0x1D, ServerUnloadChunkPacket.class);
this.registerOutgoing(30, ServerNotifyClientPacket.class); this.registerOutgoing(0x1E, ServerNotifyClientPacket.class);
this.registerOutgoing(31, ServerKeepAlivePacket.class); this.registerOutgoing(0x1F, ServerKeepAlivePacket.class);
this.registerOutgoing(32, ServerChunkDataPacket.class); this.registerOutgoing(0x20, ServerChunkDataPacket.class);
this.registerOutgoing(33, ServerPlayEffectPacket.class); this.registerOutgoing(0x21, ServerPlayEffectPacket.class);
this.registerOutgoing(34, ServerSpawnParticlePacket.class); this.registerOutgoing(0x22, ServerSpawnParticlePacket.class);
this.registerOutgoing(35, ServerJoinGamePacket.class); this.registerOutgoing(0x23, ServerJoinGamePacket.class);
this.registerOutgoing(36, ServerMapDataPacket.class); this.registerOutgoing(0x24, ServerMapDataPacket.class);
this.registerOutgoing(37, ServerEntityPositionPacket.class); this.registerOutgoing(0x25, ServerEntityPositionPacket.class);
this.registerOutgoing(38, ServerEntityPositionRotationPacket.class); this.registerOutgoing(0x26, ServerEntityPositionRotationPacket.class);
this.registerOutgoing(39, ServerEntityRotationPacket.class); this.registerOutgoing(0x27, ServerEntityRotationPacket.class);
this.registerOutgoing(40, ServerEntityMovementPacket.class); this.registerOutgoing(0x28, ServerEntityMovementPacket.class);
this.registerOutgoing(41, ServerVehicleMovePacket.class); this.registerOutgoing(0x29, ServerVehicleMovePacket.class);
this.registerOutgoing(42, ServerOpenTileEntityEditorPacket.class); this.registerOutgoing(0x2A, ServerOpenTileEntityEditorPacket.class);
this.registerOutgoing(43, ServerPlayerAbilitiesPacket.class); this.registerOutgoing(0x2B, ServerPlayerAbilitiesPacket.class);
this.registerOutgoing(44, ServerCombatPacket.class); this.registerOutgoing(0x2C, ServerCombatPacket.class);
this.registerOutgoing(45, ServerPlayerListEntryPacket.class); this.registerOutgoing(0x2D, ServerPlayerListEntryPacket.class);
this.registerOutgoing(46, ServerPlayerPositionRotationPacket.class); this.registerOutgoing(0x2E, ServerPlayerPositionRotationPacket.class);
this.registerOutgoing(47, ServerPlayerUseBedPacket.class); this.registerOutgoing(0x2F, ServerPlayerUseBedPacket.class);
this.registerOutgoing(48, ServerEntityDestroyPacket.class); this.registerOutgoing(0x30, ServerEntityDestroyPacket.class);
this.registerOutgoing(49, ServerEntityRemoveEffectPacket.class); this.registerOutgoing(0x31, ServerEntityRemoveEffectPacket.class);
this.registerOutgoing(50, ServerResourcePackSendPacket.class); this.registerOutgoing(0x32, ServerResourcePackSendPacket.class);
this.registerOutgoing(51, ServerRespawnPacket.class); this.registerOutgoing(0x33, ServerRespawnPacket.class);
this.registerOutgoing(52, ServerEntityHeadLookPacket.class); this.registerOutgoing(0x34, ServerEntityHeadLookPacket.class);
this.registerOutgoing(53, ServerWorldBorderPacket.class); this.registerOutgoing(0x35, ServerWorldBorderPacket.class);
this.registerOutgoing(54, ServerSwitchCameraPacket.class); this.registerOutgoing(0x36, ServerSwitchCameraPacket.class);
this.registerOutgoing(55, ServerPlayerChangeHeldItemPacket.class); this.registerOutgoing(0x37, ServerPlayerChangeHeldItemPacket.class);
this.registerOutgoing(56, ServerDisplayScoreboardPacket.class); this.registerOutgoing(0x38, ServerDisplayScoreboardPacket.class);
this.registerOutgoing(57, ServerEntityMetadataPacket.class); this.registerOutgoing(0x39, ServerEntityMetadataPacket.class);
this.registerOutgoing(58, ServerEntityAttachPacket.class); this.registerOutgoing(0x3A, ServerEntityAttachPacket.class);
this.registerOutgoing(59, ServerEntityVelocityPacket.class); this.registerOutgoing(0x3B, ServerEntityVelocityPacket.class);
this.registerOutgoing(60, ServerEntityEquipmentPacket.class); this.registerOutgoing(0x3C, ServerEntityEquipmentPacket.class);
this.registerOutgoing(61, ServerPlayerSetExperiencePacket.class); this.registerOutgoing(0x3D, ServerPlayerSetExperiencePacket.class);
this.registerOutgoing(62, ServerPlayerHealthPacket.class); this.registerOutgoing(0x3E, ServerPlayerHealthPacket.class);
this.registerOutgoing(63, ServerScoreboardObjectivePacket.class); this.registerOutgoing(0x3F, ServerScoreboardObjectivePacket.class);
this.registerOutgoing(64, ServerEntitySetPassengersPacket.class); this.registerOutgoing(0x40, ServerEntitySetPassengersPacket.class);
this.registerOutgoing(65, ServerTeamPacket.class); this.registerOutgoing(0x41, ServerTeamPacket.class);
this.registerOutgoing(66, ServerUpdateScorePacket.class); this.registerOutgoing(0x42, ServerUpdateScorePacket.class);
this.registerOutgoing(67, ServerSpawnPositionPacket.class); this.registerOutgoing(0x43, ServerSpawnPositionPacket.class);
this.registerOutgoing(68, ServerUpdateTimePacket.class); this.registerOutgoing(0x44, ServerUpdateTimePacket.class);
this.registerOutgoing(69, ServerTitlePacket.class); this.registerOutgoing(0x45, ServerTitlePacket.class);
this.registerOutgoing(70, ServerUpdateSignPacket.class); this.registerOutgoing(0x46, ServerPlayBuiltinSoundPacket.class);
this.registerOutgoing(71, ServerPlayBuiltinSoundPacket.class); this.registerOutgoing(0x47, ServerPlayerListDataPacket.class);
this.registerOutgoing(72, ServerPlayerListDataPacket.class); this.registerOutgoing(0x48, ServerEntityCollectItemPacket.class);
this.registerOutgoing(73, ServerEntityCollectItemPacket.class); this.registerOutgoing(0x49, ServerEntityTeleportPacket.class);
this.registerOutgoing(74, ServerEntityTeleportPacket.class); this.registerOutgoing(0x4A, ServerEntityPropertiesPacket.class);
this.registerOutgoing(75, ServerEntityPropertiesPacket.class); this.registerOutgoing(0x4B, ServerEntityEffectPacket.class);
this.registerOutgoing(76, ServerEntityEffectPacket.class);
} }
private void initClientStatus(Session session) { private void initClientStatus(Session session) {
this.registerIncoming(0, StatusResponsePacket.class); this.registerIncoming(0x00, StatusResponsePacket.class);
this.registerIncoming(1, StatusPongPacket.class); this.registerIncoming(0x01, StatusPongPacket.class);
this.registerOutgoing(0, StatusQueryPacket.class); this.registerOutgoing(0x00, StatusQueryPacket.class);
this.registerOutgoing(1, StatusPingPacket.class); this.registerOutgoing(0x01, StatusPingPacket.class);
} }
private void initServerStatus(Session session) { private void initServerStatus(Session session) {
this.registerIncoming(0, StatusQueryPacket.class); this.registerIncoming(0x00, StatusQueryPacket.class);
this.registerIncoming(1, StatusPingPacket.class); this.registerIncoming(0x01, StatusPingPacket.class);
this.registerOutgoing(0, StatusResponsePacket.class); this.registerOutgoing(0x00, StatusResponsePacket.class);
this.registerOutgoing(1, StatusPongPacket.class); this.registerOutgoing(0x01, StatusPongPacket.class);
} }
} }

View file

@ -492,6 +492,7 @@ public class MagicValues {
register(UpdatedTileType.BANNER, 6); register(UpdatedTileType.BANNER, 6);
register(UpdatedTileType.STRUCTURE_BLOCK, 7); register(UpdatedTileType.STRUCTURE_BLOCK, 7);
register(UpdatedTileType.END_GATEWAY, 8); register(UpdatedTileType.END_GATEWAY, 8);
register(UpdatedTileType.SIGN, 9);
register(ClientNotification.INVALID_BED, 0); register(ClientNotification.INVALID_BED, 0);
register(ClientNotification.START_RAIN, 2); register(ClientNotification.START_RAIN, 2);

View file

@ -1,18 +1,21 @@
package org.spacehq.mc.protocol.data.game.chunk; package org.spacehq.mc.protocol.data.game.chunk;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
public class Column { public class Column {
private int x; private int x;
private int z; private int z;
private Chunk chunks[]; private Chunk chunks[];
private byte biomeData[]; private byte biomeData[];
private CompoundTag tileEntities[];
private boolean skylight; private boolean skylight;
public Column(int x, int z, Chunk chunks[]) { public Column(int x, int z, Chunk chunks[], CompoundTag tileEntities[]) {
this(x, z, chunks, null); this(x, z, chunks, null, tileEntities);
} }
public Column(int x, int z, Chunk chunks[], byte biomeData[]) { public Column(int x, int z, Chunk chunks[], byte biomeData[], CompoundTag tileEntities[]) {
if(chunks.length != 16) { if(chunks.length != 16) {
throw new IllegalArgumentException("Chunk array length must be 16."); throw new IllegalArgumentException("Chunk array length must be 16.");
} }
@ -23,9 +26,9 @@ public class Column {
this.skylight = false; this.skylight = false;
boolean noSkylight = false; boolean noSkylight = false;
for(int index = 0; index < chunks.length; index++) { for (Chunk chunk : chunks) {
if(chunks[index] != null) { if (chunk != null) {
if(chunks[index].getSkyLight() == null) { if (chunk.getSkyLight() == null) {
noSkylight = true; noSkylight = true;
} else { } else {
this.skylight = true; this.skylight = true;
@ -41,6 +44,7 @@ public class Column {
this.z = z; this.z = z;
this.chunks = chunks; this.chunks = chunks;
this.biomeData = biomeData; this.biomeData = biomeData;
this.tileEntities = tileEntities;
} }
public int getX() { public int getX() {
@ -63,6 +67,10 @@ public class Column {
return this.biomeData; return this.biomeData;
} }
public CompoundTag[] getTileEntities() {
return this.tileEntities;
}
public boolean hasSkylight() { public boolean hasSkylight() {
return this.skylight; return this.skylight;
} }

View file

@ -8,5 +8,6 @@ public enum UpdatedTileType {
FLOWER_POT, FLOWER_POT,
BANNER, BANNER,
STRUCTURE_BLOCK, STRUCTURE_BLOCK,
END_GATEWAY; END_GATEWAY,
SIGN;
} }

View file

@ -3,6 +3,7 @@ package org.spacehq.mc.protocol.packet.ingame.server.world;
import org.spacehq.mc.protocol.data.game.chunk.Column; import org.spacehq.mc.protocol.data.game.chunk.Column;
import org.spacehq.mc.protocol.util.NetUtil; import org.spacehq.mc.protocol.util.NetUtil;
import org.spacehq.mc.protocol.util.ReflectionToString; import org.spacehq.mc.protocol.util.ReflectionToString;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import org.spacehq.packetlib.io.NetInput; import org.spacehq.packetlib.io.NetInput;
import org.spacehq.packetlib.io.NetOutput; import org.spacehq.packetlib.io.NetOutput;
import org.spacehq.packetlib.io.stream.StreamNetOutput; import org.spacehq.packetlib.io.stream.StreamNetOutput;
@ -33,8 +34,11 @@ public class ServerChunkDataPacket implements Packet {
boolean fullChunk = in.readBoolean(); boolean fullChunk = in.readBoolean();
int chunkMask = in.readVarInt(); int chunkMask = in.readVarInt();
byte data[] = in.readBytes(in.readVarInt()); byte data[] = in.readBytes(in.readVarInt());
CompoundTag[] tileEntities = new CompoundTag[in.readVarInt()];
this.column = NetUtil.readColumn(data, x, z, fullChunk, false, chunkMask); for (int i = 0; i < tileEntities.length; i++) {
tileEntities[i] = NetUtil.readNBT(in);
}
this.column = NetUtil.readColumn(data, x, z, fullChunk, false, chunkMask, tileEntities);
} }
@Override @Override
@ -49,6 +53,16 @@ public class ServerChunkDataPacket implements Packet {
out.writeVarInt(mask); out.writeVarInt(mask);
out.writeVarInt(byteOut.size()); out.writeVarInt(byteOut.size());
out.writeBytes(byteOut.toByteArray(), byteOut.size()); out.writeBytes(byteOut.toByteArray(), byteOut.size());
ByteArrayOutputStream tileEntitiesByteOut = new ByteArrayOutputStream();
NetOutput tileEntitiesNetOut = new StreamNetOutput(tileEntitiesByteOut);
for (CompoundTag compoundTag : column.getTileEntities()) {
NetUtil.writeNBT(tileEntitiesNetOut, compoundTag);
}
out.writeVarInt(column.getTileEntities().length);
out.writeBytes(tileEntitiesByteOut.toByteArray(), tileEntitiesByteOut.size());
} }
@Override @Override

View file

@ -1,77 +0,0 @@
package org.spacehq.mc.protocol.packet.ingame.server.world;
import org.spacehq.mc.protocol.data.game.entity.metadata.Position;
import org.spacehq.mc.protocol.data.message.Message;
import org.spacehq.mc.protocol.util.NetUtil;
import org.spacehq.mc.protocol.util.ReflectionToString;
import org.spacehq.packetlib.io.NetInput;
import org.spacehq.packetlib.io.NetOutput;
import org.spacehq.packetlib.packet.Packet;
import java.io.IOException;
public class ServerUpdateSignPacket implements Packet {
private Position position;
private Message lines[];
@SuppressWarnings("unused")
private ServerUpdateSignPacket() {
}
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!");
}
this.position = position;
this.lines = lines;
}
public Position getPosition() {
return this.position;
}
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 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;
}
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;
}
@Override
public String toString() {
return ReflectionToString.toString(this);
}
}

View file

@ -236,7 +236,7 @@ public class NetUtil {
out.writeByte(255); out.writeByte(255);
} }
public static Column readColumn(byte data[], int x, int z, boolean fullChunk, boolean hasSkylight, int mask) throws IOException { public static Column readColumn(byte data[], int x, int z, boolean fullChunk, boolean hasSkylight, int mask, CompoundTag[] tileEntities) throws IOException {
NetInput in = new StreamNetInput(new ByteArrayInputStream(data)); NetInput in = new StreamNetInput(new ByteArrayInputStream(data));
Exception ex = null; Exception ex = null;
Column column = null; Column column = null;
@ -255,15 +255,14 @@ public class NetUtil {
if(fullChunk) { if(fullChunk) {
biomeData = in.readBytes(256); biomeData = in.readBytes(256);
} }
column = new Column(x, z, chunks, biomeData, tileEntities);
column = new Column(x, z, chunks, biomeData);
} catch(Exception e) { } catch(Exception e) {
ex = e; ex = e;
} }
// Unfortunately, this is needed to detect whether the chunks contain skylight or not. // Unfortunately, this is needed to detect whether the chunks contain skylight or not.
if((in.available() > 0 || ex != null) && !hasSkylight) { if((in.available() > 0 || ex != null) && !hasSkylight) {
return readColumn(data, x, z, fullChunk, true, mask); return readColumn(data, x, z, fullChunk, true, mask, tileEntities);
} else if(ex != null) { } else if(ex != null) {
throw new IOException("Failed to read chunk data.", ex); throw new IOException("Failed to read chunk data.", ex);
} }