Skip to content

Commit

Permalink
手持武器时不切换工具;修复CraftDrop吞道具的Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
0XPYEX0 committed Jul 13, 2023
1 parent 9c6455a commit 83a56c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public void onInteract(PlayerInteractEvent event) {
if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
return;

if (StrUtil.endsWithIgnoreCaseOr(event.getPlayer().getInventory().getItemInMainHand().getType().toString(), "_SWORDS", "BOW", "TRIDENT")) {
return; //弓、剑、弩、三叉戟 不处理
}
if (event.getClickedBlock() != null) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (StrUtil.containsIgnoreCaseOr(ValueUtil.getOrDefault(event.getItem(), InvUtil.AIR_STACK).getType().toString(), "BOW")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ public void onCraft(CraftItemEvent event) {

event.setCancelled(true);
ItemStack tool = new ItemStack(event.getWhoClicked().getInventory().getItemInMainHand());
event.getWhoClicked().getInventory().setItemInMainHand(event.getRecipe().getResult());
event.getWhoClicked().getInventory().getItemInMainHand().setAmount(least.getAmount());

ItemStack toDrop = new ItemStack(event.getRecipe().getResult());
toDrop.setAmount(toDrop.getAmount() * least.getAmount());
event.getWhoClicked().getInventory().setItemInMainHand(toDrop);
event.getWhoClicked().dropItem(true);

for (ItemStack matrix : event.getInventory().getMatrix()) {
if (matrix == null || matrix.getAmount() == 0) continue;

Expand Down

0 comments on commit 83a56c0

Please sign in to comment.