Posted May 1, 201312 yr I was hoping it would be a simple Forge Event check, but as far as I can tell, it definitely isn't. Has anyone does this before? Any tips on where I should start? --> Back to coding... Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
May 1, 201312 yr Author I'm trying to create a mod that will keep track of all player actions, ie putting items in chests, taking items out of chests, picking up items, dropping items, destroying and placing blocks..etc. The last four seem pretty self-explanatory, for the most part (buckets excluded), but it doesn't seem that there is a way to actively get Chest events. Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
May 2, 201312 yr A little bit of a hack-y workaround you could use is to just monitor changes with updateEntity(). Store the inventory contents each tick (or as often as you want to evaluate) and then compare with the last contents (ItemStack[]). Follow my mod(s) here: http://www.minecraftforum.net/topic/1969694-
May 2, 201312 yr Author There are no events for breaking / placing blocks either. You have to do such things by becoming a coremod and make your own hooks via ASM. Thats not easy, as it requires you to understand java bytecode quite well. I'm already a coremod, as this is for a single server that won't be working with anything else and I've had to make some...interesting..changes...thus far.. But I've already done 'placing/breaking' blocks using just events- in my zone protection mod. So I don't think it'll be a huge issue. @Reika: I was considering something like that if it absolutely came down to it, but I'm worried about the efficiency hit. I've already introduced several other things that have had minor detrimental effects on FPS, and anything that does a check every tick for every chest is a little worrisome. If it's not possible with events- is there anywhere in the core code that I should start at? Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
May 2, 201312 yr maybe you could parse the ItemStack[] into a separate thread and then process it in the other thread so the main Minecraft thread doesn't take a huge hit every tick comparing old itemstack to new itemstack. obviously still going to get a hit if the CPU affinity is 1.
May 2, 201312 yr @Reika: I was considering something like that if it absolutely came down to it, but I'm worried about the efficiency hit. I've already introduced several other things that have had minor detrimental effects on FPS, and anything that does a check every tick for every chest is a little worrisome. If it's not possible with events- is there anywhere in the core code that I should start at? I do far larger things on every tick, and even my so-slow-it-takes-longer-to-boot-than-the-battery-lasts laptop is not strongly affected. And I mean something like 400 lines of code - per TileEntity - with half a dozen method calls, including this monstrosity: public int[] findSourceBlock(World world, int x, int y, int z) { int[] loc = {x,y-1,z}; int tries = 0; boolean found = false; //ModLoader.getMinecraftInstance().ingameGUI.addChatMessage(String.format("%d", world.getBlockId(x, y-1, z))); while (!this.isSource(world, loc[0], loc[1], loc[2]) && tries < 200 && !found) { //ModLoader.getMinecraftInstance().ingameGUI.addChatMessage(String.format("%d %d %d %d", loc[0], loc[1], loc[2], world.getBlockId(loc[0], loc[1], loc[2]))); loc[0] += -1 + par5Random.nextInt(3); loc[1] = y -6 + par5Random.nextInt(7); loc[2] += -1 + par5Random.nextInt(3); tries++; // to prevent 1fps if (ReikaMathLibrary.py3d(loc[0]-x, 0, loc[2]-z) > 16) { loc[0] = x; loc[2] = z; } } //ModLoader.getMinecraftInstance().ingameGUI.addChatMessage(String.format("%d %d %d %d", loc[0], loc[1], loc[2], world.getBlockId(loc[0], loc[1], loc[2]))); return loc; } maybe you could parse the ItemStack[] into a separate thread and then process it in the other thread so the main Minecraft thread doesn't take a huge hit every tick comparing old itemstack to new itemstack. How would one open a separate thread (I am not a coremod)? Follow my mod(s) here: http://www.minecraftforum.net/topic/1969694-
May 2, 201312 yr Author I'll probably just do it via coremod. I found a good place to try and add a custom hook, so hopefully that won't prove to be too difficult. My main problem with doing it based purely on the updateEntity event is that I need the person as well as the chest. Thanks for the help though. Good luck with your mods! Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
May 3, 201312 yr Author Hey, I misunderstood the mods intentions ( I love when that happens) so apparently I'm supposed to just scan through all of the chests on the server. Does anyone know an efficient means of getting every chest? Even those in unloaded chunks? Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help! http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/
May 3, 201312 yr Don't do that. Just do it when it is accessed by a player or a block next to it updates (to catch items piping or whatnot).
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.