From b18d0965f217411db9ef6a09679b620e1e82b102 Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Sat, 28 May 2022 22:53:57 -0500 Subject: [PATCH 01/13] script player.sendMessage uses String as color parameter --- .../npcs/scripted/entity/ScriptPlayer.java | 34 +++++++++++++++++++ .../scripted/interfaces/entity/IPlayer.java | 4 +++ 2 files changed, 38 insertions(+) diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index b812d8e70..2ca8be221 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -277,6 +277,40 @@ public class ScriptPlayer extends ScriptLivingBase chat.setChatStyle(style); player.addChatMessage(chat); } + + public void sendMessage(String message, String color, boolean bold, boolean italic, boolean underlined) { + EnumChatFormatting c = getColor(color); + if (c == null) return; + sendMessage(message, c, bold, italic, underlined); + } + + public void sendMessage(String message, String color, boolean bold, boolean italic, boolean obfuscated, boolean strikethrough, boolean underlined) { + EnumChatFormatting c = getColor(color); + if (c == null) return; + sendMessage(message, c, bold, italic, obfuscated, strikethrough, underlined); + } + + private EnumChatFormatting getColor(String color) { + switch (color) { + case "black": return EnumChatFormatting.BLACK; + case "dark_blue": return EnumChatFormatting.DARK_BLUE; + case "dark_green": return EnumChatFormatting.DARK_GREEN; + case "dark_aqua": return EnumChatFormatting.DARK_AQUA; + case "dark_red": return EnumChatFormatting.DARK_RED; + case "dark_purple": return EnumChatFormatting.DARK_PURPLE; + case "gold": return EnumChatFormatting.GOLD; + case "gray": return EnumChatFormatting.GRAY; + case "dark_gray": return EnumChatFormatting.DARK_GRAY; + case "blue": return EnumChatFormatting.BLUE; + case "green": return EnumChatFormatting.GREEN; + case "aqua": return EnumChatFormatting.AQUA; + case "red": return EnumChatFormatting.RED; + case "light_purple": return EnumChatFormatting.LIGHT_PURPLE; + case "yellow": return EnumChatFormatting.YELLOW; + case "white": return EnumChatFormatting.WHITE; + default: return null; + } + } /** * @return Return gamemode. 0: Survival, 1: Creative, 2: Adventure diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java index 2dbd2c72b..e7898cf08 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java @@ -99,6 +99,10 @@ public interface IPlayer extends IEntityLivingBase void sendMessage(String message, EnumChatFormatting color, boolean bold, boolean italic, boolean underlined); void sendMessage(String message, EnumChatFormatting color, boolean bold, boolean italic, boolean obfuscated, boolean strikethrough, boolean underlined); + + void sendMessage(String message, String color, boolean bold, boolean italic, boolean underlined); + + void sendMessage(String message, String color, boolean bold, boolean italic, boolean obfuscated, boolean strikethrough, boolean underlined); /** * @return Return gamemode. 0: Survival, 1: Creative, 2: Adventure From b7ad0ce29bb23511e3203d00b9a0e6d373e9e456 Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Sat, 28 May 2022 23:00:39 -0500 Subject: [PATCH 02/13] soulstone villagers and friendly npcs --- src/main/java/noppes/npcs/CustomNpcs.java | 6 ++++++ src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index ad4842791..73af7a9ef 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -123,8 +123,14 @@ public class CustomNpcs { @ConfigProp(info = "Normal players can use soulstone on animals") public static boolean SoulStoneAnimals = true; + @ConfigProp(info = "Normal players can use soulstone on villagers") + public static boolean SoulStoneVillagers = false; + @ConfigProp(info = "Normal players can use soulstone on all npcs") public static boolean SoulStoneNPCs = false; + + @ConfigProp(info = "Normal players can use soulstone on friendly npcs") + public static boolean SoulStoneFriendlyNPCs = false; @ConfigProp(info="When set to Minecraft it will use minecrafts font, when Default it will use OpenSans. Can only use fonts installed on your PC") public static String FontType = "Default"; diff --git a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java index 74e739860..8e0383deb 100644 --- a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java +++ b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java @@ -1,9 +1,11 @@ package noppes.npcs.items; +import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -17,7 +19,6 @@ import noppes.npcs.controllers.ServerCloneController; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleFollower; -import cpw.mods.fml.common.registry.GameRegistry; public class ItemSoulstoneEmpty extends Item { public ItemSoulstoneEmpty(){ @@ -85,11 +86,11 @@ public class ItemSoulstoneEmpty extends Item { 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; - + if (entity instanceof EntityAnimal) return CustomNpcs.SoulStoneAnimals; + if (entity instanceof EntityVillager) return CustomNpcs.SoulStoneVillagers; return false; } } From 9fef65b1948336f47fd7ba19f44f0f333d2b4ba5 Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Sat, 28 May 2022 23:40:01 -0500 Subject: [PATCH 03/13] get the name of the player who spawned this npc with soulstone --- src/main/java/noppes/npcs/DataAdvanced.java | 6 ++++++ .../java/noppes/npcs/items/ItemSoulstoneFilled.java | 2 +- .../java/noppes/npcs/scripted/entity/ScriptNpc.java | 8 ++++++++ .../npcs/scripted/interfaces/entity/ICustomNpc.java | 12 +++++++++++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/DataAdvanced.java b/src/main/java/noppes/npcs/DataAdvanced.java index 67200a374..cb93437c7 100644 --- a/src/main/java/noppes/npcs/DataAdvanced.java +++ b/src/main/java/noppes/npcs/DataAdvanced.java @@ -52,6 +52,8 @@ public class DataAdvanced { public boolean attackOtherFactions = false; public boolean defendFaction = false; public boolean disablePitch = false; + + public String soulStonePlayerName; public DataAdvanced(EntityNPCInterface npc) { this.npc = npc; @@ -83,6 +85,8 @@ public class DataAdvanced { compound.setTag("NPCDialogOptions", nbtDialogs(npc.dialogs)); + compound.setString("SoulStonePlayerName", soulStonePlayerName); + return compound; } @@ -113,6 +117,8 @@ public class DataAdvanced { factions.readFromNBT(compound.getCompoundTag("FactionPoints")); npc.dialogs = getDialogs(compound.getTagList("NPCDialogOptions", 10)); + + soulStonePlayerName = compound.getString("SoulStonePlayerName"); } private HashMap getDialogs(NBTTagList tagList) { diff --git a/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java b/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java index 416bb62a3..3ead74869 100644 --- a/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java +++ b/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java @@ -78,7 +78,7 @@ public class ItemSoulstoneFilled extends Item { npc.ai.startPos = new int[]{x, y, z}; npc.setHealth(npc.getMaxHealth()); npc.setPosition((float)x + 0.5F, npc.getStartYPos(), (float)z + 0.5F); - + npc.advanced.soulStonePlayerName = player.getDisplayName(); if(npc.advanced.role == EnumRoleType.Companion && player != null){ PlayerData data = PlayerDataController.instance.getPlayerData(player); if(data.hasCompanion()) diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index ef258ed41..927292f89 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -862,6 +862,14 @@ public class ScriptNpc extends ScriptLiving imp npc.stats.canDespawn = canDespawn; npc.stats.playerSetCanDespawn = canDespawn; } + + public boolean spawnedFromSoulStone() { + return npc.advanced.soulStonePlayerName != null; + } + + public String getSoulStonePlayerName() { + return npc.advanced.soulStonePlayerName; + } 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 754395065..452b77b08 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java @@ -623,7 +623,17 @@ public interface ICustomNpc extends IEntityLiving { * @param canDespawn True if the NPC should naturally despawn. False otherwise. */ void setNaturallyDespawns(boolean canDespawn); - + + /** + * @return true if this npc was spawned by a player using soulstone + */ + boolean spawnedFromSoulStone(); + + /** + * @return the name of the player who spawned this npc using soulstone. null if not spawned by soulstone + */ + String getSoulStonePlayerName(); + /** * @param player The player to give the item to * @param item The item given to the player From fd0a99b3edcf58d1c4893b6187a5397b1d2faba2 Mon Sep 17 00:00:00 2001 From: "Luis C.M" <42545778+c0508383@users.noreply.github.com> Date: Sun, 29 May 2022 00:59:40 -0500 Subject: [PATCH 04/13] Revert "NPC Skin Changes" --- src/main/java/noppes/npcs/DataDisplay.java | 2 +- .../java/noppes/npcs/client/EntityUtil.java | 1 + .../client/gui/GuiNpcTextureOverlays.java | 2 +- .../client/gui/mainmenu/GuiNpcDisplay.java | 12 ++--- .../client/gui/model/GuiCreationScreen.java | 47 ++++++++++--------- .../client/gui/model/GuiEntitySelection.java | 1 + .../noppes/npcs/client/model/ModelMPM.java | 26 ++++------ .../client/renderer/RenderCNPCPlayer.java | 9 ---- .../npcs/client/renderer/RenderCustomNpc.java | 2 +- .../client/renderer/RenderNPCHumanMale.java | 25 ++-------- .../client/renderer/RenderNPCInterface.java | 34 +++++--------- .../npcs/entity/EntityNPCInterface.java | 1 + .../npcs/scripted/entity/ScriptNpc.java | 8 ++-- 13 files changed, 64 insertions(+), 106 deletions(-) diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index 6a5582f2b..15dbe469a 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -46,7 +46,6 @@ public class DataDisplay { public int showName = 0; public int modelType = 0; - public boolean x64texture = false; public boolean disableLivingAnimation = false; @@ -185,6 +184,7 @@ public class DataDisplay { if(prevSkinType != skinType || !texture.equals(prevTexture)) npc.textureLocation = null; + npc.textureGlowLocation = null; npc.textureCloakLocation = null; npc.updateHitbox(); } diff --git a/src/main/java/noppes/npcs/client/EntityUtil.java b/src/main/java/noppes/npcs/client/EntityUtil.java index e8a9c7523..8da93fe43 100644 --- a/src/main/java/noppes/npcs/client/EntityUtil.java +++ b/src/main/java/noppes/npcs/client/EntityUtil.java @@ -90,6 +90,7 @@ public class EntityUtil { EntityNPCInterface target = (EntityNPCInterface) entity; target.textureLocation = npc.textureLocation; + target.textureGlowLocation = npc.textureGlowLocation; target.textureCloakLocation = npc.textureCloakLocation; target.display = npc.display; target.inventory = npc.inventory; diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java index d0152dcd6..4a67adc62 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java @@ -77,7 +77,7 @@ public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{ public void elementClicked(){ if(dataTextures.contains(slot.selected) && slot.selected != null){ //npc.display.glowTexture = assets.getAsset(slot.selected); - //npc.textureGlowLocation = null; + npc.textureGlowLocation = null; npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay( assets.getAsset(slot.selected), true, 1.0F, 1.0F, 0.0F, 0.0F, diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java index 2c1621059..f6423f312 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java @@ -129,14 +129,12 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene display.cloakTexture = textfield.getText(); } else if(textfield.id == 9){ - //npc.textureGlowLocation = null; + npc.textureGlowLocation = null; //display.glowTexture = textfield.getText(); - if (!textfield.getText().isEmpty()) { - npc.display.skinOverlayData.overlayList.put(0, new SkinOverlay( - textfield.getText(), true, 1.0F, 1.0F, 0.0F, 0.0F, - 1.0F, 1.0F, 0.0F, 0.0F, 0.0F - )); - } + npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay( + textfield.getText(), true, 1.0F, 1.0F, 0.0F, 0.0F, + 1.0F, 1.0F, 0.0F, 0.0F, 0.0F + )); } else if(textfield.id == 11){ display.title = textfield.getText(); diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java index 9c8f5c36d..82c5a76ef 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java @@ -110,25 +110,25 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol addButton(new GuiNpcButton(7, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); addLabel(new GuiNpcLabel(4, "Legs", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(250, guiLeft + 50, y += 22, 50, 20, new String[]{"Steve","Alex"}, this.npc.display.modelType/2)); + addButton(new GuiNpcButton(250, guiLeft + 50, y += 22, 50, 20, new String[]{"Default","Steve64","Alex"}, this.npc.display.modelType)); addLabel(new GuiNpcLabel(250, "Model", guiLeft, y + 5, 0xFFFFFF)); - + addButton(new GuiNpcButton(44, guiLeft + 310, guiTop + 14, 80, 20, "Save Model")); addButton(new GuiNpcButton(45, guiLeft + 310, guiTop + 36, 80, 20, "Load Model")); - - + + } - + private void showPixelmonMenu(EntityLivingBase entity) { GuiCustomScroll scroll = new GuiCustomScroll(this, 0); scroll.setSize(120, 200); scroll.guiLeft = guiLeft; scroll.guiTop = guiTop + 20; addScroll(scroll); - + scroll.setList(PixelmonHelper.getPixelmonList()); scroll.setSelected(PixelmonHelper.getName(entity)); - + Minecraft.getMinecraft().thePlayer.sendChatMessage(PixelmonHelper.getName(entity)); } @@ -137,7 +137,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol if(entity instanceof EntityNPCInterface) return; int y = guiTop + 20; - + NBTTagCompound compound = getExtras(entity); Set keys = compound.func_150296_c(); int i = 0; @@ -159,7 +159,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol i++; addLabel(new GuiNpcLabel(100 + i, name, guiLeft, y + 5 + i * 22, 0xFFFFFF)); addButton(new GuiNpcButton(100 + i, guiLeft + 80, y + i * 22, 50, 20, new String[]{"gui.no","gui.yes"}, b)); - + mapped.put(i, name); } } @@ -169,7 +169,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol Method method = entity.getClass().getMethod("getBreedID"); breed = (Integer) method.invoke(entity); } catch (Exception e) { - + } i++; addLabel(new GuiNpcLabel(201, "Breed", guiLeft, y + 5 + i * 22, 0xFFFFFF)); @@ -186,18 +186,18 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol private NBTTagCompound getExtras(EntityLivingBase entity) { NBTTagCompound fake = new NBTTagCompound(); new EntityFakeLiving(entity.worldObj).writeEntityToNBT(fake); - + NBTTagCompound compound = new NBTTagCompound(); try{ entity.writeEntityToNBT(compound); } catch(Exception e){ - + } Set keys = fake.func_150296_c(); for(String name : keys) compound.removeTag(name); - + return compound; } @@ -221,7 +221,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol } else{ playerdata.setEntityClass(data.get(list.get(index))); - + EntityLivingBase entity = playerdata.getEntity(npc); if(entity != null){ RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); @@ -231,6 +231,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol //npc.display.glowTexture = ""; npc.display.skinOverlayData.overlayList.remove(0); npc.textureLocation = null; + npc.textureGlowLocation = null; npc.updateHitbox(); } catch(Exception ex){ @@ -246,10 +247,10 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol playerdata.setEntityClass(data.get(list.get(index))); updateTexture(); - + initGui(); } - + if(button.id == 1){ this.mc.displayGuiScreen(new GuiEntitySelection(this, playerdata, npc)); } @@ -270,18 +271,21 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol // New Button for Changing Models // URL Swapper if(button.id == 250){ - npc.display.modelType = button.displayString.equals("Alex") ? 2 : 1; - - if(npc.display.modelType == 1){ + if(npc.display.modelType == 0){ if (npc.display.skinType == 2){ npc.display.skinType = 3; } - } else { + npc.display.modelType = 1; + } + else if(npc.display.modelType == 1){ + npc.display.modelType = 2; + } + else { if (npc.display.skinType == 3){ npc.display.skinType = 2; } + npc.display.modelType = 0; } - npc.textureLocation = null; } if(button.id == 8){ @@ -335,6 +339,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol //npc.display.glowTexture = ""; npc.display.skinOverlayData.overlayList.remove(0); npc.textureLocation = null; + npc.textureGlowLocation = null; npc.updateHitbox(); } catch(Exception ex){ diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java index 0e124d88e..15704114e 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java @@ -129,6 +129,7 @@ public class GuiEntitySelection extends GuiNPCInterface //npc.display.glowTexture = ""; npc.display.skinOverlayData.overlayList.remove(0); npc.textureLocation = null; + npc.textureGlowLocation = null; npc.updateHitbox(); } catch(Exception ex){ diff --git a/src/main/java/noppes/npcs/client/model/ModelMPM.java b/src/main/java/noppes/npcs/client/model/ModelMPM.java index 01f251ac4..a4d158aa0 100644 --- a/src/main/java/noppes/npcs/client/model/ModelMPM.java +++ b/src/main/java/noppes/npcs/client/model/ModelMPM.java @@ -194,7 +194,7 @@ public class ModelMPM extends ModelNPCMale{ } // Steve 64x32 - public ModelMPM(float par1, int alexArms) { + public ModelMPM(float par1) { super(par1); isArmor = par1 > 0; @@ -219,24 +219,14 @@ public class ModelMPM extends ModelNPCMale{ this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1); this.bipedBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); - if (alexArms == 0) { - this.bipedRightArm = new ModelScaleRenderer(this, 40, 16); - this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1); - this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + par2, 0.0F); + this.bipedRightArm = new ModelScaleRenderer(this, 40, 16); + this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + par2, 0.0F); - this.bipedLeftArm = new ModelScaleRenderer(this, 40, 16); - this.bipedLeftArm.mirror = true; - this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1); - this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F); - } else { - this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); - this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1); - - this.bipedLeftArm = new ModelScaleRenderer(this, 40, 16); - this.bipedLeftArm.mirror = true; - this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1); - this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F); - } + this.bipedLeftArm = new ModelScaleRenderer(this, 40, 16); + this.bipedLeftArm.mirror = true; + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F); this.bipedRightLeg = new ModelScaleRenderer(this, 0, 16); this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index fe913ebe1..c8c005025 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -48,9 +48,6 @@ public class RenderCNPCPlayer extends RenderPlayer { private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation, boolean glow, float alpha, float size, float speedX, float speedY, float scaleX, float scaleY, float offsetX, float offsetY, float offsetZ) { - if (overlayLocation.getResourcePath().isEmpty()) - return false; - try { this.bindTexture(overlayLocation); } catch (Exception exception) { @@ -115,9 +112,6 @@ public class RenderCNPCPlayer extends RenderPlayer { { if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlay overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { - if (overlayData.texture.isEmpty()) - continue; - if (overlayData.location == null) { overlayData.location = new ResourceLocation(overlayData.texture); } else { @@ -318,9 +312,6 @@ public class RenderCNPCPlayer extends RenderPlayer { if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlay overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { - if (overlayData.texture.isEmpty()) - continue; - if (overlayData.location == null) { overlayData.location = new ResourceLocation(overlayData.texture); } else { diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java b/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java index 22c619b99..51a0ff9aa 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java @@ -29,7 +29,7 @@ public class RenderCustomNpc extends RenderNPCHumanMale{ // Default Renderer public RenderCustomNpc() { - super(new ModelMPM(0,0), new ModelMPM(1,0), new ModelMPM(0.5f,0)); + super(new ModelMPM(0), new ModelMPM(1), new ModelMPM(0.5f)); } @Override diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java index e0615c6c7..b2ef80bab 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java @@ -37,10 +37,6 @@ public class RenderNPCHumanMale extends RenderNPCInterface protected final static ModelMPM steve64 = new ModelMPM(0, false); protected final static ModelMPM alex = new ModelMPM(0, true); - protected final static ModelMPM alex32mainmodel = new ModelMPM(0,1); - protected final static ModelMPM alex32armorChest = new ModelMPM(1,1); - protected final static ModelMPM alex32armor = new ModelMPM(0.5F,1); - public RenderNPCHumanMale(ModelNPCMale mainmodel, ModelNPCMale armorChest, ModelNPCMale armor) { super(mainmodel, 0.5F); @@ -119,28 +115,13 @@ public class RenderNPCHumanMale extends RenderNPCInterface EntityCustomNpc test = (EntityCustomNpc) npc; if(test.modelData.entityClass == null){ int modelVal = npc.display.modelType; - if(modelVal == 1 && npc.display.x64texture){ + if(modelVal == 1){ this.mainModel = steve64; this.modelBipedMain = steve64; } else if(modelVal == 2){ - if (npc.display.x64texture) { - this.mainModel = alex; - this.modelBipedMain = alex; - } else { - ((EntityCustomNpc) npc).modelData.bodywear = 0; - ((EntityCustomNpc) npc).modelData.armwear = 0; - ((EntityCustomNpc) npc).modelData.legwear = 0; - this.mainModel = alex32mainmodel; - this.modelBipedMain = alex32mainmodel; - } - } - else if(modelVal == 3){ - ((EntityCustomNpc) npc).modelData.bodywear = 0; - ((EntityCustomNpc) npc).modelData.armwear = 0; - ((EntityCustomNpc) npc).modelData.legwear = 0; - this.mainModel = alex32mainmodel; - this.modelBipedMain = alex32mainmodel; + this.mainModel = alex; + this.modelBipedMain = alex; } else{ ((EntityCustomNpc) npc).modelData.bodywear = 0; diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 254c3ef16..74f428de9 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -22,7 +22,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.BossStatus; -import net.minecraft.util.ReportedException; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.model.ModelMPM; @@ -222,9 +221,6 @@ public class RenderNPCInterface extends RenderLiving{ if (!npc.display.skinOverlayData.overlayList.isEmpty()) { for (ISkinOverlay overlayData : npc.display.skinOverlayData.overlayList.values()) { try { - if (overlayData.getTexture().isEmpty()) - continue; - if (overlayData.getLocation() == null) { overlayData.setLocation(new ResourceLocation(overlayData.getTexture())); } else { @@ -234,12 +230,7 @@ public class RenderNPCInterface extends RenderLiving{ } } - if (overlayData.getLocation().getResourcePath().isEmpty()) - continue; - - try { - this.bindTexture(overlayData.getLocation()); - } catch (Exception e) { continue; } + this.bindTexture(overlayData.getLocation()); // Overlay & Glow GL11.glEnable(GL11.GL_BLEND); @@ -349,12 +340,13 @@ public class RenderNPCInterface extends RenderLiving{ } private ResourceLocation adjustLocalTexture(EntityNPCInterface npc, ResourceLocation location) throws IOException { + if (npc.display.modelType != 0) { + return location; + } + InputStream inputstream = null; try { - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - texturemanager.deleteTexture(location); - IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(location); inputstream = iresource.getInputStream(); @@ -363,16 +355,14 @@ public class RenderNPCInterface extends RenderLiving{ int totalWidth = bufferedimage.getWidth(); int totalHeight = bufferedimage.getHeight(); - npc.display.x64texture = totalHeight > 32; - if (npc.display.x64texture) { - if (npc.display.modelType == 0 || npc.display.modelType == 3) { - bufferedimage = bufferedimage.getSubimage(0, 0, totalWidth, 32); - } - } + if (totalHeight > 32) { + bufferedimage = bufferedimage.getSubimage(0, 0, totalWidth, 32); - ImageDownloadAlt object = new ImageDownloadAlt(null, npc.display.texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false)); - object.setBufferedImage(bufferedimage); - texturemanager.loadTexture(location, object); + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + ImageDownloadAlt object = new ImageDownloadAlt(null, npc.display.texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false)); + object.setBufferedImage(bufferedimage); + texturemanager.loadTexture(location, object); + } return location; } finally { diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 904b11d15..9f7719377 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -128,6 +128,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public List interactingEntities = new ArrayList(); public ResourceLocation textureLocation = null; + public ResourceLocation textureGlowLocation = null; public ResourceLocation textureCloakLocation = null; public EnumAnimation currentAnimation = EnumAnimation.NONE; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index ef258ed41..29074db9d 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -73,14 +73,14 @@ public class ScriptNpc extends ScriptLiving imp } /** - * @param modelType The modelType of the NPC. 0: Steve, 1: Alex + * @param modelType The modelType of the NPC. 0: Steve, 1: Steve64, 2: Alex */ public void setModelType(int modelType){ - if(modelType > 1) - modelType = 1; + if(modelType > 2) + modelType = 2; else if(modelType < 0) modelType = 0; - npc.display.modelType = modelType + 1; + npc.display.modelType = modelType; npc.script.clientNeedsUpdate = true; } 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 05/13] 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 From a675033d6290c3a50653f7a5d0e47702d9770a39 Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Sun, 29 May 2022 14:42:28 -0500 Subject: [PATCH 06/13] String data can't be null --- src/main/java/noppes/npcs/DataAdvanced.java | 2 +- src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/DataAdvanced.java b/src/main/java/noppes/npcs/DataAdvanced.java index 93d3caa3b..3051af8a1 100644 --- a/src/main/java/noppes/npcs/DataAdvanced.java +++ b/src/main/java/noppes/npcs/DataAdvanced.java @@ -54,7 +54,7 @@ public class DataAdvanced { public boolean disablePitch = false; public boolean refuseSoulStone = false; - public String soulStonePlayerName; + public String soulStonePlayerName = ""; public DataAdvanced(EntityNPCInterface npc) { this.npc = npc; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 38aa68998..83d68da2f 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -868,7 +868,7 @@ public class ScriptNpc extends ScriptLiving imp } public boolean spawnedFromSoulStone() { - return npc.advanced.soulStonePlayerName != null; + return !npc.advanced.soulStonePlayerName.equals(""); } public String getSoulStonePlayerName() { From 8c687e7ef573ddf7fbd6775fe4d2733792976ee1 Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Thu, 2 Jun 2022 21:32:19 -0500 Subject: [PATCH 07/13] fixed DataTimers.writeToNBT --- src/main/java/noppes/npcs/entity/data/DataTimers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/entity/data/DataTimers.java b/src/main/java/noppes/npcs/entity/data/DataTimers.java index 228e7a02b..85c62217c 100644 --- a/src/main/java/noppes/npcs/entity/data/DataTimers.java +++ b/src/main/java/noppes/npcs/entity/data/DataTimers.java @@ -99,7 +99,7 @@ public class DataTimers implements ITimers { DataTimers.Timer timer = (DataTimers.Timer)var3.next(); NBTTagCompound c = new NBTTagCompound(); c.setInteger("ID", timer.id); - c.setInteger("TimerTicks", timer.id); + c.setInteger("TimerTicks", timer.timerTicks); c.setBoolean("Repeat", timer.repeat); c.setInteger("Ticks", timer.ticks); list.appendTag(c); From 17fa6328c9a35b5b513c6427f05d0616f68aaae2 Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Mon, 6 Jun 2022 14:38:33 -0500 Subject: [PATCH 08/13] fixed crash when hovering over a trader item slot HashMap.put doesn't work the way I thought it did --- .../noppes/npcs/containers/ContainerNPCTrader.java | 4 ++-- src/main/java/noppes/npcs/roles/RoleTrader.java | 13 ++++++------- .../npcs/scripted/roles/ScriptRoleTrader.java | 5 ++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java b/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java index f0390478e..f6b936b46 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java @@ -68,12 +68,12 @@ public class ContainerNPCTrader extends ContainerNpcInterface{ NoppesUtilPlayer.consumeItem(entityplayer, role.inventoryCurrency.getStackInSlot(i + 18), role.ignoreDamage, role.ignoreNBT); ItemStack soldItem = item.copy(); givePlayer(soldItem, entityplayer); - role.addPurchase(i, entityplayer); + role.addPurchase(i, entityplayer.getDisplayName()); return soldItem; } public boolean isSlotEnabled(int slot, EntityPlayer player) { - return role.isSlotEnabled(slot, player); + return role.isSlotEnabled(slot, player.getDisplayName()); } public boolean canBuy(int slot, EntityPlayer player) { ItemStack currency = role.inventoryCurrency.getStackInSlot(slot); diff --git a/src/main/java/noppes/npcs/roles/RoleTrader.java b/src/main/java/noppes/npcs/roles/RoleTrader.java index 3c918dc57..b239a5b94 100644 --- a/src/main/java/noppes/npcs/roles/RoleTrader.java +++ b/src/main/java/noppes/npcs/roles/RoleTrader.java @@ -118,23 +118,22 @@ public class RoleTrader extends RoleInterface{ return false; } - public void addPurchase(int slot, EntityPlayer player) { + public void addPurchase(int slot, String playerName) { if(slot >= 18 || slot < 0) return; ++purchases[slot]; - ++getArrayByName(player.getDisplayName(), playerPurchases)[slot]; + ++getArrayByName(playerName, playerPurchases)[slot]; } - public boolean isSlotEnabled(int slot, EntityPlayer player) { + public boolean isSlotEnabled(int slot, String playerName) { if(slot >= 18 || slot < 0) return false; if (disableSlot[slot] > 0) return false; - if (getArrayByName(player.getDisplayName(), playerDisableSlot)[slot] > 0) return false; + if (getArrayByName(playerName, playerDisableSlot)[slot] > 0) return false; return true; } public int[] getArrayByName(String name, HashMap map) { - int[] a = map.get(name); - if (a == null) a = map.put(name, new int[18]); - return a; + if (map.get(name) == null) map.put(name, new int[18]); + return map.get(name); } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java index 6d36f0d0d..98271fcc5 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java @@ -1,13 +1,12 @@ package noppes.npcs.scripted.roles; import foxz.utils.Market; -import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTrader; import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.constants.RoleType; import noppes.npcs.scripted.interfaces.entity.IPlayer; +import noppes.npcs.scripted.interfaces.item.IItemStack; public class ScriptRoleTrader extends ScriptRoleInterface{ private RoleTrader role; @@ -160,7 +159,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface{ */ public boolean isSlotEnabled(int slot, IPlayer player) { if(slot >= 18 || slot < 0) return false; - return role.isSlotEnabled(slot, (EntityPlayer)player.getMCEntity()); + return role.isSlotEnabled(slot, player.getDisplayName()); } /** From 5edb08945ead0372f02c180044b0d2799390bf1a Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Mon, 6 Jun 2022 14:39:10 -0500 Subject: [PATCH 09/13] changed slot disabled label color --- src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java b/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java index 6536f822f..799d019ab 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java @@ -119,7 +119,7 @@ public class GuiNPCTrader extends GuiContainerNPCInterface{ } else if (!container.isSlotEnabled(slot, player)) { String title = StatCollector.translateToLocal("trader.slotdisabled"); - this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title))/2, 131, 0x00DD00); + this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title))/2, 131, 0xFF4000 ); } else{ String title = StatCollector.translateToLocal("trader.sufficient"); From 825c42fc52a1c8be1c063c6cf298a33f87b80a54 Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Tue, 7 Jun 2022 12:31:49 -0500 Subject: [PATCH 10/13] npc.isSoulStoneinit --- src/main/java/noppes/npcs/DataAdvanced.java | 3 ++- src/main/java/noppes/npcs/entity/EntityNPCInterface.java | 1 + src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java | 1 + src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java | 4 ++++ .../noppes/npcs/scripted/interfaces/entity/ICustomNpc.java | 5 +++++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/DataAdvanced.java b/src/main/java/noppes/npcs/DataAdvanced.java index 3051af8a1..696912d05 100644 --- a/src/main/java/noppes/npcs/DataAdvanced.java +++ b/src/main/java/noppes/npcs/DataAdvanced.java @@ -53,8 +53,9 @@ public class DataAdvanced { public boolean defendFaction = false; public boolean disablePitch = false; - public boolean refuseSoulStone = false; public String soulStonePlayerName = ""; + public boolean refuseSoulStone = false; + public boolean soulStoneInit = false; public DataAdvanced(EntityNPCInterface npc) { this.npc = npc; diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 904b11d15..71b5871e4 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -218,6 +218,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public void onUpdate(){ super.onUpdate(); if(this.ticksExisted % 10 == 0) { + advanced.soulStoneInit = false; EventHooks.onNPCUpdate(this); } this.timers.update(); diff --git a/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java b/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java index 3ead74869..b563329e9 100644 --- a/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java +++ b/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java @@ -79,6 +79,7 @@ public class ItemSoulstoneFilled extends Item { npc.setHealth(npc.getMaxHealth()); npc.setPosition((float)x + 0.5F, npc.getStartYPos(), (float)z + 0.5F); npc.advanced.soulStonePlayerName = player.getDisplayName(); + npc.advanced.soulStoneInit = true; if(npc.advanced.role == EnumRoleType.Companion && player != null){ PlayerData data = PlayerDataController.instance.getPlayerData(player); if(data.hasCompanion()) diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 83d68da2f..91b704a29 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -882,6 +882,10 @@ public class ScriptNpc extends ScriptLiving imp public void setRefuseSoulStone(boolean refuse) { npc.advanced.refuseSoulStone = refuse; } + + public boolean isSoulStoneInit() { + return npc.advanced.soulStoneInit; + } 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 592324fd0..1e0a02af6 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,11 @@ public interface ICustomNpc extends IEntityLiving { */ String getSoulStonePlayerName(); + /** + * @return true if npc was spawned by soul stone. becomes false after the init function is called. + */ + boolean isSoulStoneInit(); + /** * @return does this npc refuse to be taken by soul stone */ From 4a70dfb4ce343070d4347a67aa0a17966c8aa7c3 Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Wed, 8 Jun 2022 00:32:58 -0500 Subject: [PATCH 11/13] soulStoneInit field bugfix --- src/main/java/noppes/npcs/EventHooks.java | 2 +- src/main/java/noppes/npcs/entity/EntityNPCInterface.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index 4da9356f7..339b42582 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -118,11 +118,11 @@ public class EventHooks { public static void onNPCInit(EntityNPCInterface npc) { if(npc == null || npc.wrappedNPC == null) return; - noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC); ScriptController.Instance.npcScripts.callScript(EnumScriptType.INIT, event); npc.script.callScript(EnumScriptType.INIT); NpcAPI.EVENT_BUS.post(event); + npc.advanced.soulStoneInit = false; } public static void onNPCUpdate(EntityNPCInterface npc) { diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 71b5871e4..904b11d15 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -218,7 +218,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public void onUpdate(){ super.onUpdate(); if(this.ticksExisted % 10 == 0) { - advanced.soulStoneInit = false; EventHooks.onNPCUpdate(this); } this.timers.update(); From 5740519ed287f4c669c997e716bd3ef3d4b6be49 Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Wed, 8 Jun 2022 12:12:18 -0500 Subject: [PATCH 12/13] ScriptRoleTrader.getSellOption returns the item being sold instead of the currency --- src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java index 98271fcc5..3c842fd45 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java @@ -55,7 +55,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface{ public IItemStack getSellOption(int slot) { if (slot >= 18 || slot < 0) return null; if (role.inventorySold.items.get(slot) == null) return null; - return NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot)); + return NpcAPI.Instance().getIItemStack(role.inventorySold.items.get(slot)); } /** From b7ef1da0d8472b8bd772db813e3e895c3aa98148 Mon Sep 17 00:00:00 2001 From: 1whohears <1whohears28@gmail.com> Date: Wed, 8 Jun 2022 22:13:30 -0500 Subject: [PATCH 13/13] added npc.setMinPointsToSoulStone --- src/main/java/noppes/npcs/DataAdvanced.java | 3 +++ .../noppes/npcs/items/ItemSoulstoneEmpty.java | 13 +++++++++-- .../npcs/scripted/entity/ScriptNpc.java | 8 +++++++ .../interfaces/entity/ICustomNpc.java | 22 ++++++++++++++++--- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/main/java/noppes/npcs/DataAdvanced.java b/src/main/java/noppes/npcs/DataAdvanced.java index 696912d05..e58fe0d0a 100644 --- a/src/main/java/noppes/npcs/DataAdvanced.java +++ b/src/main/java/noppes/npcs/DataAdvanced.java @@ -56,6 +56,7 @@ public class DataAdvanced { public String soulStonePlayerName = ""; public boolean refuseSoulStone = false; public boolean soulStoneInit = false; + public int minFactionPointsToSoulStone = -1; public DataAdvanced(EntityNPCInterface npc) { this.npc = npc; @@ -89,6 +90,7 @@ public class DataAdvanced { compound.setBoolean("RefuseSoulStone", refuseSoulStone); compound.setString("SoulStonePlayerName", soulStonePlayerName); + compound.setInteger("MinFactionPointsToSoulStone", minFactionPointsToSoulStone); return compound; } @@ -123,6 +125,7 @@ public class DataAdvanced { refuseSoulStone = compound.getBoolean("RefuseSoulStone"); soulStonePlayerName = compound.getString("SoulStonePlayerName"); + minFactionPointsToSoulStone = compound.getInteger("MinFactionPointsToSoulStone"); } private HashMap getDialogs(NBTTagList tagList) { diff --git a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java index 8ce64a8df..08d10bdde 100644 --- a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java +++ b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java @@ -15,7 +15,10 @@ import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.NoppesUtilServer; import noppes.npcs.constants.EnumRoleType; +import noppes.npcs.controllers.FactionController; +import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.ServerCloneController; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleFollower; @@ -77,8 +80,14 @@ public class ItemSoulstoneEmpty extends Item { if(entity instanceof EntityNPCInterface){ EntityNPCInterface npc = (EntityNPCInterface) entity; if (npc.advanced.refuseSoulStone) return false; - if (npc.getFaction() != null && npc.getFaction().isFriendlyToPlayer(player) - && CustomNpcs.SoulStoneFriendlyNPCs) return true; + if (CustomNpcs.SoulStoneFriendlyNPCs && npc.getFaction() != null) { + int p = npc.advanced.minFactionPointsToSoulStone; + if (p == -1 && npc.getFaction().isFriendlyToPlayer(player)) return true; + else if (p != -1) { + PlayerData data = PlayerDataController.instance.getPlayerData(player); + return data.factionData.getFactionPoints(npc.getFaction().getId()) >= p; + } + } if (npc.advanced.role == EnumRoleType.Companion){ RoleCompanion role = (RoleCompanion) npc.roleInterface; if(role.getOwner() == player) diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 91b704a29..91c394669 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -886,6 +886,14 @@ public class ScriptNpc extends ScriptLiving imp public boolean isSoulStoneInit() { return npc.advanced.soulStoneInit; } + + public int getMinPointsToSoulStone() { + return npc.advanced.minFactionPointsToSoulStone; + } + + public void setMinPointsToSoulStone(int points) { + npc.advanced.minFactionPointsToSoulStone = points; + } 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 1e0a02af6..93afe8911 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java @@ -7,11 +7,11 @@ package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.EntityCreature; import noppes.npcs.scripted.ScriptFaction; -import noppes.npcs.scripted.interfaces.ISkinOverlay; +import noppes.npcs.scripted.interfaces.ITimers; import noppes.npcs.scripted.interfaces.handler.IOverlayHandler; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.interfaces.ITimers; -import noppes.npcs.scripted.roles.*; +import noppes.npcs.scripted.roles.ScriptJobInterface; +import noppes.npcs.scripted.roles.ScriptRoleInterface; public interface ICustomNpc extends IEntityLiving { /** @@ -649,6 +649,22 @@ public interface ICustomNpc extends IEntityLiving { */ void setRefuseSoulStone(boolean refuse); + /** + * requires SoulStoneFriendlyNPCs in config to be true + * -1 by default + * if -1, the minimum points are the faction's friendly points + * @return the minimum faction points needed to soulstone this npc + */ + int getMinPointsToSoulStone(); + + /** + * requires SoulStoneFriendlyNPCs in config to be true + * -1 by default + * if -1, the minimum points are the faction's friendly points + * @param points the minimum faction points needed to soulstone this npc + */ + void setMinPointsToSoulStone(int points); + /** * @param player The player to give the item to * @param item The item given to the player