first commit
This commit is contained in:
164
fabric/build.gradle
Normal file
164
fabric/build.gradle
Normal file
@@ -0,0 +1,164 @@
|
||||
plugins {
|
||||
id 'fabric-loom'
|
||||
id 'com.matthewprenger.cursegradle' version "${cursegradle_version}"
|
||||
id 'com.github.johnrengelman.shadow' version "${shadow_version}"
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaLanguageVersion.of(java_version as int)
|
||||
targetCompatibility = JavaLanguageVersion.of(java_version as int)
|
||||
|
||||
var mod_version = mcef_version
|
||||
|
||||
archivesBaseName = archives_base_name
|
||||
version = mod_version
|
||||
group = maven_group
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = 'https://maven.fabricmc.net/' }
|
||||
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
/*
|
||||
Add the following to ~/.gradle/gradle.properties
|
||||
systemProp.org.gradle.s3.endpoint=https://<the s3 endpoint>
|
||||
MCEF_S3_PUBLISH_URL_SNAPSHOT=s3://<bucket>/repositories/snapshots
|
||||
MCEF_S3_PUBLISH_URL_RELEASE=s3://<bucket>/repositories/releases
|
||||
MCEF_S3_PUBLISH_ACCESS_KEY=<access key>
|
||||
MCEF_S3_PUBLISH_SECRET_KEY=<secret key>
|
||||
*/
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
url ((mcef_version.toString().endsWith("SNAPSHOT")) ? findProperty('MCEF_S3_PUBLISH_URL_SNAPSHOT') : findProperty('MCEF_S3_PUBLISH_URL_RELEASE'))
|
||||
credentials(AwsCredentials) {
|
||||
accessKey = findProperty('MCEF_S3_PUBLISH_ACCESS_KEY')
|
||||
secretKey = findProperty('MCEF_S3_PUBLISH_SECRET_KEY')
|
||||
}
|
||||
}
|
||||
}
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
groupId = 'com.cinemamod'
|
||||
artifactId = 'mcef-fabric'
|
||||
version = mcef_version
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${minecraft_version}"
|
||||
mappings loom.officialMojangMappings()
|
||||
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||
|
||||
Set<String> apiModules = [
|
||||
'fabric-api-base',
|
||||
'fabric-command-api-v2',
|
||||
'fabric-lifecycle-events-v1',
|
||||
'fabric-networking-api-v1',
|
||||
'fabric-resource-loader-v0',
|
||||
'fabric-key-binding-api-v1'
|
||||
]
|
||||
|
||||
apiModules.forEach {
|
||||
modImplementation(fabricApi.module(it, fabric_version))
|
||||
}
|
||||
|
||||
implementation project(path: ':common', configuration: 'namedElements')
|
||||
}
|
||||
|
||||
loom {
|
||||
mixin {
|
||||
defaultRefmapName = "mcef.refmap.json"
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('generateJava', Copy) {
|
||||
from project(':common').file('src/template/java')
|
||||
into "${buildDir}/generated/java"
|
||||
expand 'compatibility_version': mod_compatibility_version
|
||||
}
|
||||
sourceSets.main.java {
|
||||
srcDir "${buildDir}/generated/java"
|
||||
}
|
||||
compileJava.dependsOn generateJava
|
||||
generateJava.dependsOn('sourcesJar')
|
||||
|
||||
processResources {
|
||||
filesMatching('fabric.mod.json') {
|
||||
expand 'mod_id': mod_id,
|
||||
'mod_name': mod_name,
|
||||
'mod_vendor': mod_vendor,
|
||||
'mod_version': mod_version,
|
||||
'java_version': java_version,
|
||||
'minecraft_dependency': minecraft_dependency,
|
||||
'fabric_loader_version': fabric_loader_version,
|
||||
'min_fabric_version': min_fabric_version
|
||||
}
|
||||
from project(":common").sourceSets.main.resources
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
source(project(':common').sourceSets.main.allSource)
|
||||
source(project(':common').sourceSets.jcef.allSource)
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = 'UTF-8'
|
||||
it.options.release = java_version as int
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
jar {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
manifest {
|
||||
attributes(['Specification-Title' : mod_name,
|
||||
'Specification-Vendor' : mod_vendor,
|
||||
'Specification-Version' : "1",
|
||||
'Implementation-Title' : mod_name,
|
||||
'Implementation-Version' : mod_version,
|
||||
'Implementation-Vendor' : mod_vendor,
|
||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||
'java-cef-commit' : project.parent.getCheckedOutGitCommitHash(project.parent)
|
||||
])
|
||||
}
|
||||
from('LICENSE') {
|
||||
rename { "${it}_${archivesBaseName}" }
|
||||
}
|
||||
}
|
||||
|
||||
curseforge {
|
||||
apiKey = file("${rootDir}/curseforge_api_key.txt").exists() ? file("${rootDir}/curseforge_api_key.txt").text.trim() : ''
|
||||
project {
|
||||
id = curse_id
|
||||
releaseType = release_type
|
||||
addGameVersion minecraft_version
|
||||
addGameVersion 'Fabric'
|
||||
addGameVersion "Java ${java_version}"
|
||||
mainArtifact(file("${buildDir}/libs/${archivesBaseName}-${version}.jar")) {
|
||||
displayName = "[FABRIC][${minecraft_version}] ${mod_name} ${mod_version}"
|
||||
}
|
||||
afterEvaluate {
|
||||
uploadTask.dependsOn(remapJar)
|
||||
}
|
||||
}
|
||||
options {
|
||||
forgeGradleIntegration = false
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadow]
|
||||
archiveClassifier = 'shadow-dev'
|
||||
}
|
||||
|
||||
remapJar {
|
||||
dependsOn shadowJar
|
||||
inputFile = shadowJar.archiveFile.get()
|
||||
}
|
||||
15
fabric/gradle.properties
Normal file
15
fabric/gradle.properties
Normal file
@@ -0,0 +1,15 @@
|
||||
org.gradle.jvmargs=-Xmx4G
|
||||
org.gradle.daemon=false
|
||||
|
||||
minecraft_dependency=1.21.1
|
||||
curseforge_minecraft_version=1.21.1
|
||||
|
||||
fabric_version=0.104.0+1.21.1
|
||||
min_fabric_version=0.100.0+1.21
|
||||
|
||||
maven_group=com.cinemamod
|
||||
archives_base_name=mcef-fabric
|
||||
|
||||
curse_id=636236
|
||||
release_type=release
|
||||
recommended=true
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* MCEF (Minecraft Chromium Embedded Framework)
|
||||
* Copyright (C) 2023 CinemaMod Group
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*/
|
||||
|
||||
package com.cinemamod.mcef;
|
||||
|
||||
import com.cinemamod.mcef.example.MCEFExampleMod;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
public class FabricMCEFClientMod implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
if (FabricLoader.getInstance().isDevelopmentEnvironment()) {
|
||||
new MCEFExampleMod();
|
||||
}
|
||||
}
|
||||
}
|
||||
30
fabric/src/main/java/com/cinemamod/mcef/FabricMCEFMod.java
Normal file
30
fabric/src/main/java/com/cinemamod/mcef/FabricMCEFMod.java
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* MCEF (Minecraft Chromium Embedded Framework)
|
||||
* Copyright (C) 2023 CinemaMod Group
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*/
|
||||
|
||||
package com.cinemamod.mcef;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
public class FabricMCEFMod implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
// MCEF server-side does nothing
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* MCEF (Minecraft Chromium Embedded Framework)
|
||||
* Copyright (C) 2023 CinemaMod Group
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*/
|
||||
|
||||
package com.cinemamod.mcef.example;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public class MCEFExampleMod {
|
||||
private static final Minecraft minecraft = Minecraft.getInstance();
|
||||
|
||||
public static final KeyMapping KEY_MAPPING = new KeyMapping(
|
||||
"Open Browser", InputConstants.Type.KEYSYM,
|
||||
GLFW.GLFW_KEY_F10, "key.categories.misc"
|
||||
);
|
||||
|
||||
public MCEFExampleMod() {
|
||||
ClientTickEvents.START_CLIENT_TICK.register((client) -> onTick());
|
||||
}
|
||||
|
||||
public void onTick() {
|
||||
// Check if our key was pressed
|
||||
if (KEY_MAPPING.isDown() && !(minecraft.screen instanceof ExampleScreen)) {
|
||||
//Display the web browser UI.
|
||||
minecraft.setScreen(new ExampleScreen(
|
||||
Component.literal("Example Screen")
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
38
fabric/src/main/resources/fabric.mod.json
Normal file
38
fabric/src/main/resources/fabric.mod.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "${mod_id}",
|
||||
"version": "${mod_version}",
|
||||
"name": "${mod_name}",
|
||||
"description": "A Minecraft mod and library for adding the Chromium web browser into the game (Minecraft Chromium Embedded Framework).",
|
||||
"authors": [
|
||||
"${mod_vendor}"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://github.com/CinemaMod/mcef",
|
||||
"issues": "https://github.com/CinemaMod/mcef/issues",
|
||||
"sources": "https://github.com/CinemaMod/mcef",
|
||||
"discord": "https://discord.gg/rNrh5kW8Ty"
|
||||
},
|
||||
"license": "LGPL 2.1",
|
||||
"icon": "icon.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"com.cinemamod.mcef.FabricMCEFClientMod"
|
||||
],
|
||||
"main": [
|
||||
"com.cinemamod.mcef.FabricMCEFMod"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"mcef.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=${fabric_loader_version}",
|
||||
"minecraft": ["1.21", "1.21.1"],
|
||||
"java": ">=${java_version}"
|
||||
},
|
||||
"breaks": {
|
||||
"fabric-api": "<${min_fabric_version}"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user