mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-27 14:13:24 +02:00
Added entity in EntitySpawnEvent
This commit is contained in:
parent
c3b1e88b83
commit
3464d27ab1
@ -684,7 +684,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
|
||||
this.instance = instance;
|
||||
instance.addEntity(this);
|
||||
spawn();
|
||||
EntitySpawnEvent entitySpawnEvent = new EntitySpawnEvent(instance);
|
||||
EntitySpawnEvent entitySpawnEvent = new EntitySpawnEvent(this, instance);
|
||||
callEvent(EntitySpawnEvent.class, entitySpawnEvent);
|
||||
}
|
||||
|
||||
|
@ -583,7 +583,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
// This is the last chunk to be loaded , spawn player
|
||||
this.viewableEntities.forEach(entity -> entity.removeViewer(this));
|
||||
super.setInstance(instance);
|
||||
PlayerSpawnEvent spawnEvent = new PlayerSpawnEvent(instance, firstSpawn);
|
||||
PlayerSpawnEvent spawnEvent = new PlayerSpawnEvent(this, instance, firstSpawn);
|
||||
callEvent(PlayerSpawnEvent.class, spawnEvent);
|
||||
} else {
|
||||
// Increment the counter of current loaded chunks
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.instance.Instance;
|
||||
|
||||
@ -8,12 +9,23 @@ import net.minestom.server.instance.Instance;
|
||||
*/
|
||||
public class EntitySpawnEvent extends Event {
|
||||
|
||||
private Instance spawnInstance;
|
||||
private final Entity entity;
|
||||
private final Instance spawnInstance;
|
||||
|
||||
public EntitySpawnEvent(Instance spawnInstance) {
|
||||
public EntitySpawnEvent(Entity entity, Instance spawnInstance) {
|
||||
this.entity = entity;
|
||||
this.spawnInstance = spawnInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entity who spawned in the instance
|
||||
*
|
||||
* @return the entity
|
||||
*/
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entity new instance
|
||||
*
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.entity.EntitySpawnEvent;
|
||||
import net.minestom.server.instance.Instance;
|
||||
|
||||
@ -10,8 +11,8 @@ public class PlayerSpawnEvent extends EntitySpawnEvent {
|
||||
|
||||
private final boolean firstSpawn;
|
||||
|
||||
public PlayerSpawnEvent(Instance spawnInstance, boolean firstSpawn) {
|
||||
super(spawnInstance);
|
||||
public PlayerSpawnEvent(Entity entity, Instance spawnInstance, boolean firstSpawn) {
|
||||
super(entity, spawnInstance);
|
||||
this.firstSpawn = firstSpawn;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user