mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
TU19: merge Minecraft.Client/Player
This commit is contained in:
parent
3f143811e3
commit
a493e42532
|
|
@ -18,6 +18,7 @@
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.network.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.network.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.dimension.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.dimension.h"
|
||||||
#include "../../Minecraft.World/Util/BasicTypeContainers.h"
|
#include "../../Minecraft.World/Util/BasicTypeContainers.h"
|
||||||
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
|
||||||
#include "../Network/PlayerConnection.h"
|
#include "../Network/PlayerConnection.h"
|
||||||
|
|
||||||
EntityTracker::EntityTracker(ServerLevel* level) {
|
EntityTracker::EntityTracker(ServerLevel* level) {
|
||||||
|
|
@ -26,7 +27,7 @@ EntityTracker::EntityTracker(ServerLevel* level) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTracker::addEntity(std::shared_ptr<Entity> e) {
|
void EntityTracker::addEntity(std::shared_ptr<Entity> e) {
|
||||||
if (e->GetType() == eTYPE_SERVERPLAYER) {
|
if (e->instanceof(eTYPE_SERVERPLAYER)) {
|
||||||
addEntity(e, 32 * 16, 2);
|
addEntity(e, 32 * 16, 2);
|
||||||
std::shared_ptr<ServerPlayer> player =
|
std::shared_ptr<ServerPlayer> player =
|
||||||
std::dynamic_pointer_cast<ServerPlayer>(e);
|
std::dynamic_pointer_cast<ServerPlayer>(e);
|
||||||
|
|
@ -35,51 +36,57 @@ void EntityTracker::addEntity(std::shared_ptr<Entity> e) {
|
||||||
(*it)->updatePlayer(this, player);
|
(*it)->updatePlayer(this, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (e->GetType() == eTYPE_FISHINGHOOK)
|
} else if (e->instanceof(eTYPE_FISHINGHOOK))
|
||||||
addEntity(e, 16 * 4, 5, true);
|
addEntity(e, 16 * 4, 5, true);
|
||||||
else if (e->GetType() == eTYPE_SMALL_FIREBALL)
|
else if (e->instanceof(eTYPE_SMALL_FIREBALL))
|
||||||
addEntity(e, 16 * 4, 10, false);
|
addEntity(e, 16 * 4, 10, false);
|
||||||
else if (e->GetType() == eTYPE_DRAGON_FIREBALL)
|
else if (e->instanceof(eTYPE_DRAGON_FIREBALL))
|
||||||
addEntity(e, 16 * 4, 10, false); // 4J Added TU9
|
addEntity(e, 16 * 4, 10, false); // 4J Added TU9
|
||||||
else if (e->GetType() == eTYPE_ARROW)
|
else if (e->instanceof(eTYPE_ARROW))
|
||||||
addEntity(e, 16 * 4, 20, false);
|
addEntity(e, 16 * 4, 20, false);
|
||||||
else if (e->GetType() == eTYPE_FIREBALL)
|
else if (e->instanceof(eTYPE_FIREBALL))
|
||||||
addEntity(e, 16 * 4, 10, false);
|
addEntity(e, 16 * 4, 10, false);
|
||||||
else if (e->GetType() == eTYPE_SNOWBALL)
|
else if (e->instanceof(eTYPE_SNOWBALL))
|
||||||
addEntity(e, 16 * 4, 10, true);
|
addEntity(e, 16 * 4, 10, true);
|
||||||
else if (e->GetType() == eTYPE_THROWNENDERPEARL)
|
else if (e->instanceof(eTYPE_THROWNENDERPEARL))
|
||||||
addEntity(e, 16 * 4, 10, true);
|
addEntity(e, 16 * 4, 10, true);
|
||||||
else if (e->GetType() == eTYPE_EYEOFENDERSIGNAL)
|
else if (e->instanceof(eTYPE_EYEOFENDERSIGNAL))
|
||||||
addEntity(e, 16 * 4, 4, true);
|
addEntity(e, 16 * 4, 4, true);
|
||||||
else if (e->GetType() == eTYPE_THROWNEGG)
|
else if (e->instanceof(eTYPE_THROWNEGG))
|
||||||
addEntity(e, 16 * 4, 10, true);
|
addEntity(e, 16 * 4, 10, true);
|
||||||
else if (e->GetType() == eTYPE_THROWNPOTION)
|
else if (e->instanceof(eTYPE_THROWNPOTION))
|
||||||
addEntity(e, 16 * 4, 10, true);
|
addEntity(e, 16 * 4, 10, true);
|
||||||
else if (e->GetType() == eTYPE_THROWNEXPBOTTLE)
|
else if (e->instanceof(eTYPE_THROWNEXPBOTTLE))
|
||||||
addEntity(e, 16 * 4, 10, true);
|
addEntity(e, 16 * 4, 10, true);
|
||||||
else if (e->GetType() == eTYPE_ITEMENTITY)
|
else if (e->instanceof(eTYPE_FIREWORKS_ROCKET))
|
||||||
|
addEntity(e, 16 * 4, 10, true);
|
||||||
|
else if (e->instanceof(eTYPE_ITEMENTITY))
|
||||||
addEntity(e, 16 * 4, 20, true);
|
addEntity(e, 16 * 4, 20, true);
|
||||||
else if (e->GetType() == eTYPE_MINECART)
|
else if (e->instanceof(eTYPE_MINECART))
|
||||||
addEntity(e, 16 * 5, 3, true);
|
addEntity(e, 16 * 5, 3, true);
|
||||||
else if (e->GetType() == eTYPE_BOAT)
|
else if (e->instanceof(eTYPE_BOAT))
|
||||||
addEntity(e, 16 * 5, 3, true);
|
addEntity(e, 16 * 5, 3, true);
|
||||||
else if (e->GetType() == eTYPE_SQUID)
|
else if (e->instanceof(eTYPE_SQUID))
|
||||||
addEntity(e, 16 * 4, 3, true);
|
addEntity(e, 16 * 4, 3, true);
|
||||||
|
else if (e->instanceof(eTYPE_WITHERBOSS))
|
||||||
|
addEntity(e, 16 * 5, 3, false);
|
||||||
|
else if (e->instanceof(eTYPE_BAT))
|
||||||
|
addEntity(e, 16 * 5, 3, false);
|
||||||
else if (std::dynamic_pointer_cast<Creature>(e) != NULL)
|
else if (std::dynamic_pointer_cast<Creature>(e) != NULL)
|
||||||
addEntity(e, 16 * 5, 3, true);
|
addEntity(e, 16 * 5, 3, true);
|
||||||
else if (e->GetType() == eTYPE_ENDERDRAGON)
|
else if (e->instanceof(eTYPE_ENDERDRAGON))
|
||||||
addEntity(e, 16 * 10, 3, true);
|
addEntity(e, 16 * 10, 3, true);
|
||||||
else if (e->GetType() == eTYPE_PRIMEDTNT)
|
else if (e->instanceof(eTYPE_PRIMEDTNT))
|
||||||
addEntity(e, 16 * 10, 10, true);
|
addEntity(e, 16 * 10, 10, true);
|
||||||
else if (e->GetType() == eTYPE_FALLINGTILE)
|
else if (e->instanceof(eTYPE_FALLINGTILE))
|
||||||
addEntity(e, 16 * 10, 20, true);
|
addEntity(e, 16 * 10, 20, true);
|
||||||
else if (e->GetType() == eTYPE_PAINTING)
|
else if (e->instanceof(eTYPE_HANGING_ENTITY))
|
||||||
addEntity(e, 16 * 10, INT_MAX, false);
|
addEntity(e, 16 * 10, INT_MAX, false);
|
||||||
else if (e->GetType() == eTYPE_EXPERIENCEORB)
|
else if (e->instanceof(eTYPE_EXPERIENCEORB))
|
||||||
addEntity(e, 16 * 10, 20, true);
|
addEntity(e, 16 * 10, 20, true);
|
||||||
else if (e->GetType() == eTYPE_ENDER_CRYSTAL)
|
else if (e->instanceof(eTYPE_ENDER_CRYSTAL))
|
||||||
addEntity(e, 16 * 16, INT_MAX, false);
|
addEntity(e, 16 * 16, INT_MAX, false);
|
||||||
else if (e->GetType() == eTYPE_ITEM_FRAME)
|
else if (e->instanceof(eTYPE_ITEM_FRAME))
|
||||||
addEntity(e, 16 * 10, INT_MAX, false);
|
addEntity(e, 16 * 10, INT_MAX, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,6 +132,10 @@ void EntityTracker::removePlayer(std::shared_ptr<Entity> e) {
|
||||||
for (AUTO_VAR(it, entities.begin()); it != entities.end(); it++) {
|
for (AUTO_VAR(it, entities.begin()); it != entities.end(); it++) {
|
||||||
(*it)->removePlayer(player);
|
(*it)->removePlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 4J: Flush now to ensure remove packets are sent before player
|
||||||
|
// respawns and add entity packets are sent
|
||||||
|
player->flushEntitiesToRemove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,6 +227,17 @@ void EntityTracker::clear(std::shared_ptr<ServerPlayer> serverPlayer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityTracker::playerLoadedChunk(std::shared_ptr<ServerPlayer> player,
|
||||||
|
LevelChunk* chunk) {
|
||||||
|
for (AUTO_VAR(it, entities.begin()); it != entities.end(); ++it) {
|
||||||
|
std::shared_ptr<TrackedEntity> te = *it;
|
||||||
|
if (te->e != player && te->e->xChunk == chunk->x &&
|
||||||
|
te->e->zChunk == chunk->z) {
|
||||||
|
te->updatePlayer(this, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// AP added for Vita so the range can be increased once the level starts
|
// AP added for Vita so the range can be increased once the level starts
|
||||||
void EntityTracker::updateMaxRange() {
|
void EntityTracker::updateMaxRange() {
|
||||||
maxRange = level->getServer()->getPlayers()->getMaxRange();
|
maxRange = level->getServer()->getPlayers()->getMaxRange();
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ public:
|
||||||
void broadcastAndSend(std::shared_ptr<Entity> e,
|
void broadcastAndSend(std::shared_ptr<Entity> e,
|
||||||
std::shared_ptr<Packet> packet);
|
std::shared_ptr<Packet> packet);
|
||||||
void clear(std::shared_ptr<ServerPlayer> serverPlayer);
|
void clear(std::shared_ptr<ServerPlayer> serverPlayer);
|
||||||
|
void playerLoadedChunk(std::shared_ptr<ServerPlayer> player,
|
||||||
|
LevelChunk* chunk);
|
||||||
void updateMaxRange(); // AP added for Vita
|
void updateMaxRange(); // AP added for Vita
|
||||||
|
|
||||||
// 4J-JEV: Added, needed access to tracked entity of a riders mount.
|
// 4J-JEV: Added, needed access to tracked entity of a riders mount.
|
||||||
|
|
|
||||||
|
|
@ -16,18 +16,22 @@
|
||||||
#include "../GameState/CreativeMode.h"
|
#include "../GameState/CreativeMode.h"
|
||||||
#include "../Rendering/GameRenderer.h"
|
#include "../Rendering/GameRenderer.h"
|
||||||
#include "../Rendering/EntityRenderers/ItemInHandRenderer.h"
|
#include "../Rendering/EntityRenderers/ItemInHandRenderer.h"
|
||||||
|
#include "../../Minecraft.World/AI/Attributes/AttributeInstance.h"
|
||||||
#include "../../Minecraft.World/Level/LevelData.h"
|
#include "../../Minecraft.World/Level/LevelData.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.damagesource.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.damagesource.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.item.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.item.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.food.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.food.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.effect.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.effect.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.player.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.player.h"
|
||||||
|
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.monster.h"
|
||||||
#include "../../Minecraft.World/Entities/ItemEntity.h"
|
#include "../../Minecraft.World/Entities/ItemEntity.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||||
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.phys.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.phys.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.stats.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.stats.h"
|
||||||
#include "../../Minecraft.World/Headers/com.mojang.nbt.h"
|
#include "../../Minecraft.World/Headers/com.mojang.nbt.h"
|
||||||
#include "../../Minecraft.World/Util/Random.h"
|
#include "../../Minecraft.World/Util/Random.h"
|
||||||
|
#include "../../Minecraft.World/Blocks/TileEntities/TileEntity.h"
|
||||||
#include "../../Minecraft.World/Util/Mth.h"
|
#include "../../Minecraft.World/Util/Mth.h"
|
||||||
#include "../UI/Screens/AchievementPopup.h"
|
#include "../UI/Screens/AchievementPopup.h"
|
||||||
#include "../Rendering/Particles/CritParticle.h"
|
#include "../Rendering/Particles/CritParticle.h"
|
||||||
|
|
@ -55,7 +59,7 @@
|
||||||
|
|
||||||
LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user,
|
LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user,
|
||||||
int dimension)
|
int dimension)
|
||||||
: Player(level) {
|
: Player(level, user->name) {
|
||||||
flyX = flyY = flyZ = 0.0f; // 4J added
|
flyX = flyY = flyZ = 0.0f; // 4J added
|
||||||
m_awardedThisSession = 0;
|
m_awardedThisSession = 0;
|
||||||
|
|
||||||
|
|
@ -64,6 +68,10 @@ LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user,
|
||||||
twoJumpsRegistered = false;
|
twoJumpsRegistered = false;
|
||||||
sprintTime = 0;
|
sprintTime = 0;
|
||||||
m_uiInactiveTicks = 0;
|
m_uiInactiveTicks = 0;
|
||||||
|
portalTime = 0.0f;
|
||||||
|
oPortalTime = 0.0f;
|
||||||
|
jumpRidingTicks = 0;
|
||||||
|
jumpRidingScale = 0.0f;
|
||||||
|
|
||||||
yBob = xBob = yBobO = xBobO = 0.0f;
|
yBob = xBob = yBobO = xBobO = 0.0f;
|
||||||
|
|
||||||
|
|
@ -76,7 +84,6 @@ LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user,
|
||||||
}
|
}
|
||||||
if (user != NULL) {
|
if (user != NULL) {
|
||||||
this->name = user->name;
|
this->name = user->name;
|
||||||
m_UUID = name;
|
|
||||||
// wprintf(L"Created LocalPlayer with name %ls\n", name.c_str() );
|
// wprintf(L"Created LocalPlayer with name %ls\n", name.c_str() );
|
||||||
// check to see if this player's xuid is in the list of special players
|
// check to see if this player's xuid is in the list of special players
|
||||||
MOJANG_DATA* pMojangData = app.GetMojangDataForXuid(getOnlineXuid());
|
MOJANG_DATA* pMojangData = app.GetMojangDataForXuid(getOnlineXuid());
|
||||||
|
|
@ -116,28 +123,6 @@ LocalPlayer::~LocalPlayer() {
|
||||||
if (this->input != NULL) delete input;
|
if (this->input != NULL) delete input;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J - added noEntityCubes parameter
|
|
||||||
void LocalPlayer::move(double xa, double ya, double za, bool noEntityCubes) {
|
|
||||||
if (ClientConstants::DEADMAU5_CAMERA_CHEATS) {
|
|
||||||
if (shared_from_this() == minecraft->player &&
|
|
||||||
minecraft->options->isFlying) {
|
|
||||||
noPhysics = true;
|
|
||||||
float tmp = walkDist; // update
|
|
||||||
calculateFlight((float)xa, (float)ya, (float)za);
|
|
||||||
fallDistance = 0.0f;
|
|
||||||
yd = 0.0f;
|
|
||||||
Player::move(flyX, flyY, flyZ, noEntityCubes);
|
|
||||||
onGround = true;
|
|
||||||
walkDist = tmp;
|
|
||||||
} else {
|
|
||||||
noPhysics = false;
|
|
||||||
Player::move(xa, ya, za, noEntityCubes);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Player::move(xa, ya, za, noEntityCubes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocalPlayer::calculateFlight(float xa, float ya, float za) {
|
void LocalPlayer::calculateFlight(float xa, float ya, float za) {
|
||||||
xa = xa * minecraft->options->flySpeed;
|
xa = xa * minecraft->options->flySpeed;
|
||||||
ya = 0;
|
ya = 0;
|
||||||
|
|
@ -193,7 +178,7 @@ void LocalPlayer::serverAiStep() {
|
||||||
// mapPlayerChunk(8);
|
// mapPlayerChunk(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalPlayer::isEffectiveAI() { return true; }
|
bool LocalPlayer::isEffectiveAi() { return true; }
|
||||||
|
|
||||||
void LocalPlayer::aiStep() {
|
void LocalPlayer::aiStep() {
|
||||||
if (sprintTime > 0) {
|
if (sprintTime > 0) {
|
||||||
|
|
@ -248,7 +233,7 @@ void LocalPlayer::aiStep() {
|
||||||
// input->tick( std::dynamic_pointer_cast<Player>( shared_from_this() ) );
|
// input->tick( std::dynamic_pointer_cast<Player>( shared_from_this() ) );
|
||||||
// 4J-PB - make it a localplayer
|
// 4J-PB - make it a localplayer
|
||||||
input->tick(this);
|
input->tick(this);
|
||||||
if (isUsingItem()) {
|
if (isUsingItem() && !isRiding()) {
|
||||||
input->xa *= 0.2f;
|
input->xa *= 0.2f;
|
||||||
input->ya *= 0.2f;
|
input->ya *= 0.2f;
|
||||||
sprintTriggerTime = 0;
|
sprintTriggerTime = 0;
|
||||||
|
|
@ -373,6 +358,36 @@ void LocalPlayer::aiStep() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRidingJumpable()) {
|
||||||
|
if (jumpRidingTicks < 0) {
|
||||||
|
jumpRidingTicks++;
|
||||||
|
if (jumpRidingTicks == 0) {
|
||||||
|
// reset scale (for gui)
|
||||||
|
jumpRidingScale = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wasJumping && !input->jumping) {
|
||||||
|
// jump release
|
||||||
|
jumpRidingTicks = -10;
|
||||||
|
sendRidingJump();
|
||||||
|
} else if (!wasJumping && input->jumping) {
|
||||||
|
// jump press
|
||||||
|
jumpRidingTicks = 0;
|
||||||
|
jumpRidingScale = 0;
|
||||||
|
} else if (wasJumping) {
|
||||||
|
// calc jump scale
|
||||||
|
jumpRidingTicks++;
|
||||||
|
if (jumpRidingTicks < 10) {
|
||||||
|
jumpRidingScale = (float)jumpRidingTicks * .1f;
|
||||||
|
} else {
|
||||||
|
jumpRidingScale =
|
||||||
|
.8f + (2.f / ((float)(jumpRidingTicks - 9))) * .1f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
jumpRidingScale = 0;
|
||||||
|
}
|
||||||
|
|
||||||
Player::aiStep();
|
Player::aiStep();
|
||||||
|
|
||||||
// 4J-PB - If we're in Creative Mode, allow flying on ground
|
// 4J-PB - If we're in Creative Mode, allow flying on ground
|
||||||
|
|
@ -491,8 +506,10 @@ float LocalPlayer::getFieldOfViewModifier() {
|
||||||
|
|
||||||
// modify for movement
|
// modify for movement
|
||||||
if (abilities.flying) targetFov *= 1.1f;
|
if (abilities.flying) targetFov *= 1.1f;
|
||||||
targetFov *=
|
|
||||||
((walkingSpeed * getWalkingSpeedModifier()) / defaultWalkSpeed + 1) / 2;
|
AttributeInstance* speed =
|
||||||
|
getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED);
|
||||||
|
targetFov *= (speed->getValue() / abilities.getWalkingSpeed() + 1) / 2;
|
||||||
|
|
||||||
// modify for bow =)
|
// modify for bow =)
|
||||||
if (isUsingItem() && getUseItem()->id == Item::bow->id) {
|
if (isUsingItem() && getUseItem()->id == Item::bow->id) {
|
||||||
|
|
@ -511,12 +528,12 @@ float LocalPlayer::getFieldOfViewModifier() {
|
||||||
|
|
||||||
void LocalPlayer::addAdditonalSaveData(CompoundTag* entityTag) {
|
void LocalPlayer::addAdditonalSaveData(CompoundTag* entityTag) {
|
||||||
Player::addAdditonalSaveData(entityTag);
|
Player::addAdditonalSaveData(entityTag);
|
||||||
entityTag->putInt(L"Score", score);
|
// entityTag->putInt(L"Score", score);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::readAdditionalSaveData(CompoundTag* entityTag) {
|
void LocalPlayer::readAdditionalSaveData(CompoundTag* entityTag) {
|
||||||
Player::readAdditionalSaveData(entityTag);
|
Player::readAdditionalSaveData(entityTag);
|
||||||
score = entityTag->getInt(L"Score");
|
// score = entityTag->getInt(L"Score");
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::closeContainer() {
|
void LocalPlayer::closeContainer() {
|
||||||
|
|
@ -530,12 +547,23 @@ void LocalPlayer::closeContainer() {
|
||||||
ui.CloseUIScenes(m_iPad);
|
ui.CloseUIScenes(m_iPad);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::openTextEdit(std::shared_ptr<SignTileEntity> sign) {
|
void LocalPlayer::openTextEdit(std::shared_ptr<TileEntity> tileEntity) {
|
||||||
#ifdef ENABLE_JAVA_GUIS
|
#ifdef ENABLE_JAVA_GUIS
|
||||||
minecraft->setScreen(new TextEditScreen(sign));
|
minecraft->setScreen(new TextEditScreen(sign));
|
||||||
bool success = true;
|
bool success = true;
|
||||||
#else
|
#else
|
||||||
bool success = app.LoadSignEntryMenu(GetXboxPad(), sign);
|
bool success;
|
||||||
|
|
||||||
|
if (tileEntity->GetType() == eTYPE_SIGNTILEENTITY) {
|
||||||
|
success = app.LoadSignEntryMenu(
|
||||||
|
GetXboxPad(),
|
||||||
|
std::dynamic_pointer_cast<SignTileEntity>(tileEntity));
|
||||||
|
} else if (tileEntity->GetType() == eTYPE_COMMANDBLOCKTILEENTITY) {
|
||||||
|
success = app.LoadCommandBlockMenu(
|
||||||
|
GetXboxPad(),
|
||||||
|
std::dynamic_pointer_cast<CommandBlockEntity>(tileEntity));
|
||||||
|
}
|
||||||
|
|
||||||
if (success) ui.PlayUISFX(eSFX_Press);
|
if (success) ui.PlayUISFX(eSFX_Press);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -548,6 +576,30 @@ bool LocalPlayer::openContainer(std::shared_ptr<Container> container) {
|
||||||
bool success = app.LoadContainerMenu(GetXboxPad(), inventory, container);
|
bool success = app.LoadContainerMenu(GetXboxPad(), inventory, container);
|
||||||
if (success) ui.PlayUISFX(eSFX_Press);
|
if (success) ui.PlayUISFX(eSFX_Press);
|
||||||
#endif
|
#endif
|
||||||
|
// minecraft->setScreen(new ContainerScreen(inventory, container));
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalPlayer::openHopper(std::shared_ptr<HopperTileEntity> container) {
|
||||||
|
// minecraft->setScreen(new HopperScreen(inventory, container));
|
||||||
|
bool success = app.LoadHopperMenu(GetXboxPad(), inventory, container);
|
||||||
|
if (success) ui.PlayUISFX(eSFX_Press);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalPlayer::openHopper(std::shared_ptr<MinecartHopper> container) {
|
||||||
|
// minecraft->setScreen(new HopperScreen(inventory, container));
|
||||||
|
bool success = app.LoadHopperMenu(GetXboxPad(), inventory, container);
|
||||||
|
if (success) ui.PlayUISFX(eSFX_Press);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalPlayer::openHorseInventory(std::shared_ptr<EntityHorse> horse,
|
||||||
|
std::shared_ptr<Container> container) {
|
||||||
|
// minecraft->setScreen(new HorseInventoryScreen(inventory, container,
|
||||||
|
// horse));
|
||||||
|
bool success = app.LoadHorseMenu(GetXboxPad(), inventory, container, horse);
|
||||||
|
if (success) ui.PlayUISFX(eSFX_Press);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -562,12 +614,22 @@ bool LocalPlayer::startCrafting(int x, int y, int z) {
|
||||||
if (success) ui.PlayUISFX(eSFX_Press);
|
if (success) ui.PlayUISFX(eSFX_Press);
|
||||||
#endif
|
#endif
|
||||||
// app.LoadXuiCraftMenu(0,inventory, level, x, y, z);
|
// app.LoadXuiCraftMenu(0,inventory, level, x, y, z);
|
||||||
|
// minecraft->setScreen(new CraftingScreen(inventory, level, x, y, z));
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalPlayer::startEnchanting(int x, int y, int z) {
|
bool LocalPlayer::openFireworks(int x, int y, int z) {
|
||||||
|
bool success = app.LoadFireworksMenu(
|
||||||
|
GetXboxPad(),
|
||||||
|
std::dynamic_pointer_cast<LocalPlayer>(shared_from_this()), x, y, z);
|
||||||
|
if (success) ui.PlayUISFX(eSFX_Press);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalPlayer::startEnchanting(int x, int y, int z,
|
||||||
|
const std::wstring& name) {
|
||||||
bool success =
|
bool success =
|
||||||
app.LoadEnchantingMenu(GetXboxPad(), inventory, x, y, z, level);
|
app.LoadEnchantingMenu(GetXboxPad(), inventory, x, y, z, level, name);
|
||||||
if (success) ui.PlayUISFX(eSFX_Press);
|
if (success) ui.PlayUISFX(eSFX_Press);
|
||||||
// minecraft.setScreen(new EnchantmentScreen(inventory, level, x, y, z));
|
// minecraft.setScreen(new EnchantmentScreen(inventory, level, x, y, z));
|
||||||
return success;
|
return success;
|
||||||
|
|
@ -606,6 +668,13 @@ bool LocalPlayer::openBrewingStand(
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LocalPlayer::openBeacon(std::shared_ptr<BeaconTileEntity> beacon) {
|
||||||
|
// minecraft->setScreen(new BeaconScreen(inventory, beacon));
|
||||||
|
bool success = app.LoadBeaconMenu(GetXboxPad(), inventory, beacon);
|
||||||
|
if (success) ui.PlayUISFX(eSFX_Press);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
bool LocalPlayer::openTrap(std::shared_ptr<DispenserTileEntity> trap) {
|
bool LocalPlayer::openTrap(std::shared_ptr<DispenserTileEntity> trap) {
|
||||||
bool success = app.LoadTrapMenu(GetXboxPad(), inventory, trap);
|
bool success = app.LoadTrapMenu(GetXboxPad(), inventory, trap);
|
||||||
if (success) ui.PlayUISFX(eSFX_Press);
|
if (success) ui.PlayUISFX(eSFX_Press);
|
||||||
|
|
@ -613,9 +682,10 @@ bool LocalPlayer::openTrap(std::shared_ptr<DispenserTileEntity> trap) {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalPlayer::openTrading(std::shared_ptr<Merchant> traderTarget) {
|
bool LocalPlayer::openTrading(std::shared_ptr<Merchant> traderTarget,
|
||||||
|
const std::wstring& name) {
|
||||||
bool success =
|
bool success =
|
||||||
app.LoadTradingMenu(GetXboxPad(), inventory, traderTarget, level);
|
app.LoadTradingMenu(GetXboxPad(), inventory, traderTarget, level, name);
|
||||||
if (success) ui.PlayUISFX(eSFX_Press);
|
if (success) ui.PlayUISFX(eSFX_Press);
|
||||||
// minecraft.setScreen(new MerchantScreen(inventory, traderTarget, level));
|
// minecraft.setScreen(new MerchantScreen(inventory, traderTarget, level));
|
||||||
return success;
|
return success;
|
||||||
|
|
@ -645,8 +715,8 @@ void LocalPlayer::chat(const std::wstring& message) {}
|
||||||
|
|
||||||
bool LocalPlayer::isSneaking() { return input->sneaking && !m_isSleeping; }
|
bool LocalPlayer::isSneaking() { return input->sneaking && !m_isSleeping; }
|
||||||
|
|
||||||
void LocalPlayer::hurtTo(int newHealth, ETelemetryChallenges damageSource) {
|
void LocalPlayer::hurtTo(float newHealth, ETelemetryChallenges damageSource) {
|
||||||
int dmg = getHealth() - newHealth;
|
float dmg = getHealth() - newHealth;
|
||||||
if (dmg <= 0) {
|
if (dmg <= 0) {
|
||||||
setHealth(newHealth);
|
setHealth(newHealth);
|
||||||
if (dmg < 0) {
|
if (dmg < 0) {
|
||||||
|
|
@ -660,8 +730,9 @@ void LocalPlayer::hurtTo(int newHealth, ETelemetryChallenges damageSource) {
|
||||||
hurtTime = hurtDuration = 10;
|
hurtTime = hurtDuration = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->health <= 0) {
|
if (this->getHealth() <= 0) {
|
||||||
int deathTime = (int)(level->getTime() % Level::TICKS_PER_DAY) / 1000;
|
int deathTime =
|
||||||
|
(int)(level->getGameTime() % Level::TICKS_PER_DAY) / 1000;
|
||||||
int carriedId =
|
int carriedId =
|
||||||
inventory->getSelected() == NULL ? 0 : inventory->getSelected()->id;
|
inventory->getSelected() == NULL ? 0 : inventory->getSelected()->id;
|
||||||
TelemetryManager->RecordPlayerDiedOrFailed(GetXboxPad(), 0, y, 0, 0,
|
TelemetryManager->RecordPlayerDiedOrFailed(GetXboxPad(), 0, y, 0, 0,
|
||||||
|
|
@ -972,15 +1043,15 @@ void LocalPlayer::awardStat(Stat* stat, byteArray param) {
|
||||||
bool justPickedupWool = false;
|
bool justPickedupWool = false;
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
if (stat == GenericStats::itemsCollected(Tile::cloth_Id, i))
|
if (stat == GenericStats::itemsCollected(Tile::wool_Id, i))
|
||||||
justPickedupWool = true;
|
justPickedupWool = true;
|
||||||
|
|
||||||
if (justPickedupWool) {
|
if (justPickedupWool) {
|
||||||
unsigned int woolCount = 0;
|
unsigned int woolCount = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 16; i++) {
|
for (unsigned int i = 0; i < 16; i++) {
|
||||||
if (pStats->getTotalValue(GenericStats::itemsCollected(
|
if (pStats->getTotalValue(
|
||||||
Tile::cloth_Id, i)) > 0)
|
GenericStats::itemsCollected(Tile::wool_Id, i)) > 0)
|
||||||
woolCount++;
|
woolCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1084,6 +1155,33 @@ void LocalPlayer::setExperienceValues(float experienceProgress, int totalExp,
|
||||||
this->experienceLevel = experienceLevel;
|
this->experienceLevel = experienceLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 4J: removed
|
||||||
|
// void LocalPlayer::sendMessage(ChatMessageComponent *message)
|
||||||
|
//{
|
||||||
|
// minecraft->gui->getChat()->addMessage(message.toString(true));
|
||||||
|
//}
|
||||||
|
|
||||||
|
Pos LocalPlayer::getCommandSenderWorldPosition() {
|
||||||
|
return new Pos(floor(x + .5), floor(y + .5), floor(z + .5));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<ItemInstance> LocalPlayer::getCarriedItem() {
|
||||||
|
return inventory->getSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalPlayer::playSound(int soundId, float volume, float pitch) {
|
||||||
|
level->playLocalSound(x, y - heightOffset, z, soundId, volume, pitch,
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalPlayer::isRidingJumpable() {
|
||||||
|
return riding != NULL && riding->GetType() == eTYPE_HORSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
float LocalPlayer::getJumpRidingScale() { return jumpRidingScale; }
|
||||||
|
|
||||||
|
void LocalPlayer::sendRidingJump() {}
|
||||||
|
|
||||||
bool LocalPlayer::hasPermission(EGameCommand command) {
|
bool LocalPlayer::hasPermission(EGameCommand command) {
|
||||||
return level->getLevelData()->getAllowCommands();
|
return level->getLevelData()->getAllowCommands();
|
||||||
}
|
}
|
||||||
|
|
@ -1168,7 +1266,7 @@ void LocalPlayer::handleMouseDown(int button, bool down) {
|
||||||
minecraft->gameMode->continueDestroyBlock(x, y, z,
|
minecraft->gameMode->continueDestroyBlock(x, y, z,
|
||||||
minecraft->hitResult->f);
|
minecraft->hitResult->f);
|
||||||
|
|
||||||
if (mayBuild(x, y, z)) {
|
if (mayDestroyBlockAt(x, y, z)) {
|
||||||
minecraft->particleEngine->crack(x, y, z, minecraft->hitResult->f);
|
minecraft->particleEngine->crack(x, y, z, minecraft->hitResult->f);
|
||||||
swing();
|
swing();
|
||||||
}
|
}
|
||||||
|
|
@ -1449,15 +1547,12 @@ void LocalPlayer::updateRichPresence() {
|
||||||
app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_FISHING);
|
app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_FISHING);
|
||||||
} else if (selectedItem != NULL && selectedItem->id == Item::map_Id) {
|
} else if (selectedItem != NULL && selectedItem->id == Item::map_Id) {
|
||||||
app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_MAP);
|
app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_MAP);
|
||||||
} else if (riding != NULL &&
|
} else if ((riding != NULL) && riding->instanceof(eTYPE_MINECART)) {
|
||||||
std::dynamic_pointer_cast<Minecart>(riding) != NULL) {
|
|
||||||
app.SetRichPresenceContext(m_iPad,
|
app.SetRichPresenceContext(m_iPad,
|
||||||
CONTEXT_GAME_STATE_RIDING_MINECART);
|
CONTEXT_GAME_STATE_RIDING_MINECART);
|
||||||
} else if (riding != NULL &&
|
} else if ((riding != NULL) && riding->instanceof(eTYPE_BOAT)) {
|
||||||
std::dynamic_pointer_cast<Boat>(riding) != NULL) {
|
|
||||||
app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_BOATING);
|
app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_BOATING);
|
||||||
} else if (riding != NULL &&
|
} else if ((riding != NULL) && riding->instanceof(eTYPE_PIG)) {
|
||||||
std::dynamic_pointer_cast<Pig>(riding) != NULL) {
|
|
||||||
app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_RIDING_PIG);
|
app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_RIDING_PIG);
|
||||||
} else if (this->dimension == -1) {
|
} else if (this->dimension == -1) {
|
||||||
app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_NETHER);
|
app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_NETHER);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ class LocalPlayer : public Player {
|
||||||
public:
|
public:
|
||||||
static const int SPRINT_DURATION = 20 * 30;
|
static const int SPRINT_DURATION = 20 * 30;
|
||||||
|
|
||||||
|
eINSTANCEOF GetType() { return eTYPE_LOCALPLAYER; }
|
||||||
|
|
||||||
Input* input;
|
Input* input;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -42,24 +44,23 @@ public:
|
||||||
float yBob, xBob;
|
float yBob, xBob;
|
||||||
float yBobO, xBobO;
|
float yBobO, xBobO;
|
||||||
|
|
||||||
|
float portalTime;
|
||||||
|
float oPortalTime;
|
||||||
|
|
||||||
LocalPlayer(Minecraft* minecraft, Level* level, User* user, int dimension);
|
LocalPlayer(Minecraft* minecraft, Level* level, User* user, int dimension);
|
||||||
virtual ~LocalPlayer();
|
virtual ~LocalPlayer();
|
||||||
|
|
||||||
void move(
|
|
||||||
double xa, double ya, double za,
|
|
||||||
bool noEntityCubes = false); // 4J - added noEntityCubes parameter
|
|
||||||
|
|
||||||
int m_iScreenSection; // assuming 4player splitscreen for now, or -1 for
|
int m_iScreenSection; // assuming 4player splitscreen for now, or -1 for
|
||||||
// single player
|
// single player
|
||||||
__uint64
|
uint64_t
|
||||||
ullButtonsPressed; // Stores the button presses, since the inputmanager
|
ullButtonsPressed; // Stores the button presses, since the inputmanager
|
||||||
// can be ticked faster than the minecraft player
|
// can be ticked faster than the minecraft
|
||||||
// tick, and a button press and release combo can be
|
// player tick, and a button press and release combo can be missed in the
|
||||||
// missed in the minecraft::tick
|
// minecraft::tick
|
||||||
|
|
||||||
__uint64 ullDpad_last;
|
uint64_t ullDpad_last;
|
||||||
__uint64 ullDpad_this;
|
uint64_t ullDpad_this;
|
||||||
__uint64 ullDpad_filtered;
|
uint64_t ullDpad_filtered;
|
||||||
|
|
||||||
// 4J-PB - moved these in from the minecraft structure, since they are per
|
// 4J-PB - moved these in from the minecraft structure, since they are per
|
||||||
// player things for splitscreen
|
// player things for splitscreen
|
||||||
|
|
@ -74,6 +75,9 @@ public:
|
||||||
private:
|
private:
|
||||||
float flyX, flyY, flyZ;
|
float flyX, flyY, flyZ;
|
||||||
|
|
||||||
|
int jumpRidingTicks;
|
||||||
|
float jumpRidingScale;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 4J-PB - player's xbox pad
|
// 4J-PB - player's xbox pad
|
||||||
int m_iPad;
|
int m_iPad;
|
||||||
|
|
@ -95,7 +99,7 @@ public:
|
||||||
virtual void serverAiStep();
|
virtual void serverAiStep();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool isEffectiveAI();
|
bool isEffectiveAi();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void aiStep();
|
virtual void aiStep();
|
||||||
|
|
@ -104,26 +108,38 @@ public:
|
||||||
virtual void addAdditonalSaveData(CompoundTag* entityTag);
|
virtual void addAdditonalSaveData(CompoundTag* entityTag);
|
||||||
virtual void readAdditionalSaveData(CompoundTag* entityTag);
|
virtual void readAdditionalSaveData(CompoundTag* entityTag);
|
||||||
virtual void closeContainer();
|
virtual void closeContainer();
|
||||||
virtual void openTextEdit(std::shared_ptr<SignTileEntity> sign);
|
virtual void openTextEdit(std::shared_ptr<TileEntity> sign);
|
||||||
virtual bool openContainer(
|
virtual bool openContainer(
|
||||||
std::shared_ptr<Container> container); // 4J added bool return
|
std::shared_ptr<Container> container); // 4J added bool return
|
||||||
virtual bool startCrafting(int x, int y, int z); // 4J added bool return
|
virtual bool openHopper(
|
||||||
virtual bool startEnchanting(int x, int y, int z); // 4J added bool return
|
std::shared_ptr<HopperTileEntity> container); // 4J added bool return
|
||||||
|
virtual bool openHopper(
|
||||||
|
std::shared_ptr<MinecartHopper> container); // 4J added bool return
|
||||||
|
virtual bool openHorseInventory(
|
||||||
|
std::shared_ptr<EntityHorse> horse,
|
||||||
|
std::shared_ptr<Container> container); // 4J added bool return
|
||||||
|
virtual bool startCrafting(int x, int y, int z); // 4J added bool return
|
||||||
|
virtual bool openFireworks(int x, int y, int z); // 4J added
|
||||||
|
virtual bool startEnchanting(
|
||||||
|
int x, int y, int z, const std::wstring& name); // 4J added bool return
|
||||||
virtual bool startRepairing(int x, int y, int z);
|
virtual bool startRepairing(int x, int y, int z);
|
||||||
virtual bool openFurnace(
|
virtual bool openFurnace(
|
||||||
std::shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
|
std::shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
|
||||||
virtual bool openBrewingStand(std::shared_ptr<BrewingStandTileEntity>
|
virtual bool openBrewingStand(std::shared_ptr<BrewingStandTileEntity>
|
||||||
brewingStand); // 4J added bool return
|
brewingStand); // 4J added bool return
|
||||||
|
virtual bool openBeacon(
|
||||||
|
std::shared_ptr<BeaconTileEntity> beacon); // 4J added bool return
|
||||||
virtual bool openTrap(
|
virtual bool openTrap(
|
||||||
std::shared_ptr<DispenserTileEntity> trap); // 4J added bool return
|
std::shared_ptr<DispenserTileEntity> trap); // 4J added bool return
|
||||||
virtual bool openTrading(std::shared_ptr<Merchant> traderTarget);
|
virtual bool openTrading(std::shared_ptr<Merchant> traderTarget,
|
||||||
|
const std::wstring& name);
|
||||||
virtual void crit(std::shared_ptr<Entity> e);
|
virtual void crit(std::shared_ptr<Entity> e);
|
||||||
virtual void magicCrit(std::shared_ptr<Entity> e);
|
virtual void magicCrit(std::shared_ptr<Entity> e);
|
||||||
virtual void take(std::shared_ptr<Entity> e, int orgCount);
|
virtual void take(std::shared_ptr<Entity> e, int orgCount);
|
||||||
virtual void chat(const std::wstring& message);
|
virtual void chat(const std::wstring& message);
|
||||||
virtual bool isSneaking();
|
virtual bool isSneaking();
|
||||||
// virtual bool isIdle();
|
// virtual bool isIdle();
|
||||||
virtual void hurtTo(int newHealth, ETelemetryChallenges damageSource);
|
virtual void hurtTo(float newHealth, ETelemetryChallenges damageSource);
|
||||||
virtual void respawn();
|
virtual void respawn();
|
||||||
virtual void animateRespawn();
|
virtual void animateRespawn();
|
||||||
virtual void displayClientMessage(int messageId);
|
virtual void displayClientMessage(int messageId);
|
||||||
|
|
@ -174,8 +190,8 @@ public:
|
||||||
// Minecraft.Client
|
// Minecraft.Client
|
||||||
virtual void onCrafted(std::shared_ptr<ItemInstance> item);
|
virtual void onCrafted(std::shared_ptr<ItemInstance> item);
|
||||||
|
|
||||||
virtual void setAndBroadcastCustomSkin(std::uint32_t skinId);
|
virtual void setAndBroadcastCustomSkin(DWORD skinId);
|
||||||
virtual void setAndBroadcastCustomCape(std::uint32_t capeId);
|
virtual void setAndBroadcastCustomCape(DWORD capeId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isSolidBlock(int x, int y, int z);
|
bool isSolidBlock(int x, int y, int z);
|
||||||
|
|
@ -189,6 +205,17 @@ public:
|
||||||
void setExperienceValues(float experienceProgress, int totalExp,
|
void setExperienceValues(float experienceProgress, int totalExp,
|
||||||
int experienceLevel);
|
int experienceLevel);
|
||||||
|
|
||||||
|
// virtual void sendMessage(ChatMessageComponent *message); // 4J: removed
|
||||||
|
virtual Pos getCommandSenderWorldPosition();
|
||||||
|
virtual std::shared_ptr<ItemInstance> getCarriedItem();
|
||||||
|
virtual void playSound(int soundId, float volume, float pitch);
|
||||||
|
bool isRidingJumpable();
|
||||||
|
float getJumpRidingScale();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void sendRidingJump();
|
||||||
|
|
||||||
|
public:
|
||||||
bool hasPermission(EGameCommand command);
|
bool hasPermission(EGameCommand command);
|
||||||
|
|
||||||
void updateRichPresence();
|
void updateRichPresence();
|
||||||
|
|
@ -197,7 +224,6 @@ public:
|
||||||
float m_sessionTimeStart;
|
float m_sessionTimeStart;
|
||||||
float m_dimensionTimeStart;
|
float m_dimensionTimeStart;
|
||||||
|
|
||||||
public:
|
|
||||||
void SetSessionTimerStart(void);
|
void SetSessionTimerStart(void);
|
||||||
float getSessionTimer(void);
|
float getSessionTimer(void);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ MultiPlayerGameMode::MultiPlayerGameMode(Minecraft* minecraft,
|
||||||
xDestroyBlock = -1;
|
xDestroyBlock = -1;
|
||||||
yDestroyBlock = -1;
|
yDestroyBlock = -1;
|
||||||
zDestroyBlock = -1;
|
zDestroyBlock = -1;
|
||||||
|
destroyingItem = nullptr;
|
||||||
destroyProgress = 0;
|
destroyProgress = 0;
|
||||||
oDestroyProgress = 0;
|
|
||||||
destroyTicks = 0;
|
destroyTicks = 0;
|
||||||
destroyDelay = 0;
|
destroyDelay = 0;
|
||||||
isDestroying = false;
|
isDestroying = false;
|
||||||
|
|
@ -58,8 +58,18 @@ bool MultiPlayerGameMode::canHurtPlayer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face) {
|
bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face) {
|
||||||
if (localPlayerMode->isReadOnly()) {
|
if (localPlayerMode->isAdventureRestricted()) {
|
||||||
return false;
|
if (!minecraft->player->mayDestroyBlockAt(x, y, z)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (localPlayerMode->isCreative()) {
|
||||||
|
if (minecraft->player->getCarriedItem() != NULL &&
|
||||||
|
dynamic_cast<WeaponItem*>(
|
||||||
|
minecraft->player->getCarriedItem()->getItem()) != NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Level* level = minecraft->level;
|
Level* level = minecraft->level;
|
||||||
|
|
@ -72,10 +82,11 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face) {
|
||||||
oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
||||||
|
|
||||||
int data = level->getData(x, y, z);
|
int data = level->getData(x, y, z);
|
||||||
bool changed = level->setTile(x, y, z, 0);
|
bool changed = level->removeTile(x, y, z);
|
||||||
if (changed) {
|
if (changed) {
|
||||||
oldTile->destroy(level, x, y, z, data);
|
oldTile->destroy(level, x, y, z, data);
|
||||||
}
|
}
|
||||||
|
yDestroyBlock = -1;
|
||||||
|
|
||||||
if (!localPlayerMode->isCreative()) {
|
if (!localPlayerMode->isCreative()) {
|
||||||
std::shared_ptr<ItemInstance> item =
|
std::shared_ptr<ItemInstance> item =
|
||||||
|
|
@ -93,8 +104,11 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face) {
|
||||||
|
|
||||||
void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
|
void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||||
if (!minecraft->player->isAllowedToMine()) return;
|
if (!minecraft->player->isAllowedToMine()) return;
|
||||||
if (localPlayerMode->isReadOnly()) {
|
|
||||||
return;
|
if (localPlayerMode->isAdventureRestricted()) {
|
||||||
|
if (!minecraft->player->mayDestroyBlockAt(x, y, z)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localPlayerMode->isCreative()) {
|
if (localPlayerMode->isCreative()) {
|
||||||
|
|
@ -103,8 +117,13 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||||
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)));
|
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)));
|
||||||
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
||||||
destroyDelay = 5;
|
destroyDelay = 5;
|
||||||
} else if (!isDestroying || x != xDestroyBlock || y != yDestroyBlock ||
|
} else if (!isDestroying || !sameDestroyTarget(x, y, z)) {
|
||||||
z != zDestroyBlock) {
|
if (isDestroying) {
|
||||||
|
connection->send(
|
||||||
|
std::shared_ptr<PlayerActionPacket>(new PlayerActionPacket(
|
||||||
|
PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock,
|
||||||
|
yDestroyBlock, zDestroyBlock, face)));
|
||||||
|
}
|
||||||
connection->send(
|
connection->send(
|
||||||
std::shared_ptr<PlayerActionPacket>(new PlayerActionPacket(
|
std::shared_ptr<PlayerActionPacket>(new PlayerActionPacket(
|
||||||
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)));
|
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)));
|
||||||
|
|
@ -114,18 +133,18 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||||
minecraft->player);
|
minecraft->player);
|
||||||
if (t > 0 &&
|
if (t > 0 &&
|
||||||
(Tile::tiles[t]->getDestroyProgress(
|
(Tile::tiles[t]->getDestroyProgress(
|
||||||
minecraft->player, minecraft->player->level, x, y, z) >= 1 ||
|
minecraft->player, minecraft->player->level, x, y, z) >= 1
|
||||||
(app.DebugSettingsOn() &&
|
// ||(app.DebugSettingsOn() &&
|
||||||
app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) &
|
// app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_InstantDestroy))
|
||||||
(1L << eDebugSetting_InstantDestroy)))) {
|
)) {
|
||||||
destroyBlock(x, y, z, face);
|
destroyBlock(x, y, z, face);
|
||||||
} else {
|
} else {
|
||||||
isDestroying = true;
|
isDestroying = true;
|
||||||
xDestroyBlock = x;
|
xDestroyBlock = x;
|
||||||
yDestroyBlock = y;
|
yDestroyBlock = y;
|
||||||
zDestroyBlock = z;
|
zDestroyBlock = z;
|
||||||
|
destroyingItem = minecraft->player->getCarriedItem();
|
||||||
destroyProgress = 0;
|
destroyProgress = 0;
|
||||||
oDestroyProgress = 0;
|
|
||||||
destroyTicks = 0;
|
destroyTicks = 0;
|
||||||
minecraft->level->destroyTileProgress(
|
minecraft->level->destroyTileProgress(
|
||||||
minecraft->player->entityId, xDestroyBlock, yDestroyBlock,
|
minecraft->player->entityId, xDestroyBlock, yDestroyBlock,
|
||||||
|
|
@ -170,7 +189,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock) {
|
if (sameDestroyTarget(x, y, z)) {
|
||||||
int t = minecraft->level->getTile(x, y, z);
|
int t = minecraft->level->getTile(x, y, z);
|
||||||
if (t == 0) {
|
if (t == 0) {
|
||||||
isDestroying = false;
|
isDestroying = false;
|
||||||
|
|
@ -201,7 +220,6 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) {
|
||||||
PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face)));
|
PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face)));
|
||||||
destroyBlock(x, y, z, face);
|
destroyBlock(x, y, z, face);
|
||||||
destroyProgress = 0;
|
destroyProgress = 0;
|
||||||
oDestroyProgress = 0;
|
|
||||||
destroyTicks = 0;
|
destroyTicks = 0;
|
||||||
destroyDelay = 5;
|
destroyDelay = 5;
|
||||||
}
|
}
|
||||||
|
|
@ -223,10 +241,23 @@ float MultiPlayerGameMode::getPickRange() {
|
||||||
|
|
||||||
void MultiPlayerGameMode::tick() {
|
void MultiPlayerGameMode::tick() {
|
||||||
ensureHasSentCarriedItem();
|
ensureHasSentCarriedItem();
|
||||||
oDestroyProgress = destroyProgress;
|
|
||||||
// minecraft->soundEngine->playMusicTick();
|
// minecraft->soundEngine->playMusicTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MultiPlayerGameMode::sameDestroyTarget(int x, int y, int z) {
|
||||||
|
std::shared_ptr<ItemInstance> selected =
|
||||||
|
minecraft->player->getCarriedItem();
|
||||||
|
bool sameItems = destroyingItem == NULL && selected == NULL;
|
||||||
|
if (destroyingItem != NULL && selected != NULL) {
|
||||||
|
sameItems = selected->id == destroyingItem->id &&
|
||||||
|
ItemInstance::tagMatches(selected, destroyingItem) &&
|
||||||
|
(selected->isDamageableItem() ||
|
||||||
|
selected->getAuxValue() == destroyingItem->getAuxValue());
|
||||||
|
}
|
||||||
|
return x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock &&
|
||||||
|
sameItems;
|
||||||
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::ensureHasSentCarriedItem() {
|
void MultiPlayerGameMode::ensureHasSentCarriedItem() {
|
||||||
int newItem = minecraft->player->inventory->selected;
|
int newItem = minecraft->player->inventory->selected;
|
||||||
if (newItem != carriedItem) {
|
if (newItem != carriedItem) {
|
||||||
|
|
@ -251,31 +282,34 @@ bool MultiPlayerGameMode::useItemOn(std::shared_ptr<Player> player,
|
||||||
float clickY = (float)hit->y - y;
|
float clickY = (float)hit->y - y;
|
||||||
float clickZ = (float)hit->z - z;
|
float clickZ = (float)hit->z - z;
|
||||||
bool didSomething = false;
|
bool didSomething = false;
|
||||||
int t = level->getTile(x, y, z);
|
|
||||||
|
|
||||||
if (t > 0 && player->isAllowedToUse(Tile::tiles[t])) {
|
if (!player->isSneaking() || player->getCarriedItem() == NULL) {
|
||||||
if (bTestUseOnly) {
|
int t = level->getTile(x, y, z);
|
||||||
switch (t) {
|
if (t > 0 && player->isAllowedToUse(Tile::tiles[t])) {
|
||||||
case Tile::recordPlayer_Id:
|
if (bTestUseOnly) {
|
||||||
case Tile::bed_Id: // special case for a bed
|
switch (t) {
|
||||||
if (Tile::tiles[t]->TestUse(level, x, y, z, player)) {
|
case Tile::jukebox_Id:
|
||||||
return true;
|
case Tile::bed_Id: // special case for a bed
|
||||||
} else if (t == Tile::bed_Id) // 4J-JEV: You can still use
|
if (Tile::tiles[t]->TestUse(level, x, y, z, player)) {
|
||||||
// items on record players
|
return true;
|
||||||
// (ie. set fire to them).
|
} else if (t ==
|
||||||
{
|
Tile::bed_Id) // 4J-JEV: You can still use
|
||||||
// bed is too far away, or something
|
// items on record players
|
||||||
return false;
|
// (ie. set fire to them).
|
||||||
}
|
{
|
||||||
break;
|
// bed is too far away, or something
|
||||||
default:
|
return false;
|
||||||
if (Tile::tiles[t]->TestUse()) return true;
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if (Tile::tiles[t]->TestUse()) return true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Tile::tiles[t]->use(level, x, y, z, player, face, clickX,
|
||||||
|
clickY, clickZ))
|
||||||
|
didSomething = true;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (Tile::tiles[t]->use(level, x, y, z, player, face, clickX,
|
|
||||||
clickY, clickZ))
|
|
||||||
didSomething = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,6 +340,7 @@ bool MultiPlayerGameMode::useItemOn(std::shared_ptr<Player> player,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
int t = level->getTile(x, y, z);
|
||||||
// 4J - Bit of a hack, however seems preferable to any larger changes
|
// 4J - Bit of a hack, however seems preferable to any larger changes
|
||||||
// which would have more chance of causing unwanted side effects. If we
|
// which would have more chance of causing unwanted side effects. If we
|
||||||
// aren't going to be actually performing the use method locally, then
|
// aren't going to be actually performing the use method locally, then
|
||||||
|
|
@ -355,7 +390,7 @@ bool MultiPlayerGameMode::useItem(std::shared_ptr<Player> player, Level* level,
|
||||||
|
|
||||||
// 4J-PB added for tooltips to test use only
|
// 4J-PB added for tooltips to test use only
|
||||||
if (bTestUseOnly) {
|
if (bTestUseOnly) {
|
||||||
result = item->TestUse(level, player);
|
result = item->TestUse(item, level, player);
|
||||||
} else {
|
} else {
|
||||||
int oldCount = item->count;
|
int oldCount = item->count;
|
||||||
std::shared_ptr<ItemInstance> itemInstance = item->use(level, player);
|
std::shared_ptr<ItemInstance> itemInstance = item->use(level, player);
|
||||||
|
|
@ -445,7 +480,9 @@ void MultiPlayerGameMode::releaseUsingItem(std::shared_ptr<Player> player) {
|
||||||
player->releaseUsingItem();
|
player->releaseUsingItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::hasExperience() { return true; }
|
bool MultiPlayerGameMode::hasExperience() {
|
||||||
|
return localPlayerMode->isSurvival();
|
||||||
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::hasMissTime() {
|
bool MultiPlayerGameMode::hasMissTime() {
|
||||||
return !localPlayerMode->isCreative();
|
return !localPlayerMode->isCreative();
|
||||||
|
|
@ -459,6 +496,13 @@ bool MultiPlayerGameMode::hasFarPickRange() {
|
||||||
return localPlayerMode->isCreative();
|
return localPlayerMode->isCreative();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true when the inventory is opened from the server-side. Currently
|
||||||
|
// only happens when the player is riding a horse.
|
||||||
|
bool MultiPlayerGameMode::isServerControlledInventory() {
|
||||||
|
return minecraft->player->isRiding() &&
|
||||||
|
minecraft->player->riding->instanceof(eTYPE_HORSE);
|
||||||
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::handleCraftItem(int recipe,
|
bool MultiPlayerGameMode::handleCraftItem(int recipe,
|
||||||
std::shared_ptr<Player> player) {
|
std::shared_ptr<Player> player) {
|
||||||
short changeUid = player->containerMenu->backup(player->inventory);
|
short changeUid = player->containerMenu->backup(player->inventory);
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ private:
|
||||||
int xDestroyBlock;
|
int xDestroyBlock;
|
||||||
int yDestroyBlock;
|
int yDestroyBlock;
|
||||||
int zDestroyBlock;
|
int zDestroyBlock;
|
||||||
|
std::shared_ptr<ItemInstance> destroyingItem;
|
||||||
float destroyProgress;
|
float destroyProgress;
|
||||||
float oDestroyProgress;
|
|
||||||
int destroyTicks; // 4J was float but doesn't seem to need to be
|
int destroyTicks; // 4J was float but doesn't seem to need to be
|
||||||
int destroyDelay;
|
int destroyDelay;
|
||||||
bool isDestroying;
|
bool isDestroying;
|
||||||
|
|
@ -22,7 +22,6 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MultiPlayerGameMode(Minecraft* minecraft, ClientConnection* connection);
|
MultiPlayerGameMode(Minecraft* minecraft, ClientConnection* connection);
|
||||||
virtual ~MultiPlayerGameMode() {}
|
|
||||||
static void creativeDestroyBlock(Minecraft* minecraft,
|
static void creativeDestroyBlock(Minecraft* minecraft,
|
||||||
MultiPlayerGameMode* gameMode, int x,
|
MultiPlayerGameMode* gameMode, int x,
|
||||||
int y, int z, int face);
|
int y, int z, int face);
|
||||||
|
|
@ -42,6 +41,7 @@ private:
|
||||||
int carriedItem;
|
int carriedItem;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool sameDestroyTarget(int x, int y, int z);
|
||||||
void ensureHasSentCarriedItem();
|
void ensureHasSentCarriedItem();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -70,6 +70,7 @@ public:
|
||||||
virtual bool hasMissTime();
|
virtual bool hasMissTime();
|
||||||
virtual bool hasInfiniteItems();
|
virtual bool hasInfiniteItems();
|
||||||
virtual bool hasFarPickRange();
|
virtual bool hasFarPickRange();
|
||||||
|
virtual bool isServerControlledInventory();
|
||||||
|
|
||||||
// 4J Stu - Added so we can send packets for this in the network game
|
// 4J Stu - Added so we can send packets for this in the network game
|
||||||
virtual bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
|
virtual bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
|
||||||
|
|
@ -80,4 +81,4 @@ public:
|
||||||
virtual bool isInputAllowed(int mapping) { return true; }
|
virtual bool isInputAllowed(int mapping) { return true; }
|
||||||
virtual bool isTutorial() { return false; }
|
virtual bool isTutorial() { return false; }
|
||||||
virtual Tutorial* getTutorial() { return NULL; }
|
virtual Tutorial* getTutorial() { return NULL; }
|
||||||
};
|
};
|
||||||
|
|
@ -12,6 +12,13 @@
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.effect.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.effect.h"
|
||||||
#include "../../Minecraft.World/Level/LevelData.h"
|
#include "../../Minecraft.World/Level/LevelData.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
|
||||||
|
#include "../Input/Input.h"
|
||||||
|
#include "../Rendering/LevelRenderer.h"
|
||||||
|
|
||||||
|
// 4J added for testing
|
||||||
|
#ifdef STRESS_TEST_MOVE
|
||||||
|
volatile bool stressTestEnabled = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
MultiplayerLocalPlayer::MultiplayerLocalPlayer(Minecraft* minecraft,
|
MultiplayerLocalPlayer::MultiplayerLocalPlayer(Minecraft* minecraft,
|
||||||
Level* level, User* user,
|
Level* level, User* user,
|
||||||
|
|
@ -30,11 +37,11 @@ MultiplayerLocalPlayer::MultiplayerLocalPlayer(Minecraft* minecraft,
|
||||||
this->connection = connection;
|
this->connection = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiplayerLocalPlayer::hurt(DamageSource* source, int dmg) {
|
bool MultiplayerLocalPlayer::hurt(DamageSource* source, float dmg) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::heal(int heal) {}
|
void MultiplayerLocalPlayer::heal(float heal) {}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::tick() {
|
void MultiplayerLocalPlayer::tick() {
|
||||||
// 4J Added
|
// 4J Added
|
||||||
|
|
@ -57,14 +64,31 @@ void MultiplayerLocalPlayer::tick() {
|
||||||
if (!level->hasChunkAt(Mth::floor(x), 0, Mth::floor(z))) return;
|
if (!level->hasChunkAt(Mth::floor(x), 0, Mth::floor(z))) return;
|
||||||
|
|
||||||
double tempX = x, tempY = y, tempZ = z;
|
double tempX = x, tempY = y, tempZ = z;
|
||||||
|
|
||||||
LocalPlayer::tick();
|
LocalPlayer::tick();
|
||||||
|
|
||||||
|
// 4J added for testing
|
||||||
|
#ifdef STRESS_TEST_MOVE
|
||||||
|
if (stressTestEnabled) {
|
||||||
|
StressTestMove(&tempX, &tempY, &tempZ);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// if( !minecraft->localgameModes[m_iPad]->isTutorial() ||
|
// if( !minecraft->localgameModes[m_iPad]->isTutorial() ||
|
||||||
// minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition(tempX,
|
// minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition(tempX,
|
||||||
// tempY, tempZ, x, y, z) )
|
// tempY, tempZ, x, y, z) )
|
||||||
if (minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition(
|
if (minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition(
|
||||||
tempX, tempY, tempZ, x, y, z)) {
|
tempX, tempY, tempZ, x, y, z)) {
|
||||||
sendPosition();
|
if (isRiding()) {
|
||||||
|
connection->send(
|
||||||
|
std::shared_ptr<MovePlayerPacket>(new MovePlayerPacket::Rot(
|
||||||
|
yRot, xRot, onGround, abilities.flying)));
|
||||||
|
connection->send(
|
||||||
|
std::shared_ptr<PlayerInputPacket>(new PlayerInputPacket(
|
||||||
|
xxa, yya, input->jumping, input->sneaking)));
|
||||||
|
} else {
|
||||||
|
sendPosition();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// app.Debugprintf("Cannot move to position (%f, %f, %f), falling back
|
// app.Debugprintf("Cannot move to position (%f, %f, %f), falling back
|
||||||
// to (%f, %f, %f)\n", x, y, z, tempX, y, tempZ);
|
// to (%f, %f, %f)\n", x, y, z, tempX, y, tempZ);
|
||||||
|
|
@ -189,7 +213,8 @@ void MultiplayerLocalPlayer::respawn() {
|
||||||
new ClientCommandPacket(ClientCommandPacket::PERFORM_RESPAWN)));
|
new ClientCommandPacket(ClientCommandPacket::PERFORM_RESPAWN)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::actuallyHurt(DamageSource* source, int dmg) {
|
void MultiplayerLocalPlayer::actuallyHurt(DamageSource* source, float dmg) {
|
||||||
|
if (isInvulnerable()) return;
|
||||||
setHealth(getHealth() - dmg);
|
setHealth(getHealth() - dmg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,7 +241,8 @@ void MultiplayerLocalPlayer::onEffectAdded(MobEffectInstance* effect) {
|
||||||
Player::onEffectAdded(effect);
|
Player::onEffectAdded(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance* effect) {
|
void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance* effect,
|
||||||
|
bool doRefreshAttributes) {
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
if (pMinecraft->localgameModes[m_iPad] != NULL) {
|
if (pMinecraft->localgameModes[m_iPad] != NULL) {
|
||||||
TutorialMode* gameMode =
|
TutorialMode* gameMode =
|
||||||
|
|
@ -224,7 +250,7 @@ void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance* effect) {
|
||||||
Tutorial* tutorial = gameMode->getTutorial();
|
Tutorial* tutorial = gameMode->getTutorial();
|
||||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
||||||
}
|
}
|
||||||
Player::onEffectUpdated(effect);
|
Player::onEffectUpdated(effect, doRefreshAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance* effect) {
|
void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance* effect) {
|
||||||
|
|
@ -241,11 +267,16 @@ void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance* effect) {
|
||||||
void MultiplayerLocalPlayer::closeContainer() {
|
void MultiplayerLocalPlayer::closeContainer() {
|
||||||
connection->send(std::shared_ptr<ContainerClosePacket>(
|
connection->send(std::shared_ptr<ContainerClosePacket>(
|
||||||
new ContainerClosePacket(containerMenu->containerId)));
|
new ContainerClosePacket(containerMenu->containerId)));
|
||||||
|
clientSideCloseContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
// close the container without sending a packet to the server
|
||||||
|
void MultiplayerLocalPlayer::clientSideCloseContainer() {
|
||||||
inventory->setCarried(nullptr);
|
inventory->setCarried(nullptr);
|
||||||
LocalPlayer::closeContainer();
|
LocalPlayer::closeContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::hurtTo(int newHealth,
|
void MultiplayerLocalPlayer::hurtTo(float newHealth,
|
||||||
ETelemetryChallenges damageSource) {
|
ETelemetryChallenges damageSource) {
|
||||||
if (flashOnSetHealth) {
|
if (flashOnSetHealth) {
|
||||||
LocalPlayer::hurtTo(newHealth, damageSource);
|
LocalPlayer::hurtTo(newHealth, damageSource);
|
||||||
|
|
@ -283,11 +314,30 @@ void MultiplayerLocalPlayer::onUpdateAbilities() {
|
||||||
|
|
||||||
bool MultiplayerLocalPlayer::isLocalPlayer() { return true; }
|
bool MultiplayerLocalPlayer::isLocalPlayer() { return true; }
|
||||||
|
|
||||||
|
void MultiplayerLocalPlayer::sendRidingJump() {
|
||||||
|
connection->send(
|
||||||
|
std::shared_ptr<PlayerCommandPacket>(new PlayerCommandPacket(
|
||||||
|
shared_from_this(), PlayerCommandPacket::RIDING_JUMP,
|
||||||
|
(int)(getJumpRidingScale() * 100.0f))));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultiplayerLocalPlayer::sendOpenInventory() {
|
||||||
|
connection->send(
|
||||||
|
std::shared_ptr<PlayerCommandPacket>(new PlayerCommandPacket(
|
||||||
|
shared_from_this(), PlayerCommandPacket::OPEN_INVENTORY)));
|
||||||
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e) {
|
void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e) {
|
||||||
bool wasRiding = riding != NULL;
|
bool wasRiding = riding != NULL;
|
||||||
LocalPlayer::ride(e);
|
LocalPlayer::ride(e);
|
||||||
bool isRiding = riding != NULL;
|
bool isRiding = riding != NULL;
|
||||||
|
|
||||||
|
// 4J Added
|
||||||
|
if (wasRiding && !isRiding) {
|
||||||
|
setSneaking(false);
|
||||||
|
input->sneaking = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (isRiding) {
|
if (isRiding) {
|
||||||
ETelemetryChallenges eventType = eTelemetryChallenges_Unknown;
|
ETelemetryChallenges eventType = eTelemetryChallenges_Unknown;
|
||||||
if (this->riding != NULL) {
|
if (this->riding != NULL) {
|
||||||
|
|
@ -301,8 +351,6 @@ void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e) {
|
||||||
case eTYPE_PIG:
|
case eTYPE_PIG:
|
||||||
eventType = eTelemetryInGame_Ride_Pig;
|
eventType = eTelemetryInGame_Ride_Pig;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
TelemetryManager->RecordEnemyKilledOrOvercome(GetXboxPad(), 0, y, 0, 0,
|
TelemetryManager->RecordEnemyKilledOrOvercome(GetXboxPad(), 0, y, 0, 0,
|
||||||
|
|
@ -320,12 +368,7 @@ void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e) {
|
||||||
gameMode->getTutorial()->changeTutorialState(
|
gameMode->getTutorial()->changeTutorialState(
|
||||||
e_Tutorial_State_Gameplay);
|
e_Tutorial_State_Gameplay);
|
||||||
} else if (!wasRiding && isRiding) {
|
} else if (!wasRiding && isRiding) {
|
||||||
if (std::dynamic_pointer_cast<Minecart>(e) != NULL)
|
gameMode->getTutorial()->onRideEntity(e);
|
||||||
gameMode->getTutorial()->changeTutorialState(
|
|
||||||
e_Tutorial_State_Riding_Minecart);
|
|
||||||
else if (std::dynamic_pointer_cast<Boat>(e) != NULL)
|
|
||||||
gameMode->getTutorial()->changeTutorialState(
|
|
||||||
e_Tutorial_State_Riding_Boat);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -363,3 +406,78 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId) {
|
||||||
shared_from_this(), TextureChangePacket::e_TextureChange_Cape,
|
shared_from_this(), TextureChangePacket::e_TextureChange_Cape,
|
||||||
app.GetPlayerCapeName(GetXboxPad()))));
|
app.GetPlayerCapeName(GetXboxPad()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 4J added for testing. This moves the player in a repeated sequence of 2
|
||||||
|
// modes: Mode 0 - teleports to random location in the world, and waits for the
|
||||||
|
// number of chunks that are fully loaded/created to have setting for 2 seconds
|
||||||
|
// before changing to mode 1 Mode 1 - picks a random direction to move in for
|
||||||
|
// 200 ticks (~10 seconds), repeating for a total of 2000 ticks, before cycling
|
||||||
|
// back to mode 0 Whilst carrying out this movement pattern, this calls
|
||||||
|
// checkAllPresentChunks which checks the integrity of all currently
|
||||||
|
// loaded/created chunks round the player.
|
||||||
|
#ifdef STRESS_TEST_MOVE
|
||||||
|
void MultiplayerLocalPlayer::StressTestMove(double* tempX, double* tempY,
|
||||||
|
double* tempZ) {
|
||||||
|
static volatile int64_t lastChangeTime = 0;
|
||||||
|
static volatile int64_t lastTeleportTime = 0;
|
||||||
|
static int lastCount = 0;
|
||||||
|
static int stressTestCount = 0;
|
||||||
|
const int dirChangeTickCount = 200;
|
||||||
|
|
||||||
|
int64_t currentTime = System::currentTimeMillis();
|
||||||
|
|
||||||
|
bool faultFound = false;
|
||||||
|
int count = Minecraft::GetInstance()->levelRenderer->checkAllPresentChunks(
|
||||||
|
&faultFound);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if( faultFound )
|
||||||
|
{
|
||||||
|
app.DebugPrintf("Fault found\n");
|
||||||
|
stressTestEnabled = false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (count != lastCount) {
|
||||||
|
lastChangeTime = currentTime;
|
||||||
|
lastCount = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float angle = 30.0;
|
||||||
|
static float dx = cos(30.0);
|
||||||
|
static float dz = sin(30.0);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if( ( stressTestCount % dirChangeTickCount) == 0 )
|
||||||
|
{
|
||||||
|
int angledeg = rand() % 360;
|
||||||
|
angle = (((double)angledeg) / 360.0 ) * ( 2.0 * 3.141592654 );
|
||||||
|
dx = cos(angle);
|
||||||
|
dz = sin(angle);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float nx = x + (dx * 1.2);
|
||||||
|
float nz = z + (dz * 1.2);
|
||||||
|
float ny = y;
|
||||||
|
if (ny < 140.0f) ny += 0.5f;
|
||||||
|
if (nx > 2539.0) {
|
||||||
|
nx = 2539.0;
|
||||||
|
dx = -dx;
|
||||||
|
}
|
||||||
|
if (nz > 2539.0) {
|
||||||
|
nz = 2539.0;
|
||||||
|
dz = -dz;
|
||||||
|
}
|
||||||
|
if (nx < -2550.0) {
|
||||||
|
nx = -2550.0;
|
||||||
|
dx = -dx;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nz < -2550.0) {
|
||||||
|
nz = -2550.0;
|
||||||
|
dz = -dz;
|
||||||
|
}
|
||||||
|
absMoveTo(nx, ny, nz, yRot, xRot);
|
||||||
|
stressTestCount++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -7,6 +7,8 @@ class ClientConnection;
|
||||||
class Minecraft;
|
class Minecraft;
|
||||||
class Level;
|
class Level;
|
||||||
|
|
||||||
|
// #define STRESS_TEST_MOVE
|
||||||
|
|
||||||
class MultiplayerLocalPlayer : public LocalPlayer {
|
class MultiplayerLocalPlayer : public LocalPlayer {
|
||||||
private:
|
private:
|
||||||
static const int POSITION_REMINDER_INTERVAL =
|
static const int POSITION_REMINDER_INTERVAL =
|
||||||
|
|
@ -27,8 +29,8 @@ private:
|
||||||
float yRotLast, xRotLast;
|
float yRotLast, xRotLast;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool hurt(DamageSource* source, int dmg);
|
virtual bool hurt(DamageSource* source, float dmg);
|
||||||
virtual void heal(int heal);
|
virtual void heal(float heal);
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -53,24 +55,32 @@ public:
|
||||||
virtual void respawn();
|
virtual void respawn();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void actuallyHurt(DamageSource* source, int dmg);
|
virtual void actuallyHurt(DamageSource* source, float dmg);
|
||||||
|
|
||||||
// 4J Added override to capture event for tutorial messages
|
// 4J Added override to capture event for tutorial messages
|
||||||
virtual void completeUsingItem();
|
virtual void completeUsingItem();
|
||||||
|
|
||||||
// 4J Added overrides to capture events for tutorial
|
// 4J Added overrides to capture events for tutorial
|
||||||
virtual void onEffectAdded(MobEffectInstance* effect);
|
virtual void onEffectAdded(MobEffectInstance* effect);
|
||||||
virtual void onEffectUpdated(MobEffectInstance* effect);
|
virtual void onEffectUpdated(MobEffectInstance* effect,
|
||||||
|
bool doRefreshAttributes);
|
||||||
virtual void onEffectRemoved(MobEffectInstance* effect);
|
virtual void onEffectRemoved(MobEffectInstance* effect);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void closeContainer();
|
virtual void closeContainer();
|
||||||
virtual void hurtTo(int newHealth, ETelemetryChallenges damageSource);
|
void clientSideCloseContainer();
|
||||||
|
virtual void hurtTo(float newHealth, ETelemetryChallenges damageSource);
|
||||||
virtual void awardStat(Stat* stat, byteArray param);
|
virtual void awardStat(Stat* stat, byteArray param);
|
||||||
void awardStatFromServer(Stat* stat, byteArray param);
|
void awardStatFromServer(Stat* stat, byteArray param);
|
||||||
void onUpdateAbilities();
|
void onUpdateAbilities();
|
||||||
bool isLocalPlayer();
|
bool isLocalPlayer();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void sendRidingJump();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void sendOpenInventory();
|
||||||
|
|
||||||
// 4J - send the custom skin texture data if there is one
|
// 4J - send the custom skin texture data if there is one
|
||||||
// void CustomSkin(PBYTE pbData, DWORD dwBytes);
|
// void CustomSkin(PBYTE pbData, DWORD dwBytes);
|
||||||
|
|
||||||
|
|
@ -81,6 +91,11 @@ public:
|
||||||
virtual void StopSleeping();
|
virtual void StopSleeping();
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
virtual void setAndBroadcastCustomSkin(std::uint32_t skinId);
|
virtual void setAndBroadcastCustomSkin(DWORD skinId);
|
||||||
virtual void setAndBroadcastCustomCape(std::uint32_t capeId);
|
virtual void setAndBroadcastCustomCape(DWORD capeId);
|
||||||
|
|
||||||
|
// 4J added for testing
|
||||||
|
#ifdef STRESS_TEST_MOVE
|
||||||
|
void StressTestMove(double* tempX, double* tempY, double* tempZ);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,34 +4,28 @@
|
||||||
#include "../../Minecraft.World/Util/Mth.h"
|
#include "../../Minecraft.World/Util/Mth.h"
|
||||||
|
|
||||||
RemotePlayer::RemotePlayer(Level* level, const std::wstring& name)
|
RemotePlayer::RemotePlayer(Level* level, const std::wstring& name)
|
||||||
: Player(level) {
|
: Player(level, name) {
|
||||||
// 4J - added initialisers
|
// 4J - added initialisers
|
||||||
hasStartedUsingItem = false;
|
hasStartedUsingItem = false;
|
||||||
lSteps = 0;
|
lSteps = 0;
|
||||||
lx = ly = lz = lyr = lxr = 0.0;
|
lx = ly = lz = lyr = lxr = 0.0;
|
||||||
fallTime = 0.0f;
|
fallTime = 0.0f;
|
||||||
|
|
||||||
this->name = name;
|
|
||||||
m_UUID = name;
|
|
||||||
app.DebugPrintf("Created RemotePlayer with name %ls\n", name.c_str());
|
app.DebugPrintf("Created RemotePlayer with name %ls\n", name.c_str());
|
||||||
|
|
||||||
heightOffset = 0;
|
heightOffset = 0;
|
||||||
this->footSize = 0;
|
footSize = 0;
|
||||||
if (name.length() > 0) {
|
|
||||||
customTextureUrl = L""; // L"http://s3.amazonaws.com/MinecraftSkins/" +
|
|
||||||
// name + L".png";
|
|
||||||
}
|
|
||||||
|
|
||||||
this->noPhysics = true;
|
noPhysics = true;
|
||||||
|
|
||||||
bedOffsetY = 4 / 16.0f;
|
bedOffsetY = 4 / 16.0f;
|
||||||
|
|
||||||
this->viewScale = 10;
|
viewScale = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemotePlayer::setDefaultHeadHeight() { heightOffset = 0; }
|
void RemotePlayer::setDefaultHeadHeight() { heightOffset = 0; }
|
||||||
|
|
||||||
bool RemotePlayer::hurt(DamageSource* source, int dmg) { return true; }
|
bool RemotePlayer::hurt(DamageSource* source, float dmg) { return true; }
|
||||||
|
|
||||||
void RemotePlayer::lerpTo(double x, double y, double z, float yRot, float xRot,
|
void RemotePlayer::lerpTo(double x, double y, double z, float yRot, float xRot,
|
||||||
int steps) {
|
int steps) {
|
||||||
|
|
@ -99,8 +93,8 @@ void RemotePlayer::aiStep() {
|
||||||
xRot += (float)((lxr - xRot) / lSteps);
|
xRot += (float)((lxr - xRot) / lSteps);
|
||||||
|
|
||||||
lSteps--;
|
lSteps--;
|
||||||
this->setPos(xt, yt, zt);
|
setPos(xt, yt, zt);
|
||||||
this->setRot(yRot, xRot);
|
setRot(yRot, xRot);
|
||||||
}
|
}
|
||||||
oBob = bob;
|
oBob = bob;
|
||||||
|
|
||||||
|
|
@ -129,4 +123,8 @@ void RemotePlayer::animateRespawn() {
|
||||||
// Player.animateRespawn(this, level);
|
// Player.animateRespawn(this, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
float RemotePlayer::getHeadHeight() { return 1.82f; }
|
float RemotePlayer::getHeadHeight() { return 1.82f; }
|
||||||
|
|
||||||
|
Pos RemotePlayer::getCommandSenderWorldPosition() {
|
||||||
|
return new Pos(floor(x + .5), floor(y + .5), floor(z + .5));
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
class Input;
|
class Input;
|
||||||
|
|
||||||
class RemotePlayer : public Player {
|
class RemotePlayer : public Player {
|
||||||
|
public:
|
||||||
|
eINSTANCEOF GetType() { return eTYPE_REMOTEPLAYER; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool hasStartedUsingItem;
|
bool hasStartedUsingItem;
|
||||||
|
|
||||||
|
|
@ -16,7 +19,7 @@ protected:
|
||||||
virtual void setDefaultHeadHeight();
|
virtual void setDefaultHeadHeight();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool hurt(DamageSource* source, int dmg);
|
virtual bool hurt(DamageSource* source, float dmg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int lSteps;
|
int lSteps;
|
||||||
|
|
@ -39,4 +42,5 @@ public:
|
||||||
virtual void animateRespawn();
|
virtual void animateRespawn();
|
||||||
virtual float getHeadHeight();
|
virtual float getHeadHeight();
|
||||||
bool hasPermission(EGameCommand command) { return false; }
|
bool hasPermission(EGameCommand command) { return false; }
|
||||||
|
virtual Pos getCommandSenderWorldPosition();
|
||||||
};
|
};
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -10,6 +10,10 @@ class Stat;
|
||||||
class TileEntity;
|
class TileEntity;
|
||||||
class Entity;
|
class Entity;
|
||||||
class BrewingStandTileEntity;
|
class BrewingStandTileEntity;
|
||||||
|
class HopperTileEntity;
|
||||||
|
class MinecartHopper;
|
||||||
|
class BeaconTileEntity;
|
||||||
|
class EntityHorse;
|
||||||
class Merchant;
|
class Merchant;
|
||||||
|
|
||||||
class ServerPlayer : public Player,
|
class ServerPlayer : public Player,
|
||||||
|
|
@ -29,12 +33,14 @@ public:
|
||||||
Biome* currentBiome;
|
Biome* currentBiome;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int lastSentHealth;
|
float lastRecordedHealthAndAbsorption;
|
||||||
|
float lastSentHealth;
|
||||||
int lastSentFood;
|
int lastSentFood;
|
||||||
bool lastFoodSaturationZero;
|
bool lastFoodSaturationZero;
|
||||||
int lastSentExp;
|
int lastSentExp;
|
||||||
int invulnerableTime;
|
int invulnerableTime;
|
||||||
int viewDistance;
|
int viewDistance;
|
||||||
|
int64_t lastActionTime;
|
||||||
int lastBrupSendTickCount; // 4J Added
|
int lastBrupSendTickCount; // 4J Added
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -46,15 +52,9 @@ public:
|
||||||
|
|
||||||
virtual void readAdditionalSaveData(CompoundTag* entityTag);
|
virtual void readAdditionalSaveData(CompoundTag* entityTag);
|
||||||
virtual void addAdditonalSaveData(CompoundTag* entityTag);
|
virtual void addAdditonalSaveData(CompoundTag* entityTag);
|
||||||
virtual void withdrawExperienceLevels(int amount);
|
virtual void giveExperienceLevels(int amount);
|
||||||
void initMenu();
|
void initMenu();
|
||||||
|
|
||||||
private:
|
|
||||||
ItemInstanceArray lastCarried;
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual ItemInstanceArray getEquipmentSlots();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setDefaultHeadHeight();
|
virtual void setDefaultHeadHeight();
|
||||||
|
|
||||||
|
|
@ -64,13 +64,14 @@ public:
|
||||||
void flushEntitiesToRemove();
|
void flushEntitiesToRemove();
|
||||||
virtual std::shared_ptr<ItemInstance> getCarried(int slot);
|
virtual std::shared_ptr<ItemInstance> getCarried(int slot);
|
||||||
virtual void die(DamageSource* source);
|
virtual void die(DamageSource* source);
|
||||||
virtual bool hurt(DamageSource* dmgSource, int dmg);
|
virtual bool hurt(DamageSource* dmgSource, float dmg);
|
||||||
virtual bool isPlayerVersusPlayer();
|
virtual bool canHarmPlayer(std::shared_ptr<Player> target);
|
||||||
|
bool canHarmPlayer(std::wstring targetName); // 4J: Added
|
||||||
void doTick(bool sendChunks, bool dontDelayChunks = false,
|
void doTick(bool sendChunks, bool dontDelayChunks = false,
|
||||||
bool ignorePortal = false);
|
bool ignorePortal = false);
|
||||||
void doTickA();
|
void doTickA();
|
||||||
void doChunkSendingTick(bool dontDelayChunks);
|
void doChunkSendingTick(bool dontDelayChunks);
|
||||||
void doTickB(bool ignorePortal);
|
void doTickB();
|
||||||
virtual void changeDimension(int i);
|
virtual void changeDimension(int i);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -78,7 +79,6 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void take(std::shared_ptr<Entity> e, int orgCount);
|
virtual void take(std::shared_ptr<Entity> e, int orgCount);
|
||||||
virtual void swing();
|
|
||||||
virtual BedSleepingResult startSleepInBed(int x, int y, int z,
|
virtual BedSleepingResult startSleepInBed(int x, int y, int z,
|
||||||
bool bTestUse = false);
|
bool bTestUse = false);
|
||||||
|
|
||||||
|
|
@ -106,19 +106,27 @@ private:
|
||||||
void nextContainerCounter();
|
void nextContainerCounter();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool startCrafting(int x, int y, int z); // 4J added bool return
|
virtual void openTextEdit(std::shared_ptr<TileEntity> sign);
|
||||||
virtual bool startEnchanting(int x, int y, int z); // 4J added bool return
|
virtual bool startCrafting(int x, int y, int z); // 4J added bool return
|
||||||
virtual bool startRepairing(int x, int y, int z); // 4J added bool return
|
virtual bool openFireworks(int x, int y, int z); // 4J added
|
||||||
|
virtual bool startEnchanting(
|
||||||
|
int x, int y, int z, const std::wstring& name); // 4J added bool return
|
||||||
|
virtual bool startRepairing(int x, int y, int z); // 4J added bool return
|
||||||
virtual bool openContainer(
|
virtual bool openContainer(
|
||||||
std::shared_ptr<Container> container); // 4J added bool return
|
std::shared_ptr<Container> container); // 4J added bool return
|
||||||
|
virtual bool openHopper(std::shared_ptr<HopperTileEntity> container);
|
||||||
|
virtual bool openHopper(std::shared_ptr<MinecartHopper> container);
|
||||||
virtual bool openFurnace(
|
virtual bool openFurnace(
|
||||||
std::shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
|
std::shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
|
||||||
virtual bool openTrap(
|
virtual bool openTrap(
|
||||||
std::shared_ptr<DispenserTileEntity> trap); // 4J added bool return
|
std::shared_ptr<DispenserTileEntity> trap); // 4J added bool return
|
||||||
virtual bool openBrewingStand(std::shared_ptr<BrewingStandTileEntity>
|
virtual bool openBrewingStand(std::shared_ptr<BrewingStandTileEntity>
|
||||||
brewingStand); // 4J added bool return
|
brewingStand); // 4J added bool return
|
||||||
virtual bool openTrading(
|
virtual bool openBeacon(std::shared_ptr<BeaconTileEntity> beacon);
|
||||||
std::shared_ptr<Merchant> traderTarget); // 4J added bool return
|
virtual bool openTrading(std::shared_ptr<Merchant> traderTarget,
|
||||||
|
const std::wstring& name); // 4J added bool return
|
||||||
|
virtual bool openHorseInventory(std::shared_ptr<EntityHorse> horse,
|
||||||
|
std::shared_ptr<Container> container);
|
||||||
virtual void slotChanged(AbstractContainerMenu* container, int slotIndex,
|
virtual void slotChanged(AbstractContainerMenu* container, int slotIndex,
|
||||||
std::shared_ptr<ItemInstance> item);
|
std::shared_ptr<ItemInstance> item);
|
||||||
void refreshContainer(AbstractContainerMenu* menu);
|
void refreshContainer(AbstractContainerMenu* menu);
|
||||||
|
|
@ -130,8 +138,7 @@ public:
|
||||||
virtual void closeContainer();
|
virtual void closeContainer();
|
||||||
void broadcastCarriedItem();
|
void broadcastCarriedItem();
|
||||||
void doCloseContainer();
|
void doCloseContainer();
|
||||||
void setPlayerInput(float xa, float ya, bool jumping, bool sneaking,
|
void setPlayerInput(float xa, float ya, bool jumping, bool sneaking);
|
||||||
float xRot, float yRot);
|
|
||||||
|
|
||||||
virtual void awardStat(Stat* stat, byteArray param);
|
virtual void awardStat(Stat* stat, byteArray param);
|
||||||
|
|
||||||
|
|
@ -150,7 +157,8 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onEffectAdded(MobEffectInstance* effect);
|
virtual void onEffectAdded(MobEffectInstance* effect);
|
||||||
virtual void onEffectUpdated(MobEffectInstance* effect);
|
virtual void onEffectUpdated(MobEffectInstance* effect,
|
||||||
|
bool doRefreshAttributes);
|
||||||
virtual void onEffectRemoved(MobEffectInstance* effect);
|
virtual void onEffectRemoved(MobEffectInstance* effect);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -166,11 +174,14 @@ public:
|
||||||
ChatPacket::EChatPacketMessage type = ChatPacket::e_ChatCustom,
|
ChatPacket::EChatPacketMessage type = ChatPacket::e_ChatCustom,
|
||||||
int customData = -1, const std::wstring& additionalMessage = L"");
|
int customData = -1, const std::wstring& additionalMessage = L"");
|
||||||
bool hasPermission(EGameCommand command);
|
bool hasPermission(EGameCommand command);
|
||||||
// 4J - Don't use
|
// bool hasPermission(int permissionLevel, EGameCommand command);
|
||||||
// void updateOptions(std::shared_ptr<ClientInformationPacket> packet);
|
// void updateOptions(std::shared_ptr<ClientInformationPacket> packet); //
|
||||||
|
// 4J: Don't use
|
||||||
int getViewDistance();
|
int getViewDistance();
|
||||||
// bool canChatInColor();
|
// bool canChatInColor();
|
||||||
// int getChatVisibility();
|
// int getChatVisibility();
|
||||||
|
Pos* getCommandSenderWorldPosition();
|
||||||
|
void resetLastActionTime();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static int getFlagIndexForChunk(const ChunkPos& pos,
|
static int getFlagIndexForChunk(const ChunkPos& pos,
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,10 @@ void ServerPlayerGameMode::tick() {
|
||||||
void ServerPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
|
void ServerPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||||
if (!player->isAllowedToMine()) return;
|
if (!player->isAllowedToMine()) return;
|
||||||
|
|
||||||
if (gameModeForPlayer->isReadOnly()) {
|
if (gameModeForPlayer->isAdventureRestricted()) {
|
||||||
return;
|
if (!player->mayDestroyBlockAt(x, y, z)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCreative()) {
|
if (isCreative()) {
|
||||||
|
|
@ -138,9 +140,12 @@ void ServerPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||||
Tile::tiles[t]->getDestroyProgress(player, player->level, x, y, z);
|
Tile::tiles[t]->getDestroyProgress(player, player->level, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t > 0 && (progress >= 1 || (app.DebugSettingsOn() &&
|
if (t > 0 &&
|
||||||
(player->GetDebugOptions() &
|
(progress >=
|
||||||
(1L << eDebugSetting_InstantDestroy))))) {
|
1)) //|| (app.DebugSettingsOn() &&
|
||||||
|
//(player->GetDebugOptions()&(1L<<eDebugSetting_InstantDestroy)
|
||||||
|
//) )))
|
||||||
|
{
|
||||||
destroyBlock(x, y, z);
|
destroyBlock(x, y, z);
|
||||||
} else {
|
} else {
|
||||||
isDestroyingBlock = true;
|
isDestroyingBlock = true;
|
||||||
|
|
@ -164,7 +169,7 @@ void ServerPlayerGameMode::stopDestroyBlock(int x, int y, int z) {
|
||||||
// MGH - removed checking for the destroy progress here, it has
|
// MGH - removed checking for the destroy progress here, it has
|
||||||
// already been checked on the client before it sent the packet.
|
// already been checked on the client before it sent the packet.
|
||||||
// fixes issues with this failing to destroy
|
// fixes issues with this failing to destroy
|
||||||
//because of packets bunching up
|
// because of packets bunching up
|
||||||
// float destroyProgress =
|
// float destroyProgress =
|
||||||
// tile->getDestroyProgress(player, player->level, x, y,
|
// tile->getDestroyProgress(player, player->level, x, y,
|
||||||
// z) * (ticksSpentDestroying + 1); if (destroyProgress
|
// z) * (ticksSpentDestroying + 1); if (destroyProgress
|
||||||
|
|
@ -201,7 +206,7 @@ bool ServerPlayerGameMode::superDestroyBlock(int x, int y, int z) {
|
||||||
oldTile->playerWillDestroy(level, x, y, z, data, player);
|
oldTile->playerWillDestroy(level, x, y, z, data, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changed = level->setTile(x, y, z, 0);
|
bool changed = level->removeTile(x, y, z);
|
||||||
if (oldTile != NULL && changed) {
|
if (oldTile != NULL && changed) {
|
||||||
oldTile->destroy(level, x, y, z, data);
|
oldTile->destroy(level, x, y, z, data);
|
||||||
}
|
}
|
||||||
|
|
@ -209,8 +214,18 @@ bool ServerPlayerGameMode::superDestroyBlock(int x, int y, int z) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerPlayerGameMode::destroyBlock(int x, int y, int z) {
|
bool ServerPlayerGameMode::destroyBlock(int x, int y, int z) {
|
||||||
if (gameModeForPlayer->isReadOnly()) {
|
if (gameModeForPlayer->isAdventureRestricted()) {
|
||||||
return false;
|
if (!player->mayDestroyBlockAt(x, y, z)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameModeForPlayer->isCreative()) {
|
||||||
|
if (player->getCarriedItem() != NULL &&
|
||||||
|
dynamic_cast<WeaponItem*>(player->getCarriedItem()->getItem()) !=
|
||||||
|
NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int t = level->getTile(x, y, z);
|
int t = level->getTile(x, y, z);
|
||||||
|
|
@ -293,17 +308,23 @@ bool ServerPlayerGameMode::useItem(std::shared_ptr<Player> player, Level* level,
|
||||||
int oldCount = item->count;
|
int oldCount = item->count;
|
||||||
int oldAux = item->getAuxValue();
|
int oldAux = item->getAuxValue();
|
||||||
std::shared_ptr<ItemInstance> itemInstance = item->use(level, player);
|
std::shared_ptr<ItemInstance> itemInstance = item->use(level, player);
|
||||||
if ((itemInstance != NULL && itemInstance != item) ||
|
if (itemInstance != item ||
|
||||||
(itemInstance != NULL && itemInstance->count != oldCount) ||
|
(itemInstance != NULL && (itemInstance->count != oldCount ||
|
||||||
(itemInstance != NULL && itemInstance->getUseDuration() > 0)) {
|
itemInstance->getUseDuration() > 0 ||
|
||||||
|
itemInstance->getAuxValue() != oldAux))) {
|
||||||
player->inventory->items[player->inventory->selected] = itemInstance;
|
player->inventory->items[player->inventory->selected] = itemInstance;
|
||||||
if (isCreative()) {
|
if (isCreative()) {
|
||||||
itemInstance->count = oldCount;
|
itemInstance->count = oldCount;
|
||||||
itemInstance->setAuxValue(oldAux);
|
if (itemInstance->isDamageableItem())
|
||||||
|
itemInstance->setAuxValue(oldAux);
|
||||||
}
|
}
|
||||||
if (itemInstance->count == 0) {
|
if (itemInstance->count == 0) {
|
||||||
player->inventory->items[player->inventory->selected] = nullptr;
|
player->inventory->items[player->inventory->selected] = nullptr;
|
||||||
}
|
}
|
||||||
|
if (!player->isUsingItem()) {
|
||||||
|
std::dynamic_pointer_cast<ServerPlayer>(player)->refreshContainer(
|
||||||
|
player->inventoryMenu);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -317,14 +338,16 @@ bool ServerPlayerGameMode::useItemOn(std::shared_ptr<Player> player,
|
||||||
bool bTestUseOnOnly, bool* pbUsedItem) {
|
bool bTestUseOnOnly, bool* pbUsedItem) {
|
||||||
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
||||||
int t = level->getTile(x, y, z);
|
int t = level->getTile(x, y, z);
|
||||||
if (t > 0 && player->isAllowedToUse(Tile::tiles[t])) {
|
if (!player->isSneaking() || player->getCarriedItem() == NULL) {
|
||||||
if (bTestUseOnOnly) {
|
if (t > 0 && player->isAllowedToUse(Tile::tiles[t])) {
|
||||||
if (Tile::tiles[t]->TestUse()) return true;
|
if (bTestUseOnOnly) {
|
||||||
} else {
|
if (Tile::tiles[t]->TestUse()) return true;
|
||||||
if (Tile::tiles[t]->use(level, x, y, z, player, face, clickX,
|
} else {
|
||||||
clickY, clickZ)) {
|
if (Tile::tiles[t]->use(level, x, y, z, player, face, clickX,
|
||||||
if (m_gameRules != NULL) m_gameRules->onUseTile(t, x, y, z);
|
clickY, clickZ)) {
|
||||||
return true;
|
if (m_gameRules != NULL) m_gameRules->onUseTile(t, x, y, z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -25,7 +25,8 @@ private:
|
||||||
bool updatedPlayerVisibility;
|
bool updatedPlayerVisibility;
|
||||||
bool trackDelta;
|
bool trackDelta;
|
||||||
int teleportDelay;
|
int teleportDelay;
|
||||||
std::shared_ptr<Entity> wasRiding;
|
std::shared_ptr<Entity> lastRidingEntity;
|
||||||
|
bool wasRiding;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool moved;
|
bool moved;
|
||||||
|
|
@ -39,6 +40,11 @@ public:
|
||||||
|
|
||||||
void tick(EntityTracker* tracker,
|
void tick(EntityTracker* tracker,
|
||||||
std::vector<std::shared_ptr<Player> >* players);
|
std::vector<std::shared_ptr<Player> >* players);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void sendDirtyEntityData();
|
||||||
|
|
||||||
|
public:
|
||||||
void broadcast(std::shared_ptr<Packet> packet);
|
void broadcast(std::shared_ptr<Packet> packet);
|
||||||
void broadcastAndSend(std::shared_ptr<Packet> packet);
|
void broadcastAndSend(std::shared_ptr<Packet> packet);
|
||||||
void broadcastRemoved();
|
void broadcastRemoved();
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
std::vector<Tile*> User::allowedTiles;
|
std::vector<Tile*> User::allowedTiles;
|
||||||
|
|
||||||
void User::staticCtor() {
|
void User::staticCtor() {
|
||||||
allowedTiles.push_back(Tile::rock);
|
allowedTiles.push_back(Tile::stone);
|
||||||
allowedTiles.push_back(Tile::stoneBrick);
|
allowedTiles.push_back(Tile::cobblestone);
|
||||||
allowedTiles.push_back(Tile::redBrick);
|
allowedTiles.push_back(Tile::redBrick);
|
||||||
allowedTiles.push_back(Tile::dirt);
|
allowedTiles.push_back(Tile::dirt);
|
||||||
allowedTiles.push_back(Tile::wood);
|
allowedTiles.push_back(Tile::wood);
|
||||||
|
|
@ -16,17 +16,17 @@ void User::staticCtor() {
|
||||||
allowedTiles.push_back(Tile::stoneSlabHalf);
|
allowedTiles.push_back(Tile::stoneSlabHalf);
|
||||||
|
|
||||||
allowedTiles.push_back(Tile::glass);
|
allowedTiles.push_back(Tile::glass);
|
||||||
allowedTiles.push_back(Tile::mossStone);
|
allowedTiles.push_back(Tile::mossyCobblestone);
|
||||||
allowedTiles.push_back(Tile::sapling);
|
allowedTiles.push_back(Tile::sapling);
|
||||||
allowedTiles.push_back(Tile::flower);
|
allowedTiles.push_back(Tile::flower);
|
||||||
allowedTiles.push_back(Tile::rose);
|
allowedTiles.push_back(Tile::rose);
|
||||||
allowedTiles.push_back(Tile::mushroom1);
|
allowedTiles.push_back(Tile::mushroom_brown);
|
||||||
allowedTiles.push_back(Tile::mushroom2);
|
allowedTiles.push_back(Tile::mushroom_red);
|
||||||
allowedTiles.push_back(Tile::sand);
|
allowedTiles.push_back(Tile::sand);
|
||||||
allowedTiles.push_back(Tile::gravel);
|
allowedTiles.push_back(Tile::gravel);
|
||||||
allowedTiles.push_back(Tile::sponge);
|
allowedTiles.push_back(Tile::sponge);
|
||||||
|
|
||||||
allowedTiles.push_back(Tile::cloth);
|
allowedTiles.push_back(Tile::wool);
|
||||||
allowedTiles.push_back(Tile::coalOre);
|
allowedTiles.push_back(Tile::coalOre);
|
||||||
allowedTiles.push_back(Tile::ironOre);
|
allowedTiles.push_back(Tile::ironOre);
|
||||||
allowedTiles.push_back(Tile::goldOre);
|
allowedTiles.push_back(Tile::goldOre);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue