-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plus a little rewrite, don't worry about that
- Loading branch information
Past Ennui
committed
Jun 11, 2020
1 parent
e2b465d
commit 9adee6a
Showing
16 changed files
with
212 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created | ||
# For more information see: https://github.com/actions/setup-java#publishing-using-gradle | ||
|
||
name: Gradle Package | ||
|
||
on: push | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 14 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 14 | ||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | ||
settings-path: ${{ github.workspace }} # location for the settings.xml file | ||
- name: Build with Gradle | ||
run: gradle build | ||
|
||
# The USERNAME and PASSWORD need to correspond to the credentials environment variables used in | ||
# the publishing section of your build.gradle | ||
- name: Publish to GitHub Packages | ||
run: gradle publish | ||
env: | ||
USERNAME: ${{ github.actor }} | ||
PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
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 |
---|---|---|
|
@@ -5,6 +5,10 @@ build/ | |
out/ | ||
classes/ | ||
|
||
# eclipse | ||
|
||
*.launch | ||
|
||
# idea | ||
|
||
.idea/ | ||
|
@@ -22,4 +26,4 @@ bin/ | |
|
||
# fabric | ||
|
||
run/ | ||
run/ |
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,17 @@ | ||
# Boring Backgrounds | ||
<img src="./src/main/resources/assets/boringbackgrounds/icon.png" align="right" width="128px"/> | ||
|
||
A mod that changes the boring dirt background with any texture that you specify in the config file. This mod depends on [Cotton](https://www.curseforge.com/minecraft/mc-mods/cotton). | ||
# Boring Template | ||
|
||
A mod that changes the boring dirt background with any texture that you specify in the config file. This mod bundles the [Fiber Config API](https://github.com/FabLabsMC/fiber) and does not require any other mods. | ||
|
||
## Download | ||
|
||
This mod is available for download on the following services: | ||
|
||
- [CurseForge (recommended)](https://www.curseforge.com/minecraft/mc-mods/boring-backgrounds) | ||
- [GitHub Releases (alternative)](https://github.com/joaoh1/BoringBackgrounds/releases) | ||
- [GitHub Packages (indev releases, **use at your own risk**)](https://github.com/joaoh1/BoringBackgrounds/packages) | ||
|
||
## License | ||
|
||
This mod is licensed under the MIT license. You can freely include the mod on any modpack with no permission. | ||
This mod is licensed under the MIT license. You can freely include the mod on any modpack with no permission. Use of this mod's code on other projects is allowed as long as credits are given. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
# Done to increase the memory available to gradle. | ||
org.gradle.jvmargs=-Xmx1G | ||
org.gradle.jvmargs = -Xmx1G | ||
|
||
# Fabric Properties, check these on http://modmuss50.me/fabric.html | ||
minecraft_version=20w10a | ||
yarn_mappings=20w10a+build.2 | ||
loader_version=0.7.8+build.186 | ||
minecraft_version = 1.16-pre3 | ||
yarn_mappings = 1.16-pre3+build.1 | ||
loader_version = 0.8.7+build.201 | ||
|
||
# Mod Properties | ||
mod_version = 2.0.0 | ||
mod_version = 2.1.0-1.16.pre3 | ||
maven_group = io.github.joaoh1 | ||
archives_base_name = boringbackgrounds | ||
archives_base_name = boringbackgrounds | ||
|
||
# Dependencies | ||
fiber_version = 0.22.1-2 |
Binary file not shown.
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,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
11 changes: 0 additions & 11 deletions
11
src/main/java/io/github/joaoh1/boringbackgrounds/BoringBackgroundsConfig.java
This file was deleted.
Oops, something went wrong.
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
74 changes: 74 additions & 0 deletions
74
src/main/java/io/github/joaoh1/boringbackgrounds/config/BoringBackgroundsConfig.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,74 @@ | ||
package io.github.joaoh1.boringbackgrounds.config; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import io.github.fablabsmc.fablabs.api.fiber.v1.exception.FiberException; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.schema.type.derived.ConfigTypes; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.serialization.FiberSerialization; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.serialization.JanksonValueSerializer; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.tree.ConfigTree; | ||
import io.github.fablabsmc.fablabs.api.fiber.v1.tree.PropertyMirror; | ||
|
||
public class BoringBackgroundsConfig { | ||
//Current config | ||
private static final Path boringBackgroundsConfigPath = Paths.get("./config/boring_backgrounds.json5"); | ||
public static final PropertyMirror<String[]> textureIdentifiers = PropertyMirror.create(ConfigTypes.makeArray(ConfigTypes.STRING)); | ||
public static final PropertyMirror<Boolean> changeAfterNewScreen = PropertyMirror.create(ConfigTypes.BOOLEAN); | ||
|
||
//TODO - Remove backward compatibility when 3.0.0 comes | ||
//Backward compatibility with Boring Backgrounds 2.0.0/1.0.1 | ||
private static final Path legacyBoringBackgroundsConfigPath = Paths.get("./config/boringbackgrounds.json5"); | ||
public static final PropertyMirror<String[]> legacyTextureIdentifiers = PropertyMirror.create(ConfigTypes.makeArray(ConfigTypes.STRING)); | ||
|
||
public static final ConfigTree tree = ConfigTree.builder() | ||
.beginValue("texture_identifiers", ConfigTypes.makeArray(ConfigTypes.STRING), new String[]{"minecraft:textures/gui/options_background.png"}) | ||
.withComment("The array of texture identifiers which will replace the dirt background, one will be picked once loaded.\nExample of a texture identifier: \"minecraft:textures/block/iron_block.png\"") | ||
.finishValue(textureIdentifiers::mirror) | ||
.beginValue("change_after_new_screen", ConfigTypes.BOOLEAN, false) | ||
.withComment("If enabled, when a screen is opened, a new background will be chosen from the texture identifier array.") | ||
.finishValue(changeAfterNewScreen::mirror) | ||
.build(); | ||
|
||
public static final ConfigTree legacyTree = ConfigTree.builder() | ||
.beginValue("textureIds", ConfigTypes.makeArray(ConfigTypes.STRING), new String[]{"minecraft:textures/gui/options_background.png"}) | ||
.withComment("The array of texture IDs which will replace the dirt background, one will be picked.") | ||
.finishValue(legacyTextureIdentifiers::mirror) | ||
.build(); | ||
|
||
private static JanksonValueSerializer serializer = new JanksonValueSerializer(false); | ||
|
||
public static void loadJanksonConfig() { | ||
if (Files.exists(legacyBoringBackgroundsConfigPath)) { | ||
try { | ||
FiberSerialization.deserialize(legacyTree, Files.newInputStream(legacyBoringBackgroundsConfigPath), serializer); | ||
textureIdentifiers.setValue(legacyTextureIdentifiers.getValue()); | ||
Files.delete(legacyBoringBackgroundsConfigPath); | ||
saveJanksonConfig(); | ||
} catch (IOException | FiberException e) { | ||
e.printStackTrace(); | ||
} | ||
} else if (Files.exists(boringBackgroundsConfigPath)) { | ||
try { | ||
FiberSerialization.deserialize(tree, Files.newInputStream(boringBackgroundsConfigPath), serializer); | ||
} catch (IOException | FiberException e) { | ||
e.printStackTrace(); | ||
} | ||
} else { | ||
saveJanksonConfig(); | ||
} | ||
} | ||
|
||
public static void saveJanksonConfig() { | ||
try { | ||
if (!Files.exists(Paths.get("./config/"))) { | ||
Files.createDirectories(Paths.get("./config/")); | ||
} | ||
FiberSerialization.serialize(tree, Files.newOutputStream(boringBackgroundsConfigPath), serializer); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/io/github/joaoh1/boringbackgrounds/mixin/MinecraftClientMixin.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,21 @@ | ||
package io.github.joaoh1.boringbackgrounds.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import io.github.joaoh1.boringbackgrounds.BoringBackgroundsMod; | ||
import io.github.joaoh1.boringbackgrounds.config.BoringBackgroundsConfig; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.Screen; | ||
|
||
@Mixin(MinecraftClient.class) | ||
public class MinecraftClientMixin { | ||
@Inject(at = @At("HEAD"), method = "openScreen(Lnet/minecraft/client/gui/screen/Screen;)V") | ||
public void changeBackgroundAfterOpenScreen(Screen screen, CallbackInfo info) { | ||
if (BoringBackgroundsConfig.changeAfterNewScreen.getValue()) { | ||
BoringBackgroundsMod.updateBackground(); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
{ | ||
"required": true, | ||
"package": "io.github.joaoh1.boringbackgrounds.mixin", | ||
"compatibilityLevel": "JAVA_8", | ||
"client": [ | ||
"TextureManagerMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
"required": true, | ||
"package": "io.github.joaoh1.boringbackgrounds.mixin", | ||
"compatibilityLevel": "JAVA_8", | ||
"client": [ | ||
"MinecraftClientMixin", | ||
"TextureManagerMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |
Oops, something went wrong.