From ac4ca933de707b5874e7619ebf54f11da3a67423 Mon Sep 17 00:00:00 2001 From: Qiuzhizhe <42761326+quizhizhe@users.noreply.github.com> Date: Sat, 18 Mar 2023 06:33:20 -0700 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=A8`HitResult`=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LiteLoader/include/llapi/mc/HitResult.hpp | 28 ++++++++++------------- LiteLoader/src/llapi/mc/HitResultAPI.cpp | 5 ++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/LiteLoader/include/llapi/mc/HitResult.hpp b/LiteLoader/include/llapi/mc/HitResult.hpp index ead0658..9b3e460 100644 --- a/LiteLoader/include/llapi/mc/HitResult.hpp +++ b/LiteLoader/include/llapi/mc/HitResult.hpp @@ -9,10 +9,10 @@ class StackResultStorageEntity; enum class HitResultType:int { - TILE=0, - ENTITY, - ENTITY_OUT_OF_RANGE, - NO_HIT, + TILE = 0, + ENTITY = 0x1, + ENTITY_OUT_OF_RANGE = 0x2, + NO_HIT = 0x3, }; #undef BEFORE_EXTRA @@ -22,7 +22,6 @@ class HitResult { #define AFTER_EXTRA // Add Member There - //char filler[112]; Vec3 startPos; //0 Vec3 rayDir; //12 HitResultType type; //24 @@ -30,20 +29,17 @@ class HitResult { BlockPos endBpos; //32 Vec3 endPos; //44 uintptr_t actorRef; //56 - uintptr_t unk64; - int unk72; - int unk76; //76 - bool hitLiquid; //80 - FaceID liquidFace; //81 - BlockPos liquidBpos; //84 - Vec3 liquidPos; //96 - bool indirectHit; //108 - //112 + bool mIsHitLiquid; //64 + FaceID liquidFace; //65 + BlockPos liquidBpos; //68 + Vec3 liquidPos; //80 + bool indirectHit; //92 public: - inline bool __fastcall isHit() { - return (unsigned int)(*((int*)this + 6) - 2) > 1; + inline bool isHit() { + return (unsigned int)(this->type) > 3; } + LIAPI Actor* getEntity(); LIAPI FaceID getFacing(); LIAPI Vec3 getPos(); LIAPI bool isHitLiquid(); diff --git a/LiteLoader/src/llapi/mc/HitResultAPI.cpp b/LiteLoader/src/llapi/mc/HitResultAPI.cpp index 622469b..5d53b52 100644 --- a/LiteLoader/src/llapi/mc/HitResultAPI.cpp +++ b/LiteLoader/src/llapi/mc/HitResultAPI.cpp @@ -1,5 +1,10 @@ #include #include +#include + +Actor* HitResult::getEntity() { + return (Actor*)this->actorRef; +} FaceID HitResult::getFacing() { return dAccess(this, ll::offset::HITRESULTAPI_getFacing);