NoStack - carrying nerf

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Planetguy

New Member
Jul 29, 2019
156
0
0
Simply makes everything only stack to a limit of 1 (configurable).

Download: https://www.mediafire.com/folder/68pjsa7de2boh/NoStack

Source is included in the download, or posted below. License is MIT (permissive). (If you make something public, a post in this thread would be appreciated (but not required) - I'd love to hear from you!)

Code:
package me.planetguy.nostack;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;

@Mod(modid="planetguy_nostack", version="1.0")
public class NoStack {
   
    private Configuration config;
   
    private int size=1;
   
    @EventHandler
    public void preInit(FMLPreInitializationEvent pie){
        config=new Configuration(pie.getSuggestedConfigurationFile());
        config.load();
        size=config.getInt("maximumPossibleStack", Configuration.CATEGORY_GENERAL, size, 1, 64, "No items may be stacked greater than this number.");
        config.save();
    }
   
    @EventHandler
    public void postInit(FMLPostInitializationEvent post){
       
        for(Object key:Item.itemRegistry.getKeys()){
            adjustStackSize((Item)Item.itemRegistry.getObject(key));
        }
        if(Block.blockRegistry!=null){
            for(Object key:Block.blockRegistry.getKeys()){
                Block b=(Block) Block.blockRegistry.getObject(key);
                if(b!=null){
                    Item i=Item.getItemFromBlock(b);
                    if(i!=null)adjustStackSize(i);
                }
            }
        }
    }
   
    public void adjustStackSize(Item i){
        int newSize=Math.min(size,i.getItemStackLimit());
        i.setMaxStackSize(newSize);
    }

}
 
So you can adjust the stacksize of anything on an item by item level?

Hell yeah, count me in!
No, looking at the code, it reads the config for the stacksize, and then dynamically applies this to every object/item.
The horrors of global stacksize 1. *shudder*
 
No, looking at the code, it reads the config for the stacksize, and then dynamically applies this to every object/item.
The horrors of global stacksize 1. *shudder*

My bad- I thought you could stick items IDs in here.
Code:
 public void adjustStackSize(Item i){
        int newSize=Math.min(size,i.getItemStackLimit());
        i.setMaxStackSize(newSize);

Still could be useful for a certain player base- set everything to 64.
 
  • Like
Reactions: 1SDAN
It can only reduce stack sizes for now - note the Math.min of the item's old and new stack limits. I don't think I'll implement increasing stack size over 64 - there seems to be a magic number hidden somewhere, since player inventory slots only accept stacks of 64 and leave any extra items in your hand.

This mod is a pretty brutal nerf, so I'd recommend not using it except in brutal hardcore modpacks.
 
  • Like
Reactions: Celestialphoenix