appeng.api.networking.IGridHost Java Examples

The following examples show how to use appeng.api.networking.IGridHost. 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: SemiBlockRequester.java    From PneumaticCraft with GNU General Public License v3.0 7 votes vote down vote up
@Optional.Method(modid = ModIds.AE2)
private boolean checkForInterface(){
    if(isPlacedOnInterface()) {
        TileEntity te = getTileEntity();
        if(te instanceof IGridHost) {
            if(((IGridHost)te).getGridNode(null) == null) return true;
            if(getGridNode(null) == null) return true;
            try {
                AEApi.instance().createGridConnection(getGridNode(null), ((IGridHost)te).getGridNode(null));
            } catch(FailedConnection e) {
                Log.error("Couldn't connect to an ME Interface!");
                e.printStackTrace();
            }
        }
    }
    return false;
}
 
Example #2
Source File: MotorModifierAE2.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
public double getTotalStored() {

            double nodePower = 0;

            if (node != null) {
                for (IGridNode n : node.getGrid().getNodes()) {
                    if (n != node) {
                        IGridHost host = n.getGridBlock().getMachine();
                        if (host instanceof IAEPowerStorage) {
                            IAEPowerStorage storage = (IAEPowerStorage) host;
                            if (storage.isAEPublicPowerStorage()
                                    && (storage.getPowerFlow() == AccessRestriction.READ || storage.getPowerFlow() == AccessRestriction.READ_WRITE))
                                nodePower += storage.getAECurrentPower();
                        }
                    }
                }
            }

            return Math.min(getEnergyBuffer() + nodePower, getEnergyBufferSize());// FIXME
        }
 
Example #3
Source File: AdapterNetwork.java    From OpenPeripheral-Integration with MIT License 6 votes vote down vote up
@ScriptCallable(description = "Get a list of the stored and craftable items in the network.", returnTypes = ReturnType.TABLE)
public List<?> getAvailableItems(IGridHost host,
		@Env(Constants.ARG_CONVERTER) IConverter converter,
		@Optionals @Arg(name = "details", description = "Format of stored items details (defalt: none)") ItemDetails format) {
	IStorageGrid storageGrid = getStorageGrid(host);
	final IItemList<IAEItemStack> storageList = storageGrid.getItemInventory().getStorageList();

	List<Object> result = Lists.newArrayList();
	for (IAEItemStack stack : storageList) {
		@SuppressWarnings("unchecked")
		Map<String, Object> map = (Map<String, Object>)converter.fromJava(stack);
		if (format != null && format != ItemDetails.NONE) {
			final ItemStack itemStack = stack.getItemStack();
			if (format == ItemDetails.PROXY) map.put("item", OpcAccess.itemStackMetaBuilder.createProxy(itemStack));
			else if (format == ItemDetails.ALL) map.put("item", itemStack);
		}
		result.add(map);
	}

	return result;
}
 
Example #4
Source File: AdapterNetwork.java    From OpenPeripheral-Integration with MIT License 6 votes vote down vote up
@ScriptCallable(description = "Get a list of tables representing the available CPUs in the network.", returnTypes = ReturnType.TABLE)
public List<Map<String, Object>> getCraftingCPUs(IGridHost host) {
	ICraftingGrid craftingGrid = getCraftingGrid(host);

	List<Map<String, Object>> cpus = Lists.newArrayList();
	for (ICraftingCPU cpu : craftingGrid.getCpus()) {
		Map<String, Object> cpuDetails = Maps.newHashMap();
		cpuDetails.put("name", cpu.getName());
		cpuDetails.put("storage", cpu.getAvailableStorage());
		cpuDetails.put("coprocessors", cpu.getCoProcessors());
		cpuDetails.put("busy", cpu.isBusy());
		cpus.add(cpuDetails);
	}

	return cpus;
}
 
Example #5
Source File: AdapterNetwork.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@ScriptCallable(description = "Retrieves details about the specified item from the ME Network.", returnTypes = ReturnType.OBJECT)
public Object getItemDetail(IGridHost host,
		@Arg(name = "item", description = "Details of the item you are looking for") ItemFingerprint needle,
		@Optionals @Arg(name = "proxy", description = "If false, method will compute whole table, instead of returning proxy") Boolean proxy) {
	final IItemList<IAEItemStack> items = getStorageGrid(host).getItemInventory().getStorageList();
	final IAEItemStack stack = findStack(items, needle);
	if (stack == null) return null;
	ItemStack vanillaStack = stack.getItemStack();
	return proxy != Boolean.FALSE? OpcAccess.itemStackMetaBuilder.createProxy(vanillaStack) : vanillaStack;
}
 
Example #6
Source File: AdapterNetwork.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Get the idle power usage of the network.", returnTypes = ReturnType.NUMBER)
public double getIdlePowerUsage(IGridHost host) {
	return getEnergyGrid(host).getIdlePowerUsage();
}
 
Example #7
Source File: SemiBlockRequester.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.AE2)
public IGridHost getMachine(){
    return this;
}
 
Example #8
Source File: MENetworkSpatialEvent.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param SpatialIO   ( INSTANCE of the SpatialIO block )
 * @param EnergyUsage ( the amount of energy that the SpatialIO uses)
 */
public MENetworkSpatialEvent( IGridHost SpatialIO, double EnergyUsage )
{
	this.host = SpatialIO;
	this.spatialEnergyUsage = EnergyUsage;
}
 
Example #9
Source File: MENetworkSpatialEvent.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param SpatialIO   ( instance of the SpatialIO block )
 * @param EnergyUsage ( the amount of energy that the SpatialIO uses)
 */
public MENetworkSpatialEvent(IGridHost SpatialIO, double EnergyUsage)
{
	host = SpatialIO;
	spatialEnergyUsage = EnergyUsage;
}
 
Example #10
Source File: MotorModifierAE2.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
@Override
public IGridHost getMachine() {

    return this;
}
 
Example #11
Source File: AdapterNetwork.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Get the stored power in the network.", returnTypes = ReturnType.NUMBER)
public double getStoredPower(IGridHost host) {
	return getEnergyGrid(host).getStoredPower();
}
 
Example #12
Source File: AdapterNetwork.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Get the maximum stored power in the network.", returnTypes = ReturnType.NUMBER)
public double getMaxStoredPower(IGridHost host) {
	return getEnergyGrid(host).getMaxStoredPower();
}
 
Example #13
Source File: AdapterGridBase.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
protected <T extends IGridCache> T getCache(Class<T> cls, IGridHost host) {
	return host.getGridNode(ForgeDirection.UNKNOWN).getGrid().getCache(cls);
}
 
Example #14
Source File: AdapterNetwork.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Get the average power usage of the network.", returnTypes = ReturnType.NUMBER)
public double getAvgPowerUsage(IGridHost host) {
	return getEnergyGrid(host).getAvgPowerUsage();
}
 
Example #15
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 #16
Source File: AdapterNetwork.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@Override
public Class<?> getTargetClass() {
	return IGridHost.class;
}
 
Example #17
Source File: AdapterInterface.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Returns true when the interface can export to side.", returnTypes = ReturnType.BOOLEAN)
public boolean canExport(IGridHost tileEntityInterface, @Arg(name = "direction", description = "Location of target inventory") ForgeDirection direction) {
	return getNeighborInventory(tileEntityInterface, direction) != null;
}
 
Example #18
Source File: AdapterGridBase.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
protected IGrid getGrid(IGridHost host) {
	return host.getGridNode(ForgeDirection.UNKNOWN).getGrid();
}
 
Example #19
Source File: AdapterGridBase.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
protected IStorageGrid getStorageGrid(IGridHost host) {
	return getCache(IStorageGrid.class, host);
}
 
Example #20
Source File: AdapterGridBase.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
protected ICraftingGrid getCraftingGrid(IGridHost host) {
	return getCache(ICraftingGrid.class, host);
}
 
Example #21
Source File: AdapterGridBase.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
protected IEnergyGrid getEnergyGrid(IGridHost host) {
	return getCache(IEnergyGrid.class, host);
}
 
Example #22
Source File: INetworkTool.java    From Framez with GNU General Public License v3.0 votes vote down vote up
IGridHost getGridHost(); 
Example #23
Source File: INetworkTool.java    From PneumaticCraft with GNU General Public License v3.0 votes vote down vote up
IGridHost getGridHost();