diff --git a/assets/cubyz/blocks/vine/_defaults.zig.zon b/assets/cubyz/blocks/vine/_defaults.zig.zon new file mode 100644 index 000000000..09c760047 --- /dev/null +++ b/assets/cubyz/blocks/vine/_defaults.zig.zon @@ -0,0 +1,17 @@ +.{ + .tags = .{.cuttable}, + .blockHealth = 0.3, + .drops = .{ + .{.items = .{.auto}}, + }, + .degradable = true, + .viewThrough = true, + .absorbedLight = 0x000000, + .collide = false, + .model = { + .top = "cubyz:cross", + .bottom = "cubyz:cross_with_texture_1", + } + .rotation = "cubyz:hanging", + .lodReplacement = "cubyz:air", +} diff --git a/assets/cubyz/blocks/vine/mahogany.zig.zon b/assets/cubyz/blocks/vine/mahogany.zig.zon new file mode 100644 index 000000000..d03ef3d1e --- /dev/null +++ b/assets/cubyz/blocks/vine/mahogany.zig.zon @@ -0,0 +1,7 @@ +.{ + .texture0 = "cubyz:vine/mahogany/top", + .texture1 = "cubyz:vine/mahogany/bottom", + .item = .{ + .texture = "vine/mahogany.png", + }, +} diff --git a/assets/cubyz/blocks/vine/willow.zig.zon b/assets/cubyz/blocks/vine/willow.zig.zon new file mode 100644 index 000000000..d05fff8b4 --- /dev/null +++ b/assets/cubyz/blocks/vine/willow.zig.zon @@ -0,0 +1,7 @@ +.{ + .texture0 = "cubyz:vine/willow/top", + .texture1 = "cubyz:vine/willow/bottom", + .item = .{ + .texture = "vine/willow.png", + }, +} diff --git a/assets/cubyz/models/cross_with_texture_1.obj b/assets/cubyz/models/cross_with_texture_1.obj new file mode 100644 index 000000000..01b0c131a --- /dev/null +++ b/assets/cubyz/models/cross_with_texture_1.obj @@ -0,0 +1,20 @@ +v 1 1 0 +v 1 1 1 +v 0 0 0 +v 0 0 1 +v 0 1 0 +v 0 1 1 +v 1 0 0 +v 1 0 1 +vt 0.25 0 +vt 0.25 0.25 +vt 0.5 0 +vt 0.5 0.25 +vn -0.70703125 0.70703125 0 +vn 0.70703125 -0.70703125 0 +vn -0.70703125 -0.70703125 0 +vn 0.70703125 0.70703125 0 +f 2/2/1 1/1/1 3/3/1 4/4/1 +f 4/2/2 3/1/2 1/3/2 2/4/2 +f 6/2/3 5/1/3 7/3/3 8/4/3 +f 8/2/4 7/1/4 5/3/4 6/4/4 diff --git a/mods/cubyz/rotation/hanging.zig b/mods/cubyz/rotation/hanging.zig new file mode 100644 index 000000000..71d9632df --- /dev/null +++ b/mods/cubyz/rotation/hanging.zig @@ -0,0 +1,59 @@ +const std = @import("std"); + +const main = @import("main"); +const blocks = main.blocks; +const Block = blocks.Block; +const Neighbor = main.chunk.Neighbor; +const ModelIndex = main.models.ModelIndex; +const rotation = main.rotation; +const RotationMode = rotation.RotationMode; +const vec = main.vec; +const Vec3f = vec.Vec3f; +const Vec3i = vec.Vec3i; +const ZonElement = main.ZonElement; + +pub const dependsOnNeighbors = true; + +fn transform(_: *main.models.QuadInfo) void {} + +pub fn init() void {} +pub fn deinit() void {} +pub fn reset() void {} + +pub fn createBlockModel(_: Block, _: *u16, zon: ZonElement) ModelIndex { + const topModelIndex = main.models.getModelIndex(zon.get([]const u8, "top", "cubyz:cube")); + const bottomModelIndex = main.models.getModelIndex(zon.get([]const u8, "bottom", "cubyz:cube")); + + const modelIndex = topModelIndex.model().transformModel(transform, .{}); + _ = bottomModelIndex.model().transformModel(transform, .{}); + return modelIndex; +} + +pub fn model(block: Block) ModelIndex { + return blocks.meshes.modelIndexStart(block).add(block.data%2); +} + +pub fn generateData(_: *main.game.World, _: Vec3i, _: Vec3f, _: Vec3f, _: Vec3i, neighbor: ?Neighbor, currentData: *Block, neighborBlock: Block, blockPlacing: bool) bool { + const sameBlock = neighborBlock.typ == currentData.typ; + if(blockPlacing) { + if(neighbor != Neighbor.dirUp) return false; + if(!sameBlock) { + const neighborModel = neighborBlock.mode().model(neighborBlock).model(); + const support = !neighborBlock.replacable() and neighborModel.neighborFacingQuads[Neighbor.dirDown.toInt()].len != 0; + if(!support) return false; + } + currentData.data = 1; + return true; + } + return false; +} + +pub fn updateData(block: *Block, neighbor: Neighbor, neighborBlock: Block) bool { + if(neighbor != .dirDown) return false; + + const newData: u16 = if(neighborBlock.typ == block.typ) 0 else 1; + + if(newData == block.data) return false; + block.data = newData; + return true; +}