mmb.engine.recipe.SingleItem 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<
The newest version!
/**
*
*/
package mmb.engine.recipe;
import org.ainslec.picocog.PicoWriter;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntMaps;
import mmb.NN;
import mmb.Nil;
import mmb.engine.inv.io.InventoryWriter;
import mmb.engine.item.ItemEntry;
/**
* An item stack or an item entry
* @author oskar
*/
public interface SingleItem extends RecipeOutput {
@Override
default void produceResults(InventoryWriter tgt, int amount) {
tgt.insert(item(), amount*amount());
}
@Override
default void represent(PicoWriter out) {
out.write(amount() +"� "+item().title());
}
@Override
default double outVolume() {
return item().volume()*amount();
}
@Override
default Object2IntMap getContents() {
return Object2IntMaps.singleton(item(), amount());
}
@Override
default boolean contains(@Nil ItemEntry entry) {
return item().equals(entry);
}
@Override
default int get(ItemEntry entry) {
if(item().equals(entry)) return amount();
return 0;
}
@Override
default int getOrDefault(ItemEntry entry, int value) {
if(item().equals(entry)) return amount();
return value;
}
/** @return this item or this stack's corresponding items*/
@NN public ItemEntry item();
/** @return number of items */
public int amount();
}