1.8.8 Ender Pearl Glitching

Discussion in 'Spigot Plugin Development' started by CodingCyClone, Oct 17, 2021.

  1. How do servers stop ender pearl glitching? I cant figure out how to stop it and I have been trying for days now. I have read like 3 other spigot threads on this and checked out all plugins that supposedly "fix" this but nothing works. Right now I have a semi working system where I just give a negative velocity if when you pearl on certain objects (and a positive velocity if you turn your back before your pearl lands). This works and stops most ender pearl glitches but this is a really bad solution because this causes players to be set back 0.35 blocks minimum with it going up to almost 2 blocks when players start pearling at fence gates, fences, and glass panes at certain angles. Basically what I am trying to say is that this velocity strategy is horrible for players because whenever they throw a pearl they will get jerked around making it extremely annoying and impossible to use when trying to land a precise pearl.

    The second solution I tried was to teleport the player backwards by using the teleport event and then canceling the ender pearl teleport and teleporting the player back manually but this turned into an almost impossible feet. The reason is I cant just teleport the player back a fixed amount depending on the block the pearl hits (I tried this already) because you will be multiplying both the x and the z coordinate by the same amount making the player basically end up off target sometimes by a good amount.

    The third solution I tried was similar to the last one but instead of teleporting the player back a fixed amount I would create a unit vector based on the ender pearls location (also tried using players looking location) which at first looked like a perfect solution until I realized how easy it was to break. In any glass, fence, fence gate, iron bars, or glass plane block you can just look up between the two vectors and ender pearl this would allow you to pass right through since the vector would be so small it would not have an impact. To get around this I tried to get the blocks in front of the player to check what they are pearling at but this seemed almost impossible to do since players can just go at weird in between angles.

    Anyways how can I fix this because I am at a loss :/
  2. Try to catch a ProjectileHitEvent, check if a projectile is an EnderPearl and cancel the event and remove the projectile if it's getTicksLived() lower than 10 ticks
    #2 Groman, Oct 17, 2021
    Last edited: Oct 17, 2021
  3. How would this do anything? Removing a pearl if it landed within a half a second will literally do nothing to fix the issue.
  4. Don't make it overcomplicated. Listen the PlayerTeleportEvent, check if the cause is TeleportCause.ENDER_PEARL, run some calculations to find a safe position (for example, if player pearls against a roof, his hitbox will be stuck in the block and he can glitch through, in this case you could just set the goal to y-1 but you will have to check for blocks below), if no safe position could be found cancel the event. In its simplest form, you'd just check if the players hitbox collides with an block at event.getTo() and cancel the event accordingly. It also can't hurt to center the player when being teleported by a pearl in order to prevent various glitches. To do this just get the block coordinates from event.getTo(). (or round x and z to 0) and add .5 to the x and z value.
    #4 Sxlver_, Oct 18, 2021
    Last edited: Oct 18, 2021
  5. I dont think you understand that getting the safe location is the trouble I am having. To get a save location you have to check all the blocks around the player and then determine what is safe and what is not without accidently teleporting the player to the wrong side while also taking into account the different angles a player can throw a pearl. I dont see how this is simple unless you would like to show an example because this seems as complicated if not more so than what I was doing before...
  6. well, besides the fact that moving them sideways would be unnecessary to begin with, the algorithm to do so would be fairly simple. For example, cosmicpvp, a popular factions server (where, if you know the gamemode, ender pearl glitching would be a serious issue) is even more aggressive regarding pearls. From what I remember they only center the player to begin with, pearls thrown against the roof are being cancelled, pearls thrown into a 1x1 are being canceled etc. pp. Sure, they can throw enderpearls from many different angles, the logic would be the same. Try to find a safe position (How you do that is up to you, try checking one block down, center the player etc) and if no safe position could be found, cancel the pearl. if you're really lazy you can just not try to find a safe position at all and just cancel the pearl whenever event.getTo() (don't forget to check y+1 as the Y loc are the players feet) collides with a block.
    #6 Sxlver_, Oct 18, 2021
    Last edited: Oct 18, 2021
  7. I dont want to go too insane like the example you provided above. I am already checking to make sure people cant pearl into 1x1 holes and I also made a method that can reliably stop pearl glitching through roofs without just canceling them but the problem I am having is being able to stop pearls from going through glass, fences, fence gates, iron bars, and glass panes because for some reason its insanely easy to pearl through these objects. Can you give me an example for how I can stop this because just centering the player wont work because even if a millimeter of a players body is in the block they can phase right through.
  8. The blocks which you have mentioned all belong to one Material property.
    In 1.17, this is 'isOccluding()'.
    In 1.8.8, I think is used 'isTransparent()'.
    (Other Material properties may be useful too)
    So perhaps, checking if the player is looking at these types of blocks when they launch a pearl?
  9. So everything I mentioned above including stuff like stone pillars are considered transparent? Also another issue is they all behave slightly differently for example you can pearl through glass easily compared to all other regular blocks but compared to other blocks like fences and fence gates glass is a lot more solid (not saying much though). That being said I can get the material by check what the pear hits but the issue is I dont know where to go from there any ideas?