diff --git a/modifiedeight-newadditions/headers/input/ControllerHandler.hpp b/modifiedeight-newadditions/headers/input/ControllerHandler.hpp
index d45e38c..130a7bc 100644
--- a/modifiedeight-newadditions/headers/input/ControllerHandler.hpp
+++ b/modifiedeight-newadditions/headers/input/ControllerHandler.hpp
@@ -23,7 +23,10 @@ struct ControllerHandler {
static void clampVec(float&, float&);
static int32_t lastPerspectiveMs;
static bool_t jumpHeld, sneakHeld, sprintHeld;
+ static bool_t sneakToggle;
static bool_t attackHeld, useHeld, confirmHeld;
+ static bool_t justCaptured;
+ static bool_t wasConnected;
static void beginCapture(bool_t);
static void endCapture();
diff --git a/modifiedeight-newadditions/headers/input/ControllerLayout.hpp b/modifiedeight-newadditions/headers/input/ControllerLayout.hpp
index 7a965ea..75cb77a 100644
--- a/modifiedeight-newadditions/headers/input/ControllerLayout.hpp
+++ b/modifiedeight-newadditions/headers/input/ControllerLayout.hpp
@@ -15,11 +15,12 @@ enum ControllerAction {
CA_TOGGLE_PERSPECTIVE = 8,
CA_SNEAK = 9,
CA_GAME_MENU = 10,
- CA_MOVE_AXIS_X = 11,
- CA_MOVE_AXIS_Y = 12,
- CA_LOOK_AXIS_X = 13,
- CA_LOOK_AXIS_Y = 14,
- CA_COUNT = 15
+ CA_CHAT = 11,
+ CA_MOVE_AXIS_X = 12,
+ CA_MOVE_AXIS_Y = 13,
+ CA_LOOK_AXIS_X = 14,
+ CA_LOOK_AXIS_Y = 15,
+ CA_COUNT = 16
};
struct ControllerLayout {
diff --git a/modifiedeight-newadditions/impl/Minecraft.cpp b/modifiedeight-newadditions/impl/Minecraft.cpp
index f148d30..45d4753 100644
--- a/modifiedeight-newadditions/impl/Minecraft.cpp
+++ b/modifiedeight-newadditions/impl/Minecraft.cpp
@@ -511,20 +511,27 @@ void Minecraft::joinMultiplayer(const struct PingedCompatibleServer& a2, bool_t
}
void Minecraft::leaveGame(bool_t a2, bool_t a3) {
if(!this->field_CF4 && this->levelGenerated) {
- if (this->player && this->level && this->level->getLevelData()) {
- CompoundTag playerTag;
- this->player->saveWithoutId(&playerTag);
- this->level->getLevelData()->setPlayerTag(&playerTag);
+ bool_t skipSave = this->level && this->level->isClientMaybe && !a2;
+ if (!skipSave) {
+ if (this->player && this->level && this->level->getLevelData()) {
+ CompoundTag playerTag;
+ this->player->saveWithoutId(&playerTag);
+ this->level->getLevelData()->setPlayerTag(&playerTag);
+ }
}
- if (this->level && this->level->getLevelStorage() && this->player) {
- this->level->getLevelStorage()->save(this->player);
+ if (!skipSave) {
+ if (this->level && this->level->getLevelStorage() && this->player) {
+ this->level->getLevelStorage()->save(this->player);
+ }
}
if(this->level) {
- if(this->level->getChunkSource()) {
- this->level->getChunkSource()->saveAll(0);
+ if(!skipSave) {
+ if(this->level->getChunkSource()) {
+ this->level->getChunkSource()->saveAll(0);
+ }
+ this->level->saveGame();
+ this->level->savePlayers();
}
- this->level->saveGame();
- this->level->savePlayers();
this->level->saveLevelData();
}
this->rakNetInstance->disconnect();
diff --git a/modifiedeight-newadditions/impl/gui/Gui.cpp b/modifiedeight-newadditions/impl/gui/Gui.cpp
index 86654e1..7e977a3 100644
--- a/modifiedeight-newadditions/impl/gui/Gui.cpp
+++ b/modifiedeight-newadditions/impl/gui/Gui.cpp
@@ -142,22 +142,18 @@ void Gui::onConfigChanged(const Config &a2) {
sp = a2.mc->useTouchscreen();
if (sp) {
- if (a2.mc->options.useJoypad) {
- v22 = 6;
- } else {
- v22 = 6;
- if (a2.field_0 > 480) {
- do {
- this->getSlotPos(0, v23, v25);
- sp = this->getSlotPos(v22, v24, v25);
- if ((float)((float)((float)a2.field_0 -
- (float)((float)(v24 - v23) * a2.guiScale)) *
- a2.field_1C) < 80.0) {
- break;
- }
- ++v22;
- } while (v22 != 8);
- }
+ v22 = 6;
+ if (a2.field_0 > 480) {
+ do {
+ this->getSlotPos(0, v23, v25);
+ sp = this->getSlotPos(v22, v24, v25);
+ if ((float)((float)((float)a2.field_0 -
+ (float)((float)(v24 - v23) * a2.guiScale)) *
+ a2.field_1C) < 80.0) {
+ break;
+ }
+ ++v22;
+ } while (v22 != 8);
}
this->slotsAmount = v22;
} else {
diff --git a/modifiedeight-newadditions/impl/input/ControllerHandler.cpp b/modifiedeight-newadditions/impl/input/ControllerHandler.cpp
index 340ed31..64f2d9f 100644
--- a/modifiedeight-newadditions/impl/input/ControllerHandler.cpp
+++ b/modifiedeight-newadditions/impl/input/ControllerHandler.cpp
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
#include
#include
@@ -34,9 +35,12 @@ float ControllerHandler::moveY = 0.0f;
bool_t ControllerHandler::jumpHeld = 0;
bool_t ControllerHandler::sneakHeld = 0;
bool_t ControllerHandler::sprintHeld = 0;
+bool_t ControllerHandler::sneakToggle = 0;
bool_t ControllerHandler::attackHeld = 0;
bool_t ControllerHandler::useHeld = 0;
bool_t ControllerHandler::confirmHeld = 0;
+bool_t ControllerHandler::justCaptured = 0;
+bool_t ControllerHandler::wasConnected = 0;
float ControllerHandler::frameDt = 1.0f;
double ControllerHandler::lastFrameS = 0;
void ControllerHandler::clampVec(float& x, float& y) {
@@ -75,6 +79,7 @@ bool_t ControllerHandler::takeCaptured(Binding& out) {
out = ControllerHandler::capturedBinding;
ControllerHandler::hasCaptured = 0;
ControllerHandler::captureMode = 0;
+ ControllerHandler::justCaptured = 1;
return 1;
}
@@ -113,8 +118,15 @@ void ControllerHandler::tick(Minecraft* mc) {
if(dtMs > 100.0f) dtMs = 100.0f;
ControllerHandler::lastFrameS = nowS;
ControllerHandler::frameDt += ((dtMs / 16.6667f) - ControllerHandler::frameDt) * 0.2f;
+ if(mc && Gamepad::connected && !ControllerHandler::wasConnected && mc->useTouchscreen() && !mc->options.useJoypad) {
+ mc->options.useJoypad = 1;
+ mc->options.save();
+ mc->optionUpdated(&Options::Option::USE_TOUCH_JOYPAD, 1);
+ }
+ ControllerHandler::wasConnected = Gamepad::connected;
if(!ControllerHandler::isEnabled(mc)) {
ControllerHandler::releaseAll();
+ ControllerHandler::sneakToggle = 0;
ControllerHandler::confirmHeld = 0;
Gamepad::beginFrame();
return;
@@ -122,6 +134,7 @@ void ControllerHandler::tick(Minecraft* mc) {
if(ControllerHandler::captureMode) {
ControllerHandler::releaseAll();
+ ControllerHandler::sneakToggle = 0;
ControllerHandler::confirmHeld = 0;
if(!ControllerHandler::hasCaptured) {
Binding found;
@@ -164,7 +177,13 @@ void ControllerHandler::tickGame(Minecraft* mc) {
ControllerHandler::moveY = my;
ControllerHandler::jumpHeld = Gamepad::isBindingDown(ControllerLayout::get(CA_JUMP));
- ControllerHandler::sneakHeld = Gamepad::isBindingDown(ControllerLayout::get(CA_SNEAK));
+ if(Gamepad::wasBindingPressed(ControllerLayout::get(CA_SNEAK))) {
+ ControllerHandler::sneakToggle ^= 1;
+ if(mc->soundEngine) {
+ mc->soundEngine->playUI("random.click", 1.0f, 1.0f);
+ }
+ }
+ ControllerHandler::sneakHeld = ControllerHandler::sneakToggle;
static int32_t lastFwdTapMs = 0;
static bool_t fwdWasDown = 0;
@@ -241,6 +260,10 @@ void ControllerHandler::tickGame(Minecraft* mc) {
mc->gui.handleKeyPressed(100);
}
+ if(Gamepad::wasBindingPressed(ControllerLayout::get(CA_CHAT))) {
+ mc->screenChooser.setScreen(CHAT_SCREEN);
+ }
+
if(Gamepad::wasBindingPressed(ControllerLayout::get(CA_TOGGLE_PERSPECTIVE))) {
int32_t nowMs = getTimeMs();
if(nowMs - ControllerHandler::lastPerspectiveMs >= 350) {
@@ -289,7 +312,10 @@ void ControllerHandler::tickMenu(Minecraft* mc) {
int16_t cy = (int16_t)ControllerHandler::cursorY;
bool_t confirm = Gamepad::isBindingDown(ControllerLayout::get(CA_JUMP));
- if(confirm && !ControllerHandler::confirmHeld) {
+ if(!confirm) {
+ ControllerHandler::justCaptured = 0;
+ }
+ if(confirm && !ControllerHandler::confirmHeld && !ControllerHandler::justCaptured) {
ControllerHandler::confirmHeld = 1;
ControllerHandler::lastPadCursorMs = getTimeMs();
Mouse::feed(1, 1, cx, cy);
@@ -348,13 +374,11 @@ void ControllerHandler::applyMove(IMoveInput* input, Player* player) {
}
}
- if(ControllerHandler::sneakHeld) {
- if(flying) {
- input->flyDownPressed = 1;
- input->sneakingMaybe = 0;
- } else {
- input->sneakingMaybe = 1;
- }
+ if(flying) {
+ input->flyDownPressed = ControllerHandler::sneakToggle;
+ input->sneakingMaybe = 0;
+ } else {
+ input->sneakingMaybe = ControllerHandler::sneakToggle;
}
if(player->isLocalPlayer()) {
diff --git a/modifiedeight-newadditions/impl/input/ControllerLayout.cpp b/modifiedeight-newadditions/impl/input/ControllerLayout.cpp
index 74d2578..1522695 100644
--- a/modifiedeight-newadditions/impl/input/ControllerLayout.cpp
+++ b/modifiedeight-newadditions/impl/input/ControllerLayout.cpp
@@ -18,6 +18,7 @@ static const char_t* _caNames[CA_COUNT] = {
"Toggle Perspective",
"Sneak/Fly Down",
"Game Menu",
+ "Chat",
"Move Left/Right",
"Move Forward/Back",
"Look Left/Right",
@@ -36,6 +37,7 @@ static const char_t* _caKeys[CA_COUNT] = {
"perspective",
"sneak",
"gamemenu",
+ "chat",
"movex",
"movey",
"lookx",
@@ -64,6 +66,7 @@ void ControllerLayout::resetToDefaults() {
ControllerLayout::bindings[CA_LOOK_AXIS_X] = Binding(BIND_AXIS_FULL, GP_AXIS_RX);
ControllerLayout::bindings[CA_LOOK_AXIS_Y] = Binding(BIND_AXIS_FULL, GP_AXIS_RY);
ControllerLayout::bindings[CA_GAME_MENU] = Binding(BIND_BUTTON, GP_BTN_START);
+ ControllerLayout::bindings[CA_CHAT] = Binding(BIND_BUTTON, GP_BTN_DPAD_RIGHT);
}
void ControllerLayout::load() {
diff --git a/modifiedeight/headers/input/ControllerHandler.hpp b/modifiedeight/headers/input/ControllerHandler.hpp
index d45e38c..130a7bc 100644
--- a/modifiedeight/headers/input/ControllerHandler.hpp
+++ b/modifiedeight/headers/input/ControllerHandler.hpp
@@ -23,7 +23,10 @@ struct ControllerHandler {
static void clampVec(float&, float&);
static int32_t lastPerspectiveMs;
static bool_t jumpHeld, sneakHeld, sprintHeld;
+ static bool_t sneakToggle;
static bool_t attackHeld, useHeld, confirmHeld;
+ static bool_t justCaptured;
+ static bool_t wasConnected;
static void beginCapture(bool_t);
static void endCapture();
diff --git a/modifiedeight/headers/input/ControllerLayout.hpp b/modifiedeight/headers/input/ControllerLayout.hpp
index 7a965ea..75cb77a 100644
--- a/modifiedeight/headers/input/ControllerLayout.hpp
+++ b/modifiedeight/headers/input/ControllerLayout.hpp
@@ -15,11 +15,12 @@ enum ControllerAction {
CA_TOGGLE_PERSPECTIVE = 8,
CA_SNEAK = 9,
CA_GAME_MENU = 10,
- CA_MOVE_AXIS_X = 11,
- CA_MOVE_AXIS_Y = 12,
- CA_LOOK_AXIS_X = 13,
- CA_LOOK_AXIS_Y = 14,
- CA_COUNT = 15
+ CA_CHAT = 11,
+ CA_MOVE_AXIS_X = 12,
+ CA_MOVE_AXIS_Y = 13,
+ CA_LOOK_AXIS_X = 14,
+ CA_LOOK_AXIS_Y = 15,
+ CA_COUNT = 16
};
struct ControllerLayout {
diff --git a/modifiedeight/impl/gui/Gui.cpp b/modifiedeight/impl/gui/Gui.cpp
index 56b458c..0f21077 100644
--- a/modifiedeight/impl/gui/Gui.cpp
+++ b/modifiedeight/impl/gui/Gui.cpp
@@ -142,22 +142,18 @@ void Gui::onConfigChanged(const Config &a2) {
sp = a2.mc->useTouchscreen();
if (sp) {
- if (a2.mc->options.useJoypad) {
- v22 = 6;
- } else {
- v22 = 6;
- if (a2.field_0 > 480) {
- do {
- this->getSlotPos(0, v23, v25);
- sp = this->getSlotPos(v22, v24, v25);
- if ((float)((float)((float)a2.field_0 -
- (float)((float)(v24 - v23) * a2.guiScale)) *
- a2.field_1C) < 80.0) {
- break;
- }
- ++v22;
- } while (v22 != 8);
- }
+ v22 = 6;
+ if (a2.field_0 > 480) {
+ do {
+ this->getSlotPos(0, v23, v25);
+ sp = this->getSlotPos(v22, v24, v25);
+ if ((float)((float)((float)a2.field_0 -
+ (float)((float)(v24 - v23) * a2.guiScale)) *
+ a2.field_1C) < 80.0) {
+ break;
+ }
+ ++v22;
+ } while (v22 != 8);
}
this->slotsAmount = v22;
} else {
diff --git a/modifiedeight/impl/gui/screens/ChatScreen.cpp b/modifiedeight/impl/gui/screens/ChatScreen.cpp
index 94e92f8..c5f21d2 100644
--- a/modifiedeight/impl/gui/screens/ChatScreen.cpp
+++ b/modifiedeight/impl/gui/screens/ChatScreen.cpp
@@ -226,6 +226,7 @@ static bool resolveItem(const std::string& rawName, int& outId, std::string& out
}
static bool executeCommand(Minecraft* mc, const std::string& line) {
+ if (!mc || !mc->level || mc->isOnlineClient() || (mc->level && mc->level->isClientMaybe)) return false;
if (line.empty() || line[0] != '/') return false;
std::stringstream ss(line.substr(1));
@@ -498,12 +499,13 @@ static bool executeCommand(Minecraft* mc, const std::string& line) {
void ChatScreen::sendChatMessage() {
if(this->field_54.size()) {
- if(!executeCommand(this->minecraft, this->field_54)) {
+ if (this->minecraft->isOnlineClient() || (this->minecraft->level && this->minecraft->level->isClientMaybe)) {
MessagePacket v7(this->field_54, this->minecraft->player->username);
this->minecraft->rakNetInstance->send(v7);
- if(!this->minecraft->isOnlineClient()) {
- this->minecraft->gui.addMessage(this->minecraft->player->username, this->field_54, 200);
- }
+ } else if(!executeCommand(this->minecraft, this->field_54)) {
+ MessagePacket v7(this->field_54, this->minecraft->player->username);
+ this->minecraft->rakNetInstance->send(v7);
+ this->minecraft->gui.addMessage(this->minecraft->player->username, this->field_54, 200);
}
this->field_78.emplace_back(this->field_54);
this->field_84 = this->field_78.size();
diff --git a/modifiedeight/impl/input/ControllerHandler.cpp b/modifiedeight/impl/input/ControllerHandler.cpp
index 340ed31..64f2d9f 100644
--- a/modifiedeight/impl/input/ControllerHandler.cpp
+++ b/modifiedeight/impl/input/ControllerHandler.cpp
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
#include
#include
@@ -34,9 +35,12 @@ float ControllerHandler::moveY = 0.0f;
bool_t ControllerHandler::jumpHeld = 0;
bool_t ControllerHandler::sneakHeld = 0;
bool_t ControllerHandler::sprintHeld = 0;
+bool_t ControllerHandler::sneakToggle = 0;
bool_t ControllerHandler::attackHeld = 0;
bool_t ControllerHandler::useHeld = 0;
bool_t ControllerHandler::confirmHeld = 0;
+bool_t ControllerHandler::justCaptured = 0;
+bool_t ControllerHandler::wasConnected = 0;
float ControllerHandler::frameDt = 1.0f;
double ControllerHandler::lastFrameS = 0;
void ControllerHandler::clampVec(float& x, float& y) {
@@ -75,6 +79,7 @@ bool_t ControllerHandler::takeCaptured(Binding& out) {
out = ControllerHandler::capturedBinding;
ControllerHandler::hasCaptured = 0;
ControllerHandler::captureMode = 0;
+ ControllerHandler::justCaptured = 1;
return 1;
}
@@ -113,8 +118,15 @@ void ControllerHandler::tick(Minecraft* mc) {
if(dtMs > 100.0f) dtMs = 100.0f;
ControllerHandler::lastFrameS = nowS;
ControllerHandler::frameDt += ((dtMs / 16.6667f) - ControllerHandler::frameDt) * 0.2f;
+ if(mc && Gamepad::connected && !ControllerHandler::wasConnected && mc->useTouchscreen() && !mc->options.useJoypad) {
+ mc->options.useJoypad = 1;
+ mc->options.save();
+ mc->optionUpdated(&Options::Option::USE_TOUCH_JOYPAD, 1);
+ }
+ ControllerHandler::wasConnected = Gamepad::connected;
if(!ControllerHandler::isEnabled(mc)) {
ControllerHandler::releaseAll();
+ ControllerHandler::sneakToggle = 0;
ControllerHandler::confirmHeld = 0;
Gamepad::beginFrame();
return;
@@ -122,6 +134,7 @@ void ControllerHandler::tick(Minecraft* mc) {
if(ControllerHandler::captureMode) {
ControllerHandler::releaseAll();
+ ControllerHandler::sneakToggle = 0;
ControllerHandler::confirmHeld = 0;
if(!ControllerHandler::hasCaptured) {
Binding found;
@@ -164,7 +177,13 @@ void ControllerHandler::tickGame(Minecraft* mc) {
ControllerHandler::moveY = my;
ControllerHandler::jumpHeld = Gamepad::isBindingDown(ControllerLayout::get(CA_JUMP));
- ControllerHandler::sneakHeld = Gamepad::isBindingDown(ControllerLayout::get(CA_SNEAK));
+ if(Gamepad::wasBindingPressed(ControllerLayout::get(CA_SNEAK))) {
+ ControllerHandler::sneakToggle ^= 1;
+ if(mc->soundEngine) {
+ mc->soundEngine->playUI("random.click", 1.0f, 1.0f);
+ }
+ }
+ ControllerHandler::sneakHeld = ControllerHandler::sneakToggle;
static int32_t lastFwdTapMs = 0;
static bool_t fwdWasDown = 0;
@@ -241,6 +260,10 @@ void ControllerHandler::tickGame(Minecraft* mc) {
mc->gui.handleKeyPressed(100);
}
+ if(Gamepad::wasBindingPressed(ControllerLayout::get(CA_CHAT))) {
+ mc->screenChooser.setScreen(CHAT_SCREEN);
+ }
+
if(Gamepad::wasBindingPressed(ControllerLayout::get(CA_TOGGLE_PERSPECTIVE))) {
int32_t nowMs = getTimeMs();
if(nowMs - ControllerHandler::lastPerspectiveMs >= 350) {
@@ -289,7 +312,10 @@ void ControllerHandler::tickMenu(Minecraft* mc) {
int16_t cy = (int16_t)ControllerHandler::cursorY;
bool_t confirm = Gamepad::isBindingDown(ControllerLayout::get(CA_JUMP));
- if(confirm && !ControllerHandler::confirmHeld) {
+ if(!confirm) {
+ ControllerHandler::justCaptured = 0;
+ }
+ if(confirm && !ControllerHandler::confirmHeld && !ControllerHandler::justCaptured) {
ControllerHandler::confirmHeld = 1;
ControllerHandler::lastPadCursorMs = getTimeMs();
Mouse::feed(1, 1, cx, cy);
@@ -348,13 +374,11 @@ void ControllerHandler::applyMove(IMoveInput* input, Player* player) {
}
}
- if(ControllerHandler::sneakHeld) {
- if(flying) {
- input->flyDownPressed = 1;
- input->sneakingMaybe = 0;
- } else {
- input->sneakingMaybe = 1;
- }
+ if(flying) {
+ input->flyDownPressed = ControllerHandler::sneakToggle;
+ input->sneakingMaybe = 0;
+ } else {
+ input->sneakingMaybe = ControllerHandler::sneakToggle;
}
if(player->isLocalPlayer()) {
diff --git a/modifiedeight/impl/input/ControllerLayout.cpp b/modifiedeight/impl/input/ControllerLayout.cpp
index 74d2578..1522695 100644
--- a/modifiedeight/impl/input/ControllerLayout.cpp
+++ b/modifiedeight/impl/input/ControllerLayout.cpp
@@ -18,6 +18,7 @@ static const char_t* _caNames[CA_COUNT] = {
"Toggle Perspective",
"Sneak/Fly Down",
"Game Menu",
+ "Chat",
"Move Left/Right",
"Move Forward/Back",
"Look Left/Right",
@@ -36,6 +37,7 @@ static const char_t* _caKeys[CA_COUNT] = {
"perspective",
"sneak",
"gamemenu",
+ "chat",
"movex",
"movey",
"lookx",
@@ -64,6 +66,7 @@ void ControllerLayout::resetToDefaults() {
ControllerLayout::bindings[CA_LOOK_AXIS_X] = Binding(BIND_AXIS_FULL, GP_AXIS_RX);
ControllerLayout::bindings[CA_LOOK_AXIS_Y] = Binding(BIND_AXIS_FULL, GP_AXIS_RY);
ControllerLayout::bindings[CA_GAME_MENU] = Binding(BIND_BUTTON, GP_BTN_START);
+ ControllerLayout::bindings[CA_CHAT] = Binding(BIND_BUTTON, GP_BTN_DPAD_RIGHT);
}
void ControllerLayout::load() {