Skip to content

Commit

Permalink
Use wrapAsHolder instead of direct for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
aromaa committed May 21, 2024
1 parent b1ec627 commit 22e18ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
package org.spongepowered.common.mixin.api.minecraft.world.entity;

import net.minecraft.core.Holder;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeMap;
import org.spongepowered.api.data.Keys;
Expand Down Expand Up @@ -57,7 +57,7 @@ public abstract class LivingEntityMixin_API extends EntityMixin_API implements L
public Optional<Attribute> attribute(final AttributeType type) {
Objects.requireNonNull(type, "AttributeType cannot be null");

return Optional.ofNullable((Attribute) this.shadow$getAttributes().getInstance(Holder.direct((net.minecraft.world.entity.ai.attributes.Attribute) type)));
return Optional.ofNullable((Attribute) this.shadow$getAttributes().getInstance(BuiltInRegistries.ATTRIBUTE.wrapAsHolder((net.minecraft.world.entity.ai.attributes.Attribute) type)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,18 @@
import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.event.HoverEventSource;
import net.minecraft.core.Holder;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.EquipmentSlotGroup;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.component.ItemAttributeModifiers;
import net.minecraft.world.item.enchantment.Enchantment;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.slf4j.Logger;
import org.spongepowered.api.data.SerializableDataHolder;
import org.spongepowered.api.data.persistence.DataContainer;
import org.spongepowered.api.data.persistence.DataView;
Expand All @@ -54,7 +51,6 @@
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.inventory.equipment.EquipmentType;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Interface.Remap;
Expand Down Expand Up @@ -169,7 +165,7 @@ public SerializableDataHolder.Mutable copy() {
};

this.shadow$update(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY, component ->
component.withModifierAdded(Holder.direct((Attribute) attributeType),
component.withModifierAdded(BuiltInRegistries.ATTRIBUTE.wrapAsHolder((Attribute) attributeType),
(net.minecraft.world.entity.ai.attributes.AttributeModifier) (Object) modifier,
group));
}
Expand Down

0 comments on commit 22e18ca

Please sign in to comment.