Skip to content

Commit

Permalink
Merge pull request #119 from asiekierka/gtnh-oc-1.8.4-20240407
Browse files Browse the repository at this point in the history
Minor fixes from upstream
  • Loading branch information
eigenraven authored Apr 7, 2024
2 parents ca6f4ce + 9d2b2d0 commit ccf61a1
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This mod is [licensed under the **MIT license**](LICENSE). All **assets are publ
4. **Core Scripts**
If you would like to contribute scripts to the "core" Lua code (which basically defines 'OpenOS'), please have a look at the [code conventions][] for Lua to save us all some time. Bug fixes are always welcome. Additional programs and features should be kept small. Bigger programs (rule of thumb: larger than 3KiB) should go onto loot disks.
5. **Drivers**
As of OC 1.4, mod interaction that was previously provided by OpenComponents it now fully integrated into OC itself. If you wish to contribute a driver for blocks from other mods, cool! Have a look at the [integration][] package to get an idea of how to structure modules and read the readme in that package for more information (in particular on additional criteria to get your PR merged).
As of OC 1.4, mod interaction that was previously provided by OpenComponents is now fully integrated into OC itself. If you wish to contribute a driver for blocks from other mods, cool! Have a look at the [integration][] package to get an idea of how to structure modules and read the readme in that package for more information (in particular on additional criteria to get your PR merged).

#### Pull requests
The following are a few quick guidelines on pull requests. That is to say they are not necessarily *rules*, so there may be exceptions and all that. Just try to stick to those points as a baseline.
Expand Down
14 changes: 7 additions & 7 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## Fixes/improvements

