sounds are go
This commit is contained in:
parent
9c7e135ff2
commit
f4b2fd0fec
14 changed files with 185 additions and 67 deletions
|
@ -9,6 +9,8 @@ import net.machinemuse.general.geometry.MusePoint2D;
|
||||||
import net.machinemuse.general.gui.clickable.ClickableButton;
|
import net.machinemuse.general.gui.clickable.ClickableButton;
|
||||||
import net.machinemuse.general.gui.clickable.ClickableItem;
|
import net.machinemuse.general.gui.clickable.ClickableItem;
|
||||||
import net.machinemuse.general.gui.clickable.ClickableModule;
|
import net.machinemuse.general.gui.clickable.ClickableModule;
|
||||||
|
import net.machinemuse.general.sound.Musique;
|
||||||
|
import net.machinemuse.general.sound.SoundLoader;
|
||||||
import net.machinemuse.powersuits.network.MusePacket;
|
import net.machinemuse.powersuits.network.MusePacket;
|
||||||
import net.machinemuse.powersuits.network.packets.MusePacketInstallModuleRequest;
|
import net.machinemuse.powersuits.network.packets.MusePacketInstallModuleRequest;
|
||||||
import net.machinemuse.powersuits.network.packets.MusePacketSalvageModuleRequest;
|
import net.machinemuse.powersuits.network.packets.MusePacketSalvageModuleRequest;
|
||||||
|
@ -165,6 +167,7 @@ public class InstallSalvageFrame extends ScrollableFrame {
|
||||||
ItemStack stack = targetItem.getSelectedItem().getItem();
|
ItemStack stack = targetItem.getSelectedItem().getItem();
|
||||||
IPowerModule module = targetModule.getSelectedModule().getModule();
|
IPowerModule module = targetModule.getSelectedModule().getModule();
|
||||||
if (player.capabilities.isCreativeMode || MuseItemUtils.hasInInventory(module.getInstallCost(), player.inventory)) {
|
if (player.capabilities.isCreativeMode || MuseItemUtils.hasInInventory(module.getInstallCost(), player.inventory)) {
|
||||||
|
Musique.playClientSound(SoundLoader.SOUND_GUI_INSTALL, 1);
|
||||||
// Now send request to server to make it legit
|
// Now send request to server to make it legit
|
||||||
MusePacket newpacket = new MusePacketInstallModuleRequest(
|
MusePacket newpacket = new MusePacketInstallModuleRequest(
|
||||||
(Player) player,
|
(Player) player,
|
||||||
|
|
64
src/minecraft/net/machinemuse/general/sound/Musique.scala
Normal file
64
src/minecraft/net/machinemuse/general/sound/Musique.scala
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
package net.machinemuse.general.sound
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler
|
||||||
|
import cpw.mods.fml.relauncher.Side
|
||||||
|
import net.minecraft.client.Minecraft
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
|
import net.minecraft.client.audio.SoundManager
|
||||||
|
import scala.Predef.String
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles sound mechanics
|
||||||
|
*/
|
||||||
|
object Musique {
|
||||||
|
def soundsystem = SoundManager.sndSystem
|
||||||
|
|
||||||
|
def mcsound = Minecraft.getMinecraft.sndManager
|
||||||
|
|
||||||
|
def options = Minecraft.getMinecraft.gameSettings
|
||||||
|
|
||||||
|
val soundprefix = "MMMPS"
|
||||||
|
|
||||||
|
|
||||||
|
def playClientSound(soundname: String, volume: Float) {
|
||||||
|
if (FMLCommonHandler.instance.getEffectiveSide eq Side.CLIENT) {
|
||||||
|
val pitch: Float = 1.0f
|
||||||
|
mcsound.playSoundFX(soundname, volume, pitch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def makeSoundString(player: EntityPlayer, soundname: String): String = soundprefix + player.username + soundname
|
||||||
|
|
||||||
|
def playerSound(player: EntityPlayer, soundname: String, volume: Float, pitch: Float = 1.0f, continuous: Boolean = true) {
|
||||||
|
if (FMLCommonHandler.instance.getEffectiveSide eq Side.CLIENT) {
|
||||||
|
val pitch: Float = 1.0f
|
||||||
|
val unknownflag = true
|
||||||
|
val soundid = makeSoundString(player, soundname)
|
||||||
|
if (!soundsystem.playing(soundid)) {
|
||||||
|
val soundfile = getSoundPoolEntry(soundname)
|
||||||
|
val amp: Float = 16.0F * Math.max(1, volume)
|
||||||
|
soundsystem.newSource(unknownflag, soundid, soundfile.soundUrl, soundfile.soundName, false, player.posX.toFloat, player.posY.toFloat, player.posZ.toFloat, 2, amp)
|
||||||
|
soundsystem.setLooping(soundid, continuous)
|
||||||
|
soundsystem.play(soundid)
|
||||||
|
}
|
||||||
|
soundsystem.setPitch(soundid, pitch)
|
||||||
|
soundsystem.setPosition(soundid, player.posX.toFloat, player.posY.toFloat, player.posZ.toFloat)
|
||||||
|
soundsystem.setVolume(soundid, Math.min(volume, 1) * this.options.soundVolume)
|
||||||
|
soundsystem.setVelocity(soundid, player.motionX.toFloat, player.motionY.toFloat, player.motionZ.toFloat)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def stopPlayerSound(player: EntityPlayer, soundname: String) {
|
||||||
|
if (FMLCommonHandler.instance.getEffectiveSide eq Side.CLIENT) {
|
||||||
|
val soundid = makeSoundString(player, soundname)
|
||||||
|
val vol = soundsystem.getVolume(soundid) - 0.1f
|
||||||
|
if (vol > 0) {
|
||||||
|
soundsystem.setVolume(soundid, vol)
|
||||||
|
} else {
|
||||||
|
soundsystem.stop(makeSoundString(player, soundname))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getSoundPoolEntry(s: String) = mcsound.soundPoolSounds.getRandomSoundFromSoundPool(s)
|
||||||
|
}
|
|
@ -16,14 +16,21 @@ public class SoundLoader {
|
||||||
SOUND_RESOURCE_LOCATION + "GUISelect.ogg", SOUND_RESOURCE_LOCATION + "JetBoots.ogg", SOUND_RESOURCE_LOCATION + "Jetpack.ogg",
|
SOUND_RESOURCE_LOCATION + "GUISelect.ogg", SOUND_RESOURCE_LOCATION + "JetBoots.ogg", SOUND_RESOURCE_LOCATION + "Jetpack.ogg",
|
||||||
SOUND_RESOURCE_LOCATION + "JumpAssist.ogg", SOUND_RESOURCE_LOCATION + "SwimAssist.ogg",
|
SOUND_RESOURCE_LOCATION + "JumpAssist.ogg", SOUND_RESOURCE_LOCATION + "SwimAssist.ogg",
|
||||||
SOUND_RESOURCE_LOCATION + "WaterElectrolyzer.ogg" };
|
SOUND_RESOURCE_LOCATION + "WaterElectrolyzer.ogg" };
|
||||||
public static final String SOUND_GLIDER = SOUND_PREFIX + "Glider";
|
|
||||||
public static final String SOUND_GUI_INSTALL = SOUND_PREFIX + "GUIInstall";
|
public static final String SOUND_GUI_INSTALL = SOUND_PREFIX + "GUIInstall";
|
||||||
public static final String SOUND_GUI_SELECT = SOUND_PREFIX + "GUISelect";
|
public static final String SOUND_GUI_SELECT = SOUND_PREFIX + "GUISelect";
|
||||||
public static final String SOUND_JET_BOOTS = SOUND_PREFIX + "JetBoots";
|
|
||||||
public static final String SOUND_JETPACK = SOUND_PREFIX + "Jetpack";
|
|
||||||
public static final String SOUND_JUMP_ASSIST = SOUND_PREFIX + "JumpAssist";
|
public static final String SOUND_JUMP_ASSIST = SOUND_PREFIX + "JumpAssist";
|
||||||
public static final String SOUND_SWIM_ASSIST = SOUND_PREFIX + "SwimAssist";
|
|
||||||
public static final String SOUND_WATER_ELECTROLYZER = SOUND_PREFIX + "WaterElectrolyzer";
|
|
||||||
|
public static final String SOUND_GLIDER = SOUND_PREFIX + "Glider";
|
||||||
|
public static final float GLIDER_PRIORITY = 5;
|
||||||
|
public static final String SOUND_JETBOOTS = SOUND_PREFIX + "JetBoots";
|
||||||
|
public static final float JETBOOTS_PRIORITY = 4;
|
||||||
|
public static final String SOUND_JETPACK = SOUND_PREFIX + "Jetpack";
|
||||||
|
public static final float JETPACK_PRIORITY = 3;
|
||||||
|
public static final String SOUND_SWIMASSIST = SOUND_PREFIX + "SwimAssist";
|
||||||
|
public static final float SWIMASSIST_PRIORITY = 2;
|
||||||
|
public static final String SOUND_ELECTROLYZER = SOUND_PREFIX + "WaterElectrolyzer";
|
||||||
|
public static final float ELECTROLYZER_PRIORITY = 1;
|
||||||
|
|
||||||
@ForgeSubscribe
|
@ForgeSubscribe
|
||||||
public void onSoundLoad(SoundLoadEvent event) {
|
public void onSoundLoad(SoundLoadEvent event) {
|
||||||
|
|
|
@ -1,43 +1,45 @@
|
||||||
package net.machinemuse.powersuits.common;
|
package net.machinemuse.powersuits.common;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
|
import net.machinemuse.general.gui.GuiFieldTinker;
|
||||||
|
import net.machinemuse.general.gui.GuiTinkerTable;
|
||||||
import net.machinemuse.general.gui.KeyConfigGui;
|
import net.machinemuse.general.gui.KeyConfigGui;
|
||||||
import net.machinemuse.powersuits.block.GuiTinkerTable;
|
|
||||||
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;
|
||||||
import net.minecraft.stats.AchievementList;
|
import net.minecraft.stats.AchievementList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gui handler for this mod. Mainly just takes an ID according to what was
|
* Gui handler for this mod. Mainly just takes an ID according to what was
|
||||||
* passed to player.OpenGUI, and opens the corresponding GUI.
|
* passed to player.OpenGUI, and opens the corresponding GUI.
|
||||||
*
|
*
|
||||||
* @author MachineMuse
|
* @author MachineMuse
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GuiHandler implements IGuiHandler {
|
public class GuiHandler implements IGuiHandler {
|
||||||
@Override
|
@Override
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
|
||||||
int x, int y, int z) {
|
int x, int y, int z) {
|
||||||
switch (ID) {
|
switch (ID) {
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
|
||||||
int x, int y, int z) {
|
int x, int y, int z) {
|
||||||
switch (ID) {
|
switch (ID) {
|
||||||
case 0:
|
case 0:
|
||||||
Minecraft.getMinecraft().thePlayer.addStat(
|
Minecraft.getMinecraft().thePlayer.addStat(
|
||||||
AchievementList.openInventory, 1);
|
AchievementList.openInventory, 1);
|
||||||
return new GuiTinkerTable((EntityClientPlayerMP) player);
|
return new GuiTinkerTable((EntityClientPlayerMP) player);
|
||||||
case 1:
|
case 1:
|
||||||
return new KeyConfigGui(player);
|
return new KeyConfigGui(player);
|
||||||
default:
|
case 2:
|
||||||
return null;
|
return new GuiFieldTinker((EntityClientPlayerMP) player);
|
||||||
}
|
default:
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class MovementManager {
|
||||||
double jumpAssist = ModuleManager.computeModularProperty(stack, JumpAssistModule.JUMP_MULTIPLIER) * 2;
|
double jumpAssist = ModuleManager.computeModularProperty(stack, JumpAssistModule.JUMP_MULTIPLIER) * 2;
|
||||||
double drain = ModuleManager.computeModularProperty(stack, JumpAssistModule.JUMP_ENERGY_CONSUMPTION);
|
double drain = ModuleManager.computeModularProperty(stack, JumpAssistModule.JUMP_ENERGY_CONSUMPTION);
|
||||||
double avail = ElectricItemUtils.getPlayerEnergy(player);
|
double avail = ElectricItemUtils.getPlayerEnergy(player);
|
||||||
Musique.playOneshotSound(player, SoundLoader.SOUND_JUMP_ASSIST, 1);
|
Musique.playerSound(player, SoundLoader.SOUND_JUMP_ASSIST, (float) (jumpAssist/8.0), 2, false);
|
||||||
if (drain < avail) {
|
if (drain < avail) {
|
||||||
ElectricItemUtils.drainPlayerEnergy(player, drain);
|
ElectricItemUtils.drainPlayerEnergy(player, drain);
|
||||||
setPlayerJumpTicks(player, jumpAssist);
|
setPlayerJumpTicks(player, jumpAssist);
|
||||||
|
@ -68,6 +68,7 @@ public class MovementManager {
|
||||||
if (boots != null) {
|
if (boots != null) {
|
||||||
if (MuseItemUtils.itemHasActiveModule(boots, ShockAbsorberModule.MODULE_SHOCK_ABSORBER) && event.distance > 3) {
|
if (MuseItemUtils.itemHasActiveModule(boots, ShockAbsorberModule.MODULE_SHOCK_ABSORBER) && event.distance > 3) {
|
||||||
double distanceAbsorb = event.distance * ModuleManager.computeModularProperty(boots, ShockAbsorberModule.SHOCK_ABSORB_MULTIPLIER);
|
double distanceAbsorb = event.distance * ModuleManager.computeModularProperty(boots, ShockAbsorberModule.SHOCK_ABSORB_MULTIPLIER);
|
||||||
|
Musique.playerSound(player, SoundLoader.SOUND_GUI_INSTALL, (float) (distanceAbsorb), 2, false);
|
||||||
|
|
||||||
double drain = distanceAbsorb * ModuleManager.computeModularProperty(boots, ShockAbsorberModule.SHOCK_ABSORB_ENERGY_CONSUMPTION);
|
double drain = distanceAbsorb * ModuleManager.computeModularProperty(boots, ShockAbsorberModule.SHOCK_ABSORB_ENERGY_CONSUMPTION);
|
||||||
double avail = ElectricItemUtils.getPlayerEnergy(player);
|
double avail = ElectricItemUtils.getPlayerEnergy(player);
|
||||||
|
|
|
@ -4,6 +4,8 @@ import net.machinemuse.api.IModularItem;
|
||||||
import net.machinemuse.api.ModuleManager;
|
import net.machinemuse.api.ModuleManager;
|
||||||
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
||||||
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
||||||
|
import net.machinemuse.general.sound.Musique;
|
||||||
|
import net.machinemuse.general.sound.SoundLoader;
|
||||||
import net.machinemuse.powersuits.item.ItemComponent;
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
||||||
import net.machinemuse.utils.ElectricItemUtils;
|
import net.machinemuse.utils.ElectricItemUtils;
|
||||||
|
@ -45,6 +47,7 @@ public class WaterElectrolyzerModule extends PowerModuleBase implements IPlayerT
|
||||||
double energy = ElectricItemUtils.getPlayerEnergy(player);
|
double energy = ElectricItemUtils.getPlayerEnergy(player);
|
||||||
double energyConsumption = ModuleManager.computeModularProperty(item, WATERBREATHING_ENERGY_CONSUMPTION);
|
double energyConsumption = ModuleManager.computeModularProperty(item, WATERBREATHING_ENERGY_CONSUMPTION);
|
||||||
if (energy > energyConsumption && player.getAir() < 10) {
|
if (energy > energyConsumption && player.getAir() < 10) {
|
||||||
|
Musique.playClientSound(SoundLoader.SOUND_ELECTROLYZER, 1.0f);
|
||||||
ElectricItemUtils.drainPlayerEnergy(player, energyConsumption);
|
ElectricItemUtils.drainPlayerEnergy(player, energyConsumption);
|
||||||
player.setAir(300);
|
player.setAir(300);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package net.machinemuse.powersuits.powermodule.movement;
|
||||||
import net.machinemuse.api.IModularItem;
|
import net.machinemuse.api.IModularItem;
|
||||||
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
||||||
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
||||||
|
import net.machinemuse.general.sound.Musique;
|
||||||
|
import net.machinemuse.general.sound.SoundLoader;
|
||||||
import net.machinemuse.powersuits.control.PlayerInputMap;
|
import net.machinemuse.powersuits.control.PlayerInputMap;
|
||||||
import net.machinemuse.powersuits.item.ItemComponent;
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
||||||
|
@ -57,8 +59,9 @@ public class GliderModule extends PowerModuleBase implements IToggleableModule,
|
||||||
if (torso != null && torso.getItem() instanceof IModularItem) {
|
if (torso != null && torso.getItem() instanceof IModularItem) {
|
||||||
hasParachute = MuseItemUtils.itemHasActiveModule(torso, ParachuteModule.MODULE_PARACHUTE);
|
hasParachute = MuseItemUtils.itemHasActiveModule(torso, ParachuteModule.MODULE_PARACHUTE);
|
||||||
}
|
}
|
||||||
if (sneakkey && player.motionY < -0.1 && (!hasParachute || forwardkey > 0)) {
|
if (sneakkey && player.motionY < 0 && (!hasParachute || forwardkey > 0)) {
|
||||||
if (player.motionY < -0.1) {
|
if (player.motionY < -0.1) {
|
||||||
|
float vol = (float)( player.motionX*player.motionX + player.motionZ * player.motionZ);
|
||||||
double motionYchange = Math.min(0.08, -0.1 - player.motionY);
|
double motionYchange = Math.min(0.08, -0.1 - player.motionY);
|
||||||
player.motionY += motionYchange;
|
player.motionY += motionYchange;
|
||||||
player.motionX += playerHorzFacing.xCoord * motionYchange;
|
player.motionX += playerHorzFacing.xCoord * motionYchange;
|
||||||
|
@ -66,19 +69,8 @@ public class GliderModule extends PowerModuleBase implements IToggleableModule,
|
||||||
|
|
||||||
// sprinting speed
|
// sprinting speed
|
||||||
player.jumpMovementFactor += 0.03f;
|
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;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import net.machinemuse.api.IModularItem;
|
||||||
import net.machinemuse.api.ModuleManager;
|
import net.machinemuse.api.ModuleManager;
|
||||||
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
||||||
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
||||||
|
import net.machinemuse.general.sound.Musique;
|
||||||
|
import net.machinemuse.general.sound.SoundLoader;
|
||||||
import net.machinemuse.powersuits.control.PlayerInputMap;
|
import net.machinemuse.powersuits.control.PlayerInputMap;
|
||||||
import net.machinemuse.powersuits.item.ItemComponent;
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
||||||
|
@ -18,8 +20,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class JetBootsModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
public class JetBootsModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
||||||
public static final String MODULE_JETBOOTS = "Jet Boots";
|
public static final String MODULE_JETBOOTS = "Jet Boots";
|
||||||
public static final String JET_ENERGY_CONSUMPTION = "Jet Energy Consumption";
|
public static final String JET_ENERGY_CONSUMPTION = "Jetboots Energy Consumption";
|
||||||
public static final String JET_THRUST = "Jet Thrust";
|
public static final String JET_THRUST = "Jetboots Thrust";
|
||||||
|
|
||||||
public JetBootsModule(List<IModularItem> validItems) {
|
public JetBootsModule(List<IModularItem> validItems) {
|
||||||
super(validItems);
|
super(validItems);
|
||||||
|
@ -48,7 +50,7 @@ public class JetBootsModule extends PowerModuleBase implements IToggleableModule
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
|
public void onPlayerTickActive(EntityPlayer player, ItemStack item) {
|
||||||
ItemStack chest = player.getCurrentArmor(1);
|
ItemStack chest = player.getCurrentArmor(1);
|
||||||
if (MuseItemUtils.itemHasActiveModule(chest, JetPackModule.MODULE_JETPACK) || player.isInWater()) {
|
if (player.isInWater()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
||||||
|
@ -61,15 +63,24 @@ public class JetBootsModule extends PowerModuleBase implements IToggleableModule
|
||||||
if (jetEnergy < ElectricItemUtils.getPlayerEnergy(player)) {
|
if (jetEnergy < ElectricItemUtils.getPlayerEnergy(player)) {
|
||||||
thrust *= MusePlayerUtils.getWeightPenaltyRatio(MuseItemUtils.getPlayerWeight(player), 25000);
|
thrust *= MusePlayerUtils.getWeightPenaltyRatio(MuseItemUtils.getPlayerWeight(player), 25000);
|
||||||
if (hasFlightControl && thrust > 0) {
|
if (hasFlightControl && thrust > 0) {
|
||||||
MusePlayerUtils.thrust(player, thrust, jetEnergy, true);
|
thrust = MusePlayerUtils.thrust(player, thrust, true);
|
||||||
|
Musique.playerSound(player, SoundLoader.SOUND_JETBOOTS, (float) (thrust*12.5), 1.0f, true);
|
||||||
|
ElectricItemUtils.drainPlayerEnergy(player, thrust * jetEnergy);
|
||||||
} else if (jumpkey && player.motionY < 0.5) {
|
} else if (jumpkey && player.motionY < 0.5) {
|
||||||
MusePlayerUtils.thrust(player, thrust, jetEnergy, false);
|
thrust = MusePlayerUtils.thrust(player, thrust, false);
|
||||||
|
Musique.playerSound(player, SoundLoader.SOUND_JETBOOTS,(float) (thrust*12.5), 1.0f, true);
|
||||||
|
ElectricItemUtils.drainPlayerEnergy(player, thrust * jetEnergy);
|
||||||
|
} else {
|
||||||
|
Musique.stopPlayerSound(player, SoundLoader.SOUND_JETBOOTS);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Musique.stopPlayerSound(player, SoundLoader.SOUND_JETBOOTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {
|
||||||
|
Musique.stopPlayerSound(player, SoundLoader.SOUND_JETBOOTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,6 +4,8 @@ import net.machinemuse.api.IModularItem;
|
||||||
import net.machinemuse.api.ModuleManager;
|
import net.machinemuse.api.ModuleManager;
|
||||||
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
||||||
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
||||||
|
import net.machinemuse.general.sound.Musique;
|
||||||
|
import net.machinemuse.general.sound.SoundLoader;
|
||||||
import net.machinemuse.powersuits.control.PlayerInputMap;
|
import net.machinemuse.powersuits.control.PlayerInputMap;
|
||||||
import net.machinemuse.powersuits.item.ItemComponent;
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
||||||
|
@ -18,8 +20,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class JetPackModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
public class JetPackModule extends PowerModuleBase implements IToggleableModule, IPlayerTickModule {
|
||||||
public static final String MODULE_JETPACK = "Jetpack";
|
public static final String MODULE_JETPACK = "Jetpack";
|
||||||
public static final String JET_ENERGY_CONSUMPTION = "Jet Energy Consumption";
|
public static final String JET_ENERGY_CONSUMPTION = "Jetpack Energy Consumption";
|
||||||
public static final String JET_THRUST = "Jet Thrust";
|
public static final String JET_THRUST = "Jetpack Thrust";
|
||||||
|
|
||||||
public JetPackModule(List<IModularItem> validItems) {
|
public JetPackModule(List<IModularItem> validItems) {
|
||||||
super(validItems);
|
super(validItems);
|
||||||
|
@ -63,15 +65,24 @@ public class JetPackModule extends PowerModuleBase implements IToggleableModule,
|
||||||
if (jetEnergy < ElectricItemUtils.getPlayerEnergy(player)) {
|
if (jetEnergy < ElectricItemUtils.getPlayerEnergy(player)) {
|
||||||
thrust *= MusePlayerUtils.getWeightPenaltyRatio(MuseItemUtils.getPlayerWeight(player), 25000);
|
thrust *= MusePlayerUtils.getWeightPenaltyRatio(MuseItemUtils.getPlayerWeight(player), 25000);
|
||||||
if (hasFlightControl && thrust > 0) {
|
if (hasFlightControl && thrust > 0) {
|
||||||
MusePlayerUtils.thrust(player, thrust, jetEnergy, true);
|
thrust = MusePlayerUtils.thrust(player, thrust, true);
|
||||||
|
Musique.playerSound(player, SoundLoader.SOUND_JETPACK, (float) (thrust*6.25), 1.0f, true);
|
||||||
|
ElectricItemUtils.drainPlayerEnergy(player, thrust * jetEnergy);
|
||||||
} else if (jumpkey && player.motionY < 0.5) {
|
} else if (jumpkey && player.motionY < 0.5) {
|
||||||
MusePlayerUtils.thrust(player, thrust, jetEnergy, false);
|
thrust = MusePlayerUtils.thrust(player, thrust, false);
|
||||||
|
Musique.playerSound(player, SoundLoader.SOUND_JETPACK,(float) (thrust*6.25), 1.0f, true);
|
||||||
|
ElectricItemUtils.drainPlayerEnergy(player, thrust * jetEnergy);
|
||||||
|
} else {
|
||||||
|
Musique.stopPlayerSound(player, SoundLoader.SOUND_JETPACK);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Musique.stopPlayerSound(player, SoundLoader.SOUND_JETPACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {
|
||||||
|
Musique.stopPlayerSound(player, SoundLoader.SOUND_JETPACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,6 +3,8 @@ package net.machinemuse.powersuits.powermodule.movement;
|
||||||
import net.machinemuse.api.IModularItem;
|
import net.machinemuse.api.IModularItem;
|
||||||
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
||||||
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
||||||
|
import net.machinemuse.general.sound.Musique;
|
||||||
|
import net.machinemuse.general.sound.SoundLoader;
|
||||||
import net.machinemuse.powersuits.control.PlayerInputMap;
|
import net.machinemuse.powersuits.control.PlayerInputMap;
|
||||||
import net.machinemuse.powersuits.event.MovementManager;
|
import net.machinemuse.powersuits.event.MovementManager;
|
||||||
import net.machinemuse.powersuits.item.ItemComponent;
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
|
|
|
@ -4,6 +4,8 @@ import net.machinemuse.api.IModularItem;
|
||||||
import net.machinemuse.api.ModuleManager;
|
import net.machinemuse.api.ModuleManager;
|
||||||
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
||||||
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
import net.machinemuse.api.moduletrigger.IToggleableModule;
|
||||||
|
import net.machinemuse.general.sound.Musique;
|
||||||
|
import net.machinemuse.general.sound.SoundLoader;
|
||||||
import net.machinemuse.powersuits.control.PlayerInputMap;
|
import net.machinemuse.powersuits.control.PlayerInputMap;
|
||||||
import net.machinemuse.powersuits.item.ItemComponent;
|
import net.machinemuse.powersuits.item.ItemComponent;
|
||||||
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
import net.machinemuse.powersuits.powermodule.PowerModuleBase;
|
||||||
|
@ -66,14 +68,22 @@ public class SwimAssistModule extends PowerModuleBase implements IToggleableModu
|
||||||
double swimAssistRate = ModuleManager.computeModularProperty(item, SWIM_BOOST_AMOUNT) * 0.05;
|
double swimAssistRate = ModuleManager.computeModularProperty(item, SWIM_BOOST_AMOUNT) * 0.05;
|
||||||
double swimEnergyConsumption = ModuleManager.computeModularProperty(item, SWIM_BOOST_ENERGY_CONSUMPTION);
|
double swimEnergyConsumption = ModuleManager.computeModularProperty(item, SWIM_BOOST_ENERGY_CONSUMPTION);
|
||||||
if (swimEnergyConsumption < ElectricItemUtils.getPlayerEnergy(player)) {
|
if (swimEnergyConsumption < ElectricItemUtils.getPlayerEnergy(player)) {
|
||||||
MusePlayerUtils.thrust(player, swimAssistRate, swimEnergyConsumption, true);
|
Musique.playerSound(player, SoundLoader.SOUND_SWIMASSIST, 1.0f, 1.0f, true);
|
||||||
|
MusePlayerUtils.thrust(player, swimAssistRate, true);
|
||||||
|
} else {
|
||||||
|
Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {
|
public void onPlayerTickInactive(EntityPlayer player, ItemStack item) {
|
||||||
|
Musique.stopPlayerSound(player, SoundLoader.SOUND_SWIMASSIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,6 +8,8 @@ import cpw.mods.fml.common.TickType;
|
||||||
import net.machinemuse.api.ModuleManager;
|
import net.machinemuse.api.ModuleManager;
|
||||||
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
import net.machinemuse.api.moduletrigger.IPlayerTickModule;
|
||||||
import net.machinemuse.general.MuseLogger;
|
import net.machinemuse.general.MuseLogger;
|
||||||
|
import net.machinemuse.general.sound.Musique;
|
||||||
|
import net.machinemuse.general.sound.SoundLoader;
|
||||||
import net.machinemuse.powersuits.event.MovementManager;
|
import net.machinemuse.powersuits.event.MovementManager;
|
||||||
import net.machinemuse.utils.MuseHeatUtils;
|
import net.machinemuse.utils.MuseHeatUtils;
|
||||||
import net.machinemuse.utils.MuseItemUtils;
|
import net.machinemuse.utils.MuseItemUtils;
|
||||||
|
@ -15,6 +17,7 @@ import net.machinemuse.utils.MuseMathUtils;
|
||||||
import net.machinemuse.utils.MusePlayerUtils;
|
import net.machinemuse.utils.MusePlayerUtils;
|
||||||
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.util.Vec3;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
@ -84,6 +87,12 @@ public class PlayerTickHandler implements ITickHandler {
|
||||||
} else {
|
} else {
|
||||||
player.extinguish();
|
player.extinguish();
|
||||||
}
|
}
|
||||||
|
double velsq2 = MuseMathUtils.sumsq(player.motionX, player.motionY, player.motionZ) - 0.5;
|
||||||
|
if(player.isAirBorne && velsq2 > 0) {
|
||||||
|
Musique.playerSound(player, SoundLoader.SOUND_GLIDER, (float) (velsq2/3), 1.0f, true);
|
||||||
|
} else {
|
||||||
|
Musique.stopPlayerSound(player, SoundLoader.SOUND_GLIDER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,7 @@ object MuseMathUtils {
|
||||||
if (value > max) return max
|
if (value > max) return max
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
def sumsq(x: Double, y: Double, z: Double) = x * x + y * y + z * z
|
||||||
|
|
||||||
|
def pythag(x: Double, y: Double, z: Double) = Math.sqrt(x * x + y * y + z * z)
|
||||||
}
|
}
|
|
@ -172,14 +172,14 @@ public class MusePlayerUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void thrust(EntityPlayer player, double thrust, double jetEnergy, boolean flightControl) {
|
public static double thrust(EntityPlayer player, double thrust, boolean flightControl) {
|
||||||
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
PlayerInputMap movementInput = PlayerInputMap.getInputMapFor(player.username);
|
||||||
boolean jumpkey = movementInput.jumpKey;
|
boolean jumpkey = movementInput.jumpKey;
|
||||||
float forwardkey = movementInput.forwardKey;
|
float forwardkey = movementInput.forwardKey;
|
||||||
float strafekey = movementInput.strafeKey;
|
float strafekey = movementInput.strafeKey;
|
||||||
boolean downkey = movementInput.downKey;
|
boolean downkey = movementInput.downKey;
|
||||||
boolean sneakkey = movementInput.sneakKey;
|
boolean sneakkey = movementInput.sneakKey;
|
||||||
double totalEnergyDrain = 0;
|
double thrustUsed = 0;
|
||||||
if (flightControl) {
|
if (flightControl) {
|
||||||
Vec3 desiredDirection = player.getLookVec().normalize();
|
Vec3 desiredDirection = player.getLookVec().normalize();
|
||||||
double strafeX = desiredDirection.zCoord;
|
double strafeX = desiredDirection.zCoord;
|
||||||
|
@ -218,38 +218,38 @@ public class MusePlayerUtils {
|
||||||
// Brakes
|
// Brakes
|
||||||
if (player.motionY < 0 && desiredDirection.yCoord >= 0) {
|
if (player.motionY < 0 && desiredDirection.yCoord >= 0) {
|
||||||
if (-player.motionY > thrust) {
|
if (-player.motionY > thrust) {
|
||||||
totalEnergyDrain += jetEnergy * thrust;
|
|
||||||
player.motionY += thrust;
|
player.motionY += thrust;
|
||||||
|
thrustUsed += thrust;
|
||||||
thrust = 0;
|
thrust = 0;
|
||||||
} else {
|
} else {
|
||||||
totalEnergyDrain += jetEnergy * Math.abs(player.motionY);
|
|
||||||
thrust -= player.motionY;
|
thrust -= player.motionY;
|
||||||
|
thrustUsed += player.motionY;
|
||||||
player.motionY = 0;
|
player.motionY = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (player.motionY < -1) {
|
if (player.motionY < -1) {
|
||||||
totalEnergyDrain += jetEnergy * Math.abs(1 + player.motionY);
|
|
||||||
thrust += 1 + player.motionY;
|
thrust += 1 + player.motionY;
|
||||||
|
thrustUsed -= 1 + player.motionY;
|
||||||
player.motionY = -1;
|
player.motionY = -1;
|
||||||
}
|
}
|
||||||
if (Math.abs(player.motionX) > 0 && desiredDirection.lengthVector() == 0) {
|
if (Math.abs(player.motionX) > 0 && desiredDirection.lengthVector() == 0) {
|
||||||
if (Math.abs(player.motionX) > thrust) {
|
if (Math.abs(player.motionX) > thrust) {
|
||||||
totalEnergyDrain += jetEnergy * thrust;
|
|
||||||
player.motionX -= Math.signum(player.motionX) * thrust;
|
player.motionX -= Math.signum(player.motionX) * thrust;
|
||||||
|
thrustUsed += thrust;
|
||||||
thrust = 0;
|
thrust = 0;
|
||||||
} else {
|
} else {
|
||||||
totalEnergyDrain += jetEnergy * Math.abs(player.motionX);
|
|
||||||
thrust -= Math.abs(player.motionX);
|
thrust -= Math.abs(player.motionX);
|
||||||
|
thrustUsed += Math.abs(player.motionX);
|
||||||
player.motionX = 0;
|
player.motionX = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Math.abs(player.motionZ) > 0 && desiredDirection.lengthVector() == 0) {
|
if (Math.abs(player.motionZ) > 0 && desiredDirection.lengthVector() == 0) {
|
||||||
if (Math.abs(player.motionZ) > thrust) {
|
if (Math.abs(player.motionZ) > thrust) {
|
||||||
totalEnergyDrain += jetEnergy * thrust;
|
|
||||||
player.motionZ -= Math.signum(player.motionZ) * thrust;
|
player.motionZ -= Math.signum(player.motionZ) * thrust;
|
||||||
|
thrustUsed += thrust;
|
||||||
thrust = 0;
|
thrust = 0;
|
||||||
} else {
|
} else {
|
||||||
totalEnergyDrain += jetEnergy * Math.abs(player.motionZ);
|
thrustUsed += Math.abs(player.motionZ);
|
||||||
thrust -= Math.abs(player.motionZ);
|
thrust -= Math.abs(player.motionZ);
|
||||||
player.motionZ = 0;
|
player.motionZ = 0;
|
||||||
}
|
}
|
||||||
|
@ -262,13 +262,12 @@ public class MusePlayerUtils {
|
||||||
player.motionX += vx;
|
player.motionX += vx;
|
||||||
player.motionY += vy;
|
player.motionY += vy;
|
||||||
player.motionZ += vz;
|
player.motionZ += vz;
|
||||||
|
thrustUsed += thrust;
|
||||||
|
|
||||||
totalEnergyDrain += jetEnergy * (vx * vx + vy * vy + vz * vz);
|
|
||||||
} else {
|
} else {
|
||||||
Vec3 playerHorzFacing = player.getLookVec();
|
Vec3 playerHorzFacing = player.getLookVec();
|
||||||
playerHorzFacing.yCoord = 0;
|
playerHorzFacing.yCoord = 0;
|
||||||
playerHorzFacing.normalize();
|
playerHorzFacing.normalize();
|
||||||
totalEnergyDrain += jetEnergy;
|
|
||||||
if (forwardkey == 0) {
|
if (forwardkey == 0) {
|
||||||
player.motionY += thrust;
|
player.motionY += thrust;
|
||||||
} else {
|
} else {
|
||||||
|
@ -276,6 +275,7 @@ public class MusePlayerUtils {
|
||||||
player.motionX += playerHorzFacing.xCoord * thrust / root2 * Math.signum(forwardkey);
|
player.motionX += playerHorzFacing.xCoord * thrust / root2 * Math.signum(forwardkey);
|
||||||
player.motionZ += playerHorzFacing.zCoord * thrust / root2 * Math.signum(forwardkey);
|
player.motionZ += playerHorzFacing.zCoord * thrust / root2 * Math.signum(forwardkey);
|
||||||
}
|
}
|
||||||
|
thrustUsed += thrust;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slow the player if they are going too fast
|
// Slow the player if they are going too fast
|
||||||
|
@ -291,7 +291,7 @@ public class MusePlayerUtils {
|
||||||
player.motionZ *= ratio;
|
player.motionZ *= ratio;
|
||||||
}
|
}
|
||||||
resetFloatKickTicks(player);
|
resetFloatKickTicks(player);
|
||||||
ElectricItemUtils.drainPlayerEnergy(player, totalEnergyDrain);
|
return thrustUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getWeightPenaltyRatio(double currentWeight, double capacity) {
|
public static double getWeightPenaltyRatio(double currentWeight, double capacity) {
|
||||||
|
|
Loading…
Reference in a new issue