1.15.2 How do I set items on item frame in a specific location?

Discussion in 'Spigot Plugin Development' started by Akiraff, Jan 30, 2020.

  1. I've been trying to get location of ItemFrame, however I made very little progress with the plugin. I have a code below, which whenever I place an ItemFrame on the wall, it will automatically place with a diamond on the item frame.
    Code (Java):
    @EventHandler
    public void hangingPlace(HangingPlaceEvent event) {
      Hanging hanging = event.getEntity();
      if (hanging instanceof ItemFrame) {
        ItemFrame itemFrame = (ItemFrame) hanging;
        itemFrame.setItem(new ItemStack(Material.DIAMOND);
    }
    However, I want to place items on the item frames that are already on the wall. I got a feeling that I need to get the player position and use PlayerInteractEntityEvent. However, I reached in a dead end.