Fixed changlings not being able to feed from players

This commit is contained in:
Sollace 2019-02-08 23:02:07 +02:00
parent 8aab123770
commit eacaea2898

View file

@ -15,7 +15,7 @@ import com.minelittlepony.util.MagicalDamageSource;
import com.minelittlepony.util.vector.VecHelper; import com.minelittlepony.util.vector.VecHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityPig; import net.minecraft.entity.passive.EntityPig;
@ -67,7 +67,7 @@ public class PowerFeed implements IPower<Hit> {
} }
private boolean canDrain(Entity e) { private boolean canDrain(Entity e) {
return (e instanceof EntityLiving) return (e instanceof EntityLivingBase)
&& (e instanceof EntityCow && (e instanceof EntityCow
|| e instanceof EntityVillager || e instanceof EntityVillager
|| e instanceof EntityPlayer || e instanceof EntityPlayer
@ -81,7 +81,7 @@ public class PowerFeed implements IPower<Hit> {
return Hit.class; return Hit.class;
} }
protected List<EntityLiving> getTargets(IPlayer player) { protected List<EntityLivingBase> getTargets(IPlayer player) {
List<Entity> list = VecHelper.getWithinRange(player.getOwner(), 3, this::canDrain); List<Entity> list = VecHelper.getWithinRange(player.getOwner(), 3, this::canDrain);
Entity looked = VecHelper.getLookedAtEntity(player.getOwner(), 17); Entity looked = VecHelper.getLookedAtEntity(player.getOwner(), 17);
@ -89,7 +89,7 @@ public class PowerFeed implements IPower<Hit> {
list.add(looked); list.add(looked);
} }
return list.stream().map(i -> (EntityLiving)i).collect(Collectors.toList()); return list.stream().map(i -> (EntityLivingBase)i).collect(Collectors.toList());
} }
@Override @Override
@ -103,8 +103,8 @@ public class PowerFeed implements IPower<Hit> {
float healAmount = 0; float healAmount = 0;
for (Entity i : getTargets(iplayer)) { for (EntityLivingBase i : getTargets(iplayer)) {
healAmount += drainFrom(player, (EntityLiving)i); healAmount += drainFrom(player, i);
} }
int foodAmount = (int)Math.floor(Math.min(healAmount / 3, maximumFoodGain)); int foodAmount = (int)Math.floor(Math.min(healAmount / 3, maximumFoodGain));
@ -120,7 +120,7 @@ public class PowerFeed implements IPower<Hit> {
} }
} }
protected float drainFrom(EntityPlayer changeling, EntityLiving living) { protected float drainFrom(EntityPlayer changeling, EntityLivingBase living) {
DamageSource d = MagicalDamageSource.causePlayerDamage("feed", changeling); DamageSource d = MagicalDamageSource.causePlayerDamage("feed", changeling);
float damage = living.getHealth()/2; float damage = living.getHealth()/2;