Solved Placing Blocks on Fake Blocks

Discussion in 'Spigot Plugin Development' started by WarlordWeaponry, Feb 17, 2020.

  1. So I'm using ProtocolLib to spawn in fake blocks for players and I want the player to be able to place normal blocks on them, preferably with the BlockPlaceEvent firing off.
    I've managed to prevent the fake block from disappearing on right click, however the blocks it places are fake. I would be able to work with this, however I'm unable to get the material and data of the fake block placed, and the BlockPlaceEvent doesn't fire off either.

    Is there any way to get the material and data of a clientside block? Or is there a way to get the block an item will place?
  2. What are you trying to achieve with the fake blocks? this seems like an xy. You can't get fake blocks with normal methods, you have to store it on cache.
  3. Ah, my bad. Lemme explain my goal.

    Essentially, I'm trying to enable clientside building, where I would be able to build something that only I or other chosen players can see. I would then be able to save it and load it at will.
    The issue comes in when I'm placing fake blocks on other fake blocks, as those do not get saved. Placing fake blocks on real blocks however works as intended.
  4. This is mostly just a guess, but I imagine what's happening is that a BlockPlaceEvent isn't ever getting called because the player is trying to essentially place a block mid-air, which the server doesn't allow. If you listen to the packet detailed in you should be able to get what you want since that packet gets sent whenever a player attempts to place a block.
  5. Managed to solve it. I had to trick the server to think that they were placing a block on something, so what I did is I filled the clientside region with LONG_GRASS, then had the client hide it from the player.
    Everything seems to work now. Just some fine-tuning is left