Add OC integration skeleton
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.integration.oc;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.proxy.CapabilityNetworkNodeProxy;
|
||||||
|
import li.cil.oc.api.driver.DriverBlock;
|
||||||
|
import li.cil.oc.api.network.ManagedEnvironment;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class DriverNetwork implements DriverBlock {
|
||||||
|
@Override
|
||||||
|
public boolean worksWith(World world, BlockPos pos, EnumFacing facing) {
|
||||||
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
|
|
||||||
|
return tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ManagedEnvironment createEnvironment(World world, BlockPos pos, EnumFacing facing) {
|
||||||
|
return new EnvironmentNetwork(world.getTileEntity(pos).getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing).getNode());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.integration.oc;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||||
|
import li.cil.oc.api.Network;
|
||||||
|
import li.cil.oc.api.network.Visibility;
|
||||||
|
import li.cil.oc.api.prefab.AbstractManagedEnvironment;
|
||||||
|
|
||||||
|
public class EnvironmentNetwork extends AbstractManagedEnvironment {
|
||||||
|
protected final INetworkNode node;
|
||||||
|
|
||||||
|
public EnvironmentNetwork(INetworkNode node) {
|
||||||
|
this.node = node;
|
||||||
|
|
||||||
|
setNode(Network.newNode(this, Visibility.Network).withComponent("refinedstorage", Visibility.Network).create());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.integration.oc;
|
||||||
|
|
||||||
|
import li.cil.oc.api.Driver;
|
||||||
|
import net.minecraftforge.fml.common.Loader;
|
||||||
|
|
||||||
|
public final class IntegrationOC {
|
||||||
|
private static final String ID = "opencomputers";
|
||||||
|
|
||||||
|
public static boolean isLoaded() {
|
||||||
|
return Loader.isModLoaded(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void register() {
|
||||||
|
Driver.add(new DriverNetwork());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ import com.raoulvdberge.refinedstorage.block.*;
|
|||||||
import com.raoulvdberge.refinedstorage.gui.GuiHandler;
|
import com.raoulvdberge.refinedstorage.gui.GuiHandler;
|
||||||
import com.raoulvdberge.refinedstorage.integration.craftingtweaks.IntegrationCraftingTweaks;
|
import com.raoulvdberge.refinedstorage.integration.craftingtweaks.IntegrationCraftingTweaks;
|
||||||
import com.raoulvdberge.refinedstorage.integration.forgeenergy.ReaderWriterHandlerForgeEnergy;
|
import com.raoulvdberge.refinedstorage.integration.forgeenergy.ReaderWriterHandlerForgeEnergy;
|
||||||
|
import com.raoulvdberge.refinedstorage.integration.oc.IntegrationOC;
|
||||||
import com.raoulvdberge.refinedstorage.integration.tesla.IntegrationTesla;
|
import com.raoulvdberge.refinedstorage.integration.tesla.IntegrationTesla;
|
||||||
import com.raoulvdberge.refinedstorage.item.*;
|
import com.raoulvdberge.refinedstorage.item.*;
|
||||||
import com.raoulvdberge.refinedstorage.network.*;
|
import com.raoulvdberge.refinedstorage.network.*;
|
||||||
@@ -818,7 +819,9 @@ public class ProxyCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void init(FMLInitializationEvent e) {
|
public void init(FMLInitializationEvent e) {
|
||||||
// NO OP
|
if (IntegrationOC.isLoaded()) {
|
||||||
|
IntegrationOC.register();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postInit(FMLPostInitializationEvent e) {
|
public void postInit(FMLPostInitializationEvent e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user