Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/pumpkin-command/src/argument_types/block_predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl BlockPredicate {
nbt,
} => {
if block.id != expected.id
|| !content::state(state_id.as_u16()).is_some_and(|state| {
|| !content::state(state_id.as_u32()).is_some_and(|state| {
properties
.iter()
.all(|(key, value)| state.properties.get(key) == Some(value))
Expand Down Expand Up @@ -244,7 +244,7 @@ fn parse_concrete_predicate(
reader: &mut StringReader,
) -> Result<BlockPredicate, CommandSyntaxError> {
let (block, id) = read_block(reader)?;
if content::state(block.default_state.id.as_u16()).is_none() {
if content::state(block.default_state.id.as_u32()).is_none() {
let input = read_block_input(reader, block, &id, true)?;
return Ok(BlockPredicate::Block {
block,
Expand All @@ -258,7 +258,7 @@ fn parse_concrete_predicate(
block
.states
.iter()
.filter_map(|state| content::state(state.id.as_u16()))
.filter_map(|state| content::state(state.id.as_u32()))
};
read_block_properties(
reader,
Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/block/blocks/carved_pumpkin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn spawn_golem(world: &Arc<World>, pattern: &GolemPattern) {
world.sync_world_event(
WorldEvent::ParticlesDestroyBlock,
pos,
i32::from(state_id.as_u16()),
i32::from(state_id.vanilla_view().as_u16()),
);
}

Expand Down
6 changes: 3 additions & 3 deletions crates/pumpkin-core/src/block/blocks/doors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn is_lower_door(state: &BlockState) -> bool {
if !block.has_tag(&tag::Block::MINECRAFT_DOORS) {
return false;
}
if let Some(custom) = pumpkin_data::content::state(state.id.as_u16()) {
if let Some(custom) = pumpkin_data::content::state(state.id.as_u32()) {
return custom
.properties
.get("half")
Expand Down Expand Up @@ -189,7 +189,7 @@ impl DoorBlock {
if !block.has_tag(&tag::Block::MINECRAFT_DOORS) {
return false;
}
if let Some(custom) = pumpkin_data::content::state(block_state.as_u16()) {
if let Some(custom) = pumpkin_data::content::state(block_state.as_u32()) {
return custom
.properties
.get("open")
Expand All @@ -203,7 +203,7 @@ impl DoorBlock {
if !block.has_tag(&tag::Block::MINECRAFT_DOORS) {
return;
}
if pumpkin_data::content::state(block_state.as_u16()).is_some() {
if pumpkin_data::content::state(block_state.as_u32()).is_some() {
if let Some(behaviour) = world.block_registry.get_pumpkin_block(block.id) {
behaviour.set_door_open(world, block_pos, block, open);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/block/blocks/wither_skull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn spawn_wither(world: &Arc<World>, pattern: &WitherPattern) {
world.sync_world_event(
WorldEvent::ParticlesDestroyBlock,
pos,
i32::from(state_id.as_u16()),
i32::from(state_id.vanilla_view().as_u16()),
);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/block/entities/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub(crate) fn state_changed(
new: BlockStateId,
moved: bool,
) {
if old != new && (old.as_u16() >= BlockStateId::COUNT || new.as_u16() >= BlockStateId::COUNT) {
if old != new && (!old.is_vanilla() || !new.is_vanilla()) {
let change = if moved {
Change::Moved(old, new)
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/block/entities/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ pub fn create_block_entity_for_state(
use pumpkin_data::block_properties::StructureblockMode;

let state = BlockState::from_id(state_id);
if let Some(entry) = pumpkin_data::content::state(state_id.as_u16()) {
if let Some(entry) = pumpkin_data::content::state(state_id.as_u32()) {
return entry.entity.map(|id| {
Arc::new(content::ContentBlockEntity::new(id, position)) as Arc<dyn BlockEntity>
});
Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/block/fluid/physics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn can_be_replaced(block_state: &BlockState, block: &Block, fluid: &Fluid) -
|| id == Block::POINTED_DRIPSTONE.id
|| id == Block::SCAFFOLDING.id
|| (id.as_u16() >= BlockId::COUNT
&& pumpkin_data::content::state(block_state.id.as_u16())
&& pumpkin_data::content::state(block_state.id.as_u32())
.is_some_and(|state| state.scaffolding.is_some()))
{
return false;
Expand Down
4 changes: 2 additions & 2 deletions crates/pumpkin-core/src/block/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,8 @@ impl BlockRegistry {
let state = BlockState::from_id(new_state);
let mut buildable = true;
let collision = placed_block != &Block::SCAFFOLDING
&& (new_state.as_u16() < BlockStateId::COUNT
|| pumpkin_data::content::state(new_state.as_u16())
&& (new_state.is_vanilla()
|| pumpkin_data::content::state(new_state.as_u32())
.and_then(|state| state.scaffolding.as_ref())
.is_none_or(|props| props.bottom));
for shape in state
Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/entity/ai/goal/break_door.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl Goal for BreakDoorGoal {
world.sync_world_event(
WorldEvent::ParticlesDestroyBlock,
self.door_interact_goal.door_pos,
i32::from(block_state_id.as_u16()),
i32::from(block_state_id.vanilla_view().as_u16()),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/entity/decoration/armor_stand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl ArmorStandEntity {
Vector3::new(width / 4.0, height / 4.0, width / 4.0),
0.05,
10,
Block::OAK_PLANKS.default_state.id.as_u16(),
Block::OAK_PLANKS.default_state.id,
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/pumpkin-core/src/entity/decoration/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ impl BlockDisplayEntity {
self.display.entity.set_synced_data(
pumpkin_data::tracked_data::block_display::BLOCK_STATE,
VarInt(i32::from(
pumpkin_data::BlockStateId::runtime_or_air(block_state as u16)
pumpkin_data::BlockStateId::runtime_or_air(block_state as u32)
.block_display_view()
.as_u16(),
)),
Expand Down Expand Up @@ -728,7 +728,7 @@ impl EntityBase for BlockDisplayEntity {
pumpkin_data::tracked_data::block_display::BLOCK_STATE,
VarInt(i32::from(
pumpkin_data::BlockStateId::runtime_or_air(
self.block_state.load(Ordering::Relaxed) as u16,
self.block_state.load(Ordering::Relaxed) as u32,
)
.block_display_view()
.as_u16(),
Expand Down
6 changes: 3 additions & 3 deletions crates/pumpkin-core/src/entity/falling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl FallingEntity {
})?;
entity
.data
.store(i32::from(falling_state.as_u16()), Ordering::Relaxed);
.store(falling_state.as_u32() as i32, Ordering::Relaxed);
let falling = Arc::new(Self::new(entity, falling_state));
world.spawn_entity_non_save(falling.clone());
Some(falling)
Expand Down Expand Up @@ -252,7 +252,7 @@ impl EntityBase for FallingEntity {
let placed = world.get_block_state_id(&landing_pos);
world.send_to_tracking_players_editioned(
entity,
&CBlockUpdate::new(landing_pos, i32::from(placed.as_u16()).into()),
&CBlockUpdate::new(landing_pos, (placed.as_u32() as i32).into()),
&CUpdateBlock::new(landing_pos, BlockState::to_be_network_id(placed)),
);
}
Expand Down Expand Up @@ -299,7 +299,7 @@ impl EntityBase for FallingEntity {
self.block_state_id.store(state_id);
self.entity
.data
.store(i32::from(state_id.as_u16()), Ordering::Relaxed);
.store(state_id.as_u32() as i32, Ordering::Relaxed);
self.time
.store(nbt.get_numeric_int("Time").unwrap_or(0), Ordering::Relaxed);
self.drop_item
Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4086,7 +4086,7 @@ impl Entity {
let data = self.data.load(Relaxed);
let data = if self.entity_type == &EntityType::FALLING_BLOCK {
i32::from(
pumpkin_data::BlockStateId::runtime_or_air(data as u16)
pumpkin_data::BlockStateId::runtime_or_air(data as u32)
.vanilla_view()
.as_u16(),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/entity/passive/fox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ impl FoxEntity {
world.sync_world_event(
WorldEvent::ParticlesAndSoundDestroyBlock,
pos,
i32::from(state.as_u16()),
i32::from(state.vanilla_view().as_u16()),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/entity/passive/rabbit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ impl RaidGardenGoal {
world.sync_world_event(
WorldEvent::ParticlesAndSoundDestroyBlock,
crops_pos,
i32::from(state_id.as_u16()),
i32::from(state_id.vanilla_view().as_u16()),
);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/entity/passive/turtle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl Mob for TurtleEntity {
world.sync_world_event(
WorldEvent::ParticlesAndSoundDestroyBlock,
pos,
i32::from(below.as_u16()),
i32::from(below.vanilla_view().as_u16()),
);
entity.emit_own_game_event(self, GameEvent::EntityAction);
}
Expand Down
10 changes: 5 additions & 5 deletions crates/pumpkin-core/src/entity/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2965,11 +2965,11 @@ impl Player {
self.try_send_client_packet(&packet);
}

pub fn send_block_change(&self, location: BlockPos, state_id: u16) {
pub fn send_block_change(&self, location: BlockPos, state_id: u32) {
let je_packet = CBlockUpdate::new(location, (state_id as i32).into());
let be_packet = pumpkin_protocol::bedrock::client::update_block::CUpdateBlock::new(
location,
pumpkin_data::BlockState::to_be_network_id(pumpkin_data::BlockStateId::new_or_air(
pumpkin_data::BlockState::to_be_network_id(pumpkin_data::BlockStateId::runtime_or_air(
state_id,
)),
);
Expand All @@ -2978,7 +2978,7 @@ impl Player {

pub fn reset_block_change(&self, location: BlockPos) {
let state_id = self.world().get_block_state_id(&location);
self.send_block_change(location, state_id.as_u16());
self.send_block_change(location, state_id.as_u32());
}

pub fn send_hurt_animation(&self, yaw: f32) {
Expand Down Expand Up @@ -3646,7 +3646,7 @@ impl Player {
);
self.try_send_client_packet(&CBlockUpdate::new(
position,
VarInt(i32::from(state.id.as_u16())),
VarInt(state.id.as_u32() as i32),
));
}

Expand Down Expand Up @@ -3835,7 +3835,7 @@ impl Player {
Vector3::new(0.3, 0.3, 0.3),
0.15,
particles,
on_state.id.as_u16(),
on_state.id,
);
self.spawn_extra_particles_on_fall
.store(false, Ordering::Relaxed);
Expand Down
2 changes: 1 addition & 1 deletion crates/pumpkin-core/src/item/items/brush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl ItemBehaviour for BrushItem {
world.sync_world_event(
WorldEvent::ParticlesAndSoundBrushBlockComplete,
location,
i32::from(current_state_id.as_u16()),
i32::from(current_state_id.vanilla_view().as_u16()),
);
let replacement_state_id = if is_sand {
Block::SAND.default_state.id
Expand Down
6 changes: 3 additions & 3 deletions crates/pumpkin-core/src/net/java/play/player_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl JavaClient {
if interact_event.cancelled {
player.try_send_client_packet(&CBlockUpdate::new(
position,
VarInt(i32::from(state.id.as_u16())),
VarInt(state.id.as_u32() as i32),
));
self.update_sequence(player_action.sequence.0);
return;
Expand All @@ -73,7 +73,7 @@ impl JavaClient {
if cannot_mine {
player.try_send_client_packet(&CBlockUpdate::new(
position,
VarInt(i32::from(state.id.as_u16())),
VarInt(state.id.as_u32() as i32),
));
self.update_sequence(player_action.sequence.0);
return;
Expand Down Expand Up @@ -312,7 +312,7 @@ impl JavaClient {
let synced_state_id = world.get_block_state_id(&position);
self.try_send_packet(&CBlockUpdate::new(
position,
VarInt(i32::from(synced_state_id.as_u16())),
VarInt(synced_state_id.as_u32() as i32),
));
}
}
6 changes: 3 additions & 3 deletions crates/pumpkin-core/src/net/java/play/use_item_on.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl JavaClient {
let state_id = world.get_block_state_id(&position);
player.try_send_client_packet(&CBlockUpdate::new(
position,
VarInt(i32::from(state_id.as_u16())),
VarInt(state_id.as_u32() as i32),
));
return Ok(());
}
Expand Down Expand Up @@ -98,7 +98,7 @@ impl JavaClient {
let state_id = world.get_block_state_id(&position);
player.try_send_client_packet(&CBlockUpdate::new(
position,
VarInt(i32::from(state_id.as_u16())),
VarInt(state_id.as_u32() as i32),
));
return Ok(());
}
Expand Down Expand Up @@ -250,7 +250,7 @@ impl JavaClient {
Ok(Some((final_block_pos, new_state))) => {
player.try_send_client_packet(&CBlockUpdate::new(
final_block_pos,
VarInt(i32::from(new_state.as_u16())),
VarInt(new_state.as_u32() as i32),
));
Ok(true)
}
Expand Down
7 changes: 5 additions & 2 deletions crates/pumpkin-core/src/world/container_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ mod tests {
fn accepts_only_unopened_vanilla_single_chests() {
let single = Block::CHEST.default_state.id;
let base = unopened();
assert_eq!(ChestLikeProperties::from_state_id(single).r#type, ChestType::Single);
assert_eq!(
ChestLikeProperties::from_state_id(single).r#type,
ChestType::Single
);
assert!(supported(single, &base));
assert!(!supported(Block::TRAPPED_CHEST.default_state.id, &base));
assert!(!supported(Block::BARREL.default_state.id, &base));
Expand Down Expand Up @@ -230,7 +233,7 @@ fn replace(
return Outcome::Deferred;
}
let Some(id) =
pumpkin_data::content::state(destination.as_u16()).and_then(|entry| entry.entity)
pumpkin_data::content::state(destination.as_u32()).and_then(|entry| entry.entity)
else {
return Outcome::Deferred;
};
Expand Down
Loading
Loading