KubeJS

KubeJS

61M Downloads

block.break event has event.player === event.getEntity(), block.place doesn't

Lupus590 opened this issue ยท 1 comments

commented

I would expect consistency.

commented

A BlockPlaceEventJS doesn't actually have a player attribute as you can see here

public class BlockPlaceEventJS extends EntityEventJS {
private final Entity entity;
private final Level world;
private final BlockPos pos;
private final BlockState state;

This is just due to the original Forge / Fabric event's structure, which may accept non-player entities, as well. That said, this obviously makes event.player return undefined, so if you want to compare the entity to something, you should probably just use their UUIDs:

public UUID getId() {
return minecraftEntity.getUUID();
}

In the future, there might be ways to "convert" an EntityJS to a PlayerJS, though our long term goal is actually to mostly do away with wrapper classes entirely and just integrate our functionality into the relevant vanilla classes