1. Guest, as per the stickied thread, this forum has not been in use since 2014. All bugs and feature requests should be posted to JIRA.

Solved Possible issue with setTicksLived and FallingBlocks

Discussion in 'Bugs & Feature Requests' started by PaulaTheKoala, Jun 12, 2016.

  1. The following code will spawn a falling block without gravity whenever you break a block, the problem is that it gets removed after 30 seconds (600 ticks).

    The solution to this should be to use setTicksLived but it doesn't appear to be working, I'm not sure if this is a known issue or not.

    I was able to resolve the problem by using reflection to manually set ticks lived to 1 every so often.

    Code (Text):
        @EventHandler
        public void onBlockBreak(BlockBreakEvent event)
        {
            Block block = event.getBlock();
         
            FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0, 2, 0), block.getTypeId(), block.getData());
            fallingBlock.setGravity(false);
         
            getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable()
            {
                @Override
                public void run()
                {
                    fallingBlock.setTicksLived(1);
                }
            }, 0L, 100L);
        }
    EDIT:

    I see that this forum is no longer active, If anyone wishes to post this issue on JIRA they're welcome to, I don't plan on it.
     
    #1 PaulaTheKoala, Jun 12, 2016
    Last edited: Jun 12, 2016