Jump to content

[1.16.4] Very odd mod issue concerning ArmorTick


vassdeniss

Recommended Posts

A few weeks ago I made custom armor for my mod and after finally being able to craft it in my server my friend placed it on causing a crash. I have no idea idea what's the issue. I tried some things myslef but nothing worked. Help appriicated! 

 

I've attached the relevant crash report alongside my ArmorHelmet class as stated in the crash report.

 

package com.vassdeniss.makoru.items;

import com.vassdeniss.makoru.util.RegistryHandler;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.IArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.world.World;

public class ArmorHelmet extends ArmorItem {
    public ArmorHelmet(IArmorMaterial materialIn, EquipmentSlotType slot, Properties builderIn) {
        super(materialIn, slot, builderIn);
    }

    @Override
    public void onCreated(ItemStack stack, World worldIn, PlayerEntity playerIn) {
        super.onCreated(stack, worldIn, playerIn);
        stack.addEnchantment(Enchantments.PROTECTION, 4);
        stack.addEnchantment(Enchantments.MENDING, 1);
        stack.addEnchantment(Enchantments.UNBREAKING, 3);
        stack.addEnchantment(Enchantments.THORNS, 3);

        stack.addEnchantment(Enchantments.RESPIRATION, 3);
        stack.addEnchantment(Enchantments.AQUA_AFFINITY, 1);
    }

    @Override
    public void onArmorTick(ItemStack stack, World world, PlayerEntity player) {
        ItemStack boots = player.inventory.armorItemInSlot(0);
        ItemStack legs = player.inventory.armorItemInSlot(1);
        ItemStack chest = player.inventory.armorItemInSlot(2);
        ItemStack helmet = player.inventory.armorItemInSlot(3);

        if (boots != null && boots.getItem() == RegistryHandler.RU_BOOTS.get() &&
                legs != null && legs.getItem() == RegistryHandler.RU_LEGGINGS.get() &&
                chest != null && chest.getItem() == RegistryHandler.RU_CHESTPLATE.get() &&
                helmet != null && helmet.getItem() == RegistryHandler.RU_HELMET.get()) {
            player.addPotionEffect(new EffectInstance(Effects.SPEED, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.JUMP_BOOST, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.HASTE, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.NIGHT_VISION, 10));
            player.addPotionEffect(new EffectInstance(Effects.WATER_BREATHING));
        } else if (boots != null && boots.getItem() == RegistryHandler.MAKO_BOOTS.get() &&
                legs != null && legs.getItem() == RegistryHandler.MAKO_LEGGINGS.get() &&
                chest != null && chest.getItem() == RegistryHandler.MAKO_CHESTPLATE.get() &&
                helmet != null && helmet.getItem() == RegistryHandler.MAKO_HELMET.get()) {
            player.addPotionEffect(new EffectInstance(Effects.SPEED, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.JUMP_BOOST, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.HASTE, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.NIGHT_VISION, 10));
            player.addPotionEffect(new EffectInstance(Effects.WATER_BREATHING));
        }
    }
}

 

latest.log

Link to comment
Share on other sites

12 minutes ago, diesieben07 said:

armorItemInSlot is annotated with @OnlyIn(CLIENT). This means you cannot use it from common code, because it does not exist on the server.

 

Use PlayerEntity#getItemStackFromSlot instead.

I assume this is wha you mean? I just want to be sure.

 @Override
    public void onArmorTick(ItemStack stack, World world, PlayerEntity player) {
        ItemStack boots = player.getItemStackFromSlot(EquipmentSlotType.FEET);
        ItemStack legs = player.getItemStackFromSlot(EquipmentSlotType.LEGS);
        ItemStack chest = player.getItemStackFromSlot(EquipmentSlotType.CHEST);
        ItemStack helmet = player.getItemStackFromSlot(EquipmentSlotType.HEAD);

        if (boots != null && boots.getItem() == RegistryHandler.RU_BOOTS.get() &&
                legs != null && legs.getItem() == RegistryHandler.RU_LEGGINGS.get() &&
                chest != null && chest.getItem() == RegistryHandler.RU_CHESTPLATE.get() &&
                helmet != null && helmet.getItem() == RegistryHandler.RU_HELMET.get()) {
            player.addPotionEffect(new EffectInstance(Effects.SPEED, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.JUMP_BOOST, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.HASTE, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.NIGHT_VISION, 10));
            player.addPotionEffect(new EffectInstance(Effects.WATER_BREATHING));
        } else if (boots != null && boots.getItem() == RegistryHandler.MAKO_BOOTS.get() &&
                legs != null && legs.getItem() == RegistryHandler.MAKO_LEGGINGS.get() &&
                chest != null && chest.getItem() == RegistryHandler.MAKO_CHESTPLATE.get() &&
                helmet != null && helmet.getItem() == RegistryHandler.MAKO_HELMET.get()) {
            player.addPotionEffect(new EffectInstance(Effects.SPEED, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.JUMP_BOOST, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.HASTE, 10, 2));
            player.addPotionEffect(new EffectInstance(Effects.NIGHT_VISION, 10));
            player.addPotionEffect(new EffectInstance(Effects.WATER_BREATHING));
        }
    }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.