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

Interactive blocks #333

Merged
merged 15 commits into from
Dec 7, 2024
Merged

Interactive blocks #333

merged 15 commits into from
Dec 7, 2024

Conversation

leobeg
Copy link
Contributor

@leobeg leobeg commented Nov 23, 2024

Description

This PR aims to add interactive blocks such as crafting tables, furnances and many more.

  • It will add an easy expandable platform to register new block implementations

How to use:

  • Use the macro #[pumpkin_block("minecraft:<your_block_id>")] and specify your block id
  • Implement the async trait PumpkinBlock for your block
  • Include the block in the blocks mod
  • Go into the mod file of the block folder
  • Add your block to the manager with manager.register(<YourBlock>);
  • Now your all set

Currently implemented block events

on_use: Gets called when clicked with an empty hand
on_use_with_item: Gets called when clicked with an item
on_placed: Gets called after placing a block
on_broken: Gets called after the block is removed

Note: The on_use_with_item needs a BlockActionResult which can be Continue and Consume

Testing

Start up the server, place a jukebox, insert a disc and start vibing

Checklist

Things need to be done before this Pull Request can be merged.

  • Code is well-formatted and adheres to project style guidelines: cargo fmt
  • Code does not produce any clippy warnings cargo clippy

@OfficialKris
Copy link
Contributor

OfficialKris commented Nov 29, 2024

very impressive! would be nice to get this merged so additional interactive blocks can be added! Feature works before the master merge

@leobeg
Copy link
Contributor Author

leobeg commented Nov 29, 2024

very impressive! would be nice to get this merged so additional interactive blocks can be added! Feature works before the master merge

Yeah I know it's currently broken. The shrinking of the json completly destroyed my code :(
But Ill fix it now

@leobeg leobeg marked this pull request as ready for review November 29, 2024 13:14
@leobeg leobeg changed the title Interactive blocks - WIP Interactive blocks Nov 29, 2024
@Snowiiii
Copy link
Owner

Works pretty good. Only problem is when the Jukebox is destroyed the Music is still playing. I think you should implement a function which gets called when a block is destroyed

@leobeg
Copy link
Contributor Author

leobeg commented Nov 30, 2024

Works pretty good. Only problem is when the Jukebox is destroyed the Music is still playing. I think you should implement a function which gets called when a block is destroyed

Sounds good. Kinda forgot about that. Will add that soon

@leobeg
Copy link
Contributor Author

leobeg commented Nov 30, 2024

@Snowiiii Done

@Snowiiii
Copy link
Owner

Snowiiii commented Dec 7, 2024

Tested again and everything including the block destruction works fine :D.
Big thanks @leobeg, really good work 👍

@Snowiiii Snowiiii merged commit b82a4e1 into Snowiiii:master Dec 7, 2024
9 checks passed
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.

3 participants