Skip to content

Commit

Permalink
fix: error when right clicking air while holding block in <1.13
Browse files Browse the repository at this point in the history
Closes #754
  • Loading branch information
kernitus committed Oct 28, 2024
1 parent 07106e6 commit cbc0c4b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -82,8 +83,11 @@ public void onRightClick(PlayerInteractEvent e) {
// TODO right-clicking on a mob also only fires one hand
if (action == Action.RIGHT_CLICK_BLOCK && e.getHand() == EquipmentSlot.HAND) return;
if (e.isBlockInHand()){
if(lastInteractedBlocks != null)
lastInteractedBlocks.put(e.getClickedBlock().getLocation(), player.getUniqueId());
if(lastInteractedBlocks != null) {
final Block clickedBlock = e.getClickedBlock();
if(clickedBlock != null)
lastInteractedBlocks.put(clickedBlock.getLocation(), player.getUniqueId());
}
return; // Handle failed block place in separate listener
}

Expand Down

0 comments on commit cbc0c4b

Please sign in to comment.