CosmicDan Posted September 26, 2017 Posted September 26, 2017 (edited) Hi, I've been trying to figure out how to get a variant property string (for the purposes of building a ModelResourceLocation for a subblock) programmatically, given a block meta and/or blockstate. The variants seem to be ordered the same as meta, but I am not sure if this is always the case. If it is, is there a better way than doing blockState.getValue(blockState.getPropertyKeys(...))? If it is not the case, how would one achieve this? Also, I've noticed there is a getVariants method in BlockStateMapper, but I'm unable to get a handle on the BlockModelShapes as early as I require (in the ModelRegistryEvent) sadly. Cheers. Edited December 20, 2017 by CosmicDan Mark as solved Quote CosmicDan.com Windows software, Android hacking, and other curios
Choonster Posted September 26, 2017 Posted September 26, 2017 Create an instance of an anonymous class that extends StateMapperBase and implements StateMapperBase#getModelResourceLocation to return a dummy ModelResourceLocation (e.g. new ModelResourceLocation("minecraft:air")). You can then use StateMapperBase#getPropertyString to get a property string to use as the variant of a ModelResourceLocation. You can see how I do this in my mod here and here. 2 Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
CosmicDan Posted September 26, 2017 Author Posted September 26, 2017 Oh wow that seems really obvious now, I already use #getPropertyString in an actual StateMapper already *facepalm* Thanks heaps! An aside, would you happen to have any recommended reading for the latest Forge stuff (in addition to the Forge docs and TheGreyGhost's articles/MBE repo)? I recently read a gist of yours that was helpful. Quote CosmicDan.com Windows software, Android hacking, and other curios
P3pp3rF1y Posted September 26, 2017 Posted September 26, 2017 Definitely check out these - https://wiki.mcjty.eu/modding/index.php/Main_Page McJty is doing a great job explaining plenty of topics there and has links to other sites as well. 1 Quote
Choonster Posted September 26, 2017 Posted September 26, 2017 I try to keep TestMod3 up to date with the latest Forge/Minecraft changes, so you can reference it to see how to adapt to recent changes or how to implement various features. You can also search this forum to see if anyone has asked about the topic before. 1 Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
CosmicDan Posted September 26, 2017 Author Posted September 26, 2017 Sweet, thanks guys - will do. Quote CosmicDan.com Windows software, Android hacking, and other curios
Recommended Posts
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.