sendBlockChange() does not work correctly with clickedblocks

Discussion in 'Plugin Development' started by Krippi, Aug 27, 2021.

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

    Krippi

    Hi,
    the problem is that I cannot use sendBlockchange() to change the block that I click on. However, if I exchange the e.getClickedBlock().GetLocation() with e.getplayer.getLocation() in the method, it works.
    But then of course the block is at the player's location and not at the clicked block Location.


    Code:
        public void onBlockClick(PlayerInteractEvent e){
            EquipmentSlot es = e.getHand();
            if(e.getClickedBlock().getType() == Material.WHITE_CONCRETE && es.equals(EquipmentSlot.HAND)){
                e.getPlayer().sendBlockChange(e.getClickedBlock().getLocation(),Material.OAK_PLANKS.createBlockData());
            }
        }
    *Edit* Could it be that right-clicking will make the fake block disappear immediately?
     
    Last edited: Aug 27, 2021
  2. Online

    timtower Administrator Administrator Moderator

    @Krippi Block update fires after the event, send the change a tick later.
     
Thread Status:
Not open for further replies.

Share This Page