當前位置: 首頁>>代碼示例>>Java>>正文


Java NBTTagFloat類代碼示例

本文整理匯總了Java中net.minecraft.nbt.NBTTagFloat的典型用法代碼示例。如果您正苦於以下問題:Java NBTTagFloat類的具體用法?Java NBTTagFloat怎麽用?Java NBTTagFloat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NBTTagFloat類屬於net.minecraft.nbt包,在下文中一共展示了NBTTagFloat類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getElectricityStored

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
/**
 * Gets the energy stored in the item. Energy is stored using item NBT
 */
@Override
public float getElectricityStored(ItemStack itemStack)
{
    if (itemStack.getTagCompound() == null)
    {
        itemStack.setTagCompound(new NBTTagCompound());
    }
    float energyStored = 0f;
    if (itemStack.getTagCompound().hasKey("electricity"))
    {
        NBTBase obj = itemStack.getTagCompound().getTag("electricity");
        if (obj instanceof NBTTagDouble)
        {
            energyStored = ((NBTTagDouble) obj).func_150288_h();
        }
        else if (obj instanceof NBTTagFloat)
        {
            energyStored = ((NBTTagFloat) obj).func_150288_h();
        }
    }

    /** Sets the damage as a percentage to render the bar properly. */
    itemStack.setItemDamage((int) (100 - energyStored / this.getMaxElectricityStored(itemStack) * 100));
    return energyStored;
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:29,代碼來源:ItemElectricBase.java

示例2: asJson

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
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;
	}

}
 
開發者ID:tiffit,項目名稱:TaleCraft,代碼行數:17,代碼來源:NBTHelper.java

示例3: any

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
private static StringBuilder any(StringBuilder sb, NBTBase nbt) {
	switch (nbt.getId()) {
	case Constants.NBT.TAG_COMPOUND:
		return compound(sb, (NBTTagCompound) nbt);
	case Constants.NBT.TAG_LIST:
		return list(sb, (NBTTagList) nbt);
	case Constants.NBT.TAG_INT_ARRAY:
		return intArray(sb, (NBTTagIntArray) nbt);
	case Constants.NBT.TAG_STRING:
		return string(sb, (NBTTagString) nbt);
	case Constants.NBT.TAG_DOUBLE:
		return _double(sb, (NBTTagDouble) nbt);
	case Constants.NBT.TAG_FLOAT:
		return _float(sb, (NBTTagFloat) nbt);
	default:
		return other(sb, nbt);
	}
}
 
開發者ID:Earthcomputer,項目名稱:Easy-Editors,代碼行數:19,代碼來源:NBTToJson.java

示例4: createTag

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
/** 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);
}
 
開發者ID:copygirl,項目名稱:copycore,代碼行數:18,代碼來源:NbtUtils.java

示例5: getObject

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
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;
}
 
開發者ID:CreativeMD,項目名稱:CraftingManager,代碼行數:27,代碼來源:ConvertNBTTagCompound.java

示例6: setValidValue

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
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));
}
 
開發者ID:DavidGoldman,項目名稱:NBTEdit,代碼行數:24,代碼來源:GuiEditNBT.java

示例7: getElectricityStored

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
/** Gets the energy stored in the item. Energy is stored using item NBT */
@Override
public float getElectricityStored(ItemStack itemStack)
{
	if (itemStack.getTagCompound() == null)
	{
		itemStack.setTagCompound(new NBTTagCompound());
	}
	float energyStored = 0f;
	if (itemStack.getTagCompound().hasKey("electricity"))
	{
		NBTBase obj = itemStack.getTagCompound().getTag("electricity");
		if (obj instanceof NBTTagDouble)
		{
			energyStored = (float) ((NBTTagDouble) obj).data;
		}
		else if (obj instanceof NBTTagFloat)
		{
			energyStored = ((NBTTagFloat) obj).data;
		}
	}

	/** Sets the damage as a percentage to render the bar properly. */
	itemStack.setItemDamage((int) (100 - (energyStored / this.getMaxElectricityStored(itemStack)) * 100));
	return energyStored;
}
 
開發者ID:4Space,項目名稱:4-Space-Legacy,代碼行數:27,代碼來源:ItemElectric.java

