Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I have seen that whenever a new block is created, people create a whole new class.

That seems like a lot of useless classes and code must be copy-pasted every time.

So I created only two classes, one for creating blocks, and one for creating items, and I just pass arguments to a constructor, and inside it runs methods: setMaxStackSize(), setUnlocalizedName() and a few more. That saves me from creating a new class every time I need to create a new block. So, since I haven't seen that aproach used anywhere, I just wonder is there something wrong with it? Does it create lag, or conflicts with some rules or conventions?

 

package packageName;

import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;


public class className extends Item{

public className(int itemID, int stackSize, String name, CreativeTabs tab, String texture) {
	super(itemID);

	setMaxStackSize(stackSize);
	setUnlocalizedName(name);
	setCreativeTab(tab);
	setTextureName("intercraft:"+texture);


}

public className(int itemID, int stackSize, String name, CreativeTabs tab) {
	super(itemID);

	setMaxStackSize(stackSize);
	setUnlocalizedName(name);
	setCreativeTab(tab);


}

}

 

There are many behind me, but still some ahead...

its a good approach for basic items. If you want to do some complex stuff with behaviour of an item, then you have to make it a class. So you can override onItemUse in item A and onItemRightClick in class B.

 

In the end it really, really depends what you want that item to be able to do. If it's just a show item, you found the best approach.

I am fairly new to Java and modding, so my answers are not always 100% correct. Sorry for that!

  • Author

Thank you, I thougt it migt cause some illogical problems.

There are many behind me, but still some ahead...

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.