diff --git a/LICENSE b/LICENSE index 6df36a4..0df01b1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Jani Haiko +Copyright (c) 2023 - 2024 Jani Haiko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a9929b8..5a2da6d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PiShock Shock Collar Integration for Minecraft +# PiShock Shock Collar Integration for Minecraft: Java Edition This Forge mod allows players to connect their [PiShock](https://pishock.com) device to the game for added realism and _...fun..._:smiling_imp:. Whenever the player takes damage, they will get a corresponding shock, @@ -39,7 +39,8 @@ The mod is licensed under a MIT license, so feel free to include it in any modpa This mod should be compatible with almost everything. If you're using other mods that alter the player health (e.g., changes the maxium health), please note that the shock intensity scaling might not work as expected. -However, even in that case the player will never be shocked with higher intensity than the configured `intensity_range` allows. +However, +even in that case the player will never be shocked with a higher intensity than the configured `intensity_range` allows. ## Mod configuration The mod configuration file is named `pishockmc-client.toml` and it can be edited with any text editor. In-game settings GUI might be added in a later release to make configuring easier. The configuration file will look like this: @@ -59,11 +60,16 @@ intensity_range = "NORMAL" code = "" ``` -`username`, `apikey` and `code` are all mandatory, and you must get all of them from [pishock.com](https://pishock.com). +`username`, `apikey` and `code` are all mandatory, and you can get all of them from [pishock.com](https://pishock.com). It's also important to set the desired intensity level (`intensity_range`). -The default value is `MINIMAL`, but personally I feel that `NORMAL`or `INTENSE` have the best balance between feeling kinda nasty but not being too overwhelming. -But it's all very dependent on each person's pain tolerance and location of the shocker, so feel free to experiment. -Also, please be aware that for most people getting shocked at the same spot multiple times heightens the sensation and each consecutive shock will be more painful. +The default value is `MINIMAL`, +but for me personally `NORMAL`or `INTENSE` have the best balance +between feeling kinda nasty but not being too overwhelming. +But it's all very dependent on each person's pain tolerance and location of the shocker, +so you need to experiment what works for each person. +Also, +please be aware that for most people getting shocked at the same spot multiple times drastically heightens the sensation +and each consecutive shock will be more painful. ### Punishment for death Setting `punishment_for_death` --> `enabled` option to `true` will send a shock with the configured intensity and duration when the player dies in-game. @@ -76,14 +82,29 @@ When creating a share code, the `Max Duration` value needs to be set to at least 6 (seconds) or the value of `punishment_for_death` --> `duration` if it's higher than 6. -### Intensity ranges -| intensity_range | Maxium intensity % | -|-----------------|--------------------| -| MINIMAL | 20% | -| NORMAL | 40% | -| INTENSE | 60% | -| HARDCORE | 80% | -| ULTRA_HARDCORE | 100% | +The mod will warn about a misconfiguration if this is not set correctly. + +### Shock intensity calculation +The intensity of the shock is calculated using the following formula: +[The amount of damage taken] * [intensity range multiplayer (see the table below)]. +The maximum amount of damage taken into account is 20 (10 hearts). +This won't be exceeded even if other mods raise the player's maximum health. +If [absorption](https://minecraft.fandom.com/wiki/Absorption) cancels the incoming damage, no shock will be triggered. + +After a shock is triggered, +there's a cooldown of 25 ticks (just bit over a second) before another shock can be triggered. +The damage taken during that time will be backlogged, +and another shock with the intensity calculated using the accumulated damage will be triggered after the cooldown ends. + + +### Intensity ranges and multipliers +| intensity_range | Maxium intensity % | Damage Multiplier | +|-----------------|--------------------|-------------------| +| MINIMAL | 20% | 1 | +| NORMAL | 40% | 2 | +| INTENSE | 60% | 3 | +| HARDCORE | 80% | 4 | +| ULTRA_HARDCORE | 100% | 5 | ## Common issues and FAQ ### Sometimes the shocker isn't activated when it should @@ -108,7 +129,9 @@ Please open [an issue](https://github.com/ojaha065/PiShockForMC/issues) here on * **Support for multiple shockers** * I currently only own one, so testing and debugging would be kinda hard. * In-game configuration GUI -* More configuration options +* **More configuration options** + * Configurable shock duration + * Configurable cooldown time ## The boring stuff diff --git a/build.gradle b/build.gradle index 6c5941d..4eb0d67 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { id 'net.minecraftforge.gradle' version '[6.0.16,6.2)' } -version = '1.20-1.1.2.1' +version = '1.20-1.1.2.2' group = 'fi.kissakala' base.archivesName = 'pishockmc' @@ -32,7 +32,7 @@ repositories { } dependencies { - minecraft 'net.minecraftforge:forge:1.20.4-49.0.14' + minecraft 'net.minecraftforge:forge:1.20.4-49.0.30' } jar { diff --git a/src/main/java/fi/kissakala/pishockmc/Config.java b/src/main/java/fi/kissakala/pishockmc/Config.java index d4f9d75..7b00ab5 100644 --- a/src/main/java/fi/kissakala/pishockmc/Config.java +++ b/src/main/java/fi/kissakala/pishockmc/Config.java @@ -58,10 +58,10 @@ private static ForgeConfigSpec.Builder build(final ForgeConfigSpec.Builder build public enum INTENSITY_SETTING_VALUE { MINIMAL(1f), // 1 - 20 - NORMAL(2f), // 21 - 40 - INTENSE(3f), // 41 - 60 - HARDCORE(4f), // 61 - 80 - ULTRA_HARDCORE(5f); // 81 - 100 + NORMAL(2f), // 2 - 40 + INTENSE(3f), // 3 - 60 + HARDCORE(4f), // 4 - 80 + ULTRA_HARDCORE(5f); // 5 - 100 private final float multiplier; INTENSITY_SETTING_VALUE(final float multiplier) { diff --git a/src/main/java/fi/kissakala/pishockmc/PiShockForMC.java b/src/main/java/fi/kissakala/pishockmc/PiShockForMC.java index df3c397..0e45d54 100644 --- a/src/main/java/fi/kissakala/pishockmc/PiShockForMC.java +++ b/src/main/java/fi/kissakala/pishockmc/PiShockForMC.java @@ -1,7 +1,6 @@ package fi.kissakala.pishockmc; import net.minecraft.client.Minecraft; -import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Player; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; @@ -108,22 +107,22 @@ private void onClientTick(final TickEvent.ClientTickEvent event) { // FIXME: Messy if (API.getConnectionState().equals(PiShockAPI.CONNECTION_STATE.OK)) { - Minecraft.getInstance().gui.getChat().addMessage(Component.literal("PiShock enabled. You'll be punished for any damage you take...")); + Utils.logToChat("PiShock enabled. You'll be punished for any damage you take..."); gracePeriodTimer = null; } else if (API.getConnectionState().equals(PiShockAPI.CONNECTION_STATE.CONNECTED_WITH_WARNING)) { - Minecraft.getInstance().gui.getChat().addMessage(Component.literal("PiShock enabled. You'll be punished for any damage you take...")); - Minecraft.getInstance().gui.getChat().addMessage(Component.literal("[WARNING] There seems to be some kind of misconfiguration or issue with PiShock configuration. Please check the Minecraft Output logs and mod documentation for more details.")); + Utils.logToChat("PiShock enabled. You'll be punished for any damage you take..."); + Utils.logToChat("[WARNING] There seems to be some kind of misconfiguration or issue with PiShock configuration. Please check the Minecraft Output logs and mod documentation for more details."); gracePeriodTimer = null; } else { gracePeriodTimer = 20 * 10; API.connect().thenAccept(connectionState -> { if (connectionState.equals(PiShockAPI.CONNECTION_STATE.OK)) { - Minecraft.getInstance().gui.getChat().addMessage(Component.literal("PiShock enabled. You'll be punished for any damage you take...")); + Utils.logToChat("PiShock enabled. You'll be punished for any damage you take..."); } else if (connectionState.equals(PiShockAPI.CONNECTION_STATE.CONNECTED_WITH_WARNING)) { - Minecraft.getInstance().gui.getChat().addMessage(Component.literal("PiShock enabled. You'll be punished for any damage you take...")); - Minecraft.getInstance().gui.getChat().addMessage(Component.literal("[WARNING] There seems to be some kind of misconfiguration or issue with PiShock configuration. Please check the Minecraft Output logs and mod documentation for more details.")); + Utils.logToChat("PiShock enabled. You'll be punished for any damage you take..."); + Utils.logToChat("[WARNING] There seems to be some kind of misconfiguration or issue with PiShock configuration. Please check the Minecraft Output logs and mod documentation for more details."); } else { - Minecraft.getInstance().gui.getChat().addMessage(Component.literal("It seems that Minecraft cannot connect to your PiShock device. Please check the Minecraft Output logs and mod documentation for more help.")); + Utils.logToChat("It seems that Minecraft cannot connect to your PiShock device. Please check the Minecraft Output logs and mod documentation for more help."); } gracePeriodTimer = null; diff --git a/src/main/java/fi/kissakala/pishockmc/Utils.java b/src/main/java/fi/kissakala/pishockmc/Utils.java index 071d6df..6d4a935 100644 --- a/src/main/java/fi/kissakala/pishockmc/Utils.java +++ b/src/main/java/fi/kissakala/pishockmc/Utils.java @@ -1,5 +1,8 @@ package fi.kissakala.pishockmc; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; + import javax.annotation.Nonnull; public class Utils { @@ -22,4 +25,12 @@ public static int clamp(final int integer, final int min, final int max) { public static String log(@Nonnull final String message) { return "[PiShock] " + message; } + + /** + * Adds a message to the chat + * @param message The message + */ + public static void logToChat(@Nonnull final String message) { + Minecraft.getInstance().gui.getChat().addMessage(Component.literal(message)); + } } \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 24c8cc8..73d0850 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -5,7 +5,7 @@ issueTrackerURL="https://github.com/ojaha065/PiShockForMC/issues" [[mods]] modId="pishockmc" -version="1.20-1.1.2.1" +version="1.20-1.1.2.2" displayName="PiShock for Minecraft" #updateJSONURL="https://change.me.example.invalid/updates.json" # TODO