2021-10-18 06:33:39 -05:00
|
|
|
package noppes.npcs.scripted.entity;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2022-05-11 22:08:31 -05:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2018-09-13 12:03:28 -04:00
|
|
|
import noppes.npcs.NoppesUtilServer;
|
2023-01-12 21:33:06 -05:00
|
|
|
import noppes.npcs.api.IPos;
|
|
|
|
|
import noppes.npcs.api.ITimers;
|
|
|
|
|
import noppes.npcs.api.entity.ICustomNpc;
|
|
|
|
|
import noppes.npcs.api.entity.IEntityLivingBase;
|
|
|
|
|
import noppes.npcs.api.entity.IPlayer;
|
2023-03-17 02:36:28 -05:00
|
|
|
import noppes.npcs.api.entity.data.IModelData;
|
2023-01-12 21:33:06 -05:00
|
|
|
import noppes.npcs.api.handler.IOverlayHandler;
|
2023-01-16 13:53:15 -06:00
|
|
|
import noppes.npcs.api.handler.data.IAnimationData;
|
2023-11-30 15:29:35 -06:00
|
|
|
import noppes.npcs.api.handler.data.IDialog;
|
2023-01-12 21:33:06 -05:00
|
|
|
import noppes.npcs.api.handler.data.IFaction;
|
|
|
|
|
import noppes.npcs.api.item.IItemStack;
|
2022-11-23 23:59:01 -06:00
|
|
|
import noppes.npcs.api.jobs.IJob;
|
|
|
|
|
import noppes.npcs.api.roles.IRole;
|
2023-01-07 00:21:08 -05:00
|
|
|
import noppes.npcs.config.ConfigMain;
|
2023-01-08 17:27:37 -05:00
|
|
|
import noppes.npcs.constants.*;
|
2022-07-01 23:26:47 -05:00
|
|
|
import noppes.npcs.controllers.FactionController;
|
2023-11-30 15:29:35 -06:00
|
|
|
import noppes.npcs.controllers.data.DialogOption;
|
2022-05-24 01:07:50 -05:00
|
|
|
import noppes.npcs.controllers.data.Line;
|
2018-09-13 12:03:28 -04:00
|
|
|
import noppes.npcs.entity.EntityCustomNpc;
|
|
|
|
|
import noppes.npcs.entity.EntityNPCInterface;
|
2022-05-29 02:46:24 -05:00
|
|
|
import noppes.npcs.scripted.NpcAPI;
|
|
|
|
|
import noppes.npcs.scripted.constants.AnimationType;
|
|
|
|
|
import noppes.npcs.scripted.constants.EntityType;
|
2023-01-12 21:33:06 -05:00
|
|
|
import noppes.npcs.scripted.roles.*;
|
2018-09-13 12:03:28 -04:00
|
|
|
import noppes.npcs.util.ValueUtil;
|
|
|
|
|
|
2023-01-12 21:33:06 -05:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
2021-10-12 02:57:32 -05:00
|
|
|
public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> implements ICustomNpc {
|
2021-12-07 23:52:57 -06:00
|
|
|
public EntityNPCInterface npc;
|
2021-10-12 02:57:32 -05:00
|
|
|
|
|
|
|
|
public ScriptNpc(T npc){
|
2018-09-13 12:03:28 -04:00
|
|
|
super(npc);
|
2021-12-07 23:52:57 -06:00
|
|
|
this.npc = npc;
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-12-03 00:49:10 -06:00
|
|
|
* @return Returns the current npcs size
|
2018-09-13 12:03:28 -04:00
|
|
|
*/
|
|
|
|
|
public int getSize(){
|
|
|
|
|
return npc.display.modelSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-12-03 00:49:10 -06:00
|
|
|
* @param size The size of the npc. Default is 5
|
2018-09-13 12:03:28 -04:00
|
|
|
*/
|
|
|
|
|
public void setSize(int size){
|
2021-12-03 00:49:10 -06:00
|
|
|
if(size < 1)
|
2018-09-13 12:03:28 -04:00
|
|
|
size = 1;
|
2023-01-07 00:21:08 -05:00
|
|
|
if(size > ConfigMain.NpcSizeLimit)
|
|
|
|
|
size = ConfigMain.NpcSizeLimit;
|
2022-01-25 14:54:15 -06:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
npc.display.modelSize = size;
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
2021-05-08 03:51:29 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns the current npcs modelType of the NPC
|
|
|
|
|
*/
|
|
|
|
|
public int getModelType(){
|
|
|
|
|
return npc.display.modelType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-05-29 00:59:40 -05:00
|
|
|
* @param modelType The modelType of the NPC. 0: Steve, 1: Steve64, 2: Alex
|
2021-05-08 03:51:29 -04:00
|
|
|
*/
|
|
|
|
|
public void setModelType(int modelType){
|
2022-05-29 00:59:40 -05:00
|
|
|
if(modelType > 2)
|
|
|
|
|
modelType = 2;
|
2021-05-08 03:51:29 -04:00
|
|
|
else if(modelType < 0)
|
|
|
|
|
modelType = 0;
|
2022-05-29 00:59:40 -05:00
|
|
|
npc.display.modelType = modelType;
|
2021-05-08 03:51:29 -04:00
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The npcs name
|
|
|
|
|
*/
|
|
|
|
|
public String getName(){
|
|
|
|
|
return npc.display.name;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-03 23:36:53 -06:00
|
|
|
public void setRotation(float rotationYaw, float rotationPitch) {
|
|
|
|
|
this.setRotation(rotationYaw);
|
|
|
|
|
npc.rotationPitch = rotationPitch;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void setRotation(float rotation){
|
|
|
|
|
npc.ai.orientation = (int)rotation;
|
|
|
|
|
super.setRotation(rotation);
|
|
|
|
|
}
|
2023-01-03 23:36:53 -06:00
|
|
|
|
2021-12-29 16:22:05 -06:00
|
|
|
public void setRotationType(int rotationType){
|
|
|
|
|
for (EnumStandingType e : EnumStandingType.values()) {
|
|
|
|
|
if (e.ordinal() == rotationType) {
|
|
|
|
|
npc.ai.standingType = e;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-03 23:36:53 -06:00
|
|
|
|
2021-12-29 16:22:05 -06:00
|
|
|
public int getRotationType(){
|
|
|
|
|
return npc.ai.standingType.ordinal();
|
|
|
|
|
}
|
2023-01-03 23:36:53 -06:00
|
|
|
|
2023-01-08 17:27:37 -05:00
|
|
|
/**
|
|
|
|
|
* @param movingType The moving type of the npc. 0 = standing, 1 = wandering, 2 = moving path
|
|
|
|
|
*/
|
|
|
|
|
public void setMovingType(int movingType){
|
|
|
|
|
for(EnumMovingType e : EnumMovingType.values()) {
|
|
|
|
|
if (e.ordinal() == movingType) {
|
|
|
|
|
npc.ai.movingType = e;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The moving type of the npc. 0 = standing, 1 = wandering, 2 = moving path
|
|
|
|
|
*/
|
|
|
|
|
public int getMovingType(){
|
|
|
|
|
return npc.ai.movingType.ordinal();
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
/**
|
|
|
|
|
* @param name The name of the npc
|
|
|
|
|
*/
|
|
|
|
|
public void setName(String name){
|
|
|
|
|
npc.display.name = name;
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10
|
|
|
|
|
* @return The npcs title
|
|
|
|
|
*/
|
|
|
|
|
public String getTitle(){
|
|
|
|
|
return npc.display.title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10
|
|
|
|
|
* @param title The title of the npc
|
|
|
|
|
*/
|
|
|
|
|
public void setTitle(String title){
|
|
|
|
|
npc.display.title = title;
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The npcs texture
|
|
|
|
|
*/
|
|
|
|
|
public String getTexture(){
|
|
|
|
|
return npc.display.texture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param texture The texture of the npc
|
|
|
|
|
*/
|
|
|
|
|
public void setTexture(String texture){
|
|
|
|
|
npc.display.texture = texture;
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 01:25:28 -06:00
|
|
|
public IPos getHome() {
|
|
|
|
|
return NpcAPI.Instance().getIPos(npc.ai.startPos[0],npc.ai.startPos[1],npc.ai.startPos[2]);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
/**
|
|
|
|
|
* @return Home position x
|
|
|
|
|
*/
|
|
|
|
|
public int getHomeX(){
|
|
|
|
|
return npc.getStartPos()[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param x The home x position
|
|
|
|
|
*/
|
|
|
|
|
public void setHomeX(int x){
|
|
|
|
|
npc.ai.startPos[0] = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Home position x
|
|
|
|
|
*/
|
|
|
|
|
public int getHomeY(){
|
|
|
|
|
return npc.getStartPos()[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param y The home y position
|
|
|
|
|
*/
|
|
|
|
|
public void setHomeY(int y){
|
|
|
|
|
npc.ai.startPos[1] = y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Home position x
|
|
|
|
|
*/
|
|
|
|
|
public int getHomeZ(){
|
|
|
|
|
return npc.getStartPos()[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param z The home x position
|
|
|
|
|
*/
|
|
|
|
|
public void setHomeZ(int z){
|
|
|
|
|
npc.ai.startPos[2] = z;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param x The home x position
|
|
|
|
|
* @param y The home y position
|
|
|
|
|
* @param z The home z position
|
|
|
|
|
*/
|
|
|
|
|
public void setHome(int x, int y, int z){
|
|
|
|
|
npc.ai.startPos = new int[]{x, y, z};
|
|
|
|
|
}
|
2022-11-06 01:25:28 -06:00
|
|
|
|
|
|
|
|
public void setHome(IPos pos){
|
|
|
|
|
npc.ai.startPos = new int[]{pos.getX(), pos.getY(), pos.getZ()};
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
/**
|
|
|
|
|
* @param health New max health
|
|
|
|
|
*/
|
2021-12-03 00:49:10 -06:00
|
|
|
public void setMaxHealth(double health){
|
2018-09-13 12:03:28 -04:00
|
|
|
npc.stats.setMaxHealth(health);
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param bo Whether or not the npc will try to return to his home position
|
|
|
|
|
*/
|
|
|
|
|
public void setReturnToHome(boolean bo){
|
|
|
|
|
npc.ai.returnToStart = bo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Whether or not the npc returns home
|
|
|
|
|
*/
|
|
|
|
|
public boolean getReturnToHome(){
|
|
|
|
|
return npc.ai.returnToStart;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The faction of the npc
|
|
|
|
|
*/
|
2022-07-01 23:26:47 -05:00
|
|
|
public IFaction getFaction(){
|
|
|
|
|
return FactionController.getInstance().get(this.npc.faction.id);
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param id The id of the new faction
|
|
|
|
|
*/
|
|
|
|
|
public void setFaction(int id){
|
|
|
|
|
npc.setFaction(id);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 21:13:56 -06:00
|
|
|
public void setAttackFactions(boolean attackOtherFactions){
|
|
|
|
|
npc.advanced.attackOtherFactions = attackOtherFactions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getAttackFactions(){
|
|
|
|
|
return npc.advanced.attackOtherFactions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDefendFaction(boolean defendFaction){
|
|
|
|
|
npc.advanced.defendFaction = defendFaction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getDefendFaction(){
|
|
|
|
|
return npc.advanced.defendFaction;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
@Override
|
|
|
|
|
public int getType(){
|
|
|
|
|
return EntityType.NPC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean typeOf(int type){
|
|
|
|
|
return type == EntityType.NPC?true:super.typeOf(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param target The targeted npc
|
|
|
|
|
* @param item The item you want to shoot
|
|
|
|
|
* @param accuracy Accuracy of the shot (0-100)
|
|
|
|
|
*/
|
2022-05-11 22:08:31 -05:00
|
|
|
public void shootItem(IEntityLivingBase target, IItemStack item, int accuracy){
|
2018-09-13 12:03:28 -04:00
|
|
|
if(item == null)
|
|
|
|
|
return;
|
|
|
|
|
if(accuracy < 0)
|
|
|
|
|
accuracy = 0;
|
|
|
|
|
else if(accuracy > 100)
|
|
|
|
|
accuracy = 100;
|
2022-05-11 22:08:31 -05:00
|
|
|
npc.shoot(target.getMCEntity(), accuracy, item.getMCItemStack(), false);
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void setProjectilesKeepTerrain(boolean t) {
|
2022-05-26 01:45:10 -05:00
|
|
|
npc.stats.projectilesKeepTerrain = t;
|
2022-05-24 03:06:16 -05:00
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public boolean getProjectilesKeepTerrain() {
|
2022-05-26 01:45:10 -05:00
|
|
|
return npc.stats.projectilesKeepTerrain;
|
2022-05-24 03:06:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
/**
|
|
|
|
|
* @param message The message the npc will say
|
|
|
|
|
*/
|
|
|
|
|
public void say(String message){
|
|
|
|
|
npc.saySurrounding(new Line(message));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param message The message the npc will say
|
|
|
|
|
*/
|
2022-05-11 22:08:31 -05:00
|
|
|
public void say(IPlayer player, String message){
|
2018-09-13 12:03:28 -04:00
|
|
|
if(player == null || message == null || message.isEmpty())
|
|
|
|
|
return;
|
2022-05-11 22:08:31 -05:00
|
|
|
npc.say((EntityPlayer) player.getMCEntity(), new Line(message));
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2023-11-30 15:29:35 -06:00
|
|
|
|
|
|
|
|
public IDialog getDialog(int slot) {
|
|
|
|
|
return NpcAPI.Instance().getDialogs().get(this.getDialogId(slot));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getDialogId(int slot) {
|
|
|
|
|
if (npc.dialogs.containsKey(slot)) {
|
|
|
|
|
DialogOption option = npc.dialogs.get(slot);
|
|
|
|
|
if (option.hasDialog()) {
|
|
|
|
|
return option.dialogId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDialog(int slot, IDialog dialog) {
|
|
|
|
|
this.setDialog(slot, dialog.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDialog(int slot, int dialogId) {
|
|
|
|
|
NoppesUtilServer.setNpcDialog(slot,dialogId, this.npc);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
/**
|
|
|
|
|
* Kill the npc, doesnt't despawn it
|
|
|
|
|
*/
|
|
|
|
|
public void kill(){
|
|
|
|
|
npc.setDead();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Basically completely resets the npc. This will also call the Init script
|
|
|
|
|
*/
|
|
|
|
|
public void reset(){
|
|
|
|
|
npc.reset();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-16 13:53:15 -06:00
|
|
|
public IAnimationData getAnimationData() {
|
|
|
|
|
return this.npc.display.animationData;
|
2023-01-11 19:12:53 -06:00
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
/**
|
|
|
|
|
* @return Returns the npcs current role
|
|
|
|
|
*/
|
2022-11-23 23:59:01 -06:00
|
|
|
public IRole getRole(){
|
2018-09-13 12:03:28 -04:00
|
|
|
if(npc.advanced.role == EnumRoleType.Bank)
|
|
|
|
|
return new ScriptRoleBank(npc);
|
|
|
|
|
else if(npc.advanced.role == EnumRoleType.Follower)
|
|
|
|
|
return new ScriptRoleFollower(npc);
|
|
|
|
|
else if(npc.advanced.role == EnumRoleType.Postman)
|
|
|
|
|
return new ScriptRoleMailman(npc);
|
|
|
|
|
else if(npc.advanced.role == EnumRoleType.Trader)
|
|
|
|
|
return new ScriptRoleTrader(npc);
|
|
|
|
|
else if(npc.advanced.role == EnumRoleType.Transporter)
|
|
|
|
|
return new ScriptRoleTransporter(npc);
|
|
|
|
|
return new ScriptRoleInterface(npc);
|
|
|
|
|
}
|
2022-05-11 16:31:14 -05:00
|
|
|
|
2021-12-29 22:34:51 -06:00
|
|
|
public void setRole(int role){
|
|
|
|
|
for (EnumRoleType e : EnumRoleType.values()) {
|
|
|
|
|
if (e.ordinal() == role) {
|
|
|
|
|
npc.advanced.role = e;
|
2022-12-07 23:38:15 -06:00
|
|
|
npc.advanced.setRole(role);
|
2021-12-29 22:34:51 -06:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns the npcs current job
|
|
|
|
|
*/
|
2022-11-23 23:59:01 -06:00
|
|
|
public IJob getJob(){
|
2018-09-13 12:03:28 -04:00
|
|
|
if(npc.advanced.job == EnumJobType.Bard)
|
|
|
|
|
return new ScriptJobBard(npc);
|
|
|
|
|
else if(npc.advanced.job == EnumJobType.Conversation)
|
|
|
|
|
return new ScriptJobConversation(npc);
|
|
|
|
|
else if(npc.advanced.job == EnumJobType.Follower)
|
|
|
|
|
return new ScriptJobFollower(npc);
|
|
|
|
|
else if(npc.advanced.job == EnumJobType.Guard)
|
|
|
|
|
return new ScriptJobGuard(npc);
|
|
|
|
|
else if(npc.advanced.job == EnumJobType.Healer)
|
|
|
|
|
return new ScriptJobHealer(npc);
|
|
|
|
|
else if(npc.advanced.job == EnumJobType.ItemGiver)
|
|
|
|
|
return new ScriptJobItemGiver(npc);
|
|
|
|
|
else if(npc.advanced.job == EnumJobType.Spawner)
|
|
|
|
|
return new ScriptJobSpawner(npc);
|
|
|
|
|
return new ScriptJobInterface(npc);
|
|
|
|
|
}
|
2022-05-11 16:31:14 -05:00
|
|
|
|
2021-12-29 22:34:51 -06:00
|
|
|
public void setJob(int job){
|
|
|
|
|
for (EnumJobType e : EnumJobType.values()) {
|
|
|
|
|
if (e.ordinal() == job) {
|
|
|
|
|
npc.advanced.job = e;
|
2022-12-07 23:38:15 -06:00
|
|
|
npc.advanced.setJob(job);
|
2021-12-29 22:34:51 -06:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The item held in the right hand
|
|
|
|
|
*/
|
2022-05-11 01:10:31 -05:00
|
|
|
public IItemStack getRightItem(){
|
2022-05-11 17:12:48 -05:00
|
|
|
return NpcAPI.Instance().getIItemStack(npc.inventory.getWeapon());
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param item Item to be held in the right hand
|
|
|
|
|
*/
|
2022-05-11 22:08:31 -05:00
|
|
|
public void setRightItem(IItemStack item){
|
2018-09-13 12:03:28 -04:00
|
|
|
if(item == null)
|
|
|
|
|
npc.inventory.setWeapon(null);
|
|
|
|
|
else
|
2022-05-11 22:08:31 -05:00
|
|
|
npc.inventory.setWeapon(item.getMCItemStack());
|
2018-09-13 12:03:28 -04:00
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The item held in the left hand
|
|
|
|
|
*/
|
2022-05-11 01:10:31 -05:00
|
|
|
public IItemStack getLefttItem(){
|
2022-05-11 17:12:48 -05:00
|
|
|
return NpcAPI.Instance().getIItemStack(npc.getOffHand());
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param item Item to be held in the left hand
|
|
|
|
|
*/
|
2022-05-11 22:08:31 -05:00
|
|
|
public void setLeftItem(IItemStack item){
|
2018-09-13 12:03:28 -04:00
|
|
|
if(item == null)
|
|
|
|
|
npc.inventory.setOffHand(null);
|
|
|
|
|
else
|
2022-05-11 22:08:31 -05:00
|
|
|
npc.inventory.setOffHand(item.getMCItemStack());
|
2018-09-13 12:03:28 -04:00
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns the projectile the npc uses
|
|
|
|
|
*/
|
2022-05-11 01:10:31 -05:00
|
|
|
public IItemStack getProjectileItem(){
|
2022-05-11 17:12:48 -05:00
|
|
|
return NpcAPI.Instance().getIItemStack(npc.inventory.getProjectile());
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param item Item to be used as projectile
|
|
|
|
|
*/
|
2022-05-11 22:08:31 -05:00
|
|
|
public void setProjectileItem(IItemStack item){
|
2018-09-13 12:03:28 -04:00
|
|
|
if(item == null)
|
|
|
|
|
npc.inventory.setProjectile(null);
|
|
|
|
|
else
|
2022-05-11 22:08:31 -05:00
|
|
|
npc.inventory.setProjectile(item.getMCItemStack());
|
2018-09-13 12:03:28 -04:00
|
|
|
npc.script.aiNeedsUpdate = true;
|
|
|
|
|
}
|
2021-12-03 21:13:56 -06:00
|
|
|
|
|
|
|
|
public boolean canAimWhileShooting() {
|
|
|
|
|
return !npc.stats.aimWhileShooting;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void aimWhileShooting(boolean aimWhileShooting) {
|
|
|
|
|
npc.stats.aimWhileShooting = aimWhileShooting;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-29 17:17:06 -06:00
|
|
|
public void setMinProjectileDelay(int minDelay){
|
|
|
|
|
npc.stats.minDelay = minDelay;
|
|
|
|
|
}
|
|
|
|
|
public int getMinProjectileDelay(){
|
|
|
|
|
return npc.stats.minDelay;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMaxProjectileDelay(int maxDelay){
|
|
|
|
|
npc.stats.maxDelay = maxDelay;
|
|
|
|
|
}
|
|
|
|
|
public int getMaxProjectileDelay(){
|
|
|
|
|
return npc.stats.maxDelay;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-05 16:31:39 -07:00
|
|
|
public void setRangedRange(int rangedRange) {
|
2021-12-29 17:17:06 -06:00
|
|
|
npc.stats.rangedRange = rangedRange;
|
|
|
|
|
}
|
2022-07-05 16:31:39 -07:00
|
|
|
public int getRangedRange() {
|
2021-12-29 17:17:06 -06:00
|
|
|
return npc.stats.rangedRange;
|
|
|
|
|
}
|
2022-07-05 16:31:39 -07:00
|
|
|
public void setRangedRage(int rangedRage) { this.setRangedRange(rangedRage); }
|
|
|
|
|
public int getRangedRage() { return this.getRangedRange(); }
|
2021-12-29 17:17:06 -06:00
|
|
|
|
|
|
|
|
public void setFireRate(int rate) {
|
|
|
|
|
npc.stats.fireRate = rate;
|
|
|
|
|
}
|
|
|
|
|
public int getFireRate() {
|
|
|
|
|
return npc.stats.fireRate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBurstCount(int burstCount) {
|
|
|
|
|
npc.stats.burstCount = burstCount;
|
|
|
|
|
}
|
|
|
|
|
public int getBurstCount() {
|
|
|
|
|
return npc.stats.burstCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setShotCount(int shotCount) {
|
|
|
|
|
npc.stats.shotCount = shotCount;
|
|
|
|
|
}
|
|
|
|
|
public int getShotCount() {
|
|
|
|
|
return npc.stats.shotCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAccuracy(int accuracy) {
|
|
|
|
|
npc.stats.accuracy = accuracy;
|
|
|
|
|
}
|
|
|
|
|
public int getAccuracy() {
|
|
|
|
|
return npc.stats.accuracy;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 21:13:56 -06:00
|
|
|
public String getFireSound() {
|
|
|
|
|
return npc.stats.fireSound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFireSound(String fireSound) {
|
|
|
|
|
npc.stats.fireSound = fireSound;
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param slot The armor slot to return. 0:head, 1:body, 2:legs, 3:boots
|
|
|
|
|
* @return Returns the worn armor in slot
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
2022-05-11 01:10:31 -05:00
|
|
|
public IItemStack getArmor(int slot){
|
2022-05-11 17:12:48 -05:00
|
|
|
return NpcAPI.Instance().getIItemStack(npc.inventory.armor.get(slot));
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param slot The armor slot to set. 0:head, 1:body, 2:legs, 3:boots
|
|
|
|
|
* @param item Item to be set as armor
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
2022-05-11 22:08:31 -05:00
|
|
|
public void setArmor(int slot, IItemStack item){
|
2018-09-13 12:03:28 -04:00
|
|
|
if(item == null)
|
|
|
|
|
npc.inventory.armor.put(slot, null);
|
|
|
|
|
else
|
2022-05-11 22:08:31 -05:00
|
|
|
npc.inventory.armor.put(slot, item.getMCItemStack());
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
2021-12-03 21:13:56 -06:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param slot The slot from the NPC's drop list to return (0-8)
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-11 01:10:31 -05:00
|
|
|
public IItemStack getLootItem(int slot) {
|
2022-05-11 17:12:48 -05:00
|
|
|
return NpcAPI.Instance().getIItemStack(npc.inventory.getStackInSlot(slot+7));
|
2021-12-03 21:13:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param slot The slot from the NPC's drop list to change
|
|
|
|
|
* @param item The item the drop list slot will be changed to
|
|
|
|
|
*/
|
2022-05-11 22:08:31 -05:00
|
|
|
public void setLootItem(int slot, IItemStack item) {
|
|
|
|
|
npc.inventory.setInventorySlotContents(slot+7, item.getMCItemStack());
|
2021-12-03 21:13:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param slot The slot from the NPC's drop list to return (0-8)
|
|
|
|
|
* @return The chance of dropping the item in this slot. Returns 100 if the slot is not found.
|
|
|
|
|
*/
|
2022-01-27 03:50:36 -06:00
|
|
|
public double getLootChance(int slot) {
|
2021-12-03 21:13:56 -06:00
|
|
|
if(!npc.inventory.dropchance.containsKey(slot))
|
|
|
|
|
return 100;
|
|
|
|
|
|
|
|
|
|
return npc.inventory.dropchance.get(slot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param slot The slot from the NPC's drop list to change
|
|
|
|
|
* @param chance The new chance of dropping the item in this slot
|
|
|
|
|
*/
|
2022-01-27 03:50:36 -06:00
|
|
|
public void setLootChance(int slot, double chance) {
|
|
|
|
|
if(!npc.inventory.dropchance.containsKey(slot))
|
2021-12-03 21:13:56 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(chance < 0)
|
|
|
|
|
chance = 0;
|
|
|
|
|
if(chance > 100)
|
|
|
|
|
chance = 100;
|
|
|
|
|
|
|
|
|
|
npc.inventory.dropchance.put(slot,chance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getLootMode(){
|
|
|
|
|
return npc.inventory.lootMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setLootMode(int lootMode){
|
|
|
|
|
if(lootMode < 0 || lootMode > 1)
|
|
|
|
|
return;
|
|
|
|
|
npc.inventory.lootMode = lootMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMinLootXP(int lootXP) {
|
|
|
|
|
if(lootXP > npc.inventory.maxExp)
|
|
|
|
|
lootXP = npc.inventory.maxExp;
|
|
|
|
|
if(lootXP < 0)
|
|
|
|
|
lootXP = 0;
|
|
|
|
|
if(lootXP > Short.MAX_VALUE)
|
|
|
|
|
lootXP = Short.MAX_VALUE;
|
|
|
|
|
|
|
|
|
|
npc.inventory.minExp = lootXP;
|
|
|
|
|
}
|
|
|
|
|
public void setMaxLootXP(int lootXP) {
|
|
|
|
|
if(lootXP < npc.inventory.minExp)
|
|
|
|
|
lootXP = npc.inventory.minExp;
|
|
|
|
|
if(lootXP < 0)
|
|
|
|
|
lootXP = 0;
|
|
|
|
|
if(lootXP > Short.MAX_VALUE)
|
|
|
|
|
lootXP = Short.MAX_VALUE;
|
|
|
|
|
|
|
|
|
|
npc.inventory.maxExp = lootXP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getMinLootXP(){
|
|
|
|
|
return npc.inventory.minExp;
|
|
|
|
|
}
|
|
|
|
|
public int getMaxLootXP(){
|
|
|
|
|
return npc.inventory.maxExp;
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param type The AnimationType
|
|
|
|
|
*/
|
|
|
|
|
public void setAnimation(int type){
|
|
|
|
|
if(type == AnimationType.NORMAL)
|
|
|
|
|
npc.ai.animationType = EnumAnimation.NONE;
|
|
|
|
|
else if(type == AnimationType.SITTING)
|
|
|
|
|
npc.ai.animationType = EnumAnimation.SITTING;
|
|
|
|
|
else if(type == AnimationType.DANCING)
|
|
|
|
|
npc.ai.animationType = EnumAnimation.DANCING;
|
|
|
|
|
else if(type == AnimationType.SNEAKING)
|
|
|
|
|
npc.ai.animationType = EnumAnimation.SNEAKING;
|
|
|
|
|
else if(type == AnimationType.LYING)
|
|
|
|
|
npc.ai.animationType = EnumAnimation.LYING;
|
|
|
|
|
else if(type == AnimationType.HUGGING)
|
|
|
|
|
npc.ai.animationType = EnumAnimation.HUG;
|
2021-12-03 21:13:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTacticalVariant(int variant){
|
2022-01-31 23:01:52 -06:00
|
|
|
if(variant > EnumNavType.values().length-1 || variant < 0)
|
2021-12-03 21:13:56 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
npc.ai.tacticalVariant = EnumNavType.values()[variant];
|
2022-01-31 23:01:52 -06:00
|
|
|
npc.ai.directLOS = EnumNavType.values()[variant] != EnumNavType.Stalk && npc.ai.directLOS;
|
2021-12-03 21:13:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getTacticalVariant(){
|
|
|
|
|
return npc.ai.tacticalVariant.ordinal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTacticalVariant(String variant){
|
|
|
|
|
boolean found = false;
|
|
|
|
|
for(String s : EnumNavType.names()){
|
|
|
|
|
if(s.equals(variant))
|
|
|
|
|
found = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!found)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
npc.ai.tacticalVariant = EnumNavType.valueOf(variant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getTacticalVariantName(){
|
|
|
|
|
return npc.ai.tacticalVariant.name();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTacticalRadius(int tacticalRadius){
|
|
|
|
|
if(tacticalRadius < 0)
|
|
|
|
|
tacticalRadius = 0;
|
|
|
|
|
|
|
|
|
|
npc.ai.tacticalRadius = tacticalRadius;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getTacticalRadius(){
|
|
|
|
|
return npc.ai.tacticalRadius;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setIgnoreCobweb(boolean ignore){
|
|
|
|
|
npc.ai.ignoreCobweb = ignore;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getIgnoreCobweb(){
|
|
|
|
|
return npc.ai.ignoreCobweb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setOnFoundEnemy(int onAttack){
|
|
|
|
|
if(onAttack < 0 || onAttack > 3)
|
|
|
|
|
return;
|
|
|
|
|
npc.ai.onAttack = onAttack;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int onFoundEnemy(){
|
|
|
|
|
return npc.ai.onAttack;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setShelterFrom(int shelterFrom){
|
|
|
|
|
if(shelterFrom < 0 || shelterFrom > 2)
|
|
|
|
|
return;
|
|
|
|
|
npc.ai.findShelter = shelterFrom;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getShelterFrom(){
|
|
|
|
|
return npc.ai.findShelter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean hasLivingAnimation() {
|
|
|
|
|
return !npc.display.disableLivingAnimation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setLivingAnimation(boolean livingAnimation) {
|
|
|
|
|
npc.display.disableLivingAnimation = !livingAnimation;
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param type The visibility type of the npc, 0:visible, 1:invisible, 2:semi-visible
|
|
|
|
|
*/
|
|
|
|
|
public void setVisibleType(int type){
|
|
|
|
|
npc.display.visible = type;
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The visibility type of the npc, 0:visible, 1:invisible, 2:semi-visible
|
|
|
|
|
*/
|
|
|
|
|
public int getVisibleType(){
|
|
|
|
|
return npc.display.visible;
|
|
|
|
|
}
|
2021-11-22 23:34:02 -06:00
|
|
|
|
2022-05-11 22:08:31 -05:00
|
|
|
public void setVisibleTo(IPlayer player, boolean visible) {
|
|
|
|
|
UUID uuid = player.getMCEntity().getPersistentID();
|
2021-11-22 23:34:02 -06:00
|
|
|
ArrayList<UUID> uuidList = npc.display.invisibleToList;
|
|
|
|
|
if(uuidList != null) {
|
|
|
|
|
if (!uuidList.contains(uuid)) {
|
|
|
|
|
if (!visible)
|
|
|
|
|
npc.display.invisibleToList.add(uuid);
|
|
|
|
|
} else if (visible) {
|
|
|
|
|
npc.display.invisibleToList.remove(uuid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-11 22:08:31 -05:00
|
|
|
public boolean isVisibleTo(IPlayer player) {
|
|
|
|
|
return !npc.scriptInvisibleToPlayer((EntityPlayer) player.getMCEntity());
|
2021-11-22 23:34:02 -06:00
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param type The visibility type of the name, 0:visible, 1:invisible, 2:when-attacking
|
|
|
|
|
*/
|
|
|
|
|
public void setShowName(int type){
|
|
|
|
|
npc.display.showName = type;
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns the visibility type of the name, 0:visible, 1:invisible, 2:when-attacking
|
|
|
|
|
*/
|
|
|
|
|
public int getShowName(){
|
|
|
|
|
return npc.display.showName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns the visiblity of the boss bar, 0:invisible, 1:visible, 2:when-attacking
|
|
|
|
|
*/
|
|
|
|
|
public int getShowBossBar(){
|
|
|
|
|
return npc.display.showBossBar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param type The visibility type of the boss bar, 0:invisible, 1:visible, 2:when-attacking
|
|
|
|
|
*/
|
|
|
|
|
public void setShowBossBar(int type){
|
|
|
|
|
npc.display.showBossBar = (byte) type;
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The melee strength
|
|
|
|
|
*/
|
2022-12-24 01:46:43 -06:00
|
|
|
public double getMeleeStrength(){
|
2018-09-13 12:03:28 -04:00
|
|
|
return npc.stats.getAttackStrength();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param strength The melee strength
|
|
|
|
|
*/
|
2022-12-24 01:46:43 -06:00
|
|
|
public void setMeleeStrength(double strength){
|
2018-09-13 12:03:28 -04:00
|
|
|
npc.stats.setAttackStrength(strength);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The melee speed
|
|
|
|
|
*/
|
|
|
|
|
public int getMeleeSpeed(){
|
|
|
|
|
return npc.stats.attackSpeed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param speed The melee speed
|
|
|
|
|
*/
|
|
|
|
|
public void setMeleeSpeed(int speed){
|
|
|
|
|
npc.stats.attackSpeed = speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The ranged strength
|
|
|
|
|
*/
|
2021-12-03 00:49:10 -06:00
|
|
|
public float getRangedStrength(){
|
2018-09-13 12:03:28 -04:00
|
|
|
return npc.stats.pDamage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param strength The ranged strength
|
|
|
|
|
*/
|
2021-12-03 00:49:10 -06:00
|
|
|
public void setRangedStrength(float strength){
|
2021-12-04 12:46:53 -06:00
|
|
|
npc.stats.pDamage = (float)(Math.floor(strength));
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The ranged speed
|
|
|
|
|
*/
|
|
|
|
|
public int getRangedSpeed(){
|
|
|
|
|
return npc.stats.pSpeed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param speed The ranged speed
|
|
|
|
|
*/
|
|
|
|
|
public void setRangedSpeed(int speed){
|
|
|
|
|
npc.stats.pSpeed = speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The ranged burst count
|
|
|
|
|
*/
|
|
|
|
|
public int getRangedBurst(){
|
|
|
|
|
return npc.stats.burstCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param count The ranged burst count
|
|
|
|
|
*/
|
|
|
|
|
public void setRangedBurst(int count){
|
|
|
|
|
npc.stats.burstCount = count;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 21:13:56 -06:00
|
|
|
public int getRespawnTime() {
|
|
|
|
|
return npc.stats.respawnTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRespawnTime(int time) {
|
|
|
|
|
npc.stats.respawnTime = time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getRespawnCycle() {
|
|
|
|
|
return npc.stats.spawnCycle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRespawnCycle(int cycle) {
|
|
|
|
|
if(cycle < 0)
|
|
|
|
|
cycle = 0;
|
|
|
|
|
if(cycle > 3)
|
|
|
|
|
cycle = 3;
|
|
|
|
|
|
|
|
|
|
npc.stats.spawnCycle = cycle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getHideKilledBody() {
|
|
|
|
|
return npc.stats.hideKilledBody;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void hideKilledBody(boolean hide) {
|
|
|
|
|
npc.stats.hideKilledBody = hide;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean naturallyDespawns() {
|
|
|
|
|
return npc.stats.canDespawn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setNaturallyDespawns(boolean canDespawn) {
|
|
|
|
|
npc.stats.canDespawn = canDespawn;
|
2022-05-26 03:00:49 -05:00
|
|
|
npc.stats.playerSetCanDespawn = canDespawn;
|
2021-12-03 21:13:56 -06:00
|
|
|
}
|
2022-05-28 23:40:01 -05:00
|
|
|
|
|
|
|
|
public boolean spawnedFromSoulStone() {
|
2022-05-29 14:42:28 -05:00
|
|
|
return !npc.advanced.soulStonePlayerName.equals("");
|
2022-05-28 23:40:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getSoulStonePlayerName() {
|
|
|
|
|
return npc.advanced.soulStonePlayerName;
|
|
|
|
|
}
|
2022-05-29 02:46:24 -05:00
|
|
|
|
|
|
|
|
public boolean getRefuseSoulStone() {
|
|
|
|
|
return npc.advanced.refuseSoulStone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRefuseSoulStone(boolean refuse) {
|
|
|
|
|
npc.advanced.refuseSoulStone = refuse;
|
|
|
|
|
}
|
2022-06-07 12:31:49 -05:00
|
|
|
|
|
|
|
|
public boolean isSoulStoneInit() {
|
|
|
|
|
return npc.advanced.soulStoneInit;
|
|
|
|
|
}
|
2022-06-08 22:13:30 -05:00
|
|
|
|
|
|
|
|
public int getMinPointsToSoulStone() {
|
|
|
|
|
return npc.advanced.minFactionPointsToSoulStone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMinPointsToSoulStone(int points) {
|
|
|
|
|
npc.advanced.minFactionPointsToSoulStone = points;
|
|
|
|
|
}
|
2021-12-03 21:13:56 -06:00
|
|
|
|
2022-05-11 22:08:31 -05:00
|
|
|
public void giveItem(IPlayer player, IItemStack item){
|
|
|
|
|
npc.givePlayerItem((EntityPlayer) player.getMCEntity(), item.getMCItemStack());
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2021-12-03 21:13:56 -06:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void executeCommand(String command){
|
|
|
|
|
NoppesUtilServer.runCommand(npc, npc.getCommandSenderName(), command, null);
|
|
|
|
|
}
|
2023-03-17 02:36:28 -05:00
|
|
|
|
|
|
|
|
public IModelData getModelData() {
|
|
|
|
|
return npc instanceof EntityCustomNpc ? ((EntityCustomNpc) npc).modelData : null;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public void setHeadScale(float x, float y, float z){
|
2021-12-07 23:52:57 -06:00
|
|
|
if(npc instanceof EntityCustomNpc) {
|
2023-03-17 02:59:33 -05:00
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.head.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f);
|
|
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.head.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f);
|
|
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.head.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f);
|
2021-12-07 23:52:57 -06:00
|
|
|
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBodyScale(float x, float y, float z){
|
2021-12-07 23:52:57 -06:00
|
|
|
if(npc instanceof EntityCustomNpc) {
|
2023-03-17 02:59:33 -05:00
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.body.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f);
|
|
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.body.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f);
|
|
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.body.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f);
|
2021-12-07 23:52:57 -06:00
|
|
|
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setArmsScale(float x, float y, float z){
|
2021-12-07 23:52:57 -06:00
|
|
|
if(npc instanceof EntityCustomNpc) {
|
2023-03-17 02:59:33 -05:00
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.arms.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f);
|
|
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.arms.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f);
|
|
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.arms.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f);
|
2021-12-07 23:52:57 -06:00
|
|
|
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setLegsScale(float x, float y, float z){
|
2021-12-07 23:52:57 -06:00
|
|
|
if(npc instanceof EntityCustomNpc) {
|
2023-03-17 02:59:33 -05:00
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.legs.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f);
|
|
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.legs.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f);
|
|
|
|
|
((EntityCustomNpc) this.npc).modelData.modelScale.legs.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f);
|
2021-12-07 23:52:57 -06:00
|
|
|
|
|
|
|
|
npc.script.clientNeedsUpdate = true;
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10c
|
|
|
|
|
* @param resistance Explosion resistance (0-2) default is 1
|
|
|
|
|
*/
|
2021-05-09 01:46:37 -04:00
|
|
|
public void setExplosionResistance(float resistance){
|
2023-03-17 02:59:33 -05:00
|
|
|
npc.stats.resistances.explosion = ValueUtil.clamp(resistance, 0, 2);
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.7.10c
|
|
|
|
|
* @return Returns Explosion Resistance
|
|
|
|
|
*/
|
|
|
|
|
public float getExplosionResistance(){
|
|
|
|
|
return npc.stats.resistances.explosion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param resistance Melee resistance (0-2) default is 1
|
|
|
|
|
*/
|
|
|
|
|
public void setMeleeResistance(float resistance){
|
2023-03-17 02:59:33 -05:00
|
|
|
npc.stats.resistances.playermelee = ValueUtil.clamp(resistance, 0, 2);
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns Melee Resistance
|
|
|
|
|
*/
|
|
|
|
|
public float getMeleeResistance(){
|
|
|
|
|
return npc.stats.resistances.playermelee;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param resistance Arrow resistance (0-2) default is 1
|
|
|
|
|
*/
|
|
|
|
|
public void setArrowResistance(float resistance){
|
2023-03-17 02:59:33 -05:00
|
|
|
npc.stats.resistances.arrow = ValueUtil.clamp(resistance, 0, 2);
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns Arrow Resistance
|
|
|
|
|
*/
|
|
|
|
|
public float getArrowResistance(){
|
|
|
|
|
return npc.stats.resistances.arrow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param resistance Knockback resistance (0-2) default is 1
|
|
|
|
|
*/
|
2022-12-24 01:46:43 -06:00
|
|
|
public void setKnockbackResistance(double resistance){
|
2023-03-17 02:59:33 -05:00
|
|
|
npc.stats.resistances.knockback = ValueUtil.clamp((float) resistance, 0, 2);
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns Knockback Resistance
|
|
|
|
|
*/
|
2022-12-24 01:46:43 -06:00
|
|
|
public double getKnockbackResistance(){
|
2018-09-13 12:03:28 -04:00
|
|
|
return npc.stats.resistances.knockback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param type Retaliation type. 0:normal, 1:panic, 2:retreat, 3:nothing
|
|
|
|
|
*/
|
|
|
|
|
public void setRetaliateType(int type){
|
2022-07-27 18:47:20 -05:00
|
|
|
if (type < 0)
|
|
|
|
|
type = 0;
|
|
|
|
|
if (type > 3)
|
|
|
|
|
type = 3;
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
npc.ai.onAttack = type;
|
2022-07-27 18:47:20 -05:00
|
|
|
npc.updateTasks();
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns the combat health regen per second
|
|
|
|
|
*/
|
2021-12-03 00:49:10 -06:00
|
|
|
public float getCombatRegen(){
|
2018-09-13 12:03:28 -04:00
|
|
|
return npc.stats.combatRegen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param regen The combat health regen per second
|
|
|
|
|
*/
|
2021-12-03 00:49:10 -06:00
|
|
|
public void setCombatRegen(float regen){
|
2021-12-04 12:46:53 -06:00
|
|
|
npc.stats.combatRegen = (float)(Math.floor(regen));
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns the health regen per second when not in combat
|
|
|
|
|
*/
|
2021-12-03 00:49:10 -06:00
|
|
|
public float getHealthRegen(){
|
2018-09-13 12:03:28 -04:00
|
|
|
return npc.stats.healthRegen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param regen The health regen per second when not in combat
|
|
|
|
|
*/
|
2021-12-03 00:49:10 -06:00
|
|
|
public void setHealthRegen(float regen){
|
2021-12-04 12:46:53 -06:00
|
|
|
npc.stats.healthRegen = (float)(Math.floor(regen));
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public boolean getCanDrown() {
|
2022-06-29 12:21:30 -05:00
|
|
|
return npc.stats.drowningType > 0;
|
2022-05-24 03:06:16 -05:00
|
|
|
}
|
|
|
|
|
public void setCanDrown(boolean d) {
|
2022-06-29 12:21:30 -05:00
|
|
|
npc.stats.drowningType = d ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDrowningType(int type) {
|
|
|
|
|
if (type < 0)
|
|
|
|
|
type = 0;
|
|
|
|
|
if (type > 2)
|
|
|
|
|
type = 2;
|
|
|
|
|
|
|
|
|
|
npc.stats.drowningType = type;
|
2022-05-24 03:06:16 -05:00
|
|
|
}
|
2022-05-27 15:31:02 -05:00
|
|
|
|
2022-11-12 15:53:20 -06:00
|
|
|
public boolean canBreathe() {
|
|
|
|
|
return npc.canBreathe();
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
@Override
|
|
|
|
|
public long getAge(){
|
|
|
|
|
return npc.totalTicksAlive;
|
|
|
|
|
}
|
2021-10-20 23:04:52 -05:00
|
|
|
|
|
|
|
|
public ITimers getTimers() {
|
|
|
|
|
return ((EntityNPCInterface)this.npc).timers;
|
|
|
|
|
}
|
2021-12-03 00:49:10 -06:00
|
|
|
|
|
|
|
|
public void setFly(int fly){
|
|
|
|
|
if(fly > 0)
|
|
|
|
|
fly = 1;
|
|
|
|
|
else fly = 0;
|
|
|
|
|
|
|
|
|
|
npc.ai.movementType = fly;
|
|
|
|
|
}
|
2021-12-03 21:13:56 -06:00
|
|
|
|
2021-12-06 00:10:10 -06:00
|
|
|
public boolean canFly(){
|
|
|
|
|
return npc.ai.movementType == 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFlySpeed(double flySpeed){
|
|
|
|
|
if(flySpeed < 0.0D)
|
|
|
|
|
flySpeed = 0.0D;
|
|
|
|
|
|
|
|
|
|
npc.ai.flySpeed = flySpeed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double getFlySpeed(double flySpeed){
|
|
|
|
|
return npc.ai.flySpeed;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-08 04:50:23 -06:00
|
|
|
public void setFlyGravity(double flyGravity){
|
|
|
|
|
if(flyGravity < 0.0D)
|
|
|
|
|
flyGravity = 0.0D;
|
|
|
|
|
if(flyGravity > 1.0D)
|
|
|
|
|
flyGravity = 1.0D;
|
|
|
|
|
|
|
|
|
|
npc.ai.flyGravity = flyGravity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double getFlyGravity(double flySpeed){
|
|
|
|
|
return npc.ai.flyGravity;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-13 05:28:20 -06:00
|
|
|
public void setFlyHeightLimit(int flyHeightLimit){
|
|
|
|
|
if(flyHeightLimit < 0)
|
|
|
|
|
flyHeightLimit = 0;
|
|
|
|
|
|
|
|
|
|
this.npc.ai.flyHeightLimit = flyHeightLimit;
|
|
|
|
|
}
|
|
|
|
|
public int getFlyHeightLimit(int flyHeightLimit){
|
|
|
|
|
return this.npc.ai.flyHeightLimit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void limitFlyHeight(boolean limit){
|
|
|
|
|
this.npc.ai.hasFlyLimit = limit;
|
|
|
|
|
}
|
|
|
|
|
public boolean isFlyHeightLimited(boolean limit){
|
|
|
|
|
return this.npc.ai.hasFlyLimit;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-24 01:46:43 -06:00
|
|
|
public void setSpeed(double speed) {
|
2021-12-12 23:10:55 -06:00
|
|
|
npc.ai.setWalkingSpeed(speed);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-24 01:46:43 -06:00
|
|
|
public double getSpeed() {
|
2021-12-12 23:10:55 -06:00
|
|
|
return npc.ai.getWalkingSpeed();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 21:13:56 -06:00
|
|
|
public void setSkinType(byte type) {
|
|
|
|
|
npc.display.skinType = type;
|
2022-11-06 01:25:28 -06:00
|
|
|
npc.script.clientNeedsUpdate = true;
|
2021-12-03 21:13:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte getSkinType() {
|
|
|
|
|
return npc.display.skinType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setSkinUrl(String url){
|
|
|
|
|
if(this.npc.display.url.equals(url))
|
|
|
|
|
return;
|
|
|
|
|
this.npc.display.url = url;
|
|
|
|
|
npc.textureLocation = null;
|
|
|
|
|
npc.display.skinType = 2;
|
2022-11-06 01:25:28 -06:00
|
|
|
npc.script.clientNeedsUpdate = true;
|
2021-12-03 21:13:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getSkinUrl() {
|
|
|
|
|
return this.npc.display.url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setCloakTexture(String cloakTexture) {
|
|
|
|
|
npc.display.cloakTexture = cloakTexture;
|
2022-11-06 01:25:28 -06:00
|
|
|
npc.script.clientNeedsUpdate = true;
|
2021-12-03 21:13:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getCloakTexture() {
|
|
|
|
|
return npc.display.cloakTexture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setOverlayTexture(String overlayTexture) {
|
2023-01-07 00:21:08 -05:00
|
|
|
if (this.getOverlays().size() >= ConfigMain.SkinOverlayLimit) {
|
2022-06-14 23:27:15 -05:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 20:41:32 -05:00
|
|
|
this.getOverlays().add(0, NpcAPI.Instance().createSkinOverlay(overlayTexture));
|
2022-11-06 01:25:28 -06:00
|
|
|
npc.script.clientNeedsUpdate = true;
|
2021-12-03 21:13:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getOverlayTexture() {
|
2022-05-23 20:41:32 -05:00
|
|
|
if (!npc.display.skinOverlayData.overlayList.containsKey(0))
|
2022-05-17 04:34:46 -05:00
|
|
|
return "";
|
2022-05-15 16:47:48 -05:00
|
|
|
|
2022-05-23 20:41:32 -05:00
|
|
|
return npc.display.skinOverlayData.overlayList.get(0).getTexture();
|
2022-05-15 16:47:48 -05:00
|
|
|
}
|
|
|
|
|
|
2022-05-23 20:41:32 -05:00
|
|
|
public IOverlayHandler getOverlays() {
|
|
|
|
|
return npc.display.skinOverlayData;
|
2021-12-03 21:13:56 -06:00
|
|
|
}
|
2022-01-03 21:30:38 -06:00
|
|
|
|
2022-01-14 19:07:41 -06:00
|
|
|
public void setCollisionType(int type){
|
|
|
|
|
npc.display.collidesWith = type;
|
|
|
|
|
}
|
|
|
|
|
public int getCollisionType(){
|
|
|
|
|
return npc.display.collidesWith;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateClient() { this.npc.updateClient(); }
|
2022-11-06 01:25:28 -06:00
|
|
|
|
|
|
|
|
public void updateAI() { this.npc.updateTasks(); }
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|