How to setTileEntity

Discussion in 'Plugin Development' started by HeroBear, Dec 29, 2019.

Thread Status:
Not open for further replies.
  1. I have this Test code but its not working because i dont have knowlage about TileEntity managing so teach me pls.

    Code:
    @EventHandler
        public void onETableClick(PlayerInteractEvent e)
        {
            Player p = e.getPlayer();
            WorldServer world = ((CraftWorld)Bukkit.getServer().getWorlds().get(0)).getHandle();
           
            if ((e.getClickedBlock() != null) && (e.getAction() == Action.RIGHT_CLICK_BLOCK))
            {
                int bx = e.getClickedBlock().getX();
                int by = e.getClickedBlock().getY();
                int bz = e.getClickedBlock().getZ();
               
                BlockPosition bp = new BlockPosition(bx, by, bz);
               
                e.setCancelled(true);
               
                TileEntity te = world.getTileEntity(bp);
                p.sendMessage("1:"+te);
               
                getServer().getScheduler().scheduleSyncDelayedTask((Plugin)this, new Runnable()
                {
                    public void run()
                    {
                        p.sendMessage("2:"+te);
                        e.getClickedBlock().getLocation().add(0, 1, 0).getBlock().setType(Material.END_PORTAL_FRAME);
                        world.setTileEntity(bp, te);
                    }
                },  1L);
               
            }
        }
     
  2. Offline

    KarimAKL

    @HeroBear What are you trying to do?
    From what i understand you want to set the block above the clicked block's material to END_PORTAL_FRAME when it's right clicked but, i'm really not sure.
     
  3. @KarimAKL Yea exactly, but thats not the important part, ignore that, thats just a test plugin.
    What i wanna know is how to set TileEntity to another block.
     
    Last edited: Jan 2, 2020
Thread Status:
Not open for further replies.

Share This Page