Java Code Examples for net.minecraft.entity.Entity#attackEntityFrom()
The following examples show how to use
net.minecraft.entity.Entity#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 | 6 votes |
public static void buckleMobs(EntityLiving entityattacker, Double dist, World worldObj) { List list = worldObj.getEntitiesWithinAABBExcludingEntity(entityattacker, entityattacker.boundingBox.expand(dist, 2D, dist)); for (int i = 0; i < list.size(); i++) { Entity entitytarget = (Entity) list.get(i); if (!(entitytarget instanceof EntityLiving) || (entityattacker.riddenByEntity != null && entitytarget == entityattacker.riddenByEntity)) { continue; } //EntityMob entitymob = (EntityMob) entity; entitytarget.attackEntityFrom(DamageSource.causeMobDamage(entityattacker), 2); bigsmack(entityattacker, entitytarget, 0.6F); playCustomSound(entityattacker, "tud", worldObj); //todo tuck sound!! } }
Example 2
Source File: MoCEntityCrocodile.java From mocreaturesdev with GNU General Public License v3.0 | 6 votes |
@Override protected void attackEntity(Entity entity, float f) { if (getHasCaughtPrey()) { return; } if (attackTime <= 0 && (f < 3F) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY)) { attackTime = 20; if (entity.ridingEntity == null && rand.nextInt(3) == 0) { entity.mountEntity(this); setHasCaughtPrey(true); } else { entity.attackEntityFrom(DamageSource.causeMobDamage(this), 2); if (!(entity instanceof EntityPlayer)) { MoCTools.destroyDrops(this, 3D); } crocBite(); setHasCaughtPrey(false); } } }
Example 3
Source File: EntityDabSquirrel.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void fall(float distance, float damageMultiplier) { if (distance > 1.0F) { this.playSound(SoundEvents.ENTITY_HORSE_LAND, 0.4F, 1.0F); } int i = MathHelper.ceil((distance * 0.5F - 3.0F) * damageMultiplier); if (i > 0) { this.attackEntityFrom(DamageSource.FALL, i); if (this.isBeingRidden()) { for (Entity entity : this.getRecursivePassengers()) { entity.attackEntityFrom(DamageSource.FALL, i); } } BlockPos pos = new BlockPos(this.posX, this.posY - 0.2D - this.prevRotationYaw, this.posZ); IBlockState iblockstate = this.world.getBlockState(pos); Block block = iblockstate.getBlock(); if (iblockstate.getMaterial() != Material.AIR && !this.isSilent()) { SoundType soundtype = block.getSoundType(block.getDefaultState(), this.world, pos, this); this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, soundtype.getStepSound(), this.getSoundCategory(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F); } } }
Example 4
Source File: EntityFallingBlockEU.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public void fall(float distance, float damageMultiplier) { Block block = this.blockState.getBlock(); if (this.hurtEntities) { int i = MathHelper.ceil(distance - 1.0F); if (i > 0) { boolean isAnvil = block == Blocks.ANVIL; List<Entity> list = Lists.newArrayList(this.getEntityWorld().getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox())); DamageSource damageSource = isAnvil ? DamageSource.ANVIL : DamageSource.FALLING_BLOCK; for (Entity entity : list) { entity.attackEntityFrom(damageSource, Math.min(MathHelper.floor(i * this.fallHurtAmount), this.fallHurtMax)); } if (isAnvil && this.rand.nextFloat() < 0.05D + i * 0.05D) { int j = this.blockState.getValue(BlockAnvil.DAMAGE).intValue() + 1; if (j > 2) { this.canSetAsBlock = false; } else { this.blockState = this.blockState.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(j)); } } } } }
Example 5
Source File: MoCEntityBoar.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@Override protected void attackEntity(Entity entity, float f) { if (attackTime <= 0 && (f < 2.5D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY)) { attackTime = 20; entity.attackEntityFrom(DamageSource.causeMobDamage(this), force); if (!(entity instanceof EntityPlayer)) { MoCTools.destroyDrops(this, 3D); } } }
Example 6
Source File: BlockCrusherBlade.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { if (state.getValue(ACTIVE)) { entityIn.attackEntityFrom(DamageSources.getCrusherDamage(), 5.0f); entityIn.motionY *= 0.04; } }
Example 7
Source File: MoCEntityBee.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@Override protected void attackEntity(Entity entity, float f) { if (this.attackTime <= 0 && (f < 2.0D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY)) { attackTime = 20; entity.attackEntityFrom(DamageSource.causeMobDamage(this), 2); } }
Example 8
Source File: BlockSpikes.java From Artifacts with MIT License | 5 votes |
@Override public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if(entity instanceof EntityLivingBase) { entity.attackEntityFrom(DamageSource.generic, 2); entity.motionX *= 0.7D; entity.motionZ *= 0.7D; TileEntity te = world.getTileEntity(x, y, z); if(te != null && te instanceof TileEntitySpikes) { ((TileEntitySpikes)te).setBloody(2); } } }
Example 9
Source File: MoCEntityElephant.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@Override protected void attackEntity(Entity entity, float f) { if (this.attackTime <= 0 && (f < 2D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY)) { attackTime = 20; entity.attackEntityFrom(DamageSource.causeMobDamage(this), 4); } }
Example 10
Source File: EntityClayGolem.java From Artifacts with MIT License | 5 votes |
public boolean attackEntityAsMob(Entity par1Entity) { this.attackTimer = 10; this.worldObj.setEntityState(this, (byte)4); boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), 7); if (flag) { par1Entity.motionY += 0.4000000059604645D; } this.playSound("mob.irongolem.throw", 1.0F, 1.0F); return flag; }
Example 11
Source File: MoCEntityFlyerMob.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@Override protected void attackEntity(Entity entity, float f) { if (attackTime <= 0 && (f < 2.5D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY)) { attackTime = 20; entity.attackEntityFrom(DamageSource.causeMobDamage(this), attackStrength); } }
Example 12
Source File: EntityMage.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
protected float redirectAttack(DamageSource source, float amount) { float reflectFactor = rand.nextFloat(); float reflectAmount = amount * reflectFactor; float passAmount = amount - reflectAmount; reflectAmount *= ToroQuestConfiguration.bossAttackDamageMultiplier; Entity attacker = source.getTrueSource(); if (attacker != null) { attacker.attackEntityFrom(source, reflectAmount); } this.world.setEntityState(this, (byte) 15); return passAmount; }
Example 13
Source File: MoCEntityFishy.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@Override protected void attackEntity(Entity entity, float f) { if (attackTime <= 0 && (f < 2D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY)) { if (entity.isInWater() || (entity instanceof EntityPlayer && ((EntityPlayer)entity).ridingEntity == null)) { attackTime = 20; entity.attackEntityFrom(DamageSource.causeMobDamage(this), 1); } } }
Example 14
Source File: EntityBear.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public boolean attackEntityAsMob (Entity par1Entity) { int dam = 5; return par1Entity.attackEntityFrom (DamageSource.causeMobDamage (this), dam); }
Example 15
Source File: MoCEntityPetScorpion.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
@Override protected void attackEntity(Entity entity, float f) { if ((f > 2.0F) && (f < 6F) && (rand.nextInt(50) == 0)) { if (onGround) { double d = entity.posX - posX; double d1 = entity.posZ - posZ; float f1 = MathHelper.sqrt_double((d * d) + (d1 * d1)); motionX = ((d / f1) * 0.5D * 0.8D) + (motionX * 0.2D); motionZ = ((d1 / f1) * 0.5D * 0.8D) + (motionZ * 0.2D); motionY = 0.4D; } } else if (attackTime <= 0 && (f < 3.0D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY)) { attackTime = 20; boolean flag = (entity instanceof EntityPlayer); if (!getIsPoisoning() && rand.nextInt(5) == 0) { setPoisoning(true); if (getType() <= 2)// regular scorpions { if (flag) { MoCreatures.poisonPlayer((EntityPlayer) entity); } ((EntityLiving) entity).addPotionEffect(new PotionEffect(Potion.poison.id, 70, 0)); } else if (getType() == 4)// blue scorpions { if (flag) { MoCreatures.freezePlayer((EntityPlayer) entity); } ((EntityLiving) entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 70, 0)); } else if (getType() == 3)// red scorpions { if (flag && MoCreatures.isServer() && !worldObj.provider.isHellWorld) { MoCreatures.burnPlayer((EntityPlayer) entity); ((EntityLiving) entity).setFire(15); } } } else { entity.attackEntityFrom(DamageSource.causeMobDamage(this), 1); swingArm(); } } }
Example 16
Source File: MoCEntitySnake.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
@Override protected void attackEntity(Entity entity, float f) { if ((getType() < 3 || getIsTamed()) && entity instanceof EntityPlayer) { entityToAttack = null; return; } // attack only after hissing/rattling! if (!isPissed()) { return; } if (attackTime <= 0 && (f < 2.5D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY)) // if((f < 2.5D) && (entity.boundingBox.maxY > boundingBox.minY) && // (entity.boundingBox.minY < boundingBox.maxY)) { /* * if (attackTime == 5)//<5 && attackTime >0) { //start biting * setBiting(true); } else if (attackTime <=0) */ { setBiting(true); attackTime = 20; // venom! if (rand.nextInt(2) == 0 && entity instanceof EntityPlayer && getType() > 2 && getType() < 8) { MoCreatures.poisonPlayer((EntityPlayer) entity); ((EntityPlayer) entity).addPotionEffect(new PotionEffect(Potion.poison.id, 120, 0)); } entity.attackEntityFrom(DamageSource.causeMobDamage(this), 2); if (!(entity instanceof EntityPlayer)) { MoCTools.destroyDrops(this, 3D); } } } }
Example 17
Source File: BlockFirepit.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public void onEntityCollidedWithBlock(World worldObj, BlockPos pos, IBlockState state, Entity entityIn) { if(state.getValue(LIT)) entityIn.attackEntityFrom(DamageSource.IN_FIRE, 0.25F); }
Example 18
Source File: ItemKatana.java From Sakura_mod with MIT License | 4 votes |
@Override public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.SWEEPING, stack); if (k > 0) { //big sweep!!! entityLiving.swingArm(entityLiving.getActiveHand()); float f = (float) entityLiving.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue(); f += EnchantmentHelper.getModifierForCreature(stack, entityLiving.getCreatureAttribute()) / 1.2F; float f3 = 2.0F + EnchantmentHelper.getSweepingDamageRatio(entityLiving) * f; float sweepingRatio = EnchantmentHelper.getSweepingDamageRatio(entityLiving); for (Entity entitylivingbase : worldIn.getEntitiesWithinAABB(Entity.class, entityLiving.getEntityBoundingBox().grow(1.4D + sweepingRatio * 1.2D, 0.3D + sweepingRatio * 0.15D, 1.4D + sweepingRatio * 1.2D))) { if (entitylivingbase != entityLiving && !entityLiving.isOnSameTeam(entitylivingbase)) { if (entitylivingbase instanceof EntityLivingBase) { if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isActiveItemStackBlocking()) { //disable shield ((EntityPlayer) entitylivingbase).disableShield(false); } ((EntityLivingBase) entitylivingbase).knockBack(entityLiving, 0.4F + 0.4F * EnchantmentHelper.getSweepingDamageRatio(entityLiving), MathHelper.sin(entityLiving.rotationYaw * 0.017453292F), (-MathHelper.cos(entityLiving.rotationYaw * 0.017453292F))); entitylivingbase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) entityLiving), f3); } if (entitylivingbase instanceof MultiPartEntityPart) { entitylivingbase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) entityLiving), f3); } } } worldIn.playSound(null, entityLiving.posX, entityLiving.posY, entityLiving.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, entityLiving.getSoundCategory(), 1.0F, 1.0F); if (worldIn instanceof WorldServer) { double d0 = (-MathHelper.sin(entityLiving.rotationYaw * 0.017453292F)); double d1 = MathHelper.cos(entityLiving.rotationYaw * 0.017453292F); ((WorldServer) worldIn).spawnParticle(EnumParticleTypes.SWEEP_ATTACK, entityLiving.posX + d0, entityLiving.posY + entityLiving.height * 0.5D, entityLiving.posZ + d1, 0, d0, 0.0D, d1, 0.0D); } stack.damageItem(2, entityLiving); ((EntityPlayer) entityLiving).getCooldownTracker().setCooldown(this, 25); } }
Example 19
Source File: EntityLion.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public boolean attackEntityAsMob (Entity par1Entity) { int dam = 100; return par1Entity.attackEntityFrom (DamageSource.causeMobDamage (this), dam); }
Example 20
Source File: EntityTiger.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public boolean attackEntityAsMob (Entity par1Entity) { int dam = 100; return par1Entity.attackEntityFrom (DamageSource.causeMobDamage (this), dam); }