diff --git a/Jenkinsfile b/Jenkinsfile index d06b5d9..089cc0c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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, diff --git a/src/main/ts/src/test/index.ts b/src/main/ts/src/test/index.ts deleted file mode 100644 index f804dc7..0000000 --- a/src/main/ts/src/test/index.ts +++ /dev/null @@ -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()); diff --git a/src/main/ts/tsconfig.json b/src/main/ts/tsconfig.json index ec25cf7..aa70bb4 100644 --- a/src/main/ts/tsconfig.json +++ b/src/main/ts/tsconfig.json @@ -10,9 +10,6 @@ "typeRoots": ["src/types"], "rootDir": "src", "baseUrl": "src", - "paths": { - "minecraft": ["minecraft/index"] - }, "outDir": "lib/ts", "declaration": true, "declarationDir": "lib/dts" diff --git a/typescript.build.gradle b/typescript.build.gradle index 5495b1e..eb8499d 100644 --- a/typescript.build.gradle +++ b/typescript.build.gradle @@ -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