mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Hacky hack to avoid filesystems flushing to real HDD when sending client descriptor packets.
This commit is contained in:
parent
5ca28b2d92
commit
fb88a19e10
@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.client.Sound
|
||||
import li.cil.oc.server.fs.FileSystem
|
||||
import li.cil.oc.util.BlockPosition
|
||||
import li.cil.oc.util.SideTracker
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
@ -88,10 +89,16 @@ trait TileEntity extends net.minecraft.tileentity.TileEntity {
|
||||
|
||||
override def getDescriptionPacket = {
|
||||
val nbt = new NBTTagCompound()
|
||||
try writeToNBTForClient(nbt) catch {
|
||||
case e: Throwable => OpenComputers.log.warn("There was a problem writing a TileEntity description packet. Please report this if you see it!", e)
|
||||
|
||||
FileSystem.savingForClients = true
|
||||
try {
|
||||
try writeToNBTForClient(nbt) catch {
|
||||
case e: Throwable => OpenComputers.log.warn("There was a problem writing a TileEntity description packet. Please report this if you see it!", e)
|
||||
}
|
||||
if (nbt.hasNoTags) null else new S35PacketUpdateTileEntity(x, y, z, -1, nbt)
|
||||
} finally {
|
||||
FileSystem.savingForClients = false
|
||||
}
|
||||
if (nbt.hasNoTags) null else new S35PacketUpdateTileEntity(x, y, z, -1, nbt)
|
||||
}
|
||||
|
||||
override def onDataPacket(manager: NetworkManager, packet: S35PacketUpdateTileEntity) {
|
||||
|
@ -5,15 +5,16 @@ import java.io.IOException
|
||||
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api.Network
|
||||
import li.cil.oc.api.network.EnvironmentHost
|
||||
import li.cil.oc.api.fs.Label
|
||||
import li.cil.oc.api.fs.Mode
|
||||
import li.cil.oc.api.fs.{FileSystem => IFileSystem}
|
||||
import li.cil.oc.api.machine.Arguments
|
||||
import li.cil.oc.api.machine.Callback
|
||||
import li.cil.oc.api.machine.Context
|
||||
import li.cil.oc.api.network.EnvironmentHost
|
||||
import li.cil.oc.api.network._
|
||||
import li.cil.oc.api.prefab
|
||||
import li.cil.oc.server.fs.FileSystem
|
||||
import li.cil.oc.server.{PacketSender => ServerPacketSender}
|
||||
import li.cil.oc.util.ExtendedNBT._
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
@ -282,19 +283,22 @@ class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option
|
||||
override def save(nbt: NBTTagCompound) = fileSystem.synchronized {
|
||||
super.save(nbt)
|
||||
|
||||
val ownersNbt = new NBTTagList()
|
||||
for ((address, handles) <- owners) {
|
||||
val ownerNbt = new NBTTagCompound()
|
||||
ownerNbt.setString("address", address)
|
||||
ownerNbt.setTag("handles", new NBTTagIntArray(handles.toArray))
|
||||
ownersNbt.appendTag(ownerNbt)
|
||||
}
|
||||
nbt.setTag("owners", ownersNbt)
|
||||
|
||||
if (label != null) {
|
||||
label.save(nbt)
|
||||
}
|
||||
nbt.setNewCompoundTag("fs", fileSystem.save)
|
||||
|
||||
if (!FileSystem.savingForClients) {
|
||||
val ownersNbt = new NBTTagList()
|
||||
for ((address, handles) <- owners) {
|
||||
val ownerNbt = new NBTTagCompound()
|
||||
ownerNbt.setString("address", address)
|
||||
ownerNbt.setTag("handles", new NBTTagIntArray(handles.toArray))
|
||||
ownersNbt.appendTag(ownerNbt)
|
||||
}
|
||||
nbt.setTag("owners", ownersNbt)
|
||||
|
||||
nbt.setNewCompoundTag("fs", fileSystem.save)
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
@ -22,6 +22,8 @@ import net.minecraftforge.common.DimensionManager
|
||||
import scala.util.Try
|
||||
|
||||
object FileSystem extends api.detail.FileSystemAPI {
|
||||
var savingForClients = false
|
||||
|
||||
lazy val isCaseInsensitive = Settings.get.forceCaseInsensitive || (try {
|
||||
val uuid = UUID.randomUUID().toString
|
||||
val lowerCase = new io.File(DimensionManager.getCurrentSaveRootDirectory, uuid + "oc_rox")
|
||||
|
Loading…
x
Reference in New Issue
Block a user