Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Rotation + Throwing emeralds

Comments in 'Plugin Development' started by Kvetinac97, Jul 18, 2015.

  1. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    1) Can I block »ONLY« rotating players head? e.g. You can move, but you can't move your head (propably something with x-rot and y-rot?)

    2) Can I set any item throwable (e.g. throwing emeralds like enderpearls)
  2. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    (2 could be usefull in SuperPaintball...)
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    X-rot is called yaw and Y-rot is called pitch. Check in PlayerMoveEvent if from pitch !== to pitch or from yaw !== to yaw cancel event. Note that the Player can still rotate head, just that after hundreds of milliseconds it will get reverted.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    For 2, handle PlayerInteractEvent. If event action is RIGHT_CLICK_AIR and event item is a snowball, cancel it.
    CrazedMiner likes this.
  5. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    So, can you give me some example?
  6. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    PHP:
    public function onInteract(PlayerInteractEvent $ev){
    if (
    $ev->getAction() == PlayerInteractEvent::RIGHT_CLICK_AIR){
    //now what? It's bad/ good?
    }
    }
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    public function onInteract(PlayerInteractEvent $ev){
    if (
    $ev->getAction() === PlayerInteractEvent::RIGHT_CLICK_AIR and in_array($event->getItem()->getId(), [/*snowball ID*//*egg ID*/])){
    //now what? It's bad/ good?
    }
    }
  8. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    OK, but how set emerald throwable(with this code)?
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Throw an emerald???
  10. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    add motion to item :D
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Copy the code in Player.php about throwing snowballs and replace it with emerald dropped items.
    Legoboy0215 likes this.
  12. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    throwed snowball is normal item? :D
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No, but if you want emerald texture, dropped item is a good alternative.
  14. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
  15. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    How get emerald dropped motion?
  16. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    you dont need get motion but set motion to item :)
  17. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    But... how? I rewrote Player.php:

    $emerald->setMotion(//now what?);
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
  19. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    I looked there, but I don't think simply replacing "Item::SNOWBALL" with "item::EMERALD" should work.
  20. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    do not rewrite player.php only write it into your plugin :) and it wont work

Share This Page

Advertisement