|
2 | 2 |
|
3 | 3 | import javax.annotation.Nonnull; |
4 | 4 |
|
| 5 | +import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; |
| 6 | +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; |
5 | 7 | import org.bukkit.Location; |
6 | 8 | import org.bukkit.entity.ArmorStand; |
7 | 9 |
|
@@ -47,13 +49,22 @@ public class ArmorStandUtils { |
47 | 49 | * @return The spawned {@link ArmorStand} |
48 | 50 | */ |
49 | 51 | public static @Nonnull ArmorStand spawnArmorStand(@Nonnull Location location) { |
50 | | - return location.getWorld().spawn(location, ArmorStand.class, armorStand -> { |
51 | | - armorStand.setVisible(false); |
52 | | - armorStand.setSilent(true); |
53 | | - armorStand.setMarker(true); |
54 | | - armorStand.setGravity(false); |
55 | | - armorStand.setBasePlate(false); |
56 | | - armorStand.setRemoveWhenFarAway(false); |
57 | | - }); |
| 52 | + // 1.19 and below don't have the consumer method so flicker exists on these versions. |
| 53 | + if (Slimefun.getMinecraftVersion().isBefore(MinecraftVersion.MINECRAFT_1_20)) { |
| 54 | + ArmorStand armorStand = location.getWorld().spawn(location, ArmorStand.class); |
| 55 | + setupArmorStand(armorStand); |
| 56 | + return armorStand; |
| 57 | + } |
| 58 | + |
| 59 | + return location.getWorld().spawn(location, ArmorStand.class, armorStand -> setupArmorStand(armorStand)); |
| 60 | + } |
| 61 | + |
| 62 | + private static void setupArmorStand(ArmorStand armorStand) { |
| 63 | + armorStand.setVisible(false); |
| 64 | + armorStand.setSilent(true); |
| 65 | + armorStand.setMarker(true); |
| 66 | + armorStand.setGravity(false); |
| 67 | + armorStand.setBasePlate(false); |
| 68 | + armorStand.setRemoveWhenFarAway(false); |
58 | 69 | } |
59 | 70 | } |
0 commit comments