Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit e89c962

Browse files
authored
Merge development into main
Merge development into main
2 parents 1cc703b + 90126b1 commit e89c962

101 files changed

Lines changed: 291 additions & 220 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1.12.2/cloudclient/src/main/java/dev/cloudmc/Cloud.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,23 @@ public void init(FMLInitializationEvent event) throws IOException {
5353
messageHelper = new MessageHelper()
5454
);
5555

56-
if (!ConfigSaver.configExists()) {
57-
ConfigSaver.saveConfig();
56+
try {
57+
if (!ConfigSaver.configExists()) {
58+
ConfigSaver.saveConfig();
59+
}
60+
ConfigLoader.loadConfig();
61+
} catch (Exception e) {
62+
System.out.println(e.getMessage());
5863
}
59-
ConfigLoader.loadConfig();
6064
fontHelper.init();
6165

62-
Runtime.getRuntime().addShutdownHook(new Thread(ConfigSaver::saveConfig));
66+
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
67+
try {
68+
ConfigSaver.saveConfig();
69+
} catch (Exception e) {
70+
System.out.println(e.getMessage());
71+
}
72+
}));
6373
}
6474

6575
private void registerEvents(Object... events) {

1.12.2/cloudclient/src/main/java/dev/cloudmc/config/ConfigLoader.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,8 @@ public class ConfigLoader {
2323
* Loads the config from .minecraft/cloud/config.json
2424
*/
2525

26-
public static void loadConfig() {
27-
FileReader reader = null;
28-
try {
29-
reader = new FileReader(OSHelper.getCloudDirectory() + "config.json");
30-
} catch (FileNotFoundException e) {
31-
System.out.println(e.getMessage());
32-
}
33-
34-
if(reader == null) {
35-
return;
36-
}
26+
public static void loadConfig() throws FileNotFoundException {
27+
FileReader reader = new FileReader(OSHelper.getCloudDirectory() + "config.json");
3728

3829
Config config = new Gson().fromJson(reader, Config.class);
3930

1.12.2/cloudclient/src/main/java/dev/cloudmc/config/ConfigSaver.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,10 @@ public class ConfigSaver {
2323
* Creates and saves a configuration in .minecraft/cloud/config.json
2424
*/
2525

26-
public static void saveConfig() {
26+
public static void saveConfig() throws IOException {
2727
createDir();
2828

29-
FileWriter writer;
30-
try {
31-
writer = new FileWriter(OSHelper.getCloudDirectory() + "config.json");
32-
} catch (IOException e) {
33-
throw new RuntimeException(e);
34-
}
29+
FileWriter writer = new FileWriter(OSHelper.getCloudDirectory() + "config.json");
3530

3631
Config config = new Config();
3732

@@ -57,12 +52,8 @@ public static void saveConfig() {
5752
config.setSnapping(Style.isSnapping());
5853

5954
String json = new Gson().toJson(config);
60-
try {
61-
writer.write(json);
62-
writer.close();
63-
} catch (IOException e) {
64-
throw new RuntimeException(e);
65-
}
55+
writer.write(json);
56+
writer.close();
6657
}
6758

6859
/**

1.12.2/cloudclient/src/main/java/dev/cloudmc/feature/mod/ModManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void init() {
4040
addMod(new FreelookMod());
4141
addMod(new CrosshairMod());
4242
addMod(new MotionblurMod());
43-
addMod(new GuiBlurMod());
43+
addMod(new GuiTweaksMod());
4444
addMod(new BlockOverlayMod());
4545
addMod(new BlockInfoMod());
4646
addMod(new ReachDisplayMod());

1.12.2/cloudclient/src/main/java/dev/cloudmc/feature/mod/impl/GuiBlurMod.java

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2022 DupliCAT
3+
* GNU Lesser General Public License v3.0
4+
*/
5+
6+
package dev.cloudmc.feature.mod.impl;
7+
8+
import dev.cloudmc.Cloud;
9+
import dev.cloudmc.feature.mod.Mod;
10+
import dev.cloudmc.feature.mod.Type;
11+
import dev.cloudmc.feature.setting.Setting;
12+
import net.minecraft.client.gui.GuiChat;
13+
import net.minecraft.util.ResourceLocation;
14+
import net.minecraftforge.client.event.GuiOpenEvent;
15+
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
16+
17+
public class GuiTweaksMod extends Mod {
18+
19+
public GuiTweaksMod() {
20+
super(
21+
"Gui Tweaks",
22+
"Adds Tweaks to the Gui like blur and transparency.",
23+
Type.Tweaks
24+
);
25+
26+
Cloud.INSTANCE.settingManager.addSetting(new Setting("Blur Background", this, true));
27+
Cloud.INSTANCE.settingManager.addSetting(new Setting("Darken Background", this, true));
28+
}
29+
30+
@SubscribeEvent
31+
public void onGuiOpen(GuiOpenEvent e) {
32+
if (Cloud.INSTANCE.settingManager.getSettingByModAndName(getName(), "Blur Background").isCheckToggled()) {
33+
if (!(e.getGui() instanceof GuiChat)) {
34+
try {
35+
Cloud.INSTANCE.mc.entityRenderer.loadShader(
36+
new ResourceLocation("shaders/post/blur.json"));
37+
} catch (Exception exception) {
38+
System.out.println(exception.getMessage());
39+
}
40+
}
41+
if (e.getGui() == null) {
42+
if (Cloud.INSTANCE.mc.entityRenderer.getShaderGroup() != null) {
43+
Cloud.INSTANCE.mc.entityRenderer.getShaderGroup().deleteShaderGroup();
44+
}
45+
}
46+
}
47+
}
48+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package dev.cloudmc.mixins;
2+
3+
import dev.cloudmc.Cloud;
4+
import net.minecraft.client.gui.Gui;
5+
import net.minecraft.client.gui.GuiScreen;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.injection.At;
8+
import org.spongepowered.asm.mixin.injection.Redirect;
9+
10+
@Mixin(GuiScreen.class)
11+
public abstract class GuiScreenMixin extends Gui {
12+
13+
@Redirect(
14+
method = "drawWorldBackground",
15+
at = @At(
16+
value = "INVOKE",
17+
target = "Lnet/minecraft/client/gui/GuiScreen;drawGradientRect(IIIIII)V"
18+
)
19+
)
20+
public void drawWorldBackground(GuiScreen instance, int left, int top, int right, int bottom, int startColor, int endColor) {
21+
if (Cloud.INSTANCE.settingManager.getSettingByModAndName("Gui Tweaks", "Darken Background").isCheckToggled() &&
22+
Cloud.INSTANCE.modManager.getMod("Gui Tweaks").isToggled()) {
23+
this.drawGradientRect(left, top, right, bottom, startColor, endColor);
24+
}
25+
}
26+
}

1.12.2/cloudclient/src/main/resources/assets/cloudmc/icon/button/button/guiblur.png renamed to 1.12.2/cloudclient/src/main/resources/assets/cloudmc/icon/button/button/gui tweaks.png

File renamed without changes.

1.12.2/cloudclient/src/main/resources/mixins.cloudmc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"GuiIngameMenuMixin",
1010
"GuiInGameMixin",
1111
"GuiMainMenuMixin",
12+
"GuiScreenMixin",
1213
"ItemRendererMixin",
1314
"MinecraftMixin"
1415
],

1.7.10/cloudclient/src/main/java/dev/cloudmc/Cloud.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,23 @@ public void init(FMLInitializationEvent event) throws IOException {
6464
messageHelper = new MessageHelper()
6565
);
6666

67-
if (!ConfigSaver.configExists()) {
68-
ConfigSaver.saveConfig();
67+
try {
68+
if (!ConfigSaver.configExists()) {
69+
ConfigSaver.saveConfig();
70+
}
71+
ConfigLoader.loadConfig();
72+
} catch (Exception e) {
73+
System.out.println(e.getMessage());
6974
}
70-
ConfigLoader.loadConfig();
7175
fontHelper.init();
7276

73-
Runtime.getRuntime().addShutdownHook(new Thread(ConfigSaver::saveConfig));
77+
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
78+
try {
79+
ConfigSaver.saveConfig();
80+
} catch (Exception e) {
81+
System.out.println(e.getMessage());
82+
}
83+
}));
7484
}
7585

7686
private void registerEvents(Object... events) {

0 commit comments

Comments
 (0)