-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
None
-
Environment:
macOS 10.15.2
Java 1.8.0_221
-
git-Spigot-492a779-d208733
-
Yes
The VehicleBlockCollisionEvent returns the block in the opposite direction to the collided block
Code used to test:
List<BlockFace> faces = Arrays.asList(BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH, BlockFace.EAST); @EventHandler(ignoreCancelled = true) public void onVehicleBlockCollision(VehicleBlockCollisionEvent event) { if (event.getVehicle() instanceof Minecart) { Block block = event.getBlock(); // block in opposite direction of collision Bukkit.getLogger().info("event block: " + block.getType().toString()); Block minecartBlock = event.getVehicle().getLocation().getBlock(); for (BlockFace face : faces) { Block bb = minecartBlock.getRelative(face); Bukkit.getLogger().info(face.toString() + ": " + bb.getType().toString()); } } }
Typical output of the above is:
[23:26:28 INFO]: event block: RAIL [23:26:28 INFO]: NORTH: AIR [23:26:28 INFO]: WEST: IRON_DOOR [23:26:28 INFO]: SOUTH: AIR [23:26:28 INFO]: EAST: RAIL