-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(world): added EntityVariantComponent
- Loading branch information
Showing
4 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ActorDataId, ActorDataType } from "@serenityjs/protocol"; | ||
|
||
import { EntityDataComponent } from "./data"; | ||
|
||
import type { Entity } from "../../../entity"; | ||
|
||
class EntityVariantComponent extends EntityDataComponent<number> { | ||
public static readonly identifier = "minecraft:variant"; | ||
|
||
public readonly key = ActorDataId.Variant; | ||
|
||
public readonly type = ActorDataType.Int; | ||
|
||
public defaultValue = 0; | ||
|
||
/** | ||
* Set a variant for the entity. | ||
* | ||
* @param entity The entity the component is binded to. | ||
* @returns A new entity scale component | ||
*/ | ||
public constructor(entity: Entity) { | ||
super(entity, EntityVariantComponent.identifier); | ||
|
||
// Check if the entity is a player | ||
if (entity.isPlayer()) this.defaultValue = 1; | ||
|
||
// Set the entity to have a variant | ||
this.setCurrentValue(this.defaultValue, false); | ||
} | ||
} | ||
|
||
export { EntityVariantComponent }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters