Skip to content

Commit

Permalink
feat: reset entity motion if entity is moving into unloaded chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Oct 15, 2024
1 parent 7e623a0 commit 64a8f33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ protected boolean checkChunk(Location3fc oldLoc, Location3fc newLoc) {
if (newChunk == null) {
// Moving into an unloaded chunk is not allowed. Because the chunk holds the entity,
// moving to an unloaded chunk will result in the loss of the entity
log.warn("New chunk {} {} is null while moving entity!", newChunkX, newChunkZ);
log.warn("Entity {} is trying to move into unloaded chunk {} {}", runtimeId, newChunkX, newChunkZ);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ protected boolean updateEntityLocation(Entity entity, Location3fc newLoc) {
baseComponent.broadcastMoveToViewers(newLoc, false);
return true;
} else {
// Entity is moving into unloaded chunk, and we need to reset the motion
// to prevent the entity from moving into unloaded chunk continuously
entity.setMotion(0, 0, 0);
return false;
}
}
Expand Down

0 comments on commit 64a8f33

Please sign in to comment.