當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityLivingBase.writeToNBT方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:18,代碼來源:MobImprisonmentToolItem.java

示例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);
}
 
開發者ID:SihenZhang,項目名稱:CursedLasso,代碼行數:29,代碼來源:ItemCursedLasso.java

示例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();
	 */
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:47,代碼來源:EntityStatue.java


注:本文中的net.minecraft.entity.EntityLivingBase.writeToNBT方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。