Skip to content
Open
Show file tree
Hide file tree
Changes from 93 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
ba74b99
renamed _leaves to /leaves
tillpp Nov 11, 2025
cd8282d
added decayability settings to logs and leaves
tillpp Nov 11, 2025
f089bb4
leaves do decay!
tillpp Nov 11, 2025
634f443
removed .logBreak, updates happen when anyblock is broken,
tillpp Nov 11, 2025
448abe2
.onUpdate .leafBreak replaces .decayable
tillpp Nov 11, 2025
5777cb5
zig: added onUpdate and leafDecay, removed DelayedEventQueue and logB…
tillpp Nov 11, 2025
b75da2a
comments
tillpp Nov 11, 2025
979004a
leafdecay a bit faster
tillpp Nov 11, 2025
ee6b3e0
Bugfix: undecayable leaves were decaying too
tillpp Nov 12, 2025
6b840f1
making the code uglier (using the formatter)
tillpp Nov 12, 2025
e195369
making all files ugly (using formatter on all files)
tillpp Nov 12, 2025
c62e400
make .zon files ugly too (formatted)
tillpp Nov 12, 2025
0b8fbe8
whitespace in comments
tillpp Nov 12, 2025
c284468
(forgot to delete a debug line)
tillpp Nov 12, 2025
c819ef1
Merge branch 'PixelGuys:master' into LeaveDecay
tillpp Nov 13, 2025
c497bf5
Merge branch 'master' into LeaveDecay
tillpp Nov 13, 2025
286a57c
new commit on master used old name: https://github.com/PixelGuys/Cuby…
tillpp Nov 13, 2025
9bc4a02
Merge branch 'master' into LeaveDecay
tillpp Nov 13, 2025
1fdc836
refactor, moved undecayables in seperate folder
tillpp Nov 13, 2025
e7543e9
removed double _opaques.png
tillpp Nov 13, 2025
06c5c46
undecayables also point to opaque/ instead of _opaque now
tillpp Nov 13, 2025
dbaf081
Merge branch 'PixelGuys:master' into LeaveDecay
tillpp Nov 13, 2025
81d3b86
Merge branch 'PixelGuys:master' into LeaveDecay
tillpp Nov 15, 2025
8a2210e
Merge branch 'PixelGuys:master' into LeaveDecay
tillpp Nov 15, 2025
40090ff
removed _decayable property
tillpp Nov 15, 2025
5bc6a8f
used _defaults for undecayables
tillpp Nov 15, 2025
3c5a2a2
code cleaner
tillpp Nov 15, 2025
541782a
make server block callback _list.zig alphabetically
tillpp Nov 16, 2025
3d4533b
use L2 instead of L1 Norm
tillpp Nov 16, 2025
06592ab
branches prevent leaves from decaying
tillpp Nov 16, 2025
e109703
replacec chunk.getBlock with server.getBlock (idk but it works now)
tillpp Nov 17, 2025
2bdd785
typo: leaf insteaf of leave
tillpp Nov 17, 2025
f9e496f
fmt
tillpp Nov 17, 2025
9c8b693
flag is set before entry to the queue
tillpp Nov 17, 2025
73276b0
always surrounding when placing or breaking a block. use cmpxchgBlock…
tillpp Nov 17, 2025
de523df
added custom decay product
tillpp Nov 17, 2025
342dbba
call onBreak event only if block gets broken
tillpp Nov 17, 2025
2c1dcc6
fmt
tillpp Nov 17, 2025
56bf2a5
consistent blockupdate processing
tillpp Nov 17, 2025
5bd55e1
only update direct neighbours when breaking a block
tillpp Nov 17, 2025
a7ffacf
log breaks do updates bigger area
tillpp Nov 17, 2025
f84c04c
Timed updates
tillpp Nov 19, 2025
2be7203
fmt
tillpp Nov 19, 2025
588fbac
removed legacy comment
tillpp Nov 19, 2025
cabb65d
use naturalDefault
tillpp Nov 20, 2025
277e8d8
TODOs are not cool anymore :,(
tillpp Nov 20, 2025
b5b68c4
use stackAllocator instead
tillpp Nov 20, 2025
900ed25
Only update within loaded chunks
tillpp Nov 20, 2025
a18ec0b
rename inTicks to delayTicks
tillpp Nov 20, 2025
7cdf90f
no timed event.
tillpp Nov 21, 2025
c27990b
Leave the hanging Leaf problem for a future PR
tillpp Nov 21, 2025
a8b8d9d
decayReplacement is part of the callback now.
tillpp Nov 22, 2025
023a6ce
onBreak on every break event
tillpp Nov 22, 2025
87287b6
use early exit in leaf log-search check
tillpp Nov 22, 2025
2440eee
use Vec3i instead of 3 different variables
tillpp Nov 22, 2025
ed802df
fmt
tillpp Nov 22, 2025
5427c96
leafDecay: only return .handled when block was actually changed
tillpp Nov 22, 2025
d0026c9
renamed updateSurrounding to triggerNeighborBlockUpdates
tillpp Nov 22, 2025
1638f70
removed useless allocation for updateSystem
tillpp Nov 22, 2025
186ce8b
use mutex and ListUnmanaged instead
tillpp Nov 22, 2025
3394618
undecayable is now handled by rotation
tillpp Nov 22, 2025
5937a1c
fmt
tillpp Nov 22, 2025
96e2617
correct item drop for leaves
tillpp Nov 22, 2025
6bc9951
fmt
tillpp Nov 22, 2025
6bf83fb
updateSystem per EntetyChunk instead of entire world
tillpp Nov 22, 2025
e73ce71
fmt
tillpp Nov 22, 2025
e95584a
renamed UpdateSystem to BlockUpdateSystem
tillpp Nov 22, 2025
415a644
Use wrapping arithmetic in world space for leafDecay
tillpp Nov 22, 2025
a8dd749
Dont lock mutex during deinit
tillpp Nov 22, 2025
014d4e1
Merge branch 'LeaveDecay' of https://github.com/tillpp/Cubzio into Le…
tillpp Nov 22, 2025
5710a5f
use u5 as position relative to chunk
tillpp Nov 22, 2025
5e80ca3
_decayProhibitor init in the same order as above
tillpp Nov 22, 2025
ed204d1
pointless (but linefull) comment got deleted
tillpp Nov 22, 2025
7e56a73
moved functions in order of array declaration
tillpp Nov 22, 2025
6301765
removed unintended line change.
tillpp Nov 22, 2025
c4c715a
use .branch and .log tags
tillpp Nov 23, 2025
e25c55e
introduce callback deinit
tillpp Nov 23, 2025
4aa4ed5
Merge branch 'master' into BranchDecay
tillpp Nov 23, 2025
046393e
removed decay prohibitor
tillpp Nov 23, 2025
6ce1be7
fmt
tillpp Nov 23, 2025
79b8ccb
whitespace in comments
tillpp Nov 23, 2025
8fb3788
forgot to delete the old leadDecay.zig
tillpp Nov 23, 2025
b42d73e
added https://github.com/Argmaster optimization: branches only look t…
tillpp Nov 24, 2025
aa1fafa
bugfix: wrong block getting compared for branch connectivity
tillpp Nov 24, 2025
e6ac49e
fixed: https://github.com/PixelGuys/Cubyz/pull/2334#issuecomment-3570…
tillpp Nov 24, 2025
6a5ab35
Merge branch 'PixelGuys:master' into BranchDecay
tillpp Nov 24, 2025
d178573
make Cactus branches decayable
tillpp Nov 25, 2025
483a06b
Branches look for any solid blocks
tillpp Nov 25, 2025
1fa3c9c
added candy_cane and palm
tillpp Nov 25, 2025
0343817
.Decay doesnt need a .prevention for branches anymore
tillpp Nov 25, 2025
f973e36
fmt
tillpp Nov 25, 2025
46cfd7f
Merge branch 'PixelGuys:master' into BranchDecay
tillpp Nov 26, 2025
0dae77b
Merge remote-tracking branch 'origin/master' into BranchDecay
tillpp Nov 29, 2025
edfeac6
decapitalizing Decay
tillpp Dec 1, 2025
a496fc9
decapitalizing decay.
tillpp Dec 1, 2025
84287d8
removed Callback deinits
tillpp Dec 1, 2025
2e92ba2
fmt
tillpp Dec 1, 2025
1e4c5b9
Merge branch 'PixelGuys:master' into BranchDecay
tillpp Dec 1, 2025
1547916
mushrooms are considered branches
tillpp Dec 1, 2025
4608a81
branch connecting block has to be opaque to stop decay
tillpp Dec 1, 2025
87c56a0
forgot to lowercase the cactus_arm
tillpp Dec 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/baobab_branch.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 4,
.drops = .{
.{.items = .{.auto}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/baobab_log.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/baobab"}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/baobab_top.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/baobab"}},
Expand Down
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/birch_branch.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 4,
.drops = .{
.{.items = .{.auto}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/birch_log.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/birch"}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/birch_top.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/birch"}},
Expand Down
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/bolete_branch.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .cuttable, .mushroom},
.tags = .{.choppable, .cuttable, .mushroom, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 2,
.drops = .{
.{.items = .{.auto}},
Expand Down
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/branch/leafy/_defaults.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .cuttable, .leaf},
.tags = .{.choppable, .cuttable, .leaf, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 0.5,
.absorbedLight = 0x202830,
.alwaysViewThrough = true,
Expand Down
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/branch/palm.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 4,
.drops = .{
.{.items = .{.auto}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/cactus.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .cuttable},
.tags = .{.choppable, .cuttable, .log},
.blockHealth = 5,
.drops = .{
.{.items = .{"cubyz:log/cactus"}},
Expand Down
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/cactus_arm.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .cuttable},
.tags = .{.choppable, .cuttable, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 2.5,
.drops = .{
.{.items = .{.auto}},
Expand Down
3 changes: 3 additions & 0 deletions assets/cubyz/blocks/candy_cane/branch.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .wood},
.onUpdate = .{
.type = .Decay,
},
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if they should decay. They are really not like normal trees.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I only did this, because carrie requested it: #2334 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@careeoki what do you think now?

Copy link
Contributor

Choose a reason for hiding this comment

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

They don't have to decay if we don't want them to. My main concern was palm branch and cactus arms

.blockHealth = 4,
.drops = .{
.{.items = .{.auto}},
Expand Down
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/glimmergill_branch.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .cuttable, .mushroom},
.tags = .{.choppable, .cuttable, .mushroom, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 2,
.drops = .{
.{.items = .{.auto}},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/leaves/_defaults.zig.zon
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.{
.onUpdate = .{
.type = .leafDecay,
.type = .Decay,
.prevention = .{.log, .branch},
},
.rotation = "cubyz:decayable",
.tags = .{.cuttable, .leaf},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/log/_defaults.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{.auto}},
Expand Down
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/mahogany_branch.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 4,
.drops = .{
.{.items = .{.auto}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/mahogany_log.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/mahogany"}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/mahogany_top.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/mahogany"}},
Expand Down
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/oak_branch.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 4,
.drops = .{
.{.items = .{.auto}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/oak_log.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/oak"}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/oak_top.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/oak"}},
Expand Down
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/pine_branch.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 4,
.drops = .{
.{.items = .{.auto}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/pine_log.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/pine"}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/pine_top.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/pine"}},
Expand Down
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/toadstool_branch.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .cuttable, .mushroom},
.tags = .{.choppable, .cuttable, .mushroom, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 2,
.drops = .{
.{.items = .{.auto}},
Expand Down
5 changes: 4 additions & 1 deletion assets/cubyz/blocks/willow_branch.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .branch},
.onUpdate = .{
.type = .Decay,
},
.blockHealth = 4,
.drops = .{
.{.items = .{.auto}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/willow_log.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/willow"}},
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/willow_top.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.tags = .{.choppable, .wood},
.tags = .{.choppable, .wood, .log},
.blockHealth = 8,
.drops = .{
.{.items = .{"cubyz:log/willow"}},
Expand Down
10 changes: 6 additions & 4 deletions mods/cubyz/rotation/branch.zig
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ const HashMapKey = struct {
return std.mem.eql(u8, val1.shellModelId, val2.shellModelId);
}
};
pub const BranchData = packed struct(u6) {
pub const BranchData = packed struct(u7) {
enabledConnections: u6,
placedByHuman: u1,

pub inline fn init(blockData: u16) BranchData {
return .{.enabledConnections = @truncate(blockData)};
return .{.enabledConnections = @truncate(blockData), .placedByHuman = @truncate(blockData >> 6)};
}

pub inline fn isConnected(self: @This(), neighbor: Neighbor) bool {
Expand Down Expand Up @@ -352,7 +353,8 @@ pub fn generateData(
const targetVal = ((!neighborBlock.replacable() and (!neighborBlock.viewThrough() or canConnectToNeighbor)) and (canConnectToNeighbor or neighborModel.isNeighborOccluded[neighbor.?.reverse().toInt()]));
currentData.setConnection(neighbor.?, targetVal);

const result: u16 = currentData.enabledConnections;
currentData.placedByHuman = 1;
const result: u16 = @as(u7, @bitCast(currentData));
if(result == currentBlock.data) return false;

currentBlock.data = result;
Expand All @@ -375,7 +377,7 @@ pub fn updateData(block: *Block, neighbor: Neighbor, neighborBlock: Block) bool
currentData.setConnection(neighbor, false);
}

const result: u16 = currentData.enabledConnections;
const result: u16 = @as(u7, @bitCast(currentData));
if(result == block.data) return false;

block.data = result;
Expand Down
12 changes: 7 additions & 5 deletions src/blocks.zig
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ var _absorption: [maxBlockCount]u32 = undefined;
var _onInteract: [maxBlockCount]ClientBlockCallback = undefined;
var _onBreak: [maxBlockCount]ServerBlockCallback = undefined;
var _onUpdate: [maxBlockCount]ServerBlockCallback = undefined;
var _decayProhibitor: [maxBlockCount]bool = undefined;
var _mode: [maxBlockCount]*const RotationMode = undefined;
var _modeData: [maxBlockCount]u16 = undefined;
var _lodReplacement: [maxBlockCount]u16 = undefined;
Expand Down Expand Up @@ -142,7 +141,6 @@ pub fn register(_: []const u8, id: []const u8, zon: ZonElement) u16 {
break :blk .noop;
};
};
_decayProhibitor[size] = zon.get(bool, "decayProhibitor", false);

_transparent[size] = zon.get(bool, "transparent", false);
_collide[size] = zon.get(bool, "collide", true);
Expand Down Expand Up @@ -256,6 +254,13 @@ pub fn finishBlocks(zonElements: Assets.ZonHashMap) void {
}

pub fn reset() void {
for(0..size) |index| {
_onBreak[index].deinit();
_onTick[index].deinit();
_onInteract[index].deinit();
_onUpdate[index].deinit();
_onTouch[index].deinit();
}
size = 0;
ores = .{};
reverseIndices = .{};
Expand Down Expand Up @@ -419,9 +424,6 @@ pub const Block = packed struct { // MARK: Block
pub inline fn onUpdate(self: Block) ServerBlockCallback {
return _onUpdate[self.typ];
}
pub inline fn decayProhibitor(self: Block) bool {
return _decayProhibitor[self.typ];
}
pub inline fn mode(self: Block) *const RotationMode {
return _mode[self.typ];
}
Expand Down
1 change: 1 addition & 0 deletions src/callbacks/block/client/openWindow.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ pub fn run(self: *@This(), _: main.callbacks.ClientBlockCallback.Params) main.ca
main.Window.setMouseGrabbed(false);
return .handled;
}
pub fn deinit(_: *@This()) void {}
Loading