Jump to content

How to exactly use IItemTier [1.15.2]


Harry12OK

Recommended Posts

So basically i was creating some custom tools.Having been upgraded from 1.12.2 to 1.15.2;I can't really understand how to create your own tool material ,after some figuring out I got to know that it it IItemTier class that will create new tool material,but i cant really understand how that works,i also cannot find any hood tutorials or info on forge Documentation.Any help would be appreciated..

Link to comment
Share on other sites

You need to create your own class (preferably enum, it’ll be easier) and let it implement IItemTier as an interface.

You’ll need to override all the methods of IItemTier in your new class - look at what the vanilla one does, and just replicate its functionality.

Then you can just use your MyModItemTier.SOME_MATERIAL in the constructor of your new tool Items.

  • Thanks 2
Link to comment
Share on other sites

Note that if you are just looking to create one IItemTier implementation then there is no point in using an enum.

  • Thanks 1

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

On 4/28/2020 at 12:08 PM, Fluorescent Flamingo said:

You need to create your own class

So isn't there any functionality like Enumhelper that would reduce the code.

On 4/28/2020 at 12:21 PM, DavidM said:

Note that if you are just looking to create one IItemTier implementation then there is no point in using an enum.

So what should i do?

Link to comment
Share on other sites

19 minutes ago, Harry12OK said:

So what should i do?

Just pass an instance of IItemTier to your item.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

On 4/28/2020 at 12:49 PM, DavidM said:

Just pass an instance of IItemTier to your item.

But IItemTier is an interface.It isn't a class.How am i supposed to pass an instance of it.I could only implement it.

 

Sorry if i asked some foolish thing,i just have knowledge of basic core java.

Edited by Harry12OK
Link to comment
Share on other sites

2 minutes ago, Harry12OK said:

But IItemTier is an interface.It isn't a class.How am i supposed to pass an instance of it.I could only implement it.

 

Sorry if i asked some foolish thing,i just have knowledge of basic core java.

Basically the item tier is what used to be tool material in older versions.

You create a class that implents IItemTier and then you pass that class to your item. (In simple words you "just copy" the vanilla ItemTier class and replace the values.)

  • Thanks 1
Link to comment
Share on other sites

18 hours ago, Harry12OK said:

But IItemTier is an interface.It isn't a class.How am i supposed to pass an instance of it.I could only implement it.

 

Sorry if i asked some foolish thing,i just have knowledge of basic core java.

An instance of a class implementing IItemTier is also an instance of IItemTier.

In terms of class hierarchy as OOP concept, class and interface are treated the same way. Phrases such as “instance of” and “superclass of” apply to both classes and interfaces.

Edited by DavidM
  • Thanks 2

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

Have an example usage

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/item/ModItemTier.java

 

Just be aware that the suppliers are absolutely required.

  • Like 1
  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

thank You guys. I figured out and create my material. Bascially what i did was created a new class for my new material and implemented IItemTier and then did like the vanilla code.

here is my code ===>

public enum ToolMaterial implements IItemTier{
	   
     RUBY(3, 1000, 5.0f, 9.0f, 10, () -> {
		      return Ingredient.fromItems(ModItems.RUBY.get());
	});

	   private final int A;
	   private final int B;
	   private final float C;
	   private final float D;
	   private final int E;
	   private final LazyValue<Ingredient> f;
	 

private ToolMaterial(int i, int j, float f, float g, int k, Supplier<Ingredient> object) {
	  this.A = i;
      this.B = j;
      this.C = f;
      this.D = g;
      this.E = k;
      this.f = new LazyValue<>(object);
}

@Override
public int getMaxUses() {
   
	return this.B;
	
}

@Override
public float getEfficiency() {
	return this.C;
	
}

@Override
public float getAttackDamage() {

	return this.D;
}

@Override
public int getHarvestLevel() {
	
	return this.A;
}

@Override
public int getEnchantability() {

	return this.E;
}

@Override
public Ingredient getRepairMaterial() {

	return this.f.getValue();
}
}

 

