mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-11-19 01:40:00 +00:00
Restore LocationUtil compatibility with 1_8_R1
This commit is contained in:
parent
58948b45b3
commit
2d376bc72f
1 changed files with 11 additions and 1 deletions
|
@ -195,8 +195,18 @@ public class LocationUtil {
|
|||
VOLUME = pos.toArray(new Vector3D[0]);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Location getTarget(final LivingEntity entity) throws Exception {
|
||||
final Block block = entity.getTargetBlock(TRANSPARENT_MATERIALS, 300);
|
||||
Block block;
|
||||
try {
|
||||
block = entity.getTargetBlock(TRANSPARENT_MATERIALS, 300);
|
||||
} catch (NoSuchMethodError e) {
|
||||
HashSet<Byte> legacyTransparent = new HashSet<>(); // Bukkit API prevents declaring as Set<Byte>
|
||||
for (Material m : TRANSPARENT_MATERIALS) {
|
||||
legacyTransparent.add((byte) m.getId());
|
||||
}
|
||||
block = entity.getTargetBlock(legacyTransparent, 300);
|
||||
}
|
||||
if (block == null) {
|
||||
throw new Exception("Not targeting a block");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue