Added Bedwars
Added ConfigurationHandler for games Further progress
This commit is contained in:
@ -7,6 +7,7 @@ import net.minestom.server.event.entity.EntityAttackEvent;
|
||||
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
|
||||
import net.minestom.server.event.instance.RemoveEntityFromInstanceEvent;
|
||||
import net.minestom.server.event.player.PlayerEntityInteractEvent;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@ -24,8 +25,13 @@ public class InteractableEntity extends EntityCreature {
|
||||
|
||||
.addListener(AddEntityToInstanceEvent.class, this::onSpawn)
|
||||
.addListener(RemoveEntityFromInstanceEvent.class, this::onDespawn)
|
||||
.addListener(PlayerEntityInteractEvent.class, this::onInteract)
|
||||
.addListener(PlayerEntityInteractEvent.class, this::onInteract) //TODO Why are some of these listeners not working?
|
||||
|
||||
.addListener(EntityAttackEvent.class, this::onAttack);
|
||||
|
||||
System.out.println(eventNode().getChildren());
|
||||
|
||||
System.out.println(eventNode().getParent().getChildren());
|
||||
}
|
||||
|
||||
private void setInstanceEvent(@NotNull AddEntityToInstanceEvent addEntityToInstanceEvent) {
|
||||
@ -34,16 +40,19 @@ public class InteractableEntity extends EntityCreature {
|
||||
}
|
||||
|
||||
addEntityToInstanceEvent.getInstance().eventNode()
|
||||
.addListener(PlayerMoveEvent.class, playerMoveEvent -> {
|
||||
//TODO might be expensive
|
||||
if(this.position.distance(playerMoveEvent.getNewPosition()) < 5)
|
||||
this.lookAt(playerMoveEvent.getPlayer());
|
||||
})
|
||||
.addListener(PlayerEntityInteractEvent.class, playerEntityInteractEvent -> {
|
||||
if(playerEntityInteractEvent.getTarget() == this) {
|
||||
onInteract(playerEntityInteractEvent);
|
||||
this.lookAt(playerEntityInteractEvent.getPlayer());
|
||||
}
|
||||
})
|
||||
.addListener(EntityAttackEvent.class, entityAttackEvent -> {
|
||||
if(entityAttackEvent.getTarget() == this) {
|
||||
onAttack(entityAttackEvent);
|
||||
this.lookAt(entityAttackEvent.getEntity());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user