mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-27 02:48:04 +01:00
Allow interacting with the block at head height if stuck.
This commit is contained in:
parent
a5cc3f819f
commit
ac048474b7
@ -37,14 +37,21 @@ public class Visible extends Check {
|
|||||||
public boolean check(final Player player, final Location loc, final Block block, final BlockFace face, final Action action, final BlockInteractData data, final BlockInteractConfig cc) {
|
public boolean check(final Player player, final Location loc, final Block block, final BlockFace face, final Action action, final BlockInteractData data, final BlockInteractConfig cc) {
|
||||||
|
|
||||||
// TODO: Might confine what to check for (left/right, target blocks depending on item in hand, container blocks).
|
// TODO: Might confine what to check for (left/right, target blocks depending on item in hand, container blocks).
|
||||||
|
final boolean collides;
|
||||||
blockCache.setAccess(loc.getWorld());
|
final double eyeHeight = player.getEyeHeight();
|
||||||
rayTracing.setBlockCache(blockCache);
|
if (block.getX() == loc.getBlockX() && block.getZ() == loc.getBlockZ() && block.getY() == Location.locToBlock(loc.getY() + eyeHeight)){
|
||||||
rayTracing.set(loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ(), 0.5 + block.getX() + 0.6 * face.getModX(), 0.5 + block.getY() + 0.6 * face.getModY(), 0.5 + block.getZ() + 0.6 * face.getModZ());
|
// Player is interacting with the block his head is in.
|
||||||
rayTracing.loop();
|
collides = false;
|
||||||
final boolean collides = rayTracing.collides();
|
}
|
||||||
blockCache.cleanup();
|
else{
|
||||||
rayTracing.cleanup();
|
blockCache.setAccess(loc.getWorld());
|
||||||
|
rayTracing.setBlockCache(blockCache);
|
||||||
|
rayTracing.set(loc.getX(), loc.getY() + eyeHeight, loc.getZ(), 0.5 + block.getX() + 0.6 * face.getModX(), 0.5 + block.getY() + 0.6 * face.getModY(), 0.5 + block.getZ() + 0.6 * face.getModZ());
|
||||||
|
rayTracing.loop();
|
||||||
|
collides = rayTracing.collides();
|
||||||
|
blockCache.cleanup();
|
||||||
|
rayTracing.cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
|
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
|
||||||
player.sendMessage("Interact visible: " + (action == Action.RIGHT_CLICK_BLOCK ? "right" : "left") + " collide=" + rayTracing.collides());
|
player.sendMessage("Interact visible: " + (action == Action.RIGHT_CLICK_BLOCK ? "right" : "left") + " collide=" + rayTracing.collides());
|
||||||
|
Loading…
Reference in New Issue
Block a user