From 9ce5a79cc8bc55ae1f3636f6f496792830f2f159 Mon Sep 17 00:00:00 2001 From: Weiiswurst <31365822+WeiiswurstDev@users.noreply.github.com> Date: Tue, 26 Apr 2022 11:01:47 +0000 Subject: [PATCH] Ignore arrows and spectators (#986) --- .../java/net/minestom/server/collision/BlockCollision.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minestom/server/collision/BlockCollision.java b/src/main/java/net/minestom/server/collision/BlockCollision.java index 001cd90c1..a303b837b 100644 --- a/src/main/java/net/minestom/server/collision/BlockCollision.java +++ b/src/main/java/net/minestom/server/collision/BlockCollision.java @@ -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