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


Java EntityItem.setNoDespawn方法代碼示例

本文整理匯總了Java中net.minecraft.entity.item.EntityItem.setNoDespawn方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityItem.setNoDespawn方法的具體用法?Java EntityItem.setNoDespawn怎麽用?Java EntityItem.setNoDespawn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.entity.item.EntityItem的用法示例。


在下文中一共展示了EntityItem.setNoDespawn方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: performEffect

import net.minecraft.entity.item.EntityItem; //導入方法依賴的package包/類
@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
	if (rtrace.typeOfHit == Type.ENTITY && rtrace.entityHit instanceof EntityLivingBase) {
		EntityLivingBase entity = (EntityLivingBase) rtrace.entityHit;
		EnumHand hand = null;
		if (!entity.getHeldItemMainhand().isEmpty()) hand = EnumHand.MAIN_HAND;
		else if (!entity.getHeldItemOffhand().isEmpty()) hand = EnumHand.OFF_HAND;
		if (hand != null) {
			ItemStack stack = entity.getHeldItem(hand).copy();
			entity.setHeldItem(hand, ItemStack.EMPTY);
			if (!(entity instanceof EntityPlayer) && stack.isItemStackDamageable() && stack.getItemDamage() == 0) {
				stack.setItemDamage((int) (stack.getMaxDamage() * (0.5D + 0.5D * Math.random())));
			}
			EntityItem ei = new EntityItem(world, entity.posX, entity.posY, entity.posZ, stack);
			ei.setPickupDelay(200);
			ei.setNoDespawn();
			if (!world.isRemote) world.spawnEntity(ei);
		}
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:21,代碼來源:SpellDisarming.java

示例2: dropFewItems

import net.minecraft.entity.item.EntityItem; //導入方法依賴的package包/類
/**
 * Drop 0-2 items of this living's type
 */
protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
{
    EntityItem entityitem = this.dropItem(Items.nether_star, 1);

    if (entityitem != null)
    {
        entityitem.setNoDespawn();
    }

    if (!this.worldObj.isRemote)
    {
        for (EntityPlayer entityplayer : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, this.getEntityBoundingBox().expand(50.0D, 100.0D, 50.0D)))
        {
            entityplayer.triggerAchievement(AchievementList.killWither);
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:21,代碼來源:EntityWither.java

示例3: dropFewItems

import net.minecraft.entity.item.EntityItem; //導入方法依賴的package包/類
/**
 * Drop 0-2 items of this living's type
 */
protected void dropFewItems(boolean wasRecentlyHit, int lootingModifier)
{
    EntityItem entityitem = this.dropItem(Items.NETHER_STAR, 1);

    if (entityitem != null)
    {
        entityitem.setNoDespawn();
    }

    if (!this.world.isRemote)
    {
        for (EntityPlayer entityplayer : this.world.getEntitiesWithinAABB(EntityPlayer.class, this.getEntityBoundingBox().expand(50.0D, 100.0D, 50.0D)))
        {
            entityplayer.addStat(AchievementList.KILL_WITHER);
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:21,代碼來源:EntityWither.java

示例4: dropFewItems

import net.minecraft.entity.item.EntityItem; //導入方法依賴的package包/類
/**
 * Drop 0-2 items of this living's type
 */
protected void dropFewItems(boolean wasRecentlyHit, int lootingModifier)
{
    EntityItem entityitem = this.dropItem(Items.NETHER_STAR, 1);

    if (entityitem != null)
    {
        entityitem.setNoDespawn();
    }

    if (!this.worldObj.isRemote)
    {
        for (EntityPlayer entityplayer : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, this.getEntityBoundingBox().expand(50.0D, 100.0D, 50.0D)))
        {
            entityplayer.addStat(AchievementList.KILL_WITHER);
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:21,代碼來源:EntityWither.java

示例5: onEntityItemUpdate

import net.minecraft.entity.item.EntityItem; //導入方法依賴的package包/類
@Override
public boolean onEntityItemUpdate(EntityItem entityItem) {
    if (!entityItem.world.isRemote) entityItem.setNoDespawn(); //age-- TODO 1.8 test
    return false;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:6,代碼來源:ItemNonDespawning.java


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