Package com.saicone.rtag.entity
Class EntityObject
java.lang.Object
com.saicone.rtag.entity.EntityObject
Class to invoke Entity methods across versions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getEncodeId
(Object entity) Get encode ID from provided entity.static String
getEncodeId
(Object entity, boolean includeNonSaveable) Get encode ID from provided entity.static Entity
Get provided Minecraft Entity as Bukkit Entity.static Object
Get provided Bukkit Entity as Minecraft Entity.static boolean
isCraftEntity
(Object object) Check if the provided object is instance of CraftEntity.static boolean
isMinecraftEntity
(Object object) Check if the provided object is instance of Minecraft Entity.static void
Load NBTTagCompound into entity.static Object
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.
-
Method Details
-
isMinecraftEntity
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
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
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
Get provided Bukkit Entity as Minecraft Entity.- Parameters:
entity
- Entity to convert.- Returns:
- A Minecraft Entity.
-
getEncodeId
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
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
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
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
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
Load NBTTagCompound into entity.- Parameters:
entity
- Entity instance.tag
- The NBTTagCompound to load.
-