Skip to content

Commit

Permalink
Cleaned up some of the jetpack logic and added a slider to control me…
Browse files Browse the repository at this point in the history
…kasuit thrust
  • Loading branch information
mewacaser committed Jan 7, 2024
1 parent c978d58 commit 611b328
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,7 @@
"module.mekanism.inhalation_purification_unit": "ʇᴉu∩ uoᴉʇɐɔᴉɟᴉɹnԀ uoᴉʇɐꞁɐɥuI",
"module.mekanism.installed": "%s :pǝꞁꞁɐʇsuI",
"module.mekanism.jetpack_mode": "ǝpoW ʞɔɐdʇǝՐ",
"module.mekanism.jetpack_mult": "ɹǝᴉꞁdᴉʇꞁnW ʇsnɹɥ⟘",
"module.mekanism.jetpack_unit": "ʇᴉu∩ ʞɔɐdʇǝՐ",
"module.mekanism.jump_boost": "ʇsooᗺ dɯnՐ",
"module.mekanism.laser_dissipation_unit": "ʇᴉu∩ uoᴉʇɐdᴉssᴉᗡ ɹǝsɐꞀ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,7 @@
"module.mekanism.inhalation_purification_unit": "Inhalation Purification Unit",
"module.mekanism.installed": "Installed: %1$s",
"module.mekanism.jetpack_mode": "Jetpack Mode",
"module.mekanism.jetpack_mult": "Thrust Multiplier",
"module.mekanism.jetpack_unit": "Jetpack Unit",
"module.mekanism.jump_boost": "Jump Boost",
"module.mekanism.laser_dissipation_unit": "Laser Dissipation Unit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,7 @@ private void addMisc() {
add(MekanismLang.MODULE_EFFICIENCY, "Efficiency");
add(MekanismLang.MODULE_MODE_CHANGE, "%1$s bumped to: %2$s");
add(MekanismLang.MODULE_JETPACK_MODE, "Jetpack Mode");
add(MekanismLang.MODULE_JETPACK_MULT, "Thrust Multiplier");
add(MekanismLang.MODULE_GRAVITATIONAL_MODULATION, "Gravitational Modulation");
add(MekanismLang.MODULE_MAGNETIC_ATTRACTION, "Magnetic Attraction");
add(MekanismLang.MODULE_CHARGE_SUIT, "Charge Suit");
Expand Down
1 change: 1 addition & 0 deletions src/main/java/mekanism/common/MekanismLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ public enum MekanismLang implements ILangEntry {
MODULE_EFFICIENCY("module", "efficiency"),
MODULE_BREATHING_HELD("module", "breathing.held"),
MODULE_JETPACK_MODE("module", "jetpack_mode"),
MODULE_JETPACK_MULT("module", "jetpack_mult"),
MODULE_GRAVITATIONAL_MODULATION("module", "gravitational_modulation"),
MODULE_MAGNETIC_ATTRACTION("module", "magnetic_attraction"),
MODULE_MODE_CHANGE("module", "mode_change"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mekanism.common.content.gear.mekasuit;

import java.util.function.Consumer;
import mekanism.api.annotations.NothingNullByDefault;
import mekanism.api.annotations.ParametersAreNotNullByDefault;
import mekanism.api.chemical.gas.GasStack;
import mekanism.api.gear.ICustomModule;
Expand All @@ -10,23 +11,28 @@
import mekanism.api.gear.config.IModuleConfigItem;
import mekanism.api.gear.config.ModuleConfigItemCreator;
import mekanism.api.gear.config.ModuleEnumData;
import mekanism.api.text.IHasTextComponent;
import mekanism.api.text.TextComponentUtil;
import mekanism.common.MekanismLang;
import mekanism.common.config.MekanismConfig;
import mekanism.common.item.gear.ItemMekaSuitArmor;
import mekanism.common.item.interfaces.IJetpackItem.JetpackMode;
import mekanism.common.registries.MekanismGases;
import mekanism.common.util.StorageUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;

@ParametersAreNotNullByDefault
public class ModuleJetpackUnit implements ICustomModule<ModuleJetpackUnit> {

private IModuleConfigItem<JetpackMode> jetpackMode;
private IModuleConfigItem<ThrustMultiplier> thrustMultiplier;

@Override
public void init(IModule<ModuleJetpackUnit> module, ModuleConfigItemCreator configItemCreator) {
jetpackMode = configItemCreator.createConfigItem("jetpack_mode", MekanismLang.MODULE_JETPACK_MODE, new ModuleEnumData<>(JetpackMode.NORMAL));
thrustMultiplier = configItemCreator.createConfigItem("jetpack_mult", MekanismLang.MODULE_JETPACK_MULT, new ModuleEnumData<>(ThrustMultiplier.NORMAL, module.getInstalledCount() + 1));
}

@Override
Expand Down Expand Up @@ -54,4 +60,34 @@ public void changeMode(IModule<ModuleJetpackUnit> module, Player player, ItemSta
public JetpackMode getMode() {
return jetpackMode.get();
}

public float getThrustMultiplier() {
return thrustMultiplier.get().getMultiplier();
}

@NothingNullByDefault
public enum ThrustMultiplier implements IHasTextComponent {
HALF(.5f),
NORMAL(1f),
FAST(2f),
FASTER(4f),
FASTEST(8f);

private final float mult;
private final Component label;

ThrustMultiplier(float mult) {
this.mult = mult;
this.label = TextComponentUtil.getString(Float.toString(mult));
}

@Override
public Component getTextComponent() {
return label;
}

public float getMultiplier() {
return mult;
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/mekanism/common/item/gear/ItemJetpack.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public JetpackMode getJetpackMode(ItemStack stack) {

@Override
public double getJetpackThrust(ItemStack stack) {
return 0.15D;
return 0.1D;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public JetpackMode getJetpackMode(ItemStack stack) {
public double getJetpackThrust(ItemStack stack) {
IModule<ModuleJetpackUnit> module = getModule(stack, MekanismModules.JETPACK_UNIT);
if (module != null && module.isEnabled()) {
return 0.15D * module.getInstalledCount();
return 0.1D * module.getCustomInstance().getThrustMultiplier();
}
return 0D;
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/mekanism/common/item/interfaces/IJetpackItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ static boolean handleJetpackMotion(Player player, JetpackMode mode, double thrus
Vec3 motion = player.getDeltaMovement();
if ((mode == JetpackMode.NORMAL || mode == JetpackMode.VECTOR) && player.isFallFlying()) {
Vec3 forward = player.getLookAngle();
Vec3 delta = forward.multiply(forward.scale(thrust))
.add(forward.scale(1.5).subtract(motion).scale(0.5));
Vec3 drag = forward.scale(1.5).subtract(motion).scale(0.5);
Vec3 delta = forward.scale(thrust).add(drag);
player.setDeltaMovement(motion.add(delta));
return false;
} else if (mode == JetpackMode.NORMAL) {
player.setDeltaMovement(motion.x(), Math.min(motion.y() + thrust, 0.5D), motion.z());
player.setDeltaMovement(motion.x(), motion.y() + thrust * Math.min(1, Math.exp(-motion.y())), motion.z());
} else if (mode == JetpackMode.VECTOR) {
Vec3 forward = player.getLookAngle();
float theta = player.getYRot() * ((float) Math.PI / 180F);
Vec3 left = new Vec3(Mth.cos(theta), 0, Mth.sin(theta));
Vec3 up = forward.cross(left);
Vec3 velocity = motion.add(up.scale(thrust));
player.setDeltaMovement(new Vec3(velocity.x, Math.min(0.5D, velocity.y), velocity.z));
Vec3 thrustVec = up.scale(thrust);
player.setDeltaMovement(motion.add(new Vec3(thrustVec.x, thrustVec.y * Math.min(1, Math.exp(-motion.y())), thrustVec.z)));
} else if (mode == JetpackMode.HOVER) {
boolean ascending = ascendingSupplier.getAsBoolean();
boolean descending = player.isDescending();
Expand Down

0 comments on commit 611b328

Please sign in to comment.