Implement a version of FabricDefaultAttributeRegistry#register that takes a DefaultAttributeContainer ()

Refer to https://github.com/orgs/FabricMC/discussions/2587 for motivations :)
This commit is contained in:
triphora 2022-11-07 13:30:06 -05:00 committed by GitHub
parent 12bfe4ea1a
commit 06e0e251a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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));
}
}