Small Fix

This commit is contained in:
TheBrokenRail 2025-02-26 06:29:27 -05:00
parent d4e3e83b42
commit 140e2eef48
4 changed files with 23 additions and 23 deletions

View File

@ -84,8 +84,8 @@ static std::string get_blocks(CommandServer *server, const Vec3 &start, const Ve
int end_z = int(end.z); int end_z = int(end.z);
// Apply Offset // Apply Offset
server->pos_translator.from(start_x, start_y, start_z); server->pos_translator.from_int(start_x, start_y, start_z);
server->pos_translator.from(end_x, end_y, end_z); server->pos_translator.from_int(end_x, end_y, end_z);
// Swap If Needed // Swap If Needed
#define swap_if_needed(axis) \ #define swap_if_needed(axis) \
@ -225,7 +225,7 @@ static std::string get_entity_message(CommandServer *server, Entity *entity) {
float x = entity->x; float x = entity->x;
float y = entity->y - entity->height_offset; float y = entity->y - entity->height_offset;
float z = entity->z; float z = entity->z;
server->pos_translator.to(x, y, z); server->pos_translator.to_float(x, y, z);
pieces.push_back(std::to_string(x)); pieces.push_back(std::to_string(x));
pieces.push_back(std::to_string(y)); pieces.push_back(std::to_string(y));
pieces.push_back(std::to_string(z)); pieces.push_back(std::to_string(z));
@ -508,7 +508,7 @@ std::string CommandServer_parse_injection(CommandServer_parse_t old, CommandServ
next_int(id); next_int(id);
next_int(data); next_int(data);
// Translate // Translate
server->pos_translator.from(x, y, z); server->pos_translator.from_int(x, y, z);
// Set Block // Set Block
server->minecraft->level->setTileAndData(x, y, z, id, data); server->minecraft->level->setTileAndData(x, y, z, id, data);
// Set Sign Data // Set Sign Data
@ -535,7 +535,7 @@ sign->lines[i] = get_input(line_##i); \
next_int(y); next_int(y);
next_int(z); next_int(z);
// Translate // Translate
server->pos_translator.from(x, y, z); server->pos_translator.from_int(x, y, z);
// Read // Read
SignTileEntity *sign = get_sign(server, x, y, z); SignTileEntity *sign = get_sign(server, x, y, z);
if (sign == nullptr) { if (sign == nullptr) {
@ -553,9 +553,7 @@ sign->lines[i] = get_input(line_##i); \
next_float(z); next_float(z);
next_int(type); next_int(type);
// Translate // Translate
x -= server->pos_translator.x; server->pos_translator.from_float(x, y, z);
y -= server->pos_translator.y;
z -= server->pos_translator.z;
if (api_compat_mode) { if (api_compat_mode) {
api_convert_to_mcpi_entity_type(type); api_convert_to_mcpi_entity_type(type);
} }

View File

@ -22,10 +22,10 @@ struct ProjectileHitEvent {
}; };
static std::string event_to_string(CommandServer *server, const ProjectileHitEvent &e) { static std::string event_to_string(CommandServer *server, const ProjectileHitEvent &e) {
// Offset Position // Offset Position
float nx = float(e.x); int nx = e.x;
float ny = float(e.y); int ny = e.y;
float nz = float(e.z); int nz = e.z;
server->pos_translator.to(nx, ny, nz); server->pos_translator.to_int(nx, ny, nz);
// Get Outputs // Get Outputs
std::vector pieces = { std::vector pieces = {
// Position // Position
@ -75,16 +75,16 @@ static std::string event_to_string(__attribute__((unused)) CommandServer *server
// Block Hit Event // Block Hit Event
static std::string event_to_string(CommandServer *server, const TileEvent &e) { static std::string event_to_string(CommandServer *server, const TileEvent &e) {
// Offset Coordinates // Offset Coordinates
float x = float(e.x); int x = e.x;
float y = float(e.y); int y = e.y;
float z = float(e.z); int z = e.z;
server->pos_translator.to(x, y, z); server->pos_translator.to_int(x, y, z);
// Output // Output
return api_join_outputs({ return api_join_outputs({
// Position // Position
std::to_string(int(x)), std::to_string(x),
std::to_string(int(y)), std::to_string(y),
std::to_string(int(z)), std::to_string(z),
// Face // Face
std::to_string(e.face), std::to_string(e.face),
// Entity ID // Entity ID

View File

@ -52,7 +52,7 @@ static std::vector<std::string> get_debug_info_left(const Minecraft *minecraft)
float x = minecraft->player->x; float x = minecraft->player->x;
float y = minecraft->player->y - minecraft->player->height_offset; float y = minecraft->player->y - minecraft->player->height_offset;
float z = minecraft->player->z; float z = minecraft->player->z;
minecraft->command_server->pos_translator.to(x, y, z); minecraft->command_server->pos_translator.to_float(x, y, z);
info.push_back("X: " + to_string_with_precision(x, debug_precision)); info.push_back("X: " + to_string_with_precision(x, debug_precision));
info.push_back("Y: " + to_string_with_precision(y, debug_precision)); info.push_back("Y: " + to_string_with_precision(y, debug_precision));
info.push_back("Z: " + to_string_with_precision(z, debug_precision)); info.push_back("Z: " + to_string_with_precision(z, debug_precision));
@ -142,7 +142,7 @@ static std::vector<std::string> get_debug_info_right(const Minecraft *minecraft)
} }
xyz_precision = debug_precision; xyz_precision = debug_precision;
} }
minecraft->command_server->pos_translator.to(x, y, z); minecraft->command_server->pos_translator.to_float(x, y, z);
info.push_back(""); info.push_back("");
info.push_back("Target X: " + to_string_with_precision(x, xyz_precision)); info.push_back("Target X: " + to_string_with_precision(x, xyz_precision));
info.push_back("Target Y: " + to_string_with_precision(y, xyz_precision)); info.push_back("Target Y: " + to_string_with_precision(y, xyz_precision));

View File

@ -1,5 +1,7 @@
method void from(int &x, int &y, int &z) = 0x27c98; method void from_int(int &x, int &y, int &z) = 0x27c98;
method void to(float &x, float &y, float &z) = 0x27be0; method void from_float(float &x, float &y, float &z) = 0x27c64;
method void to_float(float &x, float &y, float &z) = 0x27be0;
method void to_int(int &x, int &y, int &z) = 0x27c14;
property float x = 0x4; property float x = 0x4;
property float y = 0x8; property float y = 0x8;