Generate DTS Better
Some checks failed
ScriptCraft/pipeline/head There was a failure building this commit
Some checks failed
ScriptCraft/pipeline/head There was a failure building this commit
This commit is contained in:
parent
7ffcc55da5
commit
275ec8f2c6
3
Jenkinsfile
vendored
3
Jenkinsfile
vendored
@ -10,11 +10,12 @@ pipeline {
|
||||
}
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh './gradlew build typedoc eslint typescriptDist'
|
||||
sh './gradlew build typedoc eslint'
|
||||
}
|
||||
post {
|
||||
success {
|
||||
archiveArtifacts artifacts: 'build/libs/*', fingerprint: true
|
||||
archiveArtifacts artifacts: 'build/distributions/*', fingerprint: true
|
||||
|
||||
publishHTML target: [
|
||||
allowMissing: false,
|
||||
|
@ -1,73 +0,0 @@
|
||||
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());
|
@ -10,9 +10,6 @@
|
||||
"typeRoots": ["src/types"],
|
||||
"rootDir": "src",
|
||||
"baseUrl": "src",
|
||||
"paths": {
|
||||
"minecraft": ["minecraft/index"]
|
||||
},
|
||||
"outDir": "lib/ts",
|
||||
"declaration": true,
|
||||
"declarationDir": "lib/dts"
|
||||
|
@ -21,20 +21,23 @@ task typescript(group: 'typescript', type: Exec) {
|
||||
}
|
||||
}
|
||||
|
||||
task typescriptDist(group: 'typescript', type: Tar) {
|
||||
task apiTar(group: 'typescript', type: Tar) {
|
||||
into('/types') {
|
||||
from new File(typescriptRootFile as File, 'src/types')
|
||||
}
|
||||
into('/lib') {
|
||||
from dtsOut
|
||||
}
|
||||
from new File(typescriptRootFile as File, 'package.json')
|
||||
|
||||
archiveName 'typescript-dist.tar.gz'
|
||||
destinationDir new File(buildDir, 'libs')
|
||||
compression Compression.GZIP
|
||||
classifier 'api'
|
||||
}
|
||||
|
||||
typescriptDist.dependsOn typescript
|
||||
apiTar.dependsOn typescript
|
||||
|
||||
artifacts {
|
||||
archives apiTar
|
||||
}
|
||||
|
||||
task eslint(group: 'typescript', type: Exec) {
|
||||
workingDir typescriptRootFile
|
||||
|
Reference in New Issue
Block a user