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!)
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);
}
}