-
-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathItemModelAdapter.java
More file actions
36 lines (30 loc) · 1.35 KB
/
ItemModelAdapter.java
File metadata and controls
36 lines (30 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.denizenscript.denizen.paper.datacomponents;
import com.denizenscript.denizen.utilities.Utilities;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ElementTag;
import io.papermc.paper.datacomponent.DataComponentTypes;
import net.kyori.adventure.key.Key;
public class ItemModelAdapter extends DataComponentAdapter.Valued<ElementTag, Key> {
// <--[property]
// @object ItemTag
// @name item_model
// @input ElementTag
// @description
// Controls an item's model <@link language Item Components> in namespaced key format.
// The default namespace is "minecraft", so for example an input of "stone" becomes "minecraft:stone", and will set the item model to a stone block.
// This can also be used to display item models from your own custom resource packs.
// @mechanism
// Provide no input to reset the item to its default value.
// -->
public ItemModelAdapter() {
super(ElementTag.class, DataComponentTypes.ITEM_MODEL, "item_model");
}
@Override
public ElementTag toDenizen(Key value) {
return new ElementTag(value.asMinimalString(), true);
}
@Override
public Key fromDenizen(ElementTag value, Mechanism mechanism) {
return Utilities.parseNamespacedKey(value.asString());
}
}