AkitaAttribute Posted November 14, 2021 Posted November 14, 2021 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.) Quote
Draco18s Posted November 14, 2021 Posted November 14, 2021 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. Quote 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.
AkitaAttribute Posted November 14, 2021 Author Posted November 14, 2021 (edited) 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 November 14, 2021 by AkitaAttribute More info. Quote
AkitaAttribute Posted November 14, 2021 Author Posted November 14, 2021 The big difference I see is that: public void tick() { if (net.minecraftforge.common.ForgeHooks.onLivingUpdate(this)) return; the onLivingUpdate has a Forge Hook. Maybe there isn't a ItemEntity version of this? Quote
AkitaAttribute Posted November 14, 2021 Author Posted November 14, 2021 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. Quote
Draco18s Posted November 14, 2021 Posted November 14, 2021 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). Quote 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.
AkitaAttribute Posted November 14, 2021 Author Posted November 14, 2021 @Draco18s, that actually helped a lot. I was able to reference this past post: Post and find exactly what I needed. Quote
Recommended Posts
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.