Skip to content

Saplings and Seeds - #2585

Open
tillpp wants to merge 34 commits into
PixelGuys:masterfrom
tillpp:saplings
Open

Saplings and Seeds#2585
tillpp wants to merge 34 commits into
PixelGuys:masterfrom
tillpp:saplings

Conversation

@tillpp

@tillpp tillpp commented Feb 22, 2026

Copy link
Copy Markdown
Contributor
output.mp4

Be able to to add saplings, and other structures growable structures.

.{
	..
	.onTick = .{
		.type = .sapling,
		.structures = .{
			.{
				.id = "cubyz:sbb",
				.structure = "cubyz:tree/oak/white", // what structure should be grown?
				.placeMode = .degradable,
				.chance = 0.03, // chance, that tick will cause this to grow
			},
			// other alternative structures, this sapling can grow into
		},		
	},
	..
}

@IntegratedQuantum

Copy link
Copy Markdown
Member

Why do some of them decay instantly?

@tillpp

tillpp commented Feb 23, 2026

Copy link
Copy Markdown
Contributor Author

Why do some of them decay instantly?

I think it's because default tree generation creates too many leafs, and they then instantly decay because their are too far away from a branch/log

@IntegratedQuantum

Copy link
Copy Markdown
Member

Are you sure that's the case?
These things could also happen if it does the updates during your placement.

@tillpp

tillpp commented Feb 23, 2026

Copy link
Copy Markdown
Contributor Author

Are you sure that's the case? These things could also happen if it does the updates during your placement.

oh you mean, sometimes leafs are generated before stems are generated?

@IntegratedQuantum

Copy link
Copy Markdown
Member

yes

@tillpp

tillpp commented Feb 24, 2026

Copy link
Copy Markdown
Contributor Author

I think this is a general problem with the Blueprint.paste() function, so I think It's better to fix that in a separate PR.

@IntegratedQuantum IntegratedQuantum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some flaws with your approach. Instead of unnecessarily trying to bend your code around the terrain generation system, I'd suggest to directly reference the underlying SBB.

Comment thread src/server/terrain/simple_structures/Boulder.zig Outdated
Comment thread src/callbacks/block/server/sapling.zig Outdated
Comment thread src/callbacks/block/server/sapling.zig Outdated
Comment thread src/server/terrain/simple_structures/SbbGen.zig Outdated
Comment thread src/callbacks/block/server/sapling.zig Outdated
@tillpp

tillpp commented Feb 25, 2026

Copy link
Copy Markdown
Contributor Author

One problem i have, is that It feels too laggy if you have too many trees growing at once,
what do you think?

Maybe the way we paste Blueprint has to be optimized.

(Btw does someone know why the check failed)

@Wunka

Wunka commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

(Btw does someone know why the check failed)

You get a recursion of imports through pub const SimpleStructures = @import("simple_structures/_list.zig"); in biomes.zig
At least that is what I think because the test passes If I remove that and instead do
const sbbGen = @import("../../../server/terrain/simple_structures/SbbGen.zig"); inside sapling.zig but that is pretty cursed so I hope for you that you find some other way

@IntegratedQuantum

Copy link
Copy Markdown
Member

One problem i have, is that It feels too laggy if you have too many trees growing at once,
what do you think?

Well, if you have a performance problem: Measure it.

If the problem is mesh light sampling then #2405 might help improve it a bit. Other than that, there is a good chance that it's just the light updates.

@tillpp

tillpp commented Feb 25, 2026

Copy link
Copy Markdown
Contributor Author

I think the lagg spikes are soo big, that i dont really need to meassure something:
(each line is a tree that grows)
I think optimizing Blueprint pasting is something we need to work on

grafik

also thanks @Wunka for the tip

@tillpp
tillpp marked this pull request as ready for review February 26, 2026 05:05
@BoySanic BoySanic moved this to In review in PRs to review Feb 26, 2026
@IntegratedQuantum

Copy link
Copy Markdown
Member

I think the lagg spikes are soo big, that i dont really need to meassure something:

The measuring is to figure out what exactly is responsible for this. And I doubt that it's the blueprint pasting.

