Skip to content

Commit df6dc37

Browse files
committed
Fix grindstone and villager not dropping XP
(Fix villager trading via resuming vanilla move on the result slot)
1 parent be9a97b commit df6dc37

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/main/java/com/mikedeejay2/simplestack/listeners/player/InventoryClickListener.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ public void stackEvent(InventoryClickEvent event)
5858

5959
boolean cancel1 = CancelUtils.cancelStackCheck(plugin, itemPickUp);
6060
boolean cancel2 = CancelUtils.cancelStackCheck(plugin, itemPutDown);
61-
boolean cancel3 = CancelUtils.cancelGUICheck(plugin, topInv, itemPutDown);
62-
if((cancel1 && cancel2) || event.isCancelled() || cancel3)
61+
boolean cancel3 = CancelUtils.cancelGUICheck(topInv, itemPutDown);
62+
boolean cancel4 = CancelUtils.cancelItemClick(clickedInv, itemPutDown, slot);
63+
if((cancel1 && cancel2) || event.isCancelled() || cancel3 || cancel4)
6364
{
6465
return;
6566
}

src/main/java/com/mikedeejay2/simplestack/listeners/player/InventoryDragListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void inventoryDragEvent(InventoryDragEvent event)
5252

5353
ItemStack cursor = event.getOldCursor();
5454
if(CancelUtils.cancelStackCheck(plugin, cursor)) return;
55-
if(CancelUtils.cancelGUICheck(plugin, event.getInventory(), cursor)) return;
55+
if(CancelUtils.cancelGUICheck(event.getInventory(), cursor)) return;
5656
GameMode gameMode = player.getGameMode();
5757
if(gameMode == GameMode.SURVIVAL || gameMode == GameMode.ADVENTURE)
5858
{

src/main/java/com/mikedeejay2/simplestack/util/CancelUtils.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,29 @@ public static boolean cancelMoveCheck(Simplestack plugin, ItemStack item, Invent
130130
* @param inv Inventory to check
131131
* @return If inventory should be cancelled
132132
*/
133-
public static boolean cancelGUICheck(Simplestack plugin, Inventory inv, ItemStack cursorItem)
133+
public static boolean cancelGUICheck(Inventory inv, ItemStack cursorItem)
134134
{
135135
if(inv == null) return true;
136136
if(MinecraftVersion.getVersionShort() >= 16 && inv instanceof SmithingInventory) return false;
137-
if(inv instanceof MerchantInventory) return true;
138137
if(ShulkerBoxes.isShulkerBox(cursorItem.getType()) && inv.getLocation() != null)
139138
{
140139
Location location = inv.getLocation();
141140
World world = location.getWorld();
142141
Block block = world.getBlockAt(location);
143142
Material blockType = block.getType();
144-
if(ShulkerBoxes.isShulkerBox(blockType)) return true;
143+
return ShulkerBoxes.isShulkerBox(blockType);
145144
}
146145
return false;
147146
}
148147

148+
public static boolean cancelItemClick(Inventory clickedInv, ItemStack cursorItem, int slot)
149+
{
150+
if(clickedInv instanceof PlayerInventory) return false;
151+
if(MinecraftVersion.getVersionShort() >= 14 && clickedInv instanceof GrindstoneInventory) return true;
152+
if(clickedInv instanceof MerchantInventory && slot == 2) return true;
153+
return false;
154+
}
155+
149156
public static boolean cancelCurseOfBinding(InventoryClickEvent event)
150157
{
151158
if(event.getWhoClicked().getGameMode() == GameMode.CREATIVE) return false;

0 commit comments

Comments
 (0)