1

Code

JimboPanda123 3/17/15 1:36 pm
353
3/19/2015 9:13 am
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
Posted by
JimboPanda123
Level 41 : Master Enderdragon
21

  Have something to say?

JoinSign in

3

sekwah41
03/19/2015 7:06 am
He/Him • Level 89 : Elite Cyborg Senpai
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.
1
L4BORG
03/17/2015 1:52 pm
Level 1 : New Miner
You should implement Listener and then check in PlayerInteractEntityEvent(PlayerInteractEntityEvent playerInteractEntityEvent) which block was clicked and by who.
1
SomeonePrivate
03/19/2015 9:13 am
Level 9 : Apprentice Explorer
Block is not an entity, it is PlayerInteractEvent and then get the action right click block
1

Welcome