Skip to content

feature/block-behavior#325

Draft
MSKatKing wants to merge 41 commits intoferrumc-rs:masterfrom
MSKatKing:feature/block-ticking
Draft

feature/block-behavior#325
MSKatKing wants to merge 41 commits intoferrumc-rs:masterfrom
MSKatKing:feature/block-ticking

Conversation

@MSKatKing
Copy link
Contributor

This PR implements a simple system that allows for blocks to possess specific behavior such as different placement states, random ticking, and more.

I'm going to add methods that are still needed to the BlockBehavior trait, as well as adding documentation explaining how to implement behavior for a block. I am also going to rework the static registry to use block state ids rather than names.

# Conflicts:
#	src/bin/src/packet_handlers/play_packets/place_block.rs
#	src/lib/core/Cargo.toml
use tracing::error;

#[derive(Resource, Default)]
pub struct BlockUpdates(Vec<BlockPos>);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably either be a VecDeque or a crossbeam queue

/// This macro simple exists to make adding methods to blocks easier.
///
/// The syntax for this macro is as follows: `fn <name>([mut]; <arguments>) [-> <return type>; <default return value>]`
macro_rules! block_behavior_trait {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you give an example of how and where this would be used?


impl BlockBehavior for SlabBlock {
#[inline(always)]
fn get_placement_state(&mut self, context: PlacementContext, world: &World, pos: BlockPos) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this take into account stuff like placing blocks inside others (eg. trying to place a block on another block's face but there is a door/sign/trapdoor in the way)? It might also need to take into account stuff like entity collisions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants