Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tech.cookiepower.blueberrytools.util
- import org.bukkit.entity.Entity
- import taboolib.module.nms.nmsClass
- import taboolib.module.nms.obcClass
- object SerializeEntity {
- private val getHandleMethod = obcClass("entity.CraftEntity").getMethod("getHandle")
- private val nbtClass = nmsClass("NBTTagCompound")
- private val nbtConstructor = nbtClass.getConstructor()
- private val entityClass = nmsClass("Entity")
- private val serializeEntityMethod = entityClass.getMethod("serializeEntity",nbtClass)
- /**
- * @return Compound
- * */
- fun getNBTCompoundData(entity : Entity): Any? {
- val entityNMS = getHandleMethod.invoke(entity)
- val compound = nbtConstructor.newInstance()
- serializeEntityMethod.invoke(entityNMS,compound)
- return compound
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment