Add potioneffect that the player can't see?

Discussion in 'Plugin Development' started by MinecraftShamrock, Oct 26, 2013.

Thread Status:
Not open for further replies.
  1. Hey guys.
    There are some plugins that give players PotionEffects that affect the player as usual.
    But when the player opens his inventory he can't see the effect beside the inventory.

    How is that possible?
     
  2. which effect are those? i know that you can do slowness and speed via Player.setWalkSpeed(speed); (not sure if said it right)
     
  3. Offline

    Janmm14

    MinecraftShamrock
    Some things can be also done by other methods, some effects are handled client-side.

    Strength and weakness can be done through EntitiyDamagedByEntityEvent
     
  4. Strength + Weakness : EntityDamageByEntityEvent
    Jump : PlayerMoveEvent>velocity
    Speed + Slowness : player.setWalkSpeeed(int);
    Mining haste : PlayerInteractEvent>Left click block> ...
    etc...
     
  5. Asticoli_express So if I want to cancel a jump without let a player bug around i could set his y velocity to 0?

    Or would that only port him back? Because i want him to stay unlike cancel a move event that would port him back
     
  6. But anyway why don't you want to directly use potions? why seeing it in the inventory is such a problem?

    Use this and he will almost not be able to jump :
    Code:java
    1. @EventHandler
    2. public void onMove(PlayerMoveEvent e){
    3. Player p = e.getPlayer();
    4. if(e.getFrom().getY()<e.getTo().getY()){
    5. p.setVelocity(p.getVelocity().add(new Vector(0,-10,0)));
    6. }
    7. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  7. Asticoli_express And will the player be ported back? (Same as cancelling the event) or won't he even move on the client side?
     
  8. Offline

    xTrollxDudex

    MinecraftShamrock
    If you do player.setPassenger(player); he won't move but one side effect is that he is sitting in midair
     
    MinecraftShamrock likes this.
  9. xTrollxDudex so he's sitting on himself? (Lol)
    Could he move at all? Or just not jump?
     
  10. Offline

    xTrollxDudex

    MinecraftShamrock
    Nope. Not at all. Probably can look around, but I haven't tested that yet. You can always make him stop sitting using
    PHP:
    player.eject()
     
    MinecraftShamrock likes this.
  11. xTrollxDudex cool :D thank you very much! Finally a nice way of prevent player moving. :D
     
  12. Offline

    TheUpdater

    there is an easyer way

    p.getPlayerMovmentType().equals(Player.GetMoveType().cancel); =)
    good luck ^^
     
  13. No.
     
  14. MinecraftShamrock if you want that player wont be able to jump (client side (?)) , use p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, set here level to -1 and time to the time you want)) << havent checked it in eclipse, but thatshow i make the player wont be able to jump
     
  15. But he doesn't want the potion effect to show when the player opens his inventory.
     
  16. Asticoli_express yea, im just telling him that its another way... (if he want it client side..)
     
Thread Status:
Not open for further replies.

Share This Page