Skip to content

Commit

Permalink
fix spawn protection when out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
MelanX committed Apr 20, 2024
1 parent 25f0efb commit 9a38a01
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,14 @@ private static boolean ignore(Type type) {
return !SpawnConfig.spawnProtectionEvents.contains(type);
}

private static boolean isOnSpawn(Entity entity) {
return SpawnProtectionEvents.isOnSpawn(entity.level(), entity.blockPosition());
}

private static boolean isOnSpawn(Level level, BlockPos blockPos) {
ChunkPos pos = new ChunkPos(blockPos);
return WorldUtil.isSkyblock(level) && SpawnConfig.dimension == level.dimension()
&& Math.abs(pos.x) < SpawnConfig.spawnProtectionRadius && Math.abs(pos.z) < SpawnConfig.spawnProtectionRadius;
}

private static boolean isOnSpawn(Entity entity) {
ChunkPos pos = new ChunkPos(entity.blockPosition());
return WorldUtil.isSkyblock(entity.level()) && SpawnConfig.dimension == entity.level().dimension()
&& Math.abs(pos.x) < SpawnConfig.spawnProtectionRadius && Math.abs(pos.z) < SpawnConfig.spawnProtectionRadius;
&& Math.abs(pos.x) < SpawnConfig.spawnProtectionRadius && Math.abs(pos.z) < SpawnConfig.spawnProtectionRadius
&& !level.isOutsideBuildHeight(blockPos);
}
}

0 comments on commit 9a38a01

Please sign in to comment.