From fb0ff509943f80d5aa47d923bcfe52b86c029c67 Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Sun, 29 May 2022 02:46:24 -0500 Subject: [PATCH] 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 --- src/main/java/noppes/npcs/DataAdvanced.java | 3 ++ .../noppes/npcs/items/ItemSoulstoneEmpty.java | 8 +++-- .../npcs/scripted/entity/ScriptNpc.java | 30 +++++++++++++------ .../interfaces/entity/ICustomNpc.java | 10 +++++++ 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/main/java/noppes/npcs/DataAdvanced.java b/src/main/java/noppes/npcs/DataAdvanced.java index cb93437c7..93d3caa3b 100644 --- a/src/main/java/noppes/npcs/DataAdvanced.java +++ b/src/main/java/noppes/npcs/DataAdvanced.java @@ -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"); } diff --git a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java index 8e0383deb..8ce64a8df 100644 --- a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java +++ b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java @@ -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; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 927292f89..38aa68998 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -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 extends ScriptLiving implements ICustomNpc { public EntityNPCInterface npc; @@ -870,6 +874,14 @@ public class ScriptNpc extends ScriptLiving 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()); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java index 452b77b08..592324fd0 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java @@ -634,6 +634,16 @@ public interface ICustomNpc extends IEntityLiving { */ 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