Jump to content

[1.12.2] Can't get correct meta from blockstate


Eric12324

Recommended Posts

Hello everyone, I want to get block's meta from a BlockPlaceEvent, it works perfectly for vanilla blocks(e.g. minecraft:wool or planks) but not mod blcoks, I try to get meta from ic2's machines, but it's always 1.  

my code:

public void forgePlaceBlock(BlockEvent.EntityPlaceEvent event){
        IBlockState iBlockState = event.getPlacedBlock();
        Block block = iBlockState.getBlock();

        String name = Objects.requireNonNull(block.getRegistryName()).toString();
        String meta = String.valueOf(block.getMetaFromState(iBlockState));

        Player player = getSpongePlayerByName(Objects.requireNonNull(event.getEntity()).getName());
        player.sendMessage(Text.of(name+":"+meta));

    }

 

 

86Y5UM8T7BFG2GMU32EJ6(R.png

Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.