mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-07-28 16:33:02 +00:00
Theres documentation at https://sylvessa.zip/fourkit/ now. And a bunch of other changes. Check the discord server for a more comprehensive list
38 lines
1.4 KiB
Markdown
38 lines
1.4 KiB
Markdown
@page usage-of-all-events Usage of all Events
|
|
|
|
This will go over how to utilize each event that FourKit provides.
|
|
|
|
@section entitydamageevent EntityDamageEvent and EntityDamageByEntityEvent
|
|
|
|
\ref Minecraft.Server.FourKit.Event.Entity.EntityDamageEvent "EntityDamageEvent" and \ref Minecraft.Server.FourKit.Event.Entity.EntityDamageByEntityEvent "EntityDamageByEntityEvent" are fired when any entity is damaged.
|
|
|
|
When one of these events are fired, it passes an entity. It can be a Player, or any LivingEntity
|
|
|
|
You can check what type of entity it is with `getEntityType()`. This will return a \ref Minecraft.Server.FourKit.Entity.EntityType "EntityType" enum.
|
|
|
|
From there, you can cast the entity to the actual type (in this case \ref Minecraft.Server.FourKit.Entity.LivingEntity "LivingEntity"):
|
|
|
|
```csharp
|
|
[EventHandler]
|
|
public void entityDamage(EntityDamageEvent e)
|
|
{
|
|
LivingEntity entity = (LivingEntity)e.getEntity();
|
|
}
|
|
```
|
|
|
|
Or if its a player, you can even cast it to \ref Minecraft.Server.FourKit.Entity.Player "Player":
|
|
|
|
```csharp
|
|
[EventHandler]
|
|
public void entityDamage(EntityDamageEvent e)
|
|
{
|
|
if (e.getEntityType() == EntityType.PLAYER)
|
|
{
|
|
Player player = (Player)e.getEntity();
|
|
}
|
|
}
|
|
```
|
|
|
|
As of right now, this event is only fired for \ref Minecraft.Server.FourKit.Entity.LivingEntity "LivingEntity" and \ref Minecraft.Server.FourKit.Entity.Player "Player"s.
|
|
|
|
<h1>Page currently under construction</h1> |