]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
Add config option for creeper turn explosion 1.15
authorStephen Seo <seo.disparate@gmail.com>
Wed, 18 Nov 2020 07:16:18 +0000 (16:16 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Wed, 18 Nov 2020 07:16:18 +0000 (16:16 +0900)
Changelog.md
build.gradle
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Battle.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Combatant.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Config.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java
src/main/resources/META-INF/mods.toml
src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml
src/main/resources/mcmod.info

index f9a72654efcbcf89ac514e438419c80d4b49b85e..57ecaf7cf4ade6794f8fb294d38b24d566196610 100644 (file)
@@ -1,5 +1,10 @@
 # Upcoming changes
 
+# Version 1.15
+
+Add server-side config option that determines on what turn a Creeper will
+explode in battle.
+
 # Version 1.14
 
 Implemented support for Creepers in battle.
index 353be68338a69dc0a4e1626f2e2fe78873570be3..7ce28a7789fe7dd27da736ee7a411caf967f5dcd 100644 (file)
@@ -14,7 +14,7 @@ apply plugin: 'eclipse'
 //apply plugin: 'maven-publish'\r
 apply plugin: 'com.github.johnrengelman.shadow'\r
 \r
-version = "1.14"\r
+version = "1.15"\r
 group = "com.burnedkirby.TurnBasedMinecraft"\r
 archivesBaseName = "TurnBasedMinecraft"\r
 \r
index 28c09b1f2072f204c14e3d2d2879568a63b52b8b..17eaf00bbc22e1cba7af3c4cbcf89f16e5a9ddb6 100644 (file)
@@ -830,7 +830,7 @@ public class Battle
                     if(!(c.entity instanceof PlayerEntity) && c.decision == Decision.UNDECIDED && c.entityInfo != null)
                     {
                         if(c.entity instanceof CreeperEntity) {
-                            if(c.creeperTurns++ < 2) {
+                            if(c.creeperTurns++ < TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
                                 c.decision = Decision.CREEPER_WAIT;
                             } else {
                                 c.decision = Decision.CREEPER_EXPLODE;
@@ -857,7 +857,7 @@ public class Battle
                     if(!(c.entity instanceof PlayerEntity) && c.decision == Decision.UNDECIDED && c.entityInfo != null)
                     {
                         if(c.entity instanceof CreeperEntity) {
-                            if(c.creeperTurns++ < 2) {
+                            if(c.creeperTurns++ < TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
                                 c.decision = Decision.CREEPER_WAIT;
                             } else {
                                 c.decision = Decision.CREEPER_EXPLODE;
@@ -1348,7 +1348,7 @@ public class Battle
                         break;
                     case CREEPER_WAIT:
                         debugLog += " creeper wait";
-                        if(next.creeperTurns < 2) {
+                        if(next.creeperTurns < TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
                             sendMessageToAllPlayers(PacketBattleMessage.MessageType.CREEPER_WAIT, next.entity.getEntityId(), 0, 0);
                         } else {
                             sendMessageToAllPlayers(PacketBattleMessage.MessageType.CREEPER_WAIT_FINAL, next.entity.getEntityId(), 0, 0);
@@ -1493,7 +1493,7 @@ public class Battle
     private void defuseCreepers() {
         for(Combatant c : sideA.values()) {
             if(c.entity instanceof CreeperEntity) {
-                if(c.creeperTurns <= 2) {
+                if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
                     ((CreeperEntity)c.entity).setCreeperState(-10);
                 } else {
                     ((CreeperEntity)c.entity).setCreeperState(1000000);
@@ -1502,7 +1502,7 @@ public class Battle
         }
         for(Combatant c : sideB.values()) {
             if(c.entity instanceof CreeperEntity) {
-                if(c.creeperTurns <= 2) {
+                if(c.creeperTurns <= TurnBasedMinecraftMod.proxy.getConfig().getCreeperExplodeTurn()) {
                     ((CreeperEntity)c.entity).setCreeperState(-10);
                 } else {
                     ((CreeperEntity) c.entity).setCreeperState(1000000);
index 037fb0cea9810fe0a98f44688dc0c72430cbe59c..f7ed61d6f3d688c117aaee451e5970dd24c24714 100644 (file)
@@ -32,7 +32,7 @@ public class Combatant
         decision = Battle.Decision.UNDECIDED;
         recalcSpeedOnCompare = false;
         remainingDefenses = 0;
-        creeperTurns = 0;
+        creeperTurns = 1;
     }
     
     public Combatant(Entity e, EntityInfo entityInfo)
@@ -42,7 +42,7 @@ public class Combatant
         this.entityInfo = entityInfo;
         recalcSpeedOnCompare = false;
         remainingDefenses = 0;
-        creeperTurns = 0;
+        creeperTurns = 1;
     }
     
     /**
index 61745212775ab68d21eae8f6caf01a1d169e9787..251be08c50e2de54d173d21f9657c4c69ae85d05 100644 (file)
@@ -45,6 +45,7 @@ public class Config
     private boolean oldBattleBehaviorEnabled = false;
     private int leaveBattleCooldownSeconds = 5;
     private int aggroStartBattleDistance = 8;
+    private int creeperExplodeTurn = 5;
 
     public Config(Logger logger)
     {
@@ -236,6 +237,23 @@ public class Config
             logTOMLInvalidValue("server_config.aggro_start_battle_max_distance", "8");
         }
 
+        try {
+            OptionalInt creeper_explode_turn = conf.getOptionalInt("server_config.creeper_explode_turn");
+            if(creeper_explode_turn.isPresent()) {
+                this.creeperExplodeTurn = creeper_explode_turn.getAsInt();
+                if(this.creeperExplodeTurn < 1) {
+                    logClampedValue("server_config.creeper_explode_turn", Integer.toString(this.creeperExplodeTurn), "1");
+                    this.creeperExplodeTurn = 1;
+                }
+            } else {
+                this.creeperExplodeTurn = 5;
+                logNotFound("server_config.creeper_explode_turn", "5");
+            }
+        } catch(ClassCastException e) {
+            this.creeperExplodeTurn = 5;
+            logTOMLInvalidValue("server_config.creeper_explode_turn", "5");
+        }
+
         try {
             Boolean old_battle_behavior = conf.get("server_config.old_battle_behavior");
             if(old_battle_behavior != null) {
@@ -1137,4 +1155,6 @@ public class Config
     {
         return aggroStartBattleDistance;
     }
+
+    public int getCreeperExplodeTurn() { return creeperExplodeTurn; }
 }
index 2f8244d0420c1207371e824732bc8fde1259b2f2..9a8fc72451ab95479cd41556b9ac16890bcde0ea 100644 (file)
@@ -35,7 +35,7 @@ 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.14";
+    public static final String VERSION = "1.15";
     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/";
index 4ed5397d25d09bfa6cbf7ae139d075b8b208090b..cf7b29130365d24e92791ff6d6b4d290420b50d4 100644 (file)
@@ -15,7 +15,7 @@ license="MIT"
 # The modid of the mod
 modId="com_burnedkirby_turnbasedminecraft" #mandatory
 # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
-version="1.14" #mandatory
+version="1.15" #mandatory
  # A display name for the mod
 displayName="TurnBasedMinecraftMod" #mandatory
 # A URL to query for updates for this mod. See the JSON update specification <here>
index 919b01cee41f12668fd04e53fd633e7e7b710d49..a55d44f31c1f34000188bd2657e5d14acaaa6a7e 100644 (file)
@@ -1,6 +1,6 @@
 # Please do not change this option, the mod uses this to keep track of what new
 # changes to add to the config.
-version = 4
+version = 5
 do_not_overwrite = false
 
 [client_config]
@@ -69,6 +69,9 @@ minimum_hit_percentage = 4
 # Minimum 5, maximum 60.
 battle_turn_time_seconds = 15
 
+# On what turn a Creeper will explode in battle
+creeper_explode_turn = 5
+
 
 # Each "server_config.entity" entry uses the following options:
 # name: full class name of the entity, cannot also have option "custom_name"
index 45497a9e81118f89c5d89a674afa562971b55820..20cc2a16a96457b4ea747a90341d1cce754e7495 100644 (file)
@@ -3,7 +3,7 @@
   "modid": "com_burnedkirby_turnbasedminecraft",
   "name": "Turn Based Minecraft",
   "description": "Changes battles to be turn-based.",
-  "version": "1.14",
+  "version": "1.15",
   "mcversion": "1.16.3",
   "url": "",
   "updateUrl": "",