Java Code Examples for cn.nukkit.entity.data.StringEntityData
The following examples show how to use
cn.nukkit.entity.data.StringEntityData. These examples are extracted from open source projects.
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 Project: Jupiter Source File: EntityTameable.java License: GNU General Public License v3.0 | 6 votes |
@Override protected void initEntity() { super.initEntity(); if (getDataProperty(DATA_TAMED_FLAG) == null) { setDataProperty(new ByteEntityData(DATA_TAMED_FLAG, (byte) 0)); } if (getDataProperty(DATA_OWNER_NAME) == null) { setDataProperty(new StringEntityData(DATA_OWNER_NAME, "")); } String ownerName = ""; if (namedTag != null) { if (namedTag.contains("Owner")) { ownerName = namedTag.getString("Owner"); } if (ownerName.length() > 0) { this.setOwnerName(ownerName); this.setTamed(true); } this.setSitting(namedTag.getBoolean("Sitting")); } }
Example 2
Source Project: Nukkit Source File: EntityTameable.java License: GNU General Public License v3.0 | 6 votes |
@Override protected void initEntity() { super.initEntity(); if (getDataProperty(DATA_TAMED_FLAG) == null) { setDataProperty(new ByteEntityData(DATA_TAMED_FLAG, (byte) 0)); } if (getDataProperty(DATA_OWNER_NAME) == null) { setDataProperty(new StringEntityData(DATA_OWNER_NAME, "")); } String ownerName = ""; if (namedTag != null) { if (namedTag.contains("Owner")) { ownerName = namedTag.getString("Owner"); } if (ownerName.length() > 0) { this.setOwnerName(ownerName); this.setTamed(true); } this.setSitting(namedTag.getBoolean("Sitting")); } }
Example 3
Source Project: Nukkit Source File: EntityTameable.java License: GNU General Public License v3.0 | 6 votes |
@Override protected void initEntity() { super.initEntity(); if (getDataProperty(DATA_TAMED_FLAG) == null) { setDataProperty(new ByteEntityData(DATA_TAMED_FLAG, (byte) 0)); } if (getDataProperty(DATA_OWNER_NAME) == null) { setDataProperty(new StringEntityData(DATA_OWNER_NAME, "")); } String ownerName = ""; if (namedTag != null) { if (namedTag.contains("Owner")) { ownerName = namedTag.getString("Owner"); } if (ownerName.length() > 0) { this.setOwnerName(ownerName); this.setTamed(true); } this.setSitting(namedTag.getBoolean("Sitting")); } }
Example 4
Source Project: Jupiter Source File: Entity.java License: GNU General Public License v3.0 | 4 votes |
public void setNameTag(String name) { this.setDataProperty(new StringEntityData(DATA_NAMETAG, name)); }
Example 5
Source Project: Jupiter Source File: EntityTameable.java License: GNU General Public License v3.0 | 4 votes |
@Override public void setOwnerName(String playerName) { setDataProperty(new StringEntityData(DATA_OWNER_NAME, playerName)); }
Example 6
Source Project: Jupiter Source File: Binary.java License: 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(); }
Example 7
Source Project: Nukkit Source File: EntityTameable.java License: GNU General Public License v3.0 | 4 votes |
@Override public void setOwnerName(String playerName) { setDataProperty(new StringEntityData(DATA_OWNER_NAME, playerName)); }
Example 8
Source Project: Nukkit Source File: EntityTameable.java License: GNU General Public License v3.0 | 4 votes |
@Override public void setOwnerName(String playerName) { setDataProperty(new StringEntityData(DATA_OWNER_NAME, playerName)); }