mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-30 20:13:31 +00:00
Compare commits
4 Commits
f5fecbc928
...
ba3ed3b4dd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba3ed3b4dd | ||
|
|
5783fb93f3 | ||
|
|
73fb2a2b3d | ||
|
|
bcf48eb5e3 |
@@ -553,7 +553,7 @@ void Minecraft::tick(int nTick, int maxTick) {
|
|||||||
level->tickEntities();
|
level->tickEntities();
|
||||||
level->tick();
|
level->tick();
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
TIMER_POP_PUSH("animateTick");
|
TIMER_POP_PUSH("animateTick");
|
||||||
if (player) {
|
if (player) {
|
||||||
level->animateTick(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
level->animateTick(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,20 +30,29 @@ void signal_callback_handler(int signum) {
|
|||||||
int main(int numArguments, char* pszArgs[]) {
|
int main(int numArguments, char* pszArgs[]) {
|
||||||
ArgumentsSettings aSettings(numArguments, pszArgs);
|
ArgumentsSettings aSettings(numArguments, pszArgs);
|
||||||
if(aSettings.getShowHelp()) {
|
if(aSettings.getShowHelp()) {
|
||||||
|
// TODO: Map with args and print it with std::cout and for loop
|
||||||
|
// TODO: World size setting
|
||||||
|
|
||||||
ArgumentsSettings defaultSettings(0, NULL);
|
ArgumentsSettings defaultSettings(0, NULL);
|
||||||
|
|
||||||
printf("Minecraft Pockect Edition Server %s\n", Common::getGameVersionString("").c_str());
|
printf("Minecraft Pockect Edition Server %s\n", Common::getGameVersionString("").c_str());
|
||||||
printf("-------------------------------------------------------\n");
|
printf("-------------------------------------------------------\n");
|
||||||
|
|
||||||
printf("--cachepath - Path to where the server can store temp stuff (not sure if this is used) [default: \"%s\"]\n", defaultSettings.getCachePath().c_str());
|
printf("--cachepath - Path to where the server can store temp stuff (not sure if this is used) [default: \"%s\"]\n", defaultSettings.getCachePath().c_str());
|
||||||
printf("--externalpath - The path to the place where the server should store the levels. [default: \"%s\"]\n", defaultSettings.getExternalPath().c_str());
|
printf("--externalpath - The path to the place where the server should store the levels. [default: \"%s\"]\n", defaultSettings.getExternalPath().c_str());
|
||||||
printf("--levelname - The name of the server [default: \"%s\"]\n", defaultSettings.getLevelName().c_str());
|
printf("--levelname - The name of the server [default: \"%s\"]\n", defaultSettings.getLevelName().c_str());
|
||||||
|
printf("--gamemode - The name of the gamemode [default: \"%s\"]\n", defaultSettings.getGamemode().c_str());
|
||||||
printf("--leveldir - The name of the server [default: \"%s\"]\n", defaultSettings.getLevelDir().c_str());
|
printf("--leveldir - The name of the server [default: \"%s\"]\n", defaultSettings.getLevelDir().c_str());
|
||||||
printf("--help - Shows this message.\n");
|
printf("--help - Shows this message.\n");
|
||||||
printf("--port - The port to run the server on. [default: %d]\n", defaultSettings.getPort());
|
printf("--port - The port to run the server on. [default: %d]\n", defaultSettings.getPort());
|
||||||
printf("--serverkey - The key that the server should use for API calls. [default: \"%s\"]\n", defaultSettings.getServerKey().c_str());
|
printf("--serverkey - The key that the server should use for API calls. [default: \"%s\"]\n", defaultSettings.getServerKey().c_str());
|
||||||
|
|
||||||
printf("-------------------------------------------------------\n");
|
printf("-------------------------------------------------------\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
printf("Level Name: %s\n", aSettings.getLevelName().c_str());
|
printf("Level Name: %s\n", aSettings.getLevelName().c_str());
|
||||||
|
|
||||||
AppContext appContext;
|
AppContext appContext;
|
||||||
appContext.platform = new AppPlatform();
|
appContext.platform = new AppPlatform();
|
||||||
App* app = new MAIN_CLASS();
|
App* app = new MAIN_CLASS();
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ void ClientSideNetworkHandler::onUnableToConnect()
|
|||||||
|
|
||||||
void ClientSideNetworkHandler::onDisconnect(const RakNet::RakNetGUID& guid)
|
void ClientSideNetworkHandler::onDisconnect(const RakNet::RakNetGUID& guid)
|
||||||
{
|
{
|
||||||
|
// TODO: Good disconnecting
|
||||||
LOGI("onDisconnect\n");
|
LOGI("onDisconnect\n");
|
||||||
if (level)
|
if (level)
|
||||||
{
|
{
|
||||||
@@ -352,6 +353,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, AddItemE
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, TakeItemEntityPacket* packet) {
|
void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, TakeItemEntityPacket* packet) {
|
||||||
|
printf("TakeItemEntityPacket \n");
|
||||||
if (!level) return;
|
if (!level) return;
|
||||||
|
|
||||||
Entity* e = level->getEntity(packet->itemId);
|
Entity* e = level->getEntity(packet->itemId);
|
||||||
@@ -397,7 +399,6 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MovePlay
|
|||||||
void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, SendInventoryPacket* packet) {
|
void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, SendInventoryPacket* packet) {
|
||||||
if (!level) return;
|
if (!level) return;
|
||||||
|
|
||||||
// TODO: Linked slots
|
|
||||||
if (packet->entityId == minecraft->player->entityId) {
|
if (packet->entityId == minecraft->player->entityId) {
|
||||||
auto items = packet->items;
|
auto items = packet->items;
|
||||||
|
|
||||||
@@ -852,6 +853,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& source, SetHealt
|
|||||||
if (!level || !minecraft->player)
|
if (!level || !minecraft->player)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
printf("SetHealthPacket \n");
|
||||||
minecraft->player->hurtTo(packet->health);
|
minecraft->player->hurtTo(packet->health);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "world/item/crafting/Recipe.h"
|
#include "world/item/crafting/Recipe.h"
|
||||||
#include "world/item/crafting/Recipes.h"
|
#include "world/item/crafting/Recipes.h"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdio>
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
#include "../client/sound/SoundEngine.h"
|
#include "../client/sound/SoundEngine.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -410,18 +411,23 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MovePlay
|
|||||||
{
|
{
|
||||||
ServerPlayer* player = (ServerPlayer*) getPlayer(source);
|
ServerPlayer* player = (ServerPlayer*) getPlayer(source);
|
||||||
|
|
||||||
float vectorDist = sqrt( (packet->x - entity->x) * (packet->x - entity->x) +
|
// float vectorDist = sqrt( (packet->x - entity->x) * (packet->x - entity->x) +
|
||||||
(packet->y - entity->y) * (packet->y - entity->y) +
|
// (packet->y - entity->y) * (packet->y - entity->y) +
|
||||||
(packet->z - entity->z) * (packet->z - entity->z));
|
// (packet->z - entity->z) * (packet->z - entity->z));
|
||||||
float speed = vectorDist / (minecraft->getTicks() - player->getLastMoveTicks());
|
// float speed = vectorDist / (minecraft->getTicks() - player->getLastMoveTicks());
|
||||||
|
|
||||||
if (speed < 2.5f) {
|
|
||||||
entity->xd = entity->yd = entity->zd = 0;
|
|
||||||
entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3);
|
|
||||||
|
|
||||||
|
// TODO: Replace with Entity::move()
|
||||||
|
// if (speed < 2.5f) {
|
||||||
|
printf("Packet do: %f, %f, %f \n", packet->x, packet->y, packet->z);
|
||||||
|
printf("Entity do: %f, %f, %f \n", entity->x, entity->y, entity->z);
|
||||||
|
printf("Delta: %f %f %f \n", packet->x - entity->x, packet->y - entity->y, packet->z - entity->z);
|
||||||
|
player->xd = player->yd = player->zd = 0;
|
||||||
|
player->move(packet->x - entity->x, packet->y - entity->y, packet->z - entity->z);
|
||||||
|
printf("Entity after: %f, %f, %f \n", entity->x, entity->y, entity->z);
|
||||||
|
// entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3);
|
||||||
// broadcast this packet to other clients
|
// broadcast this packet to other clients
|
||||||
redistributePacket(packet, source);
|
redistributePacket(packet, source);
|
||||||
}
|
//}
|
||||||
|
|
||||||
player->setLastMoveTicks(minecraft->getTicks());
|
player->setLastMoveTicks(minecraft->getTicks());
|
||||||
}
|
}
|
||||||
@@ -459,7 +465,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, RemoveBl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//oldTile->spawnResources(level, x, y, z, data, 1); //@todo
|
// oldTile->spawnResources(level, x, y, z, data, 1); //@todo
|
||||||
oldTile->playerDestroy(level, player, x, y, z, data);
|
oldTile->playerDestroy(level, player, x, y, z, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -934,19 +940,19 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, Containe
|
|||||||
|
|
||||||
void ServerSideNetworkHandler::handle( const RakNet::RakNetGUID& source, SetHealthPacket* packet )
|
void ServerSideNetworkHandler::handle( const RakNet::RakNetGUID& source, SetHealthPacket* packet )
|
||||||
{
|
{
|
||||||
LOGI("SetHealthPacket\n");
|
LOGI("net idi nahui\n");
|
||||||
|
|
||||||
for (unsigned int i = 0; i < level->players.size(); ++i) {
|
// for (unsigned int i = 0; i < level->players.size(); ++i) {
|
||||||
Player* p = level->players[i];
|
// Player* p = level->players[i];
|
||||||
if (p->owner == source) {
|
// if (p->owner == source) {
|
||||||
if (packet->health <= -32) {
|
// if (packet->health <= -32) {
|
||||||
int diff = packet->health - SetHealthPacket::HEALTH_MODIFY_OFFSET;
|
// int diff = packet->health - SetHealthPacket::HEALTH_MODIFY_OFFSET;
|
||||||
if (diff > 0) p->hurt(NULL, diff);
|
// if (diff > 0) p->hurt(NULL, diff);
|
||||||
else if (diff < 0) p->heal(-diff);
|
// else if (diff < 0) p->heal(-diff);
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerSideNetworkHandler::handle( const RakNet::RakNetGUID& source, SignUpdatePacket* packet ) {
|
void ServerSideNetworkHandler::handle( const RakNet::RakNetGUID& source, SignUpdatePacket* packet ) {
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ ArgumentsSettings::ArgumentsSettings(int numArguments, char** arguments)
|
|||||||
levelName = std::string(arguments[a+1]);
|
levelName = std::string(arguments[a+1]);
|
||||||
a++; // Skip the next argument since it's part of this one.
|
a++; // Skip the next argument since it's part of this one.
|
||||||
}
|
}
|
||||||
|
} else if(strcmp(arguments[a], "--gamemode") == 0) {
|
||||||
|
if(a + 1 < numArguments) {
|
||||||
|
gamemode = std::string(arguments[a+1]);
|
||||||
|
a++; // Skip the next argument since it's part of this one.
|
||||||
|
}
|
||||||
} else if(strcmp(arguments[a], "--leveldir") == 0) {
|
} else if(strcmp(arguments[a], "--leveldir") == 0) {
|
||||||
if(a + 1 < numArguments) {
|
if(a + 1 < numArguments) {
|
||||||
levelDir = std::string(arguments[a+1]);
|
levelDir = std::string(arguments[a+1]);
|
||||||
@@ -51,6 +56,9 @@ std::string ArgumentsSettings::getServerKey() {
|
|||||||
std::string ArgumentsSettings::getCachePath() {
|
std::string ArgumentsSettings::getCachePath() {
|
||||||
return cachePath;
|
return cachePath;
|
||||||
}
|
}
|
||||||
|
std::string ArgumentsSettings::getGamemode() {
|
||||||
|
return gamemode;
|
||||||
|
}
|
||||||
std::string ArgumentsSettings::getLevelDir() {
|
std::string ArgumentsSettings::getLevelDir() {
|
||||||
return levelDir;
|
return levelDir;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,20 +4,27 @@
|
|||||||
class ArgumentsSettings {
|
class ArgumentsSettings {
|
||||||
public:
|
public:
|
||||||
ArgumentsSettings(int numArguments, char** arguments);
|
ArgumentsSettings(int numArguments, char** arguments);
|
||||||
|
|
||||||
std::string getExternalPath();
|
std::string getExternalPath();
|
||||||
std::string getLevelName();
|
std::string getLevelName();
|
||||||
std::string getServerKey();
|
std::string getServerKey();
|
||||||
std::string getCachePath();
|
std::string getCachePath();
|
||||||
std::string getLevelDir();
|
std::string getLevelDir();
|
||||||
|
std::string getGamemode();
|
||||||
|
|
||||||
bool getShowHelp();
|
bool getShowHelp();
|
||||||
|
|
||||||
int getPort();
|
int getPort();
|
||||||
private:
|
private:
|
||||||
std::string cachePath;
|
std::string cachePath;
|
||||||
std::string externalPath;
|
std::string externalPath;
|
||||||
std::string levelName;
|
std::string levelName;
|
||||||
|
std::string gamemode;
|
||||||
std::string levelDir;
|
std::string levelDir;
|
||||||
std::string serverKey;
|
std::string serverKey;
|
||||||
|
|
||||||
bool showHelp;
|
bool showHelp;
|
||||||
|
|
||||||
int port;
|
int port;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ void ServerPlayer::take( Entity* e, int orgCount ) {
|
|||||||
TakeItemEntityPacket packet(e->entityId, entityId);
|
TakeItemEntityPacket packet(e->entityId, entityId);
|
||||||
// SendInventoryPacket packet(this, false);
|
// SendInventoryPacket packet(this, false);
|
||||||
_mc->raknetInstance->send(packet);
|
_mc->raknetInstance->send(packet);
|
||||||
|
printf("TakeItemEntityPacket \n");
|
||||||
|
|
||||||
LOGI("Inventory:\n");
|
LOGI("Inventory:\n");
|
||||||
for (int i = 0; i < inventory->numLinkedSlots; i++) {
|
for (int i = 0; i < inventory->numLinkedSlots; i++) {
|
||||||
@@ -174,3 +175,12 @@ void ServerPlayer::displayClientMessage( const std::string& messageId ) {
|
|||||||
ChatPacket package(messageId);
|
ChatPacket package(messageId);
|
||||||
_mc->raknetInstance->send(owner, package);
|
_mc->raknetInstance->send(owner, package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerPlayer::causeFallDamage(float distance) {
|
||||||
|
int dmg = (int) ceil((distance - 3));
|
||||||
|
if (dmg > 0) {
|
||||||
|
SetHealthPacket packet(SetHealthPacket::HEALTH_MODIFY_OFFSET + dmg);
|
||||||
|
_mc->raknetInstance->send(owner, packet);
|
||||||
|
}
|
||||||
|
super::causeFallDamage(distance);
|
||||||
|
}
|
||||||
@@ -52,6 +52,8 @@ public:
|
|||||||
|
|
||||||
void setNewProto(bool proto) { isNewProto = proto; }
|
void setNewProto(bool proto) { isNewProto = proto; }
|
||||||
bool getProto() { return isNewProto; }
|
bool getProto() { return isNewProto; }
|
||||||
|
|
||||||
|
virtual void causeFallDamage(float distance);
|
||||||
private:
|
private:
|
||||||
void nextContainerCounter();
|
void nextContainerCounter();
|
||||||
void setContainerMenu( BaseContainerMenu* menu );
|
void setContainerMenu( BaseContainerMenu* menu );
|
||||||
|
|||||||
Reference in New Issue
Block a user