Jump to content

Recommended Posts

Posted

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/

Posted

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/

Posted

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.

Posted

 

@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)?

Posted

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/

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.