Skip to content

Commit

Permalink
Migrate to official mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Feb 2, 2024
1 parent 82f4af6 commit 8a857dc
Show file tree
Hide file tree
Showing 234 changed files with 2,293 additions and 2,232 deletions.
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
object Constants {
// https://fabricmc.net/develop/
const val MINECRAFT_VERSION: String = "1.20.4"
const val YARN_VERSION: String = "1.20.4+build.3"
const val FABRIC_LOADER_VERSION: String = "0.15.6"
const val FABRIC_API_VERSION: String = "0.95.3+1.20.4"

Expand Down Expand Up @@ -64,7 +63,7 @@ sourceSets {

dependencies {
minecraft(group = "com.mojang", name = "minecraft", version = Constants.MINECRAFT_VERSION)
mappings(group = "net.fabricmc", name = "yarn", version = Constants.YARN_VERSION, classifier = "v2")
mappings(loom.officialMojangMappings())
modImplementation(group = "net.fabricmc", name = "fabric-loader", version = Constants.FABRIC_LOADER_VERSION)

fun addEmbeddedFabricModule(name: String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.caffeinemc.mods.sodium.api.math;

import com.mojang.blaze3d.vertex.PoseStack;
import net.caffeinemc.mods.sodium.api.util.NormI8;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Direction;
import net.minecraft.core.Direction;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Vector3f;
Expand Down Expand Up @@ -120,11 +120,11 @@ public static float transformPositionZ(Matrix4f mat, float x, float y, float z)
* @param angleY The angle to rotate by on the Y-axis
* @param angleX The angle to rotate by on the X-axis
*/
public static void rotateZYX(MatrixStack.Entry matrices, float angleZ, float angleY, float angleX) {
matrices.getPositionMatrix()
public static void rotateZYX(PoseStack.Pose matrices, float angleZ, float angleY, float angleX) {
matrices.pose()
.rotateZYX(angleZ, angleY, angleX);

matrices.getNormalMatrix()
matrices.normal()
.rotateZYX(angleZ, angleY, angleX);
}

Expand Down
4 changes: 2 additions & 2 deletions src/api/java/net/caffeinemc/mods/sodium/api/util/NormI8.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.caffeinemc.mods.sodium.api.util;

import net.minecraft.util.math.MathHelper;
import net.minecraft.util.Mth;
import org.joml.Vector3f;

/**
Expand Down Expand Up @@ -52,7 +52,7 @@ public static int pack(float x, float y, float z) {
*/
private static int encode(float comp) {
// TODO: is the clamp necessary here? our inputs should always be normalized vector components
return ((int) (MathHelper.clamp(comp, -1.0F, 1.0F) * COMPONENT_RANGE) & 255);
return ((int) (Mth.clamp(comp, -1.0F, 1.0F) * COMPONENT_RANGE) & 255);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package net.caffeinemc.mods.sodium.api.vertex.attributes;

import net.minecraft.client.render.VertexFormatElement;
import net.minecraft.client.render.VertexFormats;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormatElement;

public enum CommonVertexAttribute {
POSITION(VertexFormats.POSITION_ELEMENT),
COLOR(VertexFormats.COLOR_ELEMENT),
TEXTURE(VertexFormats.TEXTURE_ELEMENT),
OVERLAY(VertexFormats.OVERLAY_ELEMENT),
LIGHT(VertexFormats.LIGHT_ELEMENT),
NORMAL(VertexFormats.NORMAL_ELEMENT);
POSITION(DefaultVertexFormat.ELEMENT_POSITION),
COLOR(DefaultVertexFormat.ELEMENT_COLOR),
TEXTURE(DefaultVertexFormat.ELEMENT_UV0),
OVERLAY(DefaultVertexFormat.ELEMENT_UV1),
LIGHT(DefaultVertexFormat.ELEMENT_UV2),
NORMAL(DefaultVertexFormat.ELEMENT_NORMAL);

private final VertexFormatElement element;

Expand All @@ -30,6 +30,6 @@ public static CommonVertexAttribute getCommonType(VertexFormatElement element) {
}

public int getByteLength() {
return this.element.getByteLength();
return this.element.getByteSize();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.caffeinemc.mods.sodium.api.vertex.buffer;

import com.mojang.blaze3d.vertex.VertexConsumer;
import net.caffeinemc.mods.sodium.api.memory.MemoryIntrinsics;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription;
import net.minecraft.client.render.VertexConsumer;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.system.MemoryStack;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.caffeinemc.mods.sodium.api.vertex.format;

import com.mojang.blaze3d.vertex.VertexFormat;
import net.caffeinemc.mods.sodium.api.internal.DependencyInjection;
import net.minecraft.client.render.VertexFormat;

public interface VertexFormatRegistry {
VertexFormatRegistry INSTANCE = DependencyInjection.load(VertexFormatRegistry.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package net.caffeinemc.mods.sodium.api.vertex.format.common;

import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import net.caffeinemc.mods.sodium.api.math.MatrixHelper;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.ColorAttribute;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.PositionAttribute;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry;
import net.minecraft.client.render.VertexFormats;
import org.joml.Matrix4f;

public final class ColorVertex {
public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance()
.get(VertexFormats.POSITION_COLOR);
.get(DefaultVertexFormat.POSITION_COLOR);

public static final int STRIDE = 16;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package net.caffeinemc.mods.sodium.api.vertex.format.common;

import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.ColorAttribute;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.LightAttribute;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.PositionAttribute;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.TextureAttribute;
import net.minecraft.client.render.VertexFormats;

public final class GlyphVertex {
public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance()
.get(VertexFormats.POSITION_COLOR_TEXTURE_LIGHT);
.get(DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP);

public static final int STRIDE = 28;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package net.caffeinemc.mods.sodium.api.vertex.format.common;

import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.ColorAttribute;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.NormalAttribute;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.PositionAttribute;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry;
import net.minecraft.client.render.VertexFormats;

public final class LineVertex {
public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance()
.get(VertexFormats.LINES);
.get(DefaultVertexFormat.POSITION_COLOR_NORMAL);

public static final int STRIDE = 20;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package net.caffeinemc.mods.sodium.api.vertex.format.common;

import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.*;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry;
import net.minecraft.client.render.VertexFormats;

public final class ModelVertex {
public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance()
.get(VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL);
.get(DefaultVertexFormat.NEW_ENTITY);

public static final int STRIDE = 36;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package net.caffeinemc.mods.sodium.api.vertex.format.common;

import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.ColorAttribute;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.LightAttribute;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.PositionAttribute;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry;
import net.caffeinemc.mods.sodium.api.vertex.attributes.common.TextureAttribute;
import net.minecraft.client.render.VertexFormats;

public final class ParticleVertex {
public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance()
.get(VertexFormats.POSITION_TEXTURE_COLOR_LIGHT);
.get(DefaultVertexFormat.PARTICLE);

public static final int STRIDE = 28;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.text.Text;
import net.minecraft.network.chat.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -66,7 +66,7 @@ private static SodiumGameOptions loadConfig() {
LOGGER.error("Failed to load configuration file", e);
LOGGER.error("Using default configuration file in read-only mode");

Console.instance().logMessage(MessageLevel.SEVERE, Text.translatable("sodium.console.config_not_loaded"), 12.5);
Console.instance().logMessage(MessageLevel.SEVERE, Component.translatable("sodium.console.config_not_loaded"), 12.5);

var config = SodiumGameOptions.defaults();
config.setReadOnly();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import me.jellysquid.mods.sodium.client.platform.MessageBox;
import me.jellysquid.mods.sodium.client.platform.windows.WindowsDriverStoreVersion;
import net.minecraft.Util;
import me.jellysquid.mods.sodium.client.compatibility.environment.probe.GraphicsAdapterInfo;
import me.jellysquid.mods.sodium.client.compatibility.environment.probe.GraphicsAdapterProbe;
import me.jellysquid.mods.sodium.client.compatibility.environment.probe.GraphicsAdapterVendor;
import net.minecraft.util.Util;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -58,7 +59,7 @@ private static void showUnsupportedDriverMessageBox(String message, String url)

// https://github.com/CaffeineMC/sodium-fabric/issues/899
private static @Nullable WindowsDriverStoreVersion findBrokenIntelGen7GraphicsDriver() {
if (Util.getOperatingSystem() != Util.OperatingSystem.WINDOWS) {
if (Util.getPlatform() != Util.OS.WINDOWS) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import me.jellysquid.mods.sodium.client.compatibility.workarounds.nvidia.NvidiaDriverVersion;
import me.jellysquid.mods.sodium.client.gui.console.Console;
import me.jellysquid.mods.sodium.client.gui.console.message.MessageLevel;
import net.minecraft.Util;
import net.minecraft.network.chat.Component;
import me.jellysquid.mods.sodium.client.compatibility.environment.GLContextInfo;
import net.minecraft.text.Text;
import net.minecraft.util.Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -20,7 +20,7 @@ public static void onContextInitialized() {
checkContextImplementation();

if (isUsingPojavLauncher()) {
Console.instance().logMessage(MessageLevel.SEVERE, Text.translatable("sodium.console.pojav_launcher"), 30.0);
Console.instance().logMessage(MessageLevel.SEVERE, Component.translatable("sodium.console.pojav_launcher"), 30.0);
LOGGER.error("It appears that PojavLauncher is being used with an OpenGL compatibility layer. This will " +
"likely cause severe performance issues, graphical issues, and crashes when used with Sodium. This " +
"configuration is not supported -- you are on your own!");
Expand All @@ -41,7 +41,7 @@ private static void checkContextImplementation() {

if (!isSupportedNvidiaDriver(driver)) {
Console.instance()
.logMessage(MessageLevel.SEVERE, Text.translatable("sodium.console.broken_nvidia_driver"), 30.0);
.logMessage(MessageLevel.SEVERE, Component.translatable("sodium.console.broken_nvidia_driver"), 30.0);

LOGGER.error("The NVIDIA graphics driver appears to be out of date. This will likely cause severe " +
"performance issues and crashes when used with Sodium. The graphics driver should be updated to " +
Expand All @@ -56,7 +56,7 @@ private static void checkContextImplementation() {
private static boolean isSupportedNvidiaDriver(GLContextInfo driver) {
// The Linux driver has two separate branches which have overlapping version numbers, despite also having
// different feature sets. As a result, we can't reliably determine which Linux drivers are broken...
if (Util.getOperatingSystem() != Util.OperatingSystem.WINDOWS) {
if (Util.getPlatform() != Util.OS.WINDOWS) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

import me.jellysquid.mods.sodium.client.platform.MessageBox;
import me.jellysquid.mods.sodium.client.platform.windows.api.Kernel32;
import me.jellysquid.mods.sodium.client.platform.windows.api.version.LanguageCodePage;
import me.jellysquid.mods.sodium.client.platform.windows.api.version.Version;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.Window;
import net.minecraft.util.WinNativeModuleUtil;
import me.jellysquid.mods.sodium.client.platform.windows.api.version.VersionInfo;
import net.minecraft.client.Minecraft;
import net.minecraft.util.NativeModuleLister;
import net.minecraft.util.NativeModuleLister.NativeModuleInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mojang.blaze3d.platform.Window;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
Expand All @@ -25,10 +28,10 @@ public class ModuleScanner {
private static final String[] RTSS_HOOKS_MODULE_NAMES = { "RTSSHooks64.dll", "RTSSHooks.dll" };

public static void checkModules() {
List<WinNativeModuleUtil.NativeModule> modules;
List<NativeModuleLister.NativeModuleInfo> modules;

try {
modules = WinNativeModuleUtil.collectNativeModules();
modules = NativeModuleLister.listModules();
} catch (Throwable t) {
LOGGER.warn("Failed to scan the currently loaded modules", t);
return;
Expand Down Expand Up @@ -63,7 +66,7 @@ private static void checkRTSSModules() {
}

if (version == null || !isRTSSCompatible(version)) {
Window window = MinecraftClient.getInstance().getWindow();
Window window = Minecraft.getInstance().getWindow();
MessageBox.showMessageBox(window, MessageBox.IconType.ERROR, "Sodium Renderer",
"You appear to be using an older version of RivaTuner Statistics Server (RTSS) which is not compatible with Sodium. " +
"You must either update to a newer version (7.3.4 and later) or close the RivaTuner Statistics Server application.\n\n" +
Expand Down Expand Up @@ -158,10 +161,10 @@ private static String findRTSSModuleVersion() {
return fileVersion;
}

private static boolean isModuleLoaded(List<WinNativeModuleUtil.NativeModule> modules, String[] names) {
private static boolean isModuleLoaded(List<NativeModuleLister.NativeModuleInfo> modules, String[] names) {
for (var name : names) {
for (var module : modules) {
if (module.path.equalsIgnoreCase(name)) {
if (module.name.equalsIgnoreCase(name)) {
return true;
}
}
Expand Down
Loading

0 comments on commit 8a857dc

Please sign in to comment.