Fix formatting
This commit is contained in:
parent
4ac2a8dafa
commit
ee8e6cb9f3
|
@ -6647,97 +6647,199 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn verify_blocks() {
|
fn verify_blocks() {
|
||||||
let dirt = Block::Dirt { snowy: true, variant: DirtVariant::Normal };
|
let dirt = Block::Dirt {
|
||||||
let stone = Block::Stone { variant: StoneVariant::Normal };
|
snowy: true,
|
||||||
let vine = Block::Vine { up: false, south: false, west: false, north: true, east: false };
|
variant: DirtVariant::Normal,
|
||||||
let pumpkin_lit = Block::PumpkinLit { facing: Direction::North, without_face: true };
|
};
|
||||||
let cocoa = Block::Cocoa { age: 1, facing: Direction::North };
|
let stone = Block::Stone {
|
||||||
let leaves = Block::Leaves { variant: TreeVariant::Oak, decayable: false, check_decay: false, distance: 1 };
|
variant: StoneVariant::Normal,
|
||||||
let leaves2 = Block::Leaves2 { variant: TreeVariant::Oak, decayable: false, check_decay: false };
|
};
|
||||||
let wool = Block::Wool { color: ColoredVariant::White };
|
let vine = Block::Vine {
|
||||||
let tall_seagrass = Block::TallSeagrass { half: TallSeagrassHalf::Upper };
|
up: false,
|
||||||
|
south: false,
|
||||||
|
west: false,
|
||||||
|
north: true,
|
||||||
|
east: false,
|
||||||
|
};
|
||||||
|
let pumpkin_lit = Block::PumpkinLit {
|
||||||
|
facing: Direction::North,
|
||||||
|
without_face: true,
|
||||||
|
};
|
||||||
|
let cocoa = Block::Cocoa {
|
||||||
|
age: 1,
|
||||||
|
facing: Direction::North,
|
||||||
|
};
|
||||||
|
let leaves = Block::Leaves {
|
||||||
|
variant: TreeVariant::Oak,
|
||||||
|
decayable: false,
|
||||||
|
check_decay: false,
|
||||||
|
distance: 1,
|
||||||
|
};
|
||||||
|
let leaves2 = Block::Leaves2 {
|
||||||
|
variant: TreeVariant::Oak,
|
||||||
|
decayable: false,
|
||||||
|
check_decay: false,
|
||||||
|
};
|
||||||
|
let wool = Block::Wool {
|
||||||
|
color: ColoredVariant::White,
|
||||||
|
};
|
||||||
|
let tall_seagrass = Block::TallSeagrass {
|
||||||
|
half: TallSeagrassHalf::Upper,
|
||||||
|
};
|
||||||
let data = [
|
let data = [
|
||||||
(dirt, None, Some(0.75)),
|
(dirt, None, Some(0.75)),
|
||||||
(dirt, Some(Tool::Shovel(ToolMaterial::Wood)), Some(0.4)),
|
(dirt, Some(Tool::Shovel(ToolMaterial::Wood)), Some(0.4)),
|
||||||
(dirt, Some(Tool::Pickaxe(ToolMaterial::Wood)), Some(0.75)),
|
(dirt, Some(Tool::Pickaxe(ToolMaterial::Wood)), Some(0.75)),
|
||||||
|
|
||||||
(stone, None, Some(7.5)),
|
(stone, None, Some(7.5)),
|
||||||
(stone, Some(Tool::Shovel(ToolMaterial::Wood)), Some(7.5)),
|
(stone, Some(Tool::Shovel(ToolMaterial::Wood)), Some(7.5)),
|
||||||
(stone, Some(Tool::Pickaxe(ToolMaterial::Wood)), Some(1.15)),
|
(stone, Some(Tool::Pickaxe(ToolMaterial::Wood)), Some(1.15)),
|
||||||
|
|
||||||
(Block::Obsidian {}, None, Some(250.0)),
|
(Block::Obsidian {}, None, Some(250.0)),
|
||||||
(Block::Obsidian {}, Some(Tool::Pickaxe(ToolMaterial::Wood)), Some(125.0)),
|
(
|
||||||
(Block::Obsidian {}, Some(Tool::Pickaxe(ToolMaterial::Stone)), Some(62.5)),
|
Block::Obsidian {},
|
||||||
(Block::Obsidian {}, Some(Tool::Pickaxe(ToolMaterial::Iron)), Some(41.7)),
|
Some(Tool::Pickaxe(ToolMaterial::Wood)),
|
||||||
(Block::Obsidian {}, Some(Tool::Pickaxe(ToolMaterial::Diamond)), Some(9.4)),
|
Some(125.0),
|
||||||
(Block::Obsidian {}, Some(Tool::Pickaxe(ToolMaterial::Netherite)), Some(8.35)),
|
),
|
||||||
(Block::Obsidian {}, Some(Tool::Pickaxe(ToolMaterial::Gold)), Some(20.85)),
|
(
|
||||||
|
Block::Obsidian {},
|
||||||
|
Some(Tool::Pickaxe(ToolMaterial::Stone)),
|
||||||
|
Some(62.5),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::Obsidian {},
|
||||||
|
Some(Tool::Pickaxe(ToolMaterial::Iron)),
|
||||||
|
Some(41.7),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::Obsidian {},
|
||||||
|
Some(Tool::Pickaxe(ToolMaterial::Diamond)),
|
||||||
|
Some(9.4),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::Obsidian {},
|
||||||
|
Some(Tool::Pickaxe(ToolMaterial::Netherite)),
|
||||||
|
Some(8.35),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::Obsidian {},
|
||||||
|
Some(Tool::Pickaxe(ToolMaterial::Gold)),
|
||||||
|
Some(20.85),
|
||||||
|
),
|
||||||
(Block::Bedrock {}, None, None),
|
(Block::Bedrock {}, None, None),
|
||||||
(Block::Bedrock {}, Some(Tool::Pickaxe(ToolMaterial::Wood)), None),
|
(
|
||||||
(Block::Bedrock {}, Some(Tool::Pickaxe(ToolMaterial::Stone)), None),
|
Block::Bedrock {},
|
||||||
(Block::Bedrock {}, Some(Tool::Pickaxe(ToolMaterial::Iron)), None),
|
Some(Tool::Pickaxe(ToolMaterial::Wood)),
|
||||||
(Block::Bedrock {}, Some(Tool::Pickaxe(ToolMaterial::Diamond)), None),
|
None,
|
||||||
(Block::Bedrock {}, Some(Tool::Pickaxe(ToolMaterial::Netherite)), None),
|
),
|
||||||
(Block::Bedrock {}, Some(Tool::Pickaxe(ToolMaterial::Gold)), None),
|
(
|
||||||
|
Block::Bedrock {},
|
||||||
|
Some(Tool::Pickaxe(ToolMaterial::Stone)),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::Bedrock {},
|
||||||
|
Some(Tool::Pickaxe(ToolMaterial::Iron)),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::Bedrock {},
|
||||||
|
Some(Tool::Pickaxe(ToolMaterial::Diamond)),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::Bedrock {},
|
||||||
|
Some(Tool::Pickaxe(ToolMaterial::Netherite)),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::Bedrock {},
|
||||||
|
Some(Tool::Pickaxe(ToolMaterial::Gold)),
|
||||||
|
None,
|
||||||
|
),
|
||||||
(Block::Web {}, None, Some(20.0)),
|
(Block::Web {}, None, Some(20.0)),
|
||||||
(Block::Web {}, Some(Tool::Pickaxe(ToolMaterial::Wood)), Some(20.0)),
|
(
|
||||||
|
Block::Web {},
|
||||||
|
Some(Tool::Pickaxe(ToolMaterial::Wood)),
|
||||||
|
Some(20.0),
|
||||||
|
),
|
||||||
(vine, None, Some(0.3)),
|
(vine, None, Some(0.3)),
|
||||||
(vine, Some(Tool::Pickaxe(ToolMaterial::Wood)), Some(0.3)),
|
(vine, Some(Tool::Pickaxe(ToolMaterial::Wood)), Some(0.3)),
|
||||||
(vine, Some(Tool::Axe(ToolMaterial::Wood)), Some(0.15)),
|
(vine, Some(Tool::Axe(ToolMaterial::Wood)), Some(0.15)),
|
||||||
(vine, Some(Tool::Axe(ToolMaterial::Stone)), Some(0.1)),
|
(vine, Some(Tool::Axe(ToolMaterial::Stone)), Some(0.1)),
|
||||||
(vine, Some(Tool::Axe(ToolMaterial::Iron)), Some(0.05)),
|
(vine, Some(Tool::Axe(ToolMaterial::Iron)), Some(0.05)),
|
||||||
(vine, Some(Tool::Axe(ToolMaterial::Diamond)), Some(0.05)),
|
(vine, Some(Tool::Axe(ToolMaterial::Diamond)), Some(0.05)),
|
||||||
|
|
||||||
(wool, None, Some(1.2)),
|
(wool, None, Some(1.2)),
|
||||||
|
|
||||||
(leaves, None, Some(0.3)),
|
(leaves, None, Some(0.3)),
|
||||||
(leaves, Some(Tool::Hoe(ToolMaterial::Wood)), Some(0.15)),
|
(leaves, Some(Tool::Hoe(ToolMaterial::Wood)), Some(0.15)),
|
||||||
(leaves, Some(Tool::Hoe(ToolMaterial::Stone)), Some(0.1)),
|
(leaves, Some(Tool::Hoe(ToolMaterial::Stone)), Some(0.1)),
|
||||||
(leaves, Some(Tool::Hoe(ToolMaterial::Iron)), Some(0.05)),
|
(leaves, Some(Tool::Hoe(ToolMaterial::Iron)), Some(0.05)),
|
||||||
(leaves, Some(Tool::Hoe(ToolMaterial::Diamond)), Some(0.05)),
|
(leaves, Some(Tool::Hoe(ToolMaterial::Diamond)), Some(0.05)),
|
||||||
|
|
||||||
(leaves2, None, Some(0.3)),
|
(leaves2, None, Some(0.3)),
|
||||||
(leaves2, Some(Tool::Hoe(ToolMaterial::Wood)), Some(0.15)),
|
(leaves2, Some(Tool::Hoe(ToolMaterial::Wood)), Some(0.15)),
|
||||||
(leaves2, Some(Tool::Hoe(ToolMaterial::Stone)), Some(0.1)),
|
(leaves2, Some(Tool::Hoe(ToolMaterial::Stone)), Some(0.1)),
|
||||||
(leaves2, Some(Tool::Hoe(ToolMaterial::Iron)), Some(0.05)),
|
(leaves2, Some(Tool::Hoe(ToolMaterial::Iron)), Some(0.05)),
|
||||||
(leaves2, Some(Tool::Hoe(ToolMaterial::Diamond)), Some(0.05)),
|
(leaves2, Some(Tool::Hoe(ToolMaterial::Diamond)), Some(0.05)),
|
||||||
|
|
||||||
(Block::DeadBush {}, None, Some(0.05)),
|
(Block::DeadBush {}, None, Some(0.05)),
|
||||||
(Block::DeadBush {}, Some(Tool::Shears), Some(0.05)),
|
(Block::DeadBush {}, Some(Tool::Shears), Some(0.05)),
|
||||||
|
|
||||||
(Block::Seagrass {}, None, Some(0.05)),
|
(Block::Seagrass {}, None, Some(0.05)),
|
||||||
(Block::Seagrass {}, Some(Tool::Shears), Some(0.05)),
|
(Block::Seagrass {}, Some(Tool::Shears), Some(0.05)),
|
||||||
|
|
||||||
(tall_seagrass, None, Some(0.05)),
|
(tall_seagrass, None, Some(0.05)),
|
||||||
(tall_seagrass, Some(Tool::Shears), Some(0.05)),
|
(tall_seagrass, Some(Tool::Shears), Some(0.05)),
|
||||||
|
|
||||||
(cocoa, None, Some(0.3)),
|
(cocoa, None, Some(0.3)),
|
||||||
(cocoa, Some(Tool::Axe(ToolMaterial::Wood)), Some(0.15)),
|
(cocoa, Some(Tool::Axe(ToolMaterial::Wood)), Some(0.15)),
|
||||||
(cocoa, Some(Tool::Axe(ToolMaterial::Stone)), Some(0.1)),
|
(cocoa, Some(Tool::Axe(ToolMaterial::Stone)), Some(0.1)),
|
||||||
(cocoa, Some(Tool::Axe(ToolMaterial::Iron)), Some(0.05)),
|
(cocoa, Some(Tool::Axe(ToolMaterial::Iron)), Some(0.05)),
|
||||||
(cocoa, Some(Tool::Axe(ToolMaterial::Diamond)), Some(0.05)),
|
(cocoa, Some(Tool::Axe(ToolMaterial::Diamond)), Some(0.05)),
|
||||||
|
|
||||||
(Block::MelonBlock {}, None, Some(1.5)),
|
(Block::MelonBlock {}, None, Some(1.5)),
|
||||||
(Block::MelonBlock {}, Some(Tool::Axe(ToolMaterial::Wood)), Some(0.75)),
|
(
|
||||||
(Block::MelonBlock {}, Some(Tool::Axe(ToolMaterial::Stone)), Some(0.4)),
|
Block::MelonBlock {},
|
||||||
(Block::MelonBlock {}, Some(Tool::Axe(ToolMaterial::Iron)), Some(0.25)),
|
Some(Tool::Axe(ToolMaterial::Wood)),
|
||||||
(Block::MelonBlock {}, Some(Tool::Axe(ToolMaterial::Diamond)), Some(0.2)),
|
Some(0.75),
|
||||||
(Block::MelonBlock {}, Some(Tool::Axe(ToolMaterial::Netherite)), Some(0.2)),
|
),
|
||||||
(Block::MelonBlock {}, Some(Tool::Axe(ToolMaterial::Gold)), Some(0.15)),
|
(
|
||||||
|
Block::MelonBlock {},
|
||||||
|
Some(Tool::Axe(ToolMaterial::Stone)),
|
||||||
|
Some(0.4),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::MelonBlock {},
|
||||||
|
Some(Tool::Axe(ToolMaterial::Iron)),
|
||||||
|
Some(0.25),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::MelonBlock {},
|
||||||
|
Some(Tool::Axe(ToolMaterial::Diamond)),
|
||||||
|
Some(0.2),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::MelonBlock {},
|
||||||
|
Some(Tool::Axe(ToolMaterial::Netherite)),
|
||||||
|
Some(0.2),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::MelonBlock {},
|
||||||
|
Some(Tool::Axe(ToolMaterial::Gold)),
|
||||||
|
Some(0.15),
|
||||||
|
),
|
||||||
(Block::Pumpkin {}, None, Some(1.5)),
|
(Block::Pumpkin {}, None, Some(1.5)),
|
||||||
(Block::Pumpkin {}, Some(Tool::Axe(ToolMaterial::Wood)), Some(0.75)),
|
(
|
||||||
(Block::Pumpkin {}, Some(Tool::Axe(ToolMaterial::Stone)), Some(0.4)),
|
Block::Pumpkin {},
|
||||||
(Block::Pumpkin {}, Some(Tool::Axe(ToolMaterial::Iron)), Some(0.25)),
|
Some(Tool::Axe(ToolMaterial::Wood)),
|
||||||
|
Some(0.75),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::Pumpkin {},
|
||||||
|
Some(Tool::Axe(ToolMaterial::Stone)),
|
||||||
|
Some(0.4),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
Block::Pumpkin {},
|
||||||
|
Some(Tool::Axe(ToolMaterial::Iron)),
|
||||||
|
Some(0.25),
|
||||||
|
),
|
||||||
(pumpkin_lit, None, Some(1.5)),
|
(pumpkin_lit, None, Some(1.5)),
|
||||||
(pumpkin_lit, Some(Tool::Axe(ToolMaterial::Wood)), Some(0.75)),
|
(pumpkin_lit, Some(Tool::Axe(ToolMaterial::Wood)), Some(0.75)),
|
||||||
(pumpkin_lit, Some(Tool::Axe(ToolMaterial::Stone)), Some(0.4)),
|
(pumpkin_lit, Some(Tool::Axe(ToolMaterial::Stone)), Some(0.4)),
|
||||||
(pumpkin_lit, Some(Tool::Axe(ToolMaterial::Iron)), Some(0.25)),
|
(pumpkin_lit, Some(Tool::Axe(ToolMaterial::Iron)), Some(0.25)),
|
||||||
|
|
||||||
// TODO: Fix special sword rules
|
// TODO: Fix special sword rules
|
||||||
//(Block::Web {}, Some(Tool::Sword(ToolMaterial::Wood)), Some(0.4)),
|
//(Block::Web {}, Some(Tool::Sword(ToolMaterial::Wood)), Some(0.4)),
|
||||||
//(Block::Web {}, Some(Tool::Sword(ToolMaterial::Stone)), Some(0.4)),
|
//(Block::Web {}, Some(Tool::Sword(ToolMaterial::Stone)), Some(0.4)),
|
||||||
|
@ -8810,7 +8912,7 @@ impl ToolMaterial {
|
||||||
ToolMaterial::Gold => 12.0,
|
ToolMaterial::Gold => 12.0,
|
||||||
ToolMaterial::Iron => 6.0,
|
ToolMaterial::Iron => 6.0,
|
||||||
ToolMaterial::Diamond => 8.0,
|
ToolMaterial::Diamond => 8.0,
|
||||||
ToolMaterial::Netherite => 9.0
|
ToolMaterial::Netherite => 9.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8833,7 +8935,7 @@ impl Tool {
|
||||||
Tool::Shovel(m) => m.get_multiplier(),
|
Tool::Shovel(m) => m.get_multiplier(),
|
||||||
Tool::Hoe(m) => m.get_multiplier(),
|
Tool::Hoe(m) => m.get_multiplier(),
|
||||||
Tool::Sword(_) => 1.5, // TODO: Handle different block values.
|
Tool::Sword(_) => 1.5, // TODO: Handle different block values.
|
||||||
Tool::Shears => 2.0, // TODO: Handle different block values.
|
Tool::Shears => 2.0, // TODO: Handle different block values.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
use super::{
|
use super::{
|
||||||
Bounds, GameInfo, Gravity, Light, Position, Rotation, TargetPosition, TargetRotation, Velocity, MouseButtons, Digging
|
Bounds, Digging, GameInfo, Gravity, Light, MouseButtons, Position, Rotation, TargetPosition,
|
||||||
|
TargetRotation, Velocity,
|
||||||
};
|
};
|
||||||
use crate::ecs;
|
use crate::ecs;
|
||||||
use crate::format;
|
use crate::format;
|
||||||
|
|
|
@ -311,11 +311,7 @@ impl ApplyDigging {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_packet(&self,
|
fn send_packet(&self, conn: &mut Conn, target: &DiggingState, state: i32) {
|
||||||
conn: &mut Conn,
|
|
||||||
target: &DiggingState,
|
|
||||||
state: i32
|
|
||||||
) {
|
|
||||||
match state {
|
match state {
|
||||||
0 => debug!("Send start dig packet {:?}", target),
|
0 => debug!("Send start dig packet {:?}", target),
|
||||||
1 => debug!("Send cancel dig packet {:?}", target),
|
1 => debug!("Send cancel dig packet {:?}", target),
|
||||||
|
@ -325,32 +321,44 @@ impl ApplyDigging {
|
||||||
|
|
||||||
match conn.protocol_version {
|
match conn.protocol_version {
|
||||||
// 1.7.10
|
// 1.7.10
|
||||||
5 => conn.write_packet(packet::play::serverbound::PlayerDigging_u8_u8y {
|
5 => conn
|
||||||
status: state as u8,
|
.write_packet(packet::play::serverbound::PlayerDigging_u8_u8y {
|
||||||
x: target.position.x,
|
status: state as u8,
|
||||||
y: target.position.y as u8,
|
x: target.position.x,
|
||||||
z: target.position.z,
|
y: target.position.y as u8,
|
||||||
face: target.face.index() as u8,
|
z: target.position.z,
|
||||||
}).unwrap(),
|
face: target.face.index() as u8,
|
||||||
|
})
|
||||||
|
.unwrap(),
|
||||||
// 1.8.9 or v15w39c
|
// 1.8.9 or v15w39c
|
||||||
47|74 => conn.write_packet(packet::play::serverbound::PlayerDigging_u8 {
|
47 | 74 => conn
|
||||||
status: state as u8,
|
.write_packet(packet::play::serverbound::PlayerDigging_u8 {
|
||||||
location: target.position,
|
status: state as u8,
|
||||||
face: target.face.index() as u8,
|
location: target.position,
|
||||||
}).unwrap(),
|
face: target.face.index() as u8,
|
||||||
|
})
|
||||||
|
.unwrap(),
|
||||||
// 1.9+
|
// 1.9+
|
||||||
_ => conn.write_packet(packet::play::serverbound::PlayerDigging {
|
_ => conn
|
||||||
status: protocol::VarInt(state),
|
.write_packet(packet::play::serverbound::PlayerDigging {
|
||||||
location: target.position,
|
status: protocol::VarInt(state),
|
||||||
face: target.face.index() as u8,
|
location: target.position,
|
||||||
}).unwrap(),
|
face: target.face.index() as u8,
|
||||||
|
})
|
||||||
|
.unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_state(&self,
|
fn next_state(
|
||||||
|
&self,
|
||||||
last: &Option<DiggingState>,
|
last: &Option<DiggingState>,
|
||||||
mouse_buttons: &MouseButtons,
|
mouse_buttons: &MouseButtons,
|
||||||
target: Option<(shared::Position, block::Block, shared::Direction, Vector3<f64>)>
|
target: Option<(
|
||||||
|
shared::Position,
|
||||||
|
block::Block,
|
||||||
|
shared::Direction,
|
||||||
|
Vector3<f64>,
|
||||||
|
)>,
|
||||||
) -> Option<DiggingState> {
|
) -> Option<DiggingState> {
|
||||||
// Figure out the next state
|
// Figure out the next state
|
||||||
if !mouse_buttons.left {
|
if !mouse_buttons.left {
|
||||||
|
@ -360,7 +368,9 @@ impl ApplyDigging {
|
||||||
match (last, target) {
|
match (last, target) {
|
||||||
// Started digging
|
// Started digging
|
||||||
(None, Some((position, block, face, _))) => Some(DiggingState {
|
(None, Some((position, block, face, _))) => Some(DiggingState {
|
||||||
block, face, position,
|
block,
|
||||||
|
face,
|
||||||
|
position,
|
||||||
start: std::time::Instant::now(),
|
start: std::time::Instant::now(),
|
||||||
finished: false,
|
finished: false,
|
||||||
}),
|
}),
|
||||||
|
@ -372,7 +382,9 @@ impl ApplyDigging {
|
||||||
|
|
||||||
// Start digging a different block.
|
// Start digging a different block.
|
||||||
Some(DiggingState {
|
Some(DiggingState {
|
||||||
block, face, position,
|
block,
|
||||||
|
face,
|
||||||
|
position,
|
||||||
start: std::time::Instant::now(),
|
start: std::time::Instant::now(),
|
||||||
finished: false,
|
finished: false,
|
||||||
})
|
})
|
||||||
|
@ -388,7 +400,7 @@ impl ApplyDigging {
|
||||||
Some(mining_time) => {
|
Some(mining_time) => {
|
||||||
let finish_time = state.start + mining_time;
|
let finish_time = state.start + mining_time;
|
||||||
finish_time > std::time::Instant::now()
|
finish_time > std::time::Instant::now()
|
||||||
},
|
}
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,12 +411,21 @@ impl ecs::System for ApplyDigging {
|
||||||
&self.filter
|
&self.filter
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, m: &mut ecs::Manager, world: &mut world::World, renderer: &mut render::Renderer) {
|
fn update(
|
||||||
use crate::server::target::{trace_ray, test_block};
|
&mut self,
|
||||||
|
m: &mut ecs::Manager,
|
||||||
|
world: &mut world::World,
|
||||||
|
renderer: &mut render::Renderer,
|
||||||
|
) {
|
||||||
|
use crate::server::target::{test_block, trace_ray};
|
||||||
use cgmath::EuclideanSpace;
|
use cgmath::EuclideanSpace;
|
||||||
|
|
||||||
let world_entity = m.get_world();
|
let world_entity = m.get_world();
|
||||||
let mut conn = m.get_component(world_entity, self.conn).unwrap().write().unwrap();
|
let mut conn = m
|
||||||
|
.get_component(world_entity, self.conn)
|
||||||
|
.unwrap()
|
||||||
|
.write()
|
||||||
|
.unwrap();
|
||||||
let conn = match conn.as_mut() {
|
let conn = match conn.as_mut() {
|
||||||
Some(conn) => conn,
|
Some(conn) => conn,
|
||||||
// Don't keep processing digging operations if the connection was
|
// Don't keep processing digging operations if the connection was
|
||||||
|
@ -442,13 +463,13 @@ impl ecs::System for ApplyDigging {
|
||||||
}
|
}
|
||||||
// Start the new digging operation.
|
// Start the new digging operation.
|
||||||
self.send_packet(conn, current, 0);
|
self.send_packet(conn, current, 0);
|
||||||
},
|
}
|
||||||
// Finish the new digging operation.
|
// Finish the new digging operation.
|
||||||
(Some(_), Some(current)) if !self.is_finished(current) && !current.finished => {
|
(Some(_), Some(current)) if !self.is_finished(current) && !current.finished => {
|
||||||
self.send_packet(conn, current, 2);
|
self.send_packet(conn, current, 2);
|
||||||
current.finished = true;
|
current.finished = true;
|
||||||
},
|
}
|
||||||
_ => {},
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -797,9 +797,7 @@ impl Server {
|
||||||
|
|
||||||
pub fn on_left_mouse_button(&mut self, pressed: bool) {
|
pub fn on_left_mouse_button(&mut self, pressed: bool) {
|
||||||
if let Some(player) = self.player {
|
if let Some(player) = self.player {
|
||||||
if let Some(mouse_buttons) = self
|
if let Some(mouse_buttons) = self.entities.get_component_mut(player, self.mouse_buttons)
|
||||||
.entities
|
|
||||||
.get_component_mut(player, self.mouse_buttons)
|
|
||||||
{
|
{
|
||||||
mouse_buttons.left = pressed;
|
mouse_buttons.left = pressed;
|
||||||
}
|
}
|
||||||
|
@ -808,9 +806,7 @@ impl Server {
|
||||||
|
|
||||||
pub fn on_right_mouse_button(&mut self, pressed: bool) {
|
pub fn on_right_mouse_button(&mut self, pressed: bool) {
|
||||||
if let Some(player) = self.player {
|
if let Some(player) = self.player {
|
||||||
if let Some(mouse_buttons) = self
|
if let Some(mouse_buttons) = self.entities.get_component_mut(player, self.mouse_buttons)
|
||||||
.entities
|
|
||||||
.get_component_mut(player, self.mouse_buttons)
|
|
||||||
{
|
{
|
||||||
mouse_buttons.right = pressed;
|
mouse_buttons.right = pressed;
|
||||||
}
|
}
|
||||||
|
@ -1079,10 +1075,7 @@ impl Server {
|
||||||
|
|
||||||
fn write_plugin_message(&mut self, channel: &str, data: &[u8]) {
|
fn write_plugin_message(&mut self, channel: &str, data: &[u8]) {
|
||||||
let mut conn = self.conn.write().unwrap();
|
let mut conn = self.conn.write().unwrap();
|
||||||
let _ = conn
|
let _ = conn.as_mut().unwrap().write_plugin_message(channel, data); // TODO handle errors
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
|
||||||
.write_plugin_message(channel, data); // TODO handle errors
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_game_join_worldnames_ishard_simdist(
|
fn on_game_join_worldnames_ishard_simdist(
|
||||||
|
|
Loading…
Reference in New Issue