Hello all, I am developing a plugin that will shoot a wither skull from a location to a location using vector subtraction (code below). The wither skull fires fine and goes to the right location. However, it launches it super quick and thus makes the wither skull invisible. Is there any way to fix this? Code:java Location p = getRandomPlayer().getLocation(); Vector from = new Vector(wither1ss.getX(), wither1ss.getY(), wither1ss.getZ()); Vector to = new Vector(p.getX(), p.getY(), p.getZ()); Vector vector = to.subtract(from); WitherSkull wither1Skull = (WitherSkull) wither1ss.getWorld().spawnEntity(wither1ss, EntityType.WITHER_SKULL); wither1Skull.setDirection(vector.normalize()); wither1Skull.setVelocity(vector);
ZingCraft Code:java wither1Skull.setVelocity(vector.normalize().multiply(x)); Adjust x to get your perfect speed.
When I do that, I see the witherskull for the first fraction of a second, then it goes invisible again. I have tried multiplying the velocity by 0.1, 2 and 10. I can see that it takes longer for the witherskull to explode when it hits me, but it is still invisible (going too fast)
ZingCraft That seems to be incorrect, as doing Vector#normalize() creates a new vector with the total magnitude equal to 1, in the corresponding direction. So doing Vector#normalize().multiply(2) and setting the velocity to that vector would result in the wither skull flying at (almost) exactly 2 m/s, perhaps you should look elsewhere for what is causing the problem.
mythbusterma I did once try removing the setVelocity line (commenting out) and the same thing occurred. Could it perhaps be related to the setDirection?
ZingCraft Sounds like a client side issue. I've heard about a similar bug when summoning skulls with command blocks. It might be related to the fact that the skull has no owner. As a test, you could try to multiply vector by -1 (so that it launches from the player), and instead of using World#spawnEntity, use player.launchProjectile(WitherSkull.class), and keep the velocity/direction code. If it works, then I guess something hacky would be to spawn an entity at the "from" location and then kill it right after...