Migrated all PlayerTickHandler modules into their respective classes :)
This commit is contained in:
parent
7f2de861b1
commit
4809b71b82
14 changed files with 807 additions and 331 deletions
|
@ -14,10 +14,19 @@ import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
import net.machinemuse.powersuits.powermodule.PowerModule;
|
import net.machinemuse.powersuits.powermodule.PowerModule;
|
||||||
import net.machinemuse.powersuits.powermodule.ToggleablePowerModule;
|
import net.machinemuse.powersuits.powermodule.ToggleablePowerModule;
|
||||||
import net.machinemuse.powersuits.powermodule.modules.BlinkDriveModule;
|
import net.machinemuse.powersuits.powermodule.modules.BlinkDriveModule;
|
||||||
|
import net.machinemuse.powersuits.powermodule.modules.FlightControlModule;
|
||||||
|
import net.machinemuse.powersuits.powermodule.modules.GliderModule;
|
||||||
|
import net.machinemuse.powersuits.powermodule.modules.InvisibilityModule;
|
||||||
|
import net.machinemuse.powersuits.powermodule.modules.JetBootsModule;
|
||||||
|
import net.machinemuse.powersuits.powermodule.modules.JetPackModule;
|
||||||
|
import net.machinemuse.powersuits.powermodule.modules.JumpAssistModule;
|
||||||
|
import net.machinemuse.powersuits.powermodule.modules.NightVisionModule;
|
||||||
|
import net.machinemuse.powersuits.powermodule.modules.ParachuteModule;
|
||||||
import net.machinemuse.powersuits.powermodule.modules.PlasmaCannonModule;
|
import net.machinemuse.powersuits.powermodule.modules.PlasmaCannonModule;
|
||||||
import net.machinemuse.powersuits.powermodule.modules.RailgunModule;
|
import net.machinemuse.powersuits.powermodule.modules.RailgunModule;
|
||||||
import net.machinemuse.powersuits.powermodule.modules.SprintAssistModule;
|
import net.machinemuse.powersuits.powermodule.modules.SprintAssistModule;
|
||||||
import net.machinemuse.powersuits.powermodule.modules.StepAssistModule;
|
import net.machinemuse.powersuits.powermodule.modules.StepAssistModule;
|
||||||
|
import net.machinemuse.powersuits.powermodule.modules.SwimAssistModule;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -188,22 +197,6 @@ public class Config {
|
||||||
|
|
||||||
IPowerModule module;
|
IPowerModule module;
|
||||||
|
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_NIGHT_VISION, HEADONLY, MuseIcon.SCANNER, MuseCommonStrings.CATEGORY_SPECIAL)
|
|
||||||
.setDescription("A pair of augmented vision goggles to help you see at night and underwater.")
|
|
||||||
.addInstallCost(copyAndResize(ItemComponent.laserHologram, 1)).addInstallCost(copyAndResize(ItemComponent.controlCircuit, 1));
|
|
||||||
addModule(module);
|
|
||||||
|
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_ACTIVE_CAMOUFLAGE, TORSOONLY, MuseIcon.ORB_1_BLUE,
|
|
||||||
MuseCommonStrings.CATEGORY_SPECIAL).setDescription("Emit a hologram of your surroundings to make yourself almost imperceptible.")
|
|
||||||
.addInstallCost(copyAndResize(ItemComponent.laserHologram, 4)).addInstallCost(copyAndResize(ItemComponent.fieldEmitter, 2))
|
|
||||||
.addInstallCost(copyAndResize(ItemComponent.controlCircuit, 2));
|
|
||||||
addModule(module);
|
|
||||||
|
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_FLIGHT_CONTROL, HEADONLY, MuseIcon.INDICATOR_1_GREEN,
|
|
||||||
MuseCommonStrings.CATEGORY_SPECIAL).setDescription("An integrated control circuit to help you fly better. Press Z to go down.")
|
|
||||||
.addInstallCost(copyAndResize(ItemComponent.controlCircuit, 1));
|
|
||||||
addModule(module);
|
|
||||||
|
|
||||||
addModule(new PlasmaCannonModule(TOOLONLY));
|
addModule(new PlasmaCannonModule(TOOLONLY));
|
||||||
|
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_MELEE_ASSIST, TOOLONLY, MuseIcon.PUNCHY, MuseCommonStrings.CATEGORY_WEAPON)
|
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_MELEE_ASSIST, TOOLONLY, MuseIcon.PUNCHY, MuseCommonStrings.CATEGORY_WEAPON)
|
||||||
|
@ -301,14 +294,16 @@ public class Config {
|
||||||
addModule(module);
|
addModule(module);
|
||||||
|
|
||||||
addModule(new SprintAssistModule());
|
addModule(new SprintAssistModule());
|
||||||
|
addModule(new JumpAssistModule());
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_JUMP_ASSIST, LEGSONLY, MuseIcon.JUMP_ASSIST, MuseCommonStrings.CATEGORY_MOVEMENT)
|
addModule(new SwimAssistModule());
|
||||||
.setDescription("Another set of servo motors to help you jump higher.")
|
addModule(new StepAssistModule());
|
||||||
.addSimpleTradeoff(module, "Power", MuseCommonStrings.JUMP_ENERGY_CONSUMPTION, "J", 0, 25, MuseCommonStrings.JUMP_MULTIPLIER, "%", 1,
|
addModule(new NightVisionModule());
|
||||||
4)
|
addModule(new InvisibilityModule());
|
||||||
.addSimpleTradeoff(module, "Compensation", MuseCommonStrings.JUMP_ENERGY_CONSUMPTION, "J", 0, 5,
|
addModule(new ParachuteModule());
|
||||||
MuseCommonStrings.JUMP_FOOD_COMPENSATION, "%", 0, 1).addInstallCost(copyAndResize(ItemComponent.servoMotor, 4));
|
addModule(new GliderModule());
|
||||||
addModule(module);
|
addModule(new JetBootsModule());
|
||||||
|
addModule(new JetPackModule());
|
||||||
|
addModule(new FlightControlModule());
|
||||||
|
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_SHOCK_ABSORBER, FEETONLY, MuseIcon.SHOCK_ABSORBER,
|
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_SHOCK_ABSORBER, FEETONLY, MuseIcon.SHOCK_ABSORBER,
|
||||||
MuseCommonStrings.CATEGORY_MOVEMENT)
|
MuseCommonStrings.CATEGORY_MOVEMENT)
|
||||||
|
@ -318,30 +313,6 @@ public class Config {
|
||||||
.addInstallCost(new ItemStack(Block.cloth, 2));
|
.addInstallCost(new ItemStack(Block.cloth, 2));
|
||||||
addModule(module);
|
addModule(module);
|
||||||
|
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_GLIDER, TORSOONLY, MuseIcon.GLIDER, MuseCommonStrings.CATEGORY_MOVEMENT)
|
|
||||||
.setDescription("Tack on some wings to turn downward into forward momentum. Press sneak+forward while falling to activate.")
|
|
||||||
.addInstallCost(copyAndResize(ItemComponent.gliderWing, 2));
|
|
||||||
addModule(module);
|
|
||||||
|
|
||||||
module = new PowerModule(MuseCommonStrings.MODULE_PARACHUTE, TORSOONLY, MuseIcon.PARACHUTE_MODULE, MuseCommonStrings.CATEGORY_MOVEMENT)
|
|
||||||
.setDescription("Add a parachute to slow your descent. Activate by pressing sneak (defaults to Shift) in midair.").addInstallCost(
|
|
||||||
copyAndResize(ItemComponent.parachute, 2));
|
|
||||||
addModule(module);
|
|
||||||
|
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_JETPACK, TORSOONLY, MuseIcon.JETPACK, MuseCommonStrings.CATEGORY_MOVEMENT)
|
|
||||||
.setDescription("A jetpack should allow you to jump indefinitely, or at least until you run out of power.")
|
|
||||||
.addInstallCost(copyAndResize(ItemComponent.ionThruster, 4)).addBaseProperty(MuseCommonStrings.JET_ENERGY_CONSUMPTION, 0, "J/t")
|
|
||||||
.addBaseProperty(MuseCommonStrings.JET_THRUST, 0, "N").addTradeoffProperty("Thrust", MuseCommonStrings.JET_ENERGY_CONSUMPTION, 150)
|
|
||||||
.addTradeoffProperty("Thrust", MuseCommonStrings.JET_THRUST, 0.16);
|
|
||||||
addModule(module);
|
|
||||||
|
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_JETBOOTS, FEETONLY, MuseIcon.JETBOOTS, MuseCommonStrings.CATEGORY_MOVEMENT)
|
|
||||||
.setDescription("Jet boots are not as strong as a jetpack, but they should at least be strong enough to counteract gravity.")
|
|
||||||
.addInstallCost(copyAndResize(ItemComponent.ionThruster, 2)).addBaseProperty(MuseCommonStrings.JET_ENERGY_CONSUMPTION, 0)
|
|
||||||
.addBaseProperty(MuseCommonStrings.JET_THRUST, 0).addTradeoffProperty("Thrust", MuseCommonStrings.JET_ENERGY_CONSUMPTION, 75)
|
|
||||||
.addTradeoffProperty("Thrust", MuseCommonStrings.JET_THRUST, 0.08);
|
|
||||||
addModule(module);
|
|
||||||
|
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_WATER_ELECTROLYZER, HEADONLY, MuseIcon.WATER_ELECTROLYZER,
|
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_WATER_ELECTROLYZER, HEADONLY, MuseIcon.WATER_ELECTROLYZER,
|
||||||
MuseCommonStrings.CATEGORY_ENVIRONMENTAL)
|
MuseCommonStrings.CATEGORY_ENVIRONMENTAL)
|
||||||
.setDescription("When you run out of air, this module will jolt the water around you, electrolyzing a small bubble to breathe from.")
|
.setDescription("When you run out of air, this module will jolt the water around you, electrolyzing a small bubble to breathe from.")
|
||||||
|
@ -349,16 +320,6 @@ public class Config {
|
||||||
.addBaseProperty(MuseCommonStrings.WATERBREATHING_ENERGY_CONSUMPTION, 1000, "J");
|
.addBaseProperty(MuseCommonStrings.WATERBREATHING_ENERGY_CONSUMPTION, 1000, "J");
|
||||||
addModule(module);
|
addModule(module);
|
||||||
|
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_SWIM_BOOST, LEGSONLY, MuseIcon.SWIM_BOOST, MuseCommonStrings.CATEGORY_MOVEMENT)
|
|
||||||
.setDescription(
|
|
||||||
"By refitting an ion thruster for underwater use, you may be able to add extra forward (or backward) thrust when underwater.")
|
|
||||||
.addInstallCost(copyAndResize(ItemComponent.ionThruster, 1)).addInstallCost(copyAndResize(ItemComponent.solenoid, 2))
|
|
||||||
.addTradeoffProperty("Thrust", MuseCommonStrings.SWIM_BOOST_ENERGY_CONSUMPTION, 100, "J")
|
|
||||||
.addTradeoffProperty("Thrust", MuseCommonStrings.SWIM_BOOST_AMOUNT, 1, "m/s");
|
|
||||||
addModule(module);
|
|
||||||
|
|
||||||
addModule(new StepAssistModule(LEGSONLY));
|
|
||||||
|
|
||||||
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_TINT, ALLITEMS, MuseIcon.NETHERSTAR, MuseCommonStrings.CATEGORY_COSMETIC)
|
module = new ToggleablePowerModule(MuseCommonStrings.MODULE_TINT, ALLITEMS, MuseIcon.NETHERSTAR, MuseCommonStrings.CATEGORY_COSMETIC)
|
||||||
.setDescription("Give your armor some coloured tinting to customize your armor's appearance.")
|
.setDescription("Give your armor some coloured tinting to customize your armor's appearance.")
|
||||||
.addInstallCost(copyAndResize(ItemComponent.laserHologram, 1))
|
.addInstallCost(copyAndResize(ItemComponent.laserHologram, 1))
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package net.machinemuse.powersuits.common;
|
package net.machinemuse.powersuits.common;
|
||||||
|
|
||||||
import net.machinemuse.general.gui.KeyConfigGui;
|
import net.machinemuse.general.gui.KeyConfigGui;
|
||||||
import net.machinemuse.general.gui.PortableCraftingGui;
|
|
||||||
import net.machinemuse.powersuits.block.GuiTinkerTable;
|
import net.machinemuse.powersuits.block.GuiTinkerTable;
|
||||||
import net.machinemuse.powersuits.container.PortableCraftingContainer;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package net.machinemuse.powersuits.powermodule.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.machinemuse.api.ElectricItemUtils;
|
||||||
|
import net.machinemuse.api.IModularItem;
|
||||||
|
import net.machinemuse.api.IPlayerTickModule;
|
||||||
|
import net.machinemuse.api.IToggleableModule;
|
||||||
|
import net.machinemuse.api.ModuleManager;
|
||||||
|
import net.machinemuse.api.MuseCommonStrings;
|
||||||
|
import net.machinemuse.api.MuseItemUtils;
|
||||||
|
import net.machinemuse.general.gui.MuseIcon;
|
||||||
|
import net.machinemuse.powersuits.common.ModularPowersuits;
|
||||||
|
import net.machinemuse.powersuits.common.PlayerInputMap;
|
||||||
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
|
import net.machinemuse.powersuits.tick.PlayerTickHandler;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class FlightControlModule extends PowerModuleBase implements IToggleableModule {
|
||||||
|
|
||||||
|
public FlightControlModule() {
|
||||||
|
super(Arrays.asList((IModularItem) ModularPowersuits.powerArmorHead));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.controlCircuit, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MuseIcon getIcon(ItemStack item) {
|
||||||
|
return MuseIcon.INDICATOR_1_GREEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return MuseCommonStrings.CATEGORY_SPECIAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MuseCommonStrings.MODULE_FLIGHT_CONTROL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "An integrated control circuit to help you fly better. Press Z to go down.";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
package net.machinemuse.powersuits.powermodule.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.machinemuse.api.ElectricItemUtils;
|
||||||
|
import net.machinemuse.api.IModularItem;
|
||||||
|
import net.machinemuse.api.IPlayerTickModule;
|
||||||
|
import net.machinemuse.api.IToggleableModule;
|
||||||
|
import net.machinemuse.api.ModuleManager;
|
||||||
|
import net.machinemuse.api.MuseCommonStrings;
|
||||||
|
import net.machinemuse.api.MuseItemUtils;
|
||||||
|
import net.machinemuse.general.gui.MuseIcon;
|
||||||
|
import net.machinemuse.powersuits.common.ModularPowersuits;
|
||||||
|
import net.machinemuse.powersuits.common.PlayerInputMap;
|
||||||
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
|
import net.machinemuse.powersuits.tick.PlayerTickHandler;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
|
||||||
|
public class GliderModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
||||||
|
|
||||||
|
public GliderModule() {
|
||||||
|
super(Arrays.asList((IModularItem) ModularPowersuits.powerArmorTorso));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.gliderWing, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MuseIcon getIcon(ItemStack item) {
|
||||||
|
return MuseIcon.GLIDER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return MuseCommonStrings.CATEGORY_MOVEMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MuseCommonStrings.MODULE_GLIDER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "Tack on some wings to turn downward into forward momentum. Press sneak+forward while falling to activate.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
|
||||||
|
Vec3 playerHorzFacing = player.getLookVec();
|
||||||
|
playerHorzFacing.yCoord = 0;
|
||||||
|
playerHorzFacing.normalize();
|
||||||
|
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
||||||
|
boolean sneakkey = movementInput.sneakKey;
|
||||||
|
float forwardkey = movementInput.forwardKey;
|
||||||
|
ItemStack torso = player.getCurrentArmor(2);
|
||||||
|
boolean hasParachute = false;
|
||||||
|
if (torso != null && torso.getItem() instanceof IModularItem) {
|
||||||
|
hasParachute = MuseItemUtils.itemHasActiveModule(torso, MuseCommonStrings.MODULE_PARACHUTE);
|
||||||
|
}
|
||||||
|
if (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 (gliderTicker == 0) {
|
||||||
|
// world.playSoundAtEntity(player,
|
||||||
|
// MuseCommonStrings.SOUND_GLIDER, 5.0F, 1.0F);
|
||||||
|
// gliderTicker++;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// gliderTicker++;
|
||||||
|
// if (gliderTicker >= 35) {
|
||||||
|
// gliderTicker = 0;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package net.machinemuse.powersuits.powermodule.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import net.machinemuse.api.ElectricItemUtils;
|
||||||
|
import net.machinemuse.api.IModularItem;
|
||||||
|
import net.machinemuse.api.IPlayerTickModule;
|
||||||
|
import net.machinemuse.api.IToggleableModule;
|
||||||
|
import net.machinemuse.api.MuseCommonStrings;
|
||||||
|
import net.machinemuse.api.MuseItemUtils;
|
||||||
|
import net.machinemuse.general.gui.MuseIcon;
|
||||||
|
import net.machinemuse.powersuits.common.ModularPowersuits;
|
||||||
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.potion.Potion;
|
||||||
|
import net.minecraft.potion.PotionEffect;
|
||||||
|
|
||||||
|
public class InvisibilityModule extends PowerModuleBase implements IPlayerTickModule, IToggleableModule {
|
||||||
|
public InvisibilityModule() {
|
||||||
|
super(Arrays.asList((IModularItem) ModularPowersuits.powerArmorTorso));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.laserHologram, 4));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.fieldEmitter, 2));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.controlCircuit, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MuseIcon getIcon(ItemStack item) {
|
||||||
|
return MuseIcon.ORB_1_BLUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return MuseCommonStrings.CATEGORY_SPECIAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MuseCommonStrings.MODULE_ACTIVE_CAMOUFLAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "Emit a hologram of your surroundings to make yourself almost imperceptible.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
|
||||||
|
double totalEnergy = ElectricItemUtils.getPlayerEnergy(player);
|
||||||
|
PotionEffect invis = null;
|
||||||
|
Collection<PotionEffect> effects = player.getActivePotionEffects();
|
||||||
|
for (PotionEffect effect : effects) {
|
||||||
|
if (effect.getAmplifier() == 81 && effect.getPotionID() == Potion.invisibility.id) {
|
||||||
|
invis = effect;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (50 < totalEnergy) {
|
||||||
|
if (invis == null || invis.getDuration() < 210) {
|
||||||
|
player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 500, 81));
|
||||||
|
ElectricItemUtils.drainPlayerEnergy(player, 50);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (invis != null) {
|
||||||
|
player.removePotionEffect(Potion.invisibility.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
package net.machinemuse.powersuits.powermodule.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.machinemuse.api.ElectricItemUtils;
|
||||||
|
import net.machinemuse.api.IModularItem;
|
||||||
|
import net.machinemuse.api.IPlayerTickModule;
|
||||||
|
import net.machinemuse.api.IToggleableModule;
|
||||||
|
import net.machinemuse.api.ModuleManager;
|
||||||
|
import net.machinemuse.api.MuseCommonStrings;
|
||||||
|
import net.machinemuse.api.MuseItemUtils;
|
||||||
|
import net.machinemuse.general.gui.MuseIcon;
|
||||||
|
import net.machinemuse.powersuits.common.ModularPowersuits;
|
||||||
|
import net.machinemuse.powersuits.common.PlayerInputMap;
|
||||||
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
|
import net.machinemuse.powersuits.tick.PlayerTickHandler;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class JetBootsModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
||||||
|
|
||||||
|
public JetBootsModule() {
|
||||||
|
super(Arrays.asList((IModularItem) ModularPowersuits.powerArmorFeet));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.ionThruster, 2));
|
||||||
|
addBaseProperty(MuseCommonStrings.JET_ENERGY_CONSUMPTION, 0);
|
||||||
|
addBaseProperty(MuseCommonStrings.JET_THRUST, 0);
|
||||||
|
addTradeoffProperty("Thrust", MuseCommonStrings.JET_ENERGY_CONSUMPTION, 75);
|
||||||
|
addTradeoffProperty("Thrust", MuseCommonStrings.JET_THRUST, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MuseIcon getIcon(ItemStack item) {
|
||||||
|
return MuseIcon.JETBOOTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return MuseCommonStrings.CATEGORY_MOVEMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MuseCommonStrings.MODULE_JETBOOTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "Jet boots are not as strong as a jetpack, but they should at least be strong enough to counteract gravity.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
|
||||||
|
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
||||||
|
boolean jumpkey = movementInput.jumpKey;
|
||||||
|
ItemStack helmet = player.getCurrentArmor(3);
|
||||||
|
ItemStack boots = player.getCurrentArmor(0);
|
||||||
|
boolean hasFlightControl = false;
|
||||||
|
if (helmet != null && helmet.getItem() instanceof IModularItem) {
|
||||||
|
hasFlightControl = MuseItemUtils.itemHasActiveModule(helmet, MuseCommonStrings.MODULE_FLIGHT_CONTROL);
|
||||||
|
}
|
||||||
|
double jetEnergy = 0;
|
||||||
|
double thrust = 0;
|
||||||
|
jetEnergy += ModuleManager.computeModularProperty(boots, MuseCommonStrings.JET_ENERGY_CONSUMPTION);
|
||||||
|
thrust += ModuleManager.computeModularProperty(boots, MuseCommonStrings.JET_THRUST);
|
||||||
|
|
||||||
|
if (jetEnergy < ElectricItemUtils.getPlayerEnergy(player)) {
|
||||||
|
thrust *= PlayerTickHandler.getWeightPenaltyRatio(MuseItemUtils.getPlayerWeight(player), 25000);
|
||||||
|
if (hasFlightControl && thrust > 0) {
|
||||||
|
PlayerTickHandler.thrust(player, thrust, jetEnergy, true);
|
||||||
|
} else if (jumpkey && player.motionY < 0.5) {
|
||||||
|
PlayerTickHandler.thrust(player, thrust, jetEnergy, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
package net.machinemuse.powersuits.powermodule.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.machinemuse.api.ElectricItemUtils;
|
||||||
|
import net.machinemuse.api.IModularItem;
|
||||||
|
import net.machinemuse.api.IPlayerTickModule;
|
||||||
|
import net.machinemuse.api.IToggleableModule;
|
||||||
|
import net.machinemuse.api.ModuleManager;
|
||||||
|
import net.machinemuse.api.MuseCommonStrings;
|
||||||
|
import net.machinemuse.api.MuseItemUtils;
|
||||||
|
import net.machinemuse.general.gui.MuseIcon;
|
||||||
|
import net.machinemuse.powersuits.common.ModularPowersuits;
|
||||||
|
import net.machinemuse.powersuits.common.PlayerInputMap;
|
||||||
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
|
import net.machinemuse.powersuits.tick.PlayerTickHandler;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class JetPackModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
||||||
|
|
||||||
|
public JetPackModule() {
|
||||||
|
super(Arrays.asList((IModularItem) ModularPowersuits.powerArmorTorso));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.ionThruster, 4));
|
||||||
|
addBaseProperty(MuseCommonStrings.JET_ENERGY_CONSUMPTION, 0, "J/t");
|
||||||
|
addBaseProperty(MuseCommonStrings.JET_THRUST, 0, "N");
|
||||||
|
addTradeoffProperty("Thrust", MuseCommonStrings.JET_ENERGY_CONSUMPTION, 150);
|
||||||
|
addTradeoffProperty("Thrust", MuseCommonStrings.JET_THRUST, 0.16);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MuseIcon getIcon(ItemStack item) {
|
||||||
|
return MuseIcon.JETPACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return MuseCommonStrings.CATEGORY_MOVEMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MuseCommonStrings.MODULE_JETPACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "A jetpack should allow you to jump indefinitely, or at least until you run out of power.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
|
||||||
|
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
||||||
|
boolean jumpkey = movementInput.jumpKey;
|
||||||
|
ItemStack helmet = player.getCurrentArmor(3);
|
||||||
|
ItemStack torso = player.getCurrentArmor(2);
|
||||||
|
boolean hasFlightControl = false;
|
||||||
|
if (helmet != null && helmet.getItem() instanceof IModularItem) {
|
||||||
|
hasFlightControl = MuseItemUtils.itemHasActiveModule(helmet, MuseCommonStrings.MODULE_FLIGHT_CONTROL);
|
||||||
|
}
|
||||||
|
double jetEnergy = 0;
|
||||||
|
double thrust = 0;
|
||||||
|
jetEnergy += ModuleManager.computeModularProperty(torso, MuseCommonStrings.JET_ENERGY_CONSUMPTION);
|
||||||
|
thrust += ModuleManager.computeModularProperty(torso, MuseCommonStrings.JET_THRUST);
|
||||||
|
|
||||||
|
if (jetEnergy < ElectricItemUtils.getPlayerEnergy(player)) {
|
||||||
|
thrust *= PlayerTickHandler.getWeightPenaltyRatio(MuseItemUtils.getPlayerWeight(player), 25000);
|
||||||
|
if (hasFlightControl && thrust > 0) {
|
||||||
|
PlayerTickHandler.thrust(player, thrust, jetEnergy, true);
|
||||||
|
} else if (jumpkey && player.motionY < 0.5) {
|
||||||
|
PlayerTickHandler.thrust(player, thrust, jetEnergy, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package net.machinemuse.powersuits.powermodule.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.machinemuse.api.IModularItem;
|
||||||
|
import net.machinemuse.api.IPlayerTickModule;
|
||||||
|
import net.machinemuse.api.IToggleableModule;
|
||||||
|
import net.machinemuse.api.MuseCommonStrings;
|
||||||
|
import net.machinemuse.api.MuseItemUtils;
|
||||||
|
import net.machinemuse.general.gui.MuseIcon;
|
||||||
|
import net.machinemuse.powersuits.common.ModularPowersuits;
|
||||||
|
import net.machinemuse.powersuits.common.PlayerInputMap;
|
||||||
|
import net.machinemuse.powersuits.event.MovementManager;
|
||||||
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
|
import net.machinemuse.powersuits.tick.PlayerTickHandler;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class JumpAssistModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
||||||
|
|
||||||
|
public JumpAssistModule() {
|
||||||
|
super(Arrays.asList((IModularItem) ModularPowersuits.powerArmorLegs));
|
||||||
|
addSimpleTradeoff(this, "Power", MuseCommonStrings.JUMP_ENERGY_CONSUMPTION, "J", 0, 25, MuseCommonStrings.JUMP_MULTIPLIER, "%", 1, 4);
|
||||||
|
addSimpleTradeoff(this, "Compensation", MuseCommonStrings.JUMP_ENERGY_CONSUMPTION, "J", 0, 5, MuseCommonStrings.JUMP_FOOD_COMPENSATION, "%", 0, 1);
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.servoMotor, 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MuseIcon getIcon(ItemStack item) {
|
||||||
|
return MuseIcon.JUMP_ASSIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return MuseCommonStrings.CATEGORY_MOVEMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MuseCommonStrings.MODULE_JUMP_ASSIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "Another set of servo motors to help you jump higher.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
|
||||||
|
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
||||||
|
boolean jumpkey = movementInput.jumpKey;
|
||||||
|
if (jumpkey) {
|
||||||
|
double multiplier = MovementManager.getPlayerJumpMultiplier(player);
|
||||||
|
if (multiplier > 0) {
|
||||||
|
player.motionY += 0.15 * Math.min(multiplier, 1) * PlayerTickHandler.getWeightPenaltyRatio(MuseItemUtils.getPlayerWeight(player), 25000);
|
||||||
|
MovementManager.setPlayerJumpTicks(player, multiplier - 1);
|
||||||
|
}
|
||||||
|
player.jumpMovementFactor = player.landMovementFactor * .7f;
|
||||||
|
} else {
|
||||||
|
MovementManager.setPlayerJumpTicks(player, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
package net.machinemuse.powersuits.powermodule.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import net.machinemuse.api.ElectricItemUtils;
|
||||||
|
import net.machinemuse.api.IModularItem;
|
||||||
|
import net.machinemuse.api.IPlayerTickModule;
|
||||||
|
import net.machinemuse.api.IToggleableModule;
|
||||||
|
import net.machinemuse.api.MuseCommonStrings;
|
||||||
|
import net.machinemuse.api.MuseItemUtils;
|
||||||
|
import net.machinemuse.general.gui.MuseIcon;
|
||||||
|
import net.machinemuse.powersuits.common.ModularPowersuits;
|
||||||
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.potion.Potion;
|
||||||
|
import net.minecraft.potion.PotionEffect;
|
||||||
|
|
||||||
|
public class NightVisionModule extends PowerModuleBase implements IPlayerTickModule, IToggleableModule {
|
||||||
|
public NightVisionModule() {
|
||||||
|
super(Arrays.asList((IModularItem) ModularPowersuits.powerArmorHead));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.laserHologram, 1));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.controlCircuit, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MuseIcon getIcon(ItemStack item) {
|
||||||
|
return MuseIcon.SCANNER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return MuseCommonStrings.CATEGORY_SPECIAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MuseCommonStrings.MODULE_NIGHT_VISION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "A pair of augmented vision goggles to help you see at night and underwater.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
|
||||||
|
double totalEnergy = ElectricItemUtils.getPlayerEnergy(player);
|
||||||
|
PotionEffect nightVision = null;
|
||||||
|
Collection<PotionEffect> effects = player.getActivePotionEffects();
|
||||||
|
for (PotionEffect effect : effects) {
|
||||||
|
if (effect.getAmplifier() == -337 && effect.getPotionID() == Potion.nightVision.id) {
|
||||||
|
nightVision = effect;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (5 < totalEnergy) {
|
||||||
|
if (nightVision == null || nightVision.getDuration() < 210) {
|
||||||
|
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 500, -337));
|
||||||
|
ElectricItemUtils.drainPlayerEnergy(player, 5);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (nightVision != null) {
|
||||||
|
player.removePotionEffect(Potion.nightVision.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
package net.machinemuse.powersuits.powermodule.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.machinemuse.api.IModularItem;
|
||||||
|
import net.machinemuse.api.IPlayerTickModule;
|
||||||
|
import net.machinemuse.api.IToggleableModule;
|
||||||
|
import net.machinemuse.api.MuseCommonStrings;
|
||||||
|
import net.machinemuse.api.MuseItemUtils;
|
||||||
|
import net.machinemuse.general.gui.MuseIcon;
|
||||||
|
import net.machinemuse.powersuits.common.ModularPowersuits;
|
||||||
|
import net.machinemuse.powersuits.common.PlayerInputMap;
|
||||||
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
|
import net.machinemuse.powersuits.tick.PlayerTickHandler;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class ParachuteModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
||||||
|
|
||||||
|
public ParachuteModule() {
|
||||||
|
super(Arrays.asList((IModularItem) ModularPowersuits.powerArmorTorso));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.parachute, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MuseIcon getIcon(ItemStack item) {
|
||||||
|
return MuseIcon.PARACHUTE_MODULE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return MuseCommonStrings.CATEGORY_MOVEMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MuseCommonStrings.MODULE_PARACHUTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "Add a parachute to slow your descent. Activate by pressing sneak (defaults to Shift) in midair.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
|
||||||
|
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
||||||
|
float forwardkey = movementInput.forwardKey;
|
||||||
|
boolean sneakkey = movementInput.sneakKey;
|
||||||
|
ItemStack torso = player.getCurrentArmor(2);
|
||||||
|
boolean hasGlider = false;
|
||||||
|
if (torso != null && torso.getItem() instanceof IModularItem) {
|
||||||
|
hasGlider = MuseItemUtils.itemHasActiveModule(torso, MuseCommonStrings.MODULE_GLIDER);
|
||||||
|
}
|
||||||
|
if (sneakkey && player.motionY < -0.1 && (!hasGlider || forwardkey <= 0)) {
|
||||||
|
double totalVelocity = Math.sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ + player.motionY * player.motionY)
|
||||||
|
* PlayerTickHandler.getWeightPenaltyRatio(MuseItemUtils.getPlayerWeight(player), 25000);
|
||||||
|
if (totalVelocity > 0) {
|
||||||
|
player.motionX = player.motionX * 0.1 / totalVelocity;
|
||||||
|
player.motionY = player.motionY * 0.1 / totalVelocity;
|
||||||
|
player.motionZ = player.motionZ * 0.1 / totalVelocity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {}
|
||||||
|
|
||||||
|
}
|
|
@ -84,9 +84,6 @@ public class SprintAssistModule extends PowerModuleBase implements IToggleableMo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {}
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.machinemuse.powersuits.powermodule.modules;
|
package net.machinemuse.powersuits.powermodule.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.machinemuse.api.IModularItem;
|
import net.machinemuse.api.IModularItem;
|
||||||
|
@ -8,13 +9,14 @@ import net.machinemuse.api.IToggleableModule;
|
||||||
import net.machinemuse.api.MuseCommonStrings;
|
import net.machinemuse.api.MuseCommonStrings;
|
||||||
import net.machinemuse.api.MuseItemUtils;
|
import net.machinemuse.api.MuseItemUtils;
|
||||||
import net.machinemuse.general.gui.MuseIcon;
|
import net.machinemuse.general.gui.MuseIcon;
|
||||||
|
import net.machinemuse.powersuits.common.ModularPowersuits;
|
||||||
import net.machinemuse.powersuits.item.ItemComponent;
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class StepAssistModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
public class StepAssistModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
||||||
public StepAssistModule(List<IModularItem> validItems) {
|
public StepAssistModule() {
|
||||||
super(validItems);
|
super(Arrays.asList((IModularItem) ModularPowersuits.powerArmorLegs));
|
||||||
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.servoMotor, 2));
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.servoMotor, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
package net.machinemuse.powersuits.powermodule.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import net.machinemuse.api.ElectricItemUtils;
|
||||||
|
import net.machinemuse.api.IModularItem;
|
||||||
|
import net.machinemuse.api.IPlayerTickModule;
|
||||||
|
import net.machinemuse.api.IToggleableModule;
|
||||||
|
import net.machinemuse.api.ModuleManager;
|
||||||
|
import net.machinemuse.api.MuseCommonStrings;
|
||||||
|
import net.machinemuse.api.MuseItemUtils;
|
||||||
|
import net.machinemuse.general.gui.MuseIcon;
|
||||||
|
import net.machinemuse.powersuits.common.Config;
|
||||||
|
import net.machinemuse.powersuits.common.ModularPowersuits;
|
||||||
|
import net.machinemuse.powersuits.common.PlayerInputMap;
|
||||||
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class SwimAssistModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
||||||
|
|
||||||
|
public SwimAssistModule() {
|
||||||
|
super(Arrays.asList((IModularItem) ModularPowersuits.powerArmorLegs));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.ionThruster, 1));
|
||||||
|
addInstallCost(MuseItemUtils.copyAndResize(ItemComponent.solenoid, 2));
|
||||||
|
addTradeoffProperty("Thrust", MuseCommonStrings.SWIM_BOOST_ENERGY_CONSUMPTION, 100, "J");
|
||||||
|
addTradeoffProperty("Thrust", MuseCommonStrings.SWIM_BOOST_AMOUNT, 1, "m/s");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MuseIcon getIcon(ItemStack item) {
|
||||||
|
return MuseIcon.SWIM_BOOST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory() {
|
||||||
|
return MuseCommonStrings.CATEGORY_MOVEMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MuseCommonStrings.MODULE_SWIM_BOOST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "By refitting an ion thruster for underwater use, you may be able to add extra forward (or backward) thrust when underwater.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
|
||||||
|
if (player.isInWater()) {
|
||||||
|
ItemStack pants = player.getCurrentArmor(1);
|
||||||
|
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
||||||
|
boolean jumpkey = movementInput.jumpKey;
|
||||||
|
boolean sneakkey = movementInput.sneakKey;
|
||||||
|
float forwardkey = movementInput.forwardKey;
|
||||||
|
float strafekey = movementInput.strafeKey;
|
||||||
|
if (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, MuseCommonStrings.SWIM_BOOST_AMOUNT) * 0.05;
|
||||||
|
double swimEnergyConsumption = ModuleManager.computeModularProperty(pants, MuseCommonStrings.SWIM_BOOST_ENERGY_CONSUMPTION);
|
||||||
|
if (swimEnergyConsumption < ElectricItemUtils.getPlayerEnergy(player)) {
|
||||||
|
|
||||||
|
// if (swimTicker == 0) {
|
||||||
|
// world.playSoundAtEntity(player,
|
||||||
|
// MuseCommonStrings.SOUND_SWIM_ASSIST, 2.0F, 1.0F);
|
||||||
|
// swimTicker++;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// swimTicker++;
|
||||||
|
// if (swimTicker >= 60) {
|
||||||
|
// swimTicker = 0;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
ElectricItemUtils.drainPlayerEnergy(player, swimEnergyConsumption);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {}
|
||||||
|
|
||||||
|
}
|
|
@ -3,7 +3,6 @@
|
||||||
*/
|
*/
|
||||||
package net.machinemuse.powersuits.tick;
|
package net.machinemuse.powersuits.tick;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -11,7 +10,6 @@ import net.machinemuse.api.ElectricItemUtils;
|
||||||
import net.machinemuse.api.IModularItem;
|
import net.machinemuse.api.IModularItem;
|
||||||
import net.machinemuse.api.IPlayerTickModule;
|
import net.machinemuse.api.IPlayerTickModule;
|
||||||
import net.machinemuse.api.ModuleManager;
|
import net.machinemuse.api.ModuleManager;
|
||||||
import net.machinemuse.api.MuseCommonStrings;
|
|
||||||
import net.machinemuse.api.MuseItemUtils;
|
import net.machinemuse.api.MuseItemUtils;
|
||||||
import net.machinemuse.general.MuseMathUtils;
|
import net.machinemuse.general.MuseMathUtils;
|
||||||
import net.machinemuse.powersuits.common.MuseLogger;
|
import net.machinemuse.powersuits.common.MuseLogger;
|
||||||
|
@ -19,8 +17,6 @@ import net.machinemuse.powersuits.common.PlayerInputMap;
|
||||||
import net.machinemuse.powersuits.event.MovementManager;
|
import net.machinemuse.powersuits.event.MovementManager;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.potion.Potion;
|
|
||||||
import net.minecraft.potion.PotionEffect;
|
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import cpw.mods.fml.common.ITickHandler;
|
import cpw.mods.fml.common.ITickHandler;
|
||||||
|
@ -75,17 +71,6 @@ public class PlayerTickHandler implements ITickHandler {
|
||||||
boolean sneakkey = movementInput.sneakKey;
|
boolean sneakkey = movementInput.sneakKey;
|
||||||
boolean downkey = movementInput.downKey;
|
boolean downkey = movementInput.downKey;
|
||||||
|
|
||||||
boolean hasSprintAssist = false;
|
|
||||||
boolean hasGlider = false;
|
|
||||||
boolean hasParachute = false;
|
|
||||||
boolean hasJetpack = false;
|
|
||||||
boolean hasJetboots = false;
|
|
||||||
boolean hasJumpAssist = false;
|
|
||||||
boolean hasSwimAssist = false;
|
|
||||||
boolean hasNightVision = false;
|
|
||||||
boolean hasInvis = false;
|
|
||||||
boolean hasFlightControl = false;
|
|
||||||
|
|
||||||
for (IPlayerTickModule module : ModuleManager.getPlayerTickModules()) {
|
for (IPlayerTickModule module : ModuleManager.getPlayerTickModules()) {
|
||||||
for (ItemStack itemStack : modularItemsEquipped) {
|
for (ItemStack itemStack : modularItemsEquipped) {
|
||||||
if (module.isValidForItem(itemStack, player)) {
|
if (module.isValidForItem(itemStack, player)) {
|
||||||
|
@ -98,142 +83,53 @@ public class PlayerTickHandler implements ITickHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (helmet != null && helmet.getItem() instanceof IModularItem) {
|
if (helmet != null && helmet.getItem() instanceof IModularItem) {
|
||||||
IModularItem modular = (IModularItem) helmet.getItem();
|
|
||||||
|
|
||||||
hasNightVision = MuseItemUtils.itemHasActiveModule(helmet, MuseCommonStrings.MODULE_NIGHT_VISION);
|
|
||||||
hasFlightControl = MuseItemUtils.itemHasActiveModule(helmet, MuseCommonStrings.MODULE_FLIGHT_CONTROL);
|
|
||||||
if (helmet.getTagCompound().hasKey("ench")) {
|
if (helmet.getTagCompound().hasKey("ench")) {
|
||||||
helmet.getTagCompound().removeTag("ench");
|
helmet.getTagCompound().removeTag("ench");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pants != null && pants.getItem() instanceof IModularItem) {
|
if (pants != null && pants.getItem() instanceof IModularItem) {
|
||||||
hasSprintAssist = MuseItemUtils.itemHasActiveModule(pants, MuseCommonStrings.MODULE_SPRINT_ASSIST);
|
|
||||||
hasJumpAssist = MuseItemUtils.itemHasActiveModule(pants, MuseCommonStrings.MODULE_JUMP_ASSIST);
|
|
||||||
hasSwimAssist = MuseItemUtils.itemHasActiveModule(pants, MuseCommonStrings.MODULE_SWIM_BOOST);
|
|
||||||
if (pants.getTagCompound().hasKey("ench")) {
|
if (pants.getTagCompound().hasKey("ench")) {
|
||||||
pants.getTagCompound().removeTag("ench");
|
pants.getTagCompound().removeTag("ench");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (boots != null && boots.getItem() instanceof IModularItem) {
|
if (boots != null && boots.getItem() instanceof IModularItem) {
|
||||||
hasJetboots = MuseItemUtils.itemHasActiveModule(boots, MuseCommonStrings.MODULE_JETBOOTS);
|
|
||||||
if (boots.getTagCompound().hasKey("ench")) {
|
if (boots.getTagCompound().hasKey("ench")) {
|
||||||
boots.getTagCompound().removeTag("ench");
|
boots.getTagCompound().removeTag("ench");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (torso != null && torso.getItem() instanceof IModularItem) {
|
if (torso != null && torso.getItem() instanceof IModularItem) {
|
||||||
hasInvis = MuseItemUtils.itemHasActiveModule(torso, MuseCommonStrings.MODULE_ACTIVE_CAMOUFLAGE);
|
|
||||||
hasJetpack = MuseItemUtils.itemHasActiveModule(torso, MuseCommonStrings.MODULE_JETPACK);
|
|
||||||
hasGlider = MuseItemUtils.itemHasActiveModule(torso, MuseCommonStrings.MODULE_GLIDER);
|
|
||||||
hasParachute = MuseItemUtils.itemHasActiveModule(torso, MuseCommonStrings.MODULE_PARACHUTE);
|
|
||||||
if (torso.getTagCompound().hasKey("ench")) {
|
if (torso.getTagCompound().hasKey("ench")) {
|
||||||
torso.getTagCompound().removeTag("ench");
|
torso.getTagCompound().removeTag("ench");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PotionEffect nightVision = null;
|
// Update fall distance for damage, energy drain, and
|
||||||
PotionEffect invis = null;
|
// exhaustion this tick
|
||||||
Collection<PotionEffect> effects = player.getActivePotionEffects();
|
|
||||||
for (PotionEffect effect : effects) {
|
if (totalEnergyDrain > 0) {
|
||||||
if (effect.getAmplifier() == -337 && effect.getPotionID() == Potion.nightVision.id) {
|
ElectricItemUtils.drainPlayerEnergy(player, totalEnergyDrain);
|
||||||
nightVision = effect;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (effect.getAmplifier() == 81 && effect.getPotionID() == Potion.invisibility.id) {
|
|
||||||
invis = effect;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasNightVision && totalEnergyDrain + 5 < totalEnergy) {
|
|
||||||
if (nightVision == null || nightVision.getDuration() < 210) {
|
|
||||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 500, -337));
|
|
||||||
totalEnergyDrain += 5;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (nightVision != null) {
|
ElectricItemUtils.givePlayerEnergy(player, -totalEnergyDrain);
|
||||||
player.removePotionEffect(Potion.nightVision.id);
|
}
|
||||||
|
|
||||||
|
player.getFoodStats().addExhaustion((float) (-foodAdjustment));
|
||||||
|
player.fallDistance = (float) MovementManager.computeFallHeightFromVelocity(MuseMathUtils.clampDouble(player.motionY, -1000.0, 0.0));
|
||||||
|
|
||||||
|
// Weight movement penalty
|
||||||
|
if (totalWeight > weightCapacity) {
|
||||||
|
player.motionX *= weightCapacity / totalWeight;
|
||||||
|
player.motionZ *= weightCapacity / totalWeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasInvis && totalEnergyDrain + 50 < totalEnergy) {
|
public static void thrust(EntityPlayer player, double thrust, double jetEnergy, boolean flightControl) {
|
||||||
if (invis == null || invis.getDuration() < 210) {
|
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
||||||
player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 500, 81));
|
boolean jumpkey = movementInput.jumpKey;
|
||||||
totalEnergyDrain += 50;
|
float forwardkey = movementInput.forwardKey;
|
||||||
}
|
float strafekey = movementInput.strafeKey;
|
||||||
} else {
|
boolean downkey = movementInput.downKey;
|
||||||
if (invis != null) {
|
double totalEnergyDrain = 0;
|
||||||
player.removePotionEffect(Potion.invisibility.id);
|
if (flightControl) {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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, MuseCommonStrings.SWIM_BOOST_AMOUNT) * 0.05;
|
|
||||||
double swimEnergyConsumption = ModuleManager.computeModularProperty(pants, MuseCommonStrings.SWIM_BOOST_ENERGY_CONSUMPTION);
|
|
||||||
if (swimEnergyConsumption + totalEnergyDrain < totalEnergy) {
|
|
||||||
totalEnergyDrain += swimEnergyConsumption;
|
|
||||||
|
|
||||||
// if (swimTicker == 0) {
|
|
||||||
// world.playSoundAtEntity(player,
|
|
||||||
// MuseCommonStrings.SOUND_SWIM_ASSIST, 2.0F, 1.0F);
|
|
||||||
// swimTicker++;
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// swimTicker++;
|
|
||||||
// if (swimTicker >= 60) {
|
|
||||||
// swimTicker = 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// 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 {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
player.jumpMovementFactor = player.landMovementFactor * .7f;
|
|
||||||
} else {
|
|
||||||
MovementManager.setPlayerJumpTicks(player, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Jetpack & jetboots
|
|
||||||
if (hasJetpack || hasJetboots) {
|
|
||||||
double jetEnergy = 0;
|
|
||||||
double thrust = 0;
|
|
||||||
if (hasJetpack) {
|
|
||||||
jetEnergy += ModuleManager.computeModularProperty(torso, MuseCommonStrings.JET_ENERGY_CONSUMPTION);
|
|
||||||
thrust += ModuleManager.computeModularProperty(torso, MuseCommonStrings.JET_THRUST);
|
|
||||||
}
|
|
||||||
if (hasJetboots) {
|
|
||||||
jetEnergy += ModuleManager.computeModularProperty(boots, MuseCommonStrings.JET_ENERGY_CONSUMPTION);
|
|
||||||
thrust += ModuleManager.computeModularProperty(boots, MuseCommonStrings.JET_THRUST);
|
|
||||||
}
|
|
||||||
if (jetEnergy + totalEnergyDrain < totalEnergy) {
|
|
||||||
thrust *= getWeightPenaltyRatio(totalWeight, weightCapacity);
|
|
||||||
if (hasFlightControl && thrust > 0) {
|
|
||||||
Vec3 desiredDirection = player.getLookVec().normalize();
|
Vec3 desiredDirection = player.getLookVec().normalize();
|
||||||
double strafeX = desiredDirection.zCoord;
|
double strafeX = desiredDirection.zCoord;
|
||||||
double strafeZ = -desiredDirection.xCoord;
|
double strafeZ = -desiredDirection.xCoord;
|
||||||
|
@ -312,8 +208,11 @@ public class PlayerTickHandler implements ITickHandler {
|
||||||
player.motionZ += vz;
|
player.motionZ += vz;
|
||||||
|
|
||||||
totalEnergyDrain += jetEnergy * (vx * vx + vy * vy + vz * vz);
|
totalEnergyDrain += jetEnergy * (vx * vx + vy * vy + vz * vz);
|
||||||
|
ElectricItemUtils.drainPlayerEnergy(player, totalEnergyDrain);
|
||||||
} else if (jumpkey && player.motionY < 0.5) {
|
} else {
|
||||||
|
Vec3 playerHorzFacing = player.getLookVec();
|
||||||
|
playerHorzFacing.yCoord = 0;
|
||||||
|
playerHorzFacing.normalize();
|
||||||
totalEnergyDrain += jetEnergy;
|
totalEnergyDrain += jetEnergy;
|
||||||
if (forwardkey == 0) {
|
if (forwardkey == 0) {
|
||||||
player.motionY += thrust;
|
player.motionY += thrust;
|
||||||
|
@ -325,68 +224,6 @@ public class PlayerTickHandler implements ITickHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 (gliderTicker == 0) {
|
|
||||||
// world.playSoundAtEntity(player,
|
|
||||||
// MuseCommonStrings.SOUND_GLIDER, 5.0F, 1.0F);
|
|
||||||
// gliderTicker++;
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// gliderTicker++;
|
|
||||||
// if (gliderTicker >= 35) {
|
|
||||||
// gliderTicker = 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parachute
|
|
||||||
if (hasParachute && sneakkey && player.motionY < -0.1 && (!hasGlider || forwardkey <= 0)) {
|
|
||||||
double totalVelocity = Math.sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ + 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) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update fall distance for damage, energy drain, and
|
|
||||||
// exhaustion this tick
|
|
||||||
|
|
||||||
if (totalEnergyDrain > 0) {
|
|
||||||
ElectricItemUtils.drainPlayerEnergy(player, totalEnergyDrain);
|
|
||||||
} else {
|
|
||||||
ElectricItemUtils.givePlayerEnergy(player, -totalEnergyDrain);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.getFoodStats().addExhaustion((float) (-foodAdjustment));
|
|
||||||
player.fallDistance = (float) MovementManager.computeFallHeightFromVelocity(MuseMathUtils.clampDouble(player.motionY, -1000.0, 0.0));
|
|
||||||
|
|
||||||
// Weight movement penalty
|
|
||||||
if (totalWeight > weightCapacity) {
|
|
||||||
player.motionX *= weightCapacity / totalWeight;
|
|
||||||
player.motionZ *= weightCapacity / totalWeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getWeightPenaltyRatio(double currentWeight, double capacity) {
|
public static double getWeightPenaltyRatio(double currentWeight, double capacity) {
|
||||||
if (currentWeight < capacity) {
|
if (currentWeight < capacity) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue