Update to MC 1.11

This commit is contained in:
johni0702 2016-12-03 20:31:07 +01:00
parent 55859fa1ae
commit 839925054b
17 changed files with 169 additions and 59 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.10.2-SNAPSHOT</version> <version>1.11-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.10.2"; public static final String GAME_VERSION = "1.11";
public static final int PROTOCOL_VERSION = 210; public static final int PROTOCOL_VERSION = 315;
// General Key Constants // General Key Constants
public static final String PROFILE_KEY = "profile"; public static final String PROFILE_KEY = "profile";

View file

@ -69,6 +69,7 @@ import org.spacehq.mc.protocol.data.game.world.block.value.PistonValueType;
import org.spacehq.mc.protocol.data.game.world.effect.ParticleEffect; import org.spacehq.mc.protocol.data.game.world.effect.ParticleEffect;
import org.spacehq.mc.protocol.data.game.world.effect.SmokeEffectData; import org.spacehq.mc.protocol.data.game.world.effect.SmokeEffectData;
import org.spacehq.mc.protocol.data.game.world.effect.SoundEffect; import org.spacehq.mc.protocol.data.game.world.effect.SoundEffect;
import org.spacehq.mc.protocol.data.game.world.map.MapIconType;
import org.spacehq.mc.protocol.data.game.world.notify.ClientNotification; import org.spacehq.mc.protocol.data.game.world.notify.ClientNotification;
import org.spacehq.mc.protocol.data.game.world.notify.DemoMessageValue; import org.spacehq.mc.protocol.data.game.world.notify.DemoMessageValue;
import org.spacehq.mc.protocol.data.game.world.notify.EnterCreditsValue; import org.spacehq.mc.protocol.data.game.world.notify.EnterCreditsValue;
@ -297,6 +298,8 @@ public class MagicValues {
register(EntityStatus.OP_PERMISSION_LEVEL_2, 26); register(EntityStatus.OP_PERMISSION_LEVEL_2, 26);
register(EntityStatus.OP_PERMISSION_LEVEL_3, 27); register(EntityStatus.OP_PERMISSION_LEVEL_3, 27);
register(EntityStatus.OP_PERMISSION_LEVEL_4, 28); register(EntityStatus.OP_PERMISSION_LEVEL_4, 28);
register(EntityStatus.IRON_GOLEM_NO_ROSE, 34);
register(EntityStatus.TOTEM_OF_UNDYING, 35);
register(PositionElement.X, 0); register(PositionElement.X, 0);
register(PositionElement.Y, 1); register(PositionElement.Y, 1);
@ -306,8 +309,18 @@ public class MagicValues {
register(GlobalEntityType.LIGHTNING_BOLT, 1); register(GlobalEntityType.LIGHTNING_BOLT, 1);
register(MobType.MOB, 48); register(MobType.ELDER_GUARDIAN, 4);
register(MobType.MONSTER, 49); register(MobType.WITHER_SKELETON, 5);
register(MobType.STRAY, 6);
register(MobType.HUSK, 23);
register(MobType.ZOMBIE_VILLAGER, 27);
register(MobType.SKELETON_HORSE, 28);
register(MobType.ZOMBIE_HORSE, 29);
register(MobType.DONKEY, 31);
register(MobType.MULE, 32);
register(MobType.EVOCATION_ILLAGER, 34);
register(MobType.VEX, 35);
register(MobType.VINDICATION_ILLAGER, 36);
register(MobType.CREEPER, 50); register(MobType.CREEPER, 50);
register(MobType.SKELETON, 51); register(MobType.SKELETON, 51);
register(MobType.SPIDER, 52); register(MobType.SPIDER, 52);
@ -341,6 +354,7 @@ public class MagicValues {
register(MobType.HORSE, 100); register(MobType.HORSE, 100);
register(MobType.RABBIT, 101); register(MobType.RABBIT, 101);
register(MobType.POLAR_BEAR, 102); register(MobType.POLAR_BEAR, 102);
register(MobType.LLAMA, 103);
register(MobType.VILLAGER, 120); register(MobType.VILLAGER, 120);
register(ObjectType.BOAT, 1); register(ObjectType.BOAT, 1);
@ -349,7 +363,7 @@ public class MagicValues {
register(ObjectType.MINECART, 10); register(ObjectType.MINECART, 10);
register(ObjectType.PRIMED_TNT, 50); register(ObjectType.PRIMED_TNT, 50);
register(ObjectType.ENDER_CRYSTAL, 51); register(ObjectType.ENDER_CRYSTAL, 51);
register(ObjectType.ARROW, 60); register(ObjectType.TIPPED_ARROW, 60);
register(ObjectType.SNOWBALL, 61); register(ObjectType.SNOWBALL, 61);
register(ObjectType.EGG, 62); register(ObjectType.EGG, 62);
register(ObjectType.GHAST_FIREBALL, 63); register(ObjectType.GHAST_FIREBALL, 63);
@ -357,18 +371,18 @@ public class MagicValues {
register(ObjectType.ENDER_PEARL, 65); register(ObjectType.ENDER_PEARL, 65);
register(ObjectType.WITHER_HEAD_PROJECTILE, 66); register(ObjectType.WITHER_HEAD_PROJECTILE, 66);
register(ObjectType.SHULKER_BULLET, 67); register(ObjectType.SHULKER_BULLET, 67);
register(ObjectType.LLAMA_SPIT, 68);
register(ObjectType.FALLING_BLOCK, 70); register(ObjectType.FALLING_BLOCK, 70);
register(ObjectType.ITEM_FRAME, 71); register(ObjectType.ITEM_FRAME, 71);
register(ObjectType.EYE_OF_ENDER, 72); register(ObjectType.EYE_OF_ENDER, 72);
register(ObjectType.POTION, 73); register(ObjectType.POTION, 73);
register(ObjectType.FALLING_DRAGON_EGG, 74);
register(ObjectType.EXP_BOTTLE, 75); register(ObjectType.EXP_BOTTLE, 75);
register(ObjectType.FIREWORK_ROCKET, 76); register(ObjectType.FIREWORK_ROCKET, 76);
register(ObjectType.LEASH_KNOT, 77); register(ObjectType.LEASH_KNOT, 77);
register(ObjectType.ARMOR_STAND, 78); register(ObjectType.ARMOR_STAND, 78);
register(ObjectType.EVOCATION_FANGS, 79);
register(ObjectType.FISH_HOOK, 90); register(ObjectType.FISH_HOOK, 90);
register(ObjectType.SPECTRAL_ARROW, 91); register(ObjectType.SPECTRAL_ARROW, 91);
register(ObjectType.TIPPED_ARROW, 92);
register(ObjectType.DRAGON_FIREBALL, 93); register(ObjectType.DRAGON_FIREBALL, 93);
register(MinecartType.NORMAL, 0); register(MinecartType.NORMAL, 0);
@ -444,6 +458,23 @@ public class MagicValues {
register(ScoreboardAction.ADD_OR_UPDATE, 0); register(ScoreboardAction.ADD_OR_UPDATE, 0);
register(ScoreboardAction.REMOVE, 1); register(ScoreboardAction.REMOVE, 1);
register(MapIconType.WHITE_ARROW, 0);
register(MapIconType.GREEN_ARROW, 1);
register(MapIconType.RED_ARROW, 2);
register(MapIconType.BLUE_ARROW, 3);
register(MapIconType.WHITE_CROSS, 4);
register(MapIconType.RED_POINTER, 5);
register(MapIconType.WHITE_CIRCLE, 6);
register(MapIconType.SMALL_WHITE_CIRCLE, 7);
register(MapIconType.MANSION, 8);
register(MapIconType.TEMPLE, 9);
register(MapIconType.UNUSED_10, 10);
register(MapIconType.UNUSED_11, 11);
register(MapIconType.UNUSED_12, 12);
register(MapIconType.UNUSED_13, 13);
register(MapIconType.UNUSED_14, 14);
register(MapIconType.UNUSED_15, 15);
register(WindowType.GENERIC_INVENTORY, "minecraft:container"); register(WindowType.GENERIC_INVENTORY, "minecraft:container");
register(WindowType.ANVIL, "minecraft:anvil"); register(WindowType.ANVIL, "minecraft:anvil");
register(WindowType.BEACON, "minecraft:beacon"); register(WindowType.BEACON, "minecraft:beacon");
@ -456,6 +487,7 @@ public class MagicValues {
register(WindowType.FURNACE, "minecraft:furnace"); register(WindowType.FURNACE, "minecraft:furnace");
register(WindowType.HOPPER, "minecraft:hopper"); register(WindowType.HOPPER, "minecraft:hopper");
register(WindowType.VILLAGER, "minecraft:villager"); register(WindowType.VILLAGER, "minecraft:villager");
register(WindowType.SHULKER_BOX, "minecraft:shulker_box");
register(WindowType.HORSE, "EntityHorse"); register(WindowType.HORSE, "EntityHorse");
register(BrewingStandProperty.BREW_TIME, 0); register(BrewingStandProperty.BREW_TIME, 0);
@ -750,9 +782,10 @@ public class MagicValues {
register(TitleAction.TITLE, 0); register(TitleAction.TITLE, 0);
register(TitleAction.SUBTITLE, 1); register(TitleAction.SUBTITLE, 1);
register(TitleAction.TIMES, 2); register(TitleAction.ACTION_BAR, 2);
register(TitleAction.CLEAR, 3); register(TitleAction.TIMES, 3);
register(TitleAction.RESET, 4); register(TitleAction.CLEAR, 4);
register(TitleAction.RESET, 5);
register(ResourcePackStatus.SUCCESSFULLY_LOADED, 0); register(ResourcePackStatus.SUCCESSFULLY_LOADED, 0);
register(ResourcePackStatus.DECLINED, 1); register(ResourcePackStatus.DECLINED, 1);

View file

@ -3,6 +3,7 @@ package org.spacehq.mc.protocol.data.game;
public enum TitleAction { public enum TitleAction {
TITLE, TITLE,
SUBTITLE, SUBTITLE,
ACTION_BAR,
TIMES, TIMES,
CLEAR, CLEAR,
RESET; RESET;

View file

@ -27,5 +27,7 @@ public enum EntityStatus {
OP_PERMISSION_LEVEL_1, OP_PERMISSION_LEVEL_1,
OP_PERMISSION_LEVEL_2, OP_PERMISSION_LEVEL_2,
OP_PERMISSION_LEVEL_3, OP_PERMISSION_LEVEL_3,
OP_PERMISSION_LEVEL_4; OP_PERMISSION_LEVEL_4,
IRON_GOLEM_NO_ROSE,
TOTEM_OF_UNDYING;
} }

View file

@ -1,8 +1,18 @@
package org.spacehq.mc.protocol.data.game.entity.type; package org.spacehq.mc.protocol.data.game.entity.type;
public enum MobType { public enum MobType {
MOB, ELDER_GUARDIAN,
MONSTER, WITHER_SKELETON,
STRAY,
HUSK,
ZOMBIE_VILLAGER,
SKELETON_HORSE,
ZOMBIE_HORSE,
DONKEY,
MULE,
EVOCATION_ILLAGER,
VEX,
VINDICATION_ILLAGER,
CREEPER, CREEPER,
SKELETON, SKELETON,
SPIDER, SPIDER,
@ -36,5 +46,6 @@ public enum MobType {
HORSE, HORSE,
RABBIT, RABBIT,
POLAR_BEAR, POLAR_BEAR,
LLAMA,
VILLAGER; VILLAGER;
} }

View file

@ -7,7 +7,6 @@ public enum ObjectType {
MINECART, MINECART,
PRIMED_TNT, PRIMED_TNT,
ENDER_CRYSTAL, ENDER_CRYSTAL,
ARROW,
SNOWBALL, SNOWBALL,
EGG, EGG,
GHAST_FIREBALL, GHAST_FIREBALL,
@ -15,15 +14,16 @@ public enum ObjectType {
ENDER_PEARL, ENDER_PEARL,
WITHER_HEAD_PROJECTILE, WITHER_HEAD_PROJECTILE,
SHULKER_BULLET, SHULKER_BULLET,
LLAMA_SPIT,
FALLING_BLOCK, FALLING_BLOCK,
ITEM_FRAME, ITEM_FRAME,
EYE_OF_ENDER, EYE_OF_ENDER,
POTION, POTION,
FALLING_DRAGON_EGG,
EXP_BOTTLE, EXP_BOTTLE,
FIREWORK_ROCKET, FIREWORK_ROCKET,
LEASH_KNOT, LEASH_KNOT,
ARMOR_STAND, ARMOR_STAND,
EVOCATION_FANGS,
FISH_HOOK, FISH_HOOK,
SPECTRAL_ARROW, SPECTRAL_ARROW,
TIPPED_ARROW, TIPPED_ARROW,

View file

@ -14,6 +14,7 @@ public enum WindowType {
FURNACE, FURNACE,
HOPPER, HOPPER,
VILLAGER, VILLAGER,
SHULKER_BOX,
HORSE; HORSE;
} }

View file

@ -1,15 +1,15 @@
package org.spacehq.mc.protocol.data.game.world.map; package org.spacehq.mc.protocol.data.game.world.map;
public class MapPlayer { public class MapIcon {
private int centerX; private int centerX;
private int centerZ; private int centerZ;
private int iconSize; private MapIconType iconType;
private int iconRotation; private int iconRotation;
public MapPlayer(int centerX, int centerZ, int iconSize, int iconRotation) { public MapIcon(int centerX, int centerZ, MapIconType iconType, int iconRotation) {
this.centerX = centerX; this.centerX = centerX;
this.centerZ = centerZ; this.centerZ = centerZ;
this.iconSize = iconSize; this.iconType = iconType;
this.iconRotation = iconRotation; this.iconRotation = iconRotation;
} }
@ -21,8 +21,8 @@ public class MapPlayer {
return this.centerZ; return this.centerZ;
} }
public int getIconSize() { public MapIconType getIconType() {
return this.iconSize; return this.iconType;
} }
public int getIconRotation() { public int getIconRotation() {
@ -31,7 +31,7 @@ public class MapPlayer {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
return o instanceof MapPlayer && this.centerX == ((MapPlayer) o).centerX && this.centerZ == ((MapPlayer) o).centerZ && this.iconSize == ((MapPlayer) o).iconSize && this.iconRotation == ((MapPlayer) o).iconRotation; return o instanceof MapIcon && this.centerX == ((MapIcon) o).centerX && this.centerZ == ((MapIcon) o).centerZ && this.iconType == ((MapIcon) o).iconType && this.iconRotation == ((MapIcon) o).iconRotation;
} }
@Override @Override
@ -39,7 +39,7 @@ public class MapPlayer {
int result = this.centerX; int result = this.centerX;
result = 31 * result + this.centerZ; result = 31 * result + this.centerZ;
result = 31 * result + this.iconRotation; result = 31 * result + this.iconRotation;
result = 31 * result + this.iconSize; result = 31 * result + (this.iconType != null ? this.iconType.hashCode() : 0);
return result; return result;
} }
} }

View file

@ -0,0 +1,20 @@
package org.spacehq.mc.protocol.data.game.world.map;
public enum MapIconType {
WHITE_ARROW,
GREEN_ARROW,
RED_ARROW,
BLUE_ARROW,
WHITE_CROSS,
RED_POINTER,
WHITE_CIRCLE,
SMALL_WHITE_CIRCLE,
MANSION,
TEMPLE,
UNUSED_10,
UNUSED_11,
UNUSED_12,
UNUSED_13,
UNUSED_14,
UNUSED_15;
}

View file

@ -63,9 +63,9 @@ public class ClientPlayerPlaceBlockPacket implements Packet {
this.position = NetUtil.readPosition(in); this.position = NetUtil.readPosition(in);
this.face = MagicValues.key(BlockFace.class, in.readVarInt()); this.face = MagicValues.key(BlockFace.class, in.readVarInt());
this.hand = MagicValues.key(Hand.class, in.readVarInt()); this.hand = MagicValues.key(Hand.class, in.readVarInt());
this.cursorX = in.readUnsignedByte() / 16f; this.cursorX = in.readFloat();
this.cursorY = in.readUnsignedByte() / 16f; this.cursorY = in.readFloat();
this.cursorZ = in.readUnsignedByte() / 16f; this.cursorZ = in.readFloat();
} }
@Override @Override
@ -73,9 +73,9 @@ public class ClientPlayerPlaceBlockPacket implements Packet {
NetUtil.writePosition(out, this.position); NetUtil.writePosition(out, this.position);
out.writeVarInt(MagicValues.value(Integer.class, this.face)); out.writeVarInt(MagicValues.value(Integer.class, this.face));
out.writeVarInt(MagicValues.value(Integer.class, this.hand)); out.writeVarInt(MagicValues.value(Integer.class, this.hand));
out.writeByte((int) (this.cursorX * 16)); out.writeFloat(this.cursorX);
out.writeByte((int) (this.cursorY * 16)); out.writeFloat(this.cursorY);
out.writeByte((int) (this.cursorZ * 16)); out.writeFloat(this.cursorZ);
} }
@Override @Override

View file

@ -17,6 +17,8 @@ public class ServerTitlePacket implements Packet {
private Message subtitle; private Message subtitle;
private Message actionBar;
private int fadeIn; private int fadeIn;
private int stay; private int stay;
private int fadeOut; private int fadeOut;
@ -30,12 +32,28 @@ public class ServerTitlePacket implements Packet {
} }
public ServerTitlePacket(Message title, boolean sub) { public ServerTitlePacket(Message title, boolean sub) {
if(sub) { this(sub ? TitleAction.SUBTITLE : TitleAction.TITLE, title);
this.action = TitleAction.SUBTITLE; }
this.subtitle = title;
} else { public ServerTitlePacket(TitleAction action, String title) {
this.action = TitleAction.TITLE; this(action, Message.fromString(title));
this.title = title; }
public ServerTitlePacket(TitleAction action, Message title) {
this.action = action;
switch (action) {
case TITLE:
this.title = title;
break;
case SUBTITLE:
this.subtitle = title;
break;
case ACTION_BAR:
this.actionBar = title;
break;
default:
throw new IllegalArgumentException("action must be one of TITLE, SUBTITLE, ACTION_BAR");
} }
} }
@ -66,6 +84,10 @@ public class ServerTitlePacket implements Packet {
return this.subtitle; return this.subtitle;
} }
public Message getActionBar() {
return this.actionBar;
}
public int getFadeIn() { public int getFadeIn() {
return this.fadeIn; return this.fadeIn;
} }
@ -88,6 +110,9 @@ public class ServerTitlePacket implements Packet {
case SUBTITLE: case SUBTITLE:
this.subtitle = Message.fromString(in.readString()); this.subtitle = Message.fromString(in.readString());
break; break;
case ACTION_BAR:
this.actionBar = Message.fromString(in.readString());
break;
case TIMES: case TIMES:
this.fadeIn = in.readInt(); this.fadeIn = in.readInt();
this.stay = in.readInt(); this.stay = in.readInt();
@ -110,6 +135,9 @@ public class ServerTitlePacket implements Packet {
case SUBTITLE: case SUBTITLE:
out.writeString(this.subtitle.toJsonString()); out.writeString(this.subtitle.toJsonString());
break; break;
case ACTION_BAR:
out.writeString(this.actionBar.toJsonString());
break;
case TIMES: case TIMES:
out.writeInt(this.fadeIn); out.writeInt(this.fadeIn);
out.writeInt(this.stay); out.writeInt(this.stay);

View file

@ -11,14 +11,16 @@ public class ServerEntityCollectItemPacket implements Packet {
private int collectedEntityId; private int collectedEntityId;
private int collectorEntityId; private int collectorEntityId;
private int itemCount;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private ServerEntityCollectItemPacket() { private ServerEntityCollectItemPacket() {
} }
public ServerEntityCollectItemPacket(int collectedEntityId, int collectorEntityId) { public ServerEntityCollectItemPacket(int collectedEntityId, int collectorEntityId, int itemCount) {
this.collectedEntityId = collectedEntityId; this.collectedEntityId = collectedEntityId;
this.collectorEntityId = collectorEntityId; this.collectorEntityId = collectorEntityId;
this.itemCount = itemCount;
} }
public int getCollectedEntityId() { public int getCollectedEntityId() {
@ -29,16 +31,22 @@ public class ServerEntityCollectItemPacket implements Packet {
return this.collectorEntityId; return this.collectorEntityId;
} }
public int getItemCount() {
return this.itemCount;
}
@Override @Override
public void read(NetInput in) throws IOException { public void read(NetInput in) throws IOException {
this.collectedEntityId = in.readVarInt(); this.collectedEntityId = in.readVarInt();
this.collectorEntityId = in.readVarInt(); this.collectorEntityId = in.readVarInt();
this.itemCount = in.readVarInt();
} }
@Override @Override
public void write(NetOutput out) throws IOException { public void write(NetOutput out) throws IOException {
out.writeVarInt(this.collectedEntityId); out.writeVarInt(this.collectedEntityId);
out.writeVarInt(this.collectorEntityId); out.writeVarInt(this.collectorEntityId);
out.writeVarInt(this.itemCount);
} }
@Override @Override

View file

@ -104,7 +104,7 @@ public class ServerSpawnMobPacket implements Packet {
public void read(NetInput in) throws IOException { public void read(NetInput in) throws IOException {
this.entityId = in.readVarInt(); this.entityId = in.readVarInt();
this.uuid = in.readUUID(); this.uuid = in.readUUID();
this.type = MagicValues.key(MobType.class, in.readUnsignedByte()); this.type = MagicValues.key(MobType.class, in.readVarInt());
this.x = in.readDouble(); this.x = in.readDouble();
this.y = in.readDouble(); this.y = in.readDouble();
this.z = in.readDouble(); this.z = in.readDouble();
@ -121,7 +121,7 @@ public class ServerSpawnMobPacket implements Packet {
public void write(NetOutput out) throws IOException { public void write(NetOutput out) throws IOException {
out.writeVarInt(this.entityId); out.writeVarInt(this.entityId);
out.writeUUID(this.uuid); out.writeUUID(this.uuid);
out.writeByte(MagicValues.value(Integer.class, this.type)); out.writeVarInt(MagicValues.value(Integer.class, this.type));
out.writeDouble(this.x); out.writeDouble(this.x);
out.writeDouble(this.y); out.writeDouble(this.y);
out.writeDouble(this.z); out.writeDouble(this.z);

View file

@ -131,7 +131,7 @@ public class ServerSpawnObjectPacket implements Packet {
this.data = new FallingBlockData(data & 65535, data >> 16); this.data = new FallingBlockData(data & 65535, data >> 16);
} else if(this.type == ObjectType.POTION) { } else if(this.type == ObjectType.POTION) {
this.data = new SplashPotionData(data); this.data = new SplashPotionData(data);
} else if(this.type == ObjectType.ARROW || this.type == ObjectType.SPECTRAL_ARROW || this.type == ObjectType.TIPPED_ARROW || this.type == ObjectType.GHAST_FIREBALL || this.type == ObjectType.BLAZE_FIREBALL || this.type == ObjectType.DRAGON_FIREBALL || this.type == ObjectType.WITHER_HEAD_PROJECTILE || this.type == ObjectType.FISH_HOOK) { } else if(this.type == ObjectType.SPECTRAL_ARROW || this.type == ObjectType.TIPPED_ARROW || this.type == ObjectType.GHAST_FIREBALL || this.type == ObjectType.BLAZE_FIREBALL || this.type == ObjectType.DRAGON_FIREBALL || this.type == ObjectType.WITHER_HEAD_PROJECTILE || this.type == ObjectType.FISH_HOOK) {
this.data = new ProjectileData(data); this.data = new ProjectileData(data);
} else { } else {
this.data = new ObjectData() { this.data = new ObjectData() {

View file

@ -31,6 +31,8 @@ public class ServerBlockValuePacket implements Packet {
private static final int CHEST = 54; private static final int CHEST = 54;
private static final int ENDER_CHEST = 130; private static final int ENDER_CHEST = 130;
private static final int TRAPPED_CHEST = 146; private static final int TRAPPED_CHEST = 146;
private static final int SHULKER_BOX_LOWER = 219;
private static final int SHULKER_BOX_HIGHER = 234;
private Position position; private Position position;
private BlockValueType type; private BlockValueType type;
@ -80,7 +82,8 @@ public class ServerBlockValuePacket implements Packet {
} else if(this.blockId == MOB_SPAWNER) { } else if(this.blockId == MOB_SPAWNER) {
this.type = MagicValues.key(MobSpawnerValueType.class, type); this.type = MagicValues.key(MobSpawnerValueType.class, type);
this.value = new MobSpawnerValue(); this.value = new MobSpawnerValue();
} else if(this.blockId == CHEST || this.blockId == ENDER_CHEST || this.blockId == TRAPPED_CHEST) { } else if(this.blockId == CHEST || this.blockId == ENDER_CHEST || this.blockId == TRAPPED_CHEST
|| (this.blockId >= SHULKER_BOX_LOWER && this.blockId <= SHULKER_BOX_HIGHER)) {
this.type = MagicValues.key(ChestValueType.class, type); this.type = MagicValues.key(ChestValueType.class, type);
this.value = new ChestValue(value); this.value = new ChestValue(value);
} else { } else {

View file

@ -1,7 +1,9 @@
package org.spacehq.mc.protocol.packet.ingame.server.world; package org.spacehq.mc.protocol.packet.ingame.server.world;
import org.spacehq.mc.protocol.data.MagicValues;
import org.spacehq.mc.protocol.data.game.world.map.MapData; import org.spacehq.mc.protocol.data.game.world.map.MapData;
import org.spacehq.mc.protocol.data.game.world.map.MapPlayer; import org.spacehq.mc.protocol.data.game.world.map.MapIcon;
import org.spacehq.mc.protocol.data.game.world.map.MapIconType;
import org.spacehq.mc.protocol.util.ReflectionToString; import org.spacehq.mc.protocol.util.ReflectionToString;
import org.spacehq.packetlib.io.NetInput; import org.spacehq.packetlib.io.NetInput;
import org.spacehq.packetlib.io.NetOutput; import org.spacehq.packetlib.io.NetOutput;
@ -14,7 +16,7 @@ public class ServerMapDataPacket implements Packet {
private int mapId; private int mapId;
private byte scale; private byte scale;
private boolean trackingPosition; private boolean trackingPosition;
private MapPlayer players[]; private MapIcon icons[];
private MapData data; private MapData data;
@ -22,15 +24,15 @@ public class ServerMapDataPacket implements Packet {
private ServerMapDataPacket() { private ServerMapDataPacket() {
} }
public ServerMapDataPacket(int mapId, byte scale, boolean trackingPosition, MapPlayer players[]) { public ServerMapDataPacket(int mapId, byte scale, boolean trackingPosition, MapIcon icons[]) {
this(mapId, scale, trackingPosition, players, null); this(mapId, scale, trackingPosition, icons, null);
} }
public ServerMapDataPacket(int mapId, byte scale, boolean trackingPosition, MapPlayer players[], MapData data) { public ServerMapDataPacket(int mapId, byte scale, boolean trackingPosition, MapIcon icons[], MapData data) {
this.mapId = mapId; this.mapId = mapId;
this.scale = scale; this.scale = scale;
this.trackingPosition = trackingPosition; this.trackingPosition = trackingPosition;
this.players = players; this.icons = icons;
this.data = data; this.data = data;
} }
@ -46,8 +48,8 @@ public class ServerMapDataPacket implements Packet {
return this.trackingPosition; return this.trackingPosition;
} }
public MapPlayer[] getPlayers() { public MapIcon[] getIcons() {
return this.players; return this.icons;
} }
public MapData getData() { public MapData getData() {
@ -59,14 +61,14 @@ public class ServerMapDataPacket implements Packet {
this.mapId = in.readVarInt(); this.mapId = in.readVarInt();
this.scale = in.readByte(); this.scale = in.readByte();
this.trackingPosition = in.readBoolean(); this.trackingPosition = in.readBoolean();
this.players = new MapPlayer[in.readVarInt()]; this.icons = new MapIcon[in.readVarInt()];
for(int index = 0; index < this.players.length; index++) { for(int index = 0; index < this.icons.length; index++) {
int data = in.readUnsignedByte(); int data = in.readUnsignedByte();
int size = (data >> 4) & 15; int type = (data >> 4) & 15;
int rotation = data & 15; int rotation = data & 15;
int x = in.readUnsignedByte(); int x = in.readUnsignedByte();
int z = in.readUnsignedByte(); int z = in.readUnsignedByte();
this.players[index] = new MapPlayer(x, z, size, rotation); this.icons[index] = new MapIcon(x, z, MagicValues.value(MapIconType.class, type), rotation);
} }
int columns = in.readUnsignedByte(); int columns = in.readUnsignedByte();
@ -84,12 +86,13 @@ public class ServerMapDataPacket implements Packet {
out.writeVarInt(this.mapId); out.writeVarInt(this.mapId);
out.writeByte(this.scale); out.writeByte(this.scale);
out.writeBoolean(this.trackingPosition); out.writeBoolean(this.trackingPosition);
out.writeVarInt(this.players.length); out.writeVarInt(this.icons.length);
for(int index = 0; index < this.players.length; index++) { for(int index = 0; index < this.icons.length; index++) {
MapPlayer player = this.players[index]; MapIcon icon = this.icons[index];
out.writeByte((player.getIconSize() & 15) << 4 | player.getIconRotation() & 15); int type = MagicValues.key(Integer.class, icon.getIconType());
out.writeByte(player.getCenterX()); out.writeByte((type & 15) << 4 | icon.getIconRotation() & 15);
out.writeByte(player.getCenterZ()); out.writeByte(icon.getCenterX());
out.writeByte(icon.getCenterZ());
} }
if(this.data != null && this.data.getColumns() != 0) { if(this.data != null && this.data.getColumns() != 0) {