1.12.2 Arrow bouncing off player

Discussion in 'Spigot Plugin Development' started by SenpaiiCat, Mar 14, 2020.

  1. So I'm creating a little effect where when you get hit by a zombie, an arrow hits you, you get knocked into them via an arrow. I can already do this using vectors directly on the player, but I'm curious as to why this isn't working when I shoot them. The arrow just bounces off (watch the video)


    The code is written in Kotlin, but I don't think you will have much trouble understanding it :)
    Code (Kotlin):
        override fun spawnAttack(attacker: Entity, p: Player, pl: BloodMoon) {
            val loc = attacker.location
            val direction = loc.direction
            val baseSpawnLocation = loc.add(direction.clone().multiply(6)).apply { y += 2 }
            val vector = direction.clone().multiply(Vector(-1, 0, -1))

            p.world.spawnArrow(baseSpawnLocation, vector, 0.8f, 0f, TippedArrow::class.java).apply {
                basePotionData = PotionData(PotionType.INSTANT_HEAL)
            }
        }
     
     
  2. Projectiles have a bounce property.
    You can check if this entity is set to bounce or not, and if it is change it so that it does not:
    doesBounce()
    Code (Java):
    p.world.spawnArrow(baseSpawnLocation, vector, 0.8f, 0f, TippedArrow::class.java).apply {
                basePotionData = PotionData(PotionType.INSTANT_HEAL)
                setBounce(false)
            }
    (Something like that should work)
     
  3. Nope. That made no difference.