Solved Big Question

Discussion in 'Plugin Development' started by TheYamsMan, Feb 14, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    TheYamsMan

    I want to make an item that is a item in vanilla minecraft but has a different use. Like the magic wand in world edit and the railgun in quakecraft on hypixel's server. Anyone know how to do this?
     
  2. Offline

    idontcare1025

    Seems like you can't figure it out for once...
    But, you just use PlayerInteractEvent. Check if they're right clicking or whatever you need them to do with it, than run your code if so. I could go more in depth if you told me what you want to do, but here's an example:

    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(PlayerInteractEvent e) {
    3. if (/* Check if they're doing what you want */ &&
    4. /* Check if they have the right item */) {
    5. //Your code here
    6. }
    7. }
     
    Tirelessly likes this.
  3. Offline

    DogeDev

    Example:
    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerInteract(PlayerInteractEvent event){
    4. Player player = event.getPlayer();
    5. if(event.getAction() == (Action.RIGHT_CLICK_BLOCK) || (event.getAction() == (Action.RIGHT_CLICK_AIR))){
    6. if(player.getItemInHand().getType() == Material.BLAZE_ROD){
    7. //do your cool stuff here
    8. }
    9. }
    10. }

    That will make cool stuff happen on Right-Click with a blaze rod. Just check for the type of item and what action, then add whatever code you want.
     
  4. Offline

    TheYamsMan

    idontcare1025 Yup, I should probably change that......

    Thanks to you all. I got it.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page