Posted March 5, 20196 yr I'm trying to call a function every tick for each ItemStack that is a type of my Item. How would I do that?
March 5, 20196 yr When? When in the player's inventory? Please clarify. To call a function every tick when the item stack is in the player's inventory, override Item#onUpdate. Edited March 5, 20196 yr by DavidM Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
March 5, 20196 yr Author 50 minutes ago, DavidM said: When? When in the player's inventory? Please clarify. To call a function every tick when the item stack is in the player's inventory, override Item#onUpdate. Generally anywhere. Like if it's in a player inventory, or a chest inventory (as long as it's loaded) or on the floor?
March 6, 20196 yr 36 minutes ago, FrostBytes said: Generally anywhere. Like if it's in a player inventory, or a chest inventory (as long as it's loaded) or on the floor? In this case you need to use different method fr each. I don't think this is possible with the chest inventory though (in which case you have to create your own chest). As for on the floor, override Item#onEntityItemUpdate. Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
March 6, 20196 yr What do you want to achieve? There might be other ways to achieve what you want. 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/
March 6, 20196 yr Author 47 minutes ago, DavidM said: In this case you need to use different method fr each. I don't think this is possible with the chest inventory though (in which case you have to create your own chest). As for on the floor, override Item#onEntityItemUpdate. Would it be possible to override functionality of the vanilla chest from the mod?
March 6, 20196 yr 25 minutes ago, FrostBytes said: Would it be possible to override functionality of the vanilla chest from the mod? It could be done, but would be a bad idea. You might as well create your own chest that has your custom functionalities. You can take a look at the code of the alchemical chest in ProjectE, which does exactly what you described (allow custom items update inside chest). Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
March 6, 20196 yr You also can't do anything about inventories that aren't loaded. 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.
March 6, 20196 yr If you're trying to do something that changes at a constant rate over time, you can do it using timestamps. What exactly is the goal?
March 6, 20196 yr Author 14 hours ago, Laike_Endaril said: If you're trying to do something that changes at a constant rate over time, you can do it using timestamps. What exactly is the goal? I’m trying to run code every tick for every itemstack currently loaded.
March 6, 20196 yr That much is obvious. What will this achieve for an end user perspective? About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
March 6, 20196 yr Double post Edited March 6, 20196 yr by Cadiboo About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
March 6, 20196 yr Author 14 minutes ago, Cadiboo said: That much is obvious. What will this achieve for an end user perspective? It's going to just be code that randomly checks if there is a certain container nearby and move the itemstack into it. Not sure how that would contribute to this.
March 6, 20196 yr Because there are better ways of doing this than the one you’re trying. For example, putting the item into the container from the container. This is super easy if the container has something that runs every tick (like an Entity or a TileEntity). What you’re trying to do is always relevant, because there’s usually a better way of doing it. About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
March 6, 20196 yr Author 1 hour ago, Cadiboo said: Because there are better ways of doing this than the one you’re trying. For example, putting the item into the container from the container. This is super easy if the container has something that runs every tick (like an Entity or a TileEntity). What you’re trying to do is always relevant, because there’s usually a better way of doing it. Wow. Never really thought of that. Thanks.
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.