Files
CustomNPC-Plus/src/main/java/noppes/npcs/scripted/entity/ScriptAnimal.java
T

62 lines
1.6 KiB
Java
Raw Normal View History

package noppes.npcs.scripted.entity;
2018-09-13 12:03:28 -04:00
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.scripted.NpcAPI;
2018-09-13 12:03:28 -04:00
import noppes.npcs.scripted.constants.EntityType;
2022-11-15 15:25:53 -05:00
import noppes.npcs.api.entity.IAnimal;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.item.IItemStack;
2018-09-13 12:03:28 -04:00
public class ScriptAnimal<T extends EntityAnimal> extends ScriptLiving<T> implements IAnimal {
protected T entity;
public ScriptAnimal(T entity) {
2018-09-13 12:03:28 -04:00
super(entity);
this.entity = entity;
2018-09-13 12:03:28 -04:00
}
@Override
public int getType(){
return EntityType.ANIMAL;
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(IItemStack itemStack) {
return this.entity.isBreedingItem(itemStack.getMCItemStack());
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
public boolean interact(IPlayer player) {
return this.entity.interact((EntityPlayer) player.getMCEntity());
}
public void setFollowPlayer(IPlayer player) {
this.entity.func_146082_f((EntityPlayer) player.getMCEntity());
}
public IPlayer followingPlayer() {
return (IPlayer) NpcAPI.Instance().getIEntity(this.entity.func_146083_cb());
}
public boolean isInLove() {
return this.entity.isInLove();
}
public void resetInLove() {
this.entity.resetInLove();
}
public boolean canMateWith(IAnimal animal) {
return this.entity.canMateWith((EntityAnimal) animal.getMCEntity());
}
2018-09-13 12:03:28 -04:00
public boolean typeOf(int type){
return type == EntityType.ANIMAL || super.typeOf(type);
2018-09-13 12:03:28 -04:00
}
}