Skip to content
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

Clean way to set block state on local chunk coordinates? #169

Closed
maxsupermanhd opened this issue Apr 25, 2022 · 1 comment
Closed

Clean way to set block state on local chunk coordinates? #169

maxsupermanhd opened this issue Apr 25, 2022 · 1 comment
Labels
enhancement New feature or request server framework

Comments

@maxsupermanhd
Copy link
Contributor

I am trying to make procedural generation for chunks, is there a better way of setting block state than calculating section and local section coordinates? Maybe a helper function of some sort would be nice.

@maxsupermanhd
Copy link
Contributor Author

For now I came with following procedure:

func SetChunkBlock(c *level.Chunk, lx, ly, lz, bs int) {
	sid := (ly+64)/16 + 4
	if len(c.Sections) <= sid {
		log.Printf("Failed to set block %d at %d %d %d because there is no section %d (%d allocated)", bs, lx, ly, lz, sid, len(c.Sections))
		return
	}
	c.Sections[sid].SetBlock((ly%16)*16*16+lz*16+lx, bs)
}

However client ignores chunk or block is not actually placed.

@Tnze Tnze added the enhancement New feature or request label May 20, 2022
@Tnze Tnze closed this as completed Dec 4, 2022
@Tnze Tnze pinned this issue Dec 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server framework
Projects
None yet
Development

No branches or pull requests

2 participants