forked from CaffeineMC/sodium
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
770 additions
and
191 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
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
48 changes: 48 additions & 0 deletions
48
src/desktop/java/net/caffeinemc/mods/sodium/desktop/LaunchWarn.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,48 @@ | ||
package net.caffeinemc.mods.sodium.desktop; | ||
|
||
import javax.swing.JOptionPane; | ||
import javax.swing.UIManager; | ||
import javax.swing.UnsupportedLookAndFeelException; | ||
import java.awt.Desktop; | ||
import java.awt.GraphicsEnvironment; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
|
||
/** | ||
* Taken from | ||
* https://github.com/IrisShaders/Iris/blob/6c880cd377d97ffd5de648ba4dfac7ea88897b4f/src/main/java/net/coderbot/iris/LaunchWarn.java | ||
* and modified to fit Sodium. See Iris' license for more information. | ||
*/ | ||
public class LaunchWarn { | ||
public static void main(String[] args) { | ||
String message = "You have tried to launch Sodium (a Minecraft mod) directly, but it is not an executable program or mod installer. You must install Fabric Loader for Minecraft, and place this file in your mods directory instead.\nIf this is your first time installing mods for Fabric Loader, click \"Help\" for a guide on how to do this."; | ||
String fallback = "You have tried to launch Sodium (a Minecraft mod) directly, but it is not an executable program or mod installer. You must install Fabric Loader for Minecraft, and place this file in your mods directory instead.\nIf this is your first time installing mods for Fabric Loader, open \"https://github.com/CaffeineMC/sodium-fabric/wiki/Installation\" for a guide on how to do this."; | ||
if (GraphicsEnvironment.isHeadless()) { | ||
System.err.println(fallback); | ||
} else { | ||
try { | ||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); | ||
} catch (ReflectiveOperationException | UnsupportedLookAndFeelException ignored) { | ||
// Ignored | ||
} | ||
|
||
if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { | ||
int option = JOptionPane.showOptionDialog(null, message, "Sodium", JOptionPane.YES_NO_OPTION, | ||
JOptionPane.INFORMATION_MESSAGE, null, new Object[] { "Help", "Cancel" }, JOptionPane.YES_OPTION); | ||
|
||
if (option == JOptionPane.YES_OPTION) { | ||
try { | ||
Desktop.getDesktop().browse(URI.create("https://github.com/CaffeineMC/sodium-fabric/wiki/Installation")); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} else { | ||
// Fallback for Linux, etc users with no "default" browser | ||
JOptionPane.showMessageDialog(null, fallback); | ||
} | ||
} | ||
|
||
System.exit(0); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
...ava/me/jellysquid/mods/sodium/client/compatibility/checks/SodiumResourcePackMetadata.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,22 @@ | ||
package me.jellysquid.mods.sodium.client.compatibility.checks; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.resource.metadata.ResourceMetadataSerializer; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Reads additional metadata for Sodium from a resource pack's `pack.mcmeta` file. This allows the | ||
* resource pack author to specify which shaders from their pack are not usable with Sodium, but that | ||
* the author is aware of and is fine with being ignored. | ||
*/ | ||
public record SodiumResourcePackMetadata(List<String> ignoredShaders) { | ||
public static final Codec<SodiumResourcePackMetadata> CODEC = RecordCodecBuilder.create((instance) -> | ||
instance.group(Codec.STRING.listOf().fieldOf("ignored_shaders") | ||
.forGetter(SodiumResourcePackMetadata::ignoredShaders)) | ||
.apply(instance, SodiumResourcePackMetadata::new) | ||
); | ||
public static final ResourceMetadataSerializer<SodiumResourcePackMetadata> SERIALIZER = | ||
ResourceMetadataSerializer.fromCodec("sodium", CODEC); | ||
} |
Oops, something went wrong.