Skip to content

Commit

Permalink
Mirror overworld difficulty (#46)
Browse files Browse the repository at this point in the history
* chore: Port to 1.20.5 and probably break something important

* chore: Fix commented line

Signed-off-by: Awakened-Redstone <40528665+Awakened-Redstone@users.noreply.github.com>

* chore: Add option to mirror overworld's difficulty

Signed-off-by: Awakened-Redstone <40528665+Awakened-Redstone@users.noreply.github.com>

---------

Signed-off-by: Awakened-Redstone <40528665+Awakened-Redstone@users.noreply.github.com>
  • Loading branch information
Awakened-Redstone authored May 12, 2024
1 parent db45eaf commit 5faaa69
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
33 changes: 32 additions & 1 deletion src/main/java/xyz/nucleoid/fantasy/RuntimeWorldConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public final class RuntimeWorldConfig {
private Difficulty difficulty = Difficulty.NORMAL;
private final GameRuleStore gameRules = new GameRuleStore();
private boolean mirrorOverworldGameRules = false;
private boolean mirrorOverworldDifficulty = false;
private RuntimeWorld.Constructor worldConstructor = RuntimeWorld::new;

private int sunnyTime = Integer.MAX_VALUE;
Expand Down Expand Up @@ -203,6 +204,18 @@ public RuntimeWorldConfig setMirrorOverworldGameRules(boolean mirror) {
return this;
}

/**
* Defines if the world should follow the overworld difficulty or not
*
* @param mirror Whenever it should mirror or not
*
* @return The same instance of RuntimeWorldConfig
*/
public RuntimeWorldConfig setMirrorOverworldDifficulty(boolean mirror) {
this.mirrorOverworldDifficulty = mirror;
return this;
}

/**
* Modifies the weather to sunny
*
Expand Down Expand Up @@ -336,18 +349,36 @@ public long getTimeOfDay() {
return this.timeOfDay;
}

/**
* Gets the current configured difficulty
* <br/>
* <b>It may not reflect the real difficulty, also check </b>{@link RuntimeWorldConfig#shouldMirrorOverworldDifficulty()}
*
* @return The current difficulty stored in the config
*/
public Difficulty getDifficulty() {
return this.difficulty;
}

/**
* Gets the current configured gamerules
* <br/>
* <b>It may not reflect the real gamerules, also check </b>{@link RuntimeWorldConfig#shouldMirrorOverworldGameRules()}
*
* @return The current gamerules stored in the config
*/
public GameRuleStore getGameRules() {
return this.gameRules;
}

public boolean shouldMirrorOverworldGameRules(){
public boolean shouldMirrorOverworldGameRules() {
return this.mirrorOverworldGameRules;
}

public boolean shouldMirrorOverworldDifficulty() {
return this.mirrorOverworldDifficulty;
}

public int getSunnyTime() {
return this.sunnyTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public RuntimeWorldProperties(SaveProperties saveProperties, RuntimeWorldConfig

@Override
public GameRules getGameRules() {
if (this.config.shouldMirrorOverworldGameRules())
if (this.config.shouldMirrorOverworldGameRules()) {
return super.getGameRules();
}
return this.rules;
}

Expand Down Expand Up @@ -86,6 +87,9 @@ public int getThunderTime() {

@Override
public Difficulty getDifficulty() {
if (this.config.shouldMirrorOverworldDifficulty()) {
return super.getDifficulty();
}
return this.config.getDifficulty();
}
}

0 comments on commit 5faaa69

Please sign in to comment.