public void readFromNBT( final NBTTagCompound extra ) { for( int x = 0; x < this.size; x++ ) { final NBTTagCompound link = extra.getCompoundTag( "links-" + x ); if( link != null && !link.hasNoTags() ) { this.setLink( x, AEApi.instance().storage().loadCraftingLink( link, this.owner ) ); } } }
public InvalidPatternHelper( final ItemStack is ) { final NBTTagCompound encodedValue = is.getTagCompound(); if( encodedValue == null ) { throw new IllegalArgumentException( "No pattern here!" ); } final NBTTagList inTag = encodedValue.getTagList( "in", 10 ); final NBTTagList outTag = encodedValue.getTagList( "out", 10 ); this.isCrafting = encodedValue.getBoolean( "crafting" ); this.canSubstitute = this.isCrafting && encodedValue.getBoolean( "substitute" ); for( int i = 0; i < outTag.tagCount(); i++ ) { this.outputs.add( new PatternIngredient( outTag.getCompoundTagAt( i ) ) ); } for( int i = 0; i < inTag.tagCount(); i++ ) { NBTTagCompound in = inTag.getCompoundTagAt( i ); // skip empty slots in the crafting grid if( in.hasNoTags() ) { continue; } this.inputs.add( new PatternIngredient( in ) ); } }
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 ); }
/** * null means nothing to store... * * @param from source of settings * * @return compound of source */ private NBTTagCompound downloadSettings( final SettingsFrom from ) { final NBTTagCompound output = new NBTTagCompound(); final IConfigManager cm = this.getConfigManager(); if( cm != null ) { cm.writeToNBT( output ); } if( this instanceof IPriorityHost ) { final IPriorityHost pHost = (IPriorityHost) this; output.setInteger( "priority", pHost.getPriority() ); } final IItemHandler inv = this.getInventoryByName( "config" ); if( inv instanceof AppEngInternalAEInventory ) { ( (AppEngInternalAEInventory) inv ).writeToNBT( output, "config" ); } return output.hasNoTags() ? null : output; }
if( !this.data.hasNoTags() )
return output.hasNoTags() ? null : output;
@Override public void fromBytes(ByteBuf buf) { this.tag = ByteBufUtils.readTag(buf); if (tag == null || tag.hasNoTags()) ThELog.error("[FROM] TAG HAS NO INFO"); }
public static ResourceLocation getSpiritNameOrNullFromNBTTag(NBTTagCompound tag) { if(tag != null && !tag.hasNoTags()) { String innerEntity = tag.getString(NBTKEY_INNER_SPIRIT); return getSpiritNameOrNullFromInnerEntity(innerEntity); } return null; }
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); assert gridLinkList.isEmpty(); final NBTTagCompound gridLinks = nbt.getCompoundTag("gridLinks"); for (Integer i = 0; ; i++) { final NBTTagCompound linkTag = gridLinks.getCompoundTag(i.toString()); if (linkTag.hasNoTags()) break; gridLinksBooting.add(new GridLink(linkTag, "")); } }
@Override public IItemFilter createFilterFromStack(@Nonnull ItemStack stack) { ItemFilter filter = new ItemFilter(filterType); NBTTagCompound tag = NbtValue.FILTER.getTag(stack); if (!tag.hasNoTags()) { filter.readFromNBT(tag); } return filter; }
@Override public void readFromNBT(@Nonnull Chunk chunk, @Nonnull NBTTagCompound tag) { int dimID = chunk.getWorld().provider.getDimension(); ChunkPos coords = chunk.getPos(); if (tag.hasNoTags()) { data.remove(dimID, coords); return; } T t = getOrCreateNew(dimID, coords); t.read(tag); }
@Override public IItemFilter createFilterFromStack(@Nonnull ItemStack stack) { EnchantmentFilter filter = new EnchantmentFilter(); filter.setSlotCount(size); NBTTagCompound tag = NbtValue.FILTER.getTag(stack); if (!tag.hasNoTags()) { filter.readFromNBT(tag); } return filter; }
@Override public IItemFilter createFilterFromStack(@Nonnull ItemStack stack) { SoulFilter filter = new SoulFilter(); filter.setSlotCount(size); NBTTagCompound tag = NbtValue.FILTER.getTag(stack); if (!tag.hasNoTags()) { filter.readFromNBT(tag); } return filter; }
@Override public SPacketUpdateTileEntity getUpdatePacket() { final NBTTagCompound nbttagcompound = new NBTTagCompound(); writeChisleData( nbttagcompound ); if ( nbttagcompound.hasNoTags() ) { return null; } return new SPacketUpdateTileEntity( pos, 255, nbttagcompound ); }
@Override public void writeToNBT(final NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setShort(TAG_VALUE, writing); if (serialInterface.isPresent()) { final NBTTagCompound serialInterfaceNbt = new NBTTagCompound(); serialInterface.get().writeToNBT(serialInterfaceNbt); if (!nbt.hasNoTags()) { nbt.setTag(TAG_SERIAL_INTERFACE, serialInterfaceNbt); } } }
@Nullable public MessageBase getRefreshPacket() { final NBTTagCompound nbt = new NBTTagCompound(); this.syncToNBT(nbt); if (nbt.hasNoTags()) { return null; } return new MessageSyncTile(BinnieCorePacketID.TILE_DESCRIPTION_SYNC.ordinal(), this.getTileEntity(), nbt); }
@Override public ItemStack removeModule(ItemStack stack, int slot) { IModule module = getModuleInSlot(stack, slot); NBTTagCompound tag = stack.getSubCompound(String.valueOf(slot)); stack.setTagInfo(String.valueOf(slot), new NBTTagCompound()); stack.getTagCompound().setString("slot" + slot, ""); ItemStack toReturn = new ItemStack(ModuleItemRegistry.instance().getValue(module.getName()), 1); if (tag != null && !tag.hasNoTags()) toReturn.setTagCompound(tag); return toReturn; }
public static void writePlayerData(ArrayList<IResearch> research, NBTTagCompound nbt, SyncType type) { NBTTagList researchList = new NBTTagList(); for (IResearch r : research) { NBTTagCompound researchTag = new NBTTagCompound(); researchTag.setString(RESEARCH, r.getName()); r.writeData(researchTag, type); if (!researchTag.hasNoTags()) researchList.appendTag(researchTag); } if (!researchList.hasNoTags()) nbt.setTag(LIST, researchList); }
public static void favoriteItem(EntityPlayer player, int slot) { if(!ModuleLoader.isFeatureEnabled(FavoriteItems.class) || slot >= player.inventory.getSizeInventory()) return; ItemStack stack = player.inventory.getStackInSlot(slot); if(!stack.isEmpty()) { if(isItemFavorited(stack)) { NBTTagCompound cmp = stack.getTagCompound(); cmp.removeTag(TAG_FAVORITE_ITEM); if(cmp.hasNoTags()) stack.setTagCompound(null); } else ItemNBTHelper.setBoolean(stack, TAG_FAVORITE_ITEM, true); } }