Skip to content

Commit

Permalink
Merge branch '1.17.x/dev' into 1.17.x/stable
Browse files Browse the repository at this point in the history
  • Loading branch information
FlashyReese committed Apr 3, 2022
2 parents 3a9404a + ae13c41 commit 5f90059
Show file tree
Hide file tree
Showing 33 changed files with 397 additions and 156 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'maven-publish'
id 'io.github.juuxel.loom-quiltflower' version '1.6.1'
}

sourceCompatibility = JavaVersion.VERSION_16
Expand Down Expand Up @@ -42,7 +43,7 @@ dependencies {

// Currently using altrisi/CaffeineConfig until it is officially available through CaffeineMC's maven repository
// Todo: Use https://github.com/CaffeineMC/mixin-config when available
include(modImplementation("com.github.FlashyReese:CaffeineConfig:383ee33be5"))
include(modImplementation("com.github.FlashyReese:CaffeineConfig:afbaa017c6"))

modRuntimeOnly "maven.modrinth:lazydfu:0.1.2"
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.13.3

# Mod Properties
mod_version=0.4.2
mod_version=0.4.3
maven_group=me.flashyreese.mods
archives_base_name=sodium-extra

Expand Down
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'Cotton'
url = 'https://server.bbkr.space/artifactory/libs-release/'
}
gradlePluginPortal()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ClientTickHandler {

public void onClientInitialize() {
ClientTickEvents.START_CLIENT_TICK.register(minecraftClient -> {
int currentFPS = ((MinecraftClientAccessor) minecraftClient).getCurrentFPS();
int currentFPS = MinecraftClientAccessor.getCurrentFPS();
this.averageFps.add(currentFPS);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;

@Environment(EnvType.CLIENT)
public class SodiumExtraClientMod implements ClientModInitializer {

private static final ClientTickHandler clientTickHandler = new ClientTickHandler();
private static SodiumExtraGameOptions CONFIG;
private static Logger LOGGER;

public static SodiumExtraGameOptions options() {
if (CONFIG == null) {
Expand All @@ -24,13 +20,6 @@ public static SodiumExtraGameOptions options() {
return CONFIG;
}

public static Logger logger() {
if (LOGGER == null) {
LOGGER = LogManager.getLogger("Sodium Extra");
}
return LOGGER;
}

public static ClientTickHandler getClientTickHandler() {
return clientTickHandler;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static OptionPage animation() {
.setTooltip(new TranslatableText("sodium-extra.option.animations_all.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.animationSettings.animation = value, opts -> opts.animationSettings.animation)
.setFlags(OptionFlag.REQUIRES_ASSET_RELOAD)
.build()
)
.build());
Expand All @@ -38,34 +39,47 @@ public static OptionPage animation() {
.setTooltip(new TranslatableText("sodium-extra.option.animate_water.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.animationSettings.water = value, opts -> opts.animationSettings.water)
.setFlags(OptionFlag.REQUIRES_ASSET_RELOAD)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(new TranslatableText("block.minecraft.lava"))
.setTooltip(new TranslatableText("sodium-extra.option.animate_lava.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.animationSettings.lava = value, opts -> opts.animationSettings.lava)
.setFlags(OptionFlag.REQUIRES_ASSET_RELOAD)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(new TranslatableText("block.minecraft.fire"))
.setTooltip(new TranslatableText("sodium-extra.option.animate_fire.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.animationSettings.fire = value, opts -> opts.animationSettings.fire)
.setFlags(OptionFlag.REQUIRES_ASSET_RELOAD)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(new TranslatableText("block.minecraft.nether_portal"))
.setTooltip(new TranslatableText("sodium-extra.option.animate_portal.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.animationSettings.portal = value, opts -> opts.animationSettings.portal)
.setFlags(OptionFlag.REQUIRES_ASSET_RELOAD)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(new TranslatableText("sodium-extra.option.block_animations"))
.setTooltip(new TranslatableText("sodium-extra.option.block_animations.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((options, value) -> options.animationSettings.blockAnimations = value, options -> options.animationSettings.blockAnimations)
.setFlags(OptionFlag.REQUIRES_ASSET_RELOAD)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(new TranslatableText("block.minecraft.sculk_sensor"))
.setTooltip(new TranslatableText("sodium-extra.option.animate_sculk_sensor.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((options, value) -> options.animationSettings.sculkSensor = value, options -> options.animationSettings.sculkSensor)
.setFlags(OptionFlag.REQUIRES_ASSET_RELOAD)
.build()
)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public class SodiumExtraGameOptions {
public final DetailSettings detailSettings = new DetailSettings();
public final RenderSettings renderSettings = new RenderSettings();
public final ExtraSettings extraSettings = new ExtraSettings();
public final NotificationSettings notificationSettings = new NotificationSettings();
private File file;
private boolean suggestedRSO;

public static SodiumExtraGameOptions load(File file) {
SodiumExtraGameOptions config;
Expand All @@ -40,6 +42,7 @@ public static SodiumExtraGameOptions load(File file) {
}

config.file = file;
config.suggestedRSO = false;
config.writeChanges();

return config;
Expand All @@ -63,6 +66,14 @@ public void writeChanges() {
}
}

public boolean hasSuggestedRSO() {
return this.suggestedRSO;
}

public void setSuggestedRSO(boolean suggestedRSO) {
this.suggestedRSO = suggestedRSO;
}

public enum OverlayCorner implements TextProvider {
TOP_LEFT("sodium-extra.option.overlay_corner.top_left"),
TOP_RIGHT("sodium-extra.option.overlay_corner.top_right"),
Expand All @@ -88,6 +99,7 @@ public static class AnimationSettings {
public boolean fire;
public boolean portal;
public boolean blockAnimations;
public boolean sculkSensor;

public AnimationSettings() {
this.animation = true;
Expand All @@ -96,6 +108,7 @@ public AnimationSettings() {
this.fire = true;
this.portal = true;
this.blockAnimations = true;
this.sculkSensor = false;
}
}

Expand Down Expand Up @@ -199,4 +212,11 @@ public ExtraSettings() {
}
}

public static class NotificationSettings {
public boolean hideRSORecommendation;

public NotificationSettings() {
this.hideRSORecommendation = false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package me.flashyreese.mods.sodiumextra.client.gui;

import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod;
import net.minecraft.client.font.MultilineText;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ScreenTexts;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.CheckboxWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Util;

public class SuggestRSOScreen extends Screen {

private static final Text HEADER = new TranslatableText("sodium-extra.suggestRSO.header").formatted(Formatting.BOLD);
private static final Text MESSAGE = new TranslatableText("sodium-extra.suggestRSO.message");
private static final Text CHECK_MESSAGE = new TranslatableText("multiplayerWarning.check");
private CheckboxWidget checkbox;
private MultilineText lines = MultilineText.EMPTY;
private final Screen prevScreen;

public SuggestRSOScreen(Screen prevScreen) {
super(new LiteralText("Reese's Sodium Options Suggestion"));
this.prevScreen = prevScreen;
}

@Override
protected void init() {
super.init();
this.lines = MultilineText.create(this.textRenderer, MESSAGE, this.width - 50);
int i = (this.lines.count() + 1) * this.textRenderer.fontHeight * 2;
this.addDrawableChild(new ButtonWidget(this.width / 2 - 155, 130 + i, 150, 20, new LiteralText("CurseForge"), buttonWidget -> Util.getOperatingSystem().open("https://curseforge.com/minecraft/mc-mods/reeses-sodium-options")));
this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + 160, 130 + i, 150, 20, new LiteralText("Modrinth"), buttonWidget -> Util.getOperatingSystem().open("https://modrinth.com/mod/reeses-sodium-options")));
this.addDrawableChild(new ButtonWidget(this.width / 2 - 155, 100 + i, 150, 20, ScreenTexts.PROCEED, buttonWidget -> {
if (this.checkbox.isChecked()) {
SodiumExtraClientMod.options().notificationSettings.hideRSORecommendation = true;
SodiumExtraClientMod.options().writeChanges();
}
this.client.setScreen(this.prevScreen);
}));
this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + 160, 100 + i, 150, 20, new TranslatableText("menu.quit"), buttonWidget -> this.client.scheduleStop()));
this.checkbox = new CheckboxWidget(this.width / 2 - 155 + 80, 76 + i, 150, 20, CHECK_MESSAGE, false);
this.addDrawableChild(this.checkbox);
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackgroundTexture(0);
drawTextWithShadow(matrices, this.textRenderer, HEADER, 25, 30, 0xFFFFFF);
this.lines.drawWithShadow(matrices, 25, 70, this.textRenderer.fontHeight * 2, 0xFFFFFF);
super.render(matrices, mouseX, mouseY, delta);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class SodiumExtraMixinConfigPlugin extends AbstractCaffeineConfigMixinPlu

@Override
protected CaffeineConfig createConfig() {
return CaffeineConfig.builder("Sodium Extra")
return CaffeineConfig.builder("Sodium Extra").withSettingsKey("sodium-extra:options")
.addMixinOption("animation", true)
.addMixinOption("biome_colors", true)
.addMixinOption("cloud", true)
Expand All @@ -30,7 +30,7 @@ protected CaffeineConfig createConfig() {
.addMixinOption("sodium.fast_random", true)
.addMixinOption("sodium.gui_scale", true)
.addMixinOption("sodium.resolution", true)
.addMixinOption("sodium.resolution.reeses_sodium_options", true) // whacky packaging
.addMixinOption("sodium.resolution.reeses_sodium_options", FabricLoader.getInstance().isModLoaded("reeses-sodium-options"))
.addMixinOption("stars", true)
.addMixinOption("sun_moon", true)
.addMixinOption("toasts", true)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,40 +1,23 @@
package me.flashyreese.mods.sodiumextra.mixin.animation;

import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod;
import me.flashyreese.mods.sodiumextra.client.animation.SpriteAnimationExtended;
import net.minecraft.client.texture.AbstractTexture;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.TextureTickListener;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

import java.util.List;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(SpriteAtlasTexture.class)
public abstract class MixinSpriteAtlasTexture extends AbstractTexture {

@Shadow
@Final
private List<TextureTickListener> animatedSprites;

/**
* @author FlashyReese
*/
@Overwrite
public void tickAnimatedSprites() {
this.bindTexture();

if (SodiumExtraClientMod.options().animationSettings.animation) {
for (TextureTickListener textureTickListener : this.animatedSprites) {
if (textureTickListener instanceof SpriteAnimationExtended animationExtended) {
if (this.shouldAnimate(animationExtended.getId()))
textureTickListener.tick();
}
}
}

@Redirect(method = "upload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/Sprite;getAnimation()Lnet/minecraft/client/texture/TextureTickListener;"))
public TextureTickListener sodiumExtra$tickAnimatedSprites(Sprite instance) {
if (instance.getAnimation() != null && SodiumExtraClientMod.options().animationSettings.animation && this.shouldAnimate(instance.getId()))
return instance.getAnimation();
return null;
}

private boolean shouldAnimate(Identifier identifier) {
Expand All @@ -56,6 +39,9 @@ private boolean shouldAnimate(Identifier identifier) {
path.endsWith("blast_furnace_front_on") || path.endsWith("smoker_front_on") ||
path.endsWith("stonecutter_saw")) {
return SodiumExtraClientMod.options().animationSettings.blockAnimations;
} else if (path.endsWith("sculk_sensor_tendril_inactive") || path.endsWith("sculk_sensor_tendril_active") ||
path.endsWith("particle/vibration")) {
return SodiumExtraClientMod.options().animationSettings.sculkSensor;
}
}
return true;
Expand Down
Loading

0 comments on commit 5f90059

Please sign in to comment.