Class RtagItem
-
Field Summary
Fields inherited from class com.saicone.rtag.RtagEditor
literalObject, rtag, tag, typeObject -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an RtagItem with specified Rtag parent and ItemStack to edit.Constructs an RtagItem with specified Rtag parent and NMS ItemStack to edit.Constructs an RtagItem with specified Rtag parent and NMS ItemStack to edit.Constructs an RtagItem with ItemStack to edit. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddEnchantment(Object enchant, int level) Add the provided enchantment to the item.booleanaddHideFlags(int... hideFlags) Deprecated.static <T extends ItemStack>
TEdit the provided item using a RtagItem instance by consumer with defined Rtag parent.static <T extends ItemStack, R>
REdit a RtagItem instance using the provided item by function that return any type with defined Rtag parent.
Take in count that you should useRtagEditor.load()if you want to load the changes.static <T extends ItemStack>
TEdit the provided item using a RtagItem instance by consumer.static <T extends ItemStack, R>
REdit a RtagItem instance using the provided item by function that return any type.
Take in count that you should useRtagEditor.load()if you want to load the changes.voidFix bad item caused by Bukkit serialization, most specifically item lore component that doesn't allow to compare with similar items.get()<V> VgetComponent(Object type) Get the provided component from patch or item.Get current data components.Deprecated.protected RtagItemgetEnchantment(Object enchant) Get the CompoundTag that represent the provided enchantment.intgetEnchantmentLevel(Object enchant) Get the current level for provided enchantment.Get all the enchantments inside item.Deprecated.getItem()Get current item instance.getLiteralObject(ItemStack item) Get current item tag or null.com.saicone.rtag.util.OptionalTypegetOptional(Object... path) intGet the XP level repair cost inside anvil.getTag()Get current item tag to edit.
If this instance has not been edited, it will copy the current tag or create a new one if the current tag is null.booleanhasComponent(Object type) Check if the current item or patch has he provided data component type.booleanhasEnchantment(Object enchant) Check if the current item has the provided enchantment.booleanhasHideFlags(int... hideFlags) Deprecated.booleanGet the current unbreakable status.load()Load changes into item instance.loadCopy()Load changes into new ItemStack instance and return it.<T> TloadInto(T item) Load changes into provided Minecraft ItemStack and return it.static RtagItemCreate an RtagItem using ItemStack and specified Rtag parent.static RtagItemCreate an RtagItem using ItemStack.voidremoveComponent(Object type) Mark the provided component type to be removed using current patch.intremoveEnchantment(EnchantmentTag enchant) Remove from item the provided enchantment.booleanremoveHideFlags(int... hideFlags) Deprecated.booleanChange item tag into new one.
Value must be Map<String, Object> or CompoundTag.voidsetComponent(Object type) Set the provided component into patch.voidsetComponent(Object type, Object value) Set the provided component value into patch.booleansetCustomModelData(Integer model) Deprecated.booleansetHideFlags(int... hideFlags) Deprecated.booleansetRepairCost(int cost) Change the item repair cost inside anvil.booleansetUnbreakable(boolean unbreakable) Change the current unbreakable status of item.voidMethods inherited from class com.saicone.rtag.RtagEditor
add, addEnum, addEnum, addEnum, addEnum, deepMerge, deepMerge, edit, getBitField, getLiteralObject, getObject, getRtag, getTypeObject, hasEnum, hasEnum, hasEnum, hasEnum, hasTag, hasTag, merge, merge, move, move, notHasTag, notHasTag, remove, removeEnum, removeEnum, removeEnum, removeEnum, set, setEnum, setEnum, setEnum, setEnum, update
-
Constructor Details
-
RtagItem
Constructs an RtagItem with ItemStack to edit.- Parameters:
item- Item to load changes.
-
RtagItem
Constructs an RtagItem with specified Rtag parent and ItemStack to edit.- Parameters:
rtag- Rtag parent.item- Item to load changes.
-
RtagItem
-
RtagItem
-
-
Method Details
-
of
-
of
-
getItem
-
getEditor
-
getLiteralObject
-
getLiteralTag
-
getTag
-
getTag
-
getComponents
Get current data components.- Returns:
- A patched data component map.
-
load
-
loadCopy
Load changes into new ItemStack instance and return it.- Returns:
- Copy of the original item with changes loaded.
-
loadInto
public <T> T loadInto(T item) Load changes into provided Minecraft ItemStack and return it.- Type Parameters:
T- Item type.- Parameters:
item- The item to load changes into- Returns:
- The provided item with changes loaded.
-
update
-
hasComponent
Check if the current item or patch has he provided data component type.- Parameters:
type- Data component type object or ID.- Returns:
- true if the item has the component type.
-
set
-
setComponent
Set the provided component into patch.- Parameters:
type- Data component type object or ID.
-
setComponent
Set the provided component value into patch.- Parameters:
type- Data component type object or ID.value- The value to parse, can be NBT, JsonElement or Java object.
-
removeComponent
Mark the provided component type to be removed using current patch.- Parameters:
type- Data component type object or ID.
-
get
-
get
-
getOptional
-
getExact
-
getComponent
Get the provided component from patch or item.- Parameters:
type- Data component type object or ID.- Returns:
- An object represented by component type or null if not exist.
-
hasHideFlags
Deprecated.Check if the current item has the provided hide flags ordinals.- Parameters:
hideFlags- Flags to check.- Returns:
- true if the item has all the flags.
- See Also:
-
hasEnchantment
Check if the current item has the provided enchantment.- Parameters:
enchant- Enchantment object.- Returns:
- true if contains the enchantment.
-
fixSerialization
public void fixSerialization()Fix bad item caused by Bukkit serialization, most specifically item lore component that doesn't allow to compare with similar items. -
addHideFlags
Deprecated.Add hide flags to item using flag ordinal:
0 = Enchantments
1 = AttributeModifiers
2 = Unbreakable
3 = CanDestroy
4 = CanPlaceOn
5 = Other information (stored enchants, potion effects, generation, author, explosion and fireworks)
6 = Dyed
7 = Palette information (armor trim)- Parameters:
hideFlags- Flags to add.- Returns:
- true if the flags was added.
-
addEnchantment
Add the provided enchantment to the item.- Parameters:
enchant- Enchantment object.level- Enchantment level.- Returns:
- true if the enchantment was added.
-
setUnbreakable
public boolean setUnbreakable(boolean unbreakable) Change the current unbreakable status of item.- Parameters:
unbreakable- true to make item unbreakable.- Returns:
- true if the status was changed.
-
setCustomModelData
Deprecated.Set the current custom model data of item.- Parameters:
model- Model id, null of you want to remove it.- Returns:
- true if the model was set or removed.
-
setHideFlags
Deprecated.Override the current item hide flags.- Parameters:
hideFlags- Flags to set.- Returns:
- true if the flags was set.
- See Also:
-
setRepairCost
public boolean setRepairCost(int cost) Change the item repair cost inside anvil.- Parameters:
cost- XP level repair cost.- Returns:
- true if the repair cost was changes.
-
removeHideFlags
@ScheduledForRemoval(inVersion="1.6.0") @Deprecated public boolean removeHideFlags(int... hideFlags) Deprecated.Remove hide flags from item using flag ordinal.- Parameters:
hideFlags- Flags to remove.- Returns:
- true if the flags was removed.
- See Also:
-
removeEnchantment
Remove from item the provided enchantment.- Parameters:
enchant- Enchantment object.- Returns:
- the enchantment level that was set on the item.
-
getCustomModelData
Deprecated.Get the current custom model data inside item.- Returns:
- Model id, null if the item doesn't have model.
-
getHideFlags
Deprecated.Get current hide flags.- Returns:
- A set of flag ordinals.
- See Also:
-
getRepairCost
public int getRepairCost()Get the XP level repair cost inside anvil.- Returns:
- Level repair cost.
-
getEnchantment
-
getEnchantmentLevel
Get the current level for provided enchantment.- Parameters:
enchant- Enchantment object.- Returns:
- Level integer if the enchantment was found, 0 otherwise.
-
getEnchantments
Get all the enchantments inside item.- Returns:
- A Map of EnchantmentTag objects.
-
isUnbreakable
public boolean isUnbreakable()Get the current unbreakable status.- Returns:
- true if the item is unbreakable.
-
edit
-
edit
Edit a RtagItem instance using the provided item by function that return any type.
Take in count that you should useRtagEditor.load()if you want to load the changes.- Type Parameters:
T- ItemStack type.R- The required return type.- Parameters:
item- Item to edit.function- Function to apply.- Returns:
- The object provided by the function.
-
edit
public static <T extends ItemStack> T edit(com.saicone.rtag.Rtag rtag, T item, Consumer<RtagItem> consumer) Edit the provided item using a RtagItem instance by consumer with defined Rtag parent.- Type Parameters:
T- ItemStack type.- Parameters:
rtag- Rtag parent.item- Item to edit.consumer- Consumer to accept.- Returns:
- The provided item.
-
edit
public static <T extends ItemStack, R> R edit(com.saicone.rtag.Rtag rtag, T item, Function<RtagItem, R> function) Edit a RtagItem instance using the provided item by function that return any type with defined Rtag parent.
Take in count that you should useRtagEditor.load()if you want to load the changes.- Type Parameters:
T- ItemStack type.R- The required return type.- Parameters:
rtag- Rtag parent.item- Item to edit.function- Function to apply.- Returns:
- The object provided by the function.
-