Java Code Examples for net.minecraft.entity.EntityLiving#attackEntityFrom()
The following examples show how to use
net.minecraft.entity.EntityLiving#attackEntityFrom() .
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: MoCTools.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
protected static int entityDespawnCheck(World worldObj, EntityLiving entityliving)//to keep a copy { int count = 0; EntityPlayer entityplayer = worldObj.getClosestPlayerToEntity(entityliving, -1D); if (entityplayer != null) //entityliving.canDespawn() && { double d = ((Entity) (entityplayer)).posX - entityliving.posX; double d1 = ((Entity) (entityplayer)).posY - entityliving.posY; double d2 = ((Entity) (entityplayer)).posZ - entityliving.posZ; double d3 = d * d + d1 * d1 + d2 * d2; if (d3 > 16384D) { entityliving.setDead(); count++; } if (entityliving.getAge() > 600 && worldObj.rand.nextInt(800) == 0) { if (d3 < 1024D) { //entityliving.entityAge = 0; //TODO test! entityliving.attackEntityFrom(DamageSource.causeMobDamage(null), 0); } else { entityliving.setDead(); count++; } } } return count; }
Example 2
Source File: UpgradeKilling.java From BetterChests with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void update(IUpgradableBlock chest, ItemStack stack) { if (UpgradeHelper.INSTANCE.getFrequencyTick(chest, stack, 100) != 0) { return; } AxisAlignedBB bb = new AxisAlignedBB(chest.getPosition()).grow(RADIUS); TObjectIntMap<Class<? extends EntityLiving>> map = new TObjectIntHashMap<>(); for (EntityLiving entity : chest.getWorldObj().getEntitiesWithinAABB(EntityLiving.class, bb)) { if (entity.isDead) { continue; } if (entity instanceof EntityAnimal) { EntityAnimal animal = (EntityAnimal) entity; if (entity.isChild()) { continue; } int currentAnimals = map.get(animal.getClass()); if (currentAnimals < ANIMALS_TO_KEEP_ALIVE) { map.put(animal.getClass(), currentAnimals + 1); continue; } } if (hasUpgradeOperationCost(chest)) { EntityPlayer source = null; if (chest.isUpgradeInstalled(DummyUpgradeType.AI.getStack())) { source = chest.getFakePlayer(); } entity.attackEntityFrom(getDamageSource(source), 10); drawUpgradeOperationCode(chest); } } }
Example 3
Source File: AbilityKnockback.java From HexxitGear with GNU General Public License v3.0 | 5 votes |
@Override public void start(EntityPlayer player) { List<EntityLiving> entities = player.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(player.posX - 5, player.posY, player.posZ - 5, player.posX + 5, player.posY + 3, player.posZ + 5)); for (EntityLiving entity : entities) { double relX = player.posX - entity.posX; double relZ = player.posZ - entity.posZ; if (!entity.equals(player)) { entity.attackEntityFrom(DamageSource.causePlayerDamage(player), 2); entity.addVelocity((relX * 0.25) * -1, 0.2, (relZ * 0.25) * -1); } } }