Added a bunch of new advancements

This commit is contained in:
Sollace 2021-08-19 00:49:02 +02:00
parent a20a3e638c
commit 51082fdf90
16 changed files with 542 additions and 8 deletions

View file

@ -1,6 +1,12 @@
package com.minelittlepony.unicopia.advancement; package com.minelittlepony.unicopia.advancement;
import java.util.HashSet;
import java.util.Set;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.advancement.criterion.AbstractCriterion; import net.minecraft.advancement.criterion.AbstractCriterion;
import net.minecraft.advancement.criterion.AbstractCriterionConditions; import net.minecraft.advancement.criterion.AbstractCriterionConditions;
@ -22,14 +28,26 @@ public class CustomEventCriterion extends AbstractCriterion<CustomEventCriterion
} }
@Override @Override
protected Conditions conditionsFromJson(JsonObject json, Extended player, AdvancementEntityPredicateDeserializer deserializer) { protected Conditions conditionsFromJson(JsonObject json, Extended playerPredicate, AdvancementEntityPredicateDeserializer deserializer) {
return new Conditions(player, JsonHelper.getString(json, "event"));
Set<Race> races = new HashSet<>();
if (json.has("race")) {
json.get("race").getAsJsonArray().forEach(el -> {
races.add(Race.fromName(el.getAsString()));
});
}
return new Conditions(
playerPredicate,
JsonHelper.getString(json, "event"),
races
);
} }
public CustomEventCriterion.Trigger createTrigger(String name) { public CustomEventCriterion.Trigger createTrigger(String name) {
return player -> { return player -> {
if (player instanceof ServerPlayerEntity) { if (player instanceof ServerPlayerEntity) {
test((ServerPlayerEntity)player, c -> c.test(name)); test((ServerPlayerEntity)player, c -> c.test(name, (ServerPlayerEntity)player));
} }
}; };
} }
@ -41,19 +59,27 @@ public class CustomEventCriterion extends AbstractCriterion<CustomEventCriterion
public static class Conditions extends AbstractCriterionConditions { public static class Conditions extends AbstractCriterionConditions {
private final String event; private final String event;
public Conditions(Extended playerPredicate, String event) { private final Set<Race> races;
public Conditions(Extended playerPredicate, String event, Set<Race> races) {
super(ID, playerPredicate); super(ID, playerPredicate);
this.event = event; this.event = event;
this.races = races;
} }
public boolean test(String event) { public boolean test(String event, ServerPlayerEntity player) {
return this.event.equalsIgnoreCase(event); return this.event.equalsIgnoreCase(event) && (races.isEmpty() || races.contains(Pony.of(player).getSpecies()));
} }
@Override @Override
public JsonObject toJson(AdvancementEntityPredicateSerializer serializer) { public JsonObject toJson(AdvancementEntityPredicateSerializer serializer) {
JsonObject json = super.toJson(serializer); JsonObject json = super.toJson(serializer);
json.addProperty("event", event); json.addProperty("event", event);
if (!races.isEmpty()) {
JsonArray arr = new JsonArray();
races.forEach(r -> arr.add(r.name().toLowerCase()));
json.add("race", arr);
}
return json; return json;
} }
} }

View file

@ -9,6 +9,9 @@ public interface UCriteria {
CustomEventCriterion.Trigger LOOK_INTO_SUN = CUSTOM_EVENT.createTrigger("look_into_sun"); CustomEventCriterion.Trigger LOOK_INTO_SUN = CUSTOM_EVENT.createTrigger("look_into_sun");
CustomEventCriterion.Trigger WEAR_SHADES = CUSTOM_EVENT.createTrigger("wear_shades"); CustomEventCriterion.Trigger WEAR_SHADES = CUSTOM_EVENT.createTrigger("wear_shades");
CustomEventCriterion.Trigger LIGHTNING_STRUCK = CUSTOM_EVENT.createTrigger("lightning_struck_player");
CustomEventCriterion.Trigger EAT_TRICK_APPLE = CUSTOM_EVENT.createTrigger("eat_trick_apple");
CustomEventCriterion.Trigger FEED_TRICK_APPLE = CUSTOM_EVENT.createTrigger("feed_trick_apple");
private static <T extends Criterion<?>> T register(T obj) { private static <T extends Criterion<?>> T register(T obj) {
return MixinCriteria.register(obj); return MixinCriteria.register(obj);

View file

@ -5,6 +5,7 @@ import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.magic.spell.SpellType; import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
import com.minelittlepony.unicopia.advancement.UCriteria;
import com.minelittlepony.unicopia.entity.Creature; import com.minelittlepony.unicopia.entity.Creature;
import com.minelittlepony.unicopia.entity.EntityPhysics; import com.minelittlepony.unicopia.entity.EntityPhysics;
import com.minelittlepony.unicopia.entity.Jumper; import com.minelittlepony.unicopia.entity.Jumper;
@ -525,6 +526,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ()); lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ());
entity.world.spawnEntity(lightning); entity.world.spawnEntity(lightning);
UCriteria.LIGHTNING_STRUCK.trigger(entity);
} }
} }

