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

mmb.menu.world.craft.VectorUtils 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.menu.world.craft;

import java.util.Vector;
import java.util.stream.Collectors;

import mmb.NN;
import mmb.engine.craft.RecipeOutput;
import mmb.engine.inv.ItemStack;

/**
 * @author oskar
 *
 */
public class VectorUtils {
	private VectorUtils() {}
	/**
	 * Converts an item list into an array
	 * @param output
	 * @return
	 */
	@NN public static Vector list2vector(RecipeOutput output){
		return output
				.getContents()
				.object2IntEntrySet()
				.stream()
				.map(ent -> new ItemStack(ent.getKey(), ent.getIntValue()))
				.collect(Collectors.toCollection(() -> new Vector()));
	}

	@NN public static ItemStack[] list2arr(RecipeOutput output){
		return output
				.getContents()
				.object2IntEntrySet()
				.stream()
				.map(entry -> new ItemStack(entry.getKey(), entry.getIntValue()))
				.toArray(n -> new ItemStack[n]);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy