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.OpenComputers
|
||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
import li.cil.oc.client.Sound
|
import li.cil.oc.client.Sound
|
||||||
|
import li.cil.oc.server.fs.FileSystem
|
||||||
import li.cil.oc.util.BlockPosition
|
import li.cil.oc.util.BlockPosition
|
||||||
import li.cil.oc.util.SideTracker
|
import li.cil.oc.util.SideTracker
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
@ -88,10 +89,16 @@ trait TileEntity extends net.minecraft.tileentity.TileEntity {
|
|||||||
|
|
||||||
override def getDescriptionPacket = {
|
override def getDescriptionPacket = {
|
||||||
val nbt = new NBTTagCompound()
|
val nbt = new NBTTagCompound()
|
||||||
|
|
||||||
|
FileSystem.savingForClients = true
|
||||||
|
try {
|
||||||
try writeToNBTForClient(nbt) catch {
|
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)
|
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)
|
if (nbt.hasNoTags) null else new S35PacketUpdateTileEntity(x, y, z, -1, nbt)
|
||||||
|
} finally {
|
||||||
|
FileSystem.savingForClients = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def onDataPacket(manager: NetworkManager, packet: S35PacketUpdateTileEntity) {
|
override def onDataPacket(manager: NetworkManager, packet: S35PacketUpdateTileEntity) {
|
||||||
|
@ -5,15 +5,16 @@ import java.io.IOException
|
|||||||
|
|
||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
import li.cil.oc.api.Network
|
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.Label
|
||||||
import li.cil.oc.api.fs.Mode
|
import li.cil.oc.api.fs.Mode
|
||||||
import li.cil.oc.api.fs.{FileSystem => IFileSystem}
|
import li.cil.oc.api.fs.{FileSystem => IFileSystem}
|
||||||
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
|
||||||
|
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.server.fs.FileSystem
|
||||||
import li.cil.oc.server.{PacketSender => ServerPacketSender}
|
import li.cil.oc.server.{PacketSender => ServerPacketSender}
|
||||||
import li.cil.oc.util.ExtendedNBT._
|
import li.cil.oc.util.ExtendedNBT._
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
@ -282,6 +283,11 @@ class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option
|
|||||||
override def save(nbt: NBTTagCompound) = fileSystem.synchronized {
|
override def save(nbt: NBTTagCompound) = fileSystem.synchronized {
|
||||||
super.save(nbt)
|
super.save(nbt)
|
||||||
|
|
||||||
|
if (label != null) {
|
||||||
|
label.save(nbt)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!FileSystem.savingForClients) {
|
||||||
val ownersNbt = new NBTTagList()
|
val ownersNbt = new NBTTagList()
|
||||||
for ((address, handles) <- owners) {
|
for ((address, handles) <- owners) {
|
||||||
val ownerNbt = new NBTTagCompound()
|
val ownerNbt = new NBTTagCompound()
|
||||||
@ -291,11 +297,9 @@ class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option
|
|||||||
}
|
}
|
||||||
nbt.setTag("owners", ownersNbt)
|
nbt.setTag("owners", ownersNbt)
|
||||||
|
|
||||||
if (label != null) {
|
|
||||||
label.save(nbt)
|
|
||||||
}
|
|
||||||
nbt.setNewCompoundTag("fs", fileSystem.save)
|
nbt.setNewCompoundTag("fs", fileSystem.save)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ import net.minecraftforge.common.DimensionManager
|
|||||||
import scala.util.Try
|
import scala.util.Try
|
||||||
|
|
||||||
object FileSystem extends api.detail.FileSystemAPI {
|
object FileSystem extends api.detail.FileSystemAPI {
|
||||||
|
var savingForClients = false
|
||||||
|
|
||||||
lazy val isCaseInsensitive = Settings.get.forceCaseInsensitive || (try {
|
lazy val isCaseInsensitive = Settings.get.forceCaseInsensitive || (try {
|
||||||
val uuid = UUID.randomUUID().toString
|
val uuid = UUID.randomUUID().toString
|
||||||
val lowerCase = new io.File(DimensionManager.getCurrentSaveRootDirectory, uuid + "oc_rox")
|
val lowerCase = new io.File(DimensionManager.getCurrentSaveRootDirectory, uuid + "oc_rox")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user