diff --git a/src/main/java/li/cil/oc/api/FileSystem.java b/src/main/java/li/cil/oc/api/FileSystem.java index 6025d13f6..a706e396e 100644 --- a/src/main/java/li/cil/oc/api/FileSystem.java +++ b/src/main/java/li/cil/oc/api/FileSystem.java @@ -145,14 +145,14 @@ public final class FileSystem { * * @param fileSystem the file system to wrap. * @param label the label of the file system. + * @param host the tile entity containing the file system. * @param accessSound the name of the sound effect to play when the file * system is accessed. - * @param host the tile entity containing the file system. * @return the network node wrapping the file system. */ - public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final Label label, final String accessSound, final EnvironmentHost host) { + public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final Label label, final EnvironmentHost host, final String accessSound) { if (instance != null) - return instance.asManagedEnvironment(fileSystem, label, accessSound, host); + return instance.asManagedEnvironment(fileSystem, label, host, accessSound); return null; } @@ -162,14 +162,14 @@ public final class FileSystem { * * @param fileSystem the file system to wrap. * @param label the read-only label of the file system. + * @param host the tile entity containing the file system. * @param accessSound the name of the sound effect to play when the file * system is accessed. - * @param host the tile entity containing the file system. * @return the network node wrapping the file system. */ - public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final String label, final String accessSound, final EnvironmentHost host) { + public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final String label, final EnvironmentHost host, final String accessSound) { if (instance != null) - return instance.asManagedEnvironment(fileSystem, label, accessSound, host); + return instance.asManagedEnvironment(fileSystem, label, host, accessSound); return null; } diff --git a/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java b/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java index de7568e2d..5efd028e2 100644 --- a/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java +++ b/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java @@ -100,12 +100,12 @@ public interface FileSystemAPI { * * @param fileSystem the file system to wrap. * @param label the label of the file system. + * @param host the tile entity containing the file system. * @param accessSound the name of the sound effect to play when the file * system is accessed. - * @param host the tile entity containing the file system. * @return the network node wrapping the file system. */ - ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, Label label, String accessSound, EnvironmentHost host); + ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, Label label, EnvironmentHost host, String accessSound); /** * Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, String, li.cil.oc.api.driver.EnvironmentHost)}, @@ -113,12 +113,12 @@ public interface FileSystemAPI { * * @param fileSystem the file system to wrap. * @param label the read-only label of the file system. + * @param host the tile entity containing the file system. * @param accessSound the name of the sound effect to play when the file * system is accessed. - * @param host the tile entity containing the file system. * @return the network node wrapping the file system. */ - ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, String label, String accessSound, EnvironmentHost host); + ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, String label, EnvironmentHost host, String accessSound); /** * Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, String, li.cil.oc.api.driver.EnvironmentHost)}, diff --git a/src/main/scala/li/cil/oc/server/component/FileSystem.scala b/src/main/scala/li/cil/oc/server/component/FileSystem.scala index 21bcba56c..1a031279f 100644 --- a/src/main/scala/li/cil/oc/server/component/FileSystem.scala +++ b/src/main/scala/li/cil/oc/server/component/FileSystem.scala @@ -2,24 +2,20 @@ package li.cil.oc.server.component import java.io.{FileNotFoundException, IOException} +import li.cil.oc.Settings import li.cil.oc.api.Network import li.cil.oc.api.driver.EnvironmentHost import li.cil.oc.api.fs.{Label, Mode, FileSystem => IFileSystem} import li.cil.oc.api.machine.{Arguments, Callback, Context} import li.cil.oc.api.network._ import li.cil.oc.common.{Sound, component} -import li.cil.oc.server.driver.item.ComputerCraftMedia -import li.cil.oc.server.fs.FileSystem.ItemLabel import li.cil.oc.util.ExtendedNBT._ -import li.cil.oc.util.mods.Mods -import li.cil.oc.{Settings, api} -import net.minecraft.item.ItemStack import net.minecraft.nbt.{NBTTagCompound, NBTTagIntArray, NBTTagList} import net.minecraftforge.common.util.Constants.NBT import scala.collection.mutable -class FileSystem(val fileSystem: IFileSystem, var label: Label, val sound: Option[String] = None, val host: Option[EnvironmentHost] = None) extends component.ManagedComponent { +class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option[EnvironmentHost] = None, val sound: Option[String] = None) extends component.ManagedComponent { val node = Network.newNode(this, Visibility.Network). withComponent("filesystem", Visibility.Neighbors). withConnector(). @@ -302,14 +298,6 @@ class FileSystem(val fileSystem: IFileSystem, var label: Label, val sound: Optio if (!owners.contains(owner) || !owners(owner).contains(handle)) throw new IOException("bad file descriptor") - private lazy val floppies = Set(api.Items.get("floppy"), api.Items.get("lootDisk"), api.Items.get("openOS")) - - private lazy val hdds = Set(api.Items.get("hdd1"), api.Items.get("hdd2"), api.Items.get("hdd3")) - - private def isFloppy(stack: ItemStack) = floppies contains api.Items.get(stack) - - private def isHardDisk(stack: ItemStack) = hdds contains api.Items.get(stack) - private def makeSomeNoise() { (sound, host) match { case (Some(s), Some(h)) => Sound.playDiskActivity(h, s) diff --git a/src/main/scala/li/cil/oc/server/driver/item/ComputerCraftMedia.scala b/src/main/scala/li/cil/oc/server/driver/item/ComputerCraftMedia.scala index 64aec18b0..9a8832f2b 100644 --- a/src/main/scala/li/cil/oc/server/driver/item/ComputerCraftMedia.scala +++ b/src/main/scala/li/cil/oc/server/driver/item/ComputerCraftMedia.scala @@ -16,7 +16,7 @@ object ComputerCraftMedia extends Item { if (Mods.ComputerCraft.isAvailable && ComputerCraft.isDisk(stack) && host != null) { val address = addressFromTag(dataTag(stack)) val mount = ComputerCraft.createDiskMount(stack, host.world) - Option(oc.api.FileSystem.asManagedEnvironment(mount, new ComputerCraftLabel(stack), "floppy_access", host)) match { + Option(oc.api.FileSystem.asManagedEnvironment(mount, new ComputerCraftLabel(stack), host, "floppy_access")) match { case Some(environment) => environment.node.asInstanceOf[oc.server.network.Node].address = address environment diff --git a/src/main/scala/li/cil/oc/server/driver/item/FileSystem.scala b/src/main/scala/li/cil/oc/server/driver/item/FileSystem.scala index 0e275398b..7aee5ab36 100644 --- a/src/main/scala/li/cil/oc/server/driver/item/FileSystem.scala +++ b/src/main/scala/li/cil/oc/server/driver/item/FileSystem.scala @@ -40,7 +40,7 @@ object FileSystem extends Item { val address = addressFromTag(dataTag(stack)) val isFloppy = api.Items.get(stack) == api.Items.get("floppy") val fs = oc.api.FileSystem.fromSaveDirectory(address, capacity, Settings.get.bufferChanges) - val environment = oc.api.FileSystem.asManagedEnvironment(fs, new ReadWriteItemLabel(stack), if (isFloppy) "floppy_access" else "hdd_access", host) + val environment = oc.api.FileSystem.asManagedEnvironment(fs, new ReadWriteItemLabel(stack), host, if (isFloppy) "floppy_access" else "hdd_access") if (environment != null && environment.node != null) { environment.node.asInstanceOf[oc.server.network.Node].address = address } diff --git a/src/main/scala/li/cil/oc/server/driver/item/Loot.scala b/src/main/scala/li/cil/oc/server/driver/item/Loot.scala index 237f6a1d0..358b9c15a 100644 --- a/src/main/scala/li/cil/oc/server/driver/item/Loot.scala +++ b/src/main/scala/li/cil/oc/server/driver/item/Loot.scala @@ -27,7 +27,7 @@ object Loot extends Item { dataTag(stack).getString(Settings.namespace + "fs.label") } else null - api.FileSystem.asManagedEnvironment(fs, label, "floppy_disk", host) + api.FileSystem.asManagedEnvironment(fs, label, host, "floppy_disk") } else null diff --git a/src/main/scala/li/cil/oc/server/fs/FileSystem.scala b/src/main/scala/li/cil/oc/server/fs/FileSystem.scala index 02b79351d..6050b59b4 100644 --- a/src/main/scala/li/cil/oc/server/fs/FileSystem.scala +++ b/src/main/scala/li/cil/oc/server/fs/FileSystem.scala @@ -101,11 +101,11 @@ object FileSystem extends api.detail.FileSystemAPI { else null } - def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: Label, sound: String, host: EnvironmentHost) = - Option(fileSystem).flatMap(fs => Some(new component.FileSystem(fs, label, Option(sound), Option(host)))).orNull + def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: Label, host: EnvironmentHost, sound: String) = + Option(fileSystem).flatMap(fs => Some(new component.FileSystem(fs, label, Option(host), Option(sound)))).orNull - def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: String, sound: String, host: EnvironmentHost) = - asManagedEnvironment(fileSystem, new ReadOnlyLabel(label), sound, host) + def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: String, host: EnvironmentHost, sound: String) = + asManagedEnvironment(fileSystem, new ReadOnlyLabel(label), host, sound) def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: Label) = Option(fileSystem).flatMap(fs => Some(new component.FileSystem(fs, label))).orNull