The Optional.Method annotation seems to not work in dev-env in some cases... trying to work around that to fix absence of FMP and Waila related crashes in dev-env.

This commit is contained in:
Florian Nücke 2014-07-17 16:02:36 +02:00
parent c1d5371738
commit 93218f4ff7
5 changed files with 34 additions and 25 deletions

View File

@ -30,38 +30,46 @@ import scala.collection.mutable
object EventHandler extends ITickHandler with IConnectionHandler with ICraftingHandler {
val pending = mutable.Buffer.empty[() => Unit]
def schedule(tileEntity: TileEntity) =
def schedule(tileEntity: TileEntity) {
if (FMLCommonHandler.instance.getEffectiveSide.isServer) pending.synchronized {
pending += (() => Network.joinOrCreateNetwork(tileEntity))
}
}
@Optional.Method(modid = "ForgeMultipart")
def schedule(part: TMultiPart) =
def schedule(tileEntity: () => TileEntity) {
if (FMLCommonHandler.instance.getEffectiveSide.isServer) pending.synchronized {
pending += (() => Network.joinOrCreateNetwork(part.tile))
pending += (() => Network.joinOrCreateNetwork(tileEntity()))
}
@Optional.Method(modid = "IC2")
def scheduleIC2Add(tileEntity: power.IndustrialCraft2) = if (FMLCommonHandler.instance.getEffectiveSide.isServer) pending.synchronized {
pending += (() => if (!tileEntity.addedToPowerGrid && !tileEntity.isInvalid) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(tileEntity))
tileEntity.addedToPowerGrid = true
})
}
@Optional.Method(modid = "IC2")
def scheduleIC2Remove(tileEntity: power.IndustrialCraft2) = if (FMLCommonHandler.instance.getEffectiveSide.isServer) pending.synchronized {
pending += (() => if (tileEntity.addedToPowerGrid) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(tileEntity))
tileEntity.addedToPowerGrid = false
})
def scheduleIC2Add(tileEntity: power.IndustrialCraft2) {
if (FMLCommonHandler.instance.getEffectiveSide.isServer) pending.synchronized {
pending += (() => if (!tileEntity.addedToPowerGrid && !tileEntity.isInvalid) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(tileEntity))
tileEntity.addedToPowerGrid = true
})
}
}
def scheduleWirelessRedstone(rs: server.component.RedstoneWireless) = if (FMLCommonHandler.instance.getEffectiveSide.isServer) pending.synchronized {
pending += (() => if (!rs.owner.isInvalid) {
mods.WirelessRedstone.addReceiver(rs)
mods.WirelessRedstone.updateOutput(rs)
})
@Optional.Method(modid = "IC2")
def scheduleIC2Remove(tileEntity: power.IndustrialCraft2) {
if (FMLCommonHandler.instance.getEffectiveSide.isServer) pending.synchronized {
pending += (() => if (tileEntity.addedToPowerGrid) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(tileEntity))
tileEntity.addedToPowerGrid = false
})
}
}
def scheduleWirelessRedstone(rs: server.component.RedstoneWireless) {
if (FMLCommonHandler.instance.getEffectiveSide.isServer) pending.synchronized {
pending += (() => if (!rs.owner.isInvalid) {
mods.WirelessRedstone.addReceiver(rs)
mods.WirelessRedstone.updateOutput(rs)
})
}
}
override def getLabel = "OpenComputers Network Initialization Ticker"

View File

@ -43,7 +43,7 @@ class CablePart(val original: Option[Node] = None) extends DelegatePart with TCu
override def onWorldJoin() {
super.onWorldJoin()
common.EventHandler.schedule(this)
common.EventHandler.schedule(() => tile)
}
override def onWorldSeparate() {

View File

@ -8,7 +8,7 @@ import li.cil.oc.api.network.{Analyzable, Connector, Node, Visibility}
import li.cil.oc.client.Sound
import li.cil.oc.server.{component, driver, PacketSender => ServerPacketSender}
import li.cil.oc.util.ExtendedNBT._
import li.cil.oc.util.mods.Waila
import li.cil.oc.util.mods.{Mods, Waila}
import li.cil.oc.{Localization, Settings, api, common}
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
@ -261,7 +261,7 @@ class Rack extends traits.PowerAcceptor with traits.Hub with traits.PowerBalance
// Side check for Waila (and other mods that may call this client side).
override def writeToNBT(nbt: NBTTagCompound) = if (isServer) {
if (!Waila.isSavingForTooltip) {
if (!Mods.Waila.isAvailable || !Waila.isSavingForTooltip) {
nbt.setNewTagList(Settings.namespace + "servers", servers map {
case Some(server) =>
val serverNbt = new NBTTagCompound()

View File

@ -9,7 +9,7 @@ import li.cil.oc.client.Sound
import li.cil.oc.common.tileentity.RobotProxy
import li.cil.oc.server.{driver, PacketSender => ServerPacketSender}
import li.cil.oc.util.ExtendedNBT._
import li.cil.oc.util.mods.Waila
import li.cil.oc.util.mods.{Mods, Waila}
import li.cil.oc.{Localization, Settings}
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.nbt.{NBTTagCompound, NBTTagString}
@ -148,7 +148,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
if (computer != null && !Waila.isSavingForTooltip) {
if (computer != null && (!Mods.Waila.isAvailable || !Waila.isSavingForTooltip)) {
nbt.setNewCompoundTag(Settings.namespace + "computer", computer.save)
}
}

View File

@ -36,6 +36,7 @@ object Mods {
val ThermalExpansion = new SimpleMod("ThermalExpansion")
val TinkersConstruct = new SimpleMod("TConstruct")
val UniversalElectricity = new SimpleMod("UniversalElectricity@[3.1,)")
val Waila = new SimpleMod("Waila")
val WirelessRedstoneCBE = new SimpleMod("WR-CBE|Core")
val WirelessRedstoneSV = new SimpleMod("WirelessRedstoneCore")