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

TileEntityEnderThermicLavaPump.java 文件源码 项目:ExtraUtilities 阅读 17 收藏 0 点赞 0 评论 0
public void readFromNBT(final NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);
    if (par1NBTTagCompound.hasKey("block_no") && par1NBTTagCompound.getTag("block_no") instanceof NBTTagInt) {
        this.b = par1NBTTagCompound.getInteger("block_no");
    }
    else {
        LogHelper.info("Extra Utilities: Problem loading EnderPump TileEntity Tag (block_no)", new Object[0]);
    }
    if (par1NBTTagCompound.hasKey("chunk_no") && par1NBTTagCompound.getTag("chunk_no") instanceof NBTTagByte) {
        this.chunk_no = par1NBTTagCompound.getByte("chunk_no");
    }
    else {
        LogHelper.info("Extra Utilities: Problem loading EnderPump TileEntity Tag (chunk_no)", new Object[0]);
    }
    if (this.chunk_no == -128) {
        this.finished = true;
    }
    else {
        this.setChunk(this.chunk_no);
    }
    this.tank.readFromNBT(par1NBTTagCompound.getCompoundTag("tank"));
    this.init = true;
}
NBTHelper.java 文件源码 项目:TaleCraft 阅读 23 收藏 0 点赞 0 评论 0
private static void asJson(NBTBase tag, StringBuilder builder) {
    switch(tag.getId()) {
    case NBT.TAG_BYTE: builder.append(((NBTTagByte)tag).getByte()).append('b'); break;
    case NBT.TAG_SHORT: builder.append(((NBTTagShort)tag).getByte()).append('b'); break;
    case NBT.TAG_INT: builder.append(((NBTTagInt)tag).getInt()); break;
    case NBT.TAG_LONG: builder.append(((NBTTagLong)tag).getByte()).append('l'); break;
    case NBT.TAG_FLOAT: builder.append(((NBTTagFloat)tag).getFloat()).append('f'); break;
    case NBT.TAG_DOUBLE: builder.append(((NBTTagDouble)tag).getDouble()).append('d'); break;
    case NBT.TAG_STRING: builder.append('"').append(((NBTTagString)tag).getString()).append('"'); break;
    case NBT.TAG_BYTE_ARRAY: builder.append(Arrays.toString(((NBTTagByteArray)tag).getByteArray())); break;
    case NBT.TAG_INT_ARRAY: builder.append(Arrays.toString(((NBTTagIntArray)tag).getIntArray())); break;
    case NBT.TAG_COMPOUND: asJson((NBTTagCompound) tag, builder); break;
    case NBT.TAG_LIST: asJson((NBTTagList) tag, builder); break;
    }

}
SampleItem.java 文件源码 项目:BiomeWand 阅读 14 收藏 0 点赞 0 评论 0
@Override
  @SideOnly(Side.CLIENT)
  public int getColorFromItemStack(ItemStack stack, int pass)
  {
NBTTagCompound tag = stack.getTagCompound();
int biomeId = -1;
if ( tag != null )
{
    NBTTagByte biome = ( NBTTagByte ) tag.getTag( SAMPLED_BIOME_TAG );
    if ( biome != null )
    {
        biomeId = biome.getByte() & 255;
    }
}

if ( pass == 1 )
{
    return biomeId >= 0 ? BiomeGenBase.getBiomeGenArray()[ biomeId ].color : 0;
}

      return 0xFFFFFFFF;
  }
WandItem.java 文件源码 项目:BiomeWand 阅读 14 收藏 0 点赞 0 评论 0
@Override
  @SideOnly(Side.CLIENT)
  public int getColorFromItemStack(ItemStack stack, int pass)
  {
NBTTagCompound tag = stack.getTagCompound();
int biomeId = -1;
if ( tag != null )
{
    NBTTagByte biome = ( NBTTagByte ) tag.getTag( SAMPLED_BIOME_TAG );
    if ( biome != null )
    {
        biomeId = biome.getByte() & 255;
    }
}

if ( pass == 1 )
{
    return biomeId >= 0 ? BiomeGenBase.getBiomeGenArray()[ biomeId ].color : 0;
}

      return 0xFFFFFFFF;
  }
