Use `matches!` for bool match (clippy match_like_matches_macro)
This commit is contained in:
parent
1234588974
commit
ff90d8af6a
|
@ -2244,10 +2244,7 @@ define_blocks! {
|
||||||
model { ("minecraft", "iron_bars") },
|
model { ("minecraft", "iron_bars") },
|
||||||
collision pane_collision(north, south, east, west),
|
collision pane_collision(north, south, east, west),
|
||||||
update_state (world, pos) => {
|
update_state (world, pos) => {
|
||||||
let f = |block| match block {
|
let f = |block| matches!(block, Block::IronBars{..});
|
||||||
Block::IronBars{..} => true,
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
let (north, south, west, east) = can_connect_sides(world, pos, &f);
|
let (north, south, west, east) = can_connect_sides(world, pos, &f);
|
||||||
Block::IronBars{north, south, west, east, waterlogged}
|
Block::IronBars{north, south, west, east, waterlogged}
|
||||||
|
@ -2573,16 +2570,13 @@ define_blocks! {
|
||||||
model { ("minecraft", "nether_brick_fence") },
|
model { ("minecraft", "nether_brick_fence") },
|
||||||
collision fence_collision(north, south, west, east),
|
collision fence_collision(north, south, west, east),
|
||||||
update_state (world, pos) => {
|
update_state (world, pos) => {
|
||||||
let f = |block| match block {
|
let f = |block| matches!(block, Block::NetherBrickFence{..} |
|
||||||
Block::NetherBrickFence{..} |
|
|
||||||
Block::FenceGate{..} |
|
Block::FenceGate{..} |
|
||||||
Block::SpruceFenceGate{..} |
|
Block::SpruceFenceGate{..} |
|
||||||
Block::BirchFenceGate{..} |
|
Block::BirchFenceGate{..} |
|
||||||
Block::JungleFenceGate{..} |
|
Block::JungleFenceGate{..} |
|
||||||
Block::DarkOakFenceGate{..} |
|
Block::DarkOakFenceGate{..} |
|
||||||
Block::AcaciaFenceGate{..} => true,
|
Block::AcaciaFenceGate{..});
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
let (north, south, west, east) = can_connect_sides(world, pos, &f);
|
let (north, south, west, east) = can_connect_sides(world, pos, &f);
|
||||||
Block::NetherBrickFence{north, south, west, east, waterlogged}
|
Block::NetherBrickFence{north, south, west, east, waterlogged}
|
||||||
|
@ -3074,22 +3068,17 @@ define_blocks! {
|
||||||
material material::NON_SOLID,
|
material material::NON_SOLID,
|
||||||
model { ("minecraft", format!("{}_wall", variant.as_string())) },
|
model { ("minecraft", format!("{}_wall", variant.as_string())) },
|
||||||
update_state (world, pos) => {
|
update_state (world, pos) => {
|
||||||
let f = |block| match block {
|
let f = |block| matches!(block, Block::CobblestoneWall{..} |
|
||||||
Block::CobblestoneWall{..} |
|
|
||||||
Block::FenceGate{..} |
|
Block::FenceGate{..} |
|
||||||
Block::SpruceFenceGate{..} |
|
Block::SpruceFenceGate{..} |
|
||||||
Block::BirchFenceGate{..} |
|
Block::BirchFenceGate{..} |
|
||||||
Block::JungleFenceGate{..} |
|
Block::JungleFenceGate{..} |
|
||||||
Block::DarkOakFenceGate{..} |
|
Block::DarkOakFenceGate{..} |
|
||||||
Block::AcaciaFenceGate{..} => true,
|
Block::AcaciaFenceGate{..});
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
let (north, south, west, east) = can_connect_sides(world, pos, &f);
|
let (north, south, west, east) = can_connect_sides(world, pos, &f);
|
||||||
let up = !(match world.get_block(pos.shift(Direction::Up)) {
|
let up = !(matches!(world.get_block(pos.shift(Direction::Up)), Block::Air{..}))
|
||||||
Block::Air{..} => true,
|
|| !((north && south && !west && !east) || (!north && !south && west && east));
|
||||||
_ => false,
|
|
||||||
}) || !((north && south && !west && !east) || (!north && !south && west && east));
|
|
||||||
Block::CobblestoneWall{up, north, south, west, east, variant, waterlogged}
|
Block::CobblestoneWall{up, north, south, west, east, variant, waterlogged}
|
||||||
},
|
},
|
||||||
multipart (key, val) => match key {
|
multipart (key, val) => match key {
|
||||||
|
@ -4685,12 +4674,12 @@ define_blocks! {
|
||||||
collision
|
collision
|
||||||
},
|
},
|
||||||
update_state (world, pos) => Block::ChorusPlant {
|
update_state (world, pos) => Block::ChorusPlant {
|
||||||
up: match world.get_block(pos.shift(Direction::Up)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,},
|
up: matches!(world.get_block(pos.shift(Direction::Up)), Block::ChorusPlant{..} | Block::ChorusFlower{..}),
|
||||||
down: match world.get_block(pos.shift(Direction::Down)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} | Block::EndStone{..} => true, _ => false,},
|
down: matches!(world.get_block(pos.shift(Direction::Down)), Block::ChorusPlant{..} | Block::ChorusFlower{..} | Block::EndStone{..}),
|
||||||
north: match world.get_block(pos.shift(Direction::North)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,},
|
north: matches!(world.get_block(pos.shift(Direction::North)), Block::ChorusPlant{..} | Block::ChorusFlower{..}),
|
||||||
south: match world.get_block(pos.shift(Direction::South)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,},
|
south: matches!(world.get_block(pos.shift(Direction::South)), Block::ChorusPlant{..} | Block::ChorusFlower{..}),
|
||||||
west: match world.get_block(pos.shift(Direction::West)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,},
|
west: matches!(world.get_block(pos.shift(Direction::West)), Block::ChorusPlant{..} | Block::ChorusFlower{..}),
|
||||||
east: match world.get_block(pos.shift(Direction::East)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,},
|
east: matches!(world.get_block(pos.shift(Direction::East)), Block::ChorusPlant{..} | Block::ChorusFlower{..}),
|
||||||
},
|
},
|
||||||
multipart (key, val) => match key {
|
multipart (key, val) => match key {
|
||||||
"up" => up == (val == "true"),
|
"up" => up == (val == "true"),
|
||||||
|
@ -5625,8 +5614,7 @@ define_blocks! {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn can_burn<W: WorldAccess>(world: &W, pos: Position) -> bool {
|
fn can_burn<W: WorldAccess>(world: &W, pos: Position) -> bool {
|
||||||
match world.get_block(pos) {
|
matches!(world.get_block(pos), Block::Planks { .. }
|
||||||
Block::Planks { .. }
|
|
||||||
| Block::DoubleWoodenSlab { .. }
|
| Block::DoubleWoodenSlab { .. }
|
||||||
| Block::WoodenSlab { .. }
|
| Block::WoodenSlab { .. }
|
||||||
| Block::FenceGate { .. }
|
| Block::FenceGate { .. }
|
||||||
|
@ -5662,16 +5650,11 @@ fn can_burn<W: WorldAccess>(world: &W, pos: Position) -> bool {
|
||||||
| Block::Vine { .. }
|
| Block::Vine { .. }
|
||||||
| Block::CoalBlock { .. }
|
| Block::CoalBlock { .. }
|
||||||
| Block::HayBlock { .. }
|
| Block::HayBlock { .. }
|
||||||
| Block::Carpet { .. } => true,
|
| Block::Carpet { .. })
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_snowy<W: WorldAccess>(world: &W, pos: Position) -> bool {
|
fn is_snowy<W: WorldAccess>(world: &W, pos: Position) -> bool {
|
||||||
match world.get_block(pos.shift(Direction::Up)) {
|
matches!(world.get_block(pos.shift(Direction::Up)), Block::Snow { .. } | Block::SnowLayer { .. })
|
||||||
Block::Snow { .. } | Block::SnowLayer { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn can_connect_sides<F: Fn(Block) -> bool, W: WorldAccess>(
|
fn can_connect_sides<F: Fn(Block) -> bool, W: WorldAccess>(
|
||||||
|
@ -5693,8 +5676,7 @@ fn can_connect<F: Fn(Block) -> bool, W: WorldAccess>(world: &W, pos: Position, f
|
||||||
}
|
}
|
||||||
|
|
||||||
fn can_connect_fence(block: Block) -> bool {
|
fn can_connect_fence(block: Block) -> bool {
|
||||||
match block {
|
matches!(block, Block::Fence { .. }
|
||||||
Block::Fence { .. }
|
|
||||||
| Block::SpruceFence { .. }
|
| Block::SpruceFence { .. }
|
||||||
| Block::BirchFence { .. }
|
| Block::BirchFence { .. }
|
||||||
| Block::JungleFence { .. }
|
| Block::JungleFence { .. }
|
||||||
|
@ -5705,19 +5687,14 @@ fn can_connect_fence(block: Block) -> bool {
|
||||||
| Block::BirchFenceGate { .. }
|
| Block::BirchFenceGate { .. }
|
||||||
| Block::JungleFenceGate { .. }
|
| Block::JungleFenceGate { .. }
|
||||||
| Block::DarkOakFenceGate { .. }
|
| Block::DarkOakFenceGate { .. }
|
||||||
| Block::AcaciaFenceGate { .. } => true,
|
| Block::AcaciaFenceGate { .. })
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn can_connect_glasspane(block: Block) -> bool {
|
fn can_connect_glasspane(block: Block) -> bool {
|
||||||
match block {
|
matches!(block, Block::Glass { .. }
|
||||||
Block::Glass { .. }
|
|
||||||
| Block::StainedGlass { .. }
|
| Block::StainedGlass { .. }
|
||||||
| Block::GlassPane { .. }
|
| Block::GlassPane { .. }
|
||||||
| Block::StainedGlassPane { .. } => true,
|
| Block::StainedGlassPane { .. })
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn can_connect_redstone<W: WorldAccess>(world: &W, pos: Position, dir: Direction) -> RedstoneSide {
|
fn can_connect_redstone<W: WorldAccess>(world: &W, pos: Position, dir: Direction) -> RedstoneSide {
|
||||||
|
@ -5728,11 +5705,7 @@ fn can_connect_redstone<W: WorldAccess>(world: &W, pos: Position, dir: Direction
|
||||||
let side_up = world.get_block(shift_pos.shift(Direction::Up));
|
let side_up = world.get_block(shift_pos.shift(Direction::Up));
|
||||||
let up = world.get_block(pos.shift(Direction::Up));
|
let up = world.get_block(pos.shift(Direction::Up));
|
||||||
|
|
||||||
if match side_up {
|
if matches!(side_up, Block::RedstoneWire { .. }) && !up.get_material().should_cull_against {
|
||||||
Block::RedstoneWire { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
} && !up.get_material().should_cull_against
|
|
||||||
{
|
|
||||||
return RedstoneSide::Up;
|
return RedstoneSide::Up;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5740,13 +5713,9 @@ fn can_connect_redstone<W: WorldAccess>(world: &W, pos: Position, dir: Direction
|
||||||
}
|
}
|
||||||
|
|
||||||
let side_down = world.get_block(shift_pos.shift(Direction::Down));
|
let side_down = world.get_block(shift_pos.shift(Direction::Down));
|
||||||
if match block {
|
if matches!(block, Block::RedstoneWire { .. })
|
||||||
Block::RedstoneWire { .. } => true,
|
|| matches!(side_down, Block::RedstoneWire { .. })
|
||||||
_ => false,
|
{
|
||||||
} || match side_down {
|
|
||||||
Block::RedstoneWire { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
} {
|
|
||||||
return RedstoneSide::Side;
|
return RedstoneSide::Side;
|
||||||
}
|
}
|
||||||
RedstoneSide::None
|
RedstoneSide::None
|
||||||
|
@ -5960,10 +5929,7 @@ fn door_collision(facing: Direction, hinge: Side, open: bool) -> Vec<Aabb3<f64>>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_repeater_state<W: WorldAccess>(world: &W, pos: Position, facing: Direction) -> bool {
|
fn update_repeater_state<W: WorldAccess>(world: &W, pos: Position, facing: Direction) -> bool {
|
||||||
let f = |dir| match world.get_block(pos.shift(dir)) {
|
let f = |dir| matches!(world.get_block(pos.shift(dir)), Block::RepeaterPowered { .. });
|
||||||
Block::RepeaterPowered { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
f(facing.clockwise()) || f(facing.counter_clockwise())
|
f(facing.clockwise()) || f(facing.counter_clockwise())
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,10 +72,7 @@ impl Tag {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_compound(&self) -> bool {
|
pub fn is_compound(&self) -> bool {
|
||||||
match *self {
|
matches!(*self, Tag::Compound(_))
|
||||||
Tag::Compound(_) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_byte(&self) -> Option<i8> {
|
pub fn as_byte(&self) -> Option<i8> {
|
||||||
|
|
|
@ -39,23 +39,14 @@ impl Gamemode {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn can_fly(&self) -> bool {
|
pub fn can_fly(&self) -> bool {
|
||||||
match *self {
|
matches!(*self, Gamemode::Creative | Gamemode::Spectator)
|
||||||
Gamemode::Creative | Gamemode::Spectator => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn always_fly(&self) -> bool {
|
pub fn always_fly(&self) -> bool {
|
||||||
match *self {
|
matches!(*self, Gamemode::Spectator)
|
||||||
Gamemode::Spectator => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noclip(&self) -> bool {
|
pub fn noclip(&self) -> bool {
|
||||||
match *self {
|
matches!(*self, Gamemode::Spectator)
|
||||||
Gamemode::Spectator => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1110,11 +1110,7 @@ fn calculate_light(
|
||||||
let lz = (z + oz + dz).round() as i32;
|
let lz = (z + oz + dz).round() as i32;
|
||||||
let mut bl = snapshot.get_block_light(lx, ly, lz);
|
let mut bl = snapshot.get_block_light(lx, ly, lz);
|
||||||
let mut sl = snapshot.get_sky_light(lx, ly, lz);
|
let mut sl = snapshot.get_sky_light(lx, ly, lz);
|
||||||
if (force
|
if (force && !matches!(snapshot.get_block(lx, ly, lz), block::Air {}))
|
||||||
&& match snapshot.get_block(lx, ly, lz) {
|
|
||||||
block::Air {} => false,
|
|
||||||
_ => true,
|
|
||||||
})
|
|
||||||
|| (sl == 0 && bl == 0)
|
|| (sl == 0 && bl == 0)
|
||||||
{
|
{
|
||||||
bl = s_block_light;
|
bl = s_block_light;
|
||||||
|
|
Loading…
Reference in New Issue