Solved Spectators preventing fun

Discussion in 'Plugin Development' started by Agentleader1, May 6, 2015.

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

    Agentleader1

    I tried looking it up, but the solutions were not what I was looking for or it was never solved.

    How do I have a person in player.hidePlayer(player); mode not get hit and stuff. I don't want spectators to block any projectiles, any hits on other players, or any block placing or destroying.

    What might be the easiest way to handle this?

    Solution (open)

     
    Last edited: May 11, 2015
  2. Offline

    Konato_K

    Code:
    public void collideWithStuff(Player paramPlayer, boolean paramBoolean) {
      EntityPlayer localEntityPlayer = ((CraftPlayer)paramPlayer).getHandle();
      localEntityPlayer.collidesWithEntities = paramBoolean;
      localEntityPlayer.k = paramBoolean;
      }
    This is version dependant and the "k" field may change it's name, you'll have to find the right one.

    The collideWithEntities field will prevent the player from well... colliding with entities, this means, not being able to push mobs, being hit by projectiles, or picking up items.

    The k field (appears as l in v1_7_R1) controls their "collision with blocks", if a player has this in false, they will not deny block placing if they stand in a place.
     
    _Yooxa_ likes this.
  3. Offline

    Agentleader1

    @Konato_K
    So this does specifically do what?
     
  4. Offline

    Konato_K

    It's a method, pass false to prevent observers, pass true to revert it back.
     
  5. Offline

    Agentleader1

    @Konato_K Thank you, but what is it's protocol with block placement?
     
  6. Offline

    RingOfStorms

    He explained each thing in his method, I think you're looking for the last sentence in the 3 sentence post which I have copy pasted for you here:
     
  7. Offline

    Agentleader1

    @RingOfStorms English is weird ;-;

    //Edit: I'll take the solution.
     
    Last edited: May 11, 2015
Thread Status:
Not open for further replies.

Share This Page