Posted November 24, 20213 yr 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; } }
November 24, 20213 yr Author I don't think there is an error in this part of the text, or is it? I don't get it, Can you please explain.
November 24, 20213 yr Author But how does return MAX_DAMAGE_ARRAY[equipmentSlot.getIndex() * this.maxDamageFactor]; effect the length of the array?
November 24, 20213 yr MAX_DAMAGE_ARRAY is 4 elements long, you want to get element 6 that is why you get ArrayIndexOutOfBoundsException
November 24, 20213 yr Author 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?
November 24, 20213 yr Author In registry Handler - public static final RegistryObject<ArmorItem> RUBY_HELMET = ITEMS.register("ruby_helmet", () -> new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlot.HEAD, new Item.Properties().group())); the same error as the previous one
November 24, 20213 yr Author The method is tab but while registering which tab the tutorial says .group(ItemGroup), but their is no ItemGroup, so is their a name for that as well?
November 24, 20213 yr 9 minutes ago, mahidhoni123 said: The method is tab but while registering which tab the tutorial says .group(ItemGroup), but their is no ItemGroup, so is their a name for that as well? It's CreativeTab in 1.17
November 27, 20213 yr Author 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
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.