mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Added some advancements for bat ponies
This commit is contained in:
parent
d68ada8a5b
commit
40ac0dfb00
11 changed files with 205 additions and 2 deletions
|
@ -16,7 +16,7 @@ public interface UTags {
|
|||
|
||||
Tag<Item> MAGIC_FEATHERS = item("magic_feathers");
|
||||
|
||||
Tag<Item> SHADES = item("sun_blockers");
|
||||
Tag<Item> SHADES = item("shades");
|
||||
|
||||
Tag<Block> FRAGILE = block("fragile");
|
||||
Tag<Block> INTERESTING = block("interesting");
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Optional;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.minelittlepony.unicopia.advancement.UCriteria;
|
||||
import com.minelittlepony.unicopia.command.Commands;
|
||||
import com.minelittlepony.unicopia.entity.effect.UPotions;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
@ -40,6 +41,7 @@ public class Unicopia implements ModInitializer {
|
|||
public void onInitialize() {
|
||||
Channel.bootstrap();
|
||||
UTags.bootstrap();
|
||||
UCriteria.bootstrap();
|
||||
Commands.bootstrap();
|
||||
|
||||
ServerTickEvents.END_WORLD_TICK.register(w -> {
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package com.minelittlepony.unicopia.advancement;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||
import net.minecraft.predicate.entity.AdvancementEntityPredicateSerializer;
|
||||
import net.minecraft.predicate.entity.EntityPredicate.Extended;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
|
||||
public class CustomEventCriterion extends AbstractCriterion<CustomEventCriterion.Conditions> {
|
||||
|
||||
private static final Identifier ID = new Identifier("unicopia", "custom");
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Conditions conditionsFromJson(JsonObject json, Extended player, AdvancementEntityPredicateDeserializer deserializer) {
|
||||
return new Conditions(player, JsonHelper.getString(json, "event"));
|
||||
}
|
||||
|
||||
public CustomEventCriterion.Trigger createTrigger(String name) {
|
||||
return player -> {
|
||||
if (player instanceof ServerPlayerEntity) {
|
||||
test((ServerPlayerEntity)player, c -> c.test(name));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public interface Trigger {
|
||||
void trigger(PlayerEntity player);
|
||||
}
|
||||
|
||||
public static class Conditions extends AbstractCriterionConditions {
|
||||
private final String event;
|
||||
|
||||
public Conditions(Extended playerPredicate, String event) {
|
||||
super(ID, playerPredicate);
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public boolean test(String event) {
|
||||
return this.event.equalsIgnoreCase(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject toJson(AdvancementEntityPredicateSerializer serializer) {
|
||||
JsonObject json = super.toJson(serializer);
|
||||
json.addProperty("event", event);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.minelittlepony.unicopia.advancement;
|
||||
|
||||
import com.minelittlepony.unicopia.mixin.MixinCriteria;
|
||||
|
||||
import net.minecraft.advancement.criterion.Criterion;
|
||||
|
||||
public interface UCriteria {
|
||||
CustomEventCriterion CUSTOM_EVENT = register(new CustomEventCriterion());
|
||||
|
||||
CustomEventCriterion.Trigger LOOK_INTO_SUN = CUSTOM_EVENT.createTrigger("look_into_sun");
|
||||
CustomEventCriterion.Trigger WEAR_SHADES = CUSTOM_EVENT.createTrigger("wear_shades");
|
||||
|
||||
private static <T extends Criterion<?>> T register(T obj) {
|
||||
return MixinCriteria.register(obj);
|
||||
}
|
||||
|
||||
static void bootstrap() { }
|
||||
}
|
|
@ -13,10 +13,12 @@ import com.minelittlepony.unicopia.client.sound.LoopingSoundInstance;
|
|||
import com.minelittlepony.unicopia.InteractionManager;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.UTags;
|
||||
import com.minelittlepony.unicopia.WorldTribeManager;
|
||||
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
||||
import com.minelittlepony.unicopia.ability.magic.Spell;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
|
||||
import com.minelittlepony.unicopia.advancement.UCriteria;
|
||||
import com.minelittlepony.unicopia.entity.Physics;
|
||||
import com.minelittlepony.unicopia.entity.PonyContainer;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
|
@ -41,6 +43,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.attribute.DefaultAttributeContainer;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.data.DataTracker;
|
||||
|
@ -94,6 +97,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
|||
private boolean invisible = false;
|
||||
|
||||
private int ticksInSun;
|
||||
private boolean hasShades;
|
||||
|
||||
public Pony(PlayerEntity player) {
|
||||
super(player, EFFECT);
|
||||
|
@ -291,6 +295,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
|||
|
||||
if (ticksInSun == 1) {
|
||||
entity.addStatusEffect(new StatusEffectInstance(SunBlindnessStatusEffect.INSTANCE, SunBlindnessStatusEffect.MAX_DURATION * 10, 1, true, false));
|
||||
UCriteria.LOOK_INTO_SUN.trigger(entity);
|
||||
|
||||
if (isClient()) {
|
||||
MinecraftClient.getInstance().getSoundManager().play(new LoopingSoundInstance<>(entity, e -> e.hasStatusEffect(SunBlindnessStatusEffect.INSTANCE), USounds.ENTITY_PLAYER_EARS_RINGING, 1F, 1F));
|
||||
|
@ -299,6 +304,12 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
|||
} else if (ticksInSun > 0) {
|
||||
ticksInSun--;
|
||||
}
|
||||
|
||||
boolean hasShades = entity.getEquippedStack(EquipmentSlot.HEAD).isIn(UTags.SHADES);
|
||||
if (!this.hasShades && hasShades) {
|
||||
UCriteria.WEAR_SHADES.trigger(entity);
|
||||
}
|
||||
this.hasShades = hasShades;
|
||||
}
|
||||
|
||||
tickers.forEach(Tickable::tick);
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.minelittlepony.unicopia.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.advancement.criterion.Criteria;
|
||||
import net.minecraft.advancement.criterion.Criterion;
|
||||
|
||||
@Mixin(Criteria.class)
|
||||
public interface MixinCriteria {
|
||||
@Invoker("register")
|
||||
static <T extends Criterion<?>> T register(T object) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -375,5 +375,12 @@
|
|||
"unicopia.subtitle.slime_advance": "Squealch",
|
||||
"unicopia.subtitle.slime_retract": "Sqonk",
|
||||
"unicopia.subtitle.changeling_buzz": "Drone Buzzing",
|
||||
"unicopia.subtitle.batpony_eeee": "Batpony Screeches"
|
||||
"unicopia.subtitle.batpony_eeee": "Batpony Screeches",
|
||||
|
||||
"advancements.unicopia.root.title": "Unicopia",
|
||||
"advancements.unicopia.root.description": "A world of magic and adventure",
|
||||
"advancements.unicopia.praise_the_sun.title": "Praise the Sun!",
|
||||
"advancements.unicopia.praise_the_sun.description": "Experience Celestia's unbridled glory",
|
||||
"advancements.unicopia.cool_potato.title": "Cool Potato",
|
||||
"advancements.unicopia.cool_potato.description": "Protect your eyes from the sun"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"parent": "unicopia:unicopia/praise_the_sun",
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "minecraft:potato"
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.unicopia.cool_potato.title"
|
||||
},
|
||||
"description": {
|
||||
"translate": "advancements.unicopia.cool_potato.description"
|
||||
},
|
||||
"frame": "task",
|
||||
"show_toast": true,
|
||||
"announce_to_chat": true,
|
||||
"hidden": false
|
||||
},
|
||||
"criteria": {
|
||||
"wear_shades": {
|
||||
"trigger": "unicopia:custom",
|
||||
"conditions": {
|
||||
"event": "wear_shades"
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[ "wear_shades" ]
|
||||
]
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"parent": "unicopia:unicopia/root",
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "minecraft:light"
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.unicopia.praise_the_sun.title"
|
||||
},
|
||||
"description": {
|
||||
"translate": "advancements.unicopia.praise_the_sun.description"
|
||||
},
|
||||
"frame": "task",
|
||||
"show_toast": true,
|
||||
"announce_to_chat": true,
|
||||
"hidden": false
|
||||
},
|
||||
"criteria": {
|
||||
"look_into_sun": {
|
||||
"trigger": "unicopia:custom",
|
||||
"conditions": {
|
||||
"event": "look_into_sun"
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[ "look_into_sun" ]
|
||||
]
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "unicopia:pegasus_feather"
|
||||
},
|
||||
"title": {
|
||||
"translate": "advancements.unicopia.root.title"
|
||||
},
|
||||
"description": {
|
||||
"translate": "advancements.unicopia.root.description"
|
||||
},
|
||||
"frame": "task",
|
||||
"show_toast": false,
|
||||
"announce_to_chat": false,
|
||||
"hidden": false,
|
||||
"background": "minecraft:textures/gui/advancements/backgrounds/stone.png"
|
||||
},
|
||||
"criteria": {
|
||||
"crafting_table": {
|
||||
"trigger": "minecraft:inventory_changed",
|
||||
"conditions": {
|
||||
"items": [
|
||||
{ "item": "minecraft:crafting_table" }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[ "crafting_table" ]
|
||||
]
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
"MixinBlockEntity",
|
||||
"MixinBlockItem",
|
||||
"MixinBrain",
|
||||
"MixinCriteria",
|
||||
"MixinDamageSource",
|
||||
"MixinEntity",
|
||||
"MixinFallingBlock",
|
||||
|
|
Loading…
Reference in a new issue