Howto get ExtendedState values?

@Listener
public void onBlockPlace(ChangeBlockEvent.Place event) {
    Optional<Player> optPlayer = event.getCause().first(Player.class);

    if (!optPlayer.isPresent()) return;

    Player player = optPlayer.get();
    
    int explosivelevel = this.plugin.getConfig().getNode("Explosives", "Level").getInt();
    
    for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
        //transaction.getOriginal(); // Block before change
        BlockSnapshot bs = transaction.getFinal(); // Block after change

        this.plugin.debugmsg("Player " + player.getName() + " place block " + bs.getExtendedState() , player.getName());
    }

Console output:

[10:35:30] [Server thread/INFO] [modfixer]: Player HunterzCZ place block ic2:te[facing=north,type=itnt]

Howto get type itnt inside [] ?

Unfortunately, it sounds like you’re trying to get the tile entity information that is beyond the information stored in a BlockState. Check the toContainer() of the snapshot.

Im looking for an universal(and simple) way to get what block is placed.

Again, because it’s a TileEntity, it’s stored in the container information, not the BlockState.

If you just need to know what block is placed (ie that it’s a TNT block) then you could do:

myLocation.getTileEntity().ifPresent(te -> te.getType().getName())

If you want to do more than that you’ll need to either

  • use/create a compat mod that creates Sponge-based interfaces for mod objects that plugins can references and use
  • dip into the raw minecraft code, by casting to the native entity types (eg EntityIC2Tile or something)

Thx for suggestions!