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

mmb.content.imachine.pipe.PipeBinder 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<

The newest version!
/**
 * 
 */
package mmb.content.imachine.pipe;

import mmb.NN;
import mmb.content.imachine.pipe.AbstractBasePipe.Pusher;
import mmb.data.variables.Variable;
import mmb.engine.block.BlockEntry;
import mmb.engine.block.BlockType;
import mmb.engine.inv.io.InventoryReader;
import mmb.engine.inv.io.InventoryWriter;
import mmb.engine.inv.storage.SingleItemInventory;
import mmb.engine.item.ItemEntry;
import mmb.engine.rotate.ChirotatedImageGroup;
import mmb.engine.rotate.Side;
import mmb.engine.worlds.MapProxy;

/**
 * @author oskar
 * Represents a binding pipe. The binding side goes to UP
 */
public class PipeBinder extends AbstractBasePipe{
	@NN private final Side binding;
	protected final @NN Pusher toCommon, toSide, toMain;
	/**
	 * Creates a binding pipe.
	 * @param type block type
	 * @param binding binding side
	 * @param rig texture
	 */
	public PipeBinder(BlockType type, Side binding, ChirotatedImageGroup rig) {
		super(type, 3, rig);
		this.binding = binding;
		SingleItemInventory varM = items[0];
		SingleItemInventory varS = items[1];
		SingleItemInventory varC = items[2];
		
		toCommon = new Pusher(varC, Side.U);
		toSide = new Pusher(varS, binding);
		toMain = new Pusher(varM, Side.D);
		
		InventoryReader readC = varC.createReader();
		InventoryReader readM = varM.createReader();
		InventoryReader readS = varS.createReader();
		
		InventoryWriter top = new InventoryWriter.Priority(toMain, toSide);
		
		setIn(toCommon, binding);
		inU = top;
		inD = toCommon;
		
		setOut(readS, binding);
		outD = readM;
		outU = readC;
	}
	@Override
	public void onTick(MapProxy map) {
		toCommon.push();
		toSide.push();
		toMain.push();
	}
	@Override
	public BlockEntry blockCopy() {
		PipeBinder result = new PipeBinder(type(), binding, getImage());
		System.arraycopy(items, 0, result.items, 0, 3);
		return result;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy