ChaoticTrials / SkyblockBuilder

Let you create a custom skyblock island via config
https://modrinth.com/mod/skyblock-builder
Apache License 2.0
8 stars 6 forks source link

captureBlockSnapshots cause problem #163

Closed joe-vettek closed 6 months ago

joe-vettek commented 6 months ago

Describe your idea

I didn't use debug mode before, so I didn't find the problem. I thought Skybuilder used some weird way to place the blocks. Finally, I found that the reason was the use of this.level.captureBlockSnapshots = true; I don't know why you want to use this, which resulted in the block's onplace method not being called, which is an initialization method of the block state. I don't think this is a good call. Of course BlockEntity can solve it. It's just that I need to do some extra unnecessary coding work. The most important thing is to cause trouble. image image image

joe-vettek commented 6 months ago

I also use structuretemplate.placeInWorld to place the template and it works always well without using this.level.captureBlockSnapshots = true;.

MelanX commented 6 months ago

Here is the reason for doing this: https://github.com/MelanX/SkyblockBuilder/commit/bfc8f2754c60699ecb90ab2718e1bdbdf2aa1142 If you have a better idea how I can achieve that gravel isn't falling, torches in mid air aren't droping, I'm really interested in this. Using it was never a problem since blocks were placed when creating the template -> onPlace is called -> BlockState is initialized.

joe-vettek commented 6 months ago

it's really a worldgen problem, i have ever seen the scene in desert biomes. The block don't fall until neighbor changes. if there are not tick counter and then level.scheduleTick would not work. image

joe-vettek commented 6 months ago

you can frozen it if you're placing a template.

MelanX commented 6 months ago

What exactly do you mean?

joe-vettek commented 6 months ago

the gravel fallen because the scheduleTick method of ServerLevel was called during onplace to register a timer to check whether it is floating. Just make it unregisterable.

joe-vettek commented 6 months ago

For example, i use the removeContainer(new ChunkPos(-2,-2)) in debugger at here. image Now the sand floating in the air. image image

joe-vettek commented 6 months ago

((LevelTicks<Block>)level.getBlockTicks()).removeContainer(new ChunkPos(pos)); I thought I had to use AT to change it, but it seems that there is no need to change it, the default is public. You can addContainer after you place the template.

Have test it here. image

MelanX commented 6 months ago

I tried with calling this.level.getBlockTicks().clearArea(BoundingBox.fromCorners(center, center.offset(template.getTemplate().getSize())));. This removes all the scheduled ticks for the template. Thank you very much for helping properly fixing this problem. I resolved this issue locally. Will publish it as soon as my Jenkins is working again.

MelanX commented 6 months ago

Oh wait, that would also remove the scheduled tick from your block...

joe-vettek commented 6 months ago

The way I write it is just to standardize it, and there is actually no need for scheduled. But it does need to be initialized, otherwise it will be full of uncertainty in many cases.

joe-vettek commented 6 months ago

But having said that, I think this feature should probably be allowed to be set by users?

MelanX commented 6 months ago

Sounds like a good idea.