Allow non-vanished players to place blocks on vanished players
ScoreUnder opened this issue ยท 7 comments
Could possibly be done with BlockCanBuildEvent - see https://github.com/Bukkit/CraftBukkit/blob/master/src/main/java/net/minecraft/server/World.java#L2306 (World.mayPlace) for calculation and the event itself.
Could this be fixed by faking a player death in the style of older vanish plugins? The server shouldn't prevent the placement of blocks on top of a deceased player.
I would have thought the vanilla client prevents this from occurring as well as bukkit.
The vanilla client can't prevent it from happening, because it doesn't know that the player is there in the first place.
Decided to have a poke at this, got up till this point but apparently since there isn't a method to get the placing entity in the event there's no way to check if the placing entity can see the entity in the entity list so yeah this isn't going to happen unless we can grab the placing entity in BlockCanBuildEvent
if (!event.isBuildable()) {
Location loc = event.getBlock().getLocation();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
Block nmsBlock = Block.byId[event.getMaterialId()];
World world = ((CraftWorld) loc.getWorld()).getHandle();
AxisAlignedBB axisalignedbb = nmsBlock.e(world, x, y, z);
if (axisalignedbb != null) {
List<?> list = world.getEntities(null, axisalignedbb);
for (Object object : list) {
if (!(object instanceof Entity)) {
continue;
}
Entity entity = (Entity) object;
if (entity.dead || !entity.m) {
continue;
}
if (entity instanceof EntityPlayer ) {
}
}
}
}