Skip to content

Commit

Permalink
Merge branch '1.19.x/dev' into 1.19.x/stable
Browse files Browse the repository at this point in the history
  • Loading branch information
FlashyReese committed Aug 19, 2022
2 parents 0e9a197 + 4876372 commit d622a12
Show file tree
Hide file tree
Showing 44 changed files with 2,362 additions and 264 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/self-hosted.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Self-Hosted runner CI with Gradle

on: [ push ]

jobs:
build:
runs-on: self-hosted

steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Upload build artifacts
uses: actions/upload-artifact@v1
with:
name: build-artifacts
path: build/libs
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.19
yarn_mappings=1.19+build.4
loader_version=0.14.8
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.1
loader_version=0.14.9

# Mod Properties
mod_version=0.4.6
mod_version=0.4.7
maven_group=me.flashyreese.mods
archives_base_name=sodium-extra

# Dependencies
reeses_sodium_options=1.4.4+mc1.19-build.47
reeses_sodium_options=1.4.6+mc1.19.2-build.55
sodium_version=0.4.2+build.181
fabric_version=0.57.0+1.19
fabric_version=0.59.0+1.19.2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
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-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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 Logger logger() {
if (LOGGER == null) {
LOGGER = LoggerFactory.getLogger("Sodium Extra");
}

return LOGGER;
}

