Implement more block collisions.

This commit is contained in:
Scetch 2016-04-03 23:55:20 -04:00
parent 8094fbbd0a
commit 7c31332dc8
1 changed files with 517 additions and 94 deletions

View File

@ -14,15 +14,9 @@
// Barrier // Barrier
// EndGateway // EndGateway
// TODO: Blocks // TODO: Blocks
// RedstoneRepeater (Locked State Update) // Rendering: TripwireHook, FlowingWater, FlowingLava, DoublePlant (Sunflower)
// Tripwire (State Update) // State Updates: Fire, CobblestoneWall, Tripwire, FenceGate (in_wall), RedstoneRepeater (locked)
// TripwireHook (Rendering issue) // Collisions: Chest, Hopper, CobblestoneWall, Stairs, SnowLayer
// FlowingWater
// FlowingLava
// DoublePlant (Sunflower rendering)
// PistonExtension?
// Fire (Update State)
// CobblestoneWall (Connections)
#![recursion_limit="300"] #![recursion_limit="300"]
@ -766,6 +760,7 @@ define_blocks! {
}, },
model { ("minecraft", "sticky_piston") }, model { ("minecraft", "sticky_piston") },
variant format!("extended={},facing={}", extended, facing.as_string()), variant format!("extended={},facing={}", extended, facing.as_string()),
collision piston_collision(extended, facing),
} }
Web { Web {
props {}, props {},
@ -833,6 +828,7 @@ define_blocks! {
}, },
model { ("minecraft", "piston") }, model { ("minecraft", "piston") },
variant format!("extended={},facing={}", extended, facing.as_string()), variant format!("extended={},facing={}", extended, facing.as_string()),
collision piston_collision(extended, facing),
} }
PistonHead { PistonHead {
props { props {
@ -863,6 +859,22 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "piston_head") }, model { ("minecraft", "piston_head") },
variant format!("facing={},short={},type={}", facing.as_string(), short, variant.as_string()), variant format!("facing={},short={},type={}", facing.as_string(), short, variant.as_string()),
collision {
let (min_x, min_y, min_z, max_x, max_y, max_z) = match facing {
Direction::Up => (3.0/8.0, -0.25, 3.0/8.0, 5.0/8.0, 0.75, 5.0/8.0),
Direction::Down => (3.0/8.0, 0.25, 3.0/8.0, 5.0/8.0, 1.25, 0.625),
Direction::North => (3.0/8.0, 3.0/8.0, 0.25, 5.0/8.0, 5.0/8.0, 1.25),
Direction::South => (3.0/8.0, 3.0/8.0, -0.25, 5.0/8.0, 5.0/8.0, 0.75),
Direction::West => (0.25, 3.0/8.0, 3.0/8.0, 1.25, 5.0/8.0, 5.0/8.0),
Direction::East => (-0.25, 3.0/8.0, 3.0/8.0, 0.75, 5.0/8.0, 5.0/8.0),
_ => unreachable!(),
};
vec![Aabb3::new(
Point3::new(min_x, min_y, min_z),
Point3::new(max_x, max_y, max_z)
)]
},
} }
Wool { Wool {
props { props {
@ -1212,6 +1224,10 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "farmland") }, model { ("minecraft", "farmland") },
variant format!("moisture={}", moisture), variant format!("moisture={}", moisture),
collision vec![Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 15.0/16.0, 1.0)
)],
} }
Furnace { Furnace {
props { props {
@ -1308,6 +1324,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "wooden_door") }, model { ("minecraft", "wooden_door") },
variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open), variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open),
collision door_collision(facing, hinge, open),
update_state (world, pos) => { update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered); let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::WoodenDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered} Block::WoodenDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
@ -1447,6 +1464,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "iron_door") }, model { ("minecraft", "iron_door") },
variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open), variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open),
collision door_collision(facing, hinge, open),
update_state (world, pos) => { update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered); let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::IronDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered} Block::IronDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
@ -1602,6 +1620,10 @@ define_blocks! {
data Some(age as usize), data Some(age as usize),
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "cactus") }, model { ("minecraft", "cactus") },
collision vec![Aabb3::new(
Point3::new(1.0/16.0, 0.0, 1.0/16.0),
Point3::new(1.0 - (1.0/16.0), 1.0 - (1.0/16.0), 1.0 - (1.0/16.0))
)],
} }
Clay { Clay {
props {}, props {},
@ -1636,6 +1658,7 @@ define_blocks! {
data if !north && !south && !east && !west { Some(0) } else { None }, data if !north && !south && !east && !west { Some(0) } else { None },
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "fence") }, model { ("minecraft", "fence") },
collision fence_collision(north, south, east, west),
update_state (world, pos) => Block::Fence { update_state (world, pos) => Block::Fence {
north: can_connect(world, pos.shift(Direction::North), &can_connect_fence), north: can_connect(world, pos.shift(Direction::North), &can_connect_fence),
south: can_connect(world, pos.shift(Direction::South), &can_connect_fence), south: can_connect(world, pos.shift(Direction::South), &can_connect_fence),
@ -1684,6 +1707,10 @@ define_blocks! {
props {}, props {},
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "soul_sand") }, model { ("minecraft", "soul_sand") },
collision vec![Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 7.0/8.0, 1.0)
)],
} }
Glowstone { Glowstone {
props {}, props {},
@ -1757,6 +1784,10 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "cake") }, model { ("minecraft", "cake") },
variant format!("bites={}", bites), variant format!("bites={}", bites),
collision vec![Aabb3::new(
Point3::new((1.0 + (bites as f64 * 2.0)) / 16.0, 0.0, 1.0/16.0),
Point3::new(1.0 - (1.0/16.0), 0.5, 1.0 - (1.0/16.0))
)],
} }
RepeaterUnpowered { RepeaterUnpowered {
props { props {
@ -1785,7 +1816,10 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "unpowered_repeater") }, model { ("minecraft", "unpowered_repeater") },
variant format!("delay={},facing={},locked={}", delay, facing.as_string(), locked), variant format!("delay={},facing={},locked={}", delay, facing.as_string(), locked),
collision vec![Aabb3::new(Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 0.125, 1.0))], collision vec![Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 1.0/8.0, 1.0)
)],
} }
RepeaterPowered { RepeaterPowered {
props { props {
@ -1814,7 +1848,10 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "powered_repeater") }, model { ("minecraft", "powered_repeater") },
variant format!("delay={},facing={},locked={}", delay, facing.as_string(), locked), variant format!("delay={},facing={},locked={}", delay, facing.as_string(), locked),
collision vec![Aabb3::new(Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 0.125, 1.0))], collision vec![Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 1.0/8.0, 1.0)
)],
} }
StainedGlass { StainedGlass {
props { props {
@ -1868,6 +1905,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "trapdoor") }, model { ("minecraft", "trapdoor") },
variant format!("facing={},half={},open={}", facing.as_string(), half.as_string(), open), variant format!("facing={},half={},open={}", facing.as_string(), half.as_string(), open),
collision trapdoor_collision(facing, half, open),
} }
MonsterEgg { MonsterEgg {
props { props {
@ -1953,6 +1991,7 @@ define_blocks! {
data if !north && !south && !east && !west { Some(0) } else { None }, data if !north && !south && !east && !west { Some(0) } else { None },
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "iron_bars") }, model { ("minecraft", "iron_bars") },
collision pane_collision(north, south, east, west),
update_state (world, pos) => { update_state (world, pos) => {
let f = |block| match block { let f = |block| match block {
Block::IronBars{..} => true, Block::IronBars{..} => true,
@ -1984,6 +2023,7 @@ define_blocks! {
data if !north && !south && !east && !west { Some(0) } else { None }, data if !north && !south && !east && !west { Some(0) } else { None },
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "glass_pane") }, model { ("minecraft", "glass_pane") },
collision pane_collision(north, south, east, west),
update_state (world, pos) => Block::GlassPane { update_state (world, pos) => Block::GlassPane {
north: can_connect(world, pos.shift(Direction::North), &can_connect_glasspane), north: can_connect(world, pos.shift(Direction::North), &can_connect_glasspane),
south: can_connect(world, pos.shift(Direction::South), &can_connect_glasspane), south: can_connect(world, pos.shift(Direction::South), &can_connect_glasspane),
@ -2113,6 +2153,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "fence_gate") }, model { ("minecraft", "fence_gate") },
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open), variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
} }
BrickStairs { BrickStairs {
props { props {
@ -2178,7 +2219,10 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "waterlily") }, model { ("minecraft", "waterlily") },
tint TintType::Foliage, tint TintType::Foliage,
collision vec![Aabb3::new(Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 0.1, 1.0))], collision vec![Aabb3::new(
Point3::new(1.0/16.0, 0.0, 1.0/16.0),
Point3::new(15.0/16.0, 3.0/32.0, 15.0/16.0))
],
} }
NetherBrick { NetherBrick {
props {}, props {},
@ -2195,6 +2239,7 @@ define_blocks! {
data if !north && !south && !east && !west { Some(0) } else { None }, data if !north && !south && !east && !west { Some(0) } else { None },
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "nether_brick_fence") }, model { ("minecraft", "nether_brick_fence") },
collision fence_collision(north, south, east, west),
update_state (world, pos) => { update_state (world, pos) => {
let f = |block| match block { let f = |block| match block {
Block::NetherBrickFence{..} => true, Block::NetherBrickFence{..} => true,
@ -2251,6 +2296,10 @@ define_blocks! {
props {}, props {},
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "enchanting_table") }, model { ("minecraft", "enchanting_table") },
collision vec![Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 0.75, 1.0))
],
} }
BrewingStand { BrewingStand {
props { props {
@ -2299,6 +2348,7 @@ define_blocks! {
emitted_light: 15, emitted_light: 15,
}, },
model { ("minecraft", "end_portal") }, model { ("minecraft", "end_portal") },
collision vec![],
} }
EndPortalFrame { EndPortalFrame {
props { props {
@ -2332,6 +2382,21 @@ define_blocks! {
}, },
model { ("minecraft", "end_portal_frame") }, model { ("minecraft", "end_portal_frame") },
variant format!("eye={},facing={}", eye, facing.as_string()), variant format!("eye={},facing={}", eye, facing.as_string()),
collision {
let base_aabb = Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 13.0/16.0, 1.0)
);
if eye {
vec![base_aabb, Aabb3::new(
Point3::new(5.0/16.0, 13.0/16.0, 5.0/16.0),
Point3::new(11.0/16.0, 1.0, 11.0/16.0)
)]
} else {
vec![base_aabb]
}
},
} }
EndStone { EndStone {
props {}, props {},
@ -2350,6 +2415,10 @@ define_blocks! {
emitted_light: 1, emitted_light: 1,
}, },
model { ("minecraft", "dragon_egg") }, model { ("minecraft", "dragon_egg") },
collision vec![Aabb3::new(
Point3::new(1.0/16.0, 0.0, 1.0/16.0),
Point3::new(15.0/16.0, 1.0, 15.0/16.0)
)],
} }
RedstoneLamp { RedstoneLamp {
props {}, props {},
@ -2401,8 +2470,14 @@ define_blocks! {
model { ("minecraft", format!("{}_slab", variant.as_string()) ) }, model { ("minecraft", format!("{}_slab", variant.as_string()) ) },
variant format!("half={}", half.as_string()), variant format!("half={}", half.as_string()),
collision match half { collision match half {
BlockHalf::Bottom => vec![Aabb3::new(Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 0.5, 1.0))], BlockHalf::Bottom => vec![Aabb3::new(
BlockHalf::Top => vec![Aabb3::new(Point3::new(0.0, 0.5, 0.0), Point3::new(1.0, 1.0, 1.0))], Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 0.5, 1.0)
)],
BlockHalf::Top => vec![Aabb3::new(
Point3::new(0.0, 0.5, 0.0),
Point3::new(1.0, 1.0, 1.0))
],
_ => unreachable!(), _ => unreachable!(),
}, },
} }
@ -2410,10 +2485,10 @@ define_blocks! {
props { props {
age: i32 = [0, 1, 2], age: i32 = [0, 1, 2],
facing: Direction = [ facing: Direction = [
Direction::North,
Direction::South, Direction::South,
Direction::East, Direction::West,
Direction::West Direction::North,
Direction::East
], ],
}, },
data { data {
@ -2430,6 +2505,24 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "cocoa") }, model { ("minecraft", "cocoa") },
variant format!("age={},facing={}", age, facing.as_string()), variant format!("age={},facing={}", age, facing.as_string()),
collision {
let i = 4.0 + age as f64 * 2.0;
let j = 5.0 + age as f64 * 2.0;
let f = i / 2.0;
let (min_x, min_y, min_z, max_x, max_y, max_z) = match facing {
Direction::South => (8.0 - f, 12.0 - j, 15.0 - i, 8.0 + f, 12.0, 15.0),
Direction::West => (1.0, 12.0 - j, 8.0 - f, 1.0 + i, 12.0, 8.0 + f),
Direction::North => (8.0 - f, 12.0 - j, 1.0, 8.0 + f, 12.0, 8.0 + i),
Direction::East => (15.0 - i, 12.0 - j, 8.0 - f, 15.0, 12.0, 8.0 + f),
_ => unreachable!(),
};
vec![Aabb3::new(
Point3::new(min_x / 16.0, min_y / 16.0, min_z / 16.0),
Point3::new(max_x / 16.0, max_y / 16.0, max_z / 16.0))
]
},
} }
SandstoneStairs { SandstoneStairs {
props { props {
@ -2486,6 +2579,10 @@ define_blocks! {
}, },
model { ("minecraft", "ender_chest") }, model { ("minecraft", "ender_chest") },
variant format!("facing={}", facing.as_string()), variant format!("facing={}", facing.as_string()),
collision vec![Aabb3::new(
Point3::new(1.0/16.0, 0.0, 1.0/16.0),
Point3::new(15.0/16.0, 7.0/8.0, 15.0/16.0)
)],
} }
TripwireHook { TripwireHook {
props { props {
@ -2786,23 +2883,38 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "skull") }, model { ("minecraft", "skull") },
variant format!("facing={},nodrop={}", facing.as_string(), nodrop), variant format!("facing={},nodrop={}", facing.as_string(), nodrop),
collision {
let (min_x, min_y, min_z, max_x, max_y, max_z) = match facing {
Direction::Up => (0.25, 0.0, 0.25, 0.75, 0.5, 0.75),
Direction::North => (0.25, 0.25, 0.5, 0.75, 0.75, 1.0),
Direction::South => (0.25, 0.25, 0.0, 0.75, 0.75, 0.5),
Direction::West => (0.5, 0.25, 0.25, 1.0, 0.75, 0.75),
Direction::East => (0.0, 0.25, 0.25, 0.5, 0.75, 0.75),
_ => unreachable!(),
};
vec![Aabb3::new(
Point3::new(min_x, min_y, min_z),
Point3::new(max_x, max_y, max_z)
)]
},
} }
Anvil { Anvil {
props { props {
damage: i32 = [0, 1, 2], damage: i32 = [0, 1, 2],
facing: Direction = [ facing: Direction = [
Direction::North,
Direction::South, Direction::South,
Direction::East, Direction::West,
Direction::West Direction::North,
Direction::East
], ],
}, },
data { data {
let data = match facing { let data = match facing {
Direction::North => 0, Direction::South => 0,
Direction::East => 1, Direction::West => 1,
Direction::South => 2, Direction::North => 2,
Direction::West => 3, Direction::East => 3,
_ => unreachable!(), _ => unreachable!(),
}; };
@ -2814,6 +2926,17 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "anvil") }, model { ("minecraft", "anvil") },
variant format!("damage={},facing={}", damage, facing.as_string()), variant format!("damage={},facing={}", damage, facing.as_string()),
collision match facing {
Direction::South | Direction::North => vec![Aabb3::new(
Point3::new(1.0/8.0, 0.0, 0.0),
Point3::new(7.0/8.0, 1.0, 1.0)
)],
Direction::West | Direction::East => vec![Aabb3::new(
Point3::new(0.0, 0.0, 1.0/8.0),
Point3::new(1.0, 1.0, 7.0/8.0)
)],
_ => unreachable!(),
},
} }
TrappedChest { TrappedChest {
props { props {
@ -2836,6 +2959,10 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "trapped_chest") }, model { ("minecraft", "trapped_chest") },
variant format!("facing={}", facing.as_string()), variant format!("facing={}", facing.as_string()),
collision vec![Aabb3::new(
Point3::new(1.0/16.0, 0.0, 1.0/16.0),
Point3::new(15.0/16.0, 7.0/8.0, 15.0/16.0)
)],
} }
LightWeightedPressurePlate { LightWeightedPressurePlate {
props { props {
@ -2884,7 +3011,10 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "unpowered_comparator") }, model { ("minecraft", "unpowered_comparator") },
variant format!("facing={},mode={},powered={}", facing.as_string(), mode.as_string(), powered), variant format!("facing={},mode={},powered={}", facing.as_string(), mode.as_string(), powered),
collision vec![Aabb3::new(Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 0.125, 1.0))], collision vec![Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 1.0/8.0, 1.0)
)],
} }
ComparatorPowered { ComparatorPowered {
props { props {
@ -2913,7 +3043,10 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "powered_comparator") }, model { ("minecraft", "powered_comparator") },
variant format!("facing={},mode={},powered={}", facing.as_string(), mode.as_string(), powered), variant format!("facing={},mode={},powered={}", facing.as_string(), mode.as_string(), powered),
collision vec![Aabb3::new(Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 0.125, 1.0))], collision vec![Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 1.0/8.0, 1.0)
)],
} }
DaylightDetector { DaylightDetector {
props { props {
@ -2923,7 +3056,10 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "daylight_detector") }, model { ("minecraft", "daylight_detector") },
variant format!("power={}", power), variant format!("power={}", power),
collision vec![Aabb3::new(Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 3.0/8.0, 1.0))], collision vec![Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 3.0/8.0, 1.0)
)],
} }
RedstoneBlock { RedstoneBlock {
props {}, props {},
@ -3110,6 +3246,7 @@ define_blocks! {
data if !north && !south && !east && !west { Some(color.data()) } else { None }, data if !north && !south && !east && !west { Some(color.data()) } else { None },
material material::TRANSPARENT, material material::TRANSPARENT,
model { ("minecraft", format!("{}_stained_glass_pane", color.as_string()) ) }, model { ("minecraft", format!("{}_stained_glass_pane", color.as_string()) ) },
collision pane_collision(north, south, east, west),
update_state (world, pos) => Block::StainedGlassPane { update_state (world, pos) => Block::StainedGlassPane {
color: color, color: color,
north: can_connect(world, pos.shift(Direction::North), &can_connect_glasspane), north: can_connect(world, pos.shift(Direction::North), &can_connect_glasspane),
@ -3233,6 +3370,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "iron_trapdoor") }, model { ("minecraft", "iron_trapdoor") },
variant format!("facing={},half={},open={}", facing.as_string(), half.as_string(), open), variant format!("facing={},half={},open={}", facing.as_string(), half.as_string(), open),
collision trapdoor_collision(facing, half, open),
} }
Prismarine { Prismarine {
props { props {
@ -3297,6 +3435,10 @@ define_blocks! {
data Some(color.data()), data Some(color.data()),
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", format!("{}_carpet", color.as_string()) ) }, model { ("minecraft", format!("{}_carpet", color.as_string()) ) },
collision vec![Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 1.0/16.0, 1.0)
)],
} }
HardenedClay { HardenedClay {
props {}, props {},
@ -3390,7 +3532,10 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "daylight_detector_inverted") }, model { ("minecraft", "daylight_detector_inverted") },
variant format!("power={}", power), variant format!("power={}", power),
collision vec![Aabb3::new(Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 3.0/8.0, 1.0))], collision vec![Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 3.0/8.0, 1.0)
)],
} }
RedSandstone { RedSandstone {
props { props {
@ -3447,8 +3592,14 @@ define_blocks! {
model { ("minecraft", format!("{}_slab", variant.as_string()) ) }, model { ("minecraft", format!("{}_slab", variant.as_string()) ) },
variant format!("half={}", half.as_string()), variant format!("half={}", half.as_string()),
collision match half { collision match half {
BlockHalf::Bottom => vec![Aabb3::new(Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 0.5, 1.0))], BlockHalf::Bottom => vec![Aabb3::new(
BlockHalf::Top => vec![Aabb3::new(Point3::new(0.0, 0.5, 0.0), Point3::new(1.0, 1.0, 1.0))], Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 0.5, 1.0)
)],
BlockHalf::Top => vec![Aabb3::new(
Point3::new(0.0, 0.5, 0.0),
Point3::new(1.0, 1.0, 1.0)
)],
_ => unreachable!(), _ => unreachable!(),
}, },
} }
@ -3468,6 +3619,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "spruce_fence_gate") }, model { ("minecraft", "spruce_fence_gate") },
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open), variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
} }
BirchFenceGate { BirchFenceGate {
props { props {
@ -3485,6 +3637,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "birch_fence_gate") }, model { ("minecraft", "birch_fence_gate") },
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open), variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
} }
JungleFenceGate { JungleFenceGate {
props { props {
@ -3502,6 +3655,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "jungle_fence_gate") }, model { ("minecraft", "jungle_fence_gate") },
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open), variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
} }
DarkOakFenceGate { DarkOakFenceGate {
props { props {
@ -3519,6 +3673,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "dark_oak_fence_gate") }, model { ("minecraft", "dark_oak_fence_gate") },
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open), variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
} }
AcaciaFenceGate { AcaciaFenceGate {
props { props {
@ -3536,6 +3691,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "acacia_fence_gate") }, model { ("minecraft", "acacia_fence_gate") },
variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open), variant format!("facing={},in_wall={},open={}", facing.as_string(), in_wall, open),
collision fence_gate_collision(facing, in_wall, open),
} }
SpruceFence { SpruceFence {
props { props {
@ -3547,6 +3703,7 @@ define_blocks! {
data if !north && !south && !east && !west { Some(0) } else { None }, data if !north && !south && !east && !west { Some(0) } else { None },
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "spruce_fence") }, model { ("minecraft", "spruce_fence") },
collision fence_collision(north, south, east, west),
update_state (world, pos) => Block::SpruceFence { update_state (world, pos) => Block::SpruceFence {
north: can_connect(world, pos.shift(Direction::North), &can_connect_fence), north: can_connect(world, pos.shift(Direction::North), &can_connect_fence),
south: can_connect(world, pos.shift(Direction::South), &can_connect_fence), south: can_connect(world, pos.shift(Direction::South), &can_connect_fence),
@ -3571,6 +3728,7 @@ define_blocks! {
data if !north && !south && !east && !west { Some(0) } else { None }, data if !north && !south && !east && !west { Some(0) } else { None },
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "birch_fence") }, model { ("minecraft", "birch_fence") },
collision fence_collision(north, south, east, west),
update_state (world, pos) => Block::BirchFence { update_state (world, pos) => Block::BirchFence {
north: can_connect(world, pos.shift(Direction::North), &can_connect_fence), north: can_connect(world, pos.shift(Direction::North), &can_connect_fence),
south: can_connect(world, pos.shift(Direction::South), &can_connect_fence), south: can_connect(world, pos.shift(Direction::South), &can_connect_fence),
@ -3595,6 +3753,7 @@ define_blocks! {
data if !north && !south && !east && !west { Some(0) } else { None }, data if !north && !south && !east && !west { Some(0) } else { None },
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "jungle_fence") }, model { ("minecraft", "jungle_fence") },
collision fence_collision(north, south, east, west),
update_state (world, pos) => Block::JungleFence { update_state (world, pos) => Block::JungleFence {
north: can_connect(world, pos.shift(Direction::North), &can_connect_fence), north: can_connect(world, pos.shift(Direction::North), &can_connect_fence),
south: can_connect(world, pos.shift(Direction::South), &can_connect_fence), south: can_connect(world, pos.shift(Direction::South), &can_connect_fence),
@ -3619,6 +3778,7 @@ define_blocks! {
data if !north && !south && !east && !west { Some(0) } else { None }, data if !north && !south && !east && !west { Some(0) } else { None },
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "dark_oak_fence") }, model { ("minecraft", "dark_oak_fence") },
collision fence_collision(north, south, east, west),
update_state (world, pos) => Block::DarkOakFence { update_state (world, pos) => Block::DarkOakFence {
north: can_connect(world, pos.shift(Direction::North), &can_connect_fence), north: can_connect(world, pos.shift(Direction::North), &can_connect_fence),
south: can_connect(world, pos.shift(Direction::South), &can_connect_fence), south: can_connect(world, pos.shift(Direction::South), &can_connect_fence),
@ -3643,6 +3803,7 @@ define_blocks! {
data if !north && !south && !east && !west { Some(0) } else { None }, data if !north && !south && !east && !west { Some(0) } else { None },
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "acacia_fence") }, model { ("minecraft", "acacia_fence") },
collision fence_collision(north, south, east, west),
update_state (world, pos) => Block::AcaciaFence { update_state (world, pos) => Block::AcaciaFence {
north: can_connect(world, pos.shift(Direction::North), &can_connect_fence), north: can_connect(world, pos.shift(Direction::North), &can_connect_fence),
south: can_connect(world, pos.shift(Direction::South), &can_connect_fence), south: can_connect(world, pos.shift(Direction::South), &can_connect_fence),
@ -3674,6 +3835,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "spruce_door") }, model { ("minecraft", "spruce_door") },
variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open), variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open),
collision door_collision(facing, hinge, open),
update_state (world, pos) => { update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered); let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::SpruceDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered} Block::SpruceDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
@ -3696,6 +3858,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "birch_door") }, model { ("minecraft", "birch_door") },
variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open), variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open),
collision door_collision(facing, hinge, open),
update_state (world, pos) => { update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered); let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::BirchDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered} Block::BirchDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
@ -3718,6 +3881,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "jungle_door") }, model { ("minecraft", "jungle_door") },
variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open), variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open),
collision door_collision(facing, hinge, open),
update_state (world, pos) => { update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered); let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::JungleDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered} Block::JungleDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
@ -3740,6 +3904,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "acacia_door") }, model { ("minecraft", "acacia_door") },
variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open), variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open),
collision door_collision(facing, hinge, open),
update_state (world, pos) => { update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered); let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::AcaciaDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered} Block::AcaciaDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
@ -3762,6 +3927,7 @@ define_blocks! {
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "dark_oak_door") }, model { ("minecraft", "dark_oak_door") },
variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open), variant format!("facing={},half={},hinge={},open={}", facing.as_string(), half.as_string(), hinge.as_string(), open),
collision door_collision(facing, hinge, open),
update_state (world, pos) => { update_state (world, pos) => {
let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered); let (facing, hinge, open, powered) = update_door_state(world, pos, half, facing, hinge, open, powered);
Block::DarkOakDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered} Block::DarkOakDoor{facing: facing, half: half, hinge: hinge, open: open, powered: powered}
@ -3800,19 +3966,86 @@ define_blocks! {
}, },
model { ("minecraft", "end_rod") }, model { ("minecraft", "end_rod") },
variant format!("facing={}", facing.as_string()), variant format!("facing={}", facing.as_string()),
collision {
match facing {
Direction::Up | Direction::Down => vec![Aabb3::new(
Point3::new(3.0/8.0, 0.0, 3.0/8.0),
Point3::new(5.0/8.0, 1.0, 5.0/8.0))
],
Direction::North | Direction::South => vec![Aabb3::new(
Point3::new(3.0/8.0, 3.0/8.0, 0.0),
Point3::new(5.0/8.0, 5.0/8.0, 1.0))
],
Direction::East | Direction::West => vec![Aabb3::new(
Point3::new(0.0, 3.0/8.0, 3.0/8.0),
Point3::new(1.0, 5.0/8.0, 5.0/8.0))
],
_ => unreachable!(),
}
},
} }
ChorusPlant { ChorusPlant {
props { props {
up: bool = [false, true],
down: bool = [false, true],
north: bool = [false, true], north: bool = [false, true],
south: bool = [false, true], south: bool = [false, true],
east: bool = [false, true], east: bool = [false, true],
west: bool = [false, true], west: bool = [false, true],
up: bool = [false, true],
down: bool = [false, true],
}, },
data if !north && !south && !east && !west && !up && !down { Some(0) } else { None }, data if !north && !south && !east && !west && !up && !down { Some(0) } else { None },
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "chorus_plant") }, model { ("minecraft", "chorus_plant") },
collision {
let mut collision = vec![Aabb3::new(
Point3::new(3.0/16.0, 3.0/16.0, 3.0/16.0),
Point3::new(13.0/16.0, 13.0/16.0, 13.0/16.0))
];
if up {
collision.push(Aabb3::new(
Point3::new(3.0/16.0, 13.0/16.0, 3.0/16.0),
Point3::new(13.0/16.0, 1.0, 13.0/16.0))
);
}
if down {
collision.push(Aabb3::new(
Point3::new(3.0/16.0, 0.0, 3.0/16.0),
Point3::new(13.0/16.0, 3.0/16.0, 13.0/16.0))
);
}
if north {
collision.push(Aabb3::new(
Point3::new(3.0/16.0, 3.0/16.0, 0.0),
Point3::new(13.0/16.0, 13.0/16.0, 3.0/16.0))
);
}
if south {
collision.push(Aabb3::new(
Point3::new(3.0/16.0, 3.0/16.0, 13.0/16.0),
Point3::new(13.0/16.0, 13.0/16.0, 1.0))
);
}
if east {
collision.push(Aabb3::new(
Point3::new(13.0/16.0, 3.0/16.0, 3.0/16.0),
Point3::new(1.0, 13.0/16.0, 13.0/16.0))
);
}
if west {
collision.push(Aabb3::new(
Point3::new(0.0, 3.0/16.0, 3.0/16.0),
Point3::new(3.0/16.0, 13.0/16.0, 13.0/16.0))
);
}
collision
},
update_state (world, pos) => Block::ChorusPlant { update_state (world, pos) => Block::ChorusPlant {
north: match world.get_block(pos.shift(Direction::North)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,}, north: match world.get_block(pos.shift(Direction::North)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,},
south: match world.get_block(pos.shift(Direction::South)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,}, south: match world.get_block(pos.shift(Direction::South)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,},
@ -3898,8 +4131,14 @@ define_blocks! {
model { ("minecraft", format!("{}_slab", variant.as_string()) ) }, model { ("minecraft", format!("{}_slab", variant.as_string()) ) },
variant format!("half={},variant=default", half.as_string()), variant format!("half={},variant=default", half.as_string()),
collision match half { collision match half {
BlockHalf::Bottom => vec![Aabb3::new(Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 0.5, 1.0))], BlockHalf::Bottom => vec![Aabb3::new(
BlockHalf::Top => vec![Aabb3::new(Point3::new(0.0, 0.5, 0.0), Point3::new(1.0, 1.0, 1.0))], Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 0.5, 1.0)
)],
BlockHalf::Top => vec![Aabb3::new(
Point3::new(0.0, 0.5, 0.0),
Point3::new(1.0, 1.0, 1.0)
)],
_ => unreachable!(), _ => unreachable!(),
}, },
} }
@ -3922,11 +4161,16 @@ define_blocks! {
props {}, props {},
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "grass_path") }, model { ("minecraft", "grass_path") },
collision vec![Aabb3::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 15.0/16.0, 1.0)
)],
} }
EndGateway { EndGateway {
props {}, props {},
material material::NON_SOLID, material material::NON_SOLID,
model { ("minecraft", "end_gateway") }, model { ("minecraft", "end_gateway") },
collision vec![],
} }
RepeatingCommandBlock { RepeatingCommandBlock {
props { props {
@ -4046,6 +4290,32 @@ fn fence_gate_data(facing: Direction, in_wall: bool, open: bool, powered: bool)
Some(data | (if open { 0x4 } else { 0x0 })) Some(data | (if open { 0x4 } else { 0x0 }))
} }
fn fence_gate_collision(facing: Direction, in_wall: bool, open: bool) -> Vec<Aabb3<f64>> {
if open {
return vec![];
}
let (min_x, min_y, min_z, max_x, max_y, max_z) = if in_wall {
match facing {
Direction::North | Direction::South => (0.0, 0.0, 3.0/8.0, 1.0, 13.0/16.0, 5.0/8.0),
Direction::West | Direction::East => (3.0/8.0, 0.0, 0.0, 5.0/8.0, 13.0/16.0, 1.0),
_ => unreachable!(),
}
} else {
match facing {
Direction::North | Direction::South => (0.0, 0.0, 3.0/8.0, 1.0, 1.0, 5.0/8.0),
Direction::West | Direction::East => (3.0/8.0, 0.0, 0.0, 5.0/8.0, 1.0, 1.0),
_ => unreachable!(),
}
};
vec![Aabb3::new(
Point3::new(min_x, min_y, min_z),
Point3::new(max_x, max_y, max_z)
)]
}
fn door_data(facing: Direction, half: DoorHalf, hinge: Side, open: bool, powered: bool) -> Option<usize> { fn door_data(facing: Direction, half: DoorHalf, hinge: Side, open: bool, powered: bool) -> Option<usize> {
match half { match half {
DoorHalf::Upper => { DoorHalf::Upper => {
@ -4129,6 +4399,219 @@ fn command_block_data(conditional: bool, facing: Direction) -> Option<usize> {
Some(data | (if conditional { 0x8 } else { 0x0 })) Some(data | (if conditional { 0x8 } else { 0x0 }))
} }
fn piston_collision(extended: bool, facing: Direction) -> Vec<Aabb3<f64>> {
let (min_x, min_y, min_z, max_x, max_y, max_z) = if extended {
match facing {
Direction::Up => (0.0, 0.0, 0.0, 1.0, 0.75, 1.0),
Direction::Down => (0.0, 0.25, 0.0, 1.0, 1.0, 1.0),
Direction::North => (0.0, 0.0, 0.25, 1.0, 1.0, 1.0),
Direction::South => (0.0, 0.0, 0.0, 1.0, 1.0, 0.75),
Direction::West => (0.25, 0.0, 0.0, 1.0, 1.0, 0.75),
Direction::East => (0.0, 0.0, 0.0, 0.75, 1.0, 1.0),
_ => unreachable!(),
}
} else {
(0.0, 0.0, 0.0, 1.0, 1.0, 1.0)
};
vec![Aabb3::new(
Point3::new(min_x, min_y, min_z),
Point3::new(max_x, max_y, max_z)
)]
}
fn door_collision(facing: Direction, hinge: Side, open: bool) -> Vec<Aabb3<f64>> {
let (min_x, min_y, min_z, max_x, max_y, max_z) = if open {
if hinge == Side::Left {
match facing {
Direction::North => (1.0 - (3.0 / 16.0), 0.0, 0.0, 1.0, 1.0, 1.0),
Direction::East => (0.0, 0.0, 1.0 - (3.0 / 16.0), 1.0, 1.0, 1.0),
Direction::South => (0.0, 0.0, 0.0, 3.0 / 16.0, 1.0, 1.0),
Direction::West => (0.0, 0.0, 0.0, 1.0, 1.0, 3.0 / 16.0),
_ => unreachable!(),
}
} else {
match facing {
Direction::North => (0.0, 0.0, 0.0, 3.0/16.0, 1.0, 1.0),
Direction::East => (0.0, 0.0, 0.0, 1.0, 1.0, 3.0 / 16.0),
Direction::South => (1.0 - (3.0 / 16.0), 0.0, 0.0, 1.0, 1.0, 1.0),
Direction::West => (0.0, 0.0, 1.0 - (3.0 / 16.0), 1.0, 1.0, 1.0),
_ => unreachable!(),
}
}
} else {
match facing {
Direction::North => (0.0, 0.0, 1.0 - (3.0 / 16.0), 1.0, 1.0, 1.0),
Direction::East => (0.0, 0.0, 0.0, 3.0 / 16.0, 1.0, 1.0),
Direction::South => (0.0, 0.0, 0.0, 1.0, 1.0, 3.0 / 16.0),
Direction::West => (1.0 - (3.0 / 16.0), 0.0, 0.0, 1.0, 1.0, 1.0),
_ => unreachable!(),
}
};
vec![Aabb3::new(
Point3::new(min_x, min_y, min_z),
Point3::new(max_x, max_y, max_z))
]
}
fn trapdoor_collision(facing: Direction, half: BlockHalf, open: bool) -> Vec<Aabb3<f64>> {
let (min_x, min_y, min_z, max_x, max_y, max_z) = if open {
match facing {
Direction::North => (0.0, 0.0, 3.0/16.0, 1.0, 1.0, 1.0),
Direction::South => (0.0, 0.0, 0.0, 1.0, 1.0, 3.0/16.0),
Direction::West => (3.0/16.0, 0.0, 0.0, 1.0, 1.0, 1.0),
Direction::East => (0.0, 0.0, 0.0, 3.0/16.0, 1.0, 1.0),
_ => unreachable!(),
}
} else {
match half {
BlockHalf::Bottom => (0.0, 0.0, 0.0, 1.0, 3.0/16.0, 1.0),
BlockHalf::Top => (0.0, 3.0/16.0, 0.0, 1.0, 1.0, 1.0),
_ => unreachable!(),
}
};
vec![Aabb3::new(
Point3::new(min_x, min_y, min_z),
Point3::new(max_x, max_y, max_z))
]
}
fn fence_collision(north: bool, south: bool, east: bool, west: bool) -> Vec<Aabb3<f64>> {
let mut collision = vec![Aabb3::new(
Point3::new(3.0/8.0, 0.0, 3.0/8.0),
Point3::new(5.0/8.0, 1.5, 5.0/8.0))
];
if north {
collision.push(Aabb3::new(
Point3::new(3.0/8.0, 0.0, 0.0),
Point3::new(5.0/8.0, 1.5, 3.0/8.0))
);
}
if south {
collision.push(Aabb3::new(
Point3::new(3.0/8.0, 0.0, 5.0/8.0),
Point3::new(5.0/8.0, 1.5, 1.0))
);
}
if west {
collision.push(Aabb3::new(
Point3::new(0.0, 0.0, 3.0/8.0),
Point3::new(3.0/8.0, 1.5, 5.0/8.0))
);
}
if east {
collision.push(Aabb3::new(
Point3::new(5.0/8.0, 0.0, 3.0/8.0),
Point3::new(1.0, 1.5, 5.0/8.0))
);
}
collision
}
fn pane_collision(north: bool, south: bool, east: bool, west: bool) -> Vec<Aabb3<f64>> {
let mut collision = vec![Aabb3::new(
Point3::new(7.0/16.0, 0.0, 7.0/16.0),
Point3::new(9.0/16.0, 1.0, 9.0/16.0))
];
if north {
collision.push(Aabb3::new(
Point3::new(7.0/16.0, 0.0, 0.0),
Point3::new(9.0/16.0, 1.0, 9.0/16.0))
);
}
if south {
collision.push(Aabb3::new(
Point3::new(7.0/16.0, 0.0, 7.0/16.0),
Point3::new(9.0/16.0, 1.0, 1.0))
);
}
if west {
collision.push(Aabb3::new(
Point3::new(0.0, 0.0, 7.0/16.0),
Point3::new(9.0/16.0, 1.0, 9.0/16.0))
);
}
if east {
collision.push(Aabb3::new(
Point3::new(7.0/16.0, 0.0, 7.0/16.0),
Point3::new(1.0, 1.0, 9.0/16.0))
);
}
collision
}
fn get_stair_info<W: WorldAccess>(world: &W, pos: Position) -> Option<(Direction, BlockHalf)> {
match world.get_block(pos) {
Block::OakStairs{facing, half, ..} |
Block::StoneStairs{facing, half, ..} |
Block::BrickStairs{facing, half, ..} |
Block::StoneBrickStairs{facing, half, ..} |
Block::NetherBrickStairs{facing, half, ..} |
Block::SandstoneStairs{facing, half, ..} |
Block::SpruceStairs{facing, half, ..} |
Block::BirchStairs{facing, half, ..} |
Block::JungleStairs{facing, half, ..} |
Block::QuartzStairs{facing, half, ..} |
Block::AcaciaStairs{facing, half, ..} |
Block::DarkOakStairs{facing, half, ..} |
Block::RedSandstoneStairs{facing, half, ..} |
Block::PurpurStairs{facing, half, ..} => Some((facing, half)),
_ => None,
}
}
fn update_stair_shape<W: WorldAccess>(world: &W, pos: Position, facing: Direction) -> StairShape {
if let Some((other_facing, _)) = get_stair_info(world, pos.shift(facing)) {
if other_facing != facing && other_facing != facing.opposite() {
if other_facing == facing.clockwise() {
return StairShape::OuterRight;
}
return StairShape::OuterLeft;
}
}
if let Some((other_facing, _)) = get_stair_info(world, pos.shift(facing.opposite())) {
if other_facing != facing && other_facing != facing.opposite() {
if other_facing == facing.clockwise() {
return StairShape::InnerRight;
}
return StairShape::InnerLeft;
}
}
StairShape::Straight
}
fn stair_data(facing: Direction, half: BlockHalf, shape: StairShape) -> Option<usize> {
if shape != StairShape::Straight {
return None;
}
let data = match facing {
Direction::East => 0,
Direction::West => 1,
Direction::South => 2,
Direction::North => 3,
_ => unreachable!(),
};
Some(data | (if half == BlockHalf::Top { 0x4 } else { 0x0 }))
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum StoneVariant { pub enum StoneVariant {
Normal, Normal,
@ -4932,66 +5415,6 @@ impl StairShape {
} }
} }
fn get_stair_info<W: WorldAccess>(world: &W, pos: Position) -> Option<(Direction, BlockHalf)> {
use self::Block::*;
match world.get_block(pos) {
OakStairs{facing, half, ..} |
StoneStairs{facing, half, ..} |
BrickStairs{facing, half, ..} |
StoneBrickStairs{facing, half, ..} |
NetherBrickStairs{facing, half, ..} |
SandstoneStairs{facing, half, ..} |
SpruceStairs{facing, half, ..} |
BirchStairs{facing, half, ..} |
JungleStairs{facing, half, ..} |
QuartzStairs{facing, half, ..} |
AcaciaStairs{facing, half, ..} |
DarkOakStairs{facing, half, ..} |
RedSandstoneStairs{facing, half, ..} |
PurpurStairs{facing, half, ..} => Some((facing, half)),
_ => None,
}
}
fn update_stair_shape<W: WorldAccess>(world: &W, pos: Position, facing: Direction) -> StairShape {
if let Some((other_facing, _)) = get_stair_info(world, pos.shift(facing)) {
if other_facing != facing && other_facing != facing.opposite() {
if other_facing == facing.clockwise() {
return StairShape::OuterRight;
}
return StairShape::OuterLeft;
}
}
if let Some((other_facing, _)) = get_stair_info(world, pos.shift(facing.opposite())) {
if other_facing != facing && other_facing != facing.opposite() {
if other_facing == facing.clockwise() {
return StairShape::InnerRight;
}
return StairShape::InnerLeft;
}
}
StairShape::Straight
}
fn stair_data(facing: Direction, half: BlockHalf, shape: StairShape) -> Option<usize> {
if shape != StairShape::Straight {
return None;
}
let data = match facing {
Direction::East => 0,
Direction::West => 1,
Direction::South => 2,
Direction::North => 3,
_ => unreachable!(),
};
Some(data | (if half == BlockHalf::Top { 0x4 } else { 0x0 }))
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum TreeVariant { pub enum TreeVariant {