Skip to content

Commit b932ea7

Browse files
committed
Working on Forge version
1 parent e80844e commit b932ea7

File tree

9 files changed

+237
-132
lines changed

9 files changed

+237
-132
lines changed

build.gradle

Lines changed: 176 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,199 @@
1+
buildscript {
2+
repositories {
3+
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
4+
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
5+
mavenCentral()
6+
}
7+
dependencies {
8+
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
9+
}
10+
}
11+
112
plugins {
2-
id 'fabric-loom' version '0.13-SNAPSHOT'
3-
id 'maven-publish'
13+
id 'net.minecraftforge.gradle' version '5.1.+'
414
}
515

6-
version = project.mod_version
7-
group = project.maven_group
16+
apply plugin: 'org.spongepowered.mixin'
817

9-
repositories {
10-
// Add repositories to retrieve artifacts from in here.
11-
// You should only use this when depending on other mods because
12-
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
13-
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
14-
// for more information about repositories.
15-
}
18+
jarJar.enable()
1619

17-
dependencies {
18-
// To change the versions see the gradle.properties file
19-
minecraft "com.mojang:minecraft:${project.minecraft_version}"
20-
mappings loom.officialMojangMappings()
21-
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
20+
group = 'pl.panszelescik'
21+
version = '1.0.2-forge-1.19.2'
2222

23-
implementation group: 'io.netty', name: 'netty-codec-haproxy', version: '4.1.78.Final'
24-
include group: 'io.netty', name: 'netty-codec-haproxy', version: '4.1.78.Final'
23+
java {
24+
archivesBaseName = 'proxy_protocol_support'
25+
toolchain.languageVersion = JavaLanguageVersion.of(17)
2526
}
2627

27-
processResources {
28-
inputs.property "version", project.version
29-
filteringCharset "UTF-8"
28+
minecraft {
29+
// The mappings can be changed at any time and must be in the following format.
30+
// Channel: Version:
31+
// official MCVersion Official field/method names from Mojang mapping files
32+
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
33+
//
34+
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
35+
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
36+
//
37+
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
38+
// Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started
39+
//
40+
// Use non-default mappings at your own risk. They may not always work.
41+
// Simply re-run your setup task after changing the mappings to update your workspace.
42+
mappings channel: 'official', version: '1.19.2'
43+
44+
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
45+
46+
// Default run configurations.
47+
// These can be tweaked, removed, or duplicated as needed.
48+
runs {
49+
client {
50+
workingDirectory project.file('run')
51+
52+
// Recommended logging data for a userdev environment
53+
// The markers can be added/remove as needed separated by commas.
54+
// "SCAN": For mods scan.
55+
// "REGISTRIES": For firing of registry events.
56+
// "REGISTRYDUMP": For getting the contents of all registries.
57+
property 'forge.logging.markers', 'REGISTRIES'
58+
59+
60+
// Recommended logging level for the console
61+
// You can set various levels here.
62+
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
63+
property 'forge.logging.console.level', 'debug'
64+
65+
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
66+
property 'forge.enabledGameTestNamespaces', 'proxy_protocol_support'
67+
68+
mods {
69+
proxy_protocol_support {
70+
source sourceSets.main
71+
}
72+
}
73+
}
74+
75+
server {
76+
workingDirectory project.file('run')
77+
78+
property 'forge.logging.markers', 'REGISTRIES'
79+
80+
property 'forge.logging.console.level', 'debug'
81+
82+
property 'forge.enabledGameTestNamespaces', 'proxy_protocol_support'
83+
84+
mods {
85+
proxy_protocol_support {
86+
source sourceSets.main
87+
}
88+
}
89+
}
90+
91+
// This run config launches GameTestServer and runs all registered gametests, then exits.
92+
// By default, the server will crash when no gametests are provided.
93+
// The gametest system is also enabled by default for other run configs under the /test command.
94+
gameTestServer {
95+
workingDirectory project.file('run')
96+
97+
property 'forge.logging.markers', 'REGISTRIES'
98+
99+
property 'forge.logging.console.level', 'debug'
100+
101+
property 'forge.enabledGameTestNamespaces', 'proxy_protocol_support'
102+
103+
mods {
104+
proxy_protocol_support {
105+
source sourceSets.main
106+
}
107+
}
108+
}
109+
110+
data {
111+
workingDirectory project.file('run')
112+
113+
property 'forge.logging.markers', 'REGISTRIES'
114+
115+
property 'forge.logging.console.level', 'debug'
30116

31-
filesMatching("fabric.mod.json") {
32-
expand "version": project.version
117+
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
118+
args '--mod', 'proxy_protocol_support', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
119+
120+
mods {
121+
proxy_protocol_support {
122+
source sourceSets.main
123+
}
124+
}
125+
}
33126
}
34127
}
35128

36-
def targetJavaVersion = 8
37-
tasks.withType(JavaCompile).configureEach {
38-
// ensure that the encoding is set to UTF-8, no matter what the system default is
39-
// this fixes some edge cases with special characters not displaying correctly
40-
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
41-
// If Javadoc is generated, this must be specified in that task too.
42-
it.options.encoding = "UTF-8"
43-
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
44-
it.options.release = targetJavaVersion
45-
}
129+
mixin {
130+
add sourceSets.main, "proxy_protocol_support.refmap.json"
131+
132+
config "proxy_protocol_support.mixins.json"
46133
}
47134

48-
java {
49-
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
50-
if (JavaVersion.current() < javaVersion) {
51-
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
135+
// Include resources generated by data generators.
136+
sourceSets.main.resources { srcDir 'src/generated/resources' }
137+
138+
repositories {
139+
// Put repositories for dependencies here
140+
// ForgeGradle automatically adds the Forge maven and Maven Central for you
141+
142+
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
143+
// flatDir {
144+
// dir 'libs'
145+
// }
146+
}
147+
148+
dependencies {
149+
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft' it is assumed
150+
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
151+
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
152+
minecraft 'net.minecraftforge:forge:1.19.2-43.0.15'
153+
154+
// Real mod deobf dependency examples - these get remapped to your current mappings
155+
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
156+
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
157+
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
158+
159+
// Examples using mod jars from ./libs
160+
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
161+
162+
// For more info...
163+
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
164+
// http://www.gradle.org/docs/current/userguide/dependency_management.html
165+
166+
// https://mvnrepository.com/artifact/io.netty/netty-codec-haproxy
167+
implementation group: 'io.netty', name: 'netty-codec-haproxy', version: '4.1.79.Final'
168+
jarJar(group: 'io.netty', name: 'netty-codec-haproxy', version: '[4.1.79.Final]') {
169+
jarJar.pin(it, '4.1.79.Final')
170+
transitive = false
52171
}
53-
archivesBaseName = project.archives_base_name
54-
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
55-
// if it is present.
56-
// If you remove this line, sources will not be generated.
57-
withSourcesJar()
172+
173+
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
58174
}
59175

176+
// Example for how to get properties into the manifest for reading at runtime.
60177
jar {
61-
from("LICENSE") {
62-
rename { "${it}_${project.archivesBaseName}" }
178+
manifest {
179+
attributes([
180+
"Specification-Title" : "proxy_protocol_support",
181+
"Specification-Vendor" : "PanSzelescik",
182+
"Specification-Version" : "1", // We are version 1 of ourselves
183+
"Implementation-Title" : project.name,
184+
"Implementation-Version" : project.jar.archiveVersion,
185+
"Implementation-Vendor" : "PanSzelescik",
186+
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
187+
])
63188
}
64189
}
65190

66-
// configure the maven publication
67-
publishing {
68-
publications {
69-
mavenJava(MavenPublication) {
70-
from components.java
71-
}
72-
}
191+
jar.finalizedBy('reobfJar')
73192

74-
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
75-
repositories {
76-
// Add repositories to publish to here.
77-
// Notice: This block does NOT have the same function as the block in the top level.
78-
// The repositories here will be used for publishing your artifact, not for
79-
// retrieving dependencies.
80-
}
193+
build {
194+
dependsOn 'jarJar'
195+
}
196+
197+
tasks.withType(JavaCompile).configureEach {
198+
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
81199
}

gradle.properties

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
1-
# Done to increase the memory available to gradle.
2-
org.gradle.jvmargs=-Xmx4G
3-
# Fabric Properties
4-
# check these on https://modmuss50.me/fabric.html
5-
minecraft_version=1.19.2
6-
loader_version=0.14.9
7-
# Mod Properties
8-
mod_version=1.0.2-fabric
9-
maven_group=pl.panszelescik
10-
archives_base_name=proxy_protocol_support
1+
org.gradle.jvmargs=-Xmx3G
2+
org.gradle.daemon=false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
1+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip

settings.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
pluginManagement {
22
repositories {
3-
maven {
4-
name = 'Fabric'
5-
url = 'https://maven.fabricmc.net/'
6-
}
73
gradlePluginPortal()
4+
maven { url = 'https://maven.minecraftforge.net/' }
85
}
96
}
7+
8+
rootProject.name = 'proxy_protocol_support'

src/main/java/pl/panszelescik/proxy_protocol_support/fabric/ProxyProtocolInitializer.java

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package pl.panszelescik.proxy_protocol_support.forge;
2+
3+
import net.minecraftforge.api.distmarker.Dist;
4+
import net.minecraftforge.fml.DistExecutor;
5+
import net.minecraftforge.fml.common.Mod;
6+
import net.minecraftforge.fml.loading.FMLPaths;
7+
import pl.panszelescik.proxy_protocol_support.shared.config.Config;
8+
import pl.panszelescik.proxy_protocol_support.shared.config.Configuration;
9+
import pl.panszelescik.proxy_protocol_support.shared.ProxyProtocolSupport;
10+
11+
import java.io.IOException;
12+
13+
/**
14+
* Forge's main file
15+
*
16+
* @author PanSzelescik
17+
*/
18+
@Mod(ProxyProtocolSupport.MODID)
19+
public class ProxyProtocolInitializer {
20+
21+
public ProxyProtocolInitializer() {
22+
DistExecutor.unsafeRunWhenOn(Dist.DEDICATED_SERVER, () -> () -> {
23+
try {
24+
Config config = Configuration.loadConfig(FMLPaths.CONFIGDIR.get().toFile());
25+
ProxyProtocolSupport.initialize(config);
26+
} catch (IOException e) {
27+
ProxyProtocolSupport.errorLogger.accept("Error loading config file:");
28+
throw new RuntimeException(e);
29+
}
30+
});
31+
}
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
modLoader = "javafml"
2+
loaderVersion = "[43,)"
3+
license="All Rights Reserved"
4+
issueTrackerURL="https://github.com/PanSzelescik/proxy-protocol-support/issues"
5+
[[mods]]
6+
modId="proxy_protocol_support"
7+
version="${file.jarVersion}"
8+
displayName="Proxy Protocol Support"
9+
displayURL="https://www.curseforge.com/minecraft/mc-mods/proxy-protocol-support"
10+
authors="PanSzelescik"
11+
displayTest="IGNORE_ALL_VERSION"
12+
description='''
13+
Proxy Protocol support for Forge 1.19.2 servers
14+
'''
15+
[[dependencies.proxy_protocol_support]]
16+
modId = "minecraft"
17+
mandatory = true
18+
versionRange = "[1.19,1.20)"
19+
ordering = "NONE"
20+
side = "BOTH"

0 commit comments

Comments
 (0)