1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Detecting holding right clicks

Discussion in 'Development' started by Legoboy0215, Dec 24, 2017.

  1. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    I tried my best to look for any possible solutions to detecting long right clicks, but so far I haven't found any viable solution for PMMP. I remember seeing a similar discussion somewhere, but cannot locate it. Any ideas? I saw bukkit people spawning fake shields but they aren't implemented in MCPE (I'm out of the loop, what is it called now?) yet.
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    on mcpc (hypixel) a shield appears if i hold right click
    so i suppose in MC there's a way
    probably packets...
     
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Also something I wanted to do while I was working on guns' fire rate (that was before mcpe1.2)
    Try this:
    PHP:
    /** @var Player */
    ServerScheduler::scheduleRepeatingTask(new class($plugin$player) extends PluginTask{

        
    /** @var Player */
        
    private $player;

        public function 
    onRun(int $tick) : void{
            if(
    $this->player->isUsingItem()){
                
    $this->player->sendPopup("You are currently holding ".$this->player->getInventory()->getItemInHand());
            }else{
                
    $this->getPlugin()->getServer()->getScheduler()->cancelTask($this->getTaskId());
            }
        }
    }, 
    1);
     
    Legoboy0215 likes this.
  4. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    I actually didn't know there was an isUsingItem function. Thanks!

    However, it doesn't seem to detect when I let go of the hold?
     
    Last edited: Dec 26, 2017
  5. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    This only works if using an item such as a bow (needs the release action to know when they stopped right-clicking).
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.