Posted July 23, 20169 yr Hey! Just a quick question; I've already tried playing around with the NBT compounds, but I can't seem to find out how to effectively save the lore of an itemstack in a String list. If anyone has an answer, I'd be delighted to hear it! Also, is it somehow possible to determine which colorcode was used in an itemname? I tried checking for the sign, e.g. ...contains("§5") but it doesn't seem to work.
July 23, 20169 yr Try using contains(TextFormatting.WHATEVER.toString()) instead of typing in the section symbol itself. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
July 23, 20169 yr Author Try using contains(TextFormatting.WHATEVER.toString()) instead of typing in the section symbol itself. Sadly, if (item.getEntityItem().getDisplayName().contains(TextFormatting.DARK_PURPLE.toString())) { doesn't seem to work either
July 24, 20169 yr Author You need to use ItemStack#getTextComponent . Then you can use ITextComponent#getStyle().getColor() to obtain the color (or null). But I am not sure this includes manually specified colors via color codes, so you need to scan for those as well inside ITextComponent#getUnformattedComponentText . Tried it using if (item.getEntityItem().getChatComponent().getChatStyle().getColor().equals(TextFormatting.DARK_PURPLE)) { , but without success
July 24, 20169 yr Author Ok, where is this purple coming from? What kinda ItemStack is it? All kind of items, ranging from weapons to slabs; the name is written in color, and as I didn't figure out how to properly read the lore yet, the only way to determine the "rarity" (RPG-server) of the item is to check the color.
July 24, 20169 yr Author Use whatever is used to figure out the rarity directly. That'd be the lore, and that was also part of the original question. As I said, I didn't find a way to read it out properly yet
July 25, 20169 yr Author What do you mean by lore? The display name? https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR3sfHoEiihxkitT61P1LbE5jhGOWdyBtLVel-lHwlZe6v9dgOx[/img] This is an example item; In order to know which "rarity" it has, I can either read the color (Aqua = "Legendary") or the lore, which states "Legendary Item"
July 26, 20169 yr What do you mean by lore? The display name? Lore is strings to be shown on tooltips stored in the itemstack, and frequently used by bukkit plugin developers. They stores every information about the itemstack there. (It's the only way to do that in plugin. Might be abstraction disaster) This is an example item; In order to know which "rarity" it has, I can either read the color (Aqua = "Legendary") or the lore, which states "Legendary Item" Is it generated by a plugin? Or another mod? If it's a mod, there is definitely better way. If it's a plugin, item.getTagCompound().getCompoundTag("display").getTagList("Lore", ; gives the nbt list with strings which represents the lore. use #tagCount which means the size of the list, and #getStringTagAt(i) to get the i-th lore string. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.