public static ItemStack readItem(NetInput in) throws IOException { short item = in.readShort(); if (item < 0) { return null; } else { return new ItemStack(item, in.readByte(), in.readShort(), readNBT(in)); } }
@Override public void read(NetInput in) throws IOException { this.name = in.readString(); this.action = MagicValues.key(ObjectiveAction.class, in.readByte()); if (this.action == ObjectiveAction.ADD || this.action == ObjectiveAction.UPDATE) { this.displayName = in.readString(); this.type = MagicValues.key(ScoreType.class, in.readString()); } }
@Override public void read(NetInput in) throws IOException { this.entityId = in.readVarInt(); this.effect = MagicValues.key(Effect.class, in.readByte()); this.amplifier = in.readByte(); this.duration = in.readVarInt(); int flags = in.readByte(); this.ambient = (flags & 0x1) == 0x1; this.showParticles = (flags & 0x2) == 0x2; }
public static CompoundTag readNBT(NetInput in) throws IOException { byte b = in.readByte(); if (b == 0) { return null; } else { return (CompoundTag) NBTIO.readTag(new DataInputStream(new NetInputStream(in, b))); } }
public static Position readPosition(NetInput in) throws IOException { long val = in.readLong(); int x = (int) (val >> POSITION_X_SIZE); int y = (int) ((val >> POSITION_Y_SIZE) & POSITION_Y_SHIFT); int z = (int) ((val << POSITION_Z_SIZE) >> POSITION_Z_SIZE); return new Position(x, y, z); }
@Override public void read(NetInput in) throws IOException { this.entityId = in.readVarInt(); this.x = in.readDouble(); this.y = in.readDouble(); this.z = in.readDouble(); this.yaw = in.readByte() * 360 / 256f; this.pitch = in.readByte() * 360 / 256f; this.onGround = in.readBoolean(); }
@Override public void read(NetInput in) throws IOException { this.entityId = in.readInt(); this.attachedToId = in.readInt(); }
@Override public void read(NetInput in) throws IOException { this.channel = in.readString(); this.data = in.readBytes(in.available()); }
public static EntityMetadata[] readEntityMetadata(NetInput in) throws IOException { List<EntityMetadata> ret = new ArrayList<EntityMetadata>(); byte b; while ((b = in.readByte()) != 127) { int typeId = (b & 0xE0) >> 5; int id = b & 0x1F; MetadataType type = MagicValues.key(MetadataType.class, typeId); Object value; switch (type) { case BYTE: value = in.readByte(); break; case SHORT: value = in.readShort(); break; case INT: value = in.readInt(); break; case FLOAT: value = in.readFloat(); break; case STRING: value = in.readString(); break; case ITEM: value = readItem(in); break; case POSITION: value = new Position(in.readInt(), in.readInt(), in.readInt()); break; case ROTATION: value = new Rotation(in.readFloat(), in.readFloat(), in.readFloat()); break; default: throw new IOException("Unknown metadata type id: " + typeId); } ret.add(new EntityMetadata(id, type, value)); } return ret.toArray(new EntityMetadata[ret.size()]); }
@Override public void read(NetInput in) throws IOException { this.entityId = in.readVarInt(); this.slot = MagicValues.key(EquipmentSlot.class, in.readVarInt()); this.item = NetUtil.readItem(in); }
@Override public void read(NetInput in) throws IOException { this.health = in.readFloat(); this.food = in.readVarInt(); this.saturation = in.readFloat(); }
@Override public void read(NetInput in) throws IOException { this.time = in.readLong(); }
@Override public void read(NetInput in) throws IOException { this.serverId = in.readString(); this.publicKey = CryptUtil.decodePublicKey(in.readBytes(in.readVarInt())); this.verifyToken = in.readBytes(in.readVarInt()); }