Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Pollidisiac ignoring the breeding cooldown and awarding player stats #4667

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading