go-mc
go-mc copied to clipboard
How do I set a block to a specific x, y, z?
Thank you for your project. I am preparing to build a server with 1.14.4. I need to send chunk data packets, but I know the player is moving. But it frequently fails to send chunk data packets.
How do I set a block to a specific x, y, z? And how to send the packet?
The reason I ask this question is because the setBlock function in level.chunk takes only index as a parameter.
func (s *Section) SetBlock(i int, v BlocksState) {
if block.IsAir(s.States.Get(i)) {
s.BlockCount--
}
if v != 0 {
s.BlockCount++
}
s.States.Set(i, v)
}
https://wiki.vg/index.php?title=Protocol&oldid=15346#Chunk_Data
I already understand block state id.
Please help me. I've been looking for it for several weeks, but it's a very difficult trip.
Dup: #169
ps: the index is between [0, 16*16*16). And the priority of x, y and z has changed in a version which I forget.
Current implementation should be not to support 1.14 out of box. Best wishes for you.
Thanks