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); }
private NBTBase createItemTag( final ItemStack i ) { final NBTTagCompound c = new NBTTagCompound(); if( !i.isEmpty() ) { i.writeToNBT( c ); } return c; }
@Nonnull @Override public NBTTagCompound writeToNBT(NBTTagCompound cmp) { NBTTagCompound ret = super.writeToNBT(cmp); cmp.setInteger(TAG_STACK_COUNT, stacksIn.size()); int i = 0; for(ItemStack stack : stacksIn) { NBTTagCompound stackcmp = stack.writeToNBT(new NBTTagCompound()); cmp.setTag(TAG_STACK + i, stackcmp); i++; } return ret; }
@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 ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens) { if(!compositeLens.isEmpty()) { NBTTagCompound cmp = compositeLens.writeToNBT(new NBTTagCompound()); ItemNBTHelper.setCompound(sourceLens, TAG_COMPOSITE_LENS, cmp); } return sourceLens; }
@Override public void writePacketNBT(NBTTagCompound cmp) { super.writePacketNBT(cmp); NBTTagCompound cmp1 = new NBTTagCompound(); if(!stack.isEmpty()) cmp1 = stack.writeToNBT(cmp1); cmp.setTag(TAG_STACK, cmp1); }
@Override public void writePacketNBT(NBTTagCompound par1nbtTagCompound) { super.writePacketNBT(par1nbtTagCompound); NBTTagCompound cmp = new NBTTagCompound(); if(!requestTarget.isEmpty()) cmp = requestTarget.writeToNBT(cmp); par1nbtTagCompound.setTag(TAG_REQUEST_TARGET, cmp); par1nbtTagCompound.setInteger(TAG_ITEM_COUNT, itemCount); }
@Override public void writePacketNBT(NBTTagCompound cmp) { cmp.setInteger(TAG_MANA, mana); cmp.setInteger(TAG_MANA_REQUIRED, manaRequired); cmp.setInteger(TAG_STAGE, stage.ordinal()); cmp.setInteger(TAG_STAGE_TICKS, stageTicks); cmp.setInteger(TAG_STAGE_3_END_TICKS, stage3EndTicks); NBTTagCompound itemCmp = new NBTTagCompound(); if(!itemToEnchant.isEmpty()) itemCmp = itemToEnchant.writeToNBT(itemCmp); cmp.setTag(TAG_ITEM, itemCmp); String enchStr = enchants.stream() .map(e -> Enchantment.REGISTRY.getNameForObject(e.enchantment) + "=" + e.enchantmentLevel) .collect(Collectors.joining(",")); cmp.setString(TAG_ENCHANTS, enchStr); }
@Override public void writeToNBT( final NBTTagCompound c ) { for( int x = 0; x < this.facades; x++ ) { if( this.storage.getFacade( x ) != null ) { final NBTTagCompound data = new NBTTagCompound(); this.storage.getFacade( x ).getItemStack().writeToNBT( data ); c.setTag( "facade:" + x, data ); } } }
private void setColor( final ItemStack is, final ItemStack newColor ) { final NBTTagCompound data = Platform.openNbtData( is ); if( newColor.isEmpty() ) { data.removeTag( "color" ); } else { final NBTTagCompound color = new NBTTagCompound(); newColor.writeToNBT( color ); data.setTag( "color", color ); } }
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); }
@Override public void writeToNBT( final NBTTagCompound i ) { this.getDefinition().writeToNBT( i ); i.setLong( "Cnt", this.getStackSize() ); i.setLong( "Req", this.getCountRequestable() ); i.setBoolean( "Craft", this.isCraftable() ); }
private void saveRecipeToStack(ItemCraftedEvent event, ItemStack stack) { NBTTagCompound cmp = new NBTTagCompound(); NBTTagCompound cmp1 = new NBTTagCompound(); ItemStack result = CraftingManager.findMatchingResult((InventoryCrafting) event.craftMatrix, event.player.world); if(!result.isEmpty()) { cmp1 = result.writeToNBT(cmp1); cmp.setTag(TAG_ITEM_PREFIX + 9, cmp1); for(int i = 0; i < 9; i++) { cmp1 = new NBTTagCompound(); ItemStack stackSlot = event.craftMatrix.getStackInSlot(i); if(!stackSlot.isEmpty()) { ItemStack writeStack = stackSlot.copy(); writeStack.setCount(1); cmp1 = writeStack.writeToNBT(cmp1); } cmp.setTag(TAG_ITEM_PREFIX + i, cmp1); } } ItemNBTHelper.setCompound(stack, TAG_LAST_CRAFTING, cmp); }
private void addItems( final NBTTagCompound data, final InvTracker inv, final int offset, final int length ) { final String name = '=' + Long.toString( inv.which, Character.MAX_RADIX ); final NBTTagCompound tag = data.getCompoundTag( name ); if( tag.hasNoTags() ) { tag.setLong( "sortBy", inv.sortBy ); tag.setString( "un", inv.unlocalizedName ); } for( int x = 0; x < length; x++ ) { final NBTTagCompound itemNBT = new NBTTagCompound(); final ItemStack is = inv.server.getStackInSlot( x + offset ); // "update" client side. ItemHandlerUtil.setStackInSlot( inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy() ); if( !is.isEmpty() ) { is.writeToNBT( itemNBT ); } tag.setTag( Integer.toString( x + offset ), itemNBT ); } data.setTag( name, tag ); }
@Override public NBTTagCompound writeToNBT( final NBTTagCompound data ) { super.writeToNBT( data ); if( this.forcePlan && this.myPlan != null ) { final ItemStack pattern = this.myPlan.getPattern(); if( !pattern.isEmpty() ) { final NBTTagCompound compound = new NBTTagCompound(); pattern.writeToNBT( compound ); data.setTag( "myPlan", compound ); data.setInteger( "pushDirection", this.pushDirection.ordinal() ); } } this.upgrades.writeToNBT( data, "upgrades" ); this.settings.writeToNBT( data ); return data; }
@Override public NBTTagCompound writeToNBT( final NBTTagCompound data ) { super.writeToNBT( data ); this.cm.writeToNBT( data ); data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() ); data.setLong( "securityKey", this.securityKey ); this.getConfigSlot().writeToNBT( data, "config" ); final NBTTagCompound storedItems = new NBTTagCompound(); int offset = 0; for( final IAEItemStack ais : this.inventory.getStoredItems() ) { final NBTTagCompound it = new NBTTagCompound(); ais.createItemStack().writeToNBT( it ); storedItems.setTag( String.valueOf( offset ), it ); offset++; } data.setTag( "storedItems", storedItems ); return data; }
public void writeToNBT( final NBTTagCompound data ) { this.config.writeToNBT( data, "config" ); this.patterns.writeToNBT( data, "patterns" ); this.storage.writeToNBT( data, "storage" ); this.upgrades.writeToNBT( data, "upgrades" ); this.cm.writeToNBT( data ); this.craftingTracker.writeToNBT( data ); data.setInteger( "priority", this.priority ); final NBTTagList waitingToSend = new NBTTagList(); if( this.waitingToSend != null ) { for( final ItemStack is : this.waitingToSend ) { final NBTTagCompound item = new NBTTagCompound(); is.writeToNBT( item ); waitingToSend.appendTag( item ); } } data.setTag( "waitingToSend", waitingToSend ); }
public void writeToNBT( final NBTTagCompound data ) { data.setInteger( "hasRedstone", this.hasRedstone.ordinal() ); final IFacadeContainer fc = this.getFacadeContainer(); for( final AEPartLocation s : AEPartLocation.values() ) { fc.writeToNBT( data ); final IPart part = this.getPart( s ); if( part != null ) { final NBTTagCompound def = new NBTTagCompound(); part.getItemStack( PartItemStack.WORLD ).writeToNBT( def ); final NBTTagCompound extra = new NBTTagCompound(); part.writeToNBT( extra ); data.setTag( "def:" + this.getSide( part ).ordinal(), def ); data.setTag( "extra:" + this.getSide( part ).ordinal(), extra ); } } }