From 06e0e251a92ac0de9673b8ccd8e55193201137eb Mon Sep 17 00:00:00 2001
From: triphora <emmaffle@modrinth.com>
Date: Mon, 7 Nov 2022 13:30:06 -0500
Subject: [PATCH] Implement a version of
 `FabricDefaultAttributeRegistry#register` that takes a
 `DefaultAttributeContainer` (#2589)

Refer to https://github.com/orgs/FabricMC/discussions/2587 for motivations :)
---
 .../FabricDefaultAttributeRegistry.java       | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricDefaultAttributeRegistry.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricDefaultAttributeRegistry.java
index 66ec14ee5..c7eb05453 100644
--- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricDefaultAttributeRegistry.java
+++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricDefaultAttributeRegistry.java
@@ -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));
 		}
 	}