Jump to content

Recommended Posts

  • 1 month later...
Posted

I have the same problem.

 

I'm using in 1.7.10 IICon to have one item that is multiple items depending on the metadata.

this saved me time because the items all have the same function. only a different name and texture

 


private int itemCount = Ref.CRAFTITEMS.length;

@SideOnly
(Side.CLIENT)
private IIcon[] icons;

public CraftItem() {
	super();
	setCreativeTab(PurpleStuffMod.purpleStuffTab);
	setHasSubtypes(true);
	setMaxDamage(0);
}

@Override
public String getUnlocalizedName(ItemStack stack) {
	int i = MathHelper.clamp_int(stack.getItemDamage(), 0, itemCount);
	return Ref.CRAFTITEMS[i];
}

@Override
@SideOnly
(Side.CLIENT)
public void registerIcons(IIconRegister register) {
	icons = new IIcon[itemCount];

	for (int i = 0; i < icons.length; i++) {
		icons[i] = register.registerIcon(Ref.Texture_Path + Ref.CRAFTITEMS[i]);
	}
}

@Override
@SideOnly
(Side.CLIENT)
public IIcon getIconFromDamage(int dmg) {
	return icons[dmg];
}

@Override
@SideOnly
(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
	for (int i = 0; i < itemCount; i++) {
		list.add(new ItemStack(this, 1, i));
	}
}

 

 

Posted

You have to create different items, but you can just use the same class for them

 

This is wrong.

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/OresBase.java#L108

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.

Posted

IIcon has been replaced with the ResourceLocation class (at least that's where my strings went). Usage differs depending on whether you have an item or a block. You also need to learn all about block states and the JSON files. There has been much written over the last two years, please Google the Forge + keywords and look for forum posts from mc 1.8 forward.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

IIcon has been replaced with the ResourceLocation class

Not true, the ResourceLocation class has existed for a long time.

catch(Exception e)

{

 

}

Yay, Pokémon exception handling, gotta catch 'em all (and then do nothing with 'em).

Posted

I guess I didn't say it well. For block texturing, just read about blockstates and go from there.

 

For items, ignore tutorials about the "mesher". Set a custom resource location instead (see the ModelLoader class). You should Google this forum for past discussion.

 

In either case, you'll need to write json files (maybe many of them). Use a json validator tool such as json lint. (I wonder if there's a way for me to add one to Eclipse).

 

Much of the discussion on upgrading from IIcon is now more than a year old. Do a Google search of this forum and then narrow your search using a custom date range (and continue to ignore the mesher).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

I can remember i used the resourceLocation in the past.

 

And has anybody tried to let gson create the json files for the items and blocks?

Offcourse with a check if they don't exist.

 

i just want a simple and easy way to add simple generic items,

so that i have more time to work on the more complicated stuff.

Posted

I can remember i used the resourceLocation in the past.

 

And has anybody tried to let gson create the json files for the items and blocks?

Offcourse with a check if they don't exist.

 

i just want a simple and easy way to add simple generic items,

so that i have more time to work on the more complicated stuff.

That would be very simple just do it before the game actually starts loading and by that i mean before it starts loading the resources.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

That would be very simple just do it before the game actually starts loading and by that i mean before it starts loading the resources.

 

So i guess in the preInit i need to create an arraylist with all the items/blocks and then check if the json exists. and when thats done create and register the items and the create json files.

 

and in the init method tell the proxy to use the desired json file.

 

Is this the way to it? because it kinda sounds too simple to work out of the box :P

Posted

If you really want to not write any JSON by hand then write yourself a small program to generate them beforehand instead of messing around with the game's internals.

 

First i wrote them by hand, but it was tedious work, then i searched the internet and i found the program made by wuppy and this was great but i could not copy and paste so i had to type everything and this was again a lot of work.

 

So i wrote a java program that asks for the mod root directory and then compares the names of the textures with the names of the model/json files and it creates the model/json file when there was a texture but no model/json file for it and it also adds an generic entry in the language file for the item/block.

 

But this program does basic stuff and if i make more complicated block i still have to edit the json file.

 

and i know i'm just lazy.  i was just wondering if it was possible to do it this way.

 

one of the things i want to avoid is looking for hours at my code why something is not working and then find out i forgot a column or a komma in my json file ;)

Posted

For a "complicated block" you have to write special logic anyways. If you write that in JSON or in code does not make much difference, except that JSON is cleaner here.

 

Yes i know there are always exceptions :)

 

Thank you for your feedback i really appreciated it.

 

you have helped me a lot just by helping other people on this forum.

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.