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


Java NBTTagDouble類代碼示例

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


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

示例1: getElectricityStored

import net.minecraft.nbt.NBTTagDouble; //導入依賴的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.NBTTagDouble; //導入依賴的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.NBTTagDouble; //導入依賴的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.NBTTagDouble; //導入依賴的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.NBTTagDouble; //導入依賴的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.NBTTagDouble; //導入依賴的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: func_70037_a

import net.minecraft.nbt.NBTTagDouble; //導入依賴的package包/類
public void func_70037_a(NBTTagCompound p_70037_1_) {
   this.field_70231_e = p_70037_1_.func_74765_d("xTile");
   this.field_70228_f = p_70037_1_.func_74765_d("yTile");
   this.field_70229_g = p_70037_1_.func_74765_d("zTile");
   this.field_70237_h = p_70037_1_.func_74771_c("inTile") & 255;
   this.field_70238_i = p_70037_1_.func_74771_c("inGround") == 1;
   if(p_70037_1_.func_74764_b("direction")) {
      NBTTagList var2 = p_70037_1_.func_74761_m("direction");
      this.field_70159_w = ((NBTTagDouble)var2.func_74743_b(0)).field_74755_a;
      this.field_70181_x = ((NBTTagDouble)var2.func_74743_b(1)).field_74755_a;
      this.field_70179_y = ((NBTTagDouble)var2.func_74743_b(2)).field_74755_a;
   } else {
      this.func_70106_y();
   }

}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:17,代碼來源:EntityFireball.java

示例8: readEntityFromNBT

import net.minecraft.nbt.NBTTagDouble; //導入依賴的package包/類
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
    this.xTile = par1NBTTagCompound.getShort("xTile");
    this.yTile = par1NBTTagCompound.getShort("yTile");
    this.zTile = par1NBTTagCompound.getShort("zTile");
    this.inTile = par1NBTTagCompound.getByte("inTile") & 255;
    this.inGround = par1NBTTagCompound.getByte("inGround") == 1;

    if (par1NBTTagCompound.hasKey("direction"))
    {
        NBTTagList nbttaglist = par1NBTTagCompound.getTagList("direction");
        this.motionX = ((NBTTagDouble)nbttaglist.tagAt(0)).data;
        this.motionY = ((NBTTagDouble)nbttaglist.tagAt(1)).data;
        this.motionZ = ((NBTTagDouble)nbttaglist.tagAt(2)).data;
    }
    else
    {
        this.setDead();
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:24,代碼來源:EntityFireball.java

示例9: getElectricityStored

import net.minecraft.nbt.NBTTagDouble; //導入依賴的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

示例10: readEntityFromNBT

import net.minecraft.nbt.NBTTagDouble; //導入依賴的package包/類
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
	this.xTile = par1NBTTagCompound.getShort("xTile");
	this.yTile = par1NBTTagCompound.getShort("yTile");
	this.zTile = par1NBTTagCompound.getShort("zTile");
	this.inTile = par1NBTTagCompound.getByte("inTile") & 255;
	this.inGround = par1NBTTagCompound.getByte("inGround") == 1;

	if (par1NBTTagCompound.hasKey("direction"))
	{
		NBTTagList nbttaglist = par1NBTTagCompound.getTagList("direction");
		this.motionX = ((NBTTagDouble)nbttaglist.tagAt(0)).data;
		this.motionY = ((NBTTagDouble)nbttaglist.tagAt(1)).data;
		this.motionZ = ((NBTTagDouble)nbttaglist.tagAt(2)).data;
	}
	else
	{
		this.setDead();
	}
}
 
開發者ID:WildBamaBoy,項目名稱:spellbound,代碼行數:21,代碼來源:AbstractTargetSpell.java

示例11: getElectricityStored

import net.minecraft.nbt.NBTTagDouble; //導入依賴的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

示例12: addEntitiesToWorld

import net.minecraft.nbt.NBTTagDouble; //導入依賴的package包/類
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
    for (Template.EntityInfo template$entityinfo : this.entities)
    {
        BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);

        if (aabb == null || aabb.isVecInside(blockpos))
        {
            NBTTagCompound nbttagcompound = template$entityinfo.entityData;
            Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
            Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
            NBTTagList nbttaglist = new NBTTagList();
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.x));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.y));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.z));
            nbttagcompound.setTag("Pos", nbttaglist);
            nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
            Entity entity;

            try
            {
                entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
            }
            catch (Exception var15)
            {
                entity = null;
            }

            if (entity != null)
            {
                float f = entity.getMirroredYaw(mirrorIn);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
                entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch);
                worldIn.spawnEntity(entity);
            }
        }
    }
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:39,代碼來源:HarshenTemplate.java

示例13: writeDoubles

import net.minecraft.nbt.NBTTagDouble; //導入依賴的package包/類
private NBTTagList writeDoubles(double... values)
{
    NBTTagList nbttaglist = new NBTTagList();

    for (double d0 : values)
    {
        nbttaglist.appendTag(new NBTTagDouble(d0));
    }

    return nbttaglist;
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:12,代碼來源:HarshenTemplate.java

示例14: newDoubleNBTList

import net.minecraft.nbt.NBTTagDouble; //導入依賴的package包/類
/**
 * creates a NBT list from the array of doubles passed to this function
 */
protected NBTTagList newDoubleNBTList(double... numbers)
{
    NBTTagList nbttaglist = new NBTTagList();

    for (double d0 : numbers)
    {
        nbttaglist.appendTag(new NBTTagDouble(d0));
    }

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

示例15: addEntitiesToWorld

import net.minecraft.nbt.NBTTagDouble; //導入依賴的package包/類
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
    for (Template.EntityInfo template$entityinfo : this.entities)
    {
        BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);

        if (aabb == null || aabb.isVecInside(blockpos))
        {
            NBTTagCompound nbttagcompound = template$entityinfo.entityData;
            Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
            Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
            NBTTagList nbttaglist = new NBTTagList();
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.xCoord));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.yCoord));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.zCoord));
            nbttagcompound.setTag("Pos", nbttaglist);
            nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
            Entity entity;

            try
            {
                entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
            }
            catch (Exception var15)
            {
                entity = null;
            }

            if (entity != null)
            {
                float f = entity.getMirroredYaw(mirrorIn);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
                entity.setLocationAndAngles(vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, f, entity.rotationPitch);
                worldIn.spawnEntityInWorld(entity);
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:39,代碼來源:Template.java


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