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>
<groupId>org.spacehq</groupId>
<artifactId>mcprotocollib</artifactId>
<version>1.10.2-SNAPSHOT</version>
<version>1.11-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MCProtocolLib</name>

View file

@ -2,8 +2,8 @@ package org.spacehq.mc.protocol;
public class MinecraftConstants {
// General Constants
public static final String GAME_VERSION = "1.10.2";
public static final int PROTOCOL_VERSION = 210;
public static final String GAME_VERSION = "1.11";
public static final int PROTOCOL_VERSION = 315;
// General Key Constants
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.SmokeEffectData;
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.DemoMessageValue;
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_3, 27);
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.Y, 1);
@ -306,8 +309,18 @@ public class MagicValues {
register(GlobalEntityType.LIGHTNING_BOLT, 1);
register(MobType.MOB, 48);
register(MobType.MONSTER, 49);
register(MobType.ELDER_GUARDIAN, 4);
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.SKELETON, 51);
register(MobType.SPIDER, 52);
@ -341,6 +354,7 @@ public class MagicValues {
register(MobType.HORSE, 100);
register(MobType.RABBIT, 101);
register(MobType.POLAR_BEAR, 102);
register(MobType.LLAMA, 103);
register(MobType.VILLAGER, 120);
register(ObjectType.BOAT, 1);
@ -349,7 +363,7 @@ public class MagicValues {
register(ObjectType.MINECART, 10);
register(ObjectType.PRIMED_TNT, 50);
register(ObjectType.ENDER_CRYSTAL, 51);
register(ObjectType.ARROW, 60);
register(ObjectType.TIPPED_ARROW, 60);
register(ObjectType.SNOWBALL, 61);
register(ObjectType.EGG, 62);
register(ObjectType.GHAST_FIREBALL, 63);
@ -357,18 +371,18 @@ public class MagicValues {
register(ObjectType.ENDER_PEARL, 65);
register(ObjectType.WITHER_HEAD_PROJECTILE, 66);
register(ObjectType.SHULKER_BULLET, 67);
register(ObjectType.LLAMA_SPIT, 68);
register(ObjectType.FALLING_BLOCK, 70);
register(ObjectType.ITEM_FRAME, 71);
register(ObjectType.EYE_OF_ENDER, 72);
register(ObjectType.POTION, 73);
register(ObjectType.FALLING_DRAGON_EGG, 74);
register(ObjectType.EXP_BOTTLE, 75);
register(ObjectType.FIREWORK_ROCKET, 76);
register(ObjectType.LEASH_KNOT, 77);
register(ObjectType.ARMOR_STAND, 78);
register(ObjectType.EVOCATION_FANGS, 79);
register(ObjectType.FISH_HOOK, 90);
register(ObjectType.SPECTRAL_ARROW, 91);
register(ObjectType.TIPPED_ARROW, 92);
register(ObjectType.DRAGON_FIREBALL, 93);
register(MinecartType.NORMAL, 0);
@ -444,6 +458,23 @@ public class MagicValues {
register(ScoreboardAction.ADD_OR_UPDATE, 0);
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.ANVIL, "minecraft:anvil");
register(WindowType.BEACON, "minecraft:beacon");
@ -456,6 +487,7 @@ public class MagicValues {
register(WindowType.FURNACE, "minecraft:furnace");
register(WindowType.HOPPER, "minecraft:hopper");
register(WindowType.VILLAGER, "minecraft:villager");
register(WindowType.SHULKER_BOX, "minecraft:shulker_box");
register(WindowType.HORSE, "EntityHorse");
register(BrewingStandProperty.BREW_TIME, 0);
@ -750,9 +782,10 @@ public class MagicValues {
register(TitleAction.TITLE, 0);
register(TitleAction.SUBTITLE, 1);
register(TitleAction.TIMES, 2);
register(TitleAction.CLEAR, 3);
register(TitleAction.RESET, 4);
register(TitleAction.ACTION_BAR, 2);
register(TitleAction.TIMES, 3);
register(TitleAction.CLEAR, 4);
register(TitleAction.RESET, 5);
register(ResourcePackStatus.SUCCESSFULLY_LOADED, 0);
register(ResourcePackStatus.DECLINED, 1);

View file

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

View file

@ -27,5 +27,7 @@ public enum EntityStatus {
OP_PERMISSION_LEVEL_1,
OP_PERMISSION_LEVEL_2,
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;
public enum MobType {
MOB,
MONSTER,
ELDER_GUARDIAN,
WITHER_SKELETON,
STRAY,
HUSK,
ZOMBIE_VILLAGER,
SKELETON_HORSE,
ZOMBIE_HORSE,
DONKEY,
MULE,
EVOCATION_ILLAGER,
VEX,
VINDICATION_ILLAGER,
CREEPER,
SKELETON,
SPIDER,
@ -36,5 +46,6 @@ public enum MobType {
HORSE,
RABBIT,
POLAR_BEAR,
LLAMA,
VILLAGER;
}

View file

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

View file

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

View file

@ -1,15 +1,15 @@
package org.spacehq.mc.protocol.data.game.world.map;
public class MapPlayer {
public class MapIcon {
private int centerX;
private int centerZ;
private int iconSize;
private MapIconType iconType;
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.centerZ = centerZ;
this.iconSize = iconSize;
this.iconType = iconType;
this.iconRotation = iconRotation;
}
@ -21,8 +21,8 @@ public class MapPlayer {
return this.centerZ;
}
public int getIconSize() {
return this.iconSize;
public MapIconType getIconType() {
return this.iconType;
}
public int getIconRotation() {
@ -31,7 +31,7 @@ public class MapPlayer {
@Override
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
@ -39,7 +39,7 @@ public class MapPlayer {
int result = this.centerX;
result = 31 * result + this.centerZ;
result = 31 * result + this.iconRotation;
result = 31 * result + this.iconSize;
result = 31 * result + (this.iconType != null ? this.iconType.hashCode() : 0);
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.face = MagicValues.key(BlockFace.class, in.readVarInt());
this.hand = MagicValues.key(Hand.class, in.readVarInt());
this.cursorX = in.readUnsignedByte() / 16f;
this.cursorY = in.readUnsignedByte() / 16f;
this.cursorZ = in.readUnsignedByte() / 16f;
this.cursorX = in.readFloat();
this.cursorY = in.readFloat();
this.cursorZ = in.readFloat();
}
@Override
@ -73,9 +73,9 @@ public class ClientPlayerPlaceBlockPacket implements Packet {
NetUtil.writePosition(out, this.position);
out.writeVarInt(MagicValues.value(Integer.class, this.face));
out.writeVarInt(MagicValues.value(Integer.class, this.hand));
out.writeByte((int) (this.cursorX * 16));
out.writeByte((int) (this.cursorY * 16));
out.writeByte((int) (this.cursorZ * 16));
out.writeFloat(this.cursorX);
out.writeFloat(this.cursorY);
out.writeFloat(this.cursorZ);
}
@Override

View file

@ -17,6 +17,8 @@ public class ServerTitlePacket implements Packet {
private Message subtitle;
private Message actionBar;
private int fadeIn;
private int stay;
private int fadeOut;
@ -30,12 +32,28 @@ public class ServerTitlePacket implements Packet {
}
public ServerTitlePacket(Message title, boolean sub) {
if(sub) {
this.action = TitleAction.SUBTITLE;
this.subtitle = title;
} else {
this.action = TitleAction.TITLE;
this(sub ? TitleAction.SUBTITLE : TitleAction.TITLE, title);
}
public ServerTitlePacket(TitleAction action, String title) {
this(action, Message.fromString(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;
}
public Message getActionBar() {
return this.actionBar;
}
public int getFadeIn() {
return this.fadeIn;
}
@ -88,6 +110,9 @@ public class ServerTitlePacket implements Packet {
case SUBTITLE:
this.subtitle = Message.fromString(in.readString());
break;
case ACTION_BAR:
this.actionBar = Message.fromString(in.readString());
break;
case TIMES:
this.fadeIn = in.readInt();
this.stay = in.readInt();
@ -110,6 +135,9 @@ public class ServerTitlePacket implements Packet {
case SUBTITLE:
out.writeString(this.subtitle.toJsonString());
break;
case ACTION_BAR:
out.writeString(this.actionBar.toJsonString());
break;
case TIMES:
out.writeInt(this.fadeIn);
out.writeInt(this.stay);

View file

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

View file

@ -104,7 +104,7 @@ public class ServerSpawnMobPacket implements Packet {
public void read(NetInput in) throws IOException {
this.entityId = in.readVarInt();
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.y = in.readDouble();
this.z = in.readDouble();
@ -121,7 +121,7 @@ public class ServerSpawnMobPacket implements Packet {
public void write(NetOutput out) throws IOException {
out.writeVarInt(this.entityId);
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.y);
out.writeDouble(this.z);

View file

@ -131,7 +131,7 @@ public class ServerSpawnObjectPacket implements Packet {
this.data = new FallingBlockData(data & 65535, data >> 16);
} else if(this.type == ObjectType.POTION) {
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);
} else {
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 ENDER_CHEST = 130;
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 BlockValueType type;
@ -80,7 +82,8 @@ public class ServerBlockValuePacket implements Packet {
} else if(this.blockId == MOB_SPAWNER) {
this.type = MagicValues.key(MobSpawnerValueType.class, type);
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.value = new ChestValue(value);
} else {

View file

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