.drops = .{
.{.items = .{.auto}, .allowedToolTags = .{.cuttable}},
.{.chance = 0.01, .items = .{"cubyz:apple"}, .forbiddenToolTags = .{.cuttable}},
.{.chance = 0.001, .items = .{"cubyz:sapling/oak"}, .forbiddenToolTags = .{.cuttable}},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many leaf blocks are there in a tree?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably less then 1000

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have those numbers, I think for all saplings the number of saplings per tree should be consistent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to count them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the amount of leaves varies because of the generation

Comment thread src/callbacks/block/server/sapling.zig Outdated
Comment thread src/server/terrain/simple_structures/SbbGen.zig Outdated
Comment thread src/blueprint.zig Outdated
Comment thread src/server/world.zig
Comment thread src/server/world.zig Outdated
Comment thread src/callbacks/block/server/sapling.zig Outdated
Comment thread src/callbacks/block/server/sapling.zig Outdated
@careeoki

careeoki commented May 7, 2026

Copy link
Copy Markdown
Contributor

How close are we to having saplings with growth stages that have different models?

@Argmaster

Copy link
Copy Markdown
Collaborator

Nowhere close

@tillpp

tillpp commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

requires: #3043

@tillpp

tillpp commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

I think my PR broke the formatter:
grafik
(it still keeps printing)

but the game compiles

@tillpp

tillpp commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

good news: no problem on client side
bad news: server gets overwhelmed if you spam saplings

@tillpp

tillpp commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@careeoki

How close are we to having saplings with growth stages that have different models?

it depends.
In this PR one block and summon a SBB structure.
of course the resulting SBB structure can itself summon a SBB structure.
You can use this to chain SBB together to simulate something growing.
(like sugar cane or something)

but more complex stuff isn't possible with this yet. (like checking if the sugar cane isn't too big already (well technically it is possible, but it wouldn't be nice to implement), or removing a bigger SBB with a smaller SBB afterwards)

@Crepestrom

Copy link
Copy Markdown
Contributor

do you have any clue why the server is dieing?

@IntegratedQuantum

Copy link
Copy Markdown
Member

server gets overwhelmed if you spam saplings

even in release?

@tillpp

tillpp commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

even in release?

its better in release.
But my computer is also unrepresentative of the average gamer. (humble flex)
So I hope someone with a bad PC can test this by doing:

  1. select a medium sized region with the selection wand (but z height = 1)
  2. /set cubyz:sapling/oak
  3. while seeing the saplings grow, try to drop item
  4. can you see the items drop and move?

@IntegratedQuantum

Copy link
Copy Markdown
Member

There was an issue in chunk saving, it always saved it immediately instead of waiting 5 seconds in case other changes happened.
With bccdbda it should be more balanced now.

@tillpp

tillpp commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

i did merge master and my computer still struggles
nothing grows, no items drop when pressing Q. but when rejoining i can see the dropped items and the trees growing. So maybe it is the network who is overwhelmed:
grafik

@IntegratedQuantum

Copy link
Copy Markdown
Member

yes, this is #3250, it should at least be a little better though.

@IntegratedQuantum

Copy link
Copy Markdown
Member

When I was testing this, I also noticed that the roots are replacing all ground blocks, instead of checking for decayable.

@tillpp

tillpp commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

decayable

I assume you meant degradeable?

@tillpp

tillpp commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

it should at least be a little better though.

yeah a little bit:

grafik

pos[1] = chunk.super.pos.wy + pastePosition[1];
pos[2] = chunk.super.pos.wz + pastePosition[2];

rotated.blueprint.paste(pos, .{.replaceUndegradable = false});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be configurable via self.placeMode, like when placed in generation.

pub const generationMode = .floor;

const SbbGen = @This();
pub const SbbGen = @This();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes no sense to make this public

Comment thread src/server/world.zig

/// Returns the actual block on failure
pub fn cmpxchgBlock(self: *ServerWorld, wx: i32, wy: i32, wz: i32, oldBlock: ?Block, _newBlock: Block) ?Block {
pub fn cmpxchgBlock(self: *ServerWorld, wx: i32, wy: i32, wz: i32, oldBlock: ?Block, _newBlock: Block, comptime noUpdate: bool) ?Block {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use an enum to improve reasability at the callsite

@Argmaster

Copy link
Copy Markdown
Collaborator

I think I will look into taking over this PR soon, after I'm done with #3446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

8 participants