* Reworked Internet Card filtering rules.
* Implemented a new, more powerful system and improved default configuration.
* Internet Card rules are now stored in the "internet.filteringRules" configuration key.
* The old keys ("internet.whitelist", "internet.blacklist") are no longer used; an automatic migration is done upon upgrading the mod.
* [#3635] ArrayIndexOutOfBoundsException when using servers with 3 network cards
* [#3634] Internet card selector update logic erroneously drops non-ready keys
* (1.12.2) [#3659] Fixed bug when programatically transferring fluids from specific tanks. (yut23)
* [#3664] Fixed client-side errors when using third-party mod energy integration on an integrated server.
* [#3677] Fixed crash when showing error containing a percent sign with the Analyzer item.
* [#3698] Fixed documentation for the Screen's "turnOn" and "turnOff" functions. (Hawk777, DCNick3)
* [#3691] Improved documentation for software bundled with the "network" floppy. (Computerdores)
* [#3644] Improved forged packet protection with regards to configuring server racks. (Glease)

## List of contributors

asie, Fingercomp
asie, Computerdores, Glease, Hawk777, yut23
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NAME
arp - Inspect local address resolution

SYNOPSIS
arp

DESCRIPTION
Displays the address of each network interface
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ EXAMPLES
Output network status information

ifconfig bind [address]
Binds addnitional address to this device. Address should match [A-Za-z0-9%-]+ and be max 64 characters length
Binds additional address to this device. Address should match [A-Za-z0-9%-]+ and be max 64 characters length

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
NAME
nc - Connect STDIN and STDOUT to the network

SYNOPSIS
nc [-l] port [addr]

DESCRIPTION
Connect STDIN and STDOUT to a network socket so that data can be received from and sent to that socket via STDIN and STDOUT

EXAMPLES
nc -l 1337
Open a socket on port 1337. If another program connects, it can receive from STDIN and send to STDOUT.

nc 1337 host1
Connect to an open socket at address 'host1' on port 1337. The running program can send to STDOUT and receive from STDIN
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NAME
route - Show routing information

SYNOPSIS
route

DESCRIPTION
Displays the contents of the routing table
10 changes: 5 additions & 5 deletions src/main/scala/li/cil/oc/Localization.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import scala.util.matching.Regex
object Localization {
private val nl = Regex.quote("[nl]")

private def resolveKey(key: String) = if (canLocalize(Settings.namespace + key)) Settings.namespace + key else key
private def resolveKey(key: String) = if (canLocalize(Settings.namespace + key)) Option(Settings.namespace + key) else Option.empty

def canLocalize(key: String) = StatCollector.canTranslate(key)

def localizeLater(formatKey: String, values: AnyRef*) = new ChatComponentTranslation(resolveKey(formatKey), values: _*)
def localizeLater(formatKey: String, values: AnyRef*) = new ChatComponentTranslation(resolveKey(formatKey).getOrElse(formatKey), values: _*)

def localizeLater(key: String) = new ChatComponentTranslation(resolveKey(key))
def localizeLater(key: String) = resolveKey(key).map(k => new ChatComponentTranslation(k)).getOrElse(new ChatComponentText(key))

def localizeImmediately(formatKey: String, values: AnyRef*) = StatCollector.translateToLocalFormatted(resolveKey(formatKey), values: _*).split(nl).map(_.trim).mkString("\n")
def localizeImmediately(formatKey: String, values: AnyRef*) = StatCollector.translateToLocalFormatted(resolveKey(formatKey).getOrElse(formatKey), values: _*).split(nl).map(_.trim).mkString("\n")

def localizeImmediately(key: String) = StatCollector.translateToLocal(resolveKey(key)).split(nl).map(_.trim).mkString("\n")
def localizeImmediately(key: String) = resolveKey(key).map(k => StatCollector.translateToLocal(k)).getOrElse(key).split(nl).map(_.trim).mkString("\n")

object Analyzer {
def Address(value: String) = {
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/li/cil/oc/common/component/TextBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ class TextBuffer(val host: EnvironmentHost) extends prefab.ManagedEnvironment wi
@Callback(direct = true, doc = """function():boolean -- Returns whether the screen is currently on.""")
def isOn(computer: Context, args: Arguments): Array[AnyRef] = result(isDisplaying)

@Callback(doc = """function():boolean -- Turns the screen on. Returns true if it was off.""")
@Callback(doc = """function():boolean -- Turns the screen on. Returns whether the state changed, and whether it is now on.""")
def turnOn(computer: Context, args: Arguments): Array[AnyRef] = {
val oldPowerState = isDisplaying
setPowerState(value = true)
result(isDisplaying != oldPowerState, isDisplaying)
}

@Callback(doc = """function():boolean -- Turns off the screen. Returns true if it was on.""")
@Callback(doc = """function():boolean -- Turns off the screen. Returns whether the state changed, and whether it is now on.""")
def turnOff(computer: Context, args: Arguments): Array[AnyRef] = {
val oldPowerState = isDisplaying
setPowerState(value = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import scala.collection.convert.WrapAsJava._

@Injectable.Interface(value = "appeng.api.networking.IGridHost", modid = Mods.IDs.AppliedEnergistics2)
trait AppliedEnergistics2 extends Common {
private lazy val useAppliedEnergistics2Power = isServer && Mods.AppliedEnergistics2.isAvailable
private def useAppliedEnergistics2Power() = isServer && Mods.AppliedEnergistics2.isAvailable

// 'Manual' lazy val, because lazy vals mess up the class loader, leading to class not found exceptions.
private var node: Option[AnyRef] = None
Expand Down Expand Up @@ -52,24 +52,24 @@ trait AppliedEnergistics2 extends Common {

override def validate() {
super.validate()
if (useAppliedEnergistics2Power) EventHandler.scheduleAE2Add(this)
if (useAppliedEnergistics2Power()) EventHandler.scheduleAE2Add(this)
}

override def invalidate() {
super.invalidate()
if (useAppliedEnergistics2Power) securityBreak()
if (useAppliedEnergistics2Power()) securityBreak()
}

override def onChunkUnload() {
super.onChunkUnload()
if (useAppliedEnergistics2Power) securityBreak()
if (useAppliedEnergistics2Power()) securityBreak()
}

// ----------------------------------------------------------------------- //

override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
if (useAppliedEnergistics2Power) loadNode(nbt)
if (useAppliedEnergistics2Power()) loadNode(nbt)
}

@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
Expand All @@ -79,7 +79,7 @@ trait AppliedEnergistics2 extends Common {

override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
if (useAppliedEnergistics2Power) saveNode(nbt)
if (useAppliedEnergistics2Power()) saveNode(nbt)
}

@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import net.minecraft.nbt.NBTTagCompound

@Injectable.Interface(value = "factorization.api.IChargeConductor", modid = Mods.IDs.Factorization)
trait Factorization extends Common {
private lazy val useFactorizationPower = isServer && Mods.Factorization.isAvailable
private def useFactorizationPower() = isServer && Mods.Factorization.isAvailable

@Optional.Method(modid = Mods.IDs.Factorization)
private lazy val charge: AnyRef = this match {
Expand All @@ -26,7 +26,7 @@ trait Factorization extends Common {
// ----------------------------------------------------------------------- //

override def updateEntity() {
if (useFactorizationPower) updateEnergy()
if (useFactorizationPower()) updateEnergy()
super.updateEntity()
}

Expand All @@ -39,7 +39,7 @@ trait Factorization extends Common {
}

override def invalidate() {
if (useFactorizationPower) invalidateCharge()
if (useFactorizationPower()) invalidateCharge()
super.invalidate()
}

Expand All @@ -49,7 +49,7 @@ trait Factorization extends Common {
}

override def onChunkUnload() {
if (useFactorizationPower) removeCharge()
if (useFactorizationPower()) removeCharge()
super.onChunkUnload()
}

Expand All @@ -62,7 +62,7 @@ trait Factorization extends Common {

override def readFromNBTForServer(nbt: NBTTagCompound) {
super.readFromNBTForServer(nbt)
if (useFactorizationPower) loadCharge(nbt)
if (useFactorizationPower()) loadCharge(nbt)
}

@Optional.Method(modid = Mods.IDs.Factorization)
Expand All @@ -72,7 +72,7 @@ trait Factorization extends Common {

override def writeToNBTForServer(nbt: NBTTagCompound) {
super.writeToNBTForServer(nbt)
if (useFactorizationPower) saveCharge(nbt)
if (useFactorizationPower()) saveCharge(nbt)
}

@Optional.Method(modid = Mods.IDs.Factorization)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import net.minecraftforge.common.util.ForgeDirection
trait IndustrialCraft2Classic extends Common with IndustrialCraft2Common {
private var conversionBuffer = 0.0

private lazy val useIndustrialCraft2ClassicPower = isServer && Mods.IndustrialCraft2Classic.isAvailable
private def useIndustrialCraft2ClassicPower() = isServer && Mods.IndustrialCraft2Classic.isAvailable

// ----------------------------------------------------------------------- //

override def updateEntity() {
super.updateEntity()
if (useIndustrialCraft2ClassicPower && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
if (useIndustrialCraft2ClassicPower() && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
updateEnergy()
}
}
Expand All @@ -40,17 +40,17 @@ trait IndustrialCraft2Classic extends Common with IndustrialCraft2Common {

override def validate() {
super.validate()
if (useIndustrialCraft2ClassicPower && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
if (useIndustrialCraft2ClassicPower() && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
}

override def invalidate() {
super.invalidate()
if (useIndustrialCraft2ClassicPower && addedToIC2PowerGrid) removeFromIC2Grid()
if (useIndustrialCraft2ClassicPower() && addedToIC2PowerGrid) removeFromIC2Grid()
}

override def onChunkUnload() {
super.onChunkUnload()
if (useIndustrialCraft2ClassicPower && addedToIC2PowerGrid) removeFromIC2Grid()
if (useIndustrialCraft2ClassicPower() && addedToIC2PowerGrid) removeFromIC2Grid()
}

private def removeFromIC2Grid() {
Expand Down Expand Up @@ -91,7 +91,7 @@ trait IndustrialCraft2Classic extends Common with IndustrialCraft2Common {

@Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
def demandsEnergy: Int = {
if (!useIndustrialCraft2ClassicPower) 0
if (!useIndustrialCraft2ClassicPower()) 0
else if (conversionBuffer < energyThroughput * Settings.get.tickFrequency)
math.min(ForgeDirection.VALID_DIRECTIONS.map(globalDemand).max, Power.toEU(energyThroughput)).toInt
else 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import net.minecraftforge.common.util.ForgeDirection
trait IndustrialCraft2Experimental extends Common with IndustrialCraft2Common {
private var conversionBuffer = 0.0

private lazy val useIndustrialCraft2Power = isServer && Mods.IndustrialCraft2.isAvailable
private def useIndustrialCraft2Power() = isServer && Mods.IndustrialCraft2.isAvailable

// ----------------------------------------------------------------------- //

override def updateEntity() {
super.updateEntity()
if (useIndustrialCraft2Power && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
if (useIndustrialCraft2Power() && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
updateEnergy()
}
}
Expand All @@ -38,17 +38,17 @@ trait IndustrialCraft2Experimental extends Common with IndustrialCraft2Common {

override def validate() {
super.validate()
if (useIndustrialCraft2Power && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
if (useIndustrialCraft2Power() && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
}

override def invalidate() {
super.invalidate()
if (useIndustrialCraft2Power && addedToIC2PowerGrid) removeFromIC2Grid()
if (useIndustrialCraft2Power() && addedToIC2PowerGrid) removeFromIC2Grid()
}

override def onChunkUnload() {
super.onChunkUnload()
if (useIndustrialCraft2Power && addedToIC2PowerGrid) removeFromIC2Grid()
if (useIndustrialCraft2Power() && addedToIC2PowerGrid) removeFromIC2Grid()
}

private def removeFromIC2Grid() {
Expand Down Expand Up @@ -86,7 +86,7 @@ trait IndustrialCraft2Experimental extends Common with IndustrialCraft2Common {

@Optional.Method(modid = Mods.IDs.IndustrialCraft2)
def getDemandedEnergy: Double = {
if (!useIndustrialCraft2Power) 0.0
if (!useIndustrialCraft2Power()) 0.0
else if (conversionBuffer < energyThroughput * Settings.get.tickFrequency)
math.min(ForgeDirection.VALID_DIRECTIONS.map(globalDemand).max, Power.toEU(energyThroughput))
else 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import net.minecraftforge.common.util.ForgeDirection

@Injectable.Interface(value = "Reika.RotaryCraft.API.Power.ShaftPowerReceiver", modid = Mods.IDs.RotaryCraft)
trait RotaryCraft extends Common {
private lazy val useRotaryCraftPower = isServer && Mods.RotaryCraft.isAvailable
private def useRotaryCraftPower() = isServer && Mods.RotaryCraft.isAvailable

private var omega = 0
private var torque = 0
Expand All @@ -20,7 +20,7 @@ trait RotaryCraft extends Common {
// ----------------------------------------------------------------------- //

override def updateEntity() {
if (useRotaryCraftPower) updateEnergy()
if (useRotaryCraftPower()) updateEnergy()
super.updateEntity()
}

Expand Down

0 comments on commit ccf61a1

Please sign in to comment.