Messed Around with LavaSurge

Added a spawnFallingBlock method in Methods.
This commit is contained in:
Brendan Wilson 2014-12-22 13:11:10 -05:00
parent bb24c4cc6a
commit 625b91054f
2 changed files with 39 additions and 14 deletions

View file

@ -133,6 +133,7 @@ import com.projectkorra.rpg.RPGMethods;
import com.projectkorra.rpg.WorldEvents;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
@ -2119,6 +2120,28 @@ public class Methods {
}
}
}
public static FallingBlock spawnFallingBlock(Location loc, int type)
{
return spawnFallingBlock(loc, type, (byte) 0);
}
public static FallingBlock spawnFallingBlock(Location loc, Material type)
{
return spawnFallingBlock(loc, type, (byte) 0);
}
@SuppressWarnings("deprecation")
public static FallingBlock spawnFallingBlock(Location loc, int type, byte data)
{
return loc.getWorld().spawnFallingBlock(loc, type, data);
}
@SuppressWarnings("deprecation")
public static FallingBlock spawnFallingBlock(Location loc, Material type, byte data)
{
return loc.getWorld().spawnFallingBlock(loc, type, data);
}
public static void playFirebendingParticles(Location loc) {
loc.getWorld().playEffect(loc, Effect.MOBSPAWNER_FLAMES, 0, 15);

View file

@ -43,7 +43,6 @@ public class LavaSurge
private long time;
private int fallingBlocksCount = 0;
private boolean surgeStarted = false;
private boolean stopSurge = false;
private boolean fractureOpen;
private Random randy = new Random();
private Vector direction;
@ -51,7 +50,9 @@ public class LavaSurge
//private Location currentLocation; // Unused.
private List<FallingBlock> fblocks = new ArrayList<FallingBlock>();
private List<Block> fracture = new ArrayList<Block>();
private List<TempBlock> fracturetb = new ArrayList<TempBlock>();
private List<TempBlock> fracturetb = new ArrayList<TempBlock>();
private List<TempBlock> movingLava = new ArrayList<TempBlock>();
private ConcurrentHashMap<FallingBlock, TempBlock> lava = new ConcurrentHashMap<FallingBlock, TempBlock>();
private ListIterator<Block> li;
public LavaSurge(Player player)
@ -204,8 +205,17 @@ public class LavaSurge
return true;
return false;
}
public void removeLava()
{
for(TempBlock tb : lava.values())
{
tb.revertBlock();
}
movingLava.clear();
}
@SuppressWarnings("deprecation")
public void progress()
{
long curTime = System.currentTimeMillis();
@ -255,22 +265,15 @@ public class LavaSurge
}
if(surgeStarted)
{
if(stopSurge)
{
remove();
return;
}
{
if(fallingBlocksCount >= maxBlocks)
{
remove();
return;
}
if(curTime > time + (fallingBlockInterval * fallingBlocksCount))
{
FallingBlock fbs = player.getWorld().spawnFallingBlock(sourceBlock.getLocation().add(0, 1, 0), Material.STATIONARY_LAVA, (byte) 0);
FallingBlock fbs = Methods.spawnFallingBlock(sourceBlock.getLocation().add(0, 1, 0), 11, (byte) 0);
fblocks.add(fbs);
falling.add(fbs);
double x = randy.nextDouble()/5;
@ -286,7 +289,7 @@ public class LavaSurge
{
if(randy.nextBoolean() && b != sourceBlock)
{
FallingBlock fb = player.getWorld().spawnFallingBlock(b.getLocation().add(new Vector(0, 1, 0)), Material.STATIONARY_LAVA, (byte) 0);
FallingBlock fb = Methods.spawnFallingBlock(b.getLocation().add(new Vector(0, 1, 0)), 11, (byte) 0);
falling.add(fb);
fblocks.add(fb);
fb.setVelocity(direction.clone().add(new Vector(randy.nextDouble()/10, 0.1, randy.nextDouble()/10)).multiply(1.2));
@ -311,7 +314,6 @@ public class LavaSurge
}
}
}
}
}
}