Skip to content

Commit

Permalink
Add support for 1.21.4 and item-model in ItemBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSzabo committed Dec 6, 2024
1 parent 08e326b commit 484a6d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ repositories {
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.3-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")

// 3rd party
compileOnly("me.clip:placeholderapi:2.11.6")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class ItemConfig {
private List<String> appendLore;
private String material;
private Integer customModelData;
private String itemModel;
private String texture;
private Integer slot;
private List<Integer> slots;
Expand Down Expand Up @@ -57,6 +58,7 @@ public ItemConfig merge(ItemConfig other) {

if (other.material != null) ret.material = other.material;
if (other.customModelData != null) ret.customModelData = other.customModelData;
if (other.itemModel != null) ret.itemModel = other.itemModel;
if (other.texture != null) ret.texture = other.texture;
if (other.slot != null) ret.slot = other.slot;
if (other.slots != null && !other.slots.isEmpty()) {
Expand Down Expand Up @@ -142,6 +144,7 @@ public ItemConfig(ItemConfig other) {

this.material = other.material;
this.customModelData = other.customModelData;
this.itemModel = other.itemModel;
this.texture = other.texture;
this.slot = other.slot;
if (other.slots != null) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/gg/auroramc/aurora/api/menu/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ public ItemStack toItemStack(ItemStack item, Player player) {
meta.setCustomModelData(config.getCustomModelData());
}

if (Version.isAtLeastVersion(21, 4)) {
if (config.getItemModel() != null) {
meta.setItemModel(NamespacedKey.fromString(config.getItemModel()));
}
}

for (var enchant : config.getEnchantments().entrySet()) {
var key = NamespacedKey.fromString(enchant.getKey());
if (key == null) continue;
Expand Down

0 comments on commit 484a6d9

Please sign in to comment.