Skip to content

Commit 5faaa69

Browse files
Mirror overworld difficulty (#46)
* chore: Port to 1.20.5 and probably break something important * chore: Fix commented line Signed-off-by: Awakened-Redstone <[email protected]> * chore: Add option to mirror overworld's difficulty Signed-off-by: Awakened-Redstone <[email protected]> --------- Signed-off-by: Awakened-Redstone <[email protected]>
1 parent db45eaf commit 5faaa69

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/main/java/xyz/nucleoid/fantasy/RuntimeWorldConfig.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public final class RuntimeWorldConfig {
3030
private Difficulty difficulty = Difficulty.NORMAL;
3131
private final GameRuleStore gameRules = new GameRuleStore();
3232
private boolean mirrorOverworldGameRules = false;
33+
private boolean mirrorOverworldDifficulty = false;
3334
private RuntimeWorld.Constructor worldConstructor = RuntimeWorld::new;
3435

3536
private int sunnyTime = Integer.MAX_VALUE;
@@ -203,6 +204,18 @@ public RuntimeWorldConfig setMirrorOverworldGameRules(boolean mirror) {
203204
return this;
204205
}
205206

207+
/**
208+
* Defines if the world should follow the overworld difficulty or not
209+
*
210+
* @param mirror Whenever it should mirror or not
211+
*
212+
* @return The same instance of RuntimeWorldConfig
213+
*/
214+
public RuntimeWorldConfig setMirrorOverworldDifficulty(boolean mirror) {
215+
this.mirrorOverworldDifficulty = mirror;
216+
return this;
217+
}
218+
206219
/**
207220
* Modifies the weather to sunny
208221
*
@@ -336,18 +349,36 @@ public long getTimeOfDay() {
336349
return this.timeOfDay;
337350
}
338351

352+
/**
353+
* Gets the current configured difficulty
354+
* <br/>
355+
* <b>It may not reflect the real difficulty, also check </b>{@link RuntimeWorldConfig#shouldMirrorOverworldDifficulty()}
356+
*
357+
* @return The current difficulty stored in the config
358+
*/
339359
public Difficulty getDifficulty() {
340360
return this.difficulty;
341361
}
342362

363+
/**
364+
* Gets the current configured gamerules
365+
* <br/>
366+
* <b>It may not reflect the real gamerules, also check </b>{@link RuntimeWorldConfig#shouldMirrorOverworldGameRules()}
367+
*
368+
* @return The current gamerules stored in the config
369+
*/
343370
public GameRuleStore getGameRules() {
344371
return this.gameRules;
345372
}
346373

347-
public boolean shouldMirrorOverworldGameRules(){
374+
public boolean shouldMirrorOverworldGameRules() {
348375
return this.mirrorOverworldGameRules;
349376
}
350377

378+
public boolean shouldMirrorOverworldDifficulty() {
379+
return this.mirrorOverworldDifficulty;
380+
}
381+
351382
public int getSunnyTime() {
352383
return this.sunnyTime;
353384
}

src/main/java/xyz/nucleoid/fantasy/RuntimeWorldProperties.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ public RuntimeWorldProperties(SaveProperties saveProperties, RuntimeWorldConfig
1919

2020
@Override
2121
public GameRules getGameRules() {
22-
if (this.config.shouldMirrorOverworldGameRules())
22+
if (this.config.shouldMirrorOverworldGameRules()) {
2323
return super.getGameRules();
24+
}
2425
return this.rules;
2526
}
2627

@@ -86,6 +87,9 @@ public int getThunderTime() {
8687

8788
@Override
8889
public Difficulty getDifficulty() {
90+
if (this.config.shouldMirrorOverworldDifficulty()) {
91+
return super.getDifficulty();
92+
}
8993
return this.config.getDifficulty();
9094
}
9195
}

0 commit comments

Comments
 (0)