Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions data/data_symbols.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0x000000710036ed18,_ZNK5Vec3i7distSqrERKS_
0x0000007101070d48,_ZTV18ItemTotemRenameFix
0x0000007101070d98,_ZTV18ItemWaterPotionFix
0x00000071010712d8,_ZTV10DataWalker
0x00000071011172c0,_ZTV14DataFixerUpper
0x000000710111a1e8,_ZTV7DataFix
0x000000710111a218,_ZTV9DataFixer
0x000000710111e7c8,_ZTV14ItemDataWalker
0x000000710111ea30,_ZTV18ItemListDataWalker
0x000000710111ed00,_ZTV15KeyedDataWalker
0x0000007101781BBC,AABB__sThreadStorageCount
0x0000007101781BC0,AABB__sDefaultThreadStorage
0x0000007101781BE0,_ZN6Blocks8RegistryE
Expand All @@ -23,6 +33,7 @@
0x0000007101781FD8,_ZN5Biome10DEEP_OCEANE
0x0000007101781FE0,_ZN5Biome15MUSHROOM_ISLANDE
0x0000007101782068,_ZN6Blocks5ANVILE
0x0000007101782070,_ZN8BlockPos4zeroE
0x00000071017825B8,_ZN6Blocks6PLANKSE
0x00000071017825D0,_ZN6Blocks3AIRE
0x00000071017825D8,_ZN6Blocks3WEBE
Expand Down Expand Up @@ -824,6 +835,8 @@
0x000000710178CEC0,_ZN15MonsterEggBlock7Variant11MOSSY_BRICKE
0x000000710178CEC8,_ZN15MonsterEggBlock7Variant13CRACKED_BRICKE
0x000000710178CED0,_ZN15MonsterEggBlock7Variant14CHISELED_BRICKE
0x000000710178cee0,_ZN3Mth3SINE
0x000000710178cee8,_ZN3Mth4ATANE
0x000000710178CFC8,_ZN11NewLogBlock7VARIANTE
0x00000071017A1140,_ZN6Packet11sPacketsMapE
0x00000071017A16D8,_ZN15RangedAttribute13ATTACK_DAMAGEE
Expand All @@ -838,6 +851,7 @@
0x00000071017A1958,_ZN11PlanksBlock7Variant8VARIANTSE
0x00000071017A1988,_ZN11PlanksBlock9PREDICATEE
0x00000071017A1A30,_ZN15RangedAttribute12ATTACK_SPEEDE
0x00000071017a1a40,_ZN14DataFixerUpper16DATA_VERSION_KEYE
0x00000071017A1BB0,_ZN9Direction4Axis9PREDICATEE
0x00000071017A1E70,_ZN15PrismarineBlock7VARIANTE
0x00000071017A1E78,_ZN15PrismarineBlock7Variant8VARIANTSE
Expand Down Expand Up @@ -920,6 +934,7 @@
0x00000071017A4BE0,_ZN15StoneBrickBlock7Variant7CRACKEDE
0x00000071017A4BE8,_ZN15StoneBrickBlock7Variant8CHISELEDE
0x00000071017A53F8,SynchedEntityData__sIdMap
0x00000071017A58E8,_ZN4Vec34ZEROE
0x00000071017A5ED8,_ZZN10StoneBlock26createBlockStateDefinitionEvE10properties
0x00000071017A8380,_ZN3fui9sInstanceE
0x00000071017AA788,CGameNetworkManager__sInstance
Expand Down Expand Up @@ -950,6 +965,7 @@
0x00000071017C38A0,_ZN14GlStateManager14RESCALE_NORMALE
0x00000071017C38A8,_ZN14GlStateManager9ColorMask9sInstanceE
0x00000071017C38B0,_ZN14GlStateManager5Color9sInstanceE
0x00000071017C3BA8,_ZN9ItemIdFix10ID_TO_NAMEE
0x00000071017C4BB4,worldCutoff
0x00000071017C4BC0,sGlobalChunkCount
0x00000071017C5328,_ZN11MapRenderer21sMaterialColorPaletteE
Expand Down
572 changes: 286 additions & 286 deletions data/mcswitch_functions.csv

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/4JLibraries_Source/fui/fui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void fui::setScreenSize(float width, float height) {
this->m_screenHeight = height;
}

