Class EntityObject

java.lang.Object
com.saicone.rtag.entity.EntityObject

public class EntityObject extends Object
Class to invoke Entity methods across versions.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Get encode ID from provided entity.
    static String
    getEncodeId(Object entity, boolean includeNonSaveable)
    Get encode ID from provided entity.
    static Entity
    getEntity(Object entity)
    Get provided Minecraft Entity as Bukkit Entity.
    static Object
    getHandle(Entity entity)
    Get provided Bukkit Entity as Minecraft Entity.
    static boolean
    Check if the provided object is instance of CraftEntity.
    static boolean
    Check if the provided object is instance of Minecraft Entity.
    static void
    load(Object entity, Object tag)
    Load NBTTagCompound into entity.
    static Object
    save(Object entity)
    Save provided entity into newly generated NBTTagCompound.
    This method will try to include entity ID as part of compound.
    static Object
    save(Object entity, Object compound, boolean includeAll, boolean includeNonSaveable, boolean forceSerialization)
    Save provided entity into newly generated NBTTagCompound.
    This method will try to include entity ID as part of compound.
    static boolean
    saveAsPassenger(Object entity, Object compound)
    Save provided entity into provided compound as a passenger.
    This is an optional operation, the provided entity must be marked as 'savable', persistent and should have a valid type.
    static boolean
    saveAsPassenger(Object entity, Object compound, boolean includeAll, boolean includeNonSaveable, boolean forceSerialization)
    Save provided entity into provided compound as a passenger.
    This is an optional operation, the provided entity must be marked as 'savable', persistent and should have a valid type.
    static Object
    saveWithoutId(Object entity, Object compound)
    Save provided entity into newly generated NBTTagCompound.
    As its name says, this method doesn't generate the 'id' key.
    static Object
    saveWithoutId(Object entity, Object compound, boolean includeAll, boolean includeNonSaveable, boolean forceSerialization)
    Save provided entity into newly generated NBTTagCompound.
    As its name says, this method doesn't generate the 'id' key.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isMinecraftEntity

      public static boolean isMinecraftEntity(Object object)
      Check if the provided object is instance of Minecraft Entity.
      Parameters:
      object - the object to check.
      Returns:
      true if the object is an instance of Minecraft Entity.
    • isCraftEntity

      public static boolean isCraftEntity(Object object)
      Check if the provided object is instance of CraftEntity.
      Parameters:
      object - the object to check.
      Returns:
      true if the object is an instance of CraftEntity.
    • getEntity

      public static Entity getEntity(Object entity) throws IllegalArgumentException
      Get provided Minecraft Entity as Bukkit Entity.
      Parameters:
      entity - Entity to convert.
      Returns:
      A Bukkit Entity.
      Throws:
      IllegalArgumentException - if entity is not a Minecraft Entity.
    • getHandle

      public static Object getHandle(Entity entity)
      Get provided Bukkit Entity as Minecraft Entity.
      Parameters:
      entity - Entity to convert.
      Returns:
      A Minecraft Entity.
    • getEncodeId

      public static String getEncodeId(Object entity)
      Get encode ID from provided entity.
      Parameters:
      entity - the Entity to extract id.
      Returns:
      a namespaced String is provided Entity is valid and can be serialized, null otherwise.
    • getEncodeId

      public static String getEncodeId(Object entity, boolean includeNonSaveable)
      Get encode ID from provided entity.
      Parameters:
      entity - the Entity to extract id.
      includeNonSaveable - true to include entity id even if it should not be serialized.
      Returns:
      a namespaced String is provided Entity is valid and can be serialized, null otherwise.
    • save

      public static Object save(Object entity)
      Save provided entity into newly generated NBTTagCompound.
      This method will try to include entity ID as part of compound.
      Parameters:
      entity - the entity to save.
      Returns:
      a NBTTagCompound that represent the entity.
    • save

      public static Object save(Object entity, Object compound, boolean includeAll, boolean includeNonSaveable, boolean forceSerialization)
      Save provided entity into newly generated NBTTagCompound.
      This method will try to include entity ID as part of compound.
      Parameters:
      entity - the entity to save.
      compound - the tag compound that will receive entity data.
      includeAll - true to include entity position data.
      includeNonSaveable - true to include any entity id even if it should not be serialized.
      forceSerialization - save any entity even
      Returns:
      a NBTTagCompound that represent the entity.
    • saveAsPassenger

      public static boolean saveAsPassenger(Object entity, Object compound)
      Save provided entity into provided compound as a passenger.
      This is an optional operation, the provided entity must be marked as 'savable', persistent and should have a valid type.
      Parameters:
      entity - the entity to save.
      compound - the tag compound that will receive entity data.
      Returns:
      true if the entity data was saved, false otherwise.
    • saveAsPassenger

      public static boolean saveAsPassenger(Object entity, Object compound, boolean includeAll, boolean includeNonSaveable, boolean forceSerialization)
      Save provided entity into provided compound as a passenger.
      This is an optional operation, the provided entity must be marked as 'savable', persistent and should have a valid type.
      Parameters:
      entity - the entity to save.
      compound - the tag compound that will receive entity data.
      includeAll - true to include entity position data.
      includeNonSaveable - true to include any entity id even if it should not be serialized.
      forceSerialization - true to include non-persistent entity data.
      Returns:
      true if the entity data was saved, false otherwise.
    • saveWithoutId

      public static Object saveWithoutId(Object entity, Object compound)
      Save provided entity into newly generated NBTTagCompound.
      As its name says, this method doesn't generate the 'id' key.
      Parameters:
      entity - the entity instance.
      compound - the tag compound that will receive entity data.
      Returns:
      a NBTTagCompound that represent the entity.
    • saveWithoutId

      public static Object saveWithoutId(Object entity, Object compound, boolean includeAll, boolean includeNonSaveable, boolean forceSerialization)
      Save provided entity into newly generated NBTTagCompound.
      As its name says, this method doesn't generate the 'id' key.
      Parameters:
      entity - the entity instance.
      compound - the tag compound that will receive entity data.
      includeAll - true to include entity position data.
      includeNonSaveable - true to include any entity id even if it should not be serialized.
      forceSerialization - true to include non-persistent entity data.
      Returns:
      a NBTTagCompound that represent the entity.
    • load

      public static void load(Object entity, Object tag)
      Load NBTTagCompound into entity.
      Parameters:
      entity - Entity instance.
      tag - The NBTTagCompound to load.