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

项目:wizards-of-lua    文件:NbtConverterTest.java   
@Test
public void test_merge__Uses_NbtType_of_existing_Tag() {
  // Given:
  NBTTagCompound nbt = new NBTTagCompound();
  String key = "my_key";
  short value = 42;
  nbt.setShort(key, value);

  Table data = new DefaultTable();
  long newValue = 53;
  data.rawset(key, newValue);

  // When:
  NBTTagCompound actual = underTest.merge(nbt, data);

  // Then:
  assertThat(actual.getKeySet()).containsOnly(key);
  assertThat(actual.getTag(key)).isEqualTo(new NBTTagShort((short) newValue));
}
项目:TaleCraft    文件:NBTHelper.java   
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;
    }

}
项目:copycore    文件:NbtUtils.java   
/** 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);
}
项目:CraftingManager    文件:ConvertNBTTagCompound.java   
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;
}
项目:NBTEdit    文件:GuiEditNBT.java   
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));
}
项目:DecompiledMinecraft    文件:MapStorage.java   
/**
 * Loads the idCounts Map from the 'idcounts' file.
 */
private void loadIdCounts()
{
    try
    {
        this.idCounts.clear();

        if (this.saveHandler == null)
        {
            return;
        }

        File file1 = this.saveHandler.getMapFileFromName("idcounts");

        if (file1 != null && file1.exists())
        {
            DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();

            for (String s : nbttagcompound.getKeySet())
            {
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase instanceof NBTTagShort)
                {
                    NBTTagShort nbttagshort = (NBTTagShort)nbtbase;
                    short short1 = nbttagshort.getShort();
                    this.idCounts.put(s, Short.valueOf(short1));
                }
            }
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
项目:DecompiledMinecraft    文件:MapStorage.java   
/**
 * Loads the idCounts Map from the 'idcounts' file.
 */
private void loadIdCounts()
{
    try
    {
        this.idCounts.clear();

        if (this.saveHandler == null)
        {
            return;
        }

        File file1 = this.saveHandler.getMapFileFromName("idcounts");

        if (file1 != null && file1.exists())
        {
            DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();

            for (String s : nbttagcompound.getKeySet())
            {
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase instanceof NBTTagShort)
                {
                    NBTTagShort nbttagshort = (NBTTagShort)nbtbase;
                    short short1 = nbttagshort.getShort();
                    this.idCounts.put(s, Short.valueOf(short1));
                }
            }
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
项目:BaseClient    文件:MapStorage.java   
/**
 * Loads the idCounts Map from the 'idcounts' file.
 */
private void loadIdCounts()
{
    try
    {
        this.idCounts.clear();

        if (this.saveHandler == null)
        {
            return;
        }

        File file1 = this.saveHandler.getMapFileFromName("idcounts");

        if (file1 != null && file1.exists())
        {
            DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();

            for (String s : nbttagcompound.getKeySet())
            {
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase instanceof NBTTagShort)
                {
                    NBTTagShort nbttagshort = (NBTTagShort)nbtbase;
                    short short1 = nbttagshort.getShort();
                    this.idCounts.put(s, Short.valueOf(short1));
                }
            }
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
项目:BaseClient    文件:MapStorage.java   
/**
 * Loads the idCounts Map from the 'idcounts' file.
 */
private void loadIdCounts()
{
    try
    {
        this.idCounts.clear();

        if (this.saveHandler == null)
        {
            return;
        }

        File file1 = this.saveHandler.getMapFileFromName("idcounts");

        if (file1 != null && file1.exists())
        {
            DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();

            for (String s : nbttagcompound.getKeySet())
            {
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase instanceof NBTTagShort)
                {
                    NBTTagShort nbttagshort = (NBTTagShort)nbtbase;
                    short short1 = nbttagshort.getShort();
                    this.idCounts.put(s, Short.valueOf(short1));
                }
            }
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
项目:Backmemed    文件:MapStorage.java   
/**
 * Loads the idCounts Map from the 'idcounts' file.
 */
private void loadIdCounts()
{
    try
    {
        this.idCounts.clear();

        if (this.saveHandler == null)
        {
            return;
        }

        File file1 = this.saveHandler.getMapFileFromName("idcounts");

        if (file1 != null && file1.exists())
        {
            DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();

            for (String s : nbttagcompound.getKeySet())
            {
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase instanceof NBTTagShort)
                {
                    NBTTagShort nbttagshort = (NBTTagShort)nbtbase;
                    short short1 = nbttagshort.getShort();
                    this.idCounts.put(s, Short.valueOf(short1));
                }
            }
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
项目:CustomWorldGen    文件:MapStorage.java   
/**
 * Loads the idCounts Map from the 'idcounts' file.
 */
private void loadIdCounts()
{
    try
    {
        this.idCounts.clear();

        if (this.saveHandler == null)
        {
            return;
        }

        File file1 = this.saveHandler.getMapFileFromName("idcounts");

        if (file1 != null && file1.exists())
        {
            DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();

            for (String s : nbttagcompound.getKeySet())
            {
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase instanceof NBTTagShort)
                {
                    NBTTagShort nbttagshort = (NBTTagShort)nbtbase;
                    short short1 = nbttagshort.getShort();
                    this.idCounts.put(s, Short.valueOf(short1));
                }
            }
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
项目:ExtraUtilities    文件:WidgetTextData.java   
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;
        }
    }
}
项目:ExtraUtilities    文件:WidgetTextData.java   
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;
}
项目:4Space-5    文件:MappingRegistry.java   
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;
}
项目:4Space-5    文件:EntityLivingBase.java   
public void readEntityFromNBT(NBTTagCompound p_70037_1_) {
    ;
    ;
    setAbsorptionAmount(p_70037_1_.getFloat("AbsorptionAmount"));
    if ((p_70037_1_.hasKey("Attributes", 9)) && (this.worldObj != null)
            && (!this.worldObj.isRemote)) {
        SharedMonsterAttributes.func_151475_a(getAttributeMap(),
                p_70037_1_.getTagList("Attributes", 10));
    }
    if (p_70037_1_.hasKey("ActiveEffects", 9)) {
        NBTTagList nbttaglist = p_70037_1_.getTagList("ActiveEffects", 10);
        for (int i = 0; i < nbttaglist.tagCount(); i++) {
            NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
            PotionEffect potioneffect = PotionEffect
                    .readCustomPotionEffectFromNBT(nbttagcompound1);
            if (potioneffect != null) {
                this.activePotionsMap.put(
                        Integer.valueOf(potioneffect.getPotionID()),
                        potioneffect);
            }
        }
    }
    if (p_70037_1_.hasKey("HealF", 99)) {
        setHealth(p_70037_1_.getFloat("HealF"));
    } else {
        NBTBase nbtbase = p_70037_1_.getTag("Health");
        if (nbtbase == null) {
            setHealth(getMaxHealth());
        } else if (nbtbase.getId() == 5) {
            setHealth(((NBTTagFloat) nbtbase).func_150288_h());
        } else if (nbtbase.getId() == 2) {
            setHealth(((NBTTagShort) nbtbase).func_150289_e());
        }
    }
    this.hurtTime = p_70037_1_.getShort("HurtTime");
    this.deathTime = p_70037_1_.getShort("DeathTime");
    this.attackTime = p_70037_1_.getShort("AttackTime");
}
项目:wizards-of-lua    文件:NbtConverter.java   
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;
}
项目:wizards-of-lua    文件:NbtShortMerger.java   
@Override
public NBTTagShort merge(NBTTagShort nbt, Object data, String key, String path) {
  if (data instanceof Number) {
    return NbtConverter.toNbt(((Number) data).shortValue());
  }
  throw converter.conversionException(path, data, "number");
}
项目:morecommands    文件:NBTSettingsManager.java   
/**
 * 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;
}
项目:NOVA-Core    文件:DataConverter.java   
/**
 * 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;
}
项目:NOVA-Core    文件:DataConverter.java   
/**
 * 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;
}
项目:ElectricAdvantage    文件:ElectricCrusherTileEntity.java   
@Override
protected void saveTo(NBTTagCompound tagRoot) {
    NBTTagList times = new NBTTagList();
    for(int i = 0; i < numberOfInputSlots(); i++){
        times.appendTag(new NBTTagShort(smashTime[i]));
    }
    tagRoot.setTag("smashTime", times);
}
项目:ElectricAdvantage    文件:ElectricCrusherTileEntity.java   
@Override
protected void loadFrom(NBTTagCompound tagRoot) {
    NBTTagList times = tagRoot.getTagList("smashTime", 2);
    for(int i = 0; i < numberOfInputSlots(); i++){
        smashTime[i] = ((NBTTagShort)times.get(i)).getShort();
    }
}
项目:ElectricAdvantage    文件:ElectricFurnaceTileEntity.java   
@Override
protected void saveTo(NBTTagCompound tagRoot) {
    NBTTagList burnTimes = new NBTTagList();
    for(int i = 0; i < numberOfInputSlots(); i++){
        burnTimes.appendTag(new NBTTagShort(burnTime[i]));
    }
    tagRoot.setTag("cookTime", burnTimes);
}
项目:ElectricAdvantage    文件:ElectricFurnaceTileEntity.java   
@Override
protected void loadFrom(NBTTagCompound tagRoot) {
    NBTTagList burnTimes = tagRoot.getTagList("cookTime", 2);
    for(int i = 0; i < numberOfInputSlots(); i++){
        burnTime[i] = ((NBTTagShort)burnTimes.get(i)).getShort();
    }
}
项目:Connected    文件:MappingRegistry.java   
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;
}
项目:Resilience-Client-Source    文件:MapStorage.java   
/**
 * Loads the idCounts Map from the 'idcounts' file.
 */
private void loadIdCounts()
{
    try
    {
        this.idCounts.clear();

        if (this.saveHandler == null)
        {
            return;
        }

        File var1 = this.saveHandler.getMapFileFromName("idcounts");

        if (var1 != null && var1.exists())
        {
            DataInputStream var2 = new DataInputStream(new FileInputStream(var1));
            NBTTagCompound var3 = CompressedStreamTools.read(var2);
            var2.close();
            Iterator var4 = var3.func_150296_c().iterator();

            while (var4.hasNext())
            {
                String var5 = (String)var4.next();
                NBTBase var6 = var3.getTag(var5);

                if (var6 instanceof NBTTagShort)
                {
                    NBTTagShort var7 = (NBTTagShort)var6;
                    short var9 = var7.func_150289_e();
                    this.idCounts.put(var5, Short.valueOf(var9));
                }
            }
        }
    }
    catch (Exception var10)
    {
        var10.printStackTrace();
    }
}
项目:Framez    文件:MappingRegistry.java   
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;
}
项目:copycore    文件:NbtUtils.java   
/** 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");
}
项目:4Space-1.7    文件:EntityLivingBase.java   
public void readEntityFromNBT(NBTTagCompound p_70037_1_) {
    ;
    ;
    setAbsorptionAmount(p_70037_1_.getFloat("AbsorptionAmount"));
    if ((p_70037_1_.hasKey("Attributes", 9)) && (this.worldObj != null)
            && (!this.worldObj.isRemote)) {
        SharedMonsterAttributes.func_151475_a(getAttributeMap(),
                p_70037_1_.getTagList("Attributes", 10));
    }
    if (p_70037_1_.hasKey("ActiveEffects", 9)) {
        NBTTagList nbttaglist = p_70037_1_.getTagList("ActiveEffects", 10);
        for (int i = 0; i < nbttaglist.tagCount(); i++) {
            NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
            PotionEffect potioneffect = PotionEffect
                    .readCustomPotionEffectFromNBT(nbttagcompound1);
            if (potioneffect != null) {
                this.activePotionsMap.put(
                        Integer.valueOf(potioneffect.getPotionID()),
                        potioneffect);
            }
        }
    }
    if (p_70037_1_.hasKey("HealF", 99)) {
        setHealth(p_70037_1_.getFloat("HealF"));
    } else {
        NBTBase nbtbase = p_70037_1_.getTag("Health");
        if (nbtbase == null) {
            setHealth(getMaxHealth());
        } else if (nbtbase.getId() == 5) {
            setHealth(((NBTTagFloat) nbtbase).func_150288_h());
        } else if (nbtbase.getId() == 2) {
            setHealth(((NBTTagShort) nbtbase).func_150289_e());
        }
    }
    this.hurtTime = p_70037_1_.getShort("HurtTime");
    this.deathTime = p_70037_1_.getShort("DeathTime");
    this.attackTime = p_70037_1_.getShort("AttackTime");
}
项目:Cauldron    文件:MapStorage.java   
private void loadIdCounts()
{
    try
    {
        this.idCounts.clear();

        if (this.saveHandler == null)
        {
            return;
        }

        File file1 = this.saveHandler.getMapFileFromName("idcounts");

        if (file1 != null && file1.exists())
        {
            DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();
            Iterator iterator = nbttagcompound.func_150296_c().iterator();

            while (iterator.hasNext())
            {
                String s = (String)iterator.next();
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase instanceof NBTTagShort)
                {
                    NBTTagShort nbttagshort = (NBTTagShort)nbtbase;
                    short short1 = nbttagshort.func_150289_e();
                    this.idCounts.put(s, Short.valueOf(short1));
                }
            }
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
项目:Cauldron    文件:MapStorage.java   
private void loadIdCounts()
{
    try
    {
        this.idCounts.clear();

        if (this.saveHandler == null)
        {
            return;
        }

        File file1 = this.saveHandler.getMapFileFromName("idcounts");

        if (file1 != null && file1.exists())
        {
            DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();
            Iterator iterator = nbttagcompound.func_150296_c().iterator();

            while (iterator.hasNext())
            {
                String s = (String)iterator.next();
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase instanceof NBTTagShort)
                {
                    NBTTagShort nbttagshort = (NBTTagShort)nbtbase;
                    short short1 = nbttagshort.func_150289_e();
                    this.idCounts.put(s, Short.valueOf(short1));
                }
            }
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
项目:projectzulu1.7.10-pre-1.3a    文件:NBTWriter.java   
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();
    }
}
项目:DynIMC    文件:NBTTagCompoundDeserializer.java   
private NBTBase.NBTPrimitive getIdFromString(JsonElement jsonElement, String type) {
    if (jsonElement.isJsonPrimitive()) {
        JsonPrimitive jsonPrimitive = jsonElement.getAsJsonPrimitive();

        if (jsonPrimitive.isString()) {
            final String name = jsonPrimitive.getAsString();
            final String[] split = name.split(DELIMITER_ITEM_BLOCK, 2);
            int id = -1;

            if (split.length == 2) {
                if (split[0].equalsIgnoreCase(ID_TYPE_BLOCK)) {
                    id = GameData.getBlockRegistry().getId(split[1]);
                } else if (split[0].equalsIgnoreCase(ID_TYPE_ITEM)) {
                    id = GameData.getItemRegistry().getId(split[1]);
                }
            } else {
                id = GameData.getBlockRegistry().getId(split[0]);

                if (id == -1) {
                    id = GameData.getItemRegistry().getId(split[0]);
                }
            }

            if (id < 0) {
                Reference.logger.fatal(String.format("The block/item %s could not be found!", name));
            }

            if (type.equalsIgnoreCase(TYPE_SHORT)) {
                return new NBTTagShort((short) id);
            } else if (type.equalsIgnoreCase(TYPE_INT)) {
                return new NBTTagInt(id);
            }
        }
    }

    return null;
}
项目:NBTEdit    文件:NBTStringHelper.java   
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;
    }
}
项目:NBTEdit    文件:NBTStringHelper.java   
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 "?";
    }
}
项目:hcables    文件:MappingRegistry.java   
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;
}
项目:RuneCraftery    文件:MapStorage.java   
private void func_75746_b() {
   try {
      this.field_75748_d.clear();
      if(this.field_75751_a == null) {
         return;
      }

      File var1 = this.field_75751_a.func_75758_b("idcounts");
      if(var1 != null && var1.exists()) {
         DataInputStream var2 = new DataInputStream(new FileInputStream(var1));
         NBTTagCompound var3 = CompressedStreamTools.func_74794_a(var2);
         var2.close();
         Iterator var4 = var3.func_74758_c().iterator();

         while(var4.hasNext()) {
            NBTBase var5 = (NBTBase)var4.next();
            if(var5 instanceof NBTTagShort) {
               NBTTagShort var6 = (NBTTagShort)var5;
               String var7 = var6.func_74740_e();
               short var8 = var6.field_74752_a;
               this.field_75748_d.put(var7, Short.valueOf(var8));
            }
         }
      }
   } catch (Exception var9) {
      var9.printStackTrace();
   }

}
项目:RuneCraftery    文件:EntityLivingBase.java   
public void func_70037_a(NBTTagCompound p_70037_1_) {
   this.func_110149_m(p_70037_1_.func_74760_g("AbsorptionAmount"));
   if(p_70037_1_.func_74764_b("Attributes") && this.field_70170_p != null && !this.field_70170_p.field_72995_K) {
      SharedMonsterAttributes.func_111260_a(this.func_110140_aT(), p_70037_1_.func_74761_m("Attributes"), this.field_70170_p == null?null:this.field_70170_p.func_98180_V());
   }

   if(p_70037_1_.func_74764_b("ActiveEffects")) {
      NBTTagList var2 = p_70037_1_.func_74761_m("ActiveEffects");

      for(int var3 = 0; var3 < var2.func_74745_c(); ++var3) {
         NBTTagCompound var4 = (NBTTagCompound)var2.func_74743_b(var3);
         PotionEffect var5 = PotionEffect.func_82722_b(var4);
         this.field_70713_bf.put(Integer.valueOf(var5.func_76456_a()), var5);
      }
   }

   if(p_70037_1_.func_74764_b("HealF")) {
      this.func_70606_j(p_70037_1_.func_74760_g("HealF"));
   } else {
      NBTBase var6 = p_70037_1_.func_74781_a("Health");
      if(var6 == null) {
         this.func_70606_j(this.func_110138_aP());
      } else if(var6.func_74732_a() == 5) {
         this.func_70606_j(((NBTTagFloat)var6).field_74750_a);
      } else if(var6.func_74732_a() == 2) {
         this.func_70606_j((float)((NBTTagShort)var6).field_74752_a);
      }
   }

   this.field_70737_aN = p_70037_1_.func_74765_d("HurtTime");
   this.field_70725_aQ = p_70037_1_.func_74765_d("DeathTime");
   this.field_70724_aR = p_70037_1_.func_74765_d("AttackTime");
}
项目:RuneCraftery    文件:NBTTagCompound.java   
public short func_74765_d(String p_74765_1_) {
   try {
      return !this.field_74784_a.containsKey(p_74765_1_)?0:((NBTTagShort)this.field_74784_a.get(p_74765_1_)).field_74752_a;
   } catch (ClassCastException var3) {
      throw new ReportedException(this.func_82581_a(p_74765_1_, 2, var3));
   }
}
项目:RuneCraftery    文件:NBTBase.java   
public static NBTBase func_74733_a(byte p_74733_0_, String p_74733_1_) {
   switch(p_74733_0_) {
   case 0:
      return new NBTTagEnd();
   case 1:
      return new NBTTagByte(p_74733_1_);
   case 2:
      return new NBTTagShort(p_74733_1_);
   case 3:
      return new NBTTagInt(p_74733_1_);
   case 4:
      return new NBTTagLong(p_74733_1_);
   case 5:
      return new NBTTagFloat(p_74733_1_);
   case 6:
      return new NBTTagDouble(p_74733_1_);
   case 7:
      return new NBTTagByteArray(p_74733_1_);
   case 8:
      return new NBTTagString(p_74733_1_);
   case 9:
      return new NBTTagList(p_74733_1_);
   case 10:
      return new NBTTagCompound(p_74733_1_);
   case 11:
      return new NBTTagIntArray(p_74733_1_);
   default:
      return null;
   }
}