Guest User

Untitled

a guest
Mar 25th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.81 KB | None | 0 0
  1. package tech.cookiepower.blueberrytools.util
  2.  
  3. import org.bukkit.entity.Entity
  4. import taboolib.module.nms.nmsClass
  5. import taboolib.module.nms.obcClass
  6.  
  7. object SerializeEntity {
  8.  
  9.     private val getHandleMethod = obcClass("entity.CraftEntity").getMethod("getHandle")
  10.     private val nbtClass = nmsClass("NBTTagCompound")
  11.     private val nbtConstructor = nbtClass.getConstructor()
  12.     private val entityClass = nmsClass("Entity")
  13.     private val serializeEntityMethod = entityClass.getMethod("serializeEntity",nbtClass)
  14.     /**
  15.      * @return Compound
  16.      * */
  17.     fun getNBTCompoundData(entity : Entity): Any? {
  18.         val entityNMS = getHandleMethod.invoke(entity)
  19.         val compound = nbtConstructor.newInstance()
  20.         serializeEntityMethod.invoke(entityNMS,compound)
  21.         return compound
  22.     }
  23.  
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment