mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 07:28:19 +01:00
Ignore arrows and spectators (#986)
This commit is contained in:
parent
501020a453
commit
9ce5a79cc8
@ -5,6 +5,8 @@ import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.entity.metadata.other.ArmorStandMeta;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
@ -332,7 +334,7 @@ final class BlockCollision {
|
||||
static Entity canPlaceBlockAt(Instance instance, Point blockPos, Block b) {
|
||||
for (Entity entity : instance.getNearbyEntities(blockPos, 3)) {
|
||||
final EntityType type = entity.getEntityType();
|
||||
if (type == EntityType.ITEM)
|
||||
if (type == EntityType.ITEM || type == EntityType.ARROW)
|
||||
continue;
|
||||
// Marker Armor Stands should not prevent block placement
|
||||
if (entity.getEntityMeta() instanceof ArmorStandMeta armorStandMeta && armorStandMeta.isMarker())
|
||||
@ -340,6 +342,9 @@ final class BlockCollision {
|
||||
|
||||
final boolean intersects;
|
||||
if (type == EntityType.PLAYER) {
|
||||
// Ignore spectators
|
||||
if (((Player)entity).getGameMode() == GameMode.SPECTATOR)
|
||||
continue;
|
||||
// Need to move player slightly away from block we're placing.
|
||||
// If player is at block 40 we cannot place a block at block 39 with side length 1 because the block will be in [39, 40]
|
||||
// For this reason we subtract a small amount from the player position
|
||||
|
Loading…
Reference in New Issue
Block a user