private AEFluidStack( @Nonnull final FluidStack fluidStack ) { this.fluid = fluidStack.getFluid(); if( this.fluid == null ) { throw new IllegalArgumentException( "Fluid is null." ); } this.setStackSize( fluidStack.amount ); this.setCraftable( false ); this.setCountRequestable( 0 ); if( fluidStack.tag != null ) { this.tagCompound = fluidStack.tag.copy(); } }
@Override public NBTTagCompound getData( final ItemStack is ) { final NBTTagCompound c = Platform.openNbtData( is ); NBTTagCompound o = c.getCompoundTag( "Data" ); if( o == null ) { o = new NBTTagCompound(); } return o.copy(); }
private AEFluidStack( final AEFluidStack fluidStack ) { this.fluid = fluidStack.fluid; this.setStackSize( fluidStack.getStackSize() ); // priority = is.priority; this.setCraftable( fluidStack.isCraftable() ); this.setCountRequestable( fluidStack.getCountRequestable() ); if( fluidStack.hasTagCompound() ) { this.tagCompound = fluidStack.tagCompound.copy(); } }
@Override public void readFromNBT( final NBTTagCompound data ) { super.readFromNBT( data ); this.setCoreBlock( data.getBoolean( "core" ) ); if( this.isCoreBlock() ) { if( this.cluster != null ) { this.cluster.readFromNBT( data ); } else { this.setPreviousState( data.copy() ); } } }
@Override public IConfigManager getConfigManager( final ItemStack target ) { final ConfigManager out = new ConfigManager( ( manager, settingName, newValue ) -> { final NBTTagCompound data = Platform.openNbtData( target ); manager.writeToNBT( data ); } ); out.registerSetting( Settings.SORT_BY, SortOrder.NAME ); out.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); out.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); out.readFromNBT( Platform.openNbtData( target ).copy() ); return out; }
@Override public IConfigManager getConfigManager() { final ConfigManager out = new ConfigManager( ( manager, settingName, newValue ) -> { final NBTTagCompound data = Platform.openNbtData( PortableCellViewer.this.target ); manager.writeToNBT( data ); } ); out.registerSetting( Settings.SORT_BY, SortOrder.NAME ); out.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); out.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); out.readFromNBT( Platform.openNbtData( this.target ).copy() ); return out; } }
public static IAEFluidStack fromNBT( final NBTTagCompound data ) { final FluidStack fluidStack = FluidStack.loadFluidStackFromNBT( data ); if( fluidStack == null ) { return null; } final AEFluidStack fluid = AEFluidStack.fromFluidStack( fluidStack ); fluid.setStackSize( data.getLong( "Cnt" ) ); fluid.setCountRequestable( data.getLong( "Req" ) ); fluid.setCraftable( data.getBoolean( "Craft" ) ); if( fluid.hasTagCompound() ) { fluid.tagCompound = fluid.tagCompound.copy(); } return fluid; }
private boolean compareStacks(ItemStack recipe, ItemStack supplied) { if(recipe.getItem() == supplied.getItem() && recipe.getItemDamage() == supplied.getItemDamage()) { //check that the user supplied nbt tag is a superset of the recipe item nbt tag //if the recipe doesn't have an NBT tag, the user supplied one doesn't matter, it is a superset if(!recipe.hasTagCompound()) return true; //if the recipe does have an NBT tag but the user supplied doesn't, also no way it's a superset if(!supplied.hasTagCompound()) return false; NBTTagCompound mergedNBT = supplied.getTagCompound().copy(); mergedNBT.merge(recipe.getTagCompound()); return supplied.getTagCompound().equals(mergedNBT); } return false; }
/** * Gets the data of this file. The data you receive is a copied version. If you want to update * it, use {@link #setData(NBTTagCompound, Callback)} to do so. * * @return the file's data */ @Nullable public NBTTagCompound getData() { return data.copy(); }
public @Nullable NBTTagCompound setStackCopy(@Nullable NBTTagCompound tag, @Nonnull ItemStack value) { return tag != null ? setStack(tag.copy(), value) : null; }
public @Nullable NBTTagCompound removeTagCopy(@Nullable NBTTagCompound tag) { return tag != null ? removeTag(tag.copy()) : null; }
/** * Returns a copy of this file. The copied file is considered invalid and changes to it can not * be made until it is added into the file system. * * @return copy of this file */ public File copy() { return new File(name, openingApp, data.copy()); }
public ServerFile copy() { return new ServerFile(name, openingApp, data.copy()); } }
private ItemEntry getComplexItem(int itemID, int meta, NBTTagCompound nbt, boolean create) { int hash = computeComplexHash(itemID, meta, nbt); ItemEntryKey key = new ItemEntryKey(hash, itemID, meta, nbt); ItemEntry entry = complexRegistry.get(key); if (entry == null && create) { if (nbt != null) { nbt = nbt.copy(); } entry = createItemEntry(COMPLEX_DBINDEX_START + complexItems.size(), hash, itemID, meta, nbt); complexItems.add(entry); complexRegistry.put(entry, entry); } return entry; }
public ItemStack getCatalystStack() { ItemStack result = new ItemStack(this.catalyst, 1, this.catalystMeta); if(this.catalystNbt != null) { result.setTagCompound(this.catalystNbt.copy()); } return result; }
public @Nonnull NBTTagCompound toNbt(@Nullable NBTTagCompound nbt) { NBTTagCompound data = nbt != null ? nbt : new NBTTagCompound(); data.setString(ENTITY_ID_KEY, entityId.toString()); if (entityNbt != null) { data.setTag(ENTITY_KEY, entityNbt.copy()); } if (customName != null) { data.setString(CUSTOM_NAME_KEY, customName); } return data; }
public ComparableItemStackNBT(ItemStack stack) { super(stack); if (!stack.isEmpty() && stack.getTagCompound() != null) { tag = stack.getTagCompound().copy(); } }
public static ItemStack copyTag(ItemStack container, ItemStack other) { if (!other.isEmpty() && other.hasTagCompound()) { container.setTagCompound(other.getTagCompound().copy()); } return container; }
@Nullable @Override public NBTTagCompound getNBTShareTag(ItemStack stack) { if (!stack.hasTagCompound() || !stack.getTagCompound().hasKey("stored")) return super.getNBTShareTag(stack); NBTTagCompound shareTag = stack.getTagCompound().copy(); NBTTagCompound storedTag = shareTag.getCompoundTag("stored"); storedTag.removeTag("state"); storedTag.removeTag("stored"); return shareTag; } }
final NBTTagCompound data = new NBTTagCompound(); ote.writeToNBT( data ); nte.readFromNBT( data.copy() ); world.setTileEntity( d, nte );