@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 void setFluidStack( ItemStack is, FluidStack fs ) { if( fs == null ) { is.setTagCompound( null ); } else { NBTTagCompound tag = new NBTTagCompound(); fs.writeToNBT( tag ); is.setTagCompound( tag ); } }
@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); } }
@Override public void toBytes(ByteBuf buf) { writePos(pos, buf); NBTTagCompound tag = new NBTTagCompound(); if(fluid != null) { fluid.writeToNBT(tag); } ByteBufUtils.writeTag(buf, tag); }
public void writeToNBT(NBTTagCompound tag) { NBTTagList taglist = new NBTTagList(); for(FluidStack liquid : liquids) { if(FluidRegistry.getFluidName(liquid.getFluid()) == null) { TinkerSmeltery.log.error("Error trying to save fluids inside smeltery! Invalid Liquid found! Smeltery contents:"); for(FluidStack liquid2 : liquids) { TinkerSmeltery.log.error(" " + liquid2.getUnlocalizedName() + "/" + liquid2.amount + "mb"); } continue; } NBTTagCompound fluidTag = new NBTTagCompound(); liquid.writeToNBT(fluidTag); taglist.appendTag(fluidTag); } tag.setTag("Liquids", taglist); tag.setInteger("LiquidCapacity", maxCapacity); }
@Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound = super.writeToNBT(compound); currentFuel.writeToNBT(fuelTag);
@Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound = super.writeToNBT(compound); if(drained != null) { drained.writeToNBT(compound); compound.setInteger("direction", direction.getIndex()); public SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound tag = new NBTTagCompound(); writeToNBT(tag); return new SPacketUpdateTileEntity(this.getPos(), this.getBlockMetadata(), tag); public NBTTagCompound getUpdateTag() { return writeToNBT(new NBTTagCompound());
public NBTTagCompound writeToNBT(@Nonnull NBTTagCompound nbt) { if(containsValidLiquid()) { fluid.writeToNBT(nbt); } else { nbt.setBoolean("emptyTank", true); } return nbt; }
public NBTTagCompound writeToNbt() { NBTTagCompound tag = new NBTTagCompound(); for (int i = 0; i < getSlots(); ++i) { FluidStack stack = getFluid(i); if (stack != null) { tag.setTag(String.format(NBT_SLOT, i), stack.writeToNBT(new NBTTagCompound())); } } return tag; }
static NBTTagList writeFluidStackList(IStackList<FluidStack> stacks) { NBTTagList list = new NBTTagList(); for (FluidStack stack : stacks.getStacks()) { list.appendTag(stack.writeToNBT(new NBTTagCompound())); } return list; }
/** * Add a tooltip that also displays an fluidStack on the tooltip directly. */ public void add(FluidStack fluidStack, String string) { NBTTagCompound nbt = new NBTTagCompound(); fluidStack.writeToNBT(nbt); nbt.setByte(NBT_TYPE_KEY, TYPE_FLUID); this.add(NBT_SEPARATOR + nbt.toString() + NBT_SEPARATOR + string); }
@Override public NBTTagCompound writeToNBT(final NBTTagCompound nbt2) { NBTTagCompound nbt = super.writeToNBT(nbt2); nbt.setByte("dlevel", (byte) this.level); NBTTagCompound fluidNbt = new NBTTagCompound(); if (this.currentFluid != null) { this.currentFluid.writeToNBT(fluidNbt); } nbt.setTag("fluid", fluidNbt); return nbt; }
private void updateFluidNBT(ItemStack parItemStack, FluidStack parFluidStack) { if (!parItemStack.hasTagCompound()) { parItemStack.setTagCompound(new NBTTagCompound()); } NBTTagCompound fluidTag = new NBTTagCompound(); parFluidStack.writeToNBT(fluidTag); parItemStack.getTagCompound().setTag(FluidHandlerItemStack.FLUID_NBT_KEY, fluidTag); // DEBUG System.out.println("Wrote fluid tag to container item stack = " + fluidTag); }
public void writeToNbt(@Nonnull NBTTagCompound root) { if (Prep.isValid(item)) { NBTTagCompound stackRoot = new NBTTagCompound(); item.writeToNBT(stackRoot); root.setTag("itemStack", stackRoot); } else if (fluid != null) { NBTTagCompound stackRoot = new NBTTagCompound(); fluid.writeToNBT(stackRoot); root.setTag("fluidStack", stackRoot); } root.setInteger("slotNum", slotNumber); }
public static void removeRefineryRecipe(FluidStack input) { if (input == null) { return; } NBTTagCompound toSend = new NBTTagCompound(); toSend.setTag(INPUT, new NBTTagCompound()); input.writeToNBT(toSend.getCompoundTag(INPUT)); FMLInterModComms.sendMessage(MOD_ID, REMOVE_REFINERY_RECIPE, toSend); } // endregion
public static ItemStack setDefaultFluidTag(ItemStack container, FluidStack resource) { container.setTagCompound(new NBTTagCompound()); NBTTagCompound fluidTag = resource.writeToNBT(new NBTTagCompound()); container.getTagCompound().setTag("Fluid", fluidTag); return container; }
@Override public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack heldStack) { ItemStack stack = new ItemStack(ModBlocks.blood_container, 1); FluidStack fluid = ((TileBloodContainer) te).getTankInfo().fluid; if (fluid != null && fluid.amount > 0) { stack.setTagInfo("fluid", fluid.writeToNBT(new NBTTagCompound())); } spawnAsEntity(worldIn, pos, stack); }
@Override public void writeToNBT(@Nonnull NBTTagCompound nbtRoot) { super.writeToNBT(nbtRoot); FluidStack ft = getFluidType(); if (ConduitUtil.isFluidValid(ft)) { updateTank(); ft = ft.copy(); ft.amount = tank.getFluidAmount(); nbtRoot.setTag("tank", ft.writeToNBT(new NBTTagCompound())); } nbtRoot.setBoolean("fluidLocked", fluidTypeLocked); }
public static void removeBrewerRecipe(ItemStack input, FluidStack fluid) { if (input.isEmpty() || fluid == null) { return; } NBTTagCompound toSend = new NBTTagCompound(); toSend.setTag(INPUT, new NBTTagCompound()); toSend.setTag(FLUID, new NBTTagCompound()); input.writeToNBT(toSend.getCompoundTag(INPUT)); fluid.writeToNBT(toSend.getCompoundTag(FLUID)); FMLInterModComms.sendMessage(MOD_ID, REMOVE_BREWER_RECIPE, toSend); } // endregion
public static void addCrucibleRecipe(int energy, ItemStack input, FluidStack output) { if (input.isEmpty() || output == null) { return; } NBTTagCompound toSend = new NBTTagCompound(); toSend.setInteger(ENERGY, energy); toSend.setTag(INPUT, new NBTTagCompound()); toSend.setTag(OUTPUT, new NBTTagCompound()); input.writeToNBT(toSend.getCompoundTag(INPUT)); output.writeToNBT(toSend.getCompoundTag(OUTPUT)); FMLInterModComms.sendMessage(MOD_ID, ADD_CRUCIBLE_RECIPE, toSend); }