mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-12-17 23:48:00 +01:00
Added a gamerule to disable the time control ability
This commit is contained in:
parent
46e0f5d15b
commit
5a83227d2c
3 changed files with 15 additions and 0 deletions
|
@ -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<Hit> {
|
||||
|
||||
|
@ -43,6 +44,11 @@ public class TimeChangeAbility implements Ability<Hit> {
|
|||
|
||||
@Override
|
||||
public Optional<Hit> 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<Hit> {
|
|||
|
||||
@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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ public interface UGameRules {
|
|||
GameRules.Key<BooleanRule> ANNOUNCE_TRIBE_JOINS = GameRules.register("announceTribeJoins", GameRules.Category.SPAWNING, BooleanRule.create(false));
|
||||
GameRules.Key<BooleanRule> DO_NOCTURNAL_BAT_PONIES = GameRules.register("doNocturnalBatPonies", GameRules.Category.PLAYER, BooleanRule.create(true));
|
||||
GameRules.Key<IntRule> WEATHER_EFFECTS_STRENGTH = GameRules.register("weatherEffectsStrength", GameRules.Category.MISC, IntRule.create(100));
|
||||
GameRules.Key<BooleanRule> DO_TIME_MAGIC = GameRules.register("doTimeMagic", GameRules.Category.PLAYER, BooleanRule.create(true));
|
||||
|
||||
static void bootstrap() { }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue