This commit is contained in:
parent
0fee6d0022
commit
7a4b9dd4f8
9
examples/typescript/README.md
Normal file
9
examples/typescript/README.md
Normal 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.
|
@ -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
|
|
@ -3,7 +3,7 @@
|
|||||||
"typescript": "latest"
|
"typescript": "latest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"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": {
|
"scripts": {
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
|
@ -44,8 +44,8 @@ class MyBlock extends CustomBlockWithEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Registry.register(Registry.BLOCK, new Identifier('test', 'my_block'), new MyBlock());
|
Registry.register(Registry.BLOCK, new Identifier('modid', '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.ITEM, new Identifier('modid', 'my_block'), new BlockItem(new Identifier('modid', 'my_block'), new ItemSettings()));
|
||||||
|
|
||||||
class MyItem extends CustomItem {
|
class MyItem extends CustomItem {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -3,6 +3,25 @@ def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot)
|
|||||||
|
|
||||||
def typescriptOut = new File(typescriptRootFile, 'lib/ts')
|
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) {
|
task typescript(group: 'typescript', type: Exec) {
|
||||||
inputs.dir typescriptRootFile
|
inputs.dir typescriptRootFile
|
||||||
outputs.dirs typescriptOut
|
outputs.dirs typescriptOut
|
||||||
@ -20,6 +39,8 @@ task typescript(group: 'typescript', type: Exec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typescript.dependsOn typescriptInstall
|
||||||
|
|
||||||
processResources.dependsOn typescript
|
processResources.dependsOn typescript
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
@ -3,7 +3,4 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
./download-quickjs.sh
|
./download-quickjs.sh
|
||||||
./download-jni-headers.sh
|
./download-jni-headers.sh
|
||||||
|
|
||||||
cd ../src/main/ts
|
|
||||||
npm install
|
|
@ -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";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,25 @@
|
|||||||
def typescriptRoot = 'src/main/ts'
|
def typescriptRoot = 'src/main/ts'
|
||||||
def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot)
|
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 typescriptOut = new File(typescriptRootFile, 'lib/ts')
|
||||||
def dtsOut = new File(typescriptRootFile, 'lib/dts')
|
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) {
|
task typescriptAPI(group: 'typescript', type: Tar) {
|
||||||
into('/package') {
|
into('/package') {
|
||||||
into('types') {
|
into('types') {
|
||||||
@ -53,6 +74,8 @@ task eslint(group: 'typescript', type: Exec) {
|
|||||||
args 'run', 'eslint'
|
args 'run', 'eslint'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eslint.dependsOn typescriptInstall
|
||||||
|
|
||||||
processResources.dependsOn typescript
|
processResources.dependsOn typescript
|
||||||
|
|
||||||
def typedocOut = new File(typescriptRootFile, 'lib/typedoc')
|
def typedocOut = new File(typescriptRootFile, 'lib/typedoc')
|
||||||
@ -74,6 +97,8 @@ task typedoc(group: 'typescript', type: Exec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedoc.dependsOn typescriptInstall
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
from(typescriptOut.absolutePath) {
|
from(typescriptOut.absolutePath) {
|
||||||
into 'scriptcraft'
|
into 'scriptcraft'
|
||||||
|
Reference in New Issue
Block a user