Skip to content

Commit bd0aabe

Browse files
committed
Merge remote-tracking branch 'upstream/api-8' into fabric
2 parents d6fe7e8 + a375937 commit bd0aabe

File tree

314 files changed

+10645
-4614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

314 files changed

+10645
-4614
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Thumbs.db
6464
.settings
6565
.checkstyle
6666
.factorypath
67-
run
6867
eclipse
6968
nbproject
7069
atlassian-ide-plugin.xml
@@ -78,6 +77,8 @@ nb-configuration.xml
7877
/.nb-gradle/
7978
# We need to exclude the copied files.
8079
buildSrc/src/api
80+
# forge-loom always generates this for some reason...
81+
/.vscode/
8182

8283
# This is to optionally enable testplugins in development.
8384
# the test plugins themselves can be committed as examples.

forge/build.gradle.kts

+372
Large diffs are not rendered by default.

forge/gradle.properties

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ name=SpongeForge
22
implementation=Forge
33
description=The SpongeAPI implementation for MinecraftForge
44

5-
forgeDep=forge
6-
forgeOrg=net.minecraftforge
7-
forgeVersion=35.1.13
5+
forgeVersion=36.2.1
6+
loom.platform=forge
7+
mixinConfigs=mixins.spongeforge.accessors.json,mixins.spongeforge.api.json,mixins.spongeforge.core.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of Sponge, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.forge.accessor.fml;
26+
27+
import net.minecraftforge.fml.ModContainer;
28+
import net.minecraftforge.fml.ModList;
29+
import org.spongepowered.asm.mixin.Mixin;
30+
import org.spongepowered.asm.mixin.gen.Accessor;
31+
32+
import java.util.List;
33+
34+
@Mixin(value = ModList.class, remap = false)
35+
public interface ModListAccessor {
36+
37+
@Accessor("mods") List<ModContainer> accessor$mods();
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* This file is part of Sponge, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.forge.accessor.fml.javafmlmod;
26+
27+
import net.minecraftforge.fml.javafmlmod.FMLModContainer;
28+
import net.minecraftforge.forgespi.language.ModFileScanData;
29+
import org.spongepowered.asm.mixin.Mixin;
30+
import org.spongepowered.asm.mixin.gen.Accessor;
31+
32+
@Mixin(FMLModContainer.class)
33+
public interface FMLModContainerAccessor {
34+
35+
@Accessor("scanResults") ModFileScanData accessor$scanResults();
36+
37+
@Accessor("modClass") Class<?> accessor$modClass();
38+
39+
@Accessor("modInstance") void accessor$setModInstance(Object instance);
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"required": true,
3+
"parent": "mixins.sponge.parent.json",
4+
"package": "org.spongepowered.forge.accessor",
5+
"mixins": [
6+
"fml.ModListAccessor",
7+
"fml.javafmlmod.FMLModContainerAccessor"
8+
]
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* This file is part of Sponge, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.forge.applaunch.loading.metadata;
26+
27+
import net.minecraftforge.forgespi.language.IConfigurable;
28+
import net.minecraftforge.forgespi.language.IModInfo;
29+
import org.spongepowered.plugin.metadata.PluginDependency;
30+
import org.spongepowered.plugin.metadata.PluginMetadata;
31+
32+
import java.util.Collections;
33+
import java.util.List;
34+
import java.util.Optional;
35+
36+
// ModVersion
37+
public final class PluginDependencyConfigurable implements IConfigurable {
38+
39+
private final PluginMetadata metadata;
40+
private final PluginDependency dependency;
41+
42+
public PluginDependencyConfigurable(final PluginMetadata metadata, final PluginDependency dependency) {
43+
this.metadata = metadata;
44+
this.dependency = dependency;
45+
}
46+
47+
@SuppressWarnings("unchecked")
48+
@Override
49+
public <T> Optional<T> getConfigElement(final String... key) {
50+
if (key.length != 1) {
51+
return Optional.empty();
52+
}
53+
54+
final String query = key[0];
55+
if ("modId".equals(query)) {
56+
return (Optional<T>) Optional.of(this.dependency.id());
57+
}
58+
if ("mandatory".equals(query)) {
59+
return (Optional<T>) Optional.of(!this.dependency.optional());
60+
}
61+
if ("versionRange".equals(query)) {
62+
return (Optional<T>) Optional.of(this.dependency.version());
63+
}
64+
if ("ordering".equals(query)) {
65+
return (Optional<T>) Optional.of(this.loadToOrdering(this.dependency.loadOrder()).toString());
66+
}
67+
if ("side".equals(query)) {
68+
return (Optional<T>) Optional.of(IModInfo.DependencySide.BOTH.toString());
69+
}
70+
return Optional.empty();
71+
}
72+
73+
@Override
74+
public List<? extends IConfigurable> getConfigList(final String... key) {
75+
return Collections.emptyList();
76+
}
77+
78+
private IModInfo.Ordering loadToOrdering(final PluginDependency.LoadOrder order) {
79+
if (order == PluginDependency.LoadOrder.AFTER) {
80+
return IModInfo.Ordering.AFTER;
81+
}
82+
83+
return IModInfo.Ordering.NONE;
84+
}
85+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
* This file is part of Sponge, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.forge.applaunch.loading.metadata;
26+
27+
import net.minecraftforge.forgespi.language.IConfigurable;
28+
import org.spongepowered.plugin.metadata.PluginDependency;
29+
import org.spongepowered.plugin.metadata.PluginMetadata;
30+
import org.spongepowered.plugin.metadata.PluginMetadataContainer;
31+
32+
import java.util.ArrayList;
33+
import java.util.Collections;
34+
import java.util.List;
35+
import java.util.Map;
36+
import java.util.Optional;
37+
38+
// ModFileInfo
39+
public final class PluginFileConfigurable implements IConfigurable {
40+
41+
private final PluginMetadataContainer container;
42+
43+
public PluginFileConfigurable(final PluginMetadataContainer container) {
44+
this.container = container;
45+
}
46+
47+
@SuppressWarnings("unchecked")
48+
@Override
49+
public <T> Optional<T> getConfigElement(final String... key) {
50+
if (key.length < 1) {
51+
return Optional.empty();
52+
}
53+
54+
final String query = key[0];
55+
if (key.length != this.requiredConfigElements(query)) {
56+
return Optional.empty();
57+
}
58+
59+
if ("modLoader".equals(query)) {
60+
// TODO PluginMetadata will require moving this to per-file metadata and not per-plugin
61+
return (Optional<T>) Optional.of("sponge_java_plain");
62+
}
63+
64+
if ("loaderVersion".equals(query)) {
65+
// TODO Need to have loaders "versioned" in plugin-spi or just always do 1.0...may be no point in this?
66+
return (Optional<T>) Optional.of("1.0");
67+
}
68+
69+
if ("license".equals(query)) {
70+
// TODO PluginMetadata will require a "license" field
71+
return (Optional<T>) Optional.of("MIT");
72+
}
73+
74+
if (key.length == 2) {
75+
final String plugin = key[1];
76+
final PluginMetadata metadata = this.container.metadata(plugin).orElse(null);
77+
if (metadata == null) {
78+
return Optional.empty();
79+
}
80+
81+
if ("modproperties".equals(query)) {
82+
return (Optional<T>) Optional.of(metadata.extraMetadata());
83+
}
84+
}
85+
86+
return Optional.empty();
87+
}
88+
89+
@Override
90+
public List<? extends IConfigurable> getConfigList(final String... key) {
91+
if (key.length < 1) {
92+
return Collections.emptyList();
93+
}
94+
95+
final String query = key[0];
96+
if (key.length != this.requiredConfigElements(query)) {
97+
return Collections.emptyList();
98+
}
99+
100+
if ("mods".equals(query)) {
101+
final Map<String, PluginMetadata> metadataById = this.container.allMetadata();
102+
if (metadataById.isEmpty()) {
103+
return Collections.emptyList();
104+
}
105+
106+
final List<IConfigurable> metadataConfigurables = new ArrayList<>();
107+
metadataById.forEach((id, metadata) -> metadataConfigurables.add(new PluginMetadataConfigurable(metadata)));
108+
return metadataConfigurables;
109+
}
110+
111+
if (key.length != 2) {
112+
return Collections.emptyList();
113+
}
114+
115+
final String plugin = key[1];
116+
final PluginMetadata metadata = this.container.metadata(plugin).orElse(null);
117+
if (metadata == null) {
118+
return Collections.emptyList();
119+
}
120+
121+
if ("dependencies".equals(query)) {
122+
123+
// TODO Should we inject a dependency on SpongeForge?
124+
final List<PluginDependency> dependencies = metadata.dependencies();
125+
if (dependencies.isEmpty()) {
126+
return Collections.emptyList();
127+
}
128+
129+
final List<IConfigurable> depConfigurables = new ArrayList<>();
130+
for (final PluginDependency dependency : dependencies) {
131+
depConfigurables.add(new PluginDependencyConfigurable(metadata, dependency));
132+
}
133+
134+
return depConfigurables;
135+
}
136+
137+
return Collections.emptyList();
138+
}
139+
140+
private int requiredConfigElements(final String query) {
141+
if ("dependencies".equals(query) || "modproperties".equals(query)) {
142+
return 2;
143+
}
144+
145+
return 1;
146+
}
147+
}

0 commit comments

Comments
 (0)