mmb.engine.inv.InvUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multimachinebuilder Show documentation
Show all versions of multimachinebuilder Show documentation
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<
/**
*
*/
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;
}
}