From aa724f56b0489f381aaabac9dfbe57ff502ae40b Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 30 Sep 2022 10:37:56 +0200 Subject: [PATCH] Integrate changeling love sickness into the toxics system so we can have more nuanced control over what makes changelings sick --- .../com/minelittlepony/unicopia/UTags.java | 1 + .../unicopia/entity/player/Pony.java | 7 -- .../unicopia/item/toxin/Toxics.java | 75 +++++++++++-------- .../unicopia/mixin/MixinPlayerEntity.java | 9 --- 4 files changed, 43 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/UTags.java b/src/main/java/com/minelittlepony/unicopia/UTags.java index 52394303..d9eeb453 100644 --- a/src/main/java/com/minelittlepony/unicopia/UTags.java +++ b/src/main/java/com/minelittlepony/unicopia/UTags.java @@ -17,6 +17,7 @@ public interface UTags { TagKey MAGIC_FEATHERS = item("magic_feathers"); TagKey SHADES = item("shades"); + TagKey CHANGELING_EDIBLE = item("food_types/changeling_edible"); TagKey POLEARMS = item("polearms"); TagKey APPLE_SEEDS = item("apple_seeds"); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java index 6c34fdc1..fe0b3e0c 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -25,7 +25,6 @@ import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect; import com.minelittlepony.unicopia.entity.effect.UEffects; import com.minelittlepony.unicopia.item.FriendshipBraceletItem; import com.minelittlepony.unicopia.item.UItems; -import com.minelittlepony.unicopia.item.toxin.Toxin; import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.MsgOtherPlayerCapabilities; import com.minelittlepony.unicopia.network.MsgPlayerAnimationChange; @@ -543,12 +542,6 @@ public class Pony extends Living implements Transmittable, Copieab return getCharms().getArmour().contains(UItems.ALICORN_AMULET) || super.isEnemy(other); } - public void onEat(ItemStack stack) { - if (getSpecies() == Race.CHANGELING) { - Toxin.LOVE_SICKNESS.afflict(getMaster(), stack); - } - } - @Override public void toNBT(NbtCompound compound) { super.toNBT(compound); diff --git a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxics.java b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxics.java index 8f766013..8c8596d7 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxics.java +++ b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxics.java @@ -7,85 +7,94 @@ import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import static com.minelittlepony.unicopia.item.toxin.Toxicity.*; +import static com.minelittlepony.unicopia.item.toxin.Ailment.*; import static com.minelittlepony.unicopia.item.toxin.Toxin.*; public interface Toxics { Registry REGISTRY = Registries.createSimple(new Identifier("unicopia:toxic")); - Toxic EDIBLE = register("forage_edible", new Toxic.Builder(Ailment.of(SAFE, INNERT)) + Toxic EDIBLE = register("forage_edible", new Toxic.Builder(Ailment.INNERT) .food(UFoodComponents.RANDOM_FOLIAGE) - .with(Race.HUMAN, Ailment.of(LETHAL, FOOD_POISONING)) + .with(Race.HUMAN, of(LETHAL, FOOD_POISONING)) + .with(Race.CHANGELING, of(FAIR, LOVE_SICKNESS)) ); - Toxic RISKY = register("forage_risky", new Toxic.Builder(Ailment.of(FAIR, WEAK_NAUSEA.withChance(20))) + Toxic RISKY = register("forage_risky", new Toxic.Builder(of(FAIR, WEAK_NAUSEA.withChance(20))) .food(UFoodComponents.RANDOM_FOLIAGE) - .with(Race.HUMAN, Ailment.of(LETHAL, FOOD_POISONING)) + .with(Race.HUMAN, of(LETHAL, FOOD_POISONING)) ); - Toxic MODERATE = register("forage_moderate", new Toxic.Builder(Ailment.of(MILD, POISON.and(WEAK_NAUSEA))) + Toxic MODERATE = register("forage_moderate", new Toxic.Builder(of(MILD, POISON.and(WEAK_NAUSEA))) .food(UFoodComponents.RANDOM_FOLIAGE) - .with(Race.HUMAN, Ailment.of(LETHAL, FOOD_POISONING)) + .with(Race.HUMAN, of(LETHAL, FOOD_POISONING)) ); - Toxic DANGEROUS = register("forage_dangerous", new Toxic.Builder(Ailment.of(SEVERE, FOOD_POISONING)) + Toxic DANGEROUS = register("forage_dangerous", new Toxic.Builder(of(SEVERE, FOOD_POISONING)) .food(UFoodComponents.RANDOM_FOLIAGE) - .with(Race.HUMAN, Ailment.of(LETHAL, FOOD_POISONING.and(NAUSEA))) + .with(Race.HUMAN, of(LETHAL, FOOD_POISONING.and(NAUSEA))) ); - Toxic NAUSEATING = register("forage_nauseating", new Toxic.Builder(Ailment.of(SAFE, NAUSEA.and(WEAKNESS.withChance(30)))) + Toxic NAUSEATING = register("forage_nauseating", new Toxic.Builder(of(SAFE, NAUSEA.and(WEAKNESS.withChance(30)))) .food(UFoodComponents.RANDOM_FOLIAGE) - .with(Race.HUMAN, Ailment.of(LETHAL, FOOD_POISONING.and(NAUSEA))) + .with(Race.HUMAN, of(LETHAL, FOOD_POISONING.and(NAUSEA))) ); - Toxic RADIOACTIVE = register("forage_radioactive", new Toxic.Builder(Ailment.of(SAFE, NAUSEA.and(RADIOACTIVITY.withChance(30)))) + Toxic RADIOACTIVE = register("forage_radioactive", new Toxic.Builder(of(SAFE, NAUSEA.and(RADIOACTIVITY.withChance(30)))) .food(UFoodComponents.RANDOM_FOLIAGE) - .with(Race.HUMAN, Ailment.of(LETHAL, FOOD_POISONING.and(NAUSEA))) + .with(Race.HUMAN, of(LETHAL, FOOD_POISONING.and(NAUSEA))) ); - Toxic PRICKLY = register("forage_prickly", new Toxic.Builder(Ailment.of(SAFE, PRICKLING.withChance(30))) + Toxic PRICKLY = register("forage_prickly", new Toxic.Builder(of(SAFE, PRICKLING.withChance(30))) .food(UFoodComponents.RANDOM_FOLIAGE) - .with(Race.HUMAN, Ailment.of(LETHAL, FOOD_POISONING.and(NAUSEA))) + .with(Race.HUMAN, of(LETHAL, FOOD_POISONING.and(NAUSEA))) ); - Toxic STRENGHTENING = register("forage_strengthening", new Toxic.Builder(Ailment.of(SEVERE, STRENGTH.and(WEAK_NAUSEA))) + Toxic STRENGHTENING = register("forage_strengthening", new Toxic.Builder(of(SEVERE, STRENGTH.and(WEAK_NAUSEA))) .food(UFoodComponents.RANDOM_FOLIAGE) - .with(Race.HUMAN, Ailment.of(LETHAL, FOOD_POISONING.and(WEAKNESS))) + .with(Race.HUMAN, of(LETHAL, FOOD_POISONING.and(WEAKNESS))) ); - Toxic SEVERELY_NAUSEATING = register("forage_severely_nauseating", new Toxic.Builder(Ailment.of(SEVERE, STRONG_NAUSEA.and(WEAKNESS))) + Toxic SEVERELY_NAUSEATING = register("forage_severely_nauseating", new Toxic.Builder(of(SEVERE, STRONG_NAUSEA.and(WEAKNESS))) .food(UFoodComponents.RANDOM_FOLIAGE) - .with(Race.HUMAN, Ailment.of(LETHAL, FOOD_POISONING.and(WEAKNESS))) + .with(Race.HUMAN, of(LETHAL, FOOD_POISONING.and(WEAKNESS))) ); - Toxic BLINDING = register("forage_blinding", new Toxic.Builder(Ailment.of(SEVERE, BLINDNESS.and(WEAK_NAUSEA))) + Toxic BLINDING = register("forage_blinding", new Toxic.Builder(of(SEVERE, BLINDNESS.and(WEAK_NAUSEA))) .food(UFoodComponents.RANDOM_FOLIAGE) - .with(Race.HUMAN, Ailment.of(LETHAL, FOOD_POISONING)) + .with(Race.HUMAN, of(LETHAL, FOOD_POISONING)) ); - Toxic SEVERELY_PRICKLY = register("forage_severely_prickly", new Toxic.Builder(Ailment.of(SEVERE, PRICKLING.and(NAUSEA))) + Toxic SEVERELY_PRICKLY = register("forage_severely_prickly", new Toxic.Builder(of(SEVERE, PRICKLING.and(NAUSEA))) .food(UFoodComponents.RANDOM_FOLIAGE) - .with(Race.HUMAN, Ailment.of(LETHAL, FOOD_POISONING)) + .with(Race.HUMAN, of(LETHAL, FOOD_POISONING)) ); - Toxic RAW_MEAT = register("raw_meat", new Toxic.Builder(Ailment.of(SEVERE, FOOD_POISONING.withChance(5).and(POISON.withChance(20)))) + Toxic RAW_MEAT = register("raw_meat", new Toxic.Builder(of(SEVERE, FOOD_POISONING.withChance(5).and(POISON.withChance(20)))) .with(Race.HUMAN, Ailment.INNERT) - .with(Race.BAT, Ailment.of(MILD, WEAK_NAUSEA)) + .with(Race.CHANGELING, Ailment.INNERT) + .with(Race.BAT, of(MILD, WEAK_NAUSEA)) ); - Toxic ROTTEN_MEAT = register("rotten_meat", new Toxic.Builder(Ailment.of(SEVERE, FOOD_POISONING.and(POISON))) + Toxic ROTTEN_MEAT = register("rotten_meat", new Toxic.Builder(of(SEVERE, FOOD_POISONING.and(POISON))) .with(Race.HUMAN, Ailment.INNERT) - .with(Race.BAT, Ailment.of(MILD, STRONG_NAUSEA)) + .with(Race.BAT, of(MILD, STRONG_NAUSEA)) + .with(Race.CHANGELING, Ailment.INNERT) ); - Toxic COOKED_MEAT = register("cooked_meat", new Toxic.Builder(Ailment.of(FAIR, FOOD_POISONING)) + Toxic COOKED_MEAT = register("cooked_meat", new Toxic.Builder(of(FAIR, FOOD_POISONING)) .with(Race.HUMAN, Ailment.INNERT) + .with(Race.CHANGELING, Ailment.INNERT) .with(Race.BAT, Ailment.INNERT) ); - Toxic RAW_FISH = register("raw_fish", new Toxic.Builder(Ailment.of(FAIR, FOOD_POISONING.and(POISON))) + Toxic RAW_FISH = register("raw_fish", new Toxic.Builder(of(FAIR, FOOD_POISONING.and(POISON))) .with(Race.HUMAN, Ailment.INNERT) - .with(Race.PEGASUS, Ailment.of(MILD, POISON.and(WEAK_NAUSEA))) + .with(Race.PEGASUS, of(MILD, POISON.and(WEAK_NAUSEA))) .with(Race.ALICORN, Ailment.INNERT) + .with(Race.CHANGELING, of(FAIR, LOVE_SICKNESS)) ); - Toxic COOKED_FISH = register("cooked_fish", new Toxic.Builder(Ailment.of(MILD, FOOD_POISONING)) + Toxic COOKED_FISH = register("cooked_fish", new Toxic.Builder(of(MILD, FOOD_POISONING)) .with(Race.HUMAN, Ailment.INNERT) .with(Race.PEGASUS, Ailment.INNERT) .with(Race.ALICORN, Ailment.INNERT) + .with(Race.CHANGELING, of(FAIR, LOVE_SICKNESS)) ); - Toxic RAW_INSECT = register("raw_insect", new Toxic.Builder(Ailment.of(LETHAL, FOOD_POISONING)) - .with(Race.BAT, Ailment.of(MILD, WEAK_NAUSEA)) + Toxic RAW_INSECT = register("raw_insect", new Toxic.Builder(of(LETHAL, FOOD_POISONING)) + .with(Race.BAT, of(MILD, WEAK_NAUSEA)) + .with(Race.CHANGELING, Ailment.INNERT) ); - Toxic COOKED_INSECT = register("cooked_insect", new Toxic.Builder(Ailment.of(LETHAL, FOOD_POISONING)) + Toxic COOKED_INSECT = register("cooked_insect", new Toxic.Builder(of(LETHAL, FOOD_POISONING)) .food(UFoodComponents.INSECTS) + .with(Race.CHANGELING, Ailment.INNERT) .with(Race.BAT, Ailment.INNERT) ); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java index b8181fd6..f57aab10 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java @@ -25,7 +25,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.stat.Stats; import net.minecraft.util.Unit; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; @Mixin(PlayerEntity.class) abstract class MixinPlayerEntity extends LivingEntity implements PonyContainer, PlayerEntityDuck { @@ -62,14 +61,6 @@ abstract class MixinPlayerEntity extends LivingEntity implements PonyContainer

info) { - if (stack.isFood()) { - get().onEat(stack); - } - } - @Inject(method = "trySleep(Lnet/minecraft/util/math/BlockPos;)Lcom/mojang/datafixers/util/Either;", at = @At("HEAD"), cancellable = true)