public void convertCreeper(Creeper creeper, TagCompound properties) { properties.getCompoundData().put("Powered", new TagByte(creeper.isPowered())); }
public void load(TagCompound compound) { pickup = compound.getAs("Active", TagByte.class).getBooleanData(); }
public void load(TagCompound nbtTagCompound) { TagList items = nbtTagCompound.getAs("Items", TagList.class); for (int i = 0; i < items.size(); i++) { TagCompound itemCompound = items.getTagAs(i, TagCompound.class); ItemStack itemStack = ItemStackNBTConverter.compundToItemStack(itemCompound); setItem(itemCompound.getAs("Slot", TagByte.class).getByteData(), itemStack); } }
public static ItemStack compundToItemStack(TagCompound compound) { int id = compound.getAs("id", TagShort.class).getShortData(); int count = compound.getAs("Count", TagByte.class).getByteData(); int damage = compound.getAs("Damage", TagShort.class).getShortData(); ItemStack itemstack = new ItemStack(Item.getById(id), count, damage); if (compound.containsKeyAs("tag", TagCompound.class)) { TagCompound compoundToConvert = compound.get("tag"); itemstack.setTag((NBTTagCompound) compoundToVanillaCompound(compoundToConvert)); } return itemstack; }
public TagCompound save() { TagCompound nbtTagCompound = new TagCompound(); nbtTagCompound.getCompoundData().put("Active", new TagByte(pickup)); return nbtTagCompound; }
return new NBTTagString(((TagString) tag).getStringData()); case Byte: return new NBTTagByte(((TagByte) tag).getByteData()); case Byte_Array: return new NBTTagByteArray(((TagByteArray) tag).getByteArrayData());
@Override public void load(TagCompound compound) { if (compound.getCompoundData().containsKey("Buff")) { Buff selectedBuff = Buff.getBuffByID(compound.getAs("Buff", TagInt.class).getIntData()); if (selectedBuff != null) { this.selectedBuffs.add(selectedBuff); } } if (compound.getCompoundData().containsKey("Buffs")) { int[] selectedBuffs = compound.getAs("Buffs", TagIntArray.class).getIntArrayData(); if (selectedBuffs.length != 0) { for (int selectedBuffId : selectedBuffs) { Buff selectedBuff = Buff.getBuffByID(selectedBuffId); if (selectedBuff != null) { this.selectedBuffs.add(selectedBuff); } } } } if (compound.getCompoundData().containsKey("Active")) { this.active = compound.getAs("Active", TagByte.class).getBooleanData(); } if (compound.getCompoundData().containsKey("Reciever")) { this.receiver = BuffReceiver.valueOf(compound.getAs("Reciever", TagString.class).getStringData()); } }
public TagCompound save(TagCompound compound) { List<TagCompound> itemList = new ArrayList<>(); for (int i = 0; i < this.items.size(); i++) { ItemStack itemStack = this.items.get(i); if (itemStack != null) { TagCompound item = ItemStackNBTConverter.itemStackToCompund(itemStack); item.getCompoundData().put("Slot", new TagByte((byte) i)); itemList.add(item); } } compound.getCompoundData().put("Items", new TagList(itemList)); return compound; }
public void convertPig(Pig pig, TagCompound properties) { properties.getCompoundData().put("Saddle", new TagByte(pig.hasSaddle())); }
public void convertAgable(Ageable ageable, TagCompound properties) { properties.getCompoundData().put("Baby", new TagByte(!ageable.isAdult())); }
public void convertWolf(Wolf wolf, TagCompound properties) { properties.getCompoundData().put("Sitting", new TagByte(wolf.isSitting())); properties.getCompoundData().put("Tamed", new TagByte(wolf.isTamed())); properties.getCompoundData().put("CollarColor", new TagByte(wolf.getCollarColor().getWoolData())); } }
@Override public TagCompound save() { TagCompound nbtTagCompound = new TagCompound(); nbtTagCompound.getCompoundData().put("Buffs", new TagIntArray(selectedBuffs.stream().mapToInt(Buff::getId).toArray())); nbtTagCompound.getCompoundData().put("Active", new TagByte(this.active)); nbtTagCompound.getCompoundData().put("Reciever", new TagString(this.receiver.name())); return nbtTagCompound; }
public void convertZombie(Zombie zombie, TagCompound properties) { properties.getCompoundData().put("Baby", new TagByte(zombie.isBaby())); if (zombie.isVillager()) { properties.getCompoundData().put("Type", new TagInt(1)); } }
public void convertSheep(Sheep sheep, TagCompound properties) { properties.getCompoundData().put("Color", new TagInt(sheep.getColor().getDyeData())); properties.getCompoundData().put("Sheared", new TagByte(sheep.isSheared())); }
public void convertOcelot(Ocelot ocelot, TagCompound properties) { properties.getCompoundData().put("CatType", new TagInt(ocelot.getCatType().getId())); properties.getCompoundData().put("Sitting", new TagByte(ocelot.isSitting())); }
public static TagCompound itemStackToCompund(ItemStack itemStack) { TagCompound compound = new TagCompound(); compound.getCompoundData().put("id", new TagShort((short) Item.getId(itemStack.getItem()))); compound.getCompoundData().put("Count", new TagByte((byte) itemStack.count)); compound.getCompoundData().put("Damage", new TagShort((short) itemStack.getData())); if (itemStack.getTag() != null) { compound.getCompoundData().put("tag", vanillaCompoundToCompound(itemStack.getTag())); } return compound; }
public void convertHorse(Horse horse, TagCompound properties) { byte type = (byte) horse.getVariant().ordinal(); int style = horse.getStyle().ordinal(); int color = horse.getColor().ordinal(); int variant = color & 255 | style << 8; if (horse.getInventory().getArmor() != null) { TagCompound armor = MyPetApi.getPlatformHelper().itemStackToCompund(horse.getInventory().getArmor()); properties.getCompoundData().put("Armor", armor); } if (horse.getInventory().getSaddle() != null) { TagCompound saddle = MyPetApi.getPlatformHelper().itemStackToCompund(horse.getInventory().getSaddle()); properties.getCompoundData().put("Saddle", saddle); } properties.getCompoundData().put("Type", new TagByte(type)); properties.getCompoundData().put("Variant", new TagInt(variant)); properties.getCompoundData().put("Chest", new TagByte(horse.isCarryingChest())); properties.getCompoundData().put("Age", new TagInt(horse.getAge())); if (horse.isCarryingChest()) { ItemStack[] contents = horse.getInventory().getContents(); for (int i = 2; i < contents.length; i++) { ItemStack item = contents[i]; if (item != null) { horse.getWorld().dropItem(horse.getLocation(), item); } } } }
switch (vanillaTag.getTypeId()) { case 1: return new TagByte(((NBTTagByte) vanillaTag).f()); case 2: return new TagShort(((NBTTagShort) vanillaTag).e());