NbtUtils.java 文件源码 项目:copycore 阅读 23 收藏 0 点赞 0 评论 0
/** Creates and returns a primitive NBT tag from a value.
 *  If the value already is an NBT tag, it is returned instead. */
public static NBTBase createTag(Object value) {
    if (value == null)
        throw new IllegalArgumentException("value is null");
    if (value instanceof NBTBase) return (NBTBase)value;
    if (value instanceof Byte)    return new NBTTagByte((Byte)value);
    if (value instanceof Short)   return new NBTTagShort((Short)value);
    if (value instanceof Integer) return new NBTTagInt((Integer)value);
    if (value instanceof Long)    return new NBTTagLong((Long)value);
    if (value instanceof Float)   return new NBTTagFloat((Float)value);
    if (value instanceof Double)  return new NBTTagDouble((Double)value);
    if (value instanceof String)  return new NBTTagString((String)value);
    if (value instanceof byte[])  return new NBTTagByteArray((byte[])value);
    if (value instanceof int[])   return new NBTTagIntArray((int[])value);
    throw new IllegalArgumentException("Can't create an NBT tag of value: " + value);
}
ConvertNBTTagCompound.java 文件源码 项目:CraftingManager 阅读 17 收藏 0 点赞 0 评论 0
public static Object getObject(NBTBase base)
{
    if(base instanceof NBTTagByte)
        return ((NBTTagByte)base).func_150290_f();
    if(base instanceof NBTTagShort)
        return ((NBTTagShort)base).func_150289_e();
    if(base instanceof NBTTagInt)
        return ((NBTTagInt)base).func_150287_d();
    if(base instanceof NBTTagLong)
        return ((NBTTagLong)base).func_150291_c();
    if(base instanceof NBTTagFloat)
        return ((NBTTagFloat)base).func_150288_h();
    if(base instanceof NBTTagDouble)
        return ((NBTTagDouble)base).func_150286_g();
    if(base instanceof NBTTagByteArray)
        return ((NBTTagByteArray)base).func_150292_c();
    if(base instanceof NBTTagString)
        return ((NBTTagString)base).func_150285_a_();
    if(base instanceof NBTTagList)
        return base;
    if(base instanceof NBTTagCompound)
        return ((NBTTagCompound)base);
    if(base instanceof NBTTagIntArray)
        return ((NBTTagIntArray)base).func_150302_c();
    return null;
}
GuiEditNBT.java 文件源码 项目:NBTEdit 阅读 25 收藏 0 点赞 0 评论 0
private static void setValidValue(Node<NamedNBT> node, String value){
    NamedNBT named = node.getObject();
    NBTBase base = named.getNBT();

    if (base instanceof NBTTagByte)
        named.setNBT(new NBTTagByte(ParseHelper.parseByte(value)));
    if (base instanceof NBTTagShort)
        named.setNBT(new NBTTagShort(ParseHelper.parseShort(value)));
    if (base instanceof NBTTagInt)
        named.setNBT(new NBTTagInt(ParseHelper.parseInt(value)));
    if (base instanceof NBTTagLong)
        named.setNBT(new NBTTagLong(ParseHelper.parseLong(value)));
    if(base instanceof NBTTagFloat)
        named.setNBT(new NBTTagFloat(ParseHelper.parseFloat(value)));
    if(base instanceof NBTTagDouble)
        named.setNBT(new NBTTagDouble(ParseHelper.parseDouble(value)));
    if(base instanceof NBTTagByteArray)
        named.setNBT(new NBTTagByteArray(ParseHelper.parseByteArray(value)));
    if(base instanceof NBTTagIntArray)
        named.setNBT(new NBTTagIntArray(ParseHelper.parseIntArray(value)));
    if (base instanceof NBTTagString)
        named.setNBT(new NBTTagString(value));
}
RecipeLanolinFactory.java 文件源码 项目:Lanolin 阅读 22 收藏 0 点赞 0 评论 0
@Override
@Nonnull
public ItemStack getCraftingResult(InventoryCrafting inv) {
    int lanolinCount = 0;
    ItemStack craftStack = null;
    for(int i = 0; i < inv.getSizeInventory(); i++){
        ItemStack tempStack = inv.getStackInSlot(i);
        if(tempStack.getItem().getRegistryName().equals(ModItems.itemLanolin.getRegistryName()))
            lanolinCount++;
        else if(ItemLanolin.canCraftWith(tempStack) && craftStack == null) {
            craftStack = tempStack.copy();
        }
        else if(tempStack != ItemStack.EMPTY)
            return ItemStack.EMPTY;
    }
    if (craftStack == ItemStack.EMPTY || !ItemLanolin.canCraftWith(craftStack)) {
        return ItemStack.EMPTY;
    }
    // Copy Existing NBT
    if(craftStack.hasTagCompound()) {
        if(craftStack.getTagCompound().hasKey("lanolin")){
            // Increase existing lanolin count
            lanolinCount += craftStack.getTagCompound().getInteger("lanolin");
        }
    }
    if(craftStack.getItem() instanceof ItemArmor)
        craftStack.setTagInfo("lanolin", new NBTTagByte((byte) clamp(lanolinCount,0, Config.MAX_LANOLIN_ARMOR)));
    else if(craftStack.getItem() instanceof ItemTool)
        craftStack.setTagInfo("lanolin", new NBTTagByte((byte) clamp(lanolinCount,0, Config.MAX_LANOLIN_TOOLS)));
    else // Unconfigured item, that passed
        craftStack.setTagInfo("lanolin", new NBTTagByte((byte) clamp(lanolinCount,0, 15)));
    return craftStack;
}
Util.java 文件源码 项目:chesttransporter 阅读 21 收藏 0 点赞 0 评论 0
public static NonNullList<Pair<Integer, ItemStack>> readItemsFromNBT(NBTTagCompound tagCompound)
{
    NonNullList<Pair<Integer, ItemStack>> items = NonNullList.create();

    NBTTagList nbtList = tagCompound.getTagList("Items", 10);

    for (int i = 0; i < nbtList.tagCount(); ++i)
    {
        NBTTagCompound nbtTagCompound = nbtList.getCompoundTagAt(i);
        NBTBase nbt = nbtTagCompound.getTag("Slot");
        int j;
        if (nbt instanceof NBTTagByte)
        {
            j = nbtTagCompound.getByte("Slot") & 255;
        } else
        {
            j = nbtTagCompound.getShort("Slot");
        }

        if (j >= 0)
        {
            ItemStack itemstack = new ItemStack(nbtTagCompound);
            items.add(Pair.of(j, itemstack));
        }
    }

    return items;
}
TileEntityPotStill.java 文件源码 项目:Thermionics 阅读 21 收藏 0 点赞 0 评论 0
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagIn) {
    NBTTagCompound tagOut = super.writeToNBT(tagIn);
    tagOut.setTag("inputtank", CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.writeNBT(inputTank, null));
    tagOut.setTag("outputtank", CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.writeNBT(outputTank, null));
    tagOut.setTag("heatstorage", Thermionics.CAPABILITY_HEATSTORAGE.writeNBT(heat, null));
    tagOut.setTag("inventory", CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.writeNBT(itemStorage, null));

    tagOut.setTag("locked", new NBTTagByte((byte) (tanksLocked ? 1 : 0)));

    return tagOut;
}
WidgetTextData.java 文件源码 项目:ExtraUtilities 阅读 22 收藏 0 点赞 0 评论 0
public static Object getNBTBaseData(final NBTBase nbt) {
    if (nbt == null) {
        return null;
    }
    switch (nbt.getId()) {
        case 1: {
            return ((NBTTagByte)nbt).func_150290_f();
        }
        case 2: {
            return ((NBTTagShort)nbt).func_150289_e();
        }
        case 3: {
            return ((NBTTagInt)nbt).func_150287_d();
        }
        case 4: {
            return ((NBTTagLong)nbt).func_150291_c();
        }
        case 5: {
            return ((NBTTagFloat)nbt).func_150288_h();
        }
        case 6: {
            return ((NBTTagDouble)nbt).func_150286_g();
        }
        case 8: {
            return ((NBTTagString)nbt).func_150285_a_();
        }
        case 10: {
            return nbt;
        }
        default: {
            return null;
        }
    }
}
WidgetTextData.java 文件源码 项目:ExtraUtilities 阅读 21 收藏 0 点赞 0 评论 0
public static NBTBase getNBTBase(final Object o) {
    if (o instanceof Integer) {
        return (NBTBase)new NBTTagInt((Integer)o);
    }
    if (o instanceof Short) {
        return (NBTBase)new NBTTagShort((Short)o);
    }
    if (o instanceof Long) {
        return (NBTBase)new NBTTagLong((Long)o);
    }
    if (o instanceof String) {
        return (NBTBase)new NBTTagString((String)o);
    }
    if (o instanceof Double) {
        return (NBTBase)new NBTTagDouble((Double)o);
    }
    if (o instanceof Float) {
        return (NBTBase)new NBTTagFloat((Float)o);
    }
    if (o instanceof NBTTagCompound) {
        return (NBTBase)o;
    }
    if (o instanceof Byte) {
        return (NBTBase)new NBTTagByte((Byte)o);
    }
    LogHelper.debug("Can't find type for " + o, new Object[0]);
    throw null;
}
MappingRegistry.java 文件源码 项目:4Space-5 阅读 15 收藏 0 点赞 0 评论 0
private boolean isStackLayout(NBTTagCompound nbt) {
    return nbt.hasKey("id") &&
            nbt.hasKey("Count") &&
            nbt.hasKey("Damage") &&
            nbt.getTag("id") instanceof NBTTagShort &&
            nbt.getTag("Count") instanceof NBTTagByte &&
            nbt.getTag("Damage") instanceof NBTTagShort;
}
NbtConverter.java 文件源码 项目:wizards-of-lua 阅读 21 收藏 0 点赞 0 评论 0
private Map<Class<? extends NBTBase>, NbtMerger<? extends NBTBase>> getMergers() {
  if (mergers == null) {
    mergers = new HashMap<>();
    registerMerger(NBTTagByte.class, new NbtByteMerger(this));
    registerMerger(NBTTagCompound.class, new NbtCompoundMerger(this));
    registerMerger(NBTTagDouble.class, new NbtDoubleMerger(this));
    registerMerger(NBTTagFloat.class, new NbtFloatMerger(this));
    registerMerger(NBTTagInt.class, new NbtIntMerger(this));
    registerMerger(NBTTagList.class, new NbtListMerger(this));
    registerMerger(NBTTagLong.class, new NbtLongMerger(this));
    registerMerger(NBTTagShort.class, new NbtShortMerger(this));
    registerMerger(NBTTagString.class, new NbtStringMerger(this));
  }
  return mergers;
}
NbtByteMerger.java 文件源码 项目:wizards-of-lua 阅读 32 收藏 0 点赞 0 评论 0
@Override
public NBTTagByte merge(NBTTagByte nbt, Object data, String key, String path) {
  if (data instanceof Boolean) {
    return NbtConverter.toNbt((Boolean) data);
  }
  if (data instanceof Number) {
    return NbtConverter.toNbt(((Number) data).byteValue());
  }
  throw converter.conversionException(path, data, "boolean/number");
}
NBTSettingsManager.java 文件源码 项目:morecommands 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Converts a {@link JsonElement} into an {@link NBTBase}
 * 
 * @param element the {@link JsonElement} to convert
 * @return the converted {@link NBTBase}
 */
