Add villagers to the list of entities that benefit from the crystal heart. Closes #184

This commit is contained in:
Sollace 2024-03-28 17:13:50 +00:00
parent 10dc8ce6d7
commit 3bab3c4f56
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -20,6 +20,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.EndRodBlock;
import net.minecraft.entity.*;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.MerchantEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.*;
@ -34,7 +35,9 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Artifact {
static final Predicate<Entity> TARGET_PREDICATE = EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(EntityPredicates.VALID_ENTITY).and(e -> (e instanceof PlayerEntity || e instanceof MobEntity));
static final Predicate<Entity> TARGET_PREDICATE = EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR
.and(EntityPredicates.VALID_ENTITY)
.and(e -> (e instanceof PlayerEntity || e instanceof MobEntity));
private static final Supplier<Map<Item, Item>> ITEM_MAP = Suppliers.memoize(() -> {
return Map.of(
Items.BUCKET, UItems.LOVE_BUCKET,
@ -126,7 +129,8 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art
if (e instanceof PlayerEntity
|| (living instanceof TameableEntity && ((TameableEntity)living).isTamed())
|| (living instanceof Saddleable && ((Saddleable)living).isSaddled())) {
|| (living instanceof Saddleable && ((Saddleable)living).isSaddled())
|| (living instanceof MerchantEntity)) {
if (living.getHealth() < living.getMaxHealth()) {
outputs.add(living);
}