#Entity Inventory
1 messages · Page 1 of 1 (latest)
How do I show a form when the mob is interact with?
How should I type it in?
https://wiki.bedrock.dev/scripting/gametest-form.html#show-and-respond
Instead of:
itemUse
you would use: playerInteractWithEntity
Ex.
import { world } from '@minecraft/server';
world.beforeEvents.playerInteractWithEntity.subscribe((event) => {
// Code for the form
});
Hope this helps
Ok thanks, I'll probably ask some questions later but still thanks for the help
Would this work, it's just a test
import {
ActionFormData,
MessageFormData,
ModalFormData,
world
} from "@minecraft/server-ui";
}
world.beforeEvents.playerInteractWithEntity.subscribe((event) => {
// Code for the form
let form = new ActionFormData();
form.title("Test");
form.body("Entity Inventory", "textures/ui/equipment_ui_table.png");
});
You need to import world from @minecraft/server and not @minecraft/server-ui
Kind of.
Good call on the import from @minecraft/server-ui for the formDatas', world should be imported from @minecraft/server though.
And for the form you should add a button as actionFormData requires it and as Leon here said also a way to show the form.
form.button
form.show
Like this
And you have to show the form to the player
import { world } from '@minecraft/server';
import { ActionFormData } from '@minecraft/server-ui';
world.beforeEvents.playerInteractWithEntity.subscribe((event) => {
// Code for the form
let form = new ActionFormData();
form.title("Test");
form.body("Entity Inventory", "textures/ui/equipment_ui_table.png");
form.show;
});
Better?
did this end up working for you?
That's wrong.
define the player you want to display the form with form.show(player)
also wrap it around with system.run since you're doing it in beforeEvents