Jump to content

Reflection making items invisible?


Coder

Recommended Posts

Hello,

 

I am using reflection to get an item's display name by replacing its data manager.

the only thing I am changing there is setEntryValues in which I find the itemStack and like this, I get the item display name.

Sometimes when an item spawns it will disappear client side but when I will walk to the item location I will pick it up. Is it possible that forge is removing the visibility of the item for some reason?

Link to comment
Share on other sites

You're likely doing something wrong. You should stop doing it wrong.

 

Spoiler

Post your code?

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

20 hours ago, Draco18s said:

You're likely doing something wrong. You should stop doing it wrong.

 

  Hide contents

Post your code?

 

Sure

Spoiler

    private static final Field DATA_FIELD;
    static {
        {
            Class<?> clazz = Entity.class;
            Field f = null;
            for (Field field : clazz.getDeclaredFields()) {
                if (field.getType() == EntityDataManager.class) {
                    f = field;
                    break;
                }
            }
            f.setAccessible(true);
            DATA_FIELD = f;
        }
    }
    
    public static void setEntityDataManager (Entity entity, EntityDataManager manager ) {
        try {
            DATA_FIELD.set(entity, manager);
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

 

 
 

 

Edited by Coder
Link to comment
Share on other sites

1 minute ago, diesieben07 said:

Uhm, what? Why are you doing that?

Please clarify what exactly you want to achieve. You should not have to replace the EntityDataManager.

Just get the custom name of the item.

Link to comment
Share on other sites

IIRC, ItemStack#getDisplayName returns the custom name if the stack has one. What else are you trying to do?

Edited by larsgerrits

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Just now, diesieben07 said:

EntityJoinWorldEvent fires when an entity joins the world. There are no item stacks involved. Please clarify which ItemStack you want to access.

I would like to get the name of every item that "joins" the world. Meaning the entity item that's on the ground.

Link to comment
Share on other sites

9 minutes ago, diesieben07 said:

EntityItem#getItem returns the ItemStack contained in the EntityItem.

 

This is a classic XY problem. In the future please state your desired result, not how you tried to get to that result.

Aha! But for some reason it returns "Air" instead on the item name

Link to comment
Share on other sites

Just now, diesieben07 said:

On the client the EntityDataManager will only be updated with a subsequent packet.

What are you trying to do with this name?

I would like to target items with a specific custom name for highlighting etc

Link to comment
Share on other sites

1 minute ago, diesieben07 said:

You need to stop being vague. In that specific event handler, what exactly would you do with the name, and why?

I would like to get the item that has joined, get its name, take that name check if it is included inside an array if so, tell me that this item is there and it has the said custom name.

I want to highlight items that spawn when you have many items on the ground it is very helpful. That's all.

Link to comment
Share on other sites

1 minute ago, diesieben07 said:

Define "highlight". I assume that means you want to draw some kind of overlay? If so, EntityJoinWorldEvent is the wrong place to do so anyways.

Yeah, or just send a chat message to start of. Is it possible to get the name of the item at all with EntityJoinWorldEvent?

Link to comment
Share on other sites

1 minute ago, diesieben07 said:

If you want to draw an overlay, check the name wherever you draw the overlay.

If you want to send a chat message, see above.

Yes, but didn't we say it's not possible to get the name of the item using this method?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello! My friends and I were attempting to add a few extra mods to the Create Chronicles modpack, and all was well until people started crashing when they opened their inventories. Any help finding the culprit would be MUCH appreciated, I've been scratching my head for the past few days on what went wrong. https://paste.ee/p/8pajP
    • >>>KLIK LOGIN DISINI SAYANG<<< >>>KLIK DAFTAR DISINI SAYANG<<< Pendahuluan Dalam dunia perjudian online, slot menjadi salah satu permainan yang paling diminati. Dengan munculnya berbagai platform, Togel2Win hadir sebagai salah satu pilihan menarik, terutama dengan fitur anti rungkad yang dijanjikan. Artikel ini akan membahas tentang Togel2Win, keunggulan slot terbaru, dan bagaimana server Thailand berperan dalam meningkatkan pengalaman bermain. Apa Itu Togel2Win? Togel2Win adalah platform permainan yang menawarkan berbagai jenis permainan, termasuk slot dan togel. Dengan antarmuka yang ramah pengguna dan beragam pilihan permainan, situs ini bertujuan untuk memberikan pengalaman bermain yang menyenangkan dan menguntungkan bagi para pemain. Keunggulan Slot Togel2Win Fitur Anti Rungkad: Salah satu keunggulan utama dari Togel2Win adalah fitur anti rungkad yang dirancang untuk mengurangi kemungkinan gangguan saat bermain. Ini memastikan bahwa pemain dapat menikmati permainan tanpa gangguan teknis, meningkatkan kenyamanan dan fokus. Beragam Pilihan Slot: Togel2Win menawarkan berbagai jenis slot, dari yang klasik hingga yang modern dengan grafis menawan dan tema yang menarik. Ini memberikan variasi yang cukup bagi pemain untuk menemukan permainan yang sesuai dengan preferensi mereka. Server Thailand yang Stabil: Server yang berlokasi di Thailand memberikan koneksi yang cepat dan stabil. Ini sangat penting untuk pengalaman bermain yang lancar, terutama saat bermain slot yang memerlukan respons cepat. Bonus dan Promosi Menarik: Togel2Win sering menawarkan bonus dan promosi yang menarik untuk menarik pemain baru dan mempertahankan loyalitas pemain yang sudah ada. Ini bisa berupa bonus deposit, putaran gratis, atau program loyalitas. Tips untuk Pemain Slot di Togel2Win Pilih Slot dengan RTP Tinggi: Sebelum memulai permainan, pastikan untuk memilih slot dengan tingkat pengembalian pemain (RTP) yang tinggi untuk meningkatkan peluang menang. Kelola Anggaran: Tentukan batasan anggaran sebelum bermain dan patuhi itu. Ini membantu mencegah kerugian besar dan menjaga pengalaman bermain tetap menyenangkan. Manfaatkan Bonus: Jangan ragu untuk memanfaatkan bonus dan promosi yang ditawarkan. Ini bisa memberikan tambahan modal untuk bermain lebih lama. Kesimpulan Togel2Win merupakan pilihan menarik bagi para penggemar slot, terutama dengan fitur anti rungkad dan server yang stabil. Dengan berbagai pilihan permainan dan bonus yang menggiurkan, Togel2Win siap memberikan pengalaman bermain yang tak terlupakan. Jika Anda mencari platform slot yang andal dan menyenangkan, Togel2Win bisa menjadi solusi yang tepat.
    • I'm trying to make my own modpack, but sometimes, in certain areas of the world, the game just says "server closed". Minecraft doesn't close, it just returns to the menu. When I tried to figure it out on my own and understand the logs, I didn't understand anything (English is not my native language, so it's difficult for me). I've been trying to solve the problem for the third month. So I ask if anyone is good at this and it's not difficult for you, to help me with this. If you need details, ask. I'll describe everything. What it looks like Logs
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.