Edited by Harry12OK
  • Thanks 1
Link to comment
Share on other sites

11 minutes ago, diesieben07 said:

Oh god why.

Use proper variable names.

I will fix it .Actually  my brain was cooked up. I did it for testing because i thought it would not work.

 

 

 

 

and i mistakenly reported your comment by  seeing report post as reply to this post..

Link to comment
Share on other sites

3 minutes ago, Harry12OK said:

Do i have right to close this topic?

Threads on these forums don't close after the problem has been solved.

Instead, you can prepend "[Solved]" to the title of this thread to notify other people that this problem has been solved.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':processResources'. > Could not copy file 'C:\Users\jedil\Downloads\forge-1.20-46.0.14-mdk\src\main\resources\META-INF\mods.toml' to 'C:\Users\jedil\Downloads\forge-1.20-46.0.14-mdk\build\resources\main\META-INF\mods.toml'.    > Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:      SimpleTemplateScript1.groovy: 1: Unexpected input: '(' @ line 1, column 10.         out.print("""# This is an example mods.toml file. It contains the data relating to the loading mods.                  ^   This is my mods.toml script: # This is an example mods.toml file. It contains the data relating to the loading mods. # There are several mandatory fields (#mandatory), and many more that are optional (#optional). # The overall format is standard TOML format, v0.5.0. # Note that there are a couple of TOML lists in this file. # Find more information on toml format here: https://github.com/toml-lang/toml # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version loaderVersion="${46.0.14}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. license="${All Rights Reserved}" # A URL to refer people to when problems occur with this mod #issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] #mandatory # The modid of the mod modId="${MCRefined}" #mandatory # The version number of the mod version="${1.0.0}" #mandatory # A display name for the mod displayName="${Minecraft Refined}" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/ #updateJSONURL="https://change.me.example.invalid/updates.json" #optional # A URL for the "homepage" for this mod, displayed in the mod UI #displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional # A file name (in the root of the mod JAR) containing a logo for display #logoFile="examplemod.png" #optional # A text field displayed in the mod UI #credits="" #optional # A text field displayed in the mod UI authors="${me}" #optional # Display Test controls the display for your mod in the server connection screen # MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod. # IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod. # IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component. # NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value. # IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself. #displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) # The description text for the mod (multi line!) (#mandatory) description='''${Minecraft, but it's, like, better.}''' # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. I tried using --scan or --stacktrace, those were no help. I also tried Ctrl+Alt+S, the template I used did not appear. HELP
    • They were intended to be used on tutorial posts so that people could easily find tutorials based on their skill level, but instead the tags were abused for unrelated things that made the original intent useless... for example, people often posted crash reports with the "beginner" tag, so instead of finding tutorials for beginners, you got crash reports showing up in searches.
    • The crash says: Exception caught when registering wandering trader java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.Entity.m_9236_()" because "entity" is null at com.telepathicgrunt.repurposedstructures.misc.maptrades.StructureSpecificMaps$TreasureMapForEmeralds.m_213663_(StructureSpecificMaps.java:53) ~[repurposed_structures-7.1.15+1.20.1-forge.jar%23708!/:?] at jeresources.collection.TradeList.addMerchantRecipe(TradeList.java:58) ~[JustEnoughResources-1.20.1-1.4.0.247.jar%23630!/:1.4.0.247] JustEnoughResources is mentioned, too Does it work without one of these mods?
    • I have been trying to place a jigsaw structure for about a week now and cant get it to work. I have the template pool etc set up and working it does randomly generate now I just want to place it in the world using a coded trigger. I cant seem to find any useful information on the internet and am completely stuck I think I need to use : JigsawPlacement.generateJigsaw() But I cant get the Holder<StructureTemplatePool>
    • There are more - maybe   watut, whatdurability, playeranimator and vanillafix
  • Topics

×
×
  • Create New...

Important Information

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