mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
Prevent suffocation while using /rtp (#445)
* rtp: check for suffocation before teleport * safety resolvers: teleport to middle of block * rtp: Fix negative coordinates being off by one * unsafe blocks: add campfires and magma * unsafe blocks: deduplicate block id formatting
This commit is contained in:
1 parent
377e46ff92
commit
771c16ed1a
6 files changed
+118
-26
No files matched your search
@@ -72,15 +72,31 @@ public interface BukkitSafetyResolver extends SafetyResolver {
|
||||
if (x < 0 || x >= 16 || z < 0 || z >= 16) {
|
||||
continue;
|
||||
}
|
||||
final int y = Math.max((minY + 1), snapshot.getHighestBlockYAt(x, z));
|
||||
final Material blockType = snapshot.getBlockType(chunkX, y, chunkZ);
|
||||
if (isBlockSafe(blockType.getKey().toString())) {
|
||||
return Optional.of(Location.at(
|
||||
(location.getX() + dX) + 0.5d,
|
||||
y + 1,
|
||||
(location.getZ() + dZ) + 0.5d,
|
||||
location.getWorld()
|
||||
));
|
||||
final int y = Math.max((minY + 1), snapshot.getHighestBlockYAt(x, z)) + 1;
|
||||
final Material blockType = snapshot.getBlockType(x, y - 1, z);
|
||||
final Material bodyBlockType = snapshot.getBlockType(x, y, z);
|
||||
final Material headBlockType = snapshot.getBlockType(x, y + 1, z);
|
||||
if (isBlockSafeForStanding(blockType.getKey().toString())
|
||||
&& isBlockSafeForOccupation(bodyBlockType.getKey().toString())
|
||||
&& isBlockSafeForOccupation(headBlockType.getKey().toString())) {
|
||||
double locx = Math.floor(location.getX()) + dX;
|
||||
if (locx < 0) {
|
||||
locx += 1.5d;
|
||||
} else {
|
||||
locx = locx + 0.5d;
|
||||
}
|
||||
double locz = Math.floor(location.getZ()) + dZ;
|
||||
if (locz < 0) {
|
||||
locz += 1.5d;
|
||||
} else {
|
||||
locz = locz + 0.5d;
|
||||
}
|
||||
return Optional.of(Location.at(
|
||||
locx,
|
||||
y,
|
||||
locz,
|
||||
location.getWorld()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user