From 125df0725f50670017d57c97dc01b217a0669797 Mon Sep 17 00:00:00 2001 From: Qiuzhizhe <42761326+quizhizhe@users.noreply.github.com> Date: Mon, 27 Feb 2023 22:50:09 -0800 Subject: [PATCH] Fix AttributeInstance class --- LiteLoader/Header/MC/AttributeInstance.hpp | 46 ++++++++++++++++--- .../Header/MC/AttributeInstanceDelegate.hpp | 9 +++- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/LiteLoader/Header/MC/AttributeInstance.hpp b/LiteLoader/Header/MC/AttributeInstance.hpp index 72e8453..ac047d1 100644 --- a/LiteLoader/Header/MC/AttributeInstance.hpp +++ b/LiteLoader/Header/MC/AttributeInstance.hpp @@ -2,27 +2,60 @@ #pragma once #define AUTO_GENERATED #include "../Global.h" +#include "AttributeInstanceDelegate.hpp" #define BEFORE_EXTRA +class BaseAttributeMap; +class Attribute; #undef BEFORE_EXTRA class AttributeInstance { +public: + + BaseAttributeMap *mAttributeMap; + const Attribute *mAttribute; + std::vector mModifierList; + std::vector mTemporalBuffs; + std::vector mListeners; + std::shared_ptr mDelegate; + union{ + float mDefaultValues[3]; + struct + { + float mDefaultMinValue; + float mDefaultMaxValue; + float mDefaultValue; + } __s1; + } _anon_0; + union{ + float mCurrentValues[3]; + struct + { + float mCurrentMinValue; + float mCurrentMaxValue; + float mCurrentValue; + } __s1; + } _anon_1; #define AFTER_EXTRA public: inline float getMinValue()const{ - return dAccess(this, 31); + // return dAccess(this, 124); + return _anon_1.__s1.mCurrentMinValue; }; inline float getMaxValue()const{ - return dAccess(this, 32); + // return dAccess(this, 128); + return _anon_1.__s1.mCurrentMaxValue; }; inline float getCurrentValue()const{ - return dAccess(this, 33); + // return dAccess(this, 132); + return _anon_1.__s1.mCurrentValue; }; //maybe error - inline void setCurrentValue(float value)const{ - dAccess((void*)this)= value; + inline void setCurrentValue(float value){ + //dAccess((void*)this)= value; + this->_anon_1.__s1.mCurrentValue = value; //AttributeInstance::resetToMaxValue Line11~Line28 // if (this + 3) // { @@ -42,7 +75,8 @@ public: // } }; inline float getDefaultValue(int a)const{ - return dAccess(this, 30); + // return dAccess(this, 120); + return _anon_0.__s1.mDefaultValue; }; #undef AFTER_EXTRA diff --git a/LiteLoader/Header/MC/AttributeInstanceDelegate.hpp b/LiteLoader/Header/MC/AttributeInstanceDelegate.hpp index 1ecda90..928f318 100644 --- a/LiteLoader/Header/MC/AttributeInstanceDelegate.hpp +++ b/LiteLoader/Header/MC/AttributeInstanceDelegate.hpp @@ -4,13 +4,20 @@ #include "../Global.h" #define BEFORE_EXTRA +class BaseAttributeMap; +struct AttributeInstanceHandle +{ + unsigned int mAttributeID; + BaseAttributeMap *mAttributeMap; +}; #undef BEFORE_EXTRA class AttributeInstanceDelegate { #define AFTER_EXTRA - +public: + AttributeInstanceHandle mAttributeHandle; #undef AFTER_EXTRA #ifndef DISABLE_CONSTRUCTOR_PREVENTION_ATTRIBUTEINSTANCEDELEGATE public: