Skip to content
This repository has been archived by the owner on Dec 26, 2021. It is now read-only.

Commit

Permalink
Add viewmodel, improve xray(#4426)
Browse files Browse the repository at this point in the history
  • Loading branch information
FloppyDolphin57 authored Aug 18, 2021
1 parent 038e467 commit bb72373
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 57 deletions.
2 changes: 2 additions & 0 deletions Horion.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@
<ClCompile Include="Horion\Module\Modules\TriggerBot.cpp" />
<ClCompile Include="Horion\Module\Modules\Twerk.cpp" />
<ClCompile Include="Horion\Module\Modules\VanillaPlus.cpp" />
<ClCompile Include="Horion\Module\Modules\ViewModel.cpp" />
<ClCompile Include="Horion\Module\Modules\Velocity.cpp" />
<ClCompile Include="Horion\Module\Modules\Waypoints.cpp" />
<ClCompile Include="Horion\Module\Modules\Xray.cpp" />
Expand Down Expand Up @@ -548,6 +549,7 @@
<ClInclude Include="Horion\Module\Modules\TriggerBot.h" />
<ClInclude Include="Horion\Module\Modules\Twerk.h" />
<ClInclude Include="Horion\Module\Modules\VanillaPlus.h" />
<ClInclude Include="Horion\Module\Modules\ViewModel.h" />
<ClInclude Include="Horion\Module\Modules\Velocity.h" />
<ClInclude Include="Horion\Module\Modules\Waypoints.h" />
<ClInclude Include="Horion\Module\Modules\Xray.h" />
Expand Down
15 changes: 9 additions & 6 deletions Horion/Command/Commands/EnchantCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ bool EnchantCommand::execute(std::vector<std::string>* args) {
C_InventoryAction* firstAction = nullptr;
C_InventoryAction* secondAction = nullptr;

ItemDescriptor* desc = nullptr;
desc = new ItemDescriptor((*item->item)->itemId, 0);

if (isAuto) {
{
firstAction = new C_InventoryAction(supplies->selectedHotbarSlot, item, nullptr);
firstAction = new C_InventoryAction(supplies->selectedHotbarSlot, desc, nullptr, item, nullptr, item->count);
if (strcmp(g_Data.getRakNetInstance()->serverIp.getText(), "mco.mineplex.com") == 0)
secondAction = new C_InventoryAction(0, nullptr, item, 32766, 100);
secondAction = new C_InventoryAction(0, nullptr, desc, nullptr, item, item->count, 32766, 100);
else
secondAction = new C_InventoryAction(0, nullptr, item, 507, 99999);
secondAction = new C_InventoryAction(0, nullptr, desc, nullptr, item, item->count, 507, 99999);
manager->addInventoryAction(*firstAction);
manager->addInventoryAction(*secondAction);
delete firstAction;
Expand Down Expand Up @@ -159,10 +162,10 @@ bool EnchantCommand::execute(std::vector<std::string>* args) {

if (isAuto) {
if (strcmp(g_Data.getRakNetInstance()->serverIp.getText(), "mco.mineplex.com") == 0)
firstAction = new C_InventoryAction(0, item, nullptr, 32766, 100);
firstAction = new C_InventoryAction(0, desc, nullptr, item, nullptr, item->count, 32766, 100);
else
firstAction = new C_InventoryAction(0, item, nullptr, 507, 99999);
secondAction = new C_InventoryAction(supplies->selectedHotbarSlot, nullptr, item);
firstAction = new C_InventoryAction(0, desc, nullptr, item, nullptr, item->count, 507, 99999);
secondAction = new C_InventoryAction(supplies->selectedHotbarSlot, nullptr, desc, nullptr, item, item->count);
manager->addInventoryAction(*firstAction);
manager->addInventoryAction(*secondAction);
delete firstAction;
Expand Down
10 changes: 6 additions & 4 deletions Horion/DrawUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,16 @@ void DrawUtils::drawNameTags(C_Entity* ent, float textSize, bool drawHealth, boo
rectPos.w = textPos.y + textHeight + 2.f * textSize;
vec4_t subRectPos = rectPos;
subRectPos.y = subRectPos.w - 1.f * textSize;
fillRectangle(rectPos, MC_Color(13, 29, 48), 0.8f);
fillRectangle(subRectPos, MC_Color(28, 107, 201), 0.9f);
static auto nametagsMod = moduleMgr->getModule<NameTags>();
fillRectangle(rectPos, MC_Color(13, 29, 48), nametagsMod->opacity);
if (nametagsMod->underline) {
fillRectangle(subRectPos, MC_Color(30, 110, 20), 0.9f);
}
drawText(textPos, &text, MC_Color(255, 255, 255), textSize);

static auto nameTagsMod = moduleMgr->getModule<NameTags>();

if (ent->getEntityTypeId() == 63 && nameTagsMod->displayArmor) { // is player, show armor
if (ent->getEntityTypeId() == 319 && nameTagsMod->displayArmor) { // is player, show armor
auto* player = reinterpret_cast<C_Player*>(ent);
float scale = textSize * 0.6f;
float spacing = scale + 15.f;
Expand All @@ -399,7 +402,6 @@ void DrawUtils::drawNameTags(C_Entity* ent, float textSize, bool drawHealth, boo
DrawUtils::drawItem(stack, vec2_t(rectPos.z - 1.f - 15.f * scale, y), 1.f, scale, stack->isEnchanted());
}
}

}
}
}
Expand Down
1 change: 1 addition & 0 deletions Horion/Module/ModuleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void ModuleManager::initModules() {
this->moduleList.push_back(std::shared_ptr<IModule>(new Compass()));
this->moduleList.push_back(std::shared_ptr<IModule>(new Radar()));
this->moduleList.push_back(std::shared_ptr<IModule>(new VanillaPlus()));
this->moduleList.push_back(std::shared_ptr<IModule>(new ViewModel()));
this->moduleList.push_back(std::shared_ptr<IModule>(new Twerk()));
this->moduleList.push_back(std::shared_ptr<IModule>(new FollowPathModule()));

Expand Down
1 change: 1 addition & 0 deletions Horion/Module/ModuleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
#include "Modules/Compass.h"
#include "Modules/Radar.h"
#include "Modules/VanillaPlus.h"
#include "Modules/ViewModel.h"
#include "Modules/Twerk.h"

#ifdef _DEBUG
Expand Down
41 changes: 22 additions & 19 deletions Horion/Module/Modules/NameTags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#include "../../../Utils/Target.h"
#include "../ModuleManager.h"

NameTags::NameTags() : IModule(0, Category::VISUAL, "Shows better nametags above players that can be seen from a lot more far aways") {
this->registerBoolSetting("Display Armor", &this->displayArmor, this->displayArmor);
NameTags::NameTags() : IModule(0, Category::VISUAL, "Shows betterar aways") {
this->registerBoolSetting("Underline", &this->underline, this->underline);
this->registerBoolSetting("Armor", &this->displayArmor, this->displayArmor);

This comment has been minimized.

Copy link
@PacketDeveloper

PacketDeveloper Aug 19, 2021

ok no u stole that from packet dude why would onix give u the src

This comment has been minimized.

Copy link
@PlasmaWasTaken

PlasmaWasTaken Aug 20, 2021

no one likes u + onix did give him the src. 9yr old.

this->registerFloatSetting("Opacity", &this->opacity, this->opacity, 0.f, 1.f);
}

NameTags::~NameTags() {
Expand All @@ -14,7 +16,7 @@ const char* NameTags::getModuleName() {
return ("NameTags");
}

void drawNameTags(C_Entity* ent, bool isRegularEntitie) {
void drawNameTags(C_Entity* ent, bool) {
C_LocalPlayer* localPlayer = g_Data.getLocalPlayer();
static auto nameTagsMod = moduleMgr->getModule<NameTags>();

Expand All @@ -29,26 +31,27 @@ void drawNameTags(C_Entity* ent, bool isRegularEntitie) {
DrawUtils::drawNameTags(ent, fmax(0.6f, 3.f / dist));
DrawUtils::flush();
}

}
}

void NameTags::onPreRender(C_MinecraftUIRenderContext* renderCtx) {
C_LocalPlayer* localPlayer = g_Data.getLocalPlayer();
if (localPlayer == nullptr || !GameData::canUseMoveKeys()) return;

if (nameTags.size() > 100)
nameTags.clear();

if (localPlayer != nullptr && GameData::canUseMoveKeys()) {
std::vector<C_Entity*> temp;
for (int i = 0; i < g_Data.getEntityList()->getListSize(); i++)
temp.push_back(g_Data.getEntityList()->get(i));
std::sort(temp.begin(), temp.end(), [localPlayer](const C_Entity* lhs, const C_Entity* rhs) {
return localPlayer->getPos()->dist(*lhs->getPos()) > localPlayer->getPos()->dist(*rhs->getPos());
});
for (C_Entity* ent : temp)
drawNameTags(ent, true);
} else {
nameTags.clear();
}
if (ingameNametagSetting)
if (!gotPrevSetting) {
lastSetting = *ingameNametagSetting;
gotPrevSetting = true;
*ingameNametagSetting = false;
} else
*ingameNametagSetting = false; //disable other ppl's nametags

g_Data.forEachEntity(drawNameTags);
}

void NameTags::onDisable() {
if (ingameNametagSetting && gotPrevSetting) {
*ingameNametagSetting = lastSetting;
gotPrevSetting = false;
}
}
7 changes: 7 additions & 0 deletions Horion/Module/Modules/NameTags.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ class NameTags : public IModule {
public:
std::set<std::string> nameTags;
bool displayArmor = true;
bool underline = true;
float opacity = 0.2f;
NameTags();
~NameTags();

bool* ingameNametagSetting = nullptr;
bool lastSetting = true;
bool gotPrevSetting = false;

// Inherited via IModule
virtual const char* getModuleName() override;
virtual void onPreRender(C_MinecraftUIRenderContext* renderCtx) override;
virtual void onDisable() override;
};
40 changes: 40 additions & 0 deletions Horion/Module/Modules/ViewModel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "ViewModel.h"


ViewModel::ViewModel() : IModule(0, Category::VISUAL, "Custom item view model") {
this->registerBoolSetting("Reset", &this->Reset, this->Reset);
this->registerBoolSetting("Translate", &this->doTranslate, this->doTranslate);
this->registerBoolSetting("Scale", &this->doScale, this->doScale);

this->registerFloatSetting("TranslateX", &this->xTrans, 0.f, -2.f, 2.f);
this->registerFloatSetting("TranslateY", &this->yTrans, 0.f, -2.f, 2.f);
this->registerFloatSetting("TranslateZ", &this->zTrans, 0.f, -2.f, 2.f);

this->registerFloatSetting("ScaleX", &this->xMod, 1.f, 0.f, 2.f);
this->registerFloatSetting("ScaleY", &this->yMod, 1.f, 0.f, 2.f);
this->registerFloatSetting("ScaleZ", &this->zMod, 1.f, 0.f, 2.f);
}

ViewModel::~ViewModel() {
}

const char* ViewModel::getModuleName() {
return "ViewModel";
}

void ViewModel::onTick(C_GameMode* gm) {
if (g_Data.getLocalPlayer() == nullptr)
return;

if (Reset) {
xTrans = 0.f;
yTrans = 0.f;
zTrans = 0.f;

xMod = 1.f;
yMod = 1.f;
zMod = 1.f;
Reset = false;
}
}

27 changes: 27 additions & 0 deletions Horion/Module/Modules/ViewModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once
#include "Module.h"
class ViewModel : public IModule {
private:
int delay = 0;

public:
bool Reset = false;
bool doTranslate = true;
bool doScale = true;

float float1 = 0;
float xMod = 1.f;
float yMod = 1.f;
float zMod = 1.f;

float xTrans = 0.f;
float yTrans = 0.f;
float zTrans = 0.f;

ViewModel();
~ViewModel();

// Inherited via IModule
virtual const char* getModuleName() override;
virtual void onTick(C_GameMode* gm) override;
};
21 changes: 19 additions & 2 deletions Horion/Module/Modules/Xray.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
#include "Xray.h"

Xray::Xray() : IModule(VK_NUMPAD6, Category::VISUAL, "X-Ray view!") {
Xray::Xray() : IModule(0, Category::VISUAL, "Allows you to see certain blocks easier") {
}

Xray::~Xray() {
}

const char* Xray::getModuleName() {
return ("X-Ray");
return ("Xray");
}

void Xray::onTick(C_GameMode* gm) {
if (smoothLightningSetting != nullptr) {
if (!gotSmoothInfo) {
gotSmoothInfo = true;
wasSmooth = *smoothLightningSetting;
}
*smoothLightningSetting = 0;
}
}

void Xray::onDisable() {
if (smoothLightningSetting != nullptr && gotSmoothInfo) {
*smoothLightningSetting = wasSmooth;
}
gotSmoothInfo = false;
}
6 changes: 6 additions & 0 deletions Horion/Module/Modules/Xray.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
#include "Module.h"
class Xray : public IModule {
public:
bool* smoothLightningSetting = nullptr;
bool gotSmoothInfo = false;
bool wasSmooth = false;

Xray();
~Xray();

// Inherited via IModule
virtual const char* getModuleName() override;
virtual void onTick(C_GameMode* gm) override;
virtual void onDisable() override;
};
Loading

1 comment on commit bb72373

@PlasmaWasTaken
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg floppy ur such a god

Please sign in to comment.