diff --git a/src/main/java/com/froobworld/farmcontrol/controller/entity/SnapshotEntity.java b/src/main/java/com/froobworld/farmcontrol/controller/entity/SnapshotEntity.java index d6961ae..05ea114 100644 --- a/src/main/java/com/froobworld/farmcontrol/controller/entity/SnapshotEntity.java +++ b/src/main/java/com/froobworld/farmcontrol/controller/entity/SnapshotEntity.java @@ -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; @@ -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()); }