Compare commits
23 Commits
002bb40aae
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6767011d50 | |||
| db4683f62a | |||
| 61ff4835ea | |||
| 1f252ac4b3 | |||
| 7104ba93ae | |||
| 5ef00eee9f | |||
| 9a743b9aea | |||
| d7a51b09f1 | |||
| 6452eacb34 | |||
| 47cab7d66b | |||
| 09cc2ceee4 | |||
| 7620d49489 | |||
| 381ef354c6 | |||
| 8be6e381d8 | |||
| 3ab30eefa4 | |||
| 325ab94a64 | |||
| 9434a48ae7 | |||
| 79be815827 | |||
| c616546e1e | |||
| 92f972d320 | |||
| 980fc2ccfb | |||
| 3b82c519d0 | |||
|
|
f1e8932fbd |
@@ -16,7 +16,9 @@ endif()
|
||||
|
||||
enum_option(PLATFORM "Desktop;Web" "Platform to build for.")
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
if(NOT EMSCRIPTEN)
|
||||
find_package(Threads REQUIRED)
|
||||
endif()
|
||||
find_package(OpenSSL)
|
||||
|
||||
if (${PLATFORM} STREQUAL "Desktop")
|
||||
@@ -320,6 +322,10 @@ target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT} ${EXTRA
|
||||
|
||||
add_executable(${PROJECT_NAME} ${CLIENT_SOURCES})
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${PROJECT_NAME} PRIVATE data/images/pe.rc)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC ${PLATFORM_CPP})
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
|
||||
BIN
data/images/pe.ico
Normal file
BIN
data/images/pe.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
1
data/images/pe.rc
Normal file
1
data/images/pe.rc
Normal file
@@ -0,0 +1 @@
|
||||
IDI_ICON1 ICON "pe.ico"
|
||||
@@ -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.seedsmelon=Allows for more melons.
|
||||
desc.seeds_melon=Allows for more melons.
|
||||
desc.tile.melon=Can be cut up and eaten.
|
||||
|
||||
@@ -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.seedsmelon=Allows for more melons.
|
||||
desc.seeds_melon=Allows for more melons.
|
||||
desc.tile.melon=Can be cut up and eaten.
|
||||
|
||||
@@ -4,12 +4,11 @@ namespace Common {
|
||||
|
||||
std::string getGameVersionString(const std::string& versionSuffix /* = "" */)
|
||||
{
|
||||
std::string result = std::string("v0.6.1") + versionSuffix;
|
||||
std::string result = std::string("v0.1.0 (forked from v0.6.1 alpha)") + versionSuffix;
|
||||
// append 64-bit port marker only on Android 64‑bit targets
|
||||
#if defined(ANDROID) && (defined(__aarch64__) || defined(__x86_64__))
|
||||
result += " (64-bit port)";
|
||||
result += " (64-bit)";
|
||||
#endif
|
||||
result += " alpha";
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ void Minecraft::setLevel(Level* level, const std::string& message /* ="" */, Loc
|
||||
|
||||
level->ops.emplace(op);
|
||||
_hasSignaledGeneratingLevelFinished = false;
|
||||
#ifdef STANDALONE_SERVER
|
||||
#if defined(STANDALONE_SERVER) || defined(PLATFORM_WEB)
|
||||
const bool threadedLevelCreation = false;
|
||||
#else
|
||||
const bool threadedLevelCreation = true;
|
||||
@@ -516,7 +516,7 @@ void Minecraft::tick(int nTick, int maxTick) {
|
||||
if (missTime > 0) missTime--;
|
||||
#ifndef STANDALONE_SERVER
|
||||
if (!screen && player) {
|
||||
if (player->health <= 0) {
|
||||
if (player->hasDied()) {
|
||||
setScreen(new DeathScreen());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,17 +65,13 @@ OptionBool useVignette("useVignette", true);
|
||||
OptionBool useTouchscreen("useTouchscreen", true);
|
||||
|
||||
OptionBool serverVisible("servervisible", true);
|
||||
#ifndef __APPLE__
|
||||
OptionBool foliageTint("foliagetint", true);
|
||||
#endif
|
||||
OptionBool foliageTint("foliagetint", false);
|
||||
OptionInt fogType("fogType", 0, 0, 2);
|
||||
|
||||
OptionBool javaHud("javaHud", false);
|
||||
|
||||
OptionBool betaSky("betaSky", false);
|
||||
#ifndef __APPLE__
|
||||
OptionBool tintedSide("tintedSide", false);
|
||||
#endif
|
||||
OptionBool blockOutline("blockOutline", false);
|
||||
|
||||
OptionBool restoredAnims("restoredAnims", true);
|
||||
@@ -199,18 +195,14 @@ void Options::initTable() {
|
||||
m_options[OPTIONS_BAR_ON_TOP] = &barOnTop;
|
||||
m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint;
|
||||
m_options[OPTIONS_RPI_CURSOR] = &rpiCursor;
|
||||
#ifndef __APPLE__
|
||||
m_options[OPTIONS_FOLIAGE_TINT] = &foliageTint;
|
||||
#endif
|
||||
// more options yay
|
||||
m_options[OPTIONS_FOG_TYPE] = &fogType;
|
||||
|
||||
m_options[OPTIONS_DEBUG_STYLE] = &debugStyle;
|
||||
|
||||
m_options[OPTIONS_BETA_SKY] = &betaSky;
|
||||
#ifndef __APPLE__
|
||||
m_options[OPTIONS_TINTED_SIDE] = &tintedSide;
|
||||
#endif
|
||||
m_options[OPTIONS_JAVA_HUD] = &javaHud;
|
||||
|
||||
m_options[OPTIONS_AUTOJUMP] = &autoJump;
|
||||
|
||||
@@ -88,15 +88,11 @@ enum OptionId {
|
||||
OPTIONS_LAST_IP,
|
||||
|
||||
OPTIONS_RPI_CURSOR,
|
||||
#ifndef __APPLE__
|
||||
OPTIONS_FOLIAGE_TINT,
|
||||
#endif
|
||||
OPTIONS_FOG_TYPE,
|
||||
OPTIONS_JAVA_HUD,
|
||||
OPTIONS_RESTORED_ANIMS,
|
||||
#ifndef __APPLE__
|
||||
OPTIONS_TINTED_SIDE,
|
||||
#endif
|
||||
OPTIONS_BETA_SKY,
|
||||
OPTIONS_BEAUTIFUL_SKY,
|
||||
OPTIONS_VIGNETTE,
|
||||
|
||||
@@ -204,22 +204,23 @@ 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);
|
||||
|
||||
|
||||
@@ -329,7 +329,10 @@ bool ChestScreen::handleAddItem(FillingContainer* from, FillingContainer* to, in
|
||||
added = (takenItem.count != wantedCount);
|
||||
|
||||
if (added) {
|
||||
item->count -= (wantedCount - takenItem.count);
|
||||
if (!minecraft->isCreativeMode()) {
|
||||
item->count -= (wantedCount - takenItem.count);
|
||||
}
|
||||
|
||||
std::vector<int> changed;
|
||||
std::vector<const ItemInstance*> items = getItems(toPane);
|
||||
differ.getDiff(items, changed);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "../../../world/level/Level.h"
|
||||
#include "../../../network/RakNetInstance.h"
|
||||
#include "../../../network/ServerSideNetworkHandler.h"
|
||||
#include "../../../network/packet/ChatPacket.h"
|
||||
#include "../../../network/packet/MessagePacket.h"
|
||||
#include "../../../platform/log.h"
|
||||
#include "util/StringUtils.h"
|
||||
|
||||
@@ -63,24 +63,27 @@ void ConsoleScreen::execute()
|
||||
return minecraft->setScreen(NULL);
|
||||
}
|
||||
|
||||
if (_input[0] == '/') {
|
||||
// Command
|
||||
if (minecraft->netCallback && !minecraft->raknetInstance->isServer()) {
|
||||
MessagePacket packet(_input.c_str());
|
||||
minecraft->raknetInstance->send(&packet);
|
||||
} else if (_input[0] == '/') {
|
||||
_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 {
|
||||
// @ai @rewrite
|
||||
if (minecraft->netCallback && minecraft->raknetInstance->isServer()) {
|
||||
static_cast<ServerSideNetworkHandler*>(minecraft->netCallback)->displayGameMessage(_input);
|
||||
} else if (minecraft->netCallback) {
|
||||
ChatPacket chatPkt(_input);
|
||||
minecraft->raknetInstance->send(chatPkt);
|
||||
} else {
|
||||
minecraft->gui.addMessage("<" + minecraft->player->name + "> " + _input);
|
||||
}
|
||||
else {
|
||||
if (minecraft->raknetInstance->isServer()) {
|
||||
MessagePacket packet(_input.c_str());
|
||||
minecraft->raknetInstance->send(&packet);
|
||||
}
|
||||
|
||||
minecraft->gui.addMessage("<" + minecraft->player->name + "> " + _input);
|
||||
}
|
||||
|
||||
minecraft->setScreen(NULL);
|
||||
|
||||
@@ -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, "Game over!", width / 2 / 2, height / 8, 0xffffff);
|
||||
drawCenteredString(font, I18n::get("deathScreen.title.hardcore"), width / 4, 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, "You died!", width / 2 / 2, height / 8, 0xffffff);
|
||||
drawCenteredString(font, I18n::get("deathScreen.title"), width / 4, height / 8, 0xffffff);
|
||||
glPopMatrix2();
|
||||
}
|
||||
|
||||
|
||||
@@ -500,6 +500,8 @@ ItemInstance FurnaceScreen::moveOver(const ItemInstance* item, int maxCount) {
|
||||
setIfNotSet(doRecreatePane, newSize != oldSize);
|
||||
return removed;
|
||||
}
|
||||
|
||||
|
||||
return ItemInstance();
|
||||
}
|
||||
|
||||
|
||||
@@ -238,8 +238,10 @@ void OptionsScreen::generateOptionScreens() {
|
||||
.addOptionItem(OPTIONS_BAR_ON_TOP, minecraft)
|
||||
.addOptionItem(OPTIONS_MENU_STYLE, minecraft)
|
||||
.addOptionItem(OPTIONS_RPI_CURSOR, minecraft)
|
||||
#ifndef __APPLE__
|
||||
.addOptionItem(OPTIONS_FOLIAGE_TINT, minecraft)
|
||||
.addOptionItem(OPTIONS_TINTED_SIDE, minecraft)
|
||||
#endif
|
||||
.addOptionItem(OPTIONS_JAVA_HUD, minecraft)
|
||||
.addOptionItem(OPTIONS_FOG_TYPE, minecraft)
|
||||
.addOptionItem(OPTIONS_BETA_SKY, minecraft)
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
#include "../../../platform/time.h"
|
||||
#include "../../../platform/input/Keyboard.h"
|
||||
#include "../../../platform/log.h"
|
||||
#include <locale/I18n.h>
|
||||
|
||||
SimpleChooseLevelScreen::SimpleChooseLevelScreen(const std::string& levelName)
|
||||
: bHeader(0),
|
||||
bGamemode(0),
|
||||
bCheats(0),
|
||||
bBack(0),
|
||||
bCreate(0),
|
||||
: bHeader(nullptr),
|
||||
bGamemode(nullptr),
|
||||
bCheats(nullptr),
|
||||
bBack(nullptr),
|
||||
bCreate(nullptr),
|
||||
levelName(levelName),
|
||||
hasChosen(false),
|
||||
gamemode(GameType::Survival),
|
||||
@@ -42,10 +43,10 @@ void SimpleChooseLevelScreen::init()
|
||||
// first") when the name already existed.
|
||||
ChooseLevelScreen::init();
|
||||
|
||||
tLevelName.text = "New world";
|
||||
tLevelName.text = I18n::get("selectWorld.newWorld");
|
||||
|
||||
// header + close button
|
||||
bHeader = new Touch::THeader(0, "Create World");
|
||||
bHeader = new Touch::THeader(0, I18n::get("selectWorld.create"));
|
||||
// create the back/X button as ImageButton like CreditsScreen
|
||||
bBack = new ImageButton(2, "");
|
||||
{
|
||||
@@ -56,14 +57,14 @@ void SimpleChooseLevelScreen::init()
|
||||
def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height));
|
||||
bBack->setImageDef(def, true);
|
||||
}
|
||||
if (/* minecraft->useTouchscreen() */ true) {
|
||||
bGamemode = new Touch::TButton(1, "Survival mode");
|
||||
if (minecraft->options.getIntValue(OPTIONS_MENU_STYLE) != 2) {
|
||||
bGamemode = new Touch::TButton(1, I18n::get("selectWorld.gameMode.survival"));
|
||||
bCheats = new Touch::TButton(4, "Cheats: Off");
|
||||
bCreate = new Touch::TButton(3, "Create");
|
||||
bCreate = new Touch::TButton(3, I18n::get("selectWorld.create"));
|
||||
} else {
|
||||
bGamemode = new Button(1, "Survival mode");
|
||||
bGamemode = new Button(1, I18n::get("selectWorld.gameMode.survival"));
|
||||
bCheats = new Button(4, "Cheats: Off");
|
||||
bCreate = new Button(3, "Create");
|
||||
bCreate = new Button(3, I18n::get("Create"));
|
||||
}
|
||||
|
||||
buttons.push_back(bHeader);
|
||||
|
||||
@@ -21,6 +21,9 @@ 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);
|
||||
|
||||
@@ -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,22 +774,19 @@ void LocalPlayer::startCrafting(int x, int y, int z, int tableSize) {
|
||||
|
||||
void LocalPlayer::startStonecutting(int x, int y, int z) {
|
||||
#ifndef STANDALONE_SERVER
|
||||
if (!minecraft->isCreativeMode())
|
||||
minecraft->setScreen( new StonecutterScreen() );
|
||||
minecraft->setScreen( new StonecutterScreen() );
|
||||
#endif
|
||||
}
|
||||
|
||||
void LocalPlayer::openFurnace( FurnaceTileEntity* e ) {
|
||||
#ifndef STANDALONE_SERVER
|
||||
if (!minecraft->isCreativeMode())
|
||||
minecraft->setScreen( new FurnaceScreen(this, e) );
|
||||
minecraft->setScreen( new FurnaceScreen(this, e) );
|
||||
#endif
|
||||
}
|
||||
|
||||
void LocalPlayer::openContainer( ChestTileEntity* container ) {
|
||||
#ifndef STANDALONE_SERVER
|
||||
if (!minecraft->isCreativeMode())
|
||||
minecraft->setScreen( new ChestScreen(this, container) );
|
||||
minecraft->setScreen( new ChestScreen(this, container) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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->health <= 0) {
|
||||
if (player->hasDied()) {
|
||||
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->health <= 0) {
|
||||
if (player->hasDied()) {
|
||||
float duration = player->deathTime + a;
|
||||
glRotatef2(40 - (40 * 200) / (duration + 200), 0, 0, 1);
|
||||
}
|
||||
|
||||
@@ -291,14 +291,13 @@ 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));
|
||||
@@ -425,6 +424,8 @@ 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();
|
||||
|
||||
@@ -137,6 +137,11 @@ 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;
|
||||
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
Font* getFont();
|
||||
|
||||
void onGraphicsReset();
|
||||
|
||||
void setModernSkin(Entity* player);
|
||||
private:
|
||||
void assign(EntityRendererId id, EntityRenderer* renderer);
|
||||
public:
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -70,13 +70,18 @@ void PlayerRenderer::renderName( Mob* mob, float x, float y, float z ){
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerRenderer::render(Entity* mob_, float x, float y, float z, float rot, float a) {
|
||||
Mob* mob = (Mob*) mob_;
|
||||
// @note fix player skin system
|
||||
void PlayerRenderer::setModernSkin(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,
|
||||
|
||||
@@ -19,6 +19,8 @@ public:
|
||||
|
||||
virtual void renderName(Mob* mob, float x, float y, float z);
|
||||
virtual void onGraphicsReset();
|
||||
|
||||
void setModernSkin(Mob* mob);
|
||||
private:
|
||||
HumanoidModel* playerModel32;
|
||||
HumanoidModel* playerModel64;
|
||||
|
||||
@@ -2,18 +2,12 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
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);
|
||||
|
||||
@@ -21,8 +15,7 @@ public:
|
||||
virtual std::string help(Minecraft& mc) = 0;
|
||||
|
||||
protected:
|
||||
Command(const std::string& name, CommandFlags flags = (CommandFlags)0) : m_name(name), m_flags(flags) {}
|
||||
Command(const std::string& name) : m_name(name) {}
|
||||
|
||||
const std::string m_name;
|
||||
const CommandFlags m_flags;
|
||||
};
|
||||
@@ -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->bannedPpl) {
|
||||
for (auto& banned : mc.level->bannedPlayers) {
|
||||
if (nicknameLower == banned) {
|
||||
return args[0] + "already banned!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mc.level->bannedPpl.insert(nicknameLower);
|
||||
mc.level->bannedPlayers.insert(nicknameLower);
|
||||
return "ban: successfully banned player " + args[0];
|
||||
}
|
||||
|
||||
|
||||
33
src/commands/CommandGimmieItems.cpp
Normal file
33
src/commands/CommandGimmieItems.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "CommandGimmieItems.hpp"
|
||||
#include <client/Minecraft.h>
|
||||
#include <world/level/Level.h>
|
||||
#include <world/item/DyePowderItem.h>
|
||||
|
||||
CommandGimmieItems::CommandGimmieItems() : Command("gimmieitems") {}
|
||||
|
||||
std::string CommandGimmieItems::execute(Minecraft& mc, Player& player, const std::vector<std::string>& 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";
|
||||
}
|
||||
9
src/commands/CommandGimmieItems.hpp
Normal file
9
src/commands/CommandGimmieItems.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "Command.hpp"
|
||||
|
||||
class CommandGimmieItems : public Command {
|
||||
public:
|
||||
CommandGimmieItems();
|
||||
|
||||
std::string execute(Minecraft& mc, Player& player, const std::vector<std::string>& args);
|
||||
std::string help(Minecraft& mc);
|
||||
};
|
||||
@@ -8,6 +8,7 @@
|
||||
#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"
|
||||
@@ -21,6 +22,7 @@ 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<std::string> CommandManager::getListAllCommands() {
|
||||
@@ -51,15 +53,8 @@ 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 "";
|
||||
return (*it)->execute(mc, player, args);
|
||||
}
|
||||
|
||||
Command* CommandManager::getCommand(const std::string& name) {
|
||||
|
||||
@@ -190,13 +190,13 @@ int main(int numArguments, char* pszArgs[]) {
|
||||
|
||||
while (std::getline(banned, line)) {
|
||||
if (!line.empty()) {
|
||||
((MAIN_CLASS*)g_app)->level->bannedPpl.insert(line);
|
||||
((MAIN_CLASS*)g_app)->level->bannedPlayers.insert(line);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::ofstream bannedPpl("banned-players.txt");
|
||||
std::ofstream bannedPlayers("banned-players.txt");
|
||||
|
||||
if (!bannedPpl.is_open()) {
|
||||
if (!bannedPlayers.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->bannedPpl) {
|
||||
for (auto& banned : ((MAIN_CLASS*)g_app)->level->bannedPlayers) {
|
||||
bannedWrite << banned << std::endl;
|
||||
}
|
||||
bannedWrite.close();
|
||||
|
||||
@@ -200,7 +200,7 @@ void RakNetInstance::runEvents(NetEventCallback* callback)
|
||||
case ID_DISCONNECTION_NOTIFICATION:
|
||||
case ID_CONNECTION_LOST:
|
||||
callback->onDisconnect(currentEvent->guid);
|
||||
break;
|
||||
return;
|
||||
case ID_UNCONNECTED_PONG:
|
||||
{
|
||||
RakNet::TimeMS time;
|
||||
|
||||
@@ -155,6 +155,23 @@ 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);
|
||||
@@ -240,7 +257,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, LoginPac
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& banned : level->bannedPpl) {
|
||||
for (auto& banned : level->bannedPlayers) {
|
||||
if (nicknameLower == banned) {
|
||||
loginStatus = packet->newProto ? LoginStatus::Failed_Banned : LoginStatus::Failed_ClientOld;
|
||||
break;
|
||||
|
||||
@@ -58,6 +58,8 @@ 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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -224,7 +224,7 @@ void Mob::baseTick()
|
||||
if (hurtTime > 0) hurtTime--;
|
||||
if (invulnerableTime > 0) invulnerableTime--;
|
||||
|
||||
if (health <= 0) {
|
||||
if (this->hasDied()) {
|
||||
deathTime++;
|
||||
if (deathTime > SharedConstants::TicksPerSecond) {
|
||||
beforeRemove();
|
||||
@@ -437,7 +437,8 @@ void Mob::setSize( float w, float h )
|
||||
|
||||
void Mob::heal( int heal )
|
||||
{
|
||||
if (health <= 0) return;
|
||||
if (this->hasDied()) return;
|
||||
|
||||
health += heal;
|
||||
if (health > 20) health = 20;
|
||||
invulnerableTime = invulnerableDuration / 2;
|
||||
@@ -447,7 +448,8 @@ bool Mob::hurt( Entity* source, int dmg )
|
||||
{
|
||||
if (level->isClientSide) return false;
|
||||
noActionTime = 0;
|
||||
if (health <= 0) return false;
|
||||
|
||||
if (this->hasDied()) return false;
|
||||
|
||||
this->walkAnimSpeed = 1.5f;
|
||||
|
||||
@@ -485,7 +487,7 @@ bool Mob::hurt( Entity* source, int dmg )
|
||||
}
|
||||
}
|
||||
|
||||
if (health <= 0) {
|
||||
if (this->hasDied()) {
|
||||
if (sound) level->playSound(this, getDeathSound(), getSoundVolume(), getVoicePitch());
|
||||
die(source);
|
||||
} else {
|
||||
@@ -892,7 +894,7 @@ void Mob::newServerAiStep() {
|
||||
|
||||
bool Mob::isImmobile()
|
||||
{
|
||||
return health <= 0;
|
||||
return this->hasDied();
|
||||
}
|
||||
|
||||
void Mob::jumpFromGround()
|
||||
|
||||
@@ -127,6 +127,8 @@ 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);
|
||||
|
||||
|
||||
@@ -390,7 +390,7 @@ void Player::travel(float xa, float ya) {
|
||||
|
||||
/*protected*/
|
||||
bool Player::isImmobile() {
|
||||
return health <= 0 || isSleeping();
|
||||
return hasDied() || 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 || health <= 0) tBob = 0;
|
||||
if (onGround || health <= 0) tTilt = 0;
|
||||
if (!onGround || hasDied()) tBob = 0;
|
||||
if (onGround || hasDied()) tTilt = 0;
|
||||
bob += (tBob - bob) * 0.4f;
|
||||
tilt += (tTilt - tilt) * 0.8f;
|
||||
|
||||
@@ -518,14 +518,6 @@ 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;
|
||||
@@ -559,11 +551,6 @@ void Player::drop(ItemInstance* item, bool randomly) {
|
||||
thrownItem->zd += Mth::sin(dir) * pow;
|
||||
}
|
||||
|
||||
reallyDrop(thrownItem);
|
||||
}
|
||||
|
||||
/*protected*/
|
||||
void Player::reallyDrop(ItemEntity* thrownItem) {
|
||||
level->addEntity(thrownItem);
|
||||
}
|
||||
|
||||
@@ -680,7 +667,7 @@ bool Player::hurt(Entity* source, int dmg) {
|
||||
if (abilities.invulnerable) return false;
|
||||
|
||||
noActionTime = 0;
|
||||
if (health <= 0) return false;
|
||||
if (hasDied()) return false;
|
||||
if(isSleeping() && !level->isClientSide) {
|
||||
stopSleepInBed(true, true, false);
|
||||
}
|
||||
|
||||
@@ -91,10 +91,7 @@ public:
|
||||
void handleEntityEvent(char id);
|
||||
|
||||
virtual void take(Entity* e, int orgCount);
|
||||
//void drop();
|
||||
virtual void drop(ItemInstance* item);
|
||||
virtual void drop(ItemInstance* item, bool randomly);
|
||||
void reallyDrop(ItemEntity* thrownItem);
|
||||
virtual void drop(ItemInstance* item, bool randomly = false);
|
||||
|
||||
bool canDestroy(Tile* tile);
|
||||
float getDestroySpeed(Tile* tile);
|
||||
|
||||
@@ -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("seedsMelon");
|
||||
Item::seeds_melon = (new SeedItem(106, Tile::melonStem->id, Tile::farmland->id))->setIcon(14, 3)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("seeds_melon");
|
||||
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");
|
||||
|
||||
@@ -312,7 +312,7 @@ public:
|
||||
Random random;
|
||||
|
||||
std::set<std::string> ops;
|
||||
std::set<std::string> bannedPpl;
|
||||
std::set<std::string> bannedPlayers;
|
||||
protected:
|
||||
bool isFindingSpawn;
|
||||
|
||||
|
||||
@@ -43,8 +43,10 @@ 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[0]; // shredder added
|
||||
float rain = level->getBiomeSource()->downfalls != nullptr ? level->getBiomeSource()->downfalls[0] : 0; // shredder added
|
||||
if (!GrassColor::useTint && d == DEAD_SHRUB){
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user