Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reworking block properties #529

Merged
merged 8 commits into from
Feb 9, 2025

Conversation

DarkMrMelther
Copy link
Contributor

Description

Added the following properties:

  • Axis (For logs and directed blocks)
  • Open
  • Age (For crops)
  • Attachment (For bells)
  • Signal Fire (For campfire smoke)
  • 6 connection directions (For fences, walls, chorus)

Note: The blocks are not updated automatically, we should refactor block placement to allow update blocks properties, and custom placement functions (like for doors, beds or the blocks which uses the facing property inverted)

Testing

Some of the blocks affected (The lantern not)
image

Please follow our Coding Guidelines

Added the following properties:
Axis
Open
Age
Attachment
Signal Fire
6 connection directions
@Snowiiii
Copy link
Collaborator

Snowiiii commented Feb 2, 2025

I like the changes, but i believe we may should rewrite the properties to be inside the block implementations, this would make using them in code easier, That way we can implement Redstone for example

@DarkMrMelther
Copy link
Contributor Author

I like the changes, but i believe we may should rewrite the properties to be inside the block implementations, this would make using them in code easier, That way we can implement Redstone for example

@Snowiiii I was planning on changing properties and blocks to allow having custom place and update functions, if you like I can start working on that rework and in some days I could have a playable version.

@Snowiiii
Copy link
Collaborator

Snowiiii commented Feb 3, 2025

I like the changes, but i believe we may should rewrite the properties to be inside the block implementations, this would make using them in code easier, That way we can implement Redstone for example

@Snowiiii I was planning on changing properties and blocks to allow having custom place and update functions, if you like I can start working on that rework and in some days I could have a playable version.

That would be great, I think we should do that in this PR. I think a goal you can set is to have a lever working, You have to get the use_item event in the current block implentation and then changing the blockstate depending if it's on or off. Later we then can send block neighbor updates and have Redstone working :D

DarkMrMelther and others added 3 commits February 8, 2025 22:58
Changed block properties to make them more extensible and easier to handle.
@DarkMrMelther
Copy link
Contributor Author

Update: Properties rework

Now the block properties are based on the “BlockProperty” trait, which allows better separation and more extensibility, added a proc macro to make the implementation of the properties easier and now you only need to put the necessary information.
These changes have allowed us to separate the updateability of the block from its status update, separating it in the functions “on_place” and “can_update”.
Changed how to detect that the block is replaceable, being part of the “can_update” function now.

Note: All the previously implemented properties should work correctly.

Next: on_interact function implementation for properties and block modifiers to "on_place"

@DarkMrMelther DarkMrMelther changed the title Added 11 blocks properties Reworking block properties Feb 8, 2025
Made the lever work, implementing modifiers to the “on_place” per block, plus the “on_interact” function to handle the state when interacting with a block that has it.
@DarkMrMelther
Copy link
Contributor Author

Update: Levers works now! 🎊 🌟 🥳

Made the lever work, implementing modifiers to the “on_place” per block, plus the “on_interact” function to handle the state when interacting with a block that has it.

Now it remains to combine the APIs of the blocks and the properties, with respect to interactions.

Video

Grabacion.de.pantalla.2025-02-09.021805.mp4

Comment on lines 9 to 12
pub enum Powered {
True,
False,
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be a boolean, This would also match Vanilla then.
You can make a direct field

pub struct Powered(bool)

@Snowiiii
Copy link
Collaborator

Snowiiii commented Feb 9, 2025

Looks awesome. Great work like always @DarkMrMelther :D. But i think we should not only use Enums. I think there should be some kinda implementation for different property types like in Vanilla, Supporting all common types like booleans, integers and enums

@DarkMrMelther
Copy link
Contributor Author

@Snowiiii I think that this is the nearest aproach i can do to implement primitive types (Bool at the moment) without having to rewrite the entire system.

@Snowiiii
Copy link
Collaborator

Snowiiii commented Feb 9, 2025

Overall Great work @DarkMrMelther!. Thank you so much ❤️ always love to see a new PR from you :D

@Snowiiii Snowiiii merged commit daa67c2 into Pumpkin-MC:master Feb 9, 2025
9 checks passed
@deadfry42 deadfry42 mentioned this pull request Feb 10, 2025
1 task
urisinger pushed a commit to urisinger/Pumpkin that referenced this pull request Feb 16, 2025
* Added 11 blocks properties

Added the following properties:
Axis
Open
Age
Attachment
Signal Fire
6 connection directions

* Clippy my beloved 💕

* Reworked block properties

Changed block properties to make them more extensible and easier to handle.

* Little too much of Clippy

* Lever works!!! 🎉

Made the lever work, implementing modifiers to the “on_place” per block, plus the “on_interact” function to handle the state when interacting with a block that has it.

* Kinda implemented bool as value

* A little bit of Clippy :)
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