public static NBTBase toNBTElement(JsonElement element) {
    if (element.isJsonArray()) {
        NBTTagList list = new NBTTagList();
        for (JsonElement elem : element.getAsJsonArray()) list.appendTag(toNBTElement(elem));
        return list;
    }
    else if (element.isJsonObject()) {
        NBTTagCompound compound = new NBTTagCompound();
        for (Map.Entry<String, JsonElement> entry : element.getAsJsonObject().entrySet()) compound.setTag(entry.getKey(), toNBTElement(entry.getValue()));
        return compound;
    }
    else if (element.isJsonPrimitive() && element.getAsJsonPrimitive().isNumber()) {
        Number num = element.getAsJsonPrimitive().getAsNumber();

        if (num instanceof Byte) return new NBTTagByte(num.byteValue());
        else if (num instanceof Short) return new NBTTagShort(num.shortValue());
        else if (num instanceof Integer) return new NBTTagInt(num.intValue());
        else if (num instanceof Long) return new NBTTagLong(num.longValue());
        else if (num instanceof Float) return new NBTTagFloat(num.floatValue());
        else if (num instanceof Double) return new NBTTagDouble(num.doubleValue());
        else return new NBTTagDouble(num.doubleValue());
    }
    else if (element.isJsonPrimitive() && element.getAsJsonPrimitive().isString()) 
        return new NBTTagString(element.getAsJsonPrimitive().getAsString());
    else return null;
}
RFDrills.java 文件源码 项目:RFDrills 阅读 14 收藏 0 点赞 0 评论 0
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    isTELoaded = Loader.isModLoaded("ThermalExpansion");
    isEIOLoaded = Loader.isModLoaded("EnderIO");
    isRArsLoaded = Loader.isModLoaded("RedstoneArsenal");
    isRArmLoaded = Loader.isModLoaded("RArm");
    isSJLoaded = Loader.isModLoaded("simplyjetpacks");
    isXULoaded = Loader.isModLoaded("ExtraUtilities");
    isWailaLoaded = Loader.isModLoaded("Waila");

    FMLCommonHandler.instance().bus().register(new ConfigHandler(event.getSuggestedConfigurationFile()));

    if((ConfigHandler.integrateTE && isTELoaded) || (ConfigHandler.integrateEIO && isEIOLoaded)) {
        RFDrillsTab = new CreativeTabs(Reference.MOD_ID) {
            @Override
            public ItemStack getIconItemStack() {
                ItemStack itemStack = new ItemStack(getTabIconItem());
                itemStack.setTagInfo("isCreativeTabIcon", new NBTTagByte((byte) 1));
                return itemStack;
            }

            @Override
            public Item getTabIconItem() {
                if (ConfigHandler.integrateTE)
                    return ModItems.redstoneDrill;
                else
                    return ModItems.basicDrill;
            }
        };
    }

    ModItems.init();
    proxy.preInit();
}
DataConverter.java 文件源码 项目:NOVA-Core 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Reads an unknown object withPriority a known name from NBT
 * @param tag - tag to read the value from
 * @param key - name of the value
 * @return object or suggestionValue if nothing is found
 */
public Object load(NBTTagCompound tag, String key) {
    if (tag != null && key != null) {
        NBTBase saveTag = tag.getTag(key);

        if (saveTag instanceof NBTTagFloat) {
            return tag.getFloat(key);
        } else if (saveTag instanceof NBTTagDouble) {
            return tag.getDouble(key);
        } else if (saveTag instanceof NBTTagInt) {
            return tag.getInteger(key);
        } else if (saveTag instanceof NBTTagString) {
            if (tag.getBoolean(key + "::nova.isBigInteger")) {
                return new BigInteger(tag.getString(key));
            } else if (tag.getBoolean(key + "::nova.isBigDecimal")) {
                return new BigDecimal(tag.getString(key));
            } else {
                return tag.getString(key);
            }
        } else if (saveTag instanceof NBTTagShort) {
            return tag.getShort(key);
        } else if (saveTag instanceof NBTTagByte) {
            if (tag.getBoolean(key + "::nova.isBoolean")) {
                return tag.getBoolean(key);
            } else {
                return tag.getByte(key);
            }
        } else if (saveTag instanceof NBTTagLong) {
            return tag.getLong(key);
        } else if (saveTag instanceof NBTTagByteArray) {
            return tag.getByteArray(key);
        } else if (saveTag instanceof NBTTagIntArray) {
            return tag.getIntArray(key);
        } else if (saveTag instanceof NBTTagCompound) {
            NBTTagCompound innerTag = tag.getCompoundTag(key);
            return toNova(innerTag);
        }
    }
    return null;
}
DataConverter.java 文件源码 项目:NOVA-Core 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Reads an unknown object withPriority a known name from NBT
 * @param tag - tag to read the value from
 * @param key - name of the value
 * @return object or suggestionValue if nothing is found
 */
public Object load(NBTTagCompound tag, String key) {
    if (tag != null && key != null) {
        NBTBase saveTag = tag.getTag(key);

        if (saveTag instanceof NBTTagFloat) {
            return tag.getFloat(key);
        } else if (saveTag instanceof NBTTagDouble) {
            return tag.getDouble(key);
        } else if (saveTag instanceof NBTTagInt) {
            return tag.getInteger(key);
        } else if (saveTag instanceof NBTTagString) {
            if (tag.getBoolean(key + "::nova.isBigInteger")) {
                return new BigInteger(tag.getString(key));
            } else if (tag.getBoolean(key + "::nova.isBigDecimal")) {
                return new BigDecimal(tag.getString(key));
            } else {
                return tag.getString(key);
            }
        } else if (saveTag instanceof NBTTagShort) {
            return tag.getShort(key);
        } else if (saveTag instanceof NBTTagByte) {
            if (tag.getBoolean(key + "::nova.isBoolean")) {
                return tag.getBoolean(key);
            } else {
                return tag.getByte(key);
            }
        } else if (saveTag instanceof NBTTagLong) {
            return tag.getLong(key);
        } else if (saveTag instanceof NBTTagByteArray) {
            return tag.getByteArray(key);
        } else if (saveTag instanceof NBTTagIntArray) {
            return tag.getIntArray(key);
        } else if (saveTag instanceof NBTTagCompound) {
            NBTTagCompound innerTag = tag.getCompoundTag(key);
            return toNova(innerTag);
        }
    }
    return null;
}
MappingRegistry.java 文件源码 项目:Connected 阅读 16 收藏 0 点赞 0 评论 0
private boolean isStackLayout(NBTTagCompound nbt) {
    return nbt.hasKey("id") &&
            nbt.hasKey("Count") &&
            nbt.hasKey("Damage") &&
            nbt.getTag("id") instanceof NBTTagShort &&
            nbt.getTag("Count") instanceof NBTTagByte &&
            nbt.getTag("Damage") instanceof NBTTagShort;
}
GolemUpgrade.java 文件源码 项目:Gadomancy 阅读 13 收藏 0 点赞 0 评论 0
protected void addUpgrade(NBTTagCompound compound) {
    NBTTagCompound upgrades = compound.getCompoundTag(UPGRADE_COMPOUND);
    if(!compound.hasKey(UPGRADE_COMPOUND)) {
        compound.setTag(UPGRADE_COMPOUND, upgrades);
    }

    NBTBase data = createUpgradeData();
    upgrades.setTag(getTagName(), data == null ? new NBTTagByte((byte)1) : data);
}
MappingRegistry.java 文件源码 项目:Framez 阅读 17 收藏 0 点赞 0 评论 0
private boolean isStackLayout(NBTTagCompound nbt) {
    return nbt.hasKey("id") &&
            nbt.hasKey("Count") &&
            nbt.hasKey("Damage") &&
            nbt.getTag("id") instanceof NBTTagShort &&
            nbt.getTag("Count") instanceof NBTTagByte &&
            nbt.getTag("Damage") instanceof NBTTagShort;
}
EntityPropertyPrimitive.java 文件源码 项目:copycore 阅读 14 收藏 0 点赞 0 评论 0
@Override
public NBTBase write() {
    T value = get();
    if (value instanceof Boolean)
        return new NBTTagByte((Boolean)value ? (byte)1 : (byte)0);
    else return NbtUtils.createTag(get());
}
NbtUtils.java 文件源码 项目:copycore 阅读 22 收藏 0 点赞 0 评论 0
/** Returns the primitive value of a tag, casted to the return type. */
public static <T> T getTagValue(NBTBase tag) {
    if (tag == null)
        throw new IllegalArgumentException("tag is null");
    if (tag instanceof NBTTagByte)      return (T)(Object)((NBTTagByte)tag).func_150290_f();
    if (tag instanceof NBTTagShort)     return (T)(Object)((NBTTagShort)tag).func_150289_e();
    if (tag instanceof NBTTagInt)       return (T)(Object)((NBTTagInt)tag).func_150287_d();
    if (tag instanceof NBTTagLong)      return (T)(Object)((NBTTagLong)tag).func_150291_c();
    if (tag instanceof NBTTagFloat)     return (T)(Object)((NBTTagFloat)tag).func_150288_h();
    if (tag instanceof NBTTagDouble)    return (T)(Object)((NBTTagDouble)tag).func_150286_g();
    if (tag instanceof NBTTagString)    return (T)((NBTTagString)tag).func_150285_a_();
    if (tag instanceof NBTTagByteArray) return (T)((NBTTagByteArray)tag).func_150292_c();
    if (tag instanceof NBTTagIntArray)  return (T)((NBTTagIntArray)tag).func_150302_c();
    throw new IllegalArgumentException(NBTBase.NBTTypes[tag.getId()] + " isn't a primitive NBT tag");
}
VisCraftingHelper.java 文件源码 项目:ThaumicEnergistics 阅读 14 收藏 0 点赞 0 评论 0
/**
 * Gets an itemstack representing a fully charged silverwood and thaumium
 * crafting scepter.
 *
 * @return
 */
