Skip to content

Commit

Permalink
API errors begone
Browse files Browse the repository at this point in the history
  • Loading branch information
Kitteh6660 committed Jun 7, 2024
1 parent 9f80c32 commit af1cd0d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/main/java/thebetweenlands/api/item/CorrosionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -123,8 +124,8 @@ public static boolean areItemStackTagsEqual(ItemStack oldStack, ItemStack newSta
*/
public static Multimap<Attribute, AttributeModifier> getAttributeModifiers(Multimap<Attribute, AttributeModifier> 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;
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/thebetweenlands/api/item/IEquippable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<IEquipmentCapability> 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;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/thebetweenlands/api/package-info.java
Original file line number Diff line number Diff line change
@@ -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*/

//import net.minecraftforge.fml.common.API

0 comments on commit af1cd0d

Please sign in to comment.