Solved Summon ItemFrame not working

Discussion in 'Plugin Development' started by The_Spaceman, Feb 4, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    The_Spaceman

    I want to spawn an ItemFrame but when I do it gives me an IllegalArgumentException,
    code:
    Code:
    ItemFrame item = player.getWorld().spawn(player.getLocation(), ItemFrame.class);
    
    full error:
    Code:
    Caused by: java.lang.IllegalArgumentException: Cannot spawn hanging entity for org.bukkit.entity.ItemFrame at Location{world=CraftWorld{name=Islands},x=-143992.7819818626,y=69.90760396124287,z=-199999.91551359007,pitch=89.85001,yaw=136.64772} (no free face)
            at com.google.common.base.Preconditions.checkArgument(Preconditions.java:383) ~[server.jar:git-Spigot-da42974-8f47214]
            at org.bukkit.craftbukkit.v1_12_R1.CraftWorld.createEntity(CraftWorld.java:1152) ~[server.jar:git-Spigot-da42974-8f47214]
            at org.bukkit.craftbukkit.v1_12_R1.CraftWorld.spawn(CraftWorld.java:1218) ~[server.jar:git-Spigot-da42974-8f47214]
            at org.bukkit.craftbukkit.v1_12_R1.CraftWorld.spawn(CraftWorld.java:856) ~[server.jar:git-Spigot-da42974-8f47214]
            at com.Stranded.commands.War.onCommand(War.java:84) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[server.jar:git-Spigot-da42974-8f47214]
            ... 15 more
    
    the ItemFrame has all the space he needs...
    I have looked around at the internet but this method should work, but it doesn't for me. I dont know what I am doing wrong

    Code:
    Block bodyBlock = player.getTargetBlock(null, 10);
    ItemFrame i = player.getWorld().spawn(bodyBlock.getLocation().add(0, 0, 1), ItemFrame.class);
    i.setItem(new ItemStack(Material.STONE));
    i.setFacingDirection(BlockFace.SOUTH);
    HangingPlaceEvent hEvent = new HangingPlaceEvent(i, player, bodyBlock, BlockFace.NORTH);
    p.getServer().getPluginManager().callEvent(hEvent);
    
    you should chance the location but this works with thanks to SnowGears https://bukkit.org/threads/item-frame-always-spawn-facing-east.112101/''
     
    Last edited: Feb 4, 2018
Thread Status:
Not open for further replies.

Share This Page