forked from CaffeineMC/sodium
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability for mods to override other mods' options with new options
- Loading branch information
Showing
14 changed files
with
162 additions
and
27 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
9 changes: 9 additions & 0 deletions
9
...n/src/api/java/net/caffeinemc/mods/sodium/api/config/structure/OptionOverrideBuilder.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,9 @@ | ||
package net.caffeinemc.mods.sodium.api.config.structure; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public interface OptionOverrideBuilder { | ||
OptionOverrideBuilder setTarget(ResourceLocation target); | ||
|
||
OptionOverrideBuilder setReplacement(OptionBuilder option); | ||
} |
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
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
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
5 changes: 3 additions & 2 deletions
5
common/src/main/java/net/caffeinemc/mods/sodium/client/config/structure/OptionGroup.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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package net.caffeinemc.mods.sodium.client.config.structure; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import net.minecraft.network.chat.Component; | ||
|
||
public record OptionGroup(Component name, ImmutableList<Option> options) { | ||
import java.util.List; | ||
|
||
public record OptionGroup(Component name, List<Option> options) { | ||
} |
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
6 changes: 6 additions & 0 deletions
6
common/src/main/java/net/caffeinemc/mods/sodium/client/config/structure/OptionOverride.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,6 @@ | ||
package net.caffeinemc.mods.sodium.client.config.structure; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public record OptionOverride(ResourceLocation target, String source, Option replacement) { | ||
} |
30 changes: 30 additions & 0 deletions
30
...in/java/net/caffeinemc/mods/sodium/client/config/structure/OptionOverrideBuilderImpl.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,30 @@ | ||
package net.caffeinemc.mods.sodium.client.config.structure; | ||
|
||
import net.caffeinemc.mods.sodium.api.config.structure.OptionBuilder; | ||
import net.caffeinemc.mods.sodium.api.config.structure.OptionOverrideBuilder; | ||
import net.minecraft.resources.ResourceLocation; | ||
import org.apache.commons.lang3.Validate; | ||
|
||
public class OptionOverrideBuilderImpl implements OptionOverrideBuilder { | ||
private ResourceLocation target; | ||
private Option replacement; | ||
|
||
OptionOverride build(String source) { | ||
Validate.notNull(this.target, "Target must be set"); | ||
Validate.notNull(this.replacement, "Replacement must be set"); | ||
|
||
return new OptionOverride(this.target, source, this.replacement); | ||
} | ||
|
||
@Override | ||
public OptionOverrideBuilder setTarget(ResourceLocation target) { | ||
this.target = target; | ||
return this; | ||
} | ||
|
||
@Override | ||
public OptionOverrideBuilder setReplacement(OptionBuilder option) { | ||
this.replacement = ((OptionBuilderImpl) option).build(); | ||
return this; | ||
} | ||
} |
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