本文整理汇总了Java中net.minecraft.nbt.NBTPrimitive类的典型用法代码示例。如果您正苦于以下问题:Java NBTPrimitive类的具体用法?Java NBTPrimitive怎么用?Java NBTPrimitive使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NBTPrimitive类属于net.minecraft.nbt包,在下文中一共展示了NBTPrimitive类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserializeNBT
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
@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());
}
}
}
示例2: toLua
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
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());
}
示例3: compareData
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
/**
* 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;
}
示例4: readItemStacksFromTag
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
/**
* 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());
}
}
}
示例5: getUses
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
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);
}
示例6: test
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
return nbtPrimitive instanceof NBTTagFloat && comparisonMode.testFloat(this.getFloat(), nbtPrimitive.getFloat());
}
示例7: test
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
return nbtPrimitive instanceof NBTTagShort && comparisonMode.testShort(this.getShort(), nbtPrimitive.getShort());
}
示例8: test
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
return nbtPrimitive instanceof NBTTagLong && comparisonMode.testLong(this.getLong(), nbtPrimitive.getLong());
}
示例9: test
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
return nbtPrimitive instanceof NBTTagDouble && comparisonMode.testDouble(this.getDouble(), nbtPrimitive.getDouble());
}
示例10: test
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
return nbtPrimitive instanceof NBTTagByte && comparisonMode.testByte(this.getByte(), nbtPrimitive.getByte());
}
示例11: test
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
@Override
public boolean test(NBTPrimitive nbtPrimitive) {
return nbtPrimitive instanceof NBTTagInt && comparisonMode.testInt(this.getInt(), nbtPrimitive.getInt());
}
示例12: readNBT
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
@Override
public void readNBT(Capability<IMunny> capability, IMunny instance, EnumFacing side, NBTBase nbt) {
instance.setMunny(((NBTPrimitive)nbt).getInt());
}
示例13: readNBT
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
@Override
public void readNBT(Capability<ICheatMode> capability, ICheatMode instance, EnumFacing side, NBTBase nbt) {
instance.setCheatMode(((NBTPrimitive)nbt).getInt() == 1);
}
示例14: hasPrimitive
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
private static boolean hasPrimitive(NBTTagCompound compound, String key)
{
return compound.hasKey(key) && compound.getTag(key) instanceof NBTPrimitive;
}
示例15: test
import net.minecraft.nbt.NBTPrimitive; //导入依赖的package包/类
public boolean test(NBTPrimitive numberTag);