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