public ItemStack getCraftingScepter()
{
    if( this.craftingScepter == null )
    {
        // Create the item
        this.craftingScepter = new ItemStack( ConfigItems.itemWandCasting, 1, 32767 );

        // Set rod type to thaumium
        ( (ItemWandCasting)this.craftingScepter.getItem() ).setCap( this.craftingScepter, ConfigItems.WAND_CAP_THAUMIUM );

        // Set cap type to silverwood
        ( (ItemWandCasting)this.craftingScepter.getItem() ).setRod( this.craftingScepter, ConfigItems.WAND_ROD_SILVERWOOD );

        // Set that it is a scepter
        this.craftingScepter.setTagInfo( "sceptre", new NBTTagByte( (byte)1 ) );

        // Max out vis storage
        for( Aspect aspect : Aspect.getPrimalAspects() )
        {
            ( (ItemWandCasting)this.craftingScepter.getItem() ).addVis( this.craftingScepter, aspect,
                ( (ItemWandCasting)this.craftingScepter.getItem() ).getMaxVis( this.craftingScepter ), true );
        }
    }

    return this.craftingScepter;
}
NBTWriter.java 文件源码 项目:projectzulu1.7.10-pre-1.3a 阅读 18 收藏 0 点赞 0 评论 0
private static NBTBase createChildTag(byte childtag, String... values) {
    switch (childtag) {
    /* Container Tags */
    case 9:
        return new NBTTagList();
    case 10:
        return new NBTTagCompound();
        /* Value Tags: operations[2] should contain value */
    case 1:
        return new NBTTagByte(Byte.parseByte(values[0].trim()));
    case 2:
        return new NBTTagShort(Short.parseShort(values[0].trim()));
    case 3:
        return new NBTTagInt(Integer.parseInt(values[0].trim()));
    case 4:
        return new NBTTagLong(Long.parseLong(values[0].trim()));
    case 5:
        return new NBTTagFloat(Float.parseFloat(values[0].trim()));
    case 6:
        return new NBTTagDouble(Double.parseDouble(values[0].trim()));
    case 7:
        byte[] byteArray = new byte[values.length];
        for (int i = 2; i < values.length; i++) {
            byteArray[i - 2] = (byte) ParsingHelper.parseFilteredInteger(values[i], 0, "ByteArray");
        }
        return new NBTTagByteArray(byteArray);
    case 8:
        return new NBTTagString("");
    case 11:
        int[] intArray = new int[values.length - 2];
        for (int i = 2; i < values.length; i++) {
            intArray[i - 2] = (int) ParsingHelper.parseFilteredInteger(values[i], 0, "ByteArray");
        }
        return new NBTTagIntArray(intArray);
    default:
        ProjectZuluLog.severe("Unrecognised childtag tagId %s", childtag);
        throw new IllegalArgumentException();
    }
}
TileEntityQuarryFrame.java 文件源码 项目:AdvancedUtilities 阅读 13 收藏 0 点赞 0 评论 0
@Override
public void updateEntity()
{
    if(!hasChecked && !worldObj.isRemote)
    {
            if(worldObj.getWorldInfo().getAdditionalProperty("AdvancedUtilities:WorldLoaded")!= null && ((NBTTagByte) worldObj.getWorldInfo().getAdditionalProperty("AdvancedUtilities:WorldLoaded")).func_150290_f() == (byte) 1)
            {
                this.onBlocksUpdated();
                worldObj.getBlock(xCoord, yCoord, zCoord).onNeighborBlockChange(worldObj, xCoord, yCoord, zCoord, getBlockType());
                hasChecked = true;
            }
    }

}
NBTStringHelper.java 文件源码 项目:NBTEdit 阅读 19 收藏 0 点赞 0 评论 0
public static NBTBase newTag(byte type){
    switch (type)
    {
    case 0:
        return new NBTTagEnd();
    case 1:
        return new NBTTagByte((byte) 0);
    case 2:
        return new NBTTagShort();
    case 3:
        return new NBTTagInt(0);
    case 4:
        return new NBTTagLong(0);
    case 5:
        return new NBTTagFloat(0);
    case 6:
        return new NBTTagDouble(0);
    case 7:
        return new NBTTagByteArray(new byte[0]);
    case 8:
        return new NBTTagString("");
    case 9:
        return new NBTTagList();
    case 10:
        return new NBTTagCompound();
    case 11:
        return new NBTTagIntArray(new int[0]);
    default:
        return null;
    }
}
NBTStringHelper.java 文件源码 项目:NBTEdit 阅读 18 收藏 0 点赞 0 评论 0
public static String toString(NBTBase base) {
    switch(base.getId()) {
    case 1:
        return "" + ((NBTTagByte)base).func_150290_f();
    case 2:
        return "" + ((NBTTagShort)base).func_150289_e();
    case 3:
        return "" + ((NBTTagInt)base).func_150287_d();
    case 4:
        return "" + ((NBTTagLong)base).func_150291_c();
    case 5:
        return "" + ((NBTTagFloat)base).func_150288_h();
    case 6:
        return "" + ((NBTTagDouble)base).func_150286_g();
    case 7:
        return base.toString();
    case 8:
        return ((NBTTagString)base).func_150285_a_();
    case 9:
        return "(TagList)";
    case 10:
        return "(TagCompound)";
    case 11:
        return base.toString();
    default:
        return "?";
    }
}
MappingRegistry.java 文件源码 项目:hcables 阅读 15 收藏 0 点赞 0 评论 0
private boolean isStackLayout(NBTTagCompound nbt) {
    return nbt.hasKey("id") &&
            nbt.hasKey("Count") &&
            nbt.hasKey("Damage") &&
            nbt.getTag("id") instanceof NBTTagShort &&
            nbt.getTag("Count") instanceof NBTTagByte &&
            nbt.getTag("Damage") instanceof NBTTagShort;
}


问题


面经


文章

微信
公众号

扫码关注公众号