Skip to content

Commit

Permalink
refactor: use unsafe over copying tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed May 2, 2024
1 parent dd681f3 commit 32da2ea
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import net.minecraft.core.component.DataComponents
import net.minecraft.nbt.CompoundTag
import org.bukkit.inventory.ItemStack

val NMSItemStack.hasPDC: Boolean get() = components.get(DataComponents.CUSTOM_DATA)?.copyTag()?.contains("PublicBukkitValues") == true
val NMSItemStack.hasPDC: Boolean get() = components.get(DataComponents.CUSTOM_DATA)?.unsafe?.contains("PublicBukkitValues") == true
val NMSItemStack.fastPDC: WrappedPDC?
get() {
return WrappedPDC(components.get(DataComponents.CUSTOM_DATA)?.copyTag()?.getCompound("PublicBukkitValues") ?: return null)
return WrappedPDC(components.get(DataComponents.CUSTOM_DATA)?.unsafe?.getCompound("PublicBukkitValues") ?: return null)
}

val ItemStack.fastPDC get() = toNMS()?.fastPDC

0 comments on commit 32da2ea

Please sign in to comment.