easyPlace feature-complete

This commit is contained in:
ForestOfLight
2025-04-14 12:18:35 -07:00
Unverified
parent 2dfa8cb3ee
commit 5d9daa471d
3 changed files with 45 additions and 25 deletions
+15 -2
View File
@@ -1,4 +1,4 @@
import { system } from '@minecraft/server';
import { system, EntityComponentTypes } from '@minecraft/server';
import { FormCancelationReason } from '@minecraft/server-ui';
export async function forceShow(player, form, timeout = Infinity) {
@@ -11,4 +11,17 @@ export async function forceShow(player, form, timeout = Infinity) {
return response;
}
throw new Error("Menu timed out.");
};
};
export function fetchMatchingItemSlot(entity, itemToMatchId) {
if (!itemToMatchId)
return void 0;
const inventory = entity.getComponent(EntityComponentTypes.Inventory)?.container;
if (!inventory)
return void 0;
for (let index = 0; index < inventory.size; index++) {
const itemSlot = inventory.getSlot(index);
if (itemSlot.hasItem() && itemSlot?.typeId === itemToMatchId)
return itemSlot;
}
}