CustomBlock, CustomBlockWithEntity, and CustomItem are no longer abstract
All checks were successful
ScriptCraft/pipeline/head This commit looks good
All checks were successful
ScriptCraft/pipeline/head This commit looks good
This commit is contained in:
parent
05f7d5923c
commit
473b8c0ba3
@ -68,7 +68,7 @@ export class BlockSettings {
|
||||
/**
|
||||
* Custom Block
|
||||
*/
|
||||
export abstract class CustomBlock {
|
||||
export class CustomBlock {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@ -88,7 +88,9 @@ export abstract class CustomBlock {
|
||||
* @param hand Hand
|
||||
* @returns Action Result
|
||||
*/
|
||||
abstract onUse(world: World, blockState: BlockState, pos: Pos, side: Direction, player: PlayerEntity, hand: Hand): ActionResult;
|
||||
onUse(world: World, blockState: BlockState, pos: Pos, side: Direction, player: PlayerEntity, hand: Hand) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,7 +146,7 @@ export class BlockState {
|
||||
/**
|
||||
* Custom Block Entity
|
||||
*/
|
||||
export abstract class CustomBlockEntity {
|
||||
export class CustomBlockEntity {
|
||||
/**
|
||||
* World
|
||||
*/
|
||||
@ -169,24 +171,26 @@ export abstract class CustomBlockEntity {
|
||||
* @param tag Tag
|
||||
* @returns Tag
|
||||
*/
|
||||
abstract toTag(tag: CompoundTag): CompoundTag;
|
||||
toTag(tag: CompoundTag) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Data From Tag
|
||||
* @param tag Tag
|
||||
*/
|
||||
abstract fromTag(tag: CompoundTag): void;
|
||||
fromTag(tag: CompoundTag) {}
|
||||
|
||||
/**
|
||||
* Runs Every Tick
|
||||
*/
|
||||
abstract tick(): void;
|
||||
tick() {}
|
||||
|
||||
/**
|
||||
* Get World
|
||||
* @returns World
|
||||
*/
|
||||
getWorld(): World {
|
||||
getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@ -194,7 +198,7 @@ export abstract class CustomBlockEntity {
|
||||
* Get Position
|
||||
* @returns Position
|
||||
*/
|
||||
getPos(): Pos {
|
||||
getPos() {
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
@ -211,12 +215,14 @@ export abstract class CustomBlockEntity {
|
||||
/**
|
||||
* {@link CustomBlock} With {@link CustomBlockEntity}
|
||||
*/
|
||||
export abstract class CustomBlockWithEntity extends CustomBlock {
|
||||
export class CustomBlockWithEntity extends CustomBlock {
|
||||
/**
|
||||
* Create Custom Block Entity
|
||||
* @returns Custom Block Entity
|
||||
*/
|
||||
abstract createBlockEntity(): CustomBlockEntity;
|
||||
createBlockEntity(): CustomBlockEntity {
|
||||
throw new Error('CustomBlockWithEntity.createBlockEntity is not implemented');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -290,9 +296,12 @@ addBridge('CustomBlockEntity.fromTag', (id: string, i: number, tag: JavaObject)
|
||||
BlockRegistry.INSTANCE.getCustomBlockEntity(new Identifier(id), i).fromTag(new CompoundTag(tag));
|
||||
});
|
||||
|
||||
addBridge('CustomBlockEntity.toTag', (id: string, i: number, tag: JavaObject): JavaObject => {
|
||||
addBridge(
|
||||
'CustomBlockEntity.toTag',
|
||||
(id: string, i: number, tag: JavaObject): JavaObject => {
|
||||
return BlockRegistry.INSTANCE.getCustomBlockEntity(new Identifier(id), i).toTag(new CompoundTag(tag)).javaObject;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
addBridge('CustomBlockEntity.tick', (id: string, i: number) => {
|
||||
BlockRegistry.INSTANCE.getCustomBlockEntity(new Identifier(id), i).tick();
|
||||
|
@ -71,7 +71,7 @@ export class Entity {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor(object: JavaObject|Entity) {
|
||||
constructor(object: JavaObject | Entity) {
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
@ -251,5 +251,4 @@ export class LivingEntity extends Entity {
|
||||
/**
|
||||
* Player Entity
|
||||
*/
|
||||
export class PlayerEntity extends LivingEntity {
|
||||
}
|
||||
export class PlayerEntity extends LivingEntity {}
|
||||
|
@ -207,7 +207,7 @@ export class ItemSettings {
|
||||
/**
|
||||
* Custom Item
|
||||
*/
|
||||
export abstract class CustomItem {
|
||||
export class CustomItem {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@ -224,7 +224,9 @@ export abstract class CustomItem {
|
||||
* @param hand Hand
|
||||
* @returns Action Result
|
||||
*/
|
||||
abstract onUse(world: World, player: PlayerEntity, hand: Hand): ActionResult;
|
||||
onUse(world: World, player: PlayerEntity, hand: Hand) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called When The Item Is Used On A Block
|
||||
@ -235,7 +237,9 @@ export abstract class CustomItem {
|
||||
* @param hand Hand
|
||||
* @returns Action Result
|
||||
*/
|
||||
abstract onUseOnBlock(world: World, pos: Pos, side: Direction, player: PlayerEntity, hand: Hand): ActionResult;
|
||||
onUseOnBlock(world: World, pos: Pos, side: Direction, player: PlayerEntity, hand: Hand) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called When The Item Is Used On An Entity
|
||||
@ -244,7 +248,9 @@ export abstract class CustomItem {
|
||||
* @param hand Hand
|
||||
* @returns Action Result
|
||||
*/
|
||||
abstract onUseOnEntity(player: PlayerEntity, target: LivingEntity, hand: Hand): ActionResult;
|
||||
onUseOnEntity(player: PlayerEntity, target: LivingEntity, hand: Hand) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useBridge } from "./core";
|
||||
import { useBridge } from './core';
|
||||
|
||||
type TagType = number | boolean | string | CompoundTag | ListTag;
|
||||
|
||||
@ -86,7 +86,7 @@ export class CompoundTag {
|
||||
set(key: string, value: number, numberType: NumberType): void;
|
||||
set(key: string, value: Exclude<TagType, number>): void;
|
||||
set(key: string, value: TagType, numberType?: NumberType) {
|
||||
useBridge('CompoundTag.set', this.javaObject, key, (value instanceof CompoundTag || value instanceof ListTag) ? value.javaObject : value, numberType != null ? numberType : NumberType.DOUBLE);
|
||||
useBridge('CompoundTag.set', this.javaObject, key, value instanceof CompoundTag || value instanceof ListTag ? value.javaObject : value, numberType != null ? numberType : NumberType.DOUBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,7 +148,7 @@ export class ListTag {
|
||||
set(key: number, value: number, numberType: NumberType): void;
|
||||
set(key: number, value: Exclude<TagType, number>): void;
|
||||
set(key: number, value: TagType, numberType?: NumberType) {
|
||||
useBridge('ListTag.set', this.javaObject, key, (value instanceof CompoundTag || value instanceof ListTag) ? value.javaObject : value, numberType != null ? numberType : NumberType.DOUBLE);
|
||||
useBridge('ListTag.set', this.javaObject, key, value instanceof CompoundTag || value instanceof ListTag ? value.javaObject : value, numberType != null ? numberType : NumberType.DOUBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user