View file

@ -4,6 +4,7 @@ package com.minelittlepony.unicopia.item;
import java.util.Optional; import java.util.Optional;
import com.minelittlepony.unicopia.UTags; import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.advancement.UCriteria;
import com.minelittlepony.unicopia.item.toxin.Toxicity; import com.minelittlepony.unicopia.item.toxin.Toxicity;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.RayTraceHelper; import com.minelittlepony.unicopia.util.RayTraceHelper;
@ -18,6 +19,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
@ -58,6 +60,9 @@ public class ZapAppleItem extends AppleItem implements ChameleonItem {
lightning.refreshPositionAfterTeleport(player.getX(), player.getY(), player.getZ()); lightning.refreshPositionAfterTeleport(player.getX(), player.getY(), player.getZ());
w.spawnEntity(lightning); w.spawnEntity(lightning);
if (player instanceof PlayerEntity) {
UCriteria.EAT_TRICK_APPLE.trigger((PlayerEntity)player);
}
} }
return stack; return stack;
@ -72,11 +77,17 @@ public class ZapAppleItem extends AppleItem implements ChameleonItem {
public TypedActionResult<ItemStack> onFedTo(ItemStack stack, PlayerEntity player, Entity e) { public TypedActionResult<ItemStack> onFedTo(ItemStack stack, PlayerEntity player, Entity e) {
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(e.world); LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(e.world);
lightning.refreshPositionAfterTeleport(player.getX(), player.getY(), player.getZ()); lightning.refreshPositionAfterTeleport(e.getX(), e.getY(), e.getZ());
lightning.setCosmetic(true);
if (player instanceof ServerPlayerEntity) {
lightning.setChanneler((ServerPlayerEntity)player);
}
if (e.world instanceof ServerWorld) { if (e.world instanceof ServerWorld) {
e.onStruckByLightning((ServerWorld)e.world, lightning); e.onStruckByLightning((ServerWorld)e.world, lightning);
UCriteria.FEED_TRICK_APPLE.trigger(player);
} }
player.world.spawnEntity(lightning);
if (!player.getAbilities().creativeMode) { if (!player.getAbilities().creativeMode) {
stack.decrement(1); stack.decrement(1);

View file

@ -388,5 +388,27 @@
"advancements.unicopia.praise_the_sun.title": "Praise the Sun!", "advancements.unicopia.praise_the_sun.title": "Praise the Sun!",
"advancements.unicopia.praise_the_sun.description": "Experience Celestia's unbridled glory", "advancements.unicopia.praise_the_sun.description": "Experience Celestia's unbridled glory",
"advancements.unicopia.cool_potato.title": "Cool Potato", "advancements.unicopia.cool_potato.title": "Cool Potato",
"advancements.unicopia.cool_potato.description": "Protect your eyes from the sun" "advancements.unicopia.cool_potato.description": "Protect your eyes from the sun",
"advancements.unicopia.mid_flight_interruption.title": "Mid-Flight Interruption",
"advancements.unicopia.mid_flight_interruption.description": "Get struck by lightning whilst flying in a storm",
"advancements.unicopia.lightning_bug.title": "Lightning Bug",
"advancements.unicopia.lightning_bug.description": "Attract 10 lightning strikes",
"advancements.unicopia.jar.title": "Oh wow. What's this?",
"advancements.unicopia.jar.description": "Find an empty jar",
"advancements.unicopia.gotcha.title": "Got'cha!",
"advancements.unicopia.gotcha.description": "Capture a storm",
"advancements.unicopia.trick_apple.title": "Apple of Discord",
"advancements.unicopia.trick_apple.description": "Find your first zap apple",
"advancements.unicopia.feed_trick_apple.title": "Here, Try This",
"advancements.unicopia.feed_trick_apple.description": "Feed a zap apple to a mob",
"advancements.unicopia.eat_trick_apple.title": "Crunchy",
"advancements.unicopia.eat_trick_apple.description": "Bite into a zap apple",
"advancements.unicopia.burn_juice.title": "That doesn't seem right",
"advancements.unicopia.burn_juice.description": "Burn the juice",
"advancements.unicopia.apple_route.title": "Apple, Apple, Apple",
"advancements.unicopia.apple_route.description": "Start your journey towards the apple of legend",
"advancements.unicopia.juice.title": "Refreshing",
"advancements.unicopia.juice.description": "Finally a use for all these apples",
"advancements.unicopia.sweet_apple_acres.title": "Sweet Apple Acres",
"advancements.unicopia.sweet_apple_acres.description": "Obtain one of every apple"
} }

View file

@ -0,0 +1,31 @@
{
"parent": "unicopia:unicopia/root",
"display": {
"icon": {
"item": "unicopia:green_apple"
},
"title": {
"translate": "advancements.unicopia.apple_route.title"
},
"description": {
"translate": "advancements.unicopia.apple_route.description"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": false,
"hidden": true
},
"criteria": {
"has_apple": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "tag": "unicopia:apples" }
]
}
}
},
"requirements": [
[ "has_apple" ]
]
}

