How to force player to place a block

Discussion in 'Spigot Plugin Development' started by SwezedCode, Jul 12, 2018.

Thread Status:
Not open for further replies.
  1. Hello guys,
    I've been trying to get something working for a while which makes the player place a block in his hand on the ground. I tried to search for at least 20 minutes now and no solutions has been found.

    Just to clarify what I mean is not making the server spawn/create a block in front of the player, more likely making the player place the block itself.

    Thanks,
    Swezed.
     
  2. I don't think that you can do that with spigot, because you cant really controll the client.
     
  3. It's possible that you could do through packets, maybe, or something, but as @Maxdola said it's most likely not possible.
     
    • Agree Agree x 2
  4. 2008Choco

    Junior Mod

    Take a look at the net.minecraft.server.ItemStack#placeItem(EntityHuman, World, BlockPosition, EnumHand, EnumDirection, float, float, float) method. Keep in mind, this is the net.minecraft.server ItemStack class, not Bukkit's ItemStack class. You will have to use CraftItemStack.asNMSCopy(ItemStack) to copy the item you want the player to place and invoke that method. I'm sure you can infer what the parameters are, although the last three floats, I'm actually unsure of.
     
    • Winner Winner x 2
  5. If I were to guess they probably are pixel coordinates to determine if a door gets placed on the near side or far side and on which half a slab gets placed for example
     
    • Like Like x 1
    • Agree Agree x 1
    • Informative Informative x 1
  6. 2008Choco

    Junior Mod

    That’s what they are, yes. Even the BlockPlaceEvent has those. I should have known. Thanks :)
     
  7. Okay thanks for the help everyone!
     
Thread Status:
Not open for further replies.

Share This Page