From 6bc1b1f474cdfc1ddb4b637b67983912cb39ef42 Mon Sep 17 00:00:00 2001 From: J3fftw <44972470+J3fftw1@users.noreply.github.com> Date: Tue, 16 Jan 2024 13:08:14 +0100 Subject: [PATCH] fix items not being able to be placed on ancient altar (#4094) Co-authored-by: Daniel Walsh --- .../slimefun4/utils/ArmorStandUtils.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ArmorStandUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ArmorStandUtils.java index 575446fb7a..033e3ca489 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ArmorStandUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ArmorStandUtils.java @@ -2,6 +2,8 @@ import javax.annotation.Nonnull; +import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import org.bukkit.Location; import org.bukkit.entity.ArmorStand; @@ -47,13 +49,22 @@ public class ArmorStandUtils { * @return The spawned {@link ArmorStand} */ public static @Nonnull ArmorStand spawnArmorStand(@Nonnull Location location) { - 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; + } + + 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); } }