diff --git a/src/main/java/org/spacehq/mc/protocol/MinecraftConstants.java b/src/main/java/org/spacehq/mc/protocol/MinecraftConstants.java index 17ddee10..85cfea6f 100644 --- a/src/main/java/org/spacehq/mc/protocol/MinecraftConstants.java +++ b/src/main/java/org/spacehq/mc/protocol/MinecraftConstants.java @@ -2,8 +2,8 @@ package org.spacehq.mc.protocol; public class MinecraftConstants { // General Constants - public static final String GAME_VERSION = "15w33c"; - public static final int PROTOCOL_VERSION = 57; + public static final String GAME_VERSION = "15w34d"; + public static final int PROTOCOL_VERSION = 58; // General Key Constants public static final String PROFILE_KEY = "profile"; 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 f534f0b9..2041575c 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 @@ -4,6 +4,7 @@ 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.EquipmentSlot; 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; @@ -911,6 +912,13 @@ public class MagicValues { register(BlockFace.SOUTH, 3); register(BlockFace.WEST, 4); register(BlockFace.EAST, 5); + + register(EquipmentSlot.MAIN_HAND, 0); + register(EquipmentSlot.OFF_HAND, 1); + register(EquipmentSlot.BOOTS, 2); + register(EquipmentSlot.LEGGINGS, 3); + register(EquipmentSlot.CHESTPLATE, 4); + register(EquipmentSlot.HELMET, 5); } private static void register(Enum key, Object value) { @@ -934,7 +942,7 @@ public class MagicValues { } } - return null; + throw new IllegalArgumentException("Value " + value + " has no mapping for key class " + keyType + "."); } @SuppressWarnings("unchecked") @@ -960,7 +968,7 @@ public class MagicValues { } } - return null; + throw new IllegalArgumentException("Key " + key + " has no mapping for value class " + valueType + "."); } } diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/EquipmentSlot.java b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/EquipmentSlot.java new file mode 100644 index 00000000..23db1df0 --- /dev/null +++ b/src/main/java/org/spacehq/mc/protocol/data/game/values/entity/EquipmentSlot.java @@ -0,0 +1,10 @@ +package org.spacehq.mc.protocol.data.game.values.entity; + +public enum EquipmentSlot { + MAIN_HAND, + OFF_HAND, + BOOTS, + LEGGINGS, + CHESTPLATE, + HELMET; +} 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 73e9ad59..c2e0a210 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 @@ -1,6 +1,8 @@ package org.spacehq.mc.protocol.packet.ingame.server.entity; 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.entity.EquipmentSlot; import org.spacehq.mc.protocol.util.NetUtil; import org.spacehq.packetlib.io.NetInput; import org.spacehq.packetlib.io.NetOutput; @@ -11,14 +13,14 @@ import java.io.IOException; public class ServerEntityEquipmentPacket implements Packet { private int entityId; - private int slot; + private EquipmentSlot slot; private ItemStack item; @SuppressWarnings("unused") private ServerEntityEquipmentPacket() { } - public ServerEntityEquipmentPacket(int entityId, int slot, ItemStack item) { + public ServerEntityEquipmentPacket(int entityId, EquipmentSlot slot, ItemStack item) { this.entityId = entityId; this.slot = slot; this.item = item; @@ -28,7 +30,7 @@ public class ServerEntityEquipmentPacket implements Packet { return this.entityId; } - public int getSlot() { + public EquipmentSlot getSlot() { return this.slot; } @@ -39,14 +41,14 @@ public class ServerEntityEquipmentPacket implements Packet { @Override public void read(NetInput in) throws IOException { this.entityId = in.readVarInt(); - this.slot = in.readVarInt(); + this.slot = MagicValues.key(EquipmentSlot.class, in.readVarInt()); this.item = NetUtil.readItem(in); } @Override public void write(NetOutput out) throws IOException { out.writeVarInt(this.entityId); - out.writeVarInt(this.slot); + out.writeVarInt(MagicValues.value(Integer.class, this.slot)); NetUtil.writeItem(out, this.item); } 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 8d0b7d02..87b055c8 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 @@ -12,6 +12,7 @@ public class ServerMapDataPacket implements Packet { private int mapId; private byte scale; + private boolean trackingPosition; private MapPlayer players[]; private MapData data; @@ -20,13 +21,14 @@ public class ServerMapDataPacket implements Packet { private ServerMapDataPacket() { } - public ServerMapDataPacket(int mapId, byte scale, MapPlayer players[]) { - this(mapId, scale, players, null); + public ServerMapDataPacket(int mapId, byte scale, boolean trackingPosition, MapPlayer players[]) { + this(mapId, scale, trackingPosition, players, null); } - public ServerMapDataPacket(int mapId, byte scale, MapPlayer players[], MapData data) { + public ServerMapDataPacket(int mapId, byte scale, boolean trackingPosition, MapPlayer players[], MapData data) { this.mapId = mapId; this.scale = scale; + this.trackingPosition = trackingPosition; this.players = players; this.data = data; } @@ -39,6 +41,10 @@ public class ServerMapDataPacket implements Packet { return this.scale; } + public boolean getTrackingPosition() { + return this.trackingPosition; + } + public MapPlayer[] getPlayers() { return this.players; } @@ -51,6 +57,7 @@ public class ServerMapDataPacket implements Packet { public void read(NetInput in) throws IOException { this.mapId = in.readVarInt(); this.scale = in.readByte(); + this.trackingPosition = in.readBoolean(); this.players = new MapPlayer[in.readVarInt()]; for(int index = 0; index < this.players.length; index++) { int data = in.readUnsignedByte(); @@ -75,6 +82,7 @@ public class ServerMapDataPacket implements Packet { public void write(NetOutput out) throws IOException { out.writeVarInt(this.mapId); out.writeByte(this.scale); + out.writeBoolean(this.trackingPosition); out.writeVarInt(this.players.length); for(int index = 0; index < this.players.length; index++) { MapPlayer player = this.players[index];