mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
Added reference class to API to centralize version updating.
Pulled the fields with the API instances in there, so that the ID doesn't feel so alone. Updated API readme.
This commit is contained in:
parent
1c6c4be7f1
commit
155f61ce45
21
src/main/java/li/cil/oc/api/API.java
Normal file
21
src/main/java/li/cil/oc/api/API.java
Normal file
@ -0,0 +1,21 @@
|
||||
package li.cil.oc.api;
|
||||
|
||||
import li.cil.oc.api.detail.*;
|
||||
|
||||
/**
|
||||
* Central reference for the API.
|
||||
* <p/>
|
||||
* Don't use this class directly, prefer using the other classes in this
|
||||
* package instead. This class is initialized by OpenComputers in the
|
||||
* pre-init phase, so it should not be used before the init phase.
|
||||
*/
|
||||
public class API {
|
||||
public static final String ID_OWNER = "OpenComputers|Core";
|
||||
public static final String VERSION = "3.1.0";
|
||||
|
||||
public static DriverAPI driver = null;
|
||||
public static FileSystemAPI fileSystem = null;
|
||||
public static ItemAPI items = null;
|
||||
public static MachineAPI machine = null;
|
||||
public static NetworkAPI network = null;
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package li.cil.oc.api;
|
||||
|
||||
import li.cil.oc.api.detail.DriverAPI;
|
||||
import li.cil.oc.api.driver.Block;
|
||||
import li.cil.oc.api.driver.Converter;
|
||||
import li.cil.oc.api.driver.EnvironmentHost;
|
||||
@ -16,6 +15,10 @@ import net.minecraft.world.World;
|
||||
* block that should interact with the mod's component network it is enough to
|
||||
* have it implement {@link li.cil.oc.api.network.Environment} - no driver is
|
||||
* needed in that case.
|
||||
* <p/>
|
||||
* Note that these methods should <em>not</em> be called in the pre-init phase,
|
||||
* since the {@link li.cil.oc.api.API#driver} may not have been initialized
|
||||
* at that time. Only start calling these methods in the init phase or later.
|
||||
*
|
||||
* @see Network
|
||||
* @see Block
|
||||
@ -35,8 +38,8 @@ public final class Driver {
|
||||
* @param driver the driver to register.
|
||||
*/
|
||||
public static void add(final Block driver) {
|
||||
if (instance != null)
|
||||
instance.add(driver);
|
||||
if (API.driver != null)
|
||||
API.driver.add(driver);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,8 +54,8 @@ public final class Driver {
|
||||
* @param driver the driver to register.
|
||||
*/
|
||||
public static void add(final Item driver) {
|
||||
if (instance != null)
|
||||
instance.add(driver);
|
||||
if (API.driver != null)
|
||||
API.driver.add(driver);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,8 +70,8 @@ public final class Driver {
|
||||
* @param converter the converter to register.
|
||||
*/
|
||||
public static void add(final Converter converter) {
|
||||
if (instance != null)
|
||||
instance.add(converter);
|
||||
if (API.driver != null)
|
||||
API.driver.add(converter);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,8 +90,8 @@ public final class Driver {
|
||||
* @return a driver for the block, or <tt>null</tt> if there is none.
|
||||
*/
|
||||
public static Block driverFor(World world, int x, int y, int z) {
|
||||
if (instance != null)
|
||||
return instance.driverFor(world, x, y, z);
|
||||
if (API.driver != null)
|
||||
return API.driver.driverFor(world, x, y, z);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -104,8 +107,8 @@ public final class Driver {
|
||||
* @return a driver for the item, or <tt>null</tt> if there is none.
|
||||
*/
|
||||
public static Item driverFor(ItemStack stack, Class<? extends EnvironmentHost> host) {
|
||||
if (instance != null)
|
||||
return instance.driverFor(stack, host);
|
||||
if (API.driver != null)
|
||||
return API.driver.driverFor(stack, host);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -123,8 +126,8 @@ public final class Driver {
|
||||
* @return a driver for the item, or <tt>null</tt> if there is none.
|
||||
*/
|
||||
public static Item driverFor(ItemStack stack) {
|
||||
if (instance != null)
|
||||
return instance.driverFor(stack);
|
||||
if (API.driver != null)
|
||||
return API.driver.driverFor(stack);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -132,6 +135,4 @@ public final class Driver {
|
||||
|
||||
private Driver() {
|
||||
}
|
||||
|
||||
public static DriverAPI instance = null;
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package li.cil.oc.api;
|
||||
|
||||
import li.cil.oc.api.detail.FileSystemAPI;
|
||||
import li.cil.oc.api.driver.EnvironmentHost;
|
||||
import li.cil.oc.api.fs.Label;
|
||||
import li.cil.oc.api.network.ManagedEnvironment;
|
||||
@ -18,8 +17,8 @@ import li.cil.oc.api.network.ManagedEnvironment;
|
||||
* and set the visibility to the desired value.
|
||||
* <p/>
|
||||
* Note that these methods should <em>not</em> be called in the pre-init phase,
|
||||
* since the {@link #instance} may not have been initialized at that time. Only
|
||||
* start calling these methods in the init phase or later.
|
||||
* since the {@link li.cil.oc.api.API#fileSystem} may not have been initialized
|
||||
* at that time. Only start calling these methods in the init phase or later.
|
||||
*/
|
||||
public final class FileSystem {
|
||||
/**
|
||||
@ -44,8 +43,8 @@ public final class FileSystem {
|
||||
* @return a file system wrapping the specified folder.
|
||||
*/
|
||||
public static li.cil.oc.api.fs.FileSystem fromClass(final Class<?> clazz, final String domain, final String root) {
|
||||
if (instance != null)
|
||||
return instance.fromClass(clazz, domain, root);
|
||||
if (API.fileSystem != null)
|
||||
return API.fileSystem.fromClass(clazz, domain, root);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -73,8 +72,8 @@ public final class FileSystem {
|
||||
* @return a file system wrapping the specified folder.
|
||||
*/
|
||||
public static li.cil.oc.api.fs.FileSystem fromSaveDirectory(final String root, final long capacity, final boolean buffered) {
|
||||
if (instance != null)
|
||||
return instance.fromSaveDirectory(root, capacity, buffered);
|
||||
if (API.fileSystem != null)
|
||||
return API.fileSystem.fromSaveDirectory(root, capacity, buffered);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -103,8 +102,8 @@ public final class FileSystem {
|
||||
* @return a file system residing in memory.
|
||||
*/
|
||||
public static li.cil.oc.api.fs.FileSystem fromMemory(final long capacity) {
|
||||
if (instance != null)
|
||||
return instance.fromMemory(capacity);
|
||||
if (API.fileSystem != null)
|
||||
return API.fileSystem.fromMemory(capacity);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -121,8 +120,8 @@ public final class FileSystem {
|
||||
* @return a file system wrapping the specified mount.
|
||||
*/
|
||||
public static li.cil.oc.api.fs.FileSystem fromComputerCraft(final Object mount) {
|
||||
if (instance != null)
|
||||
return instance.fromComputerCraft(mount);
|
||||
if (API.fileSystem != null)
|
||||
return API.fileSystem.fromComputerCraft(mount);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -153,8 +152,8 @@ public final class FileSystem {
|
||||
* @return the network node wrapping the file system.
|
||||
*/
|
||||
public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final Label label, final EnvironmentHost host, final String accessSound) {
|
||||
if (instance != null)
|
||||
return instance.asManagedEnvironment(fileSystem, label, host, accessSound);
|
||||
if (API.fileSystem != null)
|
||||
return API.fileSystem.asManagedEnvironment(fileSystem, label, host, accessSound);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -172,8 +171,8 @@ public final class FileSystem {
|
||||
* @return the network node wrapping the file system.
|
||||
*/
|
||||
public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final String label, final EnvironmentHost host, final String accessSound) {
|
||||
if (instance != null)
|
||||
return instance.asManagedEnvironment(fileSystem, label, host, accessSound);
|
||||
if (API.fileSystem != null)
|
||||
return API.fileSystem.asManagedEnvironment(fileSystem, label, host, accessSound);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -186,8 +185,8 @@ public final class FileSystem {
|
||||
* @return the network node wrapping the file system.
|
||||
*/
|
||||
public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final Label label) {
|
||||
if (instance != null)
|
||||
return instance.asManagedEnvironment(fileSystem, label);
|
||||
if (API.fileSystem != null)
|
||||
return API.fileSystem.asManagedEnvironment(fileSystem, label);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -200,8 +199,8 @@ public final class FileSystem {
|
||||
* @return the network node wrapping the file system.
|
||||
*/
|
||||
public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final String label) {
|
||||
if (instance != null)
|
||||
return instance.asManagedEnvironment(fileSystem, label);
|
||||
if (API.fileSystem != null)
|
||||
return API.fileSystem.asManagedEnvironment(fileSystem, label);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -214,8 +213,8 @@ public final class FileSystem {
|
||||
* @return the network node wrapping the file system.
|
||||
*/
|
||||
public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem) {
|
||||
if (instance != null)
|
||||
return instance.asManagedEnvironment(fileSystem);
|
||||
if (API.fileSystem != null)
|
||||
return API.fileSystem.asManagedEnvironment(fileSystem);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -223,6 +222,4 @@ public final class FileSystem {
|
||||
|
||||
private FileSystem() {
|
||||
}
|
||||
|
||||
public static FileSystemAPI instance = null;
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package li.cil.oc.api;
|
||||
|
||||
import li.cil.oc.api.detail.ItemAPI;
|
||||
import li.cil.oc.api.detail.ItemInfo;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@ -16,14 +15,18 @@ public final class Items {
|
||||
* object can be used to retrieve both the block and item instance of the
|
||||
* item, if available. It can also be used to create a new item stack of
|
||||
* the item.
|
||||
* <p/>
|
||||
* Note that these methods should <em>not</em> be called in the pre-init phase,
|
||||
* since the {@link li.cil.oc.api.API#items} may not have been initialized
|
||||
* at that time. Only start calling these methods in the init phase or later.
|
||||
*
|
||||
* @param name the name of the item to get the descriptor for.
|
||||
* @return the descriptor for the item with the specified name, or
|
||||
* <tt>null</tt> if there is no such item.
|
||||
*/
|
||||
public static ItemInfo get(String name) {
|
||||
if (instance != null)
|
||||
return instance.get(name);
|
||||
if (API.items != null)
|
||||
return API.items.get(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -36,8 +39,8 @@ public final class Items {
|
||||
* if the stack is not a valid OpenComputers item or block.
|
||||
*/
|
||||
public static ItemInfo get(ItemStack stack) {
|
||||
if (instance != null)
|
||||
return instance.get(stack);
|
||||
if (API.items != null)
|
||||
return API.items.get(stack);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -45,6 +48,4 @@ public final class Items {
|
||||
|
||||
private Items() {
|
||||
}
|
||||
|
||||
public static ItemAPI instance = null;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package li.cil.oc.api;
|
||||
|
||||
import li.cil.oc.api.detail.MachineAPI;
|
||||
import li.cil.oc.api.machine.Architecture;
|
||||
import li.cil.oc.api.machine.MachineHost;
|
||||
|
||||
@ -18,8 +17,8 @@ import java.util.Collections;
|
||||
* convenience feature to make architectures usable via the built-in CPUs.
|
||||
* <p/>
|
||||
* Note that these methods should <em>not</em> be called in the pre-init phase,
|
||||
* since the {@link #instance} may not have been initialized at that time. Only
|
||||
* start calling these methods in the init phase or later.
|
||||
* since the {@link li.cil.oc.api.API#machine} may not have been initialized
|
||||
* at that time. Only start calling these methods in the init phase or later.
|
||||
*/
|
||||
public final class Machine {
|
||||
/**
|
||||
@ -32,16 +31,16 @@ public final class Machine {
|
||||
* @param architecture the architecture to register.
|
||||
*/
|
||||
public static void add(Class<? extends Architecture> architecture) {
|
||||
if (instance != null)
|
||||
instance.add(architecture);
|
||||
if (API.machine != null)
|
||||
API.machine.add(architecture);
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of all <em>registered</em> architectures.
|
||||
*/
|
||||
public static Iterable<Class<? extends Architecture>> architectures() {
|
||||
if (instance != null)
|
||||
return instance.architectures();
|
||||
if (API.machine != null)
|
||||
return API.machine.architectures();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@ -55,8 +54,8 @@ public final class Machine {
|
||||
* @return the newly created machine.
|
||||
*/
|
||||
public static li.cil.oc.api.machine.Machine create(MachineHost host) {
|
||||
if (instance != null)
|
||||
return instance.create(host);
|
||||
if (API.machine != null)
|
||||
return API.machine.create(host);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -65,8 +64,6 @@ public final class Machine {
|
||||
private Machine() {
|
||||
}
|
||||
|
||||
public static MachineAPI instance = null;
|
||||
|
||||
/**
|
||||
* The built-in Lua architecture. This will be set to the native Lua
|
||||
* implementation when possible, to the LuaJ fallback, otherwise.
|
||||
|
@ -1,7 +1,6 @@
|
||||
package li.cil.oc.api;
|
||||
|
||||
import li.cil.oc.api.detail.Builder;
|
||||
import li.cil.oc.api.detail.NetworkAPI;
|
||||
import li.cil.oc.api.network.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -21,8 +20,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
* logic lies - since user code only runs on the server.
|
||||
* <p/>
|
||||
* Note that these methods should <em>not</em> be called in the pre-init phase,
|
||||
* since the {@link #instance} may not have been initialized at that time. Only
|
||||
* start calling these methods in the init phase or later.
|
||||
* since the {@link li.cil.oc.api.API#network} may not have been initialized
|
||||
* at that time. Only start calling these methods in the init phase or later.
|
||||
*/
|
||||
public final class Network {
|
||||
/**
|
||||
@ -41,8 +40,8 @@ public final class Network {
|
||||
* @param tileEntity the tile entity to initialize.
|
||||
*/
|
||||
public static void joinOrCreateNetwork(final TileEntity tileEntity) {
|
||||
if (instance != null)
|
||||
instance.joinOrCreateNetwork(tileEntity);
|
||||
if (API.network != null)
|
||||
API.network.joinOrCreateNetwork(tileEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,8 +55,8 @@ public final class Network {
|
||||
* @throws IllegalArgumentException if the node already is in a network.
|
||||
*/
|
||||
public static void joinNewNetwork(final Node node) {
|
||||
if (instance != null)
|
||||
instance.joinNewNetwork(node);
|
||||
if (API.network != null)
|
||||
API.network.joinNewNetwork(node);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
@ -76,8 +75,8 @@ public final class Network {
|
||||
* @param endpoint the endpoint to register with the network.
|
||||
*/
|
||||
public static void joinWirelessNetwork(final WirelessEndpoint endpoint) {
|
||||
if (instance != null)
|
||||
instance.joinWirelessNetwork(endpoint);
|
||||
if (API.network != null)
|
||||
API.network.joinWirelessNetwork(endpoint);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,8 +91,8 @@ public final class Network {
|
||||
* @param endpoint the endpoint for which to update the position.
|
||||
*/
|
||||
public static void updateWirelessNetwork(final WirelessEndpoint endpoint) {
|
||||
if (instance != null)
|
||||
instance.updateWirelessNetwork(endpoint);
|
||||
if (API.network != null)
|
||||
API.network.updateWirelessNetwork(endpoint);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,8 +106,8 @@ public final class Network {
|
||||
* @param endpoint the endpoint to remove from the wireless network.
|
||||
*/
|
||||
public static void leaveWirelessNetwork(final WirelessEndpoint endpoint) {
|
||||
if (instance != null)
|
||||
instance.leaveWirelessNetwork(endpoint);
|
||||
if (API.network != null)
|
||||
API.network.leaveWirelessNetwork(endpoint);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,8 +124,8 @@ public final class Network {
|
||||
* @param packet the packet to send.
|
||||
*/
|
||||
public static void sendWirelessPacket(final WirelessEndpoint source, final double strength, final Packet packet) {
|
||||
if (instance != null)
|
||||
instance.sendWirelessPacket(source, strength, packet);
|
||||
if (API.network != null)
|
||||
API.network.sendWirelessPacket(source, strength, packet);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
@ -169,8 +168,8 @@ public final class Network {
|
||||
* @return a new node builder.
|
||||
*/
|
||||
public static Builder.NodeBuilder newNode(final Environment host, final Visibility reachability) {
|
||||
if (instance != null)
|
||||
return instance.newNode(host, reachability);
|
||||
if (API.network != null)
|
||||
return API.network.newNode(host, reachability);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -190,8 +189,8 @@ public final class Network {
|
||||
* @return the new packet.
|
||||
*/
|
||||
public static Packet newPacket(final String source, final String destination, final int port, final Object[] data) {
|
||||
if (instance != null)
|
||||
return instance.newPacket(source, destination, port, data);
|
||||
if (API.network != null)
|
||||
return API.network.newPacket(source, destination, port, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -202,8 +201,8 @@ public final class Network {
|
||||
* @return the loaded packet.
|
||||
*/
|
||||
public static Packet newPacket(final NBTTagCompound nbt) {
|
||||
if (instance != null)
|
||||
return instance.newPacket(nbt);
|
||||
if (API.network != null)
|
||||
return API.network.newPacket(nbt);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -211,6 +210,4 @@ public final class Network {
|
||||
|
||||
private Network() {
|
||||
}
|
||||
|
||||
public static NetworkAPI instance = null;
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ More control
|
||||
------------
|
||||
If you really need more control over how how your tile entity interacts with OpenComputer's internal network, you will have to implement the `Environment` interface on your tile entity. There's a basic implementation in the prefab package, named `TileEntityEnvironment`. Doing so will give you access to the `Node` that connects to the component network, and you must take care of the construction of the node itself (using the factory method in `api.Network`). This allows you to make the node a `Connector` node, which will allow you to draw internal power from OpenComputers or feed energy into it. You will also be able to send messages over the component network, see the `send...` methods in the `Node` interface. See the documentation on those interfaces to get a better idea on how they work together.
|
||||
|
||||
Making a thrid-party block available as component / peripheral
|
||||
Making a third-party block available as component / peripheral
|
||||
--------------------------------------------------------------
|
||||
Blocks from other mods, i.e. blocks where you have no control over the tile entity implementation, can be accessed using the Adapter block as long as there is a driver available that supports the block. If there are multiple drivers they are automatically merged. Please see the [OpenComponents][] project for examples, and consider contributing any block drivers you write to it. Thank you.
|
||||
Blocks from other mods, i.e. blocks where you have no control over the tile entity implementation, can be accessed using the Adapter block as long as there is a driver available that supports the block. If there are multiple drivers they are automatically merged. Please see the [integration][] package for examples, and consider contributing any block drivers you write. Thank you!
|
||||
|
||||
Making items available as components
|
||||
------------------------------------
|
||||
@ -82,4 +82,4 @@ public class TileEntityWithFileSystem extends TileEntityEnvironment {
|
||||
```
|
||||
|
||||
|
||||
[OpenComponents]: https://github.com/MightyPirates/OpenComponents
|
||||
[integration]: https://github.com/MightyPirates/OpenComputers/tree/master-MC1.7.10/src/main/scala/li/cil/oc/integration
|
@ -6,7 +6,9 @@
|
||||
* mod itself.
|
||||
*/
|
||||
@cpw.mods.fml.common.API(
|
||||
owner = "OpenComputers|Core",
|
||||
owner = API.ID_OWNER,
|
||||
provides = "OpenComputersAPI|Component",
|
||||
apiVersion = "3.0.1")
|
||||
package li.cil.oc.api.component;
|
||||
apiVersion = API.VERSION)
|
||||
package li.cil.oc.api.component;
|
||||
|
||||
import li.cil.oc.api.API;
|
@ -5,7 +5,9 @@
|
||||
* that is without creating an actual environment.
|
||||
*/
|
||||
@cpw.mods.fml.common.API(
|
||||
owner = "OpenComputers|Core",
|
||||
owner = API.ID_OWNER,
|
||||
provides = "OpenComputersAPI|Driver|Item",
|
||||
apiVersion = "3.0.1")
|
||||
package li.cil.oc.api.driver.item;
|
||||
apiVersion = API.VERSION)
|
||||
package li.cil.oc.api.driver.item;
|
||||
|
||||
import li.cil.oc.api.API;
|
@ -5,7 +5,9 @@
|
||||
* which is mostly used to make components wrapping them available to computers.
|
||||
*/
|
||||
@cpw.mods.fml.common.API(
|
||||
owner = "OpenComputers|Core",
|
||||
owner = API.ID_OWNER,
|
||||
provides = "OpenComputersAPI|Driver",
|
||||
apiVersion = "3.0.1")
|
||||
package li.cil.oc.api.driver;
|
||||
apiVersion = API.VERSION)
|
||||
package li.cil.oc.api.driver;
|
||||
|
||||
import li.cil.oc.api.API;
|
@ -3,7 +3,9 @@
|
||||
* of its functionality.
|
||||
*/
|
||||
@cpw.mods.fml.common.API(
|
||||
owner = "OpenComputers|Core",
|
||||
owner = API.ID_OWNER,
|
||||
provides = "OpenComputersAPI|Event",
|
||||
apiVersion = "3.0.1")
|
||||
package li.cil.oc.api.event;
|
||||
apiVersion = API.VERSION)
|
||||
package li.cil.oc.api.event;
|
||||
|
||||
import li.cil.oc.api.API;
|
@ -14,7 +14,9 @@
|
||||
* from computers).
|
||||
*/
|
||||
@cpw.mods.fml.common.API(
|
||||
owner = "OpenComputers|Core",
|
||||
owner = API.ID_OWNER,
|
||||
provides = "OpenComputersAPI|FileSystem",
|
||||
apiVersion = "3.0.1")
|
||||
package li.cil.oc.api.fs;
|
||||
apiVersion = API.VERSION)
|
||||
package li.cil.oc.api.fs;
|
||||
|
||||
import li.cil.oc.api.API;
|
@ -14,7 +14,9 @@
|
||||
* be assignable to one of the interfaces in this package).
|
||||
*/
|
||||
@cpw.mods.fml.common.API(
|
||||
owner = "OpenComputers|Core",
|
||||
owner = API.ID_OWNER,
|
||||
provides = "OpenComputersAPI|Internal",
|
||||
apiVersion = "3.0.1")
|
||||
package li.cil.oc.api.internal;
|
||||
apiVersion = API.VERSION)
|
||||
package li.cil.oc.api.internal;
|
||||
|
||||
import li.cil.oc.api.API;
|
@ -17,7 +17,9 @@
|
||||
* fashion, such as {@link li.cil.oc.api.internal.Robot}.
|
||||
*/
|
||||
@cpw.mods.fml.common.API(
|
||||
owner = "OpenComputers|Core",
|
||||
owner = API.ID_OWNER,
|
||||
provides = "OpenComputersAPI|Machine",
|
||||
apiVersion = "3.0.1")
|
||||
package li.cil.oc.api.machine;
|
||||
apiVersion = API.VERSION)
|
||||
package li.cil.oc.api.machine;
|
||||
|
||||
import li.cil.oc.api.API;
|
@ -5,7 +5,9 @@
|
||||
* all of OpenComputers' components, including blocks and items alike.
|
||||
*/
|
||||
@cpw.mods.fml.common.API(
|
||||
owner = "OpenComputers|Core",
|
||||
owner = API.ID_OWNER,
|
||||
provides = "OpenComputersAPI|Network",
|
||||
apiVersion = "3.0.1")
|
||||
package li.cil.oc.api.network;
|
||||
apiVersion = API.VERSION)
|
||||
package li.cil.oc.api.network;
|
||||
|
||||
import li.cil.oc.api.API;
|
@ -35,7 +35,7 @@
|
||||
* </dl>
|
||||
*/
|
||||
@cpw.mods.fml.common.API(
|
||||
owner = "OpenComputers|Core",
|
||||
owner = API.ID_OWNER,
|
||||
provides = "OpenComputersAPI|Core",
|
||||
apiVersion = "3.0.1")
|
||||
apiVersion = API.VERSION)
|
||||
package li.cil.oc.api;
|
@ -8,7 +8,9 @@
|
||||
* with your mod!
|
||||
*/
|
||||
@cpw.mods.fml.common.API(
|
||||
owner = "OpenComputers|Core",
|
||||
owner = API.ID_OWNER,
|
||||
provides = "OpenComputersAPI|Prefab",
|
||||
apiVersion = "3.0.1")
|
||||
package li.cil.oc.api.prefab;
|
||||
apiVersion = API.VERSION)
|
||||
package li.cil.oc.api.prefab;
|
||||
|
||||
import li.cil.oc.api.API;
|
@ -9,7 +9,6 @@ import li.cil.oc.common.init.Items
|
||||
import li.cil.oc.common.recipe.Recipes
|
||||
import li.cil.oc.integration.Mods
|
||||
import li.cil.oc.server._
|
||||
import li.cil.oc.server.machine
|
||||
import li.cil.oc.server.machine.luac.NativeLuaArchitecture
|
||||
import li.cil.oc.server.machine.luaj.LuaJLuaArchitecture
|
||||
import li.cil.oc.util.LuaStateFactory
|
||||
@ -42,15 +41,15 @@ class Proxy {
|
||||
OpenComputers.log.info("Initializing OpenComputers API.")
|
||||
|
||||
api.CreativeTab.instance = CreativeTab
|
||||
api.Driver.instance = driver.Registry
|
||||
api.FileSystem.instance = fs.FileSystem
|
||||
api.Items.instance = Items
|
||||
api.Machine.instance = machine.Machine
|
||||
api.API.driver = driver.Registry
|
||||
api.API.fileSystem = fs.FileSystem
|
||||
api.API.items = Items
|
||||
api.API.machine = machine.Machine
|
||||
api.Machine.LuaArchitecture =
|
||||
if (LuaStateFactory.isAvailable && !Settings.get.forceLuaJ) classOf[NativeLuaArchitecture]
|
||||
else classOf[LuaJLuaArchitecture]
|
||||
api.Machine.add(api.Machine.LuaArchitecture)
|
||||
api.Network.instance = network.Network
|
||||
api.API.network = network.Network
|
||||
}
|
||||
|
||||
def init(e: FMLInitializationEvent) {
|
||||
|
@ -2,6 +2,7 @@ package li.cil.oc.common.block
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.common.tileentity
|
||||
import li.cil.oc.integration.util.NEI
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.entity.Entity
|
||||
@ -13,6 +14,8 @@ import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.world.World
|
||||
|
||||
class DelegatorConverter extends Block(Material.rock) {
|
||||
NEI.hide(this)
|
||||
|
||||
override def hasTileEntity(metadata: Int) = true
|
||||
|
||||
// We don't have to register this tile entity because it'll vanish immediately anyway, so
|
||||
@ -23,6 +26,8 @@ class DelegatorConverter extends Block(Material.rock) {
|
||||
object DelegatorConverter {
|
||||
|
||||
class Item(block: Block) extends ItemBlock(block) {
|
||||
override def getItemStackDisplayName(stack: ItemStack) = "Pick me up to fix me!"
|
||||
|
||||
override def onUpdate(stack: ItemStack, world: World, entity: Entity, slot: Int, selected: Boolean) {
|
||||
entity match {
|
||||
case player: EntityPlayer => DelegatorConverter.convert(stack, this) match {
|
||||
|
Loading…
x
Reference in New Issue
Block a user