Saves on Data Size by choosing the smallest possible Data Type, and by also not adding zeros. The regular getLong() Function can also get the other Number Types.
(NBTTagCompound aNBT, Object aTag, long aValue)
| 1990 | |
| 1991 | /** Saves on Data Size by choosing the smallest possible Data Type, and by also not adding zeros. The regular getLong() Function can also get the other Number Types. */ |
| 1992 | public static NBTTagCompound setNumber(NBTTagCompound aNBT, Object aTag, long aValue) { |
| 1993 | if (aValue == 0) {aNBT.removeTag(aTag.toString()); return aNBT;} |
| 1994 | if (aValue > Integer.MAX_VALUE || aValue < Integer.MIN_VALUE) {aNBT.setLong(aTag.toString(), aValue); return aNBT;} |
| 1995 | if (aValue > Short.MAX_VALUE || aValue < Short.MIN_VALUE) {aNBT.setInteger(aTag.toString(), (int)aValue); return aNBT;} |
| 1996 | if (aValue > Byte.MAX_VALUE || aValue < Byte.MIN_VALUE) {aNBT.setShort(aTag.toString(), (short)aValue); return aNBT;} |
| 1997 | aNBT.setByte(aTag.toString(), (byte)aValue); |
| 1998 | return aNBT; |
| 1999 | } |
| 2000 | |
| 2001 | /** Saves on Data Size by choosing the smallest possible Data Type, and by also not adding zeros or negative Numbers. The regular getLong() Function can also get the other Number Types. */ |
| 2002 | public static NBTTagCompound setPosNum(NBTTagCompound aNBT, Object aTag, long aValue) { |
no test coverage detected