Update Examples
ScriptCraft/pipeline/head This commit looks good Details

This commit is contained in:
TheBrokenRail 2020-04-29 19:41:08 -04:00
parent 0fee6d0022
commit 7a4b9dd4f8
8 changed files with 59 additions and 38 deletions

View File

@ -0,0 +1,9 @@
# TypeScript Example
This is an example of a Minecraft mod made in TypeScript using ScriptCraft.
#### Files
- ```src/main/ts```: Contains TypeScript Code
- ```src/main/java```: Contains Bootstrap Java Code
#### Note
When updating Minecraft, make sure to update the ```src/main/ts/package.json``` file as well.

View File

@ -1,16 +0,0 @@
#!/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

View File

@ -3,7 +3,7 @@
"typescript": "latest"
},
"dependencies": {
"scriptcraft-api": "file:../../../libs/scriptcraft-api.tar.gz"
"scriptcraft-api": "https://maven.thebrokenrail.com/com/thebrokenrail/scriptcraft/1.15.2/scriptcraft-1.15.2-api.tar.gz"
},
"scripts": {
"build": "tsc"

View File

@ -44,8 +44,8 @@ class MyBlock extends CustomBlockWithEntity {
}
}
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()));
Registry.register(Registry.BLOCK, new Identifier('modid', 'my_block'), new MyBlock());
Registry.register(Registry.ITEM, new Identifier('modid', 'my_block'), new BlockItem(new Identifier('modid', 'my_block'), new ItemSettings()));
class MyItem extends CustomItem {
constructor() {

View File

@ -3,6 +3,25 @@ def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot)
def typescriptOut = new File(typescriptRootFile, 'lib/ts')
def nodeModules = new File(typescriptRoot, 'node_modules')
task typescriptInstall(group: 'typescript', type: Exec) {
inputs.file new File(typescriptRootFile, 'package.json')
outputs.dir nodeModules
workingDir typescriptRootFile
executable 'npm'
args 'install'
doFirst {
project.delete {
delete nodeModules
}
}
}
task typescript(group: 'typescript', type: Exec) {
inputs.dir typescriptRootFile
outputs.dirs typescriptOut
@ -20,6 +39,8 @@ task typescript(group: 'typescript', type: Exec) {
}
}
typescript.dependsOn typescriptInstall
processResources.dependsOn typescript
processResources {

View File

@ -3,7 +3,4 @@
set -e
./download-quickjs.sh
./download-jni-headers.sh
cd ../src/main/ts
npm install
./download-jni-headers.sh

View File

@ -1,15 +0,0 @@
package com.thebrokenrail.scriptcraft;
import com.thebrokenrail.scriptcraft.core.ScriptCraftEntrypoint;
public class Test implements ScriptCraftEntrypoint {
@Override
public String getModID() {
return "test";
}
@Override
public String getModIndex() {
return "index.js";
}
}

View File

@ -1,6 +1,25 @@
def typescriptRoot = 'src/main/ts'
def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot)
def nodeModules = new File(typescriptRoot, 'node_modules')
task typescriptInstall(group: 'typescript', type: Exec) {
inputs.file new File(typescriptRootFile, 'package.json')
outputs.dir nodeModules
workingDir typescriptRootFile
executable 'npm'
args 'install'
doFirst {
project.delete {
delete nodeModules
}
}
}
def typescriptOut = new File(typescriptRootFile, 'lib/ts')
def dtsOut = new File(typescriptRootFile, 'lib/dts')
@ -21,6 +40,8 @@ task typescript(group: 'typescript', type: Exec) {
}
}
typescript.dependsOn typescriptInstall
task typescriptAPI(group: 'typescript', type: Tar) {
into('/package') {
into('types') {
@ -53,6 +74,8 @@ task eslint(group: 'typescript', type: Exec) {
args 'run', 'eslint'
}
eslint.dependsOn typescriptInstall
processResources.dependsOn typescript
def typedocOut = new File(typescriptRootFile, 'lib/typedoc')
@ -74,6 +97,8 @@ task typedoc(group: 'typescript', type: Exec) {
}
}
typedoc.dependsOn typescriptInstall
processResources {
from(typescriptOut.absolutePath) {
into 'scriptcraft'