public static void setLong(ItemStack stack, String tag, long l) { getNBT(stack).setLong(tag, l); }
/** * Called on server to transfer information from server to client. * <p/> * If the {@link net.minecraft.tileentity.TileEntity} is a {@link appeng.api.networking.energy.IAEPowerStorage}, it * writes the power information to the {@code #tag} using the {@code #ID_CURRENT_POWER} key. * * @param player player looking at the power storage * @param te power storage * @param tag transferred tag which is send to the client * @param world world of the power storage * @param pos pos of the power storage * * @return tag send to the client */ @Override public NBTTagCompound getNBTData( EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos ) { if( te instanceof IAEPowerStorage ) { final IAEPowerStorage storage = (IAEPowerStorage) te; if( storage.getAEMaxPower() > 0 ) { final long internalCurrentPower = (long) ( 100 * storage.getAECurrentPower() ); tag.setLong( ID_CURRENT_POWER, internalCurrentPower ); } } return tag; }
@Override public void saveToNBT( final String name, final NBTTagCompound nodeData ) { if( this.myStorage != null ) { final NBTTagCompound node = new NBTTagCompound(); node.setInteger( "p", this.playerID ); node.setLong( "k", this.getLastSecurityKey() ); node.setLong( "g", this.myStorage.getID() ); nodeData.setTag( name, node ); } else { nodeData.removeTag( name ); } }
public void writeToNBT( final NBTTagCompound data ) { data.setTag( "finalOutput", this.writeItem( this.finalOutput ) ); data.setTag( "inventory", this.writeList( this.inventory.getItemList() ) ); data.setBoolean( "waiting", this.waiting ); data.setBoolean( "isComplete", this.isComplete ); if( this.myLastLink != null ) { final NBTTagCompound link = new NBTTagCompound(); this.myLastLink.writeToNBT( link ); data.setTag( "link", link ); } final NBTTagList list = new NBTTagList(); for( final Entry<ICraftingPatternDetails, TaskProgress> e : this.tasks.entrySet() ) { final NBTTagCompound item = this.writeItem( AEItemStack.fromItemStack( e.getKey().getPattern() ) ); item.setLong( "craftingProgress", e.getValue().value ); list.appendTag( item ); } data.setTag( "tasks", list ); data.setTag( "waitingFor", this.writeList( this.waitingFor ) ); data.setLong( "elapsedTime", this.getElapsedTime() ); data.setLong( "startItemCount", this.getStartItemCount() ); data.setLong( "remainingItemCount", this.getRemainingItemCount() ); }
@Override public void writeToNBT( final NBTTagCompound data ) { data.setString( "FluidName", this.fluid.getName() ); data.setByte( "Count", (byte) 0 ); data.setLong( "Cnt", this.getStackSize() ); data.setLong( "Req", this.getCountRequestable() ); data.setBoolean( "Craft", this.isCraftable() ); if( this.hasTagCompound() ) { data.setTag( "Tag", this.tagCompound ); } else { data.removeTag( "Tag" ); } }
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 ); 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 @Nullable NBTTagCompound setLong(@Nullable NBTTagCompound tag, long value) { if (tag != null) { tag.setLong(key, value); } return tag; }
@Override public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { super.writeEntityToNBT(par1nbtTagCompound); par1nbtTagCompound.setInteger(TAG_TICKS_EXISTED, getTicksExisted()); par1nbtTagCompound.setInteger(TAG_COLOR, getColor()); par1nbtTagCompound.setInteger(TAG_MANA, getMana()); par1nbtTagCompound.setInteger(TAG_STARTING_MANA, getStartingMana()); par1nbtTagCompound.setInteger(TAG_MIN_MANA_LOSS, getMinManaLoss()); par1nbtTagCompound.setFloat(TAG_TICK_MANA_LOSS, getManaLossPerTick()); par1nbtTagCompound.setFloat(TAG_GRAVITY, getGravity()); ItemStack stack = getSourceLens(); NBTTagCompound lensCmp = new NBTTagCompound(); if(!stack.isEmpty()) lensCmp = stack.writeToNBT(lensCmp); par1nbtTagCompound.setTag(TAG_LENS_STACK, lensCmp); BlockPos coords = getBurstSourceBlockPos(); par1nbtTagCompound.setInteger(TAG_SPREADER_X, coords.getX()); par1nbtTagCompound.setInteger(TAG_SPREADER_Y, coords.getY()); par1nbtTagCompound.setInteger(TAG_SPREADER_Z, coords.getZ()); par1nbtTagCompound.setDouble(TAG_LAST_MOTION_X, motionX); par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Y, motionY); par1nbtTagCompound.setDouble(TAG_LAST_MOTION_Z, motionZ); UUID identity = getShooterUUID(); boolean hasShooter = identity != null; par1nbtTagCompound.setBoolean(TAG_HAS_SHOOTER, hasShooter); if(hasShooter) { par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_MOST, identity.getMostSignificantBits()); par1nbtTagCompound.setLong(TAG_SHOOTER_UUID_LEAST, identity.getLeastSignificantBits()); } }
cmp.setLong( "freq", ( new Date() ).getTime() * 100 + ( randTickSeed ) % 100 ); randTickSeed++; item.grow( -1 );
public void save() { NBTTagCompound nbtTagCompound = masterStack.getTagCompound(); if (nbtTagCompound == null) { nbtTagCompound = new NBTTagCompound(); UUID uuid = UUID.randomUUID(); nbtTagCompound.setLong(Constants.NBT.MOST_SIG, uuid.getMostSignificantBits()); nbtTagCompound.setLong(Constants.NBT.LEAST_SIG, uuid.getLeastSignificantBits()); } writeToNBT(nbtTagCompound); masterStack.setTagCompound(nbtTagCompound); }
@SuppressWarnings("null") public @Nonnull ItemStack setLong(@Nonnull ItemStack stack, long value) { if (Prep.isValid(stack)) { if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } stack.getTagCompound().setLong(key, value); } return stack; }
@Override public void onEntityCollidedWithBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Entity entity) { if (!world.isRemote && entity instanceof EntityPlayerMP) { long time = entity.world.getTotalWorldTime(); EntityPlayerMP player = (EntityPlayerMP) entity; if (time % FluidConfig.nutrientFoodBoostDelay.get() == 0 && player.getEntityData().getLong("eioLastFoodBoost") != time) { player.getFoodStats().addStats(1, 0.1f); player.getEntityData().setLong("eioLastFoodBoost", time); } } super.onEntityCollidedWithBlock(world, pos, state, entity); }
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setInteger("bountyLevel", bountyLevel); nbttagcompound.setLong("lastUpdate", lastUpdate); gameBoard.writeToNBT(nbttagcompound); nbttagcompound.setInteger("Status", status.ordinal()); return nbttagcompound; }
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt.setLong(POS_KEY, position); nbt.setTag(STATE_DATA_KEY, ClimateStateHelper.INSTANCE.writeToNBT(new NBTTagCompound(), climateState)); nbt.setInteger(RANGE_KEY, range); nbt.setBoolean(CIRCULAR_KEY, circular); nbt.setTag(CHUNKS_KEY, new NBTTagLongArray(chunks)); return nbt; } }