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);
// Apply Offset
server->pos_translator.from(start_x, start_y, start_z);
server->pos_translator.from(end_x, end_y, end_z);
server->pos_translator.from_int(start_x, start_y, start_z);
server->pos_translator.from_int(end_x, end_y, end_z);
// Swap If Needed
#define swap_if_needed(axis) \
@ -225,7 +225,7 @@ static std::string get_entity_message(CommandServer *server, Entity *entity) {
float x = entity->x;
float y = entity->y - entity->height_offset;
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(y));
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(data);
// Translate
server->pos_translator.from(x, y, z);
server->pos_translator.from_int(x, y, z);
// Set Block
server->minecraft->level->setTileAndData(x, y, z, id, data);
// Set Sign Data
@ -535,7 +535,7 @@ sign->lines[i] = get_input(line_##i); \
next_int(y);
next_int(z);
// Translate
server->pos_translator.from(x, y, z);
server->pos_translator.from_int(x, y, z);
// Read
SignTileEntity *sign = get_sign(server, x, y, z);
if (sign == nullptr) {
@ -553,9 +553,7 @@ sign->lines[i] = get_input(line_##i); \
next_float(z);
next_int(type);
// Translate
x -= server->pos_translator.x;
y -= server->pos_translator.y;
z -= server->pos_translator.z;
server->pos_translator.from_float(x, y, z);
if (api_compat_mode) {
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) {
// Offset Position
float nx = float(e.x);
float ny = float(e.y);
float nz = float(e.z);
server->pos_translator.to(nx, ny, nz);
int nx = e.x;
int ny = e.y;
int nz = e.z;
server->pos_translator.to_int(nx, ny, nz);
// Get Outputs
std::vector pieces = {
// Position
@ -75,16 +75,16 @@ static std::string event_to_string(__attribute__((unused)) CommandServer *server
// Block Hit Event
static std::string event_to_string(CommandServer *server, const TileEvent &e) {
// Offset Coordinates
float x = float(e.x);
float y = float(e.y);
float z = float(e.z);
server->pos_translator.to(x, y, z);
int x = e.x;
int y = e.y;
int z = e.z;
server->pos_translator.to_int(x, y, z);
// Output
return api_join_outputs({
// Position
std::to_string(int(x)),
std::to_string(int(y)),
std::to_string(int(z)),
std::to_string(x),
std::to_string(y),
std::to_string(z),
// Face
std::to_string(e.face),
// 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 y = minecraft->player->y - minecraft->player->height_offset;
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("Y: " + to_string_with_precision(y, 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;
}
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("Target X: " + to_string_with_precision(x, 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 to(float &x, float &y, float &z) = 0x27be0;
method void from_int(int &x, int &y, int &z) = 0x27c98;
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 y = 0x8;