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