### Items Static Item Constants Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Examples of static constants representing various in-game items. ```typescript static POWERED_RAIL: (Internal.BlockItem) & (Internal.Item) static GUARDIAN_SPAWN_EGG: (Internal.SpawnEggItem) & (Internal.Item) static QUARTZ: (Internal.Item) & (Internal.Item) static TUBE_CORAL: (Internal.BlockItem) & (Internal.Item) // ... 数百个原版物品常量 static ZOMBIE_HORSE_SPAWN_EGG: (Internal.SpawnEggItem) & (Internal.Item) ``` -------------------------------- ### Customize ProbeJS Documentation Generation Source: https://context7.com/whisent/kubejs-1201-docs/llms.txt Provides hooks into the ProbeJS type-generation workflow. This example registers a custom class documentation entry. ```javascript // server_scripts/probe.js ProbeJSEvents.generateDoc(event => { // Register a custom class documentation entry event.addClassDoc('mymod.MyClass', doc => { doc.detail = 'Custom utility class for MyMod' }) }) ``` -------------------------------- ### World Static Methods for Time and Weather Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Methods for getting and setting the world's time and weather conditions. ```typescript static getTime(): number static setTime(time: number): void static getWeather(): string static setWeather(weather: string): void static getRainLevel(): number static setRainLevel(level: number): void static getThunderLevel(): number static setThunderLevel(level: number): void ``` -------------------------------- ### World Static Methods for Dimension and Biome Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Methods for getting dimension and biome information by ResourceLocation. ```typescript static getDimension(id: ResourceLocation_): Internal.ResourceKey static getDimensions(): Internal.List static getBiome(id: ResourceLocation_): Internal.Holder static getBiomes(): Internal.List ``` -------------------------------- ### Recipe Static Methods for Recipe Management Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Methods for getting, removing, and replacing recipes based on ID, output, input, or mod. ```typescript static get(id: ResourceLocation_): Internal.Recipe static getAll(): Internal.List static remove(id: ResourceLocation_): void static removeByOutput(output: any): void static removeByInput(input: any): void static removeByMod(mod: string): void static replaceInput(input: any, replacement: any): void static replaceOutput(output: any, replacement: any): void ``` -------------------------------- ### Console Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides methods for interacting with the console instance, such as getting its class, string representation, and managing thread waits. ```typescript getClass(): typeof any tosString(): string notifyAll(): void notify(): void wait(arg0: number, arg1: number): void hashCode(): number wait(): void wait(arg0: number): void equals(arg0: any): boolean ``` -------------------------------- ### World Static Methods for Structure and Feature Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Methods for getting structure and feature information by ResourceLocation. ```typescript static getStructure(id: ResourceLocation_): Internal.Holder static getStructures(): Internal.List static getFeature(id: ResourceLocation_): Internal.Holder static getFeatures(): Internal.List ``` -------------------------------- ### React to File Saves with ProbeJSEvents Source: https://context7.com/whisent/kubejs-1201-docs/llms.txt Provides hooks into the ProbeJS workflow, reacting to VS Code file saves. This example logs a message when a file is saved. ```javascript ProbeJSEvents.fileSaved('mymod:on_save', event => { console.log(`VS Code saved a file; regenerating...`) }) ``` -------------------------------- ### World Static Methods for Block Manipulation Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Methods for getting and setting block states and block entities at specific positions. ```typescript static getBlockState(pos: BlockPos_): Internal.BlockState static setBlockState(pos: BlockPos_, state: Internal.BlockState_): void static getBlockEntity(pos: BlockPos_): Internal.BlockEntity static setBlockEntity(pos: BlockPos_, entity: Internal.BlockEntity_): void ``` -------------------------------- ### Manage Item Tags with ServerEvents.tags Source: https://context7.com/whisent/kubejs-1201-docs/llms.txt Allows adding, removing, and querying Minecraft tag entries for items. This example adds modded items to vanilla tags and creates a custom tag. ```javascript ServerEvents.tags('item', event => { // Add modded items to vanilla tags event.add('minecraft:logs', ['mymod:rubber_log', 'mymod:rubber_wood']) // Create a custom tag event.add('mymod:magic_items', [ 'minecraft:ender_pearl', 'minecraft:blaze_rod', 'minecraft:dragon_breath' ]) // Remove an item from a tag event.remove('minecraft:swords', 'minecraft:wooden_sword') }) ``` -------------------------------- ### Manage Block Tags with ServerEvents.tags Source: https://context7.com/whisent/kubejs-1201-docs/llms.txt Manages Minecraft tag entries for blocks. This example adds a custom stone block to tags related to mining. ```javascript ServerEvents.tags('block', event => { event.add('minecraft:mineable/pickaxe', 'mymod:my_stone') event.add('minecraft:needs_diamond_tool', 'mymod:my_stone') }) ``` -------------------------------- ### Manage Entity Type Tags with ServerEvents.tags Source: https://context7.com/whisent/kubejs-1201-docs/llms.txt Manages Minecraft tag entries for entity types. This example adds several undead mobs to a custom tag. ```javascript ServerEvents.tags('entity_type', event => { // Add all undead mobs to a custom tag event.add('mymod:undead', ['minecraft:zombie', 'minecraft:skeleton', 'minecraft:wither_skeleton']) }) ``` -------------------------------- ### ItemStack Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides methods for interacting with an ItemStack, such as getting its item, count, or NBT tag. ```typescript getClass(): typeof any getItem(): Internal.Item getCount(): number getTag(): Internal.CompoundTag setTag(arg0: Internal.CompoundTag_): void toString(): string notifyAll(): void notify(): void wait(arg0: number, arg1: number): void hashCode(): number wait(): void wait(arg0: number): void equals(arg0: any): boolean ``` -------------------------------- ### Block Class Static Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Utility methods for interacting with blocks globally. Use these to get block IDs, entities, facing information, and more. ```typescript static id(id: ResourceLocation_): Internal.BlockIDPredicate static entity(id: ResourceLocation_): Internal.BlockEntityPredicate /** * Gets a blocks id from the Block */ static getId(block: Internal.Block_): ResourceLocation /** * Get a map of direction name to Direction. Functionally identical to Direction.ALL */ static getFacing(): Internal.Map static id(id: ResourceLocation_, properties: Internal.Map_): Internal.BlockIDPredicate /** * Gets a list of all blocks with tags */ static getTaggedIds(tag: ResourceLocation_): Internal.List /** * Gets a Block from a block id */ static getBlock(id: ResourceLocation_): Internal.Block static custom(predicate: Internal.BlockPredicate_): Internal.BlockPredicate /** * Gets a list of the classname of all registered blocks */ static getTypeList(): Internal.List ``` -------------------------------- ### Stats Class Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides methods for interacting with individual stat instances, such as getting the class type, hash code, string representation, and synchronization utilities. ```typescript getClass(): typeof any ``` ```typescript hashCode(): number ``` ```typescript toString(): string ``` ```typescript wait(): void ``` ```typescript notifyAll(): void ``` ```typescript wait(arg0: number): void ``` ```typescript equals(arg0: any): boolean ``` ```typescript notify(): void ``` ```typescript wait(arg0: number, arg1: number): void ``` -------------------------------- ### Welcome Player on Login Source: https://context7.com/whisent/kubejs-1201-docs/llms.txt Sends a welcome message and gives the player 5 bread upon logging in. Uses KubeJS Text formatting. ```javascript // server_scripts/players.js // Welcome message on login PlayerEvents.loggedIn(event => { event.player.tell( Text.of(`Welcome, ${event.player.username}!`).aqua().bold() ) event.player.give(Item.of('minecraft:bread', 5)) }) ``` -------------------------------- ### KMath Constructor Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Initializes a new instance of the KMath class. ```APIDOC ## KMath Constructor ### Description Initializes a new instance of the KMath class. ### Constructor - `constructor()` ``` -------------------------------- ### KMath Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Methods available on KMath instances. ```APIDOC ## KMath Instance Methods ### Description Methods available on KMath instances. ### Methods - `getClass(): typeof any` - `notify(): void` - `wait(arg0: number, arg1: number): void` - `toString(): string` - `notifyAll(): void` - `hashCode(): number` - `wait(): void` - `wait(arg0: number): void` - `equals(arg0: any): boolean` ``` -------------------------------- ### ResourceLocation Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides a list of instance methods for the ResourceLocation class, used for identifying game resources. ```typescript static isValidNamespace(arg0: string): boolean getClass(): typeof any compareTo(arg0: ResourceLocation_): number toLanguageKey(arg0: string): string static checkSpecialEquality(o: any, o1: any, shallow: boolean): boolean static validNamespaceChar(arg0: string): boolean static read(arg0: string): Internal.DataResult toShortLanguageKey(): string static isValidPath(arg0: string): boolean notify(): void wait(arg0: number, arg1: number): void compareTo(arg0: any): number static tryBuild(arg0: string, arg1: string): ResourceLocation "withPath(java.lang.String)"(arg0: string): this static isAllowedInResourceLocation(arg0: string): boolean static tryParse(arg0: string): ResourceLocation withPath(arg0: string): this static validPathChar(arg0: string): boolean toLanguageKey(arg0: string, arg1: string): string toDebugFileName(): string getPath(): string getNamespace(): string static of(arg0: string, arg1: string): ResourceLocation compareNamespaced(arg0: ResourceLocation_): number "compareTo(net.minecraft.resources.ResourceLocation)"(arg0: ResourceLocation_): number translate(): string withSuffix(arg0: string): this notifyAll(): void specialEquals(o: any, shallow: boolean): boolean static read(arg0: Internal.StringReader_): ResourceLocation toLanguageKey(): string static isValidResourceLocation(arg0: string): boolean "withPath(java.util.function.UnaryOperator)"(arg0: Internal.UnaryOperator_): this static "read(com.mojang.brigadier.StringReader)"(arg0: Internal.StringReader_): ResourceLocation hashCode(): number static "read(java.lang.String)"(arg0: string): Internal.DataResult wait(): void withPath(arg0: Internal.UnaryOperator_): this wait(arg0: number): void withPrefix(arg0: string): this "compareTo(java.lang.Object)"(arg0: any): number equals(arg0: any): boolean ``` -------------------------------- ### World Static Methods for Entity and Player Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Methods for spawning entities and retrieving lists of entities or players. ```typescript static spawnEntity(entity: Internal.Entity_): void static getEntities(pos: BlockPos_, radius: number): Internal.List static getPlayers(): Internal.List ``` -------------------------------- ### DamageSource Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides a comprehensive list of instance methods for interacting with DamageSource objects, including retrieving source information, checking damage types, and localization. ```typescript getClass(): typeof any getSourcePosition(): Vec3d scalesWithDifficulty(): boolean typeHolder(): Internal.Holder "is(net.minecraft.tags.TagKey)"(arg0: Internal.TagKey_): boolean notify(): void getLocalizedDeathMessage(arg0: Internal.LivingEntity_): Internal.Component wait(arg0: number, arg1: number): void is(arg0: Internal.TagKey_): boolean type(): Internal.DamageType "is(net.minecraft.resources.ResourceKey)"(arg0: Internal.ResourceKey_): boolean getType(): string getActual(): Internal.Entity getPlayer(): Internal.Player toString(): string isIndirect(): boolean getImmediate(): Internal.Entity notifyAll(): void getFoodExhaustion(): number sourcePositionRaw(): Vec3d is(arg0: Internal.ResourceKey_): boolean hashCode(): number isCreativePlayer(): boolean wait(): void wait(arg0: number): void equals(arg0: any): boolean ``` -------------------------------- ### Block Class Getter Properties Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides access to block-related properties. Use these to get the class of a block or its facing information. ```typescript get class(): typeof any /** * Get a map of direction name to Direction. Functionally identical to Direction.ALL */ get facing(): Internal.Map /** * Gets a list of the classname of all registered blocks */ get typeList(): Internal.List ``` -------------------------------- ### Block Class Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Instance methods available on Block objects. ```APIDOC ## Block Class Instance Methods ### `getClass(): typeof any` Returns the class of the object. ### `toString(): string` Returns a string representation of the object. ### `notifyAll(): void` Wakes up all threads waiting on this object's monitor. ### `notify(): void` Wakes up a single thread waiting on this object's monitor. ### `wait(arg0: number, arg1: number): void` Causes the current thread to wait until it is awakened. ### `hashCode(): number` Returns the hash code for this object. ### `wait(): void` Causes the current thread to wait until it is awakened. ### `wait(arg0: number): void` Causes the current thread to wait until it is awakened. ### `equals(arg0: any): boolean` Indicates whether some other object is "equal to" this one. ``` -------------------------------- ### Items Static Methods for Registration Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Static methods for registering blocks and items. Overloaded methods allow registration using different identifiers like ResourceKey, ResourceLocation, or string. ```typescript static registerBlock(arg0: Internal.Block_, ...arg1: Internal.Block_[]): Internal.Item static "registerItem(net.minecraft.resources.ResourceKey,net.minecraft.world.item.Item)"(arg0: Internal.ResourceKey_, arg1: Internal.Item_): Internal.Item static "registerItem(net.minecraft.resources.ResourceLocation,net.minecraft.world.item.Item)"(arg0: ResourceLocation_, arg1: Internal.Item_): Internal.Item static registerBlock(arg0: Internal.Block_): Internal.Item static "registerBlock(net.minecraft.world.level.block.Block,net.minecraft.world.item.Item)"(arg0: Internal.Block_, arg1: Internal.Item_): Internal.Item static "registerBlock(net.minecraft.world.item.BlockItem)"(arg0: Internal.BlockItem_): Internal.Item static registerItem(arg0: Internal.ResourceKey_, arg1: Internal.Item_): Internal.Item static "registerBlock(net.minecraft.world.level.block.Block)"(arg0: Internal.Block_): Internal.Item static registerItem(arg0: ResourceLocation_, arg1: Internal.Item_): Internal.Item static "registerItem(java.lang.String,net.minecraft.world.item.Item)"(arg0: string, arg1: Internal.Item_): Internal.Item static registerBlock(arg0: Internal.Block_, arg1: Internal.Item_): Internal.Item static registerItem(arg0: string, arg1: Internal.Item_): Internal.Item static registerBlock(arg0: Internal.BlockItem_): Internal.Item static "registerBlock(net.minecraft.world.level.block.Block,net.minecraft.world.level.block.Block[])"(arg0: Internal.Block_, ...arg1: Internal.Block_[]): Internal.Item ``` -------------------------------- ### Ingredient Class Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Represents a recipe ingredient that can match item stacks. ```APIDOC ## Ingredient Class **Description**: Defines a recipe ingredient that can be used in crafting recipes. It allows testing if an item stack matches the ingredient. ### Instance Methods - `test(itemStack: Internal.ItemStack_): boolean` - Tests if the given item stack matches this ingredient. - `toJson(): Internal.JsonElement` - Serializes the ingredient to a JSON element. ### Static Methods - `static of(item: Internal.Item_, count: number): Internal.Ingredient` - Creates an Ingredient from an item and count. - `static of(item: Internal.Item_): Internal.Ingredient` - Creates an Ingredient from an item. ``` -------------------------------- ### Entity Class Static Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides static methods for interacting with entities in the game, such as spawning, retrieving NBT data, and modifying entity properties like health and position. ```APIDOC ## Entity Class Static Methods ### Description Provides static methods for interacting with entities in the game, such as spawning, retrieving NBT data, and modifying entity properties like health and position. ### Methods - `static getType(id: ResourceLocation_)`: Internal.EntityType - `static getTypes(): Internal.List` - `static spawn(id: ResourceLocation_, pos: BlockPos_)`: Internal.Entity - `static spawn(id: ResourceLocation_, pos: Vec3d_)`: Internal.Entity - `static getNbt(entity: Internal.Entity_)`: Internal.CompoundTag - `static setNbt(entity: Internal.Entity_, nbt: Internal.CompoundTag_)`: void - `static getHealth(entity: Internal.Entity_)`: number - `static setHealth(entity: Internal.Entity_, health: number)`: void - `static getMaxHealth(entity: Internal.Entity_)`: number - `static getPosition(entity: Internal.Entity_)`: Vec3d - `static setPosition(entity: Internal.Entity_, pos: Vec3d_)`: void - `static getRotation(entity: Internal.Entity_)`: Vec3d - `static setRotation(entity: Internal.Entity_, rot: Vec3d_)`: void - `static getVelocity(entity: Internal.Entity_)`: Vec3d - `static setVelocity(entity: Internal.Entity_, vel: Vec3d_)`: void - `static isOnGround(entity: Internal.Entity_)`: boolean - `static setOnGround(entity: Internal.Entity_, onGround: boolean)`: void - `static isInvulnerable(entity: Internal.Entity_)`: boolean - `static setInvulnerable(entity: Internal.Entity_, invulnerable: boolean)`: void - `static isSilent(entity: Internal.Entity_)`: boolean - `static setSilent(entity: Internal.Entity_, silent: boolean)`: void - `static isGlowing(entity: Internal.Entity_)`: boolean - `static setGlowing(entity: Internal.Entity_, glowing: boolean)`: void - `static isNoGravity(entity: Internal.Entity_)`: boolean - `static setNoGravity(entity: Internal.Entity_, noGravity: boolean)`: void ``` -------------------------------- ### Subscribe to Raw Forge Event (LivingDeathEvent) Source: https://context7.com/whisent/kubejs-1201-docs/llms.txt Subscribes to a raw Forge event, specifically 'net.minecraftforge.event.entity.living.LivingDeathEvent'. This example checks if the entity is an Ender Dragon and notifies players. ```javascript ForgeEvents.onEvent('net.minecraftforge.event.entity.living.LivingDeathEvent', event => { if (event.entity.type === 'minecraft:ender_dragon') { event.level.players.forEach(p => p.tell(Text.of('The Ender Dragon has been slain!').gold().bold()) ) } }) ``` -------------------------------- ### Recipe Static Methods for Type and Serializer Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Retrieves recipe types and serializers by their ResourceLocation. ```typescript static getType(id: ResourceLocation_): Internal.RecipeType static getTypes(): Internal.List static getSerializer(id: ResourceLocation_): Internal.RecipeSerializer static getSerializers(): Internal.List ``` -------------------------------- ### Ingredient Static Factory Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Static methods for creating Ingredient instances, useful for defining recipe components. ```typescript static of(o: any): Internal.Ingredient static of(item: Internal.Item_, count: number): Internal.Ingredient static of(item: Internal.Item_): Internal.Ingredient ``` -------------------------------- ### Block Class Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Standard Java/JavaScript instance methods available on Block objects. Includes methods for object comparison and lifecycle management. ```typescript getClass(): typeof any toString(): string notifyAll(): void notify(): void wait(arg0: number, arg1: number): void hashCode(): number wait(): void wait(arg0: number): void equals(arg0: any): boolean ``` -------------------------------- ### DamageSource Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Methods available on DamageSource instances for retrieving information and performing actions. ```APIDOC ## DamageSource Instance Methods ### Description These methods allow you to interact with a `DamageSource` object, such as checking its type, retrieving the source entity, or getting localized death messages. ### Methods - `getClass(): typeof any` - `getSourcePosition(): Vec3d` - `scalesWithDifficulty(): boolean` - `typeHolder(): Internal.Holder` - `is(net.minecraft.tags.TagKey): boolean` - `notify(): void` - `getLocalizedDeathMessage(arg0: Internal.LivingEntity_): Internal.Component` - `wait(arg0: number, arg1: number): void` - `is(arg0: Internal.TagKey_): boolean` - `type(): Internal.DamageType` - `is(net.minecraft.resources.ResourceKey): boolean` - `getType(): string` - `getActual(): Internal.Entity` - `getPlayer(): Internal.Player` - `toString(): string` - `isIndirect(): boolean` - `getImmediate(): Internal.Entity` - `notifyAll(): void` - `getFoodExhaustion(): number` - `sourcePositionRaw(): Vec3d` - `is(arg0: Internal.ResourceKey_): boolean` - `hashCode(): number` - `isCreativePlayer(): boolean` - `wait(): void` - `wait(arg0: number): void` - `equals(arg0: any): boolean` ``` -------------------------------- ### KMath Static Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Utility methods for mathematical operations. ```APIDOC ## KMath Static Methods ### Description Utility methods for mathematical operations. ### Methods - `static block(x: number, y: number, z: number): BlockPos` - `static deg(value: number): number` - `static v3d(x: number, y: number, z: number): Internal.Vector3d` - `static ceil(value: number): number` - `static map(value: number, min0: number, max0: number, min1: number, max1: number): number` - `static clamp(value: number, min: number, max: number): number` - `static v4f(x: number, y: number, z: number, w: number): Vec4f` - `static rad(value: number): number` - `static degreesDifference(current: number, target: number): number` - `static floor(value: number): number` - `static lerp(value: number, min: number, max: number): number` - `static v3f(x: number, y: number, z: number): Vec3f` - `static rotateIfNecessary(current: number, target: number, max: number): number` - `static m4f(): Matrix4f` - `static v3(x: number, y: number, z: number): Vec3d` - `static quaternion(x: number, y: number, z: number, w: number): Quaternionf` - `static wrapDegrees(d: number): number` - `static m3f(): Matrix3f` - `static clampedLerp(value: number, min: number, max: number): number` - `static approachDegrees(current: number, target: number, speed: number): number` - `static approach(current: number, target: number, speed: number): number` - `static isPowerOfTwo(value: number): boolean` ``` -------------------------------- ### Items Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Standard instance methods available on the Items class. ```typescript getClass(): typeof any translate(): string toString(): string notifyAll(): void notify(): void wait(arg0: number, arg1: number): void hashCode(): number wait(): void wait(arg0: number): void equals(arg0: any): boolean ``` -------------------------------- ### Register Custom Server Commands with ServerEvents Source: https://context7.com/whisent/kubejs-1201-docs/llms.txt Define custom commands for the server using ServerEvents.commandRegistry. Commands can have arguments and permission requirements. ```javascript // server_scripts/recipes.js // Register a custom server command ServerEvents.commandRegistry(event => { const { commands: Commands, arguments: Arguments } = event event.register( Commands.literal('heal') .requires(src => src.hasPermission(2)) .executes(ctx => { ctx.source.playerOrException.heal(20) return 1 }) ) }) ``` -------------------------------- ### KMath Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides standard Java instance methods for KMath objects, such as getClass, notify, wait, toString, notifyAll, hashCode, and equals. ```typescript getClass(): typeof any notify(): void wait(arg0: number, arg1: number): void ttoString(): string notifyAll(): void hashCode(): number wait(): void wait(arg0: number): void equals(arg0: any): boolean ``` -------------------------------- ### Utilize Global Utility Classes Source: https://context7.com/whisent/kubejs-1201-docs/llms.txt Pre-declared global classes like `BlockPos`, `Vec3d`, `KMath`, and `ResourceLocation` simplify coordinate, vector, math, and resource ID operations across all script types. ```javascript // Utility usage across event scripts ServerEvents.tick(event => { // Create a BlockPos const pos = new BlockPos(100, 64, 200) const above = pos.above() console.log(`Above: ${above.toShortString()}`) // Vec3d arithmetic const v = new Vec3d(1.0, 0.0, 0.0) const scaled = v.scale(5.0) const dist = v.distanceTo(new Vec3d(4.0, 3.0, 0.0)) // 5.0 // KMath helpers const clamped = KMath.clamp(150, 0, 100) // 100 const lerped = KMath.lerp(0.5, 0.0, 10.0) // 5.0 const degrees = KMath.wrapDegrees(370) // 10 // ResourceLocation parsing const rl = new ResourceLocation('minecraft:diamond') console.log(rl.namespace) // "minecraft" console.log(rl.path) // "diamond" }) ``` -------------------------------- ### Ingredient Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Methods for using an Ingredient, such as testing if an ItemStack matches or converting it to JSON. ```typescript getClass(): typeof any test(arg0: Internal.ItemStack_): boolean toJson(): Internal.JsonElement toString(): string notifyAll(): void notify(): void wait(arg0: number, arg1: number): void hashCode(): number wait(): void wait(arg0: number): void equals(arg0: any): boolean kjs$asIngredient(): Internal.Ingredient ``` -------------------------------- ### Console Utility Class Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides static methods for logging messages to the console with different levels. ```APIDOC ## Console Class ### Description The Console class offers static methods to output messages to the game's console, categorized by severity. ### Static Methods - `log(...args: any[]): void` - Logs a general message to the console. - `info(...args: any[]): void` - Logs an informational message to the console. - `warn(...args: any[]): void` - Logs a warning message to the console. - `error(...args: any[]): void` - Logs an error message to the console. - `debug(...args: any[]): void` - Logs a debug message to the console. - `trace(...args: any[]): void` - Logs a trace message to the console. - `clear(): void` - Clears the console output. ``` -------------------------------- ### KMath Static Methods for Math Operations Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Offers a collection of static utility methods for common mathematical operations, including conversions, rounding, mapping, clamping, and vector/matrix creation. ```typescript static block(x: number, y: number, z: number): BlockPos static deg(value: number): number static v3d(x: number, y: number, z: number): Internal.Vector3d static ceil(value: number): number static map(value: number, min0: number, max0: number, min1: number, max1: number): number static clamp(value: number, min: number, max: number): number static v4f(x: number, y: number, z: number, w: number): Vec4f static rad(value: number): number static degreesDifference(current: number, target: number): number static floor(value: number): number static lerp(value: number, min: number, max: number): number static v3f(x: number, y: number, z: number): Vec3f static rotateIfNecessary(current: number, target: number, max: number): number static m4f(): Matrix4f static v3(x: number, y: number, z: number): Vec3d static quaternion(x: number, y: number, z: number, w: number): Quaternionf static wrapDegrees(d: number): number static m3f(): Matrix3f static clampedLerp(value: number, min: number, max: number): number static approachDegrees(current: number, target: number, speed: number): number static approach(current: number, target: number, speed: number): number static isPowerOfTwo(value: number): boolean ``` -------------------------------- ### ResourceLocation Constructors Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Constructors for creating ResourceLocation objects. ```APIDOC ## ResourceLocation Constructors ### Description Constructors for creating ResourceLocation objects. ### Constructors - `constructor(arg0: string, arg1: string)` - `constructor(arg0: string)` ``` -------------------------------- ### RotationAxis Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides instance methods for RotationAxis, including degree/radian conversions for Quaternions, and standard enum methods like valueOf, getClass, toString, notifyAll, notify, wait, compareTo, name, values, hashCode, getDeclaringClass, ordinal, and equals. ```typescript deg(f: number): Quaternionf static valueOf>(arg0: T, arg1: string): T getClass(): typeof any ttoString(): string notifyAll(): void static valueOf(name: string): RotationAxis notify(): void wait(arg0: number, arg1: number): void compareTo(arg0: any): number name(): string static values(): RotationAxis[] hashCode(): number rad(f: number): Quaternionf getDeclaringClass(): typeof RotationAxis ordinal(): number wait(): void "compareTo(dev.latvian.mods.kubejs.util.RotationAxis)"(arg0: RotationAxis_): number wait(arg0: number): void compareTo(arg0: RotationAxis_): number "compareTo(java.lang.Object)"(arg0: any): boolean equals(arg0: any): boolean describeConstable(): Internal.Optional> ``` -------------------------------- ### World Class Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Utility class for interacting with the game world. ```APIDOC ## World Class **Description**: Provides various methods for interacting with the game world, including managing dimensions, biomes, blocks, entities, and time. ### Static Methods - `static getDimension(id: ResourceLocation_): Internal.ResourceKey` - Gets a dimension by its ResourceLocation. - `static getBiome(id: ResourceLocation_): Internal.Holder` - Gets a biome by its ResourceLocation. - `static getStructure(id: ResourceLocation_): Internal.Holder` - Gets a structure by its ResourceLocation. - `static getFeature(id: ResourceLocation_): Internal.Holder` - Gets a feature by its ResourceLocation. - `static getBlockState(pos: BlockPos_): Internal.BlockState` - Gets the BlockState at a specific position. - `static setBlockState(pos: BlockPos_, state: Internal.BlockState_): void` - Sets the BlockState at a specific position. - `static getBlockEntity(pos: BlockPos_): Internal.BlockEntity` - Gets the BlockEntity at a specific position. - `static setBlockEntity(pos: BlockPos_, entity: Internal.BlockEntity_): void` - Sets the BlockEntity at a specific position. - `static spawnEntity(entity: Internal.Entity_): void` - Spawns an entity in the world. - `static getEntities(pos: BlockPos_, radius: number): Internal.List` - Gets a list of entities within a radius of a position. - `static getPlayers(): Internal.List` - Gets a list of all players in the world. - `static getTime(): number` - Gets the current world time. - `static setTime(time: number): void` - Sets the world time. - `static getWeather(): string` - Gets the current weather. - `static setWeather(weather: string): void` - Sets the world weather. - `static getRainLevel(): number` - Gets the current rain level. - `static setRainLevel(level: number): void` - Sets the rain level. - `static getThunderLevel(): number` - Gets the current thunder level. - `static setThunderLevel(level: number): void` - Sets the thunder level. ### Getter Properties - `dimensions(): Internal.List` - Gets a list of available dimension IDs. - `biomes(): Internal.List` - Gets a list of available biome IDs. - `structures(): Internal.List` - Gets a list of available structure IDs. - `features(): Internal.List` - Gets a list of available feature IDs. ``` -------------------------------- ### Block Class Constructor Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Constructor for the Block class. ```APIDOC ## Block Class Constructor ### `constructor()` Initializes a new instance of the Block class. ``` -------------------------------- ### Player Class Static Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides static methods for managing player-specific data and actions, including retrieving players by name or UUID, accessing inventories, and modifying player attributes like experience, health, and game mode. ```APIDOC ## Player Class Static Methods ### Description Provides static methods for managing player-specific data and actions, including retrieving players by name or UUID, accessing inventories, and modifying player attributes like experience, health, and game mode. ### Methods - `static getByName(name: string)`: Internal.Player - `static getByUuid(uuid: string)`: Internal.Player - `static getInventory(player: Internal.Player_)`: Internal.Inventory - `static getEnderChest(player: Internal.Player_)`: Internal.Inventory - `static getExperience(player: Internal.Player_)`: number - `static setExperience(player: Internal.Player_, exp: number)`: void - `static getLevel(player: Internal.Player_)`: number - `static setLevel(player: Internal.Player_, level: number)`: void - `static getFoodLevel(player: Internal.Player_)`: number - `static setFoodLevel(player: Internal.Player_, food: number)`: void - `static getSaturation(player: Internal.Player_)`: number - `static setSaturation(player: Internal.Player_, saturation: number)`: void - `static getHealth(player: Internal.Player_)`: number - `static setHealth(player: Internal.Player_, health: number)`: void - `static getMaxHealth(player: Internal.Player_)`: number - `static getGameMode(player: Internal.Player_)`: string - `static setGameMode(player: Internal.Player_, mode: string)`: void - `static isFlying(player: Internal.Player_)`: boolean - `static setFlying(player: Internal.Player_, flying: boolean)`: void - `static isCreative(player: Internal.Player_)`: boolean - `static setCreative(player: Internal.Player_, creative: boolean)`: void - `static isSpectator(player: Internal.Player_)`: boolean - `static setSpectator(player: Internal.Player_, spectator: boolean)`: void - `static isOp(player: Internal.Player_)`: boolean - `static setOp(player: Internal.Player_, op: boolean)`: void - `static giveItem(player: Internal.Player_, item: any)`: void - `static takeItem(player: Internal.Player_, item: any)`: void - `static clearInventory(player: Internal.Player_)`: void - `static teleport(player: Internal.Player_, pos: BlockPos_)`: void - `static teleport(player: Internal.Player_, pos: Vec3d_)`: void ``` -------------------------------- ### BlockStatePredicate Instance Declaration Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Declaration of the global BlockStatePredicate instance. ```APIDOC ## BlockStatePredicate Instance Declaration ### `declare const BlockStatePredicate: BlockStatePredicate` Declares the global BlockStatePredicate object. ``` -------------------------------- ### Color Utility Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Utility methods for creating and manipulating Color objects. ```APIDOC ## Color Interface **Purpose**: Color processing and constants ### Methods - `of(o: any): Internal.Color` - `rgba(r: number, g: number, b: number, a: number): Internal.Color` - `createMapped(o: any, ...names: string[]): Internal.Color` ``` -------------------------------- ### Recipe Class Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Utility class for managing and manipulating recipes. ```APIDOC ## Recipe Class **Description**: A utility class for interacting with game recipes, including getting, removing, and replacing recipes. ### Static Methods - `static get(id: ResourceLocation_): Internal.Recipe` - Gets a recipe by its ResourceLocation. - `static getAll(): Internal.List` - Gets a list of all recipes. - `static remove(id: ResourceLocation_): void` - Removes a recipe by its ResourceLocation. - `static removeByOutput(output: any): void` - Removes recipes by their output item. - `static removeByInput(input: any): void` - Removes recipes by their input item. - `static removeByMod(mod: string): void` - Removes all recipes associated with a specific mod. - `static replaceInput(input: any, replacement: any): void` - Replaces all occurrences of an input ingredient in recipes. - `static replaceOutput(output: any, replacement: any): void` - Replaces all occurrences of an output item in recipes. ### Getter Properties - `types(): Internal.List` - Gets a list of available recipe types. - `serializers(): Internal.List` - Gets a list of available recipe serializers. - `all(): Internal.List` - Gets a list of all recipes. ``` -------------------------------- ### NBTIO Interface Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Methods for reading and writing NBT data to and from a specified path. ```typescript write(path: Internal.Path_, nbt: Internal.CompoundTag_): void read(path: Internal.Path_): Internal.CompoundTag ``` -------------------------------- ### Recipe Getter Properties Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides access to the class, types, serializers, and all recipes. ```typescript get class(): typeof any get types(): Internal.List get serializers(): Internal.List get all(): Internal.List ``` -------------------------------- ### Vec3d Class Instance Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Instance methods for Vec3d objects, performing vector operations. ```APIDOC ## Vec3d Class Instance Methods ### `lengthSqr(): number` Returns the squared length of the vector. ### `distanceToSqr(arg0: Vec3d_): number` Returns the squared distance to another Vec3d. ### `notify(): void` Wakes up a single thread waiting on this object's monitor. ### `yRot(arg0: number): this` Rotates the vector around the Y axis. ### `z(): number` Returns the Z component of the vector. ### `xRot(arg0: number): this` Rotates the vector around the X axis. ### `x(): number` Returns the X component of the vector. ### `align(arg0: Internal.EnumSet_): this` Aligns the vector with the specified axes. ### `closerThan(arg0: Internal.Position_, arg1: number): boolean` Checks if the vector is closer than the specified distance to a position. ### `subtract(arg0: Vec3d_): this` Subtracts another Vec3d from this vector. ### `scale(arg0: number): this` Scales the vector by a scalar value. ### `reverse(): this` Reverses the direction of the vector. ### `wait(): void` Causes the current thread to wait until it is awakened. ### `length(): number` Returns the length of the vector. ### `distanceToSqr(arg0: number, arg1: number, arg2: number): number` Returns the squared distance to a point defined by x, y, and z coordinates. ### `subtract(arg0: number, arg1: number, arg2: number): this` Subtracts a vector defined by x, y, and z components from this vector. ### `zRot(arg0: number): this` Rotates the vector around the Z axis. ### `horizontalDistance(): number` Returns the horizontal distance of the vector. ### `normalize(): this` Normalizes the vector to a unit length. ### `get(arg0: Internal.Direction$Axis_): number` Returns the component of the vector along the specified axis. ### `lerp(arg0: Vec3d_, arg1: number): this` Performs linear interpolation between this vector and another. ### `getClass(): typeof any` Returns the class of the object. ### `relative(arg0: Internal.Direction_, arg1: number): this` Returns a new vector relative to this vector in the specified direction and distance. ### `add(arg0: number, arg1: number, arg2: number): this` Adds a vector defined by x, y, and z components to this vector. ### `cross(arg0: Vec3d_): this` Computes the cross product with another Vec3d. ### `add(arg0: Vec3d_): this` Adds another Vec3d to this vector. ### `"with"(arg0: Internal.Direction$Axis_, arg1: number): this` Returns a new vector with the component along the specified axis modified. ### `horizontalDistanceSqr(): number` Returns the squared horizontal distance of the vector. ### `dot(arg0: Vec3d_): number` Computes the dot product with another Vec3d. ### `multiply(arg0: number, arg1: number, arg2: number): this` Multiplies the vector by a scalar value for each component. ### `y(): number` Returns the Y component of the vector. ### `vectorTo(arg0: Vec3d_): this` Returns a vector pointing from this vector to another. ### `offsetRandom(arg0: Internal.RandomSource_, arg1: number): this` Applies a random offset to the vector. ### `toString(): string` Returns a string representation of the vector. ### `notifyAll(): void` Wakes up all threads waiting on this object's monitor. ### `multiply(arg0: Vec3d_): this` Multiplies this vector by another Vec3d component-wise. ### `distanceTo(arg0: Vec3d_): number` Returns the distance to another Vec3d. ### `hashCode(): number` Returns the hash code for this object. ### `toVector3f(): Vec3f` Converts this vector to a Vec3f. ### `wait(arg0: number): void` Causes the current thread to wait until it is awakened. ### `equals(arg0: any): boolean` Indicates whether some other object is "equal to" this one. ``` -------------------------------- ### Player Class Static Methods Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides static methods for retrieving players by name or UUID, and for manipulating player attributes such as inventory, experience, health, game mode, and status. ```typescript static getByName(name: string): Internal.Player static getByUuid(uuid: string): Internal.Player static getInventory(player: Internal.Player_): Internal.Inventory static getEnderChest(player: Internal.Player_): Internal.Inventory static getExperience(player: Internal.Player_): number static setExperience(player: Internal.Player_, exp: number): void static getLevel(player: Internal.Player_): number static setLevel(player: Internal.Player_, level: number): void static getFoodLevel(player: Internal.Player_): number static setFoodLevel(player: Internal.Player_, food: number): void static getSaturation(player: Internal.Player_): number static setSaturation(player: Internal.Player_, saturation: number): void static getHealth(player: Internal.Player_): number static setHealth(player: Internal.Player_, health: number): void static getMaxHealth(player: Internal.Player_): number static getGameMode(player: Internal.Player_): string static setGameMode(player: Internal.Player_, mode: string): void static isFlying(player: Internal.Player_): boolean static setFlying(player: Internal.Player_, flying: boolean): void static isCreative(player: Internal.Player_): boolean static setCreative(player: Internal.Player_, creative: boolean): void static isSpectator(player: Internal.Player_): boolean static setSpectator(player: Internal.Player_, spectator: boolean): void static isOp(player: Internal.Player_): boolean static setOp(player: Internal.Player_, op: boolean): void static giveItem(player: Internal.Player_, item: any): void static takeItem(player: Internal.Player_, item: any): void static clearInventory(player: Internal.Player_): void static teleport(player: Internal.Player_, pos: BlockPos_): void static teleport(player: Internal.Player_, pos: Vec3d_): void ``` -------------------------------- ### ItemStack Class Source: https://github.com/whisent/kubejs-1201-docs/wiki/Global Provides methods for interacting with and manipulating item stacks in the game. ```APIDOC ## ItemStack Class **Description**: Represents an item stack in the game, allowing for manipulation of its properties like count, NBT data, and item type. ### Constructors - `constructor(item: Internal.Item_, count: number, nbt: Internal.CompoundTag_)` - `constructor(item: Internal.Item_, count: number)` - `constructor(item: Internal.Item_)` ### Instance Methods - `getItem(): Internal.Item` - Gets the item associated with this stack. - `getCount(): number` - Gets the current count of items in the stack. - `getTag(): Internal.CompoundTag` - Gets the NBT tag associated with the item stack. - `setTag(tag: Internal.CompoundTag_): void` - Sets the NBT tag for the item stack. ### Static Methods - `static of(item: Internal.Item_, count: number, nbt: Internal.CompoundTag_): Internal.ItemStack` - Creates an ItemStack from an item, count, and NBT. - `static of(item: Internal.Item_, count: number): Internal.ItemStack` - Creates an ItemStack from an item and count. - `static of(item: Internal.Item_): Internal.ItemStack` - Creates an ItemStack from an item. ```