當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。