Jump to content

[SOLVED] 1.14.4 Game crashes after adding custom armor.


Recommended Posts

Posted (edited)

I've been following this tutorial for modding and I am at adding armor and after i've added it, it crashes. I hashed out the armor code and it works fine.

Here is my console output:

  Reveal hidden contents

And also here is the code that i think is the one that makes it crash:

  Reveal hidden contents

 

Edited by CuBeOnHere
Posted (edited)
  On 9/14/2019 at 10:49 AM, CuBeOnHere said:

I've been following this tutorial for modding and I am at adding armor and after i've added it, it crashes. I hashed out the armor code and it works fine.

Here is my console output:

  Reveal hidden contents

And also here is the code that i think is the one that makes it crash:

  Reveal hidden contents

 

Expand  

Very strange, as I do not have a solution I will just show you my code, as an example.

Items:

event.getRegistry().register(new ArmorItem(ModArmorMaterials.copper, EquipmentSlotType.HEAD, new Item.Properties().group(MoreStuff.morestuff_armor.GroupArmor)).setRegistryName("copper_helmet"));
event.getRegistry().register(new ArmorItem(ModArmorMaterials.copper, EquipmentSlotType.CHEST, new Item.Properties().group(MoreStuff.morestuff_armor.GroupArmor)).setRegistryName("copper_chestplate"));
event.getRegistry().register(new ArmorItem(ModArmorMaterials.copper, EquipmentSlotType.LEGS, new Item.Properties().group(MoreStuff.morestuff_armor.GroupArmor)).setRegistryName("copper_leggings"));
event.getRegistry().register(new ArmorItem(ModArmorMaterials.copper, EquipmentSlotType.FEET, new Item.Properties().group(MoreStuff.morestuff_armor.GroupArmor)).setRegistryName("copper_boots"));

Materials:

public enum ModArmorMaterials implements IArmorMaterial {


    redtunica("redtunica", 3, new int[]{0, 0, 0, 0}, 5, Items.STRING, "item.armor.equip_leather", 0.0f),

    bronze("bronze", 14, new int[]{2, 4, 5, 3}, 15, null, "item.armor.equip_gold", 0.5f),

    copper("copper", 29, new int[]{3, 6, 5, 3}, 10, null, "item.armor.equip_iron", 0.8f);


    //enum
    private static final int[] max_damage_array = new int[]{13, 15, 16, 11};
    private String name, equipSound;
    private int durability, enchantibility;
    private int[] damageReductionAmounts;
    private Item repairItem;
    private float toughness;

    private ModArmorMaterials(String name, int durability, int[] damageReductionAmounts, int enchantibility, Item repairItem, String equipSound, float toughness) {

        this.name = name;
        this.equipSound = equipSound;
        this.durability = durability;
        this.enchantibility = enchantibility;
        this.damageReductionAmounts = damageReductionAmounts;
        this.repairItem = repairItem;
        this.toughness = toughness;

    }


    @Override
    public int getDurability(EquipmentSlotType slot) {
        return max_damage_array[slot.getIndex()] * this.durability;
    }

    @Override
    public int getDamageReductionAmount(EquipmentSlotType slot) {
        return this.damageReductionAmounts[slot.getIndex()];
    }

    @Override
    public int getEnchantability() {
        return this.enchantibility;
    }

    @Override
    public SoundEvent getSoundEvent() {
        return new SoundEvent(new ResourceLocation(equipSound));
    }

    @Override
    public Ingredient getRepairMaterial() {
        return Ingredient.fromItems(this.repairItem);
    }

    @Override
    public String getName() {
        return MoreStuff.MODID + ":" + this.name;
    }

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

you should check everything.

 

I hope this is able to help you

Edited by MatsCraft1
  • Thanks 1
Posted
  On 9/14/2019 at 10:49 AM, CuBeOnHere said:

I've been following this tutorial for modding and I am at adding armor and after i've added it, it crashes. I hashed out the armor code and it works fine.

Here is my console output:

  Reveal hidden contents

And also here is the code that i think is the one that makes it crash:

  Reveal hidden contents

 

Expand  

 

  On 9/14/2019 at 12:29 PM, MatsCraft1 said:

Very strange, as I do not have a solution I will just show you my code, as an example.

Items:

event.getRegistry().register(new ArmorItem(ModArmorMaterials.copper, EquipmentSlotType.HEAD, new Item.Properties().group(MoreStuff.morestuff_armor.GroupArmor)).setRegistryName("copper_helmet"));
event.getRegistry().register(new ArmorItem(ModArmorMaterials.copper, EquipmentSlotType.CHEST, new Item.Properties().group(MoreStuff.morestuff_armor.GroupArmor)).setRegistryName("copper_chestplate"));
event.getRegistry().register(new ArmorItem(ModArmorMaterials.copper, EquipmentSlotType.LEGS, new Item.Properties().group(MoreStuff.morestuff_armor.GroupArmor)).setRegistryName("copper_leggings"));
event.getRegistry().register(new ArmorItem(ModArmorMaterials.copper, EquipmentSlotType.FEET, new Item.Properties().group(MoreStuff.morestuff_armor.GroupArmor)).setRegistryName("copper_boots"));

Materials:

public enum ModArmorMaterials implements IArmorMaterial {


    redtunica("redtunica", 3, new int[]{0, 0, 0, 0}, 5, Items.STRING, "item.armor.equip_leather", 0.0f),

    bronze("bronze", 14, new int[]{2, 4, 5, 3}, 15, null, "item.armor.equip_gold", 0.5f),

    copper("copper", 29, new int[]{3, 6, 5, 3}, 10, null, "item.armor.equip_iron", 0.8f);


    //enum
    private static final int[] max_damage_array = new int[]{13, 15, 16, 11};
    private String name, equipSound;
    private int durability, enchantibility;
    private int[] damageReductionAmounts;
    private Item repairItem;
    private float toughness;

    private ModArmorMaterials(String name, int durability, int[] damageReductionAmounts, int enchantibility, Item repairItem, String equipSound, float toughness) {

        this.name = name;
        this.equipSound = equipSound;
        this.durability = durability;
        this.enchantibility = enchantibility;
        this.damageReductionAmounts = damageReductionAmounts;
        this.repairItem = repairItem;
        this.toughness = toughness;

    }


    @Override
    public int getDurability(EquipmentSlotType slot) {
        return max_damage_array[slot.getIndex()] * this.durability;
    }

    @Override
    public int getDamageReductionAmount(EquipmentSlotType slot) {
        return this.damageReductionAmounts[slot.getIndex()];
    }

    @Override
    public int getEnchantability() {
        return this.enchantibility;
    }

    @Override
    public SoundEvent getSoundEvent() {
        return new SoundEvent(new ResourceLocation(equipSound));
    }

    @Override
    public Ingredient getRepairMaterial() {
        return Ingredient.fromItems(this.repairItem);
    }

    @Override
    public String getName() {
        return MoreStuff.MODID + ":" + this.name;
    }

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

you should check everything.

 

I hope this is able to help you

Expand  

Your Items code seems to have fixed it...

I am guessing that somehow my code is broken, atleast now it works perfectly, thank you so much!

  • Like 1

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.