From 351fb1db55b5c21171d55b94f355d0d17cf9ea7f Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 12 Oct 2023 17:19:19 +0900 Subject: [PATCH] v1.23.1 More robust possible damage source loading --- Changelog.md | 8 ++++ README.md | 2 +- build.gradle | 2 +- gradle.properties | 2 +- .../TurnBasedMinecraft/common/Config.java | 39 +++++++------------ .../common/TurnBasedMinecraftMod.java | 2 +- .../TBM_Config.toml | 5 +-- src/main/resources/mcmod.info | 2 +- 8 files changed, 29 insertions(+), 33 deletions(-) diff --git a/Changelog.md b/Changelog.md index 51efa6b..afdf9d1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,13 @@ # Upcoming changes +# Version 1.23.1 + +More robust handling of disallowed Damage Sources in battle (via config). +Basically, the mod will load all possible damage sources. Damage sources to be +ignored in battle can be modified with "/tbm-server-edit" and clicking on +"ignore\_damage\_sources". It can also be manually modified in the server +config's "ignore\_damage\_sources" array. + # Version 1.23.0 Support reproducible builds. This means that if this mod is compiled, then it diff --git a/README.md b/README.md index 16b0df7..564dde0 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ configured for them.) # Building Simply invoke `./gradlew build` in the mod directory and after some time the -finished jar will be saved at "build/libs/TurnBasedMinecraft-1.23.0.jar" +finished jar will be saved at "build/libs/TurnBasedMinecraft-1.23.1.jar" # Other notes diff --git a/build.gradle b/build.gradle index f0d3f3e..55e2214 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { id 'com.github.johnrengelman.shadow' version '8.1.1' } -version = "1.23.0" +version = "1.23.1" group = "com.burnedkirby.TurnBasedMinecraft" archivesBaseName = "TurnBasedMinecraft" diff --git a/gradle.properties b/gradle.properties index c0c0e7e..21d3ce1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -44,7 +44,7 @@ mod_name=TurnBasedMinecraftMod # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=MIT # The mod version. See https://semver.org/ -mod_version=1.23.0 +mod_version=1.23.1 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Config.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Config.java index 5a12f2e..4e27953 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Config.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Config.java @@ -7,6 +7,8 @@ import java.util.*; import com.electronwill.nightconfig.core.file.CommentedFileConfig; import com.electronwill.nightconfig.toml.TomlFormat; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.registries.VanillaRegistries; import org.apache.logging.log4j.Logger; import com.electronwill.nightconfig.core.file.FileConfig; @@ -67,29 +69,7 @@ public class Config possibleIgnoreHurtDamageSources = new HashSet(); ignoreHurtDamageSources = new HashSet(); - possibleIgnoreHurtDamageSources.add("inFire"); - possibleIgnoreHurtDamageSources.add("lightningBolt"); - possibleIgnoreHurtDamageSources.add("onFire"); - possibleIgnoreHurtDamageSources.add("lava"); - possibleIgnoreHurtDamageSources.add("hotFloor"); - possibleIgnoreHurtDamageSources.add("inWall"); - possibleIgnoreHurtDamageSources.add("cramming"); - possibleIgnoreHurtDamageSources.add("drown"); - possibleIgnoreHurtDamageSources.add("starve"); - possibleIgnoreHurtDamageSources.add("cactus"); - possibleIgnoreHurtDamageSources.add("fall"); - possibleIgnoreHurtDamageSources.add("flyIntoWall"); - possibleIgnoreHurtDamageSources.add("outOfWorld"); - possibleIgnoreHurtDamageSources.add("magic"); - possibleIgnoreHurtDamageSources.add("wither"); - possibleIgnoreHurtDamageSources.add("anvil"); - possibleIgnoreHurtDamageSources.add("fallingBlock"); - possibleIgnoreHurtDamageSources.add("dragonBreath"); - possibleIgnoreHurtDamageSources.add("dryout"); - possibleIgnoreHurtDamageSources.add("sweetBerryBush"); - possibleIgnoreHurtDamageSources.add("freeze"); - possibleIgnoreHurtDamageSources.add("fallingStalactite"); - possibleIgnoreHurtDamageSources.add("stalagmite"); + loadDamageSources(); { File confPath = new File(TurnBasedMinecraftMod.CONFIG_DIRECTORY); @@ -1536,4 +1516,15 @@ public class Config public void setIsPlayerOnlyBattles(boolean enabled) { playerOnlyBattles = enabled; } -} \ No newline at end of file + + private void loadDamageSources() { + possibleIgnoreHurtDamageSources.clear(); + + try { + VanillaRegistries.createLookup().lookupOrThrow(Registries.DAMAGE_TYPE).listElements().forEach(dt -> possibleIgnoreHurtDamageSources.add(dt.get().msgId())); + } catch (Exception e) { + logger.warn("Config failed to load possible DamageSources! Undesired things may happen, like Zombies dying from Fire during battle!"); + logger.warn(e); + } + } +} diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java index d5ac33d..4514307 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java @@ -39,7 +39,7 @@ import org.apache.logging.log4j.Logger; public class TurnBasedMinecraftMod { public static final String MODID = "com_burnedkirby_turnbasedminecraft"; public static final String NAME = "Turn Based Minecraft Mod"; - public static final String VERSION = "1.23.0"; + public static final String VERSION = "1.23.1"; public static final String CONFIG_FILENAME = "TBM_Config.toml"; public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml"; public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/"; diff --git a/src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml b/src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml index 62fc04b..dbdae74 100644 --- a/src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml +++ b/src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml @@ -87,10 +87,7 @@ creeper_always_allow_damage = true # This array lists damage sources that are ignored for an entity in battle. # To allow damage from all sources during battle, make this array empty. -# Valid values: -# "inFire", "lightningBolt", "onFire", "lava", "hotFloor", "inWall", "cramming", "drown", "starve", -# "cactus", "fall", "flyIntoWall", "outOfWorld", "magic", "wither", "anvil", "fallingBlock", -# "dragonBreath", "dryout", "sweetBerryBush", "freeze", "fallingStalactite", "stalagmite" +# Check the output of "/tbm-server-edit" and clicking on "ignore_damage_sources" for possible values. ignore_damage_sources = [ "inFire", "onFire", diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index b582d0e..71cef37 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "com_burnedkirby_turnbasedminecraft", "name": "Turn Based Minecraft", "description": "Changes battles to be turn-based.", - "version": "1.23.0", + "version": "1.23.1", "mcversion": "1.20.1", "url": "", "updateUrl": "",