Memory leak fix for explosion blocks.

This commit is contained in:
Jonathan Williams 2013-10-13 01:27:41 -07:00
parent 25dec6fb46
commit 1c1fb056a6

View File

@ -153,7 +153,7 @@ public class Explosion extends MiniPlugin
else
{
//XXX ANTILAG
double chance = 0.75 + (double)_explosionBlocks.size()/(double)500;
double chance = 0.85 + (double)_explosionBlocks.size()/(double)500;
if (Math.random() > Math.min(0.975, chance))
{
FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue());
@ -202,12 +202,12 @@ public class Explosion extends MiniPlugin
{
FallingBlock cur = fallingIterator.next();
if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400)
if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400 || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
{
fallingIterator.remove();
//Expire
if (cur.getTicksLived() > 400)
if (cur.getTicksLived() > 400 || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
{
cur.remove();
return;