Skip to content

Commit fc74ee0

Browse files
committed
Merge remote-tracking branch 'origin/main' into blockbreak
2 parents becec55 + 2f99d76 commit fc74ee0

File tree

35 files changed

+1137
-715
lines changed

35 files changed

+1137
-715
lines changed

Cargo.lock

Lines changed: 175 additions & 176 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ members = [
4444
"feather/server",
4545

4646
# Other
47-
"tools/proxy",
47+
"proxy",
4848
]
4949

5050
# No longer need to use release for "development":

feather/base/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,3 @@ bytemuck = { version = "1", features = ["derive"] }
4040
rand = "0.8"
4141
rand_pcg = "0.3"
4242
serde_test = "1"
43-
44-
[features]
45-
proxy = []

feather/base/src/anvil/player.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,17 @@ pub struct InventorySlot {
7171

7272
impl InventorySlot {
7373
/// Converts an [`ItemStack`] and network protocol index into an [`InventorySlot`].
74-
pub fn from_network_index(network: usize, stack: &ItemStack) -> Option<Self> {
75-
let slot = if SLOT_HOTBAR_OFFSET <= network && network < SLOT_HOTBAR_OFFSET + HOTBAR_SIZE {
74+
#[allow(clippy::manual_range_contains)]
75+
pub fn from_network_index(index: usize, stack: &ItemStack) -> Option<Self> {
76+
let slot = if SLOT_HOTBAR_OFFSET <= index && index < SLOT_HOTBAR_OFFSET + HOTBAR_SIZE {
7677
// Hotbar
77-
(network - SLOT_HOTBAR_OFFSET) as i8
78-
} else if network == SLOT_OFFHAND {
78+
(index - SLOT_HOTBAR_OFFSET) as i8
79+
} else if index == SLOT_OFFHAND {
7980
-106
80-
} else if SLOT_ARMOR_MIN <= network && network <= SLOT_ARMOR_MAX {
81-
((SLOT_ARMOR_MAX - network) + 100) as i8
82-
} else if SLOT_INVENTORY_OFFSET <= network
83-
&& network < SLOT_INVENTORY_OFFSET + INVENTORY_SIZE
84-
{
85-
network as i8
81+
} else if SLOT_ARMOR_MIN <= index && index <= SLOT_ARMOR_MAX {
82+
((SLOT_ARMOR_MAX - index) + 100) as i8
83+
} else if SLOT_INVENTORY_OFFSET <= index && index < SLOT_INVENTORY_OFFSET + INVENTORY_SIZE {
84+
index as i8
8685
} else {
8786
return None;
8887
};

feather/base/src/chunk/blocks.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ impl BlockStore {
5151
&self.blocks
5252
}
5353

54-
#[cfg(feature = "proxy")]
5554
pub fn data_mut(&mut self) -> &mut PackedArray {
5655
&mut self.blocks
5756
}
@@ -60,7 +59,6 @@ impl BlockStore {
6059
self.palette.as_ref()
6160
}
6261

63-
#[cfg(feature = "proxy")]
6462
pub fn palette_mut(&mut self) -> Option<&mut Palette> {
6563
self.palette.as_mut()
6664
}
@@ -83,7 +81,6 @@ impl BlockStore {
8381
self.air_block_count
8482
}
8583

86-
#[cfg(feature = "proxy")]
8784
pub fn set_air_blocks(&mut self, new_value: u32) {
8885
self.air_block_count = new_value;
8986
}

feather/base/src/chunk/heightmap.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ where
142142
self.heights.set(index, height as u64);
143143
}
144144

145-
#[cfg(feature = "proxy")]
146145
pub fn set_height_index(&mut self, index: usize, height: i64) {
147146
self.heights.as_u64_mut_vec()[index] = height as u64;
148147
}

feather/base/src/chunk/light.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ impl Default for LightStore {
1616
}
1717

1818
impl LightStore {
19-
/// Creates a `LightStore` with all light set to 15.
19+
/// Creates a `LightStore` with sky light set to 15.
2020
pub fn new() -> Self {
2121
let mut this = LightStore {
2222
block_light: PackedArray::new(SECTION_VOLUME, 4),
2323
sky_light: PackedArray::new(SECTION_VOLUME, 4),
2424
};
25-
fill_with_default_light(&mut this.block_light);
26-
fill_with_default_light(&mut this.sky_light);
25+
this.sky_light.fill(15);
2726
this
2827
}
2928

@@ -73,9 +72,3 @@ impl LightStore {
7372
&self.sky_light
7473
}
7574
}
76-
77-
fn fill_with_default_light(arr: &mut PackedArray) {
78-
for i in 0..arr.len() {
79-
arr.set(i, 15);
80-
}
81-
}

feather/base/src/chunk/packed_array.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ impl PackedArray {
166166
self.bits_per_value
167167
}
168168

169-
#[cfg(feature = "proxy")]
170169
pub fn set_bits_per_value(&mut self, new_value: usize) {
171170
self.bits_per_value = new_value;
172171
}
@@ -176,7 +175,6 @@ impl PackedArray {
176175
&self.bits
177176
}
178177

179-
#[cfg(feature = "proxy")]
180178
pub fn as_u64_mut_vec(&mut self) -> &mut Vec<u64> {
181179
&mut self.bits
182180
}

feather/common/src/world.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl ChunkMap {
199199
/// Retrieves a handle to the chunk at the given
200200
/// position, or `None` if it is not loaded.
201201
pub fn chunk_at_mut(&self, pos: ChunkPosition) -> Option<RwLockWriteGuard<Chunk>> {
202-
self.0.get(&pos).map(|lock| lock.write()).flatten()
202+
self.0.get(&pos).and_then(|lock| lock.write())
203203
}
204204

205205
/// Returns an `Arc<RwLock<Chunk>>` at the given position.
@@ -212,8 +212,7 @@ impl ChunkMap {
212212

213213
let (x, y, z) = chunk_relative_pos(pos.into());
214214
self.chunk_at(pos.chunk())
215-
.map(|chunk| chunk.block_at(x, y, z))
216-
.flatten()
215+
.and_then(|chunk| chunk.block_at(x, y, z))
217216
}
218217

219218
pub fn set_block_at(&self, pos: ValidBlockPosition, block: BlockId) -> bool {

feather/plugin-host/src/host_calls.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mod block;
1212
mod component;
1313
mod entity;
1414
mod entity_builder;
15+
mod event;
1516
mod plugin_message;
1617
mod query;
1718
mod system;
@@ -49,6 +50,7 @@ use block::*;
4950
use component::*;
5051
use entity::*;
5152
use entity_builder::*;
53+
use event::*;
5254
use plugin_message::*;
5355
use query::*;
5456
use system::*;
@@ -57,6 +59,8 @@ host_calls! {
5759
"register_system" => register_system,
5860
"entity_get_component" => entity_get_component,
5961
"entity_set_component" => entity_set_component,
62+
"entity_add_event" => entity_add_event,
63+
"add_event" => add_event,
6064
"entity_builder_new_empty" => entity_builder_new_empty,
6165
"entity_builder_new" => entity_builder_new,
6266
"entity_builder_add_component" => entity_builder_add_component,

0 commit comments

Comments
 (0)