net.minecraftforge.event.entity.player.AttackEntityEvent Java Examples

The following examples show how to use net.minecraftforge.event.entity.player.AttackEntityEvent. 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: Events.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onAttack(AttackEntityEvent event) {
    if (!cheatEnabled) {
        return;
    }
    if (!(KillAura.isActive || MobAura.isActive || ProphuntAura.isActive || Forcefield.isActive || TriggerBot.isActive || !Criticals.isActive || Wrapper.INSTANCE.player().isInWater() || Wrapper.INSTANCE.player().isInsideOfMaterial(Material.lava) || Wrapper.INSTANCE.player().isInsideOfMaterial(Material.web) || !Wrapper.INSTANCE.player().onGround || !Wrapper.INSTANCE.mcSettings().keyBindAttack.getIsKeyPressed() || Wrapper.INSTANCE.mc().objectMouseOver == null || Wrapper.INSTANCE.mc().objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.ENTITY)) {
        event.setCanceled(true);
        Wrapper.INSTANCE.player().motionY = 0.1000000014901161;
        Wrapper.INSTANCE.player().fallDistance = 0.1f;
        Wrapper.INSTANCE.player().onGround = false;
        event.setCanceled(false);
    }
    if (event.target instanceof EntityPlayer) {
        EntityPlayer e = (EntityPlayer) event.target;
        if (SeeHealth.isActive) {
            InteropUtils.log("Health of &e" + e.getCommandSenderName() + "&f: &e" + e.getHealth(), "SeeHealth");
        }
    }
}
 
Example #2
Source File: ItemUnicornDagger.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public static void onAttackEntity(AttackEntityEvent event) {
	if (event.getTarget().canBeAttackedWithItem() && !event.getTarget().hitByEntity(event.getEntity()) && event.getTarget() instanceof EntityLivingBase && event.getTarget().hurtResistantTime <= 0) {
		EntityLivingBase attacker = event.getEntityLiving();
		EntityLivingBase target = (EntityLivingBase) event.getTarget();

		if (attacker.getHeldItemMainhand() == ItemStack.EMPTY)
			return;
		if (attacker.getHeldItemMainhand().getItem() != ModItems.UNICORN_DAGGER)
			return;

		float damage = 1 + EnchantmentHelper.getEnchantmentLevel(Enchantments.KNOCKBACK, attacker.getHeldItemMainhand());
		float attackCD = attacker instanceof EntityPlayer ? ((EntityPlayer) attacker).getCooledAttackStrength(0.5F) : 1;
		damage *= (0.2f + attackCD * attackCD * 0.8f);

		target.attackEntityFrom(DamageSource.causeIndirectMagicDamage(attacker, null), damage);
		target.hurtResistantTime = 0;
	}
}
 
Example #3
Source File: PlayerListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onAttack(AttackEntityEvent e) {
    if (e.target instanceof EntityEnderman) {
        if (isZealot(e.target)) {
            countedEndermen.add(e.target.getUniqueID());
        }
    }
}
 
Example #4
Source File: PotionFire.java    From Sakura_mod with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onAttacking(AttackEntityEvent event) {
	if(event.getTarget() instanceof EntityLivingBase){
		EntityLivingBase target = (EntityLivingBase) event.getTarget();
		EntityPlayer player = event.getEntityPlayer();
		if(player.isPotionActive(this)){
			target.setFire(600);
		}
	}
}
 
Example #5
Source File: PotionAttackPotion.java    From Sakura_mod with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onAttacking(AttackEntityEvent event) {
	if(event.getTarget() instanceof EntityLivingBase){
		EntityLivingBase target = (EntityLivingBase) event.getTarget();
		EntityPlayer player = event.getEntityPlayer();
		if(player.isPotionActive(this)){
			target.addPotionEffect(new PotionEffect(potion,lvl*300, lvl));
		}
	}
}
 
Example #6
Source File: EntityEvents.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static boolean attackEntity(PlayerEntity player, Entity target) {
	if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(player, target))) {
		return false;
	}

	ItemStack stack = player.getMainHandStack();

	if (stack.isEmpty()) {
		return true;
	}

	IForgeItem item = (IForgeItem) stack.getItem();

	return !item.onLeftClickEntity(stack, player, target);
}
 
Example #7
Source File: TorchFireEventHandling.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent ev)
{
    if (!ConfigManager.SERVER.enableTorchFire.get())
        return;

    if (!ev.getTarget().func_230279_az_() && !ev.getTarget().world.isRemote)
    {
        PlayerEntity player = ev.getPlayer();
        ItemStack stack = player.getHeldItem(Hand.MAIN_HAND);
        if (stack.getCount() > 0 && stack.getItem() instanceof BlockItem)
        {
            BlockItem b = (BlockItem) stack.getItem();
            Block bl = b.getBlock();
            if (bl == Blocks.TORCH)
            {
                ev.getTarget().setFire(2);
                if (!ev.getPlayer().isCreative() && rnd.nextFloat() > 0.25)
                {
                    stack.grow(-1);
                    if (stack.getCount() <= 0)
                    {
                        player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
                    }
                }
            }
        }
    }
}
 
Example #8
Source File: IntegrationThaumicHorizions.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(AttackEntityEvent e) {
    EntityPlayer player = e.entityPlayer;
    if(!e.target.worldObj.isRemote && e.target instanceof EntityGolemTH
            && player.isSneaking()) {
        e.setCanceled(true);

        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null && stack.getItem().onLeftClickEntity(stack, player, e.target)
                && e.target.isDead) {
            CommonProxy.EVENT_HANDLER_GOLEM.on(new PlaySoundAtEntityEvent(e.target, "thaumcraft:zap", 0.5f, 1.0f));
        }
    }
}
 
Example #9
Source File: EventHandlerGolem.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(AttackEntityEvent event) {
    ItemStack heldItem = event.entityPlayer.getHeldItem();
    if(heldItem != null && heldItem.getItem() == ConfigItems.itemGolemBell && event.target instanceof EntityGolemBase
            && !event.target.worldObj.isRemote && !event.target.isDead) {
        event.target.captureDrops = true;
        markedGolems.put((EntityGolemBase) event.target, event.entityPlayer);
    }
}
 
Example #10
Source File: PlayerAttackSensor.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int emitRedstoneOnEvent(PlayerEvent event, TileEntity sensor, int range){
    if(event instanceof AttackEntityEvent) {
        return 15;
    }
    return 0;
}
 
Example #11
Source File: PlayerComboTracker.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent ev)
{
}
 
Example #12
Source File: EventHandlerUniversalSensor.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onPlayerAttack(AttackEntityEvent event){
    sendEventToSensors(event.entity.worldObj, event);
}