mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-19 22:43:32 +00:00
fix shitty 4J placing/destroying mechanics
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#include "Minecraft.h"
|
#include "Minecraft.h"
|
||||||
|
#include "client/player/input/IBuildInput.h"
|
||||||
|
|
||||||
#if defined(APPLE_DEMO_PROMOTION)
|
#if defined(APPLE_DEMO_PROMOTION)
|
||||||
#define NO_NETWORK
|
#define NO_NETWORK
|
||||||
@@ -854,51 +855,29 @@ void Minecraft::tickInput() {
|
|||||||
level->tick();
|
level->tick();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//if (!isPressed) LOGI("Key released: %d\n", key);
|
|
||||||
|
|
||||||
if (!options.useMouseForDigging) {
|
|
||||||
int passedTime = getTimeMs() - lastTickTime;
|
|
||||||
if (passedTime > 200) continue;
|
|
||||||
|
|
||||||
// Destroy and attack is on same button
|
|
||||||
if (key == options.keyDestroy.key && isPressed) {
|
|
||||||
BuildActionIntention bai(BuildActionIntention::BAI_REMOVE | BuildActionIntention::BAI_ATTACK);
|
|
||||||
handleBuildAction(&bai);
|
|
||||||
}
|
|
||||||
else // Build and use/interact is on same button
|
|
||||||
if (key == options.keyUse.key && isPressed) {
|
|
||||||
BuildActionIntention bai(BuildActionIntention::BAI_BUILD | BuildActionIntention::BAI_INTERACT);
|
|
||||||
handleBuildAction(&bai);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TIMER_POP_PUSH("tickbuild");
|
|
||||||
BuildActionIntention bai;
|
|
||||||
// @note: This might be a problem. This method is polling based here, but
|
|
||||||
// event based when using mouse (or keys..), and in java. Not quite
|
|
||||||
// sure just yet what way to go.
|
|
||||||
bool buildHandled = inputHolder->getBuildInput()->tickBuild(player, &bai);
|
|
||||||
if (buildHandled) {
|
|
||||||
if (!bai.isRemoveContinue())
|
|
||||||
handleBuildAction(&bai);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isTryingToDestroyBlock = (options.useMouseForDigging
|
|
||||||
? (Mouse::isButtonDown(MouseAction::ACTION_LEFT) && mouseDiggable)
|
|
||||||
: Keyboard::isKeyDown(options.keyDestroy.key))
|
|
||||||
|| (buildHandled && bai.isRemove());
|
|
||||||
|
|
||||||
TIMER_POP_PUSH("handlemouse");
|
TIMER_POP_PUSH("handlemouse");
|
||||||
#ifdef RPI
|
|
||||||
handleMouseDown(MouseAction::ACTION_LEFT, isTryingToDestroyBlock);
|
static bool prevMouseDownLeft = false;
|
||||||
handleMouseClick(buildHandled && bai.isInteract()
|
|
||||||
|| options.useMouseForDigging && Mouse::isButtonDown(MouseAction::ACTION_RIGHT));
|
// Destroy and attack is on same button
|
||||||
#else
|
if (Mouse::isButtonDown(MouseAction::ACTION_LEFT)) {
|
||||||
handleMouseDown(MouseAction::ACTION_LEFT, isTryingToDestroyBlock || (buildHandled && bai.isInteract()));
|
auto baiFlags = BuildActionIntention::BAI_REMOVE | BuildActionIntention::BAI_ATTACK;
|
||||||
#endif
|
|
||||||
|
if (!prevMouseDownLeft) baiFlags |= BuildActionIntention::BAI_FIRSTREMOVE;
|
||||||
|
|
||||||
|
BuildActionIntention bai(baiFlags);
|
||||||
|
handleBuildAction(&bai);
|
||||||
|
}
|
||||||
|
|
||||||
|
prevMouseDownLeft = Mouse::isButtonDown(MouseAction::ACTION_LEFT);
|
||||||
|
|
||||||
|
// Build and use/interact is on same button
|
||||||
|
if (Mouse::isButtonDown(MouseAction::ACTION_RIGHT)) {
|
||||||
|
BuildActionIntention bai(BuildActionIntention::BAI_BUILD | BuildActionIntention::BAI_INTERACT);
|
||||||
|
handleBuildAction(&bai);
|
||||||
|
}
|
||||||
|
|
||||||
lastTickTime = getTimeMs();
|
lastTickTime = getTimeMs();
|
||||||
|
|
||||||
@@ -914,42 +893,6 @@ void Minecraft::tickInput() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minecraft::handleMouseDown(int button, bool down) {
|
|
||||||
#ifndef STANDALONE_SERVER
|
|
||||||
#ifndef RPI
|
|
||||||
if(player->isUsingItem()) {
|
|
||||||
if(!down && !Keyboard::isKeyDown(options.keyUse.key)) {
|
|
||||||
gameMode->releaseUsingItem(player);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if(player->isSleeping()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (button == MouseAction::ACTION_LEFT && missTime > 0) return;
|
|
||||||
if (down && hitResult.type == TILE && button == MouseAction::ACTION_LEFT && !hitResult.indirectHit) {
|
|
||||||
int x = hitResult.x;
|
|
||||||
int y = hitResult.y;
|
|
||||||
int z = hitResult.z;
|
|
||||||
gameMode->continueDestroyBlock(x, y, z, hitResult.f);
|
|
||||||
particleEngine->crack(x, y, z, hitResult.f);
|
|
||||||
player->swing();
|
|
||||||
} else {
|
|
||||||
gameMode->stopDestroyBlock();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Minecraft::handleMouseClick(int button) {
|
|
||||||
// BuildActionIntention bai(
|
|
||||||
// (button == MouseAction::ACTION_LEFT)?
|
|
||||||
// BuildActionIntention::BAI_REMOVE
|
|
||||||
// : BuildActionIntention::BAI_BUILD);
|
|
||||||
//
|
|
||||||
// handleBuildAction(&bai);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Minecraft::handleBuildAction(BuildActionIntention* action) {
|
void Minecraft::handleBuildAction(BuildActionIntention* action) {
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
if (action->isRemove()) {
|
if (action->isRemove()) {
|
||||||
@@ -996,7 +939,15 @@ void Minecraft::handleBuildAction(BuildActionIntention* action) {
|
|||||||
|
|
||||||
//LOGI("tile: %s - %d, %d, %d. b: %f - %f\n", oldTile->getDescriptionId().c_str(), x, y, z, oldTile->getBrightness(level, x, y, z), oldTile->getBrightness(level, x, y+1, z));
|
//LOGI("tile: %s - %d, %d, %d. b: %f - %f\n", oldTile->getDescriptionId().c_str(), x, y, z, oldTile->getBrightness(level, x, y, z), oldTile->getBrightness(level, x, y+1, z));
|
||||||
level->extinguishFire(x, y, z, hitResult.f);
|
level->extinguishFire(x, y, z, hitResult.f);
|
||||||
gameMode->startDestroyBlock(x, y, z, hitResult.f);
|
|
||||||
|
if (action->isFirstRemove()) {
|
||||||
|
gameMode->startDestroyBlock(x, y, z, hitResult.f);
|
||||||
|
} else {
|
||||||
|
gameMode->continueDestroyBlock(x, y, z, hitResult.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
particleEngine->crack(x, y, z, hitResult.f);
|
||||||
|
player->swing();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ItemInstance* item = player->inventory->getSelected();
|
ItemInstance* item = player->inventory->getSelected();
|
||||||
|
|||||||
@@ -131,9 +131,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
static void* prepareLevel_tspawn(void *p_param);
|
static void* prepareLevel_tspawn(void *p_param);
|
||||||
|
|
||||||
void handleMouseClick(int button);
|
|
||||||
void handleMouseDown(int button, bool down);
|
|
||||||
|
|
||||||
void _reloadInput();
|
void _reloadInput();
|
||||||
public:
|
public:
|
||||||
int width;
|
int width;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef MAIN_GLFW_H__
|
#ifndef MAIN_GLFW_H__
|
||||||
#define MAIN_GLFW_H__
|
#define MAIN_GLFW_H__
|
||||||
|
|
||||||
|
#include "GLFW/glfw3.h"
|
||||||
#include "client/renderer/gles.h"
|
#include "client/renderer/gles.h"
|
||||||
#include "SharedConstants.h"
|
#include "SharedConstants.h"
|
||||||
|
|
||||||
@@ -103,6 +104,7 @@ int main(void) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||||
@@ -124,6 +126,7 @@ int main(void) {
|
|||||||
gladLoadGLES1Loader((GLADloadproc)glfwGetProcAddress);
|
gladLoadGLES1Loader((GLADloadproc)glfwGetProcAddress);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
App* app = new MAIN_CLASS();
|
App* app = new MAIN_CLASS();
|
||||||
|
|
||||||
g_app = app;
|
g_app = app;
|
||||||
|
|||||||
Reference in New Issue
Block a user