mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-08 03:50:06 +01:00
Trapdoors should be treated as half blocks, not transparent blocks.
This commit is contained in:
parent
a7b62c65b8
commit
7276bcccab
@ -234,59 +234,58 @@ public class Util
|
|||||||
return c.getTimeInMillis();
|
return c.getTimeInMillis();
|
||||||
}
|
}
|
||||||
// The player can stand inside these materials
|
// The player can stand inside these materials
|
||||||
private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>();
|
private static final Set<Integer> UNSAFE_MATERIALS = new HashSet<Integer>();
|
||||||
private static final HashSet<Byte> AIR_MATERIALS_TARGET = new HashSet<Byte>();
|
private static final HashSet<Byte> TRANSPARENT_MATERIALS = new HashSet<Byte>();
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
AIR_MATERIALS.add(Material.AIR.getId());
|
UNSAFE_MATERIALS.add(Material.AIR.getId());
|
||||||
AIR_MATERIALS.add(Material.SAPLING.getId());
|
UNSAFE_MATERIALS.add(Material.SAPLING.getId());
|
||||||
AIR_MATERIALS.add(Material.POWERED_RAIL.getId());
|
UNSAFE_MATERIALS.add(Material.POWERED_RAIL.getId());
|
||||||
AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId());
|
UNSAFE_MATERIALS.add(Material.DETECTOR_RAIL.getId());
|
||||||
AIR_MATERIALS.add(Material.LONG_GRASS.getId());
|
UNSAFE_MATERIALS.add(Material.LONG_GRASS.getId());
|
||||||
AIR_MATERIALS.add(Material.DEAD_BUSH.getId());
|
UNSAFE_MATERIALS.add(Material.DEAD_BUSH.getId());
|
||||||
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
|
UNSAFE_MATERIALS.add(Material.YELLOW_FLOWER.getId());
|
||||||
AIR_MATERIALS.add(Material.RED_ROSE.getId());
|
UNSAFE_MATERIALS.add(Material.RED_ROSE.getId());
|
||||||
AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
|
UNSAFE_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
|
||||||
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
|
UNSAFE_MATERIALS.add(Material.RED_MUSHROOM.getId());
|
||||||
AIR_MATERIALS.add(Material.TORCH.getId());
|
UNSAFE_MATERIALS.add(Material.TORCH.getId());
|
||||||
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
|
UNSAFE_MATERIALS.add(Material.REDSTONE_WIRE.getId());
|
||||||
AIR_MATERIALS.add(Material.SEEDS.getId());
|
UNSAFE_MATERIALS.add(Material.SEEDS.getId());
|
||||||
AIR_MATERIALS.add(Material.SIGN_POST.getId());
|
UNSAFE_MATERIALS.add(Material.SIGN_POST.getId());
|
||||||
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
|
UNSAFE_MATERIALS.add(Material.WOODEN_DOOR.getId());
|
||||||
AIR_MATERIALS.add(Material.LADDER.getId());
|
UNSAFE_MATERIALS.add(Material.LADDER.getId());
|
||||||
AIR_MATERIALS.add(Material.RAILS.getId());
|
UNSAFE_MATERIALS.add(Material.RAILS.getId());
|
||||||
AIR_MATERIALS.add(Material.WALL_SIGN.getId());
|
UNSAFE_MATERIALS.add(Material.WALL_SIGN.getId());
|
||||||
AIR_MATERIALS.add(Material.LEVER.getId());
|
UNSAFE_MATERIALS.add(Material.LEVER.getId());
|
||||||
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
|
UNSAFE_MATERIALS.add(Material.STONE_PLATE.getId());
|
||||||
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
|
UNSAFE_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
|
||||||
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
|
UNSAFE_MATERIALS.add(Material.WOOD_PLATE.getId());
|
||||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
|
UNSAFE_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
|
||||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
|
UNSAFE_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
|
||||||
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
|
UNSAFE_MATERIALS.add(Material.STONE_BUTTON.getId());
|
||||||
AIR_MATERIALS.add(Material.SNOW.getId());
|
UNSAFE_MATERIALS.add(Material.SNOW.getId());
|
||||||
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
UNSAFE_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
||||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
UNSAFE_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
||||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
UNSAFE_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
||||||
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
|
UNSAFE_MATERIALS.add(Material.PUMPKIN_STEM.getId());
|
||||||
AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
|
UNSAFE_MATERIALS.add(Material.MELON_STEM.getId());
|
||||||
AIR_MATERIALS.add(Material.MELON_STEM.getId());
|
UNSAFE_MATERIALS.add(Material.VINE.getId());
|
||||||
AIR_MATERIALS.add(Material.VINE.getId());
|
UNSAFE_MATERIALS.add(Material.FENCE_GATE.getId());
|
||||||
AIR_MATERIALS.add(Material.FENCE_GATE.getId());
|
UNSAFE_MATERIALS.add(Material.WATER_LILY.getId());
|
||||||
AIR_MATERIALS.add(Material.WATER_LILY.getId());
|
UNSAFE_MATERIALS.add(Material.NETHER_WARTS.getId());
|
||||||
AIR_MATERIALS.add(Material.NETHER_WARTS.getId());
|
|
||||||
|
|
||||||
for (Integer integer : AIR_MATERIALS)
|
for (Integer integer : UNSAFE_MATERIALS)
|
||||||
{
|
{
|
||||||
AIR_MATERIALS_TARGET.add(integer.byteValue());
|
TRANSPARENT_MATERIALS.add(integer.byteValue());
|
||||||
}
|
}
|
||||||
AIR_MATERIALS_TARGET.add((byte)Material.WATER.getId());
|
TRANSPARENT_MATERIALS.add((byte)Material.WATER.getId());
|
||||||
AIR_MATERIALS_TARGET.add((byte)Material.STATIONARY_WATER.getId());
|
TRANSPARENT_MATERIALS.add((byte)Material.STATIONARY_WATER.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getTarget(final LivingEntity entity) throws Exception
|
public static Location getTarget(final LivingEntity entity) throws Exception
|
||||||
{
|
{
|
||||||
final Block block = entity.getTargetBlock(AIR_MATERIALS_TARGET, 300);
|
final Block block = entity.getTargetBlock(TRANSPARENT_MATERIALS, 300);
|
||||||
if (block == null)
|
if (block == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Not targeting a block");
|
throw new Exception("Not targeting a block");
|
||||||
@ -408,7 +407,7 @@ public class Util
|
|||||||
|
|
||||||
private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
|
private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
|
||||||
{
|
{
|
||||||
return AIR_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
|
return UNSAFE_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
|
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
|
||||||
@ -438,8 +437,8 @@ public class Util
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!AIR_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId()))
|
if ((!UNSAFE_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId()))
|
||||||
|| (!AIR_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId())))
|
|| (!UNSAFE_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId())))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user