-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move extinguish and clear effects to a behaviour
- Loading branch information
1 parent
bf8bae3
commit b128d3e
Showing
5 changed files
with
73 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
.../lovetropics/minigames/common/core/game/behavior/instances/action/ClearEffectsAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.lovetropics.minigames.common.core.game.behavior.instances.action; | ||
|
||
import com.lovetropics.minigames.common.core.game.GameException; | ||
import com.lovetropics.minigames.common.core.game.IGamePhase; | ||
import com.lovetropics.minigames.common.core.game.behavior.IGameBehavior; | ||
import com.lovetropics.minigames.common.core.game.behavior.event.EventRegistrar; | ||
import com.lovetropics.minigames.common.core.game.behavior.event.GameActionEvents; | ||
import com.mojang.serialization.MapCodec; | ||
|
||
public record ClearEffectsAction() implements IGameBehavior { | ||
public static final MapCodec<ClearEffectsAction> CODEC = MapCodec.unit(ClearEffectsAction::new); | ||
@Override | ||
public void register(IGamePhase game, EventRegistrar events) throws GameException { | ||
events.listen(GameActionEvents.APPLY_TO_PLAYER, (context, target) -> { | ||
if (target.getActiveEffects().isEmpty()) { | ||
return false; | ||
} | ||
target.removeAllEffects(); | ||
return true; | ||
}); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...pics/minigames/common/core/game/behavior/instances/action/ExtinguishPlayerFireAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.lovetropics.minigames.common.core.game.behavior.instances.action; | ||
|
||
import com.lovetropics.minigames.common.core.game.GameException; | ||
import com.lovetropics.minigames.common.core.game.IGamePhase; | ||
import com.lovetropics.minigames.common.core.game.behavior.IGameBehavior; | ||
import com.lovetropics.minigames.common.core.game.behavior.event.EventRegistrar; | ||
import com.lovetropics.minigames.common.core.game.behavior.event.GameActionEvents; | ||
import com.mojang.serialization.MapCodec; | ||
|
||
public record ExtinguishPlayerFireAction() implements IGameBehavior { | ||
public static final MapCodec<ExtinguishPlayerFireAction> CODEC = MapCodec.unit(ExtinguishPlayerFireAction::new); | ||
@Override | ||
public void register(IGamePhase game, EventRegistrar events) throws GameException { | ||
events.listen(GameActionEvents.APPLY_TO_PLAYER, (context, target) -> { | ||
if (target.isOnFire()) { | ||
target.extinguishFire(); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...m/lovetropics/minigames/common/core/game/behavior/instances/action/ResetHungerAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.lovetropics.minigames.common.core.game.behavior.instances.action; | ||
|
||
import com.lovetropics.minigames.common.core.game.GameException; | ||
import com.lovetropics.minigames.common.core.game.IGamePhase; | ||
import com.lovetropics.minigames.common.core.game.behavior.IGameBehavior; | ||
import com.lovetropics.minigames.common.core.game.behavior.event.EventRegistrar; | ||
import com.lovetropics.minigames.common.core.game.behavior.event.GameActionEvents; | ||
import com.mojang.serialization.MapCodec; | ||
|
||
public record ResetHungerAction() implements IGameBehavior { | ||
public static final MapCodec<ResetHungerAction> CODEC = MapCodec.unit(ResetHungerAction::new); | ||
@Override | ||
public void register(IGamePhase game, EventRegistrar events) throws GameException { | ||
events.listen(GameActionEvents.APPLY_TO_PLAYER, (context, target) -> { | ||
target.getFoodData().setFoodLevel(20); | ||
target.getFoodData().setSaturation(5); | ||
target.getFoodData().setExhaustion(0); | ||
return true; | ||
}); | ||
} | ||
} |