From af1cd0dc47dc2402f391dc62ee980db0b84dc352 Mon Sep 17 00:00:00 2001 From: Kitteh6660 Date: Fri, 31 May 2024 23:24:33 -0400 Subject: [PATCH] API errors begone --- .../java/thebetweenlands/api/item/CorrosionHelper.java | 9 +++++---- .../java/thebetweenlands/api/item/IEquippable.java | 10 ++++++---- src/main/java/thebetweenlands/api/package-info.java | 5 +++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/thebetweenlands/api/item/CorrosionHelper.java b/src/main/java/thebetweenlands/api/item/CorrosionHelper.java index 961ce96eb..645f76def 100644 --- a/src/main/java/thebetweenlands/api/item/CorrosionHelper.java +++ b/src/main/java/thebetweenlands/api/item/CorrosionHelper.java @@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; +import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -48,8 +49,8 @@ public class CorrosionHelper { * @param item */ public static void addCorrosionPropertyOverrides(Item item) { - item.addPropertyOverride(new ResourceLocation("corrosion"), (stack, worldIn, entityIn) -> getCorrosionStage(stack)); - item.addPropertyOverride(new ResourceLocation("coating"), (stack, worldIn, entityIn) -> getCoatingStage(stack)); + ItemProperties.register(item, new ResourceLocation("corrosion"), (stack, worldIn, entityIn, id) -> getCorrosionStage(stack)); + ItemProperties.register(item, new ResourceLocation("coating"), (stack, worldIn, entityIn, id) -> getCoatingStage(stack)); } /** @@ -123,8 +124,8 @@ public static boolean areItemStackTagsEqual(ItemStack oldStack, ItemStack newSta */ public static Multimap getAttributeModifiers(Multimap map, EquipmentSlot slot, ItemStack stack, UUID uuid, float damageVsEntity) { if(slot == EquipmentSlot.MAINHAND) { - map.removeAll(Attributes.ATTACK_DAMAGE.getRegistryName()); - map.put(Attributes.ATTACK_DAMAGE.getRegistryName().toString(), new AttributeModifier(uuid, "Tool modifier", damageVsEntity * getModifier(stack), AttributeModifier.Operation.ADDITION)); + map.removeAll(Attributes.ATTACK_DAMAGE); + map.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(uuid, "Tool modifier", damageVsEntity * getModifier(stack), AttributeModifier.Operation.ADDITION)); } return map; } diff --git a/src/main/java/thebetweenlands/api/item/IEquippable.java b/src/main/java/thebetweenlands/api/item/IEquippable.java index 1343e91e4..ecf6ce6cd 100644 --- a/src/main/java/thebetweenlands/api/item/IEquippable.java +++ b/src/main/java/thebetweenlands/api/item/IEquippable.java @@ -2,12 +2,14 @@ import javax.annotation.Nullable; +import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.Container; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraftforge.common.util.LazyOptional; import thebetweenlands.api.capability.IEquipmentCapability; import thebetweenlands.common.capability.equipment.EnumEquipmentInventory; import thebetweenlands.common.registries.CapabilityRegistry; @@ -85,11 +87,11 @@ public interface IEquippable { * @param item */ public static void addEquippedPropertyOverrides(Item item) { - item.addPropertyOverride(new ResourceLocation("equipped"), (stack, world, entity) -> { + ItemProperties.register(item, new ResourceLocation("equipped"), (stack, world, entity, id) -> { if(stack.getItem() instanceof IEquippable && entity != null) { - IEquipmentCapability cap = entity.getCapability(CapabilityRegistry.CAPABILITY_EQUIPMENT, null); - if (cap != null) { - Container inv = cap.getInventory(((IEquippable) stack.getItem()).getEquipmentCategory(stack)); + LazyOptional cap = entity.getCapability(CapabilityRegistry.CAPABILITY_EQUIPMENT, null); + if (cap.isPresent()) { + Container inv = cap.resolve().get().getInventory(((IEquippable) stack.getItem()).getEquipmentCategory(stack)); for (int i = 0; i < inv.getContainerSize(); i++) { if (stack == inv.getItem(i)) { return 1; diff --git a/src/main/java/thebetweenlands/api/package-info.java b/src/main/java/thebetweenlands/api/package-info.java index e2da9107a..ce433779c 100644 --- a/src/main/java/thebetweenlands/api/package-info.java +++ b/src/main/java/thebetweenlands/api/package-info.java @@ -1,4 +1,5 @@ //TODO: Determine if this file should be removed. -/*@API(apiVersion = thebetweenlands.common.lib.ModInfo.API_VERSION, owner = thebetweenlands.common.lib.TheBetweenlands.MOD_ID, provides = thebetweenlands.common.lib.ModInfo.API_NAME) +//@API(apiVersion = thebetweenlands.common.lib.ModInfo.API_VERSION, owner = thebetweenlands.common.lib.TheBetweenlands.MOD_ID, provides = thebetweenlands.common.lib.ModInfo.API_NAME) package thebetweenlands.api; -import net.minecraftforge.fml.common.API*/ \ No newline at end of file + +//import net.minecraftforge.fml.common.API \ No newline at end of file