Skip to content

Commit fda0597

Browse files
committed
Equiping items in inventory bar
1 parent b7541f0 commit fda0597

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

coffee/src/client/module/InventoryBar.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class InventoryBar
4848
$(".xp_bar").css "width","#{500*progress}px"
4949
setFocus:(num)->
5050
$(".inv_cursor").css("left","calc(50vw - 253px + 55*#{num}px)")
51+
@game.socket.emit "invc",num
52+
return
5153
updateInv:(inv)->
5254
for i in [36..44]
5355
if inv[i] isnt null
@@ -69,6 +71,7 @@ class InventoryBar
6971
focus--
7072
focus=focus %% 9
7173
_this.setFocus focus
74+
return
7275
tick:()->
7376
list = $(".item")
7477
for i in [0..list.length-1]
@@ -80,5 +83,5 @@ class InventoryBar
8083
$(list[i]).html("<div style='z-index:99;text-align:right;position:relative;bottom:-22px;color:white;font-weight:bold;'>"+$(list[i]).attr('data-amount')+"</div>")
8184
if $(list[i]).attr('data-amount') is "0" or $(list[i]).attr('data-amount') is "1"
8285
$(list[i]).html("<div style='z-index:99;text-align:right;position:relative;bottom:-22px;color:white;font-weight:bold;'>&#8291</div>")
83-
86+
return
8487
export {InventoryBar}

coffee/src/server.coffee

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ module.exports=(type)->
7272
emit ["food",bot().food]
7373
return
7474
"spawn":()->
75+
# diamond=bot().inventory.slots[36]
76+
# ac=bot().inventory.slots[37]
77+
# console.log diamond,ac
78+
# bot().equip ac,"hand"
79+
# bot().heldItem.slot=37
80+
# console.log bot().updateHeldItem()
81+
# console.log bot().heldItem
7582
emit ["spawn",bot().entity.yaw,bot().entity.pitch]
7683
return
7784
"kicked":(reason,loggedIn)->
@@ -110,6 +117,15 @@ module.exports=(type)->
110117
return
111118
,10
112119
socketEventMap={
120+
"invc":(num)->
121+
item=bot().inventory.slots[num+36]
122+
if item isnt null
123+
console.log item
124+
try
125+
bot().equip item,"hand"
126+
else
127+
bot().unequip "hand"
128+
return
113129
"move":(state,toggle)->
114130
bot().setControlState(state,toggle)
115131
return

src/client/module/InventoryBar.js

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/server.js

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)