Added inventory cycle function
This commit is contained in:
19
misc.py
19
misc.py
@@ -92,6 +92,25 @@ def onPlayerInteractEntity(event):
|
|||||||
sender.playSound(entity.getLocation(), "mob.cow.say", 1, 1)
|
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
|
# Various text commands
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user