Jump to content

Why is Forge Mod Armor bound to 4?


mahidhoni123

Recommended Posts

HI, when I set MAX_DAMAGE_FACTOR greater than 1 this error comes, for example I set the Max damage factor to 2 - 

Error loading mods

1 error has occurred during loading

Forge Mod (forge_mod) encountered an error during the common_setup event phase 

java.lang.ArrayIndexOutOfBoundsException: Index 6 out of bounds for length 4

 

whereas if I set the MAX_DAMAGE_FACTOR 3 this error comes - 

Forge Mod (forge_mod) encountered an error during the common_setup event phase 

java.lang.ArrayIndexOutOfBoundsException: Index 9 out of bounds for length 4

 

My Code - 

package com.anirudh.forgemod.armor;

import com.anirudh.forgemod.ForgeMod;
import com.anirudh.forgemod.util.RegistryHandler;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import java.util.function.Supplier;

public enum ModArmorMaterial implements ArmorMaterial {

    RUBY(ForgeMod.MOD_ID + ":ruby",2, new int[] { 2, 5, 6, 2}, 999999999,
            SoundEvents.AMBIENT_CAVE, 1000.0F, () ->{ return Ingredient.of(RegistryHandler.RUBY.get()); });

    private static final int[] MAX_DAMAGE_ARRAY = new int[] {11, 16, 15, 13 };
    private final String name;
    private final int maxDamageFactor;
    private final int[] damageReductionAmountArray;
    private final int enchantability;
    private final SoundEvent soundEvent;
    private final float toughness;
    private final Supplier<Ingredient> repairMaterial;

    ModArmorMaterial(String name, int maxDamageFactor, int[] damageReductionAmountArray, int enchantability,
                     SoundEvent soundEvent, float toughness, Supplier<Ingredient> repairMaterial){
        this.name = name;
        this.maxDamageFactor = maxDamageFactor;
        this.damageReductionAmountArray = damageReductionAmountArray;
        this.enchantability = enchantability;
        this.soundEvent = soundEvent;
        this.toughness = toughness;
        this.repairMaterial = repairMaterial;
    }

    @Override
    public int getDurabilityForSlot(EquipmentSlot equipmentSlot) {
        return MAX_DAMAGE_ARRAY[equipmentSlot.getIndex() * this.maxDamageFactor];
    }

    @Override
    public int getDefenseForSlot(EquipmentSlot equipmentSlot)
     {
        return this.damageReductionAmountArray[equipmentSlot.getIndex()];
    }

    @Override
    public int getEnchantmentValue() {
        return this.enchantability;
    }

    @Override
    public SoundEvent getEquipSound() {
        return this.soundEvent;
    }

    @Override
    public Ingredient getRepairIngredient() {
        return this.repairMaterial.get();
    }

   @OnlyIn(Dist.CLIENT)

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public float getToughness() {
        return this.toughness;
    }

    @Override
    public float getKnockbackResistance() {
        return 0;
    }
}

 

Link to comment
Share on other sites

In one of the lines I wrote

    RUBY(ForgeMod.MOD_ID + ":ruby",1, new int[] { 2, 5, 6, 2, }, 999999999,
            SoundEvents.AMBIENT_CAVE, 1000.0F, () ->{ return Ingredient.of(RegistryHandler.RUBY.get()).group(); });

The error is - Cannot resolve method 'group' in Ingredient, I think the name has changed but to which name?

Link to comment
Share on other sites

my code - 

package com.anirudh.forgemod.world.gen;

import com.anirudh.forgemod.ForgeMod;
import net.minecraft.world.level.biome.Biome;

import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.registries.ForgeRegistries;

@Mod.EventBusSubscriber(modid = ForgeMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModOreGen {

    @SubscribeEvent
    public static void generateOres(FMLLoadCompleteEvent event){
        for (Biome biome : ForgeRegistries.BIOMES){

            if (biome.getBiomeCategory() == Biome.BiomeCategory.NETHER){

            } else if (biome.getBiomeCategory() == Biome.BiomeCategory.THEEND){

            } else {

            }
        }
    }
    private static void genOre(Biome biome, int count, int bottomOffset, int topOffset, int max, OreFeatureConfig.FillerBlockType filler,BlockState defaultBlockstate, int size){

    }
}

Error - Cannot resolve symbol 'OreFeatureConfig' :31

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.

Announcements



×
×
  • Create New...

Important Information

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