本文整理匯總了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;
}
示例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;
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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;
}