This commit is contained in:
Jérémy Carrat 2013-12-17 04:08:02 -08:00
commit 99f2ad14e4
2 changed files with 11 additions and 9 deletions

View File

@ -30,7 +30,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.6.4-R0.1-SNAPSHOT</version>
<version>1.7.2-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.dynmap</groupId>

View File

@ -5,6 +5,7 @@ import java.util.LinkedHashSet;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@ -291,26 +292,27 @@ public class BorderData
}
//these material IDs are acceptable for places to teleport player; breathable blocks and water
public static final LinkedHashSet<Integer> safeOpenBlocks = new LinkedHashSet<Integer>(Arrays.asList(
new Integer[] {0, 6, 8, 9, 27, 28, 30, 31, 32, 37, 38, 39, 40, 50, 55, 59, 63, 64, 65, 66, 68, 69, 70, 71, 72, 75, 76, 77, 78, 83, 90, 93, 94, 96, 104, 105, 106, 115, 131, 132, 141, 142, 149, 150, 157, 171}
public static final LinkedHashSet<Material> safeOpenBlocks = new LinkedHashSet<Material>(Arrays.asList(
new Material[] {Material.AIR, Material.SAPLING, Material.WATER, Material.STATIONARY_WATER, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.WEB, Material.LONG_GRASS, Material.DEAD_BUSH, Material.YELLOW_FLOWER, Material.RED_ROSE, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.TORCH, Material.REDSTONE_WIRE, Material.CROPS, Material.SIGN_POST, Material.WOODEN_DOOR, Material.LADDER, Material.RAILS, Material.WALL_SIGN, Material.LEVER, Material.STONE_PLATE, Material.IRON_DOOR_BLOCK, Material.WOOD_PLATE, Material.REDSTONE_TORCH_OFF, Material.REDSTONE_TORCH_ON, Material.STONE_BUTTON, Material.SNOW, Material.SUGAR_CANE_BLOCK, Material.PORTAL, Material.DIODE_BLOCK_OFF, Material.DIODE_BLOCK_ON, Material.TRAP_DOOR, Material.PUMPKIN_STEM, Material.MELON_STEM, Material.VINE, Material.NETHER_WARTS, Material.TRIPWIRE_HOOK, Material.TRIPWIRE, Material.CARROT, Material.POTATO, Material.REDSTONE_COMPARATOR_OFF, Material.REDSTONE_COMPARATOR_ON, Material.ACTIVATOR_RAIL, Material.CARPET}
));
//these material IDs are ones we don't want to drop the player onto, like cactus or lava or fire or activated Ender portal
public static final LinkedHashSet<Integer> painfulBlocks = new LinkedHashSet<Integer>(Arrays.asList(
new Integer[] {10, 11, 51, 81, 119}
public static final LinkedHashSet<Material> painfulBlocks = new LinkedHashSet<Material>(Arrays.asList(
new Material[] {Material.LAVA, Material.STATIONARY_LAVA, Material.FIRE, Material.CACTUS, Material.ENDER_PORTAL}
));
// check if a particular spot consists of 2 breathable blocks over something relatively solid
private boolean isSafeSpot(World world, int X, int Y, int Z, boolean flying)
{
boolean safe = safeOpenBlocks.contains((Integer)world.getBlockTypeIdAt(X, Y, Z)) // target block open and safe
&& safeOpenBlocks.contains((Integer)world.getBlockTypeIdAt(X, Y + 1, Z)); // above target block open and safe
boolean safe = safeOpenBlocks.contains((Material)world.getBlockAt(X, Y, Z).getType()) // target block open and safe
&& safeOpenBlocks.contains((Material)world.getBlockAt(X, Y + 1, Z).getType()); // above target block open and safe
if (!safe || flying)
return safe;
Integer below = (Integer)world.getBlockTypeIdAt(X, Y - 1, Z);
Material below = (Material)world.getBlockAt(X, Y - 1, Z).getType();
return (safe
&& (!safeOpenBlocks.contains(below) || below == 8 || below == 9) // below target block not open/breathable (so presumably solid), or is water
&& (!safeOpenBlocks.contains(below) || below.equals(Material.WATER) || below.equals(Material.STATIONARY_WATER)) // below target block not open/breathable (so presumably solid), or is water
&& !painfulBlocks.contains(below) // below target block not painful
);
}