Solved Unclickable FakeBlocks

Discussion in 'Spigot Plugin Development' started by Merlin1009, May 13, 2016.

  1. I tried to make spawnlocations for each team and protect it with fake barrierblocks so only a player of your team can enter.
    Code (Text):
        public static void setWall(Player p, ArrayList<Block> blocks){
            for(Block b : blocks){
                p.sendBlockChange(b.getLocation(), Material.BARRIER, (byte)0);
    It works but if a player clicks the fakeblock the block disappears!
    Does anyone has a solution for it? (I would like to work with fakeblocks)
    #1 Merlin1009, May 13, 2016
    Last edited: May 15, 2016
  2. MiniDigger


    don't think that thats possible. maybe try to resend that block on interact.
  3. joehot200


    You will probably need to constantly re-send the data.
  4. Cancel the PlayerInteractEvent on this player
  5. MiniDigger


    will not work. if you click the client notices that there is no block, canceling interact will not change that.
  6. Yeah i did that in the PlayerInteractEvent but rightclick air doesn't get triggert... Only Leftclick air
    Code (Text):
    public void OnClick(PlayerInteractEvent e){
             Player p = e.getPlayer();
             if(e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR|| e.getAction() == Action.RIGHT_CLICK_AIR){
                 Manager.setWall(p, main.WallBlue);
                 }else if(main.TeamBlue.contains(p)){
                     Manager.setWall(p, main.WallRed);

    and if i do it on PlayerMove you can glitch trough it if you hold rightclick
  7. So i have no real idea anymore...
  8. Try spawning an armor stand where the fake block will be and if a player interacts with the armor stand resend the fake block.
  9. You have to remember that with fake blocks the server has no idea they are there. You need to take over more than just a block change to convince the client that there are indeed blocks in places they are not. You mentioned that left click air is cancellable because the server thinks that there is simply air blocks there. With your technique you also need to make sure that you are cancelling move events into your fake blocks because the server (and other plugins) are not going to try to stop clients from walking through with a hacked client because from their perspective the player is not cheating. You can't leave it up to the client to prevent walking through the wall. You might be better off just putting real barrier blocks there and teleporting the player inside when the run into the outside :/
  10. You could also spam the blockchange every 1 or 2 ticks to the players.
  11. That is less efficient and will lag. But he can do that if he is lazy.
  12. That is the only way and how will this lag if move packets are sent every tick too? It's not the most efficient, but it works. And internet lag is not a problem in 2016. Also this doesn't take much CPU at all either
  13. Unless he sends every tick less then 10 blocks he won't notice a difference, but from the code above it seems like he is planning on having multiple matches.

    Move packets must be sent, and are made in the most efficient way Mojang could do, it's unavoidable unlike this problem.

    Internet lag is always a problem regardless to the year, it depends on the location.
    It may even cause FPS Lags, I tested myself creating a two layered hollowed-sphere of fake blocks around me, just for me and my FPS was affected (I have GeForce GTX 970).

    And again it'll take CPU if he uses that in big amounts. Unless he has a godly host (and let's not even talk about the price) this method will indeed affect him.
  14. MiniDigger


    how should invisible blocks cause fps drops? Are you sure that this is directly related to the fake blocks?
  15. Why use blocks at all? Listen for PlayerMoveEvent, if a player is near one of those points, and they're not allowed to go there, bounce them backwards.
    • Agree Agree x 2
    • Optimistic Optimistic x 1
  16. I'll be honest, I got no clue why, but for me it FPS lags when I constantly respawn them per tick.
  17. That's an option aswell.
  18. I solved it!! Soo happy i used the PacketListenerAPI !
    Here is my code:
    Code (Text):
    PacketListenerAPI.addPacketHandler(new PacketHandler() {

                public void onSend(SentPacket packet) {
                    if (packet.getPacket() instanceof PacketPlayOutBlockChange) {
                        PacketPlayOutBlockChange p2 = (PacketPlayOutBlockChange) packet.getPacket();
                        String block = p2.block.getBlock().a().toString();
                        int pos = block.indexOf(".");
                        String blockname = block.substring(pos+1);
  19. Packet and nms is alife <3