mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-11 16:28:12 -04:00
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:
parent
fab26fb92c
commit
a8c145e071
@ -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
|
||||
|
@ -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)))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user