-
-
Notifications
You must be signed in to change notification settings - Fork 114
Adds item_model, max_durability, max_stack_size, and rarity item components.
#2734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
0e03c46
3b843b5
7041ca6
af3e6b8
20a1c76
da0349d
aeba5f6
90ccdd2
83cf3cb
4ebc675
2e0b4fe
ce49c3a
4323e7d
eb4b36a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| 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. | ||
| // @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()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plain text |
||
| } | ||
|
|
||
| @Override | ||
| public Key fromDenizen(ElementTag value, Mechanism mechanism) { | ||
| return Utilities.parseNamespacedKey(value.asString()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.denizenscript.denizen.paper.datacomponents; | ||
|
|
||
| import com.denizenscript.denizencore.objects.Mechanism; | ||
| import com.denizenscript.denizencore.objects.core.ElementTag; | ||
| import io.papermc.paper.datacomponent.DataComponentTypes; | ||
|
|
||
| public class MaxDurabilityAdapter extends DataComponentAdapter.Valued<ElementTag, Integer> { | ||
|
|
||
| // <--[property] | ||
| // @object ItemTag | ||
| // @name max_durability | ||
| // @input ElementTag(Number) | ||
| // @description | ||
| // Controls an item's max durability <@link language Item Components>. | ||
| // @mechanism | ||
| // Provide no input to reset the item to its default value. | ||
| // --> | ||
|
|
||
| public MaxDurabilityAdapter() { | ||
| super(ElementTag.class, DataComponentTypes.MAX_DAMAGE, "max_durability"); | ||
| } | ||
|
|
||
| @Override | ||
| public ElementTag toDenizen(Integer value) { | ||
| return new ElementTag(value); | ||
| } | ||
|
|
||
| @Override | ||
| public Integer fromDenizen(ElementTag value, Mechanism mechanism) { | ||
| return value.asInt(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These still need input checking, can probably just tern on |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.denizenscript.denizen.paper.datacomponents; | ||
|
|
||
| import com.denizenscript.denizencore.objects.Mechanism; | ||
| import com.denizenscript.denizencore.objects.core.ElementTag; | ||
| import io.papermc.paper.datacomponent.DataComponentTypes; | ||
|
|
||
| public class MaxStackSizeAdapter extends DataComponentAdapter.Valued<ElementTag, Integer> { | ||
|
|
||
| // <--[property] | ||
| // @object ItemTag | ||
| // @name max_stack_size | ||
| // @input ElementTag(Number) | ||
| // @description | ||
| // Controls an item's max stack size <@link language Item Components>. | ||
| // @mechanism | ||
| // Provide no input to reset the item to its default value. | ||
| // --> | ||
|
|
||
| public MaxStackSizeAdapter() { | ||
| super(ElementTag.class, DataComponentTypes.MAX_STACK_SIZE, "max_stack_size"); | ||
| } | ||
|
|
||
| @Override | ||
| public ElementTag toDenizen(Integer value) { | ||
| return new ElementTag(value); | ||
| } | ||
|
|
||
| @Override | ||
| public Integer fromDenizen(ElementTag value, Mechanism mechanism) { | ||
| return value.asInt(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package com.denizenscript.denizen.paper.datacomponents; | ||
|
|
||
| import com.denizenscript.denizencore.objects.Mechanism; | ||
| import com.denizenscript.denizencore.objects.core.ElementTag; | ||
| import io.papermc.paper.datacomponent.DataComponentTypes; | ||
| import org.bukkit.inventory.ItemRarity; | ||
|
|
||
| public class RarityAdapter extends DataComponentAdapter.Valued<ElementTag, ItemRarity> { | ||
|
|
||
| // <--[property] | ||
| // @object ItemTag | ||
| // @name rarity | ||
| // @input ElementTag | ||
| // @description | ||
| // Controls an item's rarity <@link language Item Components>. | ||
| // See https://jd.papermc.io/paper/1.21.11/org/bukkit/inventory/ItemRarity.html for valid rarity values. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| // @mechanism | ||
| // Provide no input to reset the item to its default value. | ||
| // --> | ||
|
|
||
| public RarityAdapter() { | ||
| super(ElementTag.class, DataComponentTypes.RARITY, "rarity"); | ||
| } | ||
|
|
||
| @Override | ||
| public ElementTag toDenizen(ItemRarity value) { | ||
| return new ElementTag(value); | ||
| } | ||
|
|
||
| @Override | ||
| public ItemRarity fromDenizen(ElementTag value, Mechanism mechanism) { | ||
| return value.asEnum(ItemRarity.class); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be useful to say something about resource pack usage?
Can be used with your own namespace to display models from a custom resource packor something, idk.But more importantly, I'd add a note to
custom_model_datasaying to usually prefer this now.