mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-21 20:52:18 +00:00
Fixed crash when IC2 is not installed (again...)
This commit is contained in:
1 parent
ccae98e6f8
commit
3eb4206b8e
1 file changed
+16
-11
@@ -26,25 +26,22 @@ trait TilePoweredEU extends TilePoweredBase with IEnergySink {
|
||||
private lazy val ratio = Tuning.getSection("Power").getFloat("EU_MJ_Ratio")
|
||||
lazy val maxSafe = Tuning.getSection("Power").getSection("IC2").getInt("MaxSafeInput")
|
||||
|
||||
if (PowerProxy.haveIC2 && PowerProxy.EUEnabled) {
|
||||
serverTick.listen(() => {
|
||||
if (!sentLoaded) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this))
|
||||
sentLoaded = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (PowerProxy.haveIC2 && PowerProxy.EUEnabled)
|
||||
serverTick.listen(sendLoad)
|
||||
|
||||
override def invalidate() {
|
||||
sendUnload()
|
||||
if (PowerProxy.haveIC2 && PowerProxy.EUEnabled)
|
||||
sendUnload()
|
||||
super.invalidate()
|
||||
}
|
||||
|
||||
override def onChunkUnload() = {
|
||||
sendUnload()
|
||||
override def onChunkUnload() {
|
||||
if (PowerProxy.haveIC2 && PowerProxy.EUEnabled)
|
||||
sendUnload()
|
||||
super.onChunkUnload()
|
||||
}
|
||||
|
||||
@Optional.Method(modid = PowerProxy.IC2_MOD_ID)
|
||||
def sendUnload() {
|
||||
if (PowerProxy.haveIC2 && sentLoaded) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this))
|
||||
@@ -52,6 +49,14 @@ trait TilePoweredEU extends TilePoweredBase with IEnergySink {
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = PowerProxy.IC2_MOD_ID)
|
||||
def sendLoad() {
|
||||
if (PowerProxy.haveIC2 && !sentLoaded) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this))
|
||||
sentLoaded = true
|
||||
}
|
||||
}
|
||||
|
||||
def acceptsEnergyFrom(emitter: TileEntity, direction: ForgeDirection) = PowerProxy.EUEnabled
|
||||
def getMaxSafeInput = maxSafe
|
||||
def demandedEnergyUnits() = Misc.clamp(power.capacity - power.stored, 0F, power.maxReceive) * ratio
|
||||
|
||||
Reference in new issue
Block a user