cn.nukkit.entity.data.IntPositionEntityData Java Examples
The following examples show how to use
cn.nukkit.entity.data.IntPositionEntityData.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityHuman.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override protected void initEntity() { this.setDataFlag(DATA_PLAYER_FLAGS, DATA_PLAYER_FLAG_SLEEP, false); this.setDataFlag(DATA_FLAGS, DATA_FLAG_GRAVITY); this.setDataProperty(new IntPositionEntityData(DATA_PLAYER_BED_POSITION, 0, 0, 0), false); if (!(this instanceof Player)) { if (this.namedTag.contains("NameTag")) { this.setNameTag(this.namedTag.getString("NameTag")); } if (this.namedTag.contains("Skin") && this.namedTag.get("Skin") instanceof CompoundTag) { if (!this.namedTag.getCompound("Skin").contains("Transparent")) { this.namedTag.getCompound("Skin").putBoolean("Transparent", false); } this.setSkin(new Skin(this.namedTag.getCompound("Skin").getByteArray("Data"), this.namedTag.getCompound("Skin").getString("ModelId"))); } this.uuid = Utils.dataToUUID(String.valueOf(this.getId()).getBytes(StandardCharsets.UTF_8), this.getSkin() .getData(), this.getNameTag().getBytes(StandardCharsets.UTF_8)); } super.initEntity(); }
Example #2
Source File: EntityHuman.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override protected void initEntity() { this.setDataFlag(DATA_PLAYER_FLAGS, DATA_PLAYER_FLAG_SLEEP, false); this.setDataFlag(DATA_FLAGS, DATA_FLAG_GRAVITY); this.setDataProperty(new IntPositionEntityData(DATA_PLAYER_BED_POSITION, 0, 0, 0), false); if (!(this instanceof Player)) { if (this.namedTag.contains("NameTag")) { this.setNameTag(this.namedTag.getString("NameTag")); } if (this.namedTag.contains("Skin") && this.namedTag.get("Skin") instanceof CompoundTag) { if (!this.namedTag.getCompound("Skin").contains("Transparent")) { this.namedTag.getCompound("Skin").putBoolean("Transparent", false); } this.setSkin(new Skin( this.namedTag.getCompound("Skin").getString("skinId"), this.namedTag.getCompound("Skin").getByteArray("skinData"), this.namedTag.getCompound("Skin").getCompound("capeData").getByteArray("capeData"), this.namedTag.getCompound("Skin").getString("geometryName"), this.namedTag.getCompound("Skin").getCompound("geometryData").getString("geometryData") )); } this.uuid = Utils.dataToUUID(String.valueOf(this.getId()).getBytes(StandardCharsets.UTF_8), this.getSkin() .getSkinData(), this.getNameTag().getBytes(StandardCharsets.UTF_8)); } super.initEntity(); if (this instanceof Player) { ((Player) this).addWindow(this.inventory, 0); } }
Example #3
Source File: Binary.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public static byte[] writeMetadata(EntityMetadata metadata) { BinaryStream stream = new BinaryStream(); Map<Integer, EntityData> map = metadata.getMap(); stream.putUnsignedVarInt(map.size()); for (int id : map.keySet()) { EntityData d = map.get(id); stream.putUnsignedVarInt(id); stream.putUnsignedVarInt(d.getType()); switch (d.getType()) { case Entity.DATA_TYPE_BYTE: stream.putByte(((ByteEntityData) d).getData().byteValue()); break; case Entity.DATA_TYPE_SHORT: stream.putLShort(((ShortEntityData) d).getData()); break; case Entity.DATA_TYPE_INT: stream.putVarInt(((IntEntityData) d).getData()); break; case Entity.DATA_TYPE_FLOAT: stream.putLFloat(((FloatEntityData) d).getData()); break; case Entity.DATA_TYPE_STRING: String s = ((StringEntityData) d).getData(); stream.putUnsignedVarInt(s.getBytes(StandardCharsets.UTF_8).length); stream.put(s.getBytes(StandardCharsets.UTF_8)); break; case Entity.DATA_TYPE_SLOT: SlotEntityData slot = (SlotEntityData) d; stream.putLShort(slot.blockId); stream.putByte((byte) slot.meta); stream.putLShort(slot.count); break; case Entity.DATA_TYPE_POS: IntPositionEntityData pos = (IntPositionEntityData) d; stream.putVarInt(pos.x); stream.putByte((byte) pos.y); stream.putVarInt(pos.z); break; case Entity.DATA_TYPE_LONG: stream.putVarLong(((LongEntityData) d).getData()); break; case Entity.DATA_TYPE_VECTOR3F: Vector3fEntityData v3data = (Vector3fEntityData) d; stream.putLFloat(v3data.x); stream.putLFloat(v3data.y); stream.putLFloat(v3data.z); break; } } return stream.getBuffer(); }