mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-22 10:53:55 -04:00
Add a hanging plant rotation mode (#1742)
Mostly fixes #1030 It is currently not possible to make the whole vine break when the support is removed as far as I can tell, but it works well otherwise.
This commit is contained in:
parent
ca9e299b4b
commit
afc6f0fdb6
17
assets/cubyz/blocks/vine/_defaults.zig.zon
Normal file
17
assets/cubyz/blocks/vine/_defaults.zig.zon
Normal file
@ -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",
|
||||
}
|
7
assets/cubyz/blocks/vine/mahogany.zig.zon
Normal file
7
assets/cubyz/blocks/vine/mahogany.zig.zon
Normal file
@ -0,0 +1,7 @@
|
||||
.{
|
||||
.texture0 = "cubyz:vine/mahogany/top",
|
||||
.texture1 = "cubyz:vine/mahogany/bottom",
|
||||
.item = .{
|
||||
.texture = "vine/mahogany.png",
|
||||
},
|
||||
}
|
7
assets/cubyz/blocks/vine/willow.zig.zon
Normal file
7
assets/cubyz/blocks/vine/willow.zig.zon
Normal file
@ -0,0 +1,7 @@
|
||||
.{
|
||||
.texture0 = "cubyz:vine/willow/top",
|
||||
.texture1 = "cubyz:vine/willow/bottom",
|
||||
.item = .{
|
||||
.texture = "vine/willow.png",
|
||||
},
|
||||
}
|
20
assets/cubyz/models/cross_with_texture_1.obj
Normal file
20
assets/cubyz/models/cross_with_texture_1.obj
Normal file
@ -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
|
59
mods/cubyz/rotation/hanging.zig
Normal file
59
mods/cubyz/rotation/hanging.zig
Normal file
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user