本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.writeToNBT方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.writeToNBT方法的具体用法?Java EntityLivingBase.writeToNBT怎么用?Java EntityLivingBase.writeToNBT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.writeToNBT方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: itemInteractionForEntity
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand) {
if (target.getEntityWorld().isRemote) return false;
if (target instanceof EntityPlayer || !target.isNonBoss()) return false;
if (containsEntity(stack)) return false;
String entityID = EntityList.getKey(target).toString();
if (isBlacklisted(entityID)) return false;
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("entity", entityID);
nbt.setInteger("id", EntityList.getID(target.getClass()));
target.writeToNBT(nbt);
stack.setTagCompound(nbt);
playerIn.swingArm(hand);
playerIn.setHeldItem(hand, stack);
target.setDead();
return true;
}
示例2: itemInteractionForEntity
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack item, EntityPlayer player, EntityLivingBase entity) {
if (entity.worldObj.isRemote) {
return false;
}
if (entity instanceof IMob) {
if (item.hasTagCompound())
return false;
item.setTagCompound(new NBTTagCompound());
NBTTagCompound mainTag = new NBTTagCompound();
NBTTagCompound entityTag = new NBTTagCompound();
entity.writeToNBT(entityTag);
mainTag.setFloat("health",entity.getHealth());
mainTag.setTag("data", entityTag);
mainTag.setString("id", EntityList.getEntityString(entity));
if (entity instanceof EntitySlime) {
mainTag.setInteger("slimesize", ((EntitySlime) entity).getSlimeSize());
}
if(entity instanceof EntityZombie){
mainTag.setBoolean("isBabyZombie",entity.isChild());
}
item.getTagCompound().setTag("entity",mainTag);
player.setCurrentItemOrArmor(0, item);
entity.setDead();
return true;
}
return super.itemInteractionForEntity(item, player, entity);
}
示例3: EntityStatue
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public EntityStatue(World worldIn, EntityLivingBase toCopy, boolean isFeign) {
super(worldIn);
this.setPosition(toCopy.posX, toCopy.posY, toCopy.posZ);
this.width = toCopy.width;
this.height = toCopy.height;
this.entity = toCopy;
if(!this.world.isRemote) {
if(toCopy instanceof EntityPlayer) {
this.data = toCopy.writeToNBT(new NBTTagCompound());
this.player = true;
this.profile = ((EntityPlayer) toCopy).getGameProfile();
}
else {
this.data= toCopy.serializeNBT();
}
this.first = true;
this.ticksLeft = toCopy instanceof EntityPlayer ? -1 : 5200;
this.useHand = toCopy.hasCapability(TF2weapons.WEAPONS_CAP, null) && ((WeaponsCapability.get(toCopy).state & 3) != 0 || WeaponsCapability.get(toCopy).isCharging());
}
else
this.clientOnly = true;
//this.data = this.entity.serializeNBT();
this.isFeign = isFeign;
if(!isFeign) {
this.entity.deathTime = 0;
this.entity.hurtTime = 0;
this.renderYawOffset = toCopy.renderYawOffset;
this.prevRotationYaw = this.entity.prevRotationYaw;
this.rotationYaw = this.entity.rotationYaw;
}
else {
/*this.motionX=entity.motionX;
this.motionY=entity.motionY;
this.motionZ=entity.motionZ;*/
}
/*
* this.renderYawOffset=toCopy.renderYawOffset;
* this.rotationYawHead=toCopy.rotationYawHead;
* this.rotationYaw=toCopy.rotationYaw;
* this.rotationPitch=toCopy.rotationPitch;
* this.limbSwingAmount=toCopy.limbSwingAmount;
* this.limbSwing=toCopy.limbSwing;
* this.entityClass=toCopy.getClass().getName();
* this.data=toCopy.getDataManager();
*/
}