From ea813c3dcbed485d388eee21dd098f639fdb99f9 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 13 Dec 2023 18:21:06 +0000 Subject: [PATCH] Add an advancement: A Falling Wizard --- .../ability/UnicornTeleportAbility.java | 16 ++++++---- .../unicopia/advancement/UCriteria.java | 1 + .../resources/assets/unicopia/lang/en_us.json | 2 ++ .../unicopia/unicorn/a_falling_wizard.json | 29 +++++++++++++++++++ 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/main/resources/data/unicopia/advancements/unicopia/unicorn/a_falling_wizard.json diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java index 0e305e88..1f9c411e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java @@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.data.Pos; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; +import com.minelittlepony.unicopia.advancement.UCriteria; import com.minelittlepony.unicopia.block.state.StatePredicate; import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.player.Pony; @@ -163,16 +164,19 @@ public class UnicornTeleportAbility implements Ability { Vec3d dest = destination.vec().add(offset); - participant.teleport( - dest.x, - getTargetYPosition(participant.getEntityWorld(), BlockPos.ofFloored(dest), ShapeContext.of(participant)), - dest.z - ); + dest = new Vec3d(dest.x, getTargetYPosition(participant.getEntityWorld(), BlockPos.ofFloored(dest), ShapeContext.of(participant)), dest.z); + + participant.teleport(dest.x, dest.y, dest.z); teleporter.subtractEnergyCost(distance); participant.fallDistance /= distance; - participant.getWorld().playSound(null, destination.pos(), USounds.ENTITY_PLAYER_UNICORN_TELEPORT, SoundCategory.PLAYERS, 1, 1); + BlockPos blockPos = BlockPos.ofFloored(dest); + + participant.getWorld().playSound(null, blockPos, USounds.ENTITY_PLAYER_UNICORN_TELEPORT, SoundCategory.PLAYERS, 1, 1); + if (!participant.getEntityWorld().isInBuildLimit(blockPos)) { + UCriteria.TELEPORT_ABOVE_WORLD.trigger(teleporter.asEntity()); + } return true; } diff --git a/src/main/java/com/minelittlepony/unicopia/advancement/UCriteria.java b/src/main/java/com/minelittlepony/unicopia/advancement/UCriteria.java index 05121bc8..a652354d 100644 --- a/src/main/java/com/minelittlepony/unicopia/advancement/UCriteria.java +++ b/src/main/java/com/minelittlepony/unicopia/advancement/UCriteria.java @@ -27,6 +27,7 @@ public interface UCriteria { CustomEventCriterion.Trigger POWER_UP_HEART = CUSTOM_EVENT.createTrigger("power_up_heart"); CustomEventCriterion.Trigger SPLIT_SEA = CUSTOM_EVENT.createTrigger("split_sea"); CustomEventCriterion.Trigger RIDE_BALLOON = CUSTOM_EVENT.createTrigger("ride_balloon"); + CustomEventCriterion.Trigger TELEPORT_ABOVE_WORLD = CUSTOM_EVENT.createTrigger("teleport_above_world"); static void bootstrap() { } } diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index d9fdcaa0..41f63712 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -1180,6 +1180,8 @@ "advancements.unicopia.tempted.description": "Put on the alicorn amulet", "advancements.unicopia.hello_darkness_my_old_friend.title": "Hello Darkness...", "advancements.unicopia.hello_darkness_my_old_friend.description": "Delve further into the powers of the dark side", + "advancements.unicopia.a_falling_wizard.title": "A Falling Wizard", + "advancements.unicopia.a_falling_wizard.description": "A unicorn tried to perform an unsuccessful flying spell", "advancements.unicopia.split_the_sea.title": "Who are you? Moses?", "advancements.unicopia.split_the_sea.description": "Use magic to displace over 100 blocks of water in one go", diff --git a/src/main/resources/data/unicopia/advancements/unicopia/unicorn/a_falling_wizard.json b/src/main/resources/data/unicopia/advancements/unicopia/unicorn/a_falling_wizard.json new file mode 100644 index 00000000..bb6eada4 --- /dev/null +++ b/src/main/resources/data/unicopia/advancements/unicopia/unicorn/a_falling_wizard.json @@ -0,0 +1,29 @@ +{ + "parent": "unicopia:unicopia/unicorn/magical_route", + "display": { + "icon": { + "item": "unicopia:pegasus_amulet" + }, + "title": { + "translate": "advancements.unicopia.a_falling_wizard.title" + }, + "description": { + "translate": "advancements.unicopia.a_falling_wizard.description" + }, + "frame": "challenge", + "show_toast": true, + "announce_to_chat": true, + "hidden": true + }, + "criteria": { + "teleport_above_world": { + "trigger": "unicopia:custom", + "conditions": { + "event": "teleport_above_world" + } + } + }, + "requirements": [ + [ "teleport_above_world" ] + ] +}