Skip to content

Commit 66374fb

Browse files
committed
Add initial implementation of NekoJS Addon Example mod
1 parent 472d1b6 commit 66374fb

File tree

20 files changed

+779
-0
lines changed

20 files changed

+779
-0
lines changed

.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/* text eol=lf
5+
src/generated/**/*.json text eol=lf

.github/workflows/build.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout repository
10+
uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
fetch-tags: true
14+
15+
- name: Setup JDK 25
16+
uses: actions/setup-java@v4
17+
with:
18+
java-version: '25'
19+
distribution: 'temurin'
20+
21+
- name: Setup Gradle
22+
uses: gradle/actions/setup-gradle@v4
23+
24+
# This is needed to be able to run ./gradlew below
25+
# You can run `git update-index --chmod +x gradlew` then remove this step.
26+
- name: Make Gradle wrapper executable
27+
run: chmod +x ./gradlew
28+
29+
- name: Build with Gradle
30+
run: ./gradlew build

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
### Gradle ###
2+
.gradle
3+
build/
4+
!gradle/wrapper/gradle-wrapper.jar
5+
!**/src/**/build/
6+
7+
### IntelliJ IDEA ###
8+
.idea/
9+
*.iws
10+
*.iml
11+
*.ipr
12+
out/
13+
!**/src/**/out/
14+
15+
.run/
16+
17+
### Eclipse ###
18+
.apt_generated
19+
.classpath
20+
.eclipse/
21+
.factorypath
22+
.project
23+
.settings
24+
.springBeans
25+
.sts4-cache
26+
bin/
27+
!**/src/**/bin/
28+
29+
### VS Code ###
30+
.vscode/
31+
32+
### Mac OS ###
33+
.DS_Store
34+
35+
### Minecraft Modding ###
36+
run/
37+
!**/src/**/run/
38+
**/src/generated/**/.cache/
39+
repo/
40+
!**/src/**/repo/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# NekoJS Addon Example

TEMPLATE_LICENSE.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
MIT License
2+
3+
Copyright (c) 2023 NeoForged project
4+
5+
This license applies to the template files as supplied by github.com/NeoForged/MDK
6+
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy
9+
of this software and associated documentation files (the "Software"), to deal
10+
in the Software without restriction, including without limitation the rights
11+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
copies of the Software, and to permit persons to whom the Software is
13+
furnished to do so, subject to the following conditions:
14+
15+
The above copyright notice and this permission notice shall be included in all
16+
copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
SOFTWARE.

