mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-19 04:06:43 -04:00
adjustments for 1.7
This commit is contained in:
parent
ac034907fe
commit
9c3e6fca80
@ -1,28 +0,0 @@
|
||||
package li.cil.oc.server
|
||||
|
||||
import cpw.mods.fml.common.{TickType, ITickHandler}
|
||||
import java.util
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.common.tileentity.TileEntity
|
||||
import scala.collection.mutable
|
||||
|
||||
object TickHandler extends ITickHandler {
|
||||
val pendingAdds = mutable.Buffer.empty[() => Unit]
|
||||
|
||||
def schedule(tileEntity: TileEntity) = pendingAdds.synchronized {
|
||||
pendingAdds += (() => if (!tileEntity.isInvalid) api.Network.joinOrCreateNetwork(tileEntity))
|
||||
}
|
||||
|
||||
override def getLabel = "OpenComputers Network Initialization Ticker"
|
||||
|
||||
override def ticks() = util.EnumSet.of(TickType.SERVER)
|
||||
|
||||
override def tickStart(`type`: util.EnumSet[TickType], tickData: AnyRef*) {}
|
||||
|
||||
override def tickEnd(`type`: util.EnumSet[TickType], tickData: AnyRef*) = pendingAdds.synchronized {
|
||||
for (callback <- pendingAdds) {
|
||||
callback()
|
||||
}
|
||||
pendingAdds.clear()
|
||||
}
|
||||
}
|
@ -1,18 +1,36 @@
|
||||
package li.cil.oc.common
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.{Event, SubscribeEvent}
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent._
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent
|
||||
import cpw.mods.fml.common.{Loader, FMLCommonHandler}
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.server.driver.Registry
|
||||
import li.cil.oc.util.LuaStateFactory
|
||||
import li.cil.oc.{Items, Settings}
|
||||
import li.cil.oc.util.ExtendedNBT._
|
||||
import li.cil.oc.util.LuaStateFactory
|
||||
import li.cil.oc.util.mods.ProjectRed
|
||||
import net.minecraft.entity.player.{EntityPlayerMP, EntityPlayer}
|
||||
import li.cil.oc.{Items, Settings}
|
||||
import net.minecraft.entity.player.EntityPlayerMP
|
||||
import net.minecraft.item.{ItemMap, ItemStack}
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.{ChatComponentTranslation, ChatComponentText}
|
||||
import scala.collection.mutable
|
||||
|
||||
object EventHandler {
|
||||
val pendingAdds = mutable.Buffer.empty[() => Unit]
|
||||
|
||||
def schedule(tileEntity: TileEntity) = pendingAdds.synchronized {
|
||||
pendingAdds += (() => if (!tileEntity.isInvalid) api.Network.joinOrCreateNetwork(tileEntity))
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
def onTick(e: ServerTickEvent) = pendingAdds.synchronized {
|
||||
for (callback <- pendingAdds) {
|
||||
callback()
|
||||
}
|
||||
pendingAdds.clear()
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
def playerLoggedIn(e: PlayerLoggedInEvent) {
|
||||
if (FMLCommonHandler.instance.getEffectiveSide.isServer) e.player match {
|
||||
|
@ -7,7 +7,7 @@ import li.cil.oc._
|
||||
import li.cil.oc.common.asm.SimpleComponentTickHandler
|
||||
import li.cil.oc.server
|
||||
import li.cil.oc.server.network.Network
|
||||
import li.cil.oc.server.{TickHandler, driver, fs, network}
|
||||
import li.cil.oc.server.{driver, fs, network}
|
||||
import li.cil.oc.util.WirelessNetwork
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
|
||||
@ -49,8 +49,6 @@ class Proxy {
|
||||
// Don't allow driver registration after this point, to avoid issues.
|
||||
driver.Registry.locked = true
|
||||
|
||||
TickRegistry.registerTickHandler(TickHandler, Side.SERVER)
|
||||
NetworkRegistry.instance.registerConnectionHandler(ConnectionHandler)
|
||||
FMLCommonHandler.instance().bus().register(EventHandler)
|
||||
FMLCommonHandler.instance().bus().register(SimpleComponentTickHandler.Instance)
|
||||
MinecraftForge.EVENT_BUS.register(Network)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package li.cil.oc.common.tileentity
|
||||
|
||||
import li.cil.oc.api.network.{Analyzable, Visibility}
|
||||
import li.cil.oc.server.TickHandler
|
||||
import li.cil.oc.common.EventHandler
|
||||
import li.cil.oc.{api, common}
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
|
||||
@ -16,7 +16,7 @@ class Cable extends Environment with Analyzable with PassiveNode {
|
||||
|
||||
override def validate() {
|
||||
super.validate()
|
||||
TickHandler.schedule(this)
|
||||
EventHandler.schedule(this)
|
||||
}
|
||||
|
||||
override def getRenderBoundingBox = common.block.Cable.bounds(world, x, y, z).offset(x, y, z)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package li.cil.oc.common.tileentity
|
||||
|
||||
import li.cil.oc.api.network.Visibility
|
||||
import li.cil.oc.server.TickHandler
|
||||
import li.cil.oc.common.EventHandler
|
||||
import li.cil.oc.{Settings, api}
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import scala.collection.convert.WrapAsScala._
|
||||
@ -17,7 +17,7 @@ class Capacitor extends Environment with PassiveNode {
|
||||
|
||||
override def validate() {
|
||||
super.validate()
|
||||
TickHandler.schedule(this)
|
||||
EventHandler.schedule(this)
|
||||
}
|
||||
|
||||
override def invalidate() {
|
||||
|
@ -2,7 +2,7 @@ package li.cil.oc.common.tileentity
|
||||
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.network.{Analyzable, Component, Visibility}
|
||||
import li.cil.oc.server.TickHandler
|
||||
import li.cil.oc.common.EventHandler
|
||||
import li.cil.oc.server.driver.Registry
|
||||
import li.cil.oc.{api, Settings}
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
@ -23,7 +23,7 @@ class DiskDrive extends Environment with ComponentInventory with Rotatable with
|
||||
|
||||
override def validate() = {
|
||||
super.validate()
|
||||
TickHandler.schedule(this)
|
||||
EventHandler.schedule(this)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
@ -1,9 +1,10 @@
|
||||
package li.cil.oc.common.tileentity
|
||||
|
||||
import cpw.mods.fml.relauncher.{SideOnly, Side}
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api.network.{Analyzable, SidedEnvironment}
|
||||
import li.cil.oc.server.{TickHandler, component}
|
||||
import li.cil.oc.common.EventHandler
|
||||
import li.cil.oc.server.component
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.util.ExtendedNBT._
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
@ -43,7 +44,7 @@ class Keyboard(isRemote: Boolean) extends Environment with SidedEnvironment with
|
||||
|
||||
override def validate() {
|
||||
super.validate()
|
||||
TickHandler.schedule(this)
|
||||
EventHandler.schedule(this)
|
||||
}
|
||||
|
||||
override def readFromNBT(nbt: NBTTagCompound) {
|
||||
|
@ -3,7 +3,7 @@ package li.cil.oc.common.tileentity
|
||||
import cpw.mods.fml.common.{Loader, Optional}
|
||||
import dan200.computer.api.{ILuaContext, IComputerAccess, IPeripheral}
|
||||
import li.cil.oc.api.network.Message
|
||||
import li.cil.oc.server.TickHandler
|
||||
import li.cil.oc.common.EventHandler
|
||||
import scala.collection.mutable
|
||||
|
||||
@Optional.Interface(iface = "dan200.computer.api.IPeripheral", modid = "ComputerCraft")
|
||||
@ -13,7 +13,7 @@ class Router extends Hub with IPeripheral with PassiveNode {
|
||||
|
||||
override def validate() {
|
||||
super.validate()
|
||||
TickHandler.schedule(this)
|
||||
EventHandler.schedule(this)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
Loading…
x
Reference in New Issue
Block a user