public static SodiumExtraGameOptions options() {
if (CONFIG == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
import net.minecraft.text.Texts;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import org.lwjgl.glfw.GLFW;

import java.util.*;
import java.util.stream.Collectors;

public class SodiumExtraGameOptionPages {
public static final SodiumExtraOptionsStorage sodiumExtraOpts = new SodiumExtraOptionsStorage();

private static Text parseVanillaString(String key){
private static Text parseVanillaString(String key) {
return Text.literal((Text.translatable(key).getString()).replaceAll("§.", ""));
}

Expand Down Expand Up @@ -142,7 +141,8 @@ public static OptionPage particle() {
.collect(
OptionGroup::createBuilder,
OptionGroup.Builder::add,
(b1, b2) -> {}
(b1, b2) -> {
}
).build()
));

Expand Down Expand Up @@ -251,6 +251,13 @@ public static OptionPage render() {
.setBinding((opts, value) -> opts.renderSettings.beaconBeam = value, opts -> opts.renderSettings.beaconBeam)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(Text.translatable("sodium-extra.option.enchanting_table_book"))
.setTooltip(Text.translatable("sodium-extra.option.enchanting_table_book.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.renderSettings.enchantingTableBook = value, opts -> opts.renderSettings.enchantingTableBook)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(parseVanillaString("block.minecraft.piston"))
.setTooltip(Text.translatable("sodium-extra.option.piston.tooltip"))
Expand All @@ -259,25 +266,28 @@ public static OptionPage render() {
.build()
)
.build());
groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(Text.translatable("sodium-extra.option.item_frame_name_tag"))
.setTooltip(Text.translatable("sodium-extra.option.item_frame_name_tag.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.renderSettings.itemFrameNameTag = value, opts -> opts.renderSettings.itemFrameNameTag)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(Text.translatable("sodium-extra.option.player_name_tag"))
.setTooltip(Text.translatable("sodium-extra.option.player_name_tag.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((options, value) -> options.renderSettings.playerNameTag = value, options -> options.renderSettings.playerNameTag)
.build()
)
.build());
return new OptionPage(Text.translatable("sodium-extra.option.render"), ImmutableList.copyOf(groups));
}

public static OptionPage extra() {
List<OptionGroup> groups = new ArrayList<>();
groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(Text.translatable("sodium-extra.option.use_adaptive_sync.name"))
.setTooltip(Text.translatable("sodium-extra.option.use_adaptive_sync.tooltip"))
.setControl(TickBoxControl::new)
.setImpact(OptionImpact.VARIES)
.setEnabled(GLFW.glfwExtensionSupported("GLX_EXT_swap_control_tear") || GLFW.glfwExtensionSupported("WGL_EXT_swap_control_tear"))
.setBinding((opts, value) -> {
opts.extraSettings.useAdaptiveSync = value;
// Update the swap buffer
MinecraftClient.getInstance().getWindow().setVsync(MinecraftClient.getInstance().options.getEnableVsync().getValue());
}, opts -> opts.extraSettings.useAdaptiveSync)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(Text.translatable("sodium-extra.option.reduce_resolution_on_mac"))
.setTooltip(Text.translatable("sodium-extra.option.reduce_resolution_on_mac.tooltip"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
import me.jellysquid.mods.sodium.client.gui.options.TextProvider;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Map;

public class SodiumExtraGameOptions {
Expand Down Expand Up @@ -113,6 +115,33 @@ public Text getLocalizedName() {
}
}

public enum VerticalSyncOption implements TextProvider {
OFF("options.off"),
ON("options.on"),
ADAPTIVE("sodium-extra.option.use_adaptive_sync.name", GLFW.glfwExtensionSupported("GLX_EXT_swap_control_tear") || GLFW.glfwExtensionSupported("WGL_EXT_swap_control_tear"));

private final Text name;
private final boolean supported;

VerticalSyncOption(String name) {
this(name, true);
}

VerticalSyncOption(String name, boolean supported) {
this.name = Text.translatable(name);
this.supported = supported;
}

public static VerticalSyncOption[] getAvailableOptions() {
return Arrays.stream(VerticalSyncOption.values()).filter((o) -> o.supported).toArray(VerticalSyncOption[]::new);
}

@Override
public Text getLocalizedName() {
return this.name;
}
}

public static class AnimationSettings {
public boolean animation;
public boolean water;
Expand Down Expand Up @@ -176,6 +205,9 @@ public static class RenderSettings {
public boolean painting;
public boolean piston;
public boolean beaconBeam;
public boolean enchantingTableBook;
public boolean itemFrameNameTag;
public boolean playerNameTag;

public RenderSettings() {
this.fogDistance = 0;
Expand All @@ -185,6 +217,9 @@ public RenderSettings() {
this.painting = true;
this.piston = true;
this.beaconBeam = true;
this.enchantingTableBook = true;
this.itemFrameNameTag = true;
this.playerNameTag = true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public class SuggestRSOScreen extends Screen {
private static final Text HEADER = Text.translatable("sodium-extra.suggestRSO.header").formatted(Formatting.BOLD);
private static final Text MESSAGE = Text.translatable("sodium-extra.suggestRSO.message");
private static final Text CHECK_MESSAGE = Text.translatable("multiplayerWarning.check");
private final Screen prevScreen;
private CheckboxWidget checkbox;
private MultilineText lines = MultilineText.EMPTY;
private final Screen prevScreen;

public SuggestRSOScreen(Screen prevScreen) {
super(Text.literal("Reese's Sodium Options Suggestion"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package me.flashyreese.mods.sodiumextra.client.gui.scrollable_page;

import me.jellysquid.mods.sodium.client.gui.options.*;
import me.jellysquid.mods.sodium.client.gui.options.Option;
import me.jellysquid.mods.sodium.client.gui.options.OptionGroup;
import me.jellysquid.mods.sodium.client.gui.options.OptionImpact;
import me.jellysquid.mods.sodium.client.gui.options.OptionPage;
import me.jellysquid.mods.sodium.client.gui.options.control.Control;
import me.jellysquid.mods.sodium.client.gui.options.control.ControlElement;
import me.jellysquid.mods.sodium.client.util.Dim2i;
Expand Down Expand Up @@ -105,7 +108,7 @@ private void renderOptionTooltip(MatrixStack matrixStack, ControlElement<?> elem

int boxWidth = 200;

int boxY = dim.y();
int boxY = Math.max(dim.y(), this.dim.y());
int boxX = this.dim.getLimitX() + boxPadding;

Option<?> option = element.getOption();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ protected CaffeineConfig createConfig() {
.addMixinOption("sodium.accessibility", true)
.addMixinOption("sodium.gui_scale", true)
.addMixinOption("sodium.resolution", true)
.addMixinOption("sodium.resolution.reeses_sodium_options", FabricLoader.getInstance().isModLoaded("reeses-sodium-options"))
.addMixinOption("sodium.scrollable_page", true)
.addMixinOption("sodium.vsync", true)
.addMixinOption("stars", true)
.addMixinOption("sun_moon", true)
.addMixinOption("toasts", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ public class MixinWindow {
@Redirect(method = "setVsync", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwSwapInterval(I)V"))
private void setSwapInterval(int interval) {
if (SodiumExtraClientMod.options().extraSettings.useAdaptiveSync) {
GLFW.glfwSwapInterval(interval == 1 ? -1 : 0);
if (GLFW.glfwExtensionSupported("GLX_EXT_swap_control_tear") || GLFW.glfwExtensionSupported("WGL_EXT_swap_control_tear")) {
GLFW.glfwSwapInterval(-1);
} else {
SodiumExtraClientMod.logger().warn("Adaptive vsync not supported, falling back to vanilla vsync state!");
SodiumExtraClientMod.options().extraSettings.useAdaptiveSync = false;
SodiumExtraClientMod.options().writeChanges();
GLFW.glfwSwapInterval(interval);
}
} else {
GLFW.glfwSwapInterval(interval);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

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

@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()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private static void vanillaApplyFog(Camera camera, BackgroundRenderer.FogType fo
if (entity.isSpectator()) {
fogData.fogStart = -8.0f;
fogData.fogEnd = viewDistance * 0.5f;
} else if (entity instanceof LivingEntity && ((LivingEntity)entity).hasStatusEffect(StatusEffects.FIRE_RESISTANCE)) {
} else if (entity instanceof LivingEntity && ((LivingEntity) entity).hasStatusEffect(StatusEffects.FIRE_RESISTANCE)) {
fogData.fogStart = 0.0f;
fogData.fogEnd = 3.0f;
} else {
Expand All @@ -58,7 +58,7 @@ private static void vanillaApplyFog(Camera camera, BackgroundRenderer.FogType fo
fogData.fogEnd = 2.0f;
}
} else if (statusEffectFogModifier != null) {
LivingEntity livingEntity = (LivingEntity)entity;
LivingEntity livingEntity = (LivingEntity) entity;
StatusEffectInstance statusEffectInstance = livingEntity.getStatusEffect(statusEffectFogModifier.getStatusEffect());
if (statusEffectInstance != null) {
statusEffectFogModifier.applyStartEndModifier(fogData, livingEntity, statusEffectInstance, viewDistance, tickDelta);
Expand All @@ -67,7 +67,7 @@ private static void vanillaApplyFog(Camera camera, BackgroundRenderer.FogType fo
fogData.fogStart = -8.0f;
fogData.fogEnd = 96.0f;
if (entity instanceof ClientPlayerEntity) {
ClientPlayerEntity clientPlayerEntity = (ClientPlayerEntity)entity;
ClientPlayerEntity clientPlayerEntity = (ClientPlayerEntity) entity;
fogData.fogEnd *= Math.max(0.25f, clientPlayerEntity.getUnderwaterVisibility());
RegistryEntry<Biome> registryEntry = clientPlayerEntity.world.getBiome(clientPlayerEntity.getBlockPos());
if (registryEntry.isIn(BiomeTags.HAS_CLOSER_WATER_FOG)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package me.flashyreese.mods.sodiumextra.mixin.particle;

import net.minecraft.client.particle.FireworksSparkParticle;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.particle.ParticleTypes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(FireworksSparkParticle.FireworkParticle.class)
public class MixinFireworkParticle {

@Shadow
@Final
private ParticleManager particleManager;

@Inject(method = "addExplosionParticle", at = @At(value = "HEAD"), cancellable = true)
public void addExplosionParticle(double x, double y, double z, double velocityX, double velocityY, double velocityZ, int[] colors, int[] fadeColors, boolean trail, boolean flicker, CallbackInfo ci) {
if (this.particleManager.addParticle(ParticleTypes.FIREWORK, x, y, z, velocityX, velocityY, velocityZ) == null) {
ci.cancel();
}
}

@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;setColor(FFF)V"))
public void tick(Particle instance, float red, float green, float blue) {
if (instance != null) {
instance.setColor(red, green, blue);
}
}
}
Loading

0 comments on commit d622a12

Please sign in to comment.