feat: remove sprinting
This commit is contained in:
1 parent
5b198d7b31
commit
bdfe5350cd
14 files changed
+18
-196
No files matched your search
@@ -60,7 +60,6 @@ LocalPlayer::LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dim
|
||||
flyX = flyY = flyZ = 0.0f; // 4J added
|
||||
m_awardedThisSession = 0;
|
||||
|
||||
sprintTriggerTime = 0;
|
||||
sprintTriggerRegisteredReturn = false;
|
||||
twoJumpsRegistered = false;
|
||||
sprintTime = 0;
|
||||
@@ -218,15 +217,6 @@ bool LocalPlayer::isEffectiveAI()
|
||||
|
||||
void LocalPlayer::aiStep()
|
||||
{
|
||||
if (sprintTime > 0)
|
||||
{
|
||||
sprintTime--;
|
||||
if (sprintTime == 0)
|
||||
{
|
||||
setSprinting(false);
|
||||
}
|
||||
}
|
||||
if (sprintTriggerTime > 0) sprintTriggerTime--;
|
||||
if (minecraft->gameMode->isCutScene())
|
||||
{
|
||||
x = z = 0.5;
|
||||
@@ -283,7 +273,6 @@ void LocalPlayer::aiStep()
|
||||
{
|
||||
input->xa *= 0.2f;
|
||||
input->ya *= 0.2f;
|
||||
sprintTriggerTime = 0;
|
||||
}
|
||||
// this.heightOffset = input.sneaking?1.30f:1.62f; // 4J - this was already commented out
|
||||
if (input->sneaking) // 4J - removed - TODO replace
|
||||
@@ -296,45 +285,6 @@ void LocalPlayer::aiStep()
|
||||
checkInTile(x + bbWidth * 0.35, bb->y0 + 0.5, z - bbWidth * 0.35);
|
||||
checkInTile(x + bbWidth * 0.35, bb->y0 + 0.5, z + bbWidth * 0.35);
|
||||
|
||||
bool enoughFoodToSprint = getFoodData()->getFoodLevel() > FoodConstants::MAX_FOOD * FoodConstants::FOOD_SATURATION_LOW;
|
||||
|
||||
// 4J Stu - If we can fly, then we should be able to sprint without requiring food. This is particularly a problem for people who save a survival
|
||||
// world with low food, then reload it in creative.
|
||||
if(abilities.mayfly || isAllowedToFly() ) enoughFoodToSprint = true;
|
||||
|
||||
// 4J - altered this slightly to make sure that the joypad returns to below returnTreshold in between registering two movements up to runThreshold
|
||||
if (onGround && !isSprinting() && enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness))
|
||||
{
|
||||
if( !wasRunning && input->ya >= runTreshold )
|
||||
{
|
||||
if (sprintTriggerTime == 0)
|
||||
{
|
||||
sprintTriggerTime = 7;
|
||||
sprintTriggerRegisteredReturn = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( sprintTriggerRegisteredReturn )
|
||||
{
|
||||
setSprinting(true);
|
||||
sprintTriggerTime = 0;
|
||||
sprintTriggerRegisteredReturn = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( ( sprintTriggerTime > 0 ) && ( input->ya == 0.0f ) ) // ya of 0.0f here signifies that we have returned to the deadzone
|
||||
{
|
||||
sprintTriggerRegisteredReturn = true;
|
||||
}
|
||||
}
|
||||
if (isSneaking()) sprintTriggerTime = 0;
|
||||
// 4J-PB - try not stopping sprint on collision
|
||||
//if (isSprinting() && (input->ya < runTreshold || horizontalCollision || !enoughFoodToSprint))
|
||||
if (isSprinting() && (input->ya < runTreshold || !enoughFoodToSprint))
|
||||
{
|
||||
setSprinting(false);
|
||||
}
|
||||
|
||||
// 4J Stu - Fix for #52705 - Customer Encountered: Player can fly in bed while being in Creative mode.
|
||||
if (!isSleeping() && (abilities.mayfly || isAllowedToFly() ))
|
||||
{
|
||||
@@ -437,33 +387,16 @@ void LocalPlayer::aiStep()
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if( isSprinting() )
|
||||
flyX = 0.0f;
|
||||
flyY = 0.0f;
|
||||
flyZ = 0.0f;
|
||||
if( ullDpad_filtered & (1LL<<MINECRAFT_ACTION_DPAD_UP))
|
||||
{
|
||||
// Accelrate up to full speed if we are sprinting, moving in the direction of the view vector
|
||||
flyX = (float)viewVector->x * input->ya;
|
||||
flyY = (float)viewVector->y * input->ya;
|
||||
flyZ = (float)viewVector->z * input->ya;
|
||||
|
||||
float scale = ((float)(SPRINT_DURATION - sprintTime))/10.0f;
|
||||
scale = scale * scale;
|
||||
if ( scale > 1.0f ) scale = 1.0f;
|
||||
flyX *= scale;
|
||||
flyY *= scale;
|
||||
flyZ *= scale;
|
||||
flyY = 0.1f;
|
||||
}
|
||||
else
|
||||
if( ullDpad_filtered & (1LL<<MINECRAFT_ACTION_DPAD_DOWN))
|
||||
{
|
||||
flyX = 0.0f;
|
||||
flyY = 0.0f;
|
||||
flyZ = 0.0f;
|
||||
if( ullDpad_filtered & (1LL<<MINECRAFT_ACTION_DPAD_UP))
|
||||
{
|
||||
flyY = 0.1f;
|
||||
}
|
||||
if( ullDpad_filtered & (1LL<<MINECRAFT_ACTION_DPAD_DOWN))
|
||||
{
|
||||
flyY = -0.1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,13 +1044,6 @@ bool LocalPlayer::checkInTile(double x, double y, double z)
|
||||
|
||||
}
|
||||
|
||||
void LocalPlayer::setSprinting(bool value)
|
||||
{
|
||||
Player::setSprinting(value);
|
||||
if (value == false) sprintTime = 0;
|
||||
else sprintTime = SPRINT_DURATION;
|
||||
}
|
||||
|
||||
void LocalPlayer::setExperienceValues(float experienceProgress, int totalExp, int experienceLevel)
|
||||
{
|
||||
this->experienceProgress = experienceProgress;
|
||||
@@ -1236,13 +1162,6 @@ bool LocalPlayer::creativeModeHandleMouseClick(int button, bool buttonPressed)
|
||||
// If we're in disabled mode already (set when sprinting) then don't do anything - if we're sprinting, we don't auto-repeat at all.
|
||||
// With auto repeat on, we can quickly place fires causing photosensitivity issues due to rapid flashing
|
||||
if( lastClickState == lastClick_disabled ) return false;
|
||||
// If we've started sprinting, go into this mode & also don't do anything
|
||||
// Ignore repeate when sleeping
|
||||
if( isSprinting() )
|
||||
{
|
||||
lastClickState = lastClick_disabled;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get distance from last click point in each axis
|
||||
float dX = (float)x - lastClickX;
|
||||
@@ -1360,7 +1279,7 @@ bool LocalPlayer::creativeModeHandleMouseClick(int button, bool buttonPressed)
|
||||
bool itemPlaced = handleMouseClick(button);
|
||||
// If we're sprinting or riding, don't auto-repeat at all. With auto repeat on, we can quickly place fires causing photosensitivity issues due to rapid flashing
|
||||
// Also ignore repeats when the player is sleeping
|
||||
if( isSprinting() || isRiding() || isSleeping() )
|
||||
if( isRiding() || isSleeping() )
|
||||
{
|
||||
lastClickState = lastClick_disabled;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user