Jump to content

Recommended Posts

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]

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?

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.

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?

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]

Posted

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]

Posted

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.

Posted

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

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