diff --git a/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json b/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json index ebe4c28a493..51868799bdf 100644 --- a/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json +++ b/src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json @@ -1220,6 +1220,7 @@ "jetpack.mekanism.hover": "ɹǝʌoH", "jetpack.mekanism.mode_change": "%s :oʇ pǝᵷuɐɥɔ ǝpoɯ ʞɔɐdʇǝՐ", "jetpack.mekanism.normal": "ɹɐꞁnᵷǝᴚ", + "jetpack.mekanism.vector": "ɹoʇɔǝΛ", "key.mekanism.chest_mode": "ɥɔʇᴉʍS ǝpoW ʇsǝɥƆ", "key.mekanism.description": "uoᴉʇdᴉɹɔsǝᗡ ʍoɥS", "key.mekanism.details": "sꞁᴉɐʇǝᗡ ʍoɥS", diff --git a/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json b/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json index 1d86331aad7..307f70e6336 100644 --- a/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json +++ b/src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json @@ -1220,6 +1220,7 @@ "jetpack.mekanism.hover": "Hover", "jetpack.mekanism.mode_change": "Jetpack mode changed to: %1$s", "jetpack.mekanism.normal": "Regular", + "jetpack.mekanism.vector": "Vector", "key.mekanism.chest_mode": "Chest Mode Switch", "key.mekanism.description": "Show Description", "key.mekanism.details": "Show Details", diff --git a/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java b/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java index ea3e0d7bad9..1014a097f38 100644 --- a/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java +++ b/src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java @@ -1299,6 +1299,7 @@ private void addMisc() { add(MekanismLang.JETPACK_MODE_CHANGE, "Jetpack mode changed to: %1$s"); add(MekanismLang.JETPACK_NORMAL, "Regular"); add(MekanismLang.JETPACK_HOVER, "Hover"); + add(MekanismLang.JETPACK_VECTOR, "Vector"); add(MekanismLang.JETPACK_DISABLED, "Disabled"); //Disassembler Mode add(MekanismLang.DISASSEMBLER_MODE_CHANGE, "Mode toggled to: %1$s (%2$s)"); diff --git a/src/main/java/mekanism/client/ClientTickHandler.java b/src/main/java/mekanism/client/ClientTickHandler.java index 479cf87de23..b4260b0c1c9 100644 --- a/src/main/java/mekanism/client/ClientTickHandler.java +++ b/src/main/java/mekanism/client/ClientTickHandler.java @@ -85,7 +85,7 @@ public static boolean isJetpackInUse(Player player, ItemStack jetpack) { boolean guiOpen = minecraft.screen != null; boolean ascending = minecraft.player.input.jumping; boolean rising = ascending && !guiOpen; - if (mode == JetpackMode.NORMAL) { + if (mode == JetpackMode.NORMAL || mode == JetpackMode.VECTOR) { return rising; } else if (mode == JetpackMode.HOVER) { boolean descending = minecraft.player.input.shiftKeyDown; @@ -203,7 +203,8 @@ public void tickStart() { JetpackMode primaryMode = ((IJetpackItem) primaryJetpack.getItem()).getJetpackMode(primaryJetpack); JetpackMode mode = IJetpackItem.getPlayerJetpackMode(minecraft.player, primaryMode, () -> minecraft.player.input.jumping); MekanismClient.updateKey(minecraft.player.input.jumping, KeySync.ASCEND); - if (jetpackInUse && IJetpackItem.handleJetpackMotion(minecraft.player, mode, () -> minecraft.player.input.jumping)) { + double jetpackThrust = ((IJetpackItem) primaryJetpack.getItem()).getJetpackThrust(primaryJetpack); + if (jetpackInUse && IJetpackItem.handleJetpackMotion(minecraft.player, mode, jetpackThrust, () -> minecraft.player.input.jumping)) { minecraft.player.resetFallDistance(); } } diff --git a/src/main/java/mekanism/common/CommonPlayerTickHandler.java b/src/main/java/mekanism/common/CommonPlayerTickHandler.java index 17246b89e3b..1c11ede43ca 100644 --- a/src/main/java/mekanism/common/CommonPlayerTickHandler.java +++ b/src/main/java/mekanism/common/CommonPlayerTickHandler.java @@ -128,8 +128,9 @@ private void tickEnd(Player player) { if (!primaryJetpack.isEmpty()) { JetpackMode primaryMode = ((IJetpackItem) primaryJetpack.getItem()).getJetpackMode(primaryJetpack); JetpackMode mode = IJetpackItem.getPlayerJetpackMode(player, primaryMode, () -> Mekanism.keyMap.has(player.getUUID(), KeySync.ASCEND)); + double jetpackThrust = ((IJetpackItem) primaryJetpack.getItem()).getJetpackThrust(primaryJetpack); if (mode != JetpackMode.DISABLED) { - if (IJetpackItem.handleJetpackMotion(player, mode, () -> Mekanism.keyMap.has(player.getUUID(), KeySync.ASCEND))) { + if (IJetpackItem.handleJetpackMotion(player, mode, jetpackThrust, () -> Mekanism.keyMap.has(player.getUUID(), KeySync.ASCEND))) { player.resetFallDistance(); if (player instanceof ServerPlayer serverPlayer) { serverPlayer.connection.aboveGroundTickCount = 0; diff --git a/src/main/java/mekanism/common/MekanismLang.java b/src/main/java/mekanism/common/MekanismLang.java index 007a7644f76..d601c6ce53f 100644 --- a/src/main/java/mekanism/common/MekanismLang.java +++ b/src/main/java/mekanism/common/MekanismLang.java @@ -643,6 +643,7 @@ public enum MekanismLang implements ILangEntry { JETPACK_MODE_CHANGE("jetpack", "mode_change"), JETPACK_NORMAL("jetpack", "normal"), JETPACK_HOVER("jetpack", "hover"), + JETPACK_VECTOR("jetpack", "vector"), JETPACK_DISABLED("jetpack", "disabled"), //Disassembler Mode DISASSEMBLER_MODE_CHANGE("disassembler", "mode_change"), diff --git a/src/main/java/mekanism/common/item/gear/ItemJetpack.java b/src/main/java/mekanism/common/item/gear/ItemJetpack.java index c69cc4889a0..31cf614267f 100644 --- a/src/main/java/mekanism/common/item/gear/ItemJetpack.java +++ b/src/main/java/mekanism/common/item/gear/ItemJetpack.java @@ -82,6 +82,11 @@ public JetpackMode getJetpackMode(ItemStack stack) { return JetpackMode.byIndexStatic(ItemDataUtils.getInt(stack, NBTConstants.MODE)); } + @Override + public double getJetpackThrust(ItemStack stack) { + return 0.15D; + } + @Override public void useJetpackFuel(ItemStack stack) { useGas(stack, 1); diff --git a/src/main/java/mekanism/common/item/gear/ItemMekaSuitArmor.java b/src/main/java/mekanism/common/item/gear/ItemMekaSuitArmor.java index bb80bca3566..132239b7db5 100644 --- a/src/main/java/mekanism/common/item/gear/ItemMekaSuitArmor.java +++ b/src/main/java/mekanism/common/item/gear/ItemMekaSuitArmor.java @@ -386,6 +386,15 @@ public JetpackMode getJetpackMode(ItemStack stack) { return JetpackMode.DISABLED; } + @Override + public double getJetpackThrust(ItemStack stack) { + IModule module = getModule(stack, MekanismModules.JETPACK_UNIT); + if (module != null && module.isEnabled()) { + return 0.15D * module.getInstalledCount(); + } + return 0D; + } + @Override public void useJetpackFuel(ItemStack stack) { useGas(stack, MekanismGases.HYDROGEN.get(), 1); diff --git a/src/main/java/mekanism/common/item/interfaces/IJetpackItem.java b/src/main/java/mekanism/common/item/interfaces/IJetpackItem.java index 250c77a1a31..55c92f43f83 100644 --- a/src/main/java/mekanism/common/item/interfaces/IJetpackItem.java +++ b/src/main/java/mekanism/common/item/interfaces/IJetpackItem.java @@ -16,6 +16,7 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; @@ -29,12 +30,15 @@ public interface IJetpackItem { JetpackMode getJetpackMode(ItemStack stack); + double getJetpackThrust(ItemStack stack); + void useJetpackFuel(ItemStack stack); @NothingNullByDefault enum JetpackMode implements IIncrementalEnum, IHasTextComponent { NORMAL(MekanismLang.JETPACK_NORMAL, EnumColor.DARK_GREEN, MekanismUtils.getResource(ResourceType.GUI_HUD, "jetpack_normal.png")), HOVER(MekanismLang.JETPACK_HOVER, EnumColor.DARK_AQUA, MekanismUtils.getResource(ResourceType.GUI_HUD, "jetpack_hover.png")), + VECTOR(MekanismLang.JETPACK_VECTOR, EnumColor.ORANGE, MekanismUtils.getResource(ResourceType.GUI_HUD, "jetpack_vector.png")), DISABLED(MekanismLang.JETPACK_DISABLED, EnumColor.DARK_RED, MekanismUtils.getResource(ResourceType.GUI_HUD, "jetpack_off.png")); private static final JetpackMode[] MODES = values(); @@ -108,33 +112,38 @@ private static ItemStack getJetpack(LivingEntity entity, Predicate ma /** * @return If fall distance should get reset or not */ - static boolean handleJetpackMotion(Player player, JetpackMode mode, BooleanSupplier ascendingSupplier) { + static boolean handleJetpackMotion(Player player, JetpackMode mode, double thrust, BooleanSupplier ascendingSupplier) { Vec3 motion = player.getDeltaMovement(); - if (mode == JetpackMode.NORMAL) { - if (player.isFallFlying()) { - Vec3 forward = player.getLookAngle(); - Vec3 delta = forward.multiply(forward.scale(0.15)) - .add(forward.scale(1.5).subtract(motion).scale(0.5)); - player.setDeltaMovement(motion.add(delta)); - return false; - } else { - player.setDeltaMovement(motion.x(), Math.min(motion.y() + 0.15D, 0.5D), motion.z()); - } + 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)); + 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()); + } 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)); } else if (mode == JetpackMode.HOVER) { boolean ascending = ascendingSupplier.getAsBoolean(); boolean descending = player.isDescending(); if (ascending == descending) { if (motion.y() > 0) { - player.setDeltaMovement(motion.x(), Math.max(motion.y() - 0.15D, 0), motion.z()); + player.setDeltaMovement(motion.x(), Math.max(motion.y() - thrust, 0), motion.z()); } else if (motion.y() < 0) { if (!CommonPlayerTickHandler.isOnGroundOrSleeping(player)) { - player.setDeltaMovement(motion.x(), Math.min(motion.y() + 0.15D, 0), motion.z()); + player.setDeltaMovement(motion.x(), Math.min(motion.y() + thrust, 0), motion.z()); } } } else if (ascending) { - player.setDeltaMovement(motion.x(), Math.min(motion.y() + 0.15D, 0.2D), motion.z()); + player.setDeltaMovement(motion.x(), Math.min(motion.y() + thrust, 0.2D), motion.z()); } else if (!CommonPlayerTickHandler.isOnGroundOrSleeping(player)) { - player.setDeltaMovement(motion.x(), Math.max(motion.y() - 0.15D, -0.2D), motion.z()); + player.setDeltaMovement(motion.x(), Math.max(motion.y() - thrust, -0.2D), motion.z()); } } return true; @@ -148,7 +157,7 @@ static JetpackMode getPlayerJetpackMode(Player player, JetpackMode mode, Boolean if (ascending && !player.isDescending() || !CommonPlayerTickHandler.isOnGroundOrSleeping(player)) { return mode; } - } else if (mode == JetpackMode.NORMAL && ascending) { + } else if (ascending) { return mode; } } diff --git a/src/main/java/mekanism/common/registries/MekanismModules.java b/src/main/java/mekanism/common/registries/MekanismModules.java index 8405c04149f..ec58ad094b3 100644 --- a/src/main/java/mekanism/common/registries/MekanismModules.java +++ b/src/main/java/mekanism/common/registries/MekanismModules.java @@ -89,7 +89,7 @@ private MekanismModules() { public static final ModuleRegistryObject GEIGER_UNIT = MODULES.register("geiger_unit", ModuleGeigerUnit::new, () -> MekanismItems.MODULE_GEIGER.asItem(), builder -> builder.rarity(Rarity.UNCOMMON).rendersHUD()); public static final ModuleRegistryObject JETPACK_UNIT = MODULES.register("jetpack_unit", - ModuleJetpackUnit::new, () -> MekanismItems.MODULE_JETPACK.asItem(), builder -> builder.rarity(Rarity.RARE).handlesModeChange().rendersHUD() + ModuleJetpackUnit::new, () -> MekanismItems.MODULE_JETPACK.asItem(), builder -> builder.maxStackSize(4).rarity(Rarity.RARE).handlesModeChange().rendersHUD() .exclusive(ExclusiveFlag.OVERRIDE_JUMP)); public static final ModuleRegistryObject CHARGE_DISTRIBUTION_UNIT = MODULES.register("charge_distribution_unit", ModuleChargeDistributionUnit::new, () -> MekanismItems.MODULE_CHARGE_DISTRIBUTION.asItem(), builder -> builder.rarity(Rarity.RARE)); diff --git a/src/main/resources/assets/mekanism/gui/hud/jetpack_vector.png b/src/main/resources/assets/mekanism/gui/hud/jetpack_vector.png new file mode 100644 index 00000000000..066fd8582c7 Binary files /dev/null and b/src/main/resources/assets/mekanism/gui/hud/jetpack_vector.png differ