mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 16:39:49 +00:00
Added several more functions to pre-existing classes:
-Spawner, Transport, Healer, Guard, Bard jobs received more functions. -Added more functions to the transporter role. -IRole: Added getNpc() function. -IAnimal, IEntityLiving, and IEntityLivingBase received more functions from their MC counterparts. -Nearly every function with that takes position/vector parameters now has an equivalent with IPos as a parameter instead.
This commit is contained in:
1 parent
112e82a09d
commit
e9a8f8cebc
51 files changed
+1025
-227
No files matched your search
@@ -30,4 +30,50 @@ public class ScriptJobBard extends ScriptJobInterface implements IJobBard {
|
||||
job.song = song;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i The id of the instrument. IDs:
|
||||
* 0 - None,
|
||||
* 1 - Banjo,
|
||||
* 2 - Violin,
|
||||
* 3 - Guitar,
|
||||
* 4 - Harp,
|
||||
* 5 - FrenchHorn
|
||||
*/
|
||||
public void setInstrument(int i) {
|
||||
this.job.setInstrument(i);
|
||||
}
|
||||
|
||||
public int getInstrumentId() {
|
||||
return this.job.getInstrument().ordinal();
|
||||
}
|
||||
|
||||
public void setMinRange(int range) {
|
||||
this.job.minRange = range;
|
||||
}
|
||||
public int getMinRange() {
|
||||
return this.job.minRange;
|
||||
}
|
||||
|
||||
public void setMaxRange(int range) {
|
||||
this.job.maxRange = range;
|
||||
}
|
||||
public int getMaxRange() {
|
||||
return this.job.maxRange;
|
||||
}
|
||||
|
||||
public void setStreaming(boolean streaming) {
|
||||
this.job.isStreamer = streaming;
|
||||
}
|
||||
public boolean getStreaming() {
|
||||
return this.job.isStreamer;
|
||||
}
|
||||
|
||||
public void hasOffRange(boolean value) {
|
||||
this.job.hasOffRange = value;
|
||||
}
|
||||
public boolean hasOffRange() {
|
||||
return this.job.hasOffRange;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,27 @@ public class ScriptJobGuard extends ScriptJobInterface implements IJobGuard {
|
||||
super(npc);
|
||||
this.job = (JobGuard) npc.jobInterface;
|
||||
}
|
||||
|
||||
public boolean attackCreepers() {
|
||||
return job.attackCreepers;
|
||||
}
|
||||
public void attackCreepers(boolean value) {
|
||||
job.attackCreepers = value;
|
||||
}
|
||||
|
||||
public boolean attacksAnimals() {
|
||||
return job.attacksAnimals;
|
||||
}
|
||||
public void attacksAnimals(boolean value) {
|
||||
job.attacksAnimals = value;
|
||||
}
|
||||
|
||||
public boolean attackHostileMobs() {
|
||||
return job.attackHostileMobs;
|
||||
}
|
||||
public void attackHostileMobs(boolean value) {
|
||||
job.attackHostileMobs = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
|
||||
@@ -16,6 +16,20 @@ public class ScriptJobHealer extends ScriptJobInterface implements IJobHealer {
|
||||
public void heal(IEntityLivingBase entity, float amount){
|
||||
job.heal(entity.getMCEntity(), amount);
|
||||
}
|
||||
|
||||
public void setRange(int range) {
|
||||
this.job.range = range;
|
||||
}
|
||||
public int getRange() {
|
||||
return this.job.range;
|
||||
}
|
||||
|
||||
public void setSpeed(int speed) {
|
||||
this.job.speed = speed;
|
||||
}
|
||||
public int getSpeed() {
|
||||
return this.job.speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
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.INbt;
|
||||
import noppes.npcs.scripted.interfaces.IPos;
|
||||
import noppes.npcs.scripted.interfaces.IWorld;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJobSpawner;
|
||||
|
||||
public class ScriptJobSpawner extends ScriptJobInterface implements IJobSpawner {
|
||||
private JobSpawner job;
|
||||
private final JobSpawner job;
|
||||
public ScriptJobSpawner(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.job = (JobSpawner) npc.jobInterface;
|
||||
@@ -27,21 +36,64 @@ public class ScriptJobSpawner extends ScriptJobInterface implements IJobSpawner
|
||||
* @param number The entity going to be spawned (1-6)
|
||||
* @return Returns spawned entity
|
||||
*/
|
||||
public IEntityLivingBase spawnEntity(int number){
|
||||
public IEntityLivingBase<?> spawnEntity(int number){
|
||||
EntityLivingBase base = job.spawnEntity(number);
|
||||
if(base == null)
|
||||
return null;
|
||||
|
||||
return (IEntityLivingBase) NpcAPI.Instance().getIEntity(base);
|
||||
return (IEntityLivingBase<?>) NpcAPI.Instance().getIEntity(base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all spawned entities
|
||||
*/
|
||||
|
||||
public IEntityLivingBase<?> getEntity(int number, int x, int y, int z, IWorld world) {
|
||||
NBTTagCompound compound = this.job.getCompound(number);
|
||||
if(compound == null || !compound.hasKey("id"))
|
||||
return null;
|
||||
Entity entity = NoppesUtilServer.getEntityFromNBT(compound,x,y,z,world.getMCWorld());
|
||||
if (!(entity instanceof EntityLivingBase)) {
|
||||
return null;
|
||||
}
|
||||
return (IEntityLivingBase<?>) NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
|
||||
public IEntityLivingBase<?> getEntity(int number, IPos pos, IWorld world) {
|
||||
return this.getEntity(number,pos.getX(),pos.getY(),pos.getZ(),world);
|
||||
}
|
||||
|
||||
public void setEntity(int number, IEntityLivingBase<?> entityLivingBase){
|
||||
INbt nbt = entityLivingBase.getNbtOptional();
|
||||
if (nbt == null)
|
||||
return;
|
||||
this.job.setJobCompound(number,nbt.getMCNBT());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all spawned entities
|
||||
*/
|
||||
public void removeAllSpawned(){
|
||||
for(EntityLivingBase entity : job.spawned){
|
||||
entity.isDead = true;
|
||||
}
|
||||
job.spawned = new ArrayList<EntityLivingBase>();
|
||||
job.spawned = new ArrayList<>();
|
||||
}
|
||||
|
||||
public IEntityLivingBase<?>[] getNearbySpawned() {
|
||||
List<EntityLivingBase> nearbySpawned = this.job.getNearbySpawned();
|
||||
List<IEntityLivingBase<?>> list = new ArrayList<>();
|
||||
for (EntityLivingBase entity : nearbySpawned) {
|
||||
list.add((IEntityLivingBase<?>) NpcAPI.Instance().getIEntity(entity));
|
||||
}
|
||||
return list.toArray(new IEntityLivingBase[0]);
|
||||
}
|
||||
|
||||
public boolean hasPixelmon() {
|
||||
return this.job.hasPixelmon();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.job.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isOnCooldown(IPlayer<EntityPlayerMP> player) {
|
||||
return this.job.isOnCooldown(player.getName());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import net.minecraft.entity.INpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleInterface;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import noppes.npcs.scripted.interfaces.roles.IRole;
|
||||
|
||||
@@ -14,6 +16,10 @@ public class ScriptRoleInterface implements IRole {
|
||||
this.role = npc.roleInterface;
|
||||
}
|
||||
|
||||
public INpc getNpc() {
|
||||
return (INpc) NpcAPI.Instance().getIEntity(npc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see noppes.npcs.scripted.constants.RoleType
|
||||
* @return The RoleType of this role
|
||||
|
||||
@@ -1,13 +1,44 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleTransporter;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ITransportLocation;
|
||||
import noppes.npcs.scripted.interfaces.roles.IRoleTransporter;
|
||||
|
||||
public class ScriptRoleTransporter extends ScriptRoleInterface implements IRoleTransporter {
|
||||
private final RoleTransporter role;
|
||||
|
||||
public ScriptRoleTransporter(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
role = (RoleTransporter) npc.roleInterface;
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return role.name;
|
||||
}
|
||||
|
||||
public int getTransportId() {
|
||||
return role.transportId;
|
||||
}
|
||||
|
||||
public void unlock(IPlayer<EntityPlayerMP> player, ITransportLocation location) {
|
||||
this.role.unlock(player.getMCEntity(), location);
|
||||
}
|
||||
|
||||
public ITransportLocation getTransport(){
|
||||
return this.role.getLocation();
|
||||
}
|
||||
|
||||
public boolean hasTransport(){
|
||||
return this.role.hasTransport();
|
||||
}
|
||||
|
||||
public void setTransport(ITransportLocation location) {
|
||||
this.role.setTransport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user