Solved Stop new leaves from decaying

Discussion in 'Spigot Plugin Development' started by NubeBuster, May 29, 2016.

  1. I am making a world generator and I want leaves that I place with it not to decay.
    I think I have heard of a way of setting the block data to something so the leaves wont decay.

    I do not want to cancel all leave decay, so LeafDecayEvent is not the solution.
     
  2. Not sure why you wouldn't use an event for this;

    When placing/generating the block, add MetaData to it. Then listen for LeafDecayEvent, if the decaying block has the metadata, cancel the event.
     
    • Useful Useful x 1
    • Useful Useful x 1
  3. I wouldn't use an event because adding metadata to millions of blocks is not resource friendly. Besides, there is a better way as the guy after you shows.
     
  4. It actually is very resource friendly.
    Like, would it be non-resource friendly have a data on a million blocks? Same thing..
    And millions of entities. With aloot of metadata.
     
  5. If it's only one world where the leaves shouldn't decay. Then you could also just cancel the event for the leaves in that world.
     
  6. It is resource friendly.
     
  7. Changing the block data will increase the RAM usage by nothing.
    Adding the blocks to a list will use a bit of RAM aswell as adding it to a list will use CPU power. Also checking if a block is in the list will take CPU. Also the server will have to chech for those leaves if they should decay and then it needs to fire an event which I will have to cancel afterwards.
     
  8. I only want the new leaves created by my world generator not to decay.
     
  9. Not sure if troll or just-

    Leaves have a data value specifically to turn decay on and off, unlike your method it survives server restarts, takes no extra CPU time and does not bloat ram with potentially hundreds of millions of bytes of data.
     
    • Agree Agree x 1