Jump to content

Recommended Posts

Posted

private void regItems(Item item)
{

    GameRegistry.registerItem ( item = new BasicItem( /* Here I want to have the identifier of item in string form*/ ) , /* Same here */);

}

 

The mod is being made in 1.8.9

 

An example is my mod item ultraIron (the variable identifier of the item passed)

private void regItems(Item item)
{

GameRegistry.registerItem ( ultraIron = new BasicItem( "ultraIron" ) , "ultraIron" );

}

 

I am very cautious of .toString() as during my time of programming, the method .toString() has been thrusted upon me while being told that it should always be reimplemented when a need for it comes as it is a default and crappy template for the method.

I love solving puzzles and also coding. What a great combo! I also want to have a career in programming when I have gone through university. 9GAG and Quora stand in the way of me ascending from mediocre programmer to ...meh programmer and beyond!

 

I am always looking for fun projects to look at and maybe be a part of. If you have a project and want to co-operate, email me via [email protected]

 

Keep coding :)

Posted

Basically, ultraIron is defined as

public static Item ultraIron;

 

and the BasicItem method is

public BasicItem( String unlocalizedName )
{

    super();

    this.setUnlocalizedName(unlocalizedName);
    this.setCreativeTab(CreativeTabs.tabMaterials);

}

I love solving puzzles and also coding. What a great combo! I also want to have a career in programming when I have gone through university. 9GAG and Quora stand in the way of me ascending from mediocre programmer to ...meh programmer and beyond!

 

I am always looking for fun projects to look at and maybe be a part of. If you have a project and want to co-operate, email me via [email protected]

 

Keep coding :)

Posted

What String do you want to get the unlocalized Name?

 

I know this is not an answer, but why would you want to do that? I'm kind of a beginner in java sorry

 

Why would he want to do what?

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

What String do you want to get the unlocalized Name?

 

I know this is not an answer, but why would you want to do that? I'm kind of a beginner in java sorry

 

Why would he want to do what?

 

Sorry for my english, I want to know what benefit you'd get of using the string representation instead of just giving it a name.

Posted

This way he doesn't need to write

 

itemObject = new ItemClass().setUnlocalizedName("itemName");
itemObject2 = new ItemClass().setUnlocalizedName("itemName2");

 

Instead he can just do

itemObject = new ItemClass("itemName");
itemObject2 = new ItemClass("itemName2");

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

To reduce the overall code I have to write for my 20+ items I am creating. Modularising and reusing code is the most effective way of coding as it

A) Reduces the final program's file size

B) Reduces the overall amount of typing you have to do

C) Allows you to reuse the modules and functions in future projects

D) Reduces the amount of memory (RAM) used as the instructions of the method are created only once per instantiation. GameRegistry.registerItem will require quite a lot of machine code instructions. By reducing the amount of times it is stored in memory, it will make memory usage much more stable. It is also why I avoid static as much as physically possible. IDK why notch didn't consider all of this in the early days as it would require a complete recode to properly optimise the code

I love solving puzzles and also coding. What a great combo! I also want to have a career in programming when I have gone through university. 9GAG and Quora stand in the way of me ascending from mediocre programmer to ...meh programmer and beyond!

 

I am always looking for fun projects to look at and maybe be a part of. If you have a project and want to co-operate, email me via [email protected]

 

Keep coding :)

Posted

Basically, the unlocalised name. I was originally thinking the actual name used to distinguish one variable from the other but upon further review, it should be the unlocalised name

I love solving puzzles and also coding. What a great combo! I also want to have a career in programming when I have gone through university. 9GAG and Quora stand in the way of me ascending from mediocre programmer to ...meh programmer and beyond!

 

I am always looking for fun projects to look at and maybe be a part of. If you have a project and want to co-operate, email me via [email protected]

 

Keep coding :)

Posted

What do you mean by static is bad for RAM usage?

 

Static can be the biggest source of memory leaks as they are not cleaned up as they don't need an instantiation and is essensially a global variable.

I love solving puzzles and also coding. What a great combo! I also want to have a career in programming when I have gone through university. 9GAG and Quora stand in the way of me ascending from mediocre programmer to ...meh programmer and beyond!

 

I am always looking for fun projects to look at and maybe be a part of. If you have a project and want to co-operate, email me via [email protected]

 

Keep coding :)

Posted

So, I get it, you're trying to automate the item registration? But and the lang file, how would you set the items readable name?

 

I would have to do it manually. I am trying to automate as much as possible without any screwups

I love solving puzzles and also coding. What a great combo! I also want to have a career in programming when I have gone through university. 9GAG and Quora stand in the way of me ascending from mediocre programmer to ...meh programmer and beyond!

 

I am always looking for fun projects to look at and maybe be a part of. If you have a project and want to co-operate, email me via [email protected]

 

Keep coding :)

Posted

So, I get it, you're trying to automate the item registration? But and the lang file, how would you set the items readable name?

 

By using the lang file the same way as normal, the way he is doing it every time he initializes a new ItemClass() and passes in a String to the constructor it will set it to that string.

 

What do you mean by static is bad for RAM usage?

 

Static can be the biggest source of memory leaks as they are not cleaned up as they don't need an instantiation and is essensially a global variable.

 

If you are against using static variables in this aswell you can just use normal variables, but add this

 

@Instance(MODID)
public static MainModClass instance;

 

This way you have one static variable and can access the instance of your Item/Block anywhere.

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

Update to 1.10.2 and use getRegistryName.

 

He said in an earlier topic that he would update, but he is using 1.8.9 because he is making it for himself, and will update to 1.9+

"If it turns out to be a useful mod for us then I might release it and update to the other versions but for now, it will just be for 1.8.9"

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

Compatibility with older mods that either are dead or the mod creators have not bothered to update to newer versions

I love solving puzzles and also coding. What a great combo! I also want to have a career in programming when I have gone through university. 9GAG and Quora stand in the way of me ascending from mediocre programmer to ...meh programmer and beyond!

 

I am always looking for fun projects to look at and maybe be a part of. If you have a project and want to co-operate, email me via [email protected]

 

Keep coding :)

Posted

If so why doesn't forge only support downloads of source for the currently supported version of Minecraft? That would clear up all problems or cause more that I am not thinking of.

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

What is a valid reason to use an old version? Just so I know.

There isn't one.

 

I have already given you a reason

I love solving puzzles and also coding. What a great combo! I also want to have a career in programming when I have gone through university. 9GAG and Quora stand in the way of me ascending from mediocre programmer to ...meh programmer and beyond!

 

I am always looking for fun projects to look at and maybe be a part of. If you have a project and want to co-operate, email me via [email protected]

 

Keep coding :)

Posted

What is a valid reason to use an old version? Just so I know.

There isn't one.

 

I have already given you a reason

 

Acccording to diesieben07 a moderator there is no reason, I wasn't asking you :P (Not meant to be rude)

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

Acccording to diesieben07 a moderator there is no reason, I wasn't asking you :P (Not meant to be rude)

 

I did make the quote from diesieben07 it just happened to include your post that he quoted. diesieben07, I understand that modern versions are more stable but I am not leaving behind discontinued mods or mods that haven't been updated to the most recent version

I love solving puzzles and also coding. What a great combo! I also want to have a career in programming when I have gone through university. 9GAG and Quora stand in the way of me ascending from mediocre programmer to ...meh programmer and beyond!

 

I am always looking for fun projects to look at and maybe be a part of. If you have a project and want to co-operate, email me via [email protected]

 

Keep coding :)

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.