-
Reading Item lore & colorcode
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"
-
Client Side events
In other words, you're writing a client-side mod to defeat the purpose and rules of a server (i.e. cheating). I think we're done here. You shouldn't try to judge before you know the whole story. It was more of an experiment at first, and after I was done I asked for allowance, which was given to me.
-
Reading Item lore & colorcode
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
-
Reading Item lore & colorcode
Do you have any better ideas?
-
Reading Item lore & colorcode
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.
-
Reading Item lore & colorcode
Tried it using if (item.getEntityItem().getChatComponent().getChatStyle().getColor().equals(TextFormatting.DARK_PURPLE)) { , but without success
-
Client Side events
Thanks for the advice! The mod was written for a "RPG" server, where items dropped are unidentified, and there is no way to know which item you'll get unless you take it to a npc and so on, therefore this code is quite helpful for reading out the name of anything that's dropped nearby, to stop unecessary collecting of items.
-
Reading Item lore & colorcode
Sadly, if (item.getEntityItem().getDisplayName().contains(TextFormatting.DARK_PURPLE.toString())) { doesn't seem to work either
-
Reading Item lore & colorcode
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.
-
Client Side events
This solution now works for me, I do hope I did it right this time package at.skyblok.client; import java.util.LinkedList; import java.util.Queue; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class WynncraftEvents { Queue<Runnable> queue; public WynncraftEvents() { queue = new LinkedList<Runnable>(); } void addTask(Runnable r) { queue.add(r); } @SubscribeEvent public void onPlayerUpdate(LivingUpdateEvent e) { if (e.getEntity() != null && Minecraft.getMinecraft().thePlayer != null) { if (e.getEntity().getDistanceToEntity(Minecraft.getMinecraft().thePlayer) <= 10) { while (!queue.isEmpty()) { queue.remove().run(); } } } } @SubscribeEvent public void onSpawn(final EntityJoinWorldEvent e) { if (e.getEntity() != null && Minecraft.getMinecraft().thePlayer != null) { if (e.getEntity().getDistanceToEntity(Minecraft.getMinecraft().thePlayer) <= 10) { if (e.getEntity() instanceof EntityItem) { addTask(new Runnable() { @Override public void run() { readItem(e.getEntity()); } }); } } } } private void readItem(Entity en) { EntityItem item = (EntityItem) en; Util.chat(Minecraft.getMinecraft().thePlayer, "Item: " + item.getEntityItem().getDisplayName(), TextFormatting.GREEN); } }
-
Client Side events
Sorry! To be honest, I never quite touched timers I know there is the update methode called once per tick, but how would I implement it in this case? Wouldn't it have to be "counted" within the EntityJoinWorldEvent?
-
Client Side events
Nevermind, used the wrong timer For everyone still seeking a solution, this one works for me! @SubscribeEvent public void onSpawn(final EntityJoinWorldEvent e) { new java.util.Timer().schedule(new java.util.TimerTask() { @Override public void run() { if (e.getEntity() != null && Minecraft.getMinecraft().thePlayer != null) { if (e.getEntity().getDistanceToEntity(Minecraft.getMinecraft().thePlayer) <= 10) { EntityItem item = (EntityItem) e.getEntity(); Util.chat(Minecraft.getMinecraft().thePlayer, "Item: " + item.getEntityItem().getDisplayName(), TextFormatting.GREEN); } } } }, 100); }
-
Client Side events
Tried that; it doesn't seem to do the trick. While it works in singleplayer (where it is fired twice, for some reason. One time with stone and one time with the right item), it doesn't work with multiplayer
-
Client Side events
Would a scheduler delaying the "reading" of the item work, or is there a second event used?
-
Client Side events
While the code is now working perfectly in Singleplayer, the item is always "Stone" in multiplayer. Is this due to the Server not passing on information about the item? Currently using @SubscribeEvent public void onSpawn(EntityJoinWorldEvent e) { if (e.getEntity() != null && Minecraft.getMinecraft().thePlayer != null) { if (e.getEntity().getDistanceToEntity(Minecraft.getMinecraft().thePlayer) <= 10) { if (e.getEntity() instanceof EntityItem) { EntityItem item = (EntityItem) e.getEntity(); Util.chat(Minecraft.getMinecraft().thePlayer, "Item: " + item.getEntityItem().getDisplayName(), TextFormatting.GREEN); } } } }
IPS spam blocked by CleanTalk.