Skip to content

Commit 17eb436

Browse files
committed
feat: support forge 1.15.2
1 parent 7b46fab commit 17eb436

24 files changed

Lines changed: 1045 additions & 3 deletions

forge-1.15/.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Disable autocrlf on generated files, they always generate with LF
2+
# Add any extra files or paths here to make git stop saying they
3+
# are changed when only line endings change.
4+
src/generated/**/.cache/cache text eol=lf
5+
src/generated/**/*.json text eol=lf

forge-1.15/.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# eclipse
2+
bin
3+
*.launch
4+
.settings
5+
.metadata
6+
.classpath
7+
.project
8+
9+
# idea
10+
out
11+
*.ipr
12+
*.iws
13+
*.iml
14+
.idea
15+
16+
# gradle
17+
build
18+
.gradle
19+
20+
# other
21+
eclipse
22+
run
23+
24+
# Files from Forge MDK
25+
forge*changelog.txt

forge-1.15/build.gradle

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
buildscript {
2+
repositories {
3+
maven { url = 'https://maven.minecraftforge.net/' }
4+
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
5+
mavenCentral()
6+
}
7+
dependencies {
8+
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.+', changing: true
9+
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
10+
}
11+
}
12+
apply plugin: 'net.minecraftforge.gradle'
13+
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
14+
apply plugin: 'eclipse'
15+
apply plugin: 'maven-publish'
16+
apply plugin: 'org.spongepowered.mixin'
17+
18+
version = '0.3.0'
19+
group = 'net.azisaba.interchatmod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
20+
archivesBaseName = 'InterChatMod'
21+
22+
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
23+
//Print out JVM information so that we know what version is running. Extreamly useful for people to know when helping you.
24+
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
25+
26+
minecraft {
27+
// The mappings can be changed at any time, and must be in the following format.
28+
// snapshot_YYYYMMDD Snapshot are built nightly.
29+
// stable_# Stables are built at the discretion of the MCP team.
30+
// Use non-default mappings at your own risk. they may not always work.
31+
// Simply re-run your setup task after changing the mappings to update your workspace.
32+
mappings channel: 'snapshot', version: '20200514-1.15.1'
33+
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
34+
35+
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
36+
37+
// Default run configurations.
38+
// These can be tweaked, removed, or duplicated as needed.
39+
runs {
40+
client {
41+
workingDirectory project.file('run')
42+
43+
// Recommended logging data for a userdev environment
44+
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
45+
46+
// Recommended logging level for the console
47+
property 'forge.logging.console.level', 'debug'
48+
49+
mods {
50+
examplemod {
51+
source sourceSets.main
52+
}
53+
}
54+
}
55+
56+
server {
57+
workingDirectory project.file('run')
58+
59+
// Recommended logging data for a userdev environment
60+
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
61+
62+
// Recommended logging level for the console
63+
property 'forge.logging.console.level', 'debug'
64+
65+
mods {
66+
examplemod {
67+
source sourceSets.main
68+
}
69+
}
70+
}
71+
72+
data {
73+
workingDirectory project.file('run')
74+
75+
// Recommended logging data for a userdev environment
76+
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
77+
78+
// Recommended logging level for the console
79+
property 'forge.logging.console.level', 'debug'
80+
81+
args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/')
82+
83+
mods {
84+
examplemod {
85+
source sourceSets.main
86+
}
87+
}
88+
}
89+
}
90+
}
91+
92+
configurations {
93+
shade
94+
implementation.extendsFrom shade
95+
}
96+
97+
dependencies {
98+
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
99+
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
100+
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
101+
minecraft 'net.minecraftforge:forge:1.15.2-31.2.57'
102+
103+
// You may put jars on which you depend on in ./libs or you may define them like so..
104+
// compile "some.group:artifact:version:classifier"
105+
// compile "some.group:artifact:version"
106+
107+
// Real examples
108+
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
109+
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
110+
111+
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
112+
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
113+
114+
// These dependencies get remapped to your current MCP mappings
115+
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
116+
117+
// For more info...
118+
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
119+
// http://www.gradle.org/docs/current/userguide/dependency_management.html
120+
121+
annotationProcessor 'com.google.code.gson:gson:2.10.1'
122+
annotationProcessor 'com.google.guava:guava:32.1.3-jre'
123+
annotationProcessor 'org.ow2.asm:asm:9.6'
124+
annotationProcessor 'org.ow2.asm:asm-tree:9.6'
125+
annotationProcessor 'org.spongepowered:mixin:0.8.5'
126+
implementation project(':common')
127+
shade project(':common')
128+
shade "net.kyori:adventure-api:$adventureVersion"
129+
shade "net.kyori:adventure-key:$adventureVersion"
130+
shade "net.kyori:examination-api:1.3.0"
131+
shade "net.kyori:examination-string:1.3.0"
132+
shade "net.kyori:adventure-text-serializer-legacy:$adventureVersion"
133+
shade "net.kyori:adventure-text-serializer-json:$adventureVersion"
134+
shade "net.kyori:adventure-text-serializer-gson:$adventureVersion"
135+
shade "org.java-websocket:Java-WebSocket:1.5.4"
136+
shade "org.slf4j:slf4j-api:2.0.6"
137+
shade "org.slf4j:slf4j-nop:2.0.6"
138+
139+
}
140+
141+
mixin {
142+
add(sourceSets.main, 'mixins.interchatmod.refmap.json')
143+
config 'mixins.interchatmod.json'
144+
}
145+
146+
// Example for how to get properties into the manifest for reading by the runtime..
147+
jar {
148+
archiveClassifier = 'slim'
149+
manifest {
150+
attributes([
151+
"Specification-Title": "interChatMod",
152+
"Specification-Vendor": "AzisabaNetwork",
153+
"Specification-Version": "1", // We are version 1 of ourselves
154+
"Implementation-Title": project.name,
155+
"Implementation-Version": "${version}",
156+
"Implementation-Vendor" :"AzisabaNetwork",
157+
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
158+
])
159+
}
160+
}
161+
162+
shadowJar {
163+
archiveClassifier = ''
164+
configurations = [project.configurations.shade]
165+
relocate 'net.kyori', "${project.group}.lib.net.kyori"
166+
relocate 'org.slf4j', "${project.group}.lib.org.slf4j"
167+
mergeServiceFiles()
168+
finalizedBy 'reobfShadowJar'
169+
}
170+
171+
assemble.dependsOn shadowJar
172+
173+
reobf {
174+
shadowJar {}
175+
}
176+
177+
// Example configuration to allow publishing using the maven-publish task
178+
// This is the preferred method to reobfuscate your jar file
179+
jar.finalizedBy('reobfJar')
180+
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
181+
//publish.dependsOn('reobfJar')
182+
183+
publishing {
184+
publications {
185+
mavenJava(MavenPublication) {
186+
artifact jar
187+
}
188+
}
189+
repositories {
190+
maven {
191+
url "file:///${project.projectDir}/mcmodsrepo"
192+
}
193+
}
194+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package net.azisaba.interchatmod.forge;
2+
3+
import com.mojang.brigadier.arguments.ArgumentType;
4+
import com.mojang.brigadier.arguments.StringArgumentType;
5+
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
6+
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
7+
import net.azisaba.interchatmod.forge.model.Guild;
8+
import net.minecraft.client.Minecraft;
9+
import net.minecraft.command.CommandSource;
10+
import net.minecraft.command.ISuggestionProvider;
11+
import net.minecraft.util.text.StringTextComponent;
12+
13+
public class Commands {
14+
public static LiteralArgumentBuilder<ISuggestionProvider> literal(String name) {
15+
return LiteralArgumentBuilder.literal(name);
16+
}
17+
18+
public static <T> RequiredArgumentBuilder<ISuggestionProvider, T> argument(String name, ArgumentType<T> type) {
19+
return RequiredArgumentBuilder.argument(name, type);
20+
}
21+
22+
public static LiteralArgumentBuilder<ISuggestionProvider> builderGS() {
23+
return literal("cgs")
24+
.then(argument("guild", StringArgumentType.word())
25+
.suggests((ctx, builder) -> ISuggestionProvider.suggest(Mod.GUILDS.stream().map(Guild::name), builder))
26+
.executes(ctx -> executeFocus(ctx.getSource(), StringArgumentType.getString(ctx, "guild")))
27+
.then(argument("message", StringArgumentType.greedyString())
28+
.executes(ctx -> executeChat(ctx.getSource(), StringArgumentType.getString(ctx, "guild"), StringArgumentType.getString(ctx, "message")))
29+
)
30+
);
31+
}
32+
33+
public static LiteralArgumentBuilder<ISuggestionProvider> builderG() {
34+
return literal("cg")
35+
.then(argument("message", StringArgumentType.greedyString())
36+
.executes(ctx -> executeChat(ctx.getSource(), null, StringArgumentType.getString(ctx, "message")))
37+
);
38+
}
39+
40+
public static LiteralArgumentBuilder<ISuggestionProvider> builderReconnectInterChat() {
41+
return literal("reconnectinterchat")
42+
.executes(ctx -> {
43+
Mod.reconnect();
44+
return 0;
45+
})
46+
.then(argument("apikey", StringArgumentType.greedyString())
47+
.executes(ctx -> {
48+
ModConfig.apiKey = StringArgumentType.getString(ctx, "apikey");
49+
Mod.reconnect();
50+
return 0;
51+
})
52+
);
53+
}
54+
55+
public static LiteralArgumentBuilder<ISuggestionProvider> builderGuild() {
56+
return literal("cguild")
57+
.then(literal("invite")
58+
.then(argument("player", StringArgumentType.word())
59+
.executes(ctx -> {
60+
Mod.client.invite(StringArgumentType.getString(ctx, "player"));
61+
return 0;
62+
})
63+
)
64+
)
65+
.then(literal("accept")
66+
.then(argument("guild", StringArgumentType.word())
67+
.executes(ctx -> {
68+
Mod.client.respondInvite(StringArgumentType.getString(ctx, "guild"), true);
69+
return 0;
70+
})
71+
)
72+
)
73+
.then(literal("reject")
74+
.then(argument("guild", StringArgumentType.word())
75+
.executes(ctx -> {
76+
Mod.client.respondInvite(StringArgumentType.getString(ctx, "guild"), false);
77+
return 0;
78+
})
79+
)
80+
)
81+
.then(literal("nick")
82+
.executes(ctx -> {
83+
Mod.client.nick(null);
84+
return 0;
85+
})
86+
.then(argument("nickname", StringArgumentType.greedyString())
87+
.executes(ctx -> {
88+
Mod.client.nick(StringArgumentType.getString(ctx, "nickname"));
89+
return 0;
90+
})
91+
)
92+
);
93+
}
94+
95+
public static LiteralArgumentBuilder<ISuggestionProvider> builderInterChatConfig() {
96+
return literal("interchatconfig").executes(ctx -> {
97+
Minecraft.getInstance().enqueue(() -> Minecraft.getInstance().displayGuiScreen(new ModConfigScreen(Minecraft.getInstance().currentScreen)));
98+
return 0;
99+
});
100+
}
101+
102+
private static int executeFocus(ISuggestionProvider source, String guildName) {
103+
Guild guild = Mod.GUILDS.stream().filter(g -> g.name().equalsIgnoreCase(guildName)).findAny().orElse(null);
104+
if (guild == null) {
105+
if (source instanceof CommandSource) {
106+
((CommandSource) source).sendErrorMessage(new StringTextComponent("そんなぎるどないよ " + guildName));
107+
}
108+
return 0;
109+
}
110+
Mod.client.selectGuild(guild.id());
111+
if (source instanceof CommandSource) {
112+
((CommandSource) source).sendFeedback(new StringTextComponent(guild.name() + " にちゃっとするようにしたよ(/cg <めっせーじ>でできるよ)"), false);
113+
}
114+
return 1;
115+
}
116+
117+
private static int executeChat(ISuggestionProvider source, String guildName, String message) {
118+
if (guildName != null) {
119+
Guild guild = Mod.GUILDS.stream().filter(g -> g.name().equalsIgnoreCase(guildName)).findAny().orElse(null);
120+
if (guild == null) {
121+
if (source instanceof CommandSource) {
122+
((CommandSource) source).sendErrorMessage(new StringTextComponent("そんなぎるどないよ " + guildName));
123+
}
124+
return 0;
125+
}
126+
Mod.client.sendMessageToGuild(guild.id(), message);
127+
} else {
128+
Mod.client.sendMessageToGuild(null, message);
129+
}
130+
return 1;
131+
}
132+
}

0 commit comments

Comments
 (0)