-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add the same block events as mineflayer #56
Conversation
prismarine-chunk is also doing a get internally for each set. Maybe we could have only 1 get per set by changing a bit the setBlock of prismarine-chunk to have it return the old block (it currently returns nothing). https://github.com/PrismarineJS/prismarine-chunk/blob/master/src/pc/1.13/ChunkSection.js#L138 |
yeah indeed that's an option |
wdym ? getBlockType and getBlockData are indeed alias for getBlockStateId, but the getBlock(Sky)Light are from different sources. imo the most important to have is getBlockStateId as getBlock is just a wrapper arround it (adding the instanciation of a Block object) |
ah yeah true light is from a different source |
What I meant is doing something like: setBlock (pos, block) {
let old = null
if (typeof block.stateId !== 'undefined') {
// assume each function is returning the old value
let stateId = this.setBlockStateId(pos, block.stateId)
old = Block.fromStateId(stateId, block.biome)
} else {
let stateId = this.getBlockStateId(pos)
old = Block.fromStateId(stateId, block.biome)
}
if (typeof block.biome !== 'undefined') {
old.biome = this.setBiome(pos, block.biome.id)
} else { /*get*/ }
if (typeof block.skyLight !== 'undefined') {
old.skyLight = this.setSkyLight(pos, block.skyLight)
} else { /*get*/ }
if (typeof block.light !== 'undefined') {
old.light = this.setBlockLight(pos, block.light)
} else { /*get*/ }
return old
} |
yes I got it. |
ah or do you mean replacing all the setBlockX by this |
I'll try to use this in mineflayer before merging |
see https://github.com/PrismarineJS/mineflayer/blob/master/docs/api.md#blockupdate-oldblock-newblock working towards PrismarineJS/mineflayer#334 (comment) this will do a get at each set, making the set methods a bit slower it is needed to keep compatibility with mineflayer I think it is ok as initialize can be used to do a faster set for many blocks
145f712
to
09c636d
Compare
see https://github.com/PrismarineJS/mineflayer/blob/master/docs/api.md#blockupdate-oldblock-newblock
working towards PrismarineJS/mineflayer#334 (comment)
this will do a get at each set, making the set methods a bit slower
it is needed to keep compatibility with mineflayer
I think it is ok as initialize can be used to do a faster set for many blocks