Jump to content

ItemEntity version of LivingEvent.LivingUpdateEvent?


AkitaAttribute

Recommended Posts

I don't see an event associated with this.  I see under ItemEntity's "Tick" method that there is a 

if (getItem().onEntityItemUpdate(this)) return;

Just like there is in the LivingUpdateEvent, however I'm not sure where it corresponds to an event.  Inb4 "use your IDE", I did.  ItemEvent has very few events branching from it, leading me to believe it's under some other name.  Such as:

default boolean onEntityItemUpdate(ItemEntity entity)
    {
        return getStack().getItem().onEntityItemUpdate(getStack(), entity);
    }

Under the IForgeItemStack.  But I honestly don't know how to subscribe to that.  

Quote

Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner control over the update of the item without having to write a subclass.
Params:
entity – The entity Item
Returns:
Return true to skip any further update code.

I feel like I'm in the right place, but I don't know the correct syntax.  I looked on CurseForge for example mods, and although BetterDroppedItems seems like it'd modify this kind of behavior, it doesn't.  (just wanted to show ambition rather than just posting for help on first sign of problem.)

 

Link to comment
Share on other sites

What are you trying to do?

This code:

if (getItem().onEntityItemUpdate(this)) return;

Calls the onEntityItemUpdate method on the Item. You don't subscribe to it, it's not an event, it's a method you override in your item class.

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

I'm trying to subscribe to the non-living entity version of LivingEvent.LivingUpdateEvent.  Items floating after drop (their update ticks).  Experience orbs (their update ticks).  I'm not seeing events to subscribe to non-living entities.

EDIT:
The goal is to apply a change to them when they are created, then remove it after a certain amount of time is past.  This works great when I can just do a quick check to see if the entity has the change already done, then run a check to see if it's time to remove.

 

@SubscribeEvent
    public void onLivingEntityUpdate(LivingEvent.LivingUpdateEvent event) {
        if(event.getEntityLiving().isGlowing()) {
            Entity entity = event.getEntityLiving();
            if (glowHelper.removeGlowing(entity)) {
                entity.setGlowing(false);
                messageAllPlayers("Attempted to remove glowing. [Glowing][" + entity.isGlowing() + "][UUID]["
                        + entity.getUniqueID() + "]");
            }
        }
    }

 

Edited by AkitaAttribute
More info.
Link to comment
Share on other sites

I supposed I could override it, and make my own event.  I was hoping to avoid that kind of work haha.  Thanks for the suggestion.  It kinda made me think about it more.  I was hoping it already existed.

 

I find some of your responses very... unhelpful... on this forum.  So I wasn't ready to immediately dismiss that it may exist already.

Link to comment
Share on other sites

Generally speaking the way to handle this is to catch the ItemEntity spawn (EntityJoinedWorldEvent) and substitute a custom entity class (cancel the event, spawn your own item entity).

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

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



×
×
  • Create New...

Important Information

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