Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/air.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.transparent = true,
.absorbedLight = 0x000000,
.viewThrough = true,
.replacable = true,
.replaceable = true,
.rotation = "cubyz:no_rotation",
.degradable = true,
.hasItem = false,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/bolete.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.drops = .{
.{.items = .{.auto}},
},
.replacable = true,
.replaceable = true,
.viewThrough = true,
.degradable = true,
.absorbedLight = 0x010101,
Expand Down
1 change: 1 addition & 0 deletions assets/cubyz/blocks/cold_grass_vegetation.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
.item = .{
.texture = "cold_grass.png",
},
.replaceable = true,
.lodReplacement = "cubyz:air",
}
1 change: 1 addition & 0 deletions assets/cubyz/blocks/dry_grass_vegetation.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
.item = .{
.texture = "dry_grass.png",
},
.replaceable = true,
.lodReplacement = "cubyz:air",
}
1 change: 1 addition & 0 deletions assets/cubyz/blocks/fern.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
.item = .{
.texture = "fern.png",
},
.replaceable = true,
.lodReplacement = "cubyz:air",
}
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/fog/_defaults.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.degradable = true,
.transparent = true,
.hasBackFace = true,
.replacable = true,
.replaceable = true,
.collide = false,

.model = "cubyz:cube",
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/glimmergill.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.drops = .{
.{.items = .{.auto}},
},
.replacable = true,
.replaceable = true,
.degradable = true,
.viewThrough = true,
.absorbedLight = 0x010101,
Expand Down
1 change: 1 addition & 0 deletions assets/cubyz/blocks/grass_vegetation.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
.item = .{
.texture = "grass.png",
},
.replaceable = true,
.lodReplacement = "cubyz:air",
}
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/lava.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.tags = .{.fluid},
.drops = .{},
.selectable = false,
.replacable = true,
.replaceable = true,
.degradable = true,
.transparent = true,
.hasBackFace = true,
Expand Down
1 change: 1 addition & 0 deletions assets/cubyz/blocks/lush_grass_vegetation.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
.item = .{
.texture = "lush_grass.png",
},
.replaceable = true,
.lodReplacement = "cubyz:air",
}
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/sulfur_torch.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.drops = .{
.{.items = .{.auto}},
},
.replacable = true,
.replaceable = true,
.emittedLight = 0x2b81b2,
.viewThrough = true,
.absorbedLight = 0x010101,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/toadstool.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.drops = .{
.{.items = .{.auto}},
},
.replacable = true,
.replaceable = true,
.degradable = true,
.viewThrough = true,
.absorbedLight = 0x010101,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/torch.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.drops = .{
.{.items = .{.auto}},
},
.replacable = true,
.replaceable = true,
.emittedLight = 0xa58d73,
.viewThrough = true,
.absorbedLight = 0x010101,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/blocks/water.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.tags = .{.fluid},
.drops = .{},
.selectable = false,
.replacable = true,
.replaceable = true,
.degradable = true,
.transparent = true,
.hasBackFace = true,
Expand Down
6 changes: 3 additions & 3 deletions mods/cubyz/rotation/branch.zig
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,13 @@ pub fn generateData(
) bool {
const canConnectToNeighbor = currentBlock.mode() == neighborBlock.mode() and currentBlock.modeData() == neighborBlock.modeData();

if(blockPlacing or canConnectToNeighbor or !neighborBlock.replacable()) {
if(blockPlacing or canConnectToNeighbor or !neighborBlock.replaceable()) {
const neighborModel = blocks.meshes.model(neighborBlock).model();

var currentData = BranchData.init(currentBlock.data);
// Branch block upon placement should extend towards a block it was placed
// on if the block is solid or also uses branch model.
const targetVal = ((!neighborBlock.replacable() and (!neighborBlock.viewThrough() or canConnectToNeighbor)) and (canConnectToNeighbor or neighborModel.isNeighborOccluded[neighbor.?.reverse().toInt()]));
const targetVal = ((!neighborBlock.replaceable() and (!neighborBlock.viewThrough() or canConnectToNeighbor)) and (canConnectToNeighbor or neighborModel.isNeighborOccluded[neighbor.?.reverse().toInt()]));
currentData.setConnection(neighbor.?, targetVal);

const result: u16 = currentData.enabledConnections;
Expand All @@ -371,7 +371,7 @@ pub fn updateData(block: *Block, neighbor: Neighbor, neighborBlock: Block) bool
if(canConnectToNeighbor) {
const neighborData = BranchData.init(neighborBlock.data);
currentData.setConnection(neighbor, neighborData.isConnected(neighbor.reverse()));
} else if(neighborBlock.replacable()) {
} else if(neighborBlock.replaceable()) {
currentData.setConnection(neighbor, false);
}

Expand Down
2 changes: 1 addition & 1 deletion mods/cubyz/rotation/fence.zig
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn updateData(block: *Block, neighbor: Neighbor, neighborBlock: Block) bool
const blockBaseModelIndex = blocks.meshes.modelIndexStart(block.*);
const neighborBaseModelIndex = blocks.meshes.modelIndexStart(neighborBlock);
const neighborModel = blocks.meshes.model(neighborBlock).model();
const targetVal = !neighborBlock.replacable() and !neighborBlock.transparent() and (blockBaseModelIndex == neighborBaseModelIndex or neighborModel.isNeighborOccluded[neighbor.reverse().toInt()]);
const targetVal = !neighborBlock.replaceable() and !neighborBlock.transparent() and (blockBaseModelIndex == neighborBaseModelIndex or neighborModel.isNeighborOccluded[neighbor.reverse().toInt()]);
var currentData: FenceData = @bitCast(@as(u4, @truncate(block.data)));
switch(neighbor) {
.dirNegX => {
Expand Down
2 changes: 1 addition & 1 deletion mods/cubyz/rotation/hanging.zig
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn generateData(_: *main.game.World, _: Vec3i, _: Vec3f, _: Vec3f, _: Vec3i,
if(neighbor != Neighbor.dirUp) return false;
if(!sameBlock) {
const neighborModel = neighborBlock.mode().model(neighborBlock).model();
const support = !neighborBlock.replacable() and neighborModel.neighborFacingQuads[Neighbor.dirDown.toInt()].len != 0;
const support = !neighborBlock.replaceable() and neighborModel.neighborFacingQuads[Neighbor.dirDown.toInt()].len != 0;
if(!support) return false;
}
currentData.data = 1;
Expand Down
4 changes: 2 additions & 2 deletions mods/cubyz/rotation/log.zig
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ pub fn generateData(
) bool {
const canConnectToNeighbor = currentBlock.mode() == neighborBlock.mode();

if(blockPlacing or canConnectToNeighbor or !neighborBlock.replacable()) {
if(blockPlacing or canConnectToNeighbor or !neighborBlock.replaceable()) {
const neighborModel = blocks.meshes.model(neighborBlock).model();

var currentData = LogData.init(currentBlock.data);
// Log block upon placement should extend towards a block it was placed
// on if the block is solid or also uses log model.
const targetVal = ((!neighborBlock.replacable() and (!neighborBlock.viewThrough() or canConnectToNeighbor)) and (canConnectToNeighbor or neighborModel.isNeighborOccluded[neighbor.?.reverse().toInt()]));
const targetVal = ((!neighborBlock.replaceable() and (!neighborBlock.viewThrough() or canConnectToNeighbor)) and (canConnectToNeighbor or neighborModel.isNeighborOccluded[neighbor.?.reverse().toInt()]));
currentData.setConnection(neighbor.?, targetVal);

for(Neighbor.iterable) |side| {
Expand Down
4 changes: 2 additions & 2 deletions mods/cubyz/rotation/torch.zig
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn rotateZ(data: u16, angle: Degrees) u16 {
pub fn generateData(_: *main.game.World, _: Vec3i, _: Vec3f, _: Vec3f, relativeDir: Vec3i, neighbor: ?Neighbor, currentData: *Block, neighborBlock: Block, _: bool) bool {
if(neighbor == null) return false;
const neighborModel = blocks.meshes.model(neighborBlock).model();
const neighborSupport = !neighborBlock.replacable() and neighborModel.neighborFacingQuads[neighbor.?.reverse().toInt()].len != 0;
const neighborSupport = !neighborBlock.replaceable() and neighborModel.neighborFacingQuads[neighbor.?.reverse().toInt()].len != 0;
if(!neighborSupport) return false;
var data: TorchData = @bitCast(@as(u5, @truncate(currentData.data)));
if(relativeDir[0] == 1) data.posX = true;
Expand All @@ -141,7 +141,7 @@ pub fn generateData(_: *main.game.World, _: Vec3i, _: Vec3f, _: Vec3f, relativeD

pub fn updateData(block: *Block, neighbor: Neighbor, neighborBlock: Block) bool {
const neighborModel = blocks.meshes.model(neighborBlock).model();
const neighborSupport = !neighborBlock.replacable() and neighborModel.neighborFacingQuads[neighbor.reverse().toInt()].len != 0;
const neighborSupport = !neighborBlock.replaceable() and neighborModel.neighborFacingQuads[neighbor.reverse().toInt()].len != 0;
var currentData: TorchData = @bitCast(@as(u5, @truncate(block.data)));
switch(neighbor) {
.dirNegX => {
Expand Down
8 changes: 4 additions & 4 deletions src/blocks.zig
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var _blockHealth: [maxBlockCount]f32 = undefined;
var _blockResistance: [maxBlockCount]f32 = undefined;

/// Whether you can replace it with another block, mainly used for fluids/gases
var _replacable: [maxBlockCount]bool = undefined;
var _replaceable: [maxBlockCount]bool = undefined;
var _selectable: [maxBlockCount]bool = undefined;
var _blockDrops: [maxBlockCount][]BlockDrop = undefined;
/// Meaning undegradable parts of trees or other structures can grow through this block.
Expand Down Expand Up @@ -118,7 +118,7 @@ pub fn register(_: []const u8, id: []const u8, zon: ZonElement) u16 {
_absorption[size] = zon.get(u32, "absorbedLight", 0xffffff);
_degradable[size] = zon.get(bool, "degradable", false);
_selectable[size] = zon.get(bool, "selectable", true);
_replacable[size] = zon.get(bool, "replacable", false);
_replaceable[size] = zon.get(bool, "replaceable", false);
_onInteract[size] = blk: {
break :blk ClientBlockCallback.init(zon.getChildOrNull("onInteract") orelse break :blk .noop) orelse {
std.log.err("Failed to load onInteract event for block {s}", .{id});
Expand Down Expand Up @@ -336,8 +336,8 @@ pub const Block = packed struct { // MARK: Block
}

/// Whether you can replace it with another block, mainly used for fluids/gases
pub inline fn replacable(self: Block) bool {
return _replacable[self.typ];
pub inline fn replaceable(self: Block) bool {
return _replaceable[self.typ];
}

pub inline fn selectable(self: Block) bool {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ pub const MeshSelection = struct { // MARK: MeshSelection
return;
}
} else {
if(!block.replacable()) return;
if(!block.replaceable()) return;
block.typ = itemBlock;
block.data = 0;
if(rotationMode.generateData(main.game.world.?, neighborPos, relPos, lastDir, neighborDir, neighborOfSelection, &block, neighborBlock, true)) {
Expand Down
2 changes: 1 addition & 1 deletion src/rotation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub const RotationMode = struct { // MARK: RotationMode
shouldDropSourceBlockOnSuccess.* = true;
if(oldBlock == newBlock) return .no;
if(oldBlock.typ == newBlock.typ) return .yes;
if(!oldBlock.replacable()) {
if(!oldBlock.replaceable()) {
var damage: f32 = main.game.Player.defaultBlockDamage;
const isTool = item.item != null and item.item.? == .tool;
if(isTool) {
Expand Down