mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
Added advancements and recipes for crafting muffins
This commit is contained in:
parent
a878fd0d6c
commit
d94626e094
8 changed files with 100 additions and 7 deletions
|
@ -3,6 +3,8 @@ package com.minelittlepony.unicopia.advancement;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
|
@ -31,6 +33,7 @@ public class CustomEventCriterion extends AbstractCriterion<CustomEventCriterion
|
||||||
protected Conditions conditionsFromJson(JsonObject json, Extended playerPredicate, AdvancementEntityPredicateDeserializer deserializer) {
|
protected Conditions conditionsFromJson(JsonObject json, Extended playerPredicate, AdvancementEntityPredicateDeserializer deserializer) {
|
||||||
|
|
||||||
Set<Race> races = new HashSet<>();
|
Set<Race> races = new HashSet<>();
|
||||||
|
|
||||||
if (json.has("race")) {
|
if (json.has("race")) {
|
||||||
json.get("race").getAsJsonArray().forEach(el -> {
|
json.get("race").getAsJsonArray().forEach(el -> {
|
||||||
races.add(Race.fromName(el.getAsString()));
|
races.add(Race.fromName(el.getAsString()));
|
||||||
|
@ -48,18 +51,16 @@ public class CustomEventCriterion extends AbstractCriterion<CustomEventCriterion
|
||||||
|
|
||||||
public CustomEventCriterion.Trigger createTrigger(String name) {
|
public CustomEventCriterion.Trigger createTrigger(String name) {
|
||||||
return player -> {
|
return player -> {
|
||||||
|
if (player instanceof ServerPlayerEntity p) {
|
||||||
if (player instanceof ServerPlayerEntity) {
|
|
||||||
ServerPlayerEntity p = (ServerPlayerEntity)player;
|
|
||||||
int counter = Pony.of(player).getAdvancementProgress().compute(name, (key, i) -> i == null ? 1 : i + 1);
|
int counter = Pony.of(player).getAdvancementProgress().compute(name, (key, i) -> i == null ? 1 : i + 1);
|
||||||
|
|
||||||
trigger((ServerPlayerEntity)player, c -> c.test(name, counter, p));
|
trigger(p, c -> c.test(name, counter, p));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Trigger {
|
public interface Trigger {
|
||||||
void trigger(PlayerEntity player);
|
void trigger(@Nullable PlayerEntity player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Conditions extends AbstractCriterionConditions {
|
public static class Conditions extends AbstractCriterionConditions {
|
||||||
|
|
|
@ -16,6 +16,7 @@ public interface UCriteria {
|
||||||
CustomEventCriterion.Trigger SCREECH_SELF = CUSTOM_EVENT.createTrigger("screech_self");
|
CustomEventCriterion.Trigger SCREECH_SELF = CUSTOM_EVENT.createTrigger("screech_self");
|
||||||
CustomEventCriterion.Trigger SCREECH_TWENTY_MOBS = CUSTOM_EVENT.createTrigger("screech_twenty_mobs");
|
CustomEventCriterion.Trigger SCREECH_TWENTY_MOBS = CUSTOM_EVENT.createTrigger("screech_twenty_mobs");
|
||||||
CustomEventCriterion.Trigger SHED_FEATHER = CUSTOM_EVENT.createTrigger("shed_feather");
|
CustomEventCriterion.Trigger SHED_FEATHER = CUSTOM_EVENT.createTrigger("shed_feather");
|
||||||
|
CustomEventCriterion.Trigger THROW_MUFFIN = CUSTOM_EVENT.createTrigger("throw_muffin");
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.item;
|
package com.minelittlepony.unicopia.item;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.UTags;
|
import com.minelittlepony.unicopia.UTags;
|
||||||
import com.minelittlepony.unicopia.entity.PhysicsBodyProjectileEntity;
|
import com.minelittlepony.unicopia.entity.PhysicsBodyProjectileEntity;
|
||||||
|
@ -33,7 +35,7 @@ public class HeavyProjectileItem extends ProjectileItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PhysicsBodyProjectileEntity createProjectile(ItemStack stack, World world, PlayerEntity player) {
|
protected PhysicsBodyProjectileEntity createProjectile(ItemStack stack, World world, @Nullable PlayerEntity player) {
|
||||||
PhysicsBodyProjectileEntity projectile = player == null ? new PhysicsBodyProjectileEntity(world) : new PhysicsBodyProjectileEntity(world, player);
|
PhysicsBodyProjectileEntity projectile = player == null ? new PhysicsBodyProjectileEntity(world) : new PhysicsBodyProjectileEntity(world, player);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
projectile.setVelocity(player, player.getPitch(), player.getYaw(), 0, 1.5F, 1);
|
projectile.setVelocity(player, player.getPitch(), player.getYaw(), 0, 1.5F, 1);
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package com.minelittlepony.unicopia.item;
|
package com.minelittlepony.unicopia.item;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.advancement.UCriteria;
|
||||||
import com.minelittlepony.unicopia.entity.PhysicsBodyProjectileEntity;
|
import com.minelittlepony.unicopia.entity.PhysicsBodyProjectileEntity;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
@ -13,10 +16,11 @@ public class MuffinItem extends HeavyProjectileItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PhysicsBodyProjectileEntity createProjectile(ItemStack stack, World world, PlayerEntity player) {
|
protected PhysicsBodyProjectileEntity createProjectile(ItemStack stack, World world, @Nullable PlayerEntity player) {
|
||||||
PhysicsBodyProjectileEntity projectile = super.createProjectile(stack, world, player);
|
PhysicsBodyProjectileEntity projectile = super.createProjectile(stack, world, player);
|
||||||
projectile.setBouncy();
|
projectile.setBouncy();
|
||||||
projectile.setDamage(0);
|
projectile.setDamage(0);
|
||||||
|
UCriteria.THROW_MUFFIN.trigger(player);
|
||||||
return projectile;
|
return projectile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,6 +489,8 @@
|
||||||
"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.baked_bads.title": "Baked Bads",
|
||||||
|
"advancements.unicopia.baked_bads.description": "Bake a delicious muffin",
|
||||||
"advancements.unicopia.mid_flight_interruption.title": "Mid-Flight Interruption",
|
"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.mid_flight_interruption.description": "Get struck by lightning whilst flying in a storm",
|
||||||
"advancements.unicopia.lightning_bug.title": "Lightning Bug",
|
"advancements.unicopia.lightning_bug.title": "Lightning Bug",
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"parent": "minecraft:recipes/root",
|
||||||
|
"rewards": {
|
||||||
|
"recipes": [
|
||||||
|
"unicopia:muffin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"criteria": {
|
||||||
|
"has_ingredients": {
|
||||||
|
"trigger": "minecraft:inventory_changed",
|
||||||
|
"conditions": {
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"items": [
|
||||||
|
"minecraft:sugar",
|
||||||
|
"minecraft:egg",
|
||||||
|
"minecraft:potato",
|
||||||
|
"unicopia:juice",
|
||||||
|
"unicopia:wheat_worms"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"has_the_recipe": {
|
||||||
|
"trigger": "minecraft:recipe_unlocked",
|
||||||
|
"conditions": {
|
||||||
|
"recipe": "unicopia:muffin"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"requirements": [
|
||||||
|
[
|
||||||
|
"has_ingredients",
|
||||||
|
"has_the_recipe"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"parent": "unicopia:unicopia/root",
|
||||||
|
"display": {
|
||||||
|
"icon": {
|
||||||
|
"item": "unicopia:muffin"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"translate": "advancements.unicopia.baked_bads.title"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"translate": "advancements.unicopia.baked_bads.description"
|
||||||
|
},
|
||||||
|
"frame": "task",
|
||||||
|
"show_toast": true,
|
||||||
|
"announce_to_chat": true,
|
||||||
|
"hidden": true
|
||||||
|
},
|
||||||
|
"criteria": {
|
||||||
|
"throw_muffin": {
|
||||||
|
"trigger": "minecraft:inventory_changed",
|
||||||
|
"conditions": {
|
||||||
|
"items": [
|
||||||
|
{ "items": [ "unicopia:muffin" ] }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"requirements": [
|
||||||
|
[ "throw_muffin" ]
|
||||||
|
]
|
||||||
|
}
|
14
src/main/resources/data/unicopia/recipes/muffin.json
Normal file
14
src/main/resources/data/unicopia/recipes/muffin.json
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shapeless",
|
||||||
|
"ingredients": [
|
||||||
|
{ "item": "minecraft:sugar" },
|
||||||
|
{ "item": "minecraft:egg" },
|
||||||
|
{ "item": "minecraft:potato" },
|
||||||
|
{ "item": "unicopia:juice" },
|
||||||
|
{ "item": "unicopia:wheat_worms" }
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"item": "unicopia:muffin",
|
||||||
|
"count": 12
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue