9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-25 09:59:20 +00:00
This commit is contained in:
XiaoMoMi
2025-01-18 22:49:20 +08:00
parent 3eb778e687
commit 93d83ac467
6 changed files with 26 additions and 4 deletions

View File

@@ -54,6 +54,7 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
this.registerPotionEffectRequirement();
this.registerSneakRequirement();
this.registerGameModeRequirement();
this.registerHandRequirement();
}
@Override
@@ -345,4 +346,21 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
};
}, "gamemode");
}
private void registerHandRequirement() {
registerRequirement((args, actions, advanced) -> {
String hand = ((String) args).toLowerCase(Locale.ENGLISH);
return context -> {
if (context.holder() == null) return true;
EquipmentSlot slot = context.arg(ContextKeys.SLOT);
if (slot != null) {
if (slot.name().toLowerCase(Locale.ENGLISH).equals(hand)) {
return true;
}
}
if (advanced) ActionManager.trigger(context, actions);
return false;
};
}, "hand");
}
}