Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by harveycat1, Jun 1, 2017.
Whats best method for checking the block a player is looking at
Some thing like?
Player player = (Player) sender;
Block block = player.getTargetBlock(null, 100);
Location bl = block.getLocation();
Player#getTargetBlock does the trick
Hey, the easiest way is to use the getTargetBlock method in the LivingEntity class.
I think the method is easy to understand and your problem should be solved
As you can see in the bukkit documentation, 100 ist the maximum distance to scan for blocks.
Block block = p.getTargetBlock(null, 100);
is underlinder red? with "The method getTargetBlock(HashSet<Byte>, int) is ambiguous for the type Player"
Gotta cast the null to what the getTargetBlock function wants
which is? sorry never used block methods like dis and just says its ambiguous for type player
Cast null to Set<Material> so the compiler knows which of the getTargetBlock methods you are trying to call.
The HashSet method was removed in the 1.12 API, so updating tomorrow won't give you this compilation issue