Development Assistance Forge Get block ID (no not that one)

Discussion in 'Plugin Help/Development/Requests' started by Angellus_Mortis, Apr 17, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Angellus_Mortis

    How do you get a block's new block id? Not the deprecated int one, but the newer one that is a string in the format <resource>:<unlocalized_name>.

    We have a Forge mod that we wrote and part of the mod is ore regenerating (so the ore block keeps giving ore as you mine it). I need to be able to reference the block so I can intercept and override a block break event to allow the blocks to be "mined" but not "broken" inside of regions protected by other plugins.

    So it would be something like this (just as an example of what I am trying to do):
    Code:
    public void onBlockBreak(BlockBreakEvent event) {
        if (event.getBlock().getId().equals('modId:test_block') {
             // do stuff
        }
    }
     
  2. Offline

    Zombie_Striker

    Does your block have any metaData that you can try and get. That's the only way I can think of.
     
  3. Offline

    Angellus_Mortis

    It has metaData, but that does not give you a unique identifier. As far as I know, metadata can only be values 0-15. Unless you are talking about an NBT tag or something, which in that case, you cannot do without a TileEntity. You cannot add NBT tags or any extra data to blocks without TileEntities.

    There has to be some way to get the string ID for a block since plugins like GetID exists and work with non-vanilla blocks. Even if there was something like getUnlocalizedName, I could use that.

    I would like to point out to whoever moved my thread, this is not a Forge issue. This is simply how Minecraft handles IDs now. All IDs are in the format "<resource>:<unlocalized_name>". I am simply trying to get the MINECRAFT ID for a block, not the Bukkit one.

    If you do not believe me, open any Minecraft 1.7+, create a new world with cheats and type in "/give <username> minecraft:" and press TAB. The default resource for Vanilla Minecraft is obviously "minecraft" wheras for any Forge mod it will be the modID of your mod.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
Thread Status:
Not open for further replies.

Share This Page