net.minecraft.util.EntityDamageSourceIndirect Java Examples
The following examples show how to use
net.minecraft.util.EntityDamageSourceIndirect.
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: EntityMonolithEye.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } if (!world.isRemote) { if (source instanceof EntityDamageSourceIndirect) { redirectArrowAtAttacker(source); } else { redirectAttack(source, amount); } } return false; }
Example #2
Source File: EntityMage.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } if (source instanceof EntityDamageSourceIndirect) { redirectArrowAtAttacker(source); return false; } else { amount = redirectAttack(source, amount); } return super.attackEntityFrom(source, amount); }
Example #3
Source File: EntityBas.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
public boolean attackEntityFrom(DamageSource source, float amount) { if (this.isEntityInvulnerable(source)) { return false; } if (source instanceof EntityDamageSourceIndirect) { attackDistantAttackerWithBats(source); } return super.attackEntityFrom(source, amount); }
Example #4
Source File: ItemSkinUpgrade.java From Cyberware with MIT License | 5 votes |
@SubscribeEvent public void handleHurt(LivingHurtEvent event) { EntityLivingBase e = event.getEntityLiving(); if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 1))) { if (event.getSource() instanceof EntityDamageSource && !(event.getSource() instanceof EntityDamageSourceIndirect)) { for (ItemStack stack : e.getArmorInventoryList()) { if (stack != null && stack.getItem() instanceof ItemArmor) { if (((ItemArmor) stack.getItem()).getArmorMaterial().getDamageReductionAmount(EntityEquipmentSlot.CHEST) > 4) { return; } } else if (stack != null && stack.getItem() instanceof ISpecialArmor) { if (((ISpecialArmor) stack.getItem()).getProperties(e, stack, event.getSource(), event.getAmount(), 1).AbsorbRatio * 25D > 4) { return; } } } Random random = e.getRNG(); Entity attacker = ((EntityDamageSource) event.getSource()).getSourceOfDamage(); int level = 2; if (EnchantmentThorns.shouldHit(3, random)) { if (attacker != null) { attacker.attackEntityFrom(DamageSource.causeThornsDamage(e), (float) EnchantmentThorns.getDamage(2, random)); } } } } }
Example #5
Source File: ServerEventHandler.java From Et-Futurum with The Unlicense | 5 votes |
@SubscribeEvent public void livingAttack(LivingAttackEvent event) { if (event.source instanceof EntityDamageSourceIndirect) { EntityDamageSourceIndirect dmgSrc = (EntityDamageSourceIndirect) event.source; if (dmgSrc.getSourceOfDamage() instanceof EntityTippedArrow) { EntityTippedArrow tippedArrow = (EntityTippedArrow) dmgSrc.getSourceOfDamage(); if (!tippedArrow.worldObj.isRemote) event.entityLiving.addPotionEffect(tippedArrow.getEffect()); } } }
Example #6
Source File: EntityMonolithEye.java From ToroQuest with GNU General Public License v3.0 | 4 votes |
private boolean hitByRangedAttack(DamageSource source) { return source instanceof EntityDamageSourceIndirect; }
Example #7
Source File: EntityToro.java From ToroQuest with GNU General Public License v3.0 | 4 votes |
protected boolean ignoreableAttack(DamageSource source) { return !this.isEntityInvulnerable(source) && !(source instanceof EntityDamageSourceIndirect); }
Example #8
Source File: ItemMuscleUpgrade.java From Cyberware with MIT License | 4 votes |
@SubscribeEvent public void handleHurt(LivingHurtEvent event) { EntityLivingBase e = event.getEntityLiving(); ItemStack test = new ItemStack(this, 1, 0); int rank = CyberwareAPI.getCyberwareRank(e, test); if (!event.isCanceled() && e instanceof EntityPlayer && (rank > 1) && EnableDisableHelper.isEnabled(CyberwareAPI.getCyberware(e, test)) && getLastBoostSpeed(e)) { EntityPlayer p = (EntityPlayer) e; if (event.getSource() instanceof EntityDamageSource && !(event.getSource() instanceof EntityDamageSourceIndirect)) { EntityDamageSource source = (EntityDamageSource) event.getSource(); Entity attacker = source.getEntity(); int lastAttacked = ReflectionHelper.getPrivateValue(CombatTracker.class, p.getCombatTracker(), 2); if (p.ticksExisted - lastAttacked > 120) { ItemStack weapon = p.getHeldItemMainhand(); int loc = -1; if (weapon != null) { if (p.getItemInUseCount() > 0 || weapon.getItem() instanceof ItemSword || weapon.getItem().getAttributeModifiers(EntityEquipmentSlot.MAINHAND, weapon).containsKey(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName())) { loc = p.inventory.currentItem; } } if (loc == -1) { double mostDamage = 0F; for (int i = 0; i < 10; i++) { if (i != p.inventory.currentItem) { ItemStack potentialWeapon = p.inventory.mainInventory[i]; if (potentialWeapon != null) { Multimap<String, AttributeModifier> modifiers = potentialWeapon.getItem().getAttributeModifiers(EntityEquipmentSlot.MAINHAND, potentialWeapon); if (modifiers.containsKey(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName())) { double damage = modifiers.get(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName()).iterator().next().getAmount(); if (damage > mostDamage || loc == -1) { mostDamage = damage; loc = i; } } } } } } if (loc != -1) { //System.out.println("LOC " + loc); p.inventory.currentItem = loc; CyberwarePacketHandler.INSTANCE.sendTo(new SwitchHeldItemAndRotationPacket(loc, p.getEntityId(), rank > 2 ? attacker.getEntityId() : -1), (EntityPlayerMP) p); WorldServer world = (WorldServer) p.worldObj; for (EntityPlayer trackingPlayer : world.getEntityTracker().getTrackingPlayers(p)) { CyberwarePacketHandler.INSTANCE.sendTo(new SwitchHeldItemAndRotationPacket(loc, p.getEntityId(), rank > 2 ? attacker.getEntityId() : -1), (EntityPlayerMP) trackingPlayer); } } } } } }
Example #9
Source File: EntityEnderminy.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
/** * Called when the entity is attacked. */ @Override public boolean attackEntityFrom(DamageSource damageSource, float p_70097_2_) { if(isEntityInvulnerable(damageSource)) { return false; } setScreaming(true); if(damageSource instanceof EntityDamageSourceIndirect) { isAggressive = false; for (int i = 0; i < 64; ++i) { if(teleportRandomly()) { return true; } } return super.attackEntityFrom(damageSource, p_70097_2_); } boolean res = super.attackEntityFrom(damageSource, p_70097_2_); if(damageSource instanceof EntityDamageSource && damageSource.getTrueSource() instanceof EntityPlayer && getHealth() > 0 //&& !ItemDarkSteelSword.isEquippedAndPowered((EntityPlayer) damageSource.getEntity(), 1)) { ) { isAggressive = true; if(rand.nextInt(3) == 0) { for (int i = 0; i < 64; ++i) { if(teleportRandomly(16)) { setAttackTarget((EntityPlayer) damageSource.getTrueSource()); doGroupArgo(); return true; } } } } if(res) { doGroupArgo(); } return res; }