@Override public void writeSpawnData(ByteBuf buffer) { buffer.writeInt(spiderType.getId()); if (owner != null) { buffer.writeLong(owner.getMostSignificantBits()); buffer.writeLong(owner.getLeastSignificantBits()); } }
@Override public void readSpawnData(ByteBuf buffer) { spiderType = EnumSpiderType.byId(buffer.readInt()); try { owner = new UUID(buffer.readLong(), buffer.readLong()); } catch (IndexOutOfBoundsException e) { // Ignore. } }
@Override public void readEntityFromNBT(NBTTagCompound nbt) { super.readEntityFromNBT(nbt); spiderType = EnumSpiderType.byId(nbt.getInteger("spiderType")); abilityCounter = nbt.getInteger("abilityCounter"); abilityThreshold = nbt.getInteger("abilityThreshold"); killsUntilLevelUp = nbt.getInteger("killsUntilLevelUp"); owner = new UUID(nbt.getLong("ownerMSB"), nbt.getLong("ownerLSB")); final NBTTagList tagList = nbt.getTagList("inventory", 10); inventory.loadInventoryFromNBT(tagList); }
@Override public void writeEntityToNBT(NBTTagCompound nbt) { super.writeEntityToNBT(nbt); nbt.setInteger("spiderType", spiderType.getId()); nbt.setInteger("abilityCounter", abilityCounter); nbt.setInteger("abilityThreshold", abilityThreshold); nbt.setInteger("killsUntilLevelUp", killsUntilLevelUp); nbt.setLong("ownerMSB", owner.getMostSignificantBits()); nbt.setLong("ownerLSB", owner.getLeastSignificantBits()); nbt.setTag("inventory", inventory.saveInventoryToNBT()); }
@Override public String getCommandSenderName() { return spiderType.getFriendlyName() + " Spider"; }