collidesWithEntities() in 1.8

Discussion in 'Plugin Development' started by AppleBabies, Feb 14, 2016.

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

    AppleBabies

    So, hello, today I am using packets to prevent a player from colliding with entities. However, I no longer see a localEntityPlayer.collideWithEntities() boolean.

    So, does anybody know the new one?

    Thank you!
     
  2. @AppleBabies
    EDIT because tired == dumb for me:
    Do entities collide with players anyway?
     
  3. Offline

    Xerox262

    @AppleBabies @Connor2weirdness EntityPlayer#collidesWithEntities; field? Listen for join event then set their collidesWithEntities to false?
     
  4. Offline

    AppleBabies

    @Connor2weirdness Sorry, I want them to not collide with entities, such as projectiles.

    @Xerox262 Interesting...let me try that.

    EDIT: @Xerox262 Just realised, like I said, that the collidesWithEntities() boolean has been removed and probably been replaced.
     
  5. Offline

    Xerox262

  6. @Xerox262
    Didn't know that. I would've thought colliding would be preventing one entity entering another.
    restrains childish giggles
     
  7. Offline

    AppleBabies

    @Xerox262
    This is what I'm doing:
    Code:
    public void collideWithStuff(Player paramPlayer, boolean paramBoolean) {
              EntityPlayer localEntityPlayer = (((CraftPlayer) paramPlayer).getHandle());
              localEntityPlayer.ad = paramBoolean; //Doing ad based off your Gyazo picture.
              localEntityPlayer.k = paramBoolean;
              }
     
  8. Offline

    Xerox262

    @AppleBabies No, they're methods, you need to just set localEntityPlayer.collidesWithEntities to param boolean. ae and ad are just to check that the player is still alive and not dead, you don't need to worry about them.
     
  9. Offline

    AppleBabies

    @Xerox262 When I do that, it says it doesn't exist.
     
  10. Offline

    Xerox262

  11. Offline

    AppleBabies

    @Xerox262
    Code:
    public void collideWithStuff(Player paramPlayer, boolean paramBoolean) {
              EntityPlayer localEntityPlayer = (((CraftPlayer) paramPlayer).getHandle());
              localEntityPlayer.collidesWithEntities = paramBoolean; //Here it says that collidesWithEntities in an unknown method. Shouldn't ad work?
              localEntityPlayer.k = paramBoolean;
              }
     
  12. Offline

    Xerox262

    @AppleBabies No, because ad and ae are to see if the player is not dead. See https://gyazo.com/b1cb588aa793806182e82dff468fb219
    It shouldn't be saying that it's an unknown method, methods have () and yours doesn't.

    Also I just tried and it worked.

    Edit: Tried without the localEntityPlayer.k = paramBoolean; Idk what that's supposed to do.
     
  13. Offline

    AppleBabies

    @Xerox262 Sorry, it says it can't be resolved not it's not a method.

    I'm using CraftBukkit 1.8.8, so I am confused why it is not working...
     
  14. Offline

    Xerox262

    @AppleBabies Do you actually have the nms classes in your build path? If you're using Maven you most likely wont. And post your imports?
     
  15. Offline

    AppleBabies

    @Xerox262 Ew, I dislike Maven. But sure, here are my imports:
    Code:
    import net.minecraft.server.v1_8_R3.EntityPlayer;
    import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
     
  16. Offline

    Xerox262

    @AppleBabies Odd. Try Cleaning your project and see if that changes anything. Also why're you setting the entity's k?
     
  17. Offline

    AppleBabies

    @Xerox262 I'll try that, and I'm pretty sure k is to prevent blocking a player from breaking blocks or interacting with items.

    EDIT: @Xerox262 I cleaned up my project and even re-added craftbukkit-1-8-8.jar and still it says that it cannot be resolved:

    My code again:
    Code:
    public void collideWithStuff(Player paramPlayer, boolean paramBoolean) {
              EntityPlayer localEntityPlayer = (((CraftPlayer) paramPlayer).getHandle());
              localEntityPlayer.collidesWithEntities = paramBoolean;
              localEntityPlayer.k = paramBoolean;
              }
     
  18. Offline

    Xerox262

    @AppleBabies k is in the entity class so it can't change them being able to break blocks since not all entities can break blocks, why don't you cancel block break events/entity interact events for them?
     
  19. Offline

    AppleBabies

    @Xerox262 No no, I mean for example, if a player tries to break a block and the spectator walks in front of them, the spectator won't prevent the player from breaking the block.
     
  20. Offline

    Xerox262

    @AppleBabies I just copied and pasted your code into my IDE and it has no errors, what does it ask you do you want to change it to when you hover on it?

    An alternative could be to set the player's dead boolean to true, that way entities should be unable to collide, since that's what it checks along side the collide.
     
  21. Offline

    AppleBabies

    @Xerox262 It says to try ad, ai, ah, F, E, a ton of stuff...basically every other possible boolean.

    Also, setting a player to dead doesn't work for some reason. It basically constrains me in one place and then I can't do anything...weird.
     
  22. Offline

    Konato_K

    From what I've seen the collidesWithEntities field only exists in Spigot.
     
  23. Offline

    AppleBabies

  24. Offline

    Konato_K

    @AppleBabies You're quoting a post of mine, I do remember that thread, and it looks like the person got it solved, but I also use spigot when I use that and from what I saw some time after posting that the field didn't exist in CraftBukkit, you can, however, make the players invulnerable (that field does exist in CB) and make the players not collide with arrows.
     
  25. Offline

    AppleBabies

    @Konato_K What would the field be called? All I see is invulnerableTicks. In fact, is there a java doc for all the packets?
     
  26. Offline

    Konato_K

    @AppleBabies It's "invulnerable" as far I remember, but is not in the EntityPlayer class but a super class (can't remember if Entity or EntityLiving).

    There is no javadoc, but there is a reference that has pretty much everything (or the most) of information about packets http://wiki.vg/Main_Page
     
  27. Offline

    AppleBabies

    @Konato_K Hmmm...I tried both Entity and EntityLiving, neither of them seemed to have that field. There is isInvulnerable() but that's a method.
     
  28. Offline

    Konato_K

    @AppleBabies Invulnerable is a field in the Entity class, however, it's private, you'll need to use reflection to modify it.
     
  29. Offline

    AppleBabies

    @Konato_K Like this?
    Code:
    public void collideWithStuff(Player paramPlayer, boolean nonexist, boolean affectsStand) {
              EntityPlayer localEntityPlayer = (((CraftPlayer) paramPlayer).getHandle());
              try {
                ReflectionUtils.setValue(localEntityPlayer, nonexist, "invulnerable", "true");
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (NoSuchFieldException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SecurityException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
              localEntityPlayer.k = affectsStand;
              }
     
  30. Offline

    Konato_K

    @AppleBabies I don't know what ReflectionUtils#setValue is, but it seems right.
     
Thread Status:
Not open for further replies.

Share This Page