View file

@ -0,0 +1,31 @@
{
"parent": "unicopia:unicopia/juice",
"display": {
"icon": {
"item": "unicopia:burned_juice"
},
"title": {
"translate": "advancements.unicopia.burn_juice.title"
},
"description": {
"translate": "advancements.unicopia.burn_juice.description"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
"hidden": true
},
"criteria": {
"has_burned_juice": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:burned_juice" }
]
}
}
},
"requirements": [
[ "has_burned_juice" ]
]
}

View file

@ -0,0 +1,29 @@
{
"parent": "unicopia:unicopia/trick_apple",
"display": {
"icon": {
"item": "unicopia:zap_apple"
},
"title": {
"translate": "advancements.unicopia.eat_trick_apple.title"
},
"description": {
"translate": "advancements.unicopia.eat_trick_apple.description"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"eat_trick_apple": {
"trigger": "unicopia:custom",
"conditions": {
"event": "eat_trick_apple"
}
}
},
"requirements": [
[ "eat_trick_apple" ]
]
}

View file

@ -0,0 +1,29 @@
{
"parent": "unicopia:unicopia/trick_apple",
"display": {
"icon": {
"item": "unicopia:zap_apple"
},
"title": {
"translate": "advancements.unicopia.feed_trick_apple.title"
},
"description": {
"translate": "advancements.unicopia.feed_trick_apple.description"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"eat_trick_apple": {
"trigger": "unicopia:custom",
"conditions": {
"event": "feed_trick_apple"
}
}
},
"requirements": [
[ "eat_trick_apple" ]
]
}

View file

@ -0,0 +1,32 @@
{
"parent": "unicopia:unicopia/jar",
"display": {
"icon": {
"item": "unicopia:rain_cloud_jar"
},
"title": {
"translate": "advancements.unicopia.gotcha.title"
},
"description": {
"translate": "advancements.unicopia.gotcha.description"
},
"frame": "goal",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"has_the_jar": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:rain_cloud_jar" },
{ "item": "unicopia:storm_cloud_jar" }
]
}
}
},
"requirements": [
[ "has_the_jar" ]
]
}

View file

@ -0,0 +1,31 @@
{
"parent": "unicopia:unicopia/root",
"display": {
"icon": {
"item": "unicopia:empty_jar"
},
"title": {
"translate": "advancements.unicopia.jar.title"
},
"description": {
"translate": "advancements.unicopia.jar.description"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"has_the_jar": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:empty_jar" }
]
}
}
},
"requirements": [
[ "has_the_jar" ]
]
}

View file

@ -0,0 +1,31 @@
{
"parent": "unicopia:unicopia/apple_route",
"display": {
"icon": {
"item": "unicopia:juice"
},
"title": {
"translate": "advancements.unicopia.juice.title"
},
"description": {
"translate": "advancements.unicopia.juice.description"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"has_juice": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:juice" }
]
}
}
},
"requirements": [
[ "has_juice" ]
]
}

