mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-24 05:47:59 +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.CastingMethod;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
import com.minelittlepony.unicopia.server.world.UGameRules;
|
||||||
|
|
||||||
public class TimeChangeAbility implements Ability<Hit> {
|
public class TimeChangeAbility implements Ability<Hit> {
|
||||||
|
|
||||||
|
@ -43,6 +44,11 @@ public class TimeChangeAbility implements Ability<Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Hit> prepare(Pony player) {
|
public Optional<Hit> prepare(Pony player) {
|
||||||
|
|
||||||
|
if (!player.asWorld().getGameRules().getBoolean(UGameRules.DO_TIME_MAGIC)) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
if (!player.subtractEnergyCost(0)) {
|
if (!player.subtractEnergyCost(0)) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -52,6 +58,9 @@ public class TimeChangeAbility implements Ability<Hit> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pony player, Hit data) {
|
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)) {
|
if (player.getSpellSlot().contains(SpellType.TIME_CONTROL)) {
|
||||||
player.getSpellSlot().removeWhere(SpellType.TIME_CONTROL, true);
|
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.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.*;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.*;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
import com.minelittlepony.unicopia.server.world.UGameRules;
|
||||||
import com.minelittlepony.unicopia.server.world.UnicopiaWorldProperties;
|
import com.minelittlepony.unicopia.server.world.UnicopiaWorldProperties;
|
||||||
|
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
@ -29,6 +30,10 @@ public class TimeControlAbilitySpell extends AbstractSpell {
|
||||||
@Override
|
@Override
|
||||||
public boolean tick(Caster<?> source, Situation situation) {
|
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())) {
|
if (situation != Situation.BODY || !(source instanceof Pony pony) || !Abilities.TIME.canUse(pony.getCompositeRace())) {
|
||||||
return false;
|
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> 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<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<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() { }
|
static void bootstrap() { }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue