From 5a83227d2c5edae2a9946a1ec7988eee1ec4b0fb Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 4 Sep 2023 23:36:24 +0100 Subject: [PATCH] Added a gamerule to disable the time control ability --- .../unicopia/ability/TimeChangeAbility.java | 9 +++++++++ .../ability/magic/spell/TimeControlAbilitySpell.java | 5 +++++ .../minelittlepony/unicopia/server/world/UGameRules.java | 1 + 3 files changed, 15 insertions(+) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/TimeChangeAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/TimeChangeAbility.java index 96b673f8..4e0c75c0 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/TimeChangeAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/TimeChangeAbility.java @@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.ability.data.Hit.Serializer; import com.minelittlepony.unicopia.ability.magic.spell.CastingMethod; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.server.world.UGameRules; public class TimeChangeAbility implements Ability { @@ -43,6 +44,11 @@ public class TimeChangeAbility implements Ability { @Override public Optional prepare(Pony player) { + + if (!player.asWorld().getGameRules().getBoolean(UGameRules.DO_TIME_MAGIC)) { + return Optional.empty(); + } + if (!player.subtractEnergyCost(0)) { return Optional.empty(); } @@ -52,6 +58,9 @@ public class TimeChangeAbility implements Ability { @Override public boolean apply(Pony player, Hit data) { + if (!player.asWorld().getGameRules().getBoolean(UGameRules.DO_TIME_MAGIC)) { + return false; + } if (player.getSpellSlot().contains(SpellType.TIME_CONTROL)) { player.getSpellSlot().removeWhere(SpellType.TIME_CONTROL, true); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/TimeControlAbilitySpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/TimeControlAbilitySpell.java index 33e5c417..4a232a96 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/TimeControlAbilitySpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/TimeControlAbilitySpell.java @@ -4,6 +4,7 @@ import com.minelittlepony.unicopia.ability.Abilities; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.effect.*; import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.server.world.UGameRules; import com.minelittlepony.unicopia.server.world.UnicopiaWorldProperties; import net.minecraft.nbt.NbtCompound; @@ -29,6 +30,10 @@ public class TimeControlAbilitySpell extends AbstractSpell { @Override public boolean tick(Caster source, Situation situation) { + if (!source.asWorld().getGameRules().getBoolean(UGameRules.DO_TIME_MAGIC)) { + return false; + } + if (situation != Situation.BODY || !(source instanceof Pony pony) || !Abilities.TIME.canUse(pony.getCompositeRace())) { return false; } diff --git a/src/main/java/com/minelittlepony/unicopia/server/world/UGameRules.java b/src/main/java/com/minelittlepony/unicopia/server/world/UGameRules.java index 561f35a3..93fc32bd 100644 --- a/src/main/java/com/minelittlepony/unicopia/server/world/UGameRules.java +++ b/src/main/java/com/minelittlepony/unicopia/server/world/UGameRules.java @@ -9,6 +9,7 @@ public interface UGameRules { GameRules.Key ANNOUNCE_TRIBE_JOINS = GameRules.register("announceTribeJoins", GameRules.Category.SPAWNING, BooleanRule.create(false)); GameRules.Key DO_NOCTURNAL_BAT_PONIES = GameRules.register("doNocturnalBatPonies", GameRules.Category.PLAYER, BooleanRule.create(true)); GameRules.Key WEATHER_EFFECTS_STRENGTH = GameRules.register("weatherEffectsStrength", GameRules.Category.MISC, IntRule.create(100)); + GameRules.Key DO_TIME_MAGIC = GameRules.register("doTimeMagic", GameRules.Category.PLAYER, BooleanRule.create(true)); static void bootstrap() { } }