Increase "duration" to keep potion effects at to make stuff work that needs time to activate (such as nausea and nightvision), make it instantly stop on disabling instead.

Fixed onEnable/onDisable callbacks.
This commit is contained in:
Florian Nücke 2015-09-18 00:04:36 +02:00
parent fab26fb92c
commit a8c145e071
2 changed files with 5 additions and 7 deletions

View File

@ -282,7 +282,6 @@ class ControllerImpl(val player: EntityPlayer) extends Controller with WirelessE
private def cleanActiveBehaviors(): Unit = {
if (activeBehaviorsDirty) {
configuration.synchronized(if (activeBehaviorsDirty) {
activeBehaviors.clear()
val newBehaviors = configuration.behaviors.filter(_.isActive).map(_.behavior)
val addedBehaviors = newBehaviors -- activeBehaviors
val removedBehaviors = activeBehaviors -- newBehaviors

View File

@ -40,7 +40,7 @@ object PotionProvider extends SimpleProvider {
}
class PotionBehavior(val potion: Potion, player: EntityPlayer) extends SimpleBehavior(player) {
final val RefreshInterval = 40
final val Duration = 600
def amplifier(player: EntityPlayer) = api.Nanomachines.getController(player).getInputCount(this) - 1
@ -48,13 +48,12 @@ object PotionProvider extends SimpleProvider {
override def onEnable(): Unit = {}
override def onDisable(): Unit = {}
override def onDisable(): Unit = {
player.removePotionEffect(potion.id)
}
override def update(): Unit = {
player.getActivePotionEffect(potion) match {
case effect: PotionEffect if effect.getDuration > RefreshInterval / 2 => // Effect still active.
case _ => player.addPotionEffect(new PotionEffect(potion.id, RefreshInterval, amplifier(player)))
}
player.addPotionEffect(new PotionEffect(potion.id, Duration, amplifier(player)))
}
}