Skip to content

Commit

Permalink
Add support for Forge
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeregorix committed Oct 26, 2022
1 parent 0dbfdc3 commit 87c0922
Show file tree
Hide file tree
Showing 10 changed files with 263 additions and 97 deletions.
117 changes: 56 additions & 61 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,88 +23,83 @@
plugins {
id 'java-library'
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'org.spongepowered.gradle.vanilla' version '0.2'
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
}

group 'net.smoofyuniverse'
allprojects {
apply plugin: 'java-library'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = "utf-8"
}
group 'net.smoofyuniverse'

repositories {
mavenCentral()
maven {
name = 'sponge'
url = 'https://repo.spongepowered.org/repository/maven-public/'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}
}

configurations {
spongevanilla
spongeforge
}

dependencies {
implementation 'org.spongepowered:sponge:1.16.5-8.1.0-SNAPSHOT:dev'
implementation 'org.spongepowered:mixin:0.8.4'
implementation 'org.ow2.asm:asm-util:9.2'
tasks.withType(JavaCompile).configureEach {
options.encoding = "utf-8"
}

implementation 'net.smoofyuniverse:oreupdater:1.1.1'
implementation 'net.smoofyuniverse:worldmap:1.1.0'
repositories {
mavenCentral()
maven {
name = 'sponge'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
}

spongevanilla 'org.spongepowered:spongevanilla:1.16.5-8.1.0-RC1185:universal'
spongeforge 'org.spongepowered:spongeforge:1.16.5-36.2.5-8.1.0-RC1185:universal'
}
configurations {
provided
shade

minecraft {
version("1.16.5")
}
provided.extendsFrom shade
implementation.extendsFrom provided
}

jar {
classifier 'base'
manifest {
attributes(
'MixinConfigs': 'mixins.superpiston.json'
)
jar {
classifier 'base'
}
}

shadowJar {
classifier ''
subprojects {
apply plugin: 'com.github.johnrengelman.shadow'

dependencies {
include dependency('net.smoofyuniverse:oreapi')
include dependency('net.smoofyuniverse:oreupdater')
include dependency('net.smoofyuniverse:worldmap')
}
shadowJar {
classifier 'shadow'
configurations = [project.configurations.shade]

relocate 'net.smoofyuniverse.ore', 'net.smoofyuniverse.superpiston.ore'
relocate 'net.smoofyuniverse.map', 'net.smoofyuniverse.superpiston.map'
}
dependencies {
include project(':')
include dependency('net.smoofyuniverse:oreapi')
include dependency('net.smoofyuniverse:oreupdater')
include dependency('net.smoofyuniverse:worldmap')
}

task setupVanillaServer(type: Copy) {
into 'run/vanilla'
relocate 'net.smoofyuniverse.ore', 'net.smoofyuniverse.superpiston.ore'
relocate 'net.smoofyuniverse.map', 'net.smoofyuniverse.superpiston.map'

from configurations.spongevanilla
rename('spongevanilla-(.*).jar', 'spongevanilla.jar')
manifest {
attributes('MixinConfigs': 'mixins.superpiston.json')
}
}

into('mods') {
from shadowJar
dependencies {
provided project(path: ':', configuration: 'provided')
shade project(path: ':', transitive: false)
shade project(path: ':', configuration: 'shade')
}
}

task setupForgeServer(type: Copy) {
into 'run/forge/mods'
dependencies {
provided 'org.spongepowered:sponge:1.16.5-8.1.0-SNAPSHOT:dev'
provided 'org.spongepowered:mixin:0.8.4'
provided 'org.ow2.asm:asm-util:9.2'

from configurations.spongeforge
rename('spongeforge-(.*).jar', 'spongeforge.jar')
shade 'net.smoofyuniverse:oreupdater:1.1.2'
shade 'net.smoofyuniverse:worldmap:1.1.0'
}

from shadowJar
minecraft {
version '1.16.5'
}
62 changes: 62 additions & 0 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2018-2022 Hugo Dupanloup (Yeregorix)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
plugins {
id "net.smoofyuniverse.loom" version "0.12.0-SNAPSHOT"
}

archivesBaseName = 'SuperPiston-forge'

loom {
silentMojangMappingsLicense()

mixin {
useLegacyMixinAp = false
}
}

configurations {
spongeforge
}

dependencies {
minecraft 'com.mojang:minecraft:1.16.5'
forge 'net.minecraftforge:forge:1.16.5-36.2.5'
mappings loom.officialMojangMappings()

spongeforge 'org.spongepowered:spongeforge:1.16.5-36.2.5-8.1.0-RC1185:universal'
}

remapJar {
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
}

build.dependsOn remapJar

task setupServer(type: Copy) {
into 'run/mods'

from configurations.spongeforge
rename('spongeforge-(.*).jar', 'spongeforge.jar')

from remapJar
}
1 change: 1 addition & 0 deletions forge/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=forge
41 changes: 41 additions & 0 deletions forge/src/main/resources/META-INF/sponge_plugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"loader": {
"name": "java_plain",
"version": "1.0"
},
"license": "MIT",
"plugins": [
{
"id": "superpiston",
"name": "SuperPiston",
"version": "1.1.1-forge",
"entrypoint": "net.smoofyuniverse.superpiston.SuperPiston",
"description": "Configurable piston behavior",
"links": {
"homepage": "https://ore.spongepowered.org/Yeregorix/SuperPiston",
"source": "https://github.com/Yeregorix/SuperPiston/",
"issues": "https://github.com/Yeregorix/SuperPiston/issues"
},
"contributors": [
{
"name": "Yeregorix",
"description": "Lead Developer"
}
],
"dependencies": [
{
"id": "spongeapi",
"version": "8.1.0",
"load-order": "AFTER",
"optional": false
},
{
"id": "spongeforge",
"version": "8.1.0",
"load-order": "AFTER",
"optional": false
}
]
}
]
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx2G
10 changes: 10 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
pluginManagement {
repositories {
maven { url "https://repo.spongepowered.org/repository/maven-public" }
maven { url "https://maven.architectury.dev/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
gradlePluginPortal()
}
}

rootProject.name = 'SuperPiston'

include ':forge'
include ':vanilla'
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.api.Game;
import org.spongepowered.api.Platform;
import org.spongepowered.api.Server;
import org.spongepowered.api.config.ConfigDir;
import org.spongepowered.api.event.Listener;
Expand Down Expand Up @@ -105,8 +106,10 @@ public void onServerStarting(StartingEngineEvent<Server> e) {

this.game.eventManager().registerListeners(this.container, new PistonListener(this));

String platformId = this.game.platform().container(Platform.Component.IMPLEMENTATION).metadata().id();

this.game.eventManager().registerListeners(this.container, new UpdateChecker(LOGGER, this.container,
createConfigLoader(this.configDir.resolve("update.conf")), "Yeregorix", "SuperPiston"));
createConfigLoader(this.configDir.resolve("update.conf")), "Yeregorix", "SuperPiston", platformId));
}

private void loadConfigs() {
Expand Down
35 changes: 0 additions & 35 deletions src/main/resources/META-INF/sponge_plugins.json

This file was deleted.

47 changes: 47 additions & 0 deletions vanilla/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018-2022 Hugo Dupanloup (Yeregorix)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
archivesBaseName = 'SuperPiston-vanilla'

configurations {
spongevanilla
}

dependencies {
spongevanilla 'org.spongepowered:spongevanilla:1.16.5-8.1.0-RC1185:universal'
}

shadowJar {
classifier ''
}

build.dependsOn shadowJar

task setupServer(type: Copy) {
into 'run'

from configurations.spongevanilla
rename('spongevanilla-(.*).jar', 'spongevanilla.jar')

into('mods') {
from shadowJar
}
}
Loading

0 comments on commit 87c0922

Please sign in to comment.