本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.setDead方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.setDead方法的具体用法?Java EntityLivingBase.setDead怎么用?Java EntityLivingBase.setDead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.setDead方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onHitEntity
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void onHitEntity(LivingHurtEvent event) {
if (event.getAmount() <= 0 || event.getEntityLiving() instanceof EntityPlayer) return;
if (!(event.getSource().getSourceOfDamage() instanceof EntityPlayer)) return;
ItemStack transformer = BaublesApi.getBaublesHandler((EntityPlayer)event.getSource().getSourceOfDamage()).getStackInSlot(6);
if (transformer == null || (transformer != null && transformer.getItem() != this)) return;
Random rand = new Random();
if (rand.nextInt(100) != 0) return;
EntityLivingBase elb = event.getEntityLiving();
List<String> entities = new ArrayList<String>(EntityList.ENTITY_EGGS.keySet());
String randomString = entities.get(rand.nextInt(entities.size()));
Entity entity = EntityList.createEntityByName(randomString, elb.worldObj);
if (!entity.isNonBoss()) return;
entity.setPositionAndRotation(elb.posX, elb.posY, elb.posZ, elb.rotationYaw, elb.rotationPitch);
elb.worldObj.spawnEntityInWorld(entity);
elb.setDead();
}
示例3: 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);
}
示例4: arrowHit
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
protected void arrowHit(EntityLivingBase living)
{
living.setDead();
}
示例5: apply
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void apply(World world, BlockPos pos, EntityLivingBase entity, int amplifier, int tick) {
if (entity instanceof EntityMooshroom) {
EntityCow cow = new EntityCow(world);
cow.setPosition(pos.getX(), pos.getY(), pos.getZ());
entity.setDead();
world.spawnEntity(cow);
}
}
示例6: apply
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void apply(World world, BlockPos pos, EntityLivingBase entity, int amplifier, int tick) {
if (entity instanceof EntityCow & !(entity instanceof EntityMooshroom)) {
EntityMooshroom mooshroom = new EntityMooshroom(world);
mooshroom.setPosition(pos.getX(), pos.getY(), pos.getZ());
entity.setDead();
world.spawnEntity(mooshroom);
}
}
示例7: hitEntity
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
if(!(attacker instanceof EntityPlayer) || !((EntityPlayer)attacker).isCreative()) return super.hitEntity(stack, target, attacker);
target.setDead(); // bypasses all invulerabilities
return true; // bypass the damaging mechanic
}