public IconMenuItem addTag(String key, TagBase tag) { if (this.tag == null) { this.tag = new TagCompound(); } this.tag.put(key, tag); return this; }
public void load(TagCompound compound) { pickup = compound.getAs("Active", TagByte.class).getBooleanData(); }
public void clearConfig() { nbtTagCompound = new TagCompound(); } }
@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()); } }
@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 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 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 TagCompound save() { TagCompound nbtTagCompound = new TagCompound(); nbtTagCompound.getCompoundData().put("Active", new TagByte(pickup)); 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 convertCreeper(Creeper creeper, TagCompound properties) { properties.getCompoundData().put("Powered", new TagByte(creeper.isPowered())); }
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 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 convertSlime(Slime slime, TagCompound properties) { properties.getCompoundData().put("Size", new TagInt(slime.getSize())); }
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 convertAgable(Ageable ageable, TagCompound properties) { properties.getCompoundData().put("Baby", new TagByte(!ageable.isAdult())); }
public TagCompound save() { TagCompound nbtTagCompound = new TagCompound(); inv.save(nbtTagCompound); return nbtTagCompound; }
public void convertSkeleton(Skeleton skeleton, TagCompound properties) { properties.getCompoundData().put("Type", new TagInt(skeleton.getSkeletonType().ordinal())); }
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 void convertPig(Pig pig, TagCompound properties) { properties.getCompoundData().put("Saddle", new TagByte(pig.hasSaddle())); }
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())); } }