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