Search in sources :

Example 76 with CraftEntity

use of org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity in project MyPet by xXKeyleXx.

the class PlatformHelper method entityToTag.

@Override
public TagCompound entityToTag(Entity bukkitEntity) {
    net.minecraft.server.v1_16_R3.Entity entity = ((CraftEntity) bukkitEntity).getHandle();
    NBTTagCompound vanillaNBT = new NBTTagCompound();
    if (entity instanceof EntityLiving) {
        ((EntityLiving) entity).saveData(vanillaNBT);
    } else {
        Method b = ReflectionUtil.getMethod(entity.getClass(), "b", NBTTagCompound.class);
        try {
            b.invoke(entity, vanillaNBT);
        } catch (IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }
    return (TagCompound) ItemStackNBTConverter.vanillaCompoundToCompound(vanillaNBT);
}
Also used : net.minecraft.server.v1_16_R3(net.minecraft.server.v1_16_R3) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) Method(java.lang.reflect.Method) TagCompound(de.keyle.knbt.TagCompound) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Entity (org.bukkit.entity.Entity)30 Iterator (java.util.Iterator)21 List (java.util.List)21 LivingEntity (org.bukkit.entity.LivingEntity)17 UUID (java.util.UUID)12 CraftEntity (org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity)10 CraftEntity (org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity)10 HashSet (java.util.HashSet)8 Set (java.util.Set)8 CraftEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity)8 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)7 CraftEntity (org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity)7 EntityAttachmentHelper (com.denizenscript.denizen.utilities.entity.EntityAttachmentHelper)6 Location (org.bukkit.Location)6 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)6 net.minecraft.server.v1_10_R1 (net.minecraft.server.v1_10_R1)5 net.minecraft.server.v1_11_R1 (net.minecraft.server.v1_11_R1)5 Entity (net.minecraft.world.entity.Entity)5 CraftEntity (org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity)5 Vector (org.bukkit.util.Vector)5