mirror of
https://github.com/FabricMC/fabric.git
synced 2025-09-04 16:59:11 +00:00
Revert fix for FabricItem.getAttributeModifiers() and deprecate for removal.
Closes #3812
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package net.fabricmc.fabric.api.item.v1;
|
||||
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.AttributeModifiersComponent;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -64,14 +65,9 @@ public interface FabricItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the attribute modifiers to apply when this stack is worn in a living entity equipment slot.
|
||||
* Stack-aware version of {@link Item#getAttributeModifiers()}.
|
||||
*
|
||||
* <p>Note that attribute modifiers are only updated when the stack changes, i.e. when {@code ItemStack.areEqual(old, new)} is false.
|
||||
*
|
||||
* @param stack the current stack
|
||||
* @return the attribute modifiers
|
||||
* @deprecated Replaced with {@link DataComponentTypes#ATTRIBUTE_MODIFIERS}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
default AttributeModifiersComponent getAttributeModifiers(ItemStack stack) {
|
||||
return ((Item) this).getAttributeModifiers();
|
||||
}
|
||||
|
@@ -23,10 +23,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import net.minecraft.component.DataComponentType;
|
||||
import net.minecraft.component.type.AttributeModifiersComponent;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -60,27 +57,4 @@ public abstract class ItemStackMixin implements FabricItemStack {
|
||||
|
||||
original.call(instance, amount, random, serverPlayerEntity, runnable);
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "appendAttributeModifiersTooltip",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/item/ItemStack;getOrDefault(Lnet/minecraft/component/DataComponentType;Ljava/lang/Object;)Ljava/lang/Object;"
|
||||
)
|
||||
)
|
||||
public Object appendAttributeModifiersTooltip(ItemStack stack, DataComponentType<AttributeModifiersComponent> type, Object fallback) {
|
||||
return getItem().getAttributeModifiers(stack);
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "applyAttributeModifiers",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/item/Item;getAttributeModifiers()Lnet/minecraft/component/type/AttributeModifiersComponent;"
|
||||
)
|
||||
)
|
||||
public AttributeModifiersComponent applyAttributeModifiers(Item item) {
|
||||
ItemStack stack = (ItemStack) (Object) this;
|
||||
return item.getAttributeModifiers(stack);
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2560M
|
||||
org.gradle.parallel=true
|
||||
fabric.loom.multiProjectOptimisation=true
|
||||
|
||||
version=0.99.3
|
||||
version=0.99.4
|
||||
minecraft_version=1.20.6
|
||||
yarn_version=+build.1
|
||||
loader_version=0.15.6
|
||||
@@ -30,7 +30,7 @@ fabric-entity-events-v1-version=1.6.8
|
||||
fabric-events-interaction-v0-version=0.7.6
|
||||
fabric-game-rule-api-v1-version=1.0.50
|
||||
fabric-gametest-api-v1-version=1.3.17
|
||||
fabric-item-api-v1-version=8.2.2
|
||||
fabric-item-api-v1-version=8.2.3
|
||||
fabric-item-group-api-v1-version=4.0.39
|
||||
fabric-key-binding-api-v1-version=1.0.45
|
||||
fabric-keybindings-v0-version=0.2.43
|
||||
|
Reference in New Issue
Block a user