diff --git a/build.properties b/build.properties index 25b814f5c..7c54c89e6 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ minecraft.version=1.8 forge.version=11.14.1.1313 -oc.version=1.5.0 +oc.version=1.5.1 oc.subversion=beta ae2.version=rv1-stable-1 diff --git a/src/main/resources/assets/opencomputers/lang/de_DE.lang b/src/main/resources/assets/opencomputers/lang/de_DE.lang index 7767f84d3..6e3375830 100644 --- a/src/main/resources/assets/opencomputers/lang/de_DE.lang +++ b/src/main/resources/assets/opencomputers/lang/de_DE.lang @@ -195,7 +195,7 @@ oc:tooltip.Cable=Ein billiger Weg, verschiedene Blöcke miteinander zu verbinden oc:tooltip.Capacitor=Speichert Energie für spätere Verwendung. Kann extrem schnell befüllt und entleert werden. oc:tooltip.CardBase=Wie der Name schon sagt, werden alle Erweiterungskarten hieraus hergestellt. oc:tooltip.Case=Das Computergehäuse ist der essentielle Grundbaustein für einen Computer. §fErweiterungskarten§7, §fRAM§7 und §fFestplatten§7 können in einem Gehäuse installiert werden.[nl] Slots: §f%s§7 -oc:tooltip.Charger=Lädt Roboter mit Energie aus Kondensatoren auf. Die Ladegeschwindigkeit hängt vom eingehenden §fRedstonesignal§7 ab, wobei kein Signal "nicht laden" und ein Signal mit maximaler Stärke "schnellstmöglich laden" heißt. +oc:tooltip.Charger=Lädt Roboter mit Energie aus Kondensatoren auf. Die Ladegeschwindigkeit hängt vom eingehenden §fRedstonesignal§7 ab, wobei kein Signal "nicht laden" und ein Signal mit maximaler Stärke "schnellstmöglich laden" heißt. Erlaubt es auch Tablets zu laden, und ermöglicht Zugriff auf Festplatten in Tablets. oc:tooltip.CircuitBoard=Mühsam ernährt sich das Eichhörnchen. Wenn es groß wird, wird es mal eine gedruckte Leiterplatte. oc:tooltip.ControlUnit=Klingt wichtig, ist es auch. Man baut daraus immerhin CPUs. Wie könnte es da nicht wichtig sein. oc:tooltip.ComponentBus=Diese Erweiterung erlaubt es es Servern, mit noch mehr Komponenten gleichzeitig zu kommunizieren, ähnlich wie CPUs.[nl] Supported components: §f%s§7 diff --git a/src/main/resources/assets/opencomputers/lang/en_US.lang b/src/main/resources/assets/opencomputers/lang/en_US.lang index 00b969c49..8f2712151 100644 --- a/src/main/resources/assets/opencomputers/lang/en_US.lang +++ b/src/main/resources/assets/opencomputers/lang/en_US.lang @@ -219,7 +219,7 @@ oc:tooltip.Cable=A cheap way of connecting blocks. oc:tooltip.Capacitor=Stores energy for later use. Can be filled and emptied very quickly. oc:tooltip.CardBase=As the name indicates, this is the basic building block for all expansion cards. oc:tooltip.Case=The Computer Case is the basic building block for computers and houses the computer's §fextension cards§7, §fRAM§7 and §fhard disks§7.[nl] Slots: §f%s§7 -oc:tooltip.Charger=Transfers energy from capacitors into adjacent robots and drones. The transfer rate depends on the incoming §fredstone signal§7, where no signal means don't charge devices, and maximum strength means charge at full speed. +oc:tooltip.Charger=Transfers energy from capacitors into adjacent robots and drones. The transfer rate depends on the incoming §fredstone signal§7, where no signal means don't charge devices, and maximum strength means charge at full speed. Can also be used to charge tablets and access hard drives in tablets. oc:tooltip.CircuitBoard=Now we're getting somewhere. Can be etched to obtain a printed circuit board. oc:tooltip.ControlUnit=This is the unit that... controls... stuff. You need it to build a CPU. So yeah, totally important. oc:tooltip.ComponentBus=This expansion allows servers to communicate with more components at the same time, similar to how CPUs do.[nl] Supported components: §f%s§7 diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/df b/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/df index eb8a3b82d..5fc6e477f 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/df +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/df @@ -5,7 +5,7 @@ SYNOPSIS df [FILE]... DESCRIPTION - `cp` allows copying single files on a filesystem and across filesystems. + `df` outputs disk space information for the file systems containing the specified files. If no file names are given it returns the information for all currently mounted file systems. EXAMPLES df diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/primary b/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/primary index 6eedccd42..b868f738a 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/primary +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/primary @@ -6,7 +6,7 @@ SYNOPSIS primary TYPE ADDRESS DESCRIPTION - This program allows reading the address of the current primary component of the specified type. It also allows chaning the current primary component for a specified type by providing the (abbreviated) address of the new primary component. + This program allows reading the address of the current primary component of the specified type. It also allows changing the current primary component for a specified type by providing the (abbreviated) address of the new primary component. EXAMPLES primary gpu diff --git a/src/main/scala/li/cil/oc/common/SaveHandler.scala b/src/main/scala/li/cil/oc/common/SaveHandler.scala index 2b4c6e8e4..0fe41c1da 100644 --- a/src/main/scala/li/cil/oc/common/SaveHandler.scala +++ b/src/main/scala/li/cil/oc/common/SaveHandler.scala @@ -83,11 +83,16 @@ object SaveHandler { def loadNBT(nbt: NBTTagCompound, name: String): NBTTagCompound = { val data = load(nbt, name) - if (data.length > 0) { + if (data.length > 0) try { val bais = new ByteArrayInputStream(data) val dis = new DataInputStream(bais) CompressedStreamTools.read(dis) } + catch { + case t: Throwable => + OpenComputers.log.warn("There was an error trying to restore a block's state from external data. This indicates that data was somehow corrupted.", t) + new NBTTagCompound() + } else new NBTTagCompound() } diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala index e8db36d37..96aa2ef73 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala @@ -1,5 +1,6 @@ package li.cil.oc.common.tileentity.traits +import li.cil.oc.Settings import li.cil.oc.server.{PacketSender => ServerPacketSender} import net.minecraft.nbt.NBTTagCompound import net.minecraftforge.fml.relauncher.Side @@ -8,6 +9,8 @@ import net.minecraftforge.fml.relauncher.SideOnly trait PowerInformation extends TileEntity { private var lastSentRatio = -1.0 + private var ticksUntilSync = 0 + def globalBuffer: Double def globalBuffer_=(value: Double): Unit @@ -18,12 +21,23 @@ trait PowerInformation extends TileEntity { protected def updatePowerInformation() { val ratio = if (globalBufferSize > 0) globalBuffer / globalBufferSize else 0 - if (lastSentRatio < 0 || math.abs(lastSentRatio - ratio) > (5.0 / 100.0)) { + if (shouldSync(ratio) || hasChangedSignificantly(ratio)) { lastSentRatio = ratio ServerPacketSender.sendPowerState(this) } } + private def hasChangedSignificantly(ratio: Double) = lastSentRatio < 0 || math.abs(lastSentRatio - ratio) > (5.0 / 100.0) + + private def shouldSync(ratio: Double) = { + ticksUntilSync -= 1 + if (ticksUntilSync <= 0) { + ticksUntilSync = (100 / Settings.get.tickFrequency).toInt max 1 + lastSentRatio != ratio + } + else false + } + @SideOnly(Side.CLIENT) override def readFromNBTForClient(nbt: NBTTagCompound) { super.readFromNBTForClient(nbt) diff --git a/src/main/scala/li/cil/oc/server/PacketSender.scala b/src/main/scala/li/cil/oc/server/PacketSender.scala index d6107aa44..214f3f7e6 100644 --- a/src/main/scala/li/cil/oc/server/PacketSender.scala +++ b/src/main/scala/li/cil/oc/server/PacketSender.scala @@ -212,7 +212,7 @@ object PacketSender { val pb = new SimplePacketBuilder(PacketType.PowerState) pb.writeTileEntity(t) - pb.writeDouble(t.globalBuffer) + pb.writeDouble(math.round(t.globalBuffer)) pb.writeDouble(t.globalBufferSize) pb.sendToPlayersNearTileEntity(t)