Player Attacks Entity event (Feature Request) + Solution for now

Started by RexCerv on

Topic category: Feature requests and ideas for MCreator

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Player Attacks Entity event (Feature Request) + Solution for now
Tue, 01/25/2022 - 02:49 (edited)

Hello! I was messing around with mcreator just for fun and noticed there's not a Player Attacks Entity event. This event is saved on  

  • net.minecraftforge.event.entity.living.LivingEvent
  •     net.minecraftforge.event.entity.player.PlayerEvent
  •         net.minecraftforge.event.entity.player.AttackEntityEvent

and its name is 

AttackEntityEvent

Why add it? Well it will simplify the process of using the On Entity Attacked event with the if statement for checking if source entity is player, or Let's say you want to cancel the attack of a player, you could cancel the event EntityAttacked, yes. But this will still cause the red overlay appear on the entity.

Now for how to use it:

on the blocky editor place an entity trigger like Entity Attacked

on your procedure import this: 

import net.minecraftforge.event.entity.player.AttackEntityEvent;

and replace the 

onEntityAttacked(LivingAttackEvent event)

on the first line of code with 

onAttackedEntity(AttackEntityEvent event)

its that easy.

Edited by RexCerv on Tue, 01/25/2022 - 02:49