Fix Examples
All checks were successful
ScriptCraft/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-08-25 11:52:34 -04:00
parent c9eb558a3b
commit 3ea727fb7f
3 changed files with 10 additions and 26 deletions

View File

@ -7,7 +7,7 @@ import { ActionResult, ItemSettings, CustomItem } from 'minecraft';
class MyItem extends CustomItem {
constructor() {
super(new ItemSettings().setItemGroup('building_blocks').setMaxCount(128));
super(new ItemSettings().setItemGroup('building_blocks').setMaxCount(16));
}
onUse(world, player, hand) {
@ -27,13 +27,13 @@ class MyItem extends CustomItem {
}
```
JavaScript:
TypeScript:
```typescript
import { ActionResult, World, Pos, Hand, PlayerEntity, ItemSettings, CustomItem, Direction, LivingEntity } from 'minecraft';
class MyItem extends CustomItem {
constructor() {
super(new ItemSettings().setItemGroup('building_blocks').setMaxCount(128));
super(new ItemSettings().setItemGroup('building_blocks').setMaxCount(18));
}
onUse(world: World, player: PlayerEntity, hand: Hand): ActionResult {

View File

@ -1,26 +1,18 @@
import { BlockSettings, Identifier, Registry, BlockState, ActionResult, BlockItem, ItemSettings, BuiltinRegistry } from 'minecraft';
import { BlockSettings, Identifier, Registry, BlockState, ActionResult, BlockItem, ItemSettings, BuiltinRegistry, CustomBlock } from 'minecraft';
console.log('hello');
const ironBlock = BuiltinRegistry.BLOCK.get(new Identifier('minecraft:iron_block'));
class MyBlock extends CustomBlockWithEntity {
class MyBlock extends CustomBlock {
constructor() {
super(new BlockSettings(ironBlock.getMaterial(), ironBlock.getMaterialColor()));
}
onUse(world, blockState, blockPos, side, player, hand) {
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')));
console.log('Block Used!');
return ActionResult.SUCCESS;
}
createBlockEntity() {
return new MyBlockEntity();
}
}
Registry.register(Registry.BLOCK, new Identifier('modid', 'my_block'), new MyBlock());

View File

@ -1,26 +1,18 @@
import { BlockSettings, Identifier, Registry, BlockState, ActionResult, World, Pos, Hand, PlayerEntity, BlockItem, ItemSettings, Direction, BuiltinRegistry } from 'minecraft';
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 CustomBlockWithEntity {
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 {
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')));
console.log('Block Used!');
return ActionResult.SUCCESS;
}
createBlockEntity(): CustomBlockEntity {
return new MyBlockEntity();
}
}
Registry.register(Registry.BLOCK, new Identifier('modid', 'my_block'), new MyBlock());