Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror overworld difficulty #46

Merged
merged 3 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}