SPIGOT-8032: Improve ItemMeta#hasCustomModelData compatibility
This commit is contained in:
parent
cc864ea9be
commit
d275d3b96e
@ -1332,21 +1332,29 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCustomModelData() {
|
public boolean hasCustomModelData() {
|
||||||
return customModelData != null;
|
if (customModelData != null) {
|
||||||
|
List<Float> floats = customModelData.getFloats();
|
||||||
|
return !floats.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCustomModelData() {
|
public int getCustomModelData() {
|
||||||
Preconditions.checkState(hasCustomModelData(), "We don't have CustomModelData! Check hasCustomModelData first!");
|
Preconditions.checkState(hasCustomModelData(), "We don't have CustomModelData! Check hasCustomModelData first!");
|
||||||
|
|
||||||
List<Float> floats = customModelData.getFloats();
|
return customModelData.getFloats().get(0).intValue();
|
||||||
Preconditions.checkState(!floats.isEmpty(), "No numeric custom model data");
|
}
|
||||||
return floats.get(0).intValue();
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCustomModelDataComponent() {
|
||||||
|
return customModelData != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomModelDataComponent getCustomModelDataComponent() {
|
public CustomModelDataComponent getCustomModelDataComponent() {
|
||||||
return (this.hasCustomModelData()) ? new CraftCustomModelDataComponent(this.customModelData) : new CraftCustomModelDataComponent(new CustomModelData(List.of(), List.of(), List.of(), List.of()));
|
return (this.hasCustomModelDataComponent()) ? new CraftCustomModelDataComponent(this.customModelData) : new CraftCustomModelDataComponent(new CustomModelData(List.of(), List.of(), List.of(), List.of()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user