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

Posted

Hi, I'm new to Minecraft modding (not at all new to programming in general though, no worries), and I'm trying to implement what I thought would be a relatively simple mod to decrease the max stack size of almost all the vanilla items in the game that aren't already at max stack size 1. The goal is to run a multiplayer server with this mod. I've heard read that I'll probably have to re-register all the blocks in the game I want to be modified with new stack size values.

The questions I have are:

1. Is this the easiest strategy for implementing a mod/change like this? Am I correct in understanding it requires re-registering all blocks?

2. If so, what classes in the API should I be looking at for A. grabbing the existing vanilla items in the game, and then B. registering changes made to them? Example code is nice too, but in lieu of that a few pointers to the API will be just fine.

Honestly, I'm mostly just in a bit of disbelief that this seems to be the solution I have to take, why isn't the most popular game on earth more configurable? It seems like you should just be able to modify the value in a datapack, but here we are.

  • Author

No dice unfortunately. This is more or less my code:

@Mod("arducraft")
public class ArducraftMod {

  public ArducraftMod() {
    FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup);
  }

  private void onCommonSetup(FMLCommonSetupEvent event) {
    event.enqueueWork(new Runnable() {
      public void run() {
        try {
          Field stackSizeField = Items.COBBLESTONE.getClass().getDeclaredField("maxStackSize");
          stackSizeField.setAccessible(true);
          stackSizeField.set(Items.COBBLESTONE, 4);
          LOGGER.info("Successfully set COBBLESTONE size to 4");
        } catch (NoSuchFieldException ex) {
          LOGGER.error("Failed to set COBBLESTONE size (NoSuchFieldException): " + ex.getMessage());
        } catch (IllegalAccessException ex) {
          LOGGER.error("Failed to set COBBLESTONE size (IllegalAccessException): " + ex.getMessage());
        }
      }
    });
  }
}

With an output of:

[12:28:51] [Render thread/ERROR]: Failed to set COBBLESTONE size (NoSuchFieldException): maxStackSize

Based on the code I found here

  • Author

I figured it my above issue, I had to replace the line getting the field to:

Field stackSizeField = Item.class.getDeclaredField("maxStackSize");

Which seems silly because I see no reason they shouldn't do the exact same thing... But this wouldn't be the first time Java has surprised me with how screwy it is!

Thanks for the tip

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.