Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED] Get a variant string value from block meta/state
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
CosmicDan

[SOLVED] Get a variant string value from block meta/state

By CosmicDan, September 26, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

CosmicDan    5

CosmicDan

CosmicDan    5

  • Tree Puncher
  • CosmicDan
  • Members
  • 5
  • 42 posts
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

Share this post


Link to post
Share on other sites

Choonster    1651

Choonster

Choonster    1651

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1651
  • 5098 posts
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.

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

Share this post


Link to post
Share on other sites

CosmicDan    5

CosmicDan

CosmicDan    5

  • Tree Puncher
  • CosmicDan
  • Members
  • 5
  • 42 posts
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

Share this post


Link to post
Share on other sites

P3pp3rF1y    3

P3pp3rF1y

P3pp3rF1y    3

  • Tree Puncher
  • P3pp3rF1y
  • Forge Modder
  • 3
  • 18 posts
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.

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

Choonster    1651

Choonster

Choonster    1651

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1651
  • 5098 posts
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.

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

Share this post


Link to post
Share on other sites

CosmicDan    5

CosmicDan

CosmicDan    5

  • Tree Puncher
  • CosmicDan
  • Members
  • 5
  • 42 posts
Posted September 26, 2017

Sweet, thanks guys - will do.

  • Quote

CosmicDan.com

Windows software, Android hacking, and other curios

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • BobbyLikesCake
      1.16.4 Modded not loading singleplayer worlds

      By BobbyLikesCake · Posted 2 minutes ago

      Ok, Thanks I did modify quark slightly but I hope if I delete all of them I can just edit them once again
    • diesieben07
      1.16.4 Modded not loading singleplayer worlds

      By diesieben07 · Posted 3 minutes ago

      If you didn't modify any of them then its fine, they will just regenerate.
    • BobbyLikesCake
      1.16.4 Modded not loading singleplayer worlds

      By BobbyLikesCake · Posted 5 minutes ago

      Maybe...Is this world still gonna be fine if I delete every single config file? 
    • diesieben07
      1.16.4 Modded not loading singleplayer worlds

      By diesieben07 · Posted 9 minutes ago

      Did something happen to your save? All the server configs in it are coming up invalid:  
    • Draco18s
      Method to get the current durability?

      By Draco18s · Posted 10 minutes ago

      Note that it counts up towards ItemStack#getMaxDamage, so an undamaged item will return 0 out of X and a fully damaged item will be X out of X (next use breaks it).
  • Topics

    • BobbyLikesCake
      13
      1.16.4 Modded not loading singleplayer worlds

      By BobbyLikesCake
      Started 3 hours ago

    • Dr.Nickenstein
      3
      Method to get the current durability?

      By Dr.Nickenstein
      Started 11 hours ago

    • Choonster
      1
      [1.16.5] Properly using DistExecutor with arguments

      By Choonster
      Started 1 hour ago

    • F0RZera
      9
      have an error when trying to connect to LAN server with mods

      By F0RZera
      Started 4 hours ago

    • Nitrix
      0
      Forge dont want make any profile

      By Nitrix
      Started 42 minutes ago

  • Who's Online (See full list)

    • EnergizedAB
    • diesieben07
    • BobbyLikesCake
    • loordgek
    • Kreepydude
    • Draco18s
    • Fake_Name131
    • isaac25
    • UltramoxX
    • Nitrix
    • GTAGhostly
    • iHamster
    • ChampionAsh5357
    • F0RZera
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED] Get a variant string value from block meta/state
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community