当前位置: 首页>>代码示例>>Java>>正文


Java Entity.writeToNBTOptional方法代码示例

本文整理汇总了Java中net.minecraft.entity.Entity.writeToNBTOptional方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.writeToNBTOptional方法的具体用法?Java Entity.writeToNBTOptional怎么用?Java Entity.writeToNBTOptional使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.Entity的用法示例。


在下文中一共展示了Entity.writeToNBTOptional方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeEntityToNBT

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound compound)
{
    super.writeEntityToNBT(compound);
    compound.setInteger("playerGameType", this.interactionManager.getGameType().getID());
    Entity entity = this.getLowestRidingEntity();

    if (this.getRidingEntity() != null && entity != this & entity.getRecursivePassengersByType(EntityPlayerMP.class).size() == 1)
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        entity.writeToNBTOptional(nbttagcompound1);
        nbttagcompound.setUniqueId("Attach", this.getRidingEntity().getUniqueID());
        nbttagcompound.setTag("Entity", nbttagcompound1);
        compound.setTag("RootVehicle", nbttagcompound);
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:20,代码来源:EntityPlayerMP.java

示例2: writeEntityToNBT

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound compound)
{
    super.writeEntityToNBT(compound);
    compound.setInteger("playerGameType", this.interactionManager.getGameType().getID());
    Entity entity = this.getLowestRidingEntity();
    Entity entity1 = this.getRidingEntity();

    if (entity1 != null && entity != this & entity.getRecursivePassengersByType(EntityPlayerMP.class).size() == 1)
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        entity.writeToNBTOptional(nbttagcompound1);
        nbttagcompound.setUniqueId("Attach", entity1.getUniqueID());
        nbttagcompound.setTag("Entity", nbttagcompound1);
        compound.setTag("RootVehicle", nbttagcompound);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:21,代码来源:EntityPlayerMP.java

示例3: spawnNewEntity

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
private Entity spawnNewEntity(Entity entityIn, boolean spawn)
{
    if (this.getRandomEntity() != null)
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        entityIn.writeToNBTOptional(nbttagcompound);

        for (String s : this.getRandomEntity().nbtData.getKeySet())
        {
            NBTBase nbtbase = this.getRandomEntity().nbtData.getTag(s);
            nbttagcompound.setTag(s, nbtbase.copy());
        }

        entityIn.readFromNBT(nbttagcompound);

        if (entityIn.worldObj != null && spawn)
        {
            entityIn.worldObj.spawnEntityInWorld(entityIn);
        }

        NBTTagCompound nbttagcompound2;

        for (Entity entity = entityIn; nbttagcompound.hasKey("Riding", 10); nbttagcompound = nbttagcompound2)
        {
            nbttagcompound2 = nbttagcompound.getCompoundTag("Riding");
            Entity entity1 = EntityList.createEntityByName(nbttagcompound2.getString("id"), entityIn.worldObj);

            if (entity1 != null)
            {
                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                entity1.writeToNBTOptional(nbttagcompound1);

                for (String s1 : nbttagcompound2.getKeySet())
                {
                    NBTBase nbtbase1 = nbttagcompound2.getTag(s1);
                    nbttagcompound1.setTag(s1, nbtbase1.copy());
                }

                entity1.readFromNBT(nbttagcompound1);
                entity1.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);

                if (entityIn.worldObj != null && spawn)
                {
                    entityIn.worldObj.spawnEntityInWorld(entity1);
                }

                entity.mountEntity(entity1);
            }

            entity = entity1;
        }
    }
    else if (entityIn instanceof EntityLivingBase && entityIn.worldObj != null && spawn)
    {
        if (entityIn instanceof EntityLiving)
        {
            ((EntityLiving)entityIn).onInitialSpawn(entityIn.worldObj.getDifficultyForLocation(new BlockPos(entityIn)), (IEntityLivingData)null);
        }

        entityIn.worldObj.spawnEntityInWorld(entityIn);
    }

    return entityIn;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:65,代码来源:MobSpawnerBaseLogic.java


注:本文中的net.minecraft.entity.Entity.writeToNBTOptional方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。