Jump to content

mahidhoni123

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by mahidhoni123

  1. How do I fix the problem? Should I add more Items to the Array?
  2. I know some basics, but I don't know some of them For eg. final
  3. It doesn't say higher than 3, but says higher than 4
  4. But how does return MAX_DAMAGE_ARRAY[equipmentSlot.getIndex() * this.maxDamageFactor]; effect the length of the array?
  5. 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.
  6. The thing is I can set it to 1 but then the Armor will be very weak
  7. 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; } }
  8. It worked, The error was that the maxDamage factor times equipment slot should be <4 and I figured the problem
  9. Oh no, while running the game this error came - error 8c539e9e-076f-4972-87e0-d0e9a484da8e I want to paste a print screen image, how do we do that? IntelliJ terminal - FML Language Providers: [email protected] javafml@null Mod List: forge-1.17.1-37.0.109_mapped_official_1.17.1.jar |Minecraft |minecraft |1.17.1 |COMMON_SET|Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f |Forge |forge |37.0.109 |COMMON_SET|Manifest: NOSIGNATURE main |Forge Mod |forge_mod |1.17.1-1.0.0 |ERROR |Manifest: NOSIGNATURE Crash Report UUID: 0a3215c3-e186-42a6-8d23-d7ca5f6b57ee FML: 37.0 Forge: net.minecraftforge:37.0.109
  10. The error is in line - public enum ModArmorMaterial - .fromItem is not available
  11. 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 java.util.function.Supplier; public enum ModArmorMaterial implements ArmorMaterial { RUBY(ForgeMod.MOD_ID + ":ruby", 10000000, new int[] { 100, 120, 170, 100}, 18, SoundEvents.AMBIENT_CAVE, 10.0F, () ->{ return Ingredient.fromItem(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;} //The remaining code can be ignored @Override public int getDurabilityForSlot(EquipmentSlot equipmentSlot) { return 0; } @Override public int getDefenseForSlot(EquipmentSlot equipmentSlot) { return 0; } @Override public int getEnchantmentValue() { return 0; } @Override public SoundEvent getEquipSound() { return null; } @Override public Ingredient getRepairIngredient() { return null; } @Override public String getName() { return null; } @Override public float getToughness() { return 0; } @Override public float getKnockbackResistance() { return 0; } } The error is - Cannot resolve method 'fromItem' in 'Ingredient'
  12. I skipped this and tried the Armor but another problem came up - fromItem, 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 java.util.function.Supplier; public enum ModArmorMaterial implements ArmorMaterial { RUBY(ForgeMod.MOD_ID + ":ruby", 10000000, new int[] { 100, 120, 170, 100}, 18, SoundEvents.AMBIENT_CAVE, 10.0F, () ->{ return Ingredient.fromItem(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 0; } @Override public int getDefenseForSlot(EquipmentSlot equipmentSlot) { return 0; } @Override public int getEnchantmentValue() { return 0; } @Override public SoundEvent getEquipSound() { return null; } @Override public Ingredient getRepairIngredient() { return null; } @Override public String getName() { return null; } @Override public float getToughness() { return 0; } @Override public float getKnockbackResistance() { return 0; } }
×
×
  • Create New...

Important Information

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