Skip to content

Commit 6d7721a

Browse files
committed
Fix checks for 1.21.5+
1 parent e48b0aa commit 6d7721a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/java/ch/njol/skript/conditions/CondHasCustomModelData.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
@Since("2.5, INSERT VERSION (expanded data types)")
1919
@RequiredPlugins("Minecraft 1.21.4+ (floats/flags/strings/colours)")
2020
public class CondHasCustomModelData extends PropertyCondition<ItemType> {
21-
21+
22+
// 1.21.5+
23+
private static final boolean HAS_HAS_COMPONENT = Skript.methodExists(ItemMeta.class, "hasCustomModelDataComponent");
24+
2225
static {
26+
// 1.21.4+
2327
if (Skript.methodExists(ItemMeta.class, "getCustomModelDataComponent")) {
2428
// new style
2529
register(CondHasCustomModelData.class, PropertyType.HAVE, "[custom] model data [1:floats|2:flags|3:strings|4:colo[u]rs]", "itemtypes");
@@ -50,7 +54,7 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
5054
public boolean check(ItemType item) {
5155
ItemMeta meta = item.getItemMeta();
5256
if (dataType == CMDType.ANY)
53-
return meta.hasCustomModelData();
57+
return HAS_HAS_COMPONENT ? meta.hasCustomModelDataComponent() : meta.hasCustomModelData();
5458
CustomModelDataComponent component = meta.getCustomModelDataComponent();
5559
return switch (dataType) {
5660
case FLOATS -> !component.getFloats().isEmpty();

0 commit comments

Comments
 (0)