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.

Announcements



×
×
  • Create New...

Important Information

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