[NMS] Returning a custom PacketPlayOutBlockChange to its original block

Discussion in 'Plugin Development' started by tissin, Nov 5, 2019.

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

    tissin

    Hi there,
    I'm working on a plugin that uses PacketPlayOutBlockChange to change a player's surrounding blocks to rainbow wool colors and am not sure how to change them back to the original block. I'm assuming there's some packet I can send to refresh the blocks/chunk?

    Code:
                      
    PacketPlayOutBlockChange packet =
                                new PacketPlayOutBlockChange(nmsWorld, new BlockPosition(x, y, z));
    if (new Location(loc.getWorld(), x, y, z).getBlock().getType() != Material.AIR) {
        Block b = ((CraftBlockData) Bukkit.createBlockData(getRandomWool())).getState().getBlock();
        packet.block = b.getBlockData();
        ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
    }
    
     
Thread Status:
Not open for further replies.

Share This Page