public static NBTTagCompound copyNbtData(TileEntity tile) { NBTTagCompound tag = new NBTTagCompound(); tile.writeToNBT(tag); return tag; } }
public static NBTTagCompound toNative(CompoundTag tag) { NBTTagCompound compound = new NBTTagCompound(); for (Entry<String, Tag> child : tag.getValue().entrySet()) { compound.setTag(child.getKey(), toNative(child.getValue())); } return compound; }
@Override public BaseEntity getState() { net.minecraft.entity.Entity entity = entityRef.get(); if (entity != null) { String id = EntityList.getEntityString(entity); if (id != null) { NBTTagCompound tag = new NBTTagCompound(); entity.writeToNBT(tag); return new BaseEntity(EntityTypes.get(id), NBTConverter.fromNative(tag)); } else { return null; } } else { return null; } }
/** * fake storage. */ public GridStorage() { this.myID = 0; this.mySearchEntry = null; this.data = new NBTTagCompound(); }
@Subscribe public void init(FMLInitializationEvent event) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setString("ContainerClass", ContainerCraftingStation.class.getName()); tagCompound.setString("AlignToGrid", "left"); FMLInterModComms.sendMessage(modid, "RegisterProvider", tagCompound); }
/** * Builds an unusable tool that only has the rendering info */ @Nonnull public ItemStack buildItemForRendering(List<Material> materials) { ItemStack tool = new ItemStack(this); NBTTagCompound base = new NBTTagCompound(); base.setTag(Tags.BASE_DATA, buildData(materials)); tool.setTagCompound(base); return tool; }
public void writeToNBT( final NBTTagCompound data, final String name ) { final NBTTagCompound c = new NBTTagCompound(); this.writeToNBT( c ); data.setTag( name, c ); }
@Override public void toBytes(ByteBuf buf) { writePos(pos, buf); buf.writeInt(liquids.size()); for(FluidStack liquid : liquids) { NBTTagCompound fluidTag = new NBTTagCompound(); liquid.writeToNBT(fluidTag); ByteBufUtils.writeTag(buf, fluidTag); } } }
public static void setLensAtPos(ItemStack stack, ItemStack lens, int pos) { NBTTagCompound cmp = new NBTTagCompound(); if(lens != null) cmp = lens.writeToNBT(cmp); ItemNBTHelper.setCompound(stack, TAG_LENS + pos, cmp); }
@Override public final SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound tag = new NBTTagCompound(); writePacketNBT(tag); return new SPacketUpdateTileEntity(pos, -999, tag); }
private NBTBase createItemTag( final ItemStack i ) { final NBTTagCompound c = new NBTTagCompound(); if( !i.isEmpty() ) { i.writeToNBT( c ); } return c; }
/** If nullifyOnFail is true it'll return null if it doesn't find any * compounds, otherwise it'll return a new one. **/ public static NBTTagCompound getCompound(ItemStack stack, String tag, boolean nullifyOnFail) { return verifyExistance(stack, tag) ? getNBT(stack).getCompoundTag(tag) : nullifyOnFail ? null : new NBTTagCompound(); }
@Override public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) { NBTTagCompound cmp = new NBTTagCompound(); if(!cosmetic.isEmpty()) cmp = cosmetic.writeToNBT(cmp); ItemNBTHelper.setCompound(stack, TAG_COSMETIC_ITEM, cmp); }
@Override public void toBytes(ByteBuf buf) { writePos(pos, buf); writePos(tank, buf); buf.writeInt(temperature); NBTTagCompound fluidTag = new NBTTagCompound(); fuel.writeToNBT(fluidTag); ByteBufUtils.writeTag(buf, fluidTag); } }
public static ItemStack getItemstackWithMaterials(Material shaft, Material head) { ItemStack stack = new ItemStack(TinkerTools.boltCore); NBTTagList tagList = new NBTTagList(); tagList.appendTag(new NBTTagString(shaft.getIdentifier())); tagList.appendTag(new NBTTagString(head.getIdentifier())); NBTTagCompound rootTag = new NBTTagCompound(); NBTTagCompound baseTag = new NBTTagCompound(); baseTag.setTag(Tags.BASE_MATERIALS, tagList); rootTag.setTag(Tags.BASE_DATA, baseTag); stack.setTagCompound(rootTag); return stack; }
@Override public void writePacketNBT(NBTTagCompound cmp) { super.writePacketNBT(cmp); cmp.setString(TAG_SUBTILE_NAME, subTileName); NBTTagCompound subCmp = new NBTTagCompound(); cmp.setTag(TAG_SUBTILE_CMP, subCmp); if(subTile != null) subTile.writeToPacketNBTInternal(subCmp); }
public static void assignRecipe(ItemStack stack, ItemStack itemForPos, int pos) { if(!itemForPos.isEmpty()) ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, new NBTTagCompound()); else ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, getLastCraftingCompound(stack, false)); }
public static void setLens(ItemStack stack, ItemStack lens) { if(hasClip(stack)) setLensAtPos(stack, lens, getClipPos(stack)); NBTTagCompound cmp = new NBTTagCompound(); if(!lens.isEmpty()) cmp = lens.writeToNBT(cmp); ItemNBTHelper.setCompound(stack, TAG_LENS, cmp); }
@Override public void writeEntityToNBT(NBTTagCompound compound) { super.writeEntityToNBT(compound); if(!stack.isEmpty()) { compound.setTag("fly_stack", stack.writeToNBT(new NBTTagCompound())); } compound.setBoolean("flare", isFire()); }
@Override public void writeToPacketNBT(NBTTagCompound cmp) { super.writeToPacketNBT(cmp); cmp.setInteger(TAG_COOLDOWN, cooldown); cmp.setInteger(TAG_DIGESTING_MANA, digestingMana); cmp.setTag(TAG_LAST_FOOD, lastFood.writeToNBT(new NBTTagCompound())); cmp.setInteger(TAG_LAST_FOOD_COUNT, lastFoodCount); }