diff --git a/CMakeLists.txt b/CMakeLists.txt index b978db0..51bf53f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,9 +16,7 @@ endif() enum_option(PLATFORM "Desktop;Web" "Platform to build for.") -if(NOT EMSCRIPTEN) - find_package(Threads REQUIRED) -endif() +find_package(Threads REQUIRED) find_package(OpenSSL) if (${PLATFORM} STREQUAL "Desktop") diff --git a/README.md b/README.md index 094ec25..1d4caa8 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # MinecraftPE > [!Warning] -> [Github repository](https://github.com/Minecraft-PE-0-6-1/minecraft-pe-0.6.1-on-all) **isnt main**. All issues and pull requests should be send in [Gitea Repository](https://gitea.sffnetwork.ru/Kolyah35/minecraft-pe-0.6.1). +> [Github repository](https://github.com/Minecraft-PE-0-6-1/minecraft-pe-0.6.1-on-all) **isnt main**. All issues and pull requests should be send in [Gitea Repository](https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1). -> [!Note] -> There is unofficial (not related to Kolyah35 and InviseDivine) discord server, where you can report bugs or send feedback https://discord.gg/udYrbNDfDH +> [!Important] +> We have a discord server, where you can report bugs or send feedback https://discord.gg/c58YesBxve Source code for **Minecraft Pocket Edition 0.6.1 alpha** with various fixes and improvements. @@ -17,10 +17,10 @@ This project aims to preserve and improve this early version of Minecraft PE. # Screenshots

-menu -settings -worlds -gameplay +menu +settings +worlds +gameplay

diff --git a/data/lang/en_US.lang b/data/lang/en_US.lang index 567a52b..c90c4be 100755 --- a/data/lang/en_US.lang +++ b/data/lang/en_US.lang @@ -1020,5 +1020,5 @@ desc.netherbrickitem=Used to form blocks of Nether bricks. desc.netherquartz=Quartz from the Nether, used to create Blocks of Quartz. desc.quartzblock=Decorative block, used to create other kinds of Quartz blocks. desc.stonecutter=For crafting stoneblocks. -desc.seeds_melon=Allows for more melons. +desc.seedsmelon=Allows for more melons. desc.tile.melon=Can be cut up and eaten. diff --git a/project/android/assets/lang/en_US.lang b/project/android/assets/lang/en_US.lang index 83c1066..fedae1c 100755 --- a/project/android/assets/lang/en_US.lang +++ b/project/android/assets/lang/en_US.lang @@ -965,5 +965,5 @@ desc.netherbrickitem=Used to form blocks of Nether bricks. desc.netherquartz=Quartz from the Nether, used to create Blocks of Quartz. desc.quartzblock=Decorative block, used to create other kinds of Quartz blocks. desc.stonecutter=For crafting stoneblocks. -desc.seeds_melon=Allows for more melons. +desc.seedsmelon=Allows for more melons. desc.tile.melon=Can be cut up and eaten. diff --git a/src/client/Minecraft.cpp b/src/client/Minecraft.cpp index ded2191..be01595 100755 --- a/src/client/Minecraft.cpp +++ b/src/client/Minecraft.cpp @@ -516,7 +516,7 @@ void Minecraft::tick(int nTick, int maxTick) { if (missTime > 0) missTime--; #ifndef STANDALONE_SERVER if (!screen && player) { - if (player->hasDied()) { + if (player->health <= 0) { setScreen(new DeathScreen()); } } diff --git a/src/client/gui/Screen.cpp b/src/client/gui/Screen.cpp index 1a19efb..a6bcc6f 100755 --- a/src/client/gui/Screen.cpp +++ b/src/client/gui/Screen.cpp @@ -61,12 +61,6 @@ bool Screen::handleBackEvent( bool isDown ) return false; } -void Screen::tick() { - for (auto& textbox : textBoxes) { - textbox->tick(minecraft); - } -} - void Screen::updateEvents() { if (passEvents) @@ -116,12 +110,10 @@ void Screen::keyboardEvent() keyPressed(Keyboard::getEventKey()); } } - void Screen::keyboardTextEvent() { charPressed(Keyboard::getChar()); } - void Screen::renderBackground() { renderBackground(0); diff --git a/src/client/gui/Screen.h b/src/client/gui/Screen.h index 16b551a..be44d5c 100755 --- a/src/client/gui/Screen.h +++ b/src/client/gui/Screen.h @@ -31,7 +31,7 @@ public: virtual void keyboardTextEvent(); virtual bool handleBackEvent(bool isDown); - virtual void tick(); + virtual void tick() {} virtual void removed() {} diff --git a/src/client/gui/components/ScrollingPane.cpp b/src/client/gui/components/ScrollingPane.cpp index 79dd11c..090bc3a 100755 --- a/src/client/gui/components/ScrollingPane.cpp +++ b/src/client/gui/components/ScrollingPane.cpp @@ -204,23 +204,22 @@ void ScrollingPane::render( int xm, int ym, float alpha ) { const float bxx = bbox.x - (fpx /*+ dx*alpha*/) + (nw.xf - nw.x); const float byy = bbox.y - (fpy /*+ dy*alpha*/) + (nw.yf - nw.y); - for (int y = nw.y; y <= se.y; ++y) { - for (int x = nw.x; x <= se.x; ++x) { - int id = y * columns + x; - if (y <0 || id < 0 || id >= numItems) continue; // @todo: break rather - if (isNotSet(SF_WrapX) && (x < 0 || x >= columns)) continue; // @todo: break rather - GridItem item; //@todo: v- Does not support SF_Wrapping - item.id = id; - item.xf = bxx + x * itemBbox.w; - item.yf = byy + y * itemBbox.h; - item.x = (int)item.xf; - item.y = (int)item.yf; - //LOGI("i: %d (%.1f, %.1f)\t", id, item.xf, item.yf); - if (isSet(SF_MultiSelect)) item.selected = selected[id]; - else item.selected = (id == selectedId); + for (int y = nw.y; y <= se.y; ++y) + for (int x = nw.x; x <= se.x; ++x) { + int id = y * columns + x; + if (y <0 || id < 0 || id >= numItems) continue; // @todo: break rather + if (isNotSet(SF_WrapX) && (x < 0 || x >= columns)) continue; // @todo: break rather + GridItem item; //@todo: v- Does not support SF_Wrapping + item.id = id; + item.xf = bxx + x * itemBbox.w; + item.yf = byy + y * itemBbox.h; + item.x = (int)item.xf; + item.y = (int)item.yf; + //LOGI("i: %d (%.1f, %.1f)\t", id, item.xf, item.yf); + if (isSet(SF_MultiSelect)) item.selected = selected[id]; + else item.selected = (id == selectedId); - itemsToRender.push_back(item); - } + itemsToRender.push_back(item); } renderBatch(itemsToRender, alpha); diff --git a/src/client/gui/screens/ChestScreen.cpp b/src/client/gui/screens/ChestScreen.cpp index 8a7b81e..c9383c9 100755 --- a/src/client/gui/screens/ChestScreen.cpp +++ b/src/client/gui/screens/ChestScreen.cpp @@ -329,10 +329,7 @@ bool ChestScreen::handleAddItem(FillingContainer* from, FillingContainer* to, in added = (takenItem.count != wantedCount); if (added) { - if (!minecraft->isCreativeMode()) { - item->count -= (wantedCount - takenItem.count); - } - + item->count -= (wantedCount - takenItem.count); std::vector changed; std::vector items = getItems(toPane); differ.getDiff(items, changed); diff --git a/src/client/gui/screens/ConsoleScreen.cpp b/src/client/gui/screens/ConsoleScreen.cpp index 9d3e874..42f47ee 100644 --- a/src/client/gui/screens/ConsoleScreen.cpp +++ b/src/client/gui/screens/ConsoleScreen.cpp @@ -6,7 +6,7 @@ #include "../../../world/level/Level.h" #include "../../../network/RakNetInstance.h" #include "../../../network/ServerSideNetworkHandler.h" -#include "../../../network/packet/MessagePacket.h" +#include "../../../network/packet/ChatPacket.h" #include "../../../platform/log.h" #include "util/StringUtils.h" @@ -63,27 +63,24 @@ void ConsoleScreen::execute() return minecraft->setScreen(NULL); } - if (minecraft->netCallback && !minecraft->raknetInstance->isServer()) { - MessagePacket packet(_input.c_str()); - minecraft->raknetInstance->send(packet); - } else if (_input[0] == '/') { + if (_input[0] == '/') { + // Command _input = Util::stringTrim(_input.substr(1)); - - std::istringstream iss( - minecraft->commandManager().execute(*minecraft, *minecraft->player, _input) - ); - - for (std::string line; std::getline(iss, line);) { + + std::istringstream iss(minecraft->commandManager().execute(*minecraft, *minecraft->player, _input)); + for (std::string line; std::getline(iss, line); ) { minecraft->gui.addMessage(line); } - } - else { - if (minecraft->raknetInstance->isServer()) { - MessagePacket packet(_input.c_str()); - minecraft->raknetInstance->send(packet); + } else { + // @ai @rewrite + if (minecraft->netCallback && minecraft->raknetInstance->isServer()) { + static_cast(minecraft->netCallback)->displayGameMessage(_input); + } else if (minecraft->netCallback) { + ChatPacket chatPkt(_input); + minecraft->raknetInstance->send(chatPkt); + } else { + minecraft->gui.addMessage("<" + minecraft->player->name + "> " + _input); } - - minecraft->gui.addMessage("<" + minecraft->player->name + "> " + _input); } minecraft->setScreen(NULL); diff --git a/src/client/gui/screens/DeathScreen.cpp b/src/client/gui/screens/DeathScreen.cpp index 0d881a1..e97b103 100755 --- a/src/client/gui/screens/DeathScreen.cpp +++ b/src/client/gui/screens/DeathScreen.cpp @@ -72,7 +72,7 @@ void DeathScreen::render( int xm, int ym, float a ) if (minecraft->options.getIntValue(OPTIONS_MENU_STYLE) == 2){ glPushMatrix2(); glScalef2(2, 2, 2); - drawCenteredString(font, I18n::get("deathScreen.title.hardcore"), width / 4, height / 8, 0xffffff); + drawCenteredString(font, "Game over!", width / 2 / 2, height / 8, 0xffffff); glPopMatrix2(); std::stringstream ss; ss << "Score: &e" << minecraft->player->getScore(); @@ -80,7 +80,7 @@ if (minecraft->options.getIntValue(OPTIONS_MENU_STYLE) == 2){ } else { glPushMatrix2(); glScalef2(2, 2, 2); - drawCenteredString(font, I18n::get("deathScreen.title"), width / 4, height / 8, 0xffffff); + drawCenteredString(font, "You died!", width / 2 / 2, height / 8, 0xffffff); glPopMatrix2(); } diff --git a/src/client/gui/screens/FurnaceScreen.cpp b/src/client/gui/screens/FurnaceScreen.cpp index eb9861f..58d6df2 100755 --- a/src/client/gui/screens/FurnaceScreen.cpp +++ b/src/client/gui/screens/FurnaceScreen.cpp @@ -500,8 +500,6 @@ ItemInstance FurnaceScreen::moveOver(const ItemInstance* item, int maxCount) { setIfNotSet(doRecreatePane, newSize != oldSize); return removed; } - - return ItemInstance(); } diff --git a/src/client/gui/screens/OptionsScreen.cpp b/src/client/gui/screens/OptionsScreen.cpp index bdccde0..9515e9a 100755 --- a/src/client/gui/screens/OptionsScreen.cpp +++ b/src/client/gui/screens/OptionsScreen.cpp @@ -238,7 +238,7 @@ void OptionsScreen::generateOptionScreens() { .addOptionItem(OPTIONS_BAR_ON_TOP, minecraft) .addOptionItem(OPTIONS_MENU_STYLE, minecraft) .addOptionItem(OPTIONS_RPI_CURSOR, minecraft) -#ifndef __APPLE__ +#ifdef __APPLE__ .addOptionItem(OPTIONS_FOLIAGE_TINT, minecraft) .addOptionItem(OPTIONS_TINTED_SIDE, minecraft) #endif diff --git a/src/client/gui/screens/SimpleChooseLevelScreen.cpp b/src/client/gui/screens/SimpleChooseLevelScreen.cpp index 37f5c72..c5a1278 100755 --- a/src/client/gui/screens/SimpleChooseLevelScreen.cpp +++ b/src/client/gui/screens/SimpleChooseLevelScreen.cpp @@ -8,14 +8,13 @@ #include "../../../platform/time.h" #include "../../../platform/input/Keyboard.h" #include "../../../platform/log.h" -#include SimpleChooseLevelScreen::SimpleChooseLevelScreen(const std::string& levelName) -: bHeader(nullptr), - bGamemode(nullptr), - bCheats(nullptr), - bBack(nullptr), - bCreate(nullptr), +: bHeader(0), + bGamemode(0), + bCheats(0), + bBack(0), + bCreate(0), levelName(levelName), hasChosen(false), gamemode(GameType::Survival), @@ -43,10 +42,10 @@ void SimpleChooseLevelScreen::init() // first") when the name already existed. ChooseLevelScreen::init(); - tLevelName.text = I18n::get("selectWorld.newWorld"); + tLevelName.text = "New world"; // header + close button - bHeader = new Touch::THeader(0, I18n::get("selectWorld.create")); + bHeader = new Touch::THeader(0, "Create World"); // create the back/X button as ImageButton like CreditsScreen bBack = new ImageButton(2, ""); { @@ -57,14 +56,14 @@ void SimpleChooseLevelScreen::init() def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height)); bBack->setImageDef(def, true); } - if (minecraft->options.getIntValue(OPTIONS_MENU_STYLE) != 2) { - bGamemode = new Touch::TButton(1, I18n::get("selectWorld.gameMode.survival")); + if (/* minecraft->useTouchscreen() */ true) { + bGamemode = new Touch::TButton(1, "Survival mode"); bCheats = new Touch::TButton(4, "Cheats: Off"); - bCreate = new Touch::TButton(3, I18n::get("selectWorld.create")); + bCreate = new Touch::TButton(3, "Create"); } else { - bGamemode = new Button(1, I18n::get("selectWorld.gameMode.survival")); + bGamemode = new Button(1, "Survival mode"); bCheats = new Button(4, "Cheats: Off"); - bCreate = new Button(3, I18n::get("Create")); + bCreate = new Button(3, "Create"); } buttons.push_back(bHeader); diff --git a/src/client/model/HumanoidModel.cpp b/src/client/model/HumanoidModel.cpp index e6515ea..bf004ec 100755 --- a/src/client/model/HumanoidModel.cpp +++ b/src/client/model/HumanoidModel.cpp @@ -21,9 +21,6 @@ HumanoidModel::HumanoidModel( float g /*= 0*/, float yOffset /*= 0*/, int texW / texWidth = texW; texHeight = texH; - // texWidth = 64; - // texHeight = 32; - head.setModel(this); hair.setModel(this); body.setModel(this); diff --git a/src/client/player/LocalPlayer.cpp b/src/client/player/LocalPlayer.cpp index 29ccf44..86a345f 100755 --- a/src/client/player/LocalPlayer.cpp +++ b/src/client/player/LocalPlayer.cpp @@ -554,9 +554,9 @@ void LocalPlayer::aiStep() { //if (onGround && abilities.flying) // abilities.flying = false; - yBobO = yBob; - xBobO = xBob; - xBob += (xRot - xBob) * 0.5; + yBobO = yBob; + xBobO = xBob; + xBob += (xRot - xBob) * 0.5; yBob += (yRot - yBob) * 0.5; if (interpolateOnly()) @@ -774,19 +774,22 @@ void LocalPlayer::startCrafting(int x, int y, int z, int tableSize) { void LocalPlayer::startStonecutting(int x, int y, int z) { #ifndef STANDALONE_SERVER - minecraft->setScreen( new StonecutterScreen() ); + if (!minecraft->isCreativeMode()) + minecraft->setScreen( new StonecutterScreen() ); #endif } void LocalPlayer::openFurnace( FurnaceTileEntity* e ) { #ifndef STANDALONE_SERVER - minecraft->setScreen( new FurnaceScreen(this, e) ); + if (!minecraft->isCreativeMode()) + minecraft->setScreen( new FurnaceScreen(this, e) ); #endif } void LocalPlayer::openContainer( ChestTileEntity* container ) { #ifndef STANDALONE_SERVER - minecraft->setScreen( new ChestScreen(this, container) ); + if (!minecraft->isCreativeMode()) + minecraft->setScreen( new ChestScreen(this, container) ); #endif } diff --git a/src/client/player/LocalPlayer.h b/src/client/player/LocalPlayer.h index aa0b956..d1fef05 100755 --- a/src/client/player/LocalPlayer.h +++ b/src/client/player/LocalPlayer.h @@ -23,7 +23,7 @@ public: void tick(); - float yBob, xBob; // shredder added from b1.8/4j for the hand swaying animation + float yBob, xBob; // shredder added from b1.8/4j for the hand swaying animation float yBobO, xBobO; // shredder added from b1.8/4j for the hand swaying animation void move(float xa, float ya, float za); diff --git a/src/client/renderer/GameRenderer.cpp b/src/client/renderer/GameRenderer.cpp index 3ea22a0..c4bc08c 100755 --- a/src/client/renderer/GameRenderer.cpp +++ b/src/client/renderer/GameRenderer.cpp @@ -440,7 +440,7 @@ float GameRenderer::getFov(float a, bool applyEffects) { fov *= this->oFov + (this->fov - this->oFov) * a; if (player->isUnderLiquid(Material::water)) fov = 60; - if (player->hasDied()) { + if (player->health <= 0) { float duration = player->deathTime + a; fov /= ((1 - 500 / (duration + 500)) * 2.0f + 1); @@ -537,7 +537,7 @@ void GameRenderer::bobHurt(float a) { float hurt = player->hurtTime - a; - if (player->hasDied()) { + if (player->health <= 0) { float duration = player->deathTime + a; glRotatef2(40 - (40 * 200) / (duration + 200), 0, 0, 1); } diff --git a/src/client/renderer/ItemInHandRenderer.cpp b/src/client/renderer/ItemInHandRenderer.cpp index eb2be2b..fb83bdd 100755 --- a/src/client/renderer/ItemInHandRenderer.cpp +++ b/src/client/renderer/ItemInHandRenderer.cpp @@ -291,13 +291,14 @@ void ItemInHandRenderer::render( float a ) Lighting::turnOn(mc); glPopMatrix2(); - if (localPlayer) { // shredder added, basically does the hand swaying animation from b1.8 - float xrr = localPlayer->xBobO + (localPlayer->xBob - localPlayer->xBobO) * a; - float yrr = localPlayer->yBobO + (localPlayer->yBob - localPlayer->yBobO) * a; - // 4J - was using player->xRot and yRot directly here rather than interpolating between old & current with a - float yr = player->yRotO + (player->yRot - player->yRotO) * a; - glRotatef((xr - xrr) * 0.1f, 1, 0, 0); - glRotatef((yr - yrr) * 0.1f, 0, 1, 0); + if (localPlayer) // shredder added, basically does the hand swaying animation from b1.8 + { + float xrr = localPlayer->xBobO + (localPlayer->xBob - localPlayer->xBobO) * a; + float yrr = localPlayer->yBobO + (localPlayer->yBob - localPlayer->yBobO) * a; + // 4J - was using player->xRot and yRot directly here rather than interpolating between old & current with a + float yr = player->yRotO + (player->yRot - player->yRotO) * a; + glRotatef((xr - xrr) * 0.1f, 1, 0, 0); + glRotatef((yr - yrr) * 0.1f, 0, 1, 0); } float br = mc->level->getBrightness(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z)); @@ -424,8 +425,6 @@ void ItemInHandRenderer::render( float a ) EntityRenderer* er = EntityRenderDispatcher::getInstance()->getRenderer(mc->player); HumanoidMobRenderer* playerRenderer = (HumanoidMobRenderer*) er; - EntityRenderDispatcher::getInstance()->setModernSkin((Entity*)(player)); - float ss = 1; glScalef2(ss, ss, ss); playerRenderer->renderHand(); diff --git a/src/client/renderer/entity/EntityRenderDispatcher.cpp b/src/client/renderer/entity/EntityRenderDispatcher.cpp index 9381b89..b0edea7 100755 --- a/src/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/src/client/renderer/entity/EntityRenderDispatcher.cpp @@ -137,11 +137,6 @@ void EntityRenderDispatcher::render( Entity* entity, float x, float y, float z, } } -void EntityRenderDispatcher::setModernSkin(Entity* player) { - PlayerRenderer* rend = (PlayerRenderer*)(getRenderer(player)); - rend->setModernSkin((Mob*)player); -} - EntityRenderer* EntityRenderDispatcher::getRenderer( Entity* entity ) { EntityRendererId rendererId = entity->entityRendererId; diff --git a/src/client/renderer/entity/EntityRenderDispatcher.h b/src/client/renderer/entity/EntityRenderDispatcher.h index 180b4ef..06c4eac 100755 --- a/src/client/renderer/entity/EntityRenderDispatcher.h +++ b/src/client/renderer/entity/EntityRenderDispatcher.h @@ -45,8 +45,6 @@ public: Font* getFont(); void onGraphicsReset(); - - void setModernSkin(Entity* player); private: void assign(EntityRendererId id, EntityRenderer* renderer); public: diff --git a/src/client/renderer/entity/ItemRenderer.cpp b/src/client/renderer/entity/ItemRenderer.cpp index 4c48a3b..d103fcc 100755 --- a/src/client/renderer/entity/ItemRenderer.cpp +++ b/src/client/renderer/entity/ItemRenderer.cpp @@ -189,9 +189,9 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, const ItemInsta // it we're batching for saving the // buffer, this will fail miserably t.endOverrideAndDraw(); - // glDisable2(GL_TEXTURE_2D); - // fillRect(t, x, y, w, h, 0xff0000); - // glEnable2(GL_TEXTURE_2D); + glDisable2(GL_TEXTURE_2D); + fillRect(t, x, y, w, h, 0xff0000); + glEnable2(GL_TEXTURE_2D); renderGuiItemCorrect(font, textures, item, int(x), int(y)); t.beginOverride(); } diff --git a/src/client/renderer/entity/PlayerRenderer.cpp b/src/client/renderer/entity/PlayerRenderer.cpp index 93685fd..092b9dc 100755 --- a/src/client/renderer/entity/PlayerRenderer.cpp +++ b/src/client/renderer/entity/PlayerRenderer.cpp @@ -70,18 +70,13 @@ void PlayerRenderer::renderName( Mob* mob, float x, float y, float z ){ } } -// @note fix player skin system -void PlayerRenderer::setModernSkin(Mob* mob) { +void PlayerRenderer::render(Entity* mob_, float x, float y, float z, float rot, float a) { + Mob* mob = (Mob*) mob_; HumanoidModel* desired = isModernPlayerSkin(mob) ? playerModel64 : playerModel32; if (model != desired || humanoidModel != desired) { model = desired; humanoidModel = desired; } -} - -void PlayerRenderer::render(Entity* mob_, float x, float y, float z, float rot, float a) { - Mob* mob = (Mob*) mob_; - setModernSkin(mob); /* LOGI("[PlayerRenderer] %s: skin=%s, modelTex=%dx%d, desired=%s\n", ((Player*)mob)->name.c_str(), mob->getTexture().c_str(), humanoidModel->texWidth, humanoidModel->texHeight, diff --git a/src/client/renderer/entity/PlayerRenderer.h b/src/client/renderer/entity/PlayerRenderer.h index 1105c4b..d4b25e2 100755 --- a/src/client/renderer/entity/PlayerRenderer.h +++ b/src/client/renderer/entity/PlayerRenderer.h @@ -19,8 +19,6 @@ public: virtual void renderName(Mob* mob, float x, float y, float z); virtual void onGraphicsReset(); - - void setModernSkin(Mob* mob); private: HumanoidModel* playerModel32; HumanoidModel* playerModel64; diff --git a/src/commands/Command.hpp b/src/commands/Command.hpp index e19ad45..fb3fdd0 100644 --- a/src/commands/Command.hpp +++ b/src/commands/Command.hpp @@ -2,12 +2,18 @@ #include #include +enum CommandFlags { + COMMAND_FLAG_SINGLEPLAYER_ONLY = (1 << 1), + COMMAND_FLAG_NO_ARGS = (1 << 2), +}; + class Minecraft; class Player; class Command { public: const std::string& getName() { return m_name; } + const CommandFlags getFlags() { return m_flags; } bool isPlayerOp(Minecraft& mc, Player& player); @@ -15,7 +21,8 @@ public: virtual std::string help(Minecraft& mc) = 0; protected: - Command(const std::string& name) : m_name(name) {} + Command(const std::string& name, CommandFlags flags = (CommandFlags)0) : m_name(name), m_flags(flags) {} const std::string m_name; + const CommandFlags m_flags; }; \ No newline at end of file diff --git a/src/commands/CommandBan.cpp b/src/commands/CommandBan.cpp index 3877d95..0373d5b 100644 --- a/src/commands/CommandBan.cpp +++ b/src/commands/CommandBan.cpp @@ -36,14 +36,14 @@ std::string CommandBan::execute(Minecraft& mc, Player& player, const std::vector (*it)->remove(); mc.raknetInstance->getPeer()->CloseConnection((*it)->owner, true); } else { - for (auto& banned : mc.level->bannedPlayers) { + for (auto& banned : mc.level->bannedPpl) { if (nicknameLower == banned) { return args[0] + "already banned!"; } } } - mc.level->bannedPlayers.insert(nicknameLower); + mc.level->bannedPpl.insert(nicknameLower); return "ban: successfully banned player " + args[0]; } diff --git a/src/commands/CommandGimmieItems.cpp b/src/commands/CommandGimmieItems.cpp deleted file mode 100644 index 9a7f542..0000000 --- a/src/commands/CommandGimmieItems.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "CommandGimmieItems.hpp" -#include -#include -#include - -CommandGimmieItems::CommandGimmieItems() : Command("gimmieitems") {} - -std::string CommandGimmieItems::execute(Minecraft& mc, Player& player, const std::vector& args) { - if (mc.level != nullptr) { - if (mc.level->getLevelData()->getAllowCheats()) { - player.inventory->add(new ItemInstance(Item::ironIngot, 64)); - player.inventory->add(new ItemInstance(Item::ironIngot, 34)); - player.inventory->add(new ItemInstance(Tile::stonecutterBench)); - player.inventory->add(new ItemInstance(Tile::workBench)); - player.inventory->add(new ItemInstance(Tile::furnace)); - player.inventory->add(new ItemInstance(Tile::wood, 54)); - player.inventory->add(new ItemInstance(Item::stick, 14)); - player.inventory->add(new ItemInstance(Item::coal, 31)); - player.inventory->add(new ItemInstance(Tile::sand, 6)); - player.inventory->add(new ItemInstance(Item::dye_powder, 23, DyePowderItem::PURPLE)); - - return "Grant debug items. Have fun!"; - } else { - return "Cheats are not allowed!"; - } - } - - return "World not loaded"; -} - -std::string CommandGimmieItems::help(Minecraft& mc) { - return "Usage: /gimmieitems"; -} \ No newline at end of file diff --git a/src/commands/CommandGimmieItems.hpp b/src/commands/CommandGimmieItems.hpp deleted file mode 100644 index d3fa66e..0000000 --- a/src/commands/CommandGimmieItems.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "Command.hpp" - -class CommandGimmieItems : public Command { -public: - CommandGimmieItems(); - - std::string execute(Minecraft& mc, Player& player, const std::vector& args); - std::string help(Minecraft& mc); -}; \ No newline at end of file diff --git a/src/commands/CommandManager.cpp b/src/commands/CommandManager.cpp index 16b331c..fbb9324 100644 --- a/src/commands/CommandManager.cpp +++ b/src/commands/CommandManager.cpp @@ -8,7 +8,6 @@ #include "commands/CommandKick.hpp" #include "commands/CommandOp.hpp" #include "commands/CommandBan.hpp" -#include "commands/CommandGimmieItems.hpp" #include "network/packet/ChatPacket.h" #include "network/RakNetInstance.h" #include "world/level/Level.h" @@ -22,7 +21,6 @@ void CommandManager::registerAllCommands() { m_commands.push_back(new CommandKick()); m_commands.push_back(new CommandOp()); m_commands.push_back(new CommandBan()); - // m_commands.push_back(new CommandGimmieItems()); } std::vector CommandManager::getListAllCommands() { @@ -53,8 +51,15 @@ std::string CommandManager::execute(Minecraft& mc, Player& player, const std::st std::string tok; while (ss >> tok) args.push_back(tok); + + if (!mc.level->isClientSide || (*it)->getFlags() & CommandFlags::COMMAND_FLAG_SINGLEPLAYER_ONLY) { + return (*it)->execute(mc, player, args); + } else { + ChatPacket packet("/" + input); + mc.raknetInstance->send(packet); + } - return (*it)->execute(mc, player, args); + return ""; } Command* CommandManager::getCommand(const std::string& name) { diff --git a/src/main_android_java.cpp b/src/main_android_java.cpp index d407ba7..c89ae03 100755 --- a/src/main_android_java.cpp +++ b/src/main_android_java.cpp @@ -220,23 +220,16 @@ static int androidKeyToInternal(int androidKey) { JNIEXPORT void JNICALL Java_com_mojang_minecraftpe_MainActivity_nativeOnKeyDown(JNIEnv* env, jclass cls, jint keyCode) { LOGI("@nativeOnKeyDown: %d\n", keyCode); - - // @rewrite - - if (keyCode != AKEYCODE_1) { - int mapped = androidKeyToInternal(keyCode); - Keyboard::feed(mapped, true); - } + int mapped = androidKeyToInternal(keyCode); + Keyboard::feed(mapped, true); } JNIEXPORT void JNICALL Java_com_mojang_minecraftpe_MainActivity_nativeTextChar(JNIEnv* env, jclass cls, jint unicodeChar) { - LOGI("@nativeTextChar: %d '%c'", unicodeChar, (char)unicodeChar); // soft-keyboards may send a backspace as a character code - // Kolyah35: i dont believe :v - /*if (unicodeChar == 8) { + if (unicodeChar == 8) { Keyboard::feed(Keyboard::KEY_BACKSPACE, true); Keyboard::feed(Keyboard::KEY_BACKSPACE, false); - } else*/ if (unicodeChar > 0 && unicodeChar < 128) { + } else if (unicodeChar > 0 && unicodeChar < 128) { Keyboard::feedText((char)unicodeChar); } } diff --git a/src/main_dedicated.cpp b/src/main_dedicated.cpp index 5e27cd3..fcf14ce 100755 --- a/src/main_dedicated.cpp +++ b/src/main_dedicated.cpp @@ -190,13 +190,13 @@ int main(int numArguments, char* pszArgs[]) { while (std::getline(banned, line)) { if (!line.empty()) { - ((MAIN_CLASS*)g_app)->level->bannedPlayers.insert(line); + ((MAIN_CLASS*)g_app)->level->bannedPpl.insert(line); } } } else { - std::ofstream bannedPlayers("banned-players.txt"); + std::ofstream bannedPpl("banned-players.txt"); - if (!bannedPlayers.is_open()) { + if (!bannedPpl.is_open()) { throw std::runtime_error("Cannot create banned players list."); } } @@ -225,7 +225,7 @@ int main(int numArguments, char* pszArgs[]) { std::ofstream bannedWrite("banned-players.txt"); if (bannedWrite.is_open()) { - for (auto& banned : ((MAIN_CLASS*)g_app)->level->bannedPlayers) { + for (auto& banned : ((MAIN_CLASS*)g_app)->level->bannedPpl) { bannedWrite << banned << std::endl; } bannedWrite.close(); diff --git a/src/network/ClientSideNetworkHandler.cpp b/src/network/ClientSideNetworkHandler.cpp index e2b8150..022b35f 100755 --- a/src/network/ClientSideNetworkHandler.cpp +++ b/src/network/ClientSideNetworkHandler.cpp @@ -448,7 +448,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, TakeItem LOGI("TakeItemPacket\n"); - ItemInstance* item = new ItemInstance(); + ItemInstance* item; item->count = packet->count; item->id = packet->itemId; diff --git a/src/network/RakNetInstance.cpp b/src/network/RakNetInstance.cpp index d5e3ad0..75a2814 100755 --- a/src/network/RakNetInstance.cpp +++ b/src/network/RakNetInstance.cpp @@ -200,7 +200,7 @@ void RakNetInstance::runEvents(NetEventCallback* callback) case ID_DISCONNECTION_NOTIFICATION: case ID_CONNECTION_LOST: callback->onDisconnect(currentEvent->guid); - return; + break; case ID_UNCONNECTED_PONG: { RakNet::TimeMS time; diff --git a/src/network/ServerSideNetworkHandler.cpp b/src/network/ServerSideNetworkHandler.cpp index 7863e37..474d9ad 100755 --- a/src/network/ServerSideNetworkHandler.cpp +++ b/src/network/ServerSideNetworkHandler.cpp @@ -155,23 +155,6 @@ void ServerSideNetworkHandler::displayGameMessage(const std::string& message) raknetInstance->send(packet); } -void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MessagePacket* packet) -{ - auto player = getPlayer(source); - - if (player == nullptr) return; // @todo maybe kick? - std::string msg = packet->message.C_String(); - - if (msg[0] == '/') { - // This is a command - - ChatPacket resp(minecraft->commandManager().execute(*minecraft, *player, Util::stringTrim(msg.substr(1)))); - return sendPrivate(resp, source); - } - - displayGameMessage("<" + player->name + "> " + msg); -} - void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, ChatPacket* packet) { auto player = getPlayer(source); @@ -257,7 +240,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, LoginPac } } - for (auto& banned : level->bannedPlayers) { + for (auto& banned : level->bannedPpl) { if (nicknameLower == banned) { loginStatus = packet->newProto ? LoginStatus::Failed_Banned : LoginStatus::Failed_ClientOld; break; diff --git a/src/network/ServerSideNetworkHandler.h b/src/network/ServerSideNetworkHandler.h index c1cb632..1e9585d 100755 --- a/src/network/ServerSideNetworkHandler.h +++ b/src/network/ServerSideNetworkHandler.h @@ -58,8 +58,6 @@ public: virtual void handle(const RakNet::RakNetGUID& source, ContainerClosePacket* packet); virtual void handle(const RakNet::RakNetGUID& source, SignUpdatePacket* packet); virtual void handle(const RakNet::RakNetGUID& source, ChatPacket* packet); - virtual void handle(const RakNet::RakNetGUID& source, MessagePacket* packet); - virtual void handle(const RakNet::RakNetGUID& source, WantCreatePacket* packet); bool allowsIncomingConnections() { return _allowIncoming; } diff --git a/src/network/command/CommandServer.cpp b/src/network/command/CommandServer.cpp index 3bcbbc1..280b0a9 100755 --- a/src/network/command/CommandServer.cpp +++ b/src/network/command/CommandServer.cpp @@ -92,7 +92,7 @@ static std::string ToStringOk(const T& a, const T& b, const T& c) { std::stringstream ss; ss << a << "," << b << "," << c << "\n"; return ss.str(); -} +} static bool inRange(int c, int lowInclusive, int highInclusive) { return c >= lowInclusive && c <= highInclusive; diff --git a/src/world/entity/Mob.cpp b/src/world/entity/Mob.cpp index 726f444..e275ea8 100755 --- a/src/world/entity/Mob.cpp +++ b/src/world/entity/Mob.cpp @@ -224,7 +224,7 @@ void Mob::baseTick() if (hurtTime > 0) hurtTime--; if (invulnerableTime > 0) invulnerableTime--; - if (this->hasDied()) { + if (health <= 0) { deathTime++; if (deathTime > SharedConstants::TicksPerSecond) { beforeRemove(); @@ -437,8 +437,7 @@ void Mob::setSize( float w, float h ) void Mob::heal( int heal ) { - if (this->hasDied()) return; - + if (health <= 0) return; health += heal; if (health > 20) health = 20; invulnerableTime = invulnerableDuration / 2; @@ -448,8 +447,7 @@ bool Mob::hurt( Entity* source, int dmg ) { if (level->isClientSide) return false; noActionTime = 0; - - if (this->hasDied()) return false; + if (health <= 0) return false; this->walkAnimSpeed = 1.5f; @@ -487,7 +485,7 @@ bool Mob::hurt( Entity* source, int dmg ) } } - if (this->hasDied()) { + if (health <= 0) { if (sound) level->playSound(this, getDeathSound(), getSoundVolume(), getVoicePitch()); die(source); } else { @@ -894,7 +892,7 @@ void Mob::newServerAiStep() { bool Mob::isImmobile() { - return this->hasDied(); + return health <= 0; } void Mob::jumpFromGround() diff --git a/src/world/entity/Mob.h b/src/world/entity/Mob.h index 40ee980..f9a0fa0 100755 --- a/src/world/entity/Mob.h +++ b/src/world/entity/Mob.h @@ -127,8 +127,6 @@ public: virtual ItemInstance* getCarriedItem() {return NULL;} virtual int getUseItemDuration() {return 0;} virtual void swing(); - - inline bool hasDied() { return health <= 0; } protected: virtual void causeFallDamage(float distance); diff --git a/src/world/entity/player/Player.cpp b/src/world/entity/player/Player.cpp index a5fcb26..487b361 100755 --- a/src/world/entity/player/Player.cpp +++ b/src/world/entity/player/Player.cpp @@ -390,7 +390,7 @@ void Player::travel(float xa, float ya) { /*protected*/ bool Player::isImmobile() { - return hasDied() || isSleeping(); + return health <= 0 || isSleeping(); } /*protected*/ @@ -447,8 +447,8 @@ void Player::aiStep() { float tBob = (float) Mth::sqrt(xd * xd + zd * zd); float tTilt = (float) Mth::atan(-yd * 0.2f) * 15.f; if (tBob > 0.1f) tBob = 0.1f; - if (!onGround || hasDied()) tBob = 0; - if (onGround || hasDied()) tTilt = 0; + if (!onGround || health <= 0) tBob = 0; + if (onGround || health <= 0) tTilt = 0; bob += (tBob - bob) * 0.4f; tilt += (tTilt - tilt) * 0.8f; @@ -518,6 +518,14 @@ bool Player::isCreativeModeAllowed() { return true; } +//void Player::drop() { +// //drop(inventory.removeItem(inventory.selected, 1), false); +//} + +void Player::drop(ItemInstance* item) { + drop(item, false); +} + void Player::drop(ItemInstance* item, bool randomly) { if (item == NULL || item->isNull()) return; @@ -551,6 +559,11 @@ void Player::drop(ItemInstance* item, bool randomly) { thrownItem->zd += Mth::sin(dir) * pow; } + reallyDrop(thrownItem); +} + +/*protected*/ +void Player::reallyDrop(ItemEntity* thrownItem) { level->addEntity(thrownItem); } @@ -667,7 +680,7 @@ bool Player::hurt(Entity* source, int dmg) { if (abilities.invulnerable) return false; noActionTime = 0; - if (hasDied()) return false; + if (health <= 0) return false; if(isSleeping() && !level->isClientSide) { stopSleepInBed(true, true, false); } diff --git a/src/world/entity/player/Player.h b/src/world/entity/player/Player.h index 6f69b01..0fb7dae 100755 --- a/src/world/entity/player/Player.h +++ b/src/world/entity/player/Player.h @@ -91,7 +91,10 @@ public: void handleEntityEvent(char id); virtual void take(Entity* e, int orgCount); - virtual void drop(ItemInstance* item, bool randomly = false); + //void drop(); + virtual void drop(ItemInstance* item); + virtual void drop(ItemInstance* item, bool randomly); + void reallyDrop(ItemEntity* thrownItem); bool canDestroy(Tile* tile); float getDestroySpeed(Tile* tile); diff --git a/src/world/item/Item.cpp b/src/world/item/Item.cpp index 9f27efa..1430743 100755 --- a/src/world/item/Item.cpp +++ b/src/world/item/Item.cpp @@ -274,7 +274,7 @@ void Item::initItems() { //Item::diode = (new TilePlanterItem(100, Tile::diode_off))->setIcon(6, 5)->setCategory(ItemCategory::Mechanisms)->setDescriptionId("diode"); Item::shears = (ShearsItem*)(new ShearsItem(103))->setIcon(13, 5)->setCategory(ItemCategory::Tools)->setDescriptionId("shears"); Item::melon = (new FoodItem(104, 2, false))->setIcon(13, 6)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("melon"); - Item::seeds_melon = (new SeedItem(106, Tile::melonStem->id, Tile::farmland->id))->setIcon(14, 3)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("seeds_melon"); + Item::seeds_melon = (new SeedItem(106, Tile::melonStem->id, Tile::farmland->id))->setIcon(14, 3)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("seedsMelon"); Item::beef_raw = (new FoodItem(107, 3, /*FoodConstants.FOOD_SATURATION_LOW,*/ true))->setIcon(9, 6)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("beefRaw"); Item::beef_cooked = (new FoodItem(108, 8, /*FoodConstants.FOOD_SATURATION_GOOD,*/ true))->setIcon(10, 6)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("beefCooked"); Item::chicken_raw = (new FoodItem(109, 2, /*FoodConstants.FOOD_SATURATION_LOW,*/ true))->setIcon(9, 7)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("chickenRaw"); diff --git a/src/world/level/Level.h b/src/world/level/Level.h index e9b9294..17c1d48 100755 --- a/src/world/level/Level.h +++ b/src/world/level/Level.h @@ -312,7 +312,7 @@ public: Random random; std::set ops; - std::set bannedPlayers; + std::set bannedPpl; protected: bool isFindingSpawn; diff --git a/src/world/level/tile/DoorTile.cpp b/src/world/level/tile/DoorTile.cpp index 203e424..7aea82f 100755 --- a/src/world/level/tile/DoorTile.cpp +++ b/src/world/level/tile/DoorTile.cpp @@ -3,7 +3,6 @@ #include "../Level.h" #include "../../item/Item.h" #include "../../entity/player/Player.h" -#include "world/level/LevelSettings.h" DoorTile::DoorTile(int id, const Material* material) : super(id, material) @@ -151,7 +150,7 @@ void DoorTile::setOpen(Level* level, int x, int y, int z, bool shouldOpen) { void DoorTile::neighborChanged(Level* level, int x, int y, int z, int type) { int data = level->getData(x, y, z); - if ((data & C_IS_UPPER_MASK) == 0) { + if ((data & UPPER_BIT) == 0) { bool spawn = false; if (level->getTile(x, y + 1, z) != id) { level->setTile(x, y, z, 0); @@ -165,7 +164,7 @@ void DoorTile::neighborChanged(Level* level, int x, int y, int z, int type) { } } if (spawn) { - if (!level->isClientSide && level->getLevelData()->getGameType() != GameType::Creative) { + if (!level->isClientSide) { // use default chance (1.0) so the drop always occurs spawnResources(level, x, y, z, data); } @@ -194,7 +193,7 @@ int DoorTile::getResource(int data, Random* random) { // itself never drops anything and playerDestroy suppresses spawning // from the top. This prevents duplicate drops if the bottom half is // mined. - if ((data & C_IS_UPPER_MASK) != 0) return 0; + if ((data & UPPER_BIT) != 0) return 0; if (material == Material::metal) return Item::door_iron->id; return Item::door_wood->id; } @@ -206,7 +205,7 @@ HitResult DoorTile::clip(Level* level, int xt, int yt, int zt, const Vec3& a, co // override to prevent double-dropping when top half is directly mined void DoorTile::playerDestroy(Level* level, Player* player, int x, int y, int z, int data) { - if ((data & C_IS_UPPER_MASK) == 0) { + if ((data & UPPER_BIT) == 0) { // only let the lower half handle the actual spawning super::playerDestroy(level, player, x, y, z, data); } @@ -226,7 +225,7 @@ bool DoorTile::mayPlace(Level* level, int x, int y, int z, unsigned char face) { int DoorTile::getCompositeData( LevelSource* level, int x, int y, int z ) { int data = level->getData(x, y, z); - bool isUpper = (data & C_IS_UPPER_MASK) != 0; + bool isUpper = (data & UPPER_BIT) != 0; int lowerData; int upperData; if (isUpper) { diff --git a/src/world/level/tile/DoorTile.h b/src/world/level/tile/DoorTile.h index bd585e5..250d274 100755 --- a/src/world/level/tile/DoorTile.h +++ b/src/world/level/tile/DoorTile.h @@ -17,6 +17,7 @@ class DoorTile: public Tile { typedef Tile super; public: + static const int UPPER_BIT = 8; static const int C_DIR_MASK = 3; static const int C_OPEN_MASK = 4; static const int C_LOWER_DATA_MASK = 7; diff --git a/src/world/level/tile/TallGrass.cpp b/src/world/level/tile/TallGrass.cpp index 497279e..dbd3738 100755 --- a/src/world/level/tile/TallGrass.cpp +++ b/src/world/level/tile/TallGrass.cpp @@ -43,10 +43,8 @@ int TallGrass::getColor( int auxData ) { int TallGrass::getColor( LevelSource* level, int x, int y, int z ) { int d = level->getData(x, y, z); if (d == DEAD_SHRUB); //return 0xffffff; // i removed this to make it accurate to beta 1.6.6 instead of early java release versions - - level->getBiomeSource()->getBiomeBlock(x, z, 1, 1); float temp = level->getBiomeSource()->temperatures[0]; // shredder added - float rain = level->getBiomeSource()->downfalls != nullptr ? level->getBiomeSource()->downfalls[0] : 0; // shredder added + float rain = level->getBiomeSource()->downfalls[0]; // shredder added if (!GrassColor::useTint && d == DEAD_SHRUB){ return 0xffffff; }