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

In updating my mod from 1.7 to 1.10, I am faced with setting a wood EnumType in my leaves class.

How can I set it to a custom enum? Is this just me being terrible at Enums?

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

In updating my mod from 1.7 to 1.10, I am faced with setting a wood EnumType in my leaves class.

How can I set it to a custom enum? Is this just me being terrible at Enums?

Create your own enum...

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.

  • Author

In updating my mod from 1.7 to 1.10, I am faced with setting a wood EnumType in my leaves class.

How can I set it to a custom enum? Is this just me being terrible at Enums?

Create your own enum...

 

I don't think I quite understand

I did this

 
public static enum EnumType implements IStringSerializable { 
	Rubber(0, "rubber", MapColor.WOOD);

	private static final EnumType[] META_LOOKUP = new EnumType[values().length];
	private final int meta;
	private final String name;
	private final String unlocalizedName;
	/** The color that represents this entry on a map. */
	private final MapColor mapColor;

	private EnumType(int metaIn, String nameIn, MapColor mapColorIn) {
		this(metaIn, nameIn, nameIn, mapColorIn);
	}

	private EnumType(int metaIn, String nameIn, String unlocalizedNameIn, MapColor mapColorIn) {
		this.meta = metaIn;
		this.name = nameIn;
		this.unlocalizedName = unlocalizedNameIn;
		this.mapColor = mapColorIn;
	}

	public int getMetadata() {
		return this.meta;
	}

	/**
	 * The color which represents this entry on a map.
	 */
	public MapColor getMapColor() {
		return this.mapColor;
	}

	public String toString() {
		return this.name;
	}

	public static EnumType byMetadata(int meta) {
		if (meta < 0 || meta >= META_LOOKUP.length) {
			meta = 0;
		}

		return META_LOOKUP[meta];
	}

	public String getName() {
		return this.name;
	}

	public String getUnlocalizedName() {
		return this.unlocalizedName;
	}

	static {
		for (EnumType blockplanks$enumtype : values()) {
			META_LOOKUP[blockplanks$enumtype.getMetadata()] = blockplanks$enumtype;
		}
	}

 

And I can't return from this enum because the method is looking for the one in BlockPlanks, and I can't cast it because it throws an error

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

  • Author

In the leaves block class. As seen here:

 

@Override
public EnumType getWoodType(int meta) {
	// TODO Auto-generated method stub
	return (EnumType)BlockRubberLog.EnumType.Rubber;
}

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

In the leaves block class. As seen here:

 

@Override
public EnumType getWoodType(int meta) {
	// TODO Auto-generated method stub
	return (EnumType)BlockRubberLog.EnumType.Rubber;
}

You do not need to put anything there, just leave it as null and override all methods using that enum and use your own.

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.

Oh, okay. Thank you.

If you are using an IDE (hopefully you are and are not using something like notepad) just use your search feature and look for where the method is called. In this case getWoodType() is only ever called from within the leaves classes. Therefore it is not necessary unless some other mod uses it and doesn't check for null for some reason. So maybe just in case return something that works that is not null.

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.

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...

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.