Skip to content

Commit 09c8189

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents aa15a53 + e27e762 commit 09c8189

File tree

1 file changed

+62
-89
lines changed

1 file changed

+62
-89
lines changed

README.md

Lines changed: 62 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,95 @@
1-
# Sniffer
1+
> [!NOTE]
2+
> This project is now being developed by Bookshelf team and has been renamed to Sniffer. Bookshelf has added more features to Sniffer and developed a VSCode plugin! So head over to their repository to stay updated~
3+
>
4+
> It's worth mentioning that the original author is still actively contributing to Sniffer's development~
5+
>
6+
> Sniffer: <https://github.com/mcbookshelf/sniffer>
27
3-
## Overview
48

5-
Sniffer is a debug adapter for Minecraft datapacks that allows you to debug your `.mcfunction` files directly from Visual Studio Code. It provides features like breakpoints, step execution, and variable inspection to make datapack development easier and more efficient.
9+
# Datapack Breakpoint
610

7-
## Features
11+
English | [简体中文](README_zh.md)
812

9-
- Set breakpoints in `.mcfunction` files
10-
- Connect to a running Minecraft instance
11-
- Inspect game state during debugging
12-
- Step through command execution
13-
- Path mapping between Minecraft and local files
13+
## Introduce
1414

15-
## Requirements
15+
This is a fabric mod for Minecraft 1.21, which allows you to set breakpoints in the game and "freeze" the game when
16+
the breakpoint is reached.
1617

17-
- Minecraft with Fabric Loader
18-
- Visual Studio Code
18+
## Usage
1919

20+
* Set a breakpoint
2021

21-
<!-- ## Installation
22+
In datapack, you can insert `#breakpoint` into .mcfunction file to set a breakpoint. For example:
2223

23-
### Minecraft Mod Installation
24+
```mcfunction
25+
#test:test
2426
25-
1. Install [Fabric Loader](https://fabricmc.net/use/) for your Minecraft version
26-
2. Download the Sniffer mod JAR from the [releases page](https://github.com/mcbookshelf/sniffer/releases)
27-
3. Place the JAR file in your Minecraft `mods` folder
28-
4. Launch Minecraft with Fabric
29-
30-
### VSCode Extension Installation
31-
32-
1. Open Visual Studio Code
33-
2. Go to the Extensions view (Ctrl+Shift+X)
34-
3. Search for "Sniffer"
35-
4. Click Install -->
36-
37-
## Mod Configuration
38-
The mod can be configured through the in-game configuration screen, accessible via Mod Menu.
39-
You can also configure the mod in the `config/sniffer.json` file.
40-
The following options are available:
41-
42-
### Debug Server Settings
43-
- **Server Port**: The port number for the debug server (default: 25599)
44-
- **Server path**: The path to the debug server (default: `/dap`)
45-
46-
## Connecting to Minecraft
47-
48-
1. Open your datapack project in VSCode
49-
2. Create a `.vscode/launch.json` file with the following configuration:
50-
51-
```json
52-
{
53-
"version": "0.2.0",
54-
"configurations": [
55-
{
56-
"type": "sniffer",
57-
"request": "attach",
58-
"name": "Connect to Minecraft",
59-
"address": "ws://localhost:25599/dap"
60-
}
61-
]
62-
}
27+
say 1
28+
say 2
29+
#breakpoint
30+
say 3
31+
say 4
6332
```
6433

65-
3. Start Minecraft with the Sniffer mod installed
66-
4. In VSCode, press F5 or click the "Run and Debug" button
67-
5. Select "Connect to Minecraft" from the dropdown menu
34+
In this case, after the game executes `say 2`, the game will be "frozen" because it meets the breakpoint.
6835

69-
You can now place breakpoints in your `.mcfunction` files and execute it from the game to step through the code.
36+
When the game is "frozen", you can still move around, do whatever you want, just like execute the command `tick freeze`.
37+
So you can check the game state, or do some debugging.
7038

71-
## Usage in Minecraft
39+
* Step
7240

73-
The debugger can be controlled directly from Minecraft using the following commands:
41+
When the game is "frozen", you can use the command `/breakpoint step` to execute the next command. In above example,
42+
after the game meets the breakpoint, you can use `/breakpoint step` to execute `say 3`, and then use `/breakpoint step`
43+
to execute `say 4`. When all commands are executed, the game will be unfrozen and continue running.
7444

75-
- `/breakpoint continue`: Resume execution after hitting a breakpoint
76-
- `/breakpoint step`: Execute the next command and pause
77-
- `/breakpoint step_over`: Skip to the next command in the current function
78-
- `/breakpoint step_out`: Continue execution until the current function returns
45+
* Continue
7946

80-
All commands require operator permissions (level 2) to use.
47+
When the game is "frozen", you can use the command `/breakpoint move` to unfreeze the game and continue running.
8148

82-
When execution is paused at a breakpoint, the gametick will be freezed.
49+
* Get Macro Arguments
8350

51+
By using `/breakpoint get <key>`, you can get the value of the macro argument if the game is executing a macro function.
52+
For example:
8453

54+
```mcfunction
55+
#test:test_macro
8556
86-
## Development
87-
88-
### Project Structure
57+
say start
58+
#breakpoint
59+
$say $(msg)
60+
say end
61+
```
8962

90-
- `src/main`: Main mod code for Minecraft
91-
- `src/client`: Client-side mod code
92-
- `vscode`: VSCode extension source code
63+
After executing `function test:test_macro {"msg":"test"}`, we passed the value `test` to the macro argument `msg` and
64+
then the game will pause before `$say $(msg)`. At this time, you can use `/breakpoint get msg` to get the value `test`.
9365

94-
### Building the Project
66+
* Get Function Stack
9567

96-
To build the Minecraft mod:
68+
By using `/breakpoint stack`, you can get the function stack of the current game. For example, if we have following two
69+
functions:
9770

98-
```bash
99-
./gradlew build
100-
```
71+
```mcfunction
72+
#test:test1
10173
102-
To build the VSCode extension:
74+
say 1
75+
function test:test2
76+
say 2
10377
104-
```bash
105-
cd vscode
106-
npm install
107-
npm run build
78+
#test: test2
79+
say A
80+
#breakpoint
81+
say B
10882
```
10983

110-
## License
84+
When the game pauses at the breakpoint, you can use `/breakpoint stack` and the function stack will be printed in the
85+
chat screen:
11186

112-
This project is licensed under the MPL-2.0 License - see the [LICENSE](LICENSE) file for details.
113-
114-
## Contributing
87+
```
88+
test:test2
89+
test:test
11590
116-
Contributions are welcome! Please feel free to submit a Pull Request.
91+
```
11792

118-
## Acknowledgements
93+
* Run command in current context
11994

120-
- [Fabric](https://fabricmc.net/) - Mod loader for Minecraft
121-
- [VSCode Debug Adapter](https://code.visualstudio.com/api/extension-guides/debugger-extension) - VSCode debugging API
122-
- [Datapack Debugger](https://github.com/Alumopper/Datapack-Debugger/) by [Alumopper](https://github.com/Alumopper) - Original implementation of the debugger, without the DAP layer
95+
By using `/breakpoint run <command>`, you can run any command in the current context, just like `execute ... run ...`.

0 commit comments

Comments
 (0)