Add Missing File
All checks were successful
ScriptCraft/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-04-28 17:05:00 -04:00
parent cb9b124ec7
commit 5decd39cdc

View File

@ -0,0 +1,73 @@
import { useBridge } from 'scriptcraft-core';
import { ItemStack } from './item';
/**
* Inventory
*/
export class Inventory {
/**
* @internal
*/
readonly javaObject: JavaObject;
/**
* @internal
*/
constructor(object: JavaObject) {
this.javaObject = object;
}
/**
* Get Size
* @returns Inventory Size
*/
size(): number {
return useBridge('Inventory.size', this.javaObject) as number;
}
/**
* Get Maximum Stack Size
* @returns Inventory Maximum Stack Size
*/
getMaxStackSize(): number {
return useBridge('Inventory.getMaxStackSize', this.javaObject) as number;
}
/**
* Get Stack In Slot
* @param slot Inventory Slot
* @returns Item Stack
*/
get(slot: number): ItemStack {
const obj = useBridge('Inventory.get', this.javaObject, slot) as JavaObject;
if (obj !== null) {
return new ItemStack(obj);
} else {
return null;
}
}
/**
* Take Item From Slot
* @param slot Inventory Slot
* @param count Amount To Take
* @returns Item Stack
*/
take(slot: number, count: number): ItemStack {
const obj = useBridge('Inventory.take', this.javaObject, slot, count) as JavaObject;
if (obj !== null) {
return new ItemStack(obj);
} else {
return null;
}
}
/**
* Set Item In Slot
* @param slot Inventory Slot
* @param item Item Stack
*/
set(slot: number, item: ItemStack): void {
useBridge('Inventory.set', this.javaObject, slot, item.javaObject);
}
}