All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mmb.engine.inv.InvUtils Maven / Gradle / Ivy

Go to download

Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world. THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<

There is a newer version: 0.6
Show newest version
/**
 * 
 */
package mmb.engine.inv;

import mmb.Nil;
import mmb.engine.craft.RecipeOutput;
import mmb.engine.item.ItemEntry;
import monniasza.collects.Collects;

/**
 * A set of utilities for inventories
 * @author oskar
 */
public class InvUtils {
	public static @Nil ItemEntry onlyItem(RecipeOutput rout) {
		if(rout.items().size() != 1) return null;
		ItemStack entry = Collects.first(rout);
		if(entry.amount > 1) return null;
		if(entry.amount == 0) return null;
		return entry.item;
	}
	public static @Nil ItemStack onlyItemStack(RecipeOutput rout) {
		if(rout.items().size() != 1) return null;
		ItemStack entry = Collects.first(rout);
		if(entry.amount == 0) return null;
		return entry;
	}
	public static @Nil ItemStack onlyItemStackUpTo(RecipeOutput rout, int amount) {
		if(rout.items().size() != 1) return null;
		ItemStack entry = Collects.first(rout);
		if(entry.amount > amount) return null;
		if(entry.amount == 0) return null;
		return entry;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy