use of net.glowstone.net.message.play.entity.SpawnObjectMessage in project Glowstone by GlowstoneMC.
the class SpawnObjectCodec method decode.
@Override
public SpawnObjectMessage decode(ByteBuf buf) throws IOException {
int id = ByteBufUtils.readVarInt(buf);
UUID uuid = GlowBufUtils.readUuid(buf);
int type = buf.readByte();
double x = buf.readDouble();
double y = buf.readDouble();
double z = buf.readDouble();
int pitch = buf.readByte();
int yaw = buf.readByte();
int data = buf.readInt();
int velX = buf.readShort();
int velY = buf.readShort();
int velZ = buf.readShort();
return new SpawnObjectMessage(id, uuid, type, x, y, z, pitch, yaw, data, velX, velY, velZ);
}
use of net.glowstone.net.message.play.entity.SpawnObjectMessage in project Dragonet-Legacy by DragonetMC.
the class EntityMetadataMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(EntityMetadataMessage packet) {
if (!this.getTranslator().cachedEntityIDs.contains(packet.id)) {
// Not spawned yet, let's create them
if (this.getTranslator().cachedSpawnObjects.containsKey(packet.id)) {
// Spawn it :)
SpawnObjectMessage msgObj = this.getTranslator().cachedSpawnObjects.get(packet.id);
switch(msgObj.type) {
case // Dropped Item
2:
AddItemEntityPacket pkAddItemEntity = new AddItemEntityPacket();
pkAddItemEntity.eid = msgObj.id;
pkAddItemEntity.item = new PEInventorySlot((short) (((ItemStack) packet.entries.get(0).value).getTypeId() & 0xFFFF), (byte) (((ItemStack) packet.entries.get(0).value).getAmount() & 0xFF), (short) (((ItemStack) packet.entries.get(0).value).getDurability() & 0xFFFF));
pkAddItemEntity.x = (float) msgObj.velX / 32;
pkAddItemEntity.y = (float) msgObj.velY / 32;
pkAddItemEntity.z = (float) msgObj.velZ / 32;
return new PEPacket[] { pkAddItemEntity };
}
// Remove it
this.getTranslator().cachedSpawnObjects.remove(packet.id);
} else {
return null;
}
}
return null;
}
Aggregations