diff --git a/src/api b/src/api index cf6f122f9..8eaf18696 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit cf6f122f9b4070182f3907ebd7f7498c23257da2 +Subproject commit 8eaf18696b1abf883175ee11e32ebfe73e134a65 diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index bc6109e09..f0fc474cc 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -179,6 +179,7 @@ public class EventHooks { return false; ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_MELEE, event); + npc.script.callScript(EnumScriptType.ATTACK_MELEE, event, "target", event.target); npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target); return NpcAPI.EVENT_BUS.post(event); } @@ -197,6 +198,7 @@ public class EventHooks { return false; ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event); + npc.script.callScript(EnumScriptType.RANGED_LAUNCHED, event, "target", event.target); npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target); return NpcAPI.EVENT_BUS.post(event); } diff --git a/src/main/java/noppes/npcs/NoppesUtilPlayer.java b/src/main/java/noppes/npcs/NoppesUtilPlayer.java index ccfb63d90..a40fe83e9 100644 --- a/src/main/java/noppes/npcs/NoppesUtilPlayer.java +++ b/src/main/java/noppes/npcs/NoppesUtilPlayer.java @@ -320,14 +320,38 @@ public class NoppesUtilPlayer { } } + public static void clearTrackQuest(EntityPlayerMP player) throws IOException { + PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + playerData.questData.untrackQuest(); + } + + + public static void updatePartyQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException { + PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + String trackedQuestString = Server.readString(buffer); + Quest trackedQuest = getQuestFromStringKey(trackedQuestString); + if (trackedQuest != null) { + playerData.questData.trackParty(playerData.getPlayerParty()); + } else { + playerData.questData.untrackQuest(); + } + } + private static Quest getQuestFromStringKey(String string) { if (string != null && string.contains(":")) { String[] splitString = string.split(":"); - if(splitString.length < 2){ - return null; - } - String categoryName = splitString[0]; - String questName = splitString[1]; + + String categoryName; + String questName; + if (splitString.length == 3 && splitString[0].equals("P")) { + categoryName = splitString[1]; + questName = splitString[2]; + } else if (splitString.length < 2) { + return null; + } else { + categoryName = splitString[0]; + questName = splitString[1]; + } for (QuestCategory category : QuestController.Instance.categories.values()) { if (category.title.equals(categoryName)) { @@ -364,6 +388,30 @@ public class NoppesUtilPlayer { } } + public static void sendPartyTrackedQuestData(EntityPlayerMP player, Party party) { + Quest trackedQuest = (Quest) PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest(); + if(trackedQuest != null){ + NBTTagCompound compound = new NBTTagCompound(); + compound.setTag("Quest",trackedQuest.writeToNBT(new NBTTagCompound())); + compound.setString("CategoryName", trackedQuest.getCategory().getName()); + if(trackedQuest.completion == EnumQuestCompletion.Instant){ + compound.setBoolean("Instant", true); + } + else { + compound.setString("TurnInNPC", trackedQuest.getNpcName()); + } + NBTTagList nbtTagList = new NBTTagList(); + for (IQuestObjective objective : trackedQuest.questInterface.getPartyObjectives(party)) { + nbtTagList.appendTag(new NBTTagString(objective.getText())); + if(objective.getAdditionalText() != null) + nbtTagList.appendTag(new NBTTagString(objective.getAdditionalText())); + } + compound.setTag("ObjectiveList",nbtTagList); + + Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound); + } + } + public static void sendQuestLogData(EntityPlayerMP player) { if(!PlayerQuestController.hasActiveQuests(player)){ return; @@ -372,6 +420,13 @@ public class NoppesUtilPlayer { data.setData(player); Server.sendData(player, EnumPacketClient.GUI_DATA, data.writeNBT()); } + + public static void sendTrackedQuest(EntityPlayerMP player) { + QuestLogData data = new QuestLogData(); + data.setTrackedQuestKey(player); + Server.sendData(player, EnumPacketClient.PARTY_DATA, data.writeTrackedQuest()); + } + public static boolean questCompletion(EntityPlayerMP player, int questId) { if(player == null) return false; @@ -477,6 +532,7 @@ public class NoppesUtilPlayer { if (partyEv.isCancelled()) return false; + boolean hasNextQuest = data.quest.hasNewQuest(); PartyOptions partyOptions = quest.partyOptions; EnumPartyExchange complete = partyOptions.completeFor; EnumPartyExchange reward = partyOptions.rewardControl; @@ -540,11 +596,7 @@ public class NoppesUtilPlayer { } } } - - if(meetsComplete){ - data.quest.questInterface.handleComplete(player); - } - + data.quest.questInterface.handlePartyComplete(player, party, isLeader, partyOptions.objectiveRequirement); if(meetsReward){ if(data.quest.rewardExp > 0){ player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.7F + 1.8F)); @@ -565,12 +617,12 @@ public class NoppesUtilPlayer { if(meetsComplete){ PlayerQuestController.setQuestPartyFinished(data.quest, player, data); - if (data.quest.hasNewQuest()) { - QuestData nextQuest = new QuestData(data.quest.getNextQuest()); - nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts; - PlayerQuestController.addActiveQuest(nextQuest, player); - // questData.trackQuest(nextQuest.quest); - } + } + + if (hasNextQuest && meetsComplete) { + QuestData nextQuest = new QuestData(data.quest.getNextQuest()); + nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts; + PlayerQuestController.addActiveQuest(nextQuest, player); } playerData.save(); @@ -579,8 +631,30 @@ public class NoppesUtilPlayer { } } - if(data.quest.completion == EnumQuestCompletion.Npc){ + + if (hasNextQuest) { + if(party.validateQuest(data.quest.getNextQuest().getId(), true)){ + party.setQuest(data.quest.getNextQuest()); + for(String name : party.getPlayerNames()) { + EntityPlayer player = NoppesUtilServer.getPlayerByName(name); + if (player == null) + continue; + + PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + if (playerData == null) + continue; + + playerData.questData.trackParty(party); + } + } + else { + party.setQuest(null); + } + } else { party.setQuest(null); + } + + if(data.quest.completion == EnumQuestCompletion.Npc){ PartyController.Instance().sendQuestChat(party, "party.completeChat"); PartyController.Instance().pingPartyUpdate(party); } diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 384fab332..e6795de13 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -216,7 +216,7 @@ public class NoppesUtilServer { // Trim the command to remove leading/trailing spaces command = command.trim(); - String[] commands = command.split(";"); // Split the command by semicolon + String[] commands = command.split("@x"); // Split the command by @x // Create TileEntityCommandBlock instance outside the loop TileEntityCommandBlock tile = new TileEntityCommandBlock(); @@ -245,7 +245,7 @@ public class NoppesUtilServer { // Trim the command to remove leading/trailing spaces command = command.trim(); - String[] commands = command.split(";"); // Split the command by semicolon + String[] commands = command.split("@x"); // Split the command by @x CommandBlockLogic logic = tile.func_145993_a(); for (String cmd : commands) { logic.func_145752_a(cmd.trim()); // Trim the command to remove any leading/trailing spaces diff --git a/src/main/java/noppes/npcs/PacketHandlerPlayer.java b/src/main/java/noppes/npcs/PacketHandlerPlayer.java index 12b31f03c..55feeae1f 100644 --- a/src/main/java/noppes/npcs/PacketHandlerPlayer.java +++ b/src/main/java/noppes/npcs/PacketHandlerPlayer.java @@ -209,6 +209,9 @@ public class PacketHandlerPlayer{ else if(type == EnumPlayerPacket.QuestLog){ NoppesUtilPlayer.sendQuestLogData(player); } + else if(type == EnumPlayerPacket.TrackedQuest){ + NoppesUtilPlayer.sendTrackedQuest(player); + } else if(type == EnumPlayerPacket.FactionsGet){ PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; Server.sendData(player, EnumPacketClient.GUI_DATA, data.getPlayerGuiData()); diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index 41e3a2a45..14d99f16e 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -91,7 +91,13 @@ public class PacketHandlerServer{ } else if (type == EnumPacketServer.QuestLogToServer) { NoppesUtilPlayer.updateQuestLogData(buffer, player); return; - } else if(type == EnumPacketServer.DimensionsGet){ + } else if (type == EnumPacketServer.PartyLogToServer) { + NoppesUtilPlayer.updatePartyQuestLogData(buffer, player); + return; + } else if (type == EnumPacketServer.UntrackQuest) { + NoppesUtilPlayer.clearTrackQuest(player); + return; + } else if(type == EnumPacketServer.DimensionsGet){ HashMap map = new HashMap(); for(int id : DimensionManager.getStaticDimensionIDs()){ WorldProvider provider = DimensionManager.createProviderFor(id); @@ -317,6 +323,7 @@ public class PacketHandlerServer{ NBTTagCompound compound = party.writeToNBT(); if (party.getQuest() != null) { Quest quest = (Quest) party.getQuest(); + compound.setString("QuestName", quest.getCategory().getName() + ":" + quest.getName()); Vector vector = quest.questInterface.getPartyQuestLogStatus(party); NBTTagList list = new NBTTagList(); for (String s : vector) { diff --git a/src/main/java/noppes/npcs/QuestLogData.java b/src/main/java/noppes/npcs/QuestLogData.java index 608224faf..e70cfde6a 100644 --- a/src/main/java/noppes/npcs/QuestLogData.java +++ b/src/main/java/noppes/npcs/QuestLogData.java @@ -2,9 +2,11 @@ package noppes.npcs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.constants.EnumQuestCompletion; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerQuestController; +import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.Quest; @@ -47,6 +49,17 @@ public class QuestLogData { partyQuests = NBTTags.getStringIntegerMap(compound.getTagList("PartyQuests", 10)); partyOptions = NBTTags.getVectorMap(compound.getTagList("PartyOptions", 10)); } + + public NBTTagCompound writeTrackedQuest(){ + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("TrackedQuestID", trackedQuestKey); + return compound; + } + + public void readTrackedQuest(NBTTagCompound compound){ + trackedQuestKey = compound.getString("TrackedQuestID"); + } + public void setData(EntityPlayer player){ PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); @@ -76,8 +89,36 @@ public class QuestLogData { partyOptions.put(key, quest.partyOptions.getPartyOptionsList()); } } + + Party party = playerData.getPlayerParty(); + if(party != null && party.getQuest() != null){ + if (playerData.questData.getTrackedQuest() != null) { + if (party.getQuest().getId() == playerData.questData.getTrackedQuest().getId()) { + trackedQuestKey = "P" + ":" + party.getQuest().getCategory().getName() + ":" + party.getQuest().getName(); + } + } + } } + public void setTrackedQuestKey(EntityPlayer player){ + PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + + Party party = playerData.getPlayerParty(); + if(party != null && party.getQuest() != null){ + if (playerData.questData.getTrackedQuest() != null) { + if (party.getQuest().getId() == playerData.questData.getTrackedQuest().getId()) { + trackedQuestKey = "P" + ":" + party.getQuest().getCategory().getName() + ":" + party.getQuest().getName(); + } + } + } else if(playerData.questData != null && playerData.questData.getTrackedQuest() != null){ + IQuest quest = playerData.questData.getTrackedQuest(); + trackedQuestKey = quest.getCategory().getName() + ":" + quest.getName(); + } + else { + trackedQuestKey = ""; + } + } + public boolean hasSelectedQuest() { return !selectedQuest.isEmpty(); } diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index 4958589aa..2632c3e97 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -30,10 +30,7 @@ import noppes.npcs.constants.EnumQuestType; import noppes.npcs.constants.SyncType; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.controllers.data.PlayerData; -import noppes.npcs.controllers.data.PlayerDataScript; -import noppes.npcs.controllers.data.PlayerQuestData; -import noppes.npcs.controllers.data.Quest; +import noppes.npcs.controllers.data.*; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.item.ScriptCustomItem; @@ -78,7 +75,10 @@ public class ScriptPlayerEventHandler { playerData.timers.update(); } - if (playerData.questData.getTrackedQuest() != null && !playerData.questData.activeQuests.containsKey(playerData.questData.getTrackedQuest().getId())) { + + Party party = playerData.getPlayerParty(); + boolean trackingPartyQuest = playerData.questData.getTrackedQuest() != null && party != null && party.getQuest() != null && party.getQuest().getId() == playerData.questData.getTrackedQuest().getId(); + if (playerData.questData.getTrackedQuest() != null && !playerData.questData.activeQuests.containsKey(playerData.questData.getTrackedQuest().getId()) && !trackingPartyQuest) { PlayerDataController.Instance.getPlayerData(player).questData.untrackQuest(); } @@ -90,7 +90,12 @@ public class ScriptPlayerEventHandler { PlayerQuestData questData = playerData.questData; if(questData != null){ if (questData.getTrackedQuest() != null && ((Quest) questData.getTrackedQuest()).type == EnumQuestType.Item) { - NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player); + if(trackingPartyQuest){ + NoppesUtilPlayer.sendPartyTrackedQuestData((EntityPlayerMP) event.player, party); + } + else { + NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player); + } } } } @@ -483,9 +488,16 @@ public class ScriptPlayerEventHandler { IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerLogin(handler, scriptPlayer); - Quest quest = (Quest) PlayerDataController.Instance.getPlayerData(event.player).questData.getTrackedQuest(); + PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); + Quest quest = (Quest) playerData.questData.getTrackedQuest(); if (quest != null) { - NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player); + Party party = playerData.getPlayerParty(); + if(party != null && party.getQuest() != null && party.getQuest().getId() == quest.getId()){ + NoppesUtilPlayer.sendPartyTrackedQuestData((EntityPlayerMP) event.player, party); + } + else { + NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player); + } } PlayerDataController.Instance.getPlayerData(event.player).skinOverlays.updateClient(); diff --git a/src/main/java/noppes/npcs/ai/CombatHandler.java b/src/main/java/noppes/npcs/ai/CombatHandler.java index 78a300300..10db7318c 100644 --- a/src/main/java/noppes/npcs/ai/CombatHandler.java +++ b/src/main/java/noppes/npcs/ai/CombatHandler.java @@ -136,15 +136,15 @@ public class CombatHandler { public boolean shouldChangeTarget(double chance) { // Assuming randomNum is a random number between 0 and 100 double randomNum = Math.random() * 100; // Generates a random number between 0 and 100 - return randomNum <= chance; + return randomNum < chance; } - public boolean shouldSwitchTactically(EntityLivingBase originalTarget, EntityLivingBase newTarget) { - // Implement your Tactical Switcher conditions here - // Example: Switch if the new target has a higher threat level + public boolean shouldSwitchTactically(EntityLivingBase originalTarget, EntityLivingBase newTarget, boolean reverse) { float currentThreat = calculateThreatLevel(originalTarget); float newThreat = calculateThreatLevel(newTarget); - + if(reverse){ + return newThreat < currentThreat; + } return newThreat > currentThreat; } } diff --git a/src/main/java/noppes/npcs/blocks/BlockCarpentryBench.java b/src/main/java/noppes/npcs/blocks/BlockCarpentryBench.java index 31f9e1957..facbe4ec2 100644 --- a/src/main/java/noppes/npcs/blocks/BlockCarpentryBench.java +++ b/src/main/java/noppes/npcs/blocks/BlockCarpentryBench.java @@ -25,9 +25,10 @@ public class BlockCarpentryBench extends BlockContainer public BlockCarpentryBench() { super(Material.wood); + setStepSound(soundTypeWood); } - @Override + @Override public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {//onBlockActivated if(!par1World.isRemote){ @@ -36,12 +37,13 @@ public class BlockCarpentryBench extends BlockContainer return true; } - @Override + @Override public boolean isOpaqueCube()//isOpaqueCube { return false; - } - @Override + } + + @Override public int getRenderType()//getRenderType { return renderId; @@ -49,7 +51,7 @@ public class BlockCarpentryBench extends BlockContainer /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ - @Override + @Override public boolean renderAsNormalBlock()//renderAsNormalBlock { return false; @@ -59,21 +61,21 @@ public class BlockCarpentryBench extends BlockContainer @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { - + } - @Override + @Override public int damageDropped(int par1) { return par1/4; } - @Override + @Override public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); } - @Override + @Override public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack item) { int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw / 90.0F) + 0.5D) & 3; diff --git a/src/main/java/noppes/npcs/client/ClientCacheHandler.java b/src/main/java/noppes/npcs/client/ClientCacheHandler.java index 4ac631ecc..4314a83b8 100644 --- a/src/main/java/noppes/npcs/client/ClientCacheHandler.java +++ b/src/main/java/noppes/npcs/client/ClientCacheHandler.java @@ -54,6 +54,11 @@ public class ClientCacheHandler { ClientCacheHandler.skinOverlays.clear(); ClientCacheHandler.playerAnimations.clear(); ClientCacheHandler.playerData.animationData.clearCache(); - party = null; + } + + public static void clearSkinCache() { + ClientCacheHandler.imageDataCache.clear(); + ClientCacheHandler.customOverlays.clear(); + ClientCacheHandler.skinOverlays.clear(); } } diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index 85a044a88..51726cfcd 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -102,7 +102,8 @@ public class ClientProxy extends CommonProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileBlockAnvil.class, new BlockCarpentryBenchRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileMailbox.class, new BlockMailboxRenderer()); - RenderingRegistry.registerBlockHandler(new BlockBorderRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileScripted.class, new BlockScriptedRenderer()); + RenderingRegistry.registerBlockHandler(new BlockBorderRenderer()); if(!ConfigMain.DisableExtraBlock){ ClientRegistry.bindTileEntitySpecialRenderer(TileBanner.class, new BlockBannerRenderer()); @@ -126,7 +127,6 @@ public class ClientProxy extends CommonProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileBeam.class, new BlockBeamRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileBook.class, new BlockBookRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TilePedestal.class, new BlockPedestalRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileScripted.class, new BlockScriptedRenderer()); RenderingRegistry.registerBlockHandler(new BlockBloodRenderer()); } Minecraft mc = Minecraft.getMinecraft(); @@ -150,8 +150,7 @@ public class ClientProxy extends CommonProxy { if(ConfigClient.InventoryGuiEnabled){ MinecraftForge.EVENT_BUS.register(new TabRegistry()); - - if (TabRegistry.getTabList().size() < 2){ + if (TabRegistry.getTabList().isEmpty()){ TabRegistry.registerTab(new InventoryTabVanilla()); } TabRegistry.registerTab(new InventoryTabCustomNpc()); diff --git a/src/main/java/noppes/npcs/client/ClientTickHandler.java b/src/main/java/noppes/npcs/client/ClientTickHandler.java index bfbb559b3..63bb3b5ad 100644 --- a/src/main/java/noppes/npcs/client/ClientTickHandler.java +++ b/src/main/java/noppes/npcs/client/ClientTickHandler.java @@ -12,10 +12,7 @@ import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.client.controllers.MusicController; import noppes.npcs.client.controllers.ScriptSoundController; -import noppes.npcs.client.gui.player.inventory.GuiCNPCInventory; -import noppes.npcs.client.gui.player.inventory.GuiFaction; -import noppes.npcs.client.gui.player.inventory.GuiParty; -import noppes.npcs.client.gui.player.inventory.GuiQuestLog; +import noppes.npcs.client.gui.player.inventory.*; import noppes.npcs.client.renderer.RenderNPCInterface; import noppes.npcs.constants.EnumPlayerPacket; import org.lwjgl.input.Keyboard; @@ -97,14 +94,17 @@ public class ClientTickHandler{ if(mc.currentScreen == null){ switch (GuiCNPCInventory.activeTab){ case 0: - NoppesUtil.openGUI(mc.thePlayer, new GuiQuestLog(mc.thePlayer)); + NoppesUtil.openGUI(mc.thePlayer, new GuiQuestLog()); break; case 1: - NoppesUtil.openGUI(mc.thePlayer, new GuiParty(mc.thePlayer)); + NoppesUtil.openGUI(mc.thePlayer, new GuiParty()); break; case 2: NoppesUtil.openGUI(mc.thePlayer, new GuiFaction()); break; + case 3: + NoppesUtil.openGUI(mc.thePlayer, new GuiSettings()); + break; } } else if(mc.currentScreen instanceof GuiQuestLog) diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index a9e18ba53..a58e65aca 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -76,6 +76,9 @@ public class PacketHandlerClient extends PacketHandlerServer{ player.addChatMessage(new ChatComponentTranslation(npc.getCommandSenderName() + ": " + text)); } else if(type == EnumPacketClient.CHAT){ + if(!ConfigClient.ChatAlerts) + return; + String message = ""; String str; while((str = Server.readString(buffer)) != null && !str.isEmpty()) @@ -84,6 +87,9 @@ public class PacketHandlerClient extends PacketHandlerServer{ player.addChatMessage(new ChatComponentTranslation(message)); } else if(type == EnumPacketClient.MESSAGE || type == EnumPacketClient.PARTY_MESSAGE){ + if(!ConfigClient.BannerAlerts) + return; + String description = StatCollector.translateToLocal(Server.readString(buffer)); String message = Server.readString(buffer); Achievement ach = type == EnumPacketClient.MESSAGE ? new MessageAchievement(message, description) : new MessageAchievement(CustomItems.bag == null ? Items.paper : CustomItems.bag, message, description); diff --git a/src/main/java/noppes/npcs/client/gui/GuiNPCDialogSelection.java b/src/main/java/noppes/npcs/client/gui/GuiNPCDialogSelection.java deleted file mode 100644 index ad743701b..000000000 --- a/src/main/java/noppes/npcs/client/gui/GuiNPCDialogSelection.java +++ /dev/null @@ -1,119 +0,0 @@ -package noppes.npcs.client.gui; - -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import noppes.npcs.client.Client; -import noppes.npcs.client.NoppesUtil; -import noppes.npcs.client.gui.util.*; -import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.entity.EntityNPCInterface; - -import java.util.HashMap; -import java.util.Vector; - -public class GuiNPCDialogSelection extends GuiNPCInterface implements IScrollData -{ - private GuiNPCStringSlot slot; - private GuiScreen parent; - private HashMap data = new HashMap(); - private int dialog; - private boolean selectCategory = true; - public GuiSelectionListener listener; - public GuiNPCDialogSelection(EntityNPCInterface npc,GuiScreen parent,int dialog) - { - super(npc); - drawDefaultBackground = false; - title = "Select Dialog Category"; - this.parent = parent; - this.dialog = dialog; - - - if(dialog >= 0){ - Client.sendData(EnumPacketServer.DialogsGetFromDialog, dialog); - selectCategory = false; - title = "Select Dialog"; - }else - Client.sendData(EnumPacketServer.DialogCategoriesGet, dialog); - - if(parent instanceof GuiSelectionListener){ - listener = (GuiSelectionListener) parent; - } - } - - public void initGui() - { - super.initGui(); - Vector list = new Vector(); - - slot = new GuiNPCStringSlot(list,this,false,18); - slot.registerScrollButtons(4, 5); - - this.addButton(new GuiNpcButton(2, width / 2 -100, height - 41,98, 20, "gui.back")); - this.addButton(new GuiNpcButton(4, width / 2 + 2, height - 41,98, 20, "gui.select")); - } - - - public void drawScreen(int i, int j, float f) - { - slot.drawScreen(i, j, f); - super.drawScreen(i, j, f); - } - - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 2) - { - if(selectCategory){ - close(); - NoppesUtil.openGUI(player, parent); - }else{ - title = "Select Dialog Category"; - selectCategory = true; - Client.sendData(EnumPacketServer.DialogCategoriesGet, dialog); - } - } - if(id == 4) - { - doubleClicked(); - } - } - public void doubleClicked() { - if(slot.selected == null || slot.selected.isEmpty()) - return; - if(selectCategory){ - selectCategory = false; - title = "Select Dialog"; - Client.sendData(EnumPacketServer.DialogsGet, data.get(slot.selected)); - } - else{ - dialog = data.get(slot.selected); - close(); - NoppesUtil.openGUI(player, parent); - } - - } - public void save() { - if(dialog >= 0){ - if(listener != null) - listener.selected(dialog, slot.selected); - } - } - - @Override - public void setData(Vector list, HashMap data) { - this.data = data; - this.slot.setList(list); - if(dialog >= 0) - for(String name : data.keySet()) - if(data.get(name) == dialog) - slot.selected = name; - } - - @Override - public void setSelected(String selected) { - - } - - -} diff --git a/src/main/java/noppes/npcs/client/gui/GuiNPCTextures.java b/src/main/java/noppes/npcs/client/gui/GuiNPCTextures.java deleted file mode 100644 index e018ea074..000000000 --- a/src/main/java/noppes/npcs/client/gui/GuiNPCTextures.java +++ /dev/null @@ -1,92 +0,0 @@ -package noppes.npcs.client.gui; - -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.RenderManager; -import noppes.npcs.entity.EntityNPCInterface; -import org.lwjgl.opengl.GL11; - -public class GuiNPCTextures extends GuiNpcSelectionInterface -{ - public GuiNPCTextures(EntityNPCInterface npc,GuiScreen parent) - { - super(npc, parent, npc.display.texture); - title = "Select Texture"; - this.parent = parent; - } - - public void initGui() - { - super.initGui(); - int index = npc.display.texture.lastIndexOf("/"); - if(index > 0){ - String asset = npc.display.texture.substring(index + 1); - if(npc.display.texture.equals(assets.getAsset(asset))) - slot.selected = asset; - } - } - - - public void drawScreen(int i, int j, float f) - { - npc.isDrawn = true; - int l = (width/2)-180; - int i1 = (height/2) - 90; - GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); - GL11.glEnable(2903 /*GL_COLOR_MATERIAL*/); - GL11.glPushMatrix(); - GL11.glTranslatef(l + 33, i1 + 131, 50F); - float f1 = (50F * 5) / npc.display.modelSize; - GL11.glScalef(-f1, f1, f1); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - float f2 = npc.renderYawOffset; - float f3 = npc.rotationYaw; - float f4 = npc.rotationPitch; - float f7 = npc.rotationYawHead; - float f5 = (float)(l + 33) - i; - float f6 = (float)((i1 + 131) - 50) - j; - GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); - RenderHelper.enableStandardItemLighting(); - GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-(float)Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); - npc.renderYawOffset = (float)Math.atan(f5 / 40F) * 20F; - npc.rotationYaw = (float)Math.atan(f5 / 40F) * 40F; - npc.rotationPitch = -(float)Math.atan(f6 / 40F) * 20F; - npc.rotationYawHead = npc.rotationYaw; - npc.cloakUpdate(); - GL11.glTranslatef(0.0F, npc.yOffset, 0.0F); - RenderManager.instance.playerViewY = 180F; - RenderManager.instance.renderEntityWithPosYaw(npc, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); - npc.renderYawOffset = f2; - npc.rotationYaw = f3; - npc.rotationPitch = f4; - npc.rotationYawHead = f7; - npc.isDrawn = false; - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(32826 /*GL_RESCALE_NORMAL_EXT*/); - - OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GL11.glDisable(GL11.GL_TEXTURE_2D); - OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - - super.drawScreen(i, j, f); - } - @Override - public void elementClicked(){ - if(dataTextures.contains(slot.selected) && slot.selected != null){ - npc.display.texture = assets.getAsset(slot.selected); - npc.textureLocation = null; - } - } - public void save() { - } - - @Override - public String[] getExtension() { - return new String[]{"png"}; - } - - -} diff --git a/src/main/java/noppes/npcs/client/gui/OverlayQuestTracking.java b/src/main/java/noppes/npcs/client/gui/OverlayQuestTracking.java index 90a46fbe5..33818aeff 100644 --- a/src/main/java/noppes/npcs/client/gui/OverlayQuestTracking.java +++ b/src/main/java/noppes/npcs/client/gui/OverlayQuestTracking.java @@ -122,6 +122,9 @@ public class OverlayQuestTracking extends Gui { boolean completed = false; try { + if(split.length < 2) + throw new NumberFormatException("catch"); + int killed = Integer.parseInt(split[0].trim()); int total = Integer.parseInt(split[1].trim()); @@ -129,7 +132,7 @@ public class OverlayQuestTracking extends Gui { completed = true; } } catch (NumberFormatException e) { - if (objective.endsWith("(read)") || (objective.endsWith("Found") && !objective.endsWith("Not Found"))) { + if (objective.endsWith("(Done)") || objective.endsWith("(read)") || (objective.endsWith("Found") && !objective.endsWith("Not Found"))) { completed = true; } } @@ -177,61 +180,87 @@ public class OverlayQuestTracking extends Gui { public void renderGameOverlay(float partialTicks){ res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - scaledWidth = res.getScaledWidth(); - scaledHeight = res.getScaledHeight(); + + float overallScale = (float) ConfigClient.TrackingScale / 100; + + scaledWidth = (int) (res.getScaledWidth()); + scaledHeight = (int) (res.getScaledHeight()); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glPushMatrix(); - GL11.glTranslatef(ConfigClient.TrackingInfoAlignment%3*((float)(scaledWidth)/2), (float) (Math.floor((float)(ConfigClient.TrackingInfoAlignment/3))*((float)(scaledHeight)/2)),0.0F); + GL11.glTranslatef(ConfigClient.TrackingInfoAlignment%3*((float)(scaledWidth)/2), (float) (Math.floor((float)(ConfigClient.TrackingInfoAlignment/3))*((float)(scaledHeight)/2)),0.0F); - float offsetX = ConfigClient.TrackingInfoAlignment%3 == 0 ? 5 : -5; - GL11.glTranslatef(ConfigClient.TrackingInfoX + offsetX, ConfigClient.TrackingInfoY, 0.0F); + float offsetX = ConfigClient.TrackingInfoAlignment%3 == 0 ? 5 : -5; - red = (color >> 16 & 255) / 255f; - green = (color >> 8 & 255) / 255f; - blue = (color & 255) / 255f; + float offsetY = ConfigClient.TrackingInfoAlignment < 3 ? 5 : 0; + offsetY = ConfigClient.TrackingInfoAlignment > 5 ? -5 : offsetY; - float centerX = -60; - centerX *= ConfigClient.TrackingInfoAlignment%3 == 0 ? -1 : 1; + GL11.glTranslatef(ConfigClient.TrackingInfoX + offsetX, ConfigClient.TrackingInfoY + offsetY, 0.0F); - float questTitleTop; - this.renderOffsetY = -40; - GL11.glPushMatrix(); - GL11.glTranslatef(centerX, 0.0F, 0.0F); - this.renderStringLines(trackedQuestLines,1.2F, false, true, 0); - GL11.glPopMatrix(); - questTitleTop = this.renderOffsetY; - this.renderOffsetY -= 10; - GL11.glPushMatrix(); - GL11.glTranslatef(centerX, 0.0F, 0.0F); - this.renderStringLines(categoryNameLines,0.85F, false, false, 0); - GL11.glPopMatrix(); + red = (color >> 16 & 255) / 255f; + green = (color >> 8 & 255) / 255f; + blue = (color & 255) / 255f; - this.renderOffsetY = -10; - GL11.glPushMatrix(); - this.renderStringLines(objectiveLines,1F, true, false, ConfigClient.TrackingInfoAlignment%3 == 0 ? 1 : 2); - GL11.glPopMatrix(); + float centerX = (float) -overlayWidth /2 * overallScale; + if (ConfigClient.TrackingInfoAlignment % 3 == 1) { // For Center alignment + centerX = 0; + } else { + centerX *= ConfigClient.TrackingInfoAlignment % 3 == 0 ? -1 : 1; + } - this.renderOffsetY += 10; - GL11.glPushMatrix(); - this.renderStringLines(turnInText,1F, false, false, ConfigClient.TrackingInfoAlignment%3 == 0 ? 1 : 2); - GL11.glPopMatrix(); + float questTitleTop; + this.renderOffsetY = -40 * overallScale; + GL11.glPushMatrix(); + GL11.glTranslatef(centerX, 0.0F, 0.0F); + this.renderStringLines(trackedQuestLines,1.2F * overallScale, false, true, 0); + GL11.glPopMatrix(); + questTitleTop = this.renderOffsetY; + this.renderOffsetY -= 10 * overallScale; + GL11.glPushMatrix(); + GL11.glTranslatef(centerX, 0.0F, 0.0F); + this.renderStringLines(categoryNameLines,0.85F * overallScale, false, false, 0); + GL11.glPopMatrix(); - this.renderOffsetY = -20; - GL11.glPushMatrix(); - this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY+2), 0xFF777777); - this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY+1), 0xFFA8A8A8); - this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY), 0xFFFFFFFF); - GL11.glPopMatrix(); - this.renderOffsetY = questTitleTop + 2; - GL11.glPushMatrix(); - this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY), 0xFFFFFFFF); - this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY-1), 0xFFA8A8A8); - this.drawHorizontalLine((int)(-overlayWidth/2 + centerX), (int)(overlayWidth/2 + centerX), (int) (this.renderOffsetY-2), 0xFF777777); - GL11.glPopMatrix(); + this.renderOffsetY = -10 * overallScale; + GL11.glPushMatrix(); + this.renderStringLines(objectiveLines, 1F * overallScale, true, false, ConfigClient.TrackingInfoAlignment % 3 == 0 ? 1 : (ConfigClient.TrackingInfoAlignment % 3 == 2 ? 2 : 0)); + GL11.glPopMatrix(); + + this.renderOffsetY += 10 * overallScale; + GL11.glPushMatrix(); + this.renderStringLines(turnInText, 1F * overallScale, true, false, ConfigClient.TrackingInfoAlignment % 3 == 0 ? 1 : (ConfigClient.TrackingInfoAlignment % 3 == 2 ? 2 : 0)); + GL11.glPopMatrix(); + + this.renderOffsetY = -20 * overallScale; + GL11.glPushMatrix(); + if(overallScale < 0.6){ + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY)), 0xFFFFFFFF); + } else if (overallScale < 0.8){ + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY)), 0xFFA8A8A8); + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY + 1)), 0xFFFFFFFF); + } else { + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) (this.renderOffsetY), 0xFF777777); + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY + 1)), 0xFFA8A8A8); + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY + 2)), 0xFFFFFFFF); + } + GL11.glPopMatrix(); + this.renderOffsetY = questTitleTop + 2; + GL11.glPushMatrix(); + + if(overallScale < 0.6){ + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) (this.renderOffsetY - 2), 0xFFFFFFFF); + } else if (overallScale < 0.8){ + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY)), 0xFFA8A8A8); + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) (this.renderOffsetY - 1), 0xFFFFFFFF); + } else { + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY)), 0xFF777777); + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY -1)), 0xFFA8A8A8); + this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) (this.renderOffsetY - 2), 0xFFFFFFFF); + } + GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -251,6 +280,8 @@ public class OverlayQuestTracking extends Gui { stringWidth = this.fontRenderer.getStringWidth(s.replace("&a&o&m","")); } + float overallScale = (float) ConfigClient.TrackingScale / 100; + GL11.glPushMatrix(); switch (facing) { case 0://center @@ -270,7 +301,7 @@ public class OverlayQuestTracking extends Gui { GL11.glTranslatef(0.2F, 0.2F, 0.0F); this.drawString(s, 0, 0, this.color, false); } - this.renderOffsetY += downwards ? 10 : -10; + this.renderOffsetY += (downwards ? 10 : -10) * overallScale; GL11.glPopMatrix(); } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java b/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java index 097063ed8..fe72e3f8e 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java @@ -4,19 +4,17 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; -import noppes.npcs.client.NoppesUtil; -import noppes.npcs.client.gui.global.GuiNPCQuestSelection; import noppes.npcs.client.gui.player.GuiMailmanWrite; +import noppes.npcs.client.gui.select.GuiQuestSelection; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.containers.ContainerMail; import noppes.npcs.controllers.data.PlayerMail; public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener{ - + private PlayerMail mail; - private GuiNPCQuestSelection questSelection; - + public SubGuiMailmanSendSetup(PlayerMail mail, GuiScreen parent){ this.parent = parent; xSize = 256; @@ -40,10 +38,10 @@ public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfiel title = "gui.select"; addButton(new GuiNpcButton(3, guiLeft + 70, guiTop + 130, 100, 20, title)); addButton(new GuiNpcButton(4, guiLeft + 171, guiTop + 130, 20, 20, "X")); - + addButton(new GuiNpcButton(0, guiLeft + 26, guiTop + 190, 100, 20, "gui.done")); addButton(new GuiNpcButton(1, guiLeft + 130, guiTop + 190, 100, 20, "gui.cancel")); - + if(player.openContainer instanceof ContainerMail){ ContainerMail container = (ContainerMail) player.openContainer; mail.items = container.mail.items; @@ -68,9 +66,7 @@ public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfiel Client.sendData(EnumPacketServer.MailOpenSetup, mail.writeNBT()); } if(id == 3){ - questSelection = new GuiNPCQuestSelection(npc, getParent(), mail.questId); - questSelection.listener = this; - NoppesUtil.openGUI(player, questSelection); + setSubGui(new GuiQuestSelection(mail.questId)); } if(id == 4){ mail.questId = -1; @@ -81,13 +77,13 @@ public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfiel @Override public void selected(int ob, String name) { - mail.questId = ob; - mail.questTitle = questSelection.getSelected(); + mail.questId = ob; + mail.questTitle = name; initGui(); } @Override public void save() { - + } @Override diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java index 2ba36e16d..65ca11e53 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java @@ -3,7 +3,7 @@ package noppes.npcs.client.gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; -import noppes.npcs.client.NoppesUtil; +import noppes.npcs.client.gui.select.GuiDialogSelection; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumAvailabilityDialog; import noppes.npcs.constants.EnumPacketServer; @@ -13,7 +13,7 @@ import noppes.npcs.controllers.data.Dialog; public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiSelectionListener, IGuiData{ private Availability availabitily; private int slot = 0; - + public SubGuiNpcAvailabilityDialog(Availability availabitily){ this.availabitily = availabitily; setBackground("menubg.png"); @@ -51,10 +51,10 @@ public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiS this.addButton(new GuiNpcButton(13, guiLeft + 56, y, 172, 20, "availability.selectdialog")); getButton(13).setEnabled(availabitily.dialog4Available != EnumAvailabilityDialog.Always); this.addButton(new GuiNpcButton(23, guiLeft + 230, y,20, 20, "X")); - - + + this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done")); - + updateGuiButtons(); } @@ -64,7 +64,7 @@ public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiS getButton(11).setDisplayText("availability.selectdialog"); getButton(12).setDisplayText("availability.selectdialog"); getButton(13).setDisplayText("availability.selectdialog"); - + if(availabitily.dialogId >= 0){ Client.sendData(EnumPacketServer.DialogGet, availabitily.dialogId); } @@ -109,27 +109,19 @@ public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiS } if(button.id == 10){ slot = 1; - GuiNPCDialogSelection gui = new GuiNPCDialogSelection(npc, getParent(), availabitily.dialogId); - gui.listener = this; - NoppesUtil.openGUI(player, gui); + setSubGui(new GuiDialogSelection(availabitily.questId)); } if(button.id == 11){ slot = 2; - GuiNPCDialogSelection gui = new GuiNPCDialogSelection(npc, getParent(), availabitily.dialog2Id); - gui.listener = this; - NoppesUtil.openGUI(player, gui); + setSubGui(new GuiDialogSelection(availabitily.quest2Id)); } if(button.id == 12){ slot = 3; - GuiNPCDialogSelection gui = new GuiNPCDialogSelection(npc, getParent(), availabitily.dialog3Id); - gui.listener = this; - NoppesUtil.openGUI(player, gui); + setSubGui(new GuiDialogSelection(availabitily.quest3Id)); } if(button.id == 13){ slot = 4; - GuiNPCDialogSelection gui = new GuiNPCDialogSelection(npc, getParent(), availabitily.dialog4Id); - gui.listener = this; - NoppesUtil.openGUI(player, gui); + setSubGui(new GuiDialogSelection(availabitily.quest4Id)); } if(button.id == 20){ availabitily.dialogId = -1; @@ -147,7 +139,6 @@ public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiS availabitily.dialog4Id = -1; getButton(13).setDisplayText("availability.selectdialog"); } - if(button.id == 66){ close(); } @@ -163,7 +154,8 @@ public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiS availabitily.dialog3Id = id; if(slot == 4) availabitily.dialog4Id = id; - } + updateGuiButtons(); + } @Override public void setGuiData(NBTTagCompound compound) { @@ -178,5 +170,4 @@ public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiS if(availabitily.dialog4Id == dialog.id) getButton(13).setDisplayText(dialog.title); } - } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java index bdb2e1d8b..f8910438b 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java @@ -3,8 +3,8 @@ package noppes.npcs.client.gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; -import noppes.npcs.client.NoppesUtil; -import noppes.npcs.client.gui.global.GuiNPCQuestSelection; + +import noppes.npcs.client.gui.select.GuiQuestSelection; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumAvailabilityQuest; import noppes.npcs.constants.EnumPacketServer; @@ -14,7 +14,7 @@ import noppes.npcs.controllers.data.Quest; public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSelectionListener, IGuiData { private Availability availabitily; private int slot = 0; - + public SubGuiNpcAvailabilityQuest(Availability availabitily){ this.availabitily = availabitily; setBackground("menubg.png"); @@ -29,7 +29,7 @@ public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSe addLabel(new GuiNpcLabel(1,"availability.available", guiLeft, guiTop + 4)); getLabel(1).center(xSize); - int y = guiTop + 12; + int y = guiTop + 12; this.addButton(new GuiNpcButton(0, guiLeft + 4, y, 90, 20, new String[]{"availability.always","availability.after","availability.before","availability.whenactive", "availability.whennotactive"},availabitily.questAvailable.ordinal())); this.addButton(new GuiNpcButton(10, guiLeft + 96, y, 192, 20, "availability.selectquest")); getButton(10).setEnabled(availabitily.questAvailable != EnumAvailabilityQuest.Always); @@ -52,10 +52,10 @@ public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSe this.addButton(new GuiNpcButton(13, guiLeft + 96, y, 192, 20, "availability.selectquest")); getButton(13).setEnabled(availabitily.quest4Available != EnumAvailabilityQuest.Always); this.addButton(new GuiNpcButton(23, guiLeft + 290, y, 20, 20, "X")); - - + + this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done")); - + updateGuiButtons(); } @@ -110,27 +110,19 @@ public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSe } if(button.id == 10){ slot = 1; - GuiNPCQuestSelection gui = new GuiNPCQuestSelection(npc, getParent(), availabitily.questId); - gui.listener = this; - NoppesUtil.openGUI(player, gui); + setSubGui(new GuiQuestSelection(availabitily.questId)); } if(button.id == 11){ slot = 2; - GuiNPCQuestSelection gui = new GuiNPCQuestSelection(npc, getParent(), availabitily.quest2Id); - gui.listener = this; - NoppesUtil.openGUI(player, gui); + setSubGui(new GuiQuestSelection(availabitily.quest2Id)); } if(button.id == 12){ slot = 3; - GuiNPCQuestSelection gui = new GuiNPCQuestSelection(npc, getParent(), availabitily.quest3Id); - gui.listener = this; - NoppesUtil.openGUI(player, gui); + setSubGui(new GuiQuestSelection(availabitily.quest3Id)); } if(button.id == 13){ slot = 4; - GuiNPCQuestSelection gui = new GuiNPCQuestSelection(npc, getParent(), availabitily.quest4Id); - gui.listener = this; - NoppesUtil.openGUI(player, gui); + setSubGui(new GuiQuestSelection(availabitily.quest4Id)); } if(button.id == 20){ @@ -165,6 +157,7 @@ public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSe availabitily.quest3Id = id; if(slot == 4) availabitily.quest4Id = id; + updateGuiButtons(); } @Override @@ -179,7 +172,7 @@ public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSe getButton(12).setDisplayText(quest.title); if(availabitily.quest4Id == quest.id) getButton(13).setDisplayText(quest.title); - + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcCommand.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcCommand.java index 892856c0e..9e6df6db5 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcCommand.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcCommand.java @@ -6,7 +6,7 @@ import noppes.npcs.client.gui.util.*; public class SubGuiNpcCommand extends SubGuiInterface implements ITextfieldListener { public String command; - + public SubGuiNpcCommand(String command) { this.command = command; @@ -19,17 +19,18 @@ public class SubGuiNpcCommand extends SubGuiInterface implements ITextfieldListe public void initGui() { super.initGui(); - this.addTextField(new GuiNpcTextField(4, this, this.fontRendererObj, guiLeft + 4, guiTop + 84, 248, 20, command)); + this.addLabel(new GuiNpcLabel(4, "advMode.command", guiLeft + 4, guiTop + 74)); + this.addTextField(new GuiNpcTextField(4, this, this.fontRendererObj, guiLeft + 4, guiTop + 84, 248, 20, command)); this.getTextField(4).setMaxStringLength(32767); - this.addLabel(new GuiNpcLabel(4, "advMode.command", guiLeft + 4, guiTop + 110)); - this.addLabel(new GuiNpcLabel(5, "advMode.nearestPlayer", guiLeft + 4, guiTop + 125)); - this.addLabel(new GuiNpcLabel(6, "advMode.randomPlayer", guiLeft + 4, guiTop + 140)); - this.addLabel(new GuiNpcLabel(7, "advMode.allPlayers", guiLeft + 4, guiTop + 155)); - this.addLabel(new GuiNpcLabel(8, "dialog.commandoptionplayer", guiLeft + 4, guiTop + 170)); + this.addLabel(new GuiNpcLabel(5, "advMode.nearestPlayer", guiLeft + 4, guiTop + 110)); + this.addLabel(new GuiNpcLabel(6, "advMode.randomPlayer", guiLeft + 4, guiTop + 125)); + this.addLabel(new GuiNpcLabel(7, "advMode.allPlayers", guiLeft + 4, guiTop + 140)); + this.addLabel(new GuiNpcLabel(8, "dialog.commandoptionplayer", guiLeft + 4, guiTop + 155)); + this.addLabel(new GuiNpcLabel(9, "dialog.commandmultiple", guiLeft + 4, guiTop + 170)); this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190,98, 20, "gui.done")); - + } protected void actionPerformed(GuiButton guibutton) diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialog.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialog.java index a1dd989da..cb625cbbb 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialog.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialog.java @@ -1,24 +1,30 @@ package noppes.npcs.client.gui; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.CustomNpcs; +import noppes.npcs.NoppesUtilServer; +import noppes.npcs.Server; import noppes.npcs.client.Client; +import noppes.npcs.client.EntityUtil; import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.global.GuiNPCManageDialogs; -import noppes.npcs.client.gui.global.GuiNPCQuestSelection; +import noppes.npcs.client.gui.player.GuiDialogInteract; +import noppes.npcs.client.gui.select.GuiQuestSelection; import noppes.npcs.client.gui.select.GuiSoundSelection; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogOption; import noppes.npcs.controllers.data.PlayerMail; +import noppes.npcs.entity.EntityDialogNpc; public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener, GuiSelectionListener,ITextfieldListener { - public int dialogCategoryID; public Dialog dialog; private final GuiNPCManageDialogs parent; - private GuiNPCQuestSelection questSelection; public SubGuiNpcDialog(GuiNPCManageDialogs parent, Dialog dialog, int catId) { @@ -72,6 +78,7 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener, addLabel(new GuiNpcLabel(15, "dialog.disableEsc", guiLeft + 180, guiTop + 154 + 5)); addButton(new GuiNpcButton(16, guiLeft + 303, guiTop + 192, 50, 20, "gui.done")); + addButton(new GuiNpcButton(17, guiLeft + 303 - 55, guiTop + 192, 50, 20, "gui.test")); if(!parent.dialogQuestName.equals("")) getButton(7).setDisplayText(parent.dialogQuestName); @@ -96,9 +103,7 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener, setSubGui(new SubGuiNpcDialogOptions(dialog)); } if(id == 7 && dialog.id >= 0){ - questSelection = new GuiNPCQuestSelection(npc, getParent(), dialog.quest); - questSelection.listener = this; - NoppesUtil.openGUI(player, questSelection); + setSubGui(new GuiQuestSelection(dialog.quest)); } if(id == 8 && dialog.id >= 0){ dialog.quest = -1; @@ -129,6 +134,13 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener, if(id == 16){ close(); } + if(id == 17){ + EntityDialogNpc npc = new EntityDialogNpc(player.worldObj); + npc.display.name = "TEST"; + EntityUtil.Copy(player, npc); + GuiDialogInteract gui = new GuiDialogInteract(getParent(), npc, dialog); + NoppesUtil.openGUI(player, gui); + } } @Override @@ -164,6 +176,13 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener, else if(subgui instanceof SubGuiNpcCommand){ dialog.command = ((SubGuiNpcCommand) subgui).command; } + else if(subgui instanceof GuiQuestSelection){ + GuiQuestSelection gqs = (GuiQuestSelection) subgui; + if(gqs.selectedQuest != null) { + dialog.quest = gqs.selectedQuest.id; + initGui(); + } + } else if(subgui instanceof SubGuiMailmanSendSetup){ initGui(); } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java index d28d5f93d..f5d325102 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java @@ -4,6 +4,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; import noppes.npcs.client.NoppesUtil; +import noppes.npcs.client.gui.select.GuiDialogSelection; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumOptionType; import noppes.npcs.constants.EnumPacketServer; @@ -13,7 +14,7 @@ import noppes.npcs.controllers.data.DialogOption; public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData, ITextfieldListener, GuiSelectionListener, ISubGuiListener{ private DialogOption option; public static int LastColor = 0xe0e0e0; - + public SubGuiNpcDialogOption(DialogOption option){ this.option = option; setBackground("menubg.png"); @@ -27,17 +28,17 @@ public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData, super.initGui(); this.addLabel(new GuiNpcLabel(66, "dialog.editoption", guiLeft, guiTop + 4)); this.getLabel(66).center(xSize); - + this.addLabel(new GuiNpcLabel(0, "gui.title", guiLeft + 4, guiTop + 20)); this.addTextField(new GuiNpcTextField(0, this, this.fontRendererObj, guiLeft + 40, guiTop + 15, 196, 20, option.title)); - + String color = Integer.toHexString(option.optionColor); while(color.length() < 6) color = 0 + color; addLabel(new GuiNpcLabel(2, "gui.color", guiLeft + 4, guiTop + 45)); this.addButton(new GuiNpcButton(2, guiLeft + 62, guiTop + 40, 92, 20, color)); this.getButton(2).setTextColor(option.optionColor); - + this.addLabel(new GuiNpcLabel(1, "dialog.optiontype", guiLeft + 4, guiTop + 67)); this.addButton(new GuiNpcButton(1, guiLeft + 62, guiTop + 62, 92, 20, new String[]{"gui.close","dialog.dialog","gui.disabled","menu.role","tile.commandBlock.name"},option.optionType.ordinal())); @@ -50,15 +51,15 @@ public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData, this.addTextField(new GuiNpcTextField(4, this, this.fontRendererObj, guiLeft + 4, guiTop + 84, 248, 20, option.command)); this.getTextField(4).setMaxStringLength(32767); - this.addLabel(new GuiNpcLabel(4, "advMode.command", guiLeft + 4, guiTop + 110)); - this.addLabel(new GuiNpcLabel(5, "advMode.nearestPlayer", guiLeft + 4, guiTop + 125)); - this.addLabel(new GuiNpcLabel(6, "advMode.randomPlayer", guiLeft + 4, guiTop + 140)); - this.addLabel(new GuiNpcLabel(7, "advMode.allPlayers", guiLeft + 4, guiTop + 155)); - this.addLabel(new GuiNpcLabel(8, "dialog.commandoptionplayer", guiLeft + 4, guiTop + 170)); + this.addLabel(new GuiNpcLabel(5, "advMode.nearestPlayer", guiLeft + 4, guiTop + 110)); + this.addLabel(new GuiNpcLabel(6, "advMode.randomPlayer", guiLeft + 4, guiTop + 125)); + this.addLabel(new GuiNpcLabel(7, "advMode.allPlayers", guiLeft + 4, guiTop + 140)); + this.addLabel(new GuiNpcLabel(8, "dialog.commandoptionplayer", guiLeft + 4, guiTop + 155)); + this.addLabel(new GuiNpcLabel(9, "dialog.commandmultiple", guiLeft + 4, guiTop + 170)); } this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190,98, 20, "gui.done")); - + } @Override @@ -73,9 +74,7 @@ public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData, this.setSubGui(new SubGuiColorSelector(option.optionColor)); } if(button.id == 3){ - GuiNPCDialogSelection gui = new GuiNPCDialogSelection(npc, getParent(), option.dialogId); - gui.listener = this; - NoppesUtil.openGUI(player, gui); + setSubGui(new GuiDialogSelection(option.dialogId)); } if(button.id == 66) { @@ -115,8 +114,16 @@ public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData, @Override public void subGuiClosed(SubGuiInterface subgui) { - LastColor = option.optionColor = ((SubGuiColorSelector)subgui).color; - initGui(); + if(subgui instanceof SubGuiColorSelector) { + LastColor = option.optionColor = ((SubGuiColorSelector)subgui).color; + } + if(subgui instanceof GuiDialogSelection) { + Dialog dialog = ((GuiDialogSelection)subgui).selectedDialog; + if(dialog != null) { + option.dialogId = dialog.id; + } + } + initGui(); } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcQuest.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcQuest.java index 7c11c716a..482b04217 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcQuest.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcQuest.java @@ -3,12 +3,11 @@ package noppes.npcs.client.gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; -import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.global.GuiNPCManageQuest; -import noppes.npcs.client.gui.global.GuiNPCQuestSelection; import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeDialog; import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeKill; import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeLocation; +import noppes.npcs.client.gui.select.GuiQuestSelection; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.*; import noppes.npcs.controllers.data.PlayerMail; @@ -21,7 +20,6 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener, public Quest quest; private final GuiNPCManageQuest parent; private boolean questlogTA = false; - private GuiNPCQuestSelection questSelection; public SubGuiNpcQuest(GuiNPCManageQuest parent, Quest quest, int catId) { @@ -52,8 +50,6 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener, addLabel(new GuiNpcLabel(5, "quest.reward", guiLeft + 7, guiTop + 81)); addButton(new GuiNpcButton(5, guiLeft + 120, guiTop + 76, 50, 20, "selectServer.edit")); - - addLabel(new GuiNpcLabel(10, "faction.options", guiLeft + 180, guiTop + 33)); addButton(new GuiNpcButton(10, guiLeft + 303, guiTop + 28, 50, 20, "selectServer.edit")); @@ -155,9 +151,10 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener, initGui(); } if(button.id == 15 && quest.id >= 0){ - questSelection = new GuiNPCQuestSelection(npc, getParent(), quest.nextQuestid); - questSelection.listener = this; - NoppesUtil.openGUI(player, questSelection); + setSubGui(new GuiQuestSelection(quest.nextQuestid)); +// questSelection = new GuiNPCQuestSelection(npc, getParent(), quest.nextQuestid); +// questSelection.listener = this; +// NoppesUtil.openGUI(player, questSelection); } if(button.id == 18) { @@ -206,7 +203,7 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener, SubGuiNpcCommand sub = (SubGuiNpcCommand) subgui; quest.command = sub.command; } - else if(subgui instanceof SubGuiMailmanSendSetup){ + else { initGui(); } } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java index e242b27e2..b0a0a865b 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java @@ -5,16 +5,18 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; import noppes.npcs.client.NoppesUtil; -import noppes.npcs.client.gui.GuiNPCDialogSelection; +import noppes.npcs.client.gui.SubGuiColorSelector; +import noppes.npcs.client.gui.select.GuiDialogSelection; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPacketServer; +import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.data.DialogOption; import noppes.npcs.entity.EntityNPCInterface; import java.util.HashMap; -public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelectionListener,IGuiData{ +public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelectionListener, IGuiData{ private GuiScreen parent; private HashMap data = new HashMap(); @@ -31,7 +33,7 @@ public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelec int offset = i >=6 ?200:0; this.addButton(new GuiNpcButton(i + 20, guiLeft + 20 + offset, guiTop + 13 + i % 6 * 22, 20, 20, "X")); this.addLabel(new GuiNpcLabel(i, "" + i, guiLeft + 6 + offset, guiTop + 18 + i % 6 * 22)); - + String title = "dialog.selectoption"; if(data.containsKey(i)) title = data.get(i).title; @@ -46,17 +48,12 @@ public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelec private int selectedSlot; protected void actionPerformed(GuiButton guibutton) { int id = guibutton.id; - - if (id == 1) { - NoppesUtil.openGUI(player, parent); - } if (id >= 0 && id < 20) { - close(); selectedSlot = id; int dialogID = -1; if(data.containsKey(id)) dialogID = data.get(id).dialogId; - NoppesUtil.openGUI(player, new GuiNPCDialogSelection(npc, this, dialogID)); + setSubGui(new GuiDialogSelection(dialogID)); } if (id >= 20 && id < 40) { int slot = id - 20; @@ -79,12 +76,11 @@ public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelec @Override public void setGuiData(NBTTagCompound compound) { int pos = compound.getInteger("Position"); - + DialogOption dialog = new DialogOption(); dialog.readNBT(compound); - + data.put(pos, dialog); initGui(); } - } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiSlot.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiSlot.java index 34748b77c..1659720ad 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiSlot.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiSlot.java @@ -8,7 +8,11 @@ package noppes.npcs.client.gui.custom.components; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import noppes.npcs.EventHooks; +import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.gui.IItemSlot; +import noppes.npcs.containers.ContainerCustomGui; +import noppes.npcs.scripted.NpcAPI; public class CustomGuiSlot extends Slot { public boolean clientSide; @@ -23,4 +27,26 @@ public class CustomGuiSlot extends Slot { this.slot = slot; this.player = player; } + + @Override + public void onSlotChanged() { + if(!player.worldObj.isRemote){ + boolean changed; + if (getStack() != null && slot.getStack() != null) { + changed = !getStack().equals(slot.getStack().getMCItemStack()); + } else { + // Handle the case when either getStack() or slot.getStack() is null (indicating an empty slot) + changed = getStack() != null || slot.getStack() != null; + } + if(changed) { + slot.setStack(NpcAPI.Instance().getIItemStack(getStack())); + if (player.openContainer instanceof ContainerCustomGui) { + EventHooks.onCustomGuiSlot((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, + getSlotIndex(), getStack(), slot); + } + } + } + super.onSlotChanged(); + } + } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java index cab63a372..4d8502a8b 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java @@ -89,10 +89,10 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent { tessellator.startDrawingQuads(); tessellator.setColorOpaque_F(1, 1, 1); tessellator.setColorRGBA_F(red, green, blue, alpha); - tessellator.addVertexWithUV(u2 * totalWidth, v2 * totalHeight, 0, u2, v2); - tessellator.addVertexWithUV(u2 * totalWidth, v1 * totalHeight, 0, u2, v1); - tessellator.addVertexWithUV(u1 * totalWidth, v1 * totalHeight, 0, u1, v1); - tessellator.addVertexWithUV(u1 * totalWidth, v2 * totalHeight, 0, u1, v2); + tessellator.addVertexWithUV(0, height, 0, u1, v2); + tessellator.addVertexWithUV(width, height, 0, u2, v2); + tessellator.addVertexWithUV(width, 0, 0, u2, v1); + tessellator.addVertexWithUV(0, 0, 0, u1, v1); tessellator.draw(); GL11.glPopMatrix(); } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java index 5e61e605e..0954a8d8d 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java @@ -187,7 +187,6 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou if(category != null && category.id >= 0){ // Add Dialog if(id == 1){ - saveType(true); String name = "New"; while(dialogData.containsKey(name)) name += "_"; @@ -201,7 +200,6 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou } // Remove Dialog if(id == 2) { - saveType(true); if (dialogData.containsKey(dialogScroll.getSelected())) { Client.sendData(EnumPacketServer.DialogRemove, dialog.id, true); dialog = new Dialog(); @@ -210,14 +208,12 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou } // Edit Dialog if(id == 0) { - saveType(true); if (dialogData.containsKey(dialogScroll.getSelected()) && dialog != null && dialog.id >= 0) { setSubGui(new SubGuiNpcDialog(this, dialog, category.id)); } } // Clone Dialog if(id == 3) { - saveType(true); if (dialogData.containsKey(dialogScroll.getSelected()) && dialog != null && dialog.id >= 0) { String name = dialog.title; while(dialogData.containsKey(name)) diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java index 0b3ec4ce5..5343f3665 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java @@ -191,7 +191,6 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup, if(category != null && category.id >= 0){ // Add Quest if(id == 1){ - saveType(true); String name = "New"; while(questData.containsKey(name)) name += "_"; @@ -205,7 +204,6 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup, } // Remove Quest if(id == 2) { - saveType(true); if (questData.containsKey(questScroll.getSelected())) { Client.sendData(EnumPacketServer.QuestRemove, quest.id, true); quest = new Quest(); @@ -214,14 +212,12 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup, } // Edit Quest if(id == 0) { - saveType(true); if (questData.containsKey(questScroll.getSelected()) && quest != null && quest.id >= 0) { setSubGui(new SubGuiNpcQuest(this, quest, category.id)); } } // Clone Quest if(id == 3) { - saveType(true); if (questData.containsKey(questScroll.getSelected()) && quest != null && quest.id >= 0) { String name = quest.title; while(questData.containsKey(name)) diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCQuestSelection.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCQuestSelection.java deleted file mode 100644 index e10014473..000000000 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCQuestSelection.java +++ /dev/null @@ -1,125 +0,0 @@ -package noppes.npcs.client.gui.global; - -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import noppes.npcs.client.Client; -import noppes.npcs.client.NoppesUtil; -import noppes.npcs.client.gui.util.*; -import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.entity.EntityNPCInterface; - -import java.util.HashMap; -import java.util.Vector; - -public class GuiNPCQuestSelection extends GuiNPCInterface implements IScrollData -{ - private GuiNPCStringSlot slot; - private GuiScreen parent; - private HashMap data = new HashMap(); - private int quest; - private boolean selectCategory = true; - public GuiSelectionListener listener; - - - public GuiNPCQuestSelection(EntityNPCInterface npc, GuiScreen parent, int quest) - { - super(npc); - drawDefaultBackground = false; - title = "Select Quest Category"; - this.parent = parent; - this.quest = quest; - - if(quest >= 0){ - Client.sendData(EnumPacketServer.QuestsGetFromQuest, quest); - selectCategory = false; - title = "Select Quest"; - }else - Client.sendData(EnumPacketServer.QuestCategoriesGet, quest); - - if(parent instanceof GuiSelectionListener) - listener = (GuiSelectionListener) parent; - } - - public String getSelected(){ - return slot.selected; - } - - public void initGui() - { - super.initGui(); - Vector list = new Vector(); - - slot = new GuiNPCStringSlot(list,this,false,18); - slot.registerScrollButtons(4, 5); - - - this.addButton(new GuiNpcButton(2, width / 2 -100, height - 41,98, 20, "gui.back")); - this.addButton(new GuiNpcButton(4, width / 2 + 2, height - 41,98, 20, "gui.select")); - } - - - public void drawScreen(int i, int j, float f) - { - slot.drawScreen(i, j, f); - super.drawScreen(i, j, f); - } - - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 2) - { - if(selectCategory){ - close(); - NoppesUtil.openGUI(player, parent); - }else{ - title = "Select Quest Category"; - selectCategory = true; - Client.sendData(EnumPacketServer.QuestCategoriesGet, quest); - } - } - if(id == 4) - { - doubleClicked(); - } - } - - public void doubleClicked() { - if(slot.selected == null || slot.selected.isEmpty()) - return; - if(selectCategory){ - selectCategory = false; - title = "Select Quest"; - Client.sendData(EnumPacketServer.QuestsGet, data.get(slot.selected)); - } - else{ - quest = data.get(slot.selected); - close(); - NoppesUtil.openGUI(player, parent); - } - } - - public void save() { - if(quest >= 0){ - if(listener != null){ - listener.selected(quest, slot.selected); - } - } - } - - @Override - public void setData(Vector list, HashMap data) { - this.data = data; - this.slot.setList(list); - if(quest >= 0) - for(String name : data.keySet()) - if(data.get(name) == quest) - slot.selected = name; - } - - @Override - public void setSelected(String selected) { - - } - -} diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java index f13e847b5..cf3b0070f 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java @@ -80,6 +80,10 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG getTextField(4).integersOnly = true; getTextField(4).setMinMaxDefault(1, 100, 5); } + else if (ai.combatPolicy == EnumCombatPolicy.Tactical) + { + addButton(new GuiNpcButton(40, guiLeft + 295, guiTop + 160, 60, 20, new String[]{"stats.normal","stats.reverse"}, npc.ai.tacticalChance > 50 ? 1:0)); + } getButton(17).setEnabled(this.ai.onAttack == 0); getButton(15).setEnabled(this.ai.onAttack == 0); @@ -156,6 +160,15 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG ai.combatPolicy = EnumCombatPolicy.values()[button.getValue()]; initGui(); } + else if (button.id == 40) { + int val = button.getValue(); + if(val == 0){ + ai.tacticalChance = 0; + } else { + ai.tacticalChance = 100; + } + initGui(); + } } @Override 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 fe6e0364a..4b3eaf5fa 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java @@ -9,6 +9,7 @@ import noppes.npcs.client.Client; import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.*; import noppes.npcs.client.gui.model.GuiCreationScreen; +import noppes.npcs.client.gui.select.GuiTextureSelection; import noppes.npcs.client.gui.util.*; import noppes.npcs.config.ConfigMain; import noppes.npcs.constants.EnumPacketServer; @@ -153,7 +154,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene initGui(); } else if(button.id == 3){ - NoppesUtil.openGUI(player, new GuiNPCTextures(npc, this)); + setSubGui(new GuiTextureSelection(npc, npc.display.getSkinTexture())); } else if(button.id == 5){ display.disableLivingAnimation = button.getValue() == 1; @@ -197,6 +198,12 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene GeckoAddonClient.Instance.geckoNpcDisplayActionPerformed(this, button); } + @Override + public void closeSubGui(SubGuiInterface subgui) { + super.closeSubGui(subgui); + initGui(); + } + @Override public void save() { if(display.skinType == 1) diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java b/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java index 568679dd2..5c1186d23 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java @@ -3,6 +3,7 @@ package noppes.npcs.client.gui.player; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; @@ -18,7 +19,10 @@ import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.TextBlockClient; import noppes.npcs.client.controllers.MusicController; import noppes.npcs.client.gui.util.GuiNPCInterface; +import noppes.npcs.client.gui.util.GuiSelectionListener; import noppes.npcs.client.gui.util.IGuiClose; +import noppes.npcs.config.ConfigClient; +import noppes.npcs.config.ConfigMain; import noppes.npcs.constants.EnumOptionType; import noppes.npcs.constants.EnumPlayerPacket; import noppes.npcs.controllers.data.Dialog; @@ -36,6 +40,7 @@ import java.util.List; public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose { + private GuiScreen parent; private Dialog dialog; private int selected = 0; private List lineBlocks = new ArrayList(); @@ -54,9 +59,6 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose private int instantLinePos = 0; private int prevPausePos = -1; - private static int textSpeed = 10; - private static boolean textSoundEnabled = true; - private int scrollY; private ResourceLocation wheel; private ResourceLocation[] wheelparts; @@ -81,6 +83,11 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose getResource("wheel4.png"),getResource("wheel5.png"),getResource("wheel6.png")}; } + public GuiDialogInteract(GuiScreen parent, EntityNPCInterface npc, Dialog dialog){ + this(npc, dialog); + this.parent = parent; + } + public void initGui(){ super.initGui(); isGrabbed = false; @@ -169,11 +176,6 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 0.5f, 100.065F); - if (dialog.renderGradual) { - drawString(fontRendererObj, "Text Speed: " + textSpeed, 10, 10, 0xFFFFFF); - drawString(fontRendererObj, "Text Sound: " + (textSoundEnabled ? "On" : "Off"), 10, 20, 0xFFFFFF); - } - for (IDialogImage dialogImage : dialog.dialogImages.values()) { if (dialogImage.getImageType() != 0) continue; @@ -189,7 +191,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GL11.glDisable(GL11.GL_ALPHA_TEST); - + GL11.glTranslatef(image.x,image.y,0.0f); GL11.glTranslatef(image.alignment%3*((float)(scaledResolution.getScaledWidth())/2), (float) (Math.floor((float)(image.alignment/3))*((float)(scaledResolution.getScaledHeight())/2)),0.0F); image.onRender(mc); @@ -214,7 +216,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GL11.glDisable(GL11.GL_ALPHA_TEST); - + GL11.glTranslatef(image.x,image.y,0.0f); GL11.glTranslatef(guiLeft + dialog.textOffsetX, optionStart + dialog.textOffsetY - image.height * image.scale, 0.0F); image.onRender(mc); @@ -309,8 +311,8 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose try { if (textPauseTime > 0) { textPauseTime--; - } else if (textSpeed > 10 || gradualTextTime%(11 - textSpeed) == 0) { - int addChar = textSpeed > 10 ? textSpeed - 9 : 1; + } else if (ConfigClient.DialogSpeed > 10 || gradualTextTime%(11 - ConfigClient.DialogSpeed) == 0) { + int addChar = ConfigClient.DialogSpeed > 10 ? ConfigClient.DialogSpeed - 9 : 1; String addText = line.getFormattedText().substring(gradualText.length(), gradualText.length() + addChar); if (addText.matches("^(\\{(\\d+)})(.*)")) { @@ -345,10 +347,12 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose } gradualText += addText; - if (textSoundTime % 5 == 0) { - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(dialog.textSound), dialog.textPitch)); - } - textSoundTime++; + if(ConfigClient.DialogSound){ + if (textSoundTime % 5 == 0) { + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(dialog.textSound), dialog.textPitch)); + } + textSoundTime++; + } } } catch (IndexOutOfBoundsException exception) { gradualText = line.getFormattedText(); @@ -486,6 +490,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose GL11.glTranslatef(guiLeft - 30 + dialog.optionSpaceX * k, y, 0.0F); image.color = selected == k ? image.selectedColor : image.color; + GL11.glTranslatef(image.x,image.y,0.0f); image.onRender(mc); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -572,20 +577,6 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose } } - if(i == mc.gameSettings.keyBindForward.getKeyCode() || i == Keyboard.KEY_LEFT){ - textSpeed--; - if (textSpeed < 1) { - textSpeed = 1; - } - } - if(i == mc.gameSettings.keyBindBack.getKeyCode() || i == Keyboard.KEY_RIGHT){ - textSpeed++; - } - - if(i == mc.gameSettings.keyBindJump.getKeyCode() || i == Keyboard.KEY_SPACE){ - textSoundEnabled = !textSoundEnabled; - } - if (dialog.alignment == 1 && totalRows * ClientProxy.Font.height() > dialog.textHeight) { if ((i == mc.gameSettings.keyBindBack.getKeyCode() || i == 201) && scrollY < totalRows * ClientProxy.Font.height()) {//Page up scrollY += ClientProxy.Font.height() * 2; @@ -703,6 +694,13 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose } } + @Override + public void close(){ + super.close(); + if(parent != null) + NoppesUtil.openGUI(player, parent); + } + @Override public void setClose(int i, NBTTagCompound data) { grabMouse(false); diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java index 9777cd999..4a8a6489c 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java @@ -1,9 +1,12 @@ package noppes.npcs.client.gui.player.inventory; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomItems; +import noppes.npcs.client.gui.util.GuiButtonNextPage; import noppes.npcs.client.gui.util.GuiMenuSideButton; import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.config.ConfigClient; @@ -11,9 +14,10 @@ import tconstruct.client.tabs.InventoryTabCustomNpc; import tconstruct.client.tabs.TabRegistry; public class GuiCNPCInventory extends GuiNPCInterface { - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); + public static final ResourceLocation specialIcons = new ResourceLocation("customnpcs","textures/gui/icons.png"); + public static int activeTab = 0; - private Minecraft mc = Minecraft.getMinecraft(); + protected Minecraft mc = Minecraft.getMinecraft(); public GuiCNPCInventory() { super(); @@ -26,25 +30,64 @@ public class GuiCNPCInventory extends GuiNPCInterface { super.initGui(); guiTop +=10; - GuiMenuSideButton questsButton = new GuiMenuSideButton(100, guiLeft + xSize + 37, this.guiTop + 3, 22, 22, ""); + TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class); + TabRegistry.addTabsToList(buttonList); + + + int y = 3; + GuiMenuSideButton questsButton = new GuiMenuSideButton(100, guiLeft + xSize + 37, this.guiTop + y, 22, 22, ""); questsButton.rightSided = true; questsButton.active = activeTab == 0; - questsButton.renderStack = new ItemStack(CustomItems.letter); + questsButton.renderIconPosX = 32; + questsButton.renderResource = specialIcons; addButton(questsButton); - GuiMenuSideButton partyButton = new GuiMenuSideButton(101, guiLeft + xSize + 37, this.guiTop + 3 + 21, 22, 22, ""); + y += 21; + GuiMenuSideButton partyButton = new GuiMenuSideButton(101, guiLeft + xSize + 37, this.guiTop + y, 22, 22, ""); partyButton.rightSided = true; partyButton.active = activeTab == 1; - partyButton.renderStack = new ItemStack(CustomItems.bag); + partyButton.renderResource = specialIcons; addButton(partyButton); if(ConfigClient.enableFactionTab){ - GuiMenuSideButton factionButton = new GuiMenuSideButton(102, guiLeft + xSize + 37, this.guiTop + 3 + 21*2, 22, 22, ""); + y += 21; + GuiMenuSideButton factionButton = new GuiMenuSideButton(102, guiLeft + xSize + 37, this.guiTop + y, 22, 22, ""); factionButton.rightSided = true; factionButton.active = activeTab == 2; - factionButton.renderStack = new ItemStack(CustomItems.wallBanner); + factionButton.renderIconPosX = 48; + factionButton.renderResource = specialIcons; addButton(factionButton); } + + y += 21; + GuiMenuSideButton clientButton = new GuiMenuSideButton(103, guiLeft + xSize + 37, this.guiTop + y, 22, 22, ""); + clientButton.rightSided = true; + clientButton.active = activeTab == 3; + clientButton.renderIconPosX = 16; + clientButton.renderResource = specialIcons; + addButton(clientButton); + } + + @Override + protected void actionPerformed(GuiButton guibutton){ + if (guibutton.id >= 100) { + if (guibutton.id == 100 && activeTab != 0) { + activeTab = 0; + mc.displayGuiScreen(new GuiQuestLog()); + } + if (guibutton.id == 101 && activeTab != 1) { + activeTab = 1; + mc.displayGuiScreen(new GuiParty()); + } + if (guibutton.id == 102 && activeTab != 2) { + activeTab = 2; + mc.displayGuiScreen(new GuiFaction()); + } + if (guibutton.id == 103 && activeTab != 3) { + activeTab = 3; + mc.displayGuiScreen(new GuiSettings()); + } + } } @Override diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiFaction.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiFaction.java index 1b668fa1b..24dce869a 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiFaction.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiFaction.java @@ -9,22 +9,21 @@ import net.minecraft.util.StatCollector; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.client.CustomNpcResourceListener; import noppes.npcs.client.gui.util.GuiButtonNextPage; +import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.constants.EnumPlayerPacket; import noppes.npcs.controllers.data.Faction; import noppes.npcs.controllers.data.PlayerFactionData; import org.lwjgl.opengl.GL11; -import tconstruct.client.tabs.InventoryTabCustomNpc; -import tconstruct.client.tabs.TabRegistry; +import tconstruct.client.tabs.AbstractTab; import java.util.ArrayList; -public class GuiFaction extends GuiCNPCInventory implements IGuiData{ +public class GuiFaction extends GuiCNPCInventory implements IGuiData { private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); private ArrayList playerFactions = new ArrayList(); - private Minecraft mc = Minecraft.getMinecraft(); private int page = 0; private int pages = 1; @@ -45,8 +44,6 @@ public class GuiFaction extends GuiCNPCInventory implements IGuiData{ public void initGui() { super.initGui(); - TabRegistry.addTabsToList(buttonList); - TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class); this.buttonList.add(buttonNextPage = new GuiButtonNextPage(1, (guiLeft + (xSize + 35) / 2) + 25, guiTop + 170, true)); this.buttonList.add(buttonPreviousPage = new GuiButtonNextPage(2, (guiLeft + (xSize + 35) / 2) - 40, guiTop + 170, false)); @@ -133,21 +130,13 @@ public class GuiFaction extends GuiCNPCInventory implements IGuiData{ @Override protected void actionPerformed(GuiButton guibutton){ - if (guibutton.id >= 100) { - if (guibutton.id == 100 && activeTab != 0) { - activeTab = 0; - mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer)); - } - if (guibutton.id == 101 && activeTab != 1) { - activeTab = 1; - mc.displayGuiScreen(new GuiParty(mc.thePlayer)); - } - if (guibutton.id == 102 && activeTab != 2) { - activeTab = 2; - mc.displayGuiScreen(new GuiFaction()); - } - } + if(guibutton instanceof AbstractTab) + return; + if (guibutton.id >= 100 && guibutton.id <= 105) { + super.actionPerformed(guibutton); + return; + } if(!(guibutton instanceof GuiButtonNextPage)) return; int id = guibutton.id; diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiParty.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiParty.java index 8f516c887..c4cbf721c 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiParty.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiParty.java @@ -1,6 +1,5 @@ package noppes.npcs.client.gui.player.inventory; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiYesNo; import net.minecraft.client.gui.GuiYesNoCallback; @@ -9,24 +8,24 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; +import noppes.npcs.NoppesUtilPlayer; +import noppes.npcs.QuestLogData; import noppes.npcs.client.Client; import noppes.npcs.client.ClientCacheHandler; import noppes.npcs.client.CustomNpcResourceListener; -import noppes.npcs.client.TextBlockClient; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPacketServer; +import noppes.npcs.constants.EnumPlayerPacket; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.Quest; import org.lwjgl.opengl.GL11; -import tconstruct.client.tabs.InventoryTabCustomNpc; -import tconstruct.client.tabs.TabRegistry; +import tconstruct.client.tabs.AbstractTab; import java.util.*; -public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, ITopButtonListener,ICustomScrollListener, IPartyData, GuiYesNoCallback { +public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICustomScrollListener, IPartyData, GuiYesNoCallback { private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); private final EntityPlayer player; - private final Minecraft mc = Minecraft.getMinecraft(); private boolean receivedData; private long renderTicks; @@ -42,20 +41,22 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT private boolean showQuestText; private final Vector questLogStatus = new Vector<>(); private String questCompleteWith; + private String trackedQuestKey; + private String originalTracked = ""; + private QuestLogData data = new QuestLogData(); - public GuiParty(EntityPlayer player) { + public GuiParty() { super(); - this.player = player; + this.player = mc.thePlayer; xSize = 280; ySize = 180; drawDefaultBackground = false; + NoppesUtilPlayer.sendData(EnumPlayerPacket.TrackedQuest); Client.sendData(EnumPacketServer.GetPartyData); } public void initGui(){ super.initGui(); - TabRegistry.addTabsToList(buttonList); - TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class); this.selectedInvite = this.selectedPlayer = null; Party party = ClientCacheHandler.party; @@ -173,10 +174,12 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT } if (party.getIsLocked()){ - GuiNpcButton trackButton = new GuiNpcButton(340, guiLeft + 5, guiTop + ySize - 8 - 23, "party.track"); + GuiNpcButton trackButton = new GuiNpcButton(415, guiLeft + 5, guiTop + ySize - 8 - 23, new String[]{"party.track", "quest.tracking"}, data.trackedQuestKey.equals("P" + ":" + trackedQuestKey) ? 1 : 0); trackButton.width = 135; this.addButton(trackButton); - getButton(340).enabled = false; + if (trackButton.enabled && trackButton.getValue() == 1) { + trackButton.packedFGColour = 0x32CD32; + } } } } @@ -215,7 +218,14 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT @Override protected void actionPerformed(GuiButton guibutton){ + if(guibutton instanceof AbstractTab) + return; + Party party = ClientCacheHandler.party; + if (guibutton.id >= 100 && guibutton.id <= 105) { + super.actionPerformed(guibutton); + return; + } switch (guibutton.id) { case 200: @@ -278,24 +288,19 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT break; case 410: if (this.isLeader) { - GuiYesNo yesnoDisband = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("party.disbandConfirm"), 4); + GuiYesNo yesnoDisband = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("party.dropQuestConfirm"), 4); displayGuiScreen(yesnoDisband); } break; + case 415: + if (!data.trackedQuestKey.equals("P" + ":" + trackedQuestKey)) { + data.trackedQuestKey = "P" + ":" + trackedQuestKey; + } else { + data.trackedQuestKey = ""; + } + break; } initGui(); - if (guibutton.id == 100 && activeTab != 0) { - activeTab = 0; - mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer)); - } - if (guibutton.id == 101 && activeTab != 1) { - activeTab = 1; - mc.displayGuiScreen(new GuiParty(mc.thePlayer)); - } - if (guibutton.id == 102 && activeTab != 2) { - activeTab = 2; - mc.displayGuiScreen(new GuiFaction()); - } } @Override @@ -374,18 +379,18 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT } } - @Override - public boolean doesGuiPauseGame() - { - return false; - } - @Override public void setPartyData(NBTTagCompound compound) { this.receivedData = true; + if (compound.hasKey("TrackedQuestID")) { + this.originalTracked = compound.getString("TrackedQuestID"); + data.trackedQuestKey = this.originalTracked; + } + if (compound.hasKey("QuestPing")) { this.questLogStatus.clear(); this.questCompleteWith = ""; + this.trackedQuestKey = ""; if (compound.hasKey("QuestProgress")) { NBTTagList tagList = compound.getTagList("QuestProgress", 8); for (int i = 0; i < tagList.tagCount(); i++) { @@ -395,10 +400,14 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT if (compound.hasKey("QuestCompleteWith")) { this.questCompleteWith = compound.getString("QuestCompleteWith"); } + if (compound.hasKey("QuestName")) { + this.trackedQuestKey = compound.getString("QuestName"); + } } else { ClientCacheHandler.party = null; } + if (compound.hasKey("PartyUUID")) { UUID uuid = UUID.fromString(compound.getString("PartyUUID")); ClientCacheHandler.party = new Party(uuid); @@ -406,6 +415,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT party.readFromNBT(compound); this.questLogStatus.clear(); this.questCompleteWith = ""; + this.trackedQuestKey = ""; if (compound.hasKey("QuestProgress")) { NBTTagList tagList = compound.getTagList("QuestProgress", 8); for (int i = 0; i < tagList.tagCount(); i++) { @@ -415,7 +425,11 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT if (compound.hasKey("QuestCompleteWith")) { this.questCompleteWith = compound.getString("QuestCompleteWith"); } + if (compound.hasKey("QuestName")) { + this.trackedQuestKey = compound.getString("QuestName"); + } this.isLeader = ClientCacheHandler.party.getPartyLeaderName().equals(this.player.getCommandSenderName()); + System.out.println("KEY:" + trackedQuestKey); } else if (compound.hasKey("Disband")) { this.isLeader = false; } else if (compound.hasKey("PartyInvites")) { @@ -444,6 +458,9 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT if(ClientCacheHandler.party != null) Client.sendData(EnumPacketServer.SavePartyData, ClientCacheHandler.party.writeClientNBT()); } + if (!Objects.equals(this.originalTracked, data.trackedQuestKey)) { + Client.sendData(EnumPacketServer.PartyLogToServer, this.data.trackedQuestKey); + } } @Override diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java index 9e823e536..c9f9aa934 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java @@ -18,46 +18,43 @@ import noppes.npcs.constants.EnumPlayerPacket; import noppes.npcs.controllers.data.Party; import noppes.npcs.util.ValueUtil; import org.lwjgl.opengl.GL11; +import tconstruct.client.tabs.AbstractTab; import tconstruct.client.tabs.InventoryTabCustomNpc; import tconstruct.client.tabs.TabRegistry; import java.util.*; -public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,ICustomScrollListener, IGuiData, IPartyData, GuiYesNoCallback { +public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListener, IGuiData, IPartyData, GuiYesNoCallback { private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); private EntityPlayer player; private GuiCustomScroll scroll; private HashMap sideButtons = new HashMap(); - private HashMap otherButtons = new HashMap(); private QuestLogData data = new QuestLogData(); private boolean noQuests = false; private byte questPages = 1; private static long lastClicked = System.currentTimeMillis(); + private boolean isPartySet = false; private HashMap questAlertsOnOpen; private String trackedQuestKeyOnOpen; - private Minecraft mc = Minecraft.getMinecraft(); - private float sideButtonScroll = 0; private float destSideButtonScroll = 0; - public GuiQuestLog(EntityPlayer player) { + public GuiQuestLog() { super(); - this.player = player; + this.player = mc.thePlayer; xSize = 280; ySize = 180; - NoppesUtilPlayer.sendData(EnumPlayerPacket.QuestLog); drawDefaultBackground = false; - } + NoppesUtilPlayer.sendData(EnumPlayerPacket.QuestLog); + } public void initGui(){ super.initGui(); - sideButtons.clear(); - TabRegistry.addTabsToList(buttonList); - TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class); + sideButtons.clear(); noQuests = false; @@ -101,10 +98,11 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener, showTrackAlerts = false; } } - } + String partyQuestName = ClientCacheHandler.party != null ? ClientCacheHandler.party.getCurrentQuestName() : null; + isPartySet = Objects.equals(partyQuestName, data.selectedQuest); if (showParty) { // Objectives Forward-- addButton(new GuiButtonNextPage(11, guiLeft + 286, guiTop + 176, true)); @@ -112,13 +110,12 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener, // Party Back-- addButton(new GuiButtonNextPage(10, guiLeft + 144, guiTop + 176, false)); - String questName = ClientCacheHandler.party != null ? ClientCacheHandler.party.getCurrentQuestName() : null; - GuiNpcButton partyButton = new GuiNpcButton(3, guiLeft + 150, guiTop + 151, 50, 20, new String[]{"party.party", "party.partying"}, Objects.equals(questName, data.selectedQuest) ? 1 : 0); + GuiNpcButton partyButton = new GuiNpcButton(3, guiLeft + 150, guiTop + 151, 50, 20, new String[]{"party.party", "party.partying"}, isPartySet ? 1 : 0); addButton(partyButton); partyButton.enabled = ClientCacheHandler.party != null && data.hasSelectedQuest() && ClientCacheHandler.party.getPartyLeaderName().equals(this.player.getCommandSenderName()); - if (partyButton.enabled && Objects.equals(questName, data.selectedQuest)) { + if (partyButton.enabled && isPartySet) { partyButton.packedFGColour = 0x32CD32; } @@ -127,24 +124,28 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener, } GuiNpcButton trackingButton = new GuiNpcButton(4, guiLeft + 260, guiTop + 151, 50, 20, new String[]{"quest.track", "quest.tracking"}, data.trackedQuestKey.equals(data.selectedCategory + ":" + data.selectedQuest) ? 1 : 0); - if (trackingButton.displayString.equals("quest.tracking")) { - trackingButton.packedFGColour = 0x32CD32; - } addButton(trackingButton); - GuiNpcButton alertButton = new GuiNpcButton(5, guiLeft + 205, guiTop + 151, 50, 20, new String[]{"quest.alerts", "quest.noAlerts"}, data.getQuestAlerts() ? 0 : 1); addButton(alertButton); - getButton(1).visible = questPages == 1 && data.hasSelectedQuest(); - getButton(2).visible = questPages == 2 && data.hasSelectedQuest(); - getButton(4).visible = !data.selectedQuest.isEmpty() && getButton(1).visible; - getButton(5).visible = getButton(4).visible; - if (getButton(3) != null) { - getButton(3).visible = getButton(4).visible; + if(getButton(1) != null) + getButton(1).visible = questPages == 1 && data.hasSelectedQuest(); + if(getButton(2) != null) + getButton(2).visible = questPages == 2 && data.hasSelectedQuest(); + if (getButton(3) != null) + getButton(3).visible = !data.selectedQuest.isEmpty() && getButton(1).visible; + if(getButton(4) != null){ + getButton(4).visible = !data.selectedQuest.isEmpty() && getButton(1).visible; + getButton(4).enabled = showTrackAlerts && !isPartySet; + } + if(getButton(5) != null){ + getButton(5).visible = getButton(4).visible; + getButton(5).enabled = showTrackAlerts && !isPartySet; } - getButton(4).enabled = showTrackAlerts; - getButton(5).enabled = showTrackAlerts; + if (trackingButton.enabled && trackingButton.getValue() == 1) { + trackingButton.packedFGColour = 0x32CD32; + } } @Override @@ -164,10 +165,17 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener, @Override protected void actionPerformed(GuiButton guibutton){ - if(lastClicked > System.currentTimeMillis() - 10){ + if(guibutton instanceof AbstractTab) + return; + + if (guibutton.id >= 100 && guibutton.id <= 105) { + super.actionPerformed(guibutton); return; } + if(lastClicked > System.currentTimeMillis() - 5){ + return; + } if(guibutton.id == 11){ questPages = 1; lastClicked = System.currentTimeMillis(); @@ -175,13 +183,13 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener, else if(guibutton.id == 10){ questPages = 0; } - else if(guibutton.id == 1){ - questPages = 2; - } - else if(guibutton.id == 2){ - questPages = 1; + else if(guibutton.id == 1){ + questPages = 2; + } + else if(guibutton.id == 2){ + questPages = 1; lastClicked = System.currentTimeMillis(); - } + } if (guibutton.id == 3) { @@ -203,18 +211,6 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener, data.toggleQuestAlerts(); } initGui(); - if (guibutton.id == 100 && activeTab != 0) { - activeTab = 0; - mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer)); - } - if (guibutton.id == 101 && activeTab != 1) { - activeTab = 1; - mc.displayGuiScreen(new GuiParty(mc.thePlayer)); - } - if (guibutton.id == 102 && activeTab != 2) { - activeTab = 2; - mc.displayGuiScreen(new GuiFaction()); - } } @Override public void drawScreen(int i, int j, float f){ @@ -378,11 +374,6 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener, } } - @Override - public boolean doesGuiPauseGame() - { - return false; - } @Override public void setGuiData(NBTTagCompound compound) { QuestLogData data = new QuestLogData(); diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiSettings.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiSettings.java new file mode 100644 index 000000000..42e2f209d --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiSettings.java @@ -0,0 +1,193 @@ +package noppes.npcs.client.gui.player.inventory; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiYesNo; +import net.minecraft.client.gui.GuiYesNoCallback; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import noppes.npcs.client.Client; +import noppes.npcs.client.ClientCacheHandler; +import noppes.npcs.client.gui.util.*; +import noppes.npcs.config.ConfigClient; +import noppes.npcs.constants.EnumPacketServer; +import org.lwjgl.opengl.GL11; +import tconstruct.client.tabs.AbstractTab; + +public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener, GuiYesNoCallback { + + private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); + + public GuiSettings() { + super(); + xSize = 280; + ySize = 180; + this.drawDefaultBackground = false; + title = ""; + } + + @Override + public void initGui() + { + super.initGui(); + + int y = 0; + this.addLabel(new GuiNpcLabel(1, "settings.chatBubbles", guiLeft + 8, guiTop + 14 + y)); + this.addButton(new GuiNpcButton(1, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.EnableChatBubbles?1:0)); + + this.addLabel(new GuiNpcLabel(3, "settings.trackAlignment", guiLeft + 8 + 155, guiTop + 14 + y)); + this.addButton(new GuiNpcButton(3, guiLeft + 105 + 160, guiTop + 9 + y, 50, 20, new String[]{"TLeft", "TCenter", "TRight", "Left", "Center", "Right", "BLeft", "BCenter", "BRight"}, ConfigClient.TrackingInfoAlignment)); + + y += 22; + this.addLabel(new GuiNpcLabel(2, "settings.dialogSound", guiLeft + 8, guiTop + 14 + y)); + this.addButton(new GuiNpcButton(2, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.DialogSound?1:0)); + + this.addLabel(new GuiNpcLabel(12,"settings.alignmentX", guiLeft + 8 + 155, guiTop + 14 + y)); + this.addTextField(new GuiNpcTextField(12, this, this.fontRendererObj, guiLeft + 107 + 160, guiTop + 9 + y, 45, 20, ConfigClient.TrackingInfoX + "")); + getTextField(12).integersOnly = true; + getTextField(12).setMinMaxDefault(-2000, 2000, 0); + + y += 22; + this.addLabel(new GuiNpcLabel(10,"settings.dialogSpeed", guiLeft + 8, guiTop + 14 + y)); + this.addTextField(new GuiNpcTextField(10, this, this.fontRendererObj, guiLeft + 107, guiTop + 9 + y, 45, 20, ConfigClient.DialogSpeed + "")); + getTextField(10).integersOnly = true; + getTextField(10).setMinMaxDefault(1, 20, 10); + + this.addLabel(new GuiNpcLabel(13,"settings.alignmentY", guiLeft + 8 + 155, guiTop + 14 + y)); + this.addTextField(new GuiNpcTextField(13, this, this.fontRendererObj, guiLeft + 107 + 160, guiTop + 9 + y, 45, 20, ConfigClient.TrackingInfoY + "")); + getTextField(13).integersOnly = true; + getTextField(13).setMinMaxDefault(-2000, 2000, 0); + + y += 22; + + this.addLabel(new GuiNpcLabel(6, "settings.chatAlerts", guiLeft + 8, guiTop + 14 + y)); + this.addButton(new GuiNpcButton(6, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.ChatAlerts?1:0)); + + this.addLabel(new GuiNpcLabel(14,"settings.trackScale", guiLeft + 8 + 155, guiTop + 14 + y)); + this.addTextField(new GuiNpcTextField(14, this, this.fontRendererObj, guiLeft + 107 + 160, guiTop + 9 + y, 45, 20, ConfigClient.TrackingScale + "")); + getTextField(14).integersOnly = true; + getTextField(14).setMinMaxDefault(0, 300, 100); + + y += 22; + + this.addLabel(new GuiNpcLabel(7, "settings.bannerAlerts", guiLeft + 8, guiTop + 14 + y)); + this.addButton(new GuiNpcButton(7, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.BannerAlerts?1:0)); + + y += 22; + + y += 22; + + y += 22; + this.addButton(new GuiNpcButton(5, guiLeft + 8, guiTop + 9 + y, 150, 20, "settings.clearSkin")); + this.addButton(new GuiNpcButton(4, guiLeft + 8 + 155, guiTop + 9 + y, 150, 20, "settings.clearTrack")); + } + + @Override + public void drawScreen(int i, int j, float f) + { + drawDefaultBackground(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(resource); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195); + drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195); + super.drawScreen(i, j, f); + + } + + @Override + public void confirmClicked(boolean flag, int i) { + if (flag) { + switch (i) { + case 0: + // Untrack Quest + Client.sendData(EnumPacketServer.UntrackQuest); + break; + case 1: + // Clear Skin Cache + ClientCacheHandler.clearSkinCache(); + break; + } + initGui(); + } + displayGuiScreen(this); + } + + @Override + protected void actionPerformed(GuiButton btn){ + if(btn instanceof AbstractTab) + return; + + if (btn.id >= 100 && btn.id <= 105) { + super.actionPerformed(btn); + return; + } + if(!(btn instanceof GuiNpcButton)) + return; + GuiNpcButton button = (GuiNpcButton) btn; + if(button.id == 1){ + ConfigClient.EnableChatBubbles = button.getValue() == 1; + ConfigClient.EnableChatBubblesProperty.set(ConfigClient.EnableChatBubbles); + } + if(button.id == 2){ + ConfigClient.DialogSound = button.getValue() == 1; + ConfigClient.DialogSoundProperty.set(ConfigClient.DialogSound); + } + if(button.id == 3){ + ConfigClient.TrackingInfoAlignment = button.getValue(); + ConfigClient.TrackingInfoAlignmentProperty.set(ConfigClient.TrackingInfoAlignment); + } + if(button.id == 4){ + GuiYesNo yesNoTrack = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("settings.confirmClearTrack"), 0); + displayGuiScreen(yesNoTrack); + } + if(button.id == 5){ + GuiYesNo yesNoSkin = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("settings.confirmClearSkin"), 1); + displayGuiScreen(yesNoSkin); + } + if(button.id == 6){ + ConfigClient.ChatAlerts = button.getValue() == 1; + ConfigClient.ChatAlertsProperty.set(ConfigClient.ChatAlerts); + } + if(button.id == 7){ + ConfigClient.BannerAlerts = button.getValue() == 1; + ConfigClient.BannerAlertsProperty.set(ConfigClient.BannerAlerts); + } + } + + + @Override + public void keyTyped(char c, int i) + { + super.keyTyped(c, i); + if (i == 1 || isInventoryKey(i)) + { + close(); + } + } + + @Override + public void save() {} + + + @Override + public void unFocused(GuiNpcTextField textfield) { + if(textfield.id == 10){ + ConfigClient.DialogSpeed = textfield.getInteger(); + ConfigClient.DialogSpeedProperty.set(ConfigClient.DialogSound); + } + + // Quest Tracking + if(textfield.id == 12){ + ConfigClient.TrackingInfoX = textfield.getInteger(); + ConfigClient.TrackingInfoXProperty.set(ConfigClient.TrackingInfoX); + } + if(textfield.id == 13){ + ConfigClient.TrackingInfoY = textfield.getInteger(); + ConfigClient.TrackingInfoYProperty.set(ConfigClient.TrackingInfoY); + } + if(textfield.id == 14){ + ConfigClient.TrackingScale = textfield.getInteger(); + ConfigClient.TrackingScaleProperty.set(ConfigClient.TrackingScale); + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java index 78e8f1406..bfdaf32fc 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java @@ -4,8 +4,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; -import noppes.npcs.client.NoppesUtil; -import noppes.npcs.client.gui.GuiNPCDialogSelection; +import noppes.npcs.client.gui.select.GuiDialogSelection; import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiSelectionListener; import noppes.npcs.client.gui.util.IGuiData; @@ -66,10 +65,7 @@ public class GuiNpcQuestTypeDialog extends SubGuiInterface implements GuiSelecti int id = -1; if(quest.dialogs.containsKey(selectedSlot)) id = quest.dialogs.get(selectedSlot); - - GuiNPCDialogSelection gui = new GuiNPCDialogSelection(npc, getParent(), id); - gui.listener = this; - NoppesUtil.openGUI(player, gui); + setSubGui(new GuiDialogSelection(id)); } if (button.id >= 9 && button.id < 15) { int slot = button.id - 9; diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java index 2be969a75..4fc3be082 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java @@ -3,9 +3,8 @@ package noppes.npcs.client.gui.roles; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; -import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.SubGuiNpcAvailability; -import noppes.npcs.client.gui.global.GuiNPCQuestSelection; +import noppes.npcs.client.gui.select.GuiQuestSelection; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.entity.EntityNPCInterface; @@ -13,14 +12,13 @@ import noppes.npcs.roles.JobConversation; import noppes.npcs.roles.JobConversation.ConversationLine; public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldListener, GuiSelectionListener -{ +{ private JobConversation job; - + private int slot = -1; - private GuiNPCQuestSelection questSelection; - + public GuiNpcConversation(EntityNPCInterface npc){ - super(npc); + super(npc); job = (JobConversation) npc.jobInterface; } @@ -29,7 +27,7 @@ public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldLi addLabel(new GuiNpcLabel(40, "gui.name", guiLeft + 40, guiTop + 4)); addLabel(new GuiNpcLabel(41, "gui.name", guiLeft + 240, guiTop + 4)); - + addLabel(new GuiNpcLabel(42, "conversation.delay", guiLeft + 164, guiTop + 4)); addLabel(new GuiNpcLabel(43, "conversation.delay", guiLeft + 364, guiTop + 4)); @@ -39,7 +37,7 @@ public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldLi this.addLabel(new GuiNpcLabel(i, "" + (i + 1), guiLeft + 5 + offset - (i > 8?6:0), guiTop + 18 + i % 7 * 22)); this.addTextField(new GuiNpcTextField(i, this, this.fontRendererObj, guiLeft + 13 + offset, guiTop + 13 + i % 7 * 22, 100, 20, line.npc)); this.addButton(new GuiNpcButton(i, guiLeft + 115 + offset, guiTop + 13 + i % 7 * 22, 46, 20, "conversation.line")); - + if(i > 0){ this.addTextField(new GuiNpcTextField(i + 14, this, this.fontRendererObj, guiLeft + 164 + offset, guiTop + 13 + i % 7 * 22, 30, 20, line.delay + "")); this.getTextField(i + 14).integersOnly = true; @@ -55,7 +53,7 @@ public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldLi addTextField(new GuiNpcTextField(54, this, fontRendererObj, guiLeft + 260, guiTop + 191, 40, 20, job.range + "")); getTextField(54).integersOnly = true; getTextField(54).setMinMaxDefault(4, Integer.MAX_VALUE, 20); - + addLabel(new GuiNpcLabel(51, "quest.quest", guiLeft + 13, guiTop + 175)); String title = job.questTitle; if(title.isEmpty()) @@ -76,9 +74,9 @@ public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldLi ConversationLine line = job.getLine(slot); setSubGui(new SubGuiNpcConversationLine(line.text, line.sound)); } - if(button.id == 51){ - NoppesUtil.openGUI(player, new GuiNPCQuestSelection(npc, this, job.quest)); - } + if(button.id == 51){ + setSubGui(new GuiQuestSelection(job.quest)); + } if(button.id == 52){ job.quest = -1; job.questTitle = ""; @@ -93,9 +91,9 @@ public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldLi } @Override public void selected(int ob, String name) { - job.quest = ob; - job.questTitle = questSelection.getSelected(); - initGui(); + job.quest = ob; + job.questTitle = name; + initGui(); } @Override @@ -108,7 +106,7 @@ public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldLi line.sound = sub.sound; } } - + @Override public void save() { Client.sendData(EnumPacketServer.JobSave, job.writeToNBT(new NBTTagCompound())); diff --git a/src/main/java/noppes/npcs/client/gui/select/GuiDialogSelection.java b/src/main/java/noppes/npcs/client/gui/select/GuiDialogSelection.java index 0389d9ec1..fb088f3cc 100644 --- a/src/main/java/noppes/npcs/client/gui/select/GuiDialogSelection.java +++ b/src/main/java/noppes/npcs/client/gui/select/GuiDialogSelection.java @@ -1,124 +1,186 @@ -//package noppes.npcs.client.gui.select; -// -//import com.google.common.collect.Lists; -//import net.minecraft.client.gui.GuiButton; -//import noppes.npcs.client.gui.util.*; -//import noppes.npcs.controllers.DialogController; -//import noppes.npcs.controllers.data.Dialog; -//import noppes.npcs.controllers.data.DialogCategory; -// -//import java.util.HashMap; -// -//public class GuiDialogSelection extends SubGuiInterface implements ICustomScrollListener{ -// private HashMap categoryData = new HashMap(); -// private HashMap dialogData = new HashMap(); -// -// private GuiCustomScroll scrollCategories; -// private GuiCustomScroll scrollDialogs; -// -// private DialogCategory selectedCategory; -// public Dialog selectedDialog; -// -// private GuiSelectionListener listener; -// -// public GuiDialogSelection(int dialog){ -// drawDefaultBackground = false; -// title = ""; -// setBackground("menubg.png"); -// xSize = 366; -// ySize = 226; -// this.selectedDialog = DialogController.instance.dialogs.get(dialog); -// if(selectedDialog != null) { -// selectedCategory = selectedDialog.category; -// } -// } -// -// @Override -// public void initGui(){ -// super.initGui(); -// -// if(parent instanceof GuiSelectionListener){ -// listener = (GuiSelectionListener) parent; -// } -// this.addLabel(new GuiNpcLabel(0, "gui.categories", guiLeft + 8, guiTop + 4)); -// this.addLabel(new GuiNpcLabel(1, "dialog.dialogs", guiLeft + 175, guiTop + 4)); -// -// this.addButton(new GuiNpcButton(2, guiLeft + xSize - 26, guiTop + 4, 20, 20, "X")); -// -// HashMap categoryData = new HashMap(); -// HashMap dialogData = new HashMap(); -// -// for(DialogCategory category : DialogController.instance.categories.values()) { -// categoryData.put(category.title, category); -// } -// this.categoryData = categoryData; -// -// if(selectedCategory != null) { -// for(Dialog dialog : selectedCategory.dialogs.values()) { -// dialogData.put(dialog.title, dialog); -// } -// } -// this.dialogData = dialogData; -// -// if(scrollCategories == null){ -// scrollCategories = new GuiCustomScroll(this,0); -// scrollCategories.setSize(170, 200); -// } -// scrollCategories.setList(Lists.newArrayList(categoryData.keySet())); -// if(selectedCategory != null) { -// scrollCategories.setSelected(selectedCategory.title); -// } -// -// scrollCategories.guiLeft = guiLeft + 4; -// scrollCategories.guiTop = guiTop + 14; -// this.addScroll(scrollCategories); -// -// if(scrollDialogs == null){ -// scrollDialogs = new GuiCustomScroll(this,1); -// scrollDialogs.setSize(170, 200); -// } -// scrollDialogs.setList(Lists.newArrayList(dialogData.keySet())); -// if(selectedDialog != null) { -// scrollDialogs.setSelected(selectedDialog.title); -// } -// scrollDialogs.guiLeft = guiLeft + 175; -// scrollDialogs.guiTop = guiTop + 14; -// this.addScroll(scrollDialogs); -// } -// -// @Override -// public void scrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { -// if(guiCustomScroll.id == 0){ -// selectedCategory = categoryData.get(scrollCategories.getSelected()); -// selectedDialog = null; -// scrollDialogs.selected = -1; -// } -// if(guiCustomScroll.id == 1){ -// selectedDialog = dialogData.get(scrollDialogs.getSelected()); -// } -// initGui(); -// } -// -// @Override -// public void scrollDoubleClicked(String selection, GuiCustomScroll scroll) { -// if(selectedDialog == null) -// return; -// if(listener != null) { -// listener.selected(selectedDialog.id, selectedDialog.title); -// } -// close(); -// } -// -// @Override -// protected void actionPerformed(GuiButton guibutton){ -// int id = guibutton.id; -// if(id == 2){ -// if(selectedDialog != null) { -// scrollDoubleClicked(null, null); -// } -// else { -// close(); -// } -// } -// } -//} +package noppes.npcs.client.gui.select; + +import com.google.common.collect.Lists; +import net.minecraft.client.gui.GuiButton; +import noppes.npcs.client.gui.util.*; +import noppes.npcs.controllers.DialogController; +import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogCategory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class GuiDialogSelection extends SubGuiInterface implements ICustomScrollListener { + private HashMap categoryData = new HashMap(); + private HashMap dialogData = new HashMap(); + + private GuiCustomScroll scrollCategories; + private GuiCustomScroll scrollDialogs; + + private DialogCategory selectedCategory; + public Dialog selectedDialog; + + private GuiSelectionListener listener; + private String catSearch = ""; + private String dialogSearch = ""; + + public GuiDialogSelection(int dialog){ + drawDefaultBackground = false; + title = ""; + setBackground("menubg.png"); + xSize = 366; + ySize = 226; + this.selectedDialog = DialogController.Instance.dialogs.get(dialog); + if(selectedDialog != null) { + selectedCategory = selectedDialog.category; + } + } + + @Override + public void initGui(){ + super.initGui(); + + if(parent instanceof GuiSelectionListener){ + listener = (GuiSelectionListener) parent; + } + this.addLabel(new GuiNpcLabel(0, "gui.categories", guiLeft + 8, guiTop + 4)); + this.addLabel(new GuiNpcLabel(1, "dialog.dialogs", guiLeft + 184, guiTop + 4)); + + this.addButton(new GuiNpcButton(2, guiLeft + xSize - 56, guiTop + ySize - 35, 50, 20, "gui.done")); + this.addButton(new GuiNpcButton(3, guiLeft + xSize - 108, guiTop + ySize - 35, 50, 20, "gui.cancel")); + + HashMap categoryData = new HashMap(); + HashMap dialogData = new HashMap(); + + for(DialogCategory category : DialogController.Instance.categories.values()) { + categoryData.put(category.title, category); + } + this.categoryData = categoryData; + + if(selectedCategory != null) { + for(Dialog dialog : selectedCategory.dialogs.values()) { + dialogData.put(dialog.title, dialog); + } + } + this.dialogData = dialogData; + + if(scrollCategories == null){ + scrollCategories = new GuiCustomScroll(this,0, 0); + scrollCategories.setSize(177, 153); + } + scrollCategories.setList(getCatSearch()); + if(selectedCategory != null) { + scrollCategories.setSelected(selectedCategory.title); + } + scrollCategories.guiLeft = guiLeft + 4; + scrollCategories.guiTop = guiTop + 14; + this.addScroll(scrollCategories); + addTextField(new GuiNpcTextField(33, this, fontRendererObj, guiLeft + 4, guiTop + 169, 177, 20, catSearch)); + + if(scrollDialogs == null){ + scrollDialogs = new GuiCustomScroll(this,1,0); + scrollDialogs.setSize(177, 153); + } + scrollDialogs.setList(getDialogSearch()); + if(selectedDialog != null) { + scrollDialogs.setSelected(selectedDialog.title); + } + scrollDialogs.guiLeft = guiLeft + 182; + scrollDialogs.guiTop = guiTop + 14; + this.addScroll(scrollDialogs); + addTextField(new GuiNpcTextField(44, this, fontRendererObj, guiLeft + 182, guiTop + 169, 177, 20, dialogSearch)); + } + + @Override + public void keyTyped(char c, int i) + { + super.keyTyped(c, i); + if(getTextField(33) != null){ + if(getTextField(33).isFocused()){ + if(catSearch.equals(getTextField(33).getText())) + return; + catSearch = getTextField(33).getText().toLowerCase(); + scrollCategories.setList(getCatSearch()); + } + } + if(getTextField(44) != null){ + if(getTextField(44).isFocused()){ + if(dialogSearch.equals(getTextField(44).getText())) + return; + dialogSearch = getTextField(44).getText().toLowerCase(); + scrollDialogs.setList(getDialogSearch()); + } + } + } + + private List getCatSearch(){ + if(catSearch.isEmpty()){ + return Lists.newArrayList(categoryData.keySet()); + } + List list = new ArrayList(); + for(String name : Lists.newArrayList(categoryData.keySet())){ + if(name.toLowerCase().contains(catSearch)) + list.add(name); + } + return list; + } + + private List getDialogSearch(){ + if(selectedCategory == null){ + return Lists.newArrayList(dialogData.keySet()); + } + + if(dialogSearch.isEmpty()){ + return new ArrayList(Lists.newArrayList(dialogData.keySet())); + } + List list = new ArrayList(); + for(String name : Lists.newArrayList(dialogData.keySet())){ + if(name.toLowerCase().contains(dialogSearch)) + list.add(name); + } + return list; + } + + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if(guiCustomScroll.id == 0){ + selectedCategory = categoryData.get(scrollCategories.getSelected()); + selectedDialog = null; + scrollDialogs.selected = -1; + scrollDialogs.resetScroll(); + getTextField(44).setText(""); + dialogSearch = ""; + } + if(guiCustomScroll.id == 1){ + selectedDialog = dialogData.get(scrollDialogs.getSelected()); + } + initGui(); + } + + @Override + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + if(selectedDialog == null) + return; + if(listener != null) { + listener.selected(selectedDialog.id, selectedDialog.title); + } + close(); + } + + @Override + protected void actionPerformed(GuiButton guibutton){ + int id = guibutton.id; + if(id == 2){ + if(selectedDialog != null) { + customScrollDoubleClicked(null, null); + } + else { + close(); + } + } + if(id == 3){ + close(); + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/select/GuiQuestSelection.java b/src/main/java/noppes/npcs/client/gui/select/GuiQuestSelection.java index 0ba761347..c0b284b4f 100644 --- a/src/main/java/noppes/npcs/client/gui/select/GuiQuestSelection.java +++ b/src/main/java/noppes/npcs/client/gui/select/GuiQuestSelection.java @@ -1,124 +1,186 @@ -//package noppes.npcs.client.gui.select; -// -//import com.google.common.collect.Lists; -//import net.minecraft.client.gui.GuiButton; -//import noppes.npcs.client.gui.util.*; -//import noppes.npcs.controllers.QuestController; -//import noppes.npcs.controllers.data.Quest; -//import noppes.npcs.controllers.data.QuestCategory; -// -//import java.util.HashMap; -// -//public class GuiQuestSelection extends SubGuiInterface implements ICustomScrollListener{ -// private HashMap categoryData = new HashMap(); -// private HashMap questData = new HashMap(); -// -// private GuiCustomScroll scrollCategories; -// private GuiCustomScroll scrollQuests; -// -// private QuestCategory selectedCategory; -// public Quest selectedQuest; -// -// private GuiSelectionListener listener; -// -// public GuiQuestSelection(int quest){ -// drawDefaultBackground = false; -// title = ""; -// setBackground("menubg.png"); -// xSize = 366; -// ySize = 226; -// this.selectedQuest = QuestController.instance.quests.get(quest); -// if(selectedQuest != null) { -// selectedCategory = selectedQuest.category; -// } -// } -// -// @Override -// public void initGui(){ -// super.initGui(); -// -// if(parent instanceof GuiSelectionListener){ -// listener = (GuiSelectionListener) parent; -// } -// this.addLabel(new GuiNpcLabel(0, "gui.categories", guiLeft + 8, guiTop + 4)); -// this.addLabel(new GuiNpcLabel(1, "quest.quests", guiLeft + 175, guiTop + 4)); -// -// this.addButton(new GuiNpcButton(2, guiLeft + xSize - 26, guiTop + 4, 20, 20, "X")); -// -// HashMap categoryData = new HashMap(); -// HashMap questData = new HashMap(); -// -// for(QuestCategory category : QuestController.instance.categories.values()) { -// categoryData.put(category.title, category); -// } -// this.categoryData = categoryData; -// -// if(selectedCategory != null) { -// for(Quest quest : selectedCategory.quests.values()) { -// questData.put(quest.title, quest); -// } -// } -// this.questData = questData; -// -// if(scrollCategories == null){ -// scrollCategories = new GuiCustomScroll(this,0); -// scrollCategories.setSize(170, 200); -// } -// scrollCategories.setList(Lists.newArrayList(categoryData.keySet())); -// if(selectedCategory != null) { -// scrollCategories.setSelected(selectedCategory.title); -// } -// -// scrollCategories.guiLeft = guiLeft + 4; -// scrollCategories.guiTop = guiTop + 14; -// this.addScroll(scrollCategories); -// -// if(scrollQuests == null){ -// scrollQuests = new GuiCustomScroll(this,1); -// scrollQuests.setSize(170, 200); -// } -// scrollQuests.setList(Lists.newArrayList(questData.keySet())); -// if(selectedQuest != null) { -// scrollQuests.setSelected(selectedQuest.title); -// } -// scrollQuests.guiLeft = guiLeft + 175; -// scrollQuests.guiTop = guiTop + 14; -// this.addScroll(scrollQuests); -// } -// -// @Override -// public void scrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { -// if(guiCustomScroll.id == 0){ -// selectedCategory = categoryData.get(scrollCategories.getSelected()); -// selectedQuest = null; -// scrollQuests.selected = -1; -// } -// if(guiCustomScroll.id == 1){ -// selectedQuest = questData.get(scrollQuests.getSelected()); -// } -// initGui(); -// } -// -// @Override -// public void scrollDoubleClicked(String selection, GuiCustomScroll scroll) { -// if(selectedQuest == null) -// return; -// if(listener != null) { -// listener.selected(selectedQuest.id, selectedQuest.title); -// } -// close(); -// } -// -// @Override -// protected void actionPerformed(GuiButton guibutton){ -// int id = guibutton.id; -// if(id == 2){ -// if(selectedQuest != null) { -// scrollDoubleClicked(null, null); -// } -// else { -// close(); -// } -// } -// } -//} +package noppes.npcs.client.gui.select; + +import com.google.common.collect.Lists; +import net.minecraft.client.gui.GuiButton; +import noppes.npcs.client.gui.util.*; +import noppes.npcs.controllers.QuestController; +import noppes.npcs.controllers.data.Quest; +import noppes.npcs.controllers.data.QuestCategory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class GuiQuestSelection extends SubGuiInterface implements ICustomScrollListener { + private HashMap categoryData = new HashMap(); + private HashMap questData = new HashMap(); + + private GuiCustomScroll scrollCategories; + private GuiCustomScroll scrollQuests; + + private QuestCategory selectedCategory; + public Quest selectedQuest; + + private GuiSelectionListener listener; + private String catSearch = ""; + private String questSearch = ""; + + public GuiQuestSelection(int quest){ + drawDefaultBackground = false; + title = ""; + setBackground("menubg.png"); + xSize = 366; + ySize = 226; + this.selectedQuest = QuestController.Instance.quests.get(quest); + if(selectedQuest != null) { + selectedCategory = selectedQuest.category; + } + } + + @Override + public void initGui(){ + super.initGui(); + + if(parent instanceof GuiSelectionListener){ + listener = (GuiSelectionListener) parent; + } + this.addLabel(new GuiNpcLabel(0, "gui.categories", guiLeft + 8, guiTop + 4)); + this.addLabel(new GuiNpcLabel(1, "quest.quests", guiLeft + 184, guiTop + 4)); + + this.addButton(new GuiNpcButton(2, guiLeft + xSize - 56, guiTop + ySize - 35, 50, 20, "gui.done")); + this.addButton(new GuiNpcButton(3, guiLeft + xSize - 108, guiTop + ySize - 35, 50, 20, "gui.cancel")); + + HashMap categoryData = new HashMap(); + HashMap questData = new HashMap(); + + for(QuestCategory category : QuestController.Instance.categories.values()) { + categoryData.put(category.title, category); + } + this.categoryData = categoryData; + + if(selectedCategory != null) { + for(Quest quest : selectedCategory.quests.values()) { + questData.put(quest.title, quest); + } + } + this.questData = questData; + + if(scrollCategories == null){ + scrollCategories = new GuiCustomScroll(this,0, 0); + scrollCategories.setSize(177, 153); + } + scrollCategories.setList(getCatSearch()); + if(selectedCategory != null) { + scrollCategories.setSelected(selectedCategory.title); + } + scrollCategories.guiLeft = guiLeft + 4; + scrollCategories.guiTop = guiTop + 14; + this.addScroll(scrollCategories); + addTextField(new GuiNpcTextField(33, this, fontRendererObj, guiLeft + 4, guiTop + 169, 177, 20, catSearch)); + + if(scrollQuests == null){ + scrollQuests = new GuiCustomScroll(this,1, 0); + scrollQuests.setSize(177, 153); + } + scrollQuests.setList(getQuestSearch()); + if(selectedQuest != null) { + scrollQuests.setSelected(selectedQuest.title); + } + scrollQuests.guiLeft = guiLeft + 182; + scrollQuests.guiTop = guiTop + 14; + this.addScroll(scrollQuests); + addTextField(new GuiNpcTextField(44, this, fontRendererObj, guiLeft + 182, guiTop + 169, 177, 20, questSearch)); + } + + @Override + public void keyTyped(char c, int i) + { + super.keyTyped(c, i); + if(getTextField(33) != null){ + if(getTextField(33).isFocused()){ + if(catSearch.equals(getTextField(33).getText())) + return; + catSearch = getTextField(33).getText().toLowerCase(); + scrollCategories.setList(getCatSearch()); + } + } + if(getTextField(44) != null){ + if(getTextField(44).isFocused()){ + if(questSearch.equals(getTextField(44).getText())) + return; + questSearch = getTextField(44).getText().toLowerCase(); + scrollQuests.setList(getQuestSearch()); + } + } + } + + private List getCatSearch(){ + if(catSearch.isEmpty()){ + return Lists.newArrayList(categoryData.keySet()); + } + List list = new ArrayList(); + for(String name : Lists.newArrayList(categoryData.keySet())){ + if(name.toLowerCase().contains(catSearch)) + list.add(name); + } + return list; + } + + private List getQuestSearch(){ + if(selectedCategory == null){ + return Lists.newArrayList(questData.keySet()); + } + + if(questSearch.isEmpty()){ + return new ArrayList(Lists.newArrayList(questData.keySet())); + } + List list = new ArrayList(); + for(String name : Lists.newArrayList(questData.keySet())){ + if(name.toLowerCase().contains(questSearch)) + list.add(name); + } + return list; + } + + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if(guiCustomScroll.id == 0){ + selectedCategory = categoryData.get(scrollCategories.getSelected()); + selectedQuest = null; + scrollQuests.selected = -1; + scrollQuests.resetScroll(); + getTextField(44).setText(""); + questSearch = ""; + } + if(guiCustomScroll.id == 1){ + selectedQuest = questData.get(scrollQuests.getSelected()); + } + initGui(); + } + + @Override + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + if(selectedQuest == null) + return; + if(listener != null) { + listener.selected(selectedQuest.id, selectedQuest.title); + } + close(); + } + + @Override + protected void actionPerformed(GuiButton guibutton){ + int id = guibutton.id; + if(id == 2){ + if(selectedQuest != null) { + customScrollDoubleClicked(null, null); + } + else { + close(); + } + } + if(id == 3){ + close(); + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java b/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java index 74e1ed521..65b20efee 100644 --- a/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java +++ b/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java @@ -1,376 +1,374 @@ -//package noppes.npcs.client.gui.select; -// -//import com.google.common.collect.Lists; -//import net.minecraft.client.Minecraft; -//import net.minecraft.client.gui.GuiButton; -//import net.minecraft.client.resources.*; -//import net.minecraft.item.crafting.CraftingManager; -//import net.minecraft.util.ResourceLocation; -//import noppes.npcs.CustomNpcs; -//import noppes.npcs.LogWriter; -//import noppes.npcs.client.gui.util.GuiCustomScroll; -//import noppes.npcs.client.gui.util.GuiNpcButton; -//import noppes.npcs.client.gui.util.ICustomScrollListener; -//import noppes.npcs.client.gui.util.SubGuiInterface; -//import noppes.npcs.entity.EntityNPCInterface; -// -//import java.io.File; -//import java.io.UnsupportedEncodingException; -//import java.net.URL; -//import java.net.URLDecoder; -//import java.nio.charset.StandardCharsets; -//import java.util.*; -//import java.util.zip.ZipEntry; -//import java.util.zip.ZipFile; -// -//public class GuiTextureSelection extends SubGuiInterface implements ICustomScrollListener{ -// -// private String up = "..<" + I18n.translateToLocal("gui.up") + ">.."; -// private GuiCustomScroll scrollCategories; -// private GuiCustomScroll scrollQuests; -// -// private String location = ""; -// private String selectedDomain; -// public ResourceLocation selectedResource; -// -// private HashMap> domains = new HashMap>(); -// private HashMap textures = new HashMap(); -// -// public GuiTextureSelection(EntityNPCInterface npc, String texture){ -// this.npc = npc; -// drawDefaultBackground = false; -// title = ""; -// setBackground("menubg.png"); -// xSize = 366; -// ySize = 226; -// -// SimpleReloadableResourceManager simplemanager = (SimpleReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); -// -// Map map = ObfuscationReflectionHelper.getPrivateValue(SimpleReloadableResourceManager.class, simplemanager, 2); -// HashSet set = new HashSet(); -// for(String name: map.keySet()){ -// FallbackResourceManager manager = map.get(name); -// List list = ObfuscationReflectionHelper.getPrivateValue(FallbackResourceManager.class, manager, 1); -// for(IResourcePack pack : list){ -// if(pack instanceof LegacyV2Adapter) { -// pack = ObfuscationReflectionHelper.getPrivateValue(LegacyV2Adapter.class, (LegacyV2Adapter)pack, 0);; -// } -// if(pack instanceof AbstractResourcePack){ -// AbstractResourcePack p = (AbstractResourcePack) pack; -// File file = p.resourcePackFile; -// if(file != null) -// set.add(file.getAbsolutePath()); -// } -// } -// } -// for(String file : set){ -// File f = new File(file); -// if(f.isDirectory()) { -// checkFolder(new File(f, "assets"), f.getAbsolutePath().length()); -// } -// else { -// progressFile(f); -// } -// } -// for (ModContainer mod : Loader.instance().getModList()) { -// if(mod.getSource().exists()) -// progressFile(mod.getSource()); -// } -// -// ResourcePackRepository repos = Minecraft.getMinecraft().getResourcePackRepository(); -// repos.updateRepositoryEntriesAll(); -// List list = repos.getRepositoryEntries(); -// if(repos.getServerResourcePack() != null) { -// AbstractResourcePack p = (AbstractResourcePack) repos.getServerResourcePack(); -// File file = p.resourcePackFile; -// if(file != null) -// progressFile(file); -// } -// for(ResourcePackRepository.Entry entry : list) { -// File file = new File(repos.getDirResourcepacks(),entry.getResourcePackName()); -// if(file.exists()){ -// progressFile(file); -// } -// } -// checkFolder(new File(CustomNpcs.Dir,"assets"),CustomNpcs.Dir.getAbsolutePath().length()); -// -// URL url = DefaultResourcePack.class.getResource("/"); -// if(url != null) { -// File f = decodeFile(url.getFile()); -// if(f.isDirectory()) { -// checkFolder(new File(f,"assets"), url.getFile().length()); -// } -// else { -// progressFile(f); -// } -// } -// -// url = CraftingManager.class.getResource("/assets/.mcassetsroot"); -// if(url != null) { -// File f = decodeFile(url.getFile()); -// if(f.isDirectory()) { -// checkFolder(new File(f,"assets"), url.getFile().length()); -// } -// else { -// progressFile(f); -// } -// } -// -// if(texture != null && !texture.isEmpty()){ -// selectedResource = new ResourceLocation(texture); -// selectedDomain = selectedResource.getResourceDomain(); -// if(!domains.containsKey(selectedDomain)) { -// selectedDomain = null; -// } -// int i = selectedResource.getResourcePath().lastIndexOf('/'); -// location = selectedResource.getResourcePath().substring(0, i + 1); -// if(location.startsWith("textures/")){ -// location = location.substring(9); -// } -// } -// } -// private File decodeFile(String url) { -// if(url.startsWith("file:")) { -// url = url.substring(5); -// } -// url = url.replace('/', File.separatorChar); -// int i = url.indexOf('!'); -// if(i > 0) { -// url = url.substring(0, i); -// } -// try { -// url = URLDecoder.decode(url, StandardCharsets.UTF_8.name()); -// } catch (UnsupportedEncodingException e) { -// } -// return new File(url); -// } -// -// @Override -// public void initGui(){ -// super.initGui(); -// -// if(selectedDomain != null) { -// title = selectedDomain + ":" + location; -// } -// else { -// title = ""; -// } -// -// this.addButton(new GuiNpcButton(2, guiLeft + 264, guiTop + 170, 90, 20, "gui.done")); -// this.addButton(new GuiNpcButton(1, guiLeft + 264, guiTop + 190, 90, 20, "gui.cancel")); -// -// if(scrollCategories == null){ -// scrollCategories = new GuiCustomScroll(this,0); -// scrollCategories.setSize(120, 200); -// } -// -// if(selectedDomain == null) { -// scrollCategories.setList(Lists.newArrayList(domains.keySet())); -// if(selectedDomain != null) { -// scrollCategories.setSelected(selectedDomain); -// } -// } -// else { -// List list = new ArrayList(); -// list.add(up); -// List data = domains.get(selectedDomain); -// for(TextureData td : data) { -// if(location.isEmpty() || td.path.startsWith(location) && !td.path.equals(location)) { -// String path = td.path.substring(location.length()); -// int i = path.indexOf('/'); -// if(i < 0) -// continue; -// path = path.substring(0, i); -// if(!path.isEmpty() && !list.contains(path)) { -// list.add(path); -// } -// } -// } -// scrollCategories.setList(list); -// } -// scrollCategories.guiLeft = guiLeft + 4; -// scrollCategories.guiTop = guiTop + 14; -// this.addScroll(scrollCategories); -// -// if(scrollQuests == null){ -// scrollQuests = new GuiCustomScroll(this,1); -// scrollQuests.setSize(130, 200); -// } -// if(selectedDomain != null) { -// textures.clear(); -// List data = domains.get(selectedDomain); -// List list = new ArrayList(); -// String loc = location; -// if(scrollCategories.hasSelected() && !scrollCategories.getSelected().equals(up)) { -// loc += scrollCategories.getSelected() + '/'; -// } -// for(TextureData td : data) { -// if(td.path.equals(loc) && !list.contains(td.name)) { -// list.add(td.name); -// textures.put(td.name, td); -// } -// } -// scrollQuests.setList(list); -// } -// if(selectedResource != null) { -// scrollQuests.setSelected(selectedResource.getResourcePath()); -// } -// scrollQuests.guiLeft = guiLeft + 125; -// scrollQuests.guiTop = guiTop + 14; -// this.addScroll(scrollQuests); -// -// } -// -// @Override -// protected void actionPerformed(GuiButton guibutton){ -// super.actionPerformed(guibutton); -// if(guibutton.id == 2){ -// npc.display.setSkinTexture(selectedResource.toString()); -// } -// npc.textureLocation = null; -// close(); -// parent.initGui(); -// } -// -// @Override -// public void drawScreen(int i, int j, float f){ -// super.drawScreen(i, j, f); -// -// npc.textureLocation = selectedResource; -// drawNpc(npc, guiLeft + 276, guiTop + 140, 2, 0); -// } -// -// -// @Override -// public void scrollClicked(int i, int j, int k, GuiCustomScroll scroll) { -// if(scroll == scrollQuests) { -// if(scroll.id == 1){ -// TextureData data = textures.get(scroll.getSelected()); -// selectedResource = new ResourceLocation(selectedDomain, data.absoluteName); -// } -// } -// else { -// initGui(); -// } -// } -// -// @Override -// public void scrollDoubleClicked(String selection, GuiCustomScroll scroll) { -// if(scroll == scrollCategories) { -// if(selectedDomain == null) { -// selectedDomain = selection; -// } -// else if(selection.equals(up)) { -// int i = location.lastIndexOf('/', location.length() - 2); -// if(i < 0) { -// if(location.isEmpty()) { -// selectedDomain = null; -// } -// location = ""; -// } -// else { -// location = location.substring(0, i + 1); -// } -// } -// else { -// location = location + selection + '/'; -// } -// scrollCategories.selected = -1; -// scrollQuests.selected = -1; -// initGui(); -// } -// else { -// npc.display.setSkinTexture(selectedResource.toString()); -// close(); -// parent.initGui(); -// } -// } -// -// private void progressFile(File file){ -// try { -// if (!file.isDirectory() && (file.getName().endsWith(".jar") || file.getName().endsWith(".zip"))) -// { -// ZipFile zip = new ZipFile(file); -// Enumeration entries = zip.entries(); -// while(entries.hasMoreElements()){ -// ZipEntry zipentry = entries.nextElement(); -// String entryName = zipentry.getName(); -// addFile(entryName); -// -// } -// zip.close(); -// } -// else if(file.isDirectory()){ -// int length = file.getAbsolutePath().length(); -// checkFolder(file,length); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } -// -// private void checkFolder(File file, int length){ -// File[] files = file.listFiles(); -// if(files == null){ -// return; -// } -// for(File f : files){ -// String name = null; -// try { -// name = f.getAbsolutePath().substring(length); -// name = name.replace("\\", "/"); -// if(!name.startsWith("/")) -// name = "/" + name; -// if(f.isDirectory()){ -// addFile(name + "/"); -// checkFolder(f, length); -// } -// else -// addFile(name); -// } -// catch(Throwable e) { -// LogWriter.error("error with: " + name, e); -// } -// } -// } -// private void addFile(String name) { -// name = name.toLowerCase(); -// if(name.startsWith("/")) { -// name = name.substring(1); -// } -// if(!name.startsWith("assets/") || !name.toLowerCase().endsWith(".png")) { -// return; -// } -// name = name.substring(7); -// int i = name.indexOf('/'); -// String domain = name.substring(0, i); -// name = name.substring(i + 10); -// -// List list = domains.get(domain); -// if(list == null) { -// domains.put(domain, list = new ArrayList()); -// } -// boolean contains = false; -// for(TextureData data : list) { -// if(data.absoluteName.equals(name)) { -// contains = true; -// break; -// } -// } -// if(!contains) -// list.add(new TextureData(domain, name)); -// } -// class TextureData{ -// String domain; -// String absoluteName; -// String name; -// String path; -// public TextureData(String domain, String absoluteName) { -// this.domain = domain; -// int i = absoluteName.lastIndexOf('/'); -// name = absoluteName.substring(i + 1); -// path = absoluteName.substring(0, i + 1); -// this.absoluteName = "textures/" + absoluteName; -// } -// } -//} +package noppes.npcs.client.gui.select; + +import com.google.common.collect.Lists; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.ObfuscationReflectionHelper; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.resources.*; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import noppes.npcs.CustomNpcs; +import noppes.npcs.LogWriter; +import noppes.npcs.client.gui.util.GuiCustomScroll; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.ICustomScrollListener; +import noppes.npcs.client.gui.util.SubGuiInterface; +import noppes.npcs.entity.EntityNPCInterface; + +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +public class GuiTextureSelection extends SubGuiInterface implements ICustomScrollListener { + + private final String up = "..<" + StatCollector.translateToLocal("gui.up") + ">.."; + private GuiCustomScroll scrollCategories; + private GuiCustomScroll scrollTextures; + + private String location = ""; + private String selectedDomain; + public ResourceLocation selectedResource; + + private final HashMap> domains = new HashMap>(); + private final HashMap textures = new HashMap(); + + public GuiTextureSelection(EntityNPCInterface npc, String texture){ + this.npc = npc; + drawDefaultBackground = false; + title = ""; + setBackground("menubg.png"); + xSize = 366; + ySize = 226; + + SimpleReloadableResourceManager simplemanager = (SimpleReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); + + Map map = ObfuscationReflectionHelper.getPrivateValue(SimpleReloadableResourceManager.class, simplemanager, 2); + HashSet set = new HashSet(); + for(String name: map.keySet()){ + if(!(map.get(name) instanceof FallbackResourceManager)) + continue; + FallbackResourceManager manager = (FallbackResourceManager) map.get(name); + List list = ObfuscationReflectionHelper.getPrivateValue(FallbackResourceManager.class, manager, 0); + for(IResourcePack pack : list){ + if(pack instanceof AbstractResourcePack){ + AbstractResourcePack p = (AbstractResourcePack) pack; + File file = NPCResourceHelper.getPackFile(p); + if(file != null) + set.add(file.getAbsolutePath()); + } + } + } + for(String file : set){ + File f = new File(file); + if(f.isDirectory()) { + checkFolder(new File(f, "assets"), f.getAbsolutePath().length()); + } + else { + progressFile(f); + } + } + for (ModContainer mod : Loader.instance().getModList()) { + if(mod.getSource().exists()) + progressFile(mod.getSource()); + } + + ResourcePackRepository repos = Minecraft.getMinecraft().getResourcePackRepository(); + repos.updateRepositoryEntriesAll(); + List list = repos.getRepositoryEntries(); + for(ResourcePackRepository.Entry entry : list) { + File file = new File(repos.getDirResourcepacks(),entry.getResourcePackName()); + if(file.exists()){ + progressFile(file); + } + } + checkFolder(new File(CustomNpcs.Dir,"assets"),CustomNpcs.Dir.getAbsolutePath().length()); + + URL url = DefaultResourcePack.class.getResource("/"); + if(url != null) { + File f = decodeFile(url.getFile()); + if(f.isDirectory()) { + checkFolder(new File(f,"assets"), url.getFile().length()); + } + else { + progressFile(f); + } + } + + url = CraftingManager.class.getResource("/assets/.mcassetsroot"); + if(url != null) { + File f = decodeFile(url.getFile()); + if(f.isDirectory()) { + checkFolder(new File(f,"assets"), url.getFile().length()); + } + else { + progressFile(f); + } + } + + if(texture != null && !texture.isEmpty()){ + selectedResource = new ResourceLocation(texture); + selectedDomain = selectedResource.getResourceDomain(); + if(!domains.containsKey(selectedDomain)) { + selectedDomain = null; + } + int i = selectedResource.getResourcePath().lastIndexOf('/'); + location = selectedResource.getResourcePath().substring(0, i + 1); + if(location.startsWith("textures/")){ + location = location.substring(9); + } + } + } + private File decodeFile(String url) { + if(url.startsWith("file:")) { + url = url.substring(5); + } + url = url.replace('/', File.separatorChar); + int i = url.indexOf('!'); + if(i > 0) { + url = url.substring(0, i); + } + try { + url = URLDecoder.decode(url, StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException ignored) { + } + return new File(url); + } + + @Override + public void initGui(){ + super.initGui(); + + if(selectedDomain != null) { + title = selectedDomain + ":" + location; + } + else { + title = ""; + } + + this.addButton(new GuiNpcButton(2, guiLeft + 264, guiTop + 170, 90, 20, "gui.done")); + this.addButton(new GuiNpcButton(1, guiLeft + 264, guiTop + 190, 90, 20, "gui.cancel")); + + if(scrollCategories == null){ + scrollCategories = new GuiCustomScroll(this,0); + scrollCategories.setSize(120, 200); + } + + if(selectedDomain == null) { + scrollCategories.setList(Lists.newArrayList(domains.keySet())); + if(selectedDomain != null) { + scrollCategories.setSelected(selectedDomain); + } + } + else { + List list = new ArrayList(); + list.add(up); + List data = domains.get(selectedDomain); + for(TextureData td : data) { + if(location.isEmpty() || td.path.startsWith(location) && !td.path.equals(location)) { + String path = td.path.substring(location.length()); + int i = path.indexOf('/'); + if(i < 0) + continue; + path = path.substring(0, i); + if(!path.isEmpty() && !list.contains(path)) { + list.add(path); + } + } + } + scrollCategories.setList(list); + } + scrollCategories.guiLeft = guiLeft + 4; + scrollCategories.guiTop = guiTop + 14; + this.addScroll(scrollCategories); + + if(scrollTextures == null){ + scrollTextures = new GuiCustomScroll(this,1); + scrollTextures.setSize(130, 200); + } + if(selectedDomain != null) { + textures.clear(); + List data = domains.get(selectedDomain); + List list = new ArrayList(); + String loc = location; + if(scrollCategories.hasSelected() && !scrollCategories.getSelected().equals(up)) { + loc += scrollCategories.getSelected() + '/'; + } + for(TextureData td : data) { + if(td.path.equals(loc) && !list.contains(td.name)) { + list.add(td.name); + textures.put(td.name, td); + } + } + scrollTextures.setList(list); + } + if(selectedResource != null) { + scrollTextures.setSelected(selectedResource.getResourcePath()); + } + scrollTextures.guiLeft = guiLeft + 125; + scrollTextures.guiTop = guiTop + 14; + this.addScroll(scrollTextures); + + } + + @Override + protected void actionPerformed(GuiButton guibutton){ + super.actionPerformed(guibutton); + if(guibutton.id == 2){ + npc.display.setSkinTexture(selectedResource.toString()); + } + npc.textureLocation = null; + close(); + parent.initGui(); + } + + @Override + public void drawScreen(int i, int j, float f){ + super.drawScreen(i, j, f); + + npc.textureLocation = selectedResource; + drawNpc(npc, 307, 150, 1.5F, 0); + } + + + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { + if(scroll == scrollTextures) { + if(scroll.id == 1){ + TextureData data = textures.get(scroll.getSelected()); + selectedResource = new ResourceLocation(selectedDomain, data.absoluteName); + } + } + else { + initGui(); + scrollTextures.resetScroll(); + } + } + + @Override + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + if(scroll == scrollCategories) { + if(selectedDomain == null) { + selectedDomain = selection; + } + else if(selection.equals(up)) { + int i = location.lastIndexOf('/', location.length() - 2); + if(i < 0) { + if(location.isEmpty()) { + selectedDomain = null; + } + location = ""; + } + else { + location = location.substring(0, i + 1); + } + } + else { + location = location + selection + '/'; + } + scrollCategories.selected = -1; + scrollTextures.selected = -1; + initGui(); + } + else { + npc.display.setSkinTexture(selectedResource.toString()); + close(); + parent.initGui(); + } + } + + private void progressFile(File file){ + try { + if (!file.isDirectory() && (file.getName().endsWith(".jar") || file.getName().endsWith(".zip"))) + { + ZipFile zip = new ZipFile(file); + Enumeration entries = zip.entries(); + while(entries.hasMoreElements()){ + ZipEntry zipentry = entries.nextElement(); + String entryName = zipentry.getName(); + addFile(entryName); + + } + zip.close(); + } + else if(file.isDirectory()){ + int length = file.getAbsolutePath().length(); + checkFolder(file,length); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void checkFolder(File file, int length){ + File[] files = file.listFiles(); + if(files == null){ + return; + } + for(File f : files){ + String name = null; + try { + name = f.getAbsolutePath().substring(length); + name = name.replace("\\", "/"); + if(!name.startsWith("/")) + name = "/" + name; + if(f.isDirectory()){ + addFile(name + "/"); + checkFolder(f, length); + } + else + addFile(name); + } + catch(Throwable e) { + LogWriter.error("error with: " + name); + } + } + } + private void addFile(String name) { + if(name.startsWith("/")) { + name = name.substring(1); + } + if(!name.startsWith("assets/") || !name.endsWith(".png")) { + return; + } + name = name.substring(7); + int i = name.indexOf('/'); + String domain = name.substring(0, i); + name = name.substring(i + 10); + + List list = domains.get(domain); + if(list == null) { + domains.put(domain, list = new ArrayList()); + } + boolean contains = false; + for(TextureData data : list) { + if(data.absoluteName.equals(name)) { + contains = true; + break; + } + } + if(!contains) + list.add(new TextureData(domain, name)); + } + + static class TextureData { + String domain; + String absoluteName; + String name; + String path; + public TextureData(String domain, String absoluteName) { + this.domain = domain; + int i = absoluteName.lastIndexOf('/'); + name = absoluteName.substring(i + 1); + path = absoluteName.substring(0, i + 1); + this.absoluteName = "textures/" + absoluteName; + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java index d13c2968a..727d26cab 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java @@ -35,6 +35,7 @@ public class GuiCustomScroll extends GuiScreen private boolean isSorted = true; public boolean visible = true; private boolean selectable = true; + private boolean hasSubGUI = false; private int lastClickedItem; private long lastClickedTime = 0; @@ -116,7 +117,7 @@ public class GuiCustomScroll extends GuiScreen hoverCount++; } - if(hover != -1 && hoverableText && hoverCount > 100){ + if(!hasSubGUI && hover != -1 && hoverableText && hoverCount > 100){ String displayString = StatCollector.translateToLocal(list.get(hover)); GL11.glColor4f(1, 1, 1, 1); List lines = TextSplitter.splitText(displayString, 30); @@ -176,7 +177,7 @@ public class GuiCustomScroll extends GuiScreen hoverCount++; } - if(hover != -1 && hoverableText && hoverCount > 100){ + if(!hasSubGUI && hover != -1 && hoverableText && hoverCount > 100){ String displayString = StatCollector.translateToLocal(list.get(hover)); GL11.glColor4f(1, 1, 1, 1); List lines = TextSplitter.splitText(displayString, 30); @@ -374,4 +375,9 @@ public class GuiCustomScroll extends GuiScreen public void resetScroll(){ scrollY = 0; } + + public void updateSubGUI(boolean hasSubGUI) + { + this.hasSubGUI = hasSubGUI; + } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java index 99fdb45c8..866d763d7 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java @@ -6,6 +6,7 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import noppes.npcs.client.gui.player.inventory.GuiCNPCInventory; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @@ -16,6 +17,9 @@ public class GuiMenuSideButton extends GuiNpcButton{ public boolean active; public boolean rightSided; public ItemStack renderStack; + public ResourceLocation renderResource; + public int renderIconPosX = 0; + public int renderIconPosY = 0; public GuiMenuSideButton(int id, int x, int y, String s){ this(id, x, y, 200, 20, s); @@ -54,6 +58,15 @@ public class GuiMenuSideButton extends GuiNpcButton{ } mouseDragged(minecraft, i, j); + // Render Custom Icon + if (this.renderResource != null) { + this.zLevel = 100.0F; + minecraft.renderEngine.bindTexture(renderResource); + drawTexturedModalRect(xPosition + 2, yPosition + height/2 - 8, renderIconPosX, renderIconPosY, 16, 16); + this.zLevel = 0.0F; + } + + if (this.renderStack != null) { RenderHelper.enableGUIStandardItemLighting(); this.zLevel = 100.0F; @@ -71,7 +84,7 @@ public class GuiMenuSideButton extends GuiNpcButton{ this.zLevel = 0.0F; RenderHelper.disableStandardItemLighting(); } - + String text = ""; float maxWidth = width * 0.75f; if(fontrenderer.getStringWidth(displayString) > maxWidth){ @@ -102,7 +115,7 @@ public class GuiMenuSideButton extends GuiNpcButton{ @Override public void mouseReleased(int i, int j){ - + } @Override diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java index b14814ff0..7f85a4823 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java @@ -8,9 +8,11 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import noppes.npcs.client.CustomNpcResourceListener; +import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.TextBlockClient; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.input.Keyboard; @@ -237,26 +239,31 @@ public abstract class GuiNPCInterface extends GuiScreen drawBackground(); } + boolean subGui = hasSubGui(); drawCenteredString(fontRendererObj, title, width / 2, guiTop + 4, 0xffffff); for(GuiNpcLabel label : labels.values()) label.drawLabel(this,fontRendererObj); for(GuiNpcTextField tf : textfields.values()){ tf.drawTextBox(i, j); } - for(GuiCustomScroll scroll : scrolls.values()) - scroll.drawScreen(i, j, f, hasSubGui()?0:this.mouseWheel); - + for(GuiCustomScroll scroll : scrolls.values()){ + scroll.updateSubGUI(subGui); + scroll.drawScreen(i, j, f, subGui?0:this.mouseWheel); + } for(GuiScreen gui : extra.values()) gui.drawScreen(i, j, f); super.drawScreen(i, j, f); for(GuiCustomScroll scroll : scrolls.values()) if(scroll.hoverableText){ - scroll.drawHover(i, j, f, hasSubGui()?0:this.mouseWheel); + scroll.drawHover(i, j, f, subGui?0:this.mouseWheel); } - for(GuiNpcButton button : buttons.values()) + for(GuiNpcButton button : buttons.values()){ + button.updateSubGUI(subGui); if(!button.hoverableText.isEmpty()){ - button.drawHover(i, j, hasSubGui()); + button.drawHover(i, j, subGui); } + } + if(subgui != null) subgui.drawScreen(i,j,f); } @@ -330,44 +337,63 @@ public abstract class GuiNPCInterface extends GuiScreen return subgui; } - public void drawNpc(int x, int y){ + public void drawNpc(int x, int y){ + drawNpc(npc, x, y, 1, 0); + } + + public void drawNpc(EntityLivingBase entity, int x, int y, float zoomed, int rotation){ + EntityNPCInterface npc = null; + if(entity instanceof EntityNPCInterface) + npc = (EntityNPCInterface) entity; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - npc.isDrawn = true; + if(npc != null) + npc.isDrawn = true; GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glPushMatrix(); GL11.glTranslatef(guiLeft + x, guiTop + y, 50F); float scale = 1; - if(npc.height > 2.4) + if(entity.height > 2.4) scale = 2 / npc.height; - GL11.glScalef(-30 * scale, 30 * scale, 30 * scale); + GL11.glScalef(-30 * scale * zoomed, 30 * scale * zoomed, 30 * scale * zoomed); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - float f2 = npc.renderYawOffset; - float f3 = npc.rotationYaw; - float f4 = npc.rotationPitch; - float f7 = npc.rotationYawHead; + float f2 = entity.renderYawOffset; + float f3 = entity.rotationYaw; + float f4 = entity.rotationPitch; + float f7 = entity.rotationYawHead; float f5 = (float) (guiLeft + x) - mouseX; - float f6 = (float) ((guiTop + y) - 50) - mouseY; + float f6 = (float) ((guiTop + y) - 50 * scale * zoomed) - mouseY; + int orientation = 0; + if(npc != null){ + orientation = npc.ai.orientation; + npc.ai.orientation = rotation; + } + GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-(float) Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); - npc.renderYawOffset = (float) Math.atan(f5 / 40F) * 20F; - npc.rotationYaw = (float) Math.atan(f5 / 40F) * 40F; - npc.rotationPitch = -(float) Math.atan(f6 / 40F) * 20F; - npc.rotationYawHead = npc.rotationYaw; - GL11.glTranslatef(0.0F, npc.yOffset, 0.0F); + entity.renderYawOffset = rotation; + entity.rotationYaw = (float)Math.atan(f5 / 80F) * 40F + rotation; + entity.rotationPitch = -(float) Math.atan(f6 / 40F) * 20F; + entity.rotationYawHead = entity.rotationYaw; + GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); RenderManager.instance.playerViewY = 180F; - RenderManager.instance.renderEntityWithPosYaw(npc, 0, 0, 0, 0, 1); - npc.renderYawOffset = f2; - npc.rotationYaw = f3; - npc.rotationPitch = f4; - npc.rotationYawHead = f7; + RenderManager.instance.renderEntityWithPosYaw(entity, 0, 0, 0, 0, 1); + entity.prevRenderYawOffset = entity.renderYawOffset = f2; + entity.prevRotationYaw = entity.rotationYaw = f3; + entity.prevRotationPitch = entity.rotationPitch = f4; + entity.prevRotationYawHead = entity.rotationYawHead = f7; + if(npc != null){ + npc.ai.orientation = orientation; + } GL11.glPopMatrix(); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); - npc.isDrawn = false; + if(npc != null) + npc.isDrawn = false; OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java index 4eedca8b1..ed654b742 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java @@ -2,8 +2,10 @@ package noppes.npcs.client.gui.util; import kamkeel.util.TextSplitter; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; @@ -21,6 +23,7 @@ public class GuiNpcButton extends GuiButton{ public String hoverableText = ""; public int oldHover; public int hoverCount = 0; + boolean hasSubGUI = false; public GuiNpcButton(int i, int j, int k, String s) { super(i, j, k, StatCollector.translateToLocal(s)); @@ -200,4 +203,29 @@ public class GuiNpcButton extends GuiButton{ GL11.glEnable(GL12.GL_RESCALE_NORMAL); } + @Override + public int getHoverState(boolean mouseOver) + { + byte b0 = 1; + if (!this.enabled) + { + b0 = 0; + } + else if (mouseOver && !this.hasSubGUI) + { + b0 = 2; + } + + return b0; + } + + public void updateSubGUI(boolean hasSubGUI) + { + this.hasSubGUI = hasSubGUI; + } + + public boolean getHasSubGUI() + { + return this.hasSubGUI; + } } diff --git a/src/main/java/noppes/npcs/config/ConfigClient.java b/src/main/java/noppes/npcs/config/ConfigClient.java index 8e9312d39..fd89c2915 100644 --- a/src/main/java/noppes/npcs/config/ConfigClient.java +++ b/src/main/java/noppes/npcs/config/ConfigClient.java @@ -6,6 +6,7 @@ import net.minecraftforge.common.config.Property; import noppes.npcs.CustomNpcs; import noppes.npcs.config.legacy.LegacyConfig; import org.apache.logging.log4j.Level; +import tv.twitch.chat.Chat; import java.io.File; @@ -24,9 +25,6 @@ public class ConfigClient public static Property CacheLifeProperty; public static int CacheLife = 10; - public static Property enableFactionTabProperty; - public static boolean enableFactionTab = true; - /** * Visual Properties **/ @@ -36,6 +34,9 @@ public class ConfigClient public static Property InventoryGuiEnabledProperty; public static boolean InventoryGuiEnabled = true; + public static Property enableFactionTabProperty; + public static boolean enableFactionTab = true; + public static Property FontTypeProperty; public static String FontType = "Default"; @@ -54,6 +55,21 @@ public class ConfigClient public static Property TrackingInfoYProperty; public static int TrackingInfoY = 0; + public static Property TrackingScaleProperty; + public static int TrackingScale = 100; + + public static Property DialogSpeedProperty; + public static int DialogSpeed = 10; + + public static Property DialogSoundProperty; + public static boolean DialogSound = true; + + public static Property ChatAlertsProperty; + public static boolean ChatAlerts = true; + + public static Property BannerAlertsProperty; + public static boolean BannerAlerts = true; + public static void init(File configFile) { config = new Configuration(configFile); @@ -66,9 +82,6 @@ public class ConfigClient CacheLifeProperty = config.get(GENERAL, "Cache Life", 10, "How long should downloaded imagery data be saved client side? (In minutes)"); CacheLife = CacheLifeProperty.getInt(10); - enableFactionTabProperty = config.get(GENERAL, "Enable Faction Tab", true, "Enable the Faction Tab"); - enableFactionTab = enableFactionTabProperty.getBoolean(true); - // Visual EnableChatBubblesProperty = config.get(VISUAL, "Enable Chat Bubbles", true, "Enable/Disable Chat Bubbles"); EnableChatBubbles = EnableChatBubblesProperty.getBoolean(true); @@ -76,6 +89,9 @@ public class ConfigClient InventoryGuiEnabledProperty = config.get(VISUAL, "Enable Inventory Tabs", true, "Enable/Disable Inventory Tabs"); InventoryGuiEnabled = InventoryGuiEnabledProperty.getBoolean(true); + enableFactionTabProperty = config.get(VISUAL, "Enable Faction Tab", true, "Enable the Faction Tab"); + enableFactionTab = enableFactionTabProperty.getBoolean(true); + FontTypeProperty = config.get(VISUAL, "Font Type", "Default", "When set to Minecraft it will use minecrafts font, when Default it will use OpenSans. Can only use fonts installed on your PC"); FontType = FontTypeProperty.getString(); @@ -92,6 +108,21 @@ public class ConfigClient TrackingInfoYProperty = config.get(QUESTING, "Tracking Info Y", 0, "Client sided! Offsets the tracking info GUI by this amount in the Y direction."); TrackingInfoY = TrackingInfoYProperty.getInt(0); + TrackingScaleProperty = config.get(QUESTING, "Tracking Scale", 100, "Client sided! Adjusts the scaling of the Quest Tracking"); + TrackingScale = TrackingScaleProperty.getInt(100); + + DialogSpeedProperty = config.get(VISUAL, "Dialog Speed", true, "Only set for gradual dialogs"); + DialogSpeed = DialogSpeedProperty.getInt(10); + + DialogSoundProperty = config.get(VISUAL, "Dialog Sound", true, "Only for dialogs with sounds"); + DialogSound = DialogSoundProperty.getBoolean(true); + + ChatAlertsProperty = config.get(VISUAL, "All Chat Alerts", true, "Universal enable/disable for Banner Alerts"); + ChatAlerts = ChatAlertsProperty.getBoolean(true); + + BannerAlertsProperty = config.get(VISUAL, "All Banner Alerts", true, "Universal enable/disable for Banner Alerts"); + BannerAlerts = BannerAlertsProperty.getBoolean(true); + // Convert to Legacy if(CustomNpcs.legacyExist){ EnableChatBubbles = LegacyConfig.EnableChatBubbles; @@ -132,4 +163,4 @@ public class ConfigClient } } } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/config/ConfigMain.java b/src/main/java/noppes/npcs/config/ConfigMain.java index 50a3ec37e..7fa364ad9 100644 --- a/src/main/java/noppes/npcs/config/ConfigMain.java +++ b/src/main/java/noppes/npcs/config/ConfigMain.java @@ -111,19 +111,6 @@ public class ConfigMain public static Property TrackedQuestUpdateFrequencyProperty; public static int TrackedQuestUpdateFrequency = 5; - /** - * Sync Properties - **/ - - public static Property SyncQuestAutoProperty; - public static boolean SyncQuestAuto = true; - - public static Property SyncDialogAutoProperty; - public static boolean SyncDialogAuto = true; - - public static Property SyncFactionAutoProperty; - public static boolean SyncFactionAuto = true; - public static void init(File configFile) { config = new Configuration(configFile); @@ -216,16 +203,6 @@ public class ConfigMain TrackedQuestUpdateFrequencyProperty = config.get(UPDATE, "Tracked Quest Update Frequency", 5, "How often in seconds to update a players tracked quest. [Only applies to Item Quest currently]"); TrackedQuestUpdateFrequency = TrackedQuestUpdateFrequencyProperty.getInt(5); - // Sync - SyncQuestAutoProperty = config.get(SYNC, "Auto Sync Quest Data", true, "If enabled client will all Quest Data upon joining the world"); - SyncQuestAuto = SyncQuestAutoProperty.getBoolean(true); - - SyncDialogAutoProperty = config.get(SYNC, "Auto Sync Dialog Data", true, "If enabled client will all Dialog Data upon joining the world"); - SyncDialogAuto = SyncDialogAutoProperty.getBoolean(true); - - SyncFactionAutoProperty = config.get(SYNC, "Auto Sync Faction Data", true, "If enabled client will all Faction Data upon joining the world"); - SyncFactionAuto = SyncFactionAutoProperty.getBoolean(true); - // Convert to Legacy if(CustomNpcs.legacyExist){ EnableUpdateChecker = LegacyConfig.EnableUpdateChecker; diff --git a/src/main/java/noppes/npcs/constants/EnumPacketServer.java b/src/main/java/noppes/npcs/constants/EnumPacketServer.java index 2bc45401f..7e3162c88 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketServer.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketServer.java @@ -98,7 +98,7 @@ public enum EnumPacketServer { AnimationsGet, AnimationGet, AnimationRemove(CustomNpcsPermissions.GLOBAL_ANIMATION), AnimationSave(CustomNpcsPermissions.GLOBAL_ANIMATION), - RecipesGet, RecipeGet, QuestOpenGui, PlayerDataGet, QuestLogToServer, + RecipesGet, RecipeGet, QuestOpenGui, PlayerDataGet, QuestLogToServer, PartyLogToServer, UntrackQuest, RemoteNpcsGet(CustomNpcsPermissions.NPC_GUI), RemoteTpToNpc(CustomNpcsPermissions.NPC_TELEPORT), diff --git a/src/main/java/noppes/npcs/constants/EnumPlayerPacket.java b/src/main/java/noppes/npcs/constants/EnumPlayerPacket.java index e89854166..4834c9d25 100644 --- a/src/main/java/noppes/npcs/constants/EnumPlayerPacket.java +++ b/src/main/java/noppes/npcs/constants/EnumPlayerPacket.java @@ -2,7 +2,7 @@ package noppes.npcs.constants; public enum EnumPlayerPacket { FollowerHire,FollowerExtend,Trader, FollowerState, Transport, BankUnlock, BankUpgrade, - Dialog, QuestLog, CheckQuestCompletion, BankSlotOpen, FactionsGet, + Dialog, QuestLog, TrackedQuest, CheckQuestCompletion, BankSlotOpen, FactionsGet, MailGet, MailDelete, MailSend, MailRead, MailboxOpenMail, SignSave, SaveBook, CompanionOpenInv, RoleGet, KeyPressed, MouseClicked, CompanionTalentExp, ScreenSize, MarkData diff --git a/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java b/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java index 5326753a8..0df035f26 100644 --- a/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java +++ b/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java @@ -55,7 +55,7 @@ public class ContainerCarpentryBench extends Container this.onCraftMatrixChanged(this.craftMatrix); } - + public int getMetadata(){ return worldObj.getBlockMetadata(posX, posY, posZ); } @@ -68,12 +68,12 @@ public class ContainerCarpentryBench extends Container { if(!this.worldObj.isRemote){ RecipeCarpentry recipe = RecipeController.Instance.findMatchingRecipe(this.craftMatrix); - + ItemStack item = null; if(recipe != null && recipe.availability.isAvailable(player)){ item = recipe.getCraftingResult(this.craftMatrix); } - + this.craftResult.setInventorySlotContents(0, item); EntityPlayerMP plmp = (EntityPlayerMP) player; plmp.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(this.windowId, 0, item)); @@ -166,6 +166,16 @@ public class ContainerCarpentryBench extends Container var3.onPickupFromSlot(par1EntityPlayer, var4); } + // Update client-side inventory + if (!this.worldObj.isRemote && player instanceof EntityPlayerMP) { + ((EntityPlayerMP) player).sendContainerToPlayer(this); + } + return var2; } + + @Override + public boolean func_94530_a(ItemStack stack, Slot slotIn) { + return slotIn.inventory != this.craftResult && super.func_94530_a(stack, slotIn); + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerCustomGui.java b/src/main/java/noppes/npcs/containers/ContainerCustomGui.java index 895c9dcaa..c42b6f041 100644 --- a/src/main/java/noppes/npcs/containers/ContainerCustomGui.java +++ b/src/main/java/noppes/npcs/containers/ContainerCustomGui.java @@ -38,7 +38,7 @@ public class ContainerCustomGui extends Container { } slotCount=0; - inventorySlots.clear(); + // inventorySlots.clear(); for (IItemSlot slot : this.customGui.getSlots()) { if (slot.hasStack()) { this.addSlot(player, slot.getPosX(), slot.getPosY(), slot, slot.getStack().getMCItemStack(), player.worldObj.isRemote); @@ -106,40 +106,59 @@ public class ContainerCustomGui extends Container { if(slotId < 0) return super.slotClick(slotId, dragType, clickTypeIn, player); - if (slotId >= this.inventorySlots.size()) { - return null; - } - - Slot mcSlot = (Slot)this.inventorySlots.get(slotId); - if(!player.worldObj.isRemote && mcSlot != null) { + if(!player.worldObj.isRemote) { IItemSlot slot = null; if (this.getSlot(slotId) instanceof CustomGuiSlot) { slot = ((CustomGuiSlot)this.getSlot(slotId)).slot; } if(!EventHooks.onCustomGuiSlotClicked((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, slotId, slot, dragType, clickTypeIn)) { - ItemStack prevStack = mcSlot.getStack(); - if (slot != null) { - prevStack = slot.getStack() == null ? null : slot.getStack().getMCItemStack(); - } ItemStack item = super.slotClick(slotId, dragType, clickTypeIn, player); - if (!ItemStack.areItemStacksEqual(prevStack,item)) { - if (slot != null) { - slot.setStack(NpcAPI.Instance().getIItemStack(mcSlot.getStack())); - } - if (player.openContainer instanceof ContainerCustomGui) { - EventHooks.onCustomGuiSlot((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, - mcSlot.slotNumber, prevStack, slot); - } - } EntityPlayerMP p = (EntityPlayerMP) player; p.sendContainerToPlayer(this); return item; } } - return null; + +// if(slotId < 0) +// return super.slotClick(slotId, dragType, clickTypeIn, player); +// +// if (slotId >= this.inventorySlots.size()) { +// return null; +// } +// +// Slot mcSlot = (Slot)this.inventorySlots.get(slotId); +// if(!player.worldObj.isRemote && mcSlot != null) { +// IItemSlot slot = null; +// if (this.getSlot(slotId) instanceof CustomGuiSlot) { +// slot = ((CustomGuiSlot)this.getSlot(slotId)).slot; +// } +// if(!EventHooks.onCustomGuiSlotClicked((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, slotId, slot, dragType, clickTypeIn)) { +// ItemStack prevStack = mcSlot.getStack(); +// if (slot != null) { +// prevStack = slot.getStack() == null ? null : slot.getStack().getMCItemStack(); +// } +// ItemStack item = super.slotClick(slotId, dragType, clickTypeIn, player); +// +// if (!ItemStack.areItemStacksEqual(prevStack,item)) { +// if (slot != null) { +// slot.setStack(NpcAPI.Instance().getIItemStack(mcSlot.getStack())); +// } +// if (player.openContainer instanceof ContainerCustomGui) { +// EventHooks.onCustomGuiSlot((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, +// mcSlot.slotNumber, prevStack, slot); +// } +// } +// +// EntityPlayerMP p = (EntityPlayerMP) player; +// p.sendContainerToPlayer(this); +// return item; +// } +// } +// +// return null; } public boolean canDragIntoSlot(Slot p_94531_1_) { return true; } diff --git a/src/main/java/noppes/npcs/controllers/PartyController.java b/src/main/java/noppes/npcs/controllers/PartyController.java index 93b9c036f..34f4f6870 100644 --- a/src/main/java/noppes/npcs/controllers/PartyController.java +++ b/src/main/java/noppes/npcs/controllers/PartyController.java @@ -6,6 +6,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import noppes.npcs.EventHooks; +import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.NoppesUtilServer; import noppes.npcs.Server; import noppes.npcs.api.entity.IPlayer; @@ -119,6 +120,7 @@ public class PartyController { if (party.getQuest() != null) { Quest quest = (Quest) party.getQuest(); Vector vector = quest.questInterface.getPartyQuestLogStatus(party); + compound.setString("QuestName", quest.getCategory().getName() + ":" + quest.getName()); NBTTagList list = new NBTTagList(); for (String s : vector) { list.appendTag(new NBTTagString(s)); @@ -150,6 +152,7 @@ public class PartyController { Quest quest = (Quest) party.getQuest(); Vector vector = quest.questInterface.getPartyQuestLogStatus(party); NBTTagList list = new NBTTagList(); + compound.setString("QuestName", quest.getCategory().getName() + ":" + quest.getName()); for (String s : vector) { list.appendTag(new NBTTagString(s)); } @@ -201,7 +204,6 @@ public class PartyController { EventHooks.onPartyFinished(party, questData.quest); PartyController.Instance().sendQuestChat(party, "party.turnedInChat"); } else { - party.setQuest(null); PartyController.Instance().sendQuestChat(party, "party.completeChat"); } PartyController.Instance().pingPartyUpdate(party); @@ -210,9 +212,17 @@ public class PartyController { questData.isCompleted = false; } -// if (this.trackedQuest != null && questData.quest.getId() == this.trackedQuest.getId()) { -// NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player); -// } + for (String name : party.getPlayerNames()) { + EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); + if (playerMP != null) { + PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP); + if(playerData != null){ + if (playerData.questData.getTrackedQuest() != null && questData.quest.getId() == playerData.questData.getTrackedQuest().getId()) { + NoppesUtilPlayer.sendPartyTrackedQuestData((EntityPlayerMP) playerMP, party); + } + } + } + } } } diff --git a/src/main/java/noppes/npcs/controllers/SyncController.java b/src/main/java/noppes/npcs/controllers/SyncController.java index ad702bc80..cc1752a81 100644 --- a/src/main/java/noppes/npcs/controllers/SyncController.java +++ b/src/main/java/noppes/npcs/controllers/SyncController.java @@ -20,74 +20,68 @@ public class SyncController { //////////////////////////////////////////////////////////////////////////////// // Faction Sync - if(ConfigMain.SyncFactionAuto){ - for(Faction faction : FactionController.getInstance().factions.values()){ - NBTTagCompound factioNBT = new NBTTagCompound(); - faction.writeNBT(factioNBT); - list.appendTag(factioNBT); - if(list.tagCount() > 20){ - compound = new NBTTagCompound(); - compound.setTag("Data", list); - Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.FACTION, compound); - list = new NBTTagList(); - } + for(Faction faction : FactionController.getInstance().factions.values()){ + NBTTagCompound factioNBT = new NBTTagCompound(); + faction.writeNBT(factioNBT); + list.appendTag(factioNBT); + if(list.tagCount() > 20){ + compound = new NBTTagCompound(); + compound.setTag("Data", list); + Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.FACTION, compound); + list = new NBTTagList(); } - compound = new NBTTagCompound(); - compound.setTag("Data", list); - Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.FACTION, compound); } + compound = new NBTTagCompound(); + compound.setTag("Data", list); + Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.FACTION, compound); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Quest Sync - if(ConfigMain.SyncQuestAuto){ - for(QuestCategory category : QuestController.Instance.categories.values()){ - NBTTagCompound questCompound; - NBTTagList questList = new NBTTagList(); - for(int questID : category.quests.keySet()){ - Quest quest = category.quests.get(questID); - questList.appendTag(quest.writeToNBT(new NBTTagCompound())); - if(questList.tagCount() > 50){ - questCompound = new NBTTagCompound(); - questCompound.setTag("Data", questList); - questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); - Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound); - questList = new NBTTagList(); - } + for(QuestCategory category : QuestController.Instance.categories.values()){ + NBTTagCompound questCompound; + NBTTagList questList = new NBTTagList(); + for(int questID : category.quests.keySet()){ + Quest quest = category.quests.get(questID); + questList.appendTag(quest.writeToNBT(new NBTTagCompound())); + if(questList.tagCount() > 50){ + questCompound = new NBTTagCompound(); + questCompound.setTag("Data", questList); + questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); + Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound); + questList = new NBTTagList(); } - questCompound = new NBTTagCompound(); - questCompound.setTag("Data", questList); - questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); - Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound); } - Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.QUEST_CATEGORY, new NBTTagCompound()); + questCompound = new NBTTagCompound(); + questCompound.setTag("Data", questList); + questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); + Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound); } + Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.QUEST_CATEGORY, new NBTTagCompound()); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Dialog Sync - if(ConfigMain.SyncDialogAuto){ - for(DialogCategory category : DialogController.Instance.categories.values()){ - NBTTagCompound dialogCompound; - NBTTagList dialogList = new NBTTagList(); - for(int dialogID : category.dialogs.keySet()){ - Dialog dialog = category.dialogs.get(dialogID); - dialogList.appendTag(dialog.writeToNBT(new NBTTagCompound())); - if(dialogList.tagCount() > 50){ - dialogCompound = new NBTTagCompound(); - dialogCompound.setTag("Data", dialogList); - dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); - Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound); - dialogList = new NBTTagList(); - } + for(DialogCategory category : DialogController.Instance.categories.values()){ + NBTTagCompound dialogCompound; + NBTTagList dialogList = new NBTTagList(); + for(int dialogID : category.dialogs.keySet()){ + Dialog dialog = category.dialogs.get(dialogID); + dialogList.appendTag(dialog.writeToNBT(new NBTTagCompound())); + if(dialogList.tagCount() > 50){ + dialogCompound = new NBTTagCompound(); + dialogCompound.setTag("Data", dialogList); + dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); + Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound); + dialogList = new NBTTagList(); } - dialogCompound = new NBTTagCompound(); - dialogCompound.setTag("Data", dialogList); - dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); - Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound); } - Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.DIALOG_CATEGORY, new NBTTagCompound()); + dialogCompound = new NBTTagCompound(); + dialogCompound.setTag("Data", dialogList); + dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); + Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound); } + Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.DIALOG_CATEGORY, new NBTTagCompound()); //////////////////////////////////////////////////////////////////////////////// PlayerData data = PlayerData.get(player); @@ -96,97 +90,89 @@ public class SyncController { } public static void syncAllDialogs() { - if(ConfigMain.SyncDialogAuto){ - for(DialogCategory category : DialogController.Instance.categories.values()){ - NBTTagCompound dialogCompound; - NBTTagList dialogList = new NBTTagList(); - for(int dialogID : category.dialogs.keySet()){ - Dialog dialog = category.dialogs.get(dialogID); - dialogList.appendTag(dialog.writeToNBT(new NBTTagCompound())); - if(dialogList.tagCount() > 50){ - dialogCompound = new NBTTagCompound(); - dialogCompound.setTag("Data", dialogList); - dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); - Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound); - dialogList = new NBTTagList(); - } - } - dialogCompound = new NBTTagCompound(); - dialogCompound.setTag("Data", dialogList); - dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); - Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound); - } - Server.sendToAll(EnumPacketClient.SYNC_END, SyncType.DIALOG_CATEGORY, new NBTTagCompound()); - } - } - - public static void syncAllQuests() { - if(ConfigMain.SyncQuestAuto){ - for(QuestCategory category : QuestController.Instance.categories.values()){ - NBTTagCompound questCompound; - NBTTagList questList = new NBTTagList(); - for(int questID : category.quests.keySet()){ - Quest quest = category.quests.get(questID); - questList.appendTag(quest.writeToNBT(new NBTTagCompound())); - if(questList.tagCount() > 50){ - questCompound = new NBTTagCompound(); - questCompound.setTag("Data", questList); - questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); - Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound); - questList = new NBTTagList(); - } - } - questCompound = new NBTTagCompound(); - questCompound.setTag("Data", questList); - questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); - Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound); - } - Server.sendToAll(EnumPacketClient.SYNC_END, SyncType.QUEST_CATEGORY, new NBTTagCompound()); - } - } - - public static void updateQuestCat(QuestCategory questCategory) { - if(ConfigMain.SyncQuestAuto){ - NBTTagCompound questCompound; - NBTTagList questList = new NBTTagList(); - for(int questID : questCategory.quests.keySet()){ - Quest quest = questCategory.quests.get(questID); - questList.appendTag(quest.writeToNBT(new NBTTagCompound())); - if(questList.tagCount() > 50){ - questCompound = new NBTTagCompound(); - questCompound.setTag("Data", questList); - questCompound.setTag("CatNBT", questCategory.writeSmallNBT(new NBTTagCompound())); - Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.QUEST_CATEGORY, questCompound); - questList = new NBTTagList(); - } - } - questCompound = new NBTTagCompound(); - questCompound.setTag("Data", questList); - questCompound.setTag("CatNBT", questCategory.writeSmallNBT(new NBTTagCompound())); - Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.QUEST_CATEGORY, questCompound); - } - } - - public static void updateDialogCat(DialogCategory dialogCategory) { - if(ConfigMain.SyncDialogAuto){ + for(DialogCategory category : DialogController.Instance.categories.values()){ NBTTagCompound dialogCompound; NBTTagList dialogList = new NBTTagList(); - for(int questID : dialogCategory.dialogs.keySet()){ - Dialog dialog = dialogCategory.dialogs.get(questID); + for(int dialogID : category.dialogs.keySet()){ + Dialog dialog = category.dialogs.get(dialogID); dialogList.appendTag(dialog.writeToNBT(new NBTTagCompound())); if(dialogList.tagCount() > 50){ dialogCompound = new NBTTagCompound(); dialogCompound.setTag("Data", dialogList); - dialogCompound.setTag("CatNBT", dialogCategory.writeSmallNBT(new NBTTagCompound())); - Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.DIALOG_CATEGORY, dialogCompound); + dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); + Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound); dialogList = new NBTTagList(); } } dialogCompound = new NBTTagCompound(); dialogCompound.setTag("Data", dialogList); - dialogCompound.setTag("CatNBT", dialogCategory.writeSmallNBT(new NBTTagCompound())); - Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.DIALOG_CATEGORY, dialogCompound); + dialogCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); + Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, dialogCompound); } + Server.sendToAll(EnumPacketClient.SYNC_END, SyncType.DIALOG_CATEGORY, new NBTTagCompound()); + } + + public static void syncAllQuests() { + for(QuestCategory category : QuestController.Instance.categories.values()){ + NBTTagCompound questCompound; + NBTTagList questList = new NBTTagList(); + for(int questID : category.quests.keySet()){ + Quest quest = category.quests.get(questID); + questList.appendTag(quest.writeToNBT(new NBTTagCompound())); + if(questList.tagCount() > 50){ + questCompound = new NBTTagCompound(); + questCompound.setTag("Data", questList); + questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); + Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound); + questList = new NBTTagList(); + } + } + questCompound = new NBTTagCompound(); + questCompound.setTag("Data", questList); + questCompound.setTag("CatNBT", category.writeSmallNBT(new NBTTagCompound())); + Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, questCompound); + } + Server.sendToAll(EnumPacketClient.SYNC_END, SyncType.QUEST_CATEGORY, new NBTTagCompound()); + } + + public static void updateQuestCat(QuestCategory questCategory) { + NBTTagCompound questCompound; + NBTTagList questList = new NBTTagList(); + for(int questID : questCategory.quests.keySet()){ + Quest quest = questCategory.quests.get(questID); + questList.appendTag(quest.writeToNBT(new NBTTagCompound())); + if(questList.tagCount() > 50){ + questCompound = new NBTTagCompound(); + questCompound.setTag("Data", questList); + questCompound.setTag("CatNBT", questCategory.writeSmallNBT(new NBTTagCompound())); + Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.QUEST_CATEGORY, questCompound); + questList = new NBTTagList(); + } + } + questCompound = new NBTTagCompound(); + questCompound.setTag("Data", questList); + questCompound.setTag("CatNBT", questCategory.writeSmallNBT(new NBTTagCompound())); + Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.QUEST_CATEGORY, questCompound); + } + + public static void updateDialogCat(DialogCategory dialogCategory) { + NBTTagCompound dialogCompound; + NBTTagList dialogList = new NBTTagList(); + for(int questID : dialogCategory.dialogs.keySet()){ + Dialog dialog = dialogCategory.dialogs.get(questID); + dialogList.appendTag(dialog.writeToNBT(new NBTTagCompound())); + if(dialogList.tagCount() > 50){ + dialogCompound = new NBTTagCompound(); + dialogCompound.setTag("Data", dialogList); + dialogCompound.setTag("CatNBT", dialogCategory.writeSmallNBT(new NBTTagCompound())); + Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.DIALOG_CATEGORY, dialogCompound); + dialogList = new NBTTagList(); + } + } + dialogCompound = new NBTTagCompound(); + dialogCompound.setTag("Data", dialogList); + dialogCompound.setTag("CatNBT", dialogCategory.writeSmallNBT(new NBTTagCompound())); + Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.DIALOG_CATEGORY, dialogCompound); } public static void clientSync(int synctype, NBTTagCompound compound, boolean syncEnd) { diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java b/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java index 6199d9ad6..73edd5d52 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java @@ -8,6 +8,7 @@ import noppes.npcs.EventHooks; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.Server; import noppes.npcs.api.handler.IPlayerQuestData; +import noppes.npcs.api.handler.data.IParty; import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.constants.*; import noppes.npcs.controllers.PartyController; @@ -183,6 +184,17 @@ public class PlayerQuestData implements IPlayerQuestData { } } + public void trackParty(IParty party) { + if(party == null) + return; + + IQuest quest = party.getQuest(); + if (this.trackedQuest == null || quest.getId() != this.trackedQuest.getId()) { + this.trackedQuest = quest; + NoppesUtilPlayer.sendPartyTrackedQuestData((EntityPlayerMP) this.parent.player, (Party) party); + } + } + public void untrackQuest() { if (this.trackedQuest != null) { this.trackedQuest = null; diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 5e6263725..072e82ee8 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -567,12 +567,12 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti } break; case Stubborn: - if (closerTargetFound && combatHandler.shouldChangeTarget((double) ai.tacticalChance / 100)) { + if (closerTargetFound && combatHandler.shouldChangeTarget(ai.tacticalChance)) { setAttackTarget(attackingEntity); } break; case Tactical: - if (attackingEntity != getAttackTarget() && combatHandler.shouldSwitchTactically(getAttackTarget(), attackingEntity)) { + if (attackingEntity != getAttackTarget() && combatHandler.shouldSwitchTactically(getAttackTarget(), attackingEntity, ai.tacticalChance > 50)) { setAttackTarget(attackingEntity); } break; diff --git a/src/main/java/noppes/npcs/items/ItemNpcCloner.java b/src/main/java/noppes/npcs/items/ItemNpcCloner.java index edbda2f8d..dd2d3b96a 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcCloner.java +++ b/src/main/java/noppes/npcs/items/ItemNpcCloner.java @@ -27,7 +27,7 @@ public class ItemNpcCloner extends Item{ @Override public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10){ if(par3World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par2EntityPlayer, CustomNpcsPermissions.TOOL_CLONER)) - return true; + return false; NoppesUtilServer.setClonerGui((EntityPlayerMP) par2EntityPlayer, par4, par5, par6); return true; diff --git a/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java b/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java index 39b19a1fd..eaf5eab05 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java +++ b/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java @@ -38,41 +38,41 @@ public class ItemNpcMovingPath extends Item{ NoppesUtilServer.sendOpenGui(par3EntityPlayer, EnumGuiType.MovingPath, npc); return par1ItemStack; } - + @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int x, int y, int z, int par7, float par8, float par9, float par10){ + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int x, int y, int z, int par7, float par8, float par9, float par10){ if(par3World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(player, CustomNpcsPermissions.TOOL_MOUNTER)) return false; EntityNPCInterface npc = getNpc(par1ItemStack, par3World); if(npc == null) - return true; + return false; List list = npc.ai.getMovingPath(); int[] pos = list.get(list.size() - 1); list.add(new int[]{x,y,z}); - + double d3 = x - pos[0]; double d4 = y - pos[1]; double d5 = z - pos[2]; double distance = (double)MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5); - + player.addChatMessage(new ChatComponentText("Added point x:" + x + " y:"+ y + " z:" + z + " to npc " + npc.getCommandSenderName())); if(distance > ConfigMain.NpcNavRange) player.addChatMessage(new ChatComponentText("Warning: point is too far away from previous point. Max block walk distance = " + ConfigMain.NpcNavRange)); - + return true; } - + private EntityNPCInterface getNpc(ItemStack item, World world){ if(world.isRemote || item.stackTagCompound == null) return null; - + Entity entity = world.getEntityByID(item.stackTagCompound.getInteger("NPCID")); if(entity == null || !(entity instanceof EntityNPCInterface)) return null; - + return (EntityNPCInterface) entity; } - + @Override public int getColorFromItemStack(ItemStack par1ItemStack, int par2){ return 0x8B4513; @@ -82,7 +82,7 @@ public class ItemNpcMovingPath extends Item{ public boolean requiresMultipleRenderPasses(){ return true; } - + @SideOnly(Side.CLIENT) @Override public void registerIcons(IIconRegister par1IconRegister){ diff --git a/src/main/java/noppes/npcs/items/ItemNpcWand.java b/src/main/java/noppes/npcs/items/ItemNpcWand.java index e512576a7..7a12585dd 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcWand.java +++ b/src/main/java/noppes/npcs/items/ItemNpcWand.java @@ -42,9 +42,10 @@ public class ItemNpcWand extends Item{ public boolean onItemUse(ItemStack par1ItemStack, final EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if(par3World.isRemote) - return true; + return false; if(ConfigMain.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile())){ player.addChatMessage(new ChatComponentTranslation("availability.permission")); + return false; } else if(CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.NPC_CREATE)){ EntityCustomNpc npc = new EntityCustomNpc(par3World); @@ -56,10 +57,11 @@ public class ItemNpcWand extends Item{ npc.setHealth(npc.getMaxHealth()); NoppesUtilServer.sendOpenGuiNoDelay(player, EnumGuiType.MainMenuDisplay,npc); + return true; } else player.addChatMessage(new ChatComponentTranslation("availability.permission")); - return true; + return false; } @Override diff --git a/src/main/java/noppes/npcs/quests/QuestDialog.java b/src/main/java/noppes/npcs/quests/QuestDialog.java index 72b58b9f7..a4e73b5a6 100644 --- a/src/main/java/noppes/npcs/quests/QuestDialog.java +++ b/src/main/java/noppes/npcs/quests/QuestDialog.java @@ -454,6 +454,28 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { @Override public String getAdditionalText() { + if(party != null && party.getObjectiveRequirement() == EnumPartyObjectives.All){ + List incomplete = new ArrayList<>(); + for (UUID uuid: party.getPlayerUUIDs()) { + EntityPlayer individual = NoppesUtilServer.getPlayer(uuid); + PlayerData individualData; + if(individual != null){ + individualData = PlayerDataController.Instance.getPlayerData(individual); + } + else { + individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); + } + if(individualData != null){ + boolean read = individualData.dialogData.dialogsRead.contains(this.dialog.id); + if(!read) { + incomplete.add(individualData.playername); + } + } + } + if(!incomplete.isEmpty()) + return "[" + String.join(", ", incomplete) + "]"; + + } return null; } } diff --git a/src/main/java/noppes/npcs/quests/QuestInterface.java b/src/main/java/noppes/npcs/quests/QuestInterface.java index 1fa44ce11..b84722421 100644 --- a/src/main/java/noppes/npcs/quests/QuestInterface.java +++ b/src/main/java/noppes/npcs/quests/QuestInterface.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.api.handler.data.IQuestInterface; import noppes.npcs.api.handler.data.IQuestObjective; +import noppes.npcs.constants.EnumPartyObjectives; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; @@ -24,7 +25,12 @@ public abstract class QuestInterface implements IQuestInterface { } } } - public abstract Vector getQuestLogStatus(EntityPlayer player); + + public void handlePartyComplete(EntityPlayer player, Party party, boolean isLeader, EnumPartyObjectives objectives){ + handleComplete(player); + } + + public abstract Vector getQuestLogStatus(EntityPlayer player); public abstract IQuestObjective[] getObjectives(EntityPlayer var1); diff --git a/src/main/java/noppes/npcs/quests/QuestItem.java b/src/main/java/noppes/npcs/quests/QuestItem.java index 124b369e6..fdae99002 100644 --- a/src/main/java/noppes/npcs/quests/QuestItem.java +++ b/src/main/java/noppes/npcs/quests/QuestItem.java @@ -9,7 +9,6 @@ import noppes.npcs.NpcMiscInventory; import noppes.npcs.api.handler.data.IQuestItem; import noppes.npcs.api.handler.data.IQuestObjective; import noppes.npcs.constants.EnumPartyObjectives; -import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.scripted.CustomNPCsException; @@ -93,29 +92,47 @@ public class QuestItem extends QuestInterface implements IQuestItem { super.handleComplete(player); if(leaveItems) return; - for(ItemStack questitem : items.items.values()){ - int stacksize = questitem.stackSize; - for(int i = 0; i < player.inventory.mainInventory.length; i++){ - ItemStack item = player.inventory.mainInventory[i]; - if(item == null) - continue; - if(NoppesUtilPlayer.compareItems(item, questitem, ignoreDamage, ignoreNBT)){ - int size = item.stackSize; - if(stacksize - size >= 0){ - player.inventory.setInventorySlotContents(i, null); - item.splitStack(size); - } - else{ - item.splitStack(stacksize); - } - stacksize -= size; - if(stacksize <= 0) - break; - } - } - } + removeItems(player); } + public void handlePartyComplete(EntityPlayer player, Party party, boolean isLeader, EnumPartyObjectives objectives){ + super.handlePartyComplete(player, party, isLeader, objectives); + if(leaveItems) + return; + + if(isLeader && objectives == EnumPartyObjectives.Leader){ + removeItems(player); + } else if (objectives == EnumPartyObjectives.All){ + removeItems(player); + } else if (objectives == EnumPartyObjectives.Shared){ + // Shared Case + } + } + + public void removeItems(EntityPlayer player){ + for(ItemStack questitem : items.items.values()){ + int stacksize = questitem.stackSize; + for(int i = 0; i < player.inventory.mainInventory.length; i++){ + ItemStack item = player.inventory.mainInventory[i]; + if(item == null) + continue; + if(NoppesUtilPlayer.compareItems(item, questitem, ignoreDamage, ignoreNBT)){ + int size = item.stackSize; + if(stacksize - size >= 0){ + player.inventory.setInventorySlotContents(i, null); + item.splitStack(size); + } + else{ + item.splitStack(stacksize); + } + stacksize -= size; + if(stacksize <= 0) + break; + } + } + } + } + @Override public Vector getQuestLogStatus(EntityPlayer player) { Vector vec = new Vector(); @@ -528,6 +545,29 @@ public class QuestItem extends QuestInterface implements IQuestItem { @Override public String getAdditionalText() { + if(party != null && party.getObjectiveRequirement() == EnumPartyObjectives.All) { + List incompletePlayers = new ArrayList<>(); + EnumPartyObjectives objectives = party.getObjectiveRequirement(); + for (String name : party.getPlayerNames()) { + EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); + if (playerMP == null){ + incompletePlayers.add(name + ": " + "N/A"); + continue; + } + + int amount = 0; + for (ItemStack is : playerMP.inventory.mainInventory) { + if (NoppesUtilPlayer.compareItems(this.questItem, is, ignoreDamage, ignoreNBT)) + amount += is.stackSize; + } + + int completedSize = ValueUtil.clamp(amount, 0, this.questItem.stackSize); + if(completedSize < this.questItem.stackSize) + incompletePlayers.add(name + ": " + completedSize); + } + if(!incompletePlayers.isEmpty()) + return "[" + String.join(", ", incompletePlayers) + "]"; + } return null; } } diff --git a/src/main/java/noppes/npcs/quests/QuestKill.java b/src/main/java/noppes/npcs/quests/QuestKill.java index 3e2a377b2..a62a0f58d 100644 --- a/src/main/java/noppes/npcs/quests/QuestKill.java +++ b/src/main/java/noppes/npcs/quests/QuestKill.java @@ -348,11 +348,35 @@ public class QuestKill extends QuestInterface implements IQuestKill { } public String getText() { + if(party != null) { + if(party.getObjectiveRequirement() == EnumPartyObjectives.All ){ + return this.entity + ": " + this.getMaxProgress() + (isCompleted() ? " (Done)" : ""); + } + } return this.entity + ": " + this.getProgress() + "/" + this.getMaxProgress(); } @Override public String getAdditionalText() { + if(party != null) { + List incompletePlayers = new ArrayList<>(); + QuestData questdata = party.getQuestData(); + if (questdata != null) { + if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { + for (String player : party.getPlayerNames()) { + HashMap killed = this.parent.getPlayerKilled(questdata, player); + int currentProgress = !killed.containsKey(this.entity) ? 0 : (Integer) killed.get(this.entity); + if(currentProgress < this.amount){ + String state = player + ": " + currentProgress; + incompletePlayers.add(state); + } + } + if(!incompletePlayers.isEmpty()) + return "[" + String.join(", ", incompletePlayers) + "]"; + } + } + } + return null; } } diff --git a/src/main/java/noppes/npcs/quests/QuestLocation.java b/src/main/java/noppes/npcs/quests/QuestLocation.java index fcd480316..44bb59dcf 100644 --- a/src/main/java/noppes/npcs/quests/QuestLocation.java +++ b/src/main/java/noppes/npcs/quests/QuestLocation.java @@ -260,6 +260,17 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { return vec; } + public boolean isMultiQuest(Party party){ + QuestData data = party.getQuestData(); + if(data == null) + return false; + + if(data.quest == null) + return false; + + return data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All; + } + @Override public boolean isPartyCompleted(Party party) { if(party == null) @@ -383,7 +394,9 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { } public String getAdditionalText() { - return "Completed: " + String.join(", ", completedPlayers); + if(party != null && parent.isMultiQuest(party) && completedPlayers.size() != party.getPlayerNames().size()) + return "Completed: " + String.join(", ", completedPlayers); + return null; } } } diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java index 782321582..035bf1028 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java @@ -256,7 +256,7 @@ public class ScriptGui implements ICustomGui { for(int i = 0; i < list.tagCount(); i++){ NBTBase b = list.getCompoundTagAt(i); ScriptGuiComponent component = ScriptGuiComponent.createFromNBT((NBTTagCompound)b); - if (component != null) { + if (component != null && !(component instanceof ScriptGuiItemSlot)) { components.put(component.getID(), component); } } @@ -267,6 +267,7 @@ public class ScriptGui implements ICustomGui { for(int i = 0; i < list.tagCount(); i++){ NBTBase b = list.getCompoundTagAt(i); ScriptGuiItemSlot component = (ScriptGuiItemSlot)ScriptGuiComponent.createFromNBT((NBTTagCompound)b); + components.put(component.getID(), component); slots.add(component); } diff --git a/src/main/java/tconstruct/client/tabs/InventoryTabCustomNpc.java b/src/main/java/tconstruct/client/tabs/InventoryTabCustomNpc.java index d4ed35488..726d6030e 100644 --- a/src/main/java/tconstruct/client/tabs/InventoryTabCustomNpc.java +++ b/src/main/java/tconstruct/client/tabs/InventoryTabCustomNpc.java @@ -4,10 +4,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import noppes.npcs.CustomItems; -import noppes.npcs.client.gui.player.inventory.GuiCNPCInventory; -import noppes.npcs.client.gui.player.inventory.GuiFaction; -import noppes.npcs.client.gui.player.inventory.GuiParty; -import noppes.npcs.client.gui.player.inventory.GuiQuestLog; +import noppes.npcs.client.gui.player.inventory.*; public class InventoryTabCustomNpc extends AbstractTab { public InventoryTabCustomNpc() { @@ -30,19 +27,19 @@ public class InventoryTabCustomNpc extends AbstractTab { e.printStackTrace(); } Minecraft mc = Minecraft.getMinecraft(); - if(mc.currentScreen instanceof GuiCNPCInventory) - return; - switch (GuiCNPCInventory.activeTab){ case 0: - mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer)); + mc.displayGuiScreen(new GuiQuestLog()); break; case 1: - mc.displayGuiScreen(new GuiParty(mc.thePlayer)); + mc.displayGuiScreen(new GuiParty()); break; case 2: mc.displayGuiScreen(new GuiFaction()); break; + case 3: + mc.displayGuiScreen(new GuiSettings()); + break; } } }; diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index 630f70cc5..a0a9c8883 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -108,6 +108,7 @@ gui.copy=Copy gui.clear=Clear gui.done=Done gui.paste=Paste +gui.test=Test gui.settings=Settings gui.enabled=Enabled gui.website=Website @@ -184,6 +185,20 @@ party.partyRequirements=Required by party.setQuestConfirm=Setting a Quest to a party will clear its progress! party.dropQuestConfirm=Are you sure you want to drop the party quest?` +settings.chatBubbles=Chat Bubbles +settings.trackAlignment=Tracking Alignment +settings.dialogSound=Dialog Sound +settings.dialogSpeed=Dialog Speed +settings.chatAlerts=Chat Alerts +settings.bannerAlerts=Banner Alerts +settings.alignmentX=Alignment X +settings.alignmentY=Alignment Y +settings.trackScale=Tracking Scale +settings.clearTrack=Clear Tracked Quest +settings.confirmClearTrack=Are you sure you want to clear your tracked quest? +settings.clearSkin=Clear Skin Cache +settings.confirmClearSkin=Are you sure you want to clear your skin cache? + scale.shared=Shared filter.contains=Contains filter.any=Any @@ -364,6 +379,7 @@ stats.candrown=Drowns stats.firesound:=SoundFX stats.creaturetype=CreatureType stats.normal=Normal +stats.reverse=Reverse stats.undead=Undead stats.arthropod=Arthropod stats.nofalldamage=NoFallDamage @@ -548,6 +564,7 @@ dialog.option=Dialog Option dialog.roleoption=Role Option dialog.commandoption=Command Option dialog.commandoptionplayer=Use "@dp" to target the player using this +dialog.commandmultiple=Use "@x" to split the command to append multiple dialog.hideNPC=Hide NPC dialog.showWheel=Show Dialog Wheel dialog.disableEsc=Disable Esc diff --git a/src/main/resources/assets/customnpcs/textures/gui/icons.png b/src/main/resources/assets/customnpcs/textures/gui/icons.png new file mode 100644 index 000000000..80d28fa9b Binary files /dev/null and b/src/main/resources/assets/customnpcs/textures/gui/icons.png differ