1.14.4 Custom Entity Hitbox

Discussion in 'Spigot Plugin Development' started by KingCobra, Feb 2, 2020.

  1. Helo!

    I trying to change custom entities hitbox, but I always gets error or StackOverflow and I dont know what is the problem.


    Code (Java):
    @Override
        public AxisAlignedBB getBoundingBox() {
            return this.getBoundingBox() == null ? new AxisAlignedBB(0.0, 0.0, 0.0, 0.0, 0.0, 0.0) : this.getBoundingBox().expand(1.1, 0, 1.1);
            //return this.getBoundingBox().expand(1.1, 0, 1.1);
        }
    I also tried store the boundingBox after the Entity is spawned, nothing changed.
     
  2. SteelPhoenix

    Moderator

    return this.getBoundingBox() == null You're literally calling your own method in an infinite loop
     
    • Like Like x 1
    • Agree Agree x 1
  3. Ohhh jesus, how I didnt noticed... xd
     
  4. Not working, no error, simply the spawned entity disappear
    Code (Java):
    private AxisAlignedBB box;

    public Goblin(org.bukkit.World world) {
      [...]
      box = new AxisAlignedBB(0.1, 0.1, 0.1, -0.1, -0.1, -0.1);
    }

    @Override
    public AxisAlignedBB getBoundingBox() {
      return box.expand(1.1, 0, 1.1);
    }

    public Entity spawnEntity(Location loc) {
      box = new AxisAlignedBB(loc.getX() + 1, loc.getY() + 1, loc.getZ() + 1, loc.getX() - 1, loc.getY() - 1, loc.getBlockZ() - 1);
    }