Switching items with sneak

Discussion in 'Plugin Development' started by chakyl, Feb 2, 2014.

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

    chakyl

    Kind of new to Bukkit, but I wanted to know if there was a way to switch the item on the ground with the item in your hand (Assuming picking up drops is disabled). Not sure how to go about this, I skimmed the jdocs and couldn't find much that would help me.
     
  2. Offline

    Jugglernaught

    chakyl
    I haven't been doing Bukkit Coding for long, but I think you might be able to create an item stack from cancelling the pickup event. Then if the event is still cancelled, and the player sneaks, it could replace item stack in hand with item stack taken from the cancelled item pickup event. Do you get what I mean? Can anyone confirm this?
     
  3. Offline

    Nicodemeus

    Bukkit has a PlayerToggleSneakEvent. Listen for that event, then check for any nearby Item entities around the player. Set the item material that the player is holding to the material of the ground item, and vice versa.
     
Thread Status:
Not open for further replies.

Share This Page