Java Code Examples for openperipheral.api.adapter.method.ReturnType#NUMBER

The following examples show how to use openperipheral.api.adapter.method.ReturnType#NUMBER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdapterWritingDesk.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@ScriptCallable(
		returnTypes = ReturnType.NUMBER,
		description = "Push a page from the notebook into a specific slot in external inventory. Returns the amount of items moved")
public int pushNotebookPage(
		TileEntity desk,
		@Arg(name = "deskSlot") Index deskSlot,
		@Arg(name = "direction", description = "The direction of the other inventory. (north, south, east, west, up or down)") ForgeDirection direction,
		@Arg(name = "fromSlot", description = "The page slot in inventory that you're pushing from") Index fromSlot,
		@Optionals @Arg(name = "intoSlot", description = "The slot in the other inventory that you want to push into") Index intoSlot) {
	final NotebookWrapper wrapper = createInventoryWrapper(desk, deskSlot);

	ItemStack page = wrapper.getPageFromSlot(fromSlot);

	ItemStack removedPage = wrapper.removePage(page);
	Preconditions.checkNotNull(removedPage, "No page in notebook");

	GenericInventory tmp = new GenericInventory("tmp", false, 1);
	tmp.setInventorySlotContents(0, removedPage.copy());

	final IInventory target = getTargetTile(desk, direction);

	if (intoSlot == null) intoSlot = Index.fromJava(-1, 0);

	int result = ItemDistribution.moveItemInto(tmp, 0, target, intoSlot.value, removedPage.stackSize, direction, true);

	int remains = removedPage.stackSize - result;
	if (remains >= 0) {
		ItemStack returns = removedPage.copy();
		returns.stackSize = remains;
		wrapper.addPage(returns);
	}

	return result;
}
 
Example 2
Source File: AdapterTileSteamTurbine.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@ScriptCallable(description = "Get the undamagedness of the rotor, from 0% (dead) to 100% (brand new)", returnTypes = ReturnType.NUMBER)
public Integer getTurbineRotorStatus(Object tileSteamTurbine) {
	IInventory inventory = GET_INVENTORY.call(tileSteamTurbine);

	if (inventory != null && inventory.getSizeInventory() >= 1) {
		ItemStack itemStack = inventory.getStackInSlot(0);
		if (itemStack != null) {
			Item item = itemStack.getItem();
			if (item != null) { return 100 - (int)(itemStack.getItemDamage() * 100.0 / item.getMaxDamage()); }
		}
	}
	return null;
}
 
Example 3
Source File: AdapterBrewingStand.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER)
public int getBrewTime(TileEntityBrewingStand brewingStand) {
	return brewingStand.getBrewTime();
}
 
Example 4
Source File: AdapterArcaneEar.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER, description = "Gets the tone the Ear is set to")
public byte getTone(Object target) {
	return TONE.get(target);
}
 
Example 5
Source File: AdapterEnergyInfo.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Gets the EnergyPerTick of the machine.", returnTypes = ReturnType.NUMBER)
public int getEnergyPerTickInfo(IEnergyInfo tileEntity) {
	return tileEntity.getInfoEnergyPerTick();
}
 
Example 6
Source File: AdapterTemperature.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Get the temperature", returnTypes = ReturnType.NUMBER)
public float getTemperature(Object target) {
	return GET_TEMPERATURE.call(target);
}
 
Example 7
Source File: AdapterReconfigurableFacing.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER, description = "Returns the current facing of the block")
public int getFacing(IReconfigurableFacing target) {
	return target.getFacing();
}
 
Example 8
Source File: AdapterChunkLoader.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Get chunk loader radius", returnTypes = ReturnType.NUMBER)
public short getRadius(Object tileEntityChunkLoader) {
	return GET_RADIUS.call(tileEntityChunkLoader);
}
 
Example 9
Source File: AdapterHeatSource.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER)
public int getMaxKineticEnergy(IHeatSource target, @Arg(name = "side") ForgeDirection side) {
	return target.maxrequestHeatTick(side);
}
 
Example 10
Source File: AdapterFrequencyOwner.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@Asynchronous
@ScriptCallable(returnTypes = ReturnType.NUMBER, description = "Get the frequency of this chest or tank")
public int getFrequency(TileEntity frequencyOwner) {
	return FREQ.get(frequencyOwner);
}
 
Example 11
Source File: AdapterEnergySource.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Determine the tier of this energy source (1 = LV, 2 = MV, 3 = HV, 4 = EV)", returnTypes = ReturnType.NUMBER)
public int getEUSourceTier(IEnergySource sink) {
	return sink.getSourceTier();
}
 
Example 12
Source File: AdapterEssentiaTransport.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER, description = "Returns the amount of essentia in the tube")
public int getEssentiaAmount(IEssentiaTransport pipe,
		@Arg(description = "Direction suction coming from", name = "direction") ForgeDirection direction) {
	return pipe.getEssentiaAmount(direction);
}
 
Example 13
Source File: AdapterEnergySink.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Determine the tier of this energy sink (1 = LV, 2 = MV, 3 = HV, 4 = EV)", returnTypes = ReturnType.NUMBER)
public int getEUSinkTier(IEnergySink sink) {
	return sink.getSinkTier();
}
 
Example 14
Source File: AdapterBeacon.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER, description = "Get the height of the beacon's pyramid")
public int getLevels(TileEntityBeacon beacon) {
	return beacon.getLevels();
}
 
Example 15
Source File: AdapterWritingDesk.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Get the maximum number of notebooks this desk can store", returnTypes = ReturnType.NUMBER)
public int getMaxNotebookCount(Object tileEntityDesk) {
	return GET_MAX_NOTEBOOK_COUNT.call(tileEntityDesk);
}
 
Example 16
Source File: AdapterNetwork.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Get the average power injection into the network", returnTypes = ReturnType.NUMBER)
public double getAvgPowerInjection(IGridHost host) {
	return getEnergyGrid(host).getAvgPowerInjection();
}
 
Example 17
Source File: AdapterCrop.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER, description = "Get the crop's plant resistance stat. Higher values indicate more resistance against trampling.")
public byte getResistance(ICropTile target) {
	return target.getResistance();
}
 
Example 18
Source File: AdapterDaylightSensor.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER, description = "Get level of natural light (sky)")
public int getSkyLight(TileEntityDaylightDetector target) {
	World world = target.getWorldObj();
	Preconditions.checkArgument(!world.provider.hasNoSky, "World has no sky");
	return world.getSavedLightValue(EnumSkyBlock.Sky, target.xCoord, target.yCoord, target.zCoord) - world.skylightSubtracted;
}
 
Example 19
Source File: AdapterCrop.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER, description = "Get the crop's air quality. Ranges from 0 (cluttered) to 10 (fresh)")
public byte getAirQuality(ICropTile target) {
	return target.getAirQuality();
}
 
Example 20
Source File: AdapterEnergyConductor.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Get the EU conduction loss", returnTypes = ReturnType.NUMBER)
public double getEUConductionLoss(IEnergyConductor conductor) {
	return conductor.getConductionLoss();
}