Skip to content

Commit f7fd8c2

Browse files
committed
Implement basic Game Stages support
Closes #17
1 parent e0acb75 commit f7fd8c2

File tree

6 files changed

+63
-3
lines changed

6 files changed

+63
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
- With [**Tinkers' Antique (Tinkers' Construct)**](https://www.curseforge.com/minecraft/mc-mods/tinkers-antique) installed, there are new tool materials to tinker with. You can find more information on our [documentation here](https://github.com/Elite-Modding-Team/Hyxcate/wiki/Tinkers'-Construct)!
104104
- With [**Antique Armory (Construct's Armory)**](https://www.curseforge.com/minecraft/mc-mods/antique-armory) installed, there are new armor materials to tinker with. You can find more information on our [documentation here](https://github.com/Elite-Modding-Team/Hyxcate/wiki/Tinkers'-Construct-(Construct's-Armory))!
105105
- With [**Tough As Nails**](https://www.curseforge.com/minecraft/mc-mods/tough-as-nails) or [**SimpleDifficulty**](https://www.curseforge.com/minecraft/mc-mods/simpledifficulty-for-underdog) installed, the environment temperature is the same as the Nether (configurable) on active Red Giant events.
106+
- With [**Game Stages**](https://www.curseforge.com/minecraft/mc-mods/game-stages) installed, celestial/meteor/falling star events can be controlled. See [this explanation page](https://github.com/Elite-Modding-Team/Hyxcate/wiki/Game-Stages).
106107
- For mod compatibility in general, please check **Mod Compatibility** on the wiki regarding known conflicts.
107108
- More to come!
108109

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ dependencies {
147147
// PeacefulSurface
148148
implementation rfg.deobf('curse.maven:peacefulsurface-73112:2727271')
149149

150+
// Game Stages
151+
implementation 'curse.maven:game-stages-268655:2951844'
152+
150153
if (project.use_mixins.toBoolean()) {
151154
// Change your mixin refmap name here:
152155
String mixin = modUtils.enableMixins('zone.rong:mixinbooter:10.7', "mixins.${project.mod_id}.refmap.json")

src/main/java/de/ellpeck/nyx/capability/NyxWorld.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.ellpeck.nyx.capability;
22

33
import de.ellpeck.nyx.compat.astralsorcery.AstralSorcery;
4+
import de.ellpeck.nyx.compat.gamestages.GameStages;
45
import de.ellpeck.nyx.config.NyxConfig;
56
import de.ellpeck.nyx.config.NyxData;
67
import de.ellpeck.nyx.event.lunar.*;
@@ -87,8 +88,10 @@ public static NyxWorld get(World world) {
8788

8889
public void update() {
8990
if (NyxConfig.MASTER_SWITCHES.meteorEventsEnabled) updateMeteors();
90-
if (NyxConfig.MASTER_SWITCHES.lunarEventsEnabled) updateLunarEvents();
91-
if (NyxConfig.MASTER_SWITCHES.solarEventsEnabled) updateSolarEvents();
91+
if (NyxConfig.MASTER_SWITCHES.lunarEventsEnabled && GameStages.checkGameStageLunarEvents(this.world))
92+
updateLunarEvents();
93+
if (NyxConfig.MASTER_SWITCHES.solarEventsEnabled && GameStages.checkGameStageSolarEvents(this.world))
94+
updateSolarEvents();
9295
}
9396

9497
public void updateMeteors() {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package de.ellpeck.nyx.compat.gamestages;
2+
3+
import de.ellpeck.nyx.config.NyxConfig;
4+
import net.darkhax.gamestages.GameStageHelper;
5+
import net.minecraft.entity.player.EntityPlayer;
6+
import net.minecraft.world.World;
7+
import net.minecraftforge.fml.common.Loader;
8+
9+
public class GameStages {
10+
public static boolean checkGameStageLunarEvents(World world) {
11+
if (!isLoadedAndEnabled()) return true;
12+
boolean stage = false;
13+
for (EntityPlayer player : world.playerEntities) {
14+
if (GameStageHelper.hasStage(player, "hyxcateEventsLunar")) {
15+
stage = true;
16+
break;
17+
}
18+
}
19+
return stage;
20+
}
21+
22+
public static boolean checkGameStageSolarEvents(World world) {
23+
if (!isLoadedAndEnabled()) return true;
24+
boolean stage = false;
25+
for (EntityPlayer player : world.playerEntities) {
26+
if (GameStageHelper.hasStage(player, "hyxcateEventsSolar")) {
27+
stage = true;
28+
break;
29+
}
30+
}
31+
return stage;
32+
}
33+
34+
public static boolean checkGameStageMeteorEvents(EntityPlayer player) {
35+
if (!isLoadedAndEnabled()) return true;
36+
return GameStageHelper.hasStage(player, "hyxcateEventsMeteor");
37+
}
38+
39+
public static boolean checkGameStageFallingStarEvents(EntityPlayer player) {
40+
if (!isLoadedAndEnabled()) return true;
41+
return GameStageHelper.hasStage(player, "hyxcateEventsFallingStar");
42+
}
43+
44+
private static boolean isLoadedAndEnabled() {
45+
return NyxConfig.MOD_INTEGRATION.gameStagesIntegration && Loader.isModLoaded("gamestages");
46+
}
47+
}

src/main/java/de/ellpeck/nyx/config/NyxConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,10 @@ public static class ModIntegration {
692692
@Config.Comment({"Enables Peaceful Surface integration", "Mobs will spawn on the surface during events when enabled"})
693693
public boolean peacefulSurfaceIntegration = true;
694694

695+
@Config.Name("Game Stages Integration")
696+
@Config.Comment({"Enables Game Stages integration", "See wiki for details: https://github.com/Elite-Modding-Team/Hyxcate/wiki/Game-Stages"})
697+
public boolean gameStagesIntegration = false;
698+
695699
public static class SimpleDifficulty {
696700
@Config.Name("Enable SimpleDifficulty Integration")
697701
@Config.Comment("Enables SimpleDifficulty integration")

src/main/java/de/ellpeck/nyx/event/NyxEvents.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import de.ellpeck.nyx.Nyx;
44
import de.ellpeck.nyx.capability.NyxWorld;
5+
import de.ellpeck.nyx.compat.gamestages.GameStages;
56
import de.ellpeck.nyx.config.NyxConfig;
67
import de.ellpeck.nyx.config.NyxData;
78
import de.ellpeck.nyx.entity.NyxEntityEyezor;
@@ -229,6 +230,7 @@ public static void onWorldTick(TickEvent.WorldTickEvent event) {
229230
int dimension = event.world.provider.getDimensionType().getId();
230231
if (NyxData.ALLOWED_DIMENSIONS_LUNAR.contains(dimension)) {
231232
for (EntityPlayer player : event.world.playerEntities) {
233+
if (!GameStages.checkGameStageFallingStarEvents(player)) continue;
232234
if (event.world.rand.nextFloat() > (data.currentLunarEvent instanceof NyxEventStarShower ? NyxConfig.FALLING_STARS.chanceShower : NyxConfig.FALLING_STARS.chance))
233235
continue;
234236
BlockPos startPos = player.getPosition().add(event.world.rand.nextGaussian() * 20, 0, event.world.rand.nextGaussian() * 20);
@@ -246,7 +248,7 @@ public static void onWorldTick(TickEvent.WorldTickEvent event) {
246248
if (!event.world.isRemote && NyxConfig.MASTER_SWITCHES.meteorEventsEnabled && event.world.getTotalWorldTime() >= NyxConfig.METEORS.gracePeriod * 24000L && event.world.getTotalWorldTime() % 20 == 0) {
247249
if (event.world.playerEntities.isEmpty()) break meteors;
248250
EntityPlayer selectedPlayer = event.world.playerEntities.get(event.world.rand.nextInt(event.world.playerEntities.size()));
249-
if (selectedPlayer == null) break meteors;
251+
if (selectedPlayer == null || !GameStages.checkGameStageMeteorEvents(selectedPlayer)) break meteors;
250252
double spawnX = selectedPlayer.posX + MathHelper.nextDouble(event.world.rand, -NyxConfig.METEORS.spawnRadius, NyxConfig.METEORS.spawnRadius);
251253
double spawnZ = selectedPlayer.posZ + MathHelper.nextDouble(event.world.rand, -NyxConfig.METEORS.spawnRadius, NyxConfig.METEORS.spawnRadius);
252254
BlockPos spawnPos = new BlockPos(spawnX, 0, spawnZ);

0 commit comments

Comments
 (0)