37
37
38
38
import ch .njol .skript .Skript ;
39
39
import ch .njol .skript .aliases .ItemType ;
40
+ import ch .njol .skript .bukkitutil .PlayerUtils ;
40
41
import ch .njol .skript .classes .Comparator .Relation ;
41
42
import ch .njol .skript .classes .data .DefaultComparators ;
42
43
import ch .njol .skript .entity .EntityData ;
@@ -103,7 +104,7 @@ public boolean check(final Event e) {
103
104
104
105
if (e instanceof PlayerInteractEntityEvent ) {
105
106
PlayerInteractEntityEvent clickEvent = ((PlayerInteractEntityEvent ) e );
106
- if (Skript .isRunningMinecraft (1 , 9 )) { // If player has empty hand, BOTH hands trigger the event (might be a bug?)
107
+ if (Skript .isRunningMinecraft (1 , 9 )) {
107
108
ItemStack mainHand = clickEvent .getPlayer ().getInventory ().getItemInMainHand ();
108
109
ItemStack offHand = clickEvent .getPlayer ().getInventory ().getItemInOffHand ();
109
110
@@ -123,7 +124,7 @@ public boolean check(final Event e) {
123
124
block = null ;
124
125
} else if (e instanceof PlayerInteractEvent ) {
125
126
PlayerInteractEvent clickEvent = ((PlayerInteractEvent ) e );
126
- if (Skript .isRunningMinecraft (1 , 9 )) { // If player has empty hand, BOTH hands trigger the event (might be a bug?)
127
+ if (Skript .isRunningMinecraft (1 , 9 )) {
127
128
ItemStack mainHand = clickEvent .getPlayer ().getInventory ().getItemInMainHand ();
128
129
ItemStack offHand = clickEvent .getPlayer ().getInventory ().getItemInOffHand ();
129
130
@@ -198,6 +199,11 @@ public static boolean checkUseOffHand(Player player, int clickType, @Nullable Bl
198
199
ItemStack mainHand = player .getInventory ().getItemInMainHand ();
199
200
ItemStack offHand = player .getInventory ().getItemInOffHand ();
200
201
202
+ Material mainMat = mainHand .getType ();
203
+ Material offMat = offHand .getType ();
204
+ assert mainMat != null ;
205
+ assert offMat != null ;
206
+
201
207
//Skript.info("block is " + block);
202
208
//Skript.info("entity is " + entity);
203
209
@@ -231,7 +237,7 @@ public static boolean checkUseOffHand(Player player, int clickType, @Nullable Bl
231
237
}
232
238
233
239
// Seriously? Empty hand -> block in hand, since id of AIR < 256 :O
234
- if ((offHand . getType (). isBlock () && offHand . getType () != Material .AIR ) || offHand . getType (). isEdible ( )) {
240
+ if ((offMat . isBlock () && offMat != Material .AIR ) || PlayerUtils . canEat ( player , offMat )) {
235
241
offUsable = true ;
236
242
}
237
243
@@ -264,7 +270,7 @@ public static boolean checkUseOffHand(Player player, int clickType, @Nullable Bl
264
270
}
265
271
266
272
// Seriously? Empty hand -> block in hand, since id of AIR < 256 :O
267
- if ((mainHand . getType (). isBlock () && mainHand . getType () != Material .AIR ) || mainHand . getType (). isEdible ( )) {
273
+ if ((mainMat . isBlock () && mainMat != Material .AIR ) || PlayerUtils . canEat ( player , mainMat )) {
268
274
mainUsable = true ;
269
275
}
270
276
0 commit comments