Jump to content

Recommended Posts

Posted

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

Posted

1.12 is no longer supported on this forum due to age.

Please update to a modern version to receive support here.

 

More information on supported versions can be found in the LTS link at the top of every page.

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

Announcements



×
×
  • Create New...

Important Information

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