当前位置: 首页>>代码示例>>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;未经允许,请勿转载。