diff --git a/src/main/java/com/minelittlepony/unicopia/advancement/UCriteria.java b/src/main/java/com/minelittlepony/unicopia/advancement/UCriteria.java index cb6697e0..79264b61 100644 --- a/src/main/java/com/minelittlepony/unicopia/advancement/UCriteria.java +++ b/src/main/java/com/minelittlepony/unicopia/advancement/UCriteria.java @@ -23,6 +23,7 @@ public interface UCriteria { CustomEventCriterion.Trigger USE_CONSUMPTION = CUSTOM_EVENT.createTrigger("use_consumption"); CustomEventCriterion.Trigger USE_SOULMATE = CUSTOM_EVENT.createTrigger("use_soulmate"); CustomEventCriterion.Trigger SECOND_WIND = CUSTOM_EVENT.createTrigger("second_wind"); + CustomEventCriterion.Trigger DEFEAT_SOMBRA = CUSTOM_EVENT.createTrigger("defeat_sombra"); static void bootstrap() { } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java index 5d6681a4..a5a1d7b6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java +++ b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java @@ -66,6 +66,9 @@ public class UnicopiaClient implements ClientModInitializer { @Nullable private Float originalRainGradient; + private float prevRainGradient; + private float rainGradient; + private float targetRainGradient; @Override public void onInitializeClient() { @@ -104,6 +107,7 @@ public class UnicopiaClient implements ClientModInitializer { world.setThunderGradient(1); } else { if (originalRainGradient != null) { + targetRainGradient = originalRainGradient; world.setRainGradient(originalRainGradient); world.setThunderGradient(0); originalRainGradient = null; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/SombraEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/SombraEntity.java index 750e3f4a..22bea48d 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/SombraEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/SombraEntity.java @@ -7,7 +7,9 @@ import java.util.stream.Stream; import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.USounds; +import com.minelittlepony.unicopia.advancement.UCriteria; import com.minelittlepony.unicopia.entity.ai.ArenaAttackGoal; +import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.AmuletItem; import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.particle.ParticleSource; @@ -19,6 +21,7 @@ import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.ExperienceOrbEntity; +import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MovementType; import net.minecraft.entity.ai.goal.ActiveTargetGoal; @@ -323,8 +326,10 @@ public class SombraEntity extends HostileEntity implements ArenaCombatant, Parti ); } - ((LivingEntity)target).addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 26, 0, true, false)); - ((LivingEntity)target).addStatusEffect(new StatusEffectInstance(StatusEffects.DARKNESS, 26, 0, true, false)); + if (this.age % 1000 < 50) { + ((LivingEntity)target).addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 26, 0, true, false)); + ((LivingEntity)target).addStatusEffect(new StatusEffectInstance(StatusEffects.DARKNESS, 26, 0, true, false)); + } if (getTarget() == null && target instanceof PlayerEntity player && player.distanceTo(this) < getAreaRadius() / 2F) { setTarget(player); @@ -433,11 +438,28 @@ public class SombraEntity extends HostileEntity implements ArenaCombatant, Parti VecHelper.findInRange(this, getWorld(), home.toCenterPos(), getAreaRadius() - 0.2F, e -> e instanceof CrystalShardsEntity).forEach(e -> { ((CrystalShardsEntity)e).setDecaying(true); }); + + for (Entity e : VecHelper.findInRange(this, getWorld(), home.toCenterPos(), getAreaRadius() - 0.2F, EFFECT_TARGET_PREDICATE)) { + Pony.of(e).ifPresent(pony -> { + pony.getCorruption().set(0); + UCriteria.DEFEAT_SOMBRA.trigger(e); + }); + } }); + } super.onDeath(damageSource); } + @Override + protected void dropEquipment(DamageSource source, int lootingMultiplier, boolean allowDrops) { + super.dropEquipment(source, lootingMultiplier, allowDrops); + ItemEntity itemEntity = dropItem(UItems.BROKEN_ALICORN_AMULET); + if (itemEntity != null) { + itemEntity.setCovetedItem(); + } + } + @Override protected void updatePostDeath() { if (++deathTime >= 180 && deathTime <= 200) { diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index 9fea941d..53d3c5a4 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -883,6 +883,13 @@ "advancements.unicopia.deter_phantom.title": "What Flies Around", "advancements.unicopia.deter_phantom.description": "Get up there and give those phantoms a taste of their own medicine", + "advancements.unicopia.love_is_power.title": "Love is Power", + "advancements.unicopia.love_is_power.description": "Banish King Sombra with a Crystal Heart", + "advancements.unicopia.save_the_day.title": "Save the Day", + "advancements.unicopia.save_the_day.description": "Defeat King Sombra once and for all", + "advancements.unicopia.doctor_sombrero.title": "Doctor Sombrero", + "advancements.unicopia.doctor_sombrero.description": "That's not mare-iachi!", + "unicopia.toast.discoveries.title": "New Discoveries!", "unicopia.toast.discoveries.description": "Check your spellbook" } diff --git a/src/main/resources/data/unicopia/advancements/unicopia/doctor_sombrero.json b/src/main/resources/data/unicopia/advancements/unicopia/doctor_sombrero.json new file mode 100644 index 00000000..6b5b27ea --- /dev/null +++ b/src/main/resources/data/unicopia/advancements/unicopia/doctor_sombrero.json @@ -0,0 +1,30 @@ +{ + "parent": "unicopia:unicopia/save_the_day", + "display": { + "icon": { + "item": "unicopia:broken_alicorn_amulet" + }, + "title": { + "translate": "advancements.unicopia.doctor_sombrero.title" + }, + "description": { + "translate": "advancements.unicopia.doctor_sombrero.description" + }, + "frame": "challenge", + "show_toast": true, + "announce_to_chat": true, + "hidden": true + }, + "criteria": { + "defeat_sombra": { + "trigger": "unicopia:custom", + "conditions": { + "event": "defeat_sombra", + "repeats": 2 + } + }, + }, + "requirements": [ + [ "defeat_sombra" ] + ] +} diff --git a/src/main/resources/data/unicopia/advancements/unicopia/save_the_day.json b/src/main/resources/data/unicopia/advancements/unicopia/save_the_day.json new file mode 100644 index 00000000..a3dc6931 --- /dev/null +++ b/src/main/resources/data/unicopia/advancements/unicopia/save_the_day.json @@ -0,0 +1,29 @@ +{ + "parent": "unicopia:unicopia/root", + "display": { + "icon": { + "item": "unicopia:broken_alicorn_amulet" + }, + "title": { + "translate": "advancements.unicopia.save_the_day.title" + }, + "description": { + "translate": "advancements.unicopia.save_the_day.description" + }, + "frame": "goal", + "show_toast": true, + "announce_to_chat": true, + "hidden": false + }, + "criteria": { + "defeat_sombra": { + "trigger": "unicopia:custom", + "conditions": { + "event": "defeat_sombra" + } + }, + }, + "requirements": [ + [ "defeat_sombra" ] + ] +}