mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 18:09:44 +00:00
1.7.10 Files
Files added
This commit is contained in:
1 parent
393ea9b463
commit
a31efb2dc3
1768 files changed
+84831
No files matched your search
@@ -0,0 +1,74 @@
|
||||
package noppes.npcs.roles;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class JobFollower extends JobInterface{
|
||||
public EntityNPCInterface following = null;
|
||||
private int ticks = 40;
|
||||
private int range = 20;
|
||||
public String name = "";
|
||||
|
||||
public JobFollower(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setString("FollowingEntityName", name);
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
name = compound.getString("FollowingEntityName");
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean aiShouldExecute() {
|
||||
if(npc.isAttacking())
|
||||
return false;
|
||||
|
||||
ticks--;
|
||||
if(ticks > 0)
|
||||
return false;
|
||||
|
||||
ticks = 10;
|
||||
following = null;
|
||||
List<EntityNPCInterface> list = npc.worldObj.getEntitiesWithinAABB(EntityNPCInterface.class, npc.boundingBox.expand(getRange(), getRange(), getRange()));
|
||||
for(EntityNPCInterface entity : list){
|
||||
if(entity == npc || entity.isKilled())
|
||||
continue;
|
||||
if(entity.display.name.equalsIgnoreCase(name)){
|
||||
following = entity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private int getRange(){
|
||||
if(range > CustomNpcs.NpcNavRange)
|
||||
return CustomNpcs.NpcNavRange;
|
||||
return range;
|
||||
}
|
||||
|
||||
public boolean isFollowing(){
|
||||
return following != null;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
}
|
||||
public void resetTask() {
|
||||
following = null;
|
||||
}
|
||||
|
||||
public boolean hasOwner() {
|
||||
return !name.isEmpty();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user