snowfight finish

This commit is contained in:
Cheese 2015-12-07 17:56:35 +11:00
parent 1e441ac017
commit d75d7a2c8f

View File

@ -72,7 +72,7 @@ import org.bukkit.util.Vector;
public class SnowFight extends TeamGame public class SnowFight extends TeamGame
{ {
private long _meteorTime = 10000; private long _meteorTime = 240000;
private boolean _meteors = false; private boolean _meteors = false;
private HashSet<FallingBlock> _meteorSet = new HashSet<FallingBlock>(); private HashSet<FallingBlock> _meteorSet = new HashSet<FallingBlock>();
@ -104,20 +104,20 @@ public class SnowFight extends TeamGame
this.TeamArmor = true; this.TeamArmor = true;
this.TeamArmorHotbar = true; this.TeamArmorHotbar = true;
this.WorldWeatherEnabled = true; // this.WorldWeatherEnabled = true;
this.WorldTimeSet = 4000; // this.WorldTimeSet = 4000;
} }
@EventHandler // @EventHandler
public void weather(UpdateEvent event) // public void weather(UpdateEvent event)
{ // {
if (event.getType() != UpdateType.SEC) // if (event.getType() != UpdateType.SEC)
return; // return;
//
WorldData.World.setStorm(true); // WorldData.World.setStorm(true);
WorldData.World.setThundering(false); // WorldData.World.setThundering(false);
WorldData.World.setWeatherDuration(10); // WorldData.World.setWeatherDuration(12);
} // }
@EventHandler @EventHandler
public void battleAnnounce(GameStateChangeEvent event) public void battleAnnounce(GameStateChangeEvent event)
@ -243,7 +243,36 @@ public class SnowFight extends TeamGame
private boolean isOnIce(Player player) private boolean isOnIce(Player player)
{ {
return player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.PACKED_ICE; //Side Standing
double xMod = player.getLocation().getX() % 1;
if (player.getLocation().getX() < 0)
xMod += 1;
double zMod = player.getLocation().getZ() % 1;
if (player.getLocation().getZ() < 0)
zMod += 1;
int xMin = 0;
int xMax = 0;
int zMin = 0;
int zMax = 0;
if (xMod < 0.3) xMin = -1;
if (xMod > 0.7) xMax = 1;
if (zMod < 0.3) zMin = -1;
if (zMod > 0.7) zMax = 1;
for (int x=xMin ; x<=xMax ; x++)
{
for (int z=zMin ; z<=zMax ; z++)
{
if (player.getLocation().add(x, -0.5, z).getBlock().getType() == Material.PACKED_ICE)
return true;
}
}
return false;
} }
private Location getMeteorTargetLocation() private Location getMeteorTargetLocation()
@ -362,7 +391,7 @@ public class SnowFight extends TeamGame
float multiplier = 1 + Math.min(3f, timePassed / 60f); float multiplier = 1 + Math.min(3f, timePassed / 60f);
float size = 2 + multiplier; float size = 1.5f + multiplier;
if (projectile.hasMetadata("Meteor")) if (projectile.hasMetadata("Meteor"))
{ {
@ -391,9 +420,12 @@ public class SnowFight extends TeamGame
int i = 5; int i = 5;
while (block.getY() > 0 && i>0) while (block.getY() > 0 && i>0)
{ {
if (block.getType() == Material.LADDER) if (block.getType() == Material.LADDER ||
block.getType() == Material.STAINED_GLASS ||
block.getType() == Material.STAINED_GLASS_PANE)
block.breakNaturally(); block.breakNaturally();
//Has air above it //Has air above it
if (UtilBlock.solid(block) && UtilBlock.isVisible(block)) if (UtilBlock.solid(block) && UtilBlock.isVisible(block))
block.setType(Material.PACKED_ICE); block.setType(Material.PACKED_ICE);
@ -423,7 +455,7 @@ public class SnowFight extends TeamGame
//XXX DO BETTER CHECK, hanging off block, ladders, etc. //XXX DO BETTER CHECK, hanging off block, ladders, etc.
if(isOnIce(player)) if(isOnIce(player))
{ {
Bukkit.getPluginManager().callEvent(new CustomDamageEvent(player, null, null, null, DamageCause.CUSTOM, 0.5, false, true, true, "Ice", "Ice", false)); Bukkit.getPluginManager().callEvent(new CustomDamageEvent(player, null, null, null, DamageCause.CUSTOM, 1, false, true, true, "Ice", "Ice", false));
} }
} }
} }