Java Code Examples for net.minecraft.entity.EntityLivingBase#isEntityAlive()
The following examples show how to use
net.minecraft.entity.EntityLivingBase#isEntityAlive() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityAIMountedAttackOnCollide.java From EnderZoo with Creative Commons Zero v1.0 Universal | 6 votes |
/** * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { EntityLivingBase entitylivingbase = attacker.getAttackTarget(); if(entitylivingbase == null) { return false; } else if(!entitylivingbase.isEntityAlive()) { return false; } else if(this.classTarget != null && !classTarget.isAssignableFrom(entitylivingbase.getClass())) { return false; } else { if(--pathUpdateTimer <= 0) { entityPathEntity = getNavigator().getPathToEntityLiving(entitylivingbase); pathUpdateTimer = 4 + attacker.getRNG().nextInt(7); return entityPathEntity != null; } else { return true; } } }
Example 2
Source File: EntityAIFlyingAttackOnCollide.java From EnderZoo with Creative Commons Zero v1.0 Universal | 6 votes |
@Override public boolean shouldExecute() { EntityLivingBase entitylivingbase = attacker.getAttackTarget(); if (entitylivingbase == null) { return false; } else if (!entitylivingbase.isEntityAlive()) { return false; } else if (classTarget != null && !classTarget.isAssignableFrom(entitylivingbase.getClass())) { return false; } if (canPenalize) { if (--delayCounter <= 0) { setPathTo(entitylivingbase); targetX = 4 + attacker.getRNG().nextInt(7); return entityPathEntity != null; } else { return true; } } setPathTo(entitylivingbase); return this.entityPathEntity != null; }
Example 3
Source File: EntityAIAttackOnCollideAggressive.java From EnderZoo with Creative Commons Zero v1.0 Universal | 6 votes |
/** * Returns whether the EntityAIBase should begin execution. */ @Override public boolean shouldExecute() { EntityLivingBase entitylivingbase = attacker.getAttackTarget(); if (entitylivingbase == null) { return false; } else if (!entitylivingbase.isEntityAlive()) { return false; } else if (classTarget != null && !classTarget.isAssignableFrom(entitylivingbase.getClass())) { return false; } else { if (--ticksUntilNextPathingAttempt <= 0) { entityPathEntity = attacker.getNavigator().getPathToEntityLiving(entitylivingbase); ticksUntilNextPathingAttempt = 4 + attacker.getRNG().nextInt(7); return entityPathEntity != null; } else { return true; } } }
Example 4
Source File: ModelTofuGandlem.java From TofuCraftReload with MIT License | 5 votes |
@Override public void setLivingAnimations(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks) { float tick = entity.ticksExisted + partialTicks; float f = ((EntityTofuGandlem) entity).getDeadAnimationScale(tick); f = f * f; if (entity.isEntityAlive()) { GlStateManager.translate(0F, (-0.2F - MathHelper.sin(tick * 0.12F) * 0.1F) * f, 0F); } }
Example 5
Source File: EntityAIUnicornCharge.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean shouldContinueExecuting() { EntityLivingBase target = this.unicorn.getAttackTarget(); if (target == null || !target.isEntityAlive() || unicorn.getDistance(target) >= maxRange * 1.5) return false; if (target instanceof EntityPlayer && (((EntityPlayer) target).capabilities.isCreativeMode || ((EntityPlayer) target).isSpectator())) return false; return !targetHit; }
Example 6
Source File: ModToolLeveling.java From TinkersToolLeveling with MIT License | 5 votes |
@Override public void afterHit(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damageDealt, boolean wasCritical, boolean wasHit) { if(!target.getEntityWorld().isRemote && wasHit && player instanceof EntityPlayer) { // if we killed it the event for distributing xp was already fired and we just do it manually here EntityPlayer entityPlayer = (EntityPlayer) player; if(!target.isEntityAlive()) { addXp(tool, Math.round(damageDealt), entityPlayer); } else if(target.hasCapability(CapabilityDamageXp.CAPABILITY, null)) { target.getCapability(CapabilityDamageXp.CAPABILITY, null).addDamageFromTool(damageDealt, tool, entityPlayer); } } }
Example 7
Source File: TileExtendedNode.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
private boolean handleGrowingNodeSecond(boolean needUpdate) { if(extendedNodeType == null || extendedNodeType != ExtendedNodeType.GROWING) return needUpdate; if(worldObj.difficultySetting == EnumDifficulty.PEACEFUL) return needUpdate; if(worldObj.isRemote) return needUpdate; if(ticksExisted % 8 != 0) return needUpdate; List livingEntities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(6.0D, 6.0D, 6.0D)); if ((livingEntities != null) && (livingEntities.size() > 0)) { for (Object e : livingEntities) { EntityLivingBase livingEntity = (EntityLivingBase) e; if ((livingEntity.isEntityAlive()) && (!livingEntity.isEntityInvulnerable())) { if(livingEntity instanceof EntityPlayer && ((EntityPlayer) livingEntity).capabilities.isCreativeMode) continue; if(!behavior.mayZapNow()) continue; ResearchHelper.distributeResearch(Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION", worldObj, xCoord, yCoord, zCoord, 6); livingEntity.attackEntityFrom(DamageSource.magic, behavior.getZapDamage()); worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "thaumcraft:zap", 0.8F, 1.0F); PacketTCNodeBolt packet = new PacketTCNodeBolt(xCoord + 0.5F, yCoord + 0.5F, zCoord + 0.5F, (float) livingEntity.posX, (float) (livingEntity.posY + livingEntity.height), (float) livingEntity.posZ, 0, false); PacketHandler.INSTANCE.sendToAllAround(packet, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 32.0D)); } } } return needUpdate; }
Example 8
Source File: EntityEndermanFighter.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean shouldExecute() { if (this.fighter.hasCustomName() || this.fighter.isBeingControlled() != this.shouldBeControlled) { return false; } EntityLivingBase target = this.getTarget(); return target != null && target.isEntityAlive(); }
Example 9
Source File: BackpackHelper.java From WearableBackpacks with MIT License | 5 votes |
/** Checks if a player can open an entity's equipped backpack. * Returns if the player stands close enough to and behind the carrier. * Always returns true if player and carrier are the same entity. */ public static boolean canInteractWithEquippedBackpack(EntityPlayer player, EntityLivingBase carrier) { IBackpack backpack = getBackpack(carrier); if ((backpack == null) || !player.isEntityAlive() || !carrier.isEntityAlive()) return false; if (player == carrier) return true; double distance = player.getDistance(carrier); // Calculate angle between player and carrier. double angle = Math.toDegrees(Math.atan2(carrier.posZ - player.posZ, carrier.posX - player.posX)); // Calculate difference between angle and the direction the carrier entity is looking. angle = ((angle - carrier.renderYawOffset - 90) % 360 + 540) % 360 - 180; return ((distance <= INTERACT_MAX_DISTANCE) && (Math.abs(angle) < INTERACT_MAX_ANGLE / 2)); }
Example 10
Source File: EntityAIFlyingAttackOnCollide.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
@Override public boolean shouldContinueExecuting() { EntityLivingBase target = attacker.getAttackTarget(); if(target == null || !target.isEntityAlive()) { return false; } return !longMemory ? !attacker.getNavigator().noPath() : attacker.isWithinHomeDistanceFromPosition(new BlockPos(target)); }
Example 11
Source File: EntityAIAttackOnCollideAggressive.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
/** * Returns whether an in-progress EntityAIBase should continue executing */ @Override public boolean shouldContinueExecuting() { EntityLivingBase entitylivingbase = attacker.getAttackTarget(); return entitylivingbase == null ? false : (!entitylivingbase.isEntityAlive() ? false : (!longMemory ? !attacker.getNavigator().noPath() : attacker .isWithinHomeDistanceCurrentPosition())); }
Example 12
Source File: EntityAIFollowOwner.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
@Override public boolean shouldContinueExecuting() { EntityLivingBase owner = owned.getOwner(); if (owner == null || !owner.isEntityAlive()) { return false; } return !owned.asEntity().getNavigator().noPath(); }
Example 13
Source File: ItemPneumaticWrench.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean itemInteractionForEntity(ItemStack iStack, EntityPlayer player, EntityLivingBase entity){ if(!player.worldObj.isRemote) { if(entity.isEntityAlive() && entity instanceof IPneumaticWrenchable && ((ItemPneumaticWrench)Itemss.pneumaticWrench).getPressure(iStack) > 0) { if(((IPneumaticWrenchable)entity).rotateBlock(entity.worldObj, player, 0, 0, 0, ForgeDirection.UNKNOWN)) { if(!player.capabilities.isCreativeMode) ((ItemPneumaticWrench)Itemss.pneumaticWrench).addAir(iStack, -PneumaticValues.USAGE_PNEUMATIC_WRENCH); NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.PNEUMATIC_WRENCH, entity.posX, entity.posY, entity.posZ, 1.0F, 1.0F, false), entity.worldObj); return true; } } } return false; }
Example 14
Source File: EntityAIUnicornCharge.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean shouldExecute() { EntityLivingBase target = this.unicorn.getAttackTarget(); if (target == null || !target.isEntityAlive()) return false; return !(target.getDistance(unicorn) > maxRange); }
Example 15
Source File: EntityMonolithEye.java From ToroQuest with GNU General Public License v3.0 | 4 votes |
/** * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { EntityLivingBase entitylivingbase = this.theEntity.getAttackTarget(); return entitylivingbase != null && entitylivingbase.isEntityAlive(); }
Example 16
Source File: EntityAIMountedAttackOnCollide.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
/** * Returns whether an in-progress EntityAIBase should continue executing */ public boolean continueExecuting() { EntityLivingBase entitylivingbase = attacker.getAttackTarget(); return entitylivingbase == null ? false : (!entitylivingbase.isEntityAlive() ? false : (!longMemory ? !getNavigator().noPath() : attacker.isWithinHomeDistanceCurrentPosition())); }