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

mmb.engine.inv.ExtractionsOnlyItemRecord 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.NN;
import mmb.engine.item.ItemEntry;

/**
 * @author oskar
 *
 */
public class ExtractionsOnlyItemRecord implements ItemRecord{
	@NN private final ItemRecord record;
	@NN private final Inventory inv;
	/**
	 * @param rec
	 */
	private ExtractionsOnlyItemRecord(ItemRecord rec, Inventory inv) {
		record = rec;
		this.inv = inv;
	}
	/**
	 * Create an extract-only item record for given item record.
	 * @param rec target item record
	 * @param inv inventory
	 * @return the extraction only item record
	 */
	@NN public static ItemRecord decorate(ItemRecord rec, Inventory inv) {
		if(!rec.canInsert()) return rec;
		return new ExtractionsOnlyItemRecord(rec, ExtractionsOnlyInventory.decorate(inv));
	}
	@NN public static ItemRecord decorate(ItemRecord rec) {
		if(rec instanceof ExtractionsOnlyItemRecord) return rec;
		return new ExtractionsOnlyItemRecord(rec, ExtractionsOnlyInventory.decorate(rec.inventory()));
	}
	@Override
	public int amount() {
		return record.amount();
	}
	@Override
	public Inventory inventory() {
		return inv;
	}
	@Override
	public ItemEntry item() {
		return record.item();
	}
	@Override
	public int insert(int amount) {
		return 0;
	}
	@Override
	public int extract(int amount) {
		return record.extract(amount);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy