Solved Snowball range

Discussion in 'Plugin Development' started by KingFaris11, Mar 27, 2015.

Thread Status:
Not open for further replies.
  1. Hi, I'm making a bullet projectile that has a range. Here's my base class:
    Code:
    public class EntityBullet extends EntitySnowball {
        private double blockRange = 10D;
    
        public EntityBullet(World world) {
            super(world);
        }
    
        public EntityBullet(World world, EntityLiving livingEntity) {
            super(world, livingEntity);
        }
    
        public EntityBullet(World world, double x, double y, double z) {
            super(world, x, y, z);
        }
    
        public EntityBullet setRange(double range) {
            this.blockRange = range;
            return this;
        }
    }
    
    The 'blockRange' is the maximum number of blocks the projectile can travel. What would be the best, most efficient way of removing the entity after this range? I don't really want to be calling 'location.distanceSquared()' every tick, but I do want the maximum number of blocks (double) to be pretty accurate. This is why I don't want to track every projectile and create a repeated scheduler that loops through the map, comparing the distance traveled per tick, unless I absolutely must.

    Thanks in advance!

    Edit: Solved on a forum where I actually receive help.
     
    Last edited: Mar 30, 2015
Thread Status:
Not open for further replies.

Share This Page