Posted March 10, 20214 yr Hello, i have made myself a minecraft mod a month ago maybe and slowly learning how to make mods. It was all flying colors until i got a server error when testing the mod and I tried to read the log and debug it myslef but to no avail. I also tried surfing here for an answer also to no avail. So i am asking if anyone can lend me a hand please? I will attach the log file. latest.log
March 10, 20214 yr Author 29 minutes ago, diesieben07 said: Show the ArmorHelmet class. Thank god you replied! You solved all the other problems i had with your answers made in the past Here it is 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.getItem() == RegistryHandler.RU_BOOTS.get() && legs.getItem() == RegistryHandler.RU_LEGGINGS.get() && chest.getItem() == RegistryHandler.RU_CHESTPLATE.get() && 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.getItem() == RegistryHandler.MAKO_BOOTS.get() && legs.getItem() == RegistryHandler.MAKO_LEGGINGS.get() && chest.getItem() == RegistryHandler.MAKO_CHESTPLATE.get() && 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)); } } }
March 10, 20214 yr Author 4 minutes ago, diesieben07 said: Show where you register the class as well please. Gotcha package com.vassdeniss.makoru.util; import com.vassdeniss.makoru.MakoRuMod; import com.vassdeniss.makoru.armor.ModArmorMaterial; import com.vassdeniss.makoru.armor.ModArmorMaterial2; import com.vassdeniss.makoru.items.*; import com.vassdeniss.makoru.tools.ModItemTier; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ArmorItem; import net.minecraft.item.Item; import net.minecraft.item.SwordItem; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class RegistryHandler { public static DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MakoRuMod.MOD_ID); public static void init() { ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); } // Items public static final RegistryObject<Item> REDSTONE_INGOT = ITEMS.register("redstone_ingot", ItemBase::new); public static final RegistryObject<Item> EMERALD_INGOT = ITEMS.register("emerald_ingot", ItemBase::new); public static final RegistryObject<Item> DIAMOND_INGOT = ITEMS.register("diamond_ingot", ItemBase::new); public static final RegistryObject<Item> DIAMOND_INGOT_ENCHANTED = ITEMS.register("diamond_ingot_enchanted", GlowItem::new); public static final RegistryObject<Item> OWANGE_INGOT = ITEMS.register("owange_ingot", ItemBase::new); public static final RegistryObject<Item> MAKO_INGOT = ITEMS.register("mako_ingot", ItemBase::new); public static final RegistryObject<Item> MAKO_INGOT_ENCHANTED = ITEMS.register("mako_ingot_enchanted", GlowItem::new); public static final RegistryObject<Item> RU_INGOT = ITEMS.register("ru_ingot", ItemBase::new); public static final RegistryObject<Item> RU_INGOT_ENCHANTED = ITEMS.register("ru_ingot_enchanted", GlowItem::new); public static final RegistryObject<Item> PINK_CRYSTAL = ITEMS.register("pink_crystal", ItemBase::new); public static final RegistryObject<Item> PURPLE_CRYSTAL = ITEMS.register("purple_crystal", ItemBase::new); public static final RegistryObject<Item> RU_ESSENSE = ITEMS.register("ru_essense", ItemBase::new); public static final RegistryObject<Item> MAKO_ESSENSE = ITEMS.register("mako_essense", ItemBase::new); public static final RegistryObject<Item> DIAMOND_ESSENSE = ITEMS.register("diamond_essense", GlowItem::new); public static final RegistryObject<Item> RU_BREATH = ITEMS.register("ru_breath", ItemBase::new); public static final RegistryObject<Item> RED_HEART = ITEMS.register("red_heart", GlowItem::new); public static final RegistryObject<Item> ORANGE_HEART = ITEMS.register("orange_heart", GlowItem::new); public static final RegistryObject<Item> GREEN_HEART = ITEMS.register("green_heart", GlowItem::new); public static final RegistryObject<Item> TRIFORCE = ITEMS.register("triforce", Triforce::new); public static final RegistryObject<Item> ROSE = ITEMS.register("rose", Rose::new); // Tools public static final RegistryObject<SwordItem> MAKO_SWORD = ITEMS.register("mako_sword", () -> new MakoSword(ModItemTier.LOVE, 14, -1.0F, new Item.Properties().group(MakoRuMod.TAB)) ); public static final RegistryObject<SwordItem> RU_SWORD = ITEMS.register("ru_sword", () -> new RuSword(ModItemTier.LOVE, 15, -2.0F, new Item.Properties().group(MakoRuMod.TAB)) ); // Armor public static final RegistryObject<ArmorItem> RU_HELMET = ITEMS.register("ru_helmet", () -> new ArmorHelmet(ModArmorMaterial.LOVE, EquipmentSlotType.HEAD, new Item.Properties().group(MakoRuMod.TAB)) ); public static final RegistryObject<ArmorItem> RU_CHESTPLATE = ITEMS.register("ru_chestplate", () -> new ArmorChest(ModArmorMaterial.LOVE, EquipmentSlotType.CHEST, new Item.Properties().group(MakoRuMod.TAB)) ); public static final RegistryObject<ArmorItem> RU_LEGGINGS = ITEMS.register("ru_leggings", () -> new ArmorLeggings(ModArmorMaterial.LOVE, EquipmentSlotType.LEGS, new Item.Properties().group(MakoRuMod.TAB)) ); public static final RegistryObject<ArmorItem> RU_BOOTS = ITEMS.register("ru_boots", () -> new ArmorBoots(ModArmorMaterial.LOVE, EquipmentSlotType.FEET, new Item.Properties().group(MakoRuMod.TAB)) ); public static final RegistryObject<ArmorItem> MAKO_HELMET = ITEMS.register("mako_helmet", () -> new ArmorHelmet(ModArmorMaterial2.LOVE, EquipmentSlotType.HEAD, new Item.Properties().group(MakoRuMod.TAB)) ); public static final RegistryObject<ArmorItem> MAKO_CHESTPLATE = ITEMS.register("mako_chestplate", () -> new ArmorChest(ModArmorMaterial2.LOVE, EquipmentSlotType.CHEST, new Item.Properties().group(MakoRuMod.TAB)) ); public static final RegistryObject<ArmorItem> MAKO_LEGGINGS = ITEMS.register("mako_leggings", () -> new ArmorLeggings(ModArmorMaterial2.LOVE, EquipmentSlotType.LEGS, new Item.Properties().group(MakoRuMod.TAB)) ); public static final RegistryObject<ArmorItem> MAKO_BOOTS = ITEMS.register("mako_boots", () -> new ArmorBoots(ModArmorMaterial2.LOVE, EquipmentSlotType.FEET, new Item.Properties().group(MakoRuMod.TAB)) ); }
March 10, 20214 yr Author 2 minutes ago, diesieben07 said: And now ModArmorMaterial2. If you do ask for the first ModArmorMaterial its the same only diffrent values package com.vassdeniss.makoru.armor; import com.vassdeniss.makoru.MakoRuMod; import com.vassdeniss.makoru.util.RegistryHandler; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.IArmorMaterial; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvents; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import java.util.function.Supplier; public enum ModArmorMaterial2 implements IArmorMaterial { LOVE(MakoRuMod.MOD_ID + ":love2", 100, new int[] { 5, 5, 5, 5 }, 25, SoundEvents.ITEM_ARMOR_EQUIP_NETHERITE, 4.0F, () -> { return Ingredient.fromItems(RegistryHandler.MAKO_INGOT_ENCHANTED.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 sound; private final float toughness; private final Supplier<Ingredient> repairMaterial; ModArmorMaterial2(String name, int maxDamageFactor, int[] damageReductionAmountArray, int enchantability, SoundEvent sound, float toughness, Supplier<Ingredient> repairMaterial) { this.name = name; this.maxDamageFactor = maxDamageFactor; this.damageReductionAmountArray = damageReductionAmountArray; this.enchantability = enchantability; this.sound = sound; this.toughness = toughness; this.repairMaterial = repairMaterial; } @Override public int getDurability(EquipmentSlotType slotIn) { return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor; } @Override public int getDamageReductionAmount(EquipmentSlotType slotIn) { return this.damageReductionAmountArray[slotIn.getIndex()]; } @Override public int getEnchantability() { return this.enchantability; } @Override public SoundEvent getSoundEvent() { return this.sound; } @Override public Ingredient getRepairMaterial() { return this.repairMaterial.get(); } @Override public String getName() { return this.name; } @OnlyIn(Dist.CLIENT) @Override public float getToughness() { return this.toughness; } @Override public float getKnockbackResistance() { return 0.2F; } }
March 10, 20214 yr Author 3 minutes ago, diesieben07 said: Why did you put this here? Do not use @OnlyIn at all. I saw that in the tutorial i was watching. Oh but wait Only in client means that it will not work on the server side i presume? That must be the problem I was looking for.
March 10, 20214 yr Author 11 minutes ago, vassdeniss said: I saw that in the tutorial i was watching. Oh but wait Only in client means that it will not work on the server side i presume? That must be the problem I was looking for. Yup that was exactly it! It's all good now! Thank you! I didn't even looked at those 2 classes
March 10, 20214 yr Author 6 minutes ago, diesieben07 said: That is not what it means. @OnlyIn is a marker for vanilla code (do not put it in your code) that tells you if a particular element is client or server distribution only. I see. Thank you for the help and explanation!
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.