This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
ScriptCraft/examples/typescript/src/main/ts/src/modid/index.ts

20 lines
893 B
TypeScript
Raw Normal View History

2020-08-25 15:52:34 +00:00
import { BlockSettings, Identifier, Registry, BlockState, ActionResult, World, Pos, Hand, PlayerEntity, BlockItem, ItemSettings, Direction, BuiltinRegistry, CustomBlock } from 'minecraft';
2020-04-29 18:56:51 +00:00
console.log('hello');
2020-08-25 01:28:06 +00:00
const ironBlock = BuiltinRegistry.BLOCK.get(new Identifier('minecraft:iron_block'));
2020-04-29 18:56:51 +00:00
2020-08-25 15:52:34 +00:00
class MyBlock extends CustomBlock {
2020-04-29 18:56:51 +00:00
constructor() {
2020-08-25 01:28:06 +00:00
super(new BlockSettings(ironBlock.getMaterial(), ironBlock.getMaterialColor()));
2020-04-29 18:56:51 +00:00
}
onUse(world: World, blockState: BlockState, blockPos: Pos, side: Direction, player: PlayerEntity, hand: Hand): ActionResult {
2020-08-25 15:52:34 +00:00
console.log('Block Used!');
2020-04-29 18:56:51 +00:00
return ActionResult.SUCCESS;
}
}
2020-04-29 23:41:08 +00:00
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()));