Changed tick handler & module list
hopefully fixed 'player moved wrongly' errors & batteries being out of order
This commit is contained in:
parent
3c3d51b5b5
commit
db89ed8edc
4 changed files with 190 additions and 162 deletions
|
@ -23,7 +23,7 @@ public class ItemUtils {
|
|||
public static List<PowerModule> getValidModulesForItem(
|
||||
EntityPlayer player, ItemStack stack) {
|
||||
List<PowerModule> validModules = new ArrayList();
|
||||
for (PowerModule module : ModuleManager.getAllModules().values()) {
|
||||
for (PowerModule module : ModuleManager.getAllModules()) {
|
||||
if (module.isValidForSlot(getAsModular(stack.getItem())
|
||||
.getItemType().ordinal())) {
|
||||
validModules.add(module);
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.machinemuse.powersuits.network.packets;
|
|||
|
||||
import java.io.DataInputStream;
|
||||
|
||||
import net.machinemuse.powersuits.event.MovementManager;
|
||||
import net.machinemuse.powersuits.item.ItemUtils;
|
||||
import net.machinemuse.powersuits.network.MusePacket;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
|
@ -13,21 +14,27 @@ public class MusePacketPlayerUpdate extends MusePacket {
|
|||
|
||||
protected double energyAdjustment;
|
||||
protected double exhaustionAdjustment;
|
||||
protected double newFallDistance;
|
||||
protected double motionX;
|
||||
protected double motionY;
|
||||
protected double motionZ;
|
||||
protected EntityPlayer entityPlayer;
|
||||
|
||||
public MusePacketPlayerUpdate(EntityPlayer player, double energyAdjustment, double exhaustionAdjustment, double newFallDistance) {
|
||||
public MusePacketPlayerUpdate(EntityPlayer player, double energyAdjustment, double exhaustionAdjustment) {
|
||||
super((Player) player);
|
||||
writeDouble(energyAdjustment);
|
||||
writeDouble(exhaustionAdjustment);
|
||||
writeDouble(newFallDistance);
|
||||
writeDouble(player.motionX);
|
||||
writeDouble(player.motionY);
|
||||
writeDouble(player.motionZ);
|
||||
}
|
||||
|
||||
public MusePacketPlayerUpdate(DataInputStream data, Player player) {
|
||||
super(player, data);
|
||||
energyAdjustment = readDouble();
|
||||
exhaustionAdjustment = readDouble();
|
||||
newFallDistance = readDouble();
|
||||
motionX = readDouble();
|
||||
motionY = readDouble();
|
||||
motionZ = readDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,6 +55,10 @@ public class MusePacketPlayerUpdate extends MusePacket {
|
|||
player.addExhaustion((float) exhaustionAdjustment);
|
||||
}
|
||||
|
||||
player.fallDistance = (float) newFallDistance;
|
||||
player.fallDistance = (float) MovementManager.computeFallHeightFromVelocity(motionY);
|
||||
player.motionX = motionX;
|
||||
player.motionY = motionY;
|
||||
player.motionZ = motionZ;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package net.machinemuse.powersuits.powermodule;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.machinemuse.powersuits.item.ItemUtils;
|
||||
|
@ -9,24 +11,26 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
|
||||
public class ModuleManager {
|
||||
|
||||
protected static final Map<String, PowerModule> allModules = new HashMap();
|
||||
protected static final Map<String, PowerModule> moduleMap = new HashMap();
|
||||
protected static final List<PowerModule> moduleList = new ArrayList();
|
||||
|
||||
public static Map<String, PowerModule> getAllModules() {
|
||||
return allModules;
|
||||
public static List<PowerModule> getAllModules() {
|
||||
return moduleList;
|
||||
}
|
||||
|
||||
public static PowerModule getModule(String key) {
|
||||
return allModules.get(key);
|
||||
return moduleMap.get(key);
|
||||
}
|
||||
|
||||
public static void addModule(PowerModule module) {
|
||||
allModules.put(module.getName(), module);
|
||||
moduleMap.put(module.getName(), module);
|
||||
moduleList.add(module);
|
||||
}
|
||||
|
||||
public static double computeModularProperty(ItemStack stack, String propertyName) {
|
||||
double propertyValue = 0;
|
||||
NBTTagCompound itemTag = ItemUtils.getMuseItemTag(stack);
|
||||
for (PowerModule module : allModules.values()) {
|
||||
for (PowerModule module : moduleList) {
|
||||
propertyValue = module.applyPropertyModifiers(itemTag, propertyName, propertyValue);
|
||||
}
|
||||
return propertyValue;
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.machinemuse.powersuits.network.packets.MusePacketPlayerUpdate;
|
|||
import net.machinemuse.powersuits.powermodule.ModuleManager;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -41,182 +42,194 @@ public class PlayerTickHandlerClient implements ITickHandler {
|
|||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.CLIENT && rawPlayer instanceof EntityClientPlayerMP) {
|
||||
EntityClientPlayerMP player = (EntityClientPlayerMP) rawPlayer;
|
||||
handleClient(player);
|
||||
} else if((side == Side.SERVER) && (rawPlayer instanceof EntityPlayerMP)) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) rawPlayer;
|
||||
handleServer(player);
|
||||
}
|
||||
|
||||
ItemStack helmet = player.getCurrentArmor(3);
|
||||
ItemStack torso = player.getCurrentArmor(2);
|
||||
ItemStack pants = player.getCurrentArmor(1);
|
||||
ItemStack boots = player.getCurrentArmor(0);
|
||||
ItemStack tool = player.getCurrentEquippedItem();
|
||||
}
|
||||
public void handleClient(EntityClientPlayerMP player) {
|
||||
|
||||
double totalEnergy = ItemUtils.getPlayerEnergy(player);
|
||||
double totalWeight = ItemUtils.getPlayerWeight(player);
|
||||
double weightCapacity = 25000;
|
||||
ItemStack helmet = player.getCurrentArmor(3);
|
||||
ItemStack torso = player.getCurrentArmor(2);
|
||||
ItemStack pants = player.getCurrentArmor(1);
|
||||
ItemStack boots = player.getCurrentArmor(0);
|
||||
ItemStack tool = player.getCurrentEquippedItem();
|
||||
|
||||
double totalEnergyDrain = 0;
|
||||
double exhaustionAdjustment = 0;
|
||||
double totalEnergy = ItemUtils.getPlayerEnergy(player);
|
||||
double totalWeight = ItemUtils.getPlayerWeight(player);
|
||||
double weightCapacity = 25000;
|
||||
|
||||
double landMovementFactor = 0.1;
|
||||
double jumpMovementFactor = 0.02;
|
||||
double horzMovement = Math.sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ);
|
||||
double exhaustion = Math.round(horzMovement * 100.0F) * 0.01;
|
||||
double totalEnergyDrain = 0;
|
||||
double exhaustionAdjustment = 0;
|
||||
|
||||
Vec3 playerHorzFacing = player.getLookVec();
|
||||
playerHorzFacing.yCoord = 0;
|
||||
playerHorzFacing.normalize();
|
||||
double landMovementFactor = 0.1;
|
||||
double jumpMovementFactor = 0.02;
|
||||
double horzMovement = Math.sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ);
|
||||
double exhaustion = Math.round(horzMovement * 100.0F) * 0.01;
|
||||
|
||||
boolean jumpkey = player.movementInput.jump;
|
||||
float forwardkey = player.movementInput.moveForward;
|
||||
float strafekey = player.movementInput.moveStrafe;
|
||||
boolean sneakkey = player.movementInput.sneak;
|
||||
Vec3 playerHorzFacing = player.getLookVec();
|
||||
playerHorzFacing.yCoord = 0;
|
||||
playerHorzFacing.normalize();
|
||||
|
||||
boolean hasSprintAssist = false;
|
||||
boolean hasGlider = false;
|
||||
boolean hasParachute = false;
|
||||
boolean hasJetpack = false;
|
||||
boolean hasJetboots = false;
|
||||
boolean hasJumpAssist = false;
|
||||
boolean hasSwimAssist = false;
|
||||
boolean jumpkey = player.movementInput.jump;
|
||||
float forwardkey = player.movementInput.moveForward;
|
||||
float strafekey = player.movementInput.moveStrafe;
|
||||
boolean sneakkey = player.movementInput.sneak;
|
||||
|
||||
if (pants != null && pants.getItem() instanceof IModularItem) {
|
||||
hasSprintAssist = ItemUtils.itemHasModule(pants, ModularCommon.MODULE_SPRINT_ASSIST);
|
||||
hasJumpAssist = ItemUtils.itemHasModule(pants, ModularCommon.MODULE_JUMP_ASSIST);
|
||||
hasSwimAssist = ItemUtils.itemHasModule(pants, ModularCommon.MODULE_SWIM_BOOST);
|
||||
boolean hasSprintAssist = false;
|
||||
boolean hasGlider = false;
|
||||
boolean hasParachute = false;
|
||||
boolean hasJetpack = false;
|
||||
boolean hasJetboots = false;
|
||||
boolean hasJumpAssist = false;
|
||||
boolean hasSwimAssist = false;
|
||||
|
||||
if (pants != null && pants.getItem() instanceof IModularItem) {
|
||||
hasSprintAssist = ItemUtils.itemHasModule(pants, ModularCommon.MODULE_SPRINT_ASSIST);
|
||||
hasJumpAssist = ItemUtils.itemHasModule(pants, ModularCommon.MODULE_JUMP_ASSIST);
|
||||
hasSwimAssist = ItemUtils.itemHasModule(pants, ModularCommon.MODULE_SWIM_BOOST);
|
||||
}
|
||||
if (boots != null && boots.getItem() instanceof IModularItem) {
|
||||
hasJetboots = ItemUtils.itemHasModule(boots, ModularCommon.MODULE_JETBOOTS);
|
||||
}
|
||||
if (torso != null && torso.getItem() instanceof IModularItem) {
|
||||
hasJetpack = ItemUtils.itemHasModule(torso, ModularCommon.MODULE_JETPACK);
|
||||
hasGlider = ItemUtils.itemHasModule(torso, ModularCommon.MODULE_GLIDER);
|
||||
hasParachute = ItemUtils.itemHasModule(torso, ModularCommon.MODULE_PARACHUTE);
|
||||
}
|
||||
|
||||
if (player.isInWater()) {
|
||||
if (hasSwimAssist && (forwardkey != 0 || strafekey != 0 || jumpkey || sneakkey)) {
|
||||
double moveRatio = 0;
|
||||
if (forwardkey != 0) {
|
||||
moveRatio += forwardkey * forwardkey;
|
||||
}
|
||||
if (strafekey != 0) {
|
||||
moveRatio += strafekey * strafekey;
|
||||
}
|
||||
if (jumpkey || sneakkey) {
|
||||
moveRatio += 0.2 * 0.2;
|
||||
}
|
||||
double swimAssistRate = ModuleManager.computeModularProperty(pants, ModularCommon.SWIM_BOOST_AMOUNT) * 0.05;
|
||||
double swimEnergyConsumption = ModuleManager.computeModularProperty(pants, ModularCommon.SWIM_BOOST_ENERGY_CONSUMPTION);
|
||||
if (swimEnergyConsumption + totalEnergyDrain < totalEnergy) {
|
||||
totalEnergyDrain += swimEnergyConsumption;
|
||||
// Forward/backward movement
|
||||
player.motionX += player.getLookVec().xCoord * swimAssistRate * forwardkey / moveRatio;
|
||||
player.motionY += player.getLookVec().yCoord * swimAssistRate * forwardkey / moveRatio;
|
||||
player.motionZ += player.getLookVec().zCoord * swimAssistRate * forwardkey / moveRatio;
|
||||
|
||||
if (jumpkey) {
|
||||
player.motionY += swimAssistRate * 0.2 / moveRatio;
|
||||
}
|
||||
|
||||
if (sneakkey) {
|
||||
player.motionY -= swimAssistRate * 0.2 / moveRatio;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (boots != null && boots.getItem() instanceof IModularItem) {
|
||||
hasJetboots = ItemUtils.itemHasModule(boots, ModularCommon.MODULE_JETBOOTS);
|
||||
}
|
||||
if (torso != null && torso.getItem() instanceof IModularItem) {
|
||||
hasJetpack = ItemUtils.itemHasModule(torso, ModularCommon.MODULE_JETPACK);
|
||||
hasGlider = ItemUtils.itemHasModule(torso, ModularCommon.MODULE_GLIDER);
|
||||
hasParachute = ItemUtils.itemHasModule(torso, ModularCommon.MODULE_PARACHUTE);
|
||||
}
|
||||
|
||||
if (player.isInWater()) {
|
||||
if (hasSwimAssist && (forwardkey != 0 || strafekey != 0 || jumpkey || sneakkey)) {
|
||||
double moveRatio = 0;
|
||||
if (forwardkey != 0) {
|
||||
moveRatio += forwardkey * forwardkey;
|
||||
}
|
||||
if (strafekey != 0) {
|
||||
moveRatio += strafekey * strafekey;
|
||||
}
|
||||
if (jumpkey || sneakkey) {
|
||||
moveRatio += 0.2 * 0.2;
|
||||
}
|
||||
double swimAssistRate = ModuleManager.computeModularProperty(pants, ModularCommon.SWIM_BOOST_AMOUNT) * 0.05;
|
||||
double swimEnergyConsumption = ModuleManager.computeModularProperty(pants, ModularCommon.SWIM_BOOST_ENERGY_CONSUMPTION);
|
||||
if (swimEnergyConsumption + totalEnergyDrain < totalEnergy) {
|
||||
totalEnergyDrain += swimEnergyConsumption;
|
||||
// Forward/backward movement
|
||||
player.motionX += player.getLookVec().xCoord * swimAssistRate * forwardkey / moveRatio;
|
||||
player.motionY += player.getLookVec().yCoord * swimAssistRate * forwardkey / moveRatio;
|
||||
player.motionZ += player.getLookVec().zCoord * swimAssistRate * forwardkey / moveRatio;
|
||||
|
||||
if (jumpkey) {
|
||||
player.motionY += swimAssistRate * 0.2 / moveRatio;
|
||||
}
|
||||
|
||||
if (sneakkey) {
|
||||
player.motionY -= swimAssistRate * 0.2 / moveRatio;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Jump Assist
|
||||
if (hasJumpAssist && jumpkey) {
|
||||
double multiplier = MovementManager.getPlayerJumpMultiplier(player);
|
||||
if (multiplier > 0) {
|
||||
player.motionY += 0.15 * Math.min(multiplier, 1) * getWeightPenaltyRatio(totalWeight, weightCapacity);
|
||||
MovementManager.setPlayerJumpTicks(player, multiplier - 1);
|
||||
}
|
||||
} else {
|
||||
// Jump Assist
|
||||
if (hasJumpAssist && jumpkey) {
|
||||
double multiplier = MovementManager.getPlayerJumpMultiplier(player);
|
||||
if (multiplier > 0) {
|
||||
player.motionY += 0.15 * Math.min(multiplier, 1) * getWeightPenaltyRatio(totalWeight, weightCapacity);
|
||||
MovementManager.setPlayerJumpTicks(player, multiplier - 1);
|
||||
}
|
||||
} else {
|
||||
MovementManager.setPlayerJumpTicks(player, 0);
|
||||
MovementManager.setPlayerJumpTicks(player, 0);
|
||||
}
|
||||
|
||||
// Jetpack & jetboots
|
||||
if ((hasJetpack || hasJetboots) && jumpkey && player.motionY < 0.5) {
|
||||
double jetEnergy = 0;
|
||||
double thrust = 0;
|
||||
if (hasJetpack) {
|
||||
jetEnergy += ModuleManager.computeModularProperty(torso, ModularCommon.JET_ENERGY_CONSUMPTION);
|
||||
thrust += ModuleManager.computeModularProperty(torso, ModularCommon.JET_THRUST);
|
||||
}
|
||||
|
||||
// Jetpack & jetboots
|
||||
if ((hasJetpack || hasJetboots) && jumpkey && player.motionY < 0.5) {
|
||||
double jetEnergy = 0;
|
||||
double thrust = 0;
|
||||
if (hasJetpack) {
|
||||
jetEnergy += ModuleManager.computeModularProperty(torso, ModularCommon.JET_ENERGY_CONSUMPTION);
|
||||
thrust += ModuleManager.computeModularProperty(torso, ModularCommon.JET_THRUST);
|
||||
}
|
||||
if (hasJetboots) {
|
||||
jetEnergy += ModuleManager.computeModularProperty(boots, ModularCommon.JET_ENERGY_CONSUMPTION);
|
||||
thrust += ModuleManager.computeModularProperty(boots, ModularCommon.JET_THRUST);
|
||||
}
|
||||
if (jetEnergy + totalEnergyDrain < totalEnergy) {
|
||||
totalEnergyDrain += jetEnergy;
|
||||
thrust *= getWeightPenaltyRatio(totalWeight, weightCapacity);
|
||||
if (forwardkey == 0) {
|
||||
player.motionY += thrust;
|
||||
} else {
|
||||
player.motionY += thrust / 2;
|
||||
player.motionX += playerHorzFacing.xCoord * thrust / 2 * Math.signum(forwardkey);
|
||||
player.motionZ += playerHorzFacing.zCoord * thrust / 2 * Math.signum(forwardkey);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasJetboots) {
|
||||
jetEnergy += ModuleManager.computeModularProperty(boots, ModularCommon.JET_ENERGY_CONSUMPTION);
|
||||
thrust += ModuleManager.computeModularProperty(boots, ModularCommon.JET_THRUST);
|
||||
}
|
||||
|
||||
// Glider
|
||||
if (hasGlider && sneakkey && player.motionY < -0.1 && (!hasParachute || forwardkey > 0)) {
|
||||
if (player.motionY < -0.1) {
|
||||
double motionYchange = Math.min(0.08, -0.1 - player.motionY);
|
||||
player.motionY += motionYchange;
|
||||
player.motionX += playerHorzFacing.xCoord * motionYchange;
|
||||
player.motionZ += playerHorzFacing.zCoord * motionYchange;
|
||||
|
||||
// sprinting speed
|
||||
player.jumpMovementFactor += 0.03f;
|
||||
if (jetEnergy + totalEnergyDrain < totalEnergy) {
|
||||
totalEnergyDrain += jetEnergy;
|
||||
thrust *= getWeightPenaltyRatio(totalWeight, weightCapacity);
|
||||
if (forwardkey == 0) {
|
||||
player.motionY += thrust;
|
||||
} else {
|
||||
player.motionY += thrust / 2;
|
||||
player.motionX += playerHorzFacing.xCoord * thrust / 2 * Math.signum(forwardkey);
|
||||
player.motionZ += playerHorzFacing.zCoord * thrust / 2 * Math.signum(forwardkey);
|
||||
}
|
||||
}
|
||||
|
||||
// Parachute
|
||||
if (hasParachute && sneakkey && player.motionY < -0.1 && (!hasGlider || forwardkey <= 0)) {
|
||||
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()) {
|
||||
double sprintCost = ModuleManager.computeModularProperty(pants, ModularCommon.SPRINT_ENERGY_CONSUMPTION);
|
||||
if (sprintCost + totalEnergyDrain < totalEnergy) {
|
||||
double sprintMultiplier = ModuleManager.computeModularProperty(pants, ModularCommon.SPRINT_SPEED_MULTIPLIER);
|
||||
double exhaustionComp = ModuleManager.computeModularProperty(pants, ModularCommon.SPRINT_FOOD_COMPENSATION);
|
||||
totalEnergyDrain += sprintCost;
|
||||
player.landMovementFactor *= sprintMultiplier;
|
||||
// Glider
|
||||
if (hasGlider && sneakkey && player.motionY < -0.1 && (!hasParachute || forwardkey > 0)) {
|
||||
if (player.motionY < -0.1) {
|
||||
double motionYchange = Math.min(0.08, -0.1 - player.motionY);
|
||||
player.motionY += motionYchange;
|
||||
player.motionX += playerHorzFacing.xCoord * motionYchange;
|
||||
player.motionZ += playerHorzFacing.zCoord * motionYchange;
|
||||
|
||||
exhaustionComp += -0.01 * exhaustion * exhaustionComp;
|
||||
}
|
||||
// sprinting speed
|
||||
player.jumpMovementFactor += 0.03f;
|
||||
}
|
||||
}
|
||||
|
||||
// Update fall distance for damage, energy drain, and
|
||||
// exhaustion
|
||||
// this tick
|
||||
double fallDistance = MovementManager.computeFallHeightFromVelocity(player.motionY);
|
||||
|
||||
if (totalEnergyDrain > 0) {
|
||||
ItemUtils.drainPlayerEnergy(player, totalEnergyDrain);
|
||||
} else {
|
||||
ItemUtils.givePlayerEnergy(player, -totalEnergyDrain);
|
||||
// Parachute
|
||||
if (hasParachute && sneakkey && player.motionY < -0.1 && (!hasGlider || forwardkey <= 0)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
player.addExhaustion((float) (exhaustionAdjustment));
|
||||
MusePacket packet = new MusePacketPlayerUpdate(player, -totalEnergyDrain, exhaustionAdjustment, fallDistance);
|
||||
player.sendQueue.addToSendQueue(packet.getPacket250());
|
||||
// Sprint assist
|
||||
if (hasSprintAssist && player.isSprinting()) {
|
||||
double sprintCost = ModuleManager.computeModularProperty(pants, ModularCommon.SPRINT_ENERGY_CONSUMPTION);
|
||||
if (sprintCost + totalEnergyDrain < totalEnergy) {
|
||||
double sprintMultiplier = ModuleManager.computeModularProperty(pants, ModularCommon.SPRINT_SPEED_MULTIPLIER);
|
||||
double exhaustionComp = ModuleManager.computeModularProperty(pants, ModularCommon.SPRINT_FOOD_COMPENSATION);
|
||||
totalEnergyDrain += sprintCost;
|
||||
player.landMovementFactor *= sprintMultiplier;
|
||||
|
||||
// Weight movement penalty
|
||||
if (totalWeight > weightCapacity) {
|
||||
player.motionX *= weightCapacity / totalWeight;
|
||||
player.motionZ *= weightCapacity / totalWeight;
|
||||
exhaustionComp += -0.01 * exhaustion * exhaustionComp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update fall distance for damage, energy drain, and
|
||||
// exhaustion
|
||||
// this ticki
|
||||
player.fallDistance = (float) MovementManager.computeFallHeightFromVelocity(player.motionY);
|
||||
|
||||
if (totalEnergyDrain > 0) {
|
||||
ItemUtils.drainPlayerEnergy(player, totalEnergyDrain);
|
||||
} else {
|
||||
ItemUtils.givePlayerEnergy(player, -totalEnergyDrain);
|
||||
}
|
||||
|
||||
player.addExhaustion((float) (exhaustionAdjustment));
|
||||
|
||||
// Weight movement penalty
|
||||
if (totalWeight > weightCapacity) {
|
||||
player.motionX *= weightCapacity / totalWeight;
|
||||
player.motionZ *= weightCapacity / totalWeight;
|
||||
}
|
||||
|
||||
MusePacket packet = new MusePacketPlayerUpdate(player, -totalEnergyDrain, exhaustionAdjustment);
|
||||
player.sendQueue.addToSendQueue(packet.getPacket250());
|
||||
|
||||
}
|
||||
public void handleServer(EntityPlayerMP player) {
|
||||
|
||||
}
|
||||
|
||||
public static double getWeightPenaltyRatio(double currentWeight, double capacity) {
|
||||
|
|
Loading…
Reference in a new issue