Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author
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));
        }
    }

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.