Little bit of cleanup, API refactoring.

This commit is contained in:
Florian Nücke 2017-04-02 16:58:02 +02:00
parent 44e3b0ee46
commit bcd2fd7707
77 changed files with 217 additions and 301 deletions

View File

@ -18,7 +18,7 @@ import li.cil.oc.api.detail.NetworkAPI;
*/ */
public class API { public class API {
public static final String ID_OWNER = "opencomputers|core"; public static final String ID_OWNER = "opencomputers|core";
public static final String VERSION = "6.0.0-alpha"; public static final String VERSION = "7.0.0-alpha";
// ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- //

View File

@ -3,11 +3,10 @@ package li.cil.oc.api;
import li.cil.oc.api.driver.Converter; import li.cil.oc.api.driver.Converter;
import li.cil.oc.api.driver.EnvironmentProvider; import li.cil.oc.api.driver.EnvironmentProvider;
import li.cil.oc.api.driver.InventoryProvider; import li.cil.oc.api.driver.InventoryProvider;
import li.cil.oc.api.driver.Item; import li.cil.oc.api.driver.DriverItem;
import li.cil.oc.api.driver.SidedBlock; import li.cil.oc.api.driver.DriverBlock;
import li.cil.oc.api.network.EnvironmentHost; import li.cil.oc.api.network.EnvironmentHost;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -31,8 +30,8 @@ import java.util.Set;
* at that time. Only start calling these methods in the init phase or later. * at that time. Only start calling these methods in the init phase or later.
* *
* @see Network * @see Network
* @see SidedBlock * @see DriverBlock
* @see Item * @see DriverItem
*/ */
public final class Driver { public final class Driver {
/** /**
@ -47,7 +46,7 @@ public final class Driver {
* *
* @param driver the driver to register. * @param driver the driver to register.
*/ */
public static void add(final SidedBlock driver) { public static void add(final DriverBlock driver) {
if (API.driver != null) if (API.driver != null)
API.driver.add(driver); API.driver.add(driver);
} }
@ -63,7 +62,7 @@ public final class Driver {
* *
* @param driver the driver to register. * @param driver the driver to register.
*/ */
public static void add(final Item driver) { public static void add(final DriverItem driver) {
if (API.driver != null) if (API.driver != null)
API.driver.add(driver); API.driver.add(driver);
} }
@ -119,13 +118,13 @@ public final class Driver {
* Note that several drivers for a single block can exist. Because of this * Note that several drivers for a single block can exist. Because of this
* block drivers are always encapsulated in a 'compound' driver, which is * block drivers are always encapsulated in a 'compound' driver, which is
* what will be returned here. In other words, you will <em>not</em> * what will be returned here. In other words, you will <em>not</em>
* get actual instances of drivers registered via {@link #add(li.cil.oc.api.driver.SidedBlock)}. * get actual instances of drivers registered via {@link #add(DriverBlock)}.
* *
* @param world the world containing the block. * @param world the world containing the block.
* @param pos the position of the block. * @param pos the position of the block.
* @return a driver for the block, or <tt>null</tt> if there is none. * @return a driver for the block, or <tt>null</tt> if there is none.
*/ */
public static SidedBlock driverFor(World world, BlockPos pos, EnumFacing side) { public static DriverBlock driverFor(World world, BlockPos pos, EnumFacing side) {
if (API.driver != null) if (API.driver != null)
return API.driver.driverFor(world, pos, side); return API.driver.driverFor(world, pos, side);
return null; return null;
@ -142,7 +141,7 @@ public final class Driver {
* @param host the type that will host the environment created by returned driver. * @param host the type that will host the environment created by returned driver.
* @return a driver for the item, or <tt>null</tt> if there is none. * @return a driver for the item, or <tt>null</tt> if there is none.
*/ */
public static Item driverFor(ItemStack stack, Class<? extends EnvironmentHost> host) { public static DriverItem driverFor(ItemStack stack, Class<? extends EnvironmentHost> host) {
if (API.driver != null) if (API.driver != null)
return API.driver.driverFor(stack, host); return API.driver.driverFor(stack, host);
return null; return null;
@ -161,7 +160,7 @@ public final class Driver {
* @param stack the item stack to get a driver for. * @param stack the item stack to get a driver for.
* @return a driver for the item, or <tt>null</tt> if there is none. * @return a driver for the item, or <tt>null</tt> if there is none.
*/ */
public static Item driverFor(ItemStack stack) { public static DriverItem driverFor(ItemStack stack) {
if (API.driver != null) if (API.driver != null)
return API.driver.driverFor(stack); return API.driver.driverFor(stack);
return null; return null;
@ -231,7 +230,7 @@ public final class Driver {
* *
* @return the list of all registered item drivers. * @return the list of all registered item drivers.
*/ */
public static Collection<Item> itemDrivers() { public static Collection<DriverItem> itemDrivers() {
if (API.driver != null) if (API.driver != null)
return API.driver.itemDrivers(); return API.driver.itemDrivers();
return null; return null;

View File

@ -23,6 +23,19 @@ import org.apache.commons.lang3.tuple.Pair;
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public final class IMC { public final class IMC {
public static final String REGISTER_ASSEMBLER_FILTER = "registerAssemblerFilter";
public static final String REGISTER_ASSEMBLER_TEMPLATE = "registerAssemblerTemplate";
public static final String REGISTER_DISASSEMBLER_TEMPLATE = "registerDisassemblerTemplate";
public static final String REGISTER_TOOL_DURABILITY_PROVIDER = "registerToolDurabilityProvider";
public static final String REGISTER_WRENCH_TOOL = "registerWrenchTool";
public static final String REGISTER_WRENCH_TOOL_CHECK = "registerWrenchToolCheck";
public static final String REGISTER_ITEM_CHARGE = "registerItemCharge";
public static final String REGISTER_INK_PROVIDER = "registerInkProvider";
public static final String BLACKLIST_PERIPHERAL = "blacklistPeripheral";
public static final String BLACKLIST_HOST = "blacklistHost";
public static final String REGISTER_CUSTOM_POWER_SYSTEM = "registerCustomPowerSystem";
public static final String REGISTER_PROGRAM_DISK_LABEL = "registerProgramDiskLabel";
/** /**
* Register a callback that is used as a filter for assembler templates. * Register a callback that is used as a filter for assembler templates.
* Any templates that require a base item that is rejected by <em>any</em> * Any templates that require a base item that is rejected by <em>any</em>
@ -40,7 +53,7 @@ public final class IMC {
* @param callback the callback to register as a filtering method. * @param callback the callback to register as a filtering method.
*/ */
public static void registerAssemblerFilter(final String callback) { public static void registerAssemblerFilter(final String callback) {
FMLInterModComms.sendMessage(MOD_ID, "registerAssemblerFilter", callback); FMLInterModComms.sendMessage(MOD_ID, REGISTER_ASSEMBLER_FILTER, callback);
} }
/** /**
@ -153,7 +166,7 @@ public final class IMC {
nbt.setTag("componentSlots", componentsNbt); nbt.setTag("componentSlots", componentsNbt);
} }
FMLInterModComms.sendMessage(MOD_ID, "registerAssemblerTemplate", nbt); FMLInterModComms.sendMessage(MOD_ID, REGISTER_ASSEMBLER_TEMPLATE, nbt);
} }
/** /**
@ -197,7 +210,7 @@ public final class IMC {
nbt.setString("select", select); nbt.setString("select", select);
nbt.setString("disassemble", disassemble); nbt.setString("disassemble", disassemble);
FMLInterModComms.sendMessage(MOD_ID, "registerDisassemblerTemplate", nbt); FMLInterModComms.sendMessage(MOD_ID, REGISTER_DISASSEMBLER_TEMPLATE, nbt);
} }
/** /**
@ -221,7 +234,7 @@ public final class IMC {
* @param callback the callback to register as a durability provider. * @param callback the callback to register as a durability provider.
*/ */
public static void registerToolDurabilityProvider(final String callback) { public static void registerToolDurabilityProvider(final String callback) {
FMLInterModComms.sendMessage(MOD_ID, "registerToolDurabilityProvider", callback); FMLInterModComms.sendMessage(MOD_ID, REGISTER_TOOL_DURABILITY_PROVIDER, callback);
} }
/** /**
@ -245,7 +258,7 @@ public final class IMC {
* @param callback the callback to register as a wrench tool handler. * @param callback the callback to register as a wrench tool handler.
*/ */
public static void registerWrenchTool(final String callback) { public static void registerWrenchTool(final String callback) {
FMLInterModComms.sendMessage(MOD_ID, "registerWrenchTool", callback); FMLInterModComms.sendMessage(MOD_ID, REGISTER_WRENCH_TOOL, callback);
} }
/** /**
@ -268,7 +281,7 @@ public final class IMC {
* @param callback the callback to register as a wrench tool tester. * @param callback the callback to register as a wrench tool tester.
*/ */
public static void registerWrenchToolCheck(final String callback) { public static void registerWrenchToolCheck(final String callback) {
FMLInterModComms.sendMessage(MOD_ID, "registerWrenchToolCheck", callback); FMLInterModComms.sendMessage(MOD_ID, REGISTER_WRENCH_TOOL_CHECK, callback);
} }
/** /**
@ -298,7 +311,7 @@ public final class IMC {
nbt.setString("name", name); nbt.setString("name", name);
nbt.setString("canCharge", canCharge); nbt.setString("canCharge", canCharge);
nbt.setString("charge", charge); nbt.setString("charge", charge);
FMLInterModComms.sendMessage(MOD_ID, "registerItemCharge", nbt); FMLInterModComms.sendMessage(MOD_ID, REGISTER_ITEM_CHARGE, nbt);
} }
/** /**
@ -322,7 +335,7 @@ public final class IMC {
* @param callback the callback to register as an ink provider. * @param callback the callback to register as an ink provider.
*/ */
public static void registerInkProvider(final String callback) { public static void registerInkProvider(final String callback) {
FMLInterModComms.sendMessage(MOD_ID, "registerInkProvider", callback); FMLInterModComms.sendMessage(MOD_ID, REGISTER_INK_PROVIDER, callback);
} }
/** /**
@ -335,7 +348,7 @@ public final class IMC {
* @param peripheral the class of the peripheral to blacklist. * @param peripheral the class of the peripheral to blacklist.
*/ */
public static void blacklistPeripheral(final Class peripheral) { public static void blacklistPeripheral(final Class peripheral) {
FMLInterModComms.sendMessage(MOD_ID, "blacklistPeripheral", peripheral.getName()); FMLInterModComms.sendMessage(MOD_ID, BLACKLIST_PERIPHERAL, peripheral.getName());
} }
/** /**
@ -360,7 +373,7 @@ public final class IMC {
final NBTTagCompound stackNbt = new NBTTagCompound(); final NBTTagCompound stackNbt = new NBTTagCompound();
stack.writeToNBT(stackNbt); stack.writeToNBT(stackNbt);
nbt.setTag("item", stackNbt); nbt.setTag("item", stackNbt);
FMLInterModComms.sendMessage(MOD_ID, "blacklistHost", nbt); FMLInterModComms.sendMessage(MOD_ID, BLACKLIST_HOST, nbt);
} }
/** /**
@ -371,7 +384,7 @@ public final class IMC {
* avoid auto-disabling power use. * avoid auto-disabling power use.
*/ */
public static void registerCustomPowerSystem() { public static void registerCustomPowerSystem() {
FMLInterModComms.sendMessage(MOD_ID, "registerCustomPowerSystem", "true"); FMLInterModComms.sendMessage(MOD_ID, REGISTER_CUSTOM_POWER_SYSTEM, "true");
} }
/** /**
@ -409,7 +422,7 @@ public final class IMC {
} }
nbt.setTag("architectures", architecturesNbt); nbt.setTag("architectures", architecturesNbt);
} }
FMLInterModComms.sendMessage(MOD_ID, "registerProgramDiskLabel", nbt); FMLInterModComms.sendMessage(MOD_ID, REGISTER_PROGRAM_DISK_LABEL, nbt);
} }
// ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- //

View File

@ -47,35 +47,6 @@ public final class Items {
return null; return null;
} }
/**
* Register a single loot floppy disk.
* <p/>
* The disk will be listed in the creative tab of OpenComputers.
* <p/>
* The specified factory callable will be used to generate a new file
* system when the loot disk is used as a component. The specified name
* will be used as the label for the loot disk, as well as the identifier
* to select the corresponding factory method, so choose wisely.
* <p/>
* To use some directory in your mod JAR as the directory provided by the
* loot disk, use {@link FileSystem#fromClass} in your callable.
* <p/>
* Call this in the init phase or later, <em>not</em> in pre-init.
*
* @param name the label and identifier to use for the loot disk.
* @param color the color of the disk, as a Minecraft color.
* @param factory the callable to call for creating file system instances.
* @return an item stack representing the registered loot disk, to allow
* adding a recipe for your loot disk, for example.
* @deprecated use {@link #registerFloppy(String, EnumDyeColor, Callable, boolean)} instead.
*/
@Deprecated
public static ItemStack registerFloppy(String name, EnumDyeColor color, Callable<li.cil.oc.api.fs.FileSystem> factory) {
if (API.items != null)
return API.items.registerFloppy(name, color, factory);
return ItemStack.EMPTY;
}
/** /**
* Register a single loot floppy disk. * Register a single loot floppy disk.
* <p/> * <p/>

View File

@ -1,17 +0,0 @@
package li.cil.oc.api.component;
/**
* <em>Not meant to be implemented.</em>
*
* @deprecated Use li.cil.oc.api.internal.Keyboard instead.
*/
@Deprecated
public interface Keyboard extends li.cil.oc.api.internal.Keyboard {
/**
* <em>Not meant to be implemented.</em>
*
* @deprecated Use li.cil.oc.api.internal.Keyboard.UsabilityChecker instead.
*/
interface UsabilityChecker extends li.cil.oc.api.internal.Keyboard.UsabilityChecker {
}
}

View File

@ -1,16 +0,0 @@
package li.cil.oc.api.component;
import li.cil.oc.api.Persistable;
import li.cil.oc.api.network.ManagedEnvironment;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
/**
* <em>Not meant to be implemented.</em>
*
* @deprecated Use li.cil.oc.api.internal.TextBuffer instead.
*/
@Deprecated
public interface TextBuffer extends li.cil.oc.api.internal.TextBuffer {
}

View File

@ -4,8 +4,8 @@ import jline.internal.Nullable;
import li.cil.oc.api.driver.Converter; import li.cil.oc.api.driver.Converter;
import li.cil.oc.api.driver.EnvironmentProvider; import li.cil.oc.api.driver.EnvironmentProvider;
import li.cil.oc.api.driver.InventoryProvider; import li.cil.oc.api.driver.InventoryProvider;
import li.cil.oc.api.driver.Item; import li.cil.oc.api.driver.DriverItem;
import li.cil.oc.api.driver.SidedBlock; import li.cil.oc.api.driver.DriverBlock;
import li.cil.oc.api.network.EnvironmentHost; import li.cil.oc.api.network.EnvironmentHost;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -30,7 +30,7 @@ public interface DriverAPI {
* *
* @param driver the driver to register. * @param driver the driver to register.
*/ */
void add(SidedBlock driver); void add(DriverBlock driver);
/** /**
* Registers a new driver for an item component. * Registers a new driver for an item component.
@ -43,7 +43,7 @@ public interface DriverAPI {
* *
* @param driver the driver for an item component. * @param driver the driver for an item component.
*/ */
void add(Item driver); void add(DriverItem driver);
/** /**
* Registers a new type converter. * Registers a new type converter.
@ -87,7 +87,7 @@ public interface DriverAPI {
* Note that several drivers for a single block can exist. Because of this * Note that several drivers for a single block can exist. Because of this
* block drivers are always encapsulated in a 'compound' driver, which is * block drivers are always encapsulated in a 'compound' driver, which is
* what will be returned here. In other words, you should will <em>not</em> * what will be returned here. In other words, you should will <em>not</em>
* get actual instances of drivers registered via {@link #add(li.cil.oc.api.driver.SidedBlock)}. * get actual instances of drivers registered via {@link #add(DriverBlock)}.
* *
* @param world the world containing the block. * @param world the world containing the block.
* @param pos the position of the block. * @param pos the position of the block.
@ -95,7 +95,7 @@ public interface DriverAPI {
* @return a driver for the block, or <tt>null</tt> if there is none. * @return a driver for the block, or <tt>null</tt> if there is none.
*/ */
@Nullable @Nullable
SidedBlock driverFor(World world, BlockPos pos, EnumFacing side); DriverBlock driverFor(World world, BlockPos pos, EnumFacing side);
/** /**
* Looks up a driver for the specified item stack. * Looks up a driver for the specified item stack.
@ -109,7 +109,7 @@ public interface DriverAPI {
* @return a driver for the item, or <tt>null</tt> if there is none. * @return a driver for the item, or <tt>null</tt> if there is none.
*/ */
@Nullable @Nullable
Item driverFor(ItemStack stack, Class<? extends EnvironmentHost> host); DriverItem driverFor(ItemStack stack, Class<? extends EnvironmentHost> host);
/** /**
* Looks up a driver for the specified item stack. * Looks up a driver for the specified item stack.
@ -125,7 +125,7 @@ public interface DriverAPI {
* @return a driver for the item, or <tt>null</tt> if there is none. * @return a driver for the item, or <tt>null</tt> if there is none.
*/ */
@Nullable @Nullable
Item driverFor(ItemStack stack); DriverItem driverFor(ItemStack stack);
/** /**
* Looks up the environment associated with the specified item stack. * Looks up the environment associated with the specified item stack.
@ -179,5 +179,5 @@ public interface DriverAPI {
* *
* @return the list of all registered item drivers. * @return the list of all registered item drivers.
*/ */
Collection<Item> itemDrivers(); Collection<DriverItem> itemDrivers();
} }

View File

@ -34,31 +34,6 @@ public interface ItemAPI {
@Nullable @Nullable
ItemInfo get(ItemStack stack); ItemInfo get(ItemStack stack);
/**
* Register a single loot floppy disk.
* <p/>
* The disk will be listed in the creative tab of OpenComputers.
* <p/>
* The specified factory callable will be used to generate a new file
* system when the loot disk is used as a component. The specified name
* will be used as the label for the loot disk, as well as the identifier
* to select the corresponding factory method, so choose wisely.
* <p/>
* To use some directory in your mod JAR as the directory provided by the
* loot disk, use {@link FileSystem#fromClass} in your callable.
* <p/>
* Call this in the init phase or later, <em>not</em> in pre-init.
*
* @param name the label and identifier to use for the loot disk.
* @param color the color of the disk, as a Minecraft color.
* @param factory the callable to call for creating file system instances.
* @return an item stack representing the registered loot disk, to allow
* adding a recipe for your loot disk, for example.
* @deprecated use {@link #registerFloppy(String, EnumDyeColor, Callable, boolean)} instead.
*/
@Deprecated
ItemStack registerFloppy(String name, EnumDyeColor color, Callable<li.cil.oc.api.fs.FileSystem> factory);
/** /**
* Register a single loot floppy disk. * Register a single loot floppy disk.
* <p/> * <p/>

View File

@ -26,7 +26,7 @@ import net.minecraft.world.World;
* Note that side-aware block drivers are queried before regular block drivers, * Note that side-aware block drivers are queried before regular block drivers,
* because they are more specific. * because they are more specific.
*/ */
public interface SidedBlock { public interface DriverBlock {
/** /**
* Used to determine the block types this driver handles. * Used to determine the block types this driver handles.
* <p/> * <p/>

View File

@ -22,7 +22,7 @@ import net.minecraft.nbt.NBTTagCompound;
* items as you wish. I'd recommend writing one per device (type), though, to * items as you wish. I'd recommend writing one per device (type), though, to
* keep things modular. * keep things modular.
*/ */
public interface Item { public interface DriverItem {
/** /**
* Used to determine the item types this driver handles. * Used to determine the item types this driver handles.
* <p/> * <p/>

View File

@ -1,40 +0,0 @@
package li.cil.oc.api.driver;
import li.cil.oc.api.network.Environment;
import net.minecraft.item.ItemStack;
/**
* This interface can be added to either item or block drivers.
* <p/>
* It is used to statically query the type of environment that would be created
* for the block or item represented by an item stack. This is used to provide
* automatically generated ingame help in the NEI usage screen, for example.
* <p/>
* For item drivers this will usually be pretty simple to implement, assuming
* the driver only ever generates one type of environment - just return the
* class of it and you're done.
* <p/>
* For block drivers there is a bit more work involved, since you have to check
* if the item is the item block that corresponds to the supported block type.
* This should usually not be an issue either, though.
*
* @deprecated Use an {@link EnvironmentProvider} instead.
*/
@Deprecated
public interface EnvironmentAware {
/**
* Get the type of environment that would be created for the specified
* block or item.
* <p/>
* Note that for block drivers this is called for any type of item stack.
* <p/>
* For item drivers this is only called if {@link Item#worksWith(net.minecraft.item.ItemStack)}
* returns <tt>true</tt>.
*
* @param stack the item stack representing a block or item to get the
* related environment type for.
* @return the type of environment this driver would produce, or
* <tt>null</tt> if the block or item is not supported.
*/
Class<? extends Environment> providedEnvironment(ItemStack stack);
}

View File

@ -1,7 +0,0 @@
package li.cil.oc.api.driver;
/**
* @deprecated Use li.cil.oc.api.network.EnvironmentHost directly.
*/
public interface EnvironmentHost extends li.cil.oc.api.network.EnvironmentHost {
}

View File

@ -20,7 +20,7 @@ public interface EnvironmentProvider {
* by the class transformer at runtime. * by the class transformer at runtime.
* <p/> * <p/>
* For items this will be the type of the environment returned by the * For items this will be the type of the environment returned by the
* item driver's {@link Item#createEnvironment} method. * item driver's {@link DriverItem#createEnvironment} method.
* *
* @param stack the stack to get the environment type for. * @param stack the stack to get the environment type for.
* @return the environment type for the specified stack. * @return the environment type for the specified stack.

View File

@ -17,7 +17,7 @@ import net.minecraft.util.math.BlockPos;
* suppress inventory functionality if your TileEntity implements IInventory. * suppress inventory functionality if your TileEntity implements IInventory.
* <p/> * <p/>
* To do so, implement this interface in the <em>environment</em> that you * To do so, implement this interface in the <em>environment</em> that you
* return from your driver's {@link SidedBlock#createEnvironment(net.minecraft.world.World, BlockPos, net.minecraft.util.EnumFacing)} * return from your driver's {@link DriverBlock#createEnvironment(net.minecraft.world.World, BlockPos, net.minecraft.util.EnumFacing)}
* method, and provide the names of the allowed methods from {@link #whitelistedMethods()}. * method, and provide the names of the allowed methods from {@link #whitelistedMethods()}.
* <p/> * <p/>
* <em>Important</em>: if multiple drivers apply to a single block that each * <em>Important</em>: if multiple drivers apply to a single block that each

View File

@ -9,7 +9,7 @@ import net.minecraft.util.math.BlockPos;
* <p/> * <p/>
* This was previously to be implemented on the driver itself, but that has been * This was previously to be implemented on the driver itself, but that has been
* deprecated. Implement it in the environment returned from the block driver's * deprecated. Implement it in the environment returned from the block driver's
* {@link SidedBlock#createEnvironment(net.minecraft.world.World, BlockPos, net.minecraft.util.EnumFacing)} * {@link DriverBlock#createEnvironment(net.minecraft.world.World, BlockPos, net.minecraft.util.EnumFacing)}
* method instead. * method instead.
*/ */
public interface NamedBlock { public interface NamedBlock {

View File

@ -1,6 +1,6 @@
package li.cil.oc.api.driver.item; package li.cil.oc.api.driver.item;
import li.cil.oc.api.driver.Item; import li.cil.oc.api.driver.DriverItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
/** /**
@ -12,7 +12,7 @@ import net.minecraft.item.ItemStack;
* These drivers will not be queried for environments. The reported tier is the * These drivers will not be queried for environments. The reported tier is the
* maximum tier supported in the dynamic slot they provide. * maximum tier supported in the dynamic slot they provide.
*/ */
public interface Container extends Item { public interface Container extends DriverItem {
/** /**
* The type of slot provided as the dynamic slot. This will usually be * The type of slot provided as the dynamic slot. This will usually be
* for other upgrades, but may be for any type of item component. * for other upgrades, but may be for any type of item component.

View File

@ -1,7 +1,7 @@
package li.cil.oc.api.driver.item; package li.cil.oc.api.driver.item;
import li.cil.oc.api.network.EnvironmentHost; import li.cil.oc.api.network.EnvironmentHost;
import li.cil.oc.api.driver.Item; import li.cil.oc.api.driver.DriverItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
/** /**
@ -11,7 +11,7 @@ import net.minecraft.item.ItemStack;
* This is useful for drivers for components that should only go into certain * This is useful for drivers for components that should only go into certain
* environments, such as robot specific upgrades. * environments, such as robot specific upgrades.
*/ */
public interface HostAware extends Item { public interface HostAware extends DriverItem {
/** /**
* Used to determine the item types this driver handles. * Used to determine the item types this driver handles.
* <p/> * <p/>

View File

@ -1,6 +1,6 @@
package li.cil.oc.api.driver.item; package li.cil.oc.api.driver.item;
import li.cil.oc.api.driver.Item; import li.cil.oc.api.driver.DriverItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
/** /**
@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack;
* can be no hot-swappable inventories - at least none that are represented * can be no hot-swappable inventories - at least none that are represented
* in the GUI. * in the GUI.
*/ */
public interface Inventory extends Item { public interface Inventory extends DriverItem {
/** /**
* The additional amount of inventory space the specified item provides. * The additional amount of inventory space the specified item provides.
* *

View File

@ -1,6 +1,6 @@
package li.cil.oc.api.driver.item; package li.cil.oc.api.driver.item;
import li.cil.oc.api.driver.Item; import li.cil.oc.api.driver.DriverItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
/** /**
@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack;
* work. If it is installed in an external inventory the computer will not * work. If it is installed in an external inventory the computer will not
* recognize the memory. * recognize the memory.
*/ */
public interface Memory extends Item { public interface Memory extends DriverItem {
/** /**
* The amount of RAM this component provides, as a generic scaling factor. * The amount of RAM this component provides, as a generic scaling factor.
* <p/> * <p/>

View File

@ -1,6 +1,6 @@
package li.cil.oc.api.driver.item; package li.cil.oc.api.driver.item;
import li.cil.oc.api.driver.Item; import li.cil.oc.api.driver.DriverItem;
import li.cil.oc.api.machine.Architecture; import li.cil.oc.api.machine.Architecture;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -12,7 +12,7 @@ import net.minecraft.item.ItemStack;
* work. If it is installed in an external inventory the server will not * work. If it is installed in an external inventory the server will not
* recognize the memory. * recognize the memory.
*/ */
public interface Processor extends Item { public interface Processor extends DriverItem {
/** /**
* The additional number of components supported if this processor is * The additional number of components supported if this processor is
* installed in the server. * installed in the server.

View File

@ -1,12 +1,13 @@
package li.cil.oc.api.internal; package li.cil.oc.api.internal;
import li.cil.oc.api.driver.DriverItem;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
/** /**
* This interface is implemented by the computer case and robot tile entities * This interface is implemented by the computer case and robot tile entities
* to allow item components to query the orientation of their host, i.e. to * to allow item components to query the orientation of their host, i.e. to
* allow getting the facing of the tile entity passed to their drivers' * allow getting the facing of the tile entity passed to their drivers'
* {@link li.cil.oc.api.driver.Item#createEnvironment(net.minecraft.item.ItemStack, li.cil.oc.api.network.EnvironmentHost)} * {@link DriverItem#createEnvironment(net.minecraft.item.ItemStack, li.cil.oc.api.network.EnvironmentHost)}
* method. * method.
* <p/> * <p/>
* This interface is <em>not meant to be implemented</em>, just used. * This interface is <em>not meant to be implemented</em>, just used.

View File

@ -1,6 +1,8 @@
package li.cil.oc.api.network; package li.cil.oc.api.network;
import li.cil.oc.api.Persistable; import li.cil.oc.api.Persistable;
import li.cil.oc.api.driver.DriverBlock;
import li.cil.oc.api.driver.DriverItem;
/** /**
* A single node in a {@link Network}. * A single node in a {@link Network}.
@ -17,9 +19,9 @@ import li.cil.oc.api.Persistable;
* All other kinds of nodes you may come up with will also have to be * All other kinds of nodes you may come up with will also have to be
* handled manually. * handled manually.
* <p/> * <p/>
* Items have to be handled by a corresponding {@link li.cil.oc.api.driver.Item}. * Items have to be handled by a corresponding {@link DriverItem}.
* Existing blocks may be interfaced with the adapter block if a * Existing blocks may be interfaced with the adapter block if a
* {@link li.cil.oc.api.driver.SidedBlock} exists that supports the block. * {@link DriverBlock} exists that supports the block.
* <p/> * <p/>
* <em>Important</em>: like the <tt>Network</tt> interface you must not create * <em>Important</em>: like the <tt>Network</tt> interface you must not create
* your own implementations of this interface. Use the factory methods in the * your own implementations of this interface. Use the factory methods in the

View File

@ -1,5 +1,6 @@
package li.cil.oc.api.prefab; package li.cil.oc.api.prefab;
import li.cil.oc.api.network.ManagedEnvironment;
import li.cil.oc.api.network.Message; import li.cil.oc.api.network.Message;
import li.cil.oc.api.network.Node; import li.cil.oc.api.network.Node;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -8,7 +9,7 @@ import net.minecraft.nbt.NBTTagCompound;
* Simple base implementation of the <tt>ManagedEnvironment</tt> interface, so * Simple base implementation of the <tt>ManagedEnvironment</tt> interface, so
* unused methods don't clutter the implementing class. * unused methods don't clutter the implementing class.
*/ */
public abstract class ManagedEnvironment implements li.cil.oc.api.network.ManagedEnvironment { public abstract class AbstractManagedEnvironment implements ManagedEnvironment {
public static final String NODE_TAG = "node"; public static final String NODE_TAG = "node";
// Should be initialized using setNode(api.Network.newNode()). See TileEntityEnvironment. // Should be initialized using setNode(api.Network.newNode()). See TileEntityEnvironment.

View File

@ -19,7 +19,7 @@ import net.minecraft.nbt.NBTTagCompound;
* @see li.cil.oc.api.network.ManagedEnvironment * @see li.cil.oc.api.network.ManagedEnvironment
*/ */
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public abstract class DriverItem implements li.cil.oc.api.driver.Item { public abstract class DriverItem implements li.cil.oc.api.driver.DriverItem {
protected final ItemStack[] items; protected final ItemStack[] items;
protected DriverItem(final ItemStack... items) { protected DriverItem(final ItemStack... items) {

View File

@ -1,5 +1,6 @@
package li.cil.oc.api.prefab; package li.cil.oc.api.prefab;
import li.cil.oc.api.driver.DriverBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
@ -27,7 +28,7 @@ import net.minecraftforge.oredict.OreDictionary;
* @see li.cil.oc.api.network.ManagedEnvironment * @see li.cil.oc.api.network.ManagedEnvironment
*/ */
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public abstract class DriverSidedBlock implements li.cil.oc.api.driver.SidedBlock { public abstract class DriverSidedBlock implements DriverBlock {
protected final ItemStack[] blocks; protected final ItemStack[] blocks;
protected DriverSidedBlock(final ItemStack... blocks) { protected DriverSidedBlock(final ItemStack... blocks) {

View File

@ -1,5 +1,6 @@
package li.cil.oc.api.prefab; package li.cil.oc.api.prefab;
import li.cil.oc.api.driver.DriverBlock;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -9,7 +10,7 @@ import net.minecraft.world.World;
* To limit sidedness, I recommend overriding {@link #worksWith(World, BlockPos, EnumFacing)} * To limit sidedness, I recommend overriding {@link #worksWith(World, BlockPos, EnumFacing)}
* and calling <code>super.worksWith</code> in addition to the side check. * and calling <code>super.worksWith</code> in addition to the side check.
*/ */
public abstract class DriverSidedTileEntity implements li.cil.oc.api.driver.SidedBlock { public abstract class DriverSidedTileEntity implements DriverBlock {
public abstract Class<?> getTileEntityClass(); public abstract Class<?> getTileEntityClass();
@Override @Override

View File

@ -7,7 +7,6 @@ import li.cil.oc.api.network.Node;
import li.cil.oc.api.network.Visibility; import li.cil.oc.api.network.Visibility;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ITickable;
/** /**
* TileEntities can implement the {@link li.cil.oc.api.network.Environment} * TileEntities can implement the {@link li.cil.oc.api.network.Environment}
@ -18,7 +17,9 @@ import net.minecraft.util.ITickable;
* network as an index structure to find other nodes connected to them. * network as an index structure to find other nodes connected to them.
*/ */
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public abstract class TileEntityEnvironment extends TileEntity implements Environment, ITickable { public abstract class TileEntityEnvironment extends TileEntity implements Environment {
private static final String TAG_NODE = "oc:node";
/** /**
* This must be set in subclasses to the node that is used to represent * This must be set in subclasses to the node that is used to represent
* this tile entity. * this tile entity.
@ -56,9 +57,6 @@ public abstract class TileEntityEnvironment extends TileEntity implements Enviro
*/ */
protected Node node; protected Node node;
// See updateEntity().
protected boolean addedToNetwork = false;
// ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- //
@Override @Override
@ -97,16 +95,8 @@ public abstract class TileEntityEnvironment extends TileEntity implements Enviro
// ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- //
@Override @Override
public void update() { public void onLoad() {
// On the first update, try to add our node to nearby networks. We do Network.joinOrCreateNetwork(this);
// this in the update logic, not in validate() because we need to access
// neighboring tile entities, which isn't possible in validate().
// We could alternatively check node != null && node.network() == null,
// but this has somewhat better performance, and makes it clearer.
if (!addedToNetwork) {
addedToNetwork = true;
Network.joinOrCreateNetwork(this);
}
} }
@Override @Override
@ -139,7 +129,7 @@ public abstract class TileEntityEnvironment extends TileEntity implements Enviro
// to continue working without interruption across loads. If the // to continue working without interruption across loads. If the
// node is a power connector this is also required to restore the // node is a power connector this is also required to restore the
// internal energy buffer of the node. // internal energy buffer of the node.
node.load(nbt.getCompoundTag("oc:node")); node.load(nbt.getCompoundTag(TAG_NODE));
} }
} }
@ -150,7 +140,7 @@ public abstract class TileEntityEnvironment extends TileEntity implements Enviro
if (node != null && node.host() == this) { if (node != null && node.host() == this) {
final NBTTagCompound nodeNbt = new NBTTagCompound(); final NBTTagCompound nodeNbt = new NBTTagCompound();
node.save(nodeNbt); node.save(nodeNbt);
nbt.setTag("oc:node", nodeNbt); nbt.setTag(TAG_NODE, nodeNbt);
} }
return nbt; return nbt;
} }

View File

@ -5,6 +5,7 @@ import java.lang.reflect.Modifier
import li.cil.oc.OpenComputers import li.cil.oc.OpenComputers
import li.cil.oc.Settings import li.cil.oc.Settings
import li.cil.oc.api
import li.cil.oc.common.item.data.PrintData import li.cil.oc.common.item.data.PrintData
import li.cil.oc.common.template.AssemblerTemplates import li.cil.oc.common.template.AssemblerTemplates
import li.cil.oc.common.template.DisassemblerTemplates import li.cil.oc.common.template.DisassemblerTemplates
@ -25,7 +26,7 @@ import scala.collection.convert.WrapAsScala._
object IMC { object IMC {
def handleEvent(e: IMCEvent): Unit = { def handleEvent(e: IMCEvent): Unit = {
for (message <- e.getMessages) { for (message <- e.getMessages) {
if (message.key == "registerAssemblerTemplate" && message.isNBTMessage) { if (message.key == api.IMC.REGISTER_ASSEMBLER_TEMPLATE && message.isNBTMessage) {
if (message.getNBTValue.hasKey("name", NBT.TAG_STRING)) if (message.getNBTValue.hasKey("name", NBT.TAG_STRING))
OpenComputers.log.info(s"Registering new assembler template '${message.getNBTValue.getString("name")}' from mod ${message.getSender}.") OpenComputers.log.info(s"Registering new assembler template '${message.getNBTValue.getString("name")}' from mod ${message.getSender}.")
else else
@ -34,7 +35,7 @@ object IMC {
case t: Throwable => OpenComputers.log.warn("Failed registering assembler template.", t) case t: Throwable => OpenComputers.log.warn("Failed registering assembler template.", t)
} }
} }
else if (message.key == "registerDisassemblerTemplate" && message.isNBTMessage) { else if (message.key == api.IMC.REGISTER_DISASSEMBLER_TEMPLATE && message.isNBTMessage) {
if (message.getNBTValue.hasKey("name", NBT.TAG_STRING)) if (message.getNBTValue.hasKey("name", NBT.TAG_STRING))
OpenComputers.log.info(s"Registering new disassembler template '${message.getNBTValue.getString("name")}' from mod ${message.getSender}.") OpenComputers.log.info(s"Registering new disassembler template '${message.getNBTValue.getString("name")}' from mod ${message.getSender}.")
else else
@ -43,25 +44,25 @@ object IMC {
case t: Throwable => OpenComputers.log.warn("Failed registering disassembler template.", t) case t: Throwable => OpenComputers.log.warn("Failed registering disassembler template.", t)
} }
} }
else if (message.key == "registerToolDurabilityProvider" && message.isStringMessage) { else if (message.key == api.IMC.REGISTER_TOOL_DURABILITY_PROVIDER && message.isStringMessage) {
OpenComputers.log.info(s"Registering new tool durability provider '${message.getStringValue}' from mod ${message.getSender}.") OpenComputers.log.info(s"Registering new tool durability provider '${message.getStringValue}' from mod ${message.getSender}.")
try ToolDurabilityProviders.add(getStaticMethod(message.getStringValue, classOf[ItemStack])) catch { try ToolDurabilityProviders.add(getStaticMethod(message.getStringValue, classOf[ItemStack])) catch {
case t: Throwable => OpenComputers.log.warn("Failed registering tool durability provider.", t) case t: Throwable => OpenComputers.log.warn("Failed registering tool durability provider.", t)
} }
} }
else if (message.key == "registerWrenchTool" && message.isStringMessage) { else if (message.key == api.IMC.REGISTER_WRENCH_TOOL && message.isStringMessage) {
OpenComputers.log.info(s"Registering new wrench usage '${message.getStringValue}' from mod ${message.getSender}.") OpenComputers.log.info(s"Registering new wrench usage '${message.getStringValue}' from mod ${message.getSender}.")
try Wrench.addUsage(getStaticMethod(message.getStringValue, classOf[EntityPlayer], classOf[BlockPos], classOf[Boolean])) catch { try Wrench.addUsage(getStaticMethod(message.getStringValue, classOf[EntityPlayer], classOf[BlockPos], classOf[Boolean])) catch {
case t: Throwable => OpenComputers.log.warn("Failed registering wrench usage.", t) case t: Throwable => OpenComputers.log.warn("Failed registering wrench usage.", t)
} }
} }
else if (message.key == "registerWrenchToolCheck" && message.isStringMessage) { else if (message.key == api.IMC.REGISTER_WRENCH_TOOL_CHECK && message.isStringMessage) {
OpenComputers.log.info(s"Registering new wrench tool check '${message.getStringValue}' from mod ${message.getSender}.") OpenComputers.log.info(s"Registering new wrench tool check '${message.getStringValue}' from mod ${message.getSender}.")
try Wrench.addCheck(getStaticMethod(message.getStringValue, classOf[ItemStack])) catch { try Wrench.addCheck(getStaticMethod(message.getStringValue, classOf[ItemStack])) catch {
case t: Throwable => OpenComputers.log.warn("Failed registering wrench check.", t) case t: Throwable => OpenComputers.log.warn("Failed registering wrench check.", t)
} }
} }
else if (message.key == "registerItemCharge" && message.isNBTMessage) { else if (message.key == api.IMC.REGISTER_ITEM_CHARGE && message.isNBTMessage) {
OpenComputers.log.info(s"Registering new item charge implementation '${message.getNBTValue.getString("name")}' from mod ${message.getSender}.") OpenComputers.log.info(s"Registering new item charge implementation '${message.getNBTValue.getString("name")}' from mod ${message.getSender}.")
try ItemCharge.add( try ItemCharge.add(
getStaticMethod(message.getNBTValue.getString("canCharge"), classOf[ItemStack]), getStaticMethod(message.getNBTValue.getString("canCharge"), classOf[ItemStack]),
@ -70,35 +71,35 @@ object IMC {
case t: Throwable => OpenComputers.log.warn("Failed registering item charge implementation.", t) case t: Throwable => OpenComputers.log.warn("Failed registering item charge implementation.", t)
} }
} }
else if (message.key == "blacklistPeripheral" && message.isStringMessage) { else if (message.key == api.IMC.BLACKLIST_PERIPHERAL && message.isStringMessage) {
OpenComputers.log.info(s"Blacklisting CC peripheral '${message.getStringValue}' as requested by mod ${message.getSender}.") OpenComputers.log.info(s"Blacklisting CC peripheral '${message.getStringValue}' as requested by mod ${message.getSender}.")
if (!Settings.get.peripheralBlacklist.contains(message.getStringValue)) { if (!Settings.get.peripheralBlacklist.contains(message.getStringValue)) {
Settings.get.peripheralBlacklist.add(message.getStringValue) Settings.get.peripheralBlacklist.add(message.getStringValue)
} }
} }
else if (message.key == "blacklistHost" && message.isNBTMessage) { else if (message.key == api.IMC.BLACKLIST_HOST && message.isNBTMessage) {
OpenComputers.log.info(s"Blacklisting component '${message.getNBTValue.getString("name")}' for host '${message.getNBTValue.getString("host")}' as requested by mod ${message.getSender}.") OpenComputers.log.info(s"Blacklisting component '${message.getNBTValue.getString("name")}' for host '${message.getNBTValue.getString("host")}' as requested by mod ${message.getSender}.")
try Registry.blacklistHost(new ItemStack(message.getNBTValue.getCompoundTag("item")), Class.forName(message.getNBTValue.getString("host"))) catch { try Registry.blacklistHost(new ItemStack(message.getNBTValue.getCompoundTag("item")), Class.forName(message.getNBTValue.getString("host"))) catch {
case t: Throwable => OpenComputers.log.warn("Failed blacklisting component.", t) case t: Throwable => OpenComputers.log.warn("Failed blacklisting component.", t)
} }
} }
else if (message.key == "registerAssemblerFilter" && message.isStringMessage) { else if (message.key == api.IMC.REGISTER_ASSEMBLER_FILTER && message.isStringMessage) {
OpenComputers.log.info(s"Registering new assembler template filter '${message.getStringValue}' from mod ${message.getSender}.") OpenComputers.log.info(s"Registering new assembler template filter '${message.getStringValue}' from mod ${message.getSender}.")
try AssemblerTemplates.addFilter(message.getStringValue) catch { try AssemblerTemplates.addFilter(message.getStringValue) catch {
case t: Throwable => OpenComputers.log.warn("Failed registering assembler template filter.", t) case t: Throwable => OpenComputers.log.warn("Failed registering assembler template filter.", t)
} }
} }
else if (message.key == "registerInkProvider" && message.isStringMessage) { else if (message.key == api.IMC.REGISTER_INK_PROVIDER && message.isStringMessage) {
OpenComputers.log.info(s"Registering new ink provider '${message.getStringValue}' from mod ${message.getSender}.") OpenComputers.log.info(s"Registering new ink provider '${message.getStringValue}' from mod ${message.getSender}.")
try PrintData.addInkProvider(getStaticMethod(message.getStringValue, classOf[ItemStack])) catch { try PrintData.addInkProvider(getStaticMethod(message.getStringValue, classOf[ItemStack])) catch {
case t: Throwable => OpenComputers.log.warn("Failed registering ink provider.", t) case t: Throwable => OpenComputers.log.warn("Failed registering ink provider.", t)
} }
} }
else if (message.key == "registerCustomPowerSystem" && message.isStringMessage) { else if (message.key == api.IMC.REGISTER_CUSTOM_POWER_SYSTEM && message.isStringMessage) {
OpenComputers.log.info(s"Was told there is an unknown power system present by mod ${message.getSender}.") OpenComputers.log.info(s"Was told there is an unknown power system present by mod ${message.getSender}.")
Settings.get.is3rdPartyPowerSystemPresent = message.getStringValue == "true" Settings.get.is3rdPartyPowerSystemPresent = message.getStringValue == "true"
} }
else if (message.key == "registerProgramDiskLabel" && message.isNBTMessage) { else if (message.key == api.IMC.REGISTER_PROGRAM_DISK_LABEL && message.isNBTMessage) {
OpenComputers.log.info(s"Registering new program location mapping for program '${message.getNBTValue.getString("program")}' being on disk '${message.getNBTValue.getString("label")}' from mod ${message.getSender}.") OpenComputers.log.info(s"Registering new program location mapping for program '${message.getNBTValue.getString("program")}' being on disk '${message.getNBTValue.getString("label")}' from mod ${message.getSender}.")
ProgramLocations.addMapping(message.getNBTValue.getString("program"), message.getNBTValue.getString("label"), message.getNBTValue.getTagList("architectures", NBT.TAG_STRING).map((tag: NBTTagString) => tag.getString()).toArray: _*) ProgramLocations.addMapping(message.getNBTValue.getString("program"), message.getNBTValue.getString("label"), message.getNBTValue.getTagList("architectures", NBT.TAG_STRING).map((tag: NBTTagString) => tag.getString()).toArray: _*)
} }
@ -108,7 +109,7 @@ object IMC {
} }
} }
def getStaticMethod(name: String, signature: Class[_]*) = { def getStaticMethod(name: String, signature: Class[_]*): Method = {
val nameSplit = name.lastIndexOf('.') val nameSplit = name.lastIndexOf('.')
val className = name.substring(0, nameSplit) val className = name.substring(0, nameSplit)
val methodName = name.substring(nameSplit + 1) val methodName = name.substring(nameSplit + 1)

View File

@ -14,6 +14,7 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.client.renderer.TextBufferRenderCache import li.cil.oc.client.renderer.TextBufferRenderCache
import li.cil.oc.client.renderer.font.TextBufferRenderData import li.cil.oc.client.renderer.font.TextBufferRenderData
import li.cil.oc.client.{ComponentTracker => ClientComponentTracker} import li.cil.oc.client.{ComponentTracker => ClientComponentTracker}
@ -41,7 +42,7 @@ import scala.collection.convert.WrapAsJava._
import scala.collection.convert.WrapAsScala._ import scala.collection.convert.WrapAsScala._
import scala.collection.mutable import scala.collection.mutable
class TextBuffer(val host: EnvironmentHost) extends prefab.ManagedEnvironment with api.internal.TextBuffer with DeviceInfo { class TextBuffer(val host: EnvironmentHost) extends AbstractManagedEnvironment with api.internal.TextBuffer with DeviceInfo {
override val node = api.Network.newNode(this, Visibility.Network). override val node = api.Network.newNode(this, Visibility.Network).
withComponent("screen"). withComponent("screen").
withConnector(). withConnector().

View File

@ -157,10 +157,6 @@ object Items extends ItemAPI {
val registeredItems: ArrayBuffer[ItemStack] = mutable.ArrayBuffer.empty[ItemStack] val registeredItems: ArrayBuffer[ItemStack] = mutable.ArrayBuffer.empty[ItemStack]
@Deprecated
override def registerFloppy(name: String, color: EnumDyeColor, factory: Callable[FileSystem]): ItemStack =
registerFloppy(name, color, factory, doRecipeCycling = false)
override def registerFloppy(name: String, color: EnumDyeColor, factory: Callable[FileSystem], doRecipeCycling: Boolean): ItemStack = { override def registerFloppy(name: String, color: EnumDyeColor, factory: Callable[FileSystem], doRecipeCycling: Boolean): ItemStack = {
val stack = Loot.registerLootDisk(name, color, factory, doRecipeCycling) val stack = Loot.registerLootDisk(name, color, factory, doRecipeCycling)

View File

@ -3,7 +3,7 @@ package li.cil.oc.common.inventory
import li.cil.oc.OpenComputers import li.cil.oc.OpenComputers
import li.cil.oc.api import li.cil.oc.api
import li.cil.oc.api.Driver import li.cil.oc.api.Driver
import li.cil.oc.api.driver.{Item => ItemDriver} import li.cil.oc.api.driver.{DriverItem => ItemDriver}
import li.cil.oc.api.network import li.cil.oc.api.network
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network.ManagedEnvironment import li.cil.oc.api.network.ManagedEnvironment

View File

@ -2,6 +2,7 @@ package li.cil.oc.common.item.traits
import li.cil.oc.Settings import li.cil.oc.Settings
import li.cil.oc.api import li.cil.oc.api
import li.cil.oc.api.driver.DriverItem
import li.cil.oc.common.item.Delegator import li.cil.oc.common.item.Delegator
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import li.cil.oc.util.Rarity import li.cil.oc.util.Rarity
@ -64,7 +65,7 @@ trait Delegate {
protected def tierFromDriver(stack: ItemStack): Int = protected def tierFromDriver(stack: ItemStack): Int =
api.Driver.driverFor(stack) match { api.Driver.driverFor(stack) match {
case driver: api.driver.Item => driver.tier(stack) case driver: DriverItem => driver.tier(stack)
case _ => 0 case _ => 0
} }

View File

@ -9,6 +9,7 @@ import li.cil.oc.api.Driver
import li.cil.oc.api.driver.DeviceInfo import li.cil.oc.api.driver.DeviceInfo
import li.cil.oc.api.driver.DeviceInfo.DeviceAttribute import li.cil.oc.api.driver.DeviceInfo.DeviceAttribute
import li.cil.oc.api.driver.DeviceInfo.DeviceClass import li.cil.oc.api.driver.DeviceInfo.DeviceClass
import li.cil.oc.api.driver.DriverBlock
import li.cil.oc.api.internal import li.cil.oc.api.internal
import li.cil.oc.api.network.Analyzable import li.cil.oc.api.network.Analyzable
import li.cil.oc.api.network._ import li.cil.oc.api.network._
@ -29,7 +30,7 @@ import scala.collection.mutable
class Adapter extends traits.Environment with traits.ComponentInventory with traits.Tickable with traits.OpenSides with Analyzable with internal.Adapter with DeviceInfo { class Adapter extends traits.Environment with traits.ComponentInventory with traits.Tickable with traits.OpenSides with Analyzable with internal.Adapter with DeviceInfo {
val node = api.Network.newNode(this, Visibility.Network).create() val node = api.Network.newNode(this, Visibility.Network).create()
private val blocks = Array.fill[Option[(ManagedEnvironment, api.driver.SidedBlock)]](6)(None) private val blocks = Array.fill[Option[(ManagedEnvironment, DriverBlock)]](6)(None)
private val updatingBlocks = mutable.ArrayBuffer.empty[ManagedEnvironment] private val updatingBlocks = mutable.ArrayBuffer.empty[ManagedEnvironment]

View File

@ -1,6 +1,6 @@
package li.cil.oc.common.tileentity.traits package li.cil.oc.common.tileentity.traits
import li.cil.oc.api.driver.Item import li.cil.oc.api.driver.DriverItem
import li.cil.oc.api.network.ManagedEnvironment import li.cil.oc.api.network.ManagedEnvironment
import li.cil.oc.api.network.Node import li.cil.oc.api.network.Node
import li.cil.oc.common.EventHandler import li.cil.oc.common.EventHandler
@ -115,7 +115,7 @@ trait ComponentInventory extends Environment with Inventory with inventory.Compo
} }
} }
override protected def save(component: ManagedEnvironment, driver: Item, stack: ItemStack): Unit = { override protected def save(component: ManagedEnvironment, driver: DriverItem, stack: ItemStack): Unit = {
if (isServer) { if (isServer) {
super.save(component, driver, stack) super.save(component, driver, stack)
} }

View File

@ -2,9 +2,9 @@ package li.cil.oc.integration;
import li.cil.oc.api.Network; import li.cil.oc.api.Network;
import li.cil.oc.api.network.Visibility; import li.cil.oc.api.network.Visibility;
import li.cil.oc.api.prefab.ManagedEnvironment; import li.cil.oc.api.prefab.AbstractManagedEnvironment;
public class ManagedTileEntityEnvironment<T> extends ManagedEnvironment { public class ManagedTileEntityEnvironment<T> extends AbstractManagedEnvironment {
protected final T tileEntity; protected final T tileEntity;
public ManagedTileEntityEnvironment(final T tileEntity, final String name) { public ManagedTileEntityEnvironment(final T tileEntity, final String name) {

View File

@ -1,5 +1,6 @@
package li.cil.oc.integration.minecraft; package li.cil.oc.integration.minecraft;
import li.cil.oc.api.driver.DriverBlock;
import li.cil.oc.api.machine.Arguments; import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context; import li.cil.oc.api.machine.Context;
@ -12,7 +13,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
public final class DriverFluidHandler implements li.cil.oc.api.driver.SidedBlock { public final class DriverFluidHandler implements DriverBlock {
@Override @Override
public boolean worksWith(final World world, final BlockPos pos, final EnumFacing side) { public boolean worksWith(final World world, final BlockPos pos, final EnumFacing side) {
final TileEntity tileEntity = world.getTileEntity(pos); final TileEntity tileEntity = world.getTileEntity(pos);

View File

@ -3,6 +3,7 @@ package li.cil.oc.integration.opencomputers
import li.cil.oc.Settings import li.cil.oc.Settings
import li.cil.oc.api import li.cil.oc.api
import li.cil.oc.api.driver import li.cil.oc.api.driver
import li.cil.oc.api.driver.DriverItem
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.internal import li.cil.oc.api.internal
import li.cil.oc.common.Tier import li.cil.oc.common.Tier
@ -10,7 +11,7 @@ import li.cil.oc.server.driver.Registry
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
trait Item extends driver.Item { trait Item extends DriverItem {
def worksWith(stack: ItemStack, host: Class[_ <: EnvironmentHost]): Boolean = def worksWith(stack: ItemStack, host: Class[_ <: EnvironmentHost]): Boolean =
worksWith(stack) && !Registry.blacklist.exists { worksWith(stack) && !Registry.blacklist.exists {
case (blacklistedStack, blacklistedHost) => case (blacklistedStack, blacklistedHost) =>
@ -20,29 +21,29 @@ trait Item extends driver.Item {
override def tier(stack: ItemStack) = Tier.One override def tier(stack: ItemStack) = Tier.One
override def dataTag(stack: ItemStack) = Item.dataTag(stack) override def dataTag(stack: ItemStack): NBTTagCompound = Item.dataTag(stack)
protected def isOneOf(stack: ItemStack, items: api.detail.ItemInfo*) = items.filter(_ != null).contains(api.Items.get(stack)) protected def isOneOf(stack: ItemStack, items: api.detail.ItemInfo*): Boolean = items.filter(_ != null).contains(api.Items.get(stack))
protected def isAdapter(host: Class[_ <: EnvironmentHost]) = classOf[internal.Adapter].isAssignableFrom(host) protected def isAdapter(host: Class[_ <: EnvironmentHost]): Boolean = classOf[internal.Adapter].isAssignableFrom(host)
protected def isComputer(host: Class[_ <: EnvironmentHost]) = classOf[internal.Case].isAssignableFrom(host) protected def isComputer(host: Class[_ <: EnvironmentHost]): Boolean = classOf[internal.Case].isAssignableFrom(host)
protected def isRobot(host: Class[_ <: EnvironmentHost]) = classOf[internal.Robot].isAssignableFrom(host) protected def isRobot(host: Class[_ <: EnvironmentHost]): Boolean = classOf[internal.Robot].isAssignableFrom(host)
protected def isRotatable(host: Class[_ <: EnvironmentHost]) = classOf[internal.Rotatable].isAssignableFrom(host) protected def isRotatable(host: Class[_ <: EnvironmentHost]): Boolean = classOf[internal.Rotatable].isAssignableFrom(host)
protected def isServer(host: Class[_ <: EnvironmentHost]) = classOf[internal.Server].isAssignableFrom(host) protected def isServer(host: Class[_ <: EnvironmentHost]): Boolean = classOf[internal.Server].isAssignableFrom(host)
protected def isTablet(host: Class[_ <: EnvironmentHost]) = classOf[internal.Tablet].isAssignableFrom(host) protected def isTablet(host: Class[_ <: EnvironmentHost]): Boolean = classOf[internal.Tablet].isAssignableFrom(host)
protected def isMicrocontroller(host: Class[_ <: EnvironmentHost]) = classOf[internal.Microcontroller].isAssignableFrom(host) protected def isMicrocontroller(host: Class[_ <: EnvironmentHost]): Boolean = classOf[internal.Microcontroller].isAssignableFrom(host)
protected def isDrone(host: Class[_ <: EnvironmentHost]) = classOf[internal.Drone].isAssignableFrom(host) protected def isDrone(host: Class[_ <: EnvironmentHost]): Boolean = classOf[internal.Drone].isAssignableFrom(host)
} }
object Item { object Item {
def dataTag(stack: ItemStack) = { def dataTag(stack: ItemStack): NBTTagCompound = {
if (!stack.hasTagCompound) { if (!stack.hasTagCompound) {
stack.setTagCompound(new NBTTagCompound()) stack.setTagCompound(new NBTTagCompound())
} }

View File

@ -10,10 +10,11 @@ import li.cil.oc.api.Network
import li.cil.oc.api.driver.DeviceInfo import li.cil.oc.api.driver.DeviceInfo
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class CPU(val tier: Int) extends prefab.ManagedEnvironment with DeviceInfo { class CPU(val tier: Int) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Neighbors). override val node = Network.newNode(this, Visibility.Neighbors).
create() create()

View File

@ -24,13 +24,14 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
import org.apache.commons.codec.binary.Base64 import org.apache.commons.codec.binary.Base64
import org.apache.commons.io.output.ByteArrayOutputStream import org.apache.commons.io.output.ByteArrayOutputStream
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
abstract class DataCard extends prefab.ManagedEnvironment with DeviceInfo { abstract class DataCard extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Neighbors). override val node = Network.newNode(this, Visibility.Neighbors).
withComponent("data", Visibility.Neighbors). withComponent("data", Visibility.Neighbors).
withConnector(). withConnector().

View File

@ -15,6 +15,7 @@ import li.cil.oc.api.network.Packet
import li.cil.oc.api.network.SidedEnvironment import li.cil.oc.api.network.SidedEnvironment
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.api.prefab.AbstractValue import li.cil.oc.api.prefab.AbstractValue
import li.cil.oc.server.PacketSender import li.cil.oc.server.PacketSender
import li.cil.oc.server.network.DebugNetwork import li.cil.oc.server.network.DebugNetwork
@ -56,7 +57,7 @@ import net.minecraftforge.fml.common.ModAPIManager
import scala.collection.convert.WrapAsScala._ import scala.collection.convert.WrapAsScala._
import scala.collection.mutable import scala.collection.mutable
class DebugCard(host: EnvironmentHost) extends prefab.ManagedEnvironment with DebugNode { class DebugCard(host: EnvironmentHost) extends AbstractManagedEnvironment with DebugNode {
override val node: ComponentConnector = Network.newNode(this, Visibility.Neighbors). override val node: ComponentConnector = Network.newNode(this, Visibility.Neighbors).
withComponent("debug"). withComponent("debug").
withConnector(). withConnector().

View File

@ -19,6 +19,7 @@ import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network.Node import li.cil.oc.api.network.Node
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.common.Slot import li.cil.oc.common.Slot
import li.cil.oc.common.Sound import li.cil.oc.common.Sound
import li.cil.oc.common.inventory.ComponentInventory import li.cil.oc.common.inventory.ComponentInventory
@ -34,7 +35,7 @@ import net.minecraft.util.EnumHand
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class DiskDriveMountable(val rack: api.internal.Rack, val slot: Int) extends prefab.ManagedEnvironment with ItemStackInventory with ComponentInventory with RackMountable with Analyzable with DeviceInfo { class DiskDriveMountable(val rack: api.internal.Rack, val slot: Int) extends AbstractManagedEnvironment with ItemStackInventory with ComponentInventory with RackMountable with Analyzable with DeviceInfo {
// Stored for filling data packet when queried. // Stored for filling data packet when queried.
var lastAccess = 0L var lastAccess = 0L
@ -142,13 +143,13 @@ class DiskDriveMountable(val rack: api.internal.Rack, val slot: Int) extends pre
// Persistable // Persistable
override def load(nbt: NBTTagCompound) { override def load(nbt: NBTTagCompound) {
super[ManagedEnvironment].load(nbt) super[AbstractManagedEnvironment].load(nbt)
super[ComponentInventory].load(nbt) super[ComponentInventory].load(nbt)
connectComponents() connectComponents()
} }
override def save(nbt: NBTTagCompound) { override def save(nbt: NBTTagCompound) {
super[ManagedEnvironment].save(nbt) super[AbstractManagedEnvironment].save(nbt)
super[ComponentInventory].save(nbt) super[ComponentInventory].save(nbt)
} }

View File

@ -22,13 +22,14 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.server.{PacketSender => ServerPacketSender} import li.cil.oc.server.{PacketSender => ServerPacketSender}
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.DimensionManager import net.minecraftforge.common.DimensionManager
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class Drive(val capacity: Int, val platterCount: Int, val label: Label, host: Option[EnvironmentHost], val sound: Option[String], val speed: Int) extends prefab.ManagedEnvironment with DeviceInfo { class Drive(val capacity: Int, val platterCount: Int, val label: Label, host: Option[EnvironmentHost], val sound: Option[String], val speed: Int) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("drive", Visibility.Neighbors). withComponent("drive", Visibility.Neighbors).
withConnector(). withConnector().

View File

@ -13,6 +13,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.common.entity import li.cil.oc.common.entity
import li.cil.oc.util.ExtendedArguments._ import li.cil.oc.util.ExtendedArguments._
import li.cil.oc.util.InventoryUtils import li.cil.oc.util.InventoryUtils
@ -24,7 +25,7 @@ import net.minecraft.util.SoundCategory
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
import scala.collection.convert.WrapAsScala._ import scala.collection.convert.WrapAsScala._
class Drone(val agent: entity.Drone) extends prefab.ManagedEnvironment with Agent with DeviceInfo { class Drone(val agent: entity.Drone) extends AbstractManagedEnvironment with Agent with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("drone"). withComponent("drone").
withConnector(Settings.get.bufferDrone). withConnector(Settings.get.bufferDrone).

View File

@ -14,11 +14,12 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class EEPROM extends prefab.ManagedEnvironment with DeviceInfo { class EEPROM extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Neighbors). override val node = Network.newNode(this, Visibility.Neighbors).
withComponent("eeprom", Visibility.Neighbors). withComponent("eeprom", Visibility.Neighbors).
withConnector(). withConnector().

View File

@ -19,6 +19,7 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.api.prefab.AbstractValue import li.cil.oc.api.prefab.AbstractValue
import li.cil.oc.common.SaveHandler import li.cil.oc.common.SaveHandler
import li.cil.oc.server.{PacketSender => ServerPacketSender} import li.cil.oc.server.{PacketSender => ServerPacketSender}
@ -31,7 +32,7 @@ import net.minecraftforge.common.util.Constants.NBT
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
import scala.collection.mutable import scala.collection.mutable
class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option[EnvironmentHost], val sound: Option[String], val speed: Int) extends prefab.ManagedEnvironment with DeviceInfo { class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option[EnvironmentHost], val sound: Option[String], val speed: Int) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("filesystem", Visibility.Neighbors). withComponent("filesystem", Visibility.Neighbors).
withConnector(). withConnector().

View File

@ -18,6 +18,7 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.Message import li.cil.oc.api.network.Message
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import li.cil.oc.util.DatabaseAccess import li.cil.oc.util.DatabaseAccess
import li.cil.oc.util.ExtendedArguments._ import li.cil.oc.util.ExtendedArguments._
@ -33,7 +34,7 @@ import scala.collection.convert.WrapAsJava._
import scala.collection.convert.WrapAsScala._ import scala.collection.convert.WrapAsScala._
import scala.language.existentials import scala.language.existentials
class Geolyzer(val host: EnvironmentHost) extends prefab.ManagedEnvironment with DeviceInfo { class Geolyzer(val host: EnvironmentHost) extends AbstractManagedEnvironment with DeviceInfo {
override val node = api.Network.newNode(this, Visibility.Network). override val node = api.Network.newNode(this, Visibility.Network).
withComponent("geolyzer"). withComponent("geolyzer").
withConnector(). withConnector().

View File

@ -15,6 +15,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.util.PackedColor import li.cil.oc.util.PackedColor
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
@ -33,7 +34,7 @@ import scala.util.matching.Regex
// saved, but before the computer was saved, leading to mismatching states in // saved, but before the computer was saved, leading to mismatching states in
// the save file - a Bad Thing (TM). // the save file - a Bad Thing (TM).
class GraphicsCard(val tier: Int) extends prefab.ManagedEnvironment with DeviceInfo { class GraphicsCard(val tier: Int) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Neighbors). override val node = Network.newNode(this, Visibility.Neighbors).
withComponent("gpu"). withComponent("gpu").
withConnector(). withConnector().

View File

@ -28,6 +28,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.api.prefab.AbstractValue import li.cil.oc.api.prefab.AbstractValue
import li.cil.oc.util.ThreadPoolFactory import li.cil.oc.util.ThreadPoolFactory
import net.minecraft.server.MinecraftServer import net.minecraft.server.MinecraftServer
@ -37,7 +38,7 @@ import scala.collection.convert.WrapAsJava._
import scala.collection.convert.WrapAsScala._ import scala.collection.convert.WrapAsScala._
import scala.collection.mutable import scala.collection.mutable
class InternetCard extends prefab.ManagedEnvironment with DeviceInfo { class InternetCard extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("internet", Visibility.Neighbors). withComponent("internet", Visibility.Neighbors).
create() create()

View File

@ -14,6 +14,7 @@ import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network.Message import li.cil.oc.api.network.Message
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayer
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
@ -22,7 +23,7 @@ import scala.collection.mutable
// TODO key up when screen is disconnected from which the key down came // TODO key up when screen is disconnected from which the key down came
// TODO key up after load for anything that was pressed // TODO key up after load for anything that was pressed
class Keyboard(val host: EnvironmentHost) extends prefab.ManagedEnvironment with api.internal.Keyboard with DeviceInfo { class Keyboard(val host: EnvironmentHost) extends AbstractManagedEnvironment with api.internal.Keyboard with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("keyboard"). withComponent("keyboard").
create() create()

View File

@ -13,13 +13,14 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.driver.DeviceInfo import li.cil.oc.api.driver.DeviceInfo
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.server.network.QuantumNetwork import li.cil.oc.server.network.QuantumNetwork
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
import scala.collection.convert.WrapAsScala._ import scala.collection.convert.WrapAsScala._
class LinkedCard extends prefab.ManagedEnvironment with QuantumNetwork.QuantumNode with DeviceInfo { class LinkedCard extends AbstractManagedEnvironment with QuantumNetwork.QuantumNode with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("tunnel", Visibility.Neighbors). withComponent("tunnel", Visibility.Neighbors).
withConnector(). withConnector().

View File

@ -10,10 +10,11 @@ import li.cil.oc.api.Network
import li.cil.oc.api.driver.DeviceInfo import li.cil.oc.api.driver.DeviceInfo
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class Memory(val tier: Int) extends prefab.ManagedEnvironment with DeviceInfo { class Memory(val tier: Int) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Neighbors). override val node = Network.newNode(this, Visibility.Neighbors).
create() create()

View File

@ -18,6 +18,7 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.server.{PacketSender => ServerPacketSender} import li.cil.oc.server.{PacketSender => ServerPacketSender}
import net.minecraft.nbt._ import net.minecraft.nbt._
@ -25,7 +26,7 @@ import scala.collection.convert.WrapAsJava._
import scala.collection.convert.WrapAsScala._ import scala.collection.convert.WrapAsScala._
import scala.collection.mutable import scala.collection.mutable
class NetworkCard(val host: EnvironmentHost) extends prefab.ManagedEnvironment with RackBusConnectable with DeviceInfo { class NetworkCard(val host: EnvironmentHost) extends AbstractManagedEnvironment with RackBusConnectable with DeviceInfo {
protected val visibility: Visibility = host match { protected val visibility: Visibility = host match {
case _: Rack => Visibility.Neighbors case _: Rack => Visibility.Neighbors
case _ => Visibility.Network case _ => Visibility.Network

View File

@ -6,9 +6,10 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
trait RedstoneSignaller extends prefab.ManagedEnvironment { trait RedstoneSignaller extends AbstractManagedEnvironment {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("redstone", Visibility.Neighbors). withComponent("redstone", Visibility.Neighbors).
create() create()

View File

@ -14,6 +14,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.common.ToolDurabilityProviders import li.cil.oc.common.ToolDurabilityProviders
import li.cil.oc.common.tileentity import li.cil.oc.common.tileentity
import li.cil.oc.server.PacketSender import li.cil.oc.server.PacketSender
@ -26,7 +27,7 @@ import net.minecraft.util.EnumParticleTypes
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class Robot(val agent: tileentity.Robot) extends prefab.ManagedEnvironment with Agent with DeviceInfo { class Robot(val agent: tileentity.Robot) extends AbstractManagedEnvironment with Agent with DeviceInfo {
override val node = api.Network.newNode(this, Visibility.Network). override val node = api.Network.newNode(this, Visibility.Network).
withComponent("robot"). withComponent("robot").
withConnector(Settings.get.bufferRobot). withConnector(Settings.get.bufferRobot).

View File

@ -13,11 +13,12 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.common.item.TabletWrapper import li.cil.oc.common.item.TabletWrapper
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class Tablet(val tablet: TabletWrapper) extends prefab.ManagedEnvironment with DeviceInfo { class Tablet(val tablet: TabletWrapper) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("tablet"). withComponent("tablet").
withConnector(Settings.get.bufferTablet). withConnector(Settings.get.bufferTablet).

View File

@ -12,6 +12,7 @@ import li.cil.oc.api.machine.Arguments
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.common.tileentity import li.cil.oc.common.tileentity
import li.cil.oc.server.{PacketSender => ServerPacketSender} import li.cil.oc.server.{PacketSender => ServerPacketSender}
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
@ -22,7 +23,7 @@ import scala.language.existentials
object Transposer { object Transposer {
abstract class Common extends prefab.ManagedEnvironment with traits.WorldInventoryAnalytics with traits.WorldTankAnalytics with traits.InventoryTransfer with DeviceInfo { abstract class Common extends AbstractManagedEnvironment with traits.WorldInventoryAnalytics with traits.WorldTankAnalytics with traits.InventoryTransfer with DeviceInfo {
override val node = api.Network.newNode(this, Visibility.Network). override val node = api.Network.newNode(this, Visibility.Network).
withComponent("transposer"). withComponent("transposer").
withConnector(). withConnector().

View File

@ -11,12 +11,13 @@ import li.cil.oc.api.driver.DeviceInfo.DeviceClass
import li.cil.oc.api.network.Node import li.cil.oc.api.network.Node
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
// Note-to-self: this has a component to allow the robot telling it has the // Note-to-self: this has a component to allow the robot telling it has the
// upgrade. // upgrade.
class UpgradeAngel extends prefab.ManagedEnvironment with DeviceInfo { class UpgradeAngel extends AbstractManagedEnvironment with DeviceInfo {
override val node: Node = Network.newNode(this, Visibility.Network). override val node: Node = Network.newNode(this, Visibility.Network).
create() create()

View File

@ -10,10 +10,11 @@ import li.cil.oc.api.Network
import li.cil.oc.api.driver.DeviceInfo import li.cil.oc.api.driver.DeviceInfo
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class UpgradeBattery(val tier: Int) extends prefab.ManagedEnvironment with DeviceInfo { class UpgradeBattery(val tier: Int) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withConnector(Settings.get.bufferCapacitorUpgrades(tier)). withConnector(Settings.get.bufferCapacitorUpgrades(tier)).
create() create()

View File

@ -15,13 +15,14 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.common.event.ChunkloaderUpgradeHandler import li.cil.oc.common.event.ChunkloaderUpgradeHandler
import net.minecraftforge.common.ForgeChunkManager import net.minecraftforge.common.ForgeChunkManager
import net.minecraftforge.common.ForgeChunkManager.Ticket import net.minecraftforge.common.ForgeChunkManager.Ticket
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class UpgradeChunkloader(val host: EnvironmentHost) extends prefab.ManagedEnvironment with DeviceInfo { class UpgradeChunkloader(val host: EnvironmentHost) extends AbstractManagedEnvironment with DeviceInfo {
override val node = api.Network.newNode(this, Visibility.Network). override val node = api.Network.newNode(this, Visibility.Network).
withComponent("chunkloader"). withComponent("chunkloader").
withConnector(). withConnector().

View File

@ -14,6 +14,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.util.InventoryUtils import li.cil.oc.util.InventoryUtils
import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayer
import net.minecraft.inventory import net.minecraft.inventory
@ -27,7 +28,7 @@ import scala.collection.convert.WrapAsJava._
import scala.collection.mutable import scala.collection.mutable
import scala.util.control.Breaks._ import scala.util.control.Breaks._
class UpgradeCrafting(val host: EnvironmentHost with internal.Robot) extends prefab.ManagedEnvironment with DeviceInfo { class UpgradeCrafting(val host: EnvironmentHost with internal.Robot) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("crafting"). withComponent("crafting").
create() create()

View File

@ -14,6 +14,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.util.DatabaseAccess import li.cil.oc.util.DatabaseAccess
import li.cil.oc.util.ExtendedArguments._ import li.cil.oc.util.ExtendedArguments._
import li.cil.oc.util.ItemUtils import li.cil.oc.util.ItemUtils
@ -22,7 +23,7 @@ import net.minecraft.item.ItemStack
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class UpgradeDatabase(val data: IInventory) extends prefab.ManagedEnvironment with internal.Database with DeviceInfo { class UpgradeDatabase(val data: IInventory) extends AbstractManagedEnvironment with internal.Database with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("database"). withComponent("database").
create() create()

View File

@ -15,6 +15,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import net.minecraft.enchantment.Enchantment import net.minecraft.enchantment.Enchantment
import net.minecraft.enchantment.EnchantmentHelper import net.minecraft.enchantment.EnchantmentHelper
import net.minecraft.init.Items import net.minecraft.init.Items
@ -23,7 +24,7 @@ import net.minecraft.nbt.NBTTagCompound
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
import scala.collection.convert.WrapAsScala._ import scala.collection.convert.WrapAsScala._
class UpgradeExperience(val host: EnvironmentHost with internal.Agent) extends prefab.ManagedEnvironment with DeviceInfo { class UpgradeExperience(val host: EnvironmentHost with internal.Agent) extends AbstractManagedEnvironment with DeviceInfo {
final val MaxLevel = 30 final val MaxLevel = 30
override val node = api.Network.newNode(this, Visibility.Network). override val node = api.Network.newNode(this, Visibility.Network).

View File

@ -15,6 +15,7 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.util.ExtendedNBT._ import li.cil.oc.util.ExtendedNBT._
import net.minecraft.entity.item.EntityItem import net.minecraft.entity.item.EntityItem
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
@ -23,7 +24,7 @@ import net.minecraft.tileentity.TileEntityFurnace
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class UpgradeGenerator(val host: EnvironmentHost with internal.Agent) extends prefab.ManagedEnvironment with DeviceInfo { class UpgradeGenerator(val host: EnvironmentHost with internal.Agent) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("generator", Visibility.Neighbors). withComponent("generator", Visibility.Neighbors).
withConnector(). withConnector().

View File

@ -14,6 +14,7 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.common.tileentity import li.cil.oc.common.tileentity
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedArguments._ import li.cil.oc.util.ExtendedArguments._
@ -33,7 +34,7 @@ object UpgradeInventoryController {
override def getDeviceInfo: util.Map[String, String] = deviceInfo override def getDeviceInfo: util.Map[String, String] = deviceInfo
} }
class Adapter(val host: EnvironmentHost) extends prefab.ManagedEnvironment with traits.WorldInventoryAnalytics with Common { class Adapter(val host: EnvironmentHost) extends AbstractManagedEnvironment with traits.WorldInventoryAnalytics with Common {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("inventory_controller", Visibility.Network). withComponent("inventory_controller", Visibility.Network).
create() create()
@ -45,7 +46,7 @@ object UpgradeInventoryController {
override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSideAny(n) override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSideAny(n)
} }
class Drone(val host: EnvironmentHost with internal.Agent) extends prefab.ManagedEnvironment with traits.InventoryAnalytics with traits.InventoryWorldControlMk2 with traits.WorldInventoryAnalytics with traits.ItemInventoryControl with Common { class Drone(val host: EnvironmentHost with internal.Agent) extends AbstractManagedEnvironment with traits.InventoryAnalytics with traits.InventoryWorldControlMk2 with traits.WorldInventoryAnalytics with traits.ItemInventoryControl with Common {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("inventory_controller", Visibility.Neighbors). withComponent("inventory_controller", Visibility.Neighbors).
create() create()
@ -63,7 +64,7 @@ object UpgradeInventoryController {
override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSideAny(n) override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSideAny(n)
} }
class Robot(val host: EnvironmentHost with tileentity.Robot) extends prefab.ManagedEnvironment with traits.InventoryAnalytics with traits.InventoryWorldControlMk2 with traits.WorldInventoryAnalytics with traits.ItemInventoryControl with Common { class Robot(val host: EnvironmentHost with tileentity.Robot) extends AbstractManagedEnvironment with traits.InventoryAnalytics with traits.InventoryWorldControlMk2 with traits.WorldInventoryAnalytics with traits.ItemInventoryControl with Common {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("inventory_controller", Visibility.Neighbors). withComponent("inventory_controller", Visibility.Neighbors).
create() create()

View File

@ -15,6 +15,7 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.Node import li.cil.oc.api.network.Node
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.common.EventHandler import li.cil.oc.common.EventHandler
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedArguments._ import li.cil.oc.util.ExtendedArguments._
@ -29,7 +30,7 @@ import scala.collection.convert.WrapAsJava._
import scala.collection.convert.WrapAsScala._ import scala.collection.convert.WrapAsScala._
import scala.collection.mutable import scala.collection.mutable
class UpgradeLeash(val host: Entity) extends prefab.ManagedEnvironment with traits.WorldAware with DeviceInfo { class UpgradeLeash(val host: Entity) extends AbstractManagedEnvironment with traits.WorldAware with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("leash"). withComponent("leash").
create() create()

View File

@ -15,6 +15,8 @@ import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedWorld._ import li.cil.oc.util.ExtendedWorld._
import li.cil.oc.Settings import li.cil.oc.Settings
import li.cil.oc.api import li.cil.oc.api
import li.cil.oc.api.driver.DriverBlock
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
import net.minecraft.tileentity.TileEntity import net.minecraft.tileentity.TileEntity
import net.minecraft.util.EnumFacing import net.minecraft.util.EnumFacing
@ -27,13 +29,13 @@ import scala.collection.convert.WrapAsJava._
* *
* @author Sangar, Vexatos * @author Sangar, Vexatos
*/ */
class UpgradeMF(val host: EnvironmentHost, val coord: BlockPosition, val dir: EnumFacing) extends prefab.ManagedEnvironment with ChangeListener with DeviceInfo { class UpgradeMF(val host: EnvironmentHost, val coord: BlockPosition, val dir: EnumFacing) extends AbstractManagedEnvironment with ChangeListener with DeviceInfo {
override val node = api.Network.newNode(this, Visibility.None). override val node = api.Network.newNode(this, Visibility.None).
withConnector(). withConnector().
create() create()
private var otherEnv: Option[api.network.Environment] = None private var otherEnv: Option[api.network.Environment] = None
private var otherDrv: Option[(ManagedEnvironment, api.driver.SidedBlock)] = None private var otherDrv: Option[(ManagedEnvironment, DriverBlock)] = None
private var blockData: Option[BlockData] = None private var blockData: Option[BlockData] = None
override val canUpdate = true override val canUpdate = true

View File

@ -17,6 +17,7 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.common.item.data.NavigationUpgradeData import li.cil.oc.common.item.data.NavigationUpgradeData
import li.cil.oc.server.network.Waypoints import li.cil.oc.server.network.Waypoints
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
@ -27,7 +28,7 @@ import net.minecraft.util.EnumFacing
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class UpgradeNavigation(val host: EnvironmentHost with Rotatable) extends prefab.ManagedEnvironment with DeviceInfo { class UpgradeNavigation(val host: EnvironmentHost with Rotatable) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("navigation", Visibility.Neighbors). withComponent("navigation", Visibility.Neighbors).
withConnector(). withConnector().

View File

@ -15,6 +15,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedArguments._ import li.cil.oc.util.ExtendedArguments._
import li.cil.oc.util.ExtendedWorld._ import li.cil.oc.util.ExtendedWorld._
@ -25,7 +26,7 @@ import net.minecraft.util.SoundCategory
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
abstract class UpgradePiston(val host: EnvironmentHost) extends prefab.ManagedEnvironment with DeviceInfo { abstract class UpgradePiston(val host: EnvironmentHost) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("piston"). withComponent("piston").
withConnector(). withConnector().

View File

@ -13,6 +13,7 @@ import li.cil.oc.api.internal
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network.Message import li.cil.oc.api.network.Message
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedWorld._ import li.cil.oc.util.ExtendedWorld._
import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayer
@ -29,7 +30,7 @@ import net.minecraftforge.fml.common.eventhandler.Event
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
abstract class UpgradeSign extends prefab.ManagedEnvironment with DeviceInfo { abstract class UpgradeSign extends AbstractManagedEnvironment with DeviceInfo {
private final lazy val deviceInfo = Map( private final lazy val deviceInfo = Map(
DeviceAttribute.Class -> DeviceClass.Generic, DeviceAttribute.Class -> DeviceClass.Generic,
DeviceAttribute.Description -> "Sign upgrade", DeviceAttribute.Description -> "Sign upgrade",

View File

@ -11,12 +11,13 @@ import li.cil.oc.api.driver.DeviceInfo
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import net.minecraft.util.EnumFacing import net.minecraft.util.EnumFacing
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class UpgradeSolarGenerator(val host: EnvironmentHost) extends prefab.ManagedEnvironment with DeviceInfo { class UpgradeSolarGenerator(val host: EnvironmentHost) extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withConnector(). withConnector().
create() create()

View File

@ -10,6 +10,7 @@ import li.cil.oc.api.driver.DeviceInfo
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.FluidStack
import net.minecraftforge.fluids.FluidTank import net.minecraftforge.fluids.FluidTank
@ -17,7 +18,7 @@ import net.minecraftforge.fluids.IFluidTank
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
class UpgradeTank(val owner: EnvironmentHost, val capacity: Int) extends prefab.ManagedEnvironment with IFluidTank with DeviceInfo { class UpgradeTank(val owner: EnvironmentHost, val capacity: Int) extends AbstractManagedEnvironment with IFluidTank with DeviceInfo {
override val node = Network.newNode(this, Visibility.None).create() override val node = Network.newNode(this, Visibility.None).create()
private final lazy val deviceInfo = Map( private final lazy val deviceInfo = Map(

View File

@ -12,6 +12,7 @@ import li.cil.oc.api.internal
import li.cil.oc.api.machine.Arguments import li.cil.oc.api.machine.Arguments
import li.cil.oc.api.network._ import li.cil.oc.api.network._
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.common.tileentity import li.cil.oc.common.tileentity
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedArguments._ import li.cil.oc.util.ExtendedArguments._
@ -31,7 +32,7 @@ object UpgradeTankController {
override def getDeviceInfo: util.Map[String, String] = deviceInfo override def getDeviceInfo: util.Map[String, String] = deviceInfo
} }
class Adapter(val host: EnvironmentHost) extends prefab.ManagedEnvironment with traits.WorldTankAnalytics with Common { class Adapter(val host: EnvironmentHost) extends AbstractManagedEnvironment with traits.WorldTankAnalytics with Common {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("tank_controller", Visibility.Network). withComponent("tank_controller", Visibility.Network).
create() create()
@ -43,7 +44,7 @@ object UpgradeTankController {
override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSideAny(n) override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSideAny(n)
} }
class Drone(val host: EnvironmentHost with internal.Agent) extends prefab.ManagedEnvironment with traits.TankInventoryControl with traits.WorldTankAnalytics with Common { class Drone(val host: EnvironmentHost with internal.Agent) extends AbstractManagedEnvironment with traits.TankInventoryControl with traits.WorldTankAnalytics with Common {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("tank_controller", Visibility.Neighbors). withComponent("tank_controller", Visibility.Neighbors).
create() create()
@ -65,7 +66,7 @@ object UpgradeTankController {
override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSideAny(n) override protected def checkSideForAction(args: Arguments, n: Int) = args.checkSideAny(n)
} }
class Robot(val host: EnvironmentHost with tileentity.Robot) extends prefab.ManagedEnvironment with traits.TankInventoryControl with traits.WorldTankAnalytics with Common { class Robot(val host: EnvironmentHost with tileentity.Robot) extends AbstractManagedEnvironment with traits.TankInventoryControl with traits.WorldTankAnalytics with Common {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("tank_controller", Visibility.Neighbors). withComponent("tank_controller", Visibility.Neighbors).
create() create()

View File

@ -15,6 +15,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import li.cil.oc.util.InventoryUtils import li.cil.oc.util.InventoryUtils
import net.minecraft.entity.item.EntityItem import net.minecraft.entity.item.EntityItem
@ -26,7 +27,7 @@ import scala.collection.convert.WrapAsScala._
object UpgradeTractorBeam { object UpgradeTractorBeam {
abstract class Common extends prefab.ManagedEnvironment with DeviceInfo { abstract class Common extends AbstractManagedEnvironment with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("tractor_beam"). withComponent("tractor_beam").
create() create()

View File

@ -14,6 +14,7 @@ import li.cil.oc.api.machine.Context
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import net.minecraft.entity.Entity import net.minecraft.entity.Entity
import net.minecraft.entity.IMerchant import net.minecraft.entity.IMerchant
@ -22,7 +23,7 @@ import net.minecraft.util.math.Vec3d
import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsJava._
import scala.collection.convert.WrapAsScala._ import scala.collection.convert.WrapAsScala._
class UpgradeTrading(val host: EnvironmentHost) extends prefab.ManagedEnvironment with traits.WorldAware with DeviceInfo { class UpgradeTrading(val host: EnvironmentHost) extends AbstractManagedEnvironment with traits.WorldAware with DeviceInfo {
override val node = Network.newNode(this, Visibility.Network). override val node = Network.newNode(this, Visibility.Network).
withComponent("trading"). withComponent("trading").
create() create()

View File

@ -2,6 +2,7 @@ package li.cil.oc.server.driver
import com.google.common.base.Strings import com.google.common.base.Strings
import li.cil.oc.api.driver import li.cil.oc.api.driver
import li.cil.oc.api.driver.DriverBlock
import li.cil.oc.api.driver.NamedBlock import li.cil.oc.api.driver.NamedBlock
import li.cil.oc.api.network.ManagedEnvironment import li.cil.oc.api.network.ManagedEnvironment
import net.minecraft.inventory.IInventory import net.minecraft.inventory.IInventory
@ -12,7 +13,7 @@ import net.minecraft.util.EnumFacing
import net.minecraft.util.math.BlockPos import net.minecraft.util.math.BlockPos
import net.minecraft.world.World import net.minecraft.world.World
class CompoundBlockDriver(val sidedBlocks: Array[driver.SidedBlock]) extends driver.SidedBlock { class CompoundBlockDriver(val sidedBlocks: Array[DriverBlock]) extends DriverBlock {
override def createEnvironment(world: World, pos: BlockPos, side: EnumFacing): CompoundBlockEnvironment = { override def createEnvironment(world: World, pos: BlockPos, side: EnumFacing): CompoundBlockEnvironment = {
val list = sidedBlocks.map { val list = sidedBlocks.map {
driver => Option(driver.createEnvironment(world, pos, side)) match { driver => Option(driver.createEnvironment(world, pos, side)) match {

View File

@ -5,10 +5,10 @@ import java.util
import li.cil.oc.OpenComputers import li.cil.oc.OpenComputers
import li.cil.oc.api import li.cil.oc.api
import li.cil.oc.api.driver.Converter import li.cil.oc.api.driver.Converter
import li.cil.oc.api.driver.DriverBlock
import li.cil.oc.api.driver.DriverItem
import li.cil.oc.api.driver.EnvironmentProvider import li.cil.oc.api.driver.EnvironmentProvider
import li.cil.oc.api.driver.InventoryProvider import li.cil.oc.api.driver.InventoryProvider
import li.cil.oc.api.driver.Item
import li.cil.oc.api.driver.SidedBlock
import li.cil.oc.api.driver.item.HostAware import li.cil.oc.api.driver.item.HostAware
import li.cil.oc.api.machine.Value import li.cil.oc.api.machine.Value
import li.cil.oc.api.network.EnvironmentHost import li.cil.oc.api.network.EnvironmentHost
@ -43,9 +43,9 @@ import scala.math.ScalaNumber
* the computer, but may also provide context-free functions. * the computer, but may also provide context-free functions.
*/ */
private[oc] object Registry extends api.detail.DriverAPI { private[oc] object Registry extends api.detail.DriverAPI {
val sidedBlocks: ArrayBuffer[SidedBlock] = mutable.ArrayBuffer.empty[api.driver.SidedBlock] val sidedBlocks: ArrayBuffer[DriverBlock] = mutable.ArrayBuffer.empty[DriverBlock]
val items: ArrayBuffer[Item] = mutable.ArrayBuffer.empty[api.driver.Item] val items: ArrayBuffer[DriverItem] = mutable.ArrayBuffer.empty[DriverItem]
val converters: ArrayBuffer[Converter] = mutable.ArrayBuffer.empty[api.driver.Converter] val converters: ArrayBuffer[Converter] = mutable.ArrayBuffer.empty[api.driver.Converter]
@ -58,7 +58,7 @@ private[oc] object Registry extends api.detail.DriverAPI {
/** Used to keep track of whether we're past the init phase. */ /** Used to keep track of whether we're past the init phase. */
var locked = false var locked = false
override def add(driver: api.driver.SidedBlock) { override def add(driver: DriverBlock) {
if (locked) throw new IllegalStateException("Please register all drivers in the init phase.") if (locked) throw new IllegalStateException("Please register all drivers in the init phase.")
if (!sidedBlocks.contains(driver)) { if (!sidedBlocks.contains(driver)) {
OpenComputers.log.debug(s"Registering block driver ${driver.getClass.getName}.") OpenComputers.log.debug(s"Registering block driver ${driver.getClass.getName}.")
@ -66,7 +66,7 @@ private[oc] object Registry extends api.detail.DriverAPI {
} }
} }
override def add(driver: api.driver.Item) { override def add(driver: DriverItem) {
if (locked) throw new IllegalStateException("Please register all drivers in the init phase.") if (locked) throw new IllegalStateException("Please register all drivers in the init phase.")
if (!items.contains(driver)) { if (!items.contains(driver)) {
OpenComputers.log.debug(s"Registering item driver ${driver.getClass.getName}.") OpenComputers.log.debug(s"Registering item driver ${driver.getClass.getName}.")
@ -98,13 +98,13 @@ private[oc] object Registry extends api.detail.DriverAPI {
} }
} }
override def driverFor(world: World, pos: BlockPos, side: EnumFacing): api.driver.SidedBlock = override def driverFor(world: World, pos: BlockPos, side: EnumFacing): DriverBlock =
sidedBlocks.filter(_.worksWith(world, pos, side)) match { sidedBlocks.filter(_.worksWith(world, pos, side)) match {
case sidedDrivers if sidedDrivers.nonEmpty => new CompoundBlockDriver(sidedDrivers.toArray) case sidedDrivers if sidedDrivers.nonEmpty => new CompoundBlockDriver(sidedDrivers.toArray)
case _ => null case _ => null
} }
override def driverFor(stack: ItemStack, host: Class[_ <: EnvironmentHost]): Item = override def driverFor(stack: ItemStack, host: Class[_ <: EnvironmentHost]): DriverItem =
if (!stack.isEmpty) { if (!stack.isEmpty) {
val hostAware = items.collect { val hostAware = items.collect {
case driver: HostAware if driver.worksWith(stack) => driver case driver: HostAware if driver.worksWith(stack) => driver
@ -116,7 +116,7 @@ private[oc] object Registry extends api.detail.DriverAPI {
} }
else null else null
override def driverFor(stack: ItemStack): Item = override def driverFor(stack: ItemStack): DriverItem =
if (!stack.isEmpty) items.find(_.worksWith(stack)).orNull if (!stack.isEmpty) items.find(_.worksWith(stack)).orNull
else null else null
@ -139,7 +139,7 @@ private[oc] object Registry extends api.detail.DriverAPI {
} }
} }
override def itemDrivers: util.List[Item] = items.toSeq override def itemDrivers: util.List[DriverItem] = items.toSeq
def blacklistHost(stack: ItemStack, host: Class[_]) { def blacklistHost(stack: ItemStack, host: Class[_]) {
blacklist.find(_._1.isItemEqual(stack)) match { blacklist.find(_._1.isItemEqual(stack)) match {

View File

@ -26,6 +26,7 @@ import li.cil.oc.api.network.Message
import li.cil.oc.api.network.Node import li.cil.oc.api.network.Node
import li.cil.oc.api.network.Visibility import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab import li.cil.oc.api.prefab
import li.cil.oc.api.prefab.AbstractManagedEnvironment
import li.cil.oc.common.EventHandler import li.cil.oc.common.EventHandler
import li.cil.oc.common.SaveHandler import li.cil.oc.common.SaveHandler
import li.cil.oc.common.Slot import li.cil.oc.common.Slot
@ -49,7 +50,7 @@ import scala.collection.convert.WrapAsJava._
import scala.collection.convert.WrapAsScala._ import scala.collection.convert.WrapAsScala._
import scala.collection.mutable import scala.collection.mutable
class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with machine.Machine with Runnable with DeviceInfo { class Machine(val host: MachineHost) extends AbstractManagedEnvironment with machine.Machine with Runnable with DeviceInfo {
override val node: ComponentConnector = Network.newNode(this, Visibility.Network). override val node: ComponentConnector = Network.newNode(this, Visibility.Network).
withComponent("computer", Visibility.Neighbors). withComponent("computer", Visibility.Neighbors).
withConnector(Settings.get.bufferComputer). withConnector(Settings.get.bufferComputer).