These are chat archives for PrismarineJS/minecraft-data

3rd
Sep 2015
Romain Beaumont
@rom1504
Sep 03 2015 09:07
I wonder how they do it
Robin Lambertz
@roblabla
Sep 03 2015 12:44
rom1504, it has a lot more maturity >.>
Gjum
@Gjum
Sep 03 2015 20:39
rom1504, I think the size of the "saved block inventory" should go into windows
server sends additiona_slots = 0 for crafting table
but 27 for chest
I think mineflayer has something similar with inventoryStart or what its called
Romain Beaumont
@rom1504
Sep 03 2015 20:51
chest are 27 or 54
depending on some condition I don't remember
and I don't remember what this number mean :p
https://gist.github.com/rom1504/f02fabb92123e16aa52b for the fun of it @roblabla @nickelpro
2800 lines -> 1300
Nick Gamberini
@nickelpro
Sep 03 2015 20:54
rom1504: I... I could use that
Nick Gamberini
@nickelpro
Sep 03 2015 20:54
Don't make fun of my schema :'(
Romain Beaumont
@rom1504
Sep 03 2015 20:56
I just meant it was fun writing the transform script :p
I like tranforming stuff while keeping the semantic info :p
Gjum
@Gjum
Sep 03 2015 20:56
rom1504, I know that, and also that that line of code is wrong. I meant that for containers (chest, dispenser, dropper, hopper, ...) the server sends the number of slots in them, but for blocks with inventory but without persistent slots, server doesnt
Romain Beaumont
@rom1504
Sep 03 2015 20:56
idk about the schema
it does make stuff simpler
yeah so we need to know that number Gjum yes
how is that line wrong ? triple chests ?
(that transform script is not entirely complete btw, you'll notice a few 'too lazy for this' ^^, it's just a POC to see if we like it or not)
Romain Beaumont
@rom1504
Sep 03 2015 21:02
ah I forgot to simplify the containers
Gjum
@Gjum
Sep 03 2015 21:02
triple chests, custom windows from bukkit servers
currently I calculate that number from the slot ranges: slot_count = max(s['index'] + s.get('size', 1) - 1 for s in windows_by_id['slots'])
s/windows_by_id/windows_by_id[inv_type]/
it works, but I don't think it's clean
Robin Lambertz
@roblabla
Sep 03 2015 21:05
nickelpro, rom1504 looks good ^^
for the compareTo (don't be so lazy rom1504 :D) just use indexes
so 0.5.4
for instance
well, 0 or this.0
Romain Beaumont
@rom1504
Sep 03 2015 21:08
Gjum: custom windows are handled in a ContainerWindow class or something (recently added to mineflayer)
Gjum
@Gjum
Sep 03 2015 21:08
so the user tells which window class to use?
Romain Beaumont
@rom1504
Sep 03 2015 21:08
yeah, might not be the best pattern but yeah
@roblabla I just updated the gist
did ["container", [stuff] ] -> [stuff]
since we can with that format
about compareTo, yeah I know it's doable, but I need to think about how to get all the this. stuff and all, too much thinking needed :p
it's even smaller now, 1250 lines
Robin Lambertz
@roblabla
Sep 03 2015 21:11
rom1504, I actually don't implement that format anymore
I guess I could, but it'd be messy
Romain Beaumont
@rom1504
Sep 03 2015 21:11
@roblabla btw, you forgot the default in entityMetadataItem
Robin Lambertz
@roblabla
Sep 03 2015 21:11
because ["container"] can be both an empty container within a container or a malformed container :P
rom1504, default is optional
because there is the possibility to crash
the alternative would be making a "crash" or "invalid" default :P
*type
Romain Beaumont
@rom1504
Sep 03 2015 21:12
ah yes I remember now
ok
'["container"] can be both an empty container within a container or a malformed container
'
hmm "empty container" : what is that ?
malformed container : who cares about that ?
Robin Lambertz
@roblabla
Sep 03 2015 21:12
["container", []]
Romain Beaumont
@rom1504
Sep 03 2015 21:12
yeah but what's the point of an empty container ?
Robin Lambertz
@roblabla
Sep 03 2015 21:13
rom1504, I do.
there's no point, the thing is, this syntax is ambiguous
it wasn't ambiguous when it was just { type, typeArgs }, "type" and [container]
Romain Beaumont
@rom1504
Sep 03 2015 21:14
hmm I can't quite see how, if the first item is a known complex type, then the second item is a typeArgs
Robin Lambertz
@roblabla
Sep 03 2015 21:14
but since we now have [type, typeArgs] as well...
Romain Beaumont
@rom1504
Sep 03 2015 21:14
if it isn't then we have a container
Robin Lambertz
@roblabla
Sep 03 2015 21:14
ok let's say this
["container", "int"]. This is both a valid container containing an invalid container and an int
and an invalid container (typeArgs is wrong)
Romain Beaumont
@rom1504
Sep 03 2015 21:16
no of course we need to say ['container',types] is not a valid syntax anymore
Robin Lambertz
@roblabla
Sep 03 2015 21:16
the point is, in both cases, it is a valid type
Romain Beaumont
@rom1504
Sep 03 2015 21:16
but containers (and option) already have a specific syntax anyway
Robin Lambertz
@roblabla
Sep 03 2015 21:16
I don't want to special case container that much
Romain Beaumont
@rom1504
Sep 03 2015 21:16
so why not make it easier ?
Robin Lambertz
@roblabla
Sep 03 2015 21:17
they don't ?
Romain Beaumont
@rom1504
Sep 03 2015 21:17
yes they do
the other complex types are [type, {stuff}]
container is [type, [stuff]]
option is [type,stuff]
Robin Lambertz
@roblabla
Sep 03 2015 21:17
typeArgs can be of any type
that's not something special to container or option
any type defined under protocols can have any type for its typeArgs
so long as it's json-represenetable of course
Romain Beaumont
@rom1504
Sep 03 2015 21:18
"of any type" : what does that mean ? any json things ?
Robin Lambertz
@roblabla
Sep 03 2015 21:18
yeah
so object, array, string or number
Romain Beaumont
@rom1504
Sep 03 2015 21:19
so {"sdfds":0.5,[[["A":"b"]]]} is okay as a typeArgs ?
Robin Lambertz
@roblabla
Sep 03 2015 21:20
yuup
wait wat
no that's not valid
that's not valid json ._.
Romain Beaumont
@rom1504
Sep 03 2015 21:21
ah yeah replace some [ by {
Robin Lambertz
@roblabla
Sep 03 2015 21:21
well if it's json-serializable, it's valid. That's how it's currently set in my mind
Romain Beaumont
@rom1504
Sep 03 2015 21:21
{"sdfds":0.5,[[{"A":"b"}]]}
Robin Lambertz
@roblabla
Sep 03 2015 21:21
this is still invalid json
XD
{ key: value, value }
you're missing a key somewhere
Romain Beaumont
@rom1504
Sep 03 2015 21:21
lol
{"sdfds":0.5,"mojangson":[[{"A":"b"}]]}
Robin Lambertz
@roblabla
Sep 03 2015 21:22
yup. this is valid.
it's weird
but it's valid
Romain Beaumont
@rom1504
Sep 03 2015 21:22
I'm going to put mojangson in the mojangson key
with backslashes
Robin Lambertz
@roblabla
Sep 03 2015 21:22
\mojangson/
:P
Romain Beaumont
@rom1504
Sep 03 2015 21:22
hmm
well I kinda see your point
but I liked the fact my syntax made packet and container the same
Robin Lambertz
@roblabla
Sep 03 2015 21:23
rom1504, TBH, this may change if people complain that it's too hard to implement in stricter languages like C
or go or whatever
Robin Lambertz
@roblabla
Sep 03 2015 21:24
rom1504, what needs to change is packet, not container ;)
Romain Beaumont
@rom1504
Sep 03 2015 21:24
I guess
hmm fine, let's put "container" back
Robin Lambertz
@roblabla
Sep 03 2015 21:25
There is a case to be made in favor of container having this special syntax, I'm not saying it's a bad idea per se. It's just too ambiguous and protocol has too little documentation right now, so I'm afraid it'd make implementing protocol even harder to have that in
Romain Beaumont
@rom1504
Sep 03 2015 21:26
your message got cut roblabla
"even harder to have that in"
Robin Lambertz
@roblabla
Sep 03 2015 21:27
nope, didn't get cut
:P
"in the file" ?
Romain Beaumont
@rom1504
Sep 03 2015 21:27
ah okay I just don't understand english I guess :p
ah yeah okay I get it
Robin Lambertz
@roblabla
Sep 03 2015 21:28
two french people speaking english to each-other xD
Romain Beaumont
@rom1504
Sep 03 2015 21:28
the reference was too far away
Robin Lambertz
@roblabla
Sep 03 2015 21:28
yeah, wasn't the cleanest sentence I ever made hahaha
Romain Beaumont
@rom1504
Sep 03 2015 21:28
I think it looks good
but you can't just read it now
you need to look at the doc
Robin Lambertz
@roblabla
Sep 03 2015 21:29
I wonder if that's really such a huge deal
hmm
Romain Beaumont
@rom1504
Sep 03 2015 21:30
0x0f is "varint", "ubyte", "int", "int","int","byte","byte", "byte","short","short", "short", "entityMetadata"
now send a packet
:p
yeah maybe it's okay
Robin Lambertz
@roblabla
Sep 03 2015 21:30
there's also the fact that since nmp will have a merge script, we'll actually be able to generate the old file
Romain Beaumont
@rom1504
Sep 03 2015 21:30
it's a change though
Robin Lambertz
@roblabla
Sep 03 2015 21:30
if needed
(and we will need it, doc website isn't ready yet :P)
Romain Beaumont
@rom1504
Sep 03 2015 21:31
yeah sure we can generate the old file any time
well the doc website has most of the info
Robin Lambertz
@roblabla
Sep 03 2015 21:31
it's missing a few
i made tickets for it
Romain Beaumont
@rom1504
Sep 03 2015 21:32
it's missing few stuff (except for the description and comments but protocol.json never had that)
Robin Lambertz
@roblabla
Sep 03 2015 21:32
buffer countType, option's inner type
Romain Beaumont
@rom1504
Sep 03 2015 21:32
yeah I know I saw them
Robin Lambertz
@roblabla
Sep 03 2015 21:32
oh yeah that reminds me
I was thinking about removing count from array, and making the only dataType using it special
because it's effing confusing
Romain Beaumont
@rom1504
Sep 03 2015 21:33
yes I agree
I hate my oneOf in array definition in the schema
Robin Lambertz
@roblabla
Sep 03 2015 21:33
this is the only instance of it
in the whole 2800 lines file
Romain Beaumont
@rom1504
Sep 03 2015 21:34
yeah
Robin Lambertz
@roblabla
Sep 03 2015 21:34
(I sort of hate mojang for that)
Romain Beaumont
@rom1504
Sep 03 2015 21:34
I wrote this one manually, trying to make the old js object fit in a .json :p
Robin Lambertz
@roblabla
Sep 03 2015 21:34
yeah I know ^^
Not to mention, with a generalized restBuffer (oh lord...), this could actually fit nicely into a dataType
["restArray", "varint"]
ok, I'll admit, not the prettiest
but it works !
(I hate mojang for restBuffer)
(stupidest thing they ever did)
Romain Beaumont
@rom1504
Sep 03 2015 21:35
admit you just want to make restNbt :p
Robin Lambertz
@roblabla
Sep 03 2015 21:35
shhh
don't tell anyone !
I tried prototyping an nbt parser written in protocols
well guess what ?
not easy
It has a similar problem to entityMetadata too
Romain Beaumont
@rom1504
Sep 03 2015 21:40
do you think it would be easy to make super. syntax work in node-minecraft-protocol ?
Robin Lambertz
@roblabla
Sep 03 2015 21:40
Yeah, it would be
Romain Beaumont
@rom1504
Sep 03 2015 21:40
this. is still confusing to me even though I used it, so I bet it will be confusing to other devs trying to use it in other languages
Robin Lambertz
@roblabla
Sep 03 2015 21:40
I think I already have most of the code for that in Protocols/, all we'd have to do is do the actual protocol.json
Romain Beaumont
@rom1504
Sep 03 2015 21:41
(especially languages that have a sane 'this' unlike js)
okay
seems like we're going to have some super.super.super
(just super.super here but still)
Robin Lambertz
@roblabla
Sep 03 2015 21:44
we also have root, although I'd like to avoid using it as much as possible :P
it's mostly designed for very hacky protocols (java classfiles, i'm looking at you)
Romain Beaumont
@rom1504
Sep 03 2015 21:44
there is only 5 'this' in protocol.json oO
I thought there were like 20 or something
Robin Lambertz
@roblabla
Sep 03 2015 21:45
where's the super.super ?
hmm but it's a switch so maybe not
Robin Lambertz
@roblabla
Sep 03 2015 21:45
no
only containers and arrays need supers
Romain Beaumont
@rom1504
Sep 03 2015 21:46
right
Robin Lambertz
@roblabla
Sep 03 2015 21:46
think of the context as a stack. Super allows going to the upper stackframe. Only container and arrays need a new stackFrame
Romain Beaumont
@rom1504
Sep 03 2015 21:47
in that case protocol.json transformation is s/this/super/g
Robin Lambertz
@roblabla
Sep 03 2015 21:47
errrm, no ?
in most cases you drop the this entirely
Romain Beaumont
@rom1504
Sep 03 2015 21:47
ah yeah indeed
Looks like I missed it ^^)
Romain Beaumont
@rom1504
Sep 03 2015 21:48
'in most cases you drop the this entirely' everywhere actually
Robin Lambertz
@roblabla
Sep 03 2015 21:49
yeah, all the this are going to be dropped
but supers might be added in places where there was nothing currently
Romain Beaumont
@rom1504
Sep 03 2015 21:49
this. are only used in a switch that's in a container and referencing to an other field of the container
hmm, a super.super
that sucks :|
Romain Beaumont
@rom1504
Sep 03 2015 21:50
ah yeah
how come it works currently ?
Robin Lambertz
@roblabla
Sep 03 2015 21:50
because right now it defaults to the "root"
Romain Beaumont
@rom1504
Sep 03 2015 21:50
what happens if I put a field named action in that container ?
Robin Lambertz
@roblabla
Sep 03 2015 21:50
so when you do action, it looks at the root context
Romain Beaumont
@rom1504
Sep 03 2015 21:50
right
Robin Lambertz
@roblabla
Sep 03 2015 21:50
then you need to use "this.action"
that's what this does
it looks at the current context instead of the global context
the problem with this is, it composes REEEEEEEAAAAAAALLY badly
for NMP that's ok, we don't need much composition
Romain Beaumont
@rom1504
Sep 03 2015 21:51
yes
Robin Lambertz
@roblabla
Sep 03 2015 21:51
but for my other projects that sucks :|
Romain Beaumont
@rom1504
Sep 03 2015 21:51
you can't do child.action
so some things are impossible with the current pattern
Robin Lambertz
@roblabla
Sep 03 2015 21:52
it is possible
wherever.you.were.action
well, wherever.you.were.child.action
or this.child.action
oh right there's another problem with that haha
Romain Beaumont
@rom1504
Sep 03 2015 21:53
right
guess what happens if I put data.0.UUID in that
(the good way would be this.UUID and would work)
Romain Beaumont
@rom1504
Sep 03 2015 21:54
crash in some cases
Robin Lambertz
@roblabla
Sep 03 2015 21:54
(for argument's sake, let's say we're always in array element 0)
actually it crashesin every case
here's the thing
data is currently being read
So, IIRC, data doesn't exist in the global context
I'd need to check but that's pretty much the root problem
and why super/root would be a much better idea
Romain Beaumont
@rom1504
Sep 03 2015 21:56
yeah ok
Robin Lambertz
@roblabla
Sep 03 2015 21:58
wait
...
yeah rootNode is pretty much very broken right now
well context
urg, you know what would help it quite a lot ? Not having separate logic for packet and containers
xD
Romain Beaumont
@rom1504
Sep 03 2015 22:00
@roblabla :p
Robin Lambertz
@roblabla
Sep 03 2015 22:00
so right now, say you have a packet that looks like
Romain Beaumont
@rom1504
Sep 03 2015 22:01
if we figure out how to define the packet structure in protocol.json we can have the docgen auto generate the packet structure doc
you did some prototyping of a possible schema earlier, idk if that was saved in an issue
Robin Lambertz
@roblabla
Sep 03 2015 22:01
This message was deleted
it will fail
wait no that works
urg I know something fails but I can't tell what hahahaha
right I got it
nope I don't
Too tired
rom1504, can't remember Xd
Romain Beaumont
@rom1504
Sep 03 2015 22:05
the switch thing
have as many types as packet
  • a switch on the packet id
Robin Lambertz
@roblabla
Sep 03 2015 22:06
oh that, yeah
now that we have unnamed packets that's going to get even harder hahaha
well, I guess I'll end up naming the packets "<state>.<bound>.<id>"
what a horrible type name
Romain Beaumont
@rom1504
Sep 03 2015 22:07
hmm
naming the types you mean
Robin Lambertz
@roblabla
Sep 03 2015 22:07
yeah
Romain Beaumont
@rom1504
Sep 03 2015 22:07
that would be ugly
Robin Lambertz
@roblabla
Sep 03 2015 22:08
yup
but tbh whatever happens, this is going to end up messy xD
Romain Beaumont
@rom1504
Sep 03 2015 22:08
we'd need some syntactic sugar for switch if we did that
Robin Lambertz
@roblabla
Sep 03 2015 22:08
nuuuuu ;_;
Romain Beaumont
@rom1504
Sep 03 2015 22:08
or just put the packet types in the switch and be done with it
Robin Lambertz
@roblabla
Sep 03 2015 22:08
well I already said it'd be a "special_sauce_switch" anyway
...
yuck
I guess it wouldn't matter so much if it's unnamed :|
Romain Beaumont
@rom1504
Sep 03 2015 22:09
["switch", {"0x34": ["varint","int","byte"]}]
yep that's the point
Robin Lambertz
@roblabla
Sep 03 2015 22:09
hahahaha
we should totally follow the same convention mojang does
and drop the packetIds
Romain Beaumont
@rom1504
Sep 03 2015 22:09
ah yeah
Robin Lambertz
@roblabla
Sep 03 2015 22:09
use the position in the array instead
["switch", [["varint", "int", "byte"], ["position", "whatever", "test"]]
Romain Beaumont
@rom1504
Sep 03 2015 22:10
[switch, [["varint","int","byte]]]
Robin Lambertz
@roblabla
Sep 03 2015 22:10
XD
Romain Beaumont
@rom1504
Sep 03 2015 22:10
yes :p
that way the protocol.json would be 100% unreadable
Robin Lambertz
@roblabla
Sep 03 2015 22:10
I wish json had native hex :(
Romain Beaumont
@rom1504
Sep 03 2015 22:10
but it would be short
Robin Lambertz
@roblabla
Sep 03 2015 22:10
rom1504, wasn't that what we wanted ?
:P
Romain Beaumont
@rom1504
Sep 03 2015 22:11
about referencing field, there's something called https://github.com/manuelstofer/json-pointer which has a rfc and all, and might be interesting instead of using js convention of '.'
just a shame the rfc is so crappily written and I don't understand it
Robin Lambertz
@roblabla
Sep 03 2015 22:12
I remember reading this
Robin Lambertz
@roblabla
Sep 03 2015 22:12
the biggest problem I have with those :P
so unreadable
rom1504, tbh this is probably only implemented in nodejs and... nodejs :P
Robin Lambertz
@roblabla
Sep 03 2015 22:14
.>'
no implementation in rust or C ;_;
fine you win
so long as the syntax isn't too much more complicated I guess I'm fine with using prior art
Romain Beaumont
@rom1504
Sep 03 2015 22:15
well I win about it being implemented in many languages
I still don't understand json pointers :p
I don't think they are powerful enough actually
no '..'
it's like xpath but much less powerful
Robin Lambertz
@roblabla
Sep 03 2015 22:16
we'd need '..', './' and '/' :P
(we're doing a filesystem now... oh lord)
it doesn't look like they were made to be embed into a json
Robin Lambertz
@roblabla
Sep 03 2015 22:17
it's over 9000 !!!
Romain Beaumont
@rom1504
Sep 03 2015 22:18
:P
Robin Lambertz
@roblabla
Sep 03 2015 22:18
yeah no not that kind of ..
Robin Lambertz
@roblabla
Sep 03 2015 22:18
the thing is their stuff is like an 'external tool' of sort
it's not a json field that points to another json field
that's what we want
Romain Beaumont
@rom1504
Sep 03 2015 22:19
yeah hmm
that's json pointers
Robin Lambertz
@roblabla
Sep 03 2015 22:19
what we want is closer to a symbolic link
Romain Beaumont
@rom1504
Sep 03 2015 22:19
but json pointers are weak
whatever
none of this shit is mature enough
Robin Lambertz
@roblabla
Sep 03 2015 22:20
we totally have a superior format
:P
Romain Beaumont
@rom1504
Sep 03 2015 22:20
let's keep 'super.super.super'
Robin Lambertz
@roblabla
Sep 03 2015 22:20
If it makes you happy, i'm ok with replacing dots with slashes
:P
that's totally the biggest difference between us and the standard haha
Romain Beaumont
@rom1504
Sep 03 2015 22:21
yeah '../../..' might be clearer honestly
'super' feels like java
Robin Lambertz
@roblabla
Sep 03 2015 22:21
Agreed.
and '/' for root.
Romain Beaumont
@rom1504
Sep 03 2015 22:22
yeah