Skip to content

Commit

Permalink
early return
Browse files Browse the repository at this point in the history
  • Loading branch information
AutumnVN committed Dec 26, 2024
1 parent 4b88da2 commit 9b548b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/client/java/autumnvn/autumn/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public static String color(double value, double min, double max) {
public static String getOwnerName(Entity entity) {
if (!(entity instanceof TameableEntity tameableEntity)) return null;
if (tameableEntity.getOwnerUuid() == null) return null;

PlayerEntity owner = entity.getWorld().getPlayerByUuid(tameableEntity.getOwnerUuid());

return owner == null ? null : Objects.requireNonNull(owner.getDisplayName()).getString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ public class ClientPlayNetworkHandlerMixin {
private void onWorldTimeUpdate(WorldTimeUpdateS2CPacket packet, CallbackInfo ci) {
long tick = packet.time();
long time = System.nanoTime();
if (lastTick != 0 && lastTime != 0) {
long passedTick = tick - lastTick;
long passedTime = time - lastTime;
if (passedTick > 0 && passedTime > 0) {
long mspt = passedTime / passedTick / 1000000;
if (mspt > 0) {
AutumnClient.tps = Math.min(1000 / mspt, 20);
}
}
}
if (lastTick == 0 || lastTime == 0) return;

long passedTick = tick - lastTick;
long passedTime = time - lastTime;
if (passedTick == 0 || passedTime == 0) return;

long mspt = passedTime / passedTick / 1000000;
if (mspt == 0) return;

AutumnClient.tps = Math.min(1000 / mspt, 20);
lastTick = tick;
lastTime = time;
}
Expand Down

0 comments on commit 9b548b6

Please sign in to comment.