Skip to content

Commit

Permalink
Merge pull request #1 from embeddedt/12.x/forge
Browse files Browse the repository at this point in the history
Some work
  • Loading branch information
Asek3 authored Jan 11, 2024
2 parents ca34ae4 + 0df80d7 commit 1310e92
Show file tree
Hide file tree
Showing 69 changed files with 524 additions and 541 deletions.
159 changes: 36 additions & 123 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,145 +1,58 @@
plugins {
id "java-library"
id "com.gtnewhorizons.retrofuturagradle" version "1.3.26"
}

buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
maven { url = 'https://maven.outlands.top/releases' }
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.10.+', changing: true
classpath "cl.franciscosolis:blossom:1.3.1"
classpath "org.spongepowered:mixingradle:0.7-SNAPSHOT"
// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
// Azul covers the most platforms for Java 8 toolchains, crucially including MacOS arm64
vendor.set(org.gradle.jvm.toolchain.JvmVendorSpec.AZUL)
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'java'
apply plugin: 'cl.franciscosolis.blossom-extended'
apply plugin: 'org.spongepowered.mixin'

version = "${minecraft_version}-${mod_version}"
group = mod_base_package
archivesBaseName = mod_id



java.toolchain.languageVersion = JavaLanguageVersion.of(21)

minecraft {
mappings channel: mappings_channel, version: mappings_version

accessTransformer = file('src/main/resources/META-INF/sodium_at.cfg')

legacy {
fixClasspath = true
extractMappings = true
attachMappings = true
}

runs {
client {
workingDirectory project.file('run/client')

property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'

}
mcVersion.set(minecraft_version)
username.set("Developer")

server {
workingDirectory project.file('run/server')
injectedTags.put("MOD_VERSION", mod_version)
injectedTags.put("MOD_NAME", "Sodium-Vintage")
}

property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
tasks.injectTags.outputClassName.set("${mod_base_package}.Tags")

mods {
"${mod_id}" {
source sourceSets.main
}
}
}
}
}
tasks.deobfuscateMergedJarToSrg.configure {accessTransformerFiles.from("src/main/resources/META-INF/sodium_at.cfg")}

sourceSets.main.resources { srcDir 'src/generated/resources' }
mixin {add sourceSets.main, mod_id + ".mixins.refmap.json"}
repositories {
maven {
name 'Cleanroom Maven'
url 'https://maven.cleanroommc.com/'
}
maven {
url "https://repo.cleanroommc.com/snapshots"
}
maven {
url "https://maven.outlands.top/releases/"
}

mavenCentral()
maven { url "https://maven.cleanroommc.com" }
}

dependencies {
minecraft "com.cleanroommc:cleanroom:15.24.0.3023"

annotationProcessor 'org.ow2.asm:asm-debug-all:5.2'
annotationProcessor 'com.google.guava:guava:33.0.0-jre'
annotationProcessor 'com.google.code.gson:gson:2.10.1'
annotationProcessor "org.ow2.asm:asm-debug-all:5.2"
annotationProcessor "com.google.guava:guava:32.1.2-jre"
annotationProcessor "com.google.code.gson:gson:2.8.9"

annotationProcessor ('com.cleanroommc:sponge-mixin:0.15.3+mixin.0.8.5')

}
processResources {
blossom {
String mcmod = "src/main/resources/mcmod.info"
String mcmeta = "src/main/resources/pack.mcmeta"
replaceToken("mod_id", mod_id, mcmod)
replaceToken("mod_name", mod_name, mcmod)
replaceToken("mod_description", mod_description, mcmod)
replaceToken("mod_version", mod_version, mcmod)
replaceToken("mod_authors", mod_authors, mcmod)
replaceToken("minecraft_version", minecraft_version, mcmod)
replaceToken("mod_id", mod_id, mcmeta)
def mixinBooter = modUtils.enableMixins("zone.rong:mixinbooter:8.9", "sodium.mixins.refmap.json")
api (mixinBooter) {
transitive = false
}
annotationProcessor (mixinBooter) {
transitive = false
}
}

blossom {
String reference = "src/main/java/com/cleanroommc/Reference.java"
replaceToken("@VERSION@", mod_version, reference)
replaceToken("@MODNAME@", mod_name, reference)
replaceToken("@MODID@", mod_id, reference)
}

jar {
manifest {
attributes([
'Specification-Title': mod_id,
'Specification-Vendor': mod_authors,
'Specification-Version': '1', // We are version 1 of ourselves
'FMLCorePluginContainsFMLMod': true,
'FMLCorePlugin': 'me.jellysquid.mods.sodium.client.SodiumMixinTweaker',
'ForceLoadAsMod': true,
'FMLAT': 'sodium_at.cfg',
'Implementation-Title': project.name,
'Implementation-Version': mod_version,
'Implementation-Vendor': mod_authors,
'Implementation-Timestamp': new Date().format('yyyy-MM-dd\'T\'HH:mm:ssZ')
])
attributes (
"FMLCorePluginContainsFMLMod": true,
"ForceLoadAsMod": true,
"MixinConfigs": "sodium.mixins.json",
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker"
)
}
}

jar.finalizedBy('reobfJar')

publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file://${project.projectDir}/mcmodsrepo"
}
}
}
processResources {
from "common/src/main/resources"
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ mod_id=sodium
mod_name=Sodium
mod_main_class=SodiumClientMod
mod_version=1.0
mod_base_package=io.github.examplemod
mod_base_package=me.jellysquid.mods.sodium
mod_authors=JellySquid, Asek3
mod_description=Example mod description\nNewline characters can be used and will be replaced properly
15 changes: 15 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@ pluginManagement {
repositories {
gradlePluginPortal()
maven { url = 'https://gitlab.com/api/v4/projects/26758973/packages/maven' }
maven {
// RetroFuturaGradle
name = "GTNH Maven"
url = uri("http://jenkins.usrv.eu:8081/nexus/content/groups/public/")
allowInsecureProtocol = true
mavenContent {
includeGroup("com.gtnewhorizons")
includeGroup("com.gtnewhorizons.retrofuturagradle")
}
}
}
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' // Provides java toolchains
}


rootProject.name = "${mod_name}"
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.jellysquid.mods.sodium.client;

import com.google.common.collect.ImmutableList;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import zone.rong.mixinbooter.IEarlyMixinLoader;

Expand All @@ -12,7 +13,7 @@
public class SodiumMixinTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
@Override
public List<String> getMixinConfigs() {
return List.of("sodium.mixins.json");
return ImmutableList.of("sodium.mixins.json");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package me.jellysquid.mods.sodium.client.gl.attribute;

import org.lwjgl3.opengl.GL20C;
import org.lwjgl.opengl.GL11;

/**
* An enumeration over the supported data types that can be used for vertex attributes.
*/
public class GlVertexAttributeFormat {
public static final GlVertexAttributeFormat FLOAT = new GlVertexAttributeFormat(GL20C.GL_FLOAT, 4);
public static final GlVertexAttributeFormat UNSIGNED_SHORT = new GlVertexAttributeFormat(GL20C.GL_UNSIGNED_SHORT, 2);
public static final GlVertexAttributeFormat UNSIGNED_BYTE = new GlVertexAttributeFormat(GL20C.GL_UNSIGNED_BYTE, 1);
public static final GlVertexAttributeFormat FLOAT = new GlVertexAttributeFormat(GL11.GL_FLOAT, 4);
public static final GlVertexAttributeFormat UNSIGNED_SHORT = new GlVertexAttributeFormat(GL11.GL_UNSIGNED_SHORT, 2);
public static final GlVertexAttributeFormat UNSIGNED_BYTE = new GlVertexAttributeFormat(GL11.GL_UNSIGNED_BYTE, 1);

private final int glId;
private final int size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import me.jellysquid.mods.sodium.client.gl.GlObject;
import me.jellysquid.mods.sodium.client.gl.device.RenderDevice;
import org.lwjgl3.opengl.GL20;
import org.lwjgl.opengl.GL15;

public abstract class GlBuffer extends GlObject {
public static final int NULL_BUFFER_ID = 0;
Expand All @@ -12,7 +12,7 @@ public abstract class GlBuffer extends GlObject {
protected GlBuffer(RenderDevice owner, GlBufferUsage usage) {
super(owner);

this.setHandle(GL20.glGenBuffers());
this.setHandle(GL15.glGenBuffers());

this.usage = usage;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package me.jellysquid.mods.sodium.client.gl.buffer;

import org.lwjgl3.opengl.GL20C;
import org.lwjgl3.opengl.GL31C;
import org.lwjgl3.opengl.GL40C;

import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL31;
import org.lwjgl.opengl.GL40;

public enum GlBufferTarget {
ARRAY_BUFFER(GL20C.GL_ARRAY_BUFFER, GL20C.GL_ARRAY_BUFFER_BINDING),
COPY_READ_BUFFER(GL31C.GL_COPY_READ_BUFFER, GL31C.GL_COPY_READ_BUFFER),
COPY_WRITE_BUFFER(GL31C.GL_COPY_WRITE_BUFFER, GL31C.GL_COPY_WRITE_BUFFER),
DRAW_INDIRECT_BUFFER(GL40C.GL_DRAW_INDIRECT_BUFFER, GL40C.GL_DRAW_INDIRECT_BUFFER_BINDING);
ARRAY_BUFFER(GL15.GL_ARRAY_BUFFER, GL15.GL_ARRAY_BUFFER_BINDING),
COPY_READ_BUFFER(GL31.GL_COPY_READ_BUFFER, GL31.GL_COPY_READ_BUFFER),
COPY_WRITE_BUFFER(GL31.GL_COPY_WRITE_BUFFER, GL31.GL_COPY_WRITE_BUFFER),
DRAW_INDIRECT_BUFFER(GL40.GL_DRAW_INDIRECT_BUFFER, GL40.GL_DRAW_INDIRECT_BUFFER_BINDING);

public static final GlBufferTarget[] VALUES = GlBufferTarget.values();
public static final int COUNT = VALUES.length;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package me.jellysquid.mods.sodium.client.gl.buffer;

import org.lwjgl3.opengl.GL20C;
import org.lwjgl.opengl.GL15;

public enum GlBufferUsage {
GL_STREAM_DRAW(GL20C.GL_STREAM_DRAW),
GL_STREAM_READ(GL20C.GL_STREAM_READ),
GL_STREAM_COPY(GL20C.GL_STREAM_COPY),
GL_STATIC_DRAW(GL20C.GL_STATIC_DRAW),
GL_STATIC_READ(GL20C.GL_STATIC_READ),
GL_STATIC_COPY(GL20C.GL_STATIC_COPY),
GL_DYNAMIC_DRAW(GL20C.GL_DYNAMIC_DRAW),
GL_DYNAMIC_READ(GL20C.GL_DYNAMIC_READ),
GL_DYNAMIC_COPY(GL20C.GL_DYNAMIC_COPY);
GL_STREAM_DRAW(GL15.GL_STREAM_DRAW),
GL_STREAM_READ(GL15.GL_STREAM_READ),
GL_STREAM_COPY(GL15.GL_STREAM_COPY),
GL_STATIC_DRAW(GL15.GL_STATIC_DRAW),
GL_STATIC_READ(GL15.GL_STATIC_READ),
GL_STATIC_COPY(GL15.GL_STATIC_COPY),
GL_DYNAMIC_DRAW(GL15.GL_DYNAMIC_DRAW),
GL_DYNAMIC_READ(GL15.GL_DYNAMIC_READ),
GL_DYNAMIC_COPY(GL15.GL_DYNAMIC_COPY);

private final int id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl3.opengl.GL20;

import me.jellysquid.mods.sodium.client.render.chunk.shader.ChunkFogMode;
import net.minecraft.util.math.MathHelper;
import org.lwjgl.opengl.GL11;

public class FogHelper {
private static final float FAR_PLANE_THRESHOLD_EXP = (float) Math.log(1.0f / 0.0019f);
Expand Down Expand Up @@ -34,10 +34,10 @@ public static ChunkFogMode getFogMode() {
return ChunkFogMode.NONE;

switch (mode) {
case GL20.GL_EXP2:
case GL20.GL_EXP:
case GL11.GL_EXP2:
case GL11.GL_EXP:
return ChunkFogMode.EXP2;
case GL20.GL_LINEAR:
case GL11.GL_LINEAR:
return ChunkFogMode.LINEAR;
default:
throw new UnsupportedOperationException("Unknown fog mode: " + mode);
Expand All @@ -48,11 +48,11 @@ public static float getFogCutoff() {
int mode = GlStateManager.fogState.mode;

switch (mode) {
case GL20.GL_LINEAR:
case GL11.GL_LINEAR:
return getFogEnd();
case GL20.GL_EXP:
case GL11.GL_EXP:
return FAR_PLANE_THRESHOLD_EXP / getFogDensity();
case GL20.GL_EXP2:
case GL11.GL_EXP2:
return FAR_PLANE_THRESHOLD_EXP2 / getFogDensity();
default:
return 0.0f;
Expand Down
Loading

0 comments on commit 1310e92

Please sign in to comment.