Added NBTData support

This commit is contained in:
Jakob K
2020-07-23 20:08:28 +02:00
parent c23940ea0c
commit 324a326a87
3 changed files with 110 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
package net.axay.kspigot.nbt
import net.axay.kspigot.annotations.NMS_General
import net.minecraft.server.v1_16_R1.NBTTagCompound
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack
import org.bukkit.entity.Entity
import org.bukkit.inventory.ItemStack
@NMS_General
val Entity.nbtData: NBTData get() {
val nbtTagCompound = NBTTagCompound()
(this as CraftEntity).handle.load(nbtTagCompound)
return NBTData(nbtTagCompound)
}
@NMS_General
val ItemStack.nbtData: NBTData get() = NBTData(CraftItemStack.asNMSCopy(this).tag)