From 09f2bc6e5e4a06ebdbfa81fe05b6f6df95786959 Mon Sep 17 00:00:00 2001
From: shillingp
Date: Mon, 23 Jun 2014 22:52:04 +0000
Subject: [PATCH] Added inventory cycle function
---
misc.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/misc.py b/misc.py
index f2e52be..33b4012 100644
--- a/misc.py
+++ b/misc.py
@@ -92,6 +92,25 @@ def onPlayerInteractEntity(event):
sender.playSound(entity.getLocation(), "mob.cow.say", 1, 1)
+#
+# Cycling around the item bar will switch between rows of the inventory
+#
+@hook.event("inventory.PlayerItemHeldEvent", "normal")
+def onHeldEvent(event):
+ player = event.getPlayer()
+ prev_slot = event.getPreviousSlot()
+ new_slot = event.getNewSlot()
+ if (prev_slot == 0 and new_slot == 8):
+ doCycle(player, 27)
+ elif (prev_slot == 8 and new_slot == 0):
+ doCycle(player, 9)
+
+def doCycle(player, e):
+ inv = player.getContents()
+ for x in range (0, 9):
+ inv[x], inv[x+e] = inv[x+e], inv[x]
+
+
#
# Various text commands
#