mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-22 16:03:31 +00:00
Fixes and enhancements from my MCPE repository. (https://github.com/mschiller890/mcpe64)
This commit is contained in:
@@ -50,7 +50,10 @@ LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user, int dim
|
||||
sentInventoryItemId(-1),
|
||||
sentInventoryItemData(-1),
|
||||
autoJumpEnabled(true),
|
||||
armorTypeHash(0)
|
||||
armorTypeHash(0),
|
||||
sprinting(false),
|
||||
sprintDoubleTapTimer(0),
|
||||
prevForwardHeld(false)
|
||||
{
|
||||
this->dimension = dimension;
|
||||
_init();
|
||||
@@ -176,6 +179,25 @@ void LocalPlayer::aiStep() {
|
||||
if (!screenCovering)
|
||||
input->tick(this);
|
||||
|
||||
// Sprint: detect W double-tap
|
||||
{
|
||||
bool forwardHeld = (input->ya > 0);
|
||||
if (forwardHeld && !prevForwardHeld) {
|
||||
// leading edge of W press
|
||||
if (sprintDoubleTapTimer > 0)
|
||||
sprinting = true;
|
||||
else
|
||||
sprintDoubleTapTimer = 7;
|
||||
}
|
||||
if (!forwardHeld) {
|
||||
sprinting = false;
|
||||
}
|
||||
if (sprintDoubleTapTimer > 0) sprintDoubleTapTimer--;
|
||||
prevForwardHeld = forwardHeld;
|
||||
}
|
||||
if (input->sneaking || abilities.flying)
|
||||
sprinting = false;
|
||||
|
||||
if (input->sneaking) {
|
||||
if (ySlideOffset < 0.2f) ySlideOffset = 0.2f;
|
||||
}
|
||||
@@ -296,6 +318,10 @@ void LocalPlayer::releaseAllKeys()
|
||||
if (input) input->releaseAllKeys();
|
||||
}
|
||||
|
||||
float LocalPlayer::getWalkingSpeedModifier() {
|
||||
return sprinting ? 1.3f : 1.0f;
|
||||
}
|
||||
|
||||
float LocalPlayer::getFieldOfViewModifier() {
|
||||
float targetFov = 1.0f;
|
||||
if(abilities.flying) targetFov *= 1.1f;
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
|
||||
void swing();
|
||||
virtual void openTextEdit( TileEntity* tileEntity );
|
||||
virtual float getWalkingSpeedModifier();
|
||||
private:
|
||||
void calculateFlight(float xa, float ya, float za);
|
||||
bool isSolidTile(int x, int y, int z);
|
||||
@@ -99,6 +100,11 @@ private:
|
||||
int sentInventoryItemData;
|
||||
|
||||
int armorTypeHash;
|
||||
|
||||
// sprinting
|
||||
bool sprinting;
|
||||
int sprintDoubleTapTimer;
|
||||
bool prevForwardHeld;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_PLAYER__LocalPlayer_H__*/
|
||||
|
||||
Reference in New Issue
Block a user