mirror of
https://github.com/GTNewHorizons/Postea.git
synced 2026-11-12 16:37:38 +00:00
25 lines
819 B
Java
25 lines
819 B
Java
package com.gtnewhorizons.postea.api;
|
|||
|
|
|
||
|
|
import static net.minecraftforge.common.util.Constants.NBT.TAG_INT;
|
||
|
|
import static net.minecraftforge.common.util.Constants.NBT.TAG_SHORT;
|
||
|
|
|
||
|
|
import net.minecraft.nbt.NBTTagCompound;
|
||
|
|
|
||
|
|
public class IDExtenderCompat {
|
||
|
|
|
||
|
|
public static int getItemStackID(NBTTagCompound tag) {
|
||
|
|
if (tag.hasKey("idExt", TAG_INT)) return tag.getInteger("idExt");
|
||
|
|
else if (tag.hasKey("id", TAG_INT)) return tag.getInteger("id");
|
||
|
|
else if (tag.hasKey("id", TAG_SHORT)) return tag.getShort("id");
|
||
|
|
else return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void setItemStackID(NBTTagCompound tag, int id) {
|
||
|
|
if (id < 32000) {
|
||
|
|
tag.setShort("id", (short) id);
|
||
|
|
} else {
|
||
|
|
tag.setShort("id", (short) 0);
|
||
|
|
tag.setInteger("idExt", id);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|