@Override public void setDataFromItemStackTag(NBTTagCompound NBT) { if (NBT == null) { tank.empty(); return; } Fluid f = ReikaNBTHelper.getFluidFromNBT(NBT); int level = NBT.getInteger("lvl"); if (f != null && level > 0) tank.setContents(level, f); }
public ArrayList<NBTTagCompound> getCreativeModeVariants() { ArrayList<NBTTagCompound> li = new ArrayList(); for (int i = 0; i < creativeFluids.size(); i++) { NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("lvl", 1000000000); ReikaNBTHelper.writeFluidToNBT(nbt, creativeFluids.get(i)); li.add(nbt); } return li; }
@Override public NBTTagCompound getTagsToWriteToStack() { if (this.isEmpty()) return null; NBTTagCompound NBT = new NBTTagCompound(); Fluid f = this.getFluid(); int level = this.getLevel(); ReikaNBTHelper.writeFluidToNBT(NBT, f); NBT.setInteger("lvl", level); return NBT; }
public ArrayList<String> getDisplayTags(NBTTagCompound nbt) { ArrayList li = new ArrayList(); Fluid f = ReikaNBTHelper.getFluidFromNBT(nbt); if (f != null) { String fluid = f.getLocalizedName(); int amt = nbt.getInteger("lvl"); if (amt > 0) { String amount = String.format("%d", amt / 1000); String contents = "Contents: " + amount + "B of " + fluid; li.add(contents); } } return li; }