Enum blockstates using custom code

Started by TheGeekyGeekMC on

Topic category: Help with Minecraft modding (Java Edition)

Active 2 months ago
Joined Aug 2018
Points:
718

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 19
Enum blockstates using custom code

I am trying to make a custom EnumProperty blockstate for a "BuffetTable" block that is supposed to be able to be two blocks long (or longer). This is the custom element I used for the EnumProperty (based on Minecraft's "ChestType" enum from the decompiled code): https://pastebin.com/CdU7b1R9

And this is the code for the block: https://pastebin.com/LAW2PYUt

However, the code fails to compile and I get this in the console:https://pastebin.com/KXJRPrD3

Can you please help me with this? What is the correct way to make custom enum blockstates using code?

 

Active 1 year ago
Joined Jun 2022
Points:
428

User statistics:

  • Modifications: 1
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 7
I think you may have…
Thu, 08/10/2023 - 15:13

I think you may have experienced the same problem as I did. I followed this tutorial, https://mcreator.net/forum/87289/tutorial-20221-1182-change-block-modeltexture-ingame, but changed all things related to integer properties to enum. I received the cannot find symbol error and found out (thanks to ChatGPT) that I needed to implement StringRepresentable in the enum for Minecraft to read the values as strings. Here's how the code looked:

import net.minecraft.util.StringRepresentable;

public enum TileLogicProcedure implements StringRepresentable{

		ONE("one"), 
		TWO("two"), 
		THREE("three"), 
		FOUR("four"); 


		private final String name;
		private TileLogicProcedure(String name) {
			this.name = name;
			}

		@Override
		public String getSerializedName() {
			return name;
		}
}

And here's a link to a post I made where I had the same problem, but later found the solution: https://mcreator.net/forum/99492/block-enum-property-issue.

Hope this helps!