mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 06:25:11 +00:00
-Implemented interfaces for all jobs & roles. ScriptPlayer: -Added getData() function, which returns player data objects. IPlayerData: New class that holds all player data for modification. -Holds dialog, bank, quest, transport, faction, item giver, and mail data. -Also holds companion data, with functions has/set/getCompanion, and a getCompanionID function to differentiate companions.
48 lines
1.3 KiB
Java
48 lines
1.3 KiB
Java
package noppes.npcs.scripted.roles;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import noppes.npcs.entity.EntityNPCInterface;
|
|
import noppes.npcs.roles.JobSpawner;
|
|
import noppes.npcs.scripted.NpcAPI;
|
|
import noppes.npcs.scripted.constants.JobType;
|
|
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
|
import noppes.npcs.scripted.interfaces.jobs.IJobSpawner;
|
|
|
|
public class ScriptJobSpawner extends ScriptJobInterface implements IJobSpawner {
|
|
private JobSpawner job;
|
|
public ScriptJobSpawner(EntityNPCInterface npc){
|
|
super(npc);
|
|
this.job = (JobSpawner) npc.jobInterface;
|
|
}
|
|
|
|
@Override
|
|
public int getType(){
|
|
return JobType.SPAWNER;
|
|
}
|
|
|
|
/**
|
|
* Npc needs to be attacking something or be set to Despawn Spawns On Target Lost: No, otherwise it will despawn right away
|
|
* @param number The entity going to be spawned (1-6)
|
|
* @return Returns spawned entity
|
|
*/
|
|
public IEntityLivingBase spawnEntity(int number){
|
|
EntityLivingBase base = job.spawnEntity(number);
|
|
if(base == null)
|
|
return null;
|
|
|
|
return (IEntityLivingBase) NpcAPI.Instance().getIEntity(base);
|
|
}
|
|
|
|
/**
|
|
* Removes all spawned entities
|
|
*/
|
|
public void removeAllSpawned(){
|
|
for(EntityLivingBase entity : job.spawned){
|
|
entity.isDead = true;
|
|
}
|
|
job.spawned = new ArrayList<EntityLivingBase>();
|
|
}
|
|
}
|