-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make serializer-package depend on nms and move hideTooltip …
…method to Nms-package
- Loading branch information
Showing
5 changed files
with
21 additions
and
17 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
idofront-nms/src/main/kotlin/com/mineinabyss/idofront/nms/Items.kt
This file contains 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,18 @@ | ||
package com.mineinabyss.idofront.nms | ||
|
||
import net.minecraft.core.component.DataComponents | ||
import org.bukkit.craftbukkit.inventory.CraftItemStack | ||
import org.bukkit.inventory.ItemFlag | ||
import org.bukkit.inventory.ItemStack | ||
|
||
/** | ||
* In 1.20.5, HIDE_ATTIRBUTES ItemFlag has funky behaviour as the component holds the show_in_tooltip property | ||
* This method properly hides the Attributes from the tooltip if an item has the flag set | ||
*/ | ||
fun ItemStack.hideAttributeTooltipWithItemFlagSet(): ItemStack { | ||
if (!hasItemFlag(ItemFlag.HIDE_ATTRIBUTES)) return this | ||
|
||
return CraftItemStack.asCraftCopy(this).apply { | ||
handle.set(DataComponents.ATTRIBUTE_MODIFIERS, (handle.get(DataComponents.ATTRIBUTE_MODIFIERS) ?: handle.item.defaultAttributeModifiers).withTooltip(false)) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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