View file

@ -0,0 +1,102 @@
{
"parent": "unicopia:unicopia/mid_flight_interruption",
"display": {
"icon": {
"item": "unicopia:lightning_jar"
},
"title": {
"translate": "advancements.unicopia.lightning_bug.title"
},
"description": {
"translate": "advancements.unicopia.lightning_bug.description"
},
"frame": "challenge",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"one": {
"trigger": "unicopia:custom",
"conditions": {
"event": "lightning_struck_player",
"race": ["bat"]
}
},
"two": {
"trigger": "unicopia:custom",
"conditions": {
"event": "lightning_struck_player",
"race": ["bat"]
}
},
"three": {
"trigger": "unicopia:custom",
"conditions": {
"event": "lightning_struck_player",
"race": ["bat"]
}
},
"four": {
"trigger": "unicopia:custom",
"conditions": {
"event": "lightning_struck_player",
"race": ["bat"]
}
},
"five": {
"trigger": "unicopia:custom",
"conditions": {
"event": "lightning_struck_player",
"race": ["bat"]
}
},
"six": {
"trigger": "unicopia:custom",
"conditions": {
"event": "lightning_struck_player",
"race": ["bat"]
}
},
"seven": {
"trigger": "unicopia:custom",
"conditions": {
"event": "lightning_struck_player",
"race": ["bat"]
}
},
"eight": {
"trigger": "unicopia:custom",
"conditions": {
"event": "lightning_struck_player",
"race": ["bat"]
}
},
"nine": {
"trigger": "unicopia:custom",
"conditions": {
"event": "lightning_struck_player",
"race": ["bat"]
}
},
"ten": {
"trigger": "unicopia:custom",
"conditions": {
"event": "lightning_struck_player",
"race": ["bat"]
}
}
},
"requirements": [
[ "one" ],
[ "two" ],
[ "three" ],
[ "four" ],
[ "five" ],
[ "six" ],
[ "seven" ],
[ "eight" ],
[ "nine" ],
[ "ten" ]
]
}

View file

@ -0,0 +1,29 @@
{
"parent": "unicopia:unicopia/root",
"display": {
"icon": {
"item": "unicopia:pegasus_feather"
},
"title": {
"translate": "advancements.unicopia.mid_flight_interruption.title"
},
"description": {
"translate": "advancements.unicopia.mid_flight_interruption.description"
},
"frame": "challenge",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"lightning_strike": {
"trigger": "unicopia:custom",
"conditions": {
"event": "lightning_struck_player"
}
}
},
"requirements": [
[ "lightning_strike" ]
]
}

View file

@ -0,0 +1,94 @@
{
"parent": "unicopia:unicopia/apple_route",
"display": {
"icon": {
"item": "unicopia:sweet_apple"
},
"title": {
"translate": "advancements.unicopia.sweet_apple_acres.title"
},
"description": {
"translate": "advancements.unicopia.sweet_apple_acres.description"
},
"frame": "challenge",
"show_toast": true,
"announce_to_chat": true,
"hidden": true
},
"criteria": {
"red_apple": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "minecraft:apple" }
]
}
},
"green_apple": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:green_apple" }
]
}
},
"sweet_apple": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:sweet_apple" }
]
}
},
"sour_apple": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:sour_apple" }
]
}
},
"rotten_apple": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:rotten_apple" }
]
}
},
"zap_apple": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:zap_apple" }
]
}
},
"cooked_zap_apple": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:cooked_zap_apple" }
]
}
},
"golden_apple": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:golden_apple" }
]
}
}
},
"requirements": [
[ "red_apple" ],
[ "green_apple" ],
[ "sweet_apple" ],
[ "sour_apple" ],
[ "rotten_apple" ],
[ "zap_apple" ],
[ "cooked_zap_apple" ],
[ "golden_apple" ]
]
}

View file

@ -0,0 +1,31 @@
{
"parent": "unicopia:unicopia/apple_route",
"display": {
"icon": {
"item": "minecraft:enchanted_golden_apple"
},
"title": {
"translate": "advancements.unicopia.trick_apple.title"
},
"description": {
"translate": "advancements.unicopia.trick_apple.description"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": false,
"hidden": false
},
"criteria": {
"has_apple": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{ "item": "unicopia:zap_apple" }
]
}
}
},
"requirements": [
[ "has_apple" ]
]
}