Fix landing detection on cloud fall and improve clouds
This commit is contained in:
parent
b9a6fdee24
commit
7288c4f131
@ -23,7 +23,10 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
public class ChallengeCloudFall extends Challenge
|
||||
{
|
||||
private int _platformHeight = 85;
|
||||
private int _obstacleMaxHeight = 75;
|
||||
private int _obstacleMaxHeight = 70;
|
||||
|
||||
private Material _landingBlockType = Material.WOOL;
|
||||
private byte _landingBlockData = 5;
|
||||
|
||||
public ChallengeCloudFall(BawkBawkBattles host)
|
||||
{
|
||||
@ -42,7 +45,7 @@ public class ChallengeCloudFall extends Challenge
|
||||
{
|
||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||
int size = getArenaSize() - 2;
|
||||
|
||||
|
||||
for (Location location : circle(getCenter().add(0, _platformHeight, 0), size, 1, true, false, 0))
|
||||
{
|
||||
spawns.add(location.add(0.5, 1.1, 0.5));
|
||||
@ -84,11 +87,61 @@ public class ChallengeCloudFall extends Challenge
|
||||
if (!isPlayerValid(player))
|
||||
return;
|
||||
|
||||
if (Math.round(player.getLocation().getY()) == getCenter().getY() + 3)
|
||||
Block below = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
System.out.println(below.getY() + " == " + ((int) getCenter().getY() + 2));
|
||||
|
||||
if (below.getY() == (int) getCenter().getY() + 2)
|
||||
{
|
||||
event.SetCancelled("Fell on Wool");
|
||||
setCompleted(player);
|
||||
System.out.println("2");
|
||||
|
||||
if (below.isEmpty())
|
||||
{
|
||||
System.out.println("3");
|
||||
|
||||
Block[] nearby = {
|
||||
below.getRelative(BlockFace.NORTH),
|
||||
below.getRelative(BlockFace.EAST),
|
||||
below.getRelative(BlockFace.SOUTH),
|
||||
below.getRelative(BlockFace.WEST),
|
||||
below.getRelative(BlockFace.NORTH_EAST),
|
||||
below.getRelative(BlockFace.NORTH_WEST),
|
||||
below.getRelative(BlockFace.SOUTH_EAST),
|
||||
below.getRelative(BlockFace.SOUTH_WEST)
|
||||
};
|
||||
|
||||
for (Block near : nearby)
|
||||
{
|
||||
if (isLandingBlock(near))
|
||||
{
|
||||
setCompleted(player);
|
||||
event.SetCancelled("Fell on wool");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isLandingBlock(below))
|
||||
{
|
||||
System.out.println("4");
|
||||
|
||||
setCompleted(player);
|
||||
event.SetCancelled("Fell on wool");
|
||||
}
|
||||
else
|
||||
{
|
||||
event.AddMod("Fell into another block", 99999);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
event.AddMod("Fell into another block", 99999);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean isLandingBlock(Block block)
|
||||
{
|
||||
return block.getType() == _landingBlockType && block.getData() == _landingBlockData;
|
||||
}
|
||||
|
||||
private void createBottomMiddleMapPart()
|
||||
@ -113,7 +166,7 @@ public class ChallengeCloudFall extends Challenge
|
||||
createLandingWool(block, upperBlock);
|
||||
addBlock(upperBlock);
|
||||
}
|
||||
else if (y > 10 && y < 70 && UtilMath.r(200) == 1)
|
||||
else if (canCreateObstacle(block) && y > 10 && UtilMath.r(200) == 1)
|
||||
{
|
||||
addBlock(createObstacle(block));
|
||||
}
|
||||
@ -154,17 +207,57 @@ public class ChallengeCloudFall extends Challenge
|
||||
top.setData((byte) 5);
|
||||
}
|
||||
|
||||
private Block[] createObstacle(Block centerBlock)
|
||||
private boolean canCreateObstacle(Block center)
|
||||
{
|
||||
Block north = centerBlock.getRelative(BlockFace.NORTH);
|
||||
Block east = centerBlock.getRelative(BlockFace.EAST);
|
||||
Block west = centerBlock.getRelative(BlockFace.WEST);
|
||||
Block south = centerBlock.getRelative(BlockFace.SOUTH);
|
||||
Block[] area = {
|
||||
center.getRelative(BlockFace.DOWN),
|
||||
center.getRelative(BlockFace.NORTH),
|
||||
center.getRelative(BlockFace.EAST),
|
||||
center.getRelative(BlockFace.SOUTH),
|
||||
center.getRelative(BlockFace.WEST),
|
||||
center.getRelative(BlockFace.NORTH).getRelative(BlockFace.DOWN),
|
||||
center.getRelative(BlockFace.EAST).getRelative(BlockFace.DOWN),
|
||||
center.getRelative(BlockFace.SOUTH).getRelative(BlockFace.DOWN),
|
||||
center.getRelative(BlockFace.WEST).getRelative(BlockFace.DOWN)
|
||||
};
|
||||
|
||||
north.setType(Material.STAINED_CLAY);
|
||||
east.setType(Material.STAINED_CLAY);
|
||||
west.setType(Material.STAINED_CLAY);
|
||||
south.setType(Material.STAINED_CLAY);
|
||||
boolean available = true;
|
||||
|
||||
for (Block part : area)
|
||||
{
|
||||
if (!part.isEmpty())
|
||||
{
|
||||
available = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return available && center.isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private Block[] createObstacle(Block center)
|
||||
{
|
||||
Block north = center.getRelative(BlockFace.NORTH);
|
||||
Block east = center.getRelative(BlockFace.EAST);
|
||||
Block south = center.getRelative(BlockFace.SOUTH);
|
||||
Block west = center.getRelative(BlockFace.WEST);
|
||||
|
||||
byte data = 0;
|
||||
|
||||
if (Math.random() < 0.3)
|
||||
{
|
||||
data = 8;
|
||||
}
|
||||
|
||||
north.setType(Material.WOOL);
|
||||
north.setData(data);
|
||||
east.setType(Material.WOOL);
|
||||
east.setData(data);
|
||||
south.setType(Material.WOOL);
|
||||
south.setData(data);
|
||||
west.setType(Material.WOOL);
|
||||
west.setData(data);
|
||||
|
||||
return new Block[] { north, east, west, south };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user