This commit is contained in:
parent
7da36aa083
commit
e1f486a750
4
Jenkinsfile
vendored
4
Jenkinsfile
vendored
@ -1,6 +1,8 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent {
|
agent {
|
||||||
dockerfile true
|
dockerfile {
|
||||||
|
args '-v /data/maven:/data/maven'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('Setup') {
|
stage('Setup') {
|
||||||
|
31
build.gradle
31
build.gradle
@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.2.7-SNAPSHOT'
|
id 'fabric-loom' version '0.2.7-SNAPSHOT'
|
||||||
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava {
|
compileJava {
|
||||||
@ -62,27 +62,20 @@ jar {
|
|||||||
from 'LICENSE'
|
from 'LICENSE'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project.hasProperty('curseforge.api_key')) {
|
publishing {
|
||||||
curseforge {
|
publications {
|
||||||
apiKey = project.getProperty('curseforge.api_key')
|
mavenJava(MavenPublication) {
|
||||||
project {
|
artifact(remapJar) {
|
||||||
id = project.curseforge_id
|
builtBy remapJar
|
||||||
changelog = 'A changelog can be found at https://gitea.thebrokenrail.com/TheBrokenRail/ScriptCraft/src/branch/master/CHANGELOG.md'
|
|
||||||
releaseType = 'release'
|
|
||||||
addGameVersion project.simple_minecraft_version
|
|
||||||
addGameVersion 'Fabric'
|
|
||||||
mainArtifact(remapJar) {
|
|
||||||
displayName = "ScriptCraft v${mod_version} for ${project.minecraft_version}"
|
|
||||||
}
|
}
|
||||||
afterEvaluate {
|
artifact(typescriptAPI) {
|
||||||
uploadTask.dependsOn('remapJar')
|
builtBy typescriptAPI
|
||||||
}
|
|
||||||
relations {
|
|
||||||
requiredDependency 'fabric-api'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
options {
|
}
|
||||||
forgeGradleIntegration = false
|
repositories {
|
||||||
|
maven {
|
||||||
|
url '/data/maven'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
28
examples/typescript/.gitignore
vendored
Normal file
28
examples/typescript/.gitignore
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# gradle
|
||||||
|
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
out/
|
||||||
|
classes/
|
||||||
|
|
||||||
|
# idea
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# vscode
|
||||||
|
|
||||||
|
.settings/
|
||||||
|
bin/
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
|
||||||
|
# fabric
|
||||||
|
|
||||||
|
run/
|
||||||
|
|
||||||
|
remappedSrc/
|
||||||
|
|
||||||
|
libs/
|
68
examples/typescript/build.gradle
Normal file
68
examples/typescript/build.gradle
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
plugins {
|
||||||
|
id 'fabric-loom' version '0.2.7-SNAPSHOT'
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
archivesBaseName = project.archives_base_name
|
||||||
|
def mod_version = project.mod_version as Object
|
||||||
|
version = "${mod_version}+${project.minecraft_version}"
|
||||||
|
group = project.maven_group as Object
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
flatDir {
|
||||||
|
dirs 'libs'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
|
mappings "net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_build}:v2"
|
||||||
|
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
|
||||||
|
|
||||||
|
modImplementation name: 'scriptcraft'
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: './typescript.build.gradle'
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property 'version', mod_version
|
||||||
|
|
||||||
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
|
include 'fabric.mod.json'
|
||||||
|
expand 'version': mod_version
|
||||||
|
}
|
||||||
|
|
||||||
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
|
exclude 'fabric.mod.json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||||
|
// this fixes some edge cases with special characters not displaying correctly
|
||||||
|
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||||
|
// if it is present.
|
||||||
|
// If you remove this task, sources will not be generated.
|
||||||
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||||
|
classifier 'sources'
|
||||||
|
from sourceSets.main.allSource
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives sourcesJar
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
from 'LICENSE'
|
||||||
|
}
|
1
examples/typescript/gradle
Symbolic link
1
examples/typescript/gradle
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../gradle
|
13
examples/typescript/gradle.properties
Normal file
13
examples/typescript/gradle.properties
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Done to increase the memory available to gradle.
|
||||||
|
org.gradle.jvmargs = -Xmx1G
|
||||||
|
|
||||||
|
# Fabric Properties
|
||||||
|
# check these on https://fabricmc.net/use
|
||||||
|
minecraft_version = 1.15.2
|
||||||
|
yarn_build = 15
|
||||||
|
fabric_loader_version = 0.8.2+build.194
|
||||||
|
|
||||||
|
# Mod Properties
|
||||||
|
mod_version = 1.0.0
|
||||||
|
maven_group = com.thebrokenrail
|
||||||
|
archives_base_name = scriptcraft-typescript-example
|
1
examples/typescript/gradlew
vendored
Symbolic link
1
examples/typescript/gradlew
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../gradlew
|
1
examples/typescript/gradlew.bat
vendored
Symbolic link
1
examples/typescript/gradlew.bat
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../gradlew.bat
|
16
examples/typescript/scripts/setup.sh
Normal file
16
examples/typescript/scripts/setup.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SCRIPTCRAFT_BRANCH='master'
|
||||||
|
|
||||||
|
if [ -d ../libs ]; then
|
||||||
|
rm -rf ../libs
|
||||||
|
fi
|
||||||
|
mkdir ../libs
|
||||||
|
|
||||||
|
curl -L -o ../libs/scriptcraft.jar "https://jenkins.thebrokenrail.com/job/ScriptCraft/job/${SCRIPTCRAFT_BRANCH}/lastSuccessfulBuild/artifact/build/libs/scriptcraft-1.0.0-SNAPSHOT.jar"
|
||||||
|
curl -L -o ../libs/scriptcraft-api.tar.gz "https://jenkins.thebrokenrail.com/job/ScriptCraft/job/${SCRIPTCRAFT_BRANCH}/lastSuccessfulBuild/artifact/build/distributions/scriptcraft-1.0.0-SNAPSHOT-api.tar.gz"
|
||||||
|
|
||||||
|
cd ../src/main/ts
|
||||||
|
npm install
|
1
examples/typescript/settings.gradle
Symbolic link
1
examples/typescript/settings.gradle
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../settings.gradle
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.thebrokenrail.scriptcraft.example;
|
||||||
|
|
||||||
|
import com.thebrokenrail.scriptcraft.core.ScriptCraftEntrypoint;
|
||||||
|
|
||||||
|
public class TypeScriptExample implements ScriptCraftEntrypoint {
|
||||||
|
@Override
|
||||||
|
public String getModID() {
|
||||||
|
return "modid";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModIndex() {
|
||||||
|
return "index.js";
|
||||||
|
}
|
||||||
|
}
|
1
examples/typescript/src/main/resources/assets
Symbolic link
1
examples/typescript/src/main/resources/assets
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../../../src/main/resources/assets
|
28
examples/typescript/src/main/resources/fabric.mod.json
Normal file
28
examples/typescript/src/main/resources/fabric.mod.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"id": "modid",
|
||||||
|
"version": "${version}",
|
||||||
|
"name": "ScriptCraft TypeScript Example",
|
||||||
|
"description": "TypeScript Example for ScriptCraft",
|
||||||
|
"authors": [
|
||||||
|
"TheBrokenRail"
|
||||||
|
],
|
||||||
|
"contact": {
|
||||||
|
"homepage": "https://thebrokenrail.com/",
|
||||||
|
"sources": "https://gitea.thebrokenrail.com/TheBrokenRail/ScriptCraft.git",
|
||||||
|
"issues": "https://gitea.thebrokenrail.com/TheBrokenRail/ScriptCraft/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"icon": "assets/scriptcraft/icon.png",
|
||||||
|
"environment": "*",
|
||||||
|
"entrypoints": {
|
||||||
|
"scriptcraft": [
|
||||||
|
"com.thebrokenrail.scriptcraft.example.TypeScriptExample"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"depends": {
|
||||||
|
"fabricloader": ">=0.7.4",
|
||||||
|
"minecraft": "1.15.x",
|
||||||
|
"scriptcraft": "*"
|
||||||
|
}
|
||||||
|
}
|
4
examples/typescript/src/main/ts/.gitignore
vendored
Normal file
4
examples/typescript/src/main/ts/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
node_modules/
|
||||||
|
package-lock.json
|
||||||
|
scriptcraft/
|
||||||
|
lib/
|
11
examples/typescript/src/main/ts/package.json
Normal file
11
examples/typescript/src/main/ts/package.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "latest"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"scriptcraft-api": "file:../../../libs/scriptcraft-api.tar.gz"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc"
|
||||||
|
}
|
||||||
|
}
|
73
examples/typescript/src/main/ts/src/modid/index.ts
Normal file
73
examples/typescript/src/main/ts/src/modid/index.ts
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import { BlockSettings, Identifier, Registry, BlockState, ActionResult, World, Pos, Hand, PlayerEntity, BlockItem, ItemSettings, CustomItem, Direction, LivingEntity, CustomBlockWithEntity, CustomBlockEntity, CompoundTag, NumberType } from 'minecraft';
|
||||||
|
|
||||||
|
console.log('hello');
|
||||||
|
|
||||||
|
class MyBlockEntity extends CustomBlockEntity {
|
||||||
|
ticks = 0;
|
||||||
|
|
||||||
|
toTag(tag: CompoundTag): CompoundTag {
|
||||||
|
tag.set('MyTicks', this.ticks, NumberType.INT);
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
fromTag(tag: CompoundTag): void {
|
||||||
|
const obj = tag.get('MyTicks');
|
||||||
|
if (typeof obj === 'number') {
|
||||||
|
this.ticks = obj;
|
||||||
|
} else {
|
||||||
|
this.ticks = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tick(): void {
|
||||||
|
this.ticks++;
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyBlock extends CustomBlockWithEntity {
|
||||||
|
constructor() {
|
||||||
|
super(new BlockSettings('STONE', 'IRON'));
|
||||||
|
}
|
||||||
|
|
||||||
|
onUse(world: World, blockState: BlockState, blockPos: Pos, side: Direction, player: PlayerEntity, hand: Hand): ActionResult {
|
||||||
|
const entity = world.getCustomBlockEntity(blockPos);
|
||||||
|
if (entity instanceof MyBlockEntity) {
|
||||||
|
console.log('Ticks: ' + entity.ticks);
|
||||||
|
}
|
||||||
|
world.setBlockState(blockPos.offset(side), BlockState.getDefaultState(new Identifier('minecraft:stone')));
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
createBlockEntity(): CustomBlockEntity {
|
||||||
|
return new MyBlockEntity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Registry.register(Registry.BLOCK, new Identifier('test', 'my_block'), new MyBlock());
|
||||||
|
Registry.register(Registry.ITEM, new Identifier('test', 'my_block'), new BlockItem(new Identifier('test', 'my_block'), new ItemSettings()));
|
||||||
|
|
||||||
|
class MyItem extends CustomItem {
|
||||||
|
constructor() {
|
||||||
|
super(new ItemSettings().setItemGroup('building_blocks').setMaxCount(128));
|
||||||
|
}
|
||||||
|
|
||||||
|
onUse(world: World, player: PlayerEntity, hand: Hand): ActionResult {
|
||||||
|
console.log('Item Use: Normal');
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
onUseOnBlock(world: World, blockPos: Pos, side: Direction, player: PlayerEntity, hand: Hand): ActionResult {
|
||||||
|
console.log('Item Use: Block ' + blockPos.toString());
|
||||||
|
world.spawnEntity(new Identifier('minecraft:cow'), blockPos.offset(side).add(new Pos(0.5, 0, 0.5))).toString();
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
onUseOnEntity(player: PlayerEntity, target: LivingEntity, hand: Hand): ActionResult {
|
||||||
|
console.log('Item Use: Entity ' + target.toTag().toString());
|
||||||
|
console.log('Health: ' + target.toTag().get('Health').toString());
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Registry.register(Registry.ITEM, new Identifier('test', 'my_item'), new MyItem());
|
21
examples/typescript/src/main/ts/tsconfig.json
Normal file
21
examples/typescript/src/main/ts/tsconfig.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"lib": ["es2020"],
|
||||||
|
"module": "es2020",
|
||||||
|
"target": "es2020",
|
||||||
|
"typeRoots": ["node_modules/scriptcraft-api/types"],
|
||||||
|
"rootDir": "src",
|
||||||
|
"baseUrl": "src",
|
||||||
|
"paths": {
|
||||||
|
"minecraft": ["../node_modules/scriptcraft-api/lib/minecraft/index.d.ts"]
|
||||||
|
},
|
||||||
|
"outDir": "lib/ts"
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts"
|
||||||
|
]
|
||||||
|
}
|
29
examples/typescript/typescript.build.gradle
Normal file
29
examples/typescript/typescript.build.gradle
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
def typescriptRoot = 'src/main/ts'
|
||||||
|
def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot)
|
||||||
|
|
||||||
|
def typescriptOut = new File(typescriptRootFile, 'lib/ts')
|
||||||
|
|
||||||
|
task typescript(group: 'typescript', type: Exec) {
|
||||||
|
inputs.dir typescriptRootFile
|
||||||
|
outputs.dirs typescriptOut
|
||||||
|
|
||||||
|
workingDir typescriptRootFile
|
||||||
|
|
||||||
|
executable 'npm'
|
||||||
|
|
||||||
|
args 'run', 'build'
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
project.delete {
|
||||||
|
delete typescriptOut
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources.dependsOn typescript
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
from(typescriptOut.absolutePath) {
|
||||||
|
into 'scriptcraft'
|
||||||
|
}
|
||||||
|
}
|
@ -4,8 +4,6 @@ org.gradle.jvmargs = -Xmx1G
|
|||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
minecraft_version = 1.15.2
|
minecraft_version = 1.15.2
|
||||||
curseforge_id = TBD
|
|
||||||
simple_minecraft_version = 1.15.2
|
|
||||||
yarn_build = 15
|
yarn_build = 15
|
||||||
fabric_loader_version = 0.8.2+build.194
|
fabric_loader_version = 0.8.2+build.194
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "minecraft",
|
"name": "minecraft",
|
||||||
"version" : "1.0.0-SNAPSHOT",
|
"version" : "1.0.0-SNAPSHOT",
|
||||||
"types": "lib/minecraft/index.d.ts",
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "latest",
|
"@typescript-eslint/eslint-plugin": "latest",
|
||||||
"@typescript-eslint/parser": "latest",
|
"@typescript-eslint/parser": "latest",
|
||||||
|
Reference in New Issue
Block a user