Ensure writeToNBT/readFromNBT is only called on the server, as some mods may choose to call it on the client...

This commit is contained in:
Florian Nücke 2015-02-09 13:30:14 +01:00
parent dab5a56def
commit 43a40cd3a8
34 changed files with 144 additions and 128 deletions

View File

@ -120,8 +120,8 @@ class AccessPoint extends Switch with WirelessEndpoint with traits.PowerAcceptor
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) = {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) = {
super.readFromNBTForServer(nbt)
if (nbt.hasKey(Settings.namespace + "strength")) {
strength = nbt.getDouble(Settings.namespace + "strength") max 0 min Settings.get.maxWirelessRange
}
@ -134,8 +134,8 @@ class AccessPoint extends Switch with WirelessEndpoint with traits.PowerAcceptor
}
}
override def writeToNBT(nbt: NBTTagCompound) = {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) = {
super.writeToNBTForServer(nbt)
nbt.setDouble(Settings.namespace + "strength", strength)
nbt.setBoolean(Settings.namespace + "isRepeater", isRepeater)
nbt.setNewTagList(Settings.namespace + "componentNodes", componentNodes.map {

View File

@ -143,8 +143,8 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
val blocksNbt = nbt.getTagList(Settings.namespace + "adapter.blocks", NBT.TAG_COMPOUND)
(0 until (blocksNbt.tagCount min blocksData.length)).
@ -158,8 +158,8 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
}
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
val blocksNbt = new NBTTagList()
for (i <- 0 until blocks.length) {

View File

@ -126,8 +126,8 @@ class Assembler extends traits.Environment with traits.PowerAcceptor with traits
}
}
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
if (nbt.hasKey(Settings.namespace + "output")) {
output = Option(ItemUtils.loadStack(nbt.getCompoundTag(Settings.namespace + "output")))
}
@ -139,8 +139,8 @@ class Assembler extends traits.Environment with traits.PowerAcceptor with traits
requiredEnergy = nbt.getDouble(Settings.namespace + "remaining")
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
output.foreach(stack => nbt.setNewCompoundTag(Settings.namespace + "output", stack.writeToNBT))
nbt.setDouble(Settings.namespace + "total", totalRequiredEnergy)
nbt.setDouble(Settings.namespace + "remaining", requiredEnergy)

View File

@ -54,15 +54,15 @@ class Case(var tier: Int) extends traits.PowerAcceptor with traits.Computer with
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
override def readFromNBTForServer(nbt: NBTTagCompound) {
tier = nbt.getByte(Settings.namespace + "tier") max 0 min 3
color = Color.byTier(tier)
super.readFromNBT(nbt)
super.readFromNBTForServer(nbt)
}
override def writeToNBT(nbt: NBTTagCompound) {
override def writeToNBTForServer(nbt: NBTTagCompound) {
nbt.setByte(Settings.namespace + "tier", tier.toByte)
super.writeToNBT(nbt)
super.writeToNBTForServer(nbt)
}
// ----------------------------------------------------------------------- //

View File

@ -130,15 +130,15 @@ class Charger extends traits.Environment with traits.PowerAcceptor with traits.R
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
chargeSpeed = nbt.getDouble("chargeSpeed") max 0 min 1
hasPower = nbt.getBoolean("hasPower")
invertSignal = nbt.getBoolean("invertSignal")
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
nbt.setDouble("chargeSpeed", chargeSpeed)
nbt.setBoolean("hasPower", hasPower)
nbt.setBoolean("invertSignal", invertSignal)

View File

@ -123,8 +123,8 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
queue.clear()
queue ++= nbt.getTagList(Settings.namespace + "queue", NBT.TAG_COMPOUND).
map((tag: NBTTagCompound) => ItemUtils.loadStack(tag))
@ -133,8 +133,8 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
isActive = queue.nonEmpty
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
nbt.setNewTagList(Settings.namespace + "queue", queue)
nbt.setDouble(Settings.namespace + "buffer", buffer)
nbt.setDouble(Settings.namespace + "total", totalRequiredEnergy)

View File

@ -10,13 +10,13 @@ class Geolyzer extends traits.Environment {
override def canUpdate = false
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
geolyzer.load(nbt)
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
geolyzer.save(nbt)
}
}

View File

@ -351,9 +351,9 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
override def readFromNBTForServer(nbt: NBTTagCompound) {
tier = nbt.getByte(Settings.namespace + "tier") max 0 min 1
super.readFromNBT(nbt)
super.readFromNBTForServer(nbt)
val tag = SaveHandler.loadNBT(nbt, node.address + "_data")
tag.getIntArray("volume").copyToArray(volume)
tag.getIntArray("colors").map(convertColor).copyToArray(colors)
@ -363,9 +363,9 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
translation.zCoord = nbt.getDouble(Settings.namespace + "offsetZ")
}
override def writeToNBT(nbt: NBTTagCompound) = this.synchronized {
override def writeToNBTForServer(nbt: NBTTagCompound) = this.synchronized {
nbt.setByte(Settings.namespace + "tier", tier.toByte)
super.writeToNBT(nbt)
super.writeToNBTForServer(nbt)
if (!Waila.isSavingForTooltip) {
SaveHandler.scheduleSave(world, x, z, nbt, node.address + "_data", tag => {
tag.setIntArray("volume", volume)

View File

@ -38,15 +38,15 @@ class Keyboard extends traits.Environment with traits.Rotatable with traits.Immi
override def canUpdate = false
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
if (isServer) {
keyboard.load(nbt.getCompoundTag(Settings.namespace + "keyboard"))
}
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
if (isServer) {
nbt.setNewCompoundTag(Settings.namespace + "keyboard", keyboard.save)
}

View File

@ -156,16 +156,16 @@ class Microcontroller extends traits.PowerAcceptor with traits.Hub with traits.C
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
override def readFromNBTForServer(nbt: NBTTagCompound) {
// Load info before inventory and such, to avoid initializing components
// to empty inventory.
info.load(nbt.getCompoundTag(Settings.namespace + "info"))
nbt.getBooleanArray(Settings.namespace + "outputs")
super.readFromNBT(nbt)
super.readFromNBTForServer(nbt)
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
nbt.setNewCompoundTag(Settings.namespace + "info", info.save)
nbt.setBooleanArray(Settings.namespace + "outputs", outputSides)
}

View File

@ -108,13 +108,13 @@ class MotionSensor extends traits.Environment {
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
sensitivity = nbt.getDouble(Settings.namespace + "sensitivity")
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
nbt.setDouble(Settings.namespace + "sensitivity", sensitivity)
}
}

View File

@ -30,16 +30,16 @@ class PowerDistributor extends traits.Environment with traits.PowerBalancer with
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
nbt.getTagList(Settings.namespace + "connector", NBT.TAG_COMPOUND).toArray[NBTTagCompound].
zipWithIndex.foreach {
case (tag, index) => nodes(index).load(tag)
}
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
// Side check for Waila (and other mods that may call this client side).
if (isServer) {
nbt.setNewTagList(Settings.namespace + "connector", nodes.map(connector => {

View File

@ -112,8 +112,8 @@ class Raid extends traits.Environment with traits.Inventory with traits.Rotatabl
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
if (nbt.hasKey(Settings.namespace + "fs")) {
val tag = nbt.getCompoundTag(Settings.namespace + "fs")
tryCreateRaid(tag.getCompoundTag("node").getString("address"))
@ -122,8 +122,8 @@ class Raid extends traits.Environment with traits.Inventory with traits.Rotatabl
label.load(nbt)
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
filesystem.foreach(fs => nbt.setNewCompoundTag(Settings.namespace + "fs", fs.save))
label.save(nbt)
}

View File

@ -29,13 +29,13 @@ class Redstone extends Environment with BundledRedstoneAware {
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
instance.load(nbt.getCompoundTag(Settings.namespace + "redstone"))
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
nbt.setNewCompoundTag(Settings.namespace + "redstone", instance.save)
}

View File

@ -423,7 +423,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
override def readFromNBTForServer(nbt: NBTTagCompound) {
updateInventorySize()
machine.onHostChanged()
@ -450,7 +450,7 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
}
// Side check for Waila (and other mods that may call this client side).
override def writeToNBT(nbt: NBTTagCompound) = if (isServer) this.synchronized {
override def writeToNBTForServer(nbt: NBTTagCompound) = if (isServer) this.synchronized {
info.save(nbt)
// Note: computer is saved when proxy is saved (in proxy's super writeToNBT)

View File

@ -132,15 +132,15 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
}
}
override def readFromNBT(nbt: NBTTagCompound) {
override def readFromNBTForServer(nbt: NBTTagCompound) {
robot.info.load(nbt)
super.readFromNBT(nbt)
robot.readFromNBT(nbt)
super.readFromNBTForServer(nbt)
robot.readFromNBTForServer(nbt)
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
robot.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
robot.writeToNBTForServer(nbt)
}
override def save(nbt: NBTTagCompound) = robot.save(nbt)

View File

@ -279,17 +279,17 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
override def readFromNBTForServer(nbt: NBTTagCompound) {
tier = nbt.getByte(Settings.namespace + "tier") max 0 min 2
color = Color.byTier(tier)
super.readFromNBT(nbt)
super.readFromNBTForServer(nbt)
hadRedstoneInput = nbt.getBoolean(Settings.namespace + "hadRedstoneInput")
invertTouchMode = nbt.getBoolean(Settings.namespace + "invertTouchMode")
}
override def writeToNBT(nbt: NBTTagCompound) {
override def writeToNBTForServer(nbt: NBTTagCompound) {
nbt.setByte(Settings.namespace + "tier", tier.toByte)
super.writeToNBT(nbt)
super.writeToNBTForServer(nbt)
nbt.setBoolean(Settings.namespace + "hadRedstoneInput", hadRedstoneInput)
nbt.setBoolean(Settings.namespace + "invertTouchMode", invertTouchMode)
}

View File

@ -315,8 +315,8 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
}
}
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
for (slot <- 0 until getSizeInventory) {
if (getStackInSlot(slot) != null) {
val server = new component.Server(this, slot)
@ -363,7 +363,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
}
// Side check for Waila (and other mods that may call this client side).
override def writeToNBT(nbt: NBTTagCompound) = if (isServer) {
override def writeToNBTForServer(nbt: NBTTagCompound) = if (isServer) {
if (!Waila.isSavingForTooltip) {
nbt.setNewTagList(Settings.namespace + "servers", servers map {
case Some(server) =>
@ -375,7 +375,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
case _ => new NBTTagCompound()
})
}
super.writeToNBT(nbt)
super.writeToNBTForServer(nbt)
nbt.setByteArray(Settings.namespace + "sides", sides.map {
case Some(side) => side.ordinal.toByte
case _ => -1: Byte

View File

@ -107,8 +107,8 @@ class Switch extends traits.Hub with traits.NotAnalyzable with traits.ComponentI
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
for (slot <- 0 until items.length) items(slot) collect {
case stack => updateLimits(slot, stack)
}

View File

@ -97,8 +97,8 @@ trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBund
}
}
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
nbt.getTagList(Settings.namespace + "rs.bundledInput", NBT.TAG_INT_ARRAY).toArray[NBTTagIntArray].
map(_.func_150302_c()).zipWithIndex.foreach {
@ -124,8 +124,8 @@ trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBund
}
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
nbt.setNewTagList(Settings.namespace + "rs.bundledInput", _bundledInput.view)
nbt.setNewTagList(Settings.namespace + "rs.bundledOutput", _bundledOutput.view)

View File

@ -27,15 +27,15 @@ trait Colored extends TileEntity with internal.Colored {
}
}
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
if (nbt.hasKey(Settings.namespace + "renderColor")) {
_color = nbt.getInteger(Settings.namespace + "renderColor")
}
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
nbt.setInteger(Settings.namespace + "renderColor", _color)
}

View File

@ -120,8 +120,8 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
// God, this is so ugly... will need to rework the robot architecture.
// This is required for loading auxiliary data (kernel state), because the
// coordinates in the actual robot won't be set properly, otherwise.
@ -142,8 +142,8 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
_isAbstractBusAvailable = hasAbstractBusCard
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
if (machine != null) {
if (!Waila.isSavingForTooltip)
nbt.setNewCompoundTag(Settings.namespace + "computer", machine.save)

View File

@ -55,15 +55,15 @@ trait Environment extends TileEntity with network.Environment with driver.Enviro
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
if (node != null && node.host == this) {
node.load(nbt.getCompoundTag(Settings.namespace + "node"))
}
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
if (node != null && node.host == this) {
nbt.setNewCompoundTag(Settings.namespace + "node", node.save)
}

View File

@ -97,8 +97,8 @@ trait Hub extends traits.Environment with SidedEnvironment {
}
}
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
nbt.getTagList(Settings.namespace + "plugs", NBT.TAG_COMPOUND).toArray[NBTTagCompound].
zipWithIndex.foreach {
case (tag, index) => plugs(index).node.load(tag)
@ -114,8 +114,8 @@ trait Hub extends traits.Environment with SidedEnvironment {
}
}
override def writeToNBT(nbt: NBTTagCompound) = queue.synchronized {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) = queue.synchronized {
super.writeToNBTForServer(nbt)
// Side check for Waila (and other mods that may call this client side).
if (isServer) {
nbt.setNewTagList(Settings.namespace + "plugs", plugs.map(plug => {

View File

@ -13,13 +13,13 @@ trait Inventory extends TileEntity with inventory.Inventory {
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
load(nbt)
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
save(nbt)
}

View File

@ -10,11 +10,11 @@ trait PowerInformation extends TileEntity {
def globalBuffer: Double
def globalBuffer_=(value: Double)
def globalBuffer_=(value: Double): Unit
def globalBufferSize: Double
def globalBufferSize_=(value: Double)
def globalBufferSize_=(value: Double): Unit
protected def updatePowerInformation() {
val ratio = if (globalBufferSize > 0) globalBuffer / globalBufferSize else 0

View File

@ -86,8 +86,8 @@ trait RedstoneAware extends RotationAware with IConnectable with IRedstoneEmitte
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) = {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) = {
super.readFromNBTForServer(nbt)
val input = nbt.getIntArray(Settings.namespace + "rs.input")
input.copyToArray(_input, 0, input.length min _input.length)
@ -95,8 +95,8 @@ trait RedstoneAware extends RotationAware with IConnectable with IRedstoneEmitte
output.copyToArray(_output, 0, output.length min _output.length)
}
override def writeToNBT(nbt: NBTTagCompound) = {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) = {
super.writeToNBTForServer(nbt)
nbt.setIntArray(Settings.namespace + "rs.input", _input)
nbt.setIntArray(Settings.namespace + "rs.output", _output)

View File

@ -167,8 +167,8 @@ trait Rotatable extends RotationAware with internal.Rotatable {
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) = {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) = {
super.readFromNBTForServer(nbt)
if (nbt.hasKey(Settings.namespace + "pitch")) {
pitch = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "pitch"))
}
@ -179,8 +179,8 @@ trait Rotatable extends RotationAware with internal.Rotatable {
updateTranslation()
}
override def writeToNBT(nbt: NBTTagCompound) = {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) = {
super.writeToNBTForServer(nbt)
nbt.setInteger(Settings.namespace + "pitch", pitch.ordinal)
nbt.setInteger(Settings.namespace + "yaw", yaw.ordinal)
}

View File

@ -29,13 +29,13 @@ trait TextBuffer extends Environment {
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) = {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) = {
super.readFromNBTForServer(nbt)
buffer.load(nbt)
}
override def writeToNBT(nbt: NBTTagCompound) = {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) = {
super.writeToNBTForServer(nbt)
buffer.save(nbt)
}

View File

@ -63,6 +63,10 @@ trait TileEntity extends net.minecraft.tileentity.TileEntity {
// ----------------------------------------------------------------------- //
def readFromNBTForServer(nbt: NBTTagCompound): Unit = super.readFromNBT(nbt)
def writeToNBTForServer(nbt: NBTTagCompound): Unit = super.writeToNBT(nbt)
@SideOnly(Side.CLIENT)
def readFromNBTForClient(nbt: NBTTagCompound) {}
@ -70,6 +74,18 @@ trait TileEntity extends net.minecraft.tileentity.TileEntity {
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound): Unit = {
if (isServer) {
readFromNBTForServer(nbt)
}
}
override def writeToNBT(nbt: NBTTagCompound): Unit = {
if (isServer) {
writeToNBTForServer(nbt)
}
}
override def getDescriptionPacket = {
val nbt = new NBTTagCompound()
try writeToNBTForClient(nbt) catch {

View File

@ -66,8 +66,8 @@ trait AppliedEnergistics2 extends Common {
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
if (useAppliedEnergistics2Power) loadNode(nbt)
}
@ -76,8 +76,8 @@ trait AppliedEnergistics2 extends Common {
getGridNode(ForgeDirection.UNKNOWN).loadFromNBT(Settings.namespace + "ae2power", nbt)
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
if (useAppliedEnergistics2Power) saveNode(nbt)
}

View File

@ -59,8 +59,8 @@ trait Factorization extends Common {
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
if (useFactorizationPower) loadCharge(nbt)
}
@ -69,8 +69,8 @@ trait Factorization extends Common {
getCharge.readFromNBT(nbt, "fzpower")
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
if (useFactorizationPower) saveCharge(nbt)
}

View File

@ -61,13 +61,13 @@ trait IndustrialCraft2Classic extends Common with IndustrialCraft2Common {
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
conversionBuffer = nbt.getDouble(Settings.namespace + "ic2cpower")
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
nbt.setDouble(Settings.namespace + "ic2cpower", conversionBuffer)
}

View File

@ -59,13 +59,13 @@ trait IndustrialCraft2Experimental extends Common with IndustrialCraft2Common {
// ----------------------------------------------------------------------- //
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
conversionBuffer = nbt.getDouble(Settings.namespace + "ic2power")
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
nbt.setDouble(Settings.namespace + "ic2power", conversionBuffer)
}