@Override
public NBTTagFloat merge(NBTTagFloat nbt, Object data, String key, String path) {
if (data instanceof Number) {
return NbtConverter.toNbt(((Number) data).floatValue());
}
throw converter.conversionException(path, data, "number");
}
java类net.minecraft.nbt.NBTTagFloat的实例源码
NbtFloatMerger.java 文件源码
项目:wizards-of-lua
阅读 17
收藏 0
点赞 0
评论 0
MorphingStorage.java 文件源码
项目:metamorph
阅读 17
收藏 0
点赞 0
评论 0
@Override
public NBTBase writeNBT(Capability<IMorphing> capability, IMorphing instance, EnumFacing side)
{
NBTTagCompound tag = new NBTTagCompound();
NBTTagList acquired = new NBTTagList();
NBTTagList favorites = new NBTTagList();
tag.setTag("lastHealthRatio", new NBTTagFloat(instance.getLastHealthRatio()));
if (instance.getCurrentMorph() != null)
{
NBTTagCompound morph = new NBTTagCompound();
instance.getCurrentMorph().toNBT(morph);
tag.setTag("Morph", morph);
}
tag.setTag("Morphs", acquired);
tag.setTag("Favorites", favorites);
for (AbstractMorph acquiredMorph : instance.getAcquiredMorphs())
{
NBTTagCompound acquiredTag = new NBTTagCompound();
acquiredMorph.toNBT(acquiredTag);
acquired.appendTag(acquiredTag);
}
for (Integer index : instance.getFavorites())
{
favorites.appendTag(new NBTTagInt(index.intValue()));
}
return tag;
}
AnimalFarmEntity.java 文件源码
项目:Mekfarm
阅读 16
收藏 0
点赞 0
评论 0
static ItemStack packageAnimal(ItemStack packageStack, EntityAnimal animal) {
ItemStack stackCopy = (packageStack == null) ? new ItemStack(ItemsRegistry.animalPackage) : packageStack.copy();
stackCopy.setTagInfo("hasAnimal", new NBTTagInt(1));
NBTTagCompound animalCompound = new NBTTagCompound();
animal.writeEntityToNBT(animalCompound);
stackCopy.setTagInfo("animal", animalCompound);
stackCopy.setTagInfo("animalClass", new NBTTagString(animal.getClass().getName()));
stackCopy.setTagInfo("animalHealth", new NBTTagFloat(animal.getHealth()));
return stackCopy;
}
JEDWorldProperties.java 文件源码
项目:justenoughdimensions
阅读 20
收藏 0
点赞 0
评论 0
@Nonnull
private static NBTTagList writeFloats(float... values)
{
NBTTagList tagList = new NBTTagList();
for (float f : values)
{
tagList.appendTag(new NBTTagFloat(f));
}
return tagList;
}
NBTListFloatTextFieldModel.java 文件源码
项目:TaleCraft
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void setText(String text) {
this.text = text;
try {
float value = Float.parseFloat(text);
list.set(index, new NBTTagFloat(value));
valid = true;
} catch(NumberFormatException ex) {
valid = false;
}
}
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;
}
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;
}
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
阅读 24
收藏 0
点赞 0
评论 0
/**
* Returns a new NBTTagList filled with the specified floats
*/
protected NBTTagList newFloatNBTList(float ... p_70049_1_)
{
NBTTagList nbttaglist = new NBTTagList();
float[] afloat = p_70049_1_;
int i = p_70049_1_.length;
for (int j = 0; j < i; ++j)
{
float f1 = afloat[j];
nbttaglist.appendTag(new NBTTagFloat(f1));
}
return nbttaglist;
}
SchematicEntity.java 文件源码
项目:Connected
阅读 18
收藏 0
点赞 0
评论 0
protected NBTTagList newFloatNBTList(float... par1ArrayOfFloat) {
NBTTagList nbttaglist = new NBTTagList();
float[] afloat = par1ArrayOfFloat;
int i = par1ArrayOfFloat.length;
for (int j = 0; j < i; ++j) {
float f1 = afloat[j];
nbttaglist.appendTag(new NBTTagFloat(f1));
}
return nbttaglist;
}