1
Code
Hi,
I was starting to make a mod and i want the code so when a certain block is clicked with a certain item, you get a new item.
What would be the code for this?
Thanks
I was starting to make a mod and i want the code so when a certain block is clicked with a certain item, you get a new item.
What would be the code for this?
Thanks
Create an account or sign in to comment.
3
1
If youve coded the block yourself or the item yourself use the interaction method which is called in their code. I forget what their names are but I think its onInteract in the block.
If its in the block check the item the player is holding and if its the item get the block.
If your using both a vanilla item and block then it will only work with the event like L4BORG suggested and you will have to check both.
I personally used the event for bone meal on a custom sapling I made.
If its in the block check the item the player is holding and if its the item get the block.
If your using both a vanilla item and block then it will only work with the event like L4BORG suggested and you will have to check both.
I personally used the event for bone meal on a custom sapling I made.
1
You should implement Listener and then check in PlayerInteractEntityEvent(PlayerInteractEntityEvent playerInteractEntityEvent) which block was clicked and by who.
1
Block is not an entity, it is PlayerInteractEvent and then get the action right click block