Topic category: Troubleshooting, bugs, and solutions
EDIT: SOLVED in update 2021.3 for MC 1.17
My aquatic creatures will stop moving and slowly sink through the water to the ground, then just sit there. These are the conditions I've tested and witnessed it happen under:
-Spawning a dolphin near them or a dolphin swimming into range of them (within about 10ish blocks, more or less)
-If they're spawned/chase/swim around a depth of 5-6 blocks below sea-level (about coordinate height blocks 58-59 or deeper) (this only happens on regular maps--not Super-Flat worlds)
Other Notes:
-My aggressive water entities will snap out of this frozen state if they target a player, but nothing else snaps them out of it.
-I've tested presence (like dolphin) with ALL other mobs (vanilla and my mod, excluding testing the Ender Dragon), no others cause this.
I don't know if this is a bug or some setting I'm unaware of. Hours of trying to solve this, researching, and playing with settings did not fix it, so here I am
what version of mcreator you are using?
Sorry, 2021.2
im also working on this combining the 2021.1 swim code with 2021.2 swim code cause the 2021 made it so they would always move but this aloud them to leap out of the water and just rocket across the land so im adding the setmovevertical to the older one and its land if statements but first i need to did up the older 2021.1 swim lines
but this 2021.2 did fix one problem with a lot of aquatic designers we can no make crabs and other sea clawers work right
I believe you have to add in an ai block for both flying and swimming around randomly, and then change their speed to at least 1. And make sure to make them a flying entity as well as a water entity.
whelp i tried a few ways of merging the code which both of them reject each other in smaller ways
public void tick() {
if (CustomEntity.this.isInWater())
CustomEntity.this.setMotion(CustomEntity.this.getMotion().add(0, 0.005 , 0));
if (this.action == MovementController.Action.MOVE_TO && !CustomEntity.this.getNavigator().noPath()) {
double dx = this.posX - CustomEntity.this.getPosX();
double dy = this.posY - CustomEntity.this.getPosY();
double dz = this.posZ - CustomEntity.this.getPosZ();
float f = (float) (MathHelper.atan2(dz, dx) * (double) (180 / Math.PI)) - 90;
float f1 = (float) (this.speed * CustomEntity.this.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
CustomEntity.this.rotationYaw = this.limitAngle(CustomEntity.this.rotationYaw, f, 10);
CustomEntity.this.renderYawOffset = CustomEntity.this.rotationYaw;
CustomEntity.this.rotationYawHead = CustomEntity.this.rotationYaw;
if (CustomEntity.this.isInWater()) {
CustomEntity.this.setAIMoveSpeed((float) CustomEntity.this.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
float f2 = -(float) (MathHelper.atan2(dy, MathHelper.sqrt(dx * dx + dz * dz)) * (180F / Math.PI));
f2 = MathHelper.clamp(MathHelper.wrapDegrees(f2), -85, 85);
CustomEntity.this.rotationPitch = this.limitAngle(CustomEntity.this.rotationPitch, f2, 5);
float f3 = MathHelper.cos(CustomEntity.this.rotationPitch * (float) (Math.PI / 180.0));
CustomEntity.this.setMoveForward(1F);
CustomEntity.this.setMoveVertical((float) (f1 * dy));
} else {
CustomEntity.this.setAIMoveSpeed(f1 + 1);
CustomEntity.this.setMoveForward(f1 + 2);
}
} else {
CustomEntity.this.setAIMoveSpeed(0);
CustomEntity.this.setMoveVertical(0);
CustomEntity.this.setMoveForward(0);
}
}
};
got it working 2021.3 but this line should fix it. it should also work in .2
CustomEntity.this.setMoveForward(f1 + 2);
CustomEntity.this.setMotion(CustomEntity.this.getMotion().add(0, 0.005 , 0));
the speed of the mod depends on this not default setups (f1 + 2); you can change the + to * for multiplcation or just change the 2 still stops but not as much since its forced to move
@nick I tested your theory but it didn't fix it, and ontop of that it made my aggressive mobs skyrocket into the air and then get stuck maybe thirty blocks above the water and they'd just sit there frozen.
@kapo I'm not a coder so I couldn't quite follow along (though I tried). I'll have my boyfriend read this over as he knows code, but personally I have no idea what I'd even do with the code you showed me.
So as of right now I'm still having this issue. As an update from last time, with my aggressive water mob, I added other things that it attacks other than just players, and it'll snap out of its frozen state to attack them as well, but afterwards it inevitably swims to 58-59 height block and freezes/sinks. Still searching for a solution.
SOLVED
Update 2021.3 for version 1.17 fixed this bug (: