Skip to content

Commit

Permalink
fix: Wrap NBT.modify call in own try-catch to handle unsupported version
Browse files Browse the repository at this point in the history
This is part of the system to try to continue working
*somehow*/mostly in unsupported versions.
  • Loading branch information
SpraxDev committed Dec 16, 2024
1 parent ced8dc5 commit 8946f73
Showing 1 changed file with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,26 @@ public static void applyChairProtections(Entity entity) {
((LivingEntity) entity).setRemoveWhenFarAway(true);
}

NBT.modify(entity, nbt -> {
try {
nbt.setBoolean("Invulnerable", true);
nbt.setInteger("Silent", 1);

if (entity instanceof ArmorStand) {
nbt.setInteger("DisabledSlots", 0b11111);
}

if (entity instanceof Projectile) {
nbt.setBoolean("NoGravity", true);
try {
NBT.modify(entity, nbt -> {
try {
nbt.setBoolean("Invulnerable", true);
nbt.setInteger("Silent", 1);

if (entity instanceof ArmorStand) {
nbt.setInteger("DisabledSlots", 0b11111);
}

if (entity instanceof Projectile) {
nbt.setBoolean("NoGravity", true);
}
} catch (Throwable ex) {
ChairManager.getLogger().warning("Could not apply chair modifications (" + ex.getClass().getSimpleName() + ": " + ex.getMessage() + ")!");
}
} catch (Throwable ex) {
ChairManager.getLogger().warning("Could not apply chair modifications (" + ex.getClass().getSimpleName() + ": " + ex.getMessage() + ")!");
}
});
});
} catch (Throwable ex) {
ChairManager.getLogger().warning("Could not apply chair modifications (" + ex.getClass().getSimpleName() + ": " + ex.getMessage() + ")!");
}
}

/**
Expand Down

0 comments on commit 8946f73

Please sign in to comment.