From 020422b8b7126b90b29ccf96f80dc67d95b2cc05 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 6 Mar 2026 10:35:43 +0100 Subject: [PATCH 01/83] Assets. Co-authored-by: careeoki <122191047+careeoki@users.noreply.github.com> --- assets/cubyz/entity/cubert.zig.zon | 5 + assets/cubyz/entity/missing.zig.zon | 5 + assets/cubyz/entity/moffalo.zig.zon | 5 + assets/cubyz/entity/snail.zig.zon | 5 + assets/cubyz/entity/snale.zig.zon | 5 + assets/cubyz/entity/textures/cubert.png | Bin 0 -> 2342 bytes assets/cubyz/entity/textures/missing.png | Bin 0 -> 485 bytes assets/cubyz/entity/textures/moffalo.png | Bin 0 -> 3382 bytes assets/cubyz/entity/textures/snail.png | Bin 0 -> 1256 bytes assets/cubyz/models/entity/cubert.obj | 381 +++++++++ assets/cubyz/models/entity/missing.obj | 40 + assets/cubyz/models/entity/moffalo.obj | 765 ++++++++++++++++++ assets/cubyz/models/entity/snail.obj | 183 +++++ .../models => models/entity}/snale.obj | 0 src/entity.zig | 2 +- 15 files changed, 1395 insertions(+), 1 deletion(-) create mode 100644 assets/cubyz/entity/cubert.zig.zon create mode 100644 assets/cubyz/entity/missing.zig.zon create mode 100644 assets/cubyz/entity/moffalo.zig.zon create mode 100644 assets/cubyz/entity/snail.zig.zon create mode 100644 assets/cubyz/entity/snale.zig.zon create mode 100644 assets/cubyz/entity/textures/cubert.png create mode 100644 assets/cubyz/entity/textures/missing.png create mode 100644 assets/cubyz/entity/textures/moffalo.png create mode 100644 assets/cubyz/entity/textures/snail.png create mode 100644 assets/cubyz/models/entity/cubert.obj create mode 100644 assets/cubyz/models/entity/missing.obj create mode 100644 assets/cubyz/models/entity/moffalo.obj create mode 100644 assets/cubyz/models/entity/snail.obj rename assets/cubyz/{entity/models => models/entity}/snale.obj (100%) diff --git a/assets/cubyz/entity/cubert.zig.zon b/assets/cubyz/entity/cubert.zig.zon new file mode 100644 index 0000000000..4bb09ed512 --- /dev/null +++ b/assets/cubyz/entity/cubert.zig.zon @@ -0,0 +1,5 @@ +.{ + .model = "cubyz:entity/cubert", + .texture = "cubert.png", + .height = 2, +} diff --git a/assets/cubyz/entity/missing.zig.zon b/assets/cubyz/entity/missing.zig.zon new file mode 100644 index 0000000000..cb0d1e8b0b --- /dev/null +++ b/assets/cubyz/entity/missing.zig.zon @@ -0,0 +1,5 @@ +.{ + .model = "cubyz:entity/missing", + .texture = "missing.png", + .height = 1, +} diff --git a/assets/cubyz/entity/moffalo.zig.zon b/assets/cubyz/entity/moffalo.zig.zon new file mode 100644 index 0000000000..01ad2ece30 --- /dev/null +++ b/assets/cubyz/entity/moffalo.zig.zon @@ -0,0 +1,5 @@ +.{ + .model = "cubyz:entity/moffalo", + .texture = "moffalo.png", + .height = 1.8, +} diff --git a/assets/cubyz/entity/snail.zig.zon b/assets/cubyz/entity/snail.zig.zon new file mode 100644 index 0000000000..b1032e1f33 --- /dev/null +++ b/assets/cubyz/entity/snail.zig.zon @@ -0,0 +1,5 @@ +.{ + .model = "cubyz:entity/snail", + .texture = "snail.png", + .height = 1, +} diff --git a/assets/cubyz/entity/snale.zig.zon b/assets/cubyz/entity/snale.zig.zon new file mode 100644 index 0000000000..981ed0ec49 --- /dev/null +++ b/assets/cubyz/entity/snale.zig.zon @@ -0,0 +1,5 @@ +.{ + .model = "cubyz:entity/snale", + .texture = "snale.png", + .height = 2, +} diff --git a/assets/cubyz/entity/textures/cubert.png b/assets/cubyz/entity/textures/cubert.png new file mode 100644 index 0000000000000000000000000000000000000000..17d1512b5fc6e6f69d5e57a77bc7032bcd1a22ec GIT binary patch literal 2342 zcmV+>3EB3EP)AbBQJ!Sg7%=28bU-+NC+XJFZmD_2tuz3Js9*B5j_Mw*vka@ zGSE#V1TllrzzjvjyfNcwgLC&XM%HP6YwvIS?REA(XOHePqs@G9*n6+N*4pd;*1!Js zueJW;nHm^4_(}~C^R%f^dgJ_g#tikF)91QP&*1IEva_3?HXC<;(_riA_^4c5 zx2K`j_qK1@Y`-@!eAB$~d}EZp^Rojr%RUIaESV_06`JscH#27X!kByk_JYX*2wp5qxA&#e6PCm@g7ZKo0{VtWOzWJPRtVe!E0)f!%-8piy`td+${jk` zVcz`k`%(8G>g($pHuXep0{mV!rrTcoe08Vb(27?3E&zq+JxMs!aeh?7v-g4JiwpKT z?ixUp3XOr_zDk3PR%5EFsM>%u?Ao!te5teB-Y;4(*EAOjW^g#@^^d>piSoVn@}@G$ zDK;0(=lj}nu?d+7fZ!utSFPX{82@sGpvK&e4S^sn8?@JfC5slC-rhb_42c*R91d)Q zFSrtv2Wk`G3u(u{-}4ubor;n<6hIE`f{uN@%Yuaq0^5FWz7mJE64mW?3BGFFF=U0?iR)f<2ffcnpDnPs1kA3ttr9|&qfTl;tU z*#Ik~Hj;w)zeYy@>kNg@6~YT5;T3 zs{v>TNT792GBPk$oVrwSg5x@=*R|oiCkgN!lssz&g-E=^xAi$sBbYds9(`qP`NqiK zX3NnNsdMdx&Fjmj21d-R#wX2&pN`dKtv(i*l9c$&)a+}d(d2y;k=lCn>_osrb>IJi zq(lP#ynD~U24n&9KF(;M!2`5MnU-b<+c&&WMt&uV<(bxd?_Ya;r{iRUTbA!yyeU<` zQ*ShAW7r@F0^9ToQSoscWu+~OG##tB!&hchY+Mr9!rt`kP|ZUT-S2my$7FoAbxYdA?hRHLK@}1! zI)VSO5Pavl?()hwgB40Osh942+(yse%ORe%7YDx z;>|+UAy6s}nXEwmT0+-DD;hB7H9F&mEF)N?V~ad(?Qy?=egFjK@fWaj-+?i4kUUj!+=BoL$Qgl9$H*ASq5 z!dzGlU`Ptk-+Lnx9$<79V2P1*!Yz+{wc>fyi_;h(JO4Xtf_lUT5gtQQR1Hm)#=1x= z?*=|abqR6s=+>-RWA8~EYydS3<W1TIB8Q%3@V9ZCsz;YVGs&0QDpebh*&o@!w%N&5-0 z_#nR?b;0Wq8$@^-+Q#@BS9m_Vy{hSqCyXLJ66ztim%uR|%jfsDhT^AbQeFsRghI8q zyFFoOnvP#QYY-FFAK@)fRhBd1Jq1bXIWCqoJl-K* zIbf0iGr=)QfSKT!B*08?OcG!wIQ|0w0RR7_6@FX*000I_L_t&o07`?KGmPCtDF6Tf M07*qoM6N<$g2tk4^#A|> literal 0 HcmV?d00001 diff --git a/assets/cubyz/entity/textures/missing.png b/assets/cubyz/entity/textures/missing.png new file mode 100644 index 0000000000000000000000000000000000000000..a1a496d1e8e618190fe6ec2d13288d0363bd147f GIT binary patch literal 485 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 S(o>TF0000 Date: Fri, 6 Mar 2026 10:40:29 +0100 Subject: [PATCH 02/83] removed material --- assets/cubyz/models/entity/missing.obj | 2 -- 1 file changed, 2 deletions(-) diff --git a/assets/cubyz/models/entity/missing.obj b/assets/cubyz/models/entity/missing.obj index 31068c538a..895132ab60 100644 --- a/assets/cubyz/models/entity/missing.obj +++ b/assets/cubyz/models/entity/missing.obj @@ -1,6 +1,5 @@ # Blender v3.0.1 OBJ File: 'missing.blend' # www.blender.org -mtllib missing.mtl o Cube v 0.500000 0.500000 0.015418 v 0.500000 -0.500000 0.015418 @@ -30,7 +29,6 @@ vn -1.0000 0.0000 0.0000 vn 0.0000 -1.0000 0.0000 vn 1.0000 0.0000 0.0000 vn 0.0000 0.0000 -1.0000 -usemtl Material s off f 1/1/1 5/2/1 7/3/1 3/4/1 f 4/5/2 3/4/2 7/6/2 8/7/2 From a8fba76e240c374c4199a1f3019a9d535fb7be08 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 6 Mar 2026 10:48:53 +0100 Subject: [PATCH 03/83] added Templates for entity component and entity systems also renamed entity.zig -> clientEntity.zig to make it easier to distingues it from the already existing Entity.zig in server/ --- src/{entity.zig => clientEntity.zig} | 0 src/entityComponent/_list.zig | 1 + src/entityComponent/template.zig | 75 ++++++++++++++++++++++++++++ src/entitySystem/_list.zig | 1 + src/entitySystem/template.zig | 55 ++++++++++++++++++++ src/game.zig | 2 +- src/main.zig | 8 +-- src/network/protocols.zig | 10 ++-- src/renderer.zig | 6 +-- src/server/server.zig | 2 +- 10 files changed, 147 insertions(+), 13 deletions(-) rename src/{entity.zig => clientEntity.zig} (100%) create mode 100644 src/entityComponent/_list.zig create mode 100644 src/entityComponent/template.zig create mode 100644 src/entitySystem/_list.zig create mode 100644 src/entitySystem/template.zig diff --git a/src/entity.zig b/src/clientEntity.zig similarity index 100% rename from src/entity.zig rename to src/clientEntity.zig diff --git a/src/entityComponent/_list.zig b/src/entityComponent/_list.zig new file mode 100644 index 0000000000..bd38343dc2 --- /dev/null +++ b/src/entityComponent/_list.zig @@ -0,0 +1 @@ +pub const template = @import("template.zig"); diff --git a/src/entityComponent/template.zig b/src/entityComponent/template.zig new file mode 100644 index 0000000000..f90844993f --- /dev/null +++ b/src/entityComponent/template.zig @@ -0,0 +1,75 @@ +const std = @import("std"); + +const main = @import("main"); +const chunk = main.chunk; +const game = main.game; +const graphics = main.graphics; +const c = graphics.c; +const ZonElement = main.ZonElement; +const renderer = main.renderer; +const settings = main.settings; +const utils = main.utils; +const vec = main.vec; +const Mat4f = vec.Mat4f; +const Vec3d = vec.Vec3d; +const Vec3f = vec.Vec3f; +const Vec4f = vec.Vec4f; +const Vec3i = vec.Vec3i; +const NeverFailingAllocator = main.heap.NeverFailingAllocator; + +const BinaryReader = main.utils.BinaryReader; +const BinaryWriter = main.utils.BinaryWriter; + +const blocks = main.blocks; +const chunk_zig = main.chunk; +const ServerChunk = chunk_zig.ServerChunk; +const World = game.World; +const ServerWorld = main.server.ServerWorld; +const items = main.items; +const ItemStack = items.ItemStack; +const random = main.random; + +pub fn loadWorldAsset(assetFolder: []const u8, assets: *main.assets.Assets) void { + _ = assets; + _ = assetFolder; +} + +pub const ENTITY_COMPONENT_VERSION = 0; + +// ############################# Client only stuff ################################ +pub const Client = struct { + pub fn register(id: u32, reader: *utils.BinaryReader, version: u32) void { + _ = id; + _ = reader; + _ = version; + } + pub fn unregister(id: u32) void { + _ = id; + } + pub fn init() void {} + pub fn deinit() void {} + pub fn clear() void {} +}; +// ############################# Server only stuff ################################ +pub const Server = struct { + pub const ItemComponent = struct { + pub fn save(self: ItemComponent, writer: *utils.BinaryWriter) void { + _ = self; + _ = writer; + } + }; + pub fn init() void {} + pub fn deinit() void {} + pub fn get(id: u32) ?ItemComponent { + _ = id; + return null; + } + pub fn registerFromData(id: u32, reader: *utils.BinaryReader, version: u32) void { + _ = id; + _ = reader; + _ = version; + } + pub fn unregister(id: u32) void { + _ = id; + } +}; diff --git a/src/entitySystem/_list.zig b/src/entitySystem/_list.zig new file mode 100644 index 0000000000..bd38343dc2 --- /dev/null +++ b/src/entitySystem/_list.zig @@ -0,0 +1 @@ +pub const template = @import("template.zig"); diff --git a/src/entitySystem/template.zig b/src/entitySystem/template.zig new file mode 100644 index 0000000000..4f8549f8de --- /dev/null +++ b/src/entitySystem/template.zig @@ -0,0 +1,55 @@ +const std = @import("std"); + +const main = @import("main"); +const chunk = main.chunk; +const game = main.game; +const graphics = main.graphics; +const c = graphics.c; +const ZonElement = main.ZonElement; +const renderer = main.renderer; +const settings = main.settings; +const utils = main.utils; +const vec = main.vec; +const Mat4f = vec.Mat4f; +const Vec3d = vec.Vec3d; +const Vec3f = vec.Vec3f; +const Vec4f = vec.Vec4f; +const Vec3i = vec.Vec3i; +const NeverFailingAllocator = main.heap.NeverFailingAllocator; + +const BinaryReader = main.utils.BinaryReader; +const BinaryWriter = main.utils.BinaryWriter; + +const blocks = main.blocks; +const chunk_zig = main.chunk; +const ServerChunk = chunk_zig.ServerChunk; +const World = game.World; +const ServerWorld = main.server.ServerWorld; +const items = main.items; +const ItemStack = items.ItemStack; +const random = main.random; + +const entityComponent = main.entityComponent; + +// ############################# Client only stuff ################################ +pub const Client = struct { + pub fn init() void {} + pub fn deinit() void {} + pub fn clear() void {} + + pub fn render(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { + _ = projMatrix; + _ = ambientLight; + _ = playerPos; + } + pub fn renderInfo(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { + _ = projMatrix; + _ = ambientLight; + _ = playerPos; + } +}; +// ############################# Server only stuff ################################ +pub const Server = struct { + pub fn init() void {} + pub fn deinit() void {} +}; diff --git a/src/game.zig b/src/game.zig index ea88a3a30f..ca7326f17f 100644 --- a/src/game.zig +++ b/src/game.zig @@ -661,7 +661,7 @@ pub const World = struct { // MARK: World main.sync.ClientSide.reset(); main.threadPool.clear(); - main.entity.ClientEntityManager.clear(); + main.clientEntity.ClientEntityManager.clear(); self.itemDrops.deinit(); self.blockPalette.deinit(); self.itemPalette.deinit(); diff --git a/src/main.zig b/src/main.zig index c6d5657d07..8c21657b7a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -11,7 +11,9 @@ pub const blocks = @import("blocks.zig"); pub const blueprint = @import("blueprint.zig"); pub const callbacks = @import("callbacks/callbacks.zig"); pub const chunk = @import("chunk.zig"); -pub const entity = @import("entity.zig"); +pub const clientEntity = @import("clientEntity.zig"); +pub const entityComponent = @import("entityComponent/_list.zig"); +pub const entitySystem = @import("entitySystem/_list.zig"); pub const files = @import("files.zig"); pub const game = @import("game.zig"); pub const graphics = @import("graphics.zig"); @@ -582,8 +584,8 @@ pub fn main() void { // MARK: main() network.init() catch @panic("Failed to initialize network"); defer network.deinit(); - if (!headless) entity.ClientEntityManager.init(); - defer if (!headless) entity.ClientEntityManager.deinit(); + if (!headless) clientEntity.ClientEntityManager.init(); + defer if (!headless) clientEntity.ClientEntityManager.deinit(); if (!headless) gui.init(); defer if (!headless) gui.deinit(); diff --git a/src/network/protocols.zig b/src/network/protocols.zig index 304851ae6a..e5baf7d37b 100644 --- a/src/network/protocols.zig +++ b/src/network/protocols.zig @@ -393,7 +393,7 @@ pub const entityPosition = struct { // MARK: entityPosition if (conn.manager.world) |world| { const time = try reader.readInt(i16); const playerPos = try reader.readVec(Vec3d); - var entityData: main.List(main.entity.EntityNetworkData) = .init(main.stackAllocator); + var entityData: main.List(main.clientEntity.EntityNetworkData) = .init(main.stackAllocator); defer entityData.deinit(); var itemData: main.List(main.itemdrop.ItemDropNetworkData) = .init(main.stackAllocator); defer itemData.deinit(); @@ -427,11 +427,11 @@ pub const entityPosition = struct { // MARK: entityPosition }, } } - main.entity.ClientEntityManager.serverUpdate(time, entityData.items); + main.clientEntity.ClientEntityManager.serverUpdate(time, entityData.items); world.itemDrops.readPosition(time, itemData.items); } } - pub fn send(conn: *Connection, playerPos: Vec3d, entityData: []main.entity.EntityNetworkData, itemData: []main.itemdrop.ItemDropNetworkData) void { + pub fn send(conn: *Connection, playerPos: Vec3d, entityData: []main.clientEntity.EntityNetworkData, itemData: []main.itemdrop.ItemDropNetworkData) void { var writer = utils.BinaryWriter.init(main.stackAllocator); defer writer.deinit(); @@ -511,10 +511,10 @@ pub const entity = struct { // MARK: entity const elem = zonArray.array.items[i]; switch (elem) { .int => { - main.entity.ClientEntityManager.removeEntity(elem.as(u32, 0)); + main.clientEntity.ClientEntityManager.removeEntity(elem.as(u32, 0)); }, .object => { - main.entity.ClientEntityManager.addEntity(elem); + main.clientEntity.ClientEntityManager.addEntity(elem); }, .null => { i += 1; diff --git a/src/renderer.zig b/src/renderer.zig index ddb6d262a0..1d09a8bdfe 100644 --- a/src/renderer.zig +++ b/src/renderer.zig @@ -3,7 +3,7 @@ const Atomic = std.atomic.Value; const blocks = @import("blocks.zig"); const chunk = @import("chunk.zig"); -const entity = @import("entity.zig"); +const clientEntity = @import("clientEntity.zig"); const graphics = @import("graphics.zig"); const particles = @import("particles.zig"); const c = graphics.c; @@ -235,7 +235,7 @@ pub fn renderWorld(world: *World, ambientLight: Vec3f, skyColor: Vec3f, playerPo gpu_performance_measuring.stopQuery(); gpu_performance_measuring.startQuery(.entity_rendering); - entity.ClientEntityManager.render(game.projectionMatrix, ambientLight, playerPos); + clientEntity.ClientEntityManager.render(game.projectionMatrix, ambientLight, playerPos); itemdrop.ItemDropRenderer.renderItemDrops(game.projectionMatrix, ambientLight, playerPos); gpu_performance_measuring.stopQuery(); @@ -323,7 +323,7 @@ pub fn renderWorld(world: *World, ambientLight: Vec3f, skyColor: Vec3f, playerPo c.glBindFramebuffer(c.GL_FRAMEBUFFER, 0); - if (!main.gui.hideGui) entity.ClientEntityManager.renderNames(game.projectionMatrix, playerPos); + if (!main.gui.hideGui) clientEntity.ClientEntityManager.renderNames(game.projectionMatrix, playerPos); gpu_performance_measuring.stopQuery(); } diff --git a/src/server/server.zig b/src/server/server.zig index ef365885ad..05042fcaa4 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -613,7 +613,7 @@ fn update() void { // MARK: update() const itemData = world.?.itemDropManager.getPositionAndVelocityData(main.stackAllocator); defer main.stackAllocator.free(itemData); - var entityData: main.List(main.entity.EntityNetworkData) = .init(main.stackAllocator); + var entityData: main.List(main.clientEntity.EntityNetworkData) = .init(main.stackAllocator); defer entityData.deinit(); for (userList) |user| { From 61e9795194d2f544a47e6df0e4d4c14e848374dd Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 6 Mar 2026 11:02:29 +0100 Subject: [PATCH 04/83] Entity registers and unregisters from entityComponents, --- src/game.zig | 2 +- src/server/Entity.zig | 75 +++++++++++++++++++++++++++++++++++++++++-- src/server/world.zig | 2 +- 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/src/game.zig b/src/game.zig index ca7326f17f..fca7ee0418 100644 --- a/src/game.zig +++ b/src/game.zig @@ -458,7 +458,7 @@ pub const Player = struct { // MARK: Player pub const jumpHeight = 1.25; fn loadFrom(zon: ZonElement) void { - super.loadFrom(zon); + super.loadFrom(id, zon, .ClientSide); } pub fn setPosBlocking(newPos: Vec3d) void { diff --git a/src/server/Entity.zig b/src/server/Entity.zig index 42226f8e28..9f6a71b798 100644 --- a/src/server/Entity.zig +++ b/src/server/Entity.zig @@ -6,6 +6,7 @@ const vec = main.vec; const Vec3f = vec.Vec3f; const Vec3d = vec.Vec3d; const NeverFailingAllocator = main.heap.NeverFailingAllocator; +const Side = enum { ClientSide, ServerSide }; pos: Vec3d = .{0, 0, 0}, vel: Vec3d = .{0, 0, 0}, @@ -15,22 +16,90 @@ health: f32 = 8, maxHealth: f32 = 8, energy: f32 = 8, maxEnergy: f32 = 8, -// TODO: Name +name: ?[]const u8 = null, +id: u32 = 0, -pub fn loadFrom(self: *@This(), zon: ZonElement) void { +pub fn loadFrom(self: *@This(), id: u32, zon: ZonElement, comptime side: Side) void { + self.id = id; self.pos = zon.get(Vec3d, "position", .{0, 0, 0}); self.vel = zon.get(Vec3d, "velocity", .{0, 0, 0}); self.rot = zon.get(Vec3f, "rotation", .{0, 0, 0}); self.health = zon.get(f32, "health", self.maxHealth); self.energy = zon.get(f32, "energy", self.maxEnergy); + if (zon.getChildOrNull("components")) |components| { + const list = main.entityComponent; + inline for (@typeInfo(list).@"struct".decls) |decl| { + if (components.get(?[]const u8, decl.name, null)) |base64| { + if (main.utils.fromBase64(main.stackAllocator, base64) catch null) |data| { + defer main.stackAllocator.free(data); + + var reader = main.utils.BinaryReader.init(data); + const version = reader.readVarInt(u32) catch std.math.maxInt(u32); + + if (side == .ServerSide) { + @field(list, decl.name).Server.registerFromData(id, &reader, version); + } else if (side == .ClientSide) { + @field(list, decl.name).Client.register(id, &reader, version); + } + } + } + } + } + + if (zon.getChildOrNull("name")) |name| { + if (self.name) |oldname| { + main.globalAllocator.free(oldname); + } + self.name = main.globalAllocator.dupe(u8, name.as([]const u8, "invalid name")); + } +} +pub fn clone(self: *@This(), copy: *@This()) void { + const originalID = copy.id; + copy.* = self.*; + copy.name = if (self.name) |name| main.globalAllocator.dupe(u8, name) else null; + copy.id = originalID; } -pub fn save(self: *@This(), allocator: NeverFailingAllocator) ZonElement { +pub fn save(self: *const @This(), allocator: NeverFailingAllocator) ZonElement { const zon = ZonElement.initObject(allocator); zon.put("position", self.pos); zon.put("velocity", self.vel); zon.put("rotation", self.rot); zon.put("health", self.health); zon.put("energy", self.energy); + const components = ZonElement.initObject(allocator); + { + const list = main.entityComponent; + inline for (@typeInfo(list).@"struct".decls) |decl| { + if (@field(list, decl.name).Server.get(self.id)) |component| { + var writer = main.utils.BinaryWriter.init(allocator); + defer writer.deinit(); + + writer.writeVarInt(u32, @field(list, decl.name).ENTITY_COMPONENT_VERSION); + component.save(&writer); + + var base64 = main.utils.Base64.toBase64(allocator, writer.data.items); + defer base64.deinit(allocator); + + components.putOwnedString(decl.name, base64.getEncodedMessage()); + } + } + } + zon.put("components", components); + + if (self.name) |name| + zon.put("name", name); return zon; } +pub fn deinit(self: *@This(), comptime side: Side) void { + if (self.name) |name| { + main.globalAllocator.free(name); + self.name = null; + } + if (side == .ServerSide) { + const list = main.entityComponent; + inline for (@typeInfo(list).@"struct".decls) |decl| { + @field(list, decl.name).Server.unregister(self.id); + } + } +} diff --git a/src/server/world.zig b/src/server/world.zig index 03cccde000..348261b426 100644 --- a/src/server/world.zig +++ b/src/server/world.zig @@ -949,7 +949,7 @@ pub const ServerWorld = struct { // MARK: ServerWorld main.sync.setGamemode(user, self.settings.defaultGamemode); } else { - player.loadFrom(playerData.getChild("entity")); + player.loadFrom(user.id, playerData.getChild("entity"), .ServerSide); user.permissions.fromZon(playerData); From acc5c1bb8f6ce3a7845c4124084a206a5dd94402 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 6 Mar 2026 11:03:36 +0100 Subject: [PATCH 05/83] have general Base64 classes and functions --- src/utils.zig | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/utils.zig b/src/utils.zig index e082bbae7a..6d51b0c857 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -1769,8 +1769,10 @@ pub const BinaryReader = struct { defer self.remaining = self.remaining[length..]; return self.remaining[0..length]; } + pub fn readSliceWithSize(self: *BinaryReader) ![]const u8 { + return try self.readSlice(try self.readVarInt(usize)); + } }; - pub const BinaryWriter = struct { data: main.List(u8), @@ -1840,6 +1842,10 @@ pub const BinaryWriter = struct { pub fn writeSlice(self: *BinaryWriter, slice: []const u8) void { self.data.appendSlice(slice); } + pub fn writeSliceWithSize(self: *BinaryWriter, slice: []const u8) void { + self.writeVarInt(usize, slice.len); + self.writeSlice(slice); + } pub fn writeWithDelimiter(self: *BinaryWriter, slice: []const u8, delimiter: u8) void { std.debug.assert(!std.mem.containsAtLeast(u8, slice, 1, &.{delimiter})); @@ -2260,3 +2266,29 @@ pub fn obfuscateString(allocator: NeverFailingAllocator, string: []const u8) []c } return obfuscated; } + +pub const Base64 = struct { + fullBuffer: []u8, + base64Encoded: []const u8, + + pub fn toBase64(allocator: NeverFailingAllocator, source: []const u8) Base64 { + const fullBuffer = allocator.alloc(u8, std.base64.url_safe.Encoder.calcSize(source.len)); + return Base64{ + .fullBuffer = fullBuffer, + .base64Encoded = std.base64.url_safe.Encoder.encode(fullBuffer, source), + }; + } + pub fn getEncodedMessage(self: Base64) []const u8 { + return self.base64Encoded; + } + pub fn deinit(self: Base64, allocator: NeverFailingAllocator) void { + allocator.free(self.fullBuffer); + } +}; +pub fn fromBase64(allocator: NeverFailingAllocator, base64EncodedData: []const u8) ![]const u8 { + const decodedSize = try std.base64.url_safe.Decoder.calcSizeForSlice(base64EncodedData); + const bytes: []u8 = allocator.alloc(u8, decodedSize); + errdefer allocator.free(bytes); + try std.base64.url_safe.Decoder.decode(bytes, base64EncodedData); + return bytes; +} From 9a3e70ecb5a2e51c69778bf7b4346c6f79007c95 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 6 Mar 2026 11:15:17 +0100 Subject: [PATCH 06/83] EntityComponentUpdate Protocol --- src/network/protocols.zig | 58 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/src/network/protocols.zig b/src/network/protocols.zig index e5baf7d37b..71d0dd192c 100644 --- a/src/network/protocols.zig +++ b/src/network/protocols.zig @@ -431,7 +431,7 @@ pub const entityPosition = struct { // MARK: entityPosition world.itemDrops.readPosition(time, itemData.items); } } - pub fn send(conn: *Connection, playerPos: Vec3d, entityData: []main.clientEntity.EntityNetworkData, itemData: []main.itemdrop.ItemDropNetworkData) void { + pub fn send(conn: *Connection, playerPos: Vec3d, entityData: []const main.clientEntity.EntityNetworkData, itemData: []const main.itemdrop.ItemDropNetworkData) void { var writer = utils.BinaryWriter.init(main.stackAllocator); defer writer.deinit(); @@ -959,3 +959,59 @@ pub const blockEntityUpdate = struct { // MARK: blockEntityUpdate sendServerDataUpdateToClientsInternal(pos, &ch.super, block, blockEntity); } }; + +// format: entityID set componentID binary +// format: entityID reset componentID +pub const EntityComponentUpdate = struct { // MARK: EntityComponentUpdate + pub const id: u8 = 15; + pub const asynchronous = false; + + const ActionType = enum(u8) { set, reset }; + + fn clientReceive(_: *Connection, reader: *utils.BinaryReader) !void { + const entityID = try reader.readInt(u32); + const actionType: ActionType = try reader.readEnum(ActionType); + const componentID = try reader.readSliceWithSize(); + + if (actionType == .set) { + const list = main.entityComponent; + inline for (@typeInfo(list).@"struct".decls) |decl| { + if (std.mem.eql(u8, decl.name, componentID)) { + const version = reader.readVarInt(u32) catch std.math.maxInt(u32); + @field(list, decl.name).Client.register(entityID, reader, version); + break; + } + } + } else if (actionType == .reset) { + const list = main.entityComponent; + inline for (@typeInfo(list).@"struct".decls) |decl| { + if (std.mem.eql(u8, decl.name, componentID)) { + @field(list, decl.name).Client.unregister(entityID); + break; + } + } + } + } + pub fn reset(conn: *Connection, entityID: u32, componentID: []const u8) void { + var writer = utils.BinaryWriter.init(main.stackAllocator); + defer writer.deinit(); + + writer.writeInt(u32, entityID); + writer.writeEnum(ActionType, ActionType.reset); + writer.writeSliceWithSize(componentID); + + conn.send(.secure, id, writer.data.items); + } + pub fn set(conn: *Connection, entityID: u32, componentID: []const u8, version: u32, componentData: []const u8) void { + var writer = utils.BinaryWriter.init(main.stackAllocator); + defer writer.deinit(); + + writer.writeInt(u32, entityID); + writer.writeEnum(ActionType, ActionType.set); + writer.writeSliceWithSize(componentID); + writer.writeVarInt(u32, version); + writer.writeSlice(componentData); + + conn.send(.secure, id, writer.data.items); + } +}; From bafca5726a5d7bb360bed912eb1f325c2d6d2f7a Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 6 Mar 2026 11:37:19 +0100 Subject: [PATCH 07/83] load EntityTypes from Assets --- src/assets.zig | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/assets.zig b/src/assets.zig index 6c1f797e08..de0e1278de 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -35,6 +35,7 @@ pub const Assets = struct { blueprints: BytesHashMap, particles: ZonHashMap, worldPresets: ZonHashMap, + entityModel: ZonHashMap, fn init() Assets { return .{ @@ -51,6 +52,7 @@ pub const Assets = struct { .blueprints = .{}, .particles = .{}, .worldPresets = .{}, + .entityModel = .{}, }; } fn deinit(self: *Assets, allocator: NeverFailingAllocator) void { @@ -67,6 +69,7 @@ pub const Assets = struct { self.blueprints.deinit(allocator.allocator); self.particles.deinit(allocator.allocator); self.worldPresets.deinit(allocator.allocator); + self.entityModel.deinit(allocator.allocator); } fn clone(self: Assets, allocator: NeverFailingAllocator) Assets { return .{ @@ -83,6 +86,7 @@ pub const Assets = struct { .blueprints = self.blueprints.clone(allocator.allocator) catch unreachable, .particles = self.particles.clone(allocator.allocator) catch unreachable, .worldPresets = .{}, // Not accessible inside the world + .entityModel = self.entityModel.clone(allocator.allocator) catch unreachable, }; } fn read(self: *Assets, allocator: NeverFailingAllocator, assetDir: main.files.Dir, assetPath: []const u8) void { @@ -101,6 +105,7 @@ pub const Assets = struct { addon.readAllModels(allocator, &self.models); addon.readAllZon(allocator, "particles", true, &self.particles, null); addon.readAllZon(allocator, "world_presets", true, &self.worldPresets, null); + addon.readAllZon(allocator, "entity", true, &self.entityModel, null); } } fn log(self: *Assets, typ: enum { common, world }) void { @@ -510,6 +515,7 @@ pub const Palette = struct { // MARK: Palette }; var loadedAssets: bool = false; +pub var rawModelData: std.StringHashMap([]main.models.QuadInfo) = undefined; pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPalette: *Palette, toolPalette: *Palette, biomePalette: *Palette) !void { // MARK: loadWorldAssets() if (loadedAssets) return; // The assets already got loaded by the server. @@ -536,8 +542,10 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale // models: var modelIterator = worldAssets.models.iterator(); + rawModelData = std.StringHashMap([]main.models.QuadInfo).init(main.worldArena.allocator); while (modelIterator.next()) |entry| { _ = main.models.registerModel(entry.key_ptr.*, entry.value_ptr.*); + registerModelRaw(entry.key_ptr.*, entry.value_ptr.*); } if (!main.settings.launchConfig.headlessServer) blocks_zig.meshes.registerBlockBreakingAnimation(assetFolder); @@ -548,6 +556,11 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale try registerBlock(assetFolder, stringId, worldAssets.blocks.get(stringId) orelse .null); } + // EntityComponents + inline for (@typeInfo(main.entityComponent).@"struct".decls) |decl| { + @field(main.entityComponent, decl.name).loadWorldAsset(assetFolder, &worldAssets); + } + // Then all the blocks that were missing in palette but are present in the game. var iterator = worldAssets.blocks.iterator(); while (iterator.next()) |entry| { @@ -681,7 +694,9 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale worldAssets.log(.world); } - +pub fn registerModelRaw(id: []const u8, data: []const u8) void { + rawModelData.put(id, main.models.Model.loadRawModelDataFromObj(main.worldArena, data)) catch unreachable; +} pub fn unloadAssets() void { // MARK: unloadAssets() if (!loadedAssets) return; loadedAssets = false; From 93bd0949cb1a70a0418109308bedfc4298e1def2 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 6 Mar 2026 11:57:51 +0100 Subject: [PATCH 08/83] made player a function --- src/Inventory.zig | 2 +- src/itemdrop.zig | 4 ++-- src/network/protocols.zig | 2 +- src/server/command/_command.zig | 2 +- src/server/command/worldedit/paste.zig | 2 +- src/server/command/worldedit/pos1.zig | 2 +- src/server/command/worldedit/pos2.zig | 2 +- src/server/server.zig | 22 +++++++++++++--------- src/server/world.zig | 8 ++++---- src/sync.zig | 22 +++++++++++----------- 10 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/Inventory.zig b/src/Inventory.zig index 81cdebc134..ccdcbd89f3 100644 --- a/src/Inventory.zig +++ b/src/Inventory.zig @@ -130,7 +130,7 @@ pub const ServerSide = struct { // MARK: ServerSide if (self.managed == .internallyManaged) { if (self.inv.type.shouldDepositToUserOnClose()) { const playerInventory = getInventoryFromSource(.{.playerInventory = user.id}) orelse @panic("Could not find player inventory"); - sync.ServerSide.executeCommand(.{.depositOrDrop = .initWithInventories(&.{playerInventory}, self.inv, user.player.pos)}, null); + sync.ServerSide.executeCommand(.{.depositOrDrop = .initWithInventories(&.{playerInventory}, self.inv, user.player().pos)}, null); } inventoryCreationMutex.lock(); defer inventoryCreationMutex.unlock(); diff --git a/src/itemdrop.zig b/src/itemdrop.zig index 94c61a758e..112b5950be 100644 --- a/src/itemdrop.zig +++ b/src/itemdrop.zig @@ -439,8 +439,8 @@ pub const ItemDropManager = struct { // MARK: ItemDropManager continue; } const hitbox = main.game.Player.outerBoundingBox; - const min = user.player.pos + hitbox.min; - const max = user.player.pos + hitbox.max; + const min = user.player().pos + hitbox.min; + const max = user.player().pos + hitbox.max; const itemPos = self.list.items(.pos)[i]; const dist = @max(min - itemPos, itemPos - max); if (@reduce(.Max, dist) < radius + pickupRange) { diff --git a/src/network/protocols.zig b/src/network/protocols.zig index 304851ae6a..e8cc675eaf 100644 --- a/src/network/protocols.zig +++ b/src/network/protocols.zig @@ -236,7 +236,7 @@ pub const handShake = struct { // MARK: handShake pub fn sendServerPlayerData(conn: *Connection) void { const zonObject = ZonElement.initObject(main.stackAllocator); defer zonObject.deinit(main.stackAllocator); - zonObject.put("player", conn.user.?.player.save(main.stackAllocator)); + zonObject.put("player", conn.user.?.player().save(main.stackAllocator)); zonObject.put("player_id", conn.user.?.id); zonObject.put("blockPalette", main.server.world.?.blockPalette.storeToZon(main.stackAllocator)); zonObject.put("itemPalette", main.server.world.?.itemPalette.storeToZon(main.stackAllocator)); diff --git a/src/server/command/_command.zig b/src/server/command/_command.zig index 713754052e..1ce5818e53 100644 --- a/src/server/command/_command.zig +++ b/src/server/command/_command.zig @@ -70,7 +70,7 @@ pub fn parseCoordinates(split: *std.mem.SplitIterator(u8, .scalar), source: *Use output[i] = try parseAxis(split.next() orelse { source.sendMessage("#ff0000Too few arguments for position", .{}); return error.TooFewArguments; - }, source.player.pos[i], source); + }, source.player().pos[i], source); } break :blk output; }; diff --git a/src/server/command/worldedit/paste.zig b/src/server/command/worldedit/paste.zig index be3ed0935d..1653b325ef 100644 --- a/src/server/command/worldedit/paste.zig +++ b/src/server/command/worldedit/paste.zig @@ -29,7 +29,7 @@ pub fn execute(args: []const u8, source: *User) void { } if (source.worldEditData.clipboard) |clipboard| { - const pos: Vec3i = @intFromFloat(source.player.pos); + const pos: Vec3i = @intFromFloat(source.player().pos); source.sendMessage("Pasting: {}", .{pos}); const undo = Blueprint.capture(main.globalAllocator, pos, .{ diff --git a/src/server/command/worldedit/pos1.zig b/src/server/command/worldedit/pos1.zig index 63eefce988..f2923833d9 100644 --- a/src/server/command/worldedit/pos1.zig +++ b/src/server/command/worldedit/pos1.zig @@ -13,7 +13,7 @@ pub fn execute(args: []const u8, source: *User) void { return; } - const pos: Vec3i = @intFromFloat(source.player.pos); + const pos: Vec3i = @intFromFloat(source.player().pos); source.worldEditData.selectionPosition1 = pos; main.network.protocols.genericUpdate.sendWorldEditPos(source.conn, .selectedPos1, pos); diff --git a/src/server/command/worldedit/pos2.zig b/src/server/command/worldedit/pos2.zig index eee82227ab..c1f8f3e155 100644 --- a/src/server/command/worldedit/pos2.zig +++ b/src/server/command/worldedit/pos2.zig @@ -13,7 +13,7 @@ pub fn execute(args: []const u8, source: *User) void { return; } - const pos: Vec3i = @intFromFloat(source.player.pos); + const pos: Vec3i = @intFromFloat(source.player().pos); source.worldEditData.selectionPosition2 = pos; main.network.protocols.genericUpdate.sendWorldEditPos(source.conn, .selectedPos2, pos); diff --git a/src/server/server.zig b/src/server/server.zig index ef365885ad..de53667d09 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -98,7 +98,7 @@ pub const User = struct { // MARK: User const simulationSize = 2*maxSimulationDistance; const simulationMask = simulationSize - 1; conn: *Connection = undefined, - player: Entity = .{}, + inner_player: Entity = .{}, timeDifference: utils.TimeDifference = .{}, interpolation: utils.GenericInterpolation(3) = undefined, lastTime: i16 = undefined, @@ -143,6 +143,10 @@ pub const User = struct { // MARK: User permissions: permission.Permissions = undefined, + pub fn player(self: *User) *Entity { + return &self.inner_player; + } + pub fn initAndIncreaseRefCount(manager: *ConnectionManager, ipPort: []const u8) !*User { const self = main.globalAllocator.create(User); errdefer main.globalAllocator.destroy(self); @@ -243,7 +247,7 @@ pub const User = struct { // MARK: User freeId += 1; world.?.loadPlayer(self); - self.interpolation.init(@ptrCast(&self.player.pos), @ptrCast(&self.player.vel)); + self.interpolation.init(@ptrCast(&self.player().pos), @ptrCast(&self.player().vel)); self.loadUnloadChunks(); } @@ -299,7 +303,7 @@ pub const User = struct { // MARK: User } fn loadUnloadChunks(self: *User) void { - const newPos: Vec3i = @as(Vec3i, @intFromFloat(self.player.pos)) +% @as(Vec3i, @splat(chunk.chunkSize/2)) & ~@as(Vec3i, @splat(chunk.chunkMask)); + const newPos: Vec3i = @as(Vec3i, @intFromFloat(self.player().pos)) +% @as(Vec3i, @splat(chunk.chunkSize/2)) & ~@as(Vec3i, @splat(chunk.chunkMask)); const newRenderDistance = main.settings.simulationDistance; if (@reduce(.Or, newPos != self.lastPos) or newRenderDistance != self.lastRenderDistance) { self.unloadOldChunk(newPos, newRenderDistance); @@ -463,7 +467,7 @@ pub const User = struct { // MARK: User const position: [3]f64 = try reader.readVec(Vec3d); const velocity: [3]f64 = try reader.readVec(Vec3d); const rotation: [3]f32 = try reader.readVec(Vec3f); - self.player.rot = rotation; + self.player().rot = rotation; const time = try reader.readInt(i16); self.timeDifference.addDataPoint(time); self.interpolation.updatePosition(&position, &velocity, time); @@ -620,17 +624,17 @@ fn update() void { // MARK: update() const id = user.id; // TODO entityData.append(.{ .id = id, - .pos = user.player.pos, - .vel = user.player.vel, - .rot = user.player.rot, + .pos = user.player().pos, + .vel = user.player().vel, + .rot = user.player().rot, }); } for (userList) |user| { - main.network.protocols.entityPosition.send(user.conn, user.player.pos, entityData.items, itemData); + main.network.protocols.entityPosition.send(user.conn, user.player().pos, entityData.items, itemData); } for (userList) |user| { - const pos = @as(Vec3i, @intFromFloat(user.player.pos)); + const pos = @as(Vec3i, @intFromFloat(user.player().pos)); const biomeId = world.?.getBiome(pos[0], pos[1], pos[2]).paletteId; if (biomeId != user.lastSentBiomeId) { user.lastSentBiomeId = biomeId; diff --git a/src/server/world.zig b/src/server/world.zig index 03cccde000..b8fbcf32a7 100644 --- a/src/server/world.zig +++ b/src/server/world.zig @@ -211,7 +211,7 @@ pub const ChunkManager = struct { // MARK: ChunkManager pub fn getPriority(self: *ChunkLoadTask) f32 { switch (self.source) { - .user => |user| return self.pos.getPriority(user.player.pos), + .user => |user| return self.pos.getPriority(user.player().pos), else => return std.math.floatMax(f32), } } @@ -275,7 +275,7 @@ pub const ChunkManager = struct { // MARK: ChunkManager pub fn getPriority(self: *LightMapLoadTask) f32 { if (self.source) |user| { - return self.pos.getPriority(user.player.pos, terrain.LightMap.LightMapFragment.mapSize) + 100; + return self.pos.getPriority(user.player().pos, terrain.LightMap.LightMapFragment.mapSize) + 100; } else { return std.math.floatMax(f32); } @@ -943,7 +943,7 @@ pub const ServerWorld = struct { // MARK: ServerWorld } self.playerDatabase.put(main.worldArena.allocator, main.worldArena.dupe(u8, user.newKeyString), user.playerIndex) catch unreachable; } - const player = &user.player; + const player = user.player(); if (playerData == .null) { player.pos = @floatFromInt(self.spawn); @@ -1005,7 +1005,7 @@ pub const ServerWorld = struct { // MARK: ServerWorld playerZon.put("name", user.name); playerZon.put("publicKey", user.newKeyString); - playerZon.put("entity", user.player.save(main.stackAllocator)); + playerZon.put("entity", user.player().save(main.stackAllocator)); user.permissions.toZon(main.stackAllocator, &playerZon); playerZon.put("gamemode", @tagName(user.gamemode.load(.monotonic))); diff --git a/src/sync.zig b/src/sync.zig index 6d9a26306c..2a9486c47a 100644 --- a/src/sync.zig +++ b/src/sync.zig @@ -697,12 +697,12 @@ pub const Command = struct { // MARK: Command }, .addHealth => |*info| { if (side == .server) { - info.previous = info.target.?.player.health; + info.previous = info.target.?.player().health; - info.target.?.player.health = std.math.clamp(info.target.?.player.health + info.health, 0, info.target.?.player.maxHealth); + info.target.?.player().health = std.math.clamp(info.target.?.player().health + info.health, 0, info.target.?.player().maxHealth); - if (info.target.?.player.health <= 0) { - info.target.?.player.health = info.target.?.player.maxHealth; + if (info.target.?.player().health <= 0) { + info.target.?.player().health = info.target.?.player().maxHealth; info.cause.sendMessage(info.target.?.name); self.syncOperations.append(allocator, .{.kill = .{ @@ -722,9 +722,9 @@ pub const Command = struct { // MARK: Command }, .addEnergy => |*info| { if (side == .server) { - info.previous = info.target.?.player.energy; + info.previous = info.target.?.player().energy; - info.target.?.player.energy = std.math.clamp(info.target.?.player.energy + info.energy, 0, info.target.?.player.maxEnergy); + info.target.?.player().energy = std.math.clamp(info.target.?.player().energy + info.energy, 0, info.target.?.player().maxEnergy); self.syncOperations.append(allocator, .{.energy = .{ .target = info.target.?, .energy = info.energy, @@ -1032,8 +1032,8 @@ pub const Command = struct { // MARK: Command } const amount = @min(self.source.ref().amount, self.desiredAmount); if (ctx.side == .server) { - const direction = vec.rotateZ(vec.rotateX(Vec3f{0, 1, 0}, -ctx.user.?.player.rot[0]), -ctx.user.?.player.rot[2]); - main.server.world.?.dropWithCooldown(.{.item = self.source.ref().item.clone(), .amount = amount}, ctx.user.?.player.pos, direction, 20, main.server.updatesPerSec*2); + const direction = vec.rotateZ(vec.rotateX(Vec3f{0, 1, 0}, -ctx.user.?.player().rot[0]), -ctx.user.?.player().rot[2]); + main.server.world.?.dropWithCooldown(.{.item = self.source.ref().item.clone(), .amount = amount}, ctx.user.?.player().pos, direction, 20, main.server.updatesPerSec*2); } ctx.execute(.{.delete = .{ .source = self.source, @@ -1147,7 +1147,7 @@ pub const Command = struct { // MARK: Command const remainingAmount = self.destinations.putItemsInto(ctx, sourceStack.amount, .{.move = .{.inv = self.source, .slot = @intCast(sourceSlot)}}); if (remainingAmount == 0) continue; if (ctx.side == .server) { - const direction = if (ctx.user) |_user| vec.rotateZ(vec.rotateX(Vec3f{0, 1, 0}, -_user.player.rot[0]), -_user.player.rot[2]) else Vec3f{0, 0, 0}; + const direction = if (ctx.user) |_user| vec.rotateZ(vec.rotateX(Vec3f{0, 1, 0}, -_user.player().rot[0]), -_user.player().rot[2]) else Vec3f{0, 0, 0}; main.server.world.?.drop(sourceStack.clone(), self.dropLocation, direction, 20); } ctx.execute(.{.delete = .{ @@ -1169,7 +1169,7 @@ pub const Command = struct { // MARK: Command return .{ .destinations = destinations, .source = Inventory.getInventory(sourceId, side, user) orelse return error.InventoryNotFound, - .dropLocation = (user orelse return error.Invalid).player.pos, + .dropLocation = (user orelse return error.Invalid).player().pos, }; } }; @@ -1516,7 +1516,7 @@ pub const Command = struct { // MARK: Command .target = target, .health = self.health, .cause = self.cause, - .previous = if (ctx.side == .server) target.?.player.health else main.game.Player.super.health, + .previous = if (ctx.side == .server) target.?.player().health else main.game.Player.super.health, }}); } From 5fbf9bab26741a3a018d7bc63f0959de8311080c Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 6 Mar 2026 17:06:19 +0100 Subject: [PATCH 09/83] removed loadWorldAsset function --- src/entityComponent/template.zig | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/entityComponent/template.zig b/src/entityComponent/template.zig index f90844993f..37c3cb6819 100644 --- a/src/entityComponent/template.zig +++ b/src/entityComponent/template.zig @@ -29,11 +29,6 @@ const items = main.items; const ItemStack = items.ItemStack; const random = main.random; -pub fn loadWorldAsset(assetFolder: []const u8, assets: *main.assets.Assets) void { - _ = assets; - _ = assetFolder; -} - pub const ENTITY_COMPONENT_VERSION = 0; // ############################# Client only stuff ################################ From 1e04fa304f6045070d9348599556c0139e698c97 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 6 Mar 2026 23:15:36 +0100 Subject: [PATCH 10/83] removed loadWorldAssets --- src/assets.zig | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index de0e1278de..4d74d30906 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -556,11 +556,6 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale try registerBlock(assetFolder, stringId, worldAssets.blocks.get(stringId) orelse .null); } - // EntityComponents - inline for (@typeInfo(main.entityComponent).@"struct".decls) |decl| { - @field(main.entityComponent, decl.name).loadWorldAsset(assetFolder, &worldAssets); - } - // Then all the blocks that were missing in palette but are present in the game. var iterator = worldAssets.blocks.iterator(); while (iterator.next()) |entry| { From 033c645bd3c67c02c2d911002647cbe95aed902e Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 7 Mar 2026 00:29:46 +0100 Subject: [PATCH 11/83] entityModel --- src/entityModel.zig | 119 ++++++++++++++++++++++++++++++++++++++++++++ src/main.zig | 1 + 2 files changed, 120 insertions(+) create mode 100644 src/entityModel.zig diff --git a/src/entityModel.zig b/src/entityModel.zig new file mode 100644 index 0000000000..492983e17a --- /dev/null +++ b/src/entityModel.zig @@ -0,0 +1,119 @@ +const std = @import("std"); + +const main = @import("main"); +const chunk = main.chunk; +const game = main.game; +const graphics = main.graphics; +const c = graphics.c; +const ZonElement = main.ZonElement; +const renderer = main.renderer; +const settings = main.settings; +const utils = main.utils; +const vec = main.vec; +const Mat4f = vec.Mat4f; +const Vec3d = vec.Vec3d; +const Vec3f = vec.Vec3f; +const Vec4f = vec.Vec4f; +const NeverFailingAllocator = main.heap.NeverFailingAllocator; + +const BinaryReader = main.utils.BinaryReader; + +pub const EntityModel = struct { + buffer: ?main.graphics.SSBO, + size: c_int = 0, + defaultTexture: ?main.graphics.Texture, + height: f32, + + texturePath: []const u8, + modelID: []const u8, + id: []const u8, + + pub fn init(assetFolder: []const u8, id: []const u8, zon: ZonElement) EntityModel { + var self: EntityModel = undefined; + self.id = main.worldArena.dupe(u8, id); + self.height = zon.getChild("height").as(f32, 1); + self.defaultTexture = null; + self.buffer = null; + + // get TexturePath + { + var split = std.mem.splitScalar(u8, id, ':'); + const mod = split.first(); + self.texturePath = &.{}; + if (zon.get(?[]const u8, "texture", null)) |texture| { + self.texturePath = std.fmt.allocPrint(main.worldArena.allocator, "{s}/{s}/entity/textures/{s}", .{assetFolder, mod, texture}) catch &.{}; + std.fs.cwd().access(self.texturePath, .{}) catch { + self.texturePath = std.fmt.allocPrint(main.worldArena.allocator, "assets/{s}/entity/textures/{s}", .{mod, texture}) catch &.{}; + }; + } + } + self.modelID = main.worldArena.dupe(u8, zon.getChild("model").as([]const u8, "cubyz:entity/missing")); + return self; + } + fn deinit(self: *const EntityModel) void { + if (self.buffer) |buffer| { + buffer.deinit(); + } + if (self.texture) |texture| { + texture.deinit(); + } + } + fn generateGraphics(self: *EntityModel) void { + self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); + + const quadInfos = main.assets.rawModelData.get(self.modelID) orelse unreachable; + self.buffer = .initStatic(main.models.QuadInfo, quadInfos); + self.size = @intCast(quadInfos.len); + } + pub fn bind(self: *EntityModel) void { + if (self.buffer == null) { + self.generateGraphics(); + } + self.buffer.?.bind(11); + } +}; +pub const EntityModelIndex = struct { + index: u32, + pub fn get(self: EntityModelIndex) *EntityModel { + if (entityModels.items.len > self.index) + return &entityModels.items[self.index]; + // should always exist because of firstEntry in entityModelPalette + std.debug.assert(entityModels.items.len > 0); + return &entityModels.items[0]; + } +}; + +pub var reverseIndices: std.StringHashMapUnmanaged(EntityModelIndex) = .{}; +pub var entityModels: main.ListUnmanaged(EntityModel) = .{}; + +pub fn register(assetFolder: []const u8, id: []const u8, zon: ZonElement) usize { + const index = entityModels.items.len; + const entityModel = entityModels.addOne(main.worldArena); + entityModel.* = EntityModel.init(assetFolder, id, zon); + reverseIndices.put(main.worldArena.allocator, id, EntityModelIndex{.index = @truncate(index)}) catch unreachable; + return index; +} +pub fn reset() void { + entityModels = .{}; + reverseIndices = .{}; +} + +pub fn hasRegistered(id: []const u8) bool { + return reverseIndices.contains(id); +} + +pub fn getTypeById(id: []const u8) EntityModelIndex { + if (reverseIndices.get(id)) |result| { + return result; + } else { + std.log.err("Couldn't find entityModel {s}. Replacing it with cubyz:missing ...", .{id}); + return EntityModelIndex{.index = 0}; + } +} + +pub fn getTypeByIdOrNull(id: []const u8) ?EntityModelIndex { + if (reverseIndices.get(id)) |result| { + return result; + } + return null; +} diff --git a/src/main.zig b/src/main.zig index 8c21657b7a..f6d9e81b42 100644 --- a/src/main.zig +++ b/src/main.zig @@ -13,6 +13,7 @@ pub const callbacks = @import("callbacks/callbacks.zig"); pub const chunk = @import("chunk.zig"); pub const clientEntity = @import("clientEntity.zig"); pub const entityComponent = @import("entityComponent/_list.zig"); +pub const entityModel = @import("entityModel.zig"); pub const entitySystem = @import("entitySystem/_list.zig"); pub const files = @import("files.zig"); pub const game = @import("game.zig"); From 393213374646f60355ab6769a400e29f79c73945 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 7 Mar 2026 00:39:19 +0100 Subject: [PATCH 12/83] added entityModelComponent --- src/entityComponent/_list.zig | 2 + src/entityComponent/itemDrop.zig | 70 ++++++++++++++++++ src/entityComponent/model.zig | 119 +++++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 src/entityComponent/itemDrop.zig create mode 100644 src/entityComponent/model.zig diff --git a/src/entityComponent/_list.zig b/src/entityComponent/_list.zig index bd38343dc2..3bff493815 100644 --- a/src/entityComponent/_list.zig +++ b/src/entityComponent/_list.zig @@ -1 +1,3 @@ +pub const model = @import("model.zig"); +pub const itemDrop = @import("itemDrop.zig"); pub const template = @import("template.zig"); diff --git a/src/entityComponent/itemDrop.zig b/src/entityComponent/itemDrop.zig new file mode 100644 index 0000000000..3c84fbdebc --- /dev/null +++ b/src/entityComponent/itemDrop.zig @@ -0,0 +1,70 @@ +const std = @import("std"); + +const main = @import("main"); +const chunk = main.chunk; +const game = main.game; +const graphics = main.graphics; +const c = graphics.c; +const ZonElement = main.ZonElement; +const renderer = main.renderer; +const settings = main.settings; +const utils = main.utils; +const vec = main.vec; +const Mat4f = vec.Mat4f; +const Vec3d = vec.Vec3d; +const Vec3f = vec.Vec3f; +const Vec4f = vec.Vec4f; +const Vec3i = vec.Vec3i; +const NeverFailingAllocator = main.heap.NeverFailingAllocator; + +const BinaryReader = main.utils.BinaryReader; +const BinaryWriter = main.utils.BinaryWriter; + +const blocks = main.blocks; +const chunk_zig = main.chunk; +const ServerChunk = chunk_zig.ServerChunk; +const World = game.World; +const ServerWorld = main.server.ServerWorld; +const items = main.items; +const ItemStack = items.ItemStack; +const random = main.random; + +pub const ENTITY_COMPONENT_VERSION = 0; + +// ############################# Client only stuff ################################ +pub const Client = struct { + pub fn register(id: u32, reader: *utils.BinaryReader, version: u32) void { + _ = id; + _ = reader; + _ = version; + } + pub fn unregister(id: u32) void { + _ = id; + } + pub fn init() void {} + pub fn deinit() void {} + pub fn clear() void {} +}; +// ############################# Server only stuff ################################ +pub const Server = struct { + pub const ItemComponent = struct { + pub fn save(self: ItemComponent, writer: *utils.BinaryWriter) void { + _ = self; + _ = writer; + } + }; + pub fn init() void {} + pub fn deinit() void {} + pub fn get(id: u32) ?ItemComponent { + _ = id; + return null; + } + pub fn registerFromData(id: u32, reader: *utils.BinaryReader, version: u32) void { + _ = version; + _ = id; + _ = reader; + } + pub fn unregister(id: u32) void { + _ = id; + } +}; diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig new file mode 100644 index 0000000000..22eca013be --- /dev/null +++ b/src/entityComponent/model.zig @@ -0,0 +1,119 @@ +const std = @import("std"); + +const main = @import("main"); +const chunk = main.chunk; +const game = main.game; +const graphics = main.graphics; +const c = graphics.c; +const ZonElement = main.ZonElement; +const renderer = main.renderer; +const settings = main.settings; +const utils = main.utils; +const vec = main.vec; +const Mat4f = vec.Mat4f; +const Vec3d = vec.Vec3d; +const Vec3f = vec.Vec3f; +const Vec4f = vec.Vec4f; +const NeverFailingAllocator = main.heap.NeverFailingAllocator; + +const BinaryReader = main.utils.BinaryReader; + +pub const ENTITY_COMPONENT_VERSION = 0; +// ############################# Client only stuff ################################ +pub const Client = struct { + const RenderComponent = struct { + entity: u32, // entity + entityModel: main.entityModel.EntityModelIndex, // model + customTexture: ?main.graphics.Texture, // for custom textures. i.e Skins + }; + pub var renderComponents: std.AutoHashMap(u32, RenderComponent) = undefined; + + pub fn init() void { + renderComponents = .init(main.globalAllocator.allocator); + } + pub fn deinit() void { + renderComponents.deinit(); + } + pub fn clear() void { + renderComponents.deinit(); + renderComponents = .init(main.globalAllocator.allocator); + } + pub fn register(id: u32, reader: *utils.BinaryReader, version: u32) void { + _ = version; + const entityModel = reader.readInt(u32) catch return; + const customTexture: ?main.graphics.Texture = null; + + renderComponents.put(id, RenderComponent{ + .entity = id, + .customTexture = customTexture, + .entityModel = main.entityModel.EntityModelIndex{.index = entityModel}, + }) catch unreachable; + } + pub fn unregister(id: u32) void { + _ = renderComponents.remove(id); + } +}; + +// ############################# Server only stuff ################################ + +pub const Server = struct { + pub const RenderComponent = struct { + entity: u32, // entity + entityModel: main.entityModel.EntityModelIndex, // model + customTexturePath: ?[]const u8, // customTexture + fn deinit(self: RenderComponent) void { + if (self.customTexturePath) |path| { + main.globalAllocator.free(path); + } + } + pub fn save(self: RenderComponent, writer: *utils.BinaryWriter) void { + writer.writeInt(u32, self.entityModel.index); + if (self.customTexturePath) |texutre| { + writer.writeSliceWithSize(texutre); + } else writer.writeSliceWithSize(""); + } + }; + var renderComponents: std.AutoHashMap(u32, RenderComponent) = undefined; + pub fn init() void { + renderComponents = .init(main.globalAllocator.allocator); + } + pub fn deinit() void { + var it = renderComponents.valueIterator(); + while (it.next()) |component| { + component.deinit(); + } + renderComponents.deinit(); + } + pub fn registerFromData(entity: u32, reader: *utils.BinaryReader, version: usize) void { + _ = version; + const entityModel = reader.readInt(u32) catch return; + const customTexturePath = reader.readSliceWithSize() catch return; + + registerByIndex(entity, main.entityModel.EntityModelIndex{.index = entityModel}, if (customTexturePath.len == 0) null else customTexturePath); + } + pub fn registerByID(entity: u32, entityModelID: []const u8, customTexturePath: ?[]const u8) void { + registerByIndex(entity, main.entityModel.getTypeById(entityModelID), customTexturePath); + } + pub fn registerByIndex(entity: u32, entityModel: main.entityModel.EntityModelIndex, customTexturePath: ?[]const u8) void { + if (renderComponents.get(entity)) |old| { + old.deinit(); + } + renderComponents.put(entity, RenderComponent{ + .entity = entity, + .customTexturePath = customTexturePath, + .entityModel = entityModel, + }) catch unreachable; + } + pub fn unregister(id: u32) void { + _ = renderComponents.remove(id); + } + pub fn put(id: u32, renderComponent: RenderComponent) void { + if (renderComponents.get(id)) |entry| { + entry.deinit(); + } + renderComponents.put(id, renderComponent) catch unreachable; + } + pub fn get(id: u32) ?RenderComponent { + return renderComponents.get(id); + } +}; From 927849b0a3c83bf1b33264c6643d2f096f713e93 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 7 Mar 2026 01:13:30 +0100 Subject: [PATCH 13/83] temporary Deinits --- src/game.zig | 3 +++ src/server/server.zig | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/game.zig b/src/game.zig index fca7ee0418..36bafd6295 100644 --- a/src/game.zig +++ b/src/game.zig @@ -669,6 +669,9 @@ pub const World = struct { // MARK: World self.biomePalette.deinit(); self.manager.deinit(); main.server.stop(); + + Player.super.deinit(.ClientSide); + if (main.server.thread) |serverThread| { serverThread.join(); main.server.thread = null; diff --git a/src/server/server.zig b/src/server/server.zig index 05042fcaa4..95e91be014 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -178,6 +178,8 @@ pub const User = struct { // MARK: User self.worldEditData.deinit(); + self.player.deinit(.ServerSide); + self.unloadOldChunk(.{0, 0, 0}, 0); self.conn.deinit(); self.jobQueue.deinit(); @@ -515,6 +517,13 @@ fn init(name: []const u8, singlePlayerPort: ?u16) void { // MARK: init() @panic("Could not open Server."); }; // TODO Configure the second argument in the server settings. + inline for (@typeInfo(main.entityComponent).@"struct".decls) |decl| { + @field(main.entityComponent, decl.name).Server.init(); + } + inline for (@typeInfo(main.entitySystem).@"struct".decls) |decl| { + @field(main.entitySystem, decl.name).Server.init(); + } + main.items.Inventory.ServerSide.init(); main.sync.ServerSide.init(); @@ -559,6 +568,13 @@ fn deinit() void { main.sync.ServerSide.deinit(); main.items.Inventory.ServerSide.deinit(); + + inline for (@typeInfo(main.entityComponent).@"struct".decls) |decl| { + @field(main.entityComponent, decl.name).Server.deinit(); + } + inline for (@typeInfo(main.entitySystem).@"struct".decls) |decl| { + @field(main.entitySystem, decl.name).Server.deinit(); + } command.deinit(); main.heap.allocators.destroyWorldArena(); From 87b048a5158719a15ee87b1620a49521bd94c493 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 7 Mar 2026 01:16:48 +0100 Subject: [PATCH 14/83] fmt --- src/game.zig | 2 +- src/server/server.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game.zig b/src/game.zig index 36bafd6295..6e63dca48e 100644 --- a/src/game.zig +++ b/src/game.zig @@ -671,7 +671,7 @@ pub const World = struct { // MARK: World main.server.stop(); Player.super.deinit(.ClientSide); - + if (main.server.thread) |serverThread| { serverThread.join(); main.server.thread = null; diff --git a/src/server/server.zig b/src/server/server.zig index 95e91be014..aac216648f 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -568,7 +568,7 @@ fn deinit() void { main.sync.ServerSide.deinit(); main.items.Inventory.ServerSide.deinit(); - + inline for (@typeInfo(main.entityComponent).@"struct".decls) |decl| { @field(main.entityComponent, decl.name).Server.deinit(); } From aadf9e8b74233d557cb725bd0fc6e434c268b3b0 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 7 Mar 2026 01:25:58 +0100 Subject: [PATCH 15/83] fmt --- src/server/server.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/server.zig b/src/server/server.zig index 43a756ad5f..dc74b47c1a 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -182,7 +182,7 @@ pub const User = struct { // MARK: User self.worldEditData.deinit(); - self.player.deinit(.ServerSide); + self.player().deinit(.ServerSide); self.unloadOldChunk(.{0, 0, 0}, 0); self.conn.deinit(); From 74608efa2273405e5c1a935c12ae1c52fc44386e Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 7 Mar 2026 01:26:26 +0100 Subject: [PATCH 16/83] fmt --- src/server/server.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/server.zig b/src/server/server.zig index 43a756ad5f..dc74b47c1a 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -182,7 +182,7 @@ pub const User = struct { // MARK: User self.worldEditData.deinit(); - self.player.deinit(.ServerSide); + self.player().deinit(.ServerSide); self.unloadOldChunk(.{0, 0, 0}, 0); self.conn.deinit(); From 253f1b7cd3e70507e4e94e2cd06f9f7f26dabc9a Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 4 Apr 2026 20:57:13 +0200 Subject: [PATCH 17/83] make merging easier --- assets/cubyz/entity/cubert.zig.zon | 5 - assets/cubyz/entity/missing.zig.zon | 5 - assets/cubyz/entity/moffalo.zig.zon | 5 - assets/cubyz/entity/snail.zig.zon | 5 - assets/cubyz/entity/snale.zig.zon | 5 - assets/cubyz/entity/textures/cubert.png | Bin 2342 -> 0 bytes assets/cubyz/entity/textures/missing.png | Bin 485 -> 0 bytes assets/cubyz/entity/textures/moffalo.png | Bin 3382 -> 0 bytes assets/cubyz/entity/textures/snail.png | Bin 1256 -> 0 bytes assets/cubyz/entity/textures/snale.png | Bin 1873 -> 0 bytes assets/cubyz/models/entity/cubert.obj | 381 ----------- assets/cubyz/models/entity/missing.obj | 38 -- assets/cubyz/models/entity/moffalo.obj | 765 ----------------------- assets/cubyz/models/entity/snail.obj | 183 ------ assets/cubyz/models/entity/snale.obj | 383 ------------ 15 files changed, 1775 deletions(-) delete mode 100644 assets/cubyz/entity/cubert.zig.zon delete mode 100644 assets/cubyz/entity/missing.zig.zon delete mode 100644 assets/cubyz/entity/moffalo.zig.zon delete mode 100644 assets/cubyz/entity/snail.zig.zon delete mode 100644 assets/cubyz/entity/snale.zig.zon delete mode 100644 assets/cubyz/entity/textures/cubert.png delete mode 100644 assets/cubyz/entity/textures/missing.png delete mode 100644 assets/cubyz/entity/textures/moffalo.png delete mode 100644 assets/cubyz/entity/textures/snail.png delete mode 100644 assets/cubyz/entity/textures/snale.png delete mode 100644 assets/cubyz/models/entity/cubert.obj delete mode 100644 assets/cubyz/models/entity/missing.obj delete mode 100644 assets/cubyz/models/entity/moffalo.obj delete mode 100644 assets/cubyz/models/entity/snail.obj delete mode 100644 assets/cubyz/models/entity/snale.obj diff --git a/assets/cubyz/entity/cubert.zig.zon b/assets/cubyz/entity/cubert.zig.zon deleted file mode 100644 index 4bb09ed512..0000000000 --- a/assets/cubyz/entity/cubert.zig.zon +++ /dev/null @@ -1,5 +0,0 @@ -.{ - .model = "cubyz:entity/cubert", - .texture = "cubert.png", - .height = 2, -} diff --git a/assets/cubyz/entity/missing.zig.zon b/assets/cubyz/entity/missing.zig.zon deleted file mode 100644 index cb0d1e8b0b..0000000000 --- a/assets/cubyz/entity/missing.zig.zon +++ /dev/null @@ -1,5 +0,0 @@ -.{ - .model = "cubyz:entity/missing", - .texture = "missing.png", - .height = 1, -} diff --git a/assets/cubyz/entity/moffalo.zig.zon b/assets/cubyz/entity/moffalo.zig.zon deleted file mode 100644 index 01ad2ece30..0000000000 --- a/assets/cubyz/entity/moffalo.zig.zon +++ /dev/null @@ -1,5 +0,0 @@ -.{ - .model = "cubyz:entity/moffalo", - .texture = "moffalo.png", - .height = 1.8, -} diff --git a/assets/cubyz/entity/snail.zig.zon b/assets/cubyz/entity/snail.zig.zon deleted file mode 100644 index b1032e1f33..0000000000 --- a/assets/cubyz/entity/snail.zig.zon +++ /dev/null @@ -1,5 +0,0 @@ -.{ - .model = "cubyz:entity/snail", - .texture = "snail.png", - .height = 1, -} diff --git a/assets/cubyz/entity/snale.zig.zon b/assets/cubyz/entity/snale.zig.zon deleted file mode 100644 index 981ed0ec49..0000000000 --- a/assets/cubyz/entity/snale.zig.zon +++ /dev/null @@ -1,5 +0,0 @@ -.{ - .model = "cubyz:entity/snale", - .texture = "snale.png", - .height = 2, -} diff --git a/assets/cubyz/entity/textures/cubert.png b/assets/cubyz/entity/textures/cubert.png deleted file mode 100644 index 17d1512b5fc6e6f69d5e57a77bc7032bcd1a22ec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2342 zcmV+>3EB3EP)AbBQJ!Sg7%=28bU-+NC+XJFZmD_2tuz3Js9*B5j_Mw*vka@ zGSE#V1TllrzzjvjyfNcwgLC&XM%HP6YwvIS?REA(XOHePqs@G9*n6+N*4pd;*1!Js zueJW;nHm^4_(}~C^R%f^dgJ_g#tikF)91QP&*1IEva_3?HXC<;(_riA_^4c5 zx2K`j_qK1@Y`-@!eAB$~d}EZp^Rojr%RUIaESV_06`JscH#27X!kByk_JYX*2wp5qxA&#e6PCm@g7ZKo0{VtWOzWJPRtVe!E0)f!%-8piy`td+${jk` zVcz`k`%(8G>g($pHuXep0{mV!rrTcoe08Vb(27?3E&zq+JxMs!aeh?7v-g4JiwpKT z?ixUp3XOr_zDk3PR%5EFsM>%u?Ao!te5teB-Y;4(*EAOjW^g#@^^d>piSoVn@}@G$ zDK;0(=lj}nu?d+7fZ!utSFPX{82@sGpvK&e4S^sn8?@JfC5slC-rhb_42c*R91d)Q zFSrtv2Wk`G3u(u{-}4ubor;n<6hIE`f{uN@%Yuaq0^5FWz7mJE64mW?3BGFFF=U0?iR)f<2ffcnpDnPs1kA3ttr9|&qfTl;tU z*#Ik~Hj;w)zeYy@>kNg@6~YT5;T3 zs{v>TNT792GBPk$oVrwSg5x@=*R|oiCkgN!lssz&g-E=^xAi$sBbYds9(`qP`NqiK zX3NnNsdMdx&Fjmj21d-R#wX2&pN`dKtv(i*l9c$&)a+}d(d2y;k=lCn>_osrb>IJi zq(lP#ynD~U24n&9KF(;M!2`5MnU-b<+c&&WMt&uV<(bxd?_Ya;r{iRUTbA!yyeU<` zQ*ShAW7r@F0^9ToQSoscWu+~OG##tB!&hchY+Mr9!rt`kP|ZUT-S2my$7FoAbxYdA?hRHLK@}1! zI)VSO5Pavl?()hwgB40Osh942+(yse%ORe%7YDx z;>|+UAy6s}nXEwmT0+-DD;hB7H9F&mEF)N?V~ad(?Qy?=egFjK@fWaj-+?i4kUUj!+=BoL$Qgl9$H*ASq5 z!dzGlU`Ptk-+Lnx9$<79V2P1*!Yz+{wc>fyi_;h(JO4Xtf_lUT5gtQQR1Hm)#=1x= z?*=|abqR6s=+>-RWA8~EYydS3<W1TIB8Q%3@V9ZCsz;YVGs&0QDpebh*&o@!w%N&5-0 z_#nR?b;0Wq8$@^-+Q#@BS9m_Vy{hSqCyXLJ66ztim%uR|%jfsDhT^AbQeFsRghI8q zyFFoOnvP#QYY-FFAK@)fRhBd1Jq1bXIWCqoJl-K* zIbf0iGr=)QfSKT!B*08?OcG!wIQ|0w0RR7_6@FX*000I_L_t&o07`?KGmPCtDF6Tf M07*qoM6N<$g2tk4^#A|> diff --git a/assets/cubyz/entity/textures/missing.png b/assets/cubyz/entity/textures/missing.png deleted file mode 100644 index a1a496d1e8e618190fe6ec2d13288d0363bd147f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 485 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 LNkvXXu0mjffsm?v diff --git a/assets/cubyz/models/entity/cubert.obj b/assets/cubyz/models/entity/cubert.obj deleted file mode 100644 index 05ff4d9539..0000000000 --- a/assets/cubyz/models/entity/cubert.obj +++ /dev/null @@ -1,381 +0,0 @@ -o Head -v 0.25 -0.2499999999999999 1.9375 -v 0.25 0.2500000000000001 1.9375 -v 0.25 -0.25 1.4375 -v 0.25 0.25 1.4375 -v -0.25 0.2500000000000001 1.9375 -v -0.25 -0.2499999999999999 1.9375 -v -0.25 0.25 1.4375 -v -0.25 -0.25 1.4375 -vt 0.125 0.875 -vt 0.25 0.875 -vt 0.25 0.75 -vt 0.125 0.75 -vt 0 0.875 -vt 0.125 0.875 -vt 0.125 0.75 -vt 0 0.75 -vt 0.375 0.875 -vt 0.5 0.875 -vt 0.5 0.75 -vt 0.375 0.75 -vt 0.25 0.875 -vt 0.375 0.875 -vt 0.375 0.75 -vt 0.25 0.75 -vt 0.25 0.875 -vt 0.125 0.875 -vt 0.125 1 -vt 0.25 1 -vt 0.375 1 -vt 0.25 1 -vt 0.25 0.875 -vt 0.375 0.875 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 4/4/1 7/3/1 5/2/1 2/1/1 -f 3/8/2 4/7/2 2/6/2 1/5/2 -f 8/12/3 3/11/3 1/10/3 6/9/3 -f 7/16/4 8/15/4 6/14/4 5/13/4 -f 6/20/5 1/19/5 2/18/5 5/17/5 -f 7/24/6 4/23/6 3/22/6 8/21/6 -o Branch -v -0.49999999999999983 -2.2347490210655874e-16 1.625 -v -0.49999999999999983 -1.124525996440431e-16 1.875 -v -0.24999999999999983 -1.9285873212787496e-16 1.625 -v -0.24999999999999983 -8.183642966535928e-17 1.875 -v -0.24999999999999983 -1.9285873212787496e-16 1.625 -v -0.24999999999999983 -8.183642966535928e-17 1.875 -v -0.49999999999999983 -2.2347490210655874e-16 1.625 -v -0.49999999999999983 -1.124525996440431e-16 1.875 -vt 0.4375 0.9375 -vt 0.4375 1 -vt 0.375 1 -vt 0.375 0.9375 -vt 0.375 0.9375 -vt 0.375 1 -vt 0.4375 1 -vt 0.4375 0.9375 -vn -1.2246467991473532e-16 1 -4.440892098500626e-16 -vn 1.2246467991473532e-16 -1 4.440892098500626e-16 -f 9/25/7 10/26/7 12/27/7 11/28/7 -f 13/29/8 14/30/8 16/31/8 15/32/8 -o Abdomen -v 0.25 -0.12499999999999986 1 -v 0.25 0.12500000000000017 1 -v 0.25 -0.12499999999999992 0.75 -v 0.25 0.1250000000000001 0.75 -v -0.25 0.12500000000000017 1 -v -0.25 -0.12499999999999986 1 -v -0.25 0.1250000000000001 0.75 -v -0.25 -0.12499999999999992 0.75 -vt 0.5 0.5 -vt 0.625 0.5 -vt 0.625 0.4375 -vt 0.5 0.4375 -vt 0.4375 0.5 -vt 0.5 0.5 -vt 0.5 0.4375 -vt 0.4375 0.4375 -vt 0.6875 0.5 -vt 0.8125 0.5 -vt 0.8125 0.4375 -vt 0.6875 0.4375 -vt 0.625 0.5 -vt 0.6875 0.5 -vt 0.6875 0.4375 -vt 0.625 0.4375 -vt 0.625 0.5 -vt 0.5 0.5 -vt 0.5 0.5625 -vt 0.625 0.5625 -vt 0.75 0.5625 -vt 0.625 0.5625 -vt 0.625 0.5 -vt 0.75 0.5 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 20/36/9 23/35/9 21/34/9 18/33/9 -f 19/40/10 20/39/10 18/38/10 17/37/10 -f 24/44/11 19/43/11 17/42/11 22/41/11 -f 23/48/12 24/47/12 22/46/12 21/45/12 -f 22/52/13 17/51/13 18/50/13 21/49/13 -f 23/56/14 20/55/14 19/54/14 24/53/14 -o Chest -v 0.3125 -0.12499999999999976 1.4375 -v 0.3125 0.12500000000000022 1.4375 -v 0.3125 -0.12499999999999986 1 -v 0.3125 0.12500000000000017 1 -v -0.3125 0.12500000000000022 1.4375 -v -0.3125 -0.12499999999999976 1.4375 -v -0.3125 0.12500000000000017 1 -v -0.3125 -0.12499999999999986 1 -vt 0.0625 0.5 -vt 0.21875 0.5 -vt 0.21875 0.390625 -vt 0.0625 0.390625 -vt 0 0.5 -vt 0.0625 0.5 -vt 0.0625 0.390625 -vt 0 0.390625 -vt 0.28125 0.5 -vt 0.4375 0.5 -vt 0.4375 0.390625 -vt 0.28125 0.390625 -vt 0.21875 0.5 -vt 0.28125 0.5 -vt 0.28125 0.390625 -vt 0.21875 0.390625 -vt 0.21875 0.5 -vt 0.0625 0.5 -vt 0.0625 0.5625 -vt 0.21875 0.5625 -vt 0.375 0.5625 -vt 0.21875 0.5625 -vt 0.21875 0.5 -vt 0.375 0.5 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 28/60/15 31/59/15 29/58/15 26/57/15 -f 27/64/16 28/63/16 26/62/16 25/61/16 -f 32/68/17 27/67/17 25/66/17 30/65/17 -f 31/72/18 32/71/18 30/70/18 29/69/18 -f 30/76/19 25/75/19 26/74/19 29/73/19 -f 31/80/20 28/79/20 27/78/20 32/77/20 -o Mantle -v 0.375 -0.15624999999999975 1.46875 -v 0.375 0.15625000000000025 1.46875 -v 0.375 -0.15624999999999986 1.03125 -v 0.375 0.15625000000000017 1.03125 -v -0.375 0.15625000000000025 1.46875 -v -0.375 -0.15624999999999975 1.46875 -v -0.375 0.15625000000000017 1.03125 -v -0.375 -0.15624999999999986 1.03125 -vt 0.078125 0.671875 -vt 0.265625 0.671875 -vt 0.265625 0.5625 -vt 0.078125 0.5625 -vt 0 0.671875 -vt 0.078125 0.671875 -vt 0.078125 0.5625 -vt 0 0.5625 -vt 0.34375 0.671875 -vt 0.53125 0.671875 -vt 0.53125 0.5625 -vt 0.34375 0.5625 -vt 0.265625 0.671875 -vt 0.34375 0.671875 -vt 0.34375 0.5625 -vt 0.265625 0.5625 -vt 0.265625 0.671875 -vt 0.078125 0.671875 -vt 0.078125 0.75 -vt 0.265625 0.75 -vt 0.453125 0.75 -vt 0.265625 0.75 -vt 0.265625 0.671875 -vt 0.453125 0.671875 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 36/84/21 39/83/21 37/82/21 34/81/21 -f 35/88/22 36/87/22 34/86/22 33/85/22 -f 40/92/23 35/91/23 33/90/23 38/89/23 -f 39/96/24 40/95/24 38/94/24 37/93/24 -f 38/100/25 33/99/25 34/98/25 37/97/25 -f 39/104/26 36/103/26 35/102/26 40/101/26 -o RightArm -v 0.5 -0.09374999999999976 1.375 -v 0.5 0.09375000000000022 1.375 -v 0.5 -0.09374999999999993 0.625 -v 0.5 0.09375000000000007 0.625 -v 0.3125 0.09375000000000022 1.375 -v 0.3125 -0.09374999999999976 1.375 -v 0.3125 0.09375000000000007 0.625 -v 0.3125 -0.09374999999999993 0.625 -vt 0.046875 0.34375 -vt 0.09375 0.34375 -vt 0.09375 0.15625 -vt 0.046875 0.15625 -vt 0 0.34375 -vt 0.046875 0.34375 -vt 0.046875 0.15625 -vt 0 0.15625 -vt 0.140625 0.34375 -vt 0.1875 0.34375 -vt 0.1875 0.15625 -vt 0.140625 0.15625 -vt 0.09375 0.34375 -vt 0.140625 0.34375 -vt 0.140625 0.15625 -vt 0.09375 0.15625 -vt 0.09375 0.34375 -vt 0.046875 0.34375 -vt 0.046875 0.390625 -vt 0.09375 0.390625 -vt 0.140625 0.390625 -vt 0.09375 0.390625 -vt 0.09375 0.34375 -vt 0.140625 0.34375 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 44/108/27 47/107/27 45/106/27 42/105/27 -f 43/112/28 44/111/28 42/110/28 41/109/28 -f 48/116/29 43/115/29 41/114/29 46/113/29 -f 47/120/30 48/119/30 46/118/30 45/117/30 -f 46/124/31 41/123/31 42/122/31 45/121/31 -f 47/128/32 44/127/32 43/126/32 48/125/32 -o LeftArm -v -0.3125 -0.09374999999999976 1.375 -v -0.3125 0.09375000000000022 1.375 -v -0.3125 -0.09374999999999993 0.625 -v -0.3125 0.09375000000000007 0.625 -v -0.5 0.09375000000000022 1.375 -v -0.5 -0.09374999999999976 1.375 -v -0.5 0.09375000000000007 0.625 -v -0.5 -0.09374999999999993 0.625 -vt 0.234375 0.34375 -vt 0.28125 0.34375 -vt 0.28125 0.15625 -vt 0.234375 0.15625 -vt 0.1875 0.34375 -vt 0.234375 0.34375 -vt 0.234375 0.15625 -vt 0.1875 0.15625 -vt 0.328125 0.34375 -vt 0.375 0.34375 -vt 0.375 0.15625 -vt 0.328125 0.15625 -vt 0.28125 0.34375 -vt 0.328125 0.34375 -vt 0.328125 0.15625 -vt 0.28125 0.15625 -vt 0.28125 0.34375 -vt 0.234375 0.34375 -vt 0.234375 0.390625 -vt 0.28125 0.390625 -vt 0.328125 0.390625 -vt 0.28125 0.390625 -vt 0.28125 0.34375 -vt 0.328125 0.34375 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 52/132/33 55/131/33 53/130/33 50/129/33 -f 51/136/34 52/135/34 50/134/34 49/133/34 -f 56/140/35 51/139/35 49/138/35 54/137/35 -f 55/144/36 56/143/36 54/142/36 53/141/36 -f 54/148/37 49/147/37 50/146/37 53/145/37 -f 55/152/38 52/151/38 51/150/38 56/149/38 -o RightLeg -v 0.25 -0.12499999999999989 0.75 -v 0.25 0.1250000000000001 0.75 -v 0.25 -0.12500000000000006 0 -v 0.25 0.12499999999999994 0 -v 0.0625 0.1250000000000001 0.75 -v 0.0625 -0.12499999999999989 0.75 -v 0.0625 0.12499999999999994 0 -v 0.0625 -0.12500000000000006 0 -vt 0.5625 0.9375 -vt 0.609375 0.9375 -vt 0.609375 0.75 -vt 0.5625 0.75 -vt 0.5 0.9375 -vt 0.5625 0.9375 -vt 0.5625 0.75 -vt 0.5 0.75 -vt 0.671875 0.9375 -vt 0.71875 0.9375 -vt 0.71875 0.75 -vt 0.671875 0.75 -vt 0.609375 0.9375 -vt 0.671875 0.9375 -vt 0.671875 0.75 -vt 0.609375 0.75 -vt 0.609375 0.9375 -vt 0.5625 0.9375 -vt 0.5625 1 -vt 0.609375 1 -vt 0.65625 1 -vt 0.609375 1 -vt 0.609375 0.9375 -vt 0.65625 0.9375 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 60/156/39 63/155/39 61/154/39 58/153/39 -f 59/160/40 60/159/40 58/158/40 57/157/40 -f 64/164/41 59/163/41 57/162/41 62/161/41 -f 63/168/42 64/167/42 62/166/42 61/165/42 -f 62/172/43 57/171/43 58/170/43 61/169/43 -f 63/176/44 60/175/44 59/174/44 64/173/44 -o LeftLeg -v -0.0625 -0.12499999999999989 0.75 -v -0.0625 0.1250000000000001 0.75 -v -0.0625 -0.12500000000000006 0 -v -0.0625 0.12499999999999994 0 -v -0.25 0.1250000000000001 0.75 -v -0.25 -0.12499999999999989 0.75 -v -0.25 0.12499999999999994 0 -v -0.25 -0.12500000000000006 0 -vt 0.5 0.375 -vt 0.546875 0.375 -vt 0.546875 0.1875 -vt 0.5 0.1875 -vt 0.4375 0.375 -vt 0.5 0.375 -vt 0.5 0.1875 -vt 0.4375 0.1875 -vt 0.609375 0.375 -vt 0.65625 0.375 -vt 0.65625 0.1875 -vt 0.609375 0.1875 -vt 0.546875 0.375 -vt 0.609375 0.375 -vt 0.609375 0.1875 -vt 0.546875 0.1875 -vt 0.546875 0.375 -vt 0.5 0.375 -vt 0.5 0.4375 -vt 0.546875 0.4375 -vt 0.59375 0.4375 -vt 0.546875 0.4375 -vt 0.546875 0.375 -vt 0.59375 0.375 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 68/180/45 71/179/45 69/178/45 66/177/45 -f 67/184/46 68/183/46 66/182/46 65/181/46 -f 72/188/47 67/187/47 65/186/47 70/185/47 -f 71/192/48 72/191/48 70/190/48 69/189/48 -f 70/196/49 65/195/49 66/194/49 69/193/49 -f 71/200/50 68/199/50 67/198/50 72/197/50 \ No newline at end of file diff --git a/assets/cubyz/models/entity/missing.obj b/assets/cubyz/models/entity/missing.obj deleted file mode 100644 index 895132ab60..0000000000 --- a/assets/cubyz/models/entity/missing.obj +++ /dev/null @@ -1,38 +0,0 @@ -# Blender v3.0.1 OBJ File: 'missing.blend' -# www.blender.org -o Cube -v 0.500000 0.500000 0.015418 -v 0.500000 -0.500000 0.015418 -v 0.500000 0.500000 1.015418 -v 0.500000 -0.500000 1.015418 -v -0.500000 0.500000 0.015418 -v -0.500000 -0.500000 0.015418 -v -0.500000 0.500000 1.015418 -v -0.500000 -0.500000 1.015418 -vt 0.625000 0.500000 -vt 0.875000 0.500000 -vt 0.875000 0.750000 -vt 0.625000 0.750000 -vt 0.375000 0.750000 -vt 0.625000 1.000000 -vt 0.375000 1.000000 -vt 0.375000 0.000000 -vt 0.625000 0.000000 -vt 0.625000 0.250000 -vt 0.375000 0.250000 -vt 0.125000 0.500000 -vt 0.375000 0.500000 -vt 0.125000 0.750000 -vn 0.0000 1.0000 0.0000 -vn 0.0000 0.0000 1.0000 -vn -1.0000 0.0000 0.0000 -vn 0.0000 -1.0000 0.0000 -vn 1.0000 0.0000 0.0000 -vn 0.0000 0.0000 -1.0000 -s off -f 1/1/1 5/2/1 7/3/1 3/4/1 -f 4/5/2 3/4/2 7/6/2 8/7/2 -f 8/8/3 7/9/3 5/10/3 6/11/3 -f 6/12/4 2/13/4 4/5/4 8/14/4 -f 2/13/5 1/1/5 3/4/5 4/5/5 -f 6/11/6 5/10/6 1/1/6 2/13/6 diff --git a/assets/cubyz/models/entity/moffalo.obj b/assets/cubyz/models/entity/moffalo.obj deleted file mode 100644 index 9505890293..0000000000 --- a/assets/cubyz/models/entity/moffalo.obj +++ /dev/null @@ -1,765 +0,0 @@ -o cube -v -0.21875 0.8750000000000002 1.5624999999999998 -v -0.21875 1.1875000000000002 1.5624999999999998 -v -0.21875 0.8750000000000002 1.0624999999999998 -v -0.21875 1.1875000000000002 1.0624999999999998 -v -0.21875 1.1875000000000002 1.5624999999999998 -v -0.21875 0.8750000000000002 1.5624999999999998 -v -0.21875 1.1875000000000002 1.0624999999999998 -v -0.21875 0.8750000000000002 1.0624999999999998 -vt 0.0390625 0.46875 -vt 0.0390625 0.46875 -vt 0.0390625 0.40625 -vt 0.0390625 0.40625 -vt 0 0.46875 -vt 0.0390625 0.46875 -vt 0.0390625 0.40625 -vt 0 0.40625 -vt 0.078125 0.46875 -vt 0.078125 0.46875 -vt 0.078125 0.40625 -vt 0.078125 0.40625 -vt 0.0390625 0.46875 -vt 0.078125 0.46875 -vt 0.078125 0.40625 -vt 0.0390625 0.40625 -vt 0.0390625 0.46875 -vt 0.0390625 0.46875 -vt 0.0390625 0.5078125 -vt 0.0390625 0.5078125 -vt 0.0390625 0.5078125 -vt 0.0390625 0.5078125 -vt 0.0390625 0.46875 -vt 0.0390625 0.46875 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 4/4/1 7/3/1 5/2/1 2/1/1 -f 3/8/2 4/7/2 2/6/2 1/5/2 -f 8/12/3 3/11/3 1/10/3 6/9/3 -f 7/16/4 8/15/4 6/14/4 5/13/4 -f 6/20/5 1/19/5 2/18/5 5/17/5 -f 7/24/6 4/23/6 3/22/6 8/21/6 -o cube -v -0.1875 1.0000000000000002 1.6249999999999998 -v -0.1875 1.0625000000000002 1.6249999999999998 -v -0.1875 1.0000000000000002 1.0624999999999998 -v -0.1875 1.0625000000000002 1.0624999999999998 -v -0.25 1.0625000000000002 1.6249999999999998 -v -0.25 1.0000000000000002 1.6249999999999998 -v -0.25 1.0625000000000002 1.0624999999999998 -v -0.25 1.0000000000000002 1.0624999999999998 -vt 0.1328125 0.3984375 -vt 0.140625 0.3984375 -vt 0.140625 0.328125 -vt 0.1328125 0.328125 -vt 0.125 0.3984375 -vt 0.1328125 0.3984375 -vt 0.1328125 0.328125 -vt 0.125 0.328125 -vt 0.1484375 0.3984375 -vt 0.15625 0.3984375 -vt 0.15625 0.328125 -vt 0.1484375 0.328125 -vt 0.140625 0.3984375 -vt 0.1484375 0.3984375 -vt 0.1484375 0.328125 -vt 0.140625 0.328125 -vt 0.140625 0.3984375 -vt 0.1328125 0.3984375 -vt 0.1328125 0.40625 -vt 0.140625 0.40625 -vt 0.1484375 0.40625 -vt 0.140625 0.40625 -vt 0.140625 0.3984375 -vt 0.1484375 0.3984375 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 12/28/7 15/27/7 13/26/7 10/25/7 -f 11/32/8 12/31/8 10/30/8 9/29/8 -f 16/36/9 11/35/9 9/34/9 14/33/9 -f 15/40/10 16/39/10 14/38/10 13/37/10 -f 14/44/11 9/43/11 10/42/11 13/41/11 -f 15/48/12 12/47/12 11/46/12 16/45/12 -o cube -v 0.21875 0.8750000000000002 1.5624999999999998 -v 0.21875 1.1875000000000002 1.5624999999999998 -v 0.21875 0.8750000000000002 1.0624999999999998 -v 0.21875 1.1875000000000002 1.0624999999999998 -v 0.21875 1.1875000000000002 1.5624999999999998 -v 0.21875 0.8750000000000002 1.5624999999999998 -v 0.21875 1.1875000000000002 1.0624999999999998 -v 0.21875 0.8750000000000002 1.0624999999999998 -vt 0.0390625 0.46875 -vt 0.0390625 0.46875 -vt 0.0390625 0.40625 -vt 0.0390625 0.40625 -vt 0 0.46875 -vt 0.0390625 0.46875 -vt 0.0390625 0.40625 -vt 0 0.40625 -vt 0.078125 0.46875 -vt 0.078125 0.46875 -vt 0.078125 0.40625 -vt 0.078125 0.40625 -vt 0.0390625 0.46875 -vt 0.078125 0.46875 -vt 0.078125 0.40625 -vt 0.0390625 0.40625 -vt 0.0390625 0.46875 -vt 0.0390625 0.46875 -vt 0.0390625 0.5078125 -vt 0.0390625 0.5078125 -vt 0.0390625 0.5078125 -vt 0.0390625 0.5078125 -vt 0.0390625 0.46875 -vt 0.0390625 0.46875 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 20/52/13 23/51/13 21/50/13 18/49/13 -f 19/56/14 20/55/14 18/54/14 17/53/14 -f 24/60/15 19/59/15 17/58/15 22/57/15 -f 23/64/16 24/63/16 22/62/16 21/61/16 -f 22/68/17 17/67/17 18/66/17 21/65/17 -f 23/72/18 20/71/18 19/70/18 24/69/18 -o cube -v 0.25 1.0000000000000002 1.6249999999999998 -v 0.25 1.0625000000000002 1.6249999999999998 -v 0.25 1.0000000000000002 1.0624999999999998 -v 0.25 1.0625000000000002 1.0624999999999998 -v 0.1875 1.0625000000000002 1.6249999999999998 -v 0.1875 1.0000000000000002 1.6249999999999998 -v 0.1875 1.0625000000000002 1.0624999999999998 -v 0.1875 1.0000000000000002 1.0624999999999998 -vt 0.1328125 0.3984375 -vt 0.140625 0.3984375 -vt 0.140625 0.328125 -vt 0.1328125 0.328125 -vt 0.125 0.3984375 -vt 0.1328125 0.3984375 -vt 0.1328125 0.328125 -vt 0.125 0.328125 -vt 0.1484375 0.3984375 -vt 0.15625 0.3984375 -vt 0.15625 0.328125 -vt 0.1484375 0.328125 -vt 0.140625 0.3984375 -vt 0.1484375 0.3984375 -vt 0.1484375 0.328125 -vt 0.140625 0.328125 -vt 0.140625 0.3984375 -vt 0.1328125 0.3984375 -vt 0.1328125 0.40625 -vt 0.140625 0.40625 -vt 0.1484375 0.40625 -vt 0.140625 0.40625 -vt 0.140625 0.3984375 -vt 0.1484375 0.3984375 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 28/76/19 31/75/19 29/74/19 26/73/19 -f 27/80/20 28/79/20 26/78/20 25/77/20 -f 32/84/21 27/83/21 25/82/21 30/81/21 -f 31/88/22 32/87/22 30/86/22 29/85/22 -f 30/92/23 25/91/23 26/90/23 29/89/23 -f 31/96/24 28/95/24 27/94/24 32/93/24 -o cube -v 0.25 0.6250000000000002 1.0624999999999998 -v 0.25 1.0625000000000002 1.0624999999999996 -v 0.25 0.6250000000000002 0.6249999999999998 -v 0.25 1.0625000000000002 0.6249999999999996 -v -0.25 1.0625000000000002 1.0624999999999996 -v -0.25 0.6250000000000002 1.0624999999999998 -v -0.25 1.0625000000000002 0.6249999999999996 -v -0.25 0.6250000000000002 0.6249999999999998 -vt 0.5390625 0.9453125 -vt 0.6015625 0.9453125 -vt 0.6015625 0.890625 -vt 0.5390625 0.890625 -vt 0.484375 0.9453125 -vt 0.5390625 0.9453125 -vt 0.5390625 0.890625 -vt 0.484375 0.890625 -vt 0.65625 0.9453125 -vt 0.71875 0.9453125 -vt 0.71875 0.890625 -vt 0.65625 0.890625 -vt 0.6015625 0.9453125 -vt 0.65625 0.9453125 -vt 0.65625 0.890625 -vt 0.6015625 0.890625 -vt 0.6015625 0.9453125 -vt 0.5390625 0.9453125 -vt 0.5390625 1 -vt 0.6015625 1 -vt 0.6640625 1 -vt 0.6015625 1 -vt 0.6015625 0.9453125 -vt 0.6640625 0.9453125 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 36/100/25 39/99/25 37/98/25 34/97/25 -f 35/104/26 36/103/26 34/102/26 33/101/26 -f 40/108/27 35/107/27 33/106/27 38/105/27 -f 39/112/28 40/111/28 38/110/28 37/109/28 -f 38/116/29 33/115/29 34/114/29 37/113/29 -f 39/120/30 36/119/30 35/118/30 40/117/30 -o cube -v 0.125 1.0625000000000002 0.6249999999999996 -v 0.125 1.0625000000000002 0.6249999999999996 -v 0.125 1.0625000000000002 0.5624999999999996 -v 0.125 1.0625000000000002 0.5624999999999996 -v -0.125 1.0625000000000002 0.6249999999999996 -v -0.125 1.0625000000000002 0.6249999999999996 -v -0.125 1.0625000000000002 0.5624999999999996 -v -0.125 1.0625000000000002 0.5624999999999996 -vt 0.484375 0.75 -vt 0.515625 0.75 -vt 0.515625 0.7421875 -vt 0.484375 0.7421875 -vt 0.484375 0.75 -vt 0.484375 0.75 -vt 0.484375 0.7421875 -vt 0.484375 0.7421875 -vt 0.515625 0.75 -vt 0.546875 0.75 -vt 0.546875 0.7421875 -vt 0.515625 0.7421875 -vt 0.515625 0.75 -vt 0.515625 0.75 -vt 0.515625 0.7421875 -vt 0.515625 0.7421875 -vt 0.515625 0.75 -vt 0.484375 0.75 -vt 0.484375 0.75 -vt 0.515625 0.75 -vt 0.546875 0.75 -vt 0.515625 0.75 -vt 0.515625 0.75 -vt 0.546875 0.75 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 44/124/31 47/123/31 45/122/31 42/121/31 -f 43/128/32 44/127/32 42/126/32 41/125/32 -f 48/132/33 43/131/33 41/130/33 46/129/33 -f 47/136/34 48/135/34 46/134/34 45/133/34 -f 46/140/35 41/139/35 42/138/35 45/137/35 -f 47/144/36 44/143/36 43/142/36 48/141/36 -o cube -v -0.25 -0.06249999999999986 0.625 -v -0.25 0.06250000000000014 0.625 -v -0.25 -0.0625 0 -v -0.25 0.0625 0 -v -0.375 0.06250000000000014 0.625 -v -0.375 -0.06249999999999986 0.625 -v -0.375 0.0625 0 -v -0.375 -0.0625 0 -vt 0.359375 0.4921875 -vt 0.375 0.4921875 -vt 0.375 0.4140625 -vt 0.359375 0.4140625 -vt 0.34375 0.4921875 -vt 0.359375 0.4921875 -vt 0.359375 0.4140625 -vt 0.34375 0.4140625 -vt 0.390625 0.4921875 -vt 0.40625 0.4921875 -vt 0.40625 0.4140625 -vt 0.390625 0.4140625 -vt 0.375 0.4921875 -vt 0.390625 0.4921875 -vt 0.390625 0.4140625 -vt 0.375 0.4140625 -vt 0.375 0.4921875 -vt 0.359375 0.4921875 -vt 0.359375 0.5078125 -vt 0.375 0.5078125 -vt 0.390625 0.5078125 -vt 0.375 0.5078125 -vt 0.375 0.4921875 -vt 0.390625 0.4921875 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 52/148/37 55/147/37 53/146/37 50/145/37 -f 51/152/38 52/151/38 50/150/38 49/149/38 -f 56/156/39 51/155/39 49/154/39 54/153/39 -f 55/160/40 56/159/40 54/158/40 53/157/40 -f 54/164/41 49/163/41 50/162/41 53/161/41 -f 55/168/42 52/167/42 51/166/42 56/165/42 -o cube -v 0.375 0.37500000000000017 0.6249999999999999 -v 0.375 0.5000000000000002 0.6249999999999999 -v 0.375 0.375 -1.1102230246251565e-16 -v 0.375 0.5 -1.1102230246251565e-16 -v 0.25 0.5000000000000002 0.6249999999999999 -v 0.25 0.37500000000000017 0.6249999999999999 -v 0.25 0.5 -1.1102230246251565e-16 -v 0.25 0.375 -1.1102230246251565e-16 -vt 0.234375 0.4921875 -vt 0.25 0.4921875 -vt 0.25 0.4140625 -vt 0.234375 0.4140625 -vt 0.21875 0.4921875 -vt 0.234375 0.4921875 -vt 0.234375 0.4140625 -vt 0.21875 0.4140625 -vt 0.265625 0.4921875 -vt 0.28125 0.4921875 -vt 0.28125 0.4140625 -vt 0.265625 0.4140625 -vt 0.25 0.4921875 -vt 0.265625 0.4921875 -vt 0.265625 0.4140625 -vt 0.25 0.4140625 -vt 0.25 0.4921875 -vt 0.234375 0.4921875 -vt 0.234375 0.5078125 -vt 0.25 0.5078125 -vt 0.265625 0.5078125 -vt 0.25 0.5078125 -vt 0.25 0.4921875 -vt 0.265625 0.4921875 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 60/172/43 63/171/43 61/170/43 58/169/43 -f 59/176/44 60/175/44 58/174/44 57/173/44 -f 64/180/45 59/179/45 57/178/45 62/177/45 -f 63/184/46 64/183/46 62/182/46 61/181/46 -f 62/188/47 57/187/47 58/186/47 61/185/47 -f 63/192/48 60/191/48 59/190/48 64/189/48 -o cube -v -0.25 0.37500000000000017 0.6249999999999999 -v -0.25 0.5000000000000002 0.6249999999999999 -v -0.25 0.375 -1.1102230246251565e-16 -v -0.25 0.5 -1.1102230246251565e-16 -v -0.375 0.5000000000000002 0.6249999999999999 -v -0.375 0.37500000000000017 0.6249999999999999 -v -0.375 0.5 -1.1102230246251565e-16 -v -0.375 0.375 -1.1102230246251565e-16 -vt 0.359375 0.4921875 -vt 0.375 0.4921875 -vt 0.375 0.4140625 -vt 0.359375 0.4140625 -vt 0.34375 0.4921875 -vt 0.359375 0.4921875 -vt 0.359375 0.4140625 -vt 0.34375 0.4140625 -vt 0.390625 0.4921875 -vt 0.40625 0.4921875 -vt 0.40625 0.4140625 -vt 0.390625 0.4140625 -vt 0.375 0.4921875 -vt 0.390625 0.4921875 -vt 0.390625 0.4140625 -vt 0.375 0.4140625 -vt 0.375 0.4921875 -vt 0.359375 0.4921875 -vt 0.359375 0.5078125 -vt 0.375 0.5078125 -vt 0.390625 0.5078125 -vt 0.375 0.5078125 -vt 0.375 0.4921875 -vt 0.390625 0.4921875 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 68/196/49 71/195/49 69/194/49 66/193/49 -f 67/200/50 68/199/50 66/198/50 65/197/50 -f 72/204/51 67/203/51 65/202/51 70/201/51 -f 71/208/52 72/207/52 70/206/52 69/205/52 -f 70/212/53 65/211/53 66/210/53 69/209/53 -f 71/216/54 68/215/54 67/214/54 72/213/54 -o cube -v 0.375 -0.06249999999999986 0.625 -v 0.375 0.06250000000000014 0.625 -v 0.375 -0.0625 0 -v 0.375 0.0625 0 -v 0.25 0.06250000000000014 0.625 -v 0.25 -0.06249999999999986 0.625 -v 0.25 0.0625 0 -v 0.25 -0.0625 0 -vt 0.234375 0.4921875 -vt 0.25 0.4921875 -vt 0.25 0.4140625 -vt 0.234375 0.4140625 -vt 0.21875 0.4921875 -vt 0.234375 0.4921875 -vt 0.234375 0.4140625 -vt 0.21875 0.4140625 -vt 0.265625 0.4921875 -vt 0.28125 0.4921875 -vt 0.28125 0.4140625 -vt 0.265625 0.4140625 -vt 0.25 0.4921875 -vt 0.265625 0.4921875 -vt 0.265625 0.4140625 -vt 0.25 0.4140625 -vt 0.25 0.4921875 -vt 0.234375 0.4921875 -vt 0.234375 0.5078125 -vt 0.25 0.5078125 -vt 0.265625 0.5078125 -vt 0.25 0.5078125 -vt 0.25 0.4921875 -vt 0.265625 0.4921875 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 76/220/55 79/219/55 77/218/55 74/217/55 -f 75/224/56 76/223/56 74/222/56 73/221/56 -f 80/228/57 75/227/57 73/226/57 78/225/57 -f 79/232/58 80/231/58 78/230/58 77/229/58 -f 78/236/59 73/235/59 74/234/59 77/233/59 -f 79/240/60 76/239/60 75/238/60 80/237/60 -o Over -v 0.5625 -0.12499999999999961 1.625 -v 0.5625 0.6875000000000004 1.625 -v 0.5625 -0.12499999999999994 0.37500000000000006 -v 0.5625 0.6875 0.3749999999999999 -v -0.5625 0.6875000000000004 1.625 -v -0.5625 -0.12499999999999961 1.625 -v -0.5625 0.6875 0.3749999999999999 -v -0.5625 -0.12499999999999994 0.37500000000000006 -vt 0.1015625 0.8984375 -vt 0.2421875 0.8984375 -vt 0.2421875 0.7421875 -vt 0.1015625 0.7421875 -vt 0 0.8984375 -vt 0.1015625 0.8984375 -vt 0.1015625 0.7421875 -vt 0 0.7421875 -vt 0.34375 0.8984375 -vt 0.484375 0.8984375 -vt 0.484375 0.7421875 -vt 0.34375 0.7421875 -vt 0.2421875 0.8984375 -vt 0.34375 0.8984375 -vt 0.34375 0.7421875 -vt 0.2421875 0.7421875 -vt 0.2421875 0.8984375 -vt 0.1015625 0.8984375 -vt 0.1015625 1 -vt 0.2421875 1 -vt 0.3828125 1 -vt 0.2421875 1 -vt 0.2421875 0.8984375 -vt 0.3828125 0.8984375 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 84/244/61 87/243/61 85/242/61 82/241/61 -f 83/248/62 84/247/62 82/246/62 81/245/62 -f 88/252/63 83/251/63 81/250/63 86/249/63 -f 87/256/64 88/255/64 86/254/64 85/253/64 -f 86/260/65 81/259/65 82/258/65 85/257/65 -f 87/264/66 84/263/66 83/262/66 88/261/66 -o FrontUnder -v 0.4375 -0.06249999999999965 1.5625 -v 0.4375 0.6250000000000003 1.5625 -v 0.4375 -0.06249999999999986 0.625 -v 0.4375 0.6250000000000001 0.6249999999999998 -v -0.4375 0.6250000000000003 1.5625 -v -0.4375 -0.06249999999999965 1.5625 -v -0.4375 0.6250000000000001 0.6249999999999998 -v -0.4375 -0.06249999999999986 0.625 -vt 0.4921875 0.65625 -vt 0.6015625 0.65625 -vt 0.6015625 0.5390625 -vt 0.4921875 0.5390625 -vt 0.40625 0.65625 -vt 0.4921875 0.65625 -vt 0.4921875 0.5390625 -vt 0.40625 0.5390625 -vt 0.6875 0.65625 -vt 0.796875 0.65625 -vt 0.796875 0.5390625 -vt 0.6875 0.5390625 -vt 0.6015625 0.65625 -vt 0.6875 0.65625 -vt 0.6875 0.5390625 -vt 0.6015625 0.5390625 -vt 0.6015625 0.65625 -vt 0.4921875 0.65625 -vt 0.4921875 0.7421875 -vt 0.6015625 0.7421875 -vt 0.7109375 0.7421875 -vt 0.6015625 0.7421875 -vt 0.6015625 0.65625 -vt 0.7109375 0.65625 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 92/268/67 95/267/67 93/266/67 90/265/67 -f 91/272/68 92/271/68 90/270/68 89/269/68 -f 96/276/69 91/275/69 89/274/69 94/273/69 -f 95/280/70 96/279/70 94/278/70 93/277/70 -f 94/284/71 89/283/71 90/282/71 93/281/71 -f 95/288/72 92/287/72 91/286/72 96/285/72 -o cube -v -0.1875 -0.49999999999999983 0.625 -v -0.1875 -0.37499999999999983 0.625 -v -0.1875 -0.5 0 -v -0.1875 -0.375 0 -v -0.3125 -0.37499999999999983 0.625 -v -0.3125 -0.49999999999999983 0.625 -v -0.3125 -0.375 0 -v -0.3125 -0.5 0 -vt 0.359375 0.4921875 -vt 0.375 0.4921875 -vt 0.375 0.4140625 -vt 0.359375 0.4140625 -vt 0.34375 0.4921875 -vt 0.359375 0.4921875 -vt 0.359375 0.4140625 -vt 0.34375 0.4140625 -vt 0.390625 0.4921875 -vt 0.40625 0.4921875 -vt 0.40625 0.4140625 -vt 0.390625 0.4140625 -vt 0.375 0.4921875 -vt 0.390625 0.4921875 -vt 0.390625 0.4140625 -vt 0.375 0.4140625 -vt 0.375 0.4921875 -vt 0.359375 0.4921875 -vt 0.359375 0.5078125 -vt 0.375 0.5078125 -vt 0.390625 0.5078125 -vt 0.375 0.5078125 -vt 0.375 0.4921875 -vt 0.390625 0.4921875 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 100/292/73 103/291/73 101/290/73 98/289/73 -f 99/296/74 100/295/74 98/294/74 97/293/74 -f 104/300/75 99/299/75 97/298/75 102/297/75 -f 103/304/76 104/303/76 102/302/76 101/301/76 -f 102/308/77 97/307/77 98/306/77 101/305/77 -f 103/312/78 100/311/78 99/310/78 104/309/78 -o cube -v 0.3125 -0.49999999999999983 0.625 -v 0.3125 -0.37499999999999983 0.625 -v 0.3125 -0.5 0 -v 0.3125 -0.375 0 -v 0.1875 -0.37499999999999983 0.625 -v 0.1875 -0.49999999999999983 0.625 -v 0.1875 -0.375 0 -v 0.1875 -0.5 0 -vt 0.234375 0.4921875 -vt 0.25 0.4921875 -vt 0.25 0.4140625 -vt 0.234375 0.4140625 -vt 0.21875 0.4921875 -vt 0.234375 0.4921875 -vt 0.234375 0.4140625 -vt 0.21875 0.4140625 -vt 0.265625 0.4921875 -vt 0.28125 0.4921875 -vt 0.28125 0.4140625 -vt 0.265625 0.4140625 -vt 0.25 0.4921875 -vt 0.265625 0.4921875 -vt 0.265625 0.4140625 -vt 0.25 0.4140625 -vt 0.25 0.4921875 -vt 0.234375 0.4921875 -vt 0.234375 0.5078125 -vt 0.25 0.5078125 -vt 0.265625 0.5078125 -vt 0.25 0.5078125 -vt 0.25 0.4921875 -vt 0.265625 0.4921875 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 108/316/79 111/315/79 109/314/79 106/313/79 -f 107/320/80 108/319/80 106/318/80 105/317/80 -f 112/324/81 107/323/81 105/322/81 110/321/81 -f 111/328/82 112/327/82 110/326/82 109/325/82 -f 110/332/83 105/331/83 106/330/83 109/329/83 -f 111/336/84 108/335/84 107/334/84 112/333/84 -o abdomen -v 0.25 -1.0624999999999998 0.9375000000000002 -v 0.25 -0.6874999999999998 0.9375000000000001 -v 0.25 -1.0624999999999998 0.6875000000000002 -v 0.25 -0.6874999999999998 0.6875000000000001 -v -0.25 -0.6874999999999998 0.9375000000000001 -v -0.25 -1.0624999999999998 0.9375000000000002 -v -0.25 -0.6874999999999998 0.6875000000000001 -v -0.25 -1.0624999999999998 0.6875000000000002 -vt 0.53125 0.84375 -vt 0.59375 0.84375 -vt 0.59375 0.8125 -vt 0.53125 0.8125 -vt 0.484375 0.84375 -vt 0.53125 0.84375 -vt 0.53125 0.8125 -vt 0.484375 0.8125 -vt 0.640625 0.84375 -vt 0.703125 0.84375 -vt 0.703125 0.8125 -vt 0.640625 0.8125 -vt 0.59375 0.84375 -vt 0.640625 0.84375 -vt 0.640625 0.8125 -vt 0.59375 0.8125 -vt 0.59375 0.84375 -vt 0.53125 0.84375 -vt 0.53125 0.890625 -vt 0.59375 0.890625 -vt 0.65625 0.890625 -vt 0.59375 0.890625 -vt 0.59375 0.84375 -vt 0.65625 0.84375 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 116/340/85 119/339/85 117/338/85 114/337/85 -f 115/344/86 116/343/86 114/342/86 113/341/86 -f 120/348/87 115/347/87 113/346/87 118/345/87 -f 119/352/88 120/351/88 118/350/88 117/349/88 -f 118/356/89 113/355/89 114/354/89 117/353/89 -f 119/360/90 116/359/90 115/358/90 120/357/90 -o Over -v 0.4375 -0.7499999999999996 1.5 -v 0.4375 3.3306690738754696e-16 1.5 -v 0.4375 -0.75 0.3750000000000001 -v 0.4375 8.326672684688674e-17 0.375 -v -0.4375 3.3306690738754696e-16 1.5 -v -0.4375 -0.7499999999999996 1.5 -v -0.4375 8.326672684688674e-17 0.375 -v -0.4375 -0.75 0.3750000000000001 -vt 0.09375 0.6484375 -vt 0.203125 0.6484375 -vt 0.203125 0.5078125 -vt 0.09375 0.5078125 -vt 0 0.6484375 -vt 0.09375 0.6484375 -vt 0.09375 0.5078125 -vt 0 0.5078125 -vt 0.296875 0.6484375 -vt 0.40625 0.6484375 -vt 0.40625 0.5078125 -vt 0.296875 0.5078125 -vt 0.203125 0.6484375 -vt 0.296875 0.6484375 -vt 0.296875 0.5078125 -vt 0.203125 0.5078125 -vt 0.203125 0.6484375 -vt 0.09375 0.6484375 -vt 0.09375 0.7421875 -vt 0.203125 0.7421875 -vt 0.3125 0.7421875 -vt 0.203125 0.7421875 -vt 0.203125 0.6484375 -vt 0.3125 0.6484375 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 124/364/91 127/363/91 125/362/91 122/361/91 -f 123/368/92 124/367/92 122/366/92 121/365/92 -f 128/372/93 123/371/93 121/370/93 126/369/93 -f 127/376/94 128/375/94 126/374/94 125/373/94 -f 126/380/95 121/379/95 122/378/95 125/377/95 -f 127/384/96 124/383/96 123/382/96 128/381/96 -o BackUnder -v 0.375 -0.6874999999999997 1.4375 -v 0.375 -0.06249999999999968 1.4375 -v 0.375 -0.6874999999999999 0.6250000000000001 -v 0.375 -0.06249999999999986 0.625 -v -0.375 -0.06249999999999968 1.4375 -v -0.375 -0.6874999999999997 1.4375 -v -0.375 -0.06249999999999986 0.625 -v -0.375 -0.6874999999999999 0.6250000000000001 -vt 0.484375 0.4609375 -vt 0.578125 0.4609375 -vt 0.578125 0.359375 -vt 0.484375 0.359375 -vt 0.40625 0.4609375 -vt 0.484375 0.4609375 -vt 0.484375 0.359375 -vt 0.40625 0.359375 -vt 0.65625 0.4609375 -vt 0.75 0.4609375 -vt 0.75 0.359375 -vt 0.65625 0.359375 -vt 0.578125 0.4609375 -vt 0.65625 0.4609375 -vt 0.65625 0.359375 -vt 0.578125 0.359375 -vt 0.578125 0.4609375 -vt 0.484375 0.4609375 -vt 0.484375 0.5390625 -vt 0.578125 0.5390625 -vt 0.671875 0.5390625 -vt 0.578125 0.5390625 -vt 0.578125 0.4609375 -vt 0.671875 0.4609375 -vn 0 1 -2.220446049250313e-16 -vn 1 0 0 -vn 0 -1 2.220446049250313e-16 -vn -1 0 0 -vn 0 2.220446049250313e-16 1 -vn 0 -2.220446049250313e-16 -1 -f 132/388/97 135/387/97 133/386/97 130/385/97 -f 131/392/98 132/391/98 130/390/98 129/389/98 -f 136/396/99 131/395/99 129/394/99 134/393/99 -f 135/400/100 136/399/100 134/398/100 133/397/100 -f 134/404/101 129/403/101 130/402/101 133/401/101 -f 135/408/102 132/407/102 131/406/102 136/405/102 \ No newline at end of file diff --git a/assets/cubyz/models/entity/snail.obj b/assets/cubyz/models/entity/snail.obj deleted file mode 100644 index 5e6dafe778..0000000000 --- a/assets/cubyz/models/entity/snail.obj +++ /dev/null @@ -1,183 +0,0 @@ -v 0.15625 -0.40625 0.59375 -v 0.15625 0.09375 0.59375 -v 0.15625 -0.40625 0.09375 -v 0.15625 0.09375 0.09375 -v -0.15625 0.09375 0.59375 -v -0.15625 -0.40625 0.59375 -v -0.15625 0.09375 0.09375 -v -0.15625 -0.40625 0.09375 -vt 0.125 0.875 -vt 0.203125 0.875 -vt 0.203125 0.75 -vt 0.125 0.75 -vt 0 0.875 -vt 0.125 0.875 -vt 0.125 0.75 -vt 0 0.75 -vt 0.328125 0.875 -vt 0.40625 0.875 -vt 0.40625 0.75 -vt 0.328125 0.75 -vt 0.203125 0.875 -vt 0.328125 0.875 -vt 0.328125 0.75 -vt 0.203125 0.75 -vt 0.203125 0.875 -vt 0.125 0.875 -vt 0.125 1 -vt 0.203125 1 -vt 0.28125 1 -vt 0.203125 1 -vt 0.203125 0.875 -vt 0.28125 0.875 -vn 0 1 0 -vn 1 0 0 -vn 0 -1 0 -vn -1 0 0 -vn 0 0 1 -vn 0 0 -1 - -f 4/4/1 7/3/1 5/2/1 2/1/1 -f 3/8/2 4/7/2 2/6/2 1/5/2 -f 8/12/3 3/11/3 1/10/3 6/9/3 -f 7/16/4 8/15/4 6/14/4 5/13/4 -f 6/20/5 1/19/5 2/18/5 5/17/5 -f 7/24/6 4/23/6 3/22/6 8/21/6 - -v 0.125 -0.4375 0.1875 -v 0.125 0 0.1875 -v 0.125 -0.4375 0 -v 0.125 0 0 -v -0.125 0 0.1875 -v -0.125 -0.4375 0.1875 -v -0.125 0 0 -v -0.125 -0.4375 0 -vt 0.109375 0.640625 -vt 0.171875 0.640625 -vt 0.171875 0.59375 -vt 0.109375 0.59375 -vt 0 0.640625 -vt 0.109375 0.640625 -vt 0.109375 0.59375 -vt 0 0.59375 -vt 0.28125 0.640625 -vt 0.34375 0.640625 -vt 0.34375 0.59375 -vt 0.28125 0.59375 -vt 0.171875 0.640625 -vt 0.28125 0.640625 -vt 0.28125 0.59375 -vt 0.171875 0.59375 -vt 0.171875 0.640625 -vt 0.109375 0.640625 -vt 0.109375 0.75 -vt 0.171875 0.75 -vt 0.234375 0.75 -vt 0.171875 0.75 -vt 0.171875 0.640625 -vt 0.234375 0.640625 -vn 0 1 0 -vn 1 0 0 -vn 0 -1 0 -vn -1 0 0 -vn 0 0 1 -vn 0 0 -1 - -f 12/28/7 15/27/7 13/26/7 10/25/7 -f 11/32/8 12/31/8 10/30/8 9/29/8 -f 16/36/9 11/35/9 9/34/9 14/33/9 -f 15/40/10 16/39/10 14/38/10 13/37/10 -f 14/44/11 9/43/11 10/42/11 13/41/11 -f 15/48/12 12/47/12 11/46/12 16/45/12 - -v 0.125 0 0.1875 -v 0.125 0.4375 0.1875 -v 0.125 0 0 -v 0.125 0.4375 0 -v -0.125 0.4375 0.1875 -v -0.125 0 0.1875 -v -0.125 0.4375 0 -v -0.125 0 0 -vt 0.453125 0.640625 -vt 0.515625 0.640625 -vt 0.515625 0.59375 -vt 0.453125 0.59375 -vt 0.34375 0.640625 -vt 0.453125 0.640625 -vt 0.453125 0.59375 -vt 0.34375 0.59375 -vt 0.625 0.640625 -vt 0.6875 0.640625 -vt 0.6875 0.59375 -vt 0.625 0.59375 -vt 0.515625 0.640625 -vt 0.625 0.640625 -vt 0.625 0.59375 -vt 0.515625 0.59375 -vt 0.515625 0.640625 -vt 0.453125 0.640625 -vt 0.453125 0.75 -vt 0.515625 0.75 -vt 0.578125 0.75 -vt 0.515625 0.75 -vt 0.515625 0.640625 -vt 0.578125 0.640625 -vn 0 1 0 -vn 1 0 0 -vn 0 -1 0 -vn -1 0 0 -vn 0 0 1 -vn 0 0 -1 - -f 20/52/13 23/51/13 21/50/13 18/49/13 -f 19/56/14 20/55/14 18/54/14 17/53/14 -f 24/60/15 19/59/15 17/58/15 22/57/15 -f 23/64/16 24/63/16 22/62/16 21/61/16 -f 22/68/17 17/67/17 18/66/17 21/65/17 -f 23/72/18 20/71/18 19/70/18 24/69/18 - -v 0.125 0.5345571419134454 0.5497221848584004 -v 0.125 0.5345571419134454 0.5497221848584004 -v 0.125 0.4375 0.1875 -v 0.125 0.4375 0.1875 -v -0.125 0.5345571419134454 0.5497221848584004 -v -0.125 0.5345571419134454 0.5497221848584004 -v -0.125 0.4375 0.1875 -v -0.125 0.4375 0.1875 -vt 0 0.59375 -vt 0.0625 0.59375 -vt 0.0625 0.5 -vt 0 0.5 -vt 0 0.59375 -vt 0 0.59375 -vt 0 0.5 -vt 0 0.5 -vt 0.0625 0.59375 -vt 0.125 0.59375 -vt 0.125 0.5 -vt 0.0625 0.5 -vt 0.0625 0.59375 -vt 0.0625 0.59375 -vt 0.0625 0.5 -vt 0.0625 0.5 -vt 0.0625 0.59375 -vt 0 0.59375 -vt 0 0.59375 -vt 0.0625 0.59375 -vt 0.125 0.59375 -vt 0.0625 0.59375 -vt 0.0625 0.59375 -vt 0.125 0.59375 -vn 0 0.9659258262890682 -0.25881904510252096 -vn 1 0 0 -vn 0 -0.9659258262890682 0.25881904510252096 -vn -1 0 0 -vn 0 0.25881904510252096 0.9659258262890682 -vn 0 -0.25881904510252096 -0.9659258262890682 - -f 28/76/19 31/75/19 29/74/19 26/73/19 -f 27/80/20 28/79/20 26/78/20 25/77/20 -f 32/84/21 27/83/21 25/82/21 30/81/21 -f 31/88/22 32/87/22 30/86/22 29/85/22 -f 30/92/23 25/91/23 26/90/23 29/89/23 -f 31/96/24 28/95/24 27/94/24 32/93/24 \ No newline at end of file diff --git a/assets/cubyz/models/entity/snale.obj b/assets/cubyz/models/entity/snale.obj deleted file mode 100644 index 2145cf26b4..0000000000 --- a/assets/cubyz/models/entity/snale.obj +++ /dev/null @@ -1,383 +0,0 @@ -o Eyestalks -v 0.250000 0.062500 2.062500 -v 0.250000 0.062500 2.062500 -v 0.250000 0.062500 1.625000 -v 0.250000 0.062500 1.625000 -v -0.250000 0.062500 2.062500 -v -0.250000 0.062500 2.062500 -v -0.250000 0.062500 1.625000 -v -0.250000 0.062500 1.625000 -vn -0.0000 1.0000 -0.0000 -vn 1.0000 -0.0000 -0.0000 -vn -0.0000 -1.0000 -0.0000 -vn -1.0000 -0.0000 -0.0000 -vn -0.0000 -0.0000 1.0000 -vn -0.0000 -0.0000 -1.0000 -vt 0.468750 0.890625 -vt 0.593750 0.890625 -vt 0.593750 1.000000 -vt 0.468750 1.000000 -vt 0.718750 0.890625 -vt 0.718750 1.000000 -s 1 -f 4/1/1 7/2/1 5/3/1 2/4/1 -s 0 -f 3/1/1 4/1/2 2/4/1 1/4/2 -s 1 -f 8/2/3 3/5/3 1/6/3 6/3/3 -s 0 -f 7/2/1 8/2/4 6/3/1 5/3/4 -f 6/3/5 1/4/1 2/4/5 5/3/1 -f 7/6/6 4/3/1 3/3/6 8/6/1 -o Head -v 0.250000 -0.187500 1.625000 -v 0.250000 0.250000 1.625000 -v 0.250000 -0.187500 1.375000 -v 0.250000 0.250000 1.375000 -v -0.250000 0.250000 1.625000 -v -0.250000 -0.187500 1.625000 -v -0.250000 0.250000 1.375000 -v -0.250000 -0.187500 1.375000 -vn -0.0000 1.0000 -0.0000 -vn 1.0000 -0.0000 -0.0000 -vn -0.0000 -1.0000 -0.0000 -vn -1.0000 -0.0000 -0.0000 -vn -0.0000 -0.0000 1.0000 -vn -0.0000 -0.0000 -1.0000 -vt 0.109375 0.828125 -vt 0.234375 0.828125 -vt 0.234375 0.890625 -vt 0.109375 0.890625 -vt 0.000000 0.828125 -vt 0.000000 0.890625 -vt 0.343750 0.828125 -vt 0.468750 0.828125 -vt 0.468750 0.890625 -vt 0.343750 0.890625 -vt 0.234375 1.000000 -vt 0.109375 1.000000 -vt 0.359375 0.890625 -vt 0.359375 1.000000 -s 1 -f 12/7/7 15/8/7 13/9/7 10/10/7 -f 11/11/8 12/7/8 10/10/8 9/12/8 -f 16/13/9 11/14/9 9/15/9 14/16/9 -f 15/8/10 16/13/10 14/16/10 13/9/10 -f 14/17/11 9/18/11 10/10/11 13/9/11 -f 15/19/12 12/9/12 11/17/12 16/20/12 -o LeftArm -v -0.250000 -0.062500 1.343750 -v -0.250000 0.062500 1.343750 -v -0.250000 -0.062500 0.593750 -v -0.250000 0.062500 0.593750 -v -0.375000 0.062500 1.343750 -v -0.375000 -0.062500 1.343750 -v -0.375000 0.062500 0.593750 -v -0.375000 -0.062500 0.593750 -vn -0.0000 1.0000 -0.0000 -vn 1.0000 -0.0000 -0.0000 -vn -0.0000 -1.0000 -0.0000 -vn -1.0000 -0.0000 -0.0000 -vn -0.0000 -0.0000 1.0000 -vn -0.0000 -0.0000 -1.0000 -vt 0.406250 0.578125 -vt 0.437500 0.578125 -vt 0.437500 0.765625 -vt 0.406250 0.765625 -vt 0.375000 0.578125 -vt 0.375000 0.765625 -vt 0.468750 0.578125 -vt 0.500000 0.578125 -vt 0.500000 0.765625 -vt 0.468750 0.765625 -vt 0.437500 0.796875 -vt 0.406250 0.796875 -vt 0.468750 0.796875 -s 1 -f 20/21/13 23/22/13 21/23/13 18/24/13 -f 19/25/14 20/21/14 18/24/14 17/26/14 -f 24/27/15 19/28/15 17/29/15 22/30/15 -f 23/22/16 24/27/16 22/30/16 21/23/16 -f 22/31/17 17/32/17 18/24/17 21/23/17 -f 23/30/18 20/23/18 19/31/18 24/33/18 -o LeftLeg -v -0.031250 -0.093750 0.687500 -v -0.031250 0.093750 0.687500 -v -0.031250 -0.093750 0.000000 -v -0.031250 0.093750 -0.000000 -v -0.218750 0.093750 0.687500 -v -0.218750 -0.093750 0.687500 -v -0.218750 0.093750 -0.000000 -v -0.218750 -0.093750 0.000000 -vn -0.0000 1.0000 -0.0000 -vn 1.0000 -0.0000 -0.0000 -vn -0.0000 -1.0000 -0.0000 -vn -1.0000 -0.0000 -0.0000 -vn -0.0000 -0.0000 1.0000 -vn -0.0000 -0.0000 -1.0000 -vt 0.234375 0.343750 -vt 0.281250 0.343750 -vt 0.281250 0.515625 -vt 0.234375 0.515625 -vt 0.187500 0.343750 -vt 0.187500 0.515625 -vt 0.328125 0.343750 -vt 0.375000 0.343750 -vt 0.375000 0.515625 -vt 0.328125 0.515625 -vt 0.281250 0.562500 -vt 0.234375 0.562500 -vt 0.328125 0.562500 -s 1 -f 28/34/19 31/35/19 29/36/19 26/37/19 -f 27/38/20 28/34/20 26/37/20 25/39/20 -f 32/40/21 27/41/21 25/42/21 30/43/21 -f 31/35/22 32/40/22 30/43/22 29/36/22 -f 30/44/23 25/45/23 26/37/23 29/36/23 -f 31/43/24 28/36/24 27/44/24 32/46/24 -o LeftPant -v 0.000000 -0.125000 0.688125 -v 0.000000 0.125000 0.688125 -v 0.000000 -0.125000 0.188125 -v 0.000000 0.125000 0.188125 -v -0.250000 0.125000 0.688125 -v -0.250000 -0.125000 0.688125 -v -0.250000 0.125000 0.188125 -v -0.250000 -0.125000 0.188125 -vn -0.0000 1.0000 -0.0000 -vn 1.0000 -0.0000 -0.0000 -vn -0.0000 -1.0000 -0.0000 -vn -1.0000 -0.0000 -0.0000 -vn -0.0000 -0.0000 1.0000 -vn -0.0000 -0.0000 -1.0000 -vt 0.687500 0.390625 -vt 0.750000 0.390625 -vt 0.750000 0.515625 -vt 0.687500 0.515625 -vt 0.625000 0.390625 -vt 0.625000 0.515625 -vt 0.812500 0.390625 -vt 0.875000 0.390625 -vt 0.875000 0.515625 -vt 0.812500 0.515625 -vt 0.750000 0.578125 -vt 0.687500 0.578125 -vt 0.812500 0.578125 -s 1 -f 36/47/25 39/48/25 37/49/25 34/50/25 -f 35/51/26 36/47/26 34/50/26 33/52/26 -f 40/53/27 35/54/27 33/55/27 38/56/27 -f 39/48/28 40/53/28 38/56/28 37/49/28 -f 38/57/29 33/58/29 34/50/29 37/49/29 -f 39/56/30 36/49/30 35/57/30 40/59/30 -o LeftSleeve -v -0.218750 -0.093750 1.344375 -v -0.218750 0.093750 1.344375 -v -0.218750 -0.093750 0.781875 -v -0.218750 0.093750 0.781875 -v -0.406250 0.093750 1.344375 -v -0.406250 -0.093750 1.344375 -v -0.406250 0.093750 0.781875 -v -0.406250 -0.093750 0.781875 -vn -0.0000 1.0000 -0.0000 -vn 1.0000 -0.0000 -0.0000 -vn -0.0000 -1.0000 -0.0000 -vn -1.0000 -0.0000 -0.0000 -vn -0.0000 -0.0000 1.0000 -vn -0.0000 -0.0000 -1.0000 -vt 0.859375 0.625000 -vt 0.906250 0.625000 -vt 0.906250 0.765625 -vt 0.859375 0.765625 -vt 0.812500 0.625000 -vt 0.812500 0.765625 -vt 0.953125 0.625000 -vt 1.000000 0.625000 -vt 1.000000 0.765625 -vt 0.953125 0.765625 -vt 0.906250 0.812500 -vt 0.859375 0.812500 -vt 0.953125 0.812500 -s 1 -f 44/60/31 47/61/31 45/62/31 42/63/31 -f 43/64/32 44/60/32 42/63/32 41/65/32 -f 48/66/33 43/67/33 41/68/33 46/69/33 -f 47/61/34 48/66/34 46/69/34 45/62/34 -f 46/70/35 41/71/35 42/63/35 45/62/35 -f 47/69/36 44/62/36 43/70/36 48/72/36 -o RightArm -v 0.375000 -0.062500 1.343750 -v 0.375000 0.062500 1.343750 -v 0.375000 -0.062500 0.593750 -v 0.375000 0.062500 0.593750 -v 0.250000 0.062500 1.343750 -v 0.250000 -0.062500 1.343750 -v 0.250000 0.062500 0.593750 -v 0.250000 -0.062500 0.593750 -vn -0.0000 1.0000 -0.0000 -vn 1.0000 -0.0000 -0.0000 -vn -0.0000 -1.0000 -0.0000 -vn -1.0000 -0.0000 -0.0000 -vn -0.0000 -0.0000 1.0000 -vn -0.0000 -0.0000 -1.0000 -vt 0.531250 0.578125 -vt 0.562500 0.578125 -vt 0.562500 0.765625 -vt 0.531250 0.765625 -vt 0.500000 0.578125 -vt 0.500000 0.765625 -vt 0.593750 0.578125 -vt 0.625000 0.578125 -vt 0.625000 0.765625 -vt 0.593750 0.765625 -vt 0.562500 0.796875 -vt 0.531250 0.796875 -vt 0.593750 0.796875 -s 1 -f 52/73/37 55/74/37 53/75/37 50/76/37 -f 51/77/38 52/73/38 50/76/38 49/78/38 -f 56/79/39 51/80/39 49/81/39 54/82/39 -f 55/74/40 56/79/40 54/82/40 53/75/40 -f 54/83/41 49/84/41 50/76/41 53/75/41 -f 55/82/42 52/75/42 51/83/42 56/85/42 -o RightLeg -v 0.218750 -0.093750 0.687500 -v 0.218750 0.093750 0.687500 -v 0.218750 -0.093750 0.000000 -v 0.218750 0.093750 -0.000000 -v 0.031250 0.093750 0.687500 -v 0.031250 -0.093750 0.687500 -v 0.031250 0.093750 -0.000000 -v 0.031250 -0.093750 0.000000 -vn -0.0000 1.0000 -0.0000 -vn 1.0000 -0.0000 -0.0000 -vn -0.0000 -1.0000 -0.0000 -vn -1.0000 -0.0000 -0.0000 -vn -0.0000 -0.0000 1.0000 -vn -0.0000 -0.0000 -1.0000 -vt 0.046875 0.343750 -vt 0.093750 0.343750 -vt 0.093750 0.515625 -vt 0.046875 0.515625 -vt 0.000000 0.343750 -vt 0.000000 0.515625 -vt 0.140625 0.343750 -vt 0.187500 0.343750 -vt 0.187500 0.515625 -vt 0.140625 0.515625 -vt 0.093750 0.562500 -vt 0.046875 0.562500 -vt 0.140625 0.562500 -s 1 -f 60/86/43 63/87/43 61/88/43 58/89/43 -f 59/90/44 60/86/44 58/89/44 57/91/44 -f 64/92/45 59/93/45 57/94/45 62/95/45 -f 63/87/46 64/92/46 62/95/46 61/88/46 -f 62/96/47 57/97/47 58/89/47 61/88/47 -f 63/95/48 60/88/48 59/96/48 64/98/48 -o RightPant -v 0.250000 -0.125000 0.688125 -v 0.250000 0.125000 0.688125 -v 0.250000 -0.125000 0.188125 -v 0.250000 0.125000 0.188125 -v 0.000000 0.125000 0.688125 -v 0.000000 -0.125000 0.688125 -v 0.000000 0.125000 0.188125 -v 0.000000 -0.125000 0.188125 -vn -0.0000 1.0000 -0.0000 -vn 1.0000 -0.0000 -0.0000 -vn -0.0000 -1.0000 -0.0000 -vn -1.0000 -0.0000 -0.0000 -vn -0.0000 -0.0000 1.0000 -vn -0.0000 -0.0000 -1.0000 -vt 0.437500 0.390625 -vt 0.500000 0.390625 -vt 0.500000 0.515625 -vt 0.437500 0.515625 -vt 0.375000 0.390625 -vt 0.375000 0.515625 -vt 0.562500 0.390625 -vt 0.625000 0.390625 -vt 0.625000 0.515625 -vt 0.562500 0.515625 -vt 0.500000 0.578125 -vt 0.437500 0.578125 -vt 0.562500 0.578125 -s 1 -f 68/99/49 71/100/49 69/101/49 66/102/49 -f 67/103/50 68/99/50 66/102/50 65/104/50 -f 72/105/51 67/106/51 65/107/51 70/108/51 -f 71/100/52 72/105/52 70/108/52 69/101/52 -f 70/109/53 65/110/53 66/102/53 69/101/53 -f 71/108/54 68/101/54 67/109/54 72/111/54 -o RightSleeve -v 0.406250 -0.093750 1.344375 -v 0.406250 0.093750 1.344375 -v 0.406250 -0.093750 0.781875 -v 0.406250 0.093750 0.781875 -v 0.218750 0.093750 1.344375 -v 0.218750 -0.093750 1.344375 -v 0.218750 0.093750 0.781875 -v 0.218750 -0.093750 0.781875 -vn -0.0000 1.0000 -0.0000 -vn 1.0000 -0.0000 -0.0000 -vn -0.0000 -1.0000 -0.0000 -vn -1.0000 -0.0000 -0.0000 -vn -0.0000 -0.0000 1.0000 -vn -0.0000 -0.0000 -1.0000 -vt 0.671875 0.625000 -vt 0.718750 0.625000 -vt 0.718750 0.765625 -vt 0.671875 0.765625 -vt 0.625000 0.625000 -vt 0.625000 0.765625 -vt 0.765625 0.625000 -vt 0.812500 0.625000 -vt 0.812500 0.765625 -vt 0.765625 0.765625 -vt 0.718750 0.812500 -vt 0.671875 0.812500 -vt 0.765625 0.812500 -s 1 -f 76/112/55 79/113/55 77/114/55 74/115/55 -f 75/116/56 76/112/56 74/115/56 73/117/56 -f 80/118/57 75/119/57 73/120/57 78/121/57 -f 79/113/58 80/118/58 78/121/58 77/114/58 -f 78/122/59 73/123/59 74/115/59 77/114/59 -f 79/121/60 76/114/60 75/122/60 80/124/60 -o Torso -v 0.250000 -0.125000 1.375000 -v 0.250000 0.125000 1.375000 -v 0.250000 -0.125000 0.687500 -v 0.250000 0.125000 0.687500 -v -0.250000 0.125000 1.375000 -v -0.250000 -0.125000 1.375000 -v -0.250000 0.125000 0.687500 -v -0.250000 -0.125000 0.687500 -vn -0.0000 1.0000 -0.0000 -vn 1.0000 -0.0000 -0.0000 -vn -0.0000 -1.0000 -0.0000 -vn -1.0000 -0.0000 -0.0000 -vn -0.0000 -0.0000 1.0000 -vn -0.0000 -0.0000 -1.0000 -vt 0.062500 0.593750 -vt 0.187500 0.593750 -vt 0.187500 0.765625 -vt 0.062500 0.765625 -vt 0.000000 0.593750 -vt 0.000000 0.765625 -vt 0.250000 0.593750 -vt 0.375000 0.593750 -vt 0.375000 0.765625 -vt 0.250000 0.765625 -vt 0.187500 0.828125 -vt 0.062500 0.828125 -vt 0.312500 0.765625 -vt 0.312500 0.828125 -s 1 -f 84/125/61 87/126/61 85/127/61 82/128/61 -f 83/129/62 84/125/62 82/128/62 81/130/62 -f 88/131/63 83/132/63 81/133/63 86/134/63 -f 87/126/64 88/131/64 86/134/64 85/127/64 -f 86/135/65 81/136/65 82/128/65 85/127/65 -f 87/137/66 84/127/66 83/135/66 88/138/66 From fa854b42803779cfe2031d37aea6ef3ec0465912 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 4 Apr 2026 21:00:01 +0200 Subject: [PATCH 18/83] more simplification --- assets/cubyz/entity/models/snale.obj | 383 +++++++++++++++++++++++++ assets/cubyz/entity/textures/snale.png | Bin 0 -> 1873 bytes src/entityComponent/_list.zig | 1 - src/entityComponent/template.zig | 70 ----- src/entitySystem/_list.zig | 1 - src/entitySystem/template.zig | 55 ---- 6 files changed, 383 insertions(+), 127 deletions(-) create mode 100644 assets/cubyz/entity/models/snale.obj create mode 100644 assets/cubyz/entity/textures/snale.png delete mode 100644 src/entityComponent/_list.zig delete mode 100644 src/entityComponent/template.zig delete mode 100644 src/entitySystem/_list.zig delete mode 100644 src/entitySystem/template.zig diff --git a/assets/cubyz/entity/models/snale.obj b/assets/cubyz/entity/models/snale.obj new file mode 100644 index 0000000000..2145cf26b4 --- /dev/null +++ b/assets/cubyz/entity/models/snale.obj @@ -0,0 +1,383 @@ +o Eyestalks +v 0.250000 0.062500 2.062500 +v 0.250000 0.062500 2.062500 +v 0.250000 0.062500 1.625000 +v 0.250000 0.062500 1.625000 +v -0.250000 0.062500 2.062500 +v -0.250000 0.062500 2.062500 +v -0.250000 0.062500 1.625000 +v -0.250000 0.062500 1.625000 +vn -0.0000 1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.468750 0.890625 +vt 0.593750 0.890625 +vt 0.593750 1.000000 +vt 0.468750 1.000000 +vt 0.718750 0.890625 +vt 0.718750 1.000000 +s 1 +f 4/1/1 7/2/1 5/3/1 2/4/1 +s 0 +f 3/1/1 4/1/2 2/4/1 1/4/2 +s 1 +f 8/2/3 3/5/3 1/6/3 6/3/3 +s 0 +f 7/2/1 8/2/4 6/3/1 5/3/4 +f 6/3/5 1/4/1 2/4/5 5/3/1 +f 7/6/6 4/3/1 3/3/6 8/6/1 +o Head +v 0.250000 -0.187500 1.625000 +v 0.250000 0.250000 1.625000 +v 0.250000 -0.187500 1.375000 +v 0.250000 0.250000 1.375000 +v -0.250000 0.250000 1.625000 +v -0.250000 -0.187500 1.625000 +v -0.250000 0.250000 1.375000 +v -0.250000 -0.187500 1.375000 +vn -0.0000 1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.109375 0.828125 +vt 0.234375 0.828125 +vt 0.234375 0.890625 +vt 0.109375 0.890625 +vt 0.000000 0.828125 +vt 0.000000 0.890625 +vt 0.343750 0.828125 +vt 0.468750 0.828125 +vt 0.468750 0.890625 +vt 0.343750 0.890625 +vt 0.234375 1.000000 +vt 0.109375 1.000000 +vt 0.359375 0.890625 +vt 0.359375 1.000000 +s 1 +f 12/7/7 15/8/7 13/9/7 10/10/7 +f 11/11/8 12/7/8 10/10/8 9/12/8 +f 16/13/9 11/14/9 9/15/9 14/16/9 +f 15/8/10 16/13/10 14/16/10 13/9/10 +f 14/17/11 9/18/11 10/10/11 13/9/11 +f 15/19/12 12/9/12 11/17/12 16/20/12 +o LeftArm +v -0.250000 -0.062500 1.343750 +v -0.250000 0.062500 1.343750 +v -0.250000 -0.062500 0.593750 +v -0.250000 0.062500 0.593750 +v -0.375000 0.062500 1.343750 +v -0.375000 -0.062500 1.343750 +v -0.375000 0.062500 0.593750 +v -0.375000 -0.062500 0.593750 +vn -0.0000 1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.406250 0.578125 +vt 0.437500 0.578125 +vt 0.437500 0.765625 +vt 0.406250 0.765625 +vt 0.375000 0.578125 +vt 0.375000 0.765625 +vt 0.468750 0.578125 +vt 0.500000 0.578125 +vt 0.500000 0.765625 +vt 0.468750 0.765625 +vt 0.437500 0.796875 +vt 0.406250 0.796875 +vt 0.468750 0.796875 +s 1 +f 20/21/13 23/22/13 21/23/13 18/24/13 +f 19/25/14 20/21/14 18/24/14 17/26/14 +f 24/27/15 19/28/15 17/29/15 22/30/15 +f 23/22/16 24/27/16 22/30/16 21/23/16 +f 22/31/17 17/32/17 18/24/17 21/23/17 +f 23/30/18 20/23/18 19/31/18 24/33/18 +o LeftLeg +v -0.031250 -0.093750 0.687500 +v -0.031250 0.093750 0.687500 +v -0.031250 -0.093750 0.000000 +v -0.031250 0.093750 -0.000000 +v -0.218750 0.093750 0.687500 +v -0.218750 -0.093750 0.687500 +v -0.218750 0.093750 -0.000000 +v -0.218750 -0.093750 0.000000 +vn -0.0000 1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.234375 0.343750 +vt 0.281250 0.343750 +vt 0.281250 0.515625 +vt 0.234375 0.515625 +vt 0.187500 0.343750 +vt 0.187500 0.515625 +vt 0.328125 0.343750 +vt 0.375000 0.343750 +vt 0.375000 0.515625 +vt 0.328125 0.515625 +vt 0.281250 0.562500 +vt 0.234375 0.562500 +vt 0.328125 0.562500 +s 1 +f 28/34/19 31/35/19 29/36/19 26/37/19 +f 27/38/20 28/34/20 26/37/20 25/39/20 +f 32/40/21 27/41/21 25/42/21 30/43/21 +f 31/35/22 32/40/22 30/43/22 29/36/22 +f 30/44/23 25/45/23 26/37/23 29/36/23 +f 31/43/24 28/36/24 27/44/24 32/46/24 +o LeftPant +v 0.000000 -0.125000 0.688125 +v 0.000000 0.125000 0.688125 +v 0.000000 -0.125000 0.188125 +v 0.000000 0.125000 0.188125 +v -0.250000 0.125000 0.688125 +v -0.250000 -0.125000 0.688125 +v -0.250000 0.125000 0.188125 +v -0.250000 -0.125000 0.188125 +vn -0.0000 1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.687500 0.390625 +vt 0.750000 0.390625 +vt 0.750000 0.515625 +vt 0.687500 0.515625 +vt 0.625000 0.390625 +vt 0.625000 0.515625 +vt 0.812500 0.390625 +vt 0.875000 0.390625 +vt 0.875000 0.515625 +vt 0.812500 0.515625 +vt 0.750000 0.578125 +vt 0.687500 0.578125 +vt 0.812500 0.578125 +s 1 +f 36/47/25 39/48/25 37/49/25 34/50/25 +f 35/51/26 36/47/26 34/50/26 33/52/26 +f 40/53/27 35/54/27 33/55/27 38/56/27 +f 39/48/28 40/53/28 38/56/28 37/49/28 +f 38/57/29 33/58/29 34/50/29 37/49/29 +f 39/56/30 36/49/30 35/57/30 40/59/30 +o LeftSleeve +v -0.218750 -0.093750 1.344375 +v -0.218750 0.093750 1.344375 +v -0.218750 -0.093750 0.781875 +v -0.218750 0.093750 0.781875 +v -0.406250 0.093750 1.344375 +v -0.406250 -0.093750 1.344375 +v -0.406250 0.093750 0.781875 +v -0.406250 -0.093750 0.781875 +vn -0.0000 1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.859375 0.625000 +vt 0.906250 0.625000 +vt 0.906250 0.765625 +vt 0.859375 0.765625 +vt 0.812500 0.625000 +vt 0.812500 0.765625 +vt 0.953125 0.625000 +vt 1.000000 0.625000 +vt 1.000000 0.765625 +vt 0.953125 0.765625 +vt 0.906250 0.812500 +vt 0.859375 0.812500 +vt 0.953125 0.812500 +s 1 +f 44/60/31 47/61/31 45/62/31 42/63/31 +f 43/64/32 44/60/32 42/63/32 41/65/32 +f 48/66/33 43/67/33 41/68/33 46/69/33 +f 47/61/34 48/66/34 46/69/34 45/62/34 +f 46/70/35 41/71/35 42/63/35 45/62/35 +f 47/69/36 44/62/36 43/70/36 48/72/36 +o RightArm +v 0.375000 -0.062500 1.343750 +v 0.375000 0.062500 1.343750 +v 0.375000 -0.062500 0.593750 +v 0.375000 0.062500 0.593750 +v 0.250000 0.062500 1.343750 +v 0.250000 -0.062500 1.343750 +v 0.250000 0.062500 0.593750 +v 0.250000 -0.062500 0.593750 +vn -0.0000 1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.531250 0.578125 +vt 0.562500 0.578125 +vt 0.562500 0.765625 +vt 0.531250 0.765625 +vt 0.500000 0.578125 +vt 0.500000 0.765625 +vt 0.593750 0.578125 +vt 0.625000 0.578125 +vt 0.625000 0.765625 +vt 0.593750 0.765625 +vt 0.562500 0.796875 +vt 0.531250 0.796875 +vt 0.593750 0.796875 +s 1 +f 52/73/37 55/74/37 53/75/37 50/76/37 +f 51/77/38 52/73/38 50/76/38 49/78/38 +f 56/79/39 51/80/39 49/81/39 54/82/39 +f 55/74/40 56/79/40 54/82/40 53/75/40 +f 54/83/41 49/84/41 50/76/41 53/75/41 +f 55/82/42 52/75/42 51/83/42 56/85/42 +o RightLeg +v 0.218750 -0.093750 0.687500 +v 0.218750 0.093750 0.687500 +v 0.218750 -0.093750 0.000000 +v 0.218750 0.093750 -0.000000 +v 0.031250 0.093750 0.687500 +v 0.031250 -0.093750 0.687500 +v 0.031250 0.093750 -0.000000 +v 0.031250 -0.093750 0.000000 +vn -0.0000 1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.046875 0.343750 +vt 0.093750 0.343750 +vt 0.093750 0.515625 +vt 0.046875 0.515625 +vt 0.000000 0.343750 +vt 0.000000 0.515625 +vt 0.140625 0.343750 +vt 0.187500 0.343750 +vt 0.187500 0.515625 +vt 0.140625 0.515625 +vt 0.093750 0.562500 +vt 0.046875 0.562500 +vt 0.140625 0.562500 +s 1 +f 60/86/43 63/87/43 61/88/43 58/89/43 +f 59/90/44 60/86/44 58/89/44 57/91/44 +f 64/92/45 59/93/45 57/94/45 62/95/45 +f 63/87/46 64/92/46 62/95/46 61/88/46 +f 62/96/47 57/97/47 58/89/47 61/88/47 +f 63/95/48 60/88/48 59/96/48 64/98/48 +o RightPant +v 0.250000 -0.125000 0.688125 +v 0.250000 0.125000 0.688125 +v 0.250000 -0.125000 0.188125 +v 0.250000 0.125000 0.188125 +v 0.000000 0.125000 0.688125 +v 0.000000 -0.125000 0.688125 +v 0.000000 0.125000 0.188125 +v 0.000000 -0.125000 0.188125 +vn -0.0000 1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.437500 0.390625 +vt 0.500000 0.390625 +vt 0.500000 0.515625 +vt 0.437500 0.515625 +vt 0.375000 0.390625 +vt 0.375000 0.515625 +vt 0.562500 0.390625 +vt 0.625000 0.390625 +vt 0.625000 0.515625 +vt 0.562500 0.515625 +vt 0.500000 0.578125 +vt 0.437500 0.578125 +vt 0.562500 0.578125 +s 1 +f 68/99/49 71/100/49 69/101/49 66/102/49 +f 67/103/50 68/99/50 66/102/50 65/104/50 +f 72/105/51 67/106/51 65/107/51 70/108/51 +f 71/100/52 72/105/52 70/108/52 69/101/52 +f 70/109/53 65/110/53 66/102/53 69/101/53 +f 71/108/54 68/101/54 67/109/54 72/111/54 +o RightSleeve +v 0.406250 -0.093750 1.344375 +v 0.406250 0.093750 1.344375 +v 0.406250 -0.093750 0.781875 +v 0.406250 0.093750 0.781875 +v 0.218750 0.093750 1.344375 +v 0.218750 -0.093750 1.344375 +v 0.218750 0.093750 0.781875 +v 0.218750 -0.093750 0.781875 +vn -0.0000 1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.671875 0.625000 +vt 0.718750 0.625000 +vt 0.718750 0.765625 +vt 0.671875 0.765625 +vt 0.625000 0.625000 +vt 0.625000 0.765625 +vt 0.765625 0.625000 +vt 0.812500 0.625000 +vt 0.812500 0.765625 +vt 0.765625 0.765625 +vt 0.718750 0.812500 +vt 0.671875 0.812500 +vt 0.765625 0.812500 +s 1 +f 76/112/55 79/113/55 77/114/55 74/115/55 +f 75/116/56 76/112/56 74/115/56 73/117/56 +f 80/118/57 75/119/57 73/120/57 78/121/57 +f 79/113/58 80/118/58 78/121/58 77/114/58 +f 78/122/59 73/123/59 74/115/59 77/114/59 +f 79/121/60 76/114/60 75/122/60 80/124/60 +o Torso +v 0.250000 -0.125000 1.375000 +v 0.250000 0.125000 1.375000 +v 0.250000 -0.125000 0.687500 +v 0.250000 0.125000 0.687500 +v -0.250000 0.125000 1.375000 +v -0.250000 -0.125000 1.375000 +v -0.250000 0.125000 0.687500 +v -0.250000 -0.125000 0.687500 +vn -0.0000 1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.062500 0.593750 +vt 0.187500 0.593750 +vt 0.187500 0.765625 +vt 0.062500 0.765625 +vt 0.000000 0.593750 +vt 0.000000 0.765625 +vt 0.250000 0.593750 +vt 0.375000 0.593750 +vt 0.375000 0.765625 +vt 0.250000 0.765625 +vt 0.187500 0.828125 +vt 0.062500 0.828125 +vt 0.312500 0.765625 +vt 0.312500 0.828125 +s 1 +f 84/125/61 87/126/61 85/127/61 82/128/61 +f 83/129/62 84/125/62 82/128/62 81/130/62 +f 88/131/63 83/132/63 81/133/63 86/134/63 +f 87/126/64 88/131/64 86/134/64 85/127/64 +f 86/135/65 81/136/65 82/128/65 85/127/65 +f 87/137/66 84/127/66 83/135/66 88/138/66 diff --git a/assets/cubyz/entity/textures/snale.png b/assets/cubyz/entity/textures/snale.png new file mode 100644 index 0000000000000000000000000000000000000000..f4609daed35bb9c8a119e88decd63bc8d19bf40e GIT binary patch literal 1873 zcmV-X2d?;uP)hX2sSl{i(GjE-+%I5C{^p!DnQ%UAxh+VM*#?*eT-AWBkr!pSTGKmSr#kfI|;$|3MY zDXkrUC16piQH7bR)VcrMH3z!r+; zgkeE+{*8tm$0_(CK-=-DdXmfOzT1z$&wB=e=A>eY5GDzvuzG6&!la=T1KSzx`RcMeaz^mJ*CJ^agL>4ZOi_H9p`?M`6~-@5Cf8SQVh>t6W$ zNCN<(Fv5LL9c{bNXFoX9@T3O-xbxA&MtS1`6uGYJEyF>q40Ao^52QO|Q-2b;&X00799YjPOVlT$`L zJn10{qYQ0iG{9Uq3p9_8F4sp4B8>0b2`MZDzEB@2ER65lsbsi(O%7w*#2BQou-Uh9 z&xS$VvtbZ{FR*Q54E6Xr>hX2(bQ{O1iZk5!I8K#3@jU5aWHdlc4x=WAF&ECN#h9OM z8ALRlJ{Qiau_L2_lA|%17{C|d_fNkAny&fy^Sc26)5xzpJ%D7u+>Y;5Co#n2dHfl) z;B(=uGLrt%PII~^JvENzA&@8Kf*|eg9S?2A*B^e5T?ZakM)6hF7mX`P#*;Dxy(|us zM7wm!cA2j0D1&K!U)C@^Ifa`ytLz6vWAP3|Ej@! zmC22wFv7@akXva|QtudjIn*ql6Zmon^{^EHeYao55=RWcmo@mZhI%-sbTOsCvmYF4 zY#QB&VEe%g@51Lt8kEeu%lxs-^bj zkQx`(uV&imwO9muwcA&Da8CmOq(79~dFc0x{t(dY3EExLtrXV0cYolq2OAE1-|)?e zGhOL0zI%ttlWCGJ`~D$w1l~L_p(fw#+X#~eq_7GvFuRr4QFNr*jd2WbtCotwcDUOM z%wD|k>;$Fv0o}gf>{fm$JGqj(4*=HNFYGq9V0v%gj$VW}{+lupA@#XO^x+{fSueACzG)hn0Xp${zW2LY%%IUjDhH&MtMX93ehM9Js z)0W~Lw*C%J`a=loS96VtZY=%gsjKus&Dwx!3;;-@1h$tovMey#o`d--a~NFT>N{vo zeGxlFA36+Ro$$B}eb);lZhR5aB!4tA{N`B46S?_28PB1DASrD6hX`GUgXB%dbI`8L z&&*c~Y7i z&JEEG0`gX0@#4#I&Hyrk-${i3)Qx=8Ts+30AdTvn8VU! z0aNwX+gvh?I<~+UZJU*%H$1(BzBE}-mlD*b@<2#wk9a&a>hd&~K1VM@#Q;*6-@@oM z0`WMVXr5?!$y(gxRH#s)LWK$yDpaUYp+bcU6)IGyP@zJF3f<#>+bG+th_EO{00000 LNkvXXu0mjffsm?v literal 0 HcmV?d00001 diff --git a/src/entityComponent/_list.zig b/src/entityComponent/_list.zig deleted file mode 100644 index bd38343dc2..0000000000 --- a/src/entityComponent/_list.zig +++ /dev/null @@ -1 +0,0 @@ -pub const template = @import("template.zig"); diff --git a/src/entityComponent/template.zig b/src/entityComponent/template.zig deleted file mode 100644 index 37c3cb6819..0000000000 --- a/src/entityComponent/template.zig +++ /dev/null @@ -1,70 +0,0 @@ -const std = @import("std"); - -const main = @import("main"); -const chunk = main.chunk; -const game = main.game; -const graphics = main.graphics; -const c = graphics.c; -const ZonElement = main.ZonElement; -const renderer = main.renderer; -const settings = main.settings; -const utils = main.utils; -const vec = main.vec; -const Mat4f = vec.Mat4f; -const Vec3d = vec.Vec3d; -const Vec3f = vec.Vec3f; -const Vec4f = vec.Vec4f; -const Vec3i = vec.Vec3i; -const NeverFailingAllocator = main.heap.NeverFailingAllocator; - -const BinaryReader = main.utils.BinaryReader; -const BinaryWriter = main.utils.BinaryWriter; - -const blocks = main.blocks; -const chunk_zig = main.chunk; -const ServerChunk = chunk_zig.ServerChunk; -const World = game.World; -const ServerWorld = main.server.ServerWorld; -const items = main.items; -const ItemStack = items.ItemStack; -const random = main.random; - -pub const ENTITY_COMPONENT_VERSION = 0; - -// ############################# Client only stuff ################################ -pub const Client = struct { - pub fn register(id: u32, reader: *utils.BinaryReader, version: u32) void { - _ = id; - _ = reader; - _ = version; - } - pub fn unregister(id: u32) void { - _ = id; - } - pub fn init() void {} - pub fn deinit() void {} - pub fn clear() void {} -}; -// ############################# Server only stuff ################################ -pub const Server = struct { - pub const ItemComponent = struct { - pub fn save(self: ItemComponent, writer: *utils.BinaryWriter) void { - _ = self; - _ = writer; - } - }; - pub fn init() void {} - pub fn deinit() void {} - pub fn get(id: u32) ?ItemComponent { - _ = id; - return null; - } - pub fn registerFromData(id: u32, reader: *utils.BinaryReader, version: u32) void { - _ = id; - _ = reader; - _ = version; - } - pub fn unregister(id: u32) void { - _ = id; - } -}; diff --git a/src/entitySystem/_list.zig b/src/entitySystem/_list.zig deleted file mode 100644 index bd38343dc2..0000000000 --- a/src/entitySystem/_list.zig +++ /dev/null @@ -1 +0,0 @@ -pub const template = @import("template.zig"); diff --git a/src/entitySystem/template.zig b/src/entitySystem/template.zig deleted file mode 100644 index 4f8549f8de..0000000000 --- a/src/entitySystem/template.zig +++ /dev/null @@ -1,55 +0,0 @@ -const std = @import("std"); - -const main = @import("main"); -const chunk = main.chunk; -const game = main.game; -const graphics = main.graphics; -const c = graphics.c; -const ZonElement = main.ZonElement; -const renderer = main.renderer; -const settings = main.settings; -const utils = main.utils; -const vec = main.vec; -const Mat4f = vec.Mat4f; -const Vec3d = vec.Vec3d; -const Vec3f = vec.Vec3f; -const Vec4f = vec.Vec4f; -const Vec3i = vec.Vec3i; -const NeverFailingAllocator = main.heap.NeverFailingAllocator; - -const BinaryReader = main.utils.BinaryReader; -const BinaryWriter = main.utils.BinaryWriter; - -const blocks = main.blocks; -const chunk_zig = main.chunk; -const ServerChunk = chunk_zig.ServerChunk; -const World = game.World; -const ServerWorld = main.server.ServerWorld; -const items = main.items; -const ItemStack = items.ItemStack; -const random = main.random; - -const entityComponent = main.entityComponent; - -// ############################# Client only stuff ################################ -pub const Client = struct { - pub fn init() void {} - pub fn deinit() void {} - pub fn clear() void {} - - pub fn render(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { - _ = projMatrix; - _ = ambientLight; - _ = playerPos; - } - pub fn renderInfo(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { - _ = projMatrix; - _ = ambientLight; - _ = playerPos; - } -}; -// ############################# Server only stuff ################################ -pub const Server = struct { - pub fn init() void {} - pub fn deinit() void {} -}; From 34a7c3111ed5bf4d8a08bc854154fe5ef184b8be Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 4 Apr 2026 21:08:17 +0200 Subject: [PATCH 19/83] bringing more inline --- src/{clientEntity.zig => entity.zig} | 0 src/network/protocols.zig | 4 ++-- src/renderer.zig | 2 +- src/server/server.zig | 2 +- src/utils.zig | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) rename src/{clientEntity.zig => entity.zig} (100%) diff --git a/src/clientEntity.zig b/src/entity.zig similarity index 100% rename from src/clientEntity.zig rename to src/entity.zig diff --git a/src/network/protocols.zig b/src/network/protocols.zig index ab2c157a28..d2d6db516f 100644 --- a/src/network/protocols.zig +++ b/src/network/protocols.zig @@ -394,7 +394,7 @@ pub const entityPosition = struct { // MARK: entityPosition if (conn.manager.world) |world| { const time = try reader.readInt(i16); const playerPos = try reader.readVec(Vec3d); - var entityData: main.List(main.clientEntity.EntityNetworkData) = .init(main.stackAllocator); + var entityData: main.List(main.entity.EntityNetworkData) = .init(main.stackAllocator); defer entityData.deinit(); var itemData: main.List(main.itemdrop.ItemDropNetworkData) = .init(main.stackAllocator); defer itemData.deinit(); @@ -432,7 +432,7 @@ pub const entityPosition = struct { // MARK: entityPosition world.itemDrops.readPosition(time, itemData.items); } } - pub fn send(conn: *Connection, playerPos: Vec3d, entityData: []const main.clientEntity.EntityNetworkData, itemData: []const main.itemdrop.ItemDropNetworkData) void { + pub fn send(conn: *Connection, playerPos: Vec3d, entityData: []const main.entity.EntityNetworkData, itemData: []const main.itemdrop.ItemDropNetworkData) void { var writer = utils.BinaryWriter.init(main.stackAllocator); defer writer.deinit(); diff --git a/src/renderer.zig b/src/renderer.zig index 271e232394..e3fc7a489d 100644 --- a/src/renderer.zig +++ b/src/renderer.zig @@ -3,7 +3,7 @@ const Atomic = std.atomic.Value; const blocks = @import("blocks.zig"); const chunk = @import("chunk.zig"); -const clientEntity = @import("clientEntity.zig"); +const entity = @import("entity.zig"); const graphics = @import("graphics.zig"); const particles = @import("particles.zig"); const c = graphics.c; diff --git a/src/server/server.zig b/src/server/server.zig index c7f96c2069..409798bc3d 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -636,7 +636,7 @@ fn update() void { // MARK: update() const itemData = world.?.itemDropManager.getPositionAndVelocityData(main.stackAllocator); defer main.stackAllocator.free(itemData); - var entityData: main.List(main.clientEntity.EntityNetworkData) = .init(main.stackAllocator); + var entityData: main.List(main.entity.EntityNetworkData) = .init(main.stackAllocator); defer entityData.deinit(); for (userList) |user| { diff --git a/src/utils.zig b/src/utils.zig index 6d51b0c857..5c5ba19cbc 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -1773,6 +1773,7 @@ pub const BinaryReader = struct { return try self.readSlice(try self.readVarInt(usize)); } }; + pub const BinaryWriter = struct { data: main.List(u8), From 7eb07c788908003034027f4d2e96bb7d973db7b5 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 4 Apr 2026 21:10:44 +0200 Subject: [PATCH 20/83] less --- src/network/protocols.zig | 58 +-------------------------------------- 1 file changed, 1 insertion(+), 57 deletions(-) diff --git a/src/network/protocols.zig b/src/network/protocols.zig index d2d6db516f..1157f3512c 100644 --- a/src/network/protocols.zig +++ b/src/network/protocols.zig @@ -432,7 +432,7 @@ pub const entityPosition = struct { // MARK: entityPosition world.itemDrops.readPosition(time, itemData.items); } } - pub fn send(conn: *Connection, playerPos: Vec3d, entityData: []const main.entity.EntityNetworkData, itemData: []const main.itemdrop.ItemDropNetworkData) void { + pub fn send(conn: *Connection, playerPos: Vec3d, entityData: [] main.entity.EntityNetworkData, itemData: [] main.itemdrop.ItemDropNetworkData) void { var writer = utils.BinaryWriter.init(main.stackAllocator); defer writer.deinit(); @@ -960,59 +960,3 @@ pub const blockEntityUpdate = struct { // MARK: blockEntityUpdate sendServerDataUpdateToClientsInternal(pos, &ch.super, block, blockEntity); } }; - -// format: entityID set componentID binary -// format: entityID reset componentID -pub const EntityComponentUpdate = struct { // MARK: EntityComponentUpdate - pub const id: u8 = 15; - pub const asynchronous = false; - - const ActionType = enum(u8) { set, reset }; - - fn clientReceive(_: *Connection, reader: *utils.BinaryReader) !void { - const entityID = try reader.readInt(u32); - const actionType: ActionType = try reader.readEnum(ActionType); - const componentID = try reader.readSliceWithSize(); - - if (actionType == .set) { - const list = main.entityComponent; - inline for (@typeInfo(list).@"struct".decls) |decl| { - if (std.mem.eql(u8, decl.name, componentID)) { - const version = reader.readVarInt(u32) catch std.math.maxInt(u32); - @field(list, decl.name).Client.register(entityID, reader, version); - break; - } - } - } else if (actionType == .reset) { - const list = main.entityComponent; - inline for (@typeInfo(list).@"struct".decls) |decl| { - if (std.mem.eql(u8, decl.name, componentID)) { - @field(list, decl.name).Client.unregister(entityID); - break; - } - } - } - } - pub fn reset(conn: *Connection, entityID: u32, componentID: []const u8) void { - var writer = utils.BinaryWriter.init(main.stackAllocator); - defer writer.deinit(); - - writer.writeInt(u32, entityID); - writer.writeEnum(ActionType, ActionType.reset); - writer.writeSliceWithSize(componentID); - - conn.send(.secure, id, writer.data.items); - } - pub fn set(conn: *Connection, entityID: u32, componentID: []const u8, version: u32, componentData: []const u8) void { - var writer = utils.BinaryWriter.init(main.stackAllocator); - defer writer.deinit(); - - writer.writeInt(u32, entityID); - writer.writeEnum(ActionType, ActionType.set); - writer.writeSliceWithSize(componentID); - writer.writeVarInt(u32, version); - writer.writeSlice(componentData); - - conn.send(.secure, id, writer.data.items); - } -}; From 1fd28a9e4822133ede061dd52062805d0803dca0 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 4 Apr 2026 21:11:51 +0200 Subject: [PATCH 21/83] fmt --- src/network/protocols.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/protocols.zig b/src/network/protocols.zig index 1157f3512c..3300f2824e 100644 --- a/src/network/protocols.zig +++ b/src/network/protocols.zig @@ -432,7 +432,7 @@ pub const entityPosition = struct { // MARK: entityPosition world.itemDrops.readPosition(time, itemData.items); } } - pub fn send(conn: *Connection, playerPos: Vec3d, entityData: [] main.entity.EntityNetworkData, itemData: [] main.itemdrop.ItemDropNetworkData) void { + pub fn send(conn: *Connection, playerPos: Vec3d, entityData: []main.entity.EntityNetworkData, itemData: []main.itemdrop.ItemDropNetworkData) void { var writer = utils.BinaryWriter.init(main.stackAllocator); defer writer.deinit(); From 840758414909116e23c05b3e78772319e228c1e3 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 4 Apr 2026 21:12:18 +0200 Subject: [PATCH 22/83] fmt --- src/server/Entity.zig | 1 - 1 file changed, 1 deletion(-) diff --git a/src/server/Entity.zig b/src/server/Entity.zig index 0622c8b554..fc7568a71e 100644 --- a/src/server/Entity.zig +++ b/src/server/Entity.zig @@ -6,7 +6,6 @@ const vec = main.vec; const Vec3f = vec.Vec3f; const Vec3d = vec.Vec3d; const NeverFailingAllocator = main.heap.NeverFailingAllocator; -const Side = enum { ClientSide, ServerSide }; pos: Vec3d = .{0, 0, 0}, vel: Vec3d = .{0, 0, 0}, From 31fe8e9c1ace6061df5ad3874f7ff62cc0bc4d9d Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 4 Apr 2026 21:15:25 +0200 Subject: [PATCH 23/83] fmt --- src/server/server.zig | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/server/server.zig b/src/server/server.zig index 409798bc3d..91df225ed4 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -575,13 +575,6 @@ fn deinit() void { main.items.Inventory.ServerSide.deinit(); main.entity.server.deinit(); - inline for (@typeInfo(main.entityComponent).@"struct".decls) |decl| { - @field(main.entityComponent, decl.name).Server.deinit(); - } - inline for (@typeInfo(main.entitySystem).@"struct".decls) |decl| { - @field(main.entitySystem, decl.name).Server.deinit(); - } - command.deinit(); main.heap.allocators.destroyWorldArena(); } From 9e4e6a64d627fdee9a5f0391fe130c53ddc9104f Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 5 Apr 2026 11:44:20 +0200 Subject: [PATCH 24/83] tmp rename --- src/{entityModel.zig => entityModel2.zig} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{entityModel.zig => entityModel2.zig} (100%) diff --git a/src/entityModel.zig b/src/entityModel2.zig similarity index 100% rename from src/entityModel.zig rename to src/entityModel2.zig From b7d0a68f04f3cb9841614895c467690d999b07fa Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 5 Apr 2026 12:34:35 +0200 Subject: [PATCH 25/83] merged --- src/assets.zig | 5 ++ src/client/entity_manager.zig | 4 +- src/entityModel.zig | 135 ++++++++++++++++++++++++++++------ src/entityModel2.zig | 119 ------------------------------ 4 files changed, 120 insertions(+), 143 deletions(-) delete mode 100644 src/entityModel2.zig diff --git a/src/assets.zig b/src/assets.zig index e233a706ec..2350ded143 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -788,3 +788,8 @@ pub fn unloadAssets() void { // MARK: unloadAssets() pub fn worldPresets() *const Assets.ZonHashMap { return &common.worldPresets; } + +// TODO: Tempoary, will be removed in future ECS parts. +pub fn entityModelDescriptions() *const Assets.ZonHashMap { + return &common.entityModelDescriptions; +} diff --git a/src/client/entity_manager.zig b/src/client/entity_manager.zig index d1c0db806a..a5d83a4f82 100644 --- a/src/client/entity_manager.zig +++ b/src/client/entity_manager.zig @@ -43,8 +43,8 @@ pub fn init() void { .{.depthTest = true}, .{.attachments = &.{.alphaBlending}}, ); - - model = .initFromObj("assets/cubyz/entityModels/models/snale.obj", "assets/cubyz/entityModels/textures/snale.png"); + // TODO: This is Temporary, will be replace by future ECS parts. + model = .init("assets", "cubyz:snale", main.assets.entityModelDescriptions().get("cubyz:snale").?); } pub fn deinit() void { diff --git a/src/entityModel.zig b/src/entityModel.zig index 234040f96c..538ff1fd8e 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -1,13 +1,32 @@ const std = @import("std"); const main = @import("main"); +const chunk = main.chunk; +const game = main.game; const graphics = main.graphics; const c = graphics.c; +const ZonElement = main.ZonElement; +const renderer = main.renderer; +const settings = main.settings; +const utils = main.utils; +const vec = main.vec; +const Mat4f = vec.Mat4f; +const Vec3d = vec.Vec3d; +const Vec3f = vec.Vec3f; +const Vec4f = vec.Vec4f; +const NeverFailingAllocator = main.heap.NeverFailingAllocator; + +const BinaryReader = main.utils.BinaryReader; pub const EntityModel = struct { - vao: graphics.VertexArray = undefined, + vao: ?graphics.VertexArray = undefined, indexCount: c_int, - texture: main.graphics.Texture, + defaultTexture: ?main.graphics.Texture, + height: f32, + + texturePath: []const u8, + modelID: []const u8, + id: []const u8, const EntityVertex = extern struct { pos: [3]f32, @@ -33,21 +52,39 @@ pub const EntityModel = struct { }; }; - pub fn initFromObj(modelPath: []const u8, texturePath: []const u8) EntityModel { - const modelFile = main.files.cwd().read(main.stackAllocator, modelPath) catch |err| blk: { - std.log.err("Error while reading player model from path {s}: {s}", .{modelPath, @errorName(err)}); - break :blk &.{}; - }; - defer main.stackAllocator.free(modelFile); - const quadInfos = main.models.Model.loadRawModelDataFromObj(main.stackAllocator, modelFile); - defer main.stackAllocator.free(quadInfos); + pub fn init(assetFolder: []const u8, id: []const u8, zon: ZonElement) EntityModel { + var self: EntityModel = undefined; + self.id = main.globalAllocator.dupe(u8, id); + self.height = zon.getChild("height").as(f32, 1); + self.defaultTexture = null; + self.vao = null; + self.indexCount = 0; + + // get TexturePath + { + var split = std.mem.splitScalar(u8, id, ':'); + const mod = split.first(); + self.texturePath = &.{}; + if (zon.get(?[]const u8, "texture", null)) |texture| { + self.texturePath = std.fmt.allocPrint(main.globalAllocator.allocator, "{s}/{s}/entityModels/textures/{s}", .{assetFolder, mod, texture}) catch &.{}; + std.fs.cwd().access(self.texturePath, .{}) catch { + self.texturePath = std.fmt.allocPrint(main.globalAllocator.allocator, "assets/{s}/entityModels/textures/{s}", .{mod, texture}) catch &.{}; + }; + } + } + self.modelID = main.globalAllocator.dupe(u8, zon.getChild("model").as([]const u8, "cubyz:missing")); + return self; + } + fn generateGraphics(self: *EntityModel) void { + self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); + const quadInfos = main.assets.rawEntityModelData.get(self.modelID) orelse unreachable; const vertices = main.stackAllocator.alloc(EntityVertex, quadInfos.len*4); defer main.stackAllocator.free(vertices); const indices: []u32 = main.stackAllocator.alloc(u32, quadInfos.len*6); defer main.stackAllocator.free(indices); - const texture = main.graphics.Texture.initFromFile(texturePath); + const texture = main.graphics.Texture.initFromFile(self.texturePath); for (quadInfos, 0..quadInfos.len) |quad, i| { for (0..4) |j| { @@ -63,20 +100,74 @@ pub const EntityModel = struct { indices[i] = @as(u32, @intCast(i))/6*4 + lut[i%6]; } - return .{ - .vao = .init(EntityVertex, vertices, indices), - .texture = texture, - .indexCount = @intCast(indices.len), - }; + self.vao = .init(EntityVertex, vertices, indices); + self.defaultTexture = texture; + self.indexCount = @intCast(indices.len); + } + pub fn bind(self: *EntityModel) void { + if (self.vao == null) { + self.generateGraphics(); + } + self.vao.?.bind(); + self.defaultTexture.?.bindTo(0); } - pub fn bind(self: EntityModel) void { - self.vao.bind(); - self.texture.bindTo(0); + pub fn deinit(self: *EntityModel) void { + if (self.vao) |vao| { + vao.deinit(); + } + if (self.defaultTexture) |defaultTexture| { + defaultTexture.deinit(); + } + main.globalAllocator.free(self.id); + if (self.texturePath.len > 0) + main.globalAllocator.free(self.texturePath); + main.globalAllocator.free(self.modelID); } +}; - pub fn deinit(self: EntityModel) void { - self.vao.deinit(); - self.texture.deinit(); +pub const EntityModelIndex = struct { + index: u32, + pub fn get(self: EntityModelIndex) *EntityModel { + if (entityModels.items.len > self.index) + return &entityModels.items[self.index]; + // should always exist because of firstEntry in entityModelPalette + std.debug.assert(entityModels.items.len > 0); + return &entityModels.items[0]; } }; + +pub var reverseIndices: std.StringHashMapUnmanaged(EntityModelIndex) = .{}; +pub var entityModels: main.ListUnmanaged(EntityModel) = .{}; + +pub fn register(assetFolder: []const u8, id: []const u8, zon: ZonElement) usize { + const index = entityModels.items.len; + const entityModel = entityModels.addOne(main.worldArena); + entityModel.* = EntityModel.init(assetFolder, id, zon); + reverseIndices.put(main.worldArena.allocator, id, EntityModelIndex{.index = @truncate(index)}) catch unreachable; + return index; +} +pub fn reset() void { + entityModels = .{}; + reverseIndices = .{}; +} + +pub fn hasRegistered(id: []const u8) bool { + return reverseIndices.contains(id); +} + +pub fn getTypeById(id: []const u8) EntityModelIndex { + if (reverseIndices.get(id)) |result| { + return result; + } else { + std.log.err("Couldn't find entityModel {s}. Replacing it with cubyz:missing ...", .{id}); + return EntityModelIndex{.index = 0}; + } +} + +pub fn getTypeByIdOrNull(id: []const u8) ?EntityModelIndex { + if (reverseIndices.get(id)) |result| { + return result; + } + return null; +} diff --git a/src/entityModel2.zig b/src/entityModel2.zig deleted file mode 100644 index 492983e17a..0000000000 --- a/src/entityModel2.zig +++ /dev/null @@ -1,119 +0,0 @@ -const std = @import("std"); - -const main = @import("main"); -const chunk = main.chunk; -const game = main.game; -const graphics = main.graphics; -const c = graphics.c; -const ZonElement = main.ZonElement; -const renderer = main.renderer; -const settings = main.settings; -const utils = main.utils; -const vec = main.vec; -const Mat4f = vec.Mat4f; -const Vec3d = vec.Vec3d; -const Vec3f = vec.Vec3f; -const Vec4f = vec.Vec4f; -const NeverFailingAllocator = main.heap.NeverFailingAllocator; - -const BinaryReader = main.utils.BinaryReader; - -pub const EntityModel = struct { - buffer: ?main.graphics.SSBO, - size: c_int = 0, - defaultTexture: ?main.graphics.Texture, - height: f32, - - texturePath: []const u8, - modelID: []const u8, - id: []const u8, - - pub fn init(assetFolder: []const u8, id: []const u8, zon: ZonElement) EntityModel { - var self: EntityModel = undefined; - self.id = main.worldArena.dupe(u8, id); - self.height = zon.getChild("height").as(f32, 1); - self.defaultTexture = null; - self.buffer = null; - - // get TexturePath - { - var split = std.mem.splitScalar(u8, id, ':'); - const mod = split.first(); - self.texturePath = &.{}; - if (zon.get(?[]const u8, "texture", null)) |texture| { - self.texturePath = std.fmt.allocPrint(main.worldArena.allocator, "{s}/{s}/entity/textures/{s}", .{assetFolder, mod, texture}) catch &.{}; - std.fs.cwd().access(self.texturePath, .{}) catch { - self.texturePath = std.fmt.allocPrint(main.worldArena.allocator, "assets/{s}/entity/textures/{s}", .{mod, texture}) catch &.{}; - }; - } - } - self.modelID = main.worldArena.dupe(u8, zon.getChild("model").as([]const u8, "cubyz:entity/missing")); - return self; - } - fn deinit(self: *const EntityModel) void { - if (self.buffer) |buffer| { - buffer.deinit(); - } - if (self.texture) |texture| { - texture.deinit(); - } - } - fn generateGraphics(self: *EntityModel) void { - self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); - - const quadInfos = main.assets.rawModelData.get(self.modelID) orelse unreachable; - self.buffer = .initStatic(main.models.QuadInfo, quadInfos); - self.size = @intCast(quadInfos.len); - } - pub fn bind(self: *EntityModel) void { - if (self.buffer == null) { - self.generateGraphics(); - } - self.buffer.?.bind(11); - } -}; -pub const EntityModelIndex = struct { - index: u32, - pub fn get(self: EntityModelIndex) *EntityModel { - if (entityModels.items.len > self.index) - return &entityModels.items[self.index]; - // should always exist because of firstEntry in entityModelPalette - std.debug.assert(entityModels.items.len > 0); - return &entityModels.items[0]; - } -}; - -pub var reverseIndices: std.StringHashMapUnmanaged(EntityModelIndex) = .{}; -pub var entityModels: main.ListUnmanaged(EntityModel) = .{}; - -pub fn register(assetFolder: []const u8, id: []const u8, zon: ZonElement) usize { - const index = entityModels.items.len; - const entityModel = entityModels.addOne(main.worldArena); - entityModel.* = EntityModel.init(assetFolder, id, zon); - reverseIndices.put(main.worldArena.allocator, id, EntityModelIndex{.index = @truncate(index)}) catch unreachable; - return index; -} -pub fn reset() void { - entityModels = .{}; - reverseIndices = .{}; -} - -pub fn hasRegistered(id: []const u8) bool { - return reverseIndices.contains(id); -} - -pub fn getTypeById(id: []const u8) EntityModelIndex { - if (reverseIndices.get(id)) |result| { - return result; - } else { - std.log.err("Couldn't find entityModel {s}. Replacing it with cubyz:missing ...", .{id}); - return EntityModelIndex{.index = 0}; - } -} - -pub fn getTypeByIdOrNull(id: []const u8) ?EntityModelIndex { - if (reverseIndices.get(id)) |result| { - return result; - } - return null; -} From bc6e27536d604a222d6b65964d82c419d04d8f66 Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 5 Apr 2026 12:40:36 +0200 Subject: [PATCH 26/83] itemDrop not needed as component --- src/entityComponent/_list.zig | 1 - src/entityComponent/itemDrop.zig | 70 -------------------------------- 2 files changed, 71 deletions(-) delete mode 100644 src/entityComponent/itemDrop.zig diff --git a/src/entityComponent/_list.zig b/src/entityComponent/_list.zig index 3bff493815..d6c29c8bbe 100644 --- a/src/entityComponent/_list.zig +++ b/src/entityComponent/_list.zig @@ -1,3 +1,2 @@ pub const model = @import("model.zig"); -pub const itemDrop = @import("itemDrop.zig"); pub const template = @import("template.zig"); diff --git a/src/entityComponent/itemDrop.zig b/src/entityComponent/itemDrop.zig deleted file mode 100644 index 3c84fbdebc..0000000000 --- a/src/entityComponent/itemDrop.zig +++ /dev/null @@ -1,70 +0,0 @@ -const std = @import("std"); - -const main = @import("main"); -const chunk = main.chunk; -const game = main.game; -const graphics = main.graphics; -const c = graphics.c; -const ZonElement = main.ZonElement; -const renderer = main.renderer; -const settings = main.settings; -const utils = main.utils; -const vec = main.vec; -const Mat4f = vec.Mat4f; -const Vec3d = vec.Vec3d; -const Vec3f = vec.Vec3f; -const Vec4f = vec.Vec4f; -const Vec3i = vec.Vec3i; -const NeverFailingAllocator = main.heap.NeverFailingAllocator; - -const BinaryReader = main.utils.BinaryReader; -const BinaryWriter = main.utils.BinaryWriter; - -const blocks = main.blocks; -const chunk_zig = main.chunk; -const ServerChunk = chunk_zig.ServerChunk; -const World = game.World; -const ServerWorld = main.server.ServerWorld; -const items = main.items; -const ItemStack = items.ItemStack; -const random = main.random; - -pub const ENTITY_COMPONENT_VERSION = 0; - -// ############################# Client only stuff ################################ -pub const Client = struct { - pub fn register(id: u32, reader: *utils.BinaryReader, version: u32) void { - _ = id; - _ = reader; - _ = version; - } - pub fn unregister(id: u32) void { - _ = id; - } - pub fn init() void {} - pub fn deinit() void {} - pub fn clear() void {} -}; -// ############################# Server only stuff ################################ -pub const Server = struct { - pub const ItemComponent = struct { - pub fn save(self: ItemComponent, writer: *utils.BinaryWriter) void { - _ = self; - _ = writer; - } - }; - pub fn init() void {} - pub fn deinit() void {} - pub fn get(id: u32) ?ItemComponent { - _ = id; - return null; - } - pub fn registerFromData(id: u32, reader: *utils.BinaryReader, version: u32) void { - _ = version; - _ = id; - _ = reader; - } - pub fn unregister(id: u32) void { - _ = id; - } -}; From 42fd688fcdae52164c6b85d1d7d7236ad3260e24 Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 5 Apr 2026 12:41:55 +0200 Subject: [PATCH 27/83] . --- assets/cubyz/entity/cubert.zig.zon | 5 - assets/cubyz/entity/missing.zig.zon | 5 - .../entity => entity/models}/snale.obj | 0 assets/cubyz/entity/moffalo.zig.zon | 5 - assets/cubyz/entity/snail.zig.zon | 5 - assets/cubyz/entity/textures/cubert.png | Bin 2342 -> 0 bytes assets/cubyz/entity/textures/missing.png | Bin 485 -> 0 bytes assets/cubyz/entity/textures/moffalo.png | Bin 3382 -> 0 bytes assets/cubyz/entity/textures/snail.png | Bin 1256 -> 0 bytes assets/cubyz/models/entity/cubert.obj | 381 --------- assets/cubyz/models/entity/missing.obj | 38 - assets/cubyz/models/entity/moffalo.obj | 765 ------------------ assets/cubyz/models/entity/snail.obj | 183 ----- 13 files changed, 1387 deletions(-) delete mode 100644 assets/cubyz/entity/cubert.zig.zon delete mode 100644 assets/cubyz/entity/missing.zig.zon rename assets/cubyz/{models/entity => entity/models}/snale.obj (100%) delete mode 100644 assets/cubyz/entity/moffalo.zig.zon delete mode 100644 assets/cubyz/entity/snail.zig.zon delete mode 100644 assets/cubyz/entity/textures/cubert.png delete mode 100644 assets/cubyz/entity/textures/missing.png delete mode 100644 assets/cubyz/entity/textures/moffalo.png delete mode 100644 assets/cubyz/entity/textures/snail.png delete mode 100644 assets/cubyz/models/entity/cubert.obj delete mode 100644 assets/cubyz/models/entity/missing.obj delete mode 100644 assets/cubyz/models/entity/moffalo.obj delete mode 100644 assets/cubyz/models/entity/snail.obj diff --git a/assets/cubyz/entity/cubert.zig.zon b/assets/cubyz/entity/cubert.zig.zon deleted file mode 100644 index 4bb09ed512..0000000000 --- a/assets/cubyz/entity/cubert.zig.zon +++ /dev/null @@ -1,5 +0,0 @@ -.{ - .model = "cubyz:entity/cubert", - .texture = "cubert.png", - .height = 2, -} diff --git a/assets/cubyz/entity/missing.zig.zon b/assets/cubyz/entity/missing.zig.zon deleted file mode 100644 index cb0d1e8b0b..0000000000 --- a/assets/cubyz/entity/missing.zig.zon +++ /dev/null @@ -1,5 +0,0 @@ -.{ - .model = "cubyz:entity/missing", - .texture = "missing.png", - .height = 1, -} diff --git a/assets/cubyz/models/entity/snale.obj b/assets/cubyz/entity/models/snale.obj similarity index 100% rename from assets/cubyz/models/entity/snale.obj rename to assets/cubyz/entity/models/snale.obj diff --git a/assets/cubyz/entity/moffalo.zig.zon b/assets/cubyz/entity/moffalo.zig.zon deleted file mode 100644 index 01ad2ece30..0000000000 --- a/assets/cubyz/entity/moffalo.zig.zon +++ /dev/null @@ -1,5 +0,0 @@ -.{ - .model = "cubyz:entity/moffalo", - .texture = "moffalo.png", - .height = 1.8, -} diff --git a/assets/cubyz/entity/snail.zig.zon b/assets/cubyz/entity/snail.zig.zon deleted file mode 100644 index b1032e1f33..0000000000 --- a/assets/cubyz/entity/snail.zig.zon +++ /dev/null @@ -1,5 +0,0 @@ -.{ - .model = "cubyz:entity/snail", - .texture = "snail.png", - .height = 1, -} diff --git a/assets/cubyz/entity/textures/cubert.png b/assets/cubyz/entity/textures/cubert.png deleted file mode 100644 index 17d1512b5fc6e6f69d5e57a77bc7032bcd1a22ec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2342 zcmV+>3EB3EP)AbBQJ!Sg7%=28bU-+NC+XJFZmD_2tuz3Js9*B5j_Mw*vka@ zGSE#V1TllrzzjvjyfNcwgLC&XM%HP6YwvIS?REA(XOHePqs@G9*n6+N*4pd;*1!Js zueJW;nHm^4_(}~C^R%f^dgJ_g#tikF)91QP&*1IEva_3?HXC<;(_riA_^4c5 zx2K`j_qK1@Y`-@!eAB$~d}EZp^Rojr%RUIaESV_06`JscH#27X!kByk_JYX*2wp5qxA&#e6PCm@g7ZKo0{VtWOzWJPRtVe!E0)f!%-8piy`td+${jk` zVcz`k`%(8G>g($pHuXep0{mV!rrTcoe08Vb(27?3E&zq+JxMs!aeh?7v-g4JiwpKT z?ixUp3XOr_zDk3PR%5EFsM>%u?Ao!te5teB-Y;4(*EAOjW^g#@^^d>piSoVn@}@G$ zDK;0(=lj}nu?d+7fZ!utSFPX{82@sGpvK&e4S^sn8?@JfC5slC-rhb_42c*R91d)Q zFSrtv2Wk`G3u(u{-}4ubor;n<6hIE`f{uN@%Yuaq0^5FWz7mJE64mW?3BGFFF=U0?iR)f<2ffcnpDnPs1kA3ttr9|&qfTl;tU z*#Ik~Hj;w)zeYy@>kNg@6~YT5;T3 zs{v>TNT792GBPk$oVrwSg5x@=*R|oiCkgN!lssz&g-E=^xAi$sBbYds9(`qP`NqiK zX3NnNsdMdx&Fjmj21d-R#wX2&pN`dKtv(i*l9c$&)a+}d(d2y;k=lCn>_osrb>IJi zq(lP#ynD~U24n&9KF(;M!2`5MnU-b<+c&&WMt&uV<(bxd?_Ya;r{iRUTbA!yyeU<` zQ*ShAW7r@F0^9ToQSoscWu+~OG##tB!&hchY+Mr9!rt`kP|ZUT-S2my$7FoAbxYdA?hRHLK@}1! zI)VSO5Pavl?()hwgB40Osh942+(yse%ORe%7YDx z;>|+UAy6s}nXEwmT0+-DD;hB7H9F&mEF)N?V~ad(?Qy?=egFjK@fWaj-+?i4kUUj!+=BoL$Qgl9$H*ASq5 z!dzGlU`Ptk-+Lnx9$<79V2P1*!Yz+{wc>fyi_;h(JO4Xtf_lUT5gtQQR1Hm)#=1x= z?*=|abqR6s=+>-RWA8~EYydS3<W1TIB8Q%3@V9ZCsz;YVGs&0QDpebh*&o@!w%N&5-0 z_#nR?b;0Wq8$@^-+Q#@BS9m_Vy{hSqCyXLJ66ztim%uR|%jfsDhT^AbQeFsRghI8q zyFFoOnvP#QYY-FFAK@)fRhBd1Jq1bXIWCqoJl-K* zIbf0iGr=)QfSKT!B*08?OcG!wIQ|0w0RR7_6@FX*000I_L_t&o07`?KGmPCtDF6Tf M07*qoM6N<$g2tk4^#A|> diff --git a/assets/cubyz/entity/textures/missing.png b/assets/cubyz/entity/textures/missing.png deleted file mode 100644 index a1a496d1e8e618190fe6ec2d13288d0363bd147f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 485 zcmVAwv~~7OH|cY8|>1DYb%Cm*kqXLXw6{iWFDD#i8IJ zy7+7GKhRZhRS*P45OH?&*CHjpYYHvWzHoUTzW2V5yLW&;tuw>!NdSiF@N6n6t>)LH z&^rR~A&4nV%FMPFGMO~G#?K?wQar>(ukLjnqrafq4Dj_5&oYZU#Ph`IEyohPM?Azz za)J1SIL7IK#J56MJbn{g^!Q6K&t(?@zvw9y+gNF1R^kTn1aZ{RE3A1Qag(rWt}Ig? zp*0E{S)`DJ1O*jrLWhGmWs_#s*_UYemQW@SqrZhJI5~bmtaAn*cQn=OBt<}~+Bdab2JkAcVzaCy_x zlmp;u7Z`rFWG*+P04=|!0UsB@Kpq&p2m02%SvB`@{siQ<>51-u!y{mv>LVL}>H4; zN0_s@g(+gwE0&)^ECShi08^fb5 z_7=l~5j4h@4UI*;{mtiaF$AxUQ&(%%mjD$dtRJq)n$I82Wv-uG-FZNxe54#tb)2-R zEDRFA^d{~;+kUzRGJd$>zT5I(4X%N5yPM^r$^igBZCj~k^xMy`jJFtNrbQsUc#fpm zshs)XGV_gI0Nf%}5kJPCdTspk{2PeHvBOH3`g)QFuv0o=bE_dV-ztEwmZ{{`=An01 zSy>sz%pHy60tl7!&)b^&^^1h=RFF+9licWj0Kpp)=g)qdwoYnbQinwrm?OWVelDO- zCVMAFgPT9aM5BbBvzdoyI4}S8mLQgCz}w?Q9!D}mu5d4|b;ZqjcP*!Tp7`BH^qBdv zu%}7>2UJUvVnd5stBvg7-CG)ktX_Q4k)oH*W9oH*pFoQOuQEz^yGa}uL@Z9m$dB8Z zvwtnP9@8(IQqxxWV3J=Us(S(R!ei+y^rz-LIib1JC*q?bc8eAM>MEzqSroavcJl>C z;M_m~Pb?qHEKOA?x@Y*hoe%Dyp6PkACzf8=bWwK-?zE-z%)G$y4T4BDgh~8Dyh}qS zr^NrNcrCH~7`=0<@ihTilFm-`I;d$)F*oI5VReZLmF8t0lCq_O%CAVI z7%f&*K>)U2O(rfAZ*eQh!zx|( zc;$reQk@W&ws~UZN47`GVsHst^Xb4cXM07{?(KZsF6p5JC6X^G1*x)KlZfz3WcZ;}PkH9eeQj?vx>M>3=P zqjjj8us3;s8L>rKqr{Kh<{(99?L&;y@JkQ72N1Ycji0A6gn`0gRD&;G(hcJe_tQCo zS`Qmp`NU1%U{!h_nNxn9J%<1f7gQ1zWu;Ag3XIZNMN7=KQ*#!vCqsu6bm*o=T=dT^ zM)89(>#NUOkEjcEMN-;8SaravpL@S5wK9W)Ubp$RXu ziK(X!liCbJz$D%>c8}8mM){RD&8%q#4SDV2jWmGr9!qEhoP+ml>IYwAN=KX?)Y%{G zE2{8WZSK8=54zWz@QJob-P?SG7A@6F&aZB}2y@M2Eh#C>=!?A&WjB4NyMl}_td&}N z!SV1VyBoI`cZi4?Ux{_L%xdJ@wr_%Nw2MCEHropm8{ePj>5__#q6!kiKDdsBG~K=e z48s?&&(V&(;KkdTe}8=&Un)F~5499i^PlRx%f2t#6pdPW5*60o#$<-+ z+0g0zc`AHa(}OB^qXZ^v2p_!r^9el-c7*I(6T+kEEI5|RZ=xkUzgWl+N*v~krkOe! zg1=9woAPrn`pcM;!e3k2GhIDBcxCl|Pxj*hUeT|?e^hLc$7GRW1=x^HPu=;UTY`!C zp-_JI1)DUi){U0ZriWGjyud1j8-*_e)U03Lv?F?hHZ;#~7$WsAaYXV>(Uio)d$xrT z<;01xLKfVnxIF9QAb{by=%GPc&Ergj#SU`$<_<#TNnetVC7;2&kw{*^h6>9c`gT#p z6Na;+()y-G2JLV5b({t$_L?Jz@clS-Xw;-%7#@6bDcl~Wf_E0hs-_67B3+j1(3VGnJnK@}~}PL8<5$G;4!Z&n9$^UqEg(5GKNsDTyw ztQTLq=3>GQDKo|+O*F2y<$f$F^@U{W&Gp~eshuu(+Qeut>)UNSNy>ft&Qbl`)xW2W zl;rO{uL%s0s_=Ud>bE5`eo&+To_&`>jEPsAj&0p%=bk%{B(J^6*P3^Qx_t;3ew(FK zVljrWxeA=>!z|?=WE;UDak*=IGVXN~$(jLNW#p?(Ir{2lGj6=(>>f;gq` zzp*0D_#s>X2%Jinfiy^Az&Id2_H&LVdt7US-8vH&=DTyo@I$1E^cCn$(0;f`86y7? zoTACQHhs4hpv@p9p>2Cbrc*RdfBP{o7_MS8yl2<@)pym2)cH%pi|!1&(HJF_s#J-DKqmJb$bk5zAV!g zdzAIP&(J=sI$fyDGQ)g`_2w4$AxIhLhl&TcW*epCtED!gJxoNe1m9yg>x;5&7x8)h zSOytj8MgW8$c=ZaB@Y}xWt%rJ{*yJ02crHj}EUuFwE9v ze!n#V52WBt3>rX!lpHm9G^wv$J)f=79A;f@kb67mf<&uoV2|d4mj>k9V9j28=Sylf8CpTd0INwHv>br*-ZnYRrx;@2!Y*Gg) z_1>=TyZCC2ufgK!Mt7=bABiO1n#@N|$)9{z^YB z<{ZX2p{4t;%d5OYW&Nqu69n=z{~b;C=mRe5h~jCBe#-h5*OqrZrXHg)^VSL3SJ%7O zw|FIy6Q2At~k>N(A%7;?uwa zr8~?BOCrFj%Bgm*J2g=upSoY*N$WOE`&lu51kLD_a!8B?Bv4szY#DauhDThVL@Jv2 z&KVVE{{bxjJUi014$0l8NZ@s*;IM`Z^G$jfH0xDAKWbwWNow$qUdrU4dOKlBOf~%D z!a&?nan$SMEa@6CHX`DHuBaO)Uq}u1Nb(Ipu7FdPo!g(Z+wsdnSB#I+bhYT_Gp-R` zRf3&zJ|R%@v4_Xv@RVohXncD_W zE>3{wSCjGtDRO%<&`0-7hi4h|>ytvpmv-&i11O=~lwK#dxLSXw_moaMVjRu<#rZ7g zd3}zE4p^G^@MpyJ28QQgpd9r2i1x*NvX-TUP@R$VtsfGtRGz9{N9Bo$p{)H_oXMN+ z7S4LA8n(tjnBxu)=}wEjodE{5a_55=`RhOLP{}%64Z1)t)&}e-n%d@@QCq9mRjR*d zh~ble5ch^)f*)?K;vGV&me0!DxJgkPkHp3ADdi8`RdYlN!c>bPq$6;OEFN60f&PL1 z4w?KK9Rh3?dqJ#px_W62IA^sT^f)-ECbCkN^HTn|3ubVL!^F<`M#+iy(AM-%-qpsp z`dnP)Px(h)G02RCt{2nLljYR2;`Y?`+@MzQpxGdm>evD5*pSGEj+js6@6(EFdvZbz)`f zz)~?W!ps6)nGixkVqvI+L{x#)KVl#V6-uf`ZBQ>QcAUia#dr4@?D%}iwWl`ey%@nH~u%+5X{SQ6)O) zc|MW63S6kcWe;w6aITiFxaSKZBt9nVfCofKJU?B`bG4Y?kX-h<$pffh@i!4BP$L@Y z!kH&v#S_c`-vL)VIE}{fnxugwLh>&aB2s<4COM796)*Ll$@*`z>V&)ojAM;_(afvB zH6-sMn87BlZ2~b5IZ97V*f z`BTzgSmBEu@9BR=*IrHFE-(!oE406o^bU3j3wQoFKi~R?#%6cY^{V9K%@M5vpW4U| z!z$7I>sSkaVV-}3M^|sqnxA2DVTsR>+%0sN20lSBH$Q{Eu*A{xXNa%l7Kwhw@*xi2=dAu;eMTqJJ$v}Bmsd%LkAssJQ%b8iFfk!MOkONRNQx)%&l zMbpZuXhTaj_dMqF@=OWXFEp)8rQ`t6B!IS-U()Q?LCl7LFd!7#EXAaUp*^H<8$ zT!PNoSIHhU1y*Wm*v2*BsEs;9Fr2Y-l&X*LZs@oCGg)K8RmOTw4O*RQ)VL5R$ZGEb5fS5w=Qe zG&^P5?Jc4gydUUZ>kg*w;&KYpNLMIM*3tyTy$KlCPJ+e`zZPEW4x(e^CCw03+;Vrk zB93EoVq%Kr#-9M3n3&=|_Xx5-TMW&_q&xo381@}0r7YSz^^3jx!J}XL;Hz8|?SA?& zqTl-cS}uxqKYbX{A3yAV<1O0#^kGB~TaR;5wEOA9h`!N$l#8O>Pb(A(g+ifFC=?2X zLZMJ76bgkxp-?Ck3WY+UP`r%%4_4i~cXLe-e*gdg4rN$LW=%~1DgXcg2mk;800000 S(o>TF0000 Date: Sun, 5 Apr 2026 12:43:47 +0200 Subject: [PATCH 28/83] . --- assets/cubyz/entity/snale.zig.zon | 5 --- src/entityComponent/_list.zig | 3 +- src/entityComponent/template.zig | 70 ------------------------------- src/entitySystem/_list.zig | 1 - src/entitySystem/template.zig | 55 ------------------------ 5 files changed, 1 insertion(+), 133 deletions(-) delete mode 100644 assets/cubyz/entity/snale.zig.zon delete mode 100644 src/entityComponent/template.zig delete mode 100644 src/entitySystem/template.zig diff --git a/assets/cubyz/entity/snale.zig.zon b/assets/cubyz/entity/snale.zig.zon deleted file mode 100644 index 981ed0ec49..0000000000 --- a/assets/cubyz/entity/snale.zig.zon +++ /dev/null @@ -1,5 +0,0 @@ -.{ - .model = "cubyz:entity/snale", - .texture = "snale.png", - .height = 2, -} diff --git a/src/entityComponent/_list.zig b/src/entityComponent/_list.zig index d6c29c8bbe..36cf814693 100644 --- a/src/entityComponent/_list.zig +++ b/src/entityComponent/_list.zig @@ -1,2 +1 @@ -pub const model = @import("model.zig"); -pub const template = @import("template.zig"); +pub const @"cubyz:model" = @import("model.zig"); diff --git a/src/entityComponent/template.zig b/src/entityComponent/template.zig deleted file mode 100644 index 37c3cb6819..0000000000 --- a/src/entityComponent/template.zig +++ /dev/null @@ -1,70 +0,0 @@ -const std = @import("std"); - -const main = @import("main"); -const chunk = main.chunk; -const game = main.game; -const graphics = main.graphics; -const c = graphics.c; -const ZonElement = main.ZonElement; -const renderer = main.renderer; -const settings = main.settings; -const utils = main.utils; -const vec = main.vec; -const Mat4f = vec.Mat4f; -const Vec3d = vec.Vec3d; -const Vec3f = vec.Vec3f; -const Vec4f = vec.Vec4f; -const Vec3i = vec.Vec3i; -const NeverFailingAllocator = main.heap.NeverFailingAllocator; - -const BinaryReader = main.utils.BinaryReader; -const BinaryWriter = main.utils.BinaryWriter; - -const blocks = main.blocks; -const chunk_zig = main.chunk; -const ServerChunk = chunk_zig.ServerChunk; -const World = game.World; -const ServerWorld = main.server.ServerWorld; -const items = main.items; -const ItemStack = items.ItemStack; -const random = main.random; - -pub const ENTITY_COMPONENT_VERSION = 0; - -// ############################# Client only stuff ################################ -pub const Client = struct { - pub fn register(id: u32, reader: *utils.BinaryReader, version: u32) void { - _ = id; - _ = reader; - _ = version; - } - pub fn unregister(id: u32) void { - _ = id; - } - pub fn init() void {} - pub fn deinit() void {} - pub fn clear() void {} -}; -// ############################# Server only stuff ################################ -pub const Server = struct { - pub const ItemComponent = struct { - pub fn save(self: ItemComponent, writer: *utils.BinaryWriter) void { - _ = self; - _ = writer; - } - }; - pub fn init() void {} - pub fn deinit() void {} - pub fn get(id: u32) ?ItemComponent { - _ = id; - return null; - } - pub fn registerFromData(id: u32, reader: *utils.BinaryReader, version: u32) void { - _ = id; - _ = reader; - _ = version; - } - pub fn unregister(id: u32) void { - _ = id; - } -}; diff --git a/src/entitySystem/_list.zig b/src/entitySystem/_list.zig index bd38343dc2..e69de29bb2 100644 --- a/src/entitySystem/_list.zig +++ b/src/entitySystem/_list.zig @@ -1 +0,0 @@ -pub const template = @import("template.zig"); diff --git a/src/entitySystem/template.zig b/src/entitySystem/template.zig deleted file mode 100644 index 4f8549f8de..0000000000 --- a/src/entitySystem/template.zig +++ /dev/null @@ -1,55 +0,0 @@ -const std = @import("std"); - -const main = @import("main"); -const chunk = main.chunk; -const game = main.game; -const graphics = main.graphics; -const c = graphics.c; -const ZonElement = main.ZonElement; -const renderer = main.renderer; -const settings = main.settings; -const utils = main.utils; -const vec = main.vec; -const Mat4f = vec.Mat4f; -const Vec3d = vec.Vec3d; -const Vec3f = vec.Vec3f; -const Vec4f = vec.Vec4f; -const Vec3i = vec.Vec3i; -const NeverFailingAllocator = main.heap.NeverFailingAllocator; - -const BinaryReader = main.utils.BinaryReader; -const BinaryWriter = main.utils.BinaryWriter; - -const blocks = main.blocks; -const chunk_zig = main.chunk; -const ServerChunk = chunk_zig.ServerChunk; -const World = game.World; -const ServerWorld = main.server.ServerWorld; -const items = main.items; -const ItemStack = items.ItemStack; -const random = main.random; - -const entityComponent = main.entityComponent; - -// ############################# Client only stuff ################################ -pub const Client = struct { - pub fn init() void {} - pub fn deinit() void {} - pub fn clear() void {} - - pub fn render(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { - _ = projMatrix; - _ = ambientLight; - _ = playerPos; - } - pub fn renderInfo(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { - _ = projMatrix; - _ = ambientLight; - _ = playerPos; - } -}; -// ############################# Server only stuff ################################ -pub const Server = struct { - pub fn init() void {} - pub fn deinit() void {} -}; From 8a1e84991dbde99dd305eafc4e65526fc9d9a15c Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 5 Apr 2026 12:44:52 +0200 Subject: [PATCH 29/83] . --- src/entitySystem/_list.zig | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/entitySystem/_list.zig diff --git a/src/entitySystem/_list.zig b/src/entitySystem/_list.zig deleted file mode 100644 index e69de29bb2..0000000000 From 8e807258ec697ee4c094f02e759712f09406e10f Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 5 Apr 2026 12:45:49 +0200 Subject: [PATCH 30/83] . --- src/entityModel.zig | 119 -------------------------------------------- 1 file changed, 119 deletions(-) delete mode 100644 src/entityModel.zig diff --git a/src/entityModel.zig b/src/entityModel.zig deleted file mode 100644 index 492983e17a..0000000000 --- a/src/entityModel.zig +++ /dev/null @@ -1,119 +0,0 @@ -const std = @import("std"); - -const main = @import("main"); -const chunk = main.chunk; -const game = main.game; -const graphics = main.graphics; -const c = graphics.c; -const ZonElement = main.ZonElement; -const renderer = main.renderer; -const settings = main.settings; -const utils = main.utils; -const vec = main.vec; -const Mat4f = vec.Mat4f; -const Vec3d = vec.Vec3d; -const Vec3f = vec.Vec3f; -const Vec4f = vec.Vec4f; -const NeverFailingAllocator = main.heap.NeverFailingAllocator; - -const BinaryReader = main.utils.BinaryReader; - -pub const EntityModel = struct { - buffer: ?main.graphics.SSBO, - size: c_int = 0, - defaultTexture: ?main.graphics.Texture, - height: f32, - - texturePath: []const u8, - modelID: []const u8, - id: []const u8, - - pub fn init(assetFolder: []const u8, id: []const u8, zon: ZonElement) EntityModel { - var self: EntityModel = undefined; - self.id = main.worldArena.dupe(u8, id); - self.height = zon.getChild("height").as(f32, 1); - self.defaultTexture = null; - self.buffer = null; - - // get TexturePath - { - var split = std.mem.splitScalar(u8, id, ':'); - const mod = split.first(); - self.texturePath = &.{}; - if (zon.get(?[]const u8, "texture", null)) |texture| { - self.texturePath = std.fmt.allocPrint(main.worldArena.allocator, "{s}/{s}/entity/textures/{s}", .{assetFolder, mod, texture}) catch &.{}; - std.fs.cwd().access(self.texturePath, .{}) catch { - self.texturePath = std.fmt.allocPrint(main.worldArena.allocator, "assets/{s}/entity/textures/{s}", .{mod, texture}) catch &.{}; - }; - } - } - self.modelID = main.worldArena.dupe(u8, zon.getChild("model").as([]const u8, "cubyz:entity/missing")); - return self; - } - fn deinit(self: *const EntityModel) void { - if (self.buffer) |buffer| { - buffer.deinit(); - } - if (self.texture) |texture| { - texture.deinit(); - } - } - fn generateGraphics(self: *EntityModel) void { - self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); - - const quadInfos = main.assets.rawModelData.get(self.modelID) orelse unreachable; - self.buffer = .initStatic(main.models.QuadInfo, quadInfos); - self.size = @intCast(quadInfos.len); - } - pub fn bind(self: *EntityModel) void { - if (self.buffer == null) { - self.generateGraphics(); - } - self.buffer.?.bind(11); - } -}; -pub const EntityModelIndex = struct { - index: u32, - pub fn get(self: EntityModelIndex) *EntityModel { - if (entityModels.items.len > self.index) - return &entityModels.items[self.index]; - // should always exist because of firstEntry in entityModelPalette - std.debug.assert(entityModels.items.len > 0); - return &entityModels.items[0]; - } -}; - -pub var reverseIndices: std.StringHashMapUnmanaged(EntityModelIndex) = .{}; -pub var entityModels: main.ListUnmanaged(EntityModel) = .{}; - -pub fn register(assetFolder: []const u8, id: []const u8, zon: ZonElement) usize { - const index = entityModels.items.len; - const entityModel = entityModels.addOne(main.worldArena); - entityModel.* = EntityModel.init(assetFolder, id, zon); - reverseIndices.put(main.worldArena.allocator, id, EntityModelIndex{.index = @truncate(index)}) catch unreachable; - return index; -} -pub fn reset() void { - entityModels = .{}; - reverseIndices = .{}; -} - -pub fn hasRegistered(id: []const u8) bool { - return reverseIndices.contains(id); -} - -pub fn getTypeById(id: []const u8) EntityModelIndex { - if (reverseIndices.get(id)) |result| { - return result; - } else { - std.log.err("Couldn't find entityModel {s}. Replacing it with cubyz:missing ...", .{id}); - return EntityModelIndex{.index = 0}; - } -} - -pub fn getTypeByIdOrNull(id: []const u8) ?EntityModelIndex { - if (reverseIndices.get(id)) |result| { - return result; - } - return null; -} From 084543ac16d4b4f626c7284a76c25b225f3b7a04 Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 5 Apr 2026 12:56:31 +0200 Subject: [PATCH 31/83] merge... --- src/renderer.zig | 2 +- src/server/Entity.zig | 1 - src/server/server.zig | 7 ------- src/utils.zig | 1 + 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/renderer.zig b/src/renderer.zig index 271e232394..e3fc7a489d 100644 --- a/src/renderer.zig +++ b/src/renderer.zig @@ -3,7 +3,7 @@ const Atomic = std.atomic.Value; const blocks = @import("blocks.zig"); const chunk = @import("chunk.zig"); -const clientEntity = @import("clientEntity.zig"); +const entity = @import("entity.zig"); const graphics = @import("graphics.zig"); const particles = @import("particles.zig"); const c = graphics.c; diff --git a/src/server/Entity.zig b/src/server/Entity.zig index 0622c8b554..fc7568a71e 100644 --- a/src/server/Entity.zig +++ b/src/server/Entity.zig @@ -6,7 +6,6 @@ const vec = main.vec; const Vec3f = vec.Vec3f; const Vec3d = vec.Vec3d; const NeverFailingAllocator = main.heap.NeverFailingAllocator; -const Side = enum { ClientSide, ServerSide }; pos: Vec3d = .{0, 0, 0}, vel: Vec3d = .{0, 0, 0}, diff --git a/src/server/server.zig b/src/server/server.zig index 8ecd6794aa..457e57d81c 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -580,13 +580,6 @@ fn deinit() void { main.items.Inventory.ServerSide.deinit(); main.entity.server.deinit(); - inline for (@typeInfo(main.entityComponent).@"struct".decls) |decl| { - @field(main.entityComponent, decl.name).Server.deinit(); - } - inline for (@typeInfo(main.entitySystem).@"struct".decls) |decl| { - @field(main.entitySystem, decl.name).Server.deinit(); - } - command.deinit(); main.heap.allocators.destroyWorldArena(); } diff --git a/src/utils.zig b/src/utils.zig index 6d51b0c857..5c5ba19cbc 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -1773,6 +1773,7 @@ pub const BinaryReader = struct { return try self.readSlice(try self.readVarInt(usize)); } }; + pub const BinaryWriter = struct { data: main.List(u8), From 30c09964bca32f7fbb524a18374006cb5fbd48f6 Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 5 Apr 2026 12:57:09 +0200 Subject: [PATCH 32/83] . --- src/{clientEntity.zig => entity.zig} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{clientEntity.zig => entity.zig} (100%) diff --git a/src/clientEntity.zig b/src/entity.zig similarity index 100% rename from src/clientEntity.zig rename to src/entity.zig From 41181f3fca89c93b1d8a7a3d6e5d022620e84ff9 Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 5 Apr 2026 13:03:19 +0200 Subject: [PATCH 33/83] . --- src/entity.zig | 1 + src/entityComponent/model.zig | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/entity.zig b/src/entity.zig index dcfaa826eb..8a1743f620 100644 --- a/src/entity.zig +++ b/src/entity.zig @@ -21,6 +21,7 @@ pub const EntityComponentLoadError = error{ UnreadableID, UnreadableVersion, UnreadableComponentData, + Memory, }; // Analogous to Protocols. const EntityComponentVTable = struct { diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig index 22eca013be..7e6b77854f 100644 --- a/src/entityComponent/model.zig +++ b/src/entityComponent/model.zig @@ -18,9 +18,11 @@ const NeverFailingAllocator = main.heap.NeverFailingAllocator; const BinaryReader = main.utils.BinaryReader; -pub const ENTITY_COMPONENT_VERSION = 0; +pub var entityComponentID: u32 = undefined; +pub const entityComponentVersion = 0; + // ############################# Client only stuff ################################ -pub const Client = struct { +pub const client = struct { const RenderComponent = struct { entity: u32, // entity entityModel: main.entityModel.EntityModelIndex, // model @@ -38,7 +40,7 @@ pub const Client = struct { renderComponents.deinit(); renderComponents = .init(main.globalAllocator.allocator); } - pub fn register(id: u32, reader: *utils.BinaryReader, version: u32) void { + pub fn load(id: u32, reader: *utils.BinaryReader, version: u32) main.entity.EntityComponentLoadError!void { _ = version; const entityModel = reader.readInt(u32) catch return; const customTexture: ?main.graphics.Texture = null; @@ -49,14 +51,14 @@ pub const Client = struct { .entityModel = main.entityModel.EntityModelIndex{.index = entityModel}, }) catch unreachable; } - pub fn unregister(id: u32) void { + pub fn unload(id: u32) void { _ = renderComponents.remove(id); } }; // ############################# Server only stuff ################################ -pub const Server = struct { +pub const server = struct { pub const RenderComponent = struct { entity: u32, // entity entityModel: main.entityModel.EntityModelIndex, // model @@ -66,11 +68,12 @@ pub const Server = struct { main.globalAllocator.free(path); } } - pub fn save(self: RenderComponent, writer: *utils.BinaryWriter) void { + pub fn save(self: RenderComponent, writer: *utils.BinaryWriter) main.entity.ComponentSaveBehaviour { writer.writeInt(u32, self.entityModel.index); if (self.customTexturePath) |texutre| { writer.writeSliceWithSize(texutre); } else writer.writeSliceWithSize(""); + return .save; } }; var renderComponents: std.AutoHashMap(u32, RenderComponent) = undefined; @@ -84,17 +87,17 @@ pub const Server = struct { } renderComponents.deinit(); } - pub fn registerFromData(entity: u32, reader: *utils.BinaryReader, version: usize) void { + pub fn loadFromData(entity: u32, reader: *utils.BinaryReader, version: u32) main.entity.EntityComponentLoadError!void { _ = version; const entityModel = reader.readInt(u32) catch return; const customTexturePath = reader.readSliceWithSize() catch return; - registerByIndex(entity, main.entityModel.EntityModelIndex{.index = entityModel}, if (customTexturePath.len == 0) null else customTexturePath); + try loadByIndex(entity, main.entityModel.EntityModelIndex{.index = entityModel}, if (customTexturePath.len == 0) null else customTexturePath); } - pub fn registerByID(entity: u32, entityModelID: []const u8, customTexturePath: ?[]const u8) void { - registerByIndex(entity, main.entityModel.getTypeById(entityModelID), customTexturePath); + pub fn loadByID(entity: u32, entityModelID: []const u8, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { + try loadByIndex(entity, main.entityModel.getTypeById(entityModelID), customTexturePath); } - pub fn registerByIndex(entity: u32, entityModel: main.entityModel.EntityModelIndex, customTexturePath: ?[]const u8) void { + pub fn loadByIndex(entity: u32, entityModel: main.entityModel.EntityModelIndex, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { if (renderComponents.get(entity)) |old| { old.deinit(); } @@ -102,9 +105,9 @@ pub const Server = struct { .entity = entity, .customTexturePath = customTexturePath, .entityModel = entityModel, - }) catch unreachable; + }) catch return main.entity.EntityComponentLoadError.Memory; } - pub fn unregister(id: u32) void { + pub fn unload(id: u32) void { _ = renderComponents.remove(id); } pub fn put(id: u32, renderComponent: RenderComponent) void { From d007e7c990c4f46807c9525bec60cbbdae02783d Mon Sep 17 00:00:00 2001 From: till++ Date: Mon, 6 Apr 2026 01:13:23 +0200 Subject: [PATCH 34/83] Model split --- src/client/Model.zig | 90 +++++++++++++++++++++++++++++++++++ src/client/entity_manager.zig | 2 +- src/entityModel.zig | 68 ++++---------------------- src/main.zig | 1 + 4 files changed, 100 insertions(+), 61 deletions(-) create mode 100644 src/client/Model.zig diff --git a/src/client/Model.zig b/src/client/Model.zig new file mode 100644 index 0000000000..64816d36f1 --- /dev/null +++ b/src/client/Model.zig @@ -0,0 +1,90 @@ +const std = @import("std"); + +const main = @import("main"); +const chunk = main.chunk; +const game = main.game; +const graphics = main.graphics; +const c = graphics.c; +const ZonElement = main.ZonElement; +const renderer = main.renderer; +const settings = main.settings; +const utils = main.utils; +const vec = main.vec; +const Mat4f = vec.Mat4f; +const Vec3d = vec.Vec3d; +const Vec3f = vec.Vec3f; +const Vec4f = vec.Vec4f; +const NeverFailingAllocator = main.heap.NeverFailingAllocator; + +const BinaryReader = main.utils.BinaryReader; + +const Vertex = extern struct { + pos: [3]f32, + normal: [3]f32, + uv: [2]f32, + + pub const attributeDescriptions: []const c.VkVertexInputAttributeDescription = &.{ + .{ + .location = 0, + .format = c.VK_FORMAT_R32G32B32_SFLOAT, + .offset = @offsetOf(@This(), "pos"), + }, + .{ + .location = 1, + .format = c.VK_FORMAT_R32G32B32_SFLOAT, + .offset = @offsetOf(@This(), "normal"), + }, + .{ + .location = 2, + .format = c.VK_FORMAT_R32G32_SFLOAT, + .offset = @offsetOf(@This(), "uv"), + }, + }; +}; + +pub const Model = struct { + vao: graphics.VertexArray = undefined, + indexCount: c_int, + isGenerated:bool, + + pub fn init()Model{ + var self: Model = undefined; + self.vao = undefined; + self.indexCount = 0; + self.isGenerated = false; + + return self; + } + pub fn generateGraphics(self:*Model,modelID:[]const u8)void{ + const quadInfos = main.assets.rawEntityModelData.get(modelID) orelse unreachable; + const vertices = main.stackAllocator.alloc(Vertex, quadInfos.len*4); + defer main.stackAllocator.free(vertices); + const indices: []u32 = main.stackAllocator.alloc(u32, quadInfos.len*6); + defer main.stackAllocator.free(indices); + + + for (quadInfos, 0..quadInfos.len) |quad, i| { + for (0..4) |j| { + const v = i*4 + j; + vertices[v].normal = quad.normal; + vertices[v].pos = quad.corners[j]; + vertices[v].uv = quad.cornerUV[j]; + } + } + + const lut = [_]u32{0, 2, 1, 1, 2, 3}; + for (0..indices.len) |i| { + indices[i] = @as(u32, @intCast(i))/6*4 + lut[i%6]; + } + + self.vao = .init(Vertex, vertices, indices); + self.indexCount = @intCast(indices.len); + self.isGenerated = true; + } + pub fn bind(self:*Model) void { + self.vao.bind(); + } + pub fn deinit(self:*Model) void { + self.vao.deinit(); + } +}; \ No newline at end of file diff --git a/src/client/entity_manager.zig b/src/client/entity_manager.zig index a5d83a4f82..f761130840 100644 --- a/src/client/entity_manager.zig +++ b/src/client/entity_manager.zig @@ -150,7 +150,7 @@ pub fn render(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { .mul(Mat4f.rotationZ(-ent.rot[2]))); const modelViewMatrix = game.camera.viewMatrix.mul(modelMatrix); c.glUniformMatrix4fv(uniforms.viewMatrix, 1, c.GL_TRUE, @ptrCast(&modelViewMatrix)); - c.glDrawElements(c.GL_TRIANGLES, model.indexCount, c.GL_UNSIGNED_INT, null); + c.glDrawElements(c.GL_TRIANGLES, model.model.indexCount, c.GL_UNSIGNED_INT, null); } } diff --git a/src/entityModel.zig b/src/entityModel.zig index 538ff1fd8e..8cc4daedb2 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -17,48 +17,23 @@ const Vec4f = vec.Vec4f; const NeverFailingAllocator = main.heap.NeverFailingAllocator; const BinaryReader = main.utils.BinaryReader; +const Model = main.Model.Model; pub const EntityModel = struct { - vao: ?graphics.VertexArray = undefined, - indexCount: c_int, + model: Model, defaultTexture: ?main.graphics.Texture, - height: f32, + height: f32, texturePath: []const u8, modelID: []const u8, id: []const u8, - const EntityVertex = extern struct { - pos: [3]f32, - normal: [3]f32, - uv: [2]f32, - - pub const attributeDescriptions: []const c.VkVertexInputAttributeDescription = &.{ - .{ - .location = 0, - .format = c.VK_FORMAT_R32G32B32_SFLOAT, - .offset = @offsetOf(@This(), "pos"), - }, - .{ - .location = 1, - .format = c.VK_FORMAT_R32G32B32_SFLOAT, - .offset = @offsetOf(@This(), "normal"), - }, - .{ - .location = 2, - .format = c.VK_FORMAT_R32G32_SFLOAT, - .offset = @offsetOf(@This(), "uv"), - }, - }; - }; - pub fn init(assetFolder: []const u8, id: []const u8, zon: ZonElement) EntityModel { var self: EntityModel = undefined; self.id = main.globalAllocator.dupe(u8, id); self.height = zon.getChild("height").as(f32, 1); self.defaultTexture = null; - self.vao = null; - self.indexCount = 0; + self.model = .init(); // get TexturePath { @@ -77,45 +52,18 @@ pub const EntityModel = struct { } fn generateGraphics(self: *EntityModel) void { self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); - - const quadInfos = main.assets.rawEntityModelData.get(self.modelID) orelse unreachable; - const vertices = main.stackAllocator.alloc(EntityVertex, quadInfos.len*4); - defer main.stackAllocator.free(vertices); - const indices: []u32 = main.stackAllocator.alloc(u32, quadInfos.len*6); - defer main.stackAllocator.free(indices); - - const texture = main.graphics.Texture.initFromFile(self.texturePath); - - for (quadInfos, 0..quadInfos.len) |quad, i| { - for (0..4) |j| { - const v = i*4 + j; - vertices[v].normal = quad.normal; - vertices[v].pos = quad.corners[j]; - vertices[v].uv = quad.cornerUV[j]; - } - } - - const lut = [_]u32{0, 2, 1, 1, 2, 3}; - for (0..indices.len) |i| { - indices[i] = @as(u32, @intCast(i))/6*4 + lut[i%6]; - } - - self.vao = .init(EntityVertex, vertices, indices); - self.defaultTexture = texture; - self.indexCount = @intCast(indices.len); + self.model.generateGraphics(self.modelID); } pub fn bind(self: *EntityModel) void { - if (self.vao == null) { + if (!self.model.isGenerated) { self.generateGraphics(); } - self.vao.?.bind(); + self.model.bind(); self.defaultTexture.?.bindTo(0); } pub fn deinit(self: *EntityModel) void { - if (self.vao) |vao| { - vao.deinit(); - } + self.model.deinit(); if (self.defaultTexture) |defaultTexture| { defaultTexture.deinit(); } diff --git a/src/main.zig b/src/main.zig index 14fa35ba17..d8d40ae7a1 100644 --- a/src/main.zig +++ b/src/main.zig @@ -23,6 +23,7 @@ pub const items = @import("items.zig"); pub const meta = @import("meta.zig"); pub const migrations = @import("migrations.zig"); pub const models = @import("models.zig"); +pub const Model = @import("client/Model.zig"); pub const network = @import("network.zig"); pub const physics = @import("physics.zig"); pub const random = @import("random.zig"); From 8581157881b42cb23468821c3a94e058c37de86c Mon Sep 17 00:00:00 2001 From: till++ Date: Mon, 6 Apr 2026 01:37:53 +0200 Subject: [PATCH 35/83] a solution to make @ranPix happy --- src/assets.zig | 12 +++-- src/client/Model.zig | 90 ---------------------------------- src/client/RawEntityModel.zig | 91 +++++++++++++++++++++++++++++++++++ src/client/entity_manager.zig | 2 +- src/entityModel.zig | 14 +++--- src/main.zig | 2 +- 6 files changed, 109 insertions(+), 102 deletions(-) delete mode 100644 src/client/Model.zig create mode 100644 src/client/RawEntityModel.zig diff --git a/src/assets.zig b/src/assets.zig index 2350ded143..37f774015d 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -532,7 +532,7 @@ pub const Palette = struct { // MARK: Palette }; var loadedAssets: bool = false; -pub var rawEntityModelData: std.StringHashMap([]const main.models.QuadInfo) = undefined; +pub var rawEntityModels: std.StringHashMap(main.RawEntityModel) = undefined; pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPalette: *Palette, toolPalette: *Palette, biomePalette: *Palette, entityComponentPalette: *Palette) !void { // MARK: loadWorldAssets() if (loadedAssets) return; // The assets already got loaded by the server. @@ -571,7 +571,7 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale // models (Entities): { var modelIterator = worldAssets.entityModels.iterator(); - rawEntityModelData = .init(main.worldArena.allocator); + rawEntityModels = .init(main.worldArena.allocator); while (modelIterator.next()) |entry| { std.log.debug("Registering entity model {s}", .{entry.key_ptr.*}); registerEntityModelRaw(entry.key_ptr.*, entry.value_ptr.*); @@ -745,7 +745,7 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale worldAssets.log(.world); } pub fn registerEntityModelRaw(id: []const u8, data: []const u8) void { - rawEntityModelData.put(id, main.models.Model.loadRawModelDataFromObj(main.worldArena, data)) catch unreachable; + rawEntityModels.put(id, main.RawEntityModel.init(data)) catch unreachable; } pub fn unloadAssets() void { // MARK: unloadAssets() if (!loadedAssets) return; @@ -764,6 +764,12 @@ pub fn unloadAssets() void { // MARK: unloadAssets() main.rotation.reset(); main.Tag.resetTags(); + var modelIterator = rawEntityModels.valueIterator(); + while (modelIterator.next()) |rawEntityModel| { + rawEntityModel.deinit(); + } + rawEntityModels.deinit(); + // Remove paths from asset hot reloading: var dir = main.files.cwd().openIterableDir("assets") catch |err| { std.log.err("Can't open asset path {s}: {s}", .{"assets", @errorName(err)}); diff --git a/src/client/Model.zig b/src/client/Model.zig deleted file mode 100644 index 64816d36f1..0000000000 --- a/src/client/Model.zig +++ /dev/null @@ -1,90 +0,0 @@ -const std = @import("std"); - -const main = @import("main"); -const chunk = main.chunk; -const game = main.game; -const graphics = main.graphics; -const c = graphics.c; -const ZonElement = main.ZonElement; -const renderer = main.renderer; -const settings = main.settings; -const utils = main.utils; -const vec = main.vec; -const Mat4f = vec.Mat4f; -const Vec3d = vec.Vec3d; -const Vec3f = vec.Vec3f; -const Vec4f = vec.Vec4f; -const NeverFailingAllocator = main.heap.NeverFailingAllocator; - -const BinaryReader = main.utils.BinaryReader; - -const Vertex = extern struct { - pos: [3]f32, - normal: [3]f32, - uv: [2]f32, - - pub const attributeDescriptions: []const c.VkVertexInputAttributeDescription = &.{ - .{ - .location = 0, - .format = c.VK_FORMAT_R32G32B32_SFLOAT, - .offset = @offsetOf(@This(), "pos"), - }, - .{ - .location = 1, - .format = c.VK_FORMAT_R32G32B32_SFLOAT, - .offset = @offsetOf(@This(), "normal"), - }, - .{ - .location = 2, - .format = c.VK_FORMAT_R32G32_SFLOAT, - .offset = @offsetOf(@This(), "uv"), - }, - }; -}; - -pub const Model = struct { - vao: graphics.VertexArray = undefined, - indexCount: c_int, - isGenerated:bool, - - pub fn init()Model{ - var self: Model = undefined; - self.vao = undefined; - self.indexCount = 0; - self.isGenerated = false; - - return self; - } - pub fn generateGraphics(self:*Model,modelID:[]const u8)void{ - const quadInfos = main.assets.rawEntityModelData.get(modelID) orelse unreachable; - const vertices = main.stackAllocator.alloc(Vertex, quadInfos.len*4); - defer main.stackAllocator.free(vertices); - const indices: []u32 = main.stackAllocator.alloc(u32, quadInfos.len*6); - defer main.stackAllocator.free(indices); - - - for (quadInfos, 0..quadInfos.len) |quad, i| { - for (0..4) |j| { - const v = i*4 + j; - vertices[v].normal = quad.normal; - vertices[v].pos = quad.corners[j]; - vertices[v].uv = quad.cornerUV[j]; - } - } - - const lut = [_]u32{0, 2, 1, 1, 2, 3}; - for (0..indices.len) |i| { - indices[i] = @as(u32, @intCast(i))/6*4 + lut[i%6]; - } - - self.vao = .init(Vertex, vertices, indices); - self.indexCount = @intCast(indices.len); - self.isGenerated = true; - } - pub fn bind(self:*Model) void { - self.vao.bind(); - } - pub fn deinit(self:*Model) void { - self.vao.deinit(); - } -}; \ No newline at end of file diff --git a/src/client/RawEntityModel.zig b/src/client/RawEntityModel.zig new file mode 100644 index 0000000000..3236a62cee --- /dev/null +++ b/src/client/RawEntityModel.zig @@ -0,0 +1,91 @@ +const std = @import("std"); + +const main = @import("main"); +const chunk = main.chunk; +const game = main.game; +const graphics = main.graphics; +const c = graphics.c; +const ZonElement = main.ZonElement; +const renderer = main.renderer; +const settings = main.settings; +const utils = main.utils; +const vec = main.vec; +const Mat4f = vec.Mat4f; +const Vec3d = vec.Vec3d; +const Vec3f = vec.Vec3f; +const Vec4f = vec.Vec4f; +const NeverFailingAllocator = main.heap.NeverFailingAllocator; + +const BinaryReader = main.utils.BinaryReader; + +isGenerated: bool, + +vao: graphics.VertexArray = undefined, +indexCount: c_int, +quadInfos: []main.models.QuadInfo, + +const Vertex = extern struct { + pos: [3]f32, + normal: [3]f32, + uv: [2]f32, + + pub const attributeDescriptions: []const c.VkVertexInputAttributeDescription = &.{ + .{ + .location = 0, + .format = c.VK_FORMAT_R32G32B32_SFLOAT, + .offset = @offsetOf(@This(), "pos"), + }, + .{ + .location = 1, + .format = c.VK_FORMAT_R32G32B32_SFLOAT, + .offset = @offsetOf(@This(), "normal"), + }, + .{ + .location = 2, + .format = c.VK_FORMAT_R32G32_SFLOAT, + .offset = @offsetOf(@This(), "uv"), + }, + }; +}; + +pub fn init(data: []const u8) @This() { + return .{ + .isGenerated = false, + .vao = undefined, + .indexCount = 0, + .quadInfos = main.models.Model.loadRawModelDataFromObj(main.worldArena, data), + }; +} +pub fn generateGraphics(self: *@This()) void { + if (self.isGenerated) + return; + const quadInfos = self.quadInfos; + const vertices = main.stackAllocator.alloc(Vertex, quadInfos.len*4); + defer main.stackAllocator.free(vertices); + const indices: []u32 = main.stackAllocator.alloc(u32, quadInfos.len*6); + defer main.stackAllocator.free(indices); + + for (quadInfos, 0..quadInfos.len) |quad, i| { + for (0..4) |j| { + const v = i*4 + j; + vertices[v].normal = quad.normal; + vertices[v].pos = quad.corners[j]; + vertices[v].uv = quad.cornerUV[j]; + } + } + + const lut = [_]u32{0, 2, 1, 1, 2, 3}; + for (0..indices.len) |i| { + indices[i] = @as(u32, @intCast(i))/6*4 + lut[i%6]; + } + + self.vao = .init(Vertex, vertices, indices); + self.indexCount = @intCast(indices.len); + self.isGenerated = true; +} +pub fn bind(self: *@This()) void { + self.vao.bind(); +} +pub fn deinit(self: @This()) void { + self.vao.deinit(); +} diff --git a/src/client/entity_manager.zig b/src/client/entity_manager.zig index f761130840..d9c2d85b16 100644 --- a/src/client/entity_manager.zig +++ b/src/client/entity_manager.zig @@ -150,7 +150,7 @@ pub fn render(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { .mul(Mat4f.rotationZ(-ent.rot[2]))); const modelViewMatrix = game.camera.viewMatrix.mul(modelMatrix); c.glUniformMatrix4fv(uniforms.viewMatrix, 1, c.GL_TRUE, @ptrCast(&modelViewMatrix)); - c.glDrawElements(c.GL_TRIANGLES, model.model.indexCount, c.GL_UNSIGNED_INT, null); + c.glDrawElements(c.GL_TRIANGLES, model.rawModel.?.indexCount, c.GL_UNSIGNED_INT, null); } } diff --git a/src/entityModel.zig b/src/entityModel.zig index 8cc4daedb2..e02d9c54f4 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -17,10 +17,10 @@ const Vec4f = vec.Vec4f; const NeverFailingAllocator = main.heap.NeverFailingAllocator; const BinaryReader = main.utils.BinaryReader; -const Model = main.Model.Model; +const RawModel = main.RawEntityModel; pub const EntityModel = struct { - model: Model, + rawModel: ?RawModel, defaultTexture: ?main.graphics.Texture, height: f32, @@ -33,7 +33,7 @@ pub const EntityModel = struct { self.id = main.globalAllocator.dupe(u8, id); self.height = zon.getChild("height").as(f32, 1); self.defaultTexture = null; - self.model = .init(); + self.rawModel = null; // get TexturePath { @@ -52,18 +52,18 @@ pub const EntityModel = struct { } fn generateGraphics(self: *EntityModel) void { self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); - self.model.generateGraphics(self.modelID); + self.rawModel = main.assets.rawEntityModels.get(self.modelID) orelse unreachable; + self.rawModel.?.generateGraphics(); } pub fn bind(self: *EntityModel) void { - if (!self.model.isGenerated) { + if (self.rawModel == null) { self.generateGraphics(); } - self.model.bind(); + self.rawModel.?.bind(); self.defaultTexture.?.bindTo(0); } pub fn deinit(self: *EntityModel) void { - self.model.deinit(); if (self.defaultTexture) |defaultTexture| { defaultTexture.deinit(); } diff --git a/src/main.zig b/src/main.zig index d8d40ae7a1..c6079d0946 100644 --- a/src/main.zig +++ b/src/main.zig @@ -23,7 +23,7 @@ pub const items = @import("items.zig"); pub const meta = @import("meta.zig"); pub const migrations = @import("migrations.zig"); pub const models = @import("models.zig"); -pub const Model = @import("client/Model.zig"); +pub const RawEntityModel = @import("client/RawEntityModel.zig"); pub const network = @import("network.zig"); pub const physics = @import("physics.zig"); pub const random = @import("random.zig"); From 9ff6aaad9a50f69f654c553b82ed3337972e746b Mon Sep 17 00:00:00 2001 From: till++ Date: Mon, 6 Apr 2026 01:45:09 +0200 Subject: [PATCH 36/83] comments --- src/client/RawEntityModel.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/RawEntityModel.zig b/src/client/RawEntityModel.zig index 3236a62cee..3e01afe974 100644 --- a/src/client/RawEntityModel.zig +++ b/src/client/RawEntityModel.zig @@ -48,6 +48,7 @@ const Vertex = extern struct { }; }; +// No OpenGL/Vulkan allowed yet, cause this could run on server. pub fn init(data: []const u8) @This() { return .{ .isGenerated = false, @@ -56,6 +57,8 @@ pub fn init(data: []const u8) @This() { .quadInfos = main.models.Model.loadRawModelDataFromObj(main.worldArena, data), }; } + +// Now free to generate all OpenGL/Vulkan stuff. pub fn generateGraphics(self: *@This()) void { if (self.isGenerated) return; From 1ed66b60f777617c8cb6a455d672fabe2d4b2897 Mon Sep 17 00:00:00 2001 From: till++ Date: Mon, 6 Apr 2026 02:30:52 +0200 Subject: [PATCH 37/83] Each descriptor has a model --- .../{ => descriptor}/cubert.zig.zon | 1 - .../{ => descriptor}/missing.zig.zon | 1 - .../{ => descriptor}/moffalo.zig.zon | 1 - .../{ => descriptor}/snail.zig.zon | 1 - .../{ => descriptor}/snale.zig.zon | 1 - src/assets.zig | 28 ++++++++----------- src/entityModel.zig | 12 ++++---- 7 files changed, 18 insertions(+), 27 deletions(-) rename assets/cubyz/entityModels/{ => descriptor}/cubert.zig.zon (63%) rename assets/cubyz/entityModels/{ => descriptor}/missing.zig.zon (63%) rename assets/cubyz/entityModels/{ => descriptor}/moffalo.zig.zon (64%) rename assets/cubyz/entityModels/{ => descriptor}/snail.zig.zon (63%) rename assets/cubyz/entityModels/{ => descriptor}/snale.zig.zon (63%) diff --git a/assets/cubyz/entityModels/cubert.zig.zon b/assets/cubyz/entityModels/descriptor/cubert.zig.zon similarity index 63% rename from assets/cubyz/entityModels/cubert.zig.zon rename to assets/cubyz/entityModels/descriptor/cubert.zig.zon index 72aee01c38..1afc8f9093 100644 --- a/assets/cubyz/entityModels/cubert.zig.zon +++ b/assets/cubyz/entityModels/descriptor/cubert.zig.zon @@ -1,5 +1,4 @@ .{ - .model = "cubyz:cubert", .texture = "cubert.png", .height = 2, } diff --git a/assets/cubyz/entityModels/missing.zig.zon b/assets/cubyz/entityModels/descriptor/missing.zig.zon similarity index 63% rename from assets/cubyz/entityModels/missing.zig.zon rename to assets/cubyz/entityModels/descriptor/missing.zig.zon index 9c408e3cf2..f9d20773d6 100644 --- a/assets/cubyz/entityModels/missing.zig.zon +++ b/assets/cubyz/entityModels/descriptor/missing.zig.zon @@ -1,5 +1,4 @@ .{ - .model = "cubyz:missing", .texture = "missing.png", .height = 1, } diff --git a/assets/cubyz/entityModels/moffalo.zig.zon b/assets/cubyz/entityModels/descriptor/moffalo.zig.zon similarity index 64% rename from assets/cubyz/entityModels/moffalo.zig.zon rename to assets/cubyz/entityModels/descriptor/moffalo.zig.zon index 43d8ffe24d..aa866b9774 100644 --- a/assets/cubyz/entityModels/moffalo.zig.zon +++ b/assets/cubyz/entityModels/descriptor/moffalo.zig.zon @@ -1,5 +1,4 @@ .{ - .model = "cubyz:moffalo", .texture = "moffalo.png", .height = 1.8, } diff --git a/assets/cubyz/entityModels/snail.zig.zon b/assets/cubyz/entityModels/descriptor/snail.zig.zon similarity index 63% rename from assets/cubyz/entityModels/snail.zig.zon rename to assets/cubyz/entityModels/descriptor/snail.zig.zon index c8aa2abc17..e7a86ad6dc 100644 --- a/assets/cubyz/entityModels/snail.zig.zon +++ b/assets/cubyz/entityModels/descriptor/snail.zig.zon @@ -1,5 +1,4 @@ .{ - .model = "cubyz:snail", .texture = "snail.png", .height = 1, } diff --git a/assets/cubyz/entityModels/snale.zig.zon b/assets/cubyz/entityModels/descriptor/snale.zig.zon similarity index 63% rename from assets/cubyz/entityModels/snale.zig.zon rename to assets/cubyz/entityModels/descriptor/snale.zig.zon index fb4b527097..0c9d604594 100644 --- a/assets/cubyz/entityModels/snale.zig.zon +++ b/assets/cubyz/entityModels/descriptor/snale.zig.zon @@ -1,5 +1,4 @@ .{ - .model = "cubyz:snale", .texture = "snale.png", .height = 2, } diff --git a/src/assets.zig b/src/assets.zig index 37f774015d..f3169ee474 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -123,7 +123,7 @@ pub const Assets = struct { addon.readAllModels(allocator, "entityModels/models", &self.entityModels); addon.readAllZon(allocator, "particles", true, &self.particles, null); addon.readAllZon(allocator, "world_presets", true, &self.worldPresets, null); - addon.readAllZon(allocator, "entityModels", true, &self.entityModelDescriptions, null); + addon.readAllZon(allocator, "entityModels/descriptor", true, &self.entityModelDescriptions, null); } } fn log(self: *Assets, typ: enum { common, world }) void { @@ -532,7 +532,6 @@ pub const Palette = struct { // MARK: Palette }; var loadedAssets: bool = false; -pub var rawEntityModels: std.StringHashMap(main.RawEntityModel) = undefined; pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPalette: *Palette, toolPalette: *Palette, biomePalette: *Palette, entityComponentPalette: *Palette) !void { // MARK: loadWorldAssets() if (loadedAssets) return; // The assets already got loaded by the server. @@ -569,12 +568,13 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale } // models (Entities): - { - var modelIterator = worldAssets.entityModels.iterator(); - rawEntityModels = .init(main.worldArena.allocator); - while (modelIterator.next()) |entry| { + { + var modelIterator = worldAssets.entityModelDescriptions.iterator(); + while (modelIterator.next())|entry| { + const id = entry.key_ptr.*; + const zon = entry.value_ptr.*; std.log.debug("Registering entity model {s}", .{entry.key_ptr.*}); - registerEntityModelRaw(entry.key_ptr.*, entry.value_ptr.*); + _ = main.entityModel.register(assetFolder, id, zon); } } if (!main.settings.launchConfig.headlessServer) blocks_zig.meshes.registerBlockBreakingAnimation(assetFolder); @@ -744,9 +744,7 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale worldAssets.log(.world); } -pub fn registerEntityModelRaw(id: []const u8, data: []const u8) void { - rawEntityModels.put(id, main.RawEntityModel.init(data)) catch unreachable; -} + pub fn unloadAssets() void { // MARK: unloadAssets() if (!loadedAssets) return; loadedAssets = false; @@ -763,12 +761,7 @@ pub fn unloadAssets() void { // MARK: unloadAssets() main.particles.ParticleManager.reset(); main.rotation.reset(); main.Tag.resetTags(); - - var modelIterator = rawEntityModels.valueIterator(); - while (modelIterator.next()) |rawEntityModel| { - rawEntityModel.deinit(); - } - rawEntityModels.deinit(); + main.entityModel.reset(); // Remove paths from asset hot reloading: var dir = main.files.cwd().openIterableDir("assets") catch |err| { @@ -799,3 +792,6 @@ pub fn worldPresets() *const Assets.ZonHashMap { pub fn entityModelDescriptions() *const Assets.ZonHashMap { return &common.entityModelDescriptions; } +pub fn entityModels() *const Assets.BytesHashMap { + return &common.entityModels; +} diff --git a/src/entityModel.zig b/src/entityModel.zig index e02d9c54f4..4d334ab3c5 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -25,7 +25,6 @@ pub const EntityModel = struct { height: f32, texturePath: []const u8, - modelID: []const u8, id: []const u8, pub fn init(assetFolder: []const u8, id: []const u8, zon: ZonElement) EntityModel { @@ -43,16 +42,16 @@ pub const EntityModel = struct { if (zon.get(?[]const u8, "texture", null)) |texture| { self.texturePath = std.fmt.allocPrint(main.globalAllocator.allocator, "{s}/{s}/entityModels/textures/{s}", .{assetFolder, mod, texture}) catch &.{}; std.fs.cwd().access(self.texturePath, .{}) catch { + main.globalAllocator.free(self.texturePath); self.texturePath = std.fmt.allocPrint(main.globalAllocator.allocator, "assets/{s}/entityModels/textures/{s}", .{mod, texture}) catch &.{}; }; } } - self.modelID = main.globalAllocator.dupe(u8, zon.getChild("model").as([]const u8, "cubyz:missing")); return self; } fn generateGraphics(self: *EntityModel) void { self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); - self.rawModel = main.assets.rawEntityModels.get(self.modelID) orelse unreachable; + self.rawModel = .init(main.assets.entityModels().get(self.id) orelse main.assets.entityModels().get("cubyz:missing") orelse unreachable); self.rawModel.?.generateGraphics(); } pub fn bind(self: *EntityModel) void { @@ -68,9 +67,7 @@ pub const EntityModel = struct { defaultTexture.deinit(); } main.globalAllocator.free(self.id); - if (self.texturePath.len > 0) - main.globalAllocator.free(self.texturePath); - main.globalAllocator.free(self.modelID); + main.globalAllocator.free(self.texturePath); } }; @@ -96,6 +93,9 @@ pub fn register(assetFolder: []const u8, id: []const u8, zon: ZonElement) usize return index; } pub fn reset() void { + for (entityModels.items) |*model| { + model.deinit(); + } entityModels = .{}; reverseIndices = .{}; } From 0403d1361d0ebc90babc3b2b8eb36eebab4ba26d Mon Sep 17 00:00:00 2001 From: till++ Date: Mon, 6 Apr 2026 03:06:41 +0200 Subject: [PATCH 38/83] removed rawEntityModelData --- src/assets.zig | 10 ++-- src/client/RawEntityModel.zig | 94 ----------------------------------- src/client/entity_manager.zig | 2 +- src/entityModel.zig | 76 ++++++++++++++++++++++++---- src/main.zig | 1 - 5 files changed, 71 insertions(+), 112 deletions(-) delete mode 100644 src/client/RawEntityModel.zig diff --git a/src/assets.zig b/src/assets.zig index f3169ee474..7a9ede00cb 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -568,9 +568,9 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale } // models (Entities): - { + { var modelIterator = worldAssets.entityModelDescriptions.iterator(); - while (modelIterator.next())|entry| { + while (modelIterator.next()) |entry| { const id = entry.key_ptr.*; const zon = entry.value_ptr.*; std.log.debug("Registering entity model {s}", .{entry.key_ptr.*}); @@ -787,11 +787,11 @@ pub fn unloadAssets() void { // MARK: unloadAssets() pub fn worldPresets() *const Assets.ZonHashMap { return &common.worldPresets; } +pub fn entityModelFiles() *const Assets.BytesHashMap { + return &common.entityModels; +} // TODO: Tempoary, will be removed in future ECS parts. pub fn entityModelDescriptions() *const Assets.ZonHashMap { return &common.entityModelDescriptions; } -pub fn entityModels() *const Assets.BytesHashMap { - return &common.entityModels; -} diff --git a/src/client/RawEntityModel.zig b/src/client/RawEntityModel.zig deleted file mode 100644 index 3e01afe974..0000000000 --- a/src/client/RawEntityModel.zig +++ /dev/null @@ -1,94 +0,0 @@ -const std = @import("std"); - -const main = @import("main"); -const chunk = main.chunk; -const game = main.game; -const graphics = main.graphics; -const c = graphics.c; -const ZonElement = main.ZonElement; -const renderer = main.renderer; -const settings = main.settings; -const utils = main.utils; -const vec = main.vec; -const Mat4f = vec.Mat4f; -const Vec3d = vec.Vec3d; -const Vec3f = vec.Vec3f; -const Vec4f = vec.Vec4f; -const NeverFailingAllocator = main.heap.NeverFailingAllocator; - -const BinaryReader = main.utils.BinaryReader; - -isGenerated: bool, - -vao: graphics.VertexArray = undefined, -indexCount: c_int, -quadInfos: []main.models.QuadInfo, - -const Vertex = extern struct { - pos: [3]f32, - normal: [3]f32, - uv: [2]f32, - - pub const attributeDescriptions: []const c.VkVertexInputAttributeDescription = &.{ - .{ - .location = 0, - .format = c.VK_FORMAT_R32G32B32_SFLOAT, - .offset = @offsetOf(@This(), "pos"), - }, - .{ - .location = 1, - .format = c.VK_FORMAT_R32G32B32_SFLOAT, - .offset = @offsetOf(@This(), "normal"), - }, - .{ - .location = 2, - .format = c.VK_FORMAT_R32G32_SFLOAT, - .offset = @offsetOf(@This(), "uv"), - }, - }; -}; - -// No OpenGL/Vulkan allowed yet, cause this could run on server. -pub fn init(data: []const u8) @This() { - return .{ - .isGenerated = false, - .vao = undefined, - .indexCount = 0, - .quadInfos = main.models.Model.loadRawModelDataFromObj(main.worldArena, data), - }; -} - -// Now free to generate all OpenGL/Vulkan stuff. -pub fn generateGraphics(self: *@This()) void { - if (self.isGenerated) - return; - const quadInfos = self.quadInfos; - const vertices = main.stackAllocator.alloc(Vertex, quadInfos.len*4); - defer main.stackAllocator.free(vertices); - const indices: []u32 = main.stackAllocator.alloc(u32, quadInfos.len*6); - defer main.stackAllocator.free(indices); - - for (quadInfos, 0..quadInfos.len) |quad, i| { - for (0..4) |j| { - const v = i*4 + j; - vertices[v].normal = quad.normal; - vertices[v].pos = quad.corners[j]; - vertices[v].uv = quad.cornerUV[j]; - } - } - - const lut = [_]u32{0, 2, 1, 1, 2, 3}; - for (0..indices.len) |i| { - indices[i] = @as(u32, @intCast(i))/6*4 + lut[i%6]; - } - - self.vao = .init(Vertex, vertices, indices); - self.indexCount = @intCast(indices.len); - self.isGenerated = true; -} -pub fn bind(self: *@This()) void { - self.vao.bind(); -} -pub fn deinit(self: @This()) void { - self.vao.deinit(); -} diff --git a/src/client/entity_manager.zig b/src/client/entity_manager.zig index d9c2d85b16..a5d83a4f82 100644 --- a/src/client/entity_manager.zig +++ b/src/client/entity_manager.zig @@ -150,7 +150,7 @@ pub fn render(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { .mul(Mat4f.rotationZ(-ent.rot[2]))); const modelViewMatrix = game.camera.viewMatrix.mul(modelMatrix); c.glUniformMatrix4fv(uniforms.viewMatrix, 1, c.GL_TRUE, @ptrCast(&modelViewMatrix)); - c.glDrawElements(c.GL_TRIANGLES, model.rawModel.?.indexCount, c.GL_UNSIGNED_INT, null); + c.glDrawElements(c.GL_TRIANGLES, model.indexCount, c.GL_UNSIGNED_INT, null); } } diff --git a/src/entityModel.zig b/src/entityModel.zig index 4d334ab3c5..3504da6b73 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -17,22 +17,50 @@ const Vec4f = vec.Vec4f; const NeverFailingAllocator = main.heap.NeverFailingAllocator; const BinaryReader = main.utils.BinaryReader; -const RawModel = main.RawEntityModel; pub const EntityModel = struct { - rawModel: ?RawModel, - defaultTexture: ?main.graphics.Texture, - + height: f32, texturePath: []const u8, id: []const u8, + vao: ?graphics.VertexArray = null, + indexCount: c_int, + defaultTexture: ?main.graphics.Texture, + + + const Vertex = extern struct { + pos: [3]f32, + normal: [3]f32, + uv: [2]f32, + + pub const attributeDescriptions: []const c.VkVertexInputAttributeDescription = &.{ + .{ + .location = 0, + .format = c.VK_FORMAT_R32G32B32_SFLOAT, + .offset = @offsetOf(@This(), "pos"), + }, + .{ + .location = 1, + .format = c.VK_FORMAT_R32G32B32_SFLOAT, + .offset = @offsetOf(@This(), "normal"), + }, + .{ + .location = 2, + .format = c.VK_FORMAT_R32G32_SFLOAT, + .offset = @offsetOf(@This(), "uv"), + }, + }; + }; + + pub fn init(assetFolder: []const u8, id: []const u8, zon: ZonElement) EntityModel { var self: EntityModel = undefined; self.id = main.globalAllocator.dupe(u8, id); self.height = zon.getChild("height").as(f32, 1); self.defaultTexture = null; - self.rawModel = null; + self.vao = null; + self.indexCount = 0; // get TexturePath { @@ -51,23 +79,49 @@ pub const EntityModel = struct { } fn generateGraphics(self: *EntityModel) void { self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); - self.rawModel = .init(main.assets.entityModels().get(self.id) orelse main.assets.entityModels().get("cubyz:missing") orelse unreachable); - self.rawModel.?.generateGraphics(); + const file = main.assets.entityModelFiles().get(self.id) orelse main.assets.entityModelFiles().get("cubyz:missing") orelse unreachable; + + const quadInfos = main.models.Model.loadRawModelDataFromObj(main.stackAllocator, file); + defer main.stackAllocator.free(quadInfos); + const vertices = main.stackAllocator.alloc(Vertex, quadInfos.len*4); + defer main.stackAllocator.free(vertices); + const indices: []u32 = main.stackAllocator.alloc(u32, quadInfos.len*6); + defer main.stackAllocator.free(indices); + + for (quadInfos, 0..quadInfos.len) |quad, i| { + for (0..4) |j| { + const v = i*4 + j; + vertices[v].normal = quad.normal; + vertices[v].pos = quad.corners[j]; + vertices[v].uv = quad.cornerUV[j]; + } + } + + const lut = [_]u32{0, 2, 1, 1, 2, 3}; + for (0..indices.len) |i| { + indices[i] = @as(u32, @intCast(i))/6*4 + lut[i%6]; + } + + self.vao = .init(Vertex, vertices, indices); + self.indexCount = @intCast(indices.len); } pub fn bind(self: *EntityModel) void { - if (self.rawModel == null) { + if (self.vao == null) { self.generateGraphics(); } - self.rawModel.?.bind(); + self.vao.?.bind(); self.defaultTexture.?.bindTo(0); } pub fn deinit(self: *EntityModel) void { + main.globalAllocator.free(self.id); + main.globalAllocator.free(self.texturePath); if (self.defaultTexture) |defaultTexture| { defaultTexture.deinit(); } - main.globalAllocator.free(self.id); - main.globalAllocator.free(self.texturePath); + if(self.vao)|vao|{ + vao.deinit(); + } } }; diff --git a/src/main.zig b/src/main.zig index c6079d0946..14fa35ba17 100644 --- a/src/main.zig +++ b/src/main.zig @@ -23,7 +23,6 @@ pub const items = @import("items.zig"); pub const meta = @import("meta.zig"); pub const migrations = @import("migrations.zig"); pub const models = @import("models.zig"); -pub const RawEntityModel = @import("client/RawEntityModel.zig"); pub const network = @import("network.zig"); pub const physics = @import("physics.zig"); pub const random = @import("random.zig"); From 3039d14c257294e2f2f7982866512c79d739e498 Mon Sep 17 00:00:00 2001 From: till++ Date: Mon, 6 Apr 2026 03:25:05 +0200 Subject: [PATCH 39/83] fmt --- src/entityModel.zig | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/entityModel.zig b/src/entityModel.zig index 3504da6b73..6f3abda789 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -19,7 +19,6 @@ const NeverFailingAllocator = main.heap.NeverFailingAllocator; const BinaryReader = main.utils.BinaryReader; pub const EntityModel = struct { - height: f32, texturePath: []const u8, id: []const u8, @@ -28,7 +27,6 @@ pub const EntityModel = struct { indexCount: c_int, defaultTexture: ?main.graphics.Texture, - const Vertex = extern struct { pos: [3]f32, normal: [3]f32, @@ -53,7 +51,6 @@ pub const EntityModel = struct { }; }; - pub fn init(assetFolder: []const u8, id: []const u8, zon: ZonElement) EntityModel { var self: EntityModel = undefined; self.id = main.globalAllocator.dupe(u8, id); @@ -119,7 +116,7 @@ pub const EntityModel = struct { if (self.defaultTexture) |defaultTexture| { defaultTexture.deinit(); } - if(self.vao)|vao|{ + if (self.vao) |vao| { vao.deinit(); } } From 8a5db6e514e471abac588f80364fc3c9a590a94d Mon Sep 17 00:00:00 2001 From: till++ Date: Mon, 6 Apr 2026 03:31:20 +0200 Subject: [PATCH 40/83] descriptions is a better name then descriptor --- .../entityModels/{descriptor => descriptions}/cubert.zig.zon | 0 .../entityModels/{descriptor => descriptions}/missing.zig.zon | 0 .../entityModels/{descriptor => descriptions}/moffalo.zig.zon | 0 .../entityModels/{descriptor => descriptions}/snail.zig.zon | 0 .../entityModels/{descriptor => descriptions}/snale.zig.zon | 0 src/assets.zig | 2 +- 6 files changed, 1 insertion(+), 1 deletion(-) rename assets/cubyz/entityModels/{descriptor => descriptions}/cubert.zig.zon (100%) rename assets/cubyz/entityModels/{descriptor => descriptions}/missing.zig.zon (100%) rename assets/cubyz/entityModels/{descriptor => descriptions}/moffalo.zig.zon (100%) rename assets/cubyz/entityModels/{descriptor => descriptions}/snail.zig.zon (100%) rename assets/cubyz/entityModels/{descriptor => descriptions}/snale.zig.zon (100%) diff --git a/assets/cubyz/entityModels/descriptor/cubert.zig.zon b/assets/cubyz/entityModels/descriptions/cubert.zig.zon similarity index 100% rename from assets/cubyz/entityModels/descriptor/cubert.zig.zon rename to assets/cubyz/entityModels/descriptions/cubert.zig.zon diff --git a/assets/cubyz/entityModels/descriptor/missing.zig.zon b/assets/cubyz/entityModels/descriptions/missing.zig.zon similarity index 100% rename from assets/cubyz/entityModels/descriptor/missing.zig.zon rename to assets/cubyz/entityModels/descriptions/missing.zig.zon diff --git a/assets/cubyz/entityModels/descriptor/moffalo.zig.zon b/assets/cubyz/entityModels/descriptions/moffalo.zig.zon similarity index 100% rename from assets/cubyz/entityModels/descriptor/moffalo.zig.zon rename to assets/cubyz/entityModels/descriptions/moffalo.zig.zon diff --git a/assets/cubyz/entityModels/descriptor/snail.zig.zon b/assets/cubyz/entityModels/descriptions/snail.zig.zon similarity index 100% rename from assets/cubyz/entityModels/descriptor/snail.zig.zon rename to assets/cubyz/entityModels/descriptions/snail.zig.zon diff --git a/assets/cubyz/entityModels/descriptor/snale.zig.zon b/assets/cubyz/entityModels/descriptions/snale.zig.zon similarity index 100% rename from assets/cubyz/entityModels/descriptor/snale.zig.zon rename to assets/cubyz/entityModels/descriptions/snale.zig.zon diff --git a/src/assets.zig b/src/assets.zig index 7a9ede00cb..6a24e8c49d 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -123,7 +123,7 @@ pub const Assets = struct { addon.readAllModels(allocator, "entityModels/models", &self.entityModels); addon.readAllZon(allocator, "particles", true, &self.particles, null); addon.readAllZon(allocator, "world_presets", true, &self.worldPresets, null); - addon.readAllZon(allocator, "entityModels/descriptor", true, &self.entityModelDescriptions, null); + addon.readAllZon(allocator, "entityModels/descriptions", true, &self.entityModelDescriptions, null); } } fn log(self: *Assets, typ: enum { common, world }) void { From e18f348ac543b38451d8329e7137f9a274228507 Mon Sep 17 00:00:00 2001 From: till++ Date: Mon, 6 Apr 2026 05:48:31 +0200 Subject: [PATCH 41/83] make it easier for #2762 to use glb files instead of obj --- src/assets.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index 6a24e8c49d..468d9cce7b 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -119,8 +119,8 @@ pub const Assets = struct { addon.readAllZon(allocator, "recipes", false, &self.recipes, null); addon.readAllZon(allocator, "sbb", true, &self.structureBuildingBlocks, null); addon.readAllBlueprints(allocator, "sbb", &self.blueprints); - addon.readAllModels(allocator, "models", &self.blockModels); - addon.readAllModels(allocator, "entityModels/models", &self.entityModels); + addon.readAllModels(allocator, "models", ".obj", &self.blockModels); + addon.readAllModels(allocator, "entityModels/models", ".obj", &self.entityModels); addon.readAllZon(allocator, "particles", true, &self.particles, null); addon.readAllZon(allocator, "world_presets", true, &self.worldPresets, null); addon.readAllZon(allocator, "entityModels/descriptions", true, &self.entityModelDescriptions, null); @@ -301,7 +301,7 @@ pub const Assets = struct { } } - pub fn readAllModels(addon: Addon, allocator: NeverFailingAllocator, subPath: []const u8, output: *BytesHashMap) void { + pub fn readAllModels(addon: Addon, allocator: NeverFailingAllocator, subPath: []const u8, fileEnding: []const u8, output: *BytesHashMap) void { var assetsDirectory = addon.dir.openIterableDir(subPath) catch |err| { if (err != error.FileNotFound) { std.log.err("Could not open addon directory {s}: {s}", .{subPath, @errorName(err)}); @@ -317,7 +317,7 @@ pub const Assets = struct { break :blk null; }) |entry| { if (entry.kind != .file) continue; - if (!std.ascii.endsWithIgnoreCase(entry.basename, ".obj")) continue; + if (!std.ascii.endsWithIgnoreCase(entry.basename, fileEnding)) continue; const id = createAssetStringID(allocator, addon.name, "model", entry.path) catch continue; From 0fecebbc88c0b42929d04af84d89d9511b6b0dde Mon Sep 17 00:00:00 2001 From: till++ Date: Tue, 7 Apr 2026 01:54:22 +0200 Subject: [PATCH 42/83] the .obj/.glb files are to heavy to be kept in memory. Remove them after they aren't nessary anymore --- src/assets.zig | 27 +++++++++++++++++++-------- src/entityModel.zig | 14 +++++++++++--- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index 468d9cce7b..8ec2b5e377 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -34,7 +34,6 @@ pub const Assets = struct { structureTables: ZonHashMap, recipes: ZonHashMap, blockModels: BytesHashMap, - entityModels: BytesHashMap, structureBuildingBlocks: ZonHashMap, blueprints: BytesHashMap, particles: ZonHashMap, @@ -55,7 +54,6 @@ pub const Assets = struct { .structureTables = .{}, .recipes = .{}, .blockModels = .{}, - .entityModels = .{}, .structureBuildingBlocks = .{}, .blueprints = .{}, .particles = .{}, @@ -76,7 +74,6 @@ pub const Assets = struct { self.structureTables.deinit(allocator.allocator); self.recipes.deinit(allocator.allocator); self.blockModels.deinit(allocator.allocator); - self.entityModels.deinit(allocator.allocator); self.structureBuildingBlocks.deinit(allocator.allocator); self.blueprints.deinit(allocator.allocator); self.particles.deinit(allocator.allocator); @@ -97,7 +94,6 @@ pub const Assets = struct { .structureTables = self.structureTables.clone(allocator.allocator) catch unreachable, .recipes = self.recipes.clone(allocator.allocator) catch unreachable, .blockModels = self.blockModels.clone(allocator.allocator) catch unreachable, - .entityModels = self.entityModels.clone(allocator.allocator) catch unreachable, .structureBuildingBlocks = self.structureBuildingBlocks.clone(allocator.allocator) catch unreachable, .blueprints = self.blueprints.clone(allocator.allocator) catch unreachable, .particles = self.particles.clone(allocator.allocator) catch unreachable, @@ -120,7 +116,6 @@ pub const Assets = struct { addon.readAllZon(allocator, "sbb", true, &self.structureBuildingBlocks, null); addon.readAllBlueprints(allocator, "sbb", &self.blueprints); addon.readAllModels(allocator, "models", ".obj", &self.blockModels); - addon.readAllModels(allocator, "entityModels/models", ".obj", &self.entityModels); addon.readAllZon(allocator, "particles", true, &self.particles, null); addon.readAllZon(allocator, "world_presets", true, &self.worldPresets, null); addon.readAllZon(allocator, "entityModels/descriptions", true, &self.entityModelDescriptions, null); @@ -784,12 +779,28 @@ pub fn unloadAssets() void { // MARK: unloadAssets() } } +pub fn readAsset(allocator: NeverFailingAllocator, assetFolder: []const u8, subPath: []const u8, id: []const u8, fileEnding: []const u8) ?[]const u8 { + var split = std.mem.splitScalar(u8, id, ':'); + const mod = split.first(); + const name = split.next() orelse return null; + + var path = std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{assetFolder, mod, subPath, name, fileEnding}) catch &.{}; + defer main.stackAllocator.free(path); + std.fs.cwd().access(path, .{}) catch { + main.stackAllocator.free(path); + path = std.fmt.allocPrint(main.stackAllocator.allocator, "assets/{s}/{s}/{s}{s}", .{mod, subPath, name, fileEnding}) catch &.{}; + }; + + const string = std.fs.cwd().readFileAlloc(path, allocator.allocator, .unlimited) catch |err| { + std.log.err("Could not open {s}/{s}{s}: {s}", .{subPath, name, fileEnding, @errorName(err)}); + return null; + }; + return string; +} + pub fn worldPresets() *const Assets.ZonHashMap { return &common.worldPresets; } -pub fn entityModelFiles() *const Assets.BytesHashMap { - return &common.entityModels; -} // TODO: Tempoary, will be removed in future ECS parts. pub fn entityModelDescriptions() *const Assets.ZonHashMap { diff --git a/src/entityModel.zig b/src/entityModel.zig index 6f3abda789..1f6882fa10 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -26,6 +26,7 @@ pub const EntityModel = struct { vao: ?graphics.VertexArray = null, indexCount: c_int, defaultTexture: ?main.graphics.Texture, + modelFile: []const u8, const Vertex = extern struct { pos: [3]f32, @@ -58,12 +59,14 @@ pub const EntityModel = struct { self.defaultTexture = null; self.vao = null; self.indexCount = 0; + const fileEnding = ".obj"; + self.modelFile = main.assets.readAsset(main.globalAllocator, assetFolder, "entityModels/models", self.id, fileEnding) orelse main.assets.readAsset(main.stackAllocator, assetFolder, "entityModels/models", "cubyz:missing", fileEnding) orelse unreachable; // get TexturePath { + self.texturePath = &.{}; var split = std.mem.splitScalar(u8, id, ':'); const mod = split.first(); - self.texturePath = &.{}; if (zon.get(?[]const u8, "texture", null)) |texture| { self.texturePath = std.fmt.allocPrint(main.globalAllocator.allocator, "{s}/{s}/entityModels/textures/{s}", .{assetFolder, mod, texture}) catch &.{}; std.fs.cwd().access(self.texturePath, .{}) catch { @@ -76,9 +79,13 @@ pub const EntityModel = struct { } fn generateGraphics(self: *EntityModel) void { self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); - const file = main.assets.entityModelFiles().get(self.id) orelse main.assets.entityModelFiles().get("cubyz:missing") orelse unreachable; - const quadInfos = main.models.Model.loadRawModelDataFromObj(main.stackAllocator, file); + defer { + // We don't need the modelFile in memory anymore, so why waste memory? + main.globalAllocator.free(self.modelFile); + self.modelFile = &.{}; + } + const quadInfos = main.models.Model.loadRawModelDataFromObj(main.stackAllocator, self.modelFile); defer main.stackAllocator.free(quadInfos); const vertices = main.stackAllocator.alloc(Vertex, quadInfos.len*4); defer main.stackAllocator.free(vertices); @@ -113,6 +120,7 @@ pub const EntityModel = struct { pub fn deinit(self: *EntityModel) void { main.globalAllocator.free(self.id); main.globalAllocator.free(self.texturePath); + main.globalAllocator.free(self.modelFile); if (self.defaultTexture) |defaultTexture| { defaultTexture.deinit(); } From 03cdfeb32b1ad882425394f7c5a7651701f15c5b Mon Sep 17 00:00:00 2001 From: till++ Date: Tue, 7 Apr 2026 12:34:53 +0200 Subject: [PATCH 43/83] fmt --- src/entityComponent/model.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig index 7e6b77854f..0201cb1d3e 100644 --- a/src/entityComponent/model.zig +++ b/src/entityComponent/model.zig @@ -87,17 +87,17 @@ pub const server = struct { } renderComponents.deinit(); } - pub fn loadFromData(entity: u32, reader: *utils.BinaryReader, version: u32) main.entity.EntityComponentLoadError!void { + pub fn loadFromData(entity: u32, reader: *utils.BinaryReader, version: u32) main.entity.EntityComponentLoadError!void { _ = version; const entityModel = reader.readInt(u32) catch return; const customTexturePath = reader.readSliceWithSize() catch return; try loadByIndex(entity, main.entityModel.EntityModelIndex{.index = entityModel}, if (customTexturePath.len == 0) null else customTexturePath); } - pub fn loadByID(entity: u32, entityModelID: []const u8, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { + pub fn loadByID(entity: u32, entityModelID: []const u8, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { try loadByIndex(entity, main.entityModel.getTypeById(entityModelID), customTexturePath); } - pub fn loadByIndex(entity: u32, entityModel: main.entityModel.EntityModelIndex, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { + pub fn loadByIndex(entity: u32, entityModel: main.entityModel.EntityModelIndex, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { if (renderComponents.get(entity)) |old| { old.deinit(); } @@ -105,7 +105,7 @@ pub const server = struct { .entity = entity, .customTexturePath = customTexturePath, .entityModel = entityModel, - }) catch return main.entity.EntityComponentLoadError.Memory; + }) catch return main.entity.EntityComponentLoadError.Memory; } pub fn unload(id: u32) void { _ = renderComponents.remove(id); From 84654eed19598bc5d6b2ce018e8b1496fddbf328 Mon Sep 17 00:00:00 2001 From: till++ Date: Tue, 7 Apr 2026 12:39:28 +0200 Subject: [PATCH 44/83] merge fixed; Quantum really needs to hire a second PR reviewer - he is the bottleneck --- src/entityComponent/model.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig index 0201cb1d3e..128c4de3bb 100644 --- a/src/entityComponent/model.zig +++ b/src/entityComponent/model.zig @@ -68,7 +68,8 @@ pub const server = struct { main.globalAllocator.free(path); } } - pub fn save(self: RenderComponent, writer: *utils.BinaryWriter) main.entity.ComponentSaveBehaviour { + pub fn save(self: RenderComponent, writer: *utils.BinaryWriter, audience: main.entity.AudienceInfo) main.entity.ComponentSaveBehaviour { + _ = audience; writer.writeInt(u32, self.entityModel.index); if (self.customTexturePath) |texutre| { writer.writeSliceWithSize(texutre); From 20740ca22b821884a67e6558859419660343f853 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 04:11:59 +0200 Subject: [PATCH 45/83] Quantums request changes for assets.zig --- src/assets.zig | 19 +++++++------------ src/client/entity_manager.zig | 6 +++++- src/entityModel.zig | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index 8ec2b5e377..be516af0c0 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -779,30 +779,25 @@ pub fn unloadAssets() void { // MARK: unloadAssets() } } -pub fn readAsset(allocator: NeverFailingAllocator, assetFolder: []const u8, subPath: []const u8, id: []const u8, fileEnding: []const u8) ?[]const u8 { +pub fn readAsset(allocator: NeverFailingAllocator, assetFolder: []const u8, subPath: []const u8, id: []const u8, fileEnding: []const u8) ![]const u8 { var split = std.mem.splitScalar(u8, id, ':'); const mod = split.first(); - const name = split.next() orelse return null; + const name = split.next() orelse unreachable; - var path = std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{assetFolder, mod, subPath, name, fileEnding}) catch &.{}; + var path = try std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{assetFolder, mod, subPath, name, fileEnding}); defer main.stackAllocator.free(path); std.fs.cwd().access(path, .{}) catch { main.stackAllocator.free(path); - path = std.fmt.allocPrint(main.stackAllocator.allocator, "assets/{s}/{s}/{s}{s}", .{mod, subPath, name, fileEnding}) catch &.{}; + path = try std.fmt.allocPrint(main.stackAllocator.allocator, "assets/{s}/{s}/{s}{s}", .{mod, subPath, name, fileEnding}); }; - const string = std.fs.cwd().readFileAlloc(path, allocator.allocator, .unlimited) catch |err| { + const data = std.fs.cwd().readFileAlloc(path, allocator.allocator, .unlimited) catch |err| { std.log.err("Could not open {s}/{s}{s}: {s}", .{subPath, name, fileEnding, @errorName(err)}); - return null; + return err; }; - return string; + return data; } pub fn worldPresets() *const Assets.ZonHashMap { return &common.worldPresets; } - -// TODO: Tempoary, will be removed in future ECS parts. -pub fn entityModelDescriptions() *const Assets.ZonHashMap { - return &common.entityModelDescriptions; -} diff --git a/src/client/entity_manager.zig b/src/client/entity_manager.zig index a5d83a4f82..07afc6d005 100644 --- a/src/client/entity_manager.zig +++ b/src/client/entity_manager.zig @@ -44,7 +44,11 @@ pub fn init() void { .{.attachments = &.{.alphaBlending}}, ); // TODO: This is Temporary, will be replace by future ECS parts. - model = .init("assets", "cubyz:snale", main.assets.entityModelDescriptions().get("cubyz:snale").?); + { + const zon: ZonElement = main.files.Dir.init(std.fs.cwd()).readToZon(main.stackAllocator, "assets/cubyz/entityModels/descriptions/snale.zig.zon") catch unreachable; + defer zon.deinit(main.stackAllocator); + model = .init("assets", "cubyz:snale", zon); + } } pub fn deinit() void { diff --git a/src/entityModel.zig b/src/entityModel.zig index 1f6882fa10..4422ca6504 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -60,7 +60,7 @@ pub const EntityModel = struct { self.vao = null; self.indexCount = 0; const fileEnding = ".obj"; - self.modelFile = main.assets.readAsset(main.globalAllocator, assetFolder, "entityModels/models", self.id, fileEnding) orelse main.assets.readAsset(main.stackAllocator, assetFolder, "entityModels/models", "cubyz:missing", fileEnding) orelse unreachable; + self.modelFile = main.assets.readAsset(main.globalAllocator, assetFolder, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, assetFolder, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; // get TexturePath { From 8bb00a0b01cddc934d75585479d32e87340f301a Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 05:06:43 +0200 Subject: [PATCH 46/83] use append and renamed functions --- src/entityModel.zig | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/entityModel.zig b/src/entityModel.zig index 4422ca6504..a02a47625c 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -77,7 +77,7 @@ pub const EntityModel = struct { } return self; } - fn generateGraphics(self: *EntityModel) void { + fn loadModelAndTexture(self: *EntityModel) void { self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); defer { @@ -111,7 +111,7 @@ pub const EntityModel = struct { } pub fn bind(self: *EntityModel) void { if (self.vao == null) { - self.generateGraphics(); + self.loadModelAndTexture(); } self.vao.?.bind(); self.defaultTexture.?.bindTo(0); @@ -146,8 +146,7 @@ pub var entityModels: main.ListUnmanaged(EntityModel) = .{}; pub fn register(assetFolder: []const u8, id: []const u8, zon: ZonElement) usize { const index = entityModels.items.len; - const entityModel = entityModels.addOne(main.worldArena); - entityModel.* = EntityModel.init(assetFolder, id, zon); + entityModels.append(main.worldArena, EntityModel.init(assetFolder, id, zon)); reverseIndices.put(main.worldArena.allocator, id, EntityModelIndex{.index = @truncate(index)}) catch unreachable; return index; } @@ -159,20 +158,7 @@ pub fn reset() void { reverseIndices = .{}; } -pub fn hasRegistered(id: []const u8) bool { - return reverseIndices.contains(id); -} - -pub fn getTypeById(id: []const u8) EntityModelIndex { - if (reverseIndices.get(id)) |result| { - return result; - } else { - std.log.err("Couldn't find entityModel {s}. Replacing it with cubyz:missing ...", .{id}); - return EntityModelIndex{.index = 0}; - } -} - -pub fn getTypeByIdOrNull(id: []const u8) ?EntityModelIndex { +pub fn getById(id: []const u8) ?EntityModelIndex { if (reverseIndices.get(id)) |result| { return result; } From b0246c4863c95e9276af7811dcec1698fab64280 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 05:44:53 +0200 Subject: [PATCH 47/83] most of Quantums changed for entityModel.zig --- src/assets.zig | 3 +++ src/client/entity_manager.zig | 2 +- src/entityModel.zig | 43 +++++++++++++++++++---------------- src/game.zig | 1 + 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index be516af0c0..88874a14bb 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -527,11 +527,14 @@ pub const Palette = struct { // MARK: Palette }; var loadedAssets: bool = false; +pub var folder: []const u8 = undefined; pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPalette: *Palette, toolPalette: *Palette, biomePalette: *Palette, entityComponentPalette: *Palette) !void { // MARK: loadWorldAssets() if (loadedAssets) return; // The assets already got loaded by the server. loadedAssets = true; + folder = main.worldArena.dupe(u8, assetFolder); + main.Tag.initTags(); const worldArena = main.stackAllocator.createArena(); diff --git a/src/client/entity_manager.zig b/src/client/entity_manager.zig index 07afc6d005..7bda541cc4 100644 --- a/src/client/entity_manager.zig +++ b/src/client/entity_manager.zig @@ -27,7 +27,7 @@ var uniforms: struct { contrast: c_int, ambientLight: c_int, } = undefined; -var model: main.entityModel.EntityModel = undefined; +pub var model: main.entityModel.EntityModel = undefined; var pipeline: graphics.Pipeline = undefined; // Entities are sometimes small and sometimes big. Therefor it would mean a lot of work to still use smooth lighting. Therefor the non-smooth shader is used for those. pub var entities: main.utils.VirtualList(main.client.Entity, 1 << 20) = undefined; pub var mutex: std.Thread.Mutex = .{}; diff --git a/src/entityModel.zig b/src/entityModel.zig index a02a47625c..81d287e550 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -26,7 +26,6 @@ pub const EntityModel = struct { vao: ?graphics.VertexArray = null, indexCount: c_int, defaultTexture: ?main.graphics.Texture, - modelFile: []const u8, const Vertex = extern struct { pos: [3]f32, @@ -59,8 +58,6 @@ pub const EntityModel = struct { self.defaultTexture = null; self.vao = null; self.indexCount = 0; - const fileEnding = ".obj"; - self.modelFile = main.assets.readAsset(main.globalAllocator, assetFolder, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, assetFolder, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; // get TexturePath { @@ -78,14 +75,15 @@ pub const EntityModel = struct { return self; } fn loadModelAndTexture(self: *EntityModel) void { + self.deinitModelAndTexture(); + + const fileEnding = ".obj"; + const file = main.assets.readAsset(main.globalAllocator, main.assets.folder, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, main.assets.folder, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; + defer main.globalAllocator.free(file); + self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); - defer { - // We don't need the modelFile in memory anymore, so why waste memory? - main.globalAllocator.free(self.modelFile); - self.modelFile = &.{}; - } - const quadInfos = main.models.Model.loadRawModelDataFromObj(main.stackAllocator, self.modelFile); + const quadInfos = main.models.Model.loadRawModelDataFromObj(main.stackAllocator, file); defer main.stackAllocator.free(quadInfos); const vertices = main.stackAllocator.alloc(Vertex, quadInfos.len*4); defer main.stackAllocator.free(vertices); @@ -109,24 +107,22 @@ pub const EntityModel = struct { self.vao = .init(Vertex, vertices, indices); self.indexCount = @intCast(indices.len); } - pub fn bind(self: *EntityModel) void { - if (self.vao == null) { - self.loadModelAndTexture(); + pub fn deinitModelAndTexture(self: *EntityModel) void { + if (self.defaultTexture) |defaultTexture| { + defaultTexture.deinit(); + } + if (self.vao) |vao| { + vao.deinit(); } + } + pub fn bind(self: *EntityModel) void { self.vao.?.bind(); self.defaultTexture.?.bindTo(0); } - pub fn deinit(self: *EntityModel) void { main.globalAllocator.free(self.id); main.globalAllocator.free(self.texturePath); - main.globalAllocator.free(self.modelFile); - if (self.defaultTexture) |defaultTexture| { - defaultTexture.deinit(); - } - if (self.vao) |vao| { - vao.deinit(); - } + self.deinitModelAndTexture(); } }; @@ -164,3 +160,10 @@ pub fn getById(id: []const u8) ?EntityModelIndex { } return null; } +pub fn loadModelAndTexture() void { + for (entityModels.items) |*value| { + value.loadModelAndTexture(); + } + // TODO: this will be removed in future ECS parts + main.client.entity_manager.model.loadModelAndTexture(); +} diff --git a/src/game.zig b/src/game.zig index 472cae7b70..b7dc2368ec 100644 --- a/src/game.zig +++ b/src/game.zig @@ -641,6 +641,7 @@ pub const World = struct { // MARK: World main.Window.setMouseGrabbed(true); main.blocks.meshes.generateTextureArray(); + main.entityModel.loadModelAndTexture(); main.particles.ParticleManager.generateTextureArray(); main.models.uploadModels(); } From 9de1ab16a61e8f3a489806cf8f11904ef2c615fe Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 06:34:15 +0200 Subject: [PATCH 48/83] add entity model palette --- src/assets.zig | 32 +++++++++++++++++++++++++------- src/game.zig | 6 +++++- src/migrations.zig | 7 +++++++ src/network/protocols.zig | 1 + src/server/world.zig | 8 +++++++- 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index 88874a14bb..c48f0bff18 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -39,6 +39,7 @@ pub const Assets = struct { particles: ZonHashMap, worldPresets: ZonHashMap, entityModelDescriptions: ZonHashMap, + entityModelMigrations: ZonHashMap, fn init() Assets { return .{ @@ -59,6 +60,7 @@ pub const Assets = struct { .particles = .{}, .worldPresets = .{}, .entityModelDescriptions = .{}, + .entityModelMigrations = .{}, }; } fn deinit(self: *Assets, allocator: NeverFailingAllocator) void { @@ -79,6 +81,7 @@ pub const Assets = struct { self.particles.deinit(allocator.allocator); self.worldPresets.deinit(allocator.allocator); self.entityModelDescriptions.deinit(allocator.allocator); + self.entityModelMigrations.deinit(allocator.allocator); } fn clone(self: Assets, allocator: NeverFailingAllocator) Assets { return .{ @@ -99,6 +102,7 @@ pub const Assets = struct { .particles = self.particles.clone(allocator.allocator) catch unreachable, .worldPresets = .{}, // Not accessible inside the world .entityModelDescriptions = self.entityModelDescriptions.clone(allocator.allocator) catch unreachable, + .entityModelMigrations = self.entityModelMigrations.clone(allocator.allocator) catch unreachable, }; } fn read(self: *Assets, allocator: NeverFailingAllocator, assetDir: main.files.Dir, assetPath: []const u8) void { @@ -118,7 +122,7 @@ pub const Assets = struct { addon.readAllModels(allocator, "models", ".obj", &self.blockModels); addon.readAllZon(allocator, "particles", true, &self.particles, null); addon.readAllZon(allocator, "world_presets", true, &self.worldPresets, null); - addon.readAllZon(allocator, "entityModels/descriptions", true, &self.entityModelDescriptions, null); + addon.readAllZon(allocator, "entityModels/descriptions", true, &self.entityModelDescriptions, &self.entityModelMigrations); } } fn log(self: *Assets, typ: enum { common, world }) void { @@ -529,7 +533,7 @@ pub const Palette = struct { // MARK: Palette var loadedAssets: bool = false; pub var folder: []const u8 = undefined; -pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPalette: *Palette, toolPalette: *Palette, biomePalette: *Palette, entityComponentPalette: *Palette) !void { // MARK: loadWorldAssets() +pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPalette: *Palette, toolPalette: *Palette, biomePalette: *Palette, entityModelPalette: *Palette, entityComponentPalette: *Palette) !void { // MARK: loadWorldAssets() if (loadedAssets) return; // The assets already got loaded by the server. loadedAssets = true; @@ -554,6 +558,9 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale migrations_zig.registerAll(.biome, &worldAssets.biomeMigrations); migrations_zig.apply(.biome, biomePalette); + migrations_zig.registerAll(.entityModel, &worldAssets.entityModelMigrations); + migrations_zig.apply(.entityModel, entityModelPalette); + migrations_zig.registerAll(.entityComponent, &worldAssets.entityComponentMigrations); migrations_zig.apply(.entityComponent, entityComponentPalette); @@ -565,16 +572,27 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale } } - // models (Entities): + // EntityModels: { - var modelIterator = worldAssets.entityModelDescriptions.iterator(); - while (modelIterator.next()) |entry| { - const id = entry.key_ptr.*; + // First blocks from the palette to enforce ID values. + for (entityModelPalette.palette.items) |stringId| { + std.log.debug("Registering entity model {s}", .{stringId}); + _ = main.entityModel.register(assetFolder, stringId, worldAssets.entityModelDescriptions.get(stringId) orelse .null); + } + // Then all the blocks that were missing in palette but are present in the game. + var entModelIterator = worldAssets.entityModelDescriptions.iterator(); + while (entModelIterator.next()) |entry| { + const stringId = entry.key_ptr.*; const zon = entry.value_ptr.*; + + if (main.entityModel.getById(stringId) != null) continue; + std.log.debug("Registering entity model {s}", .{entry.key_ptr.*}); - _ = main.entityModel.register(assetFolder, id, zon); + _ = main.entityModel.register(assetFolder, stringId, zon); + entityModelPalette.add(stringId); } } + if (!main.settings.launchConfig.headlessServer) blocks_zig.meshes.registerBlockBreakingAnimation(assetFolder); // Blocks: diff --git a/src/game.zig b/src/game.zig index b7dc2368ec..67890f4415 100644 --- a/src/game.zig +++ b/src/game.zig @@ -619,6 +619,7 @@ pub const World = struct { // MARK: World itemPalette: *assets.Palette = undefined, toolPalette: *assets.Palette = undefined, biomePalette: *assets.Palette = undefined, + entityModelPalette: *assets.Palette = undefined, entityComponentPalette: *assets.Palette = undefined, itemDrops: ClientItemDropManager = undefined, playerBiome: Atomic(*const main.server.terrain.biomes.Biome) = undefined, @@ -667,6 +668,7 @@ pub const World = struct { // MARK: World self.toolPalette.deinit(); self.biomePalette.deinit(); self.entityComponentPalette.deinit(); + self.entityModelPalette.deinit(); self.manager.deinit(); main.server.stop(); @@ -693,12 +695,14 @@ pub const World = struct { // MARK: World errdefer self.itemPalette.deinit(); self.toolPalette = try assets.Palette.init(main.globalAllocator, zon.getChild("toolPalette"), null); errdefer self.toolPalette.deinit(); + self.entityModelPalette = try assets.Palette.init(main.globalAllocator, zon.getChild("entityModelPalette"), null); + errdefer self.entityModelPalette.deinit(); self.entityComponentPalette = try assets.Palette.init(main.globalAllocator, zon.getChild("entityComponentPalette"), null); errdefer self.entityComponentPalette.deinit(); const path = std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/serverAssets", .{main.files.cubyzDirStr()}) catch unreachable; defer main.stackAllocator.free(path); - try assets.loadWorldAssets(path, self.blockPalette, self.itemPalette, self.toolPalette, self.biomePalette, self.entityComponentPalette); + try assets.loadWorldAssets(path, self.blockPalette, self.itemPalette, self.toolPalette, self.biomePalette, self.entityModelPalette, self.entityComponentPalette); Player.id = zon.get(u32, "player_id", std.math.maxInt(u32)); Player.inventory = ClientInventory.init(main.globalAllocator, Player.inventorySize, .serverShared, .{.playerInventory = Player.id}, .{}); try Player.loadFrom(zon.getChild("player")); diff --git a/src/migrations.zig b/src/migrations.zig index 6e70f671f2..7496eda4ff 100644 --- a/src/migrations.zig +++ b/src/migrations.zig @@ -8,12 +8,14 @@ const Assets = main.assets.Assets; var blockMigrations: std.StringHashMapUnmanaged([]const u8) = .{}; var itemMigrations: std.StringHashMapUnmanaged([]const u8) = .{}; var biomeMigrations: std.StringHashMapUnmanaged([]const u8) = .{}; +var entityModelMigrations: std.StringHashMapUnmanaged([]const u8) = .{}; var entityComponentMigrations: std.StringHashMapUnmanaged([]const u8) = .{}; const MigrationType = enum { block, item, biome, + entityModel, entityComponent, }; @@ -23,6 +25,7 @@ pub fn registerAll(comptime typ: MigrationType, migrations: *Assets.AddonNameToZ .block => &blockMigrations, .item => &itemMigrations, .biome => &biomeMigrations, + .entityModel => &entityModelMigrations, .entityComponent => &entityComponentMigrations, }; var migrationIterator = migrations.iterator(); @@ -91,6 +94,7 @@ pub fn applySingle(comptime typ: MigrationType, assetName: []const u8) []const u .block => blockMigrations, .item => itemMigrations, .biome => biomeMigrations, + .entityModel => entityModelMigrations, .entityComponent => entityComponentMigrations, }; @@ -104,6 +108,7 @@ pub fn apply(comptime typ: MigrationType, palette: *Palette) void { .block => blockMigrations, .item => itemMigrations, .biome => biomeMigrations, + .entityModel => entityModelMigrations, .entityComponent => entityComponentMigrations, }; std.log.info("Applying {} migrations to {s} palette", .{migrations.count(), @tagName(typ)}); @@ -119,4 +124,6 @@ pub fn reset() void { biomeMigrations = .{}; blockMigrations = .{}; itemMigrations = .{}; + entityModelMigrations = .{}; + entityComponentMigrations = .{}; } diff --git a/src/network/protocols.zig b/src/network/protocols.zig index 3300f2824e..82bed3d91d 100644 --- a/src/network/protocols.zig +++ b/src/network/protocols.zig @@ -242,6 +242,7 @@ pub const handShake = struct { // MARK: handShake zonObject.put("itemPalette", main.server.world.?.itemPalette.storeToZon(main.stackAllocator)); zonObject.put("toolPalette", main.server.world.?.toolPalette.storeToZon(main.stackAllocator)); zonObject.put("biomePalette", main.server.world.?.biomePalette.storeToZon(main.stackAllocator)); + zonObject.put("entityModelPalette", main.server.world.?.entityModelPalette.storeToZon(main.stackAllocator)); zonObject.put("entityComponentPalette", main.server.world.?.entityComponentPalette.storeToZon(main.stackAllocator)); const outData = zonObject.toStringEfficient(main.stackAllocator, &[1]u8{@intFromEnum(Connection.HandShakeState.serverData)}); diff --git a/src/server/world.zig b/src/server/world.zig index 74e868332c..be569b7815 100644 --- a/src/server/world.zig +++ b/src/server/world.zig @@ -426,6 +426,7 @@ pub const ServerWorld = struct { // MARK: ServerWorld itemPalette: *main.assets.Palette = undefined, toolPalette: *main.assets.Palette = undefined, biomePalette: *main.assets.Palette = undefined, + entityModelPalette: *main.assets.Palette = undefined, entityComponentPalette: *main.assets.Palette = undefined, chunkManager: ChunkManager = undefined, @@ -495,6 +496,9 @@ pub const ServerWorld = struct { // MARK: ServerWorld self.biomePalette = try loadPalette(arena, path, "biome_palette", null); errdefer self.biomePalette.deinit(); + self.entityModelPalette = try loadPalette(arena, path, "entity_model_palette", "cubyz:missing"); + errdefer self.entityModelPalette.deinit(); + self.entityComponentPalette = try loadPalette(arena, path, "entity_component_palette", null); errdefer self.entityComponentPalette.deinit(); @@ -504,12 +508,13 @@ pub const ServerWorld = struct { // MARK: ServerWorld try self.loadWorldConfig(arena, dir, worldData); try self.loadPlayerLoginInfo(dir); - try main.assets.loadWorldAssets(try std.fmt.allocPrint(arena.allocator, "{s}/saves/{s}/assets/", .{files.cubyzDirStr(), path}), self.blockPalette, self.itemPalette, self.toolPalette, self.biomePalette, self.entityComponentPalette); + try main.assets.loadWorldAssets(try std.fmt.allocPrint(arena.allocator, "{s}/saves/{s}/assets/", .{files.cubyzDirStr(), path}), self.blockPalette, self.itemPalette, self.toolPalette, self.biomePalette, self.entityModelPalette, self.entityComponentPalette); // Store the block palette now that everything is loaded. try dir.writeZon("palette.zig.zon", self.blockPalette.storeToZon(arena)); try dir.writeZon("item_palette.zig.zon", self.itemPalette.storeToZon(arena)); try dir.writeZon("tool_palette.zig.zon", self.toolPalette.storeToZon(arena)); try dir.writeZon("biome_palette.zig.zon", self.biomePalette.storeToZon(arena)); + try dir.writeZon("entity_model_palette.zig.zon", self.entityModelPalette.storeToZon(arena)); try dir.writeZon("entity_component_palette.zig.zon", self.entityComponentPalette.storeToZon(arena)); self.chunkManager = try ChunkManager.init(self, worldData.getChild("generatorSettings")); @@ -547,6 +552,7 @@ pub const ServerWorld = struct { // MARK: ServerWorld self.itemPalette.deinit(); self.toolPalette.deinit(); self.biomePalette.deinit(); + self.entityModelPalette.deinit(); self.entityComponentPalette.deinit(); main.globalAllocator.free(self.path); main.globalAllocator.free(self.name); From 6bd668029c5f7a6a54d919b0e286e6a47ac4b512 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 06:47:45 +0200 Subject: [PATCH 49/83] used worldArena --- src/client/entity_manager.zig | 12 ++++-------- src/entityModel.zig | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/client/entity_manager.zig b/src/client/entity_manager.zig index 7bda541cc4..d5594d22d6 100644 --- a/src/client/entity_manager.zig +++ b/src/client/entity_manager.zig @@ -27,7 +27,7 @@ var uniforms: struct { contrast: c_int, ambientLight: c_int, } = undefined; -pub var model: main.entityModel.EntityModel = undefined; + var pipeline: graphics.Pipeline = undefined; // Entities are sometimes small and sometimes big. Therefor it would mean a lot of work to still use smooth lighting. Therefor the non-smooth shader is used for those. pub var entities: main.utils.VirtualList(main.client.Entity, 1 << 20) = undefined; pub var mutex: std.Thread.Mutex = .{}; @@ -43,12 +43,6 @@ pub fn init() void { .{.depthTest = true}, .{.attachments = &.{.alphaBlending}}, ); - // TODO: This is Temporary, will be replace by future ECS parts. - { - const zon: ZonElement = main.files.Dir.init(std.fs.cwd()).readToZon(main.stackAllocator, "assets/cubyz/entityModels/descriptions/snale.zig.zon") catch unreachable; - defer zon.deinit(main.stackAllocator); - model = .init("assets", "cubyz:snale", zon); - } } pub fn deinit() void { @@ -57,7 +51,6 @@ pub fn deinit() void { } entities.deinit(); pipeline.deinit(); - model.deinit(); } pub fn clear() void { @@ -129,6 +122,9 @@ pub fn render(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { c.glUniform3fv(uniforms.ambientLight, 1, @ptrCast(&ambientLight)); c.glUniform1f(uniforms.contrast, 0.12); + // TODO: this will be removed in future ECS parts + const model = main.entityModel.getById("cubyz:cubert").?.get(); + for (entities.items()) |ent| { if (ent.id == game.Player.id) continue; // don't render local player diff --git a/src/entityModel.zig b/src/entityModel.zig index 81d287e550..eb3310ff17 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -53,7 +53,7 @@ pub const EntityModel = struct { pub fn init(assetFolder: []const u8, id: []const u8, zon: ZonElement) EntityModel { var self: EntityModel = undefined; - self.id = main.globalAllocator.dupe(u8, id); + self.id = main.worldArena.dupe(u8, id); self.height = zon.getChild("height").as(f32, 1); self.defaultTexture = null; self.vao = null; @@ -65,10 +65,10 @@ pub const EntityModel = struct { var split = std.mem.splitScalar(u8, id, ':'); const mod = split.first(); if (zon.get(?[]const u8, "texture", null)) |texture| { - self.texturePath = std.fmt.allocPrint(main.globalAllocator.allocator, "{s}/{s}/entityModels/textures/{s}", .{assetFolder, mod, texture}) catch &.{}; + self.texturePath = std.fmt.allocPrint(main.worldArena.allocator, "{s}/{s}/entityModels/textures/{s}", .{assetFolder, mod, texture}) catch &.{}; std.fs.cwd().access(self.texturePath, .{}) catch { - main.globalAllocator.free(self.texturePath); - self.texturePath = std.fmt.allocPrint(main.globalAllocator.allocator, "assets/{s}/entityModels/textures/{s}", .{mod, texture}) catch &.{}; + main.worldArena.free(self.texturePath); + self.texturePath = std.fmt.allocPrint(main.worldArena.allocator, "assets/{s}/entityModels/textures/{s}", .{mod, texture}) catch &.{}; }; } } @@ -120,8 +120,6 @@ pub const EntityModel = struct { self.defaultTexture.?.bindTo(0); } pub fn deinit(self: *EntityModel) void { - main.globalAllocator.free(self.id); - main.globalAllocator.free(self.texturePath); self.deinitModelAndTexture(); } }; @@ -164,6 +162,4 @@ pub fn loadModelAndTexture() void { for (entityModels.items) |*value| { value.loadModelAndTexture(); } - // TODO: this will be removed in future ECS parts - main.client.entity_manager.model.loadModelAndTexture(); } From b1d3059389d13a66a11cb97e13b2c5a3918eb1bf Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 07:06:32 +0200 Subject: [PATCH 50/83] forgot to remove temporary debug thing --- src/client/entity_manager.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/entity_manager.zig b/src/client/entity_manager.zig index d5594d22d6..25f42aa7b1 100644 --- a/src/client/entity_manager.zig +++ b/src/client/entity_manager.zig @@ -123,7 +123,7 @@ pub fn render(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { c.glUniform1f(uniforms.contrast, 0.12); // TODO: this will be removed in future ECS parts - const model = main.entityModel.getById("cubyz:cubert").?.get(); + const model = main.entityModel.getById("cubyz:snale").?.get(); for (entities.items()) |ent| { if (ent.id == game.Player.id) continue; // don't render local player From 09c4c261780786c689b8f0b99c5c14c962d84b2d Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 08:13:41 +0200 Subject: [PATCH 51/83] typo --- src/entityComponent/model.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig index 128c4de3bb..19d5bd9b39 100644 --- a/src/entityComponent/model.zig +++ b/src/entityComponent/model.zig @@ -71,8 +71,8 @@ pub const server = struct { pub fn save(self: RenderComponent, writer: *utils.BinaryWriter, audience: main.entity.AudienceInfo) main.entity.ComponentSaveBehaviour { _ = audience; writer.writeInt(u32, self.entityModel.index); - if (self.customTexturePath) |texutre| { - writer.writeSliceWithSize(texutre); + if (self.customTexturePath) |texture| { + writer.writeSliceWithSize(texture); } else writer.writeSliceWithSize(""); return .save; } From 5247f074e52dda20c223ce7545f50c7b1f04643f Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 08:43:04 +0200 Subject: [PATCH 52/83] missed a entryValue --- src/game.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game.zig b/src/game.zig index 67890f4415..7eb37ad572 100644 --- a/src/game.zig +++ b/src/game.zig @@ -695,7 +695,7 @@ pub const World = struct { // MARK: World errdefer self.itemPalette.deinit(); self.toolPalette = try assets.Palette.init(main.globalAllocator, zon.getChild("toolPalette"), null); errdefer self.toolPalette.deinit(); - self.entityModelPalette = try assets.Palette.init(main.globalAllocator, zon.getChild("entityModelPalette"), null); + self.entityModelPalette = try assets.Palette.init(main.globalAllocator, zon.getChild("entityModelPalette"), "cubyz:missing"); errdefer self.entityModelPalette.deinit(); self.entityComponentPalette = try assets.Palette.init(main.globalAllocator, zon.getChild("entityComponentPalette"), null); errdefer self.entityComponentPalette.deinit(); From 23156fe4720512cba003327f4342b0bb8c6f351e Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 09:20:34 +0200 Subject: [PATCH 53/83] fmt --- src/entityComponent/model.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig index 19d5bd9b39..5484eceb9f 100644 --- a/src/entityComponent/model.zig +++ b/src/entityComponent/model.zig @@ -96,7 +96,7 @@ pub const server = struct { try loadByIndex(entity, main.entityModel.EntityModelIndex{.index = entityModel}, if (customTexturePath.len == 0) null else customTexturePath); } pub fn loadByID(entity: u32, entityModelID: []const u8, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { - try loadByIndex(entity, main.entityModel.getTypeById(entityModelID), customTexturePath); + try loadByIndex(entity, main.entityModel.getById(entityModelID), customTexturePath); } pub fn loadByIndex(entity: u32, entityModel: main.entityModel.EntityModelIndex, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { if (renderComponents.get(entity)) |old| { From da2175f57aec8c75dfded71ffa451c198b03dd13 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 09:29:41 +0200 Subject: [PATCH 54/83] Wunka told me to use main.files --- src/assets.zig | 4 ++-- src/entityModel.zig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index 47d4feee26..faba471f81 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -816,12 +816,12 @@ pub fn readAsset(allocator: NeverFailingAllocator, assetFolder: []const u8, subP var path = try std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{assetFolder, mod, subPath, name, fileEnding}); defer main.stackAllocator.free(path); - std.fs.cwd().access(path, .{}) catch { + main.files.cubyzDir().dir.access(path, .{}) catch { main.stackAllocator.free(path); path = try std.fmt.allocPrint(main.stackAllocator.allocator, "assets/{s}/{s}/{s}{s}", .{mod, subPath, name, fileEnding}); }; - const data = std.fs.cwd().readFileAlloc(path, allocator.allocator, .unlimited) catch |err| { + const data = main.files.cubyzDir().dir.readFileAlloc(path, allocator.allocator, .unlimited) catch |err| { std.log.err("Could not open {s}/{s}{s}: {s}", .{subPath, name, fileEnding, @errorName(err)}); return err; }; diff --git a/src/entityModel.zig b/src/entityModel.zig index eb3310ff17..2354811653 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -66,7 +66,7 @@ pub const EntityModel = struct { const mod = split.first(); if (zon.get(?[]const u8, "texture", null)) |texture| { self.texturePath = std.fmt.allocPrint(main.worldArena.allocator, "{s}/{s}/entityModels/textures/{s}", .{assetFolder, mod, texture}) catch &.{}; - std.fs.cwd().access(self.texturePath, .{}) catch { + main.files.cubyzDir().dir.access(self.texturePath, .{}) catch { main.worldArena.free(self.texturePath); self.texturePath = std.fmt.allocPrint(main.worldArena.allocator, "assets/{s}/entityModels/textures/{s}", .{mod, texture}) catch &.{}; }; From 14a7e6f6545527d7b0e992cacf5bfb6cd7c7d217 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 09:38:00 +0200 Subject: [PATCH 55/83] fix crash --- src/assets.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index faba471f81..377ffc970c 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -814,14 +814,17 @@ pub fn readAsset(allocator: NeverFailingAllocator, assetFolder: []const u8, subP const mod = split.first(); const name = split.next() orelse unreachable; + std.log.info("{s}\n", .{assetFolder}); + + var path = try std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{assetFolder, mod, subPath, name, fileEnding}); defer main.stackAllocator.free(path); - main.files.cubyzDir().dir.access(path, .{}) catch { + if(!main.files.cwd().hasFile(path)) { main.stackAllocator.free(path); path = try std.fmt.allocPrint(main.stackAllocator.allocator, "assets/{s}/{s}/{s}{s}", .{mod, subPath, name, fileEnding}); - }; + } - const data = main.files.cubyzDir().dir.readFileAlloc(path, allocator.allocator, .unlimited) catch |err| { + const data = main.files.cwd().read(allocator,path) catch |err| { std.log.err("Could not open {s}/{s}{s}: {s}", .{subPath, name, fileEnding, @errorName(err)}); return err; }; From abe96400b830132e9745cf6c73a6e1440a250218 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 09:38:23 +0200 Subject: [PATCH 56/83] fmt --- src/assets.zig | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index 377ffc970c..21f7d752f8 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -814,17 +814,14 @@ pub fn readAsset(allocator: NeverFailingAllocator, assetFolder: []const u8, subP const mod = split.first(); const name = split.next() orelse unreachable; - std.log.info("{s}\n", .{assetFolder}); - - var path = try std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{assetFolder, mod, subPath, name, fileEnding}); defer main.stackAllocator.free(path); - if(!main.files.cwd().hasFile(path)) { + if (!main.files.cwd().hasFile(path)) { main.stackAllocator.free(path); path = try std.fmt.allocPrint(main.stackAllocator.allocator, "assets/{s}/{s}/{s}{s}", .{mod, subPath, name, fileEnding}); } - const data = main.files.cwd().read(allocator,path) catch |err| { + const data = main.files.cwd().read(allocator, path) catch |err| { std.log.err("Could not open {s}/{s}{s}: {s}", .{subPath, name, fileEnding, @errorName(err)}); return err; }; From 232b5817114a74c523cfd89bca0d1c7ec2607814 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 09:57:16 +0200 Subject: [PATCH 57/83] temporary loadfunction moved somewhere else --- src/client/entity_manager.zig | 9 +++++---- src/game.zig | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/client/entity_manager.zig b/src/client/entity_manager.zig index 25f42aa7b1..89519d6cf2 100644 --- a/src/client/entity_manager.zig +++ b/src/client/entity_manager.zig @@ -31,7 +31,7 @@ var uniforms: struct { var pipeline: graphics.Pipeline = undefined; // Entities are sometimes small and sometimes big. Therefor it would mean a lot of work to still use smooth lighting. Therefor the non-smooth shader is used for those. pub var entities: main.utils.VirtualList(main.client.Entity, 1 << 20) = undefined; pub var mutex: std.Thread.Mutex = .{}; - +var model: *main.entityModel.EntityModel = undefined; pub fn init() void { entities = .init(); pipeline = graphics.Pipeline.init( @@ -71,6 +71,10 @@ fn update() void { lastTime = time; } +// TODO: this will be removed in future ECS parts +pub fn initAfterWorld() void { + model = main.entityModel.getById("cubyz:snale").?.get(); +} pub fn renderNames(projMatrix: Mat4f, playerPos: Vec3d) void { mutex.lock(); defer mutex.unlock(); @@ -122,9 +126,6 @@ pub fn render(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d) void { c.glUniform3fv(uniforms.ambientLight, 1, @ptrCast(&ambientLight)); c.glUniform1f(uniforms.contrast, 0.12); - // TODO: this will be removed in future ECS parts - const model = main.entityModel.getById("cubyz:snale").?.get(); - for (entities.items()) |ent| { if (ent.id == game.Player.id) continue; // don't render local player diff --git a/src/game.zig b/src/game.zig index 4d43f213ee..c035e124ff 100644 --- a/src/game.zig +++ b/src/game.zig @@ -641,6 +641,7 @@ pub const World = struct { // MARK: World main.blocks.meshes.generateTextureArray(); main.entityModel.loadModelAndTexture(); + main.client.entity_manager.initAfterWorld(); main.particles.ParticleManager.generateTextureArray(); main.models.uploadModels(); } From 5ac7159d5f8e1809849eff1007cb08d1ffb4dad6 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 14:54:15 +0200 Subject: [PATCH 58/83] invalid boolean --- src/entityModel.zig | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/entityModel.zig b/src/entityModel.zig index 2354811653..2579114e46 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -22,6 +22,7 @@ pub const EntityModel = struct { height: f32, texturePath: []const u8, id: []const u8, + invalid: bool, vao: ?graphics.VertexArray = null, indexCount: c_int, @@ -58,6 +59,7 @@ pub const EntityModel = struct { self.defaultTexture = null; self.vao = null; self.indexCount = 0; + self.invalid = false; // get TexturePath { @@ -74,7 +76,7 @@ pub const EntityModel = struct { } return self; } - fn loadModelAndTexture(self: *EntityModel) void { + fn loadModelAndTexture(self: *EntityModel) !void { self.deinitModelAndTexture(); const fileEnding = ".obj"; @@ -127,8 +129,11 @@ pub const EntityModel = struct { pub const EntityModelIndex = struct { index: u32, pub fn get(self: EntityModelIndex) *EntityModel { - if (entityModels.items.len > self.index) - return &entityModels.items[self.index]; + if (entityModels.items.len > self.index) { + const rv = &entityModels.items[self.index]; + if (!rv.invalid) + return rv; + } // should always exist because of firstEntry in entityModelPalette std.debug.assert(entityModels.items.len > 0); return &entityModels.items[0]; @@ -160,6 +165,8 @@ pub fn getById(id: []const u8) ?EntityModelIndex { } pub fn loadModelAndTexture() void { for (entityModels.items) |*value| { - value.loadModelAndTexture(); + value.loadModelAndTexture() catch { + value.invalid = true; + }; } } From fa6ba843af1cf6e2679584a7792a8cef7963cf04 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 15:28:27 +0200 Subject: [PATCH 59/83] renamed invalid to isLoaded --- src/entityModel.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/entityModel.zig b/src/entityModel.zig index 2579114e46..6fee5b2357 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -22,8 +22,8 @@ pub const EntityModel = struct { height: f32, texturePath: []const u8, id: []const u8, - invalid: bool, + isLoaded: bool, vao: ?graphics.VertexArray = null, indexCount: c_int, defaultTexture: ?main.graphics.Texture, @@ -59,7 +59,7 @@ pub const EntityModel = struct { self.defaultTexture = null; self.vao = null; self.indexCount = 0; - self.invalid = false; + self.isLoaded = false; // get TexturePath { @@ -131,7 +131,7 @@ pub const EntityModelIndex = struct { pub fn get(self: EntityModelIndex) *EntityModel { if (entityModels.items.len > self.index) { const rv = &entityModels.items[self.index]; - if (!rv.invalid) + if (rv.isLoaded) return rv; } // should always exist because of firstEntry in entityModelPalette @@ -166,7 +166,9 @@ pub fn getById(id: []const u8) ?EntityModelIndex { pub fn loadModelAndTexture() void { for (entityModels.items) |*value| { value.loadModelAndTexture() catch { - value.invalid = true; + value.isLoaded = false; + continue; }; + value.isLoaded = true; } } From 3cd9f825a05f1a2b64951c9c5164b374f110019a Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 15:36:59 +0200 Subject: [PATCH 60/83] fmt --- src/entityModel.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/entityModel.zig b/src/entityModel.zig index 6fee5b2357..cfdec5d040 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -76,6 +76,7 @@ pub const EntityModel = struct { } return self; } + fn loadModelAndTexture(self: *EntityModel) !void { self.deinitModelAndTexture(); From aa4a56db4bcba653fc567f7cf1aad90685239db1 Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 15:39:07 +0200 Subject: [PATCH 61/83] fmt --- src/entityModel.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entityModel.zig b/src/entityModel.zig index cfdec5d040..b3baf87097 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -76,7 +76,7 @@ pub const EntityModel = struct { } return self; } - + fn loadModelAndTexture(self: *EntityModel) !void { self.deinitModelAndTexture(); From 66aa25ec6db9df507d8792a58e6e1e3104ba760d Mon Sep 17 00:00:00 2001 From: till++ Date: Fri, 10 Apr 2026 15:50:24 +0200 Subject: [PATCH 62/83] fmt --- src/entityComponent/model.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig index 5484eceb9f..3522aaebc2 100644 --- a/src/entityComponent/model.zig +++ b/src/entityComponent/model.zig @@ -96,7 +96,7 @@ pub const server = struct { try loadByIndex(entity, main.entityModel.EntityModelIndex{.index = entityModel}, if (customTexturePath.len == 0) null else customTexturePath); } pub fn loadByID(entity: u32, entityModelID: []const u8, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { - try loadByIndex(entity, main.entityModel.getById(entityModelID), customTexturePath); + try loadByIndex(entity, main.entityModel.getById(entityModelID) orelse main.entityModel.getById("cubyz:missing") orelse @panic("cubyz:missing is also missing. This isnt supposed to happen"), customTexturePath); } pub fn loadByIndex(entity: u32, entityModel: main.entityModel.EntityModelIndex, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { if (renderComponents.get(entity)) |old| { From 8f9b62420cd1dd41ffbf185d7ff7b2c0e75ed4ad Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 13:11:03 +0200 Subject: [PATCH 63/83] name it worldAssetFolder --- src/assets.zig | 4 ++-- src/entityModel.zig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index 21f7d752f8..1b54bd903f 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -536,13 +536,13 @@ pub const Palette = struct { // MARK: Palette }; var loadedAssets: bool = false; -pub var folder: []const u8 = undefined; +pub var worldAssetFolder: []const u8 = undefined; pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPalette: *Palette, toolPalette: *Palette, biomePalette: *Palette, entityModelPalette: *Palette, entityComponentPalette: *Palette) !void { // MARK: loadWorldAssets() if (loadedAssets) return; // The assets already got loaded by the server. loadedAssets = true; - folder = main.worldArena.dupe(u8, assetFolder); + worldAssetFolder = main.worldArena.dupe(u8, assetFolder); main.Tag.initTags(); diff --git a/src/entityModel.zig b/src/entityModel.zig index b3baf87097..6b18dd7e96 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -81,7 +81,7 @@ pub const EntityModel = struct { self.deinitModelAndTexture(); const fileEnding = ".obj"; - const file = main.assets.readAsset(main.globalAllocator, main.assets.folder, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, main.assets.folder, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; + const file = main.assets.readAsset(main.globalAllocator, main.assets.worldAssetFolder, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, main.assets.worldAssetFolder, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; defer main.globalAllocator.free(file); self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); From aae144cc3378441f7f4b3c249f161e08f6c4e18e Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 13:12:20 +0200 Subject: [PATCH 64/83] allocations can't fail --- src/assets.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index 1b54bd903f..bf13d84111 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -814,11 +814,11 @@ pub fn readAsset(allocator: NeverFailingAllocator, assetFolder: []const u8, subP const mod = split.first(); const name = split.next() orelse unreachable; - var path = try std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{assetFolder, mod, subPath, name, fileEnding}); + var path = std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{assetFolder, mod, subPath, name, fileEnding}) orelse unreachable; defer main.stackAllocator.free(path); if (!main.files.cwd().hasFile(path)) { main.stackAllocator.free(path); - path = try std.fmt.allocPrint(main.stackAllocator.allocator, "assets/{s}/{s}/{s}{s}", .{mod, subPath, name, fileEnding}); + path = std.fmt.allocPrint(main.stackAllocator.allocator, "assets/{s}/{s}/{s}{s}", .{mod, subPath, name, fileEnding}) orelse unreachable; } const data = main.files.cwd().read(allocator, path) catch |err| { From 6061302b633624e1d093044a544e317f3d636449 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 13:13:50 +0200 Subject: [PATCH 65/83] You are using mismatched allocators in both paths. --- src/entityModel.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/entityModel.zig b/src/entityModel.zig index 6b18dd7e96..da6feb8029 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -81,8 +81,8 @@ pub const EntityModel = struct { self.deinitModelAndTexture(); const fileEnding = ".obj"; - const file = main.assets.readAsset(main.globalAllocator, main.assets.worldAssetFolder, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, main.assets.worldAssetFolder, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; - defer main.globalAllocator.free(file); + const file = main.assets.readAsset(main.stackAllocator, main.assets.worldAssetFolder, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, main.assets.worldAssetFolder, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; + defer main.stackAllocator.free(file); self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); From ef98a78aef91740e57422591c34174511f3aed18 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 13:19:09 +0200 Subject: [PATCH 66/83] removed deinitModelAndTexture --- src/assets.zig | 4 ++-- src/entityModel.zig | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index bf13d84111..56832c04e9 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -814,11 +814,11 @@ pub fn readAsset(allocator: NeverFailingAllocator, assetFolder: []const u8, subP const mod = split.first(); const name = split.next() orelse unreachable; - var path = std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{assetFolder, mod, subPath, name, fileEnding}) orelse unreachable; + var path = std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{assetFolder, mod, subPath, name, fileEnding}) catch unreachable; defer main.stackAllocator.free(path); if (!main.files.cwd().hasFile(path)) { main.stackAllocator.free(path); - path = std.fmt.allocPrint(main.stackAllocator.allocator, "assets/{s}/{s}/{s}{s}", .{mod, subPath, name, fileEnding}) orelse unreachable; + path = std.fmt.allocPrint(main.stackAllocator.allocator, "assets/{s}/{s}/{s}{s}", .{mod, subPath, name, fileEnding}) catch unreachable; } const data = main.files.cwd().read(allocator, path) catch |err| { diff --git a/src/entityModel.zig b/src/entityModel.zig index da6feb8029..1df3196195 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -78,8 +78,6 @@ pub const EntityModel = struct { } fn loadModelAndTexture(self: *EntityModel) !void { - self.deinitModelAndTexture(); - const fileEnding = ".obj"; const file = main.assets.readAsset(main.stackAllocator, main.assets.worldAssetFolder, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, main.assets.worldAssetFolder, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; defer main.stackAllocator.free(file); @@ -110,7 +108,11 @@ pub const EntityModel = struct { self.vao = .init(Vertex, vertices, indices); self.indexCount = @intCast(indices.len); } - pub fn deinitModelAndTexture(self: *EntityModel) void { + pub fn bind(self: *EntityModel) void { + self.vao.?.bind(); + self.defaultTexture.?.bindTo(0); + } + pub fn deinit(self: *EntityModel) void { if (self.defaultTexture) |defaultTexture| { defaultTexture.deinit(); } @@ -118,13 +120,6 @@ pub const EntityModel = struct { vao.deinit(); } } - pub fn bind(self: *EntityModel) void { - self.vao.?.bind(); - self.defaultTexture.?.bindTo(0); - } - pub fn deinit(self: *EntityModel) void { - self.deinitModelAndTexture(); - } }; pub const EntityModelIndex = struct { From f17d3ebc2b76926b1c847cac0bca462be0888935 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 13:20:41 +0200 Subject: [PATCH 67/83] nitpicking --- src/entityModel.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/entityModel.zig b/src/entityModel.zig index 1df3196195..4d45ad694a 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -78,12 +78,12 @@ pub const EntityModel = struct { } fn loadModelAndTexture(self: *EntityModel) !void { + self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); + const fileEnding = ".obj"; const file = main.assets.readAsset(main.stackAllocator, main.assets.worldAssetFolder, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, main.assets.worldAssetFolder, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; defer main.stackAllocator.free(file); - self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); - const quadInfos = main.models.Model.loadRawModelDataFromObj(main.stackAllocator, file); defer main.stackAllocator.free(quadInfos); const vertices = main.stackAllocator.alloc(Vertex, quadInfos.len*4); From b253c93838c193137b645c9b6d772880b0fbbf2a Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 13:31:05 +0200 Subject: [PATCH 68/83] asserted here and the incorrect data (index < len) should be handled immediately where it's created. --- src/entityModel.zig | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/entityModel.zig b/src/entityModel.zig index 4d45ad694a..def9c8b0fe 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -125,11 +125,10 @@ pub const EntityModel = struct { pub const EntityModelIndex = struct { index: u32, pub fn get(self: EntityModelIndex) *EntityModel { - if (entityModels.items.len > self.index) { - const rv = &entityModels.items[self.index]; - if (rv.isLoaded) - return rv; - } + std.debug.assert(entityModels.items.len > self.index); + const rv = &entityModels.items[self.index]; + if (rv.isLoaded) + return rv; // should always exist because of firstEntry in entityModelPalette std.debug.assert(entityModels.items.len > 0); return &entityModels.items[0]; From b3b5fc8881a54ccbdaf23449eec2f3e09595155c Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 13:33:44 +0200 Subject: [PATCH 69/83] "loadModelsAndTexture" --- src/entityModel.zig | 2 +- src/game.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/entityModel.zig b/src/entityModel.zig index def9c8b0fe..38fc6bd10f 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -158,7 +158,7 @@ pub fn getById(id: []const u8) ?EntityModelIndex { } return null; } -pub fn loadModelAndTexture() void { +pub fn loadModelsAndTexture() void { for (entityModels.items) |*value| { value.loadModelAndTexture() catch { value.isLoaded = false; diff --git a/src/game.zig b/src/game.zig index c035e124ff..adb885f324 100644 --- a/src/game.zig +++ b/src/game.zig @@ -640,7 +640,7 @@ pub const World = struct { // MARK: World main.Window.setMouseGrabbed(true); main.blocks.meshes.generateTextureArray(); - main.entityModel.loadModelAndTexture(); + main.entityModel.loadModelsAndTexture(); main.client.entity_manager.initAfterWorld(); main.particles.ParticleManager.generateTextureArray(); main.models.uploadModels(); From 84caf1a8a23b0da12a6c16b0015603ed9dadd536 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 13:36:04 +0200 Subject: [PATCH 70/83] We know the per world asset folder locally, you can also make it private. --- src/assets.zig | 4 ++-- src/entityModel.zig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index 56832c04e9..451f849ed8 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -809,12 +809,12 @@ pub fn unloadAssets() void { // MARK: unloadAssets() } } -pub fn readAsset(allocator: NeverFailingAllocator, assetFolder: []const u8, subPath: []const u8, id: []const u8, fileEnding: []const u8) ![]const u8 { +pub fn readAsset(allocator: NeverFailingAllocator, subPath: []const u8, id: []const u8, fileEnding: []const u8) ![]const u8 { var split = std.mem.splitScalar(u8, id, ':'); const mod = split.first(); const name = split.next() orelse unreachable; - var path = std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{assetFolder, mod, subPath, name, fileEnding}) catch unreachable; + var path = std.fmt.allocPrint(main.stackAllocator.allocator, "{s}/{s}/{s}/{s}{s}", .{worldAssetFolder, mod, subPath, name, fileEnding}) catch unreachable; defer main.stackAllocator.free(path); if (!main.files.cwd().hasFile(path)) { main.stackAllocator.free(path); diff --git a/src/entityModel.zig b/src/entityModel.zig index 38fc6bd10f..c95ede1132 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -81,7 +81,7 @@ pub const EntityModel = struct { self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); const fileEnding = ".obj"; - const file = main.assets.readAsset(main.stackAllocator, main.assets.worldAssetFolder, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, main.assets.worldAssetFolder, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; + const file = main.assets.readAsset(main.stackAllocator, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; defer main.stackAllocator.free(file); const quadInfos = main.models.Model.loadRawModelDataFromObj(main.stackAllocator, file); From 677638f71ec354c8c5331cb3afc019b06d6a1443 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 13:40:32 +0200 Subject: [PATCH 71/83] Idea, that me and MNHS came up with. to declare the entityModel as failed if the model didnt load --- src/entityModel.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entityModel.zig b/src/entityModel.zig index c95ede1132..d38742fe50 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -81,7 +81,7 @@ pub const EntityModel = struct { self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); const fileEnding = ".obj"; - const file = main.assets.readAsset(main.stackAllocator, "entityModels/models", self.id, fileEnding) catch main.assets.readAsset(main.stackAllocator, "entityModels/models", "cubyz:missing", fileEnding) catch unreachable; + const file = try main.assets.readAsset(main.stackAllocator, "entityModels/models", self.id, fileEnding); defer main.stackAllocator.free(file); const quadInfos = main.models.Model.loadRawModelDataFromObj(main.stackAllocator, file); From 22ea1a58acd7fa5887ac1e4cadd32c39936ca2bf Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 13:49:17 +0200 Subject: [PATCH 72/83] revert change into descriptions --- src/assets.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets.zig b/src/assets.zig index 451f849ed8..b97b1ba662 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -127,7 +127,7 @@ pub const Assets = struct { addon.readAllModels(allocator, "models", ".obj", &self.blockModels); addon.readAllZon(allocator, "particles", true, &self.particles, null); addon.readAllZon(allocator, "world_presets", true, &self.worldPresets, null); - addon.readAllZon(allocator, "entityModels/descriptions", true, &self.entityModelDescriptions, &self.entityModelMigrations); + addon.readAllZon(allocator, "entityModels", true, &self.entityModelDescriptions, &self.entityModelMigrations); } } fn log(self: *Assets, typ: enum { common, world }) void { From a7caab8d8403b9a019b2a001afa16780757f3fb1 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 13:49:55 +0200 Subject: [PATCH 73/83] asset removed descriptions folder --- assets/cubyz/entityModels/{descriptions => }/cubert.zig.zon | 0 assets/cubyz/entityModels/{descriptions => }/missing.zig.zon | 0 assets/cubyz/entityModels/{descriptions => }/moffalo.zig.zon | 0 assets/cubyz/entityModels/{descriptions => }/snail.zig.zon | 0 assets/cubyz/entityModels/{descriptions => }/snale.zig.zon | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename assets/cubyz/entityModels/{descriptions => }/cubert.zig.zon (100%) rename assets/cubyz/entityModels/{descriptions => }/missing.zig.zon (100%) rename assets/cubyz/entityModels/{descriptions => }/moffalo.zig.zon (100%) rename assets/cubyz/entityModels/{descriptions => }/snail.zig.zon (100%) rename assets/cubyz/entityModels/{descriptions => }/snale.zig.zon (100%) diff --git a/assets/cubyz/entityModels/descriptions/cubert.zig.zon b/assets/cubyz/entityModels/cubert.zig.zon similarity index 100% rename from assets/cubyz/entityModels/descriptions/cubert.zig.zon rename to assets/cubyz/entityModels/cubert.zig.zon diff --git a/assets/cubyz/entityModels/descriptions/missing.zig.zon b/assets/cubyz/entityModels/missing.zig.zon similarity index 100% rename from assets/cubyz/entityModels/descriptions/missing.zig.zon rename to assets/cubyz/entityModels/missing.zig.zon diff --git a/assets/cubyz/entityModels/descriptions/moffalo.zig.zon b/assets/cubyz/entityModels/moffalo.zig.zon similarity index 100% rename from assets/cubyz/entityModels/descriptions/moffalo.zig.zon rename to assets/cubyz/entityModels/moffalo.zig.zon diff --git a/assets/cubyz/entityModels/descriptions/snail.zig.zon b/assets/cubyz/entityModels/snail.zig.zon similarity index 100% rename from assets/cubyz/entityModels/descriptions/snail.zig.zon rename to assets/cubyz/entityModels/snail.zig.zon diff --git a/assets/cubyz/entityModels/descriptions/snale.zig.zon b/assets/cubyz/entityModels/snale.zig.zon similarity index 100% rename from assets/cubyz/entityModels/descriptions/snale.zig.zon rename to assets/cubyz/entityModels/snale.zig.zon From ccd46507c930a8282b9a92a00371cb0ddb5c710a Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 14:08:56 +0200 Subject: [PATCH 74/83] reverted removing "model" attr from entityModel --- assets/cubyz/entityModels/cubert.zig.zon | 3 ++- assets/cubyz/entityModels/missing.zig.zon | 3 ++- assets/cubyz/entityModels/moffalo.zig.zon | 3 ++- assets/cubyz/entityModels/snail.zig.zon | 3 ++- assets/cubyz/entityModels/snale.zig.zon | 3 ++- src/assets.zig | 14 ++++++------ src/entityModel.zig | 26 ++++++++++++++--------- 7 files changed, 33 insertions(+), 22 deletions(-) diff --git a/assets/cubyz/entityModels/cubert.zig.zon b/assets/cubyz/entityModels/cubert.zig.zon index 1afc8f9093..e09d106a25 100644 --- a/assets/cubyz/entityModels/cubert.zig.zon +++ b/assets/cubyz/entityModels/cubert.zig.zon @@ -1,4 +1,5 @@ .{ - .texture = "cubert.png", + .model = "cubyz:cubert", + .defaultTexture = "cubert.png", .height = 2, } diff --git a/assets/cubyz/entityModels/missing.zig.zon b/assets/cubyz/entityModels/missing.zig.zon index f9d20773d6..e3b17e3ba5 100644 --- a/assets/cubyz/entityModels/missing.zig.zon +++ b/assets/cubyz/entityModels/missing.zig.zon @@ -1,4 +1,5 @@ .{ - .texture = "missing.png", + .model = "cubyz:missing", + .defaultTexture = "missing.png", .height = 1, } diff --git a/assets/cubyz/entityModels/moffalo.zig.zon b/assets/cubyz/entityModels/moffalo.zig.zon index aa866b9774..2cc833c7f6 100644 --- a/assets/cubyz/entityModels/moffalo.zig.zon +++ b/assets/cubyz/entityModels/moffalo.zig.zon @@ -1,4 +1,5 @@ .{ - .texture = "moffalo.png", + .model = "cubyz:moffalo", + .defaultTexture = "moffalo.png", .height = 1.8, } diff --git a/assets/cubyz/entityModels/snail.zig.zon b/assets/cubyz/entityModels/snail.zig.zon index e7a86ad6dc..1ca0298404 100644 --- a/assets/cubyz/entityModels/snail.zig.zon +++ b/assets/cubyz/entityModels/snail.zig.zon @@ -1,4 +1,5 @@ .{ - .texture = "snail.png", + .model = "cubyz:snail", + .defaultTexture = "snail.png", .height = 1, } diff --git a/assets/cubyz/entityModels/snale.zig.zon b/assets/cubyz/entityModels/snale.zig.zon index 0c9d604594..5974a4fb90 100644 --- a/assets/cubyz/entityModels/snale.zig.zon +++ b/assets/cubyz/entityModels/snale.zig.zon @@ -1,4 +1,5 @@ .{ - .texture = "snale.png", + .model = "cubyz:snale", + .defaultTexture = "snale.png", .height = 2, } diff --git a/src/assets.zig b/src/assets.zig index b97b1ba662..d24222eaeb 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -580,21 +580,21 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale // EntityModels: { // First blocks from the palette to enforce ID values. - for (entityModelPalette.palette.items) |stringId| { - std.log.debug("Registering entity model {s}", .{stringId}); - _ = main.entityModel.register(assetFolder, stringId, worldAssets.entityModelDescriptions.get(stringId) orelse .null); + for (entityModelPalette.palette.items) |entityModelId| { + std.log.debug("Registering entity model {s}", .{entityModelId}); + _ = main.entityModel.register(assetFolder, entityModelId, worldAssets.entityModelDescriptions.get(entityModelId) orelse .null); } // Then all the blocks that were missing in palette but are present in the game. var entModelIterator = worldAssets.entityModelDescriptions.iterator(); while (entModelIterator.next()) |entry| { - const stringId = entry.key_ptr.*; + const entityModelId = entry.key_ptr.*; const zon = entry.value_ptr.*; - if (main.entityModel.getById(stringId) != null) continue; + if (main.entityModel.getById(entityModelId) != null) continue; std.log.debug("Registering entity model {s}", .{entry.key_ptr.*}); - _ = main.entityModel.register(assetFolder, stringId, zon); - entityModelPalette.add(stringId); + _ = main.entityModel.register(assetFolder, entityModelId, zon); + entityModelPalette.add(entityModelId); } } diff --git a/src/entityModel.zig b/src/entityModel.zig index d38742fe50..029339e3a0 100644 --- a/src/entityModel.zig +++ b/src/entityModel.zig @@ -21,7 +21,7 @@ const BinaryReader = main.utils.BinaryReader; pub const EntityModel = struct { height: f32, texturePath: []const u8, - id: []const u8, + modelId: ?[]const u8, isLoaded: bool, vao: ?graphics.VertexArray = null, @@ -52,21 +52,25 @@ pub const EntityModel = struct { }; }; - pub fn init(assetFolder: []const u8, id: []const u8, zon: ZonElement) EntityModel { + pub fn init(assetFolder: []const u8, entityModelId: []const u8, zon: ZonElement) EntityModel { var self: EntityModel = undefined; - self.id = main.worldArena.dupe(u8, id); + self.isLoaded = false; + if (zon.get(?[]const u8, "model", null)) |modelId| { + self.modelId = main.worldArena.dupe(u8, modelId); + } else { + self.modelId = null; + } self.height = zon.getChild("height").as(f32, 1); self.defaultTexture = null; self.vao = null; self.indexCount = 0; - self.isLoaded = false; // get TexturePath { self.texturePath = &.{}; - var split = std.mem.splitScalar(u8, id, ':'); + var split = std.mem.splitScalar(u8, entityModelId, ':'); const mod = split.first(); - if (zon.get(?[]const u8, "texture", null)) |texture| { + if (zon.get(?[]const u8, "defaultTexture", null)) |texture| { self.texturePath = std.fmt.allocPrint(main.worldArena.allocator, "{s}/{s}/entityModels/textures/{s}", .{assetFolder, mod, texture}) catch &.{}; main.files.cubyzDir().dir.access(self.texturePath, .{}) catch { main.worldArena.free(self.texturePath); @@ -79,9 +83,11 @@ pub const EntityModel = struct { fn loadModelAndTexture(self: *EntityModel) !void { self.defaultTexture = main.graphics.Texture.initFromFile(self.texturePath); + if (self.modelId == null) + return error.NoModelSpecified; const fileEnding = ".obj"; - const file = try main.assets.readAsset(main.stackAllocator, "entityModels/models", self.id, fileEnding); + const file = try main.assets.readAsset(main.stackAllocator, "entityModels/models", self.modelId.?, fileEnding); defer main.stackAllocator.free(file); const quadInfos = main.models.Model.loadRawModelDataFromObj(main.stackAllocator, file); @@ -138,10 +144,10 @@ pub const EntityModelIndex = struct { pub var reverseIndices: std.StringHashMapUnmanaged(EntityModelIndex) = .{}; pub var entityModels: main.ListUnmanaged(EntityModel) = .{}; -pub fn register(assetFolder: []const u8, id: []const u8, zon: ZonElement) usize { +pub fn register(assetFolder: []const u8, entityModelId: []const u8, zon: ZonElement) usize { const index = entityModels.items.len; - entityModels.append(main.worldArena, EntityModel.init(assetFolder, id, zon)); - reverseIndices.put(main.worldArena.allocator, id, EntityModelIndex{.index = @truncate(index)}) catch unreachable; + entityModels.append(main.worldArena, EntityModel.init(assetFolder, entityModelId, zon)); + reverseIndices.put(main.worldArena.allocator, entityModelId, EntityModelIndex{.index = @truncate(index)}) catch unreachable; return index; } pub fn reset() void { From 2e2a126ff20f1576a3f3c6ac8d24829e7551f94c Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 16:56:00 +0200 Subject: [PATCH 75/83] playerEntityModels as worldsetting --- src/server/server.zig | 4 ++++ src/server/world.zig | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/server/server.zig b/src/server/server.zig index 87cb996fdb..764250b6bc 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -249,6 +249,10 @@ pub const User = struct { // MARK: User self.id = freeId; freeId += 1; + if (world.?.playerEntityModels.items.len != 0) { + const defaultModel = world.?.playerEntityModels.items[main.random.nextInt(u32, &main.seed)%world.?.playerEntityModels.items.len]; + main.entity.components.@"cubyz:model".server.loadByID(self.id, defaultModel, null) catch unreachable; + } world.?.loadPlayer(self) catch { std.log.err("Error while loading player data of {s}. Discarding data.", .{self.name}); }; diff --git a/src/server/world.zig b/src/server/world.zig index be569b7815..6039ea5a06 100644 --- a/src/server/world.zig +++ b/src/server/world.zig @@ -454,6 +454,8 @@ pub const ServerWorld = struct { // MARK: ServerWorld biomeChecksum: i64 = 0, + playerEntityModels: main.ListUnmanaged([]const u8), + const ChunkUpdateRequest = struct { ch: *ServerChunk, milliTimeStamp: i64, @@ -474,6 +476,7 @@ pub const ServerWorld = struct { // MARK: ServerWorld .path = main.globalAllocator.dupe(u8, path), .chunkUpdateQueue = .init(main.globalAllocator, 256), .regionUpdateQueue = .init(main.globalAllocator, 256), + .playerEntityModels = .{}, }; self.itemDropManager.init(main.globalAllocator, self); errdefer self.itemDropManager.deinit(); @@ -520,6 +523,13 @@ pub const ServerWorld = struct { // MARK: ServerWorld self.chunkManager = try ChunkManager.init(self, worldData.getChild("generatorSettings")); errdefer self.chunkManager.deinit(); + for (self.playerEntityModels.items) |entityModel| { + if (main.entityModel.getById(entityModel) == null) { + std.log.err("EntityModel {s} is not available.", .{entityModel}); + continue; + } + } + return self; } @@ -546,6 +556,10 @@ pub const ServerWorld = struct { // MARK: ServerWorld updateRequest.region.decreaseRefCount(); } self.regionUpdateQueue.deinit(); + for (self.playerEntityModels.items) |value| { + main.globalAllocator.free(value); + } + self.playerEntityModels.deinit(main.globalAllocator); self.chunkManager.deinit(); self.itemDropManager.deinit(); self.blockPalette.deinit(); @@ -632,6 +646,26 @@ pub const ServerWorld = struct { // MARK: ServerWorld self.biomeChecksum = worldData.get(i64, "biomeChecksum", 0); self.name = main.globalAllocator.dupe(u8, worldData.get([]const u8, "name", self.path)); self.tickSpeed = .init(worldData.get(u32, "tickSpeed", 12)); + + // playerEntityModel + if (worldData.getChildOrNull("playerEntityModels")) |playerEntityModels| { + if (playerEntityModels != .array) { + std.log.err("playerEntityModels in world.zig.zon must be an Array.", .{}); + } else { + for (playerEntityModels.array.items) |value| { + const entityModel = value.as(?[]const u8, null) orelse { + std.log.err("playerEntityModels in world.zig.zon must be an Array of strings.", .{}); + continue; + }; + self.playerEntityModels.append(main.globalAllocator, main.globalAllocator.dupe(u8, entityModel)); + } + } + } + if (self.playerEntityModels.items.len == 0) { + for ([_][]const u8{"cubyz:snale", "cubyz:cubert"}) |entityModel| { + self.playerEntityModels.append(main.globalAllocator, main.globalAllocator.dupe(u8, entityModel)); + } + } } pub fn saveWorldConfig(self: *ServerWorld) !void { @@ -648,6 +682,12 @@ pub const ServerWorld = struct { // MARK: ServerWorld worldData.put("lastUsedTime", (try std.Io.Clock.Timestamp.now(main.io, .real)).raw.toMilliseconds()); worldData.put("tickSpeed", self.tickSpeed.load(.monotonic)); + const playerEntityModels = ZonElement.initArray(main.stackAllocator); + for (self.playerEntityModels.items) |entityModelId| { + playerEntityModels.append(entityModelId); + } + worldData.put("playerEntityModels", playerEntityModels); + try files.cubyzDir().writeZon(path, worldData); } From 6f21573b1952f8ec8e81f21a53e115d86b7ef333 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 17:33:28 +0200 Subject: [PATCH 76/83] merge artefact --- src/entityComponent/model.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig index 3522aaebc2..cf3dce2120 100644 --- a/src/entityComponent/model.zig +++ b/src/entityComponent/model.zig @@ -106,7 +106,7 @@ pub const server = struct { .entity = entity, .customTexturePath = customTexturePath, .entityModel = entityModel, - }) catch return main.entity.EntityComponentLoadError.Memory; + }) catch unreachable; } pub fn unload(id: u32) void { _ = renderComponents.remove(id); From 46b2697fe681fbc04ba52b4fad2dc8b7ae4f473a Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 19:36:51 +0200 Subject: [PATCH 77/83] reverted chages --- src/entity.zig | 4 ++ src/entityComponent/model.zig | 73 ++++++++++++++++------------------- src/server/server.zig | 2 +- 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/entity.zig b/src/entity.zig index 621ddb1dfd..af70866435 100644 --- a/src/entity.zig +++ b/src/entity.zig @@ -24,6 +24,10 @@ pub const EntityComponentLoadError = error{ UnknownComponentId, }; // Analogous to Protocols. +pub const Entity = enum(u32) { + noValue = std.math.maxInt(u32), + _, +}; pub const EntityComponentId = u32; const EntityComponentVTable = struct { serverLoad: *const fn (entityId: u32, reader: *main.utils.BinaryReader, version: u32) EntityComponentLoadError!void, diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig index cf3dce2120..d6b3b132ff 100644 --- a/src/entityComponent/model.zig +++ b/src/entityComponent/model.zig @@ -28,31 +28,33 @@ pub const client = struct { entityModel: main.entityModel.EntityModelIndex, // model customTexture: ?main.graphics.Texture, // for custom textures. i.e Skins }; - pub var renderComponents: std.AutoHashMap(u32, RenderComponent) = undefined; + pub var renderComponents: main.utils.SparseSet(RenderComponent, main.entity.Entity) = undefined; pub fn init() void { - renderComponents = .init(main.globalAllocator.allocator); + renderComponents = .{}; } pub fn deinit() void { - renderComponents.deinit(); + renderComponents.deinit(main.globalAllocator); } pub fn clear() void { - renderComponents.deinit(); - renderComponents = .init(main.globalAllocator.allocator); + renderComponents.deinit(main.globalAllocator); + renderComponents = .{}; } - pub fn load(id: u32, reader: *utils.BinaryReader, version: u32) main.entity.EntityComponentLoadError!void { + pub fn load(entity: u32, reader: *utils.BinaryReader, version: u32) main.entity.EntityComponentLoadError!void { _ = version; const entityModel = reader.readInt(u32) catch return; const customTexture: ?main.graphics.Texture = null; - renderComponents.put(id, RenderComponent{ - .entity = id, + renderComponents.set(main.globalAllocator, @enumFromInt(entity), RenderComponent{ + .entity = entity, .customTexture = customTexture, .entityModel = main.entityModel.EntityModelIndex{.index = entityModel}, - }) catch unreachable; + }); } - pub fn unload(id: u32) void { - _ = renderComponents.remove(id); + pub fn unload(entity: u32) void { + renderComponents.remove(@enumFromInt(entity)) catch { + std.log.err("entity {} couldn't be unloaded", .{entity}); + }; } }; @@ -62,62 +64,55 @@ pub const server = struct { pub const RenderComponent = struct { entity: u32, // entity entityModel: main.entityModel.EntityModelIndex, // model - customTexturePath: ?[]const u8, // customTexture fn deinit(self: RenderComponent) void { - if (self.customTexturePath) |path| { - main.globalAllocator.free(path); - } + _ = self; } pub fn save(self: RenderComponent, writer: *utils.BinaryWriter, audience: main.entity.AudienceInfo) main.entity.ComponentSaveBehaviour { _ = audience; writer.writeInt(u32, self.entityModel.index); - if (self.customTexturePath) |texture| { - writer.writeSliceWithSize(texture); - } else writer.writeSliceWithSize(""); return .save; } }; - var renderComponents: std.AutoHashMap(u32, RenderComponent) = undefined; + var renderComponents: main.utils.SparseSet(RenderComponent, main.entity.Entity) = undefined; pub fn init() void { - renderComponents = .init(main.globalAllocator.allocator); + renderComponents = .{}; } pub fn deinit() void { - var it = renderComponents.valueIterator(); - while (it.next()) |component| { + for (renderComponents.dense.items) |*component| { component.deinit(); } - renderComponents.deinit(); + renderComponents.deinit(main.globalAllocator); } pub fn loadFromData(entity: u32, reader: *utils.BinaryReader, version: u32) main.entity.EntityComponentLoadError!void { _ = version; const entityModel = reader.readInt(u32) catch return; - const customTexturePath = reader.readSliceWithSize() catch return; - try loadByIndex(entity, main.entityModel.EntityModelIndex{.index = entityModel}, if (customTexturePath.len == 0) null else customTexturePath); + try loadByIndex(entity, main.entityModel.EntityModelIndex{.index = entityModel}); } - pub fn loadByID(entity: u32, entityModelID: []const u8, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { - try loadByIndex(entity, main.entityModel.getById(entityModelID) orelse main.entityModel.getById("cubyz:missing") orelse @panic("cubyz:missing is also missing. This isnt supposed to happen"), customTexturePath); + pub fn loadByID(entity: u32, entityModelID: []const u8) main.entity.EntityComponentLoadError!void { + try loadByIndex(entity, main.entityModel.getById(entityModelID) orelse main.entityModel.default()); } - pub fn loadByIndex(entity: u32, entityModel: main.entityModel.EntityModelIndex, customTexturePath: ?[]const u8) main.entity.EntityComponentLoadError!void { - if (renderComponents.get(entity)) |old| { + pub fn loadByIndex(entity: u32, entityModel: main.entityModel.EntityModelIndex) main.entity.EntityComponentLoadError!void { + if (renderComponents.get(@enumFromInt(entity))) |old| { old.deinit(); } - renderComponents.put(entity, RenderComponent{ + renderComponents.set(main.globalAllocator, @enumFromInt(entity), RenderComponent{ .entity = entity, - .customTexturePath = customTexturePath, .entityModel = entityModel, - }) catch unreachable; + }); } - pub fn unload(id: u32) void { - _ = renderComponents.remove(id); + pub fn unload(entity: u32) void { + renderComponents.remove(@enumFromInt(entity)) catch { + std.log.err("entity {} couldn't be unloaded", .{entity}); + }; } - pub fn put(id: u32, renderComponent: RenderComponent) void { - if (renderComponents.get(id)) |entry| { + pub fn put(entity: u32, renderComponent: RenderComponent) void { + if (renderComponents.get(@enumFromInt(entity))) |entry| { entry.deinit(); } - renderComponents.put(id, renderComponent) catch unreachable; + renderComponents.set(main.globalAllocator, @enumFromInt(entity), renderComponent) catch unreachable; } - pub fn get(id: u32) ?RenderComponent { - return renderComponents.get(id); + pub fn get(entity: u32) ?*RenderComponent { + return renderComponents.get(@enumFromInt(entity)); } }; diff --git a/src/server/server.zig b/src/server/server.zig index 764250b6bc..79634edcbc 100644 --- a/src/server/server.zig +++ b/src/server/server.zig @@ -251,7 +251,7 @@ pub const User = struct { // MARK: User if (world.?.playerEntityModels.items.len != 0) { const defaultModel = world.?.playerEntityModels.items[main.random.nextInt(u32, &main.seed)%world.?.playerEntityModels.items.len]; - main.entity.components.@"cubyz:model".server.loadByID(self.id, defaultModel, null) catch unreachable; + main.entity.components.@"cubyz:model".server.loadByID(self.id, defaultModel) catch unreachable; } world.?.loadPlayer(self) catch { std.log.err("Error while loading player data of {s}. Discarding data.", .{self.name}); From a43766bf17ce3bbe71dfab4758684e01af478d56 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 20:02:05 +0200 Subject: [PATCH 78/83] revert changes 2 --- src/entityComponent/model.zig | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig index d6b3b132ff..9bab73051a 100644 --- a/src/entityComponent/model.zig +++ b/src/entityComponent/model.zig @@ -26,7 +26,6 @@ pub const client = struct { const RenderComponent = struct { entity: u32, // entity entityModel: main.entityModel.EntityModelIndex, // model - customTexture: ?main.graphics.Texture, // for custom textures. i.e Skins }; pub var renderComponents: main.utils.SparseSet(RenderComponent, main.entity.Entity) = undefined; @@ -43,13 +42,14 @@ pub const client = struct { pub fn load(entity: u32, reader: *utils.BinaryReader, version: u32) main.entity.EntityComponentLoadError!void { _ = version; const entityModel = reader.readInt(u32) catch return; - const customTexture: ?main.graphics.Texture = null; - renderComponents.set(main.globalAllocator, @enumFromInt(entity), RenderComponent{ + if (!renderComponents.contains(@enumFromInt(entity))) { + _ = renderComponents.add(main.globalAllocator, @enumFromInt(entity)); + } + renderComponents.get(@enumFromInt(entity)).?.* = RenderComponent{ .entity = entity, - .customTexture = customTexture, .entityModel = main.entityModel.EntityModelIndex{.index = entityModel}, - }); + }; } pub fn unload(entity: u32) void { renderComponents.remove(@enumFromInt(entity)) catch { @@ -64,9 +64,6 @@ pub const server = struct { pub const RenderComponent = struct { entity: u32, // entity entityModel: main.entityModel.EntityModelIndex, // model - fn deinit(self: RenderComponent) void { - _ = self; - } pub fn save(self: RenderComponent, writer: *utils.BinaryWriter, audience: main.entity.AudienceInfo) main.entity.ComponentSaveBehaviour { _ = audience; writer.writeInt(u32, self.entityModel.index); @@ -78,9 +75,6 @@ pub const server = struct { renderComponents = .{}; } pub fn deinit() void { - for (renderComponents.dense.items) |*component| { - component.deinit(); - } renderComponents.deinit(main.globalAllocator); } pub fn loadFromData(entity: u32, reader: *utils.BinaryReader, version: u32) main.entity.EntityComponentLoadError!void { @@ -93,13 +87,13 @@ pub const server = struct { try loadByIndex(entity, main.entityModel.getById(entityModelID) orelse main.entityModel.default()); } pub fn loadByIndex(entity: u32, entityModel: main.entityModel.EntityModelIndex) main.entity.EntityComponentLoadError!void { - if (renderComponents.get(@enumFromInt(entity))) |old| { - old.deinit(); + if (!renderComponents.contains(@enumFromInt(entity))) { + _ = renderComponents.add(main.globalAllocator, @enumFromInt(entity)); } - renderComponents.set(main.globalAllocator, @enumFromInt(entity), RenderComponent{ + renderComponents.get(@enumFromInt(entity)).?.* = RenderComponent{ .entity = entity, .entityModel = entityModel, - }); + }; } pub fn unload(entity: u32) void { renderComponents.remove(@enumFromInt(entity)) catch { @@ -107,10 +101,10 @@ pub const server = struct { }; } pub fn put(entity: u32, renderComponent: RenderComponent) void { - if (renderComponents.get(@enumFromInt(entity))) |entry| { - entry.deinit(); + if (!renderComponents.contains(@enumFromInt(entity))) { + _ = renderComponents.add(main.globalAllocator, @enumFromInt(entity)); } - renderComponents.set(main.globalAllocator, @enumFromInt(entity), renderComponent) catch unreachable; + renderComponents.get(@enumFromInt(entity)).?.* = renderComponent; } pub fn get(entity: u32) ?*RenderComponent { return renderComponents.get(@enumFromInt(entity)); From 885dfac96947ab98d7dc9b32f6d418b1cb8d25d5 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 21:13:28 +0200 Subject: [PATCH 79/83] more clean --- src/entityComponent/model.zig | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig index 9bab73051a..743d90673c 100644 --- a/src/entityComponent/model.zig +++ b/src/entityComponent/model.zig @@ -43,10 +43,8 @@ pub const client = struct { _ = version; const entityModel = reader.readInt(u32) catch return; - if (!renderComponents.contains(@enumFromInt(entity))) { - _ = renderComponents.add(main.globalAllocator, @enumFromInt(entity)); - } - renderComponents.get(@enumFromInt(entity)).?.* = RenderComponent{ + const ptr = renderComponents.get(@enumFromInt(entity)) orelse renderComponents.add(main.globalAllocator, @enumFromInt(entity)); + ptr.* = RenderComponent{ .entity = entity, .entityModel = main.entityModel.EntityModelIndex{.index = entityModel}, }; @@ -87,13 +85,12 @@ pub const server = struct { try loadByIndex(entity, main.entityModel.getById(entityModelID) orelse main.entityModel.default()); } pub fn loadByIndex(entity: u32, entityModel: main.entityModel.EntityModelIndex) main.entity.EntityComponentLoadError!void { - if (!renderComponents.contains(@enumFromInt(entity))) { - _ = renderComponents.add(main.globalAllocator, @enumFromInt(entity)); - } - renderComponents.get(@enumFromInt(entity)).?.* = RenderComponent{ + const ptr = renderComponents.get(@enumFromInt(entity)) orelse renderComponents.add(main.globalAllocator, @enumFromInt(entity)); + ptr.* = RenderComponent{ .entity = entity, .entityModel = entityModel, }; + } pub fn unload(entity: u32) void { renderComponents.remove(@enumFromInt(entity)) catch { @@ -101,12 +98,11 @@ pub const server = struct { }; } pub fn put(entity: u32, renderComponent: RenderComponent) void { - if (!renderComponents.contains(@enumFromInt(entity))) { - _ = renderComponents.add(main.globalAllocator, @enumFromInt(entity)); - } - renderComponents.get(@enumFromInt(entity)).?.* = renderComponent; + const ptr = renderComponents.get(@enumFromInt(entity)) orelse renderComponents.add(main.globalAllocator, @enumFromInt(entity)); + ptr.* = renderComponent; } pub fn get(entity: u32) ?*RenderComponent { return renderComponents.get(@enumFromInt(entity)); } }; + \ No newline at end of file From bd5d699d9112ee10ade3889f4ec442794d8a8383 Mon Sep 17 00:00:00 2001 From: till++ Date: Sat, 11 Apr 2026 22:01:53 +0200 Subject: [PATCH 80/83] fmt --- src/entityComponent/model.zig | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/entityComponent/model.zig b/src/entityComponent/model.zig index 743d90673c..f8bba63fc1 100644 --- a/src/entityComponent/model.zig +++ b/src/entityComponent/model.zig @@ -90,7 +90,6 @@ pub const server = struct { .entity = entity, .entityModel = entityModel, }; - } pub fn unload(entity: u32) void { renderComponents.remove(@enumFromInt(entity)) catch { @@ -105,4 +104,3 @@ pub const server = struct { return renderComponents.get(@enumFromInt(entity)); } }; - \ No newline at end of file From 05576eb6ed54e058894a8af89d4b5b111e1cb868 Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 12 Apr 2026 06:01:06 +0200 Subject: [PATCH 81/83] comment moved --- src/entity.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entity.zig b/src/entity.zig index af70866435..a554c543af 100644 --- a/src/entity.zig +++ b/src/entity.zig @@ -23,12 +23,12 @@ pub const EntityComponentLoadError = error{ UnreadableComponentData, UnknownComponentId, }; -// Analogous to Protocols. pub const Entity = enum(u32) { noValue = std.math.maxInt(u32), _, }; pub const EntityComponentId = u32; +// Analogous to Protocols. const EntityComponentVTable = struct { serverLoad: *const fn (entityId: u32, reader: *main.utils.BinaryReader, version: u32) EntityComponentLoadError!void, clientLoad: *const fn (entityId: u32, reader: *main.utils.BinaryReader, version: u32) EntityComponentLoadError!void, From 5379fe5136a0610840c441c8e4fbaa5130595da1 Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 12 Apr 2026 10:54:23 +0200 Subject: [PATCH 82/83] preparation --- src/client/entity_manager.zig | 9 +++++++++ src/renderer.zig | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/src/client/entity_manager.zig b/src/client/entity_manager.zig index 4e5303c741..868e755317 100644 --- a/src/client/entity_manager.zig +++ b/src/client/entity_manager.zig @@ -211,3 +211,12 @@ pub fn serverUpdate(time: i16, entityData: []main.entity.EntityNetworkData) void } } } +const Intersection = struct { + distance:f64, + entityId:u32 +}; +pub fn select(pos: Vec3d, dir: Vec3d, item: main.items.Item, maxDistance:f64) ?Intersection { + for (entities.items()) |ent| { + + } +} diff --git a/src/renderer.zig b/src/renderer.zig index 78b6f996a8..468098b25f 100644 --- a/src/renderer.zig +++ b/src/renderer.zig @@ -909,6 +909,7 @@ pub const MeshSelection = struct { // MARK: MeshSelection // Test blocks: const closestDistance: f64 = 6.0; // selection now limited + var blockIntersectionDistance: f64 = 6.0; // Implementation of "A Fast Voxel Traversal Algorithm for Ray Tracing" http://www.cse.yorku.ca/~amana/research/grid.pdf const step: Vec3i = @intFromFloat(std.math.sign(dir)); const invDir = @as(Vec3d, @splat(1))/dir; @@ -932,6 +933,7 @@ pub const MeshSelection = struct { // MARK: MeshSelection const relativePlayerPos: Vec3f = @floatCast(pos - @as(Vec3d, @floatFromInt(voxelPos))); if (block.mode().rayIntersection(block, item, relativePlayerPos, _dir)) |intersection| { if (intersection.distance <= closestDistance) { + blockIntersectionDistance = intersection.distance; selectedBlockPos = voxelPos; selectionMin = intersection.min; selectionMax = intersection.max; @@ -968,6 +970,11 @@ pub const MeshSelection = struct { // MARK: MeshSelection } } // TODO: Test entities + if(main.client.entity_manager.select(pos, dir, item,closestDistance)) |entityIntersection|{ + if(selectedBlockPos == null or blockIntersectionDistance < entityIntersection.distance){ + std.log.debug("intersected: {}", .{entityIntersection.entityId}); + } + } } fn canPlaceBlock(pos: Vec3i, block: main.blocks.Block) bool { From 0a77f7442ae041e1a341267a76b1903285dab750 Mon Sep 17 00:00:00 2001 From: till++ Date: Sun, 12 Apr 2026 12:34:25 +0200 Subject: [PATCH 83/83] tmp changes --- src/client/entity_manager.zig | 23 +++++++++++++++++++++-- src/renderer.zig | 3 ++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/client/entity_manager.zig b/src/client/entity_manager.zig index 3f3f5599a0..fe92ca81ab 100644 --- a/src/client/entity_manager.zig +++ b/src/client/entity_manager.zig @@ -77,6 +77,14 @@ pub fn initAfterWorld() void { std.log.err("EntityModel {s} wasn't found", .{"cubyz:snale"}); break :blk main.entityModel.default(); }).get(); + // TODO: remove before merge + addEntity(ZonElement.parseFromString(main.globalArena, null, + \\ .{ + \\ .id = 1, + \\ .name = "bobik", + \\ + \\ } + )) catch unreachable; } pub fn renderNames(projMatrix: Mat4f, playerPos: Vec3d) void { mutex.lock(); @@ -216,7 +224,18 @@ const Intersection = struct { entityId:u32 }; pub fn select(pos: Vec3d, dir: Vec3d, item: main.items.Item, maxDistance:f64) ?Intersection { - for (entities.items()) |ent| { - + if(true) + return Intersection{ + .distance = maxDistance/2, + .entityId = 0, + }; + _ = dir; + _ = item; + for (main.entity.components.@"cubyz:model".client.renderComponents.dense.items) |*renderComponent| { + const entModel = renderComponent.entityModel.get(); + _ = entModel; + // TODO: let entityModel decide the dimensions for the hitbox. + const difference = entities.items()[renderComponent.entity].getRenderPosition()-pos; + _ = difference; } } diff --git a/src/renderer.zig b/src/renderer.zig index 468098b25f..38ceb33239 100644 --- a/src/renderer.zig +++ b/src/renderer.zig @@ -971,8 +971,9 @@ pub const MeshSelection = struct { // MARK: MeshSelection } // TODO: Test entities if(main.client.entity_manager.select(pos, dir, item,closestDistance)) |entityIntersection|{ - if(selectedBlockPos == null or blockIntersectionDistance < entityIntersection.distance){ + if(selectedBlockPos == null or blockIntersectionDistance > entityIntersection.distance){ std.log.debug("intersected: {}", .{entityIntersection.entityId}); + selectedBlockPos = null; } } }