mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-12 08:41:00 -05:00
15w34d.
This commit is contained in:
parent
58cc7de810
commit
c49e1569d3
5 changed files with 40 additions and 12 deletions
|
@ -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";
|
||||
|
|
|
@ -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 + ".");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package org.spacehq.mc.protocol.data.game.values.entity;
|
||||
|
||||
public enum EquipmentSlot {
|
||||
MAIN_HAND,
|
||||
OFF_HAND,
|
||||
BOOTS,
|
||||
LEGGINGS,
|
||||
CHESTPLATE,
|
||||
HELMET;
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue