mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Add a fortification status effect so earth ponies can see when they're fortified
This commit is contained in:
parent
6a8c0d82ee
commit
e6ec2083ef
8 changed files with 73 additions and 13 deletions
|
@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.ability.magic.spell.effect;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.Living;
|
import com.minelittlepony.unicopia.entity.Living;
|
||||||
|
import com.minelittlepony.unicopia.entity.effect.EffectUtils;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
||||||
|
|
||||||
|
@ -61,12 +62,10 @@ public interface AttractionUtils {
|
||||||
return Pony.of(entity).map(pony -> {
|
return Pony.of(entity).map(pony -> {
|
||||||
double force = 0.75;
|
double force = 0.75;
|
||||||
|
|
||||||
if (pony.getCompositeRace().canUseEarth()) {
|
if (EffectUtils.hasExtraDefenses(pony.asEntity())) {
|
||||||
|
force /= 12;
|
||||||
|
} else if (pony.getCompositeRace().canUseEarth()) {
|
||||||
force /= 2;
|
force /= 2;
|
||||||
|
|
||||||
if (pony.asEntity().isSneaking()) {
|
|
||||||
force /= 6;
|
|
||||||
}
|
|
||||||
} else if (pony.getCompositeRace().canFly()) {
|
} else if (pony.getCompositeRace().canFly()) {
|
||||||
force *= 2;
|
force *= 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.entity.effect;
|
||||||
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.effect.StatusEffect;
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
|
|
||||||
public interface EffectUtils {
|
public interface EffectUtils {
|
||||||
static boolean isPoisoned(LivingEntity entity) {
|
static boolean isPoisoned(LivingEntity entity) {
|
||||||
|
@ -15,4 +16,26 @@ public interface EffectUtils {
|
||||||
static boolean isChangingRace(LivingEntity entity) {
|
static boolean isChangingRace(LivingEntity entity) {
|
||||||
return entity.getStatusEffects().stream().anyMatch(effect -> effect.getEffectType() instanceof RaceChangeStatusEffect);
|
return entity.getStatusEffects().stream().anyMatch(effect -> effect.getEffectType() instanceof RaceChangeStatusEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean hasExtraDefenses(LivingEntity entity) {
|
||||||
|
return entity.hasStatusEffect(UEffects.FORTIFICATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean applyStatusEffect(LivingEntity entity, StatusEffect effect, boolean apply) {
|
||||||
|
if (entity.getWorld().isClient) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean has = entity.hasStatusEffect(effect);
|
||||||
|
if (has != apply) {
|
||||||
|
if (has) {
|
||||||
|
if (entity.getStatusEffect(effect).getDuration() == StatusEffectInstance.INFINITE) {
|
||||||
|
entity.removeStatusEffect(effect);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entity.addStatusEffect(new StatusEffectInstance(effect, StatusEffectInstance.INFINITE, 0, false, false, true));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.minelittlepony.unicopia.entity.effect;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectCategory;
|
||||||
|
|
||||||
|
public class SimpleStatusEffect extends StatusEffect {
|
||||||
|
|
||||||
|
private final boolean instant;
|
||||||
|
|
||||||
|
public SimpleStatusEffect(StatusEffectCategory category, int color, boolean instant) {
|
||||||
|
super(category, color);
|
||||||
|
this.instant = instant;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean isInstant() {
|
||||||
|
return instant;
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,8 @@ public interface UEffects {
|
||||||
* When affecting an entity, will give them a random chance to reproduce or duplicate themselves when they die.
|
* When affecting an entity, will give them a random chance to reproduce or duplicate themselves when they die.
|
||||||
*/
|
*/
|
||||||
StatusEffect CORRUPT_INFLUENCE = register("corrupt_influence", new CorruptInfluenceStatusEffect(0x00FF00));
|
StatusEffect CORRUPT_INFLUENCE = register("corrupt_influence", new CorruptInfluenceStatusEffect(0x00FF00));
|
||||||
StatusEffect PARALYSIS = register("paralysis", new StatusEffect(StatusEffectCategory.HARMFUL, 0) {});
|
StatusEffect PARALYSIS = register("paralysis", new SimpleStatusEffect(StatusEffectCategory.HARMFUL, 0, false));
|
||||||
|
StatusEffect FORTIFICATION = register("fortification", new SimpleStatusEffect(StatusEffectCategory.BENEFICIAL, 0x000077, false));
|
||||||
/**
|
/**
|
||||||
* Side-effect of wearing the alicorn amulet.
|
* Side-effect of wearing the alicorn amulet.
|
||||||
* Causes the player to lose grip on whatever item they're holding.
|
* Causes the player to lose grip on whatever item they're holding.
|
||||||
|
|
|
@ -6,6 +6,8 @@ import java.util.function.Predicate;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||||
|
import com.minelittlepony.unicopia.entity.effect.EffectUtils;
|
||||||
|
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
||||||
import com.minelittlepony.unicopia.entity.mob.UEntityAttributes;
|
import com.minelittlepony.unicopia.entity.mob.UEntityAttributes;
|
||||||
import com.minelittlepony.unicopia.util.Tickable;
|
import com.minelittlepony.unicopia.util.Tickable;
|
||||||
|
|
||||||
|
@ -87,6 +89,7 @@ public class PlayerAttributes implements Tickable {
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
ATTRIBUTES.forEach(attribute -> attribute.update(pony));
|
ATTRIBUTES.forEach(attribute -> attribute.update(pony));
|
||||||
|
EffectUtils.applyStatusEffect(pony.asEntity(), UEffects.FORTIFICATION, pony.getCompositeRace().canUseEarth() && pony.asEntity().isSneaking());
|
||||||
}
|
}
|
||||||
|
|
||||||
record ToggleableAttribute(EntityAttributeModifier modifier, List<EntityAttribute> attributes, Predicate<Pony> test) {
|
record ToggleableAttribute(EntityAttributeModifier modifier, List<EntityAttribute> attributes, Predicate<Pony> test) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.minelittlepony.unicopia.advancement.UCriteria;
|
||||||
import com.minelittlepony.unicopia.entity.*;
|
import com.minelittlepony.unicopia.entity.*;
|
||||||
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
|
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
|
||||||
import com.minelittlepony.unicopia.entity.duck.LivingEntityDuck;
|
import com.minelittlepony.unicopia.entity.duck.LivingEntityDuck;
|
||||||
|
import com.minelittlepony.unicopia.entity.effect.EffectUtils;
|
||||||
import com.minelittlepony.unicopia.entity.effect.MetamorphosisStatusEffect;
|
import com.minelittlepony.unicopia.entity.effect.MetamorphosisStatusEffect;
|
||||||
import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect;
|
import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect;
|
||||||
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
||||||
|
@ -700,18 +701,17 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cause.isIn(DamageTypeTags.BYPASSES_SHIELD)
|
if (EffectUtils.hasExtraDefenses(entity)
|
||||||
|
&& !cause.isIn(DamageTypeTags.BYPASSES_SHIELD)
|
||||||
&& !cause.isOf(DamageTypes.MAGIC)
|
&& !cause.isOf(DamageTypes.MAGIC)
|
||||||
&& !cause.isIn(DamageTypeTags.IS_FIRE)
|
&& !cause.isIn(DamageTypeTags.IS_FIRE)
|
||||||
&& !cause.isIn(DamageTypeTags.BYPASSES_INVULNERABILITY)
|
&& !cause.isIn(DamageTypeTags.BYPASSES_INVULNERABILITY)
|
||||||
&& !cause.isOf(DamageTypes.THORNS)
|
&& !cause.isOf(DamageTypes.THORNS)
|
||||||
&& !cause.isOf(DamageTypes.FREEZE)) {
|
&& !cause.isOf(DamageTypes.FREEZE)) {
|
||||||
|
|
||||||
if (getCompositeRace().canUseEarth() && entity.isSneaking()) {
|
amount /= (cause.isOf(DamageTypes.MOB_PROJECTILE) ? 3 : 2) * (entity.getHealth() < 5 ? 3 : 1);
|
||||||
amount /= (cause.isOf(DamageTypes.MOB_PROJECTILE) ? 3 : 2) * (entity.getHealth() < 5 ? 3 : 1);
|
|
||||||
|
|
||||||
return Optional.of(amount);
|
return Optional.of(amount);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -727,7 +727,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
public float onImpact(float distance, float damageMultiplier, DamageSource cause) {
|
public float onImpact(float distance, float damageMultiplier, DamageSource cause) {
|
||||||
distance = super.onImpact(distance, damageMultiplier, cause);
|
distance = super.onImpact(distance, damageMultiplier, cause);
|
||||||
|
|
||||||
if (getCompositeRace().canUseEarth() && entity.isSneaking()) {
|
if (EffectUtils.hasExtraDefenses(entity)) {
|
||||||
double radius = distance / 10;
|
double radius = distance / 10;
|
||||||
if (radius > 0) {
|
if (radius > 0) {
|
||||||
EarthPonyStompAbility.spawnEffectAround(entity, entity.getSteppingPos(), radius, radius);
|
EarthPonyStompAbility.spawnEffectAround(entity, entity.getSteppingPos(), radius, radius);
|
||||||
|
@ -750,7 +750,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCompositeRace().canFly() || (getCompositeRace().canUseEarth() && entity.isSneaking())) {
|
if (getCompositeRace().canFly() || EffectUtils.hasExtraDefenses(entity)) {
|
||||||
distance -= 5;
|
distance -= 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,6 +406,7 @@
|
||||||
"effect.unicopia.corrupt_influence": "Corrupt Influence",
|
"effect.unicopia.corrupt_influence": "Corrupt Influence",
|
||||||
"effect.unicopia.paralysis": "Paralysis",
|
"effect.unicopia.paralysis": "Paralysis",
|
||||||
"effect.unicopia.butter_fingers": "Butterfingers",
|
"effect.unicopia.butter_fingers": "Butterfingers",
|
||||||
|
"effect.unicopia.fortification": "Fortification",
|
||||||
|
|
||||||
"effect.unicopia.change_race_earth": "Earth Pony Metamorphosis",
|
"effect.unicopia.change_race_earth": "Earth Pony Metamorphosis",
|
||||||
"effect.unicopia.change_race_unicorn": "Unicorn Metamorphosis",
|
"effect.unicopia.change_race_unicorn": "Unicorn Metamorphosis",
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 8.4 KiB |
Loading…
Reference in a new issue