-
-
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
Open
heypr
wants to merge
16
commits into
DenizenScript:dev
Choose a base branch
from
heypr:new-stuff
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0e03c46
Components :o
heypr 3b843b5
Updated name + corrected registration
heypr 7041ca6
Addressed comments
heypr af3e6b8
Merge remote-tracking branch 'upstream/dev' into new-stuff
heypr 20a1c76
Merge remote-tracking branch 'upstream/dev' into new-stuff
heypr da0349d
Addressed comments.
heypr aeba5f6
Max durability tag for <=1.19
heypr 90ccdd2
Update ItemDurability.java
heypr 83cf3cb
Merge remote-tracking branch 'upstream/dev' into new-stuff
heypr 4ebc675
Merge remote-tracking branch 'upstream/dev' into new-stuff
heypr 2e0b4fe
Reverted changes.
heypr ce49c3a
Forgot to revert item extensions file.
heypr 4323e7d
New item component registry system
heypr eb4b36a
toString --> asMinimalString
heypr fe6a2aa
Addressed comments
heypr 555b249
tern
heypr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
paper/src/main/java/com/denizenscript/denizen/paper/datacomponents/ItemModelAdapter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,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()); | ||
| } | ||
| } | ||
32 changes: 32 additions & 0 deletions
32
paper/src/main/java/com/denizenscript/denizen/paper/datacomponents/MaxDurabilityAdapter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 mechanism.requireInteger() ? value.asInt() : null; | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
paper/src/main/java/com/denizenscript/denizen/paper/datacomponents/MaxStackSizeAdapter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 mechanism.requireInteger() ? value.asInt() : null; | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
paper/src/main/java/com/denizenscript/denizen/paper/datacomponents/RarityAdapter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 <@link url https://jd.papermc.io/paper/org/bukkit/inventory/ItemRarity.html> for valid rarity values. | ||
| // @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 mechanism.requireEnum(ItemRarity.class) ? value.asEnum(ItemRarity.class) : null; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.