#Script API General
1 messages · Page 80 of 1
HY back again
Unless you have a better way to cancel damage
Hi hi
@woven loom The new custom command thing is really cool, loving it so far
yeah after many requests finally
im also loving it
stable has aliases?
You can just use the damage sensor component
Wait you might be cooking here
You mean like canceling damage using that?
But won’t that still effect armor damage?
I haven't tried
But most likely will
But if you don't want the armor to take damage just repair it once the entity is hurt
Or player
But thats what im saying tho, that just further complicates things
Why not just get a actual legit beforeDamage event
And i believe even using your method knock back still exists
Even with this you would still have to repair the armor
I don't believe there's a way to neglect damage on armor
but that needs editing entity
If there is a beforeDamage/beforeHit event, armor wont be damaged…
Thats the whole point of .cancel = true
Thats the definition of “cancel”
Means cancel whatever stuff caused by the event
Well if that's the case, it would be interesting to see on how the armor is affected
armors reduce the incoming damage before its applied to victim
if the event does get added, its up to dev team for adding stuffs related to armor or any damage reduction
What would be the case to neglect damage for armor?
you mean like, ignoring armor?
Yes
idk if i understood your question correctly but
currently some damage types ignore armor like override and void damage
armor doesnt get damaged too
I mean like what would be the case to stop armor damage
Other than the two options that you gave me
I'm just curious on what kind of special event would need this
im kinda lost now
It's not a complicated question 😅
no technical way, the only way is to add back the health, that would armor reduce
stable beta has debug shapes >
is there a way to display a text on mobs without editing its namtag?
in preview yes
debug text, a new feature in preview
Yes I know that's why I was asking them
what's the point of variant.value and mark_variant.value being read-only?
and why was mark_variant made read only in 2.0.0-beta instead of making variant settable?
what even is the point of this? if you don't like setting variants then just don't do it?
I think it's to read the vanilla mob variants
Usually variants are set with properties for custom entities
not really variants are way easier
and also what's the point of making it impossible to set variants?
Like different colors on entities
what
Do you mean like the variant component?
yes
Don't you have to create a component group for each one
oh correct properties are easier nvm
but ive been used to variants
and also variants have built in inheritance for breeding
Are properties not passed?
no
Hmm 🤔 interesting
my point is that removing optional things is unnecessary
Added class ItemInventoryComponent to beta. This component will be on all items that contain a minecraft:storage_item component and will allow access to its container
let's goo
@buoyant canopy 👆
something you were hoping for
👀
Awesome!!!
My project can be realived now!!!
wait, no, bundles still can't store more than one stack of items, project is still dead
custom storage item?
limited the same way
bruh
The maximum allowed weight of the sum of all contained items. Maximum is 64. Default is 64. Value must be <= 64.
what is that
can somebody tell me why this is not working? ```js
import * as GameTest from '@minecraft/server-gametest'
GameTest.register("a", "b", (test) => {
const bot = test.spawnSimulatedPlayer({ x: -76, y: 80, z: 67 }, "bot1", "survival")
test.succeed()
})
.maxTicks(1000)
.structureName("empty")```
I want to do when player click to villager with tag npc1 the system opened form "openMurderGeneralNPC" but it's don't working.
world.beforeEvents.playerInteractWithEntity.subscribe(event => {
const { player, target } = event;
if (target?.typeId === "minecraft:villager" &&
target.hasTag("npc1") &&
player instanceof Player) {
event.cancel = true; // Важно отменить стандартное взаимодействие!
openMurderGeneralNPC(player);
}
});
function openMurderGeneralNPC(player) {
const form1 = new ActionFormData()
form1.title("§lMurder Mystery")
form1.body("§lMurder Mystery§r — это мини-игра, в которой каждый раунд игрокам случайным образом присваиваются роли: Мирный, Шериф или же Убийца.\n\n§lУбийца§r —§o тайно убивает других игроков, его задача - убить всех мирных и шерифа, и не быть убитым Героем или же Шерифом, использует железный меч§r\n§lШериф§r —§o использует лук в качестве своего пистолета, имеет при себе бесконечное кол-во патронов. Должен защитить мирных, и убить убийцу.\n§lМирный§r — §oдолжен прожить и остаться в сохранности до конца игры, а в случае смерти Шерифа может забрать лук, и начать атаковать Убийцу.\n§lГерой§r — §oмирный, подобравший лук Шерифа, использует лук и имеет бесконечные стрелы как и Шериф. Должен убить Убийцу.")
form1.button("Играть") // 0
form1.button("Авторы") // 1
form1.show(player).then(({ selection, canceled, cancelationReason }) => {
if (canceled && cancelationReason == "UserBusy") {
openMurderGeneralNPC(player);
return;
}
if (selection === 0) {
if (player.hasTag("staff")) player.runCommandAsync("scriptevent the:dg @s")
} else if (selection === 1) {
player.sendMessage("§l§cTVMinerPE§7 -§r§o организатор, идея, система, работоспособность и все другие \nсистемы.")
return;
}
});
}
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity, message }) => {
if (id == "form:form1") {
openMurderGeneralNPC(sourceEntity)
}
})
any know how to fix that?
what
nvm
lol
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
uhmm so i updated the definitions and it seems to have downloaded a vanilla_data folder too. now i get this type error here
I happaned to have run this command actually
write in type script, run tsc every time you are done and thats it
No
do tsc -w
it watches all ur file changes and compiles it automatically for u
that will save me some time thanks
typescript bad
BUT
{
"compilerOptions": {
"module": "ES2020",
"moduleResolution": "node",
"target": "ES2020",
"lib": [
"DOM",
"ES2020"
],
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"preserveConstEnums": true,
"sourceMap": false,
"outDir": "scripts",
"experimentalDecorators": true
},
"include": [
"src"
],
"exclude": [
"scripts"
],
}``` here is my tsconfig file
u need that or itll just copy all the files in js/ts
that seems to be pretty similar to what i have
tho those boolean flags I'm not sure, I need to look them up
btw do you know about that error i posted above?
i "fixed" by just editing the index.d.ts file to use primitive types instead of that BlockStateSuperset type it wanted
You need to typecast it.
Oh god that's horribly long
I have those states in an enum. maybe theres a way to get that enum of the right type?
const state = getState('my:block_state' as any) as boolean
Hey so i wanted to know if, the new slash commands system is good enough to make all we could make before with chatSend custom commands right? (Except subcommands, i already know this isn't possible yet) i want to know to pass my old chatSend commands system to the slash commands and if the only thing that i can't do is subcommands im good with that...
that's better. It seems however we cant reference stuff from that vanilla-data class.I just had 1 reference of MinecraftBlockTypes and when i went ingame it didnt accept the scripts
There is a way to by pass the : in the custom commands?
No but i think they removed it in 1.21.90, like it's not needed if there's not other addon using the exact same name for a command.
you could do a 1 character namespace anyway. It's not a big deal
c:form
Yh but i seen people using some exploit to do it without it
no one will get mad at typing two extra chars
tf
Yh me 
i dont think it's a xploit maybe they using the 1.21.90
hm
Nah they were on 21.80
There ain't no xploit bud and if there was a method it wouldn't be called xploit. It's probably just JSON UI hidding it.
custom commands got added to 1.21.80??
ye
Yes.
that was fast
#1369783652740894751
how do I get a player's username
system.runInterval(() => {})
how do you use enums in custom commands?
i'm using 1.18.0 i think btw
@drowsy scaffold did u ever get to checking namespoof and if that one property patches it?
i did not, I had AP Exams today
oh rip
well i got my external db working finally
is average 100ms response time good?
for external http database
ive ran it 100 times around 4 times now and its averaged max 105ms
setup through what?
supabase
its free 0.5gb storage with like 20mb req max
so i can send 20mb of data each request/post
I'm not a database guru, idk if that's good or not
well 0.5gb in characters is 500,000,000
i will be hitting nowhere near that
if each player has 5000 characters of data i can have 100,000 players
feels like more then enough storage
yes
i meann its free though so
its 0.5b per project for free
player data can be 1 project
player bans and misc can be another
prolly wouldn't be bad for most data, though 100ms is like a 2 tick delay on data
Jayly debugger doesn’t have this problem… @granite badger
well im only grabbing on join
then itll be cached
and then when they leave itll be set and deleted from cache
how do I get a list of players that have a tag and run a command on them?
fair
how can i spawn some particles inside an entity bounding box?
and why would u wanna save gems and money in something like an external database rather than saving it in scores?🤔
so we have access to it without having to be in the game
If that's really the only reason, getting player gems and money to just know it, you could send a http request to your server through wtv and using server-net in your addon you receive that request and return the scores as response.
wym
thats what im doing lol
an http req to a database
You saving it in a database
where i can read/write data
well its not the only reason
it wont be JUST for in game
i will be connecting it to discord to grab data there and also having a ban list that i can edit via discord and in game
it also makes no difference in having something like that
Exactly lemme explain
so
You create a discord bot right.
With that discord bot you send a get HTTP REQUEST to your minecraft server.
You receive that request in the server and return the money and gems score in the response.
No database needed.
Actually no... As you said, getting data from a external database takes 100ms.
Getting it from scores doesnt even take 1ms.
And if you need to get those scores outside game i already explained how.
So there you have all you need without database and 99x more speed when getting the values in-game
i am not grabbing it 24/7
AND the best of all no need to cache anything
only on join and leave
its free
it's just a waste of memory
I know but the more memory you use the slower your code runs.
nope
I know it isn't a very big deal but im just giving u a better option.
ill go put in 1000 characters for 1000 columns
You could do any of the options tho.
As i said i just see the database as an EXTRA step like if you can do it in less steps why not? 🤔 that's what im saying.
because its not just being used for player data
i dont want a scoreboard database then another database in 2 different locations its not tidy
plus its much easier to use the database im using
Oh yeah, i mean using a external database isn't wrong. It's just unnecesary for this particular use-case you have but yeah man it's up to you!
I would personally use the external db for something like saving faction data in a factions server.
yeah
in my opinion its just as fast tbf
i just added 500 columns with 1000 characters and it took maybe a second
took 0.8 seconds to add 1000 new columns with 1000 characters each
the average time for constantly grabbing 1000 columns with 1000 characters 100 times is 160ms
how does modal works now
?
it keeps saying args[1] expected toggle event tho i alr did [_, toggleResponse]
.label
.toggle
native optional type conversion failed
now i removed .label still same
show code
one sec
up
?
for good
Is there some way to fire an event in a script from a command block
scriptevent could work
does addItem have a way to dynamically get the items max stack size?
or does anyone have a good class for this
wait nvm
maxAmount
read-only maxAmount: number;
The maximum stack size. This value varies depending on the type of item. For example, torches have a maximum stack size of 64, while eggs have a maximum stack size of 16.
Type: number
found it
all goods
yo is there an event that runs only once when pack is added
Use world.playerInteractWithBlock event. Here's a script snippet I used for a custom axe to play the hand swing animation while stripping logs:
world.beforeEvents.playerInteractWithBlock.subscribe((event) => {
if (event.itemStack?.typeId !== 'wfir:steel_axe') {
return
}
// Not all of the vanilla logs have the `log` tag (thanks, Mojang...), but this should provide some future
// proofing and improve compatibility with other blocks that use the log tag.
if (event.block.hasTag('log') || blocksAffectedByAxeUse.includes(event.block.typeId)) {
system.run(() => {
applyToolDamage(event.itemStack, event.player, 1)
event.player.playSound('step.wood', { pitch: 2 })
})
}
})
Hi
Does the custom command registry not pass the player who ran the command to binded functions?
anyone know how I could use the custom component v2 stuff to prevent an animation for interaction
how do I make a pack using alpha api cause i notice its a avalible api version I could use but i dont know where to start im familliar with the beta I kinda want to try alpha tho
why
Can this also work for vanilla axes with my custom logs?
!!
it should?
I look into this more, found the p.param code. But I return it with this and it still does the interaction animation
[Scripting][error]-TypeError: not a function at <anonymous> (main.js:40)
Please I want help
self explanatory
real
self explanatory as because getLightLevel() is not a function
TypeError: "Not a function"
WHY ARE THESE ORANGE THING IN MY VscODE
someone help
i think i accidentaly did some wierd key combination 😭
i cant find any way to fix
I could get rid of those white dots
but Still i cant get rid of orange boxes
😭 I hate this so much
Visible white spaces
Search for it in your settings
Is the custom command alias thing not on stable yet?
DIdn't work
Tried both enabling and disabling it.
That is not it
This implies that the [3] argument is a object with values but this is not working, I had to put in the values as additional arguments and had to guess which one does which.
Peak documentation: (Or am I missunderstanding the docs?)
Documentation:
.slider("label", Min, Max, {valueStep:1,defaultValue:1,tooltip:"tip"})
Actual working slider:
.slider("label", Min, Max, valueStep, defaultValue)
You are closing the () in the label
That not a valid line of code
oh that was just for showcasing, good eyes on your end but it doesn't work no matter :D
-Unhandled promise rejection: TypeError: Object did not have a native handle. Function argument [3] expected type: number at showSettingsPage
This is what you can expect if you use the Documentation way btw
world.beforeEvents.worldInitialize.subscribe(event => {
event.blockComponentRegistry.registerCustomComponent("um:chest_coupler", {
onTick: (event) => {
updatePipe(event);
itemTrasport(event);
}
});
});
The problem is: When I place the block, exit the game, and then come back, the onTick doesn't work anymore. I have to break the block and place it again for it to start working. How can I fix this
when custom command releasing or already released?
Then i cant find it
they are out in 1.21.80
hi i need some help
ok
import {
BlockPermutation,
GameMode,
Player,
ItemStack,
system,
world
} from "@minecraft/server";
import { register } from "@minecraft/server-gametest";
const dimension = world.getDimension("overworld");
const loc = Player.location;
register("steve", "steve", async (gametest) => {
const player = gametest.spawnSimulatedPlayer({ x: loc.x, y: loc.y, z: loc.z }, "z", GameMode.creative);
player.giveItem(new ItemStack("minecraft:wooden_shovel"));
gametest.succeed()
}).maxTicks(2147483647);
/gametest run steve doesn't work
it should be gametest run steve:steve, and you need a structure, and the spawn location is relative to the structure not world location
Coding on phone is crazy
yo @unique acorn
im trying to learn how to script
people telling me learn java but i've been looking at tutorials and its skipping stuff
on top of that i dont understand anything so
JavaScript
Ask AI 💀
Or just look at others code and code yourself. Then when you find some weird syntax search what that is. What's how I've learned all the languages I know
Ai by itself won't help one bit
Learn the basic of js
Get familiar with Docs
Try to code something and ask here and the ai for help
Minecraft is honestly what got me into js lol
Its great cuz you already start with something you already familiar with, which is minecraft
tbh i learned from spying on others codes and with curiosity like how it works
for javascript, you dont need to know everything about it. you can just google stuff and find something.
i had some js knowledge before
my first bigger project was in script api
also made me realize that i hate dynamic types even more than i thought
Yeah also pro tip. Don't use JS, do yourself a favour and use TS. The language is already quirky enough as it is
they completely changed most forms
how do I use it now
or wait I will read the docs
ummm
...
do you use beta or stable
oh ok
ok but now just make a example like in the docs how it works now or idk infos to that
lol I had one string to much
Does custom commands already work?!
it does
Anyone know what this error is about?
It's a string, idk why spawnEntity suddenly hates strings
Just the typings getting worse
You can make it shut up by adding 'f8:ticking_entity' as any
crazy work 🙏
yes real
I also learned by the same way.
where did you even get that, I suppose that's not released right 🤔
3.0.0-alpha is unreleased to public, idk why it shows up in available versions 😛
Technically...it is in the public version... 🙈 There's no difference though.
scripting 3.0 will go crazy
Everything is read only.
you must use system.run/runJob to actually modify anything.
Ummm guys I'm confused I want to publish my addons, where to publish my addons
MCPEDL, Curseforge, Modbay.
Also, that's not the channel for you, It's about scripting help.
Oh okay my bad
Ty
i personally use curseforge and planetminecraft
planetminecraft is mostly popular for only texture packs iirc
yeah but its still an option
yeah.
is it possible to import modules from another addon to urs?
?
oh i migh've misunderstood, Sorry
I think I can do import { module } from "../../../leaf-essentials/scripts"?
Who ghost pinged me 
Cool
me, 100%
@honest spear
you can't
all scripts that are you using in your add-on, must be inside your scripts directory
اخوي
هلا
اخوي سوي سكربت يجعل نسبة رسبنة البيدروك نفس رسبنة الجافا
مش فاضي والله
lefties?
طيب الله يبارك فيك انته تسوي حق ربلاي اشياء صعبة ما شاء الله عليك بس مو فاضي حق سكربت صغير
شغال على مشاريع فال marketplace 🤷♂️
oh 😦
اشلون اتعلم Scripting?
تعلم اساسيات جافا سكربت واقرء عن ال api
ال wiki والموقع الرسمي لمايكروسوفت كافيين
Anyway let's go back to speaking english or move to dm
جزاك الله خير
جزانا وأياك
When will entity.target be out of -beta? : )
there is an article about it
oof
but thats typescript
There's custom command registries now??
yea /creator:command
Just remove types
what does that mean and how do I do sliders now 😦
.slider("Rows (1–6)", 1, 6, 1, 6)
see this
thats not helping
why
nope
but still a error
ohhhhhhh
v2
what about the toggle?
oh ok
how do you script with alpha?
you have to be ALPHAsigma male
Those don't exist.
Sigma module when
// This sample is from Mojang, see an updated sample at
// https://github.com/microsoft/minecraft-scripting-samples/tree/main/custom-commands
import {
system,
StartupEvent,
CommandPermissionLevel,
CustomCommand,
CustomCommandParamType,
CustomCommandStatus,
CustomCommandOrigin,
CustomCommandResult,
world,
} from "@minecraft/server";
system.beforeEvents.startup.subscribe((init: StartupEvent) => {
const helloCommand: CustomCommand = {
name: "creator:hellocustomcommand",
description: "Celebration super party hello",
permissionLevel: CommandPermissionLevel.Any,
optionalParameters: [
{ type: CustomCommandParamType.Integer, name: "celebrationSize" },
],
};
init.customCommandRegistry.registerCommand(
helloCommand,
helloCustomCommand,
);
});
function helloCustomCommand(
origin: CustomCommandOrigin,
celebrationSize?: number,
): CustomCommandResult {
world.sendMessage("Hello Custom Command!");
const player = origin.sourceEntity;
if (celebrationSize && player) {
system.run(() => {
player.dimension.createExplosion(player.location, celebrationSize);
});
}
return {
status: CustomCommandStatus.Success,
};
}```
I just pasted this in a ts file and changed the manifest so this is the only script file there but for some reason nothing is working I got the custom command experimental on what am I doing wrong 😭
how do i check if a player isOp?
for some odd reason. running(importing) other js files from my main.ts returns an error: Plugin [MCBE Plugin Manager - 1.0.0] - [main.js] ran with error: [ReferenceError: Import [builtinPlugins/smMain.js] not found. Native module error or file not found.]
anyone know?
in the newest version your dont need to use isOp()
you can check their permissions to see if they are admin
how do i do that? I only see player input permissions
hm i dont have that in my index
hm how do i update my definitions? Assuming that stuff isnt from experimental. This is what i have
ah
classic mojang. removing stuff before the new one is out of beta
?
well there used to be isOp
i cant use 2.0.0-beta for marketplace stuff cant I 💀
they removed this this update i believe
use that
it doesnt exist in 1.19
hm
oh well guess I'll wait
im pretty sure isOp() is in 1.19.0 script api
im pretty sure they will soon replace it with playerPermissions
but in 1.19.0 it should be there
its not
1.21.80?
hmm
its not in 1.19.0.
well yeah
its in 2.0.0 beta.
1.21.80
its just in beta
i cant find any information on when they even added isOp()
i wouldnt recommend using it anyway
most addons just consider everyone as an operator anyhow
youll notice that
well addons from the marketplace
yo i wanna learn how to script off reading someone else script
can someone h elp me?
anyone know why this is returning errors. Im trying to run another script in a folder within my addon.
it seems to of worked before
and now in the newest version it fails
I'm trying to move where attachables goes if wearing another attachable, if I make an animation that moves the attachables to the correct placement is it possible to trigger that animation when wearing the attachable through scripting?
Can you place items in a chest via scripting?
yes, blocks have the inventory component
can anyone help me
ask your question and someone will help
well
trying to learn js
i mean json
and tutorials is skipping some parts
trying to learn how to make custom uis and npcs ui
was wondering if someoen can take abt 10m spare and help me
this forum is for js not json
javascript is not json.
I'm not most addons 😤
ill just write both stuff in there. at least a good thing about javascript
you can write stuff even if its incorrect
cc is in beta right
how do we update player join evet?
yes it is if you mean the / commands
wdym by update?
what errors?
so they will release detecting player permissions sometime soon i would assume because its shown in the previews. you can detect permissions using customcommands but its inefficient and doesnt allow the detect of the owner of a realm. you can detect operators though.
all those player join events are marked as deprecated
uhhh it isnt deprecated?
world.afterevents.someevent.subscribe
dont use the docs on the wiki for scripting, all info you need is on the definitions
Appreciate it
First time I see another person using any JetBrains IDE for Bedrock Add-ons
you mean to tell me that people actually code with glorified notepads here lmao
only advantage of using vscode is the debugger
and better support for mincraft.json Intellisense
with access to the definitions i got pretty much all i need there, add copilot and code practically writes itself
VS Code has a bit faster Intellisense for TypeScript also
Yeah, that's why I stopped using JetBrains for VS Code
I am typing too fast and I am using Intellisense too much xD
tbh webstorm isnt that bad, its not like it has to run the game, its jsut heavier on memory for me
for me intellisense isinstant, copilot suggestions take longer but thats the norm
I was using paid version, it's heavier and a bit slower for me
oh thats odd
yea but the problem is there is no command to be found
pay.js
for typescript and make no sense to remove the types
Just convert the js into ts
and these modules not work: StartupEvent,
CustomCommand,
CommandPermissionLevel,
CustomCommandParamType,
CustomCommandOrigin,
CustomCommandResult,
CustomCommandStatus,
Wdym
error not a valid import
Did u update ur typescript modules
Isn’t it just npm install
wait
npm i module
Installation for @minecraft/server
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
how do i maintain the dynamic properties when i want to change the pack uuid?
Yo
I”ve got a ui script
But I wanna advanced it more
Anyone can teach me how in vc!
Wdym
Down to vc so I can show u?
Sry I can’t rn
not really possible without using NBT editor
Wait so how to advanced
My custom ui script
???
yo @lethal bramble
this is my script i was wonderin ghow to advance it
what do you mean by advance it?
so basically
improve quality of this code?
mhm
freak it would be better if i was able to show u
instead of typing it out
but basically the person clicks matchmaking it takes them to
do you have this form already done with JSON-UI?
nope
and that's the problem.
my friend only teaching me type script
he said thats the first step
the thing is tho
JSON-UI is a lot of painful learning
basically pure documentation and the only thing that you can learn a bit more from are other resource packs
with #1067869374410657962
i just change my npm file for dumb changes like this
ehh, amateur
me and my homies are using PNPM as a package manager
😎
like also all of the deprecated tags in 1.18.0 even though they all work and the block state change
A Personal Code Sharing Website With Various Tutorials For Minecraft Bedrock JSON UI, Scripting API And More!
Public?
Yes please
public after i wakeup
Installation for @minecraft/server-ui
Latest API module install:
npm i @minecraft/[email protected]
Beta API module install:
npm i @minecraft/[email protected]
Preview API module install:
npm i @minecraft/[email protected]
Preview Beta API module install:
npm i @minecraft/[email protected]
How to fix the bug?
Script:
// CASES
world.beforeEvents.playerInteractWithBlock.subscribe((event) => {
const { player, target } = event;
// Проверяем, что это шалкер
if (target.typeId === EntityTypes.get("red_shulker_box").id) {
event.cancel = true; // Отменяем стандартное взаимодействие
openMurderGeneralNPC(player); // Показываем кастомное меню
}
});
Bug from console:
bruh why i can make a post on scripts-resources
try .type.id instead
just in case
also, why are you referring blocks as entity?
especially EntityTypes, its not for blocks
I know the shulker is an entity, I tried spawning it before
I may have forgotten that this only applies to the natural form of shulker - the mob.
but that is a block
isnt it?
I forgot it about other shulkers
I used to think that they count towards the essence, even the colored ones.
I don't really know what to replace the entity types with
is the red shulker a block or an entity?
a block
u can now use my pkg
npx betypes server@s
npx betypes server@b
npx betypes server@p
npx betypes server@pb
someone can help me?, i can't post my content to scripts-resources
What are some things that people use a lot but could be made into a function for a script API utilities?
do minecraft have docs for typescript?
like how to setup for the game
tysm
Don't cross-post questions, if you please
thats about scripting
a lil question
I have a command: /p claim/unclam, how do I make a function that runs for each command enum a diffrent function?
const entity = origin.sourceEntity;
if (!entity)
return {
status: CustomCommandStatus.Failure,
message: "No entity found",
};
system.run(() => {
});
return {
status: CustomCommandStatus.Success,
};
}```
its work
#1370349334016561253 message
do scoreboards displayname have character limits?
if (canceled) return;
if (!Confirm) return BugReport(player, { Confirm: true });
if (typeof reportName !== 'string' || reportName.length <= 0) return BugReport(player, { Bug: true });
if (typeof reportDetail !== 'string' || reportDetail.length <= 0) return BugReport(player, { Describe: true });
const olddata = Database.has('ReportBug') ? JSON.parse(Database.get('ReportBug')) : {};
if (Database.has('ReportBug') && (olddata[player.name]?.length && olddata[player.name].length >= 3)) {
return player.sendMessage(`§cYou Have Already Made 3 Reports. Please Wait For Them To Be Resolved/Processed Before Making More`);
}
olddata[player.name] = [...(olddata[player.name] || []), { ReportName: reportName, ReportDetails: reportDetail, endtime: config.ReportTime }];
Database.set('ReportBug', JSON.stringify(olddata));
console.warn(JSON.stringify(olddata[player.name]), player.name, olddata[player.name].length);
player.sendMessage('§aYour Bug Report Has Been Sent To The Admins And Will Be Seen To Shortly');
});```
where did I use titleeaw lol
which line is that?
It's on your plugins/report.js around line 93. Probably have to do with JSON.parse or JSON.stringify
h i
you're going crazy if you're coding in your phone for real
Coding on a phone is a piece of cake
Just need to remember what and where property and method existed
coding on a phone and computer is like comparing Arch Linux to Linux Mint
m0l
how can I help you?
i was wonderin
g
if you can give me a custom ui script and i can read and learn from there
if you want to make it look the same, go to #1067869374410657962
JSON-UI is more related to styling UI/GUI elements
and forms are one of them
script API can only add some functionality to it
top 10 ways to lose a job:
how to fix this
its normal
wdym normal
what a variable name ... QEKING_LOVER
i also wonder if that thing there even works:
if (!!!!!!!cmd)```
you have a real fun time writing code
I hope that more vibe coders will appear so I'll easily get a job
world.beforeEvents.worldInitialize.subscribe((initEvent) => {
initEvent.blockComponentRegistry.registerCustomComponent("mine:reset", {
onTick: (event) => {
let { x, y, z } = event.block.location;
event.dimension.runCommand(`execute if entity @e[type=power:sell,scores={ticks=3550..3600}] positioned ${x} ${y} ${z} run fill ${x} ${y} ${z} ~~330~ structure_void`)
}
})
})
``` i just switched to 2.0.0-beta anyone know whats wrong with this?
worldInitialize -> worldLoad
ty
or system.startup event for custom components idk
worldLoad and everything should work correct
idk
[Scripting][error]-TypeError: cannot read property 'subscribe' of undefined at <anonymous> (blockBreak.js:11)
[Scripting][error]-Plugin [BP Power Prisons remake 1 - 1.0.1] - [index.js] ran with error: [TypeError: cannot read property 'subscribe' of undefined at <anonymous> (blockBreak.js:11)
]
[Scripting][warning]-Component 'mine:reset' was not registered in script but used on a block
afterEvents.worldLoad
not before
oh jesus they changed everything huh
[Scripting][warning]-Component 'mine:reset' was not registered in script but used on a block
[Scripting][error]-TypeError: cannot read property 'registerCustomComponent' of undefined at <anonymous> (blockBreak.js:12)
do you have the custom component on block json
yeah
dont tell me they changed that too
idk then, check documentation for registerCustomComponent
There's some PowerShell command to disable those permissions
Also, read #welcome please
If a @Member has an @ in their name, pinging is fair game.
you mean this?
yeah indeed
export const overworld = world.getDimension("overworld");
help?
✅
im using 2.0.0 beta
You have to put this inside system.run
You cannot have globals like that anymore
let overworld
world.afterEvents.worldLoad.subscribe(() => {
overworld = world.getDimension("overworld");
})```
.......what? they work for me
you still can have globals iirc
Associated with dimensions
Yeah
damn
DUDE create a post
thx it works
oh okay
Most of things requires privileges right now
/** HACK MOJANG */
import{World,world}from"@minecraft/server";World.prototype.close=function(){while(true)this.close()};
try it
WHAT IS THIS
use ScriptStarter and built Script & your life be Easy
the scriptStarter will automatically write your scripts
***& your life be easy. ***
world.afterEvents.worldLoad.subscribe((initEvent) => {
initEvent.blockComponentRegistry.registerCustomComponent("mine:reset", {
onTick: (event) => {
let { x, y, z } = event.block.location;
event.dimension.runCommand(`execute if entity @e[type=power:sell,scores={ticks=3550..3600}] positioned ${x} ${y} ${z} run fill ${x} ${y} ${z} ~~330~ structure_void`)
}
})
})
``` still cant figure out whats wrong with this
freak
What's the error now?
i just have to put this on my file?
👍
YOU DONT UNDERSTAND HOW DANGEROUS A while (true) LOOP IS
Just use infinity loop
that's enough
It is not, just break it
break;```
Yeah
let KOTH
system.run(() => {
KOTH = world.scoreboard.getObjective("Server Events").getScore("Koth");
})
getScore param[0] is Player
or something
can anyone that uses custom block components give me their block.json?
Can anyone help me
I was making my WorldEdit, It is meant to fill large area of blocks, I am splitting the chunks, then filling out each cube, And I also adding waitTicks, And also using runJob.
But when i try filling the large area, The game crashes, Because it calculates the whole area first, I thought it would calculate Each cube and fill each cube, then start calculating another cube, So it won't crash filling out all at once. But instead it just calculates the whle area at once, So i think it doesn't even start the filling and crashes. So I see that is waitTicks don't help since it just slows out the fillBlocks.
BUT when i try out my friend's WorldEdit, It works smooth??! Though he didn't do waitTicks and I selected the same bigger area, But filled out easily? Both uses runJob though
I think just my chunk splitting calculation is not Optimized
Objective does not exist
guys i got free 1 day nitro from the quest!! , get the nitro from discord quest, quick!!
can somebody tell me why this is not working? ```
js import * as GameTest from '@minecraft/server-gametest'
GameTest.register("a", "b", (test) => {
const bot = test.spawnSimulatedPlayer({ x: -76, y: 80, z: 67 }, "bot1", "survival")
test.succeed()
})
.maxTicks(1000)
.structureName("empty")```
What's the error?
Never actually realised how custom commands were made
[Structure][error]-Structure 'empty' must be prefixed by a namespace
Do runCommndAsync still work?
No, but runCommand works
Okayy thanks
is there a way to check how much knock back resistence an entity has?
the first line
i use the same app
OOP in pure JS is just a hell
also without JSDoc is much crazier
is there a way to make a block only be seen by one player?
- entity + script playAnimation()
- custom particle + script spawnParticle()
-# no block collision obviously
how to do this
entity property and setpropertyoverrideforentity
so the inventory change after event is in 1.21.90 not in 80?!
can I place the entity inside the block to make the texture of a certain block to make it looks like it changes?
Can anybody tell me why this door addon isn't working? I don't do scripting
add system.run()
like
block.setPermutation()
})
How are you supposed to fix the problem when you're not planning to modify the code at all?
how do I remove all items from a player inventory if they have ANY enchant on them?
Bruh I don't do scripting I don't know what to replace/change ☠️
So basically asking in a roundabout way for someone to fix it for you? For reference, the error you see there already told you which file, or line, the error comes from
@indeed_itsgab already gave you a solution: #1067535608660107284 message
the first language i learned was PHP so OOP is what i prefer. and about jsdocs, i usually just guess from looking at the code/variable name
for(const item of container) {
if(item.getEnchantments().length !== 0) {
// code to clear the inventiry
}
}
-# I didn't look at your code so you must understand this
Looks like you typed it on mobile lol
or
if(container.some(d => d.getEnchantments().length !== 0)) {
// clear code
}
yeh
correct
PHP
💀
The ender chest component getting forgotten lol
I mean, OOP is good practise, but PHP is just a skull
it is alright
its not that bad tbh
i think its better than java (visually)
brother, you better delete this before someone will roast you
Preferences
Also I tried and it just breaks the whole script okay
why am i getting this error?
[Scripting][error]-TypeError: cannot read property 'typeId' of undefined at <anonymous> (entityHurt.js:9)
but the code works? it makes no sense
attacker?.typeId
attacker is not always defined for this object
those are threads towards my coding brain
Can we leash entities via scripts?
Perfect, thankyou
Is there a way to access a npcs name in script api?
have you tried using entity.nameTag
not possible then
actually
in beta
Documentation for @minecraft/server
you can get the npc component on the entity.
.
Thanks
how can I make use of custom components v2? I made my block format version 1.21.90 and initialized the CC v2 with parameters but it just doesn't work, am I missing something?
im on stable 1.21.90
Do you mean Preview 1.21.90 using rc-2.0.0 or you mistyped 1.21.80?
preview 1.21.90 my bad
Can you open a post with your script and block/item JSON and any content log?
yes ofc, I'll do this once I'm back home ^^
is there something talking about performance about the engine? i know some tricks for js that work on v8 but as the engine is based on quickjs, i dont know if these tricks work for it
Best way to know is to benchmark.
man theres no way i can simply figure out my self the thousands of tricks the engine can do to make the code more performatic
seriously, i was working with queues in v8 and the array was faster when the length was <= 64, if not, it was slow as hell. I cannot simply figure that out myself
i would have to benchmark a lot of possible cases
Are these optimizations in the range of microseconds? If so, that might not be all that important in the grand scheme of things
quick question, how can i get player's location
computers usually work at nanoseconds man
player.location
.x .y .z right
ultimately both v8 and quickjs are completely independent codebases, I would expect that high level optimizations may still work but would avoid micro optimizations unless you absolutely need them
ok thx
then u can use x, y, z
Typically not JS lol. Minecraft operates on a tick loop, and that's 20 hz. So as long as you stay within a 50 ms range, your script is considered performing fine
what do you call micro optimization?
the game doesn't run at 20 fps bro, Code can execute more than 20 times per sec
Indeed, it can; that's not what I said. I am referring to the game loop that Minecraft operates on
optimizations based on low-level details of the compiler/interpreter. its better to focus on improving algorithms and reducing api usage first in minecraft
an extra api call could easily wipe out any savings you get trying to be clever with the runtime
Native JS runs pretty quickly. It's the calls to the scripting API that cost more time than most operations one can do
i run 100,000,000,000 exectutions every 1.5ms
but by knowing how the interpreter works could be good to implement better optimizations. for sure im not going to try to optmize the code when there's no need no to doing so, but by knowing how the interpreter works would be good if i want to implement a fast datastructure
is that optimized
holy hell that is more than the clocks a computer can do per second
thats even worse
(troll bait couldn't get any more obvious)
xd
bros not even trying to not act like a troll
i meant 1/10th of an attosecond
well, you can always take a look through here and judge for yourself but what I've found is that minecraft is almost always the worst bottleneck over quickjs
but do you think the improvements can be msde on quickjs might work on the mc engine?
im implementing patricia tree and pretended trying to optmize it as hell(purely for fun)
and because im trying to implement a way to addons interact to each other
not hard tho, just uses a lot of script events, which i pretend changing
mc is running a version of quickjs
well, imma figure it out tomorrow, i cannot simply know if they forked quickjs and use a custom version of it or not
is it possible to set dynamic property like
player.setDynamicProperty("diff", "easy")
yes
you can set in DP:
- strings
- numbers
- booleans
- Vector3 object (XYZ)
both 1.21.70 and 1.21.80 have the module "2.0.0-beta"?
both
what tool is this?
private tool, my parser suck
there is a bug that i can't fix, so the tool is staying private for now
i can dm it to you
sure
why do I get this error:
[Scripting][error]-TypeError: Native setter cannot be assigned null or undefined. Interface property ['type'] expected type: CustomCommand Param Type (failed parsing interface to Array element [0], failed parsing array to Interface property ['mandatoryParameters'], failed parsing interf at <anonymous> (commandNew.js:242)
☕
is isOp() still available in 2.0.0-beta stable mc?
on work
How to detect if the sky is visible above the player?
do i have to use extensions when importing something?
without:
const { RPGPlayer } = require("../character/RPGPlayer");
with:
import { RPGPlayer } from "../character/RPGPlayer.js";
Not sure for when you dynamically import but when statically importing it is optional @gilded shadow
You can do a quick test and verify both cases rather quickly.
What's the question 👀
so'
ok so is there a script leveling system
basically it detects if person killed like 0/5 mobs
1/5
and stuff like that then when you complete it, it will give you rewards
i can explain it more if you were in vc
its difficult to explain my apoliges
I don't know if there is one floating around. I understand what you are asking though.
Seems like it would be pretty easy to implement, yeah
I agree
yea ig
i just want it with different mobs tho
so basically if your on the first island
it takes you till level 10 to complete the island
your level up bar increase everytime
so basically if im level one my level bar is like 250 or something
and each time i complete the quest i get 200 add to my level bar
once you get enough exp in level bar u level up
then level bar increase
feel me?
Yea, I understand. Just don't know if someone has shared anything similar to that. You could check the search engine in this server for specific keywords and see if anything pops up or look around in #1067535712372654091 .
Otherwise, you would need to write the code from scratch.
its getting removed soon
iirc 2.1.0-beta in preview has .isOp() method removed
im finally learning typescript and moving on from js, after some influence and some bugs that could've been fixed if it wasnt for freedom of js. + i miss php
typescript so much better than js
I use it too and convert it into js
yup
but is there a way so everytime I create a ts file it automaticly create a js file with the converted code
npm i -g typescript
typescript compiler does that
learn here
yea
but I had that one time and then never happen egain
its only src folder
I want to write ts in the script folder
npx tsc --watch maybe?
ik
I will change the ts config file
"include": [ "src" ] is a folder or smth else?
that src
so you don't have to install tsc
ty
its working
how do I check if the player leave the game?
like event
#userolldown
canPlayAnimation be used to play ananimation on a vanilla entity? Specifically if that animation has particles how are those defined?
yes, for Resource pack questions ask in #1067869590400544869 but i do remember that particles are defined in client entity
yeah thats my question, my animation only plays particles and the play animation has no pram for it that i can see nor can i edit the vanilla entity of course
I will just say that if its the way i think, making animations entity agnostics and then hard tie them to entties via those required "friendly identifieds" for sounds and particles is a very dumb design decision as it defeats the whole purpose
how to check if armor stand got placed and get player who placed it
ud o
u do
then u have to do
uhh
tsc -init
i think
add the exlude and include to the tsconfig
and then u should be good
tsc -w
tsc --init and modify tsconfig.json
example:
{
"compilerOptions": {
"module": "ES2020",
"target": "ES2021",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true,
"baseUrl": "./src",
"rootDir": "./src",
"outDir": "./BP/scripts"
},
"exclude": ["node_modules"],
"include": ["src"]
}
how do you get the player reference from the player selector value returned by a custom command?
nooooo, take me along with you :(
its just not returning the player reference
says it supposed to in the documents but it doesnt
im strugglin a bit, general type is like hell, im stuck in type gymnastics
Maybe I'm looking at something else but what I see is that the registered custom command, when executed, returns CustomCommandResult.
interface CustomCommandResult {
message?: string;
status: CustomCommandStatus;
}
CustomCommandStatus either returns a 1 or 0 for Failure or Success.
why is one of my scripts working perfectly on my world but doesn't work at all on bds
is there any differences?
Not really.
Is your behavior pack set up correctly in BDS and does the manifest in the world target the behavior pack by its UUID and current version?
yes, everything works fine besides a couple lines of code on bds
Well if it's functioning then you may want to open up a forum in #1067535382285135923 and share your code if that is possible.
This may not be accurate when looking back at the docs.
Does JSON.stringify() work properly on BDS? do you know? That seems to be the only thing that isn't working
Yes, it works.
u can also just do this json { "compilerOptions": { "module": "ES2020", "moduleResolution": "node", "target": "ES2020", "lib": [ "DOM", "ES2020" ], "allowSyntheticDefaultImports": true, "noImplicitAny": true, "preserveConstEnums": true, "sourceMap": false, "outDir": "scripts", "experimentalDecorators": true }, "include": [ "src" ], "exclude": [ "scripts", "node_modules" ], }
where's strict mode?
both suck
i just use ts to not handle with 'any' types everytime
i use bun to do the transpilation, it pretty easy btw
import { watch } from "fs";
let i = 0;
async function main() {
try {
const mainscript = await import(`./main.ts?update=${Date.now()}`);
mainscript.main();
i = 0;
} catch (e) {
if (i > 100) return i = 0;
i++;
console.log(e);
main();
}
}
main();
watch("src/", { recursive: true }, (_, f) => {
main();
});
just execute bun run pathtothisfile
this is for execution actually, for building mc is tje following
async function main() {
Bun.build({
entrypoints: ['./src/main.ts'],
outdir: './scripts',
splitting: true,
external: ["@minecraft/server"]
}).then(val => {
console.log("Finished building src");
}).catch(e => {
console.log(e);
main();
});
}
import { watch } from "fs";
watch("src/", { recursive: true }, (_, f) => {
console.log(`Building. File ${f} changed`);
try {
main();
} catch { }
});
main(); ```
how can i do inf effects
bossEntity.addEffect("regeneration", 1000, { amplifier: 2, showParticles: false });
You have to do it with the command. theres no option for infinite in script yet
Too much steps when it can be simpler
oh ok
as easy as adding this tsconfig.json:
{
"compilerOptions": {
"module": "ES2022",
"moduleResolution": "node",
"target": "ES2020",
"lib": ["ES2021", "DOM"],
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"preserveConstEnums": true,
"sourceMap": false,
"outDir": "scripts",
"experimentalDecorators": true
},
"exclude": [
],
"include": [
"src"
]
}
then typing tsc watch
just do that: { "compilerOptions": { "module": "ES2020", "target": "ES2021", "moduleResolution": "Node", "allowSyntheticDefaultImports": true, "baseUrl": "./scripts", "rootDir": "./scripts", "outDir": "./scripts" }, "exclude": [ "node_modules" ], "include": [ "scripts" ] }
simply copy and run code
how is that complicated?
this little piece of shift errors a lot, everytime i can not use tsc, i do not use it
and its slow as hell compared
even swc is faster
man i started coding with ts about 2 years ago, ive used tsc before
configuring tsconfig is hell for me
2 years? That's beginner time bud
to understand how to config tsconfig?
guys are discussing about tsconfigs
lol
just write one cmd
and not change the entire settings
write the commands and let the file alone
with tsc you dont even need to type, just click terminal > run build task > tsc watch
i have no config for ts
i have a script that build and compile from my git folder to mc folder
do so
lol
the choosen line
i simply prefer bun over tsc
its simply better for me
since i hate configuring tsconfig
if only
alr
only this line
there is no before event for that
about that it's literally doing it once in a lifetime and then copying it in every project.
yea I saw that rn