Java 类net.minecraft.nbt.NBTPrimitive 实例源码

项目:Minecraft-Flux    文件:SpecialEventReceiver.java   
@Override public void deserializeNBT(NBTBase nbt) {
    if (nbt == null)
        return;
    // NEW NBT DESERIALIZING
    if (nbt instanceof NBTTagIntArray) {
        int[] ia = ((NBTTagIntArray) nbt).getIntArray();
        for (int i : ia)
            received.add(i);
    }
    // OLD NBT DESERIALIZING
    else if (nbt instanceof NBTTagList) {
        NBTTagList nbtl = (NBTTagList) nbt;
        for (int i = 0; i < nbtl.tagCount(); i++) {
            NBTBase nb = nbtl.get(i);
            if (nb instanceof NBTPrimitive)
                received.add(((NBTPrimitive) nb).getInt());
        }
    }
}
项目:wizards-of-lua    文件:NbtConverter.java   
public static Object toLua(NBTBase nbt) {
  checkNotNull(nbt, "nbt == null!");
  if (nbt instanceof NBTPrimitive)
    return toLua((NBTPrimitive) nbt);
  if (nbt instanceof NBTTagString)
    return toLua((NBTTagString) nbt);
  if (nbt instanceof NBTTagList)
    return toLua((NBTTagList) nbt);
  if (nbt instanceof NBTTagCompound)
    return toLua((NBTTagCompound) nbt);
  throw new IllegalArgumentException(
      "Unsupported NBT type for conversion: " + nbt.getClass().getName());
}
项目:wizards-of-lua    文件:NbtConverter.java   
public static Number toLua(NBTPrimitive nbt) {
  checkNotNull(nbt, "nbt == null!");
  if (nbt instanceof NBTTagDouble)
    return ((NBTTagDouble) nbt).getDouble();
  if (nbt instanceof NBTTagFloat)
    return ((NBTTagFloat) nbt).getDouble();
  return nbt.getLong();
}
项目:metamorph    文件:EntityUtils.java   
/**
 * Compare two {@link NBTTagCompound}s for morphing acquiring
 */
public static boolean compareData(NBTTagCompound a, NBTTagCompound b)
{
    /* Different count of tags? They're different */
    if (a.getSize() != b.getSize())
    {
        return false;
    }

    for (String key : a.getKeySet())
    {
        NBTBase aTag = a.getTag(key);
        NBTBase bTag = b.getTag(key);

        /* Supporting condition for size check above, in case if the size 
         * the same, but different keys are missing */
        if (bTag == null)
        {
            return false;
        }

        /* We check only strings and primitives, lists and compounds aren't 
         * concern of mine */
        if (!(aTag instanceof NBTPrimitive) && !(aTag instanceof NBTTagString))
        {
            continue;
        }

        if (!aTag.equals(bTag))
        {
            return false;
        }
    }

    return true;
}
项目:CodeChickenLib    文件:InventoryUtils.java   
/**
 * NBT item loading function with support for stack sizes > 32K
 */
public static void readItemStacksFromTag(ItemStack[] items, NBTTagList tagList) {
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound tag = tagList.getCompoundTagAt(i);
        int b = tag.getShort("Slot");
        items[b] = new ItemStack(tag);
        if (tag.hasKey("Quantity")) {
            items[b].setCount(((NBTPrimitive) tag.getTag("Quantity")).getInt());
        }
    }
}
项目:OpenBlocks    文件:ItemImaginary.java   
public static float getUses(NBTTagCompound tag) {
    NBTBase value = tag.getTag(TAG_USES);
    if (value == null) return 0;
    if (value instanceof NBTPrimitive) return ((NBTPrimitive)value).getFloat();

    throw new IllegalStateException("Invalid tag type: " + value);
}
项目:ModularMachinery    文件:NBTComparableFloat.java   
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagFloat && comparisonMode.testFloat(this.getFloat(), nbtPrimitive.getFloat());
}
项目:ModularMachinery    文件:NBTComparableShort.java   
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagShort && comparisonMode.testShort(this.getShort(), nbtPrimitive.getShort());
}
项目:ModularMachinery    文件:NBTComparableLong.java   
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagLong && comparisonMode.testLong(this.getLong(), nbtPrimitive.getLong());
}
项目:ModularMachinery    文件:NBTComparableDouble.java   
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagDouble && comparisonMode.testDouble(this.getDouble(), nbtPrimitive.getDouble());
}
项目:ModularMachinery    文件:NBTComparableByte.java   
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagByte && comparisonMode.testByte(this.getByte(), nbtPrimitive.getByte());
}
项目:ModularMachinery    文件:NBTComparableInteger.java   
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagInt && comparisonMode.testInt(this.getInt(), nbtPrimitive.getInt());
}
项目:Kingdom-Keys-Re-Coded    文件:MunnyCapability.java   
@Override
public void readNBT(Capability<IMunny> capability, IMunny instance, EnumFacing side, NBTBase nbt) {
    instance.setMunny(((NBTPrimitive)nbt).getInt());

}
项目:Kingdom-Keys-Re-Coded    文件:CheatModeCapability.java   
@Override
public void readNBT(Capability<ICheatMode> capability, ICheatMode instance, EnumFacing side, NBTBase nbt) {
    instance.setCheatMode(((NBTPrimitive)nbt).getInt() == 1);
}
项目:IvToolkit    文件:NBTStateInjector.java   
private static boolean hasPrimitive(NBTTagCompound compound, String key)
{
    return compound.hasKey(key) && compound.getTag(key) instanceof NBTPrimitive;
}
项目:ModularMachinery    文件:NBTComparableNumber.java   
public boolean test(NBTPrimitive numberTag);