mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fixed disguises applied via commands not remaining when applied to a non-changeling entity
This commit is contained in:
parent
74e68f2e09
commit
0f4826e802
2 changed files with 19 additions and 2 deletions
|
@ -26,11 +26,18 @@ public class DispersableDisguiseSpell extends AbstractDisguiseSpell implements I
|
||||||
private final DataTracker.Entry<Boolean> suppressed = dataTracker.startTracking(TrackableDataType.BOOLEAN, false);
|
private final DataTracker.Entry<Boolean> suppressed = dataTracker.startTracking(TrackableDataType.BOOLEAN, false);
|
||||||
private int suppressionCounter;
|
private int suppressionCounter;
|
||||||
|
|
||||||
|
private boolean forced;
|
||||||
|
|
||||||
public DispersableDisguiseSpell(CustomisedSpellType<?> type) {
|
public DispersableDisguiseSpell(CustomisedSpellType<?> type) {
|
||||||
super(type);
|
super(type);
|
||||||
setHidden(true);
|
setHidden(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setForced() {
|
||||||
|
forced = true;
|
||||||
|
setHidden(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVulnerable(Caster<?> otherSource, Spell other) {
|
public boolean isVulnerable(Caster<?> otherSource, Spell other) {
|
||||||
return suppressionCounter <= otherSource.getLevel().get();
|
return suppressionCounter <= otherSource.getLevel().get();
|
||||||
|
@ -59,7 +66,7 @@ public class DispersableDisguiseSpell extends AbstractDisguiseSpell implements I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!source.canUse(Abilities.DISGUISE)) {
|
if (!forced && !source.canUse(Abilities.DISGUISE)) {
|
||||||
setDead();
|
setDead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,12 +98,14 @@ public class DispersableDisguiseSpell extends AbstractDisguiseSpell implements I
|
||||||
public void toNBT(NbtCompound compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
compound.putInt("suppressionCounter", suppressionCounter);
|
compound.putInt("suppressionCounter", suppressionCounter);
|
||||||
|
compound.putBoolean("forced", forced);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(NbtCompound compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
suppressionCounter = compound.getInt("suppressionCounter");
|
suppressionCounter = compound.getInt("suppressionCounter");
|
||||||
|
forced = compound.getBoolean("forced");
|
||||||
if (suppressionCounter > 0) {
|
if (suppressionCounter > 0) {
|
||||||
suppressed.set(true);
|
suppressed.set(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,10 @@ import java.util.function.Function;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.EquinePredicates;
|
import com.minelittlepony.unicopia.EquinePredicates;
|
||||||
import com.minelittlepony.unicopia.InteractionManager;
|
import com.minelittlepony.unicopia.InteractionManager;
|
||||||
|
import com.minelittlepony.unicopia.ability.Abilities;
|
||||||
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
|
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.CastingMethod;
|
import com.minelittlepony.unicopia.ability.magic.spell.CastingMethod;
|
||||||
|
import com.minelittlepony.unicopia.ability.magic.spell.DispersableDisguiseSpell;
|
||||||
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.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
@ -81,7 +83,13 @@ public class DisguiseCommand {
|
||||||
|
|
||||||
Pony iplayer = Pony.of(player);
|
Pony iplayer = Pony.of(player);
|
||||||
iplayer.getSpellSlot().get(SpellType.CHANGELING_DISGUISE)
|
iplayer.getSpellSlot().get(SpellType.CHANGELING_DISGUISE)
|
||||||
.orElseGet(() -> SpellType.CHANGELING_DISGUISE.withTraits().apply(iplayer, CastingMethod.INNATE))
|
.orElseGet(() -> {
|
||||||
|
DispersableDisguiseSpell spell = SpellType.CHANGELING_DISGUISE.withTraits().apply(iplayer, CastingMethod.INNATE);
|
||||||
|
if (!iplayer.canUse(Abilities.DISGUISE)) {
|
||||||
|
spell.setForced();
|
||||||
|
}
|
||||||
|
return spell;
|
||||||
|
})
|
||||||
.setDisguise(entity);
|
.setDisguise(entity);
|
||||||
|
|
||||||
if (source.getEntity() == player) {
|
if (source.getEntity() == player) {
|
||||||
|
|
Loading…
Reference in a new issue