Impl config and settings for creeper behavior

This commit is contained in:
Stephen Seo 2020-11-18 17:24:18 +09:00
parent befc7cf611
commit c67deef393
9 changed files with 63 additions and 6 deletions

View 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

View file

@ -14,7 +14,7 @@ apply plugin: 'eclipse'
//apply plugin: 'maven-publish'
apply plugin: 'com.github.johnrengelman.shadow'
version = "1.15"
version = "1.16"
group = "com.burnedkirby.TurnBasedMinecraft"
archivesBaseName = "TurnBasedMinecraft"

View 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)

View 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();

View 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; }
}

View 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/";

View 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>

View 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"

View 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": "",