Add an advancement for killing phantoms whilst flying

This commit is contained in:
Sollace 2023-05-05 23:21:45 +01:00
parent a3abee6765
commit 207320f6a0
8 changed files with 53 additions and 3 deletions

View file

@ -18,6 +18,7 @@ public interface UCriteria {
CustomEventCriterion.Trigger SEND_OATS = CUSTOM_EVENT.createTrigger("send_oats");
CustomEventCriterion.Trigger RECEIVE_OATS = CUSTOM_EVENT.createTrigger("receive_oats");
CustomEventCriterion.Trigger BREAK_WINDOW = CUSTOM_EVENT.createTrigger("break_window");
CustomEventCriterion.Trigger KILL_PHANTOM_WHILE_FLYING = CUSTOM_EVENT.createTrigger("kill_phantom_while_flying");
static void bootstrap() { }
}

View file

@ -538,6 +538,12 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
}
}
public void onKill(Entity killedEntity, DamageSource damage) {
if (killedEntity != null && killedEntity.getType() == EntityType.PHANTOM && getPhysics().isFlying()) {
UCriteria.KILL_PHANTOM_WHILE_FLYING.trigger(entity);
}
}
@Override
public boolean subtractEnergyCost(double foodSubtract) {

View file

@ -13,6 +13,8 @@ import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.server.world.UGameRules;
import com.mojang.datafixers.util.Either;
import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.screen.ScreenHandlerListener;
import net.minecraft.server.network.ServerPlayerEntity;
@ -44,4 +46,10 @@ abstract class MixinServerPlayerEntity extends PlayerEntity implements ScreenHan
info.setReturnValue(Either.left(PlayerEntity.SleepFailureReason.OTHER_PROBLEM));
}
}
@Inject(method = "updateKilledAdvancementCriterion(Lnet/minecraft/entity/Entity;ILnet/minecraft/entity/damage/DamageSource;)V",
at = @At("TAIL"))
private void onUpdateKilledAdvancementCriterion(Entity entityKilled, int score, DamageSource damageSource, CallbackInfo info) {
get().onKill(entityKilled, damageSource);
}
}

View file

@ -651,6 +651,9 @@
"advancements.unicopia.rainbow_crash.title": "Dammit, Rainbow",
"advancements.unicopia.rainbow_crash.description": "Wage war on the evil glass window nation",
"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",
"unicopia.toast.discoveries.title": "New Discoveries!",
"unicopia.toast.discoveries.description": "Check your spellbook"
}

View file

@ -0,0 +1,32 @@
{
"parent": "unicopia:unicopia/pegasus/sky_route",
"display": {
"icon": {
"item": "unicopia:phantom_membrane"
},
"title": {
"translate": "advancements.unicopia.deter_phantom.title"
},
"description": {
"translate": "advancements.unicopia.deter_phantom.description"
},
"frame": "challenge",
"show_toast": true,
"announce_to_chat": true,
"hidden": true
},
"criteria": {
"the_thing": {
"trigger": "unicopia:custom",
"conditions": {
"event": "kill_phantom_while_flying"
}
}
},
"requirements": [
[ "the_thing" ]
],
"rewards": {
"experience": 100
}
}

View file

@ -24,6 +24,6 @@
}
},
"requirements": [
[ "shed_feather" ]
[ "shed_feather" ]
]
}

View file

@ -25,6 +25,6 @@
}
},
"requirements": [
[ "shed_feather_5" ]
[ "shed_feather_5" ]
]
}

View file

@ -25,6 +25,6 @@
}
},
"requirements": [
[ "shed_feather_15" ]
[ "shed_feather_15" ]
]
}