Skip to content

Commit bd35504

Browse files
committed
Add launch arguments and update readme
- Add building and running instructions to readme. - Allow username and server to be configured using launch arguments. - Switch to using blocks-1.19.3.json instead of blocks.json so it doesn't try to load the wrong blocks file in the future. - Don't load vulkan debug extension in release mode.
1 parent e141c8d commit bd35504

File tree

9 files changed

+237
-37
lines changed

9 files changed

+237
-37
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ bench_results
2121
/out/build/x64-Debug cxx-17
2222
/extras/bazel_usage_example/bazel-*
2323
/clang
24-
blocks.json
24+
blocks*.json
2525
/x64
2626
*.spv
2727
*.jar

README.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,46 @@ It uses the original assets from a user-provided Minecraft jar. Only basic block
88
### Screenshots
99
![Polymer Image](https://i.imgur.com/rAfkvtd.png)
1010

11+
### Running
12+
Only runs on Windows currently.
13+
14+
- Requires `1.19.3.jar` from your Minecraft installation to be in the working directory. You can find this in `%appdata%/.minecraft/versions/1.19.3/`. This is used to load the textures and block models.
15+
- Requires `blocks-1.19.3.json` that is generated from running Minecraft with a [certain flag](https://wiki.vg/Data_Generators#Generators) or from the [polymer release page](https://github.com/atxi/Polymer/releases).
16+
- Requires compiled shaders. Get them from the release page or read the shader section below if manually building.
17+
18+
Running the exe will connect to localhost with the username 'polymer'. The server must be configured to be in offline mode.
19+
20+
You can specify the username and server ip by command line.
21+
`polymer.exe -u username -s 127.0.0.1:25565`
22+
23+
Currently only a spectator camera is implemented for flying around and rendering the world. By default, you will be in the survival gamemode on the server. If you want chunks to load as you move, you need to put yourself in spectator gamemode. You can do this in the server terminal or with another client connected.
24+
1125
### Building
1226
Currently only compiles on Windows, but other platforms are planned.
1327

14-
- C++ compiler (tested with MSVC and Clang)
15-
- CMake
16-
- Vulkan SDK
28+
#### Requirements
29+
- C++ compiler (tested with MSVC 2022 and Clang)
30+
- [CMake](https://cmake.org/)
31+
- [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/)
32+
33+
#### CMake Instructions
34+
##### GUI
35+
- Open CMake GUI.
36+
- Put in path to source directory.
37+
- Choose a directory where the build will go.
38+
- Press Configure.
39+
- Select the generator to use. Probably `Visual Studio 17 2022` on Windows.
40+
- Press Finish.
41+
- Press Generate.
42+
##### Terminal
43+
- Create 'build' sub-directory and open terminal in it.
44+
- `cmake .. -G "Visual Studio 17 2022"`
45+
46+
#### MSVC
47+
- Browse to the build folder created from CMake.
48+
- Open solution.
49+
- Set to Release and x64 in the Standard Toolbar.
50+
- Build or run.
51+
52+
#### Shaders
53+
The shaders must be compiled with glslc.exe that comes with the vulkan sdk. The `compile_shaders.bat` file will compile them if `%VULKAN_SDK%` is properly set in the environment variables.

polymer/asset/block_assets.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@ static u32 GetHighestStateId(json_object_s* root) {
533533

534534
bool AssetParser::ParseBlocks(MemoryArena* perm_arena, const char* blocks_filename) {
535535
FILE* f = fopen(blocks_filename, "r");
536+
537+
if (!f) {
538+
return false;
539+
}
540+
536541
fseek(f, 0, SEEK_END);
537542
long file_size = ftell(f);
538543
fseek(f, 0, SEEK_SET);

polymer/connection.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,18 @@ void Connection::SetBlocking(bool blocking) {
125125
#endif
126126
}
127127

128-
void Connection::SendHandshake(u32 version, const char* address, u16 port, ProtocolState state_request) {
128+
void Connection::SendHandshake(u32 version, const String& address, u16 port, ProtocolState state_request) {
129129
RingBuffer& wb = write_buffer;
130-
131-
String sstr;
132-
sstr.data = (char*)address;
133-
sstr.size = strlen(address);
134-
135130
u32 pid = 0;
136131

137-
size_t size = GetVarIntSize(pid) + GetVarIntSize(version) + GetVarIntSize(sstr.size) + sstr.size + sizeof(u16) +
132+
size_t size = GetVarIntSize(pid) + GetVarIntSize(version) + GetVarIntSize(address.size) + address.size + sizeof(u16) +
138133
GetVarIntSize((u64)state_request);
139134

140135
wb.WriteVarInt(size);
141136
wb.WriteVarInt(pid);
142137

143138
wb.WriteVarInt(version);
144-
wb.WriteString(sstr);
139+
wb.WriteString(address);
145140
wb.WriteU16(port);
146141
wb.WriteVarInt((u64)state_request);
147142

@@ -158,19 +153,15 @@ void Connection::SendPingRequest() {
158153
wb.WriteVarInt(pid);
159154
}
160155

161-
void Connection::SendLoginStart(const char* username) {
156+
void Connection::SendLoginStart(const String& username) {
162157
RingBuffer& wb = write_buffer;
163158

164-
String sstr;
165-
sstr.data = (char*)username;
166-
sstr.size = strlen(username);
167-
168159
u32 pid = 0;
169-
size_t size = GetVarIntSize(pid) + GetVarIntSize(sstr.size) + sstr.size + 1;
160+
size_t size = GetVarIntSize(pid) + GetVarIntSize(username.size) + username.size + 1;
170161

171162
wb.WriteVarInt(size);
172163
wb.WriteVarInt(pid);
173-
wb.WriteString(sstr);
164+
wb.WriteString(username);
174165
wb.WriteU8(0); // HasPlayerUUID
175166
}
176167

polymer/connection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ struct Connection {
3939

4040
TickResult Tick();
4141

42-
void SendHandshake(u32 version, const char* address, u16 port, ProtocolState state_request);
42+
void SendHandshake(u32 version, const String& address, u16 port, ProtocolState state_request);
4343
void SendPingRequest();
44-
void SendLoginStart(const char* username);
44+
void SendLoginStart(const String& username);
4545
void SendKeepAlive(u64 id);
4646
void SendTeleportConfirm(u64 id);
4747
void SendPlayerPositionAndRotation(const Vector3f& position, float yaw, float pitch, bool on_ground);

polymer/gamestate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct PlayerManager {
4242
size_t player_count = 0;
4343

4444
Player* client_player = nullptr;
45-
char client_name[16];
45+
char client_name[17];
4646

4747
void SetClientPlayer(Player* player) {
4848
client_player = player;

0 commit comments

Comments
 (0)