示例8: getElectricityStored

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
/** Gets the energy stored in the item. Energy is stored using item NBT */
@Override
public float getElectricityStored(ItemStack itemStack)
{
    if (itemStack.getTagCompound() == null)
    {
        itemStack.setTagCompound(new NBTTagCompound());
    }
    float energyStored = 0f;
    if (itemStack.getTagCompound().hasKey("electricity"))
    {
        NBTBase obj = itemStack.getTagCompound().getTag("electricity");
        if (obj instanceof NBTTagDouble)
        {
            energyStored = (float) ((NBTTagDouble) obj).data;
        }
        else if (obj instanceof NBTTagFloat)
        {
            energyStored = ((NBTTagFloat) obj).data;
        }
    }

    /** Sets the damage as a percentage to render the bar properly. */
    itemStack.setItemDamage((int) (100 - (energyStored / getMaxElectricityStored(itemStack)) * 100));
    return energyStored;
}
 
開發者ID:tterrag1098,項目名稱:SimpleTransmutations,代碼行數:27,代碼來源:ItemElectric.java

示例9: getNBTCapacitorDataFromItemStack

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
protected static @Nullable ICapacitorData getNBTCapacitorDataFromItemStack(@Nonnull ItemStack stack) {
  final NBTTagCompound nbtRoot = stack.getTagCompound();
  if (nbtRoot == null) {
    return null;
  }
  if (!nbtRoot.hasKey("eiocap", (new NBTTagCompound()).getId())) {
    return null;
  }
  final NBTTagCompound nbtTag = nbtRoot.getCompoundTag("eiocap");
  if (!nbtTag.hasKey("level", (new NBTTagFloat(0)).getId())) {
    return null;
  }
  final float capLevel = nbtTag.getFloat("level");
  if (capLevel < 0 || capLevel >= 10) {
    return null;
  }
  return new NBTCapacitorData(stack.getItem().getUnlocalizedName(stack), capLevel, nbtTag);
}
 
開發者ID:SleepyTrousers,項目名稱:EnderIO,代碼行數:19,代碼來源:CapacitorHelper.java

示例10: newFloatNBTList

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
/**
 * Returns a new NBTTagList filled with the specified floats
 */
protected NBTTagList newFloatNBTList(float... numbers)
{
    NBTTagList nbttaglist = new NBTTagList();

    for (float f : numbers)
    {
        nbttaglist.appendTag(new NBTTagFloat(f));
    }

    return nbttaglist;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:15,代碼來源:Entity.java

示例11: writeToNBT

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
public NBTTagList writeToNBT()
{
    NBTTagList nbttaglist = new NBTTagList();
    nbttaglist.appendTag(new NBTTagFloat(this.x));
    nbttaglist.appendTag(new NBTTagFloat(this.y));
    nbttaglist.appendTag(new NBTTagFloat(this.z));
    return nbttaglist;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:9,代碼來源:Rotations.java

示例12: writeToNBT

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
public NBTTagList writeToNBT() {
	NBTTagList nbttaglist = new NBTTagList();
	nbttaglist.appendTag(new NBTTagFloat(x));
	nbttaglist.appendTag(new NBTTagFloat(y));
	nbttaglist.appendTag(new NBTTagFloat(z));
	return nbttaglist;
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:8,代碼來源:Rotations.java

示例13: addValue

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
public static float addValue(float value, NBTTagCompound attributelist, String effect) {
	for(String name : attributelist.getKeySet()) {
		NBTBase tag = attributelist.getTag(name);
		if (tag instanceof NBTTagFloat) {
			TF2Attribute attribute = attributes[Integer.parseInt(name)];
			if (attribute != null && attribute.effect.equals(effect))
				if (attribute.typeOfValue == Type.ADDITIVE)
					value += ((NBTTagFloat) tag).getFloat();
				else
					value *= ((NBTTagFloat) tag).getFloat();
		}
	}
	return value;
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:15,代碼來源:TF2Attribute.java

示例14: getNBTBaseData

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
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;
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:35,代碼來源:WidgetTextData.java

示例15: getNBTBase

import net.minecraft.nbt.NBTTagFloat; //導入依賴的package包/類
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;
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:29,代碼來源:WidgetTextData.java


注:本文中的net.minecraft.nbt.NBTTagFloat類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。