build.gradle

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
plugins {
2+
id 'java-library'
3+
id 'maven-publish'
4+
id 'net.neoforged.moddev' version '2.0.141'
5+
id 'idea'
6+
}
7+
8+
tasks.named('wrapper', Wrapper).configure {
9+
// Define wrapper values here so as to not have to always do so when updating gradlew.properties.
10+
// Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
11+
// documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
12+
// file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
13+
// (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
14+
distributionType = Wrapper.DistributionType.BIN
15+
}
16+
17+
version = mod_version
18+
group = mod_group_id
19+
20+
sourceSets.main.resources {
21+
// Include resources generated by data generators.
22+
srcDir('src/generated/resources')
23+
24+
// Exclude common development only resources from finalized outputs
25+
exclude("**/*.bbmodel") // BlockBench project files
26+
exclude("src/generated/**/.cache") // datagen cache files
27+
}
28+
29+
repositories {
30+
// Add here additional repositories if required by some of the dependencies below.
31+
}
32+
33+
base {
34+
archivesName = mod_id
35+
}
36+
37+
// Mojang ships Java 25 to end users in 26.1, so mods should target Java 25.
38+
java.toolchain.languageVersion = JavaLanguageVersion.of(25)
39+
40+
neoForge {
41+
// Specify the version of NeoForge to use.
42+
version = project.neo_version
43+
44+
// This line is optional. Access Transformers are automatically detected
45+
// accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')
46+
47+
// Default run configurations.
48+
// These can be tweaked, removed, or duplicated as needed.
49+
runs {
50+
client {
51+
client()
52+
53+
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
54+
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
55+
}
56+
57+
server {
58+
server()
59+
programArgument '--nogui'
60+
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
61+
}
62+
63+
// This run config launches GameTestServer and runs all registered gametests, then exits.
64+
// By default, the server will crash when no gametests are provided.
65+
// The gametest system is also enabled by default for other run configs under the /test command.
66+
gameTestServer {
67+
type = "gameTestServer"
68+
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
69+
}
70+
71+
data {
72+
clientData()
73+
74+
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
75+
// gameDirectory = project.file('run-data')
76+
77+
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
78+
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
79+
}
80+
81+
// applies to all the run configs above
82+
configureEach {
83+
// Recommended logging data for a userdev environment
84+
// The markers can be added/remove as needed separated by commas.
85+
// "SCAN": For mods scan.
86+
// "REGISTRIES": For firing of registry events.
87+
// "REGISTRYDUMP": For getting the contents of all registries.
88+
systemProperty 'forge.logging.markers', 'REGISTRIES'
89+
90+
// Recommended logging level for the console
91+
// You can set various levels here.
92+
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
93+
logLevel = org.slf4j.event.Level.DEBUG
94+
}
95+
}
96+
97+
mods {
98+
// define mod <-> source bindings
99+
// these are used to tell the game which sources are for which mod
100+
// multi mod projects should define one per mod
101+
"${mod_id}" {
102+
sourceSet(sourceSets.main)
103+
}
104+
}
105+
}
106+
107+
// Sets up a dependency configuration called 'localRuntime'.
108+
// This configuration should be used instead of 'runtimeOnly' to declare
109+
// a dependency that will be present for runtime testing but that is
110+
// "optional", meaning it will not be pulled by dependents of this mod.
111+
configurations {
112+
runtimeClasspath.extendsFrom localRuntime
113+
}
114+
115+
dependencies {
116+
// Example optional mod dependency with JEI
117+
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
118+
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
119+
// compileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}"
120+
// We add the full version to localRuntime, not runtimeOnly, so that we do not publish a dependency on it
121+
// localRuntime "mezz.jei:jei-${mc_version}-neoforge:${jei_version}"
122+
123+
// Example mod dependency using a mod jar from ./libs with a flat dir repository
124+
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
125+
// The group id is ignored when searching -- in this case, it is "blank"
126+
// implementation "blank:coolmod-${mc_version}:${coolmod_version}"
127+
128+
// Example mod dependency using a file as dependency
129+
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
130+
131+
// Example project dependency using a sister or child project:
132+
// implementation project(":myproject")
133+
134+
// For more info:
135+
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
136+
// http://www.gradle.org/docs/current/userguide/dependency_management.html
137+
implementation files('libs/GraalJS-25.0.1-neoforge.jar')
138+
implementation files('libs/nekojs-26.1-1.0.5.jar')
139+
implementation files('libs/nekoprobe-1.26.1.0.0-alpha-1.0.2.jar')
140+
141+
compileOnly 'org.projectlombok:lombok:1.18.44'
142+
annotationProcessor 'org.projectlombok:lombok:1.18.44'
143+
144+
testCompileOnly 'org.projectlombok:lombok:1.18.44'
145+
testAnnotationProcessor 'org.projectlombok:lombok:1.18.44'
146+
}
147+
148+
// This block of code expands all declared replace properties in the specified resource targets.
149+
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
150+
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
151+
var replaceProperties = [
152+
minecraft_version : minecraft_version,
153+
minecraft_version_range: minecraft_version_range,
154+
neo_version : neo_version,
155+
neo_version_range : neo_version_range,
156+
loader_version_range : loader_version_range,
157+
mod_id : mod_id,
158+
mod_name : mod_name,
159+
mod_license : mod_license,
160+
mod_version : mod_version,
161+
mod_authors : mod_authors,
162+
mod_description : mod_description,
163+
nekojs_version_range : nekojs_version_range
164+
]
165+
inputs.properties replaceProperties
166+
expand replaceProperties
167+
from "src/main/templates"
168+
into "build/generated/sources/modMetadata"
169+
}
170+
// Include the output of "generateModMetadata" as an input directory for the build
171+
// this works with both building through Gradle and the IDE.
172+
sourceSets.main.resources.srcDir generateModMetadata
173+
// To avoid having to run "generateModMetadata" manually, make it run on every project reload
174+
neoForge.ideSyncTask generateModMetadata
175+
176+
// Example configuration to allow publishing using the maven-publish plugin
177+
publishing {
178+
publications {
179+
register('mavenJava', MavenPublication) {
180+
from components.java
181+
}
182+
}
183+
repositories {
184+
maven {
185+
url "file://${project.projectDir}/repo"
186+
}
187+
}
188+
}
189+
190+
tasks.withType(JavaCompile).configureEach {
191+
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
192+
}
193+
194+
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
195+
idea {
196+
module {
197+
downloadSources = true
198+
downloadJavadoc = true
199+
}
200+
}

gradle.properties

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
org.gradle.jvmargs=-Xmx4G
2+
org.gradle.daemon=true
3+
org.gradle.parallel=true
4+
org.gradle.caching=true
5+
org.gradle.configuration-cache=true
6+
7+
minecraft_version=26.1
8+
minecraft_version_range=[26.1]
9+
neo_version=26.1.0.7-beta
10+
neo_version_range=[26.1,)
11+
loader_version_range=[4,)
12+
13+
mod_id=nekojs_addon_example
14+
mod_name=NekoJS Addon Example
15+
mod_license=AGPL-3.0
16+
mod_version=0.0.1
17+
mod_group_id=dev.mangojellypudding.nekojs_addon_example
18+
mod_authors=MangoJellyPudding
19+
mod_description=An example addon for NekoJS, showcasing how to create a simple mod that integrates with the NekoJS scripting engine. This addon serves as a template for developers looking to create their own addons for NekoJS, providing basic functionality and demonstrating best practices for mod development.
20+
nekojs_version_range=[1.0.5,)

gradle/wrapper/gradle-wrapper.jar

42.7 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)