Jump to content

I can't import IItemTier in forge mod minecraft


mahidhoni123

Recommended Posts

package com.anirudh.forgemod.tools; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.world.item.Items; import net.minecraft.world.item.Tier; import net.minecraft.world.item.Tiers; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.Block; import net.minecraftforge.common.ForgeTier; import net.minecraftforge.common.TierSortingRegistry; import java.util.List; public enum ModItemTier implements { public static final Tag. net.minecraft.tags.Tag.Named<Block> MY_TIER_TAG = BlockTags.createOptional(new ResourceLocation("tag_based_tool_types:needs_my_tier_tool")); public static final Tier MY_TIER = TierSortingRegistry.registerTier( new ForgeTier(5, 5000, 10, 100, 0, MY_TIER_TAG, () -> Ingredient.of(Items.BEDROCK)), new ResourceLocation("tag_based_tool_types:my_tier"), List.of(Tiers.DIAMOND), List.of()); }

Link to comment
Share on other sites

ok - package com.anirudh.forgemod.tools;

import net.minecraft.resources.ResourceLocation;

mport net.minecraft.tags.BlockTags;

import net.minecraft.world.item.Items;

import net.minecraft.world.item.Tier;

import net.minecraft.world.item.Tiers;

import net.minecraft.world.item.crafting.Ingredient;

import net.minecraft.world.level.block.Block;

import net.minecraftforge.common.ForgeTier;

import net.minecraftforge.common.TierSortingRegistry;

import java.util.List;

public enum ModItemTier implements {

public static final Tag.

net.minecraft.tags.Tag.Named<Block> MY_TIER_TAG = BlockTags.createOptional(new ResourceLocation("tag_based_tool_types:needs_my_tier_tool")); public static final Tier MY_TIER = TierSortingRegistry.registerTier( new ForgeTier(5, 5000, 10, 100, 0, MY_TIER_TAG, () -> Ingredient.of(Items.BEDROCK)), new ResourceLocation("tag_based_tool_types:my_tier"),

List.of(Tiers.DIAMOND), List.of()); }

Link to comment
Share on other sites

56 minutes ago, mahidhoni123 said:

ok - package com.anirudh.forgemod.tools;

import net.minecraft.resources.ResourceLocation;

mport net.minecraft.tags.BlockTags;

import net.minecraft.world.item.Items;

import net.minecraft.world.item.Tier;

import net.minecraft.world.item.Tiers;

import net.minecraft.world.item.crafting.Ingredient;

import net.minecraft.world.level.block.Block;

import net.minecraftforge.common.ForgeTier;

import net.minecraftforge.common.TierSortingRegistry;

import java.util.List;

public enum ModItemTier implements {

public static final Tag.

net.minecraft.tags.Tag.Named<Block> MY_TIER_TAG = BlockTags.createOptional(new ResourceLocation("tag_based_tool_types:needs_my_tier_tool")); public static final Tier MY_TIER = TierSortingRegistry.registerTier( new ForgeTier(5, 5000, 10, 100, 0, MY_TIER_TAG, () -> Ingredient.of(Items.BEDROCK)), new ResourceLocation("tag_based_tool_types:my_tier"),

List.of(Tiers.DIAMOND), List.of()); }

Please can you send me the code

Link to comment
Share on other sites

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; } }

Link to comment
Share on other sites

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'

Link to comment
Share on other sites

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: 
        minecraft@1.0
        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

 

Link to comment
Share on other sites

  • 2 weeks later...

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.