Skip to content

Commit

Permalink
Fix regular clicking item recipes
Browse files Browse the repository at this point in the history
The way this works is super strange, but it works :D
  • Loading branch information
mcmonkey4eva committed Feb 18, 2015
1 parent 5f0d2fc commit a1b6759
Showing 1 changed file with 27 additions and 0 deletions.
Expand Up @@ -128,9 +128,36 @@ public void specialRecipeClick(InventoryClickEvent event) {
else {
processSpecialRecipes(inventory, player);
}
if (slotType.equals(SlotType.RESULT)) {
removeOneFromEachSlot(inventory, player);
}
}
}

public void removeOneFromEachSlot(final CraftingInventory inventory, final Player player) {
Bukkit.getScheduler().scheduleSyncDelayedTask(DenizenAPI.getCurrentInstance(),
new Runnable() {
@Override
public void run() {
ItemStack[] matrix = inventory.getMatrix();
for (int i = 0; i < matrix.length; i++) {
if (matrix[i] != null) {
if (matrix[i].getAmount() == 0) {
matrix[i] = null;
} else {
matrix[i].setAmount(matrix[i].getAmount() - 1);
if (matrix[i].getAmount() == 0) {
matrix[i] = null;
}
}
}
}
inventory.setContents(matrix);
player.updateInventory();
}
}, 0);
}

// When special Denizen recipes that have itemscripts as ingredients
// are being used, check crafting matrix for recipe matches whenever
// drags (which are entirely separate from clicks) are made in CRAFTING slots
Expand Down

0 comments on commit a1b6759

Please sign in to comment.