Skip to content

Commit

Permalink
Update to Rust 1.47.0 (iceiix#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
iceiix authored Oct 10, 2020
2 parents ab46000 + ff90d8a commit f4414e7
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.44.1
toolchain: 1.47.0
components: clippy, rustfmt
default: true
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ from [GitHub Actions](https://actions-badge.atrox.dev/iceiix/stevenarella/goto?r

## Dependencies

Requires Rust stable version 1.44.1 or newer.
Requires Rust stable version 1.47.0 or newer.

**Debian/Ubuntu**

Expand Down
84 changes: 25 additions & 59 deletions blocks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2244,10 +2244,7 @@ define_blocks! {
model { ("minecraft", "iron_bars") },
collision pane_collision(north, south, east, west),
update_state (world, pos) => {
let f = |block| match block {
Block::IronBars{..} => true,
_ => false,
};
let f = |block| matches!(block, Block::IronBars{..});

let (north, south, west, east) = can_connect_sides(world, pos, &f);
Block::IronBars{north, south, west, east, waterlogged}
Expand Down Expand Up @@ -2573,16 +2570,13 @@ define_blocks! {
model { ("minecraft", "nether_brick_fence") },
collision fence_collision(north, south, west, east),
update_state (world, pos) => {
let f = |block| match block {
Block::NetherBrickFence{..} |
let f = |block| matches!(block, Block::NetherBrickFence{..} |
Block::FenceGate{..} |
Block::SpruceFenceGate{..} |
Block::BirchFenceGate{..} |
Block::JungleFenceGate{..} |
Block::DarkOakFenceGate{..} |
Block::AcaciaFenceGate{..} => true,
_ => false,
};
Block::AcaciaFenceGate{..});

let (north, south, west, east) = can_connect_sides(world, pos, &f);
Block::NetherBrickFence{north, south, west, east, waterlogged}
Expand Down Expand Up @@ -3074,22 +3068,17 @@ define_blocks! {
material material::NON_SOLID,
model { ("minecraft", format!("{}_wall", variant.as_string())) },
update_state (world, pos) => {
let f = |block| match block {
Block::CobblestoneWall{..} |
let f = |block| matches!(block, Block::CobblestoneWall{..} |
Block::FenceGate{..} |
Block::SpruceFenceGate{..} |
Block::BirchFenceGate{..} |
Block::JungleFenceGate{..} |
Block::DarkOakFenceGate{..} |
Block::AcaciaFenceGate{..} => true,
_ => false,
};
Block::AcaciaFenceGate{..});

let (north, south, west, east) = can_connect_sides(world, pos, &f);
let up = !(match world.get_block(pos.shift(Direction::Up)) {
Block::Air{..} => true,
_ => false,
}) || !((north && south && !west && !east) || (!north && !south && west && east));
let up = !(matches!(world.get_block(pos.shift(Direction::Up)), Block::Air{..}))
|| !((north && south && !west && !east) || (!north && !south && west && east));
Block::CobblestoneWall{up, north, south, west, east, variant, waterlogged}
},
multipart (key, val) => match key {
Expand Down Expand Up @@ -4685,12 +4674,12 @@ define_blocks! {
collision
},
update_state (world, pos) => Block::ChorusPlant {
up: match world.get_block(pos.shift(Direction::Up)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,},
down: match world.get_block(pos.shift(Direction::Down)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} | Block::EndStone{..} => 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,},
west: match world.get_block(pos.shift(Direction::West)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,},
east: match world.get_block(pos.shift(Direction::East)) { Block::ChorusPlant{..} | Block::ChorusFlower{..} => true, _ => false,},
up: matches!(world.get_block(pos.shift(Direction::Up)), Block::ChorusPlant{..} | Block::ChorusFlower{..}),
down: matches!(world.get_block(pos.shift(Direction::Down)), Block::ChorusPlant{..} | Block::ChorusFlower{..} | Block::EndStone{..}),
north: matches!(world.get_block(pos.shift(Direction::North)), Block::ChorusPlant{..} | Block::ChorusFlower{..}),
south: matches!(world.get_block(pos.shift(Direction::South)), Block::ChorusPlant{..} | Block::ChorusFlower{..}),
west: matches!(world.get_block(pos.shift(Direction::West)), Block::ChorusPlant{..} | Block::ChorusFlower{..}),
east: matches!(world.get_block(pos.shift(Direction::East)), Block::ChorusPlant{..} | Block::ChorusFlower{..}),
},
multipart (key, val) => match key {
"up" => up == (val == "true"),
Expand Down Expand Up @@ -5625,8 +5614,7 @@ define_blocks! {
}

fn can_burn<W: WorldAccess>(world: &W, pos: Position) -> bool {
match world.get_block(pos) {
Block::Planks { .. }
matches!(world.get_block(pos), Block::Planks { .. }
| Block::DoubleWoodenSlab { .. }
| Block::WoodenSlab { .. }
| Block::FenceGate { .. }
Expand Down Expand Up @@ -5662,16 +5650,11 @@ fn can_burn<W: WorldAccess>(world: &W, pos: Position) -> bool {
| Block::Vine { .. }
| Block::CoalBlock { .. }
| Block::HayBlock { .. }
| Block::Carpet { .. } => true,
_ => false,
}
| Block::Carpet { .. })
}

fn is_snowy<W: WorldAccess>(world: &W, pos: Position) -> bool {
match world.get_block(pos.shift(Direction::Up)) {
Block::Snow { .. } | Block::SnowLayer { .. } => true,
_ => false,
}
matches!(world.get_block(pos.shift(Direction::Up)), Block::Snow { .. } | Block::SnowLayer { .. })
}

fn can_connect_sides<F: Fn(Block) -> bool, W: WorldAccess>(
Expand All @@ -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 {
match block {
Block::Fence { .. }
matches!(block, Block::Fence { .. }
| Block::SpruceFence { .. }
| Block::BirchFence { .. }
| Block::JungleFence { .. }
Expand All @@ -5705,19 +5687,14 @@ fn can_connect_fence(block: Block) -> bool {
| Block::BirchFenceGate { .. }
| Block::JungleFenceGate { .. }
| Block::DarkOakFenceGate { .. }
| Block::AcaciaFenceGate { .. } => true,
_ => false,
}
| Block::AcaciaFenceGate { .. })
}

fn can_connect_glasspane(block: Block) -> bool {
match block {
Block::Glass { .. }
matches!(block, Block::Glass { .. }
| Block::StainedGlass { .. }
| Block::GlassPane { .. }
| Block::StainedGlassPane { .. } => true,
_ => false,
}
| Block::StainedGlassPane { .. })
}

fn can_connect_redstone<W: WorldAccess>(world: &W, pos: Position, dir: Direction) -> RedstoneSide {
Expand All @@ -5728,25 +5705,17 @@ fn can_connect_redstone<W: WorldAccess>(world: &W, pos: Position, dir: Direction
let side_up = world.get_block(shift_pos.shift(Direction::Up));
let up = world.get_block(pos.shift(Direction::Up));

if match side_up {
Block::RedstoneWire { .. } => true,
_ => false,
} && !up.get_material().should_cull_against
{
if matches!(side_up, Block::RedstoneWire { .. }) && !up.get_material().should_cull_against {
return RedstoneSide::Up;
}

return RedstoneSide::None;
}

let side_down = world.get_block(shift_pos.shift(Direction::Down));
if match block {
Block::RedstoneWire { .. } => true,
_ => false,
} || match side_down {
Block::RedstoneWire { .. } => true,
_ => false,
} {
if matches!(block, Block::RedstoneWire { .. })
|| matches!(side_down, Block::RedstoneWire { .. })
{
return RedstoneSide::Side;
}
RedstoneSide::None
Expand Down Expand Up @@ -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 {
let f = |dir| match world.get_block(pos.shift(dir)) {
Block::RepeaterPowered { .. } => true,
_ => false,
};
let f = |dir| matches!(world.get_block(pos.shift(dir)), Block::RepeaterPowered { .. });

f(facing.clockwise()) || f(facing.counter_clockwise())
}
Expand Down
Loading

0 comments on commit f4414e7

Please sign in to comment.