FIX: grass color | small improvements
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
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() {
|
||||
@@ -34,32 +36,32 @@ std::vector<std::string> CommandManager::getListAllCommands() {
|
||||
}
|
||||
|
||||
std::string CommandManager::execute(Minecraft& mc, Player& player, const std::string& input) {
|
||||
std::istringstream ss(input);
|
||||
std::string cmd;
|
||||
if (!mc.level->isClientSide) {
|
||||
std::istringstream ss(input);
|
||||
std::string cmd;
|
||||
|
||||
ss >> cmd;
|
||||
ss >> cmd;
|
||||
|
||||
auto it = std::find_if(m_commands.begin(), m_commands.end(), [cmd](auto& it) -> bool {
|
||||
return it->getName() == cmd;
|
||||
});
|
||||
auto it = std::find_if(m_commands.begin(), m_commands.end(), [cmd](auto& it) -> bool {
|
||||
return it->getName() == cmd;
|
||||
});
|
||||
|
||||
if (it == m_commands.end()) {
|
||||
return "Command /" + cmd + " not found";
|
||||
}
|
||||
if (it == m_commands.end()) {
|
||||
return "Command /" + cmd + " not found";
|
||||
}
|
||||
|
||||
std::vector<std::string> args;
|
||||
std::vector<std::string> args;
|
||||
|
||||
std::string tok;
|
||||
while (ss >> tok) args.push_back(tok);
|
||||
|
||||
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 std::string();
|
||||
}
|
||||
|
||||
Command* CommandManager::getCommand(const std::string& name) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -43,14 +43,16 @@ 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
|
||||
if (!GrassColor::useTint && d == DEAD_SHRUB){
|
||||
return 0xffffff;
|
||||
}
|
||||
// if (GrassColor::useTint){
|
||||
// return GrassColor::get(temp, rain); @fixme @todo doesnt work properly
|
||||
// }
|
||||
if (GrassColor::useTint){
|
||||
return GrassColor::get(temp, rain);
|
||||
}
|
||||
// @TODO port this function from beta 1.6.6 probably, for now im using biomesource to tint it directly above - shredder
|
||||
//if (GrassColor::useTint){
|
||||
//return level->getBiome(x, z)->getGrassColor();
|
||||
|
||||
Reference in New Issue
Block a user