Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
WalshyDev committed Jan 16, 2024
1 parent b2f2554 commit 5eba3e1
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,22 @@ public class ArmorStandUtils {
* @return The spawned {@link ArmorStand}
*/
public static @Nonnull ArmorStand spawnArmorStand(@Nonnull Location location) {
// This causes an error on 1.19 and below
if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_20)) {
return location.getWorld().spawn(location, ArmorStand.class, armorStand -> {
armorStand.setVisible(false);
armorStand.setSilent(true);
armorStand.setMarker(true);
armorStand.setGravity(false);
armorStand.setBasePlate(false);
armorStand.setRemoveWhenFarAway(false);
});
// 1.19 and below don't have the consumer method so flicker exists on these versions.
if (Slimefun.getMinecraftVersion().isBefore(MinecraftVersion.MINECRAFT_1_20)) {
ArmorStand armorStand = location.getWorld().spawn(location, ArmorStand.class);
setupArmorStand(armorStand);
return armorStand;
}

// Remove this when we drop support for 1.19
ArmorStand armorStand = location.getWorld().spawn(location, ArmorStand.class);
return location.getWorld().spawn(location, ArmorStand.class, armorStand -> setupArmorStand(armorStand));
}

private static void setupArmorStand(ArmorStand armorStand) {
armorStand.setVisible(false);
armorStand.setSilent(true);
armorStand.setMarker(true);
armorStand.setGravity(false);
armorStand.setBasePlate(false);
armorStand.setRemoveWhenFarAway(false);
return armorStand;
}
}

0 comments on commit 5eba3e1

Please sign in to comment.