mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 08:27:43 +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.coordinate.Vec;
|
||||||
import net.minestom.server.entity.Entity;
|
import net.minestom.server.entity.Entity;
|
||||||
import net.minestom.server.entity.EntityType;
|
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.entity.metadata.other.ArmorStandMeta;
|
||||||
import net.minestom.server.instance.Instance;
|
import net.minestom.server.instance.Instance;
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
@ -332,7 +334,7 @@ final class BlockCollision {
|
|||||||
static Entity canPlaceBlockAt(Instance instance, Point blockPos, Block b) {
|
static Entity canPlaceBlockAt(Instance instance, Point blockPos, Block b) {
|
||||||
for (Entity entity : instance.getNearbyEntities(blockPos, 3)) {
|
for (Entity entity : instance.getNearbyEntities(blockPos, 3)) {
|
||||||
final EntityType type = entity.getEntityType();
|
final EntityType type = entity.getEntityType();
|
||||||
if (type == EntityType.ITEM)
|
if (type == EntityType.ITEM || type == EntityType.ARROW)
|
||||||
continue;
|
continue;
|
||||||
// Marker Armor Stands should not prevent block placement
|
// Marker Armor Stands should not prevent block placement
|
||||||
if (entity.getEntityMeta() instanceof ArmorStandMeta armorStandMeta && armorStandMeta.isMarker())
|
if (entity.getEntityMeta() instanceof ArmorStandMeta armorStandMeta && armorStandMeta.isMarker())
|
||||||
@ -340,6 +342,9 @@ final class BlockCollision {
|
|||||||
|
|
||||||
final boolean intersects;
|
final boolean intersects;
|
||||||
if (type == EntityType.PLAYER) {
|
if (type == EntityType.PLAYER) {
|
||||||
|
// Ignore spectators
|
||||||
|
if (((Player)entity).getGameMode() == GameMode.SPECTATOR)
|
||||||
|
continue;
|
||||||
// Need to move player slightly away from block we're placing.
|
// 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]
|
// 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
|
// For this reason we subtract a small amount from the player position
|
||||||
|
Loading…
Reference in New Issue
Block a user