added get set refuse soul stone

one may want an npc to not be able to be picked up by soul stone in any circumstance
This commit is contained in:
1whohears committed 2022-05-29 02:46:24 -05:00
1 parent 9fef65b194
commit fb0ff50994
4 files changed
+39 -12

No files matched your search

@@ -53,6 +53,7 @@ public class DataAdvanced {
public boolean defendFaction = false;
public boolean disablePitch = false;
public boolean refuseSoulStone = false;
public String soulStonePlayerName;
public DataAdvanced(EntityNPCInterface npc) {
@@ -85,6 +86,7 @@ public class DataAdvanced {
compound.setTag("NPCDialogOptions", nbtDialogs(npc.dialogs));
compound.setBoolean("RefuseSoulStone", refuseSoulStone);
compound.setString("SoulStonePlayerName", soulStonePlayerName);
return compound;
@@ -118,6 +120,7 @@ public class DataAdvanced {
npc.dialogs = getDialogs(compound.getTagList("NPCDialogOptions", 10));
refuseSoulStone = compound.getBoolean("RefuseSoulStone");
soulStonePlayerName = compound.getString("SoulStonePlayerName");
}
@@ -76,17 +76,19 @@ public class ItemSoulstoneEmpty extends Item {
return true;
if(entity instanceof EntityNPCInterface){
EntityNPCInterface npc = (EntityNPCInterface) entity;
if(npc.advanced.role == EnumRoleType.Companion){
if (npc.advanced.refuseSoulStone) return false;
if (npc.getFaction() != null && npc.getFaction().isFriendlyToPlayer(player)
&& CustomNpcs.SoulStoneFriendlyNPCs) return true;
if (npc.advanced.role == EnumRoleType.Companion){
RoleCompanion role = (RoleCompanion) npc.roleInterface;
if(role.getOwner() == player)
return true;
}
if(npc.advanced.role == EnumRoleType.Follower){
if (npc.advanced.role == EnumRoleType.Follower){
RoleFollower role = (RoleFollower) npc.roleInterface;
if(role.getOwner() == player)
return !role.refuseSoulStone;
}
if (npc.getFaction() != null && npc.getFaction().isFriendlyToPlayer(player) && CustomNpcs.SoulStoneFriendlyNPCs) return true;
return CustomNpcs.SoulStoneNPCs;
}
if (entity instanceof EntityAnimal) return CustomNpcs.SoulStoneAnimals;
@@ -1,21 +1,29 @@
package noppes.npcs.scripted.entity;
import java.util.ArrayList;
import java.util.UUID;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.constants.*;
import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.constants.EnumJobType;
import noppes.npcs.constants.EnumNavType;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.constants.EnumStandingType;
import noppes.npcs.controllers.data.Line;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptFaction;
import noppes.npcs.scripted.constants.AnimationType;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.constants.AnimationType;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.scripted.roles.ScriptJobBard;
import noppes.npcs.scripted.roles.ScriptJobConversation;
import noppes.npcs.scripted.roles.ScriptJobFollower;
@@ -31,12 +39,8 @@ import noppes.npcs.scripted.roles.ScriptRoleInterface;
import noppes.npcs.scripted.roles.ScriptRoleMailman;
import noppes.npcs.scripted.roles.ScriptRoleTrader;
import noppes.npcs.scripted.roles.ScriptRoleTransporter;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.util.ValueUtil;
import java.util.ArrayList;
import java.util.UUID;
public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> implements ICustomNpc {
public EntityNPCInterface npc;
@@ -870,6 +874,14 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
public String getSoulStonePlayerName() {
return npc.advanced.soulStonePlayerName;
}
public boolean getRefuseSoulStone() {
return npc.advanced.refuseSoulStone;
}
public void setRefuseSoulStone(boolean refuse) {
npc.advanced.refuseSoulStone = refuse;
}
public void giveItem(IPlayer player, IItemStack item){
npc.givePlayerItem((EntityPlayer) player.getMCEntity(), item.getMCItemStack());
@@ -634,6 +634,16 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
*/
String getSoulStonePlayerName();
/**
* @return does this npc refuse to be taken by soul stone
*/
boolean getRefuseSoulStone();
/**
* @param refuse set if this npc refuses to be taken by soul stone
*/
void setRefuseSoulStone(boolean refuse);
/**
* @param player The player to give the item to
* @param item The item given to the player