This commit is contained in:
Steven Smith 2014-08-04 11:28:33 -07:00
parent 3963c52123
commit b244f17d77
11 changed files with 127 additions and 18 deletions

View file

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

View file

@ -279,6 +279,7 @@ public class MinecraftProtocol extends PacketProtocol {
this.registerIncoming(68, ServerWorldBorderPacket.class);
this.registerIncoming(69, ServerSetCompressionPacket.class);
this.registerIncoming(70, ServerPlayerListDataPacket.class);
this.registerIncoming(71, ServerResourcePackSendPacket.class);
this.registerOutgoing(0, ClientKeepAlivePacket.class);
this.registerOutgoing(1, ClientChatPacket.class);
@ -305,6 +306,7 @@ public class MinecraftProtocol extends PacketProtocol {
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) {
@ -333,6 +335,7 @@ public class MinecraftProtocol extends PacketProtocol {
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);
@ -405,6 +408,7 @@ public class MinecraftProtocol extends PacketProtocol {
this.registerOutgoing(68, ServerWorldBorderPacket.class);
this.registerOutgoing(69, ServerSetCompressionPacket.class);
this.registerOutgoing(70, ServerPlayerListDataPacket.class);
this.registerOutgoing(71, ServerResourcePackSendPacket.class);
}
private void initClientStatus(Session session) {

View file

@ -3,8 +3,8 @@ package org.spacehq.mc.protocol;
public class ProtocolConstants {
// General Constants
public static final String GAME_VERSION = "14w29b";
public static final int PROTOCOL_VERSION = 29;
public static final String GAME_VERSION = "14w31a";
public static final int PROTOCOL_VERSION = 32;
// Client Key Constants
public static final String PROFILE_KEY = "profile";

View file

@ -9,6 +9,7 @@ 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.world.GenericSound;
import org.spacehq.mc.protocol.data.game.values.world.Particle;
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;
@ -18,7 +19,6 @@ 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.notify.ClientNotification;
import org.spacehq.mc.protocol.data.game.values.world.notify.DemoMessageValue;
import org.spacehq.mc.protocol.data.game.values.world.Particle;
import java.util.HashMap;
import java.util.Map;
@ -792,6 +792,11 @@ public class MagicValues {
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) {

View file

@ -0,0 +1,8 @@
package org.spacehq.mc.protocol.data.game.values;
public enum ResourcePackStatus {
SUCCESSFULLY_LOADED,
DECLINED,
FAILED_DOWNLOAD,
ACCEPTED;
}

View file

@ -31,13 +31,12 @@ public class ClientPluginMessagePacket implements Packet {
@Override
public void read(NetInput in) throws IOException {
this.channel = in.readString();
this.data = in.readBytes(in.readVarInt());
this.data = in.readBytes(in.available());
}
@Override
public void write(NetOutput out) throws IOException {
out.writeString(this.channel);
out.writeVarInt(this.data.length);
out.writeBytes(this.data);
}

View file

@ -0,0 +1,48 @@
package org.spacehq.mc.protocol.packet.ingame.client;
import org.spacehq.mc.protocol.data.game.values.MagicValues;
import org.spacehq.mc.protocol.data.game.values.ResourcePackStatus;
import org.spacehq.packetlib.io.NetInput;
import org.spacehq.packetlib.io.NetOutput;
import org.spacehq.packetlib.packet.Packet;
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;
}
}

View file

@ -24,12 +24,12 @@ public class ServerKeepAlivePacket implements Packet {
@Override
public void read(NetInput in) throws IOException {
this.id = in.readInt();
this.id = in.readVarInt();
}
@Override
public void write(NetOutput out) throws IOException {
out.writeInt(this.id);
out.writeVarInt(this.id);
}
@Override

View file

@ -31,13 +31,12 @@ public class ServerPluginMessagePacket implements Packet {
@Override
public void read(NetInput in) throws IOException {
this.channel = in.readString();
this.data = in.readBytes(in.readVarInt());
this.data = in.readBytes(in.available());
}
@Override
public void write(NetOutput out) throws IOException {
out.writeString(this.channel);
out.writeVarInt(this.data.length);
out.writeBytes(this.data);
}

View file

@ -0,0 +1,46 @@
package org.spacehq.mc.protocol.packet.ingame.server;
import org.spacehq.packetlib.io.NetInput;
import org.spacehq.packetlib.io.NetOutput;
import org.spacehq.packetlib.packet.Packet;
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;
}
}

View file

@ -16,7 +16,7 @@ public class ServerWorldBorderPacket implements Packet {
private double oldRadius;
private double newRadius;
private int speed;
private long speed;
private double centerX;
private double centerY;
@ -36,7 +36,7 @@ public class ServerWorldBorderPacket implements Packet {
this.radius = radius;
}
public ServerWorldBorderPacket(double oldRadius, double newRadius, int speed) {
public ServerWorldBorderPacket(double oldRadius, double newRadius, long speed) {
this.action = WorldBorderAction.LERP_SIZE;
this.oldRadius = oldRadius;
this.newRadius = newRadius;
@ -49,7 +49,7 @@ public class ServerWorldBorderPacket implements Packet {
this.centerY = centerY;
}
public ServerWorldBorderPacket(double centerX, double centerY, double oldRadius, double newRadius, int speed, int portalTeleportBoundary, int warningTime, int warningBlocks) {
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;
@ -87,7 +87,7 @@ public class ServerWorldBorderPacket implements Packet {
return this.newRadius;
}
public int getSpeed() {
public long getSpeed() {
return this.speed;
}
@ -119,7 +119,7 @@ public class ServerWorldBorderPacket implements Packet {
} else if(this.action == WorldBorderAction.LERP_SIZE) {
this.oldRadius = in.readDouble();
this.newRadius = in.readDouble();
this.speed = in.readVarInt();
this.speed = in.readVarLong();
} else if(this.action == WorldBorderAction.SET_CENTER) {
this.centerX = in.readDouble();
this.centerY = in.readDouble();
@ -128,7 +128,7 @@ public class ServerWorldBorderPacket implements Packet {
this.centerY = in.readDouble();
this.oldRadius = in.readDouble();
this.newRadius = in.readDouble();
this.speed = in.readVarInt();
this.speed = in.readVarLong();
this.portalTeleportBoundary = in.readVarInt();
this.warningTime = in.readVarInt();
this.warningBlocks = in.readVarInt();
@ -147,7 +147,7 @@ public class ServerWorldBorderPacket implements Packet {
} else if(this.action == WorldBorderAction.LERP_SIZE) {
out.writeDouble(this.oldRadius);
out.writeDouble(this.newRadius);
out.writeVarInt(this.speed);
out.writeVarLong(this.speed);
} else if(this.action == WorldBorderAction.SET_CENTER) {
out.writeDouble(this.centerX);
out.writeDouble(this.centerY);
@ -156,7 +156,7 @@ public class ServerWorldBorderPacket implements Packet {
out.writeDouble(this.centerY);
out.writeDouble(this.oldRadius);
out.writeDouble(this.newRadius);
out.writeVarInt(this.speed);
out.writeVarLong(this.speed);
out.writeVarInt(this.portalTeleportBoundary);
out.writeVarInt(this.warningTime);
out.writeVarInt(this.warningBlocks);