Skip to content

Commit 5bcd870

Browse files
committed
items assets (Grayed)
1 parent 914099b commit 5bcd870

File tree

986 files changed

+1868
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

986 files changed

+1868
-25
lines changed

coffee/client/module/InventoryBar.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
class InventoryBar
23
setHp: (points)->
34
lista={}

coffee/client/module/index.coffee

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ init = ()->
6666
#Czat
6767
chat=new Chat({FPC})
6868

69+
#Utworzenie inventory
70+
inv_bar = new InventoryBar()
71+
6972
#Komunikacja z serwerem websocket
7073
eventMap={
7174
"connect":()->
@@ -96,7 +99,10 @@ init = ()->
9699
inv_bar.setHp(points)
97100
return
98101
"inventory":(inv)->
99-
console.log inv
102+
for i in [36..44]
103+
try
104+
$(".inv_box").eq(i-36).css("background-image","url(/assets/items/#{inv[i].name}.png)")
105+
# console.log inv[i]
100106
return
101107
"food":(points)->
102108
inv_bar.setFood(points)
@@ -121,9 +127,6 @@ init = ()->
121127
for i of eventMap
122128
socket.on i,eventMap[i]
123129

124-
#Utworzenie inventory
125-
inv_bar = new InventoryBar()
126-
127130
#Kursor raycastowania
128131
cursor=new THREE.LineSegments(
129132
new THREE.EdgesGeometry(

coffee/items.coffee

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
request = require 'request'
2+
JSSoup = require('jssoup').default
3+
fs = require 'fs'
4+
http=require "http"
5+
https=require "https"
6+
7+
options = {
8+
method: 'GET'
9+
url: "https://www.digminecraft.com/lists/item_id_list_pc.php"
10+
encoding: "utf-8"
11+
}
12+
13+
request options, (err, response, body)->
14+
soup=new JSSoup(body)
15+
map={}
16+
last=null
17+
for i in soup.findAll("td")
18+
if (i.text isnt " ") and (i.text.includes "minecraft:")
19+
title=i.text.split("(")[0]
20+
war=0
21+
for j in [0..i.text.length-1]
22+
if i.text[j] is "("
23+
war=j
24+
type=(i.text.substr war+11).split(")")[0]
25+
console.log type,last
26+
((type,url)->
27+
file=fs.createWriteStream "#{__dirname}/client/assets/items/#{type}.png"
28+
https.get url,(response)->
29+
response.pipe(file)
30+
)(type,"https://www.digminecraft.com#{last}")
31+
else if i.find("img") isnt undefined
32+
last=i.find("img").attrs["data-src"]
33+
return

coffee/server.coffee

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,59 @@ module.exports=(type)->
77
server=http.createServer()
88
io=require("socket.io")(server)
99
express=require 'express'
10+
request = require 'request'
1011
app=express();
1112
mineflayer = require 'mineflayer'
1213
Chunk = require("prismarine-chunk")(config.realServer.version)
1314
vec3=require "vec3"
1415
Convert = require 'ansi-to-html'
1516
convert = new Convert()
1617

17-
opn("http://#{config.host}:#{config['express-port']}")
18+
# opn("http://#{config.host}:#{config['express-port']}")
1819

1920
#początkowe zmienne
2021
sf={}
2122
port=config["express-port"]
2223
socketInfo={}
2324

25+
getItem=(name,callback)->
26+
mozl=[
27+
"materials"
28+
"armor_recipes"
29+
"basic_recipes"
30+
"block_recipes"
31+
"mobs"
32+
"decoration_recipes"
33+
"dye_recipes"
34+
"firework_recipes"
35+
"food_recipes"
36+
"mechanism_recipes"
37+
"tool_recipes"
38+
"transportation_recipes"
39+
"weapon_recipes"
40+
]
41+
done=0
42+
wysl=false
43+
for i in mozl
44+
options = {
45+
method: 'GET'
46+
url: "https://www.digminecraft.com/#{i}/images/#{name}.png"
47+
encoding: null
48+
}
49+
((options)->
50+
request options, (err, response, body)->
51+
done+=1
52+
if not err and response.statusCode == 200 and wysl is false
53+
wysl=true
54+
callback options.url
55+
56+
else if wysl is false and done is mozl.length
57+
callback "error"
58+
return
59+
)(options)
60+
61+
62+
2463
#Konfiguracja serwera express
2564
if type is "production"
2665
app.use express.static(__dirname + "/dist/")
@@ -29,6 +68,9 @@ module.exports=(type)->
2968
app.use (req, res, next) ->
3069
res.set 'Cache-Control', 'no-store'
3170
next()
71+
app.get "/items/:item",(req,res)->
72+
getItem req.params.item,(resp)->
73+
res.send(resp)
3274
app.get "/websocket/",(req,res)->
3375
res.send String(config["websocket-port"])
3476
app.get "/host/",(req,res)->
@@ -93,7 +135,8 @@ module.exports=(type)->
93135
inv_new=JSON.stringify(bot().inventory.slots)
94136
if inv isnt inv_new
95137
inv=inv_new
96-
emit "inventory",bot().inventory.slots
138+
emit ["inventory",bot().inventory.slots]
139+
return
97140
,100
98141
socketEventMap={
99142
"move":(state,toggle)->

0 commit comments

Comments
 (0)