java类net.minecraft.nbt.NBTPrimitive的实例源码

SpecialEventReceiver.java 文件源码 项目:Minecraft-Flux 阅读 17 收藏 0 点赞 0 评论 0
@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());
        }
    }
}
NbtConverter.java 文件源码 项目:wizards-of-lua 阅读 22 收藏 0 点赞 0 评论 0
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());
}
NbtConverter.java 文件源码 项目:wizards-of-lua 阅读 23 收藏 0 点赞 0 评论 0
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();
}
EntityUtils.java 文件源码 项目:metamorph 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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;
}
InventoryUtils.java 文件源码 项目:CodeChickenLib 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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());
        }
    }
}
ItemImaginary.java 文件源码 项目:OpenBlocks 阅读 18 收藏 0 点赞 0 评论 0
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);
}
NBTComparableFloat.java 文件源码 项目:ModularMachinery 阅读 15 收藏 0 点赞 0 评论 0
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagFloat && comparisonMode.testFloat(this.getFloat(), nbtPrimitive.getFloat());
}
NBTComparableShort.java 文件源码 项目:ModularMachinery 阅读 16 收藏 0 点赞 0 评论 0
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagShort && comparisonMode.testShort(this.getShort(), nbtPrimitive.getShort());
}
NBTComparableLong.java 文件源码 项目:ModularMachinery 阅读 15 收藏 0 点赞 0 评论 0
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagLong && comparisonMode.testLong(this.getLong(), nbtPrimitive.getLong());
}
NBTComparableDouble.java 文件源码 项目:ModularMachinery 阅读 16 收藏 0 点赞 0 评论 0
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagDouble && comparisonMode.testDouble(this.getDouble(), nbtPrimitive.getDouble());
}
NBTComparableByte.java 文件源码 项目:ModularMachinery 阅读 15 收藏 0 点赞 0 评论 0
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagByte && comparisonMode.testByte(this.getByte(), nbtPrimitive.getByte());
}
NBTComparableInteger.java 文件源码 项目:ModularMachinery 阅读 72 收藏 0 点赞 0 评论 0
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
    return nbtPrimitive instanceof NBTTagInt && comparisonMode.testInt(this.getInt(), nbtPrimitive.getInt());
}
MunnyCapability.java 文件源码 项目:Kingdom-Keys-Re-Coded 阅读 19 收藏 0 点赞 0 评论 0
@Override
public void readNBT(Capability<IMunny> capability, IMunny instance, EnumFacing side, NBTBase nbt) {
    instance.setMunny(((NBTPrimitive)nbt).getInt());

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


问题


面经


文章

微信
公众号

扫码关注公众号