Skip to content

Commit

Permalink
fix #3664
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Apr 7, 2024
1 parent 690e8d7 commit a8fdfee
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
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 a8fdfee

Please sign in to comment.