Posted November 9, 20159 yr Hi guys, I have few fish mobs that swim gracefully in the ocean, but I noticed that when they are swimming close to the ocean floor, the collision box seems to grind against the floor ...making the movement jerky. It seems that the squid does not have the issue, but I can't pinpoint for the love of god what fixes this. Any hint?
November 10, 20159 yr Author If I had to guess without seeing the entity ai itself Your fish is trying to swim "past the floor". IE your fishes destination it is trying to get to is at a point that is going to be further than the ocean floor. It can't swim through solid blocks so it jerks along the floor instead. 2 places you could look for help 1) In the squid AI tasks this.tasks.addTask(0, new EntitySquid.AIMoveRandom()); 2) In the Ghast entity GhastMoveHelper getCollidingBoundingBoxes (this actually checks if there will be blocks in the way) class GhastMoveHelper extends EntityMoveHelper { private EntityGhast field_179927_g = EntityGhast.this; private int field_179928_h; private static final String __OBFID = "CL_00002216"; public GhastMoveHelper() { super(EntityGhast.this); } public void onUpdateMoveHelper() { if (this.update) { double d0 = this.posX - this.field_179927_g.posX; double d1 = this.posY - this.field_179927_g.posY; double d2 = this.posZ - this.field_179927_g.posZ; double d3 = d0 * d0 + d1 * d1 + d2 * d2; if (this.field_179928_h-- <= 0) { this.field_179928_h += this.field_179927_g.getRNG().nextInt(5) + 2; d3 = (double)MathHelper.sqrt_double(d3); if (this.func_179926_b(this.posX, this.posY, this.posZ, d3)) { this.field_179927_g.motionX += d0 / d3 * 0.1D; this.field_179927_g.motionY += d1 / d3 * 0.1D; this.field_179927_g.motionZ += d2 / d3 * 0.1D; } else { this.update = false; } } } } private boolean func_179926_b(double p_179926_1_, double p_179926_3_, double p_179926_5_, double p_179926_7_) { double d4 = (p_179926_1_ - this.field_179927_g.posX) / p_179926_7_; double d5 = (p_179926_3_ - this.field_179927_g.posY) / p_179926_7_; double d6 = (p_179926_5_ - this.field_179927_g.posZ) / p_179926_7_; AxisAlignedBB axisalignedbb = this.field_179927_g.getEntityBoundingBox(); for (int i = 1; (double)i < p_179926_7_; ++i) { axisalignedbb = axisalignedbb.offset(d4, d5, d6); if (!this.field_179927_g.worldObj.getCollidingBoundingBoxes(this.field_179927_g, axisalignedbb).isEmpty()) { return false; } } return true; } } This is indeed a very good theory ... I will look into it and let you know. Thanks A LOT.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.