From 762a66ad910be99971530df7e143443c1687ad83 Mon Sep 17 00:00:00 2001 From: TheRealWormbo Date: Wed, 5 Jun 2024 09:17:08 +0200 Subject: [PATCH] Fix Pollidisiac ignoring the breeding cooldown and awarding player stats (fixes #4666) --- .../flower/functional/PollidisiacBlockEntity.java | 10 ++++++---- .../java/vazkii/botania/mixin/AnimalAccessor.java | 14 ++++++++++++++ Xplat/src/main/resources/botania_xplat.mixins.json | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 Xplat/src/main/java/vazkii/botania/mixin/AnimalAccessor.java diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/PollidisiacBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/PollidisiacBlockEntity.java index 94e756e8d1..87c731388b 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/PollidisiacBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/PollidisiacBlockEntity.java @@ -25,6 +25,7 @@ import vazkii.botania.common.block.BotaniaFlowerBlocks; import vazkii.botania.common.helper.DelayHelper; import vazkii.botania.common.helper.EntityHelper; +import vazkii.botania.mixin.AnimalAccessor; import vazkii.botania.mixin.MushroomCowAccessor; import java.util.Collections; @@ -56,14 +57,15 @@ public void tickFlower() { for (Animal animal : animals) { // Note: Empty item stacks are implicitly excluded in Animal::isFood and ItemStack::is(TagKey) - if (!animal.isInLove()) { + if (animal.getAge() == 0 && !animal.isInLove()) { for (ItemEntity item : items) { if (!animal.isFood(item.getItem())) { continue; } - consumeFoodItem(item); + consumeFoodItemAndMana(item); animal.setInLoveTime(1200); + ((AnimalAccessor) animal).botania_setLoveCause(null); getLevel().broadcastEntityEvent(animal, EntityEvent.IN_LOVE_HEARTS); break; } @@ -83,7 +85,7 @@ public void tickFlower() { if (effect == null) { continue; } - consumeFoodItem(item); + consumeFoodItemAndMana(item); MushroomCowAccessor cowAccessor = (MushroomCowAccessor) animal; cowAccessor.setEffect(effect.getSuspiciousEffect()); @@ -100,7 +102,7 @@ public void tickFlower() { } } - private void consumeFoodItem(ItemEntity itemEntity) { + private void consumeFoodItemAndMana(ItemEntity itemEntity) { EntityHelper.shrinkItem(itemEntity); addMana(-MANA_COST); } diff --git a/Xplat/src/main/java/vazkii/botania/mixin/AnimalAccessor.java b/Xplat/src/main/java/vazkii/botania/mixin/AnimalAccessor.java new file mode 100644 index 0000000000..e2a0df8430 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/mixin/AnimalAccessor.java @@ -0,0 +1,14 @@ +package vazkii.botania.mixin; + +import net.minecraft.world.entity.animal.Animal; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.UUID; + +@Mixin(Animal.class) +public interface AnimalAccessor { + @Accessor("loveCause") + void botania_setLoveCause(UUID id); +} diff --git a/Xplat/src/main/resources/botania_xplat.mixins.json b/Xplat/src/main/resources/botania_xplat.mixins.json index 8561352d1f..aa07fa6be2 100644 --- a/Xplat/src/main/resources/botania_xplat.mixins.json +++ b/Xplat/src/main/resources/botania_xplat.mixins.json @@ -7,6 +7,7 @@ "AbstractFurnaceBlockEntityAccessor", "AbstractHorseAccessor", "AbstractMinecartMixin", + "AnimalAccessor", "BaseSpawnerMixin", "BeeMixin", "BiomeAccessor",