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