Skip to content

Commit

Permalink
Don't keep trying to use getBoatType if it has already failed
Browse files Browse the repository at this point in the history
  • Loading branch information
froobynooby committed Apr 26, 2024
1 parent e1abfef commit 301d8a0
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

public class SnapshotEntity {
private static final AtomicBoolean useWoodType = new AtomicBoolean(false);
private final Entity entity;
private final int entityId;
private final Vector location;
Expand Down Expand Up @@ -50,9 +52,14 @@ public SnapshotEntity(Entity entity) {
}
if (entity instanceof Boat) {
// try to add boat type, falling back to wood type for version < 1.19
try {
classifications.add(((Boat) entity).getBoatType());
} catch (Throwable throwable) {
if (!SnapshotEntity.useWoodType.get()) {
try {
classifications.add(((Boat) entity).getBoatType());
} catch (Throwable throwable) {
useWoodType.set(true);
}
}
if (SnapshotEntity.useWoodType.get()) {
//noinspection deprecation
classifications.add(((Boat) entity).getWoodType());
}
Expand Down

0 comments on commit 301d8a0

Please sign in to comment.