本文整理汇总了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;
}