Added Cloud toggle config and button in Video Settings

master
Wynd 2023-04-14 00:11:21 +03:00
parent cd9eff8f8a
commit b96c3e3a7c
6 changed files with 95 additions and 11 deletions

View File

@ -16,12 +16,32 @@ Note that if you're using something like MultiMC or any of its derivates the fol
## List of changes
### Quality of Life changes
<details><summary>Sugar canes can now be places on sand</summary>
![sugar cane on sand](https://i.imgur.com/N7WjSx8.png)
</details>
<details><summary>More sounds</summary>
- Opening / closing chests
- Minecarts
- Items breaking
**Note: The mod doesn't add any sounds by itself, all of these sounds are already present in your "resources" folder, they are automatically downloaded by Minecraft itself**
</details>
<details><summary>Adds Clouds toggle in Video Settings</summary>
<video controls src="https://i.imgur.com/MUmqtmM.mp4" />
</details>
### Fixes
<details><summary>Fixes selected blocks being rendered under text in containers</summary>
Before:
@ -102,16 +122,6 @@ After:<br>
</details>
<details><summary>More sounds</summary>
- Opening / closing chests
- Minecarts
- Items breaking
**Note: The mod doesn't add any sounds by itself, all of these sounds are already present in your "resources" folder, they are automatically downloaded by Minecraft itself**
</details>
<details><summary>Fixes leg armor not being updated while riding</summary>
Before:<br>

View File

@ -17,6 +17,9 @@ public class ModConfig {
public static final Option<Boolean> SUGAR_CANE_ON_SAND = make("Sugar Cane on sand", true, "Allows sugar canes to be placed on sand");
public static final Option<Boolean> ADD_MORE_SOUNDS = make("Add more sounds", true,
"Links a few more sounds from your local 'resources' folder with the game, namely for item breaking, minecarts and chests");
public static final Option<Boolean> ENABLE_CLOUDS = make("Enable Clouds", true,
"Enables the rendering of clouds");
public static final Option<Boolean> FIX_BOW_MODEL = make("Fix bow model", true,
"Makes the box model held by players and skeletons bigger and facing forward");
public static final Option<Boolean> FIX_MINECART_FLICKERING = make("Fix minecart flickering", true,
@ -74,6 +77,10 @@ public class ModConfig {
public <T> T get(Option<T> o) {
return this.fileConfig.getOrElse(o.name, o.defaultValue);
}
public <T> T set(Option<T> o, T value) {
return this.fileConfig.set(o.name, value);
}
public static class Option<T> {
private String name;
@ -94,5 +101,9 @@ public class ModConfig {
public T get() {
return ModConfig.instance().get(this);
}
public void set(T value) {
ModConfig.instance().set(this, value);
}
}
}

View File

@ -1,5 +1,7 @@
package xyz.pixelatedw.finalbeta.mixin;
import java.util.List;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -11,4 +13,7 @@ public class ScreenMixin {
@Shadow
public Minecraft minecraft;
@Shadow
public List buttons;
}

View File

@ -0,0 +1,35 @@
package xyz.pixelatedw.finalbeta.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 net.minecraft.client.gui.screen.VideoSettingsScreen;
import net.minecraft.client.gui.widgets.Button;
import net.minecraft.client.resource.language.TranslationStorage;
import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(VideoSettingsScreen.class)
public class VideoSettingsScreenMixin extends ScreenMixin {
@Inject(method = "init", at = @At("TAIL"))
public void init(CallbackInfo ci) {
VideoSettingsScreen screen = (VideoSettingsScreen)(Object)this;
this.buttons.add(new Button(300, screen.width / 2 - 155, screen.height / 6 + 96, 150, 20, this.getCloudsLabel()));
}
@Inject(method = "buttonClicked", at = @At("HEAD"))
public void buttonClicked(Button btn, CallbackInfo ci) {
if(btn.active) {
if(btn.id == 300) {
ModConfig.ENABLE_CLOUDS.set(!ModConfig.ENABLE_CLOUDS.get());
}
}
}
private String getCloudsLabel() {
TranslationStorage i18n = TranslationStorage.getInstance();
return "Clouds: " + (ModConfig.ENABLE_CLOUDS.get() ? i18n.translate("options.on") : i18n.translate("options.off"));
}
}

View File

@ -0,0 +1,21 @@
package xyz.pixelatedw.finalbeta.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 net.minecraft.client.render.WorldRenderer;
import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(WorldRenderer.class)
public class WorldRendererMixin {
@Inject(method = "method_1552", at = @At("HEAD"), cancellable = true)
public void cloudRenderer(float f, CallbackInfo ci) {
if(!ModConfig.ENABLE_CLOUDS.get()) {
ci.cancel();
}
}
}

View File

@ -24,7 +24,9 @@
"FishHookMixin",
"TileRendererMixin",
"LivingEntityMixin",
"FurnaceEntityMixin"
"FurnaceEntityMixin",
"WorldRendererMixin",
"VideoSettingsScreenMixin"
],
"injectors": {
"defaultRequire": 1