Adding weight penalty to thrust

This commit is contained in:
MachineMuse 2013-01-14 22:55:26 -07:00
parent f6cd0ecc83
commit e8a8a4ea40

View file

@ -126,7 +126,7 @@ public class PlayerTickHandlerClient implements ITickHandler {
if (hasJumpAssist && jumpkey) {
double multiplier = MovementManager.getPlayerJumpMultiplier(player);
if (multiplier > 0) {
player.motionY += 0.15 * Math.min(multiplier, 1);
player.motionY += 0.15 * Math.min(multiplier, 1) * getWeightPenaltyRatio(totalWeight, weightCapacity);
MovementManager.setPlayerJumpTicks(player, multiplier - 1);
}
} else {
@ -147,6 +147,7 @@ public class PlayerTickHandlerClient implements ITickHandler {
}
if (jetEnergy + totalEnergyDrain < totalEnergy) {
totalEnergyDrain += jetEnergy;
thrust *= getWeightPenaltyRatio(totalWeight, weightCapacity);
if (forwardkey == 0) {
player.motionY += thrust;
} else {
@ -173,11 +174,13 @@ public class PlayerTickHandlerClient implements ITickHandler {
// Parachute
if (hasParachute && sneakkey && player.motionY < -0.1 && (!hasGlider || forwardkey <= 0)) {
double totalVelocity = Math.sqrt(horzMovement * horzMovement + player.motionY * player.motionY);
double totalVelocity = Math.sqrt(horzMovement * horzMovement + player.motionY * player.motionY)*getWeightPenaltyRatio(totalWeight, weightCapacity);
if (totalVelocity > 0) {
player.motionX = player.motionX * 0.1 / totalVelocity;
player.motionY = player.motionY * 0.1 / totalVelocity;
player.motionZ = player.motionZ * 0.1 / totalVelocity;
}
}
// Sprint assist
if (hasSprintAssist && player.isSprinting()) {
@ -193,7 +196,8 @@ public class PlayerTickHandlerClient implements ITickHandler {
}
}
// Update fall distance for damage, energy drain, and exhaustion
// Update fall distance for damage, energy drain, and
// exhaustion
// this tick
double fallDistance = MovementManager.computeFallHeightFromVelocity(player.motionY);
@ -215,6 +219,14 @@ public class PlayerTickHandlerClient implements ITickHandler {
}
}
public static double getWeightPenaltyRatio(double currentWeight, double capacity) {
if (currentWeight < capacity) {
return 1;
} else {
return capacity / currentWeight;
}
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
EntityPlayer player = toPlayer(tickData[0]);