]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
Impl config and settings for creeper behavior 1.16
authorStephen Seo <seo.disparate@gmail.com>
Wed, 18 Nov 2020 08:24:18 +0000 (17:24 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Wed, 18 Nov 2020 08:24:18 +0000 (17:24 +0900)
Changelog.md
build.gradle
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/AttackEventHandler.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/BattleManager.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 57ecaf7cf4ade6794f8fb294d38b24d566196610..1d5b80deebfea56cc9cbc66c975e0cefd6729ed1 100644 (file)
@@ -1,5 +1,15 @@
 # Upcoming changes
 
+# Version 1.16
+
+Add config options regarding creeper behavior.
+
+By default, creepers will not explode if they leave battle (maybe due to a
+player fleeing), until the cooldown time ends.
+
+By default, creepers that explode will damage anyone, even if they weren't in
+turn-based battle.
+
 # Version 1.15
 
 Add server-side config option that determines on what turn a Creeper will
index 7ce28a7789fe7dd27da736ee7a411caf967f5dcd..5d633d112e6cb114df50164943ff630559e9fb03 100644 (file)
@@ -14,7 +14,7 @@ apply plugin: 'eclipse'
 //apply plugin: 'maven-publish'\r
 apply plugin: 'com.github.johnrengelman.shadow'\r
 \r
-version = "1.15"\r
+version = "1.16"\r
 group = "com.burnedkirby.TurnBasedMinecraft"\r
 archivesBaseName = "TurnBasedMinecraft"\r
 \r
index 2f437060a8956a1142082e20ac2e4184e0b138f8..025fb558bf4863207160a76f1bae84ed9484903b 100644 (file)
@@ -6,6 +6,7 @@ import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
 
 import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketEditingMessage;
 import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
+import net.minecraft.entity.monster.CreeperEntity;
 import net.minecraft.entity.player.ServerPlayerEntity;
 import net.minecraftforge.event.entity.living.LivingAttackEvent;
 import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
@@ -115,8 +116,12 @@ public class AttackEventHandler
         }
         if(event.getEntity() != null && event.getSource().getTrueSource() != null && (battleManager.isRecentlyLeftBattle(event.getEntity().getEntityId()) || battleManager.isRecentlyLeftBattle(event.getSource().getTrueSource().getEntityId())))
         {
+            if(event.getSource().getTrueSource().getEntity() instanceof CreeperEntity && TurnBasedMinecraftMod.proxy.getConfig().getCreeperAlwaysAllowDamage()) {
+                event.setCanceled(false);
+            } else {
 //            TurnBasedMinecraftMod.logger.debug("Canceled attack");
-            event.setCanceled(true);
+                event.setCanceled(true);
+            }
             return;
         }
         else if(!isAttackerValid(event)
index 1c2956275392e592184096ca65492789ca4e966c..23fc442250ff92b6e78c59e9ba44f04c6557164e 100644 (file)
@@ -6,6 +6,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
+import net.minecraft.entity.monster.CreeperEntity;
 import net.minecraft.entity.player.PlayerEntity;
 import net.minecraft.entity.player.ServerPlayerEntity;
 import net.minecraft.util.RegistryKey;
@@ -323,6 +324,9 @@ public class BattleManager
         for(Iterator<Map.Entry<Integer, Combatant>> iter = recentlyLeftBattle.entrySet().iterator(); iter.hasNext();)
         {
             Map.Entry<Integer, Combatant> entry = iter.next();
+            if(entry.getValue().entity instanceof CreeperEntity && TurnBasedMinecraftMod.proxy.getConfig().getCreeperStopExplodeOnLeaveBattle()) {
+                ((CreeperEntity)entry.getValue().entity).setCreeperState(-10);
+            }
             if(current - entry.getValue().time > TurnBasedMinecraftMod.proxy.getConfig().getLeaveBattleCooldownNanos())
             {
                 iter.remove();
index 251be08c50e2de54d173d21f9657c4c69ae85d05..7baa93dd372acbb66fb22dd2a9e28002655efac3 100644 (file)
@@ -46,6 +46,8 @@ public class Config
     private int leaveBattleCooldownSeconds = 5;
     private int aggroStartBattleDistance = 8;
     private int creeperExplodeTurn = 5;
+    private boolean creeperStopExplodeOnLeaveBattle = true;
+    private boolean creeperAlwaysAllowDamage = true;
 
     public Config(Logger logger)
     {
@@ -254,6 +256,32 @@ public class Config
             logTOMLInvalidValue("server_config.creeper_explode_turn", "5");
         }
 
+        try {
+            Boolean creeper_stop_explode_on_leave_battle = conf.get("server_config.creeper_stop_explode_on_leave_battle");
+            if(creeper_stop_explode_on_leave_battle != null) {
+                this.creeperStopExplodeOnLeaveBattle = creeper_stop_explode_on_leave_battle;
+            } else {
+                this.creeperStopExplodeOnLeaveBattle = true;
+                logNotFound("server_config.creeper_stop_explode_on_leave_battle", "true");
+            }
+        } catch (ClassCastException e) {
+            this.creeperStopExplodeOnLeaveBattle = true;
+            logTOMLInvalidValue("server_config.creeper_stop_explode_on_leave_battle", "true");
+        }
+
+        try {
+            Boolean creeper_always_allow_damage = conf.get("server_config.creeper_always_allow_damage");
+            if(creeper_always_allow_damage != null) {
+                this.creeperAlwaysAllowDamage = creeper_always_allow_damage;
+            } else {
+                this.creeperAlwaysAllowDamage = true;
+                logNotFound("server_config.creeper_always_allow_damage", "true");
+            }
+        } catch (ClassCastException e) {
+            this.creeperAlwaysAllowDamage = true;
+            logTOMLInvalidValue("server_config.creeper_always_allow_damage", "true");
+        }
+
         try {
             Boolean old_battle_behavior = conf.get("server_config.old_battle_behavior");
             if(old_battle_behavior != null) {
@@ -1157,4 +1185,8 @@ public class Config
     }
 
     public int getCreeperExplodeTurn() { return creeperExplodeTurn; }
+
+    public boolean getCreeperStopExplodeOnLeaveBattle() { return creeperStopExplodeOnLeaveBattle; }
+
+    public boolean getCreeperAlwaysAllowDamage() { return creeperAlwaysAllowDamage; }
 }
index 9a8fc72451ab95479cd41556b9ac16890bcde0ea..60201e2bdefc9bb8d2955b046eea38ac309c2518 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.15";
+    public static final String VERSION = "1.16";
     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 cf7b29130365d24e92791ff6d6b4d290420b50d4..e44196dfc7304af3c79e72335f61f0eab0bcdb48 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.15" #mandatory
+version="1.16" #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 a55d44f31c1f34000188bd2657e5d14acaaa6a7e..686f3a824b42ee2d3f5f7e1a55ec29da16151553 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 = 5
+version = 6
 do_not_overwrite = false
 
 [client_config]
@@ -72,6 +72,12 @@ battle_turn_time_seconds = 15
 # On what turn a Creeper will explode in battle
 creeper_explode_turn = 5
 
+# Keep creepers from exploding when they leave a battle (for leave_battle_cooldown duration)
+creeper_stop_explode_on_leave_battle = true
+
+# If false, creepers may not damage others outside of turn-based battle
+creeper_always_allow_damage = true
+
 
 # Each "server_config.entity" entry uses the following options:
 # name: full class name of the entity, cannot also have option "custom_name"
index 20cc2a16a96457b4ea747a90341d1cce754e7495..02a1d5df6443d51f0d30845490d78780fcc622c6 100644 (file)
@@ -3,7 +3,7 @@
   "modid": "com_burnedkirby_turnbasedminecraft",
   "name": "Turn Based Minecraft",
   "description": "Changes battles to be turn-based.",
-  "version": "1.15",
+  "version": "1.16",
   "mcversion": "1.16.3",
   "url": "",
   "updateUrl": "",