Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8

Conflicts:
	src/main/scala/li/cil/oc/client/Proxy.scala
This commit is contained in:
Florian Nücke 2015-05-31 14:19:26 +02:00
commit ce3b9e42a1
3 changed files with 35 additions and 22 deletions

View File

@ -34,9 +34,7 @@ private[oc] class Proxy extends CommonProxy {
api.API.manual = client.Manual
MinecraftForge.EVENT_BUS.register(Sound)
MinecraftForge.EVENT_BUS.register(Textures)
MinecraftForge.EVENT_BUS.register(HighlightRenderer)
ModelInitialization.preInit()
}
@ -73,8 +71,10 @@ private[oc] class Proxy extends CommonProxy {
ClientRegistry.registerKeyBinding(KeyBindings.materialCosts)
ClientRegistry.registerKeyBinding(KeyBindings.clipboardPaste)
MinecraftForge.EVENT_BUS.register(HighlightRenderer)
MinecraftForge.EVENT_BUS.register(PetRenderer)
MinecraftForge.EVENT_BUS.register(ServerRack)
MinecraftForge.EVENT_BUS.register(Sound)
MinecraftForge.EVENT_BUS.register(TextBuffer)
MinecraftForge.EVENT_BUS.register(WirelessNetworkDebugRenderer)
@ -83,6 +83,7 @@ private[oc] class Proxy extends CommonProxy {
FMLCommonHandler.instance.bus.register(Audio)
FMLCommonHandler.instance.bus.register(HologramRenderer)
FMLCommonHandler.instance.bus.register(PetRenderer)
FMLCommonHandler.instance.bus.register(Sound)
FMLCommonHandler.instance.bus.register(TextBufferRenderCache)
}

View File

@ -40,12 +40,16 @@ object Sound {
if (Settings.get.soundVolume > 0) {
updateTimer.scheduleAtFixedRate(new TimerTask {
override def run() {
updateVolume()
processQueue()
sources.synchronized(updateCallable = Some(() => {
updateVolume()
processQueue()
}))
}
}, 500, 50)
}
private var updateCallable = None: Option[() => Unit]
// Set in init event.
var manager: SoundManager = _
@ -115,26 +119,33 @@ object Sound {
@SubscribeEvent
def onTick(e: ClientTickEvent) {
if (!hasPreloaded && soundSystem != null) {
hasPreloaded = true
new Thread(new Runnable() {
override def run(): Unit = {
val preloadConfigLocation = new ResourceLocation(Settings.resourceDomain, "sounds/preload.cfg")
val preloadConfigResource = Minecraft.getMinecraft.getResourceManager.getResource(preloadConfigLocation)
for (location <- Source.fromInputStream(preloadConfigResource.getInputStream)(Charsets.UTF_8).getLines()) {
val url = getClass.getClassLoader.getResource(location)
if (url != null) try {
val sourceName = "preload_" + location
soundSystem.newSource(false, sourceName, url, location, true, 0, 0, 0, SoundSystemConfig.ATTENUATION_NONE, 16)
soundSystem.activate(sourceName)
soundSystem.removeSource(sourceName)
} catch {
case _: Throwable => // Meh.
if (soundSystem != null) {
if (!hasPreloaded) {
hasPreloaded = true
new Thread(new Runnable() {
override def run(): Unit = {
val preloadConfigLocation = new ResourceLocation(Settings.resourceDomain, "sounds/preload.cfg")
val preloadConfigResource = Minecraft.getMinecraft.getResourceManager.getResource(preloadConfigLocation)
for (location <- Source.fromInputStream(preloadConfigResource.getInputStream)(Charsets.UTF_8).getLines()) {
val url = getClass.getClassLoader.getResource(location)
if (url != null) try {
val sourceName = "preload_" + location
soundSystem.newSource(false, sourceName, url, location, true, 0, 0, 0, SoundSystemConfig.ATTENUATION_NONE, 16)
soundSystem.activate(sourceName)
soundSystem.removeSource(sourceName)
} catch {
case _: Throwable => // Meh.
}
else OpenComputers.log.warn(s"Couldn't preload sound $location!")
}
else OpenComputers.log.warn(s"Couldn't preload sound $location!")
}
}
})
})
}
sources.synchronized {
updateCallable.foreach(_())
updateCallable = None
}
}
}

View File

@ -132,6 +132,7 @@ class Microcontroller extends traits.PowerAcceptor with traits.Hub with traits.C
override protected def connectItemNode(node: Node) {
if (machine.node != null && node != null) {
api.Network.joinNewNetwork(machine.node)
machine.node.connect(node)
}
}