Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

  • 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/

  • 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/

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.

 

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

  • 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/

  • 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/

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.