Class EntityHooks
java.lang.Object
io.github.thecsdev.tcdcommons.api.hooks.entity.EntityHooks
-
Method Summary
Modifier and TypeMethodDescriptionstatic GenericProperties<net.minecraft.util.Identifier>
getCustomData
(net.minecraft.entity.Entity entity) Returns aHashMap
containing the custom data for a givenEntity
.static <T> T
getCustomDataEntryG
(net.minecraft.entity.Entity entity, net.minecraft.util.Identifier entryId) Deprecated.static <T> T
setCustomDataEntryG
(net.minecraft.entity.Entity entity, net.minecraft.util.Identifier entryId, T entryValue) Deprecated.
-
Method Details
-
getCustomData
public static GenericProperties<net.minecraft.util.Identifier> getCustomData(net.minecraft.entity.Entity entity) Returns aHashMap
containing the custom data for a givenEntity
. This feature is introduced through the tcdcommons mod, as Vanilla Minecraft does not support a "custom data" feature as of 1.19.x.- Parameters:
entity
- The targetEntity
.- Returns:
- The
HashMap
containing the custom data for the givenEntity
. - Throws:
NullPointerException
- When the argument is null.
-
getCustomDataEntryG
@Deprecated public static <T> T getCustomDataEntryG(net.minecraft.entity.Entity entity, net.minecraft.util.Identifier entryId) Deprecated.Retrieves a custom data entry for a givenEntity
and key.
The method attempts to cast the value to the provided type, returning null if the cast fails.
The "G" in the method name stands for "Generic".- Type Parameters:
T
- The generic type of custom data entry to retrieve.- Parameters:
entity
- The targetEntity
.entryId
- The unique identifier for the custom data entry.- Returns:
- The custom data entry associated with the given key, cast to the provided type, or null if the cast fails.
- Throws:
NullPointerException
- When theIdentifier
is null.
-
setCustomDataEntryG
@Deprecated public static <T> T setCustomDataEntryG(net.minecraft.entity.Entity entity, net.minecraft.util.Identifier entryId, T entryValue) Deprecated.Sets a custom data entry for a givenEntity
and key, then returns the value that was set.
This method allows for method chaining during assignment due to its return value.
The "G" in the method name stands for "Generic".- Type Parameters:
T
- The type of the value to be stored in the custom data entry.- Parameters:
entity
- The targetEntity
.entryId
- The unique identifier for the custom data entry.entryValue
- The value to be stored in the custom data entry.- Returns:
- The value that was set in the custom data entry.
- Throws:
NullPointerException
- When theIdentifier
is null.
-