2021-10-18 06:33:39 -05:00
|
|
|
package noppes.npcs.scripted.entity;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
import net.minecraft.entity.passive.EntityAnimal;
|
2022-11-06 01:25:28 -06:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2018-09-13 12:03:28 -04:00
|
|
|
import noppes.npcs.scripted.constants.EntityType;
|
2022-05-11 16:43:14 -05:00
|
|
|
import noppes.npcs.scripted.interfaces.entity.IAnimal;
|
2022-11-06 01:25:28 -06:00
|
|
|
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
|
|
|
|
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2021-10-12 02:57:32 -05:00
|
|
|
public class ScriptAnimal<T extends EntityAnimal> extends ScriptLiving<T> implements IAnimal {
|
2022-11-06 01:25:28 -06:00
|
|
|
protected T entity;
|
|
|
|
|
|
2021-10-12 02:57:32 -05:00
|
|
|
public ScriptAnimal(T entity) {
|
2018-09-13 12:03:28 -04:00
|
|
|
super(entity);
|
2022-11-06 01:25:28 -06:00
|
|
|
this.entity = entity;
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getType(){
|
|
|
|
|
return EntityType.ANIMAL;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 01:25:28 -06:00
|
|
|
/**
|
|
|
|
|
* 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 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
|
|
|
@Override
|
|
|
|
|
public boolean typeOf(int type){
|
2022-11-06 01:25:28 -06:00
|
|
|
return type == EntityType.ANIMAL || super.typeOf(type);
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
}
|