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

NbtDoubleMerger.java 文件源码 项目:wizards-of-lua 阅读 18 收藏 0 点赞 0 评论 0
@Override
public NBTTagDouble merge(NBTTagDouble nbt, Object data, String key, String path) {
  if (data instanceof Number) {
    return NbtConverter.toNbt(((Number) data).doubleValue());
  }
  throw converter.conversionException(path, data, "number");
}
NBTListDoubleTextFieldModel.java 文件源码 项目:TaleCraft 阅读 19 收藏 0 点赞 0 评论 0
@Override
public void setText(String text) {
    this.text = text;

    try {
        double value = Double.parseDouble(text);
        list.set(index, new NBTTagDouble(value));
        this.valid = true;
    } catch(NumberFormatException ex) {
        valid = false;
    }
}
NBTSettingsManager.java 文件源码 项目:morecommands 阅读 21 收藏 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;
}
DataConverter.java 文件源码 项目:NOVA-Core 阅读 22 收藏 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 阅读 24 收藏 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;
}
Entity.java 文件源码 项目:TickDynamic 阅读 25 收藏 0 点赞 0 评论 0
/**
 * creates a NBT list from the array of doubles passed to this function
 */
protected NBTTagList newDoubleNBTList(double ... p_70087_1_)
{
    NBTTagList nbttaglist = new NBTTagList();
    double[] adouble = p_70087_1_;
    int i = p_70087_1_.length;

    for (int j = 0; j < i; ++j)
    {
        double d1 = adouble[j];
        nbttaglist.appendTag(new NBTTagDouble(d1));
    }

    return nbttaglist;
}
SchematicEntity.java 文件源码 项目:Connected 阅读 23 收藏 0 点赞 0 评论 0
protected NBTTagList newDoubleNBTList(double... par1ArrayOfDouble) {
    NBTTagList nbttaglist = new NBTTagList();
    double[] adouble = par1ArrayOfDouble;
    int i = par1ArrayOfDouble.length;

    for (int j = 0; j < i; ++j) {
        double d1 = adouble[j];
        nbttaglist.appendTag(new NBTTagDouble(d1));
    }

    return nbttaglist;
}
Entity.java 文件源码 项目:Resilience-Client-Source 阅读 26 收藏 0 点赞 0 评论 0
/**
 * creates a NBT list from the array of doubles passed to this function
 */
protected NBTTagList newDoubleNBTList(double ... par1ArrayOfDouble)
{
    NBTTagList var2 = new NBTTagList();
    double[] var3 = par1ArrayOfDouble;
    int var4 = par1ArrayOfDouble.length;

    for (int var5 = 0; var5 < var4; ++var5)
    {
        double var6 = var3[var5];
        var2.appendTag(new NBTTagDouble(var6));
    }

    return var2;
}
SchematicEntity.java 文件源码 项目:Framez 阅读 21 收藏 0 点赞 0 评论 0
protected NBTTagList newDoubleNBTList(double... par1ArrayOfDouble) {
    NBTTagList nbttaglist = new NBTTagList();
    double[] adouble = par1ArrayOfDouble;
    int i = par1ArrayOfDouble.length;

    for (int j = 0; j < i; ++j) {
        double d1 = adouble[j];
        nbttaglist.appendTag(new NBTTagDouble(d1));
    }

    return nbttaglist;
}
NbtUtils.java 文件源码 项目:copycore 阅读 27 收藏 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");
}


问题


面经


文章

微信
公众号

扫码关注公众号