Skip to content

Commit

Permalink
Fix some offhand handling bugs (#1808)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensku committed Feb 2, 2019
1 parent 23fe8e0 commit 294ca7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion skript-aliases
7 changes: 4 additions & 3 deletions src/main/java/ch/njol/skript/events/EvtClick.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ public String toString(final @Nullable Event e, final boolean debug) {
private static final ItemType usableBlocksMainOnly = Aliases.javaItemType("block usable with main hand");

public static boolean checkUseOffHand(Player player, int clickType, @Nullable Block block, @Nullable Entity entity) {
if (clickType != RIGHT) return false; // Attacking with off hand is not possible
if ((clickType & RIGHT) == 0)
return false; // Attacking with off hand is not possible

boolean mainUsable = false; // Usable item
boolean offUsable = false;
Expand Down Expand Up @@ -317,8 +318,8 @@ public static boolean checkUseOffHand(Player player, int clickType, @Nullable Bl
if (blockUsable) { // Special behavior
if (isSneaking) {
//Skript.info("Is sneaking on usable block!");
if (offHand.getType() != Material.AIR) return false;
if (mainHand.getType() != Material.AIR) return true;
if (offHand.getType() == Material.AIR) return false;
if (mainHand.getType() == Material.AIR) return true;
//Skript.info("Sneak checks didn't pass.");
} else { // When not sneaking, main hand is ALWAYS used
return false;
Expand Down

0 comments on commit 294ca7c

Please sign in to comment.