Bug when replacing a block that has just been placed

Discussion in 'Plugin Development' started by pipo3090, Jan 24, 2018.

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

    pipo3090

    I'm trying to replace a block(EnderChest) with a Skull when the block has been placed.
    I've got a very irritating error that I can't fix.
    Error:
    Code:
    [23:12:40 ERROR]: Block at -535,59,1.284 is SKULL but has net.minecraft.server.v1_12_R1.TileEntityEnderChest@353c37ef. Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.
    My code is this for placing it is this:
    Code:
        @EventHandler
        public static void onBlockPlace(BlockPlaceEvent event){
           
            if(!event.getBlockPlaced().getType().equals(Material.ENDER_CHEST)){
               
                return;
               
            }
           
            event.setCancelled(true);
            Location loc = event.getBlockPlaced().getLocation();
            loc.getBlock().setType(Material.SKULL);
            Skull skull = (Skull) loc.getBlock().getState();
            skull.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString("73d4e068-3a6d-4c8b-8f85-3323546955c4")));
           
        }
    It happes when I place the enderchest.

    Bump.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 25, 2018
  2. Offline

    Machine Maker

    Hmm, try setting the block to air and then set the block to the skull. Or try setting the block to a skull with a 1 tick delay.
     
Thread Status:
Not open for further replies.

Share This Page