openperipheral.api.architecture.IArchitecture Java Examples

The following examples show how to use openperipheral.api.architecture.IArchitecture. 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: TileEntitySelector.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@ScriptCallable(description = "Set the items being displayed in all slots")
public void setSlots(
		@Env(Constants.ARG_ARCHITECTURE) IArchitecture access,
		@Arg(name = "items", description = "A table containing itemstacks") Map<Index, ItemStack> stacks) {
	for (int slot = 0; slot < 9; slot++) {
		final ItemStack value = stacks.get(access.wrapObject(slot));
		if (value != null) value.stackSize = 1;

		this.slots[slot].set(value);
	}

	sync();
}
 
Example #2
Source File: AdapterInventory.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get a table with all the items of the chest")
public Map<Index, Object> getAllStacks(IInventory target,
		@Env(Constants.ARG_ARCHITECTURE) IArchitecture access,
		@Optionals @Arg(name = "proxy", description = "If false, method will compute whole table, instead of returning proxy") Boolean proxy) {
	final IInventory inventory = InventoryUtils.getInventory(target);
	Map<Index, Object> result = Maps.newHashMap();

	for (int i = 0; i < inventory.getSizeInventory(); i++) {
		ItemStack stack = inventory.getStackInSlot(i);
		if (stack != null) result.put(access.createIndex(i), (proxy != Boolean.FALSE)? OpcAccess.itemStackMetaBuilder.createProxy(stack) : stack);
	}
	return result;
}
 
Example #3
Source File: DrawableContainerMaster.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@Override
public Set<Index> getAllIds(IArchitecture access) {
	final Set<Index> indices = Sets.newHashSet();
	for (int value : containers.keySet())
		indices.add(access.createIndex(value));

	return indices;
}
 
Example #4
Source File: DrawableContainerMaster.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@Override
public Map<Index, Drawable> getAllObjects(IArchitecture access) {
	final Map<Index, Drawable> result = Maps.newHashMap();
	for (Map.Entry<Integer, Drawable> e : containers.entrySet())
		result.put(access.createIndex(e.getKey()), e.getValue());

	return result;
}
 
Example #5
Source File: MethodSelector.java    From OpenPeripheral with MIT License 4 votes vote down vote up
public MethodSelector addDefaultEnv() {
	providedEnv.put(Constants.ARG_CONVERTER, IConverter.class);
	providedEnv.put(Constants.ARG_ARCHITECTURE, IArchitecture.class);
	return this;
}
 
Example #6
Source File: StructuredObjectBase.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER, name = "getId")
public Index getId(@Env(Constants.ARG_ARCHITECTURE) IArchitecture access) {
	checkState();
	return access.createIndex(id);
}
 
Example #7
Source File: GlassesEvent.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@Override
public Object[] getEventArgs(IArchitecture access) {
	return NO_EXTRAS;
}
 
Example #8
Source File: GlassesEvent.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@Override
public Object[] getEventArgs(IArchitecture access) {
	return wrap(dx, dy);
}
 
Example #9
Source File: GlassesEvent.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@Override
public Object[] getEventArgs(IArchitecture access) {
	return wrap(access.createIndex(componentId), surfaceType.scriptValue, x, y, button);
}
 
Example #10
Source File: GlassesEvent.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@Override
public Object[] getEventArgs(IArchitecture access) {
	return wrap(access.createIndex(componentId), surfaceType.scriptValue, x, y, wheel);
}
 
Example #11
Source File: GlassesEvent.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@Override
public Object[] getEventArgs(IArchitecture access) {
	return wrap(button);
}
 
Example #12
Source File: GlassesEvent.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@Override
public Object[] getEventArgs(IArchitecture access) {
	return wrap(wheel);
}
 
Example #13
Source File: GlassesEvent.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@Override
public Object[] getEventArgs(IArchitecture access) {
	return wrap(code);
}
 
Example #14
Source File: GlassesEvent.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@Override
public Object[] getEventArgs(IArchitecture access) {
	// CC has some problems with chars
	return wrap(code, Character.toString(ch), isRepeat);
}
 
Example #15
Source File: GlassesEvent.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
public Object[] getEventArgs(IArchitecture access) {
	throw new UnsupportedOperationException(getClass().getName() + " should not be used directly");
}
 
Example #16
Source File: IContainer.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get all objects")
public Map<Index, E> getAllObjects(@Env(Constants.ARG_ARCHITECTURE) IArchitecture access);
 
Example #17
Source File: IContainer.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get the ids of all the objects")
public Set<Index> getAllIds(@Env(Constants.ARG_ARCHITECTURE) IArchitecture access);