// NON_MATCHING | score: 3004 (lower is better)
void fui::unloadScene(fuiFile* file) {
if (!file)
return;
Expand Down Expand Up @@ -95,8 +96,9 @@ void fui::render(fuiFile* file, float a1, float a2, float a3, float a4, float a5
file->m_renderNodeStage->render(nullptr, nullptr);
}

// NON_MATCHING | score: 5 (lower is better)
void fui::dispatchKeyboardEvent(fuiFile* file, bool state, int c) {
FJ_FuiNode* node = file->m_data.m_fuiSymbol->m_stage; // ???
FJ_FuiNode* node = file->m_renderNodeStage->m_fuiNodeStage;

if (FJ_FuiNode* focus = static_cast<FJ_FuiNodeStage*>(node)->getFocus())
node = focus;
Expand All @@ -105,8 +107,9 @@ void fui::dispatchKeyboardEvent(fuiFile* file, bool state, int c) {
}

// param names guessed
// NON_MATCHING | score: 5 (lower is better)
void fui::dispatchMouseMoveEvent(fuiFile* file, float x, float y) {
FJ_FuiNode* node = file->m_data.m_fuiSymbol->m_stage;
FJ_FuiNode* node = file->m_renderNodeStage->m_fuiNodeStage;

if (FJ_FuiNode* focus = static_cast<FJ_FuiNodeStage*>(node)->getFocus())
node = focus;
Expand Down
130 changes: 102 additions & 28 deletions src/4JLibraries_Source/fui/fuiFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "fui/fuiSymbol.h"
#include "net/minecraft/world/ArrayWithLength.h"
#include "types.h"
#include <cstddef>

// Most structs derived from
// https://github.com/NessieHax/fui-research-repo/blob/main/DOCUMENTATION.md
Expand Down Expand Up @@ -36,6 +37,7 @@ struct fuiMatrix {

// spent an hour trying to figure out what this was
// finally thought of it being a built in C++ operator... which looks good to me.
// NON_MATCHING | score: 205 (lower is better)
fuiMatrix operator*(const fuiMatrix& rhs) const {
fuiMatrix out = {};
mul(*this, rhs, out);
Expand All @@ -46,47 +48,107 @@ struct fuiMatrix {
static void mul(const fuiMatrix& lhs, const fuiMatrix& rhs, fuiMatrix& out);
};
struct fuiColorTransform {
float m_redMultTerm;
float m_greenMultTerm;
float m_blueMultTerm;
float m_alphaMultTerm;
float m_redAddTerm;
float m_greenAddTerm;
float m_blueAddTerm;
float m_alphaAddTerm;
float m_redMultTerm;
float m_greenMultTerm;
float m_blueMultTerm;
float m_alphaMultTerm;
};

struct fuiTimeline {
int m_symbolIndex;
short m_frameIndex;
short m_frameCount;
short m_actionIndex;
short m_actionCount;
uint16_t m_frameIndex;
uint16_t m_frameCount;
uint16_t m_actionIndex;
uint16_t m_actionCount;
fuiRect m_rect;
};
struct fuiTimelineAction;
struct fuiShape;
struct fuiShapeComponent;
struct fuiVert;
struct fuiTimelineFrame;
struct fuiTimelineEvent;
struct timelineEventName;
struct fuiTimelineAction {
uint16_t m_type;
int16_t m_frame;
char m_argument0[64];
char m_argument1[64];
};
struct fuiShape {
int m_symbolIndex;
int m_componentIndex;
int m_componentCount;
fuiRect m_rect;
};
struct fuiFillStyle {
int m_type;
fuiRGBA m_colour;
int m_bitmapIndex;
fuiMatrix m_matrix;
};
struct fuiShapeComponent {
fuiFillStyle m_fill;
int m_vertexIndex;
int m_vertexCount;
};
struct fuiVert {
float m_x, m_y;
};
struct fuiTimelineFrame {
char m_name[64];
int m_eventIndex;
int m_eventCount;
};
struct fuiTimelineEvent {
uint16_t m_type;
uint8_t m_objectType;
uint8_t m_flags;
int16_t m_depth;
int16_t m_objectIndex;
int16_t m_unknown;
int16_t m_nameIndex;
fuiMatrix m_matrix;
fuiColorTransform m_colourTransform;
fuiRGBA m_colour;
};
struct timelineEventName {
char m_name[64];
};
struct fuiReference {
int m_symbolIndex;
char m_name[64];
int m_index;
};
struct fuiEdittext;
struct fuiBitmap;
struct fuiFontName;
struct fuiImportAsset;
struct fuiEdittext {
int m_symbolIndex;
fuiRect m_rect;
int m_fontId;
float m_fontSize;
fuiRGBA m_colour;
int m_flags[6];
char m_text[256];
};
struct fuiBitmap {
int m_symbolIndex;
int m_format;
int m_width;
int m_height;
int m_offset;
int m_size;
int m_alphaOffset;
int m_texture;
};
struct fuiFontName {
int m_id;
char m_name[256];
};
struct fuiImportAsset {
char m_name[64];
};
class FJ_FuiNode;

struct fuiHeader {
bool m_field0;
unsigned char m_signature[8];
int m_contentSize;
int m_field8;
char m_fileName[60];
char m_fileName[64];
int m_timelineCount;
int m_timelineEventNameCount;
int m_timelineActionCount;
Expand All @@ -97,12 +159,11 @@ struct fuiHeader {
int m_timelineEventCount;
int m_referenceCount;
int m_editTextCount;
int m_symbolCount;
int m_bitmapCount;
int m_imagesSize;
int m_field7C;
int m_fontNameCount;
int m_importAssetCount;
int m_unk;
fuiRect m_stageSize;
int m_index;
};
Expand All @@ -123,7 +184,7 @@ struct fuiData {
fuiReference* m_fuiReference;
fuiEdittext* m_fuiEdittext;
fuiSymbol* m_fuiSymbol;
fuiBitmapFont* m_fuiBitmap;
fuiBitmap* m_fuiBitmap;
void* m_imageMaybe;
fuiFontName* m_fuiFontName;
fuiImportAsset* m_fuiImportAsset;
Expand All @@ -132,10 +193,11 @@ struct fuiData {
struct fuiFile {
fuiFile();
~fuiFile();
// NOTE: HAD TO CHANGE THE SIGNATURE BECAUSE OF THE METHOD BEING DIFFERENT
// ORIG HAD A CALLBACK METHOD INSTEAD OF DATA
/** Retain the recovered symbol's ABI; its third argument is a byte stride,
* despite the old unsigned-char** declaration in the symbol map.
*/
static uint64_t addDataRegion(uint a1, uint a2, uchar** ptr, uint64_t* callbackData);
void load(arrayWithLength<uchar>, int);
bool load(arrayWithLength<uchar>, int);
bool resolveReferences(fuiFile*);
void dumpUnresolvedReferences();
void initialiseRenderTexture(fuiBitmap*, bool);
Expand All @@ -159,3 +221,15 @@ struct fuiFile {
void* m_callbackData;
void* m_field138;
};

static_assert(sizeof(fuiHeader) == 0x9c, "FUI header including runtime file index");
static_assert(offsetof(fuiHeader, m_contentSize) == 8, "FUI content size");
static_assert(offsetof(fuiHeader, m_stageSize) == 0x88, "FUI stage rectangle");
static_assert(sizeof(fuiTimeline) == 0x1c && sizeof(fuiTimelineAction) == 0x84);
static_assert(sizeof(fuiShape) == 0x1c && sizeof(fuiShapeComponent) == 0x2c);
static_assert(sizeof(fuiTimelineFrame) == 0x48 && sizeof(fuiTimelineEvent) == 0x48);
static_assert(sizeof(fuiReference) == 0x48 && sizeof(fuiEdittext) == 0x138);
static_assert(sizeof(fuiBitmap) == 0x20 && sizeof(fuiFontName) == 0x104);
static_assert(offsetof(fuiFile, m_data) == 0xa0);
static_assert(offsetof(fuiFile, m_renderNodeStage) == 0x118);
static_assert(offsetof(fuiFile, m_field138) == 0x138);
10 changes: 5 additions & 5 deletions src/4JLibraries_Source/fui/fuiSymbol.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

class FJ_FuiNodeStage;

struct fuiSymbol {
char m_padding[0xf8];
FJ_FuiNodeStage*
m_stage; // not sure if this is meant to be stage but fui::dispatchKeyboardEvent likes it sooo
char m_name[64];
int m_objectType;
int m_objectIndex;
};

static_assert(sizeof(fuiSymbol) == 0x48, "FUI on-disk symbol layout");
14 changes: 14 additions & 0 deletions src/DecompUtils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

#include <arm_neon.h>
#include <cmath>

// this can be depracated if musl is fixed

inline __attribute__((__always_inline__)) float decomp_fmax1(float x, float y) {
Expand All @@ -16,3 +19,14 @@ inline __attribute__((__always_inline__)) float decomp_fminf(float x, float y) {
__asm__("fminnm %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y));
return x;
}

/** Custom instruction helpers: AArch64 fmax/fmin propagate NaNs, unlike the C math functions. */
inline __attribute__((__always_inline__)) double decomp_fmax64(double x, double y) {
__asm__("fmax %d0, %d1, %d2" : "=w"(x) : "w"(x), "w"(y));
return x;
}

inline __attribute__((__always_inline__)) double decomp_fmin64(double x, double y) {
__asm__("fmin %d0, %d1, %d2" : "=w"(x) : "w"(x), "w"(y));
return x;
}
5 changes: 4 additions & 1 deletion src/Minecraft.Client/com/mojang/nbt/ByteArrayTag.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "com/mojang/nbt/ByteArrayTag.h"

#include "net/minecraft/world/ArrayWithLength.h"
#include <cstring>

#include "java/io/DataInput.h"
#include "java/io/DataOutput.h"
Expand All @@ -15,8 +17,9 @@ ByteArrayTag::ByteArrayTag(arrayWithLength<u8> data, bool unk) {
}

ByteArrayTag::~ByteArrayTag() {
if (m_unknown)
if (m_unknown) {
delete m_data.m_data;
}
}

void ByteArrayTag::write(DataOutput* outputStream) {
Expand Down
Loading