Skip to content

Commit

Permalink
Fix Pollidisiac ignoring the breeding cooldown and awarding player stats
Browse files Browse the repository at this point in the history
(fixes #4666)
  • Loading branch information
TheRealWormbo committed Jun 5, 2024
1 parent 50d6a7c commit 762a66a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -83,7 +85,7 @@ public void tickFlower() {
if (effect == null) {
continue;
}
consumeFoodItem(item);
consumeFoodItemAndMana(item);

MushroomCowAccessor cowAccessor = (MushroomCowAccessor) animal;
cowAccessor.setEffect(effect.getSuspiciousEffect());
Expand All @@ -100,7 +102,7 @@ public void tickFlower() {
}
}

private void consumeFoodItem(ItemEntity itemEntity) {
private void consumeFoodItemAndMana(ItemEntity itemEntity) {
EntityHelper.shrinkItem(itemEntity);
addMana(-MANA_COST);
}
Expand Down
14 changes: 14 additions & 0 deletions Xplat/src/main/java/vazkii/botania/mixin/AnimalAccessor.java
Original file line number Diff line number Diff line change
@@ -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);
}
1 change: 1 addition & 0 deletions Xplat/src/main/resources/botania_xplat.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"AbstractFurnaceBlockEntityAccessor",
"AbstractHorseAccessor",
"AbstractMinecartMixin",
"AnimalAccessor",
"BaseSpawnerMixin",
"BeeMixin",
"BiomeAccessor",
Expand Down

0 comments on commit 762a66a

Please sign in to comment.