mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-01 01:30:00 -04:00
Implement a version of FabricDefaultAttributeRegistry#register
that takes a DefaultAttributeContainer
(#2589)
Refer to https://github.com/orgs/FabricMC/discussions/2587 for motivations :)
This commit is contained in:
parent
12bfe4ea1a
commit
06e0e251a9
1 changed files with 15 additions and 4 deletions
|
@ -48,6 +48,17 @@ public final class FabricDefaultAttributeRegistry {
|
|||
private FabricDefaultAttributeRegistry() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a default attribute for a type of living entity.
|
||||
*
|
||||
* @param type the entity type
|
||||
* @param builder the builder that creates the default attribute
|
||||
* @see FabricDefaultAttributeRegistry#register(EntityType, DefaultAttributeContainer)
|
||||
*/
|
||||
public static void register(EntityType<? extends LivingEntity> type, DefaultAttributeContainer.Builder builder) {
|
||||
register(type, builder.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a default attribute for a type of living entity.
|
||||
*
|
||||
|
@ -62,12 +73,12 @@ public final class FabricDefaultAttributeRegistry {
|
|||
*
|
||||
* <p>For convenience, this can also be done on the {@link FabricEntityTypeBuilder} to simplify the building process.
|
||||
*
|
||||
* @param type the entity type
|
||||
* @param builder the builder that creates the default attribute
|
||||
* @param type the entity type
|
||||
* @param container the container for the default attribute
|
||||
* @see FabricEntityTypeBuilder.Living#defaultAttributes(Supplier)
|
||||
*/
|
||||
public static void register(EntityType<? extends LivingEntity> type, DefaultAttributeContainer.Builder builder) {
|
||||
if (DefaultAttributeRegistryAccessor.getRegistry().put(type, builder.build()) != null) {
|
||||
public static void register(EntityType<? extends LivingEntity> type, DefaultAttributeContainer container) {
|
||||
if (DefaultAttributeRegistryAccessor.getRegistry().put(type, container) != null) {
|
||||
LOGGER.debug("Overriding existing registration for entity type {}", Registry.ENTITY_TYPE.getId(type));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue