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.EntityLiving;
|
2022-11-15 15:25:53 -05:00
|
|
|
import noppes.npcs.api.entity.IEntity;
|
|
|
|
|
import noppes.npcs.api.entity.IEntityLiving;
|
|
|
|
|
import noppes.npcs.api.entity.IEntityLivingBase;
|
2023-01-12 21:33:06 -05:00
|
|
|
import noppes.npcs.scripted.NpcAPI;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2021-10-12 02:57:32 -05:00
|
|
|
public class ScriptLiving<T extends EntityLiving> extends ScriptLivingBase<T> implements IEntityLiving {
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2021-10-12 02:57:32 -05:00
|
|
|
public ScriptLiving(T entity) {
|
2018-09-13 12:03:28 -04:00
|
|
|
super(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isAttacking(){
|
|
|
|
|
return super.isAttacking() || entity.getAttackTarget() != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-05-11 22:08:31 -05:00
|
|
|
public void setAttackTarget(IEntityLivingBase living){
|
2018-09-13 12:03:28 -04:00
|
|
|
if(living == null)
|
|
|
|
|
entity.setAttackTarget(null);
|
|
|
|
|
else
|
2022-05-11 22:08:31 -05:00
|
|
|
entity.setAttackTarget(living.getMCEntity());
|
2018-09-13 12:03:28 -04:00
|
|
|
super.setAttackTarget(living);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-05-11 22:08:31 -05:00
|
|
|
public IEntityLivingBase getAttackTarget(){
|
|
|
|
|
IEntityLivingBase base = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity.getAttackTarget());
|
2018-09-13 12:03:28 -04:00
|
|
|
return (base != null)? base: super.getAttackTarget();
|
|
|
|
|
}
|
2024-02-20 21:08:48 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
/**
|
|
|
|
|
* Start path finding toward this target
|
|
|
|
|
* @param x Destination x position
|
|
|
|
|
* @param y Destination x position
|
|
|
|
|
* @param z Destination x position
|
|
|
|
|
* @param speed Walking speed of the entity 0.7 is default
|
|
|
|
|
*/
|
|
|
|
|
public void navigateTo(double x, double y, double z, double speed){
|
|
|
|
|
entity.getNavigator().tryMoveToXYZ(x, y, z, speed);
|
|
|
|
|
}
|
2024-02-20 21:08:48 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
/**
|
|
|
|
|
* Stop navigating wherever this npc was walking to
|
|
|
|
|
*/
|
|
|
|
|
public void clearNavigation(){
|
|
|
|
|
entity.getNavigator().clearPathEntity();
|
|
|
|
|
}
|
2024-02-20 21:08:48 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
/**
|
|
|
|
|
* @return Whether or not this entity is navigating somewhere
|
|
|
|
|
*/
|
|
|
|
|
public boolean isNavigating(){
|
|
|
|
|
return !entity.getNavigator().noPath();
|
|
|
|
|
}
|
2024-02-20 21:08:48 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
@Override
|
2022-05-11 22:08:31 -05:00
|
|
|
public boolean canSeeEntity(IEntity entity){
|
|
|
|
|
return this.entity.getEntitySenses().canSee(entity.getMCEntity());
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2022-11-06 01:25:28 -06:00
|
|
|
|
|
|
|
|
public void playLivingSound() {
|
|
|
|
|
this.entity.playLivingSound();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void spawnExplosionParticle()
|
|
|
|
|
{
|
|
|
|
|
this.entity.spawnExplosionParticle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMoveForward(float speed)
|
|
|
|
|
{
|
|
|
|
|
this.entity.setMoveForward(speed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void faceEntity(IEntity entity, float pitch, float yaw)
|
|
|
|
|
{
|
|
|
|
|
this.entity.faceEntity(entity.getMCEntity(), pitch, yaw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean canPickUpLoot()
|
|
|
|
|
{
|
|
|
|
|
return this.entity.canPickUpLoot();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setCanPickUpLoot(boolean pickUp)
|
|
|
|
|
{
|
|
|
|
|
this.entity.setCanPickUpLoot(pickUp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isPersistent()
|
|
|
|
|
{
|
|
|
|
|
return this.entity.isNoDespawnRequired();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void enablePersistence() {
|
|
|
|
|
this.entity.func_110163_bv();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setCustomNameTag(String text)
|
|
|
|
|
{
|
|
|
|
|
this.entity.setCustomNameTag(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getCustomNameTag()
|
|
|
|
|
{
|
|
|
|
|
return this.entity.getCustomNameTag();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean hasCustomNameTag()
|
|
|
|
|
{
|
|
|
|
|
return this.entity.hasCustomNameTag();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAlwaysRenderNameTag(boolean alwaysRender)
|
|
|
|
|
{
|
|
|
|
|
this.entity.setAlwaysRenderNameTag(alwaysRender);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getAlwaysRenderNameTag()
|
|
|
|
|
{
|
|
|
|
|
return this.entity.getAlwaysRenderNameTag();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clearLeashed(boolean sendPacket, boolean dropLeash)
|
|
|
|
|
{
|
|
|
|
|
this.entity.clearLeashed(sendPacket,dropLeash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean allowLeashing() {
|
|
|
|
|
return this.entity.allowLeashing();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getLeashed() {
|
|
|
|
|
return this.entity.getLeashed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEntity getLeashedTo() {
|
|
|
|
|
return NpcAPI.Instance().getIEntity(entity.getLeashedToEntity());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setLeashedTo(IEntity entity, boolean sendPacket) {
|
|
|
|
|
this.entity.setLeashedToEntity(entity.getMCEntity(), sendPacket);
|
|
|
|
|
}
|
2022-12-26 01:13:28 -06:00
|
|
|
|
|
|
|
|
public boolean canBeSteered() {
|
|
|
|
|
return this.entity.canBeSteered();
|
|
|
|
|
}
|
2025-02-10 21:32:55 -05:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setRotation(float rotation){
|
|
|
|
|
super.setRotation(rotation);
|
|
|
|
|
entity.getLookHelper().setLookPosition(getX(), getY(), getZ(), rotation, getPitch());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setPitch(float rotation){
|
|
|
|
|
super.setPitch(rotation);
|
|
|
|
|
entity.getLookHelper().setLookPosition(getX(), getY(), getZ(), getRotation(), rotation);
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|