20 lines
893 B
TypeScript
20 lines
893 B
TypeScript
import { BlockSettings, Identifier, Registry, BlockState, ActionResult, World, Pos, Hand, PlayerEntity, BlockItem, ItemSettings, Direction, BuiltinRegistry, CustomBlock } from 'minecraft';
|
|
|
|
console.log('hello');
|
|
|
|
const ironBlock = BuiltinRegistry.BLOCK.get(new Identifier('minecraft:iron_block'));
|
|
|
|
class MyBlock extends CustomBlock {
|
|
constructor() {
|
|
super(new BlockSettings(ironBlock.getMaterial(), ironBlock.getMaterialColor()));
|
|
}
|
|
|
|
onUse(world: World, blockState: BlockState, blockPos: Pos, side: Direction, player: PlayerEntity, hand: Hand): ActionResult {
|
|
console.log('Block Used!');
|
|
return ActionResult.SUCCESS;
|
|
}
|
|
}
|
|
|
|
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()));
|