#Script API General

1 messages · Page 50 of 1

distant tulip
#

again 👆

fallow rivet
warm mason
#

show code

fallow rivet
#

Test:back = chest minecraft
But immortal

warm mason
#

I don't know how to read this.

#

There's some horror with the spaces here

fallow rivet
warm mason
#

I want to say that this is not possible to read

distant tulip
warm mason
fallow rivet
distant tulip
#

there is no error from what i can see

warm mason
#

So you didn't set the item back to inventory

distant tulip
#

that function is not even triggering

fallow rivet
#

This is what happened a short time ago

fallow rivet
#
    const items = inventory.container.getItem(pslot);
#

It works when I make it a player but it doesn't work when I make it an item

winter plaza
#
import * as mc from "@minecraft/server";

let Powers = {
  "dragon_ball": {
    animation1: "playanimation @s animation.dragon_ball wesl3y",
    sound1: "playsound dragon_ball @a ~~~ 1.5",
    shoot1: ["wesl3y:jutsu_projetil", "dragon_ball", "player.name"]
  }
}

mc.system.runInterval(() => {
  for (const player of mc.world.getPlayers()) {
    if (player.hasTag("test3")) {
      usePower(player, "dragon_ball");
      player.removeTag("test3")
    }
  }
});

function usePower(player, powerId) {
  const test = Powers[powerId];
  if (test.shoot1 != null) shootPower(player, test.shoot1[0], test.shoot1[1], test.shoot1[2]);
}

function shootPower(player, id, event, name) {
  player.runCommandAsync(`say ${player} ${id} ${event} ${name}`);
}
[Scripting][error]-Unhandled promise rejection: CommandError: Erro de sintaxe: "[": inesperado em "say »[«object Obj"
#

help

warm mason
drowsy scaffold
#

does data.cancel no longer cancel a fishing rod?

distant tulip
fallow rivet
coral ermine
#

What means error:

Lexical declarations cannot appear in single-statement context?

remote oyster
#

Just remember that x is only available within the scope of that block statement. So if you need access to it outside of that block statement then declare it first.

drowsy scaffold
#

is there any way to get an itemStack instance of a placed shulker box that keeps the stored items?

open urchin
crude bridge
thorn flicker
thorn flicker
# crude bridge ik
const secondSlot = block.getComponent('inventory').container.getItem(1)
thorn flicker
#

you could do getSlot(1).getItem() but I edited it to be just getItem(1) because that might be better.

#

here's a doc for the block inventory component.

thorn flicker
#

both of these sites are like the same.

somber cedar
#

Waveplayz example is in there

thorn flicker
inland merlin
#

Okay need some thoughts,

I changed my spawner system to no longer spawn entities but instead just adds loot and xp inside the herobrine chestformdata setup i have.

Now... the calculations are based off events/datenow, so NO system.runInterval at all.

Is running events by 30 people constantly horrible? I forget is there a way to keep the event from being ran per player.

#

Because they can punch to generate loot

#

Or wait slowly over time with datenow

#

Calculations

valid ice
#

why not use block ticking component

inland merlin
#

Well, i want to not have any ticking at all

#

Even for blocks

#

Just event based only

#

It's based off of donutsmp spawnwrs but heavily modified for better efficency

#

Just different type of gameplay for the most place

#

Wasn't there something in js that would help merge events for players? One sec let me look at some old code

#

Sorry just going brain dead rn, ignore everything

valid ice
#

ok

inland merlin
# valid ice ok

Is there a good way to replicate mending? I'm giving players xp directly but don't think it would add to a weapon they are holding upon collection. As it's command xp

#

Since they are not killing entities, the mending wouldn't work normally

#

As I just give it to the player

#

So I need to recreate the mending enchant

#

Just the .damage right?

valid ice
#

Can't say I've ever tried to recreate it

inland merlin
#

Oh ok haha

#

I can just want sure if ypu had any thoughts on that

#

I'm not sure what amount

#

Is given to the mending enchant on a sword. Like what fix amount

valid ice
#

It's probably on the wiki

inland merlin
#

1 xp for 10 damage etc

inland merlin
valid ice
inland merlin
#

100%

#

Its 2 durability per 1 xp.

drowsy scaffold
#

how do I create an event listener with server-net?

#

does it go on world, server, or some other superclass for it

valid ice
#

like, listening for http?

#

has to be done on intervals

drowsy scaffold
#

with the new packetSend and packetRecieve

granite badger
nocturne berry
#

How do you detect if it is daytime?

gaunt salmonBOT
#

Description
There are two functions in this script:

  • function GetWorldTime

returns
The hours and minutes of the world time.

example
getworldtime.js

import { world } from "@minecraft/server";
const { hours, minutes } = GetWorldTime();
world.sendMessage(`The time is ${hours}:${minutes}`);
  • function getTimeOfDay
    Gets the name of the time of day

returns
'Sunrise', 'Day', 'Noon', 'Sunset', 'Night', or 'Midnight'

Credits
These scripts were written by Jayly#1397 on Ja

dim tusk
#

It's already labeled.
Just do js const time = world.getTimeOfDay(); if (time >= 1000 && time <= 6000) {}

#

-# oof nvm someone sends an function already lmfao

nocturne berry
#

Thanks

vague helm
#

could someone help me update a old pack?


[Scripting][warning]-Debugger auto-attach waiting for [0] seconds.

[Scripting][warning]-Debugger auto-attach did not connect.

[Scripting][warning]-Debugger auto-attach waiting for [0] seconds.

[Scripting][warning]-Debugger auto-attach did not connect.

[Item][error]-key:use | run_command | child 'run_command' not valid here.

[Item][error]-blackey:use | run_command | child 'run_command' not valid here.

[Actor][error]-New World | actor_definitions | C:/Users/treev/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/Crate System [BP] | crates:craterare | minecraft:entity | events | hit | run_command | child 'run_command' not valid here.

[Actor][error]-New World | actor_definitions | C:/Users/treev/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/Crate System [BP] | crates:cratelegendary | minecraft:entity | events | hit | run_command | child 'run_command' not valid here.

[Actor][error]-New World | actor_definitions | C:/Users/treev/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/Crate System [BP] | crates:cratecommon | minecraft:entity | events | hit | run_command | child 'run_command' not valid here.

[Scripting][warning]-Plugins have been loaded successfully in 0MS

#

its run_command but what methods are there?

dim tusk
vague helm
#

oh crap sorry

#

its json

steady glade
#
function checkForArmor(player: Player, armor: ItemStack | undefined) {
    const netheriteArmor = "minecraft:netherite_chestplate";

    if ((armor?.typeId === netheriteArmor) && player.isSneaking) {
        player.addEffect("invisibility", 200, { amplifier: 1 });
        world.getDimension('overworld').runCommandAsync(`invisibility`);
    }
}

function everyTick() {
    const players = world.getAllPlayers();
    for (const player of players) {
        const equipment = player.getComponent("equippable");
        const chestArmor = equipment?.getEquipment(EquipmentSlot.Chest);
        checkForArmor(player, chestArmor);
    }
}

system.runInterval(() => {
    everyTick()
}, 0)

got an error message
Property 'getEquipment' does not exist on type 'EntityComponent'.ts(2339)

any idea why this doesn't work?

wary edge
#

player.getComponent("equippable") as EntityEquippableComponent;

steady glade
gaunt salmonBOT
#

Description
A function to get player's clicks in a second

Credits
These scripts were written by Jayly

#

Description
This script checks whether a player has the hack "Nuker" enabled through the use of block break event.

Credits
These scripts were written by iBlqzed

crude bridge
#

using @minecraft-server-net module how can i check a packet size & packet name and then cancel it??

inland merlin
#

Packet id

#

They have a link

#

Ypu can see who is sending the packet and cancel it depending on the player

gaunt salmonBOT
#

Description
A simple to use command creator.
Parameters:

  • info (Object): An object containing the information about the command.
    • name (string): The name of the command.
    • description (string): The description of the command.
    • is_staff (boolean, default: false): Indicates if the command requires staff privileges.

Example usage

commandBuild.create(
    {
        name: 'getCommands',
        description: 'Get a list of all commands registered',
        is_staff: fa
```...
crude bridge
inland merlin
crude bridge
#

oh okay

celest abyss
#

I'm trying to replicate the red and green light system from the squid game, however, there seems to be a bit of a delay since even if the player stops, it still detects if they moved.

warm mason
celest abyss
warm mason
#

If so, you can try this

warm mason
#

Then just set a delay

distant tulip
warm mason
distant tulip
#

@celest abyss
even a 10 tick delay still capture a small velocity
so maybe check for bellow 0.01

inland merlin
#

Had anyone used server net http requests at all? Does it work on worlds/realms along side a server?

valid ice
#

It sure don't

inland merlin
#

Awh ok

valid ice
#

Solely works on BDS

inland merlin
#

Dang ok

#

Thx

empty light
marsh pebble
#

So my current plot system works on

*Remove player money
*Adds tag
*Deletes the command blocks```
But i'd also like to make an upgrade and make it to an addon so it whould have a better system
inland merlin
#

is block ticking component laggy? if too many in an area?

#

i use coordinates/locaiton of a block to link it to a database... so it wouldn't be compatible with a plot system

valid ice
inland merlin
valid ice
#

Block permutations/states would work for that

inland merlin
#

well i was hoping dynamic info

valid ice
#

Ah

#

Simple

inland merlin
#

the issue is, i've used entities in the past

valid ice
#

Ban pistons

inland merlin
#

lol

#

fair.... hmm

#

i guess the only way would be to move the location data to the pushed location

#

for pistons..

#

but

#

for plot ssystems that won't work... i would have to use some sorta sign

#

and store data onto a sign constantly

#

i wish we could save data like a sign

valid ice
#

If only piston before push event was a thing

#

Oh wait…

inland merlin
#

it.... was....

#

sadly

valid ice
inland merlin
#

yeah that would be legendary

#

thats just what i need lol

#

i use itemDynamicProperties to store data between picking up and placing down...

#

and sorta use the lore as well

#

i mostly use lore for stackable reasons...

valid ice
#

Yeah

inland merlin
#

works out pretty well

#

honestly

inland merlin
#

and thats when blockDynamicProperties would be amazing

#

i use the instant form refresh so you don't see the animation which is nice.

#

in resource

valid ice
#

Nice

inland merlin
# valid ice Nice

i've debated using without the inventory part, as its just unusable... but alot of other addons use the inventory still lol

#

so it would be more compatible keeping it

#

so idk, the compatibility thing is so annoying... but i guess it wouldn't matter for someone that knows json ui somewhat to subtract forms as needed

wary edge
#

Huh, does set fluid colour for water apply some sort of math transformation due to the tint?

.fluidColor = {alpha: 255,red: 255,green: 255,blue: 255}
Returns: {alpha: 1,red: 1,green: 1,blue: 0.00392...}

Resolved. See the OSS server: #879773489601585244 message

empty light
#
world.afterEvents.playerJoin.subscribe((eventData) => {
    const joiner = eventData.playerName
    system.runTimeout(() => {
        joiner.sendMessage(`§eWelcome, your rank is Default. Type :help for a list of commands.`);
    }, 10);
    }
)

i know what is wrong but im not sure the best way to go about fixing it. how should i get the entity of the player joining just off their name?

simple zodiac
#

use playerSpawn not playerJoin

empty light
simple zodiac
#

mostly

#

I'd say in a "good enough" state

valid ice
#

Probably just easier to acquire

inland merlin
#

yeah lol, i've decided to make my own beautiful design and they can suck it

thorn flicker
#

gotta love how the rideable component just breaks the game.

#

just trying to make it when an entity spawns in, another entity spawns and rides the entity, but it just breaks the server and crashes the game.

empty light
#

what do you guys think the laggiest particle is

#

im thinking like huge_explosion_emitter?

rapid sail
#

onStepOn but two entities has to be at the same location for it to function

inland merlin
#

its creepy, i asked o1 ai to fix a dynamic form for herobrines template... to remove the inventory part...

and it did it perfectly...

#

i love the new update that makes them dynamic

#

a while back

valid ice
distant gulch
#

😲

empty light
#

as an ai model maker, i vouch

inland merlin
inland merlin
marsh pebble
#

function getScore(player, objective) {
  try {
    const score = world.scoreboard.getObjective(objective)
    const scoreValue = score.getScore(player);
    return scoreValue
  } catch (error) {
    return 0;
  }
};

world.afterEvents.itemUse.subscribe(ev => {
  if (ev.itemStack.typeId === 'minecraft:clock') {
    shopMenu(ev.source)
  }
})

const shopData = [
  {
    title: "SHOP MENU",
    description: "Select the item you want to buy",
    insufficientFundsMessage: "You don't have enough money",
    purchaseSuccessMessage: "You purchased the item successfully",
    scoreboardObjective: "tuscore"
  }
];

const items = [
  {
    name: "Apple",
    itemId: "minecraft:apple",
    cost: 1,
    quantity: 13
  },
  {
    name: "Iron Ingot",
    itemId: "minecraft:iron_ingot",
    cost: 30,
    quantity: 10
  }
];

function shopMenu(player) {
  const menu = new ActionFormData();
  menu.title(shopData[0].title);
  menu.body(shopData[0].description);
  for (const item of items) {
    menu.button(`${item.quantity} ${item.name} for $${item.cost}`);
  }
  menu.show(player).then(r => {
    if (r.canceled) return;
    const selectedItem = items[r.selection];
    if (getScore(player, shopData[0].scoreboardObjective) >= selectedItem.cost) {
      const inventory = player.getComponent('minecraft:inventory').container;
      const itemStack = new ItemStack(selectedItem.itemId);
      itemStack.amount = selectedItem.quantity;
      inventory.addItem(itemStack);
      const score = world.scoreboard.getObjective(shopData[0].scoreboardObjective)
      score.setScore(player, getScore(player, shopData[0].scoreboardObjective) - selectedItem.cost);
      player.sendMessage(shopData[0].purchaseSuccessMessage + '\n§6-' + selectedItem.cost);
    } else {
      player.sendMessage(shopData[0].insufficientFundsMessage);
    }
  })
};```
#

Does this look

#

Weird?

crude bridge
crude bridge
#

Thx

#

Note that the inventory section of the form is simply for display, and does not reflect the actual player's inventory. Hopefully coming soon!

Soon when 😭

valid ice
inland merlin
pale terrace
#

how can I place an extended piston?

#

like pistons doesnt use states to extend

inland merlin
#

My mind finally can think! "Prototype"

#

Unrelated *

gaunt salmonBOT
#

Description
This script checks whether a player has the hack "Nuker" enabled through the use of block break event.

Credits
These scripts were written by iBlqzed

distant gulch
#

how can i get fishing hook owner?

green bison
#
system.runInterval(() => {
    for (const player of world.getPlayers()) {
      const inventory = player.getComponent('minecraft:inventory').container;
  
      inventory.addItem(
        inventory.getItem(0)?.typeId === 'minecraft:compass' 
          ? new ItemStack('air') 
          : new ItemStack('minecraft:compass', 1)
      );
    }
  });

Can I make this non stackable?

thorn flicker
#

but actually non-stackable, no.

green bison
inland merlin
turbid delta
#
itemStack.setLore(["§" + Date.now().toString().split("").join("§")]);
#

That way you don't need to loop through it every tick, more efficient

green bison
turbid delta
#

If Date.now is too long and the lore will make the ui too big when you hover over it you can use system.currentTick alternatively, granted multiple players will not get compasses in the same tick

#

Actually well Date.now() doesn't make a difference since this has to be ran in an after event anyways

gaunt salmonBOT
#

Description
A function to get player's clicks in a second

Credits
These scripts were written by Jayly

strong oar
#

How to fix this block in creative inventory looks weird in mobile phone. But in PC it's fine.

distant tulip
round bone
distant gulch
#

Is it possible to eliminate the event where the fish spawns from the fishing rod?

strong oar
#

It's weird but in my PC it's fine

inland merlin
distant gulch
inland merlin
#

It's an entity

#

It's hard coded, we can only remove the entity if it spawns.

#

You would spawn anything else you wanted and then teleport the new loot to the player

distant gulch
#

What do you mean by the spawned entity?

#

fish?

inland merlin
#

Yes the fish that comes from the loot when your fishing

distant gulch
#

u mean?

inland merlin
distant gulch
#

I just hope the fish doesn't come

inland merlin
#

Okay yes, then you use the entitySpawn event in scripts to remove the entity so you don't get fish anymore, you can define the entities you want removed because you can get the owner of the fishing hook etc.. by getting the entitySpawn info of the latest player to use the itemUse event.

Your tryn to replace the fish with a different item?

#

Or remove them all together

turbid delta
#

I think he wants to remove the event entirely

distant gulch
turbid delta
#

Try going to the loot table file and deleting every drop and see what happens

turbid delta
#

No.

inland merlin
#

Well, i don't think there is a cancel before event for entitySpawn. I would have to check .... you might be able to remove all the loot tho in the json loot table

turbid delta
inland merlin
#

There we go, dude in for the W

turbid delta
#

I feel like the event will still trigger it just doesn't give you anything 😂

inland merlin
#

Best method i would think

turbid delta
#

What is he even trying to do

inland merlin
#

But I like the idea of using that event to my advantage, so I could replace the loot with somethig else.

#

I have no idea

#

I assume change out the fishing style?

turbid delta
#

Didn't he ask how to link fishing hooks to the player that used it as well

inland merlin
#

Yep

turbid delta
#

You can do that with like 10 lines of code shrugging

inland merlin
#

Yep

turbid delta
#

You can also just edit the fishing_hook.json file and remove the minecraft:loot component if you want it to not drop anything

#

The fish bubbles still trigger no matter what but if you remove the loot its good enough I think

steady glade
#
world.afterEvents.itemUse.subscribe(({ source: player, itemStack }) => {
    const head = player.getHeadLocation();
    const viewVector = player.getViewDirection();

    if (itemStack.typeId === "minecraft:compass") {
        const ammo = "minecraft:snowball";
        const direction = { x: head.x + viewVector.x, y: head.y + viewVector.y, z: head.z + viewVector.z };
        const power = { x: viewVector.x * 1.25, y: viewVector.y * 1.25, z: viewVector.z * 1.25 };

        const entity = player.dimension.spawnEntity(ammo, direction);
        if (entity) {
            const projectileComp = entity.getComponent('minecraft:projectile') as any;
            if (projectileComp) {
                projectileComp.shoot(power, { owner: player });
            }
        }
    }
});

guys how to do rapid fire?
I made a compass to shoot snowball but it only shoot once, How to make it so it'll shoot as long as I use it

vital halo
#

Is there a way to run a script on an item when it’s created?

#

I’m trying to set a dynamic property once an item is made

dim tusk
# steady glade ```ts world.afterEvents.itemUse.subscribe(({ source: player, itemStack }) => { ...

@steady glade

import { world, system } from "@minecraft/server"; 

let use = {};
world.beforeEvents.itemUse.subscribe(({ itemStack, source }) => {
    if (source.typeId !== 'minecraft:player') return;

    if (itemStack.typeId === '<item>' && !use[source.id]) {
      use[source.id] = true;
      if (use[source.id]) {
         const head = source.getHeadLocation();
         const view = source.getViewDirection();
         system.run(() => {
            const bullet = source.dimension.spawnEntity('<projectile>', { x: head.x, y: head.y + 0.1, z: head.z });
            const proj = bullet?.getComponent('projectile');
            proj.owner = source;
            proj.shoot({ x: view.x * 5, y: view.y * 5, z: view.z * 5 });
         });
      }
   }
});

world.afterEvents.itemReleaseUse.subscribe(({ itemStack, source }) => {
    if (source.typeId !== 'minecraft:player') return;

    if (itemStack.typeId === '<item>' && use[source.id]) use[source.id] = false;
});
#

There are better ways but this is just as simple as possible....

#

you can try itemStartUse and itemStopUse

cold grove
dim tusk
#

tho you need to make your item eatables

cold grove
vital halo
#

Thank you!

cold grove
vital halo
#

Inventory will work best for what I am trying to do, but you’re right

#

Iterating over the inventory once every couple seconds isn’t that bad

#

I was hoping for something like beforeEvents.playerInventoryAdd

cold grove
#

Well you can use entitySpawn or entityLoad

#

For dropped items

dim tusk
vital halo
dim tusk
#

you can grab the name amount etc of the item as an entity.

empty light
#

https://obfuscator.io/#output

is this a solid tool to obfuscate scripts and make them harder for people to steal our code??

dim tusk
#

yes for a person who don't know how to de obfuscate that or understanding coding at all

#

And no since it can be easily reverted

crude bridge
#

There is a event for item break?

dim tusk
crude bridge
#

Whats The other way?

dim tusk
#

in playerBreakBlock, playerinteractwithBlock, and playerinteractwithEntity has two type of ItemStack, the before eit happens and after it happens

#

other than these event listeners yeah you definitely need to use runtInterval

#
world.afterEvents.playerBreakBlock.subscribe(({ itemStackBeforeBreak, itemStackAfterBreak }) => {
   //...
});

world.beforeEvents.playerInteractWithBlock.subscribe(({ beforeItemStack, itemStack }) => {
   //...
});


world.beforeEvents.playerInteractWithEntity.subscribe(({ beforeItemStack, itemStack }) => {
   //...
});```
#

here.

#

if you're gonna ask about itemUse, nope you can't use the beforeEvents built-in ItemStack since there's bug idk if I can say bug that the amount, name everything that includes durab or enchantments, matches the afterEvents ItemStack.

#

Tho I'm not sure maybe it depends on the item but you need to use equippable or anything that can grab an ItemStack in the beforeEvents and compare to the afterEvents

dim tusk
crude bridge
#

Thx

empty light
#

I have been working on a project i am passionate about, and have had my projects stolen, put on youtube gaining hundreds of thousands of views and im scared for it to happen again HAHHA

dim tusk
#

Or some sort idk..
-# never released an addon in my life (scared to be insulted)

distant tulip
#

nope
my addon got stolen too, if it wasn't for deobfuscator tools i would have never known
when he released the addon i offered help sense i got experience in that kinda of addon, but later i used a deobfuscator and found his whole code based on mine
i lost motivation in that project and ended up discontinuing it
you only have 3 options, marketplace, open sourcing your addon, release it under copyright and hope for the best

dim tusk
#

as what Minato said, Marketplace, Open Sourcing or just Copyright it

distant tulip
#

didn't even share the part that hurt the most, lol

inland merlin
dim tusk
inland merlin
#

But we use minify and obfuscate

#

It's not fool proof

#

For sure haha

dim tusk
#

tbh using others code isn't bad it's learning but without consent? Yeah different story

#

It also depends on the situation you can't just judge them

inland merlin
#

Exactly, the people who resell is the sore thumb

dim tusk
#

that's out of line

inland merlin
#

Huh?

dim tusk
inland merlin
#

Oh lmao

dim tusk
#

i remembered that you can't sell add-ons

#

Unless marketplace

inland merlin
#

Yeah haha, the eula, but the only way around that is probably subscription based stuff

#

So it's just player content. Not specifically addons

#

But obviously under the table sales all the time

dim tusk
#

That's a long typing man.

distant tulip
# dim tusk What is it?

i sent a dm to a big youtuber asking for review and got ignored, after a long time i got a notification of a video about the stolen one from the same youtuber

dim tusk
#

Bro just yoinked it.

distant tulip
#

yes way, lol

dim tusk
#

without even saying a single word?? 😭

distant tulip
#

yeah

inland merlin
#

What addon was it

dim tusk
#

Bro literally said "You shared it? Thank you then imma own this then" 😭🤯

inland merlin
#

Yeah, I do love sharing free addons, but stuff like that is stupid.. can't even police it

dim tusk
#

Imagine stealing an addon and calling the police...

inland merlin
#

Lmao

dim tusk
#

"hello 911, this guy stole my add-on can you arrest him?"

inland merlin
#

I haven't ever done a wsserver? Is it possible to send a verification thing through that

dim tusk
#

That's why sometimes I don't accept being a tester and let someone become a tester.

distant tulip
#

i cringe every time i see this now lol

dim tusk
#

unless it's on a server.

inland merlin
#

Nooo not that one!

inland merlin
#

Only server

dim tusk
#

YESS. I REMEMBER THAT.

inland merlin
#

I was able to test it in early stage and it was awesome

dim tusk
#

I see that thumbnail EVERYWHERE

inland merlin
#

Not sure what else has been added

dim tusk
#

like that thumbnail has been used by different people too

inland merlin
#

Would it make sense to throw my name into most of the code? The issue, ai csn easily remove it lol

#

But then again, they can still steal the addon without any changes

dim tusk
inland merlin
#

Yeah

dim tusk
#

That's why the best case, just open source it

inland merlin
#

True

dim tusk
#

The name "Prowl" is familiar

distant tulip
dim tusk
#

i ain't opening it.
-# i only have 500mb of data left. Lmfao

distant tulip
inland merlin
dim tusk
#

and afaik you even said you used a lot of dynamic property

#

EVERY TICK

distant tulip
#

that part is not in the released addon
hence the stolen one don't have it too lol

dim tusk
#

Lesson learned, don't do testers without making it open source

distant tulip
dim tusk
#

also you're safe if you use open source since it has history when you edited it and what you edited/added

#

Especially if GitHub
-# tho I rarely use GitHub now.

hushed ravine
dim tusk
hushed ravine
distant tulip
#

learn any thing from it -> yoink any thing from it

hushed ravine
distant tulip
#

nvm

dim tusk
#

Wait nvm, I think I started js in 1.20.30?

#

i forgor

hushed ravine
distant tulip
#

blocks are performance expensive
use particles

dim tusk
#

1 big ass particle

#

it has long range and doesn't do TPS drop (in my case)

#

HEY @inland merlin 😏

inland merlin
#

I see stolen addons all the time (or at least scripts) lol open it up see to a bunch of another persons name in it

hushed ravine
distant tulip
inland merlin
inland merlin
#

To share for particle walls

distant tulip
inland merlin
#

Lmao

hushed ravine
inland merlin
#

Eh fine ill post the resource today later

#

For particle walls, it will greatly improve border addons

#

Like world borders etc

#

Or anything really

distant tulip
#

noice

inland merlin
#

I ended up using the same files to post a animae smaller

#

One sec

dim tusk
#

Yeah, in all seriousness I kind made it better. I literally spend 20 minutes just to properly align 4 particle as a 16x16 chunk area

distant tulip
#

use math

dim tusk
#

then I made some small calculation that just make the particle stretch based on the size of the selected area

dim tusk
inland merlin
#

Examples... I changed color according to @dim tusk idea of white, but image is old

dim tusk
inland merlin
#

OPM lol

#

500x500 wall

#

No lagg, just need logic to stop players from passing etc..

distant tulip
#

pirating manga in minecraft

dim tusk
inland merlin
#

I did animated before but desyncs

#

So can't do that for walls

dim tusk
#

Hahaha, I will make a manga book in Minecraft using server form

inland merlin
#

I was tryn to recreate that Java edition skyblock wall

dim tusk
#

Thanks Minato 😀

inland merlin
#

Give people seizures

inland merlin
#

Had to match uv for scale

distant tulip
#

dakonblackrose did make a manga bookshelf

dim tusk
#

Thank you sensei

inland merlin
dim tusk
#

and this making every crafting table have manga of genshin impact

#

LMFAO

distant tulip
#

it was a book

dim tusk
distant tulip
#

i do remember it
can't find it tho

inland merlin
#

Makes it feel instant

#

Or want it feel like it's changing

dim tusk
#

It's easy to do that.
-# coming from a person who is only 2% in json ui

inland merlin
#

Yeah i do all the time

distant tulip
#

uhm...

dim tusk
#

that's easy.

#

remember Minato Multi form?

distant tulip
#

so a book ui template?

inland merlin
#

So idea time, and I'm good if yall steal it.. as it might lagg anyways lol

#

Herobrines chestformdata, instant transitions + Crates addon

#

Of course there is better uis out there, but I'm learning json ui lmao

dim tusk
dim tusk
inland merlin
#

But

#

If i constantly close form, and open

#

How much lagg lol

#

Feel like a form refresh

dim tusk
#

I tried a lot of high quality image and never had an issue rn

inland merlin
dim tusk
#

Ngl, unimportant but I like the wasd jump sneak and my time in my actionbar

inland merlin
#

Not the same form that's open, but like actual refresh

#

You doing the same form?

#

Reopens the form and closes it.

#

I have yet to test, but will this week

dim tusk
#

Especially if you have low ping in the server if that's the case

distant tulip
#

it will blink no matter what
unless it is the same form

inland merlin
#

But maybe if lagg is introduced

#

It will

distant tulip
#

which one

dim tusk
#

He modified the animations and you can move a split second if you clicked buttons

dim tusk
distant tulip
# distant tulip i do remember it can't find it tho

How To Make Readable Bookshelf In Minecraft Bedrock Edition tutorial in mcpe or bedrock edition or xbox one and ps5. Minecraft Hey guys it's dakonblackrose here and in this Minecraft video i'm showing a addon that makes book shelf more cool for minecraft in the new B.T.U !! Minecraft Bedrock MCPE ( Pocket Edition ) XBOX One / Java / Windows 10 /...

▶ Play video
inland merlin
#

Fair, I do like your version best, but for constant information updating...you would have to reopen it right

#

For me

#

I am gonna create some sorta stock market addon

dim tusk
dim tusk
#

That shit is funny and amazing to me since I don't do json ui... Till this now but meh

inland merlin
#

Haha, same.

#

I know a very small amount of json ui, just some logic to modify

#

Like compatible

dim tusk
#

I mean I do but in a sense that experienced or know at least? I doubt Soo lmao

inland merlin
#

Anyways haha

#

Do yall like economy based crap?

dim tusk
dim tusk
inland merlin
#

Lol I actually said crap

distant tulip
#

lol

inland merlin
#

Stock market (mine, or crop economy)

#

Just crap

distant tulip
#

it depend on the addon/content

dim tusk
inland merlin
#

Yeah, I have been wanting to find time for it

dim tusk
#

Someone lend me free load pls 😭🙏

junior hill
#

const maxSpin = 15;

function rotateBlock(block) {

    const currentState = block.permutation.getState("JCTbuild:spin");
    let spinValue = currentState || 1;


    let newSpin = (spinValue % maxSpin) + 1;


    const newPermutation = block.permutation.withState("JCTbuild:spin", newSpin);

    block.setPermutation(newPermutation);
}

world.beforeEvents.itemUseOn.subscribe((event) => {
    const { source: player, block } = event;
    const mainhand = player.getComponent("equippable").getEquipment(EquipmentSlot.Mainhand);

    if (player.isSneaking && mainhand?.typeId === "minecraft:wooden_sword") {
        system.run(() => rotateBlock(block));
    } else {
        console.log("Rip.");
    }
});```
Could someone tell me why this script is not rotating this block
dim tusk
junior hill
#
    at <anonymous> (test.js)``` error here
dim tusk
junior hill
distant tulip
dim tusk
junior hill
#

i swear to god this worked but i forgot back it up

#

and remade it

#

doesnt work

dim tusk
#

send your Block json?

#

not sure but I feel like uppercase namespace on states won't work

#

Unless I'm wrong.

junior hill
dim tusk
#

BRUH

#

That's not how you add state to the block

junior hill
#

o

#

yeah after going dormat from coding

#

to this

#

i forgot a lot of stuff

dim tusk
# junior hill o
"description": {
   "identifier": "...."
   //...

   "states": {
      "<name>" {
         //...
      }
   }
}```
#

Just check the docs for more confirmation

junior hill
#
  "format_version": "1.21.40",
  "minecraft:block": {
    "description": {
      "identifier": "wiki:custom_block",
      "states": {
        "wiki:string_state_example": ["red", "green", "blue"],
        "wiki:boolean_state_example": [false, true],
        "wiki:integer_state_example": [1, 2, 3],
        "wiki:integer_range_state_example": {
          "values": { "min": 0, "max": 5 } // The same as [0, 1, 2, 3, 4, 5]
        }
      }
    },
    "components": { ... },
    "permutations": [ ... ]
  }
}```
#

this was the doc said

dim tusk
#

Then use that for reference

#

you have a copy of docs 😭🙏

junior hill
#

"wiki:integer_range_state_example": {
"values": { "min": 0, "max": 5 } // The same as [0, 1, 2, 3, 4, 5]

#

this

#

is what i copied

dim tusk
junior hill
#

fuck me

#

i overlooked that

#

lmao

#

thanks

dim tusk
#
"description": {
            "identifier": "JCTbuild:acaciatriangle",
            "menu_category": {
                "category": "construction",
                "group": "itemGroup.name.concrete"
            },
            "JCTbuild:spin": {
                "values": {
                    "min": 0,
                    "max": 15
                }
            }```
#

look LMFAO

junior hill
#

i have 3k files

#

with wrong code

#

time to use vscode to mase replace

distant tulip
#

3k line or file? 💀

dim tusk
#

ahh. Simply mistakes

junior hill
#

files

distant tulip
dim tusk
#

another day another person I helped

#

But what fuck, what's inside of 3k files

distant tulip
#

one file for each line

junior hill
#

one block .json

#

3k of them

#

the mega constuction pack

#

3k varients of blocks to build with

#

and a wand to rotate them

distant tulip
#

you are not hitting the permutation limit?

junior hill
#
            "identifier": "JCTbuild:acaciatriangle",
            "menu_category": {
                "category": "construction",
                "group": "itemGroup.name.concrete"
            },
            "states": {
                "JCTbuild:spin": {
                    "values": {
                        "min": 0,
                        "max": 15
                    }
                }
            }
        },```
#

is this right?

junior hill
#

one permution namespace

#

and 0-15 ways to roatate

crude bridge
#

ive found an addon that u cant see all the files

#

u can see them only on game files

#

and still they are obfuscated

distant tulip
#

i mean even marketplace addons are not save from that
obfuscated or whatever

crude bridge
distant tulip
#

fr lol
private use addons are the safest

crude bridge
#

lol

dim tusk
#

I can confidently say that Minato, Serty and I are a trio. Imagine the hyra dragon meme. Minato the Intelligent, Serty the serious one and me. Just stupid

distant tulip
#

lol, how is that related

junior hill
#

is there a way to make it run slower?

#

isnt it like tick or something for the script

dim tusk
dim tusk
#

it's a range

#

In ticks

empty light
#

im so sorry that happened to you

#

i had made a world edit for bedrock quite a long time ago, that a respected bedrock content creator i was friends with, took my code and got about 800k views on it last I checked

#

it crushed me and i have barely shared my code since

#

i now have this new project and im terrified for it to be taken from me

true isle
#

is their any way to replicate a slime blocks bounce?

empty light
#

ill probably use ai to destroy variable names and add tons of unnecessary code, then obfuscate it, to at least deter or slow down

dim tusk
true isle
#

i mean it is part of a scripting laguange thats public so

empty light
#

still shitty you can put so much time and effort into something, and have it ripped and you discredited

#

ill probably try to put it on my channel first, let it grow then share

true isle
#

thats what id do

wary edge
#

Unfortunately the average Minecraft experience.

true isle
#

or write code so horribly that they wont use it lol

#

mines a mess

wary edge
#

I like sharing my creations, mostly scripting libraries. I can't recall the last time I released an add-on that wasn't open sourced.

true isle
#

meh i dont expect to get rich so idc if it gets ripped or not

#

if i know i did it i can atleast feel acomplished

#

and ik for a fact theres alot of code most creators use as a base for their scripts anyways. like destructuring scripts to make them readable i know alot do that and its basicly all the same just

#

formatted for their addon

dim tusk
true isle
#

lol

wary edge
#

I hate destructuring events.

distant tulip
true isle
#

for me its easier to read super adhd most of the advanced shit its like trying to read chinese if you speak english

dim tusk
distant tulip
#

totally didn't waste my time designing that

dim tusk
#

Just for a single image?

#

My god this guy's Patience is insane

#

Damn, I need to find a way to convert bindings to variables or make the binding readable to variables ughh

true isle
#

you dont know patience untill ur 3 yr old is putting shoes on

dim tusk
#

Bro can't even talk

wary edge
true isle
#

its like watching a tree grow

true isle
#

yep

#

mines put hers on upside down

#

i dont even know how she manged tha

#

my oldest mistook her fuzy sweater as a skirt once

dim tusk
vital halo
inland merlin
#

I don't care if someone wants to sell their own addon, that's fine even if it's against the eula, it's the reselling of someone else's work

#

Claiming it as their own

#

Is also a crime

#

Even if free

distant tulip
#

i read that wrong the first time lol
"I stolen addons all the time ..."
i was like "huh! ok...?"

distant tulip
#

that doesn’t sound like you
sorry for misunderstanding that, lol

vital halo
junior hill
#
    const { source: player, block } = event;
    const mainhand = player.getComponent("equippable").getEquipment(EquipmentSlot.Mainhand);

    if (player.isSneaking && mainhand?.typeId === "JCTbuild:wrench") {
        system.run(() => rotateBlock(block));
    } else {
        console.log("Rip.");
    }
});``` Could someone help me with this
#

the wrench wont work

#

but if i use a vannilla item

#

it works

wary edge
junior hill
# wary edge Does your item have a use modifiers componentM
  "format_version": "1.21.10",
  "minecraft:item": {
    "description": {
      "identifier": "JCTbuild:hammer",
      "menu_category": {
        "category": "equipment"
      }
    },
    "components": {
      "minecraft:use_modifiers": {
                "use_duration": 99999,
                "movement_modifier": 1
            },
            "minecraft:can_destroy_in_creative": false,
            "minecraft:food": {
                "can_always_eat": true,
                "nutrition": 0
            },
      "minecraft:hand_equipped": true,
      "minecraft:display_name": {
                "value": "Hammer"
            },
      "minecraft:max_stack_size": 1,
      "minecraft:allow_off_hand": true,
      "minecraft:icon": "jcthammer"
    }
  }
}```
#

yes

wary edge
#

Also avoid capital letters in your identifiers.

junior hill
#

i changed it to hammer alr

#

lmao

#

ok

meager zenith
#

Idk where to ask this but does anyone know how to setup the minecraft debugger vsc extension, if yes can you help me set it up please i have tried it is not working for me

meager zenith
wary edge
#

Yeah.

meager zenith
# wary edge Yeah.
  "version": "0.3.0",
  "configurations": [
    {
      "type": "minecraft-js",
      "request": "attach",
      "name": "Debug with Minecraft",
      "mode": "connect",
      "preLaunchTask": "build",
      "targetModuleUuid": "d1c183fe-0c37-11ec-82a8-0242ac130003",
      "localRoot": "${Origins 1.4.2 BP}/scripts",
      "port": 19144
   }
  ] 
}
```, this is what it looks like, i have changed the `targetModuleUuid` to the script uuid and `localRoot` to the addon folder and port
#

idk what's wrong

meager zenith
celest abyss
#

How can I make the player.nameTag not be removed when I exit the game?

knotty plaza
celest abyss
knotty plaza
#

And then get that property again on the playerSpawn event

celest abyss
#

Ty

turbid delta
#

make a script to find all obsidian blocks and then place a block ontop of it

vestal spruce
unique acorn
distant tulip
#

bao_icon_entities i seen that

jolly veldt
#

Is it just me or did a message disappear

distant tulip
#

yeah, i was trying to understand his problem and the messages gone

celest abyss
green bison
#

Anyone know of a Mining addon that generates random mines and rests them? For prison mines, kinda like mines+ when Aex released it

untold magnet
#

eh, can someone explain to me how the randomTick component works?

untold magnet
wary edge
#

It will randomly tick. As the name implies. Via the chunk's random tick system.

untold magnet
#

oh i see,

hushed ravine
# inland merlin

I wonder why one would want to show manga in Minecraft, but whatever lmao

vital halo
#

How do I make language-specific text appear in a script?

#

Like, access a string in en-US.lang through javascript

valid ice
#

You can't, sadly.
Best you can get is raw text translates, which is supported in a few places (forms, send messages, etc)

wise raft
#

How can I get the max possible state from a block?

weak swallow
#

or you can make a custom launguage setting

glacial widget
#

anyone know a vps that i can buy, first time trying to use one

neat hound
drowsy scaffold
sharp elbow
#

On all obsidian blocks in how big of an area? Everywhere? At the same time?

#

Because to know if a diamond block exists somewhere, the volume needs to be scanned for those diamond blocks. If the volume is the entire loaded, known world, that would take a very long time to execute.

deep yew
#

So I am going to save every player's island in my skyblock with structures, but the starting size is 50x192x50, from y-64 to y128 and it takes up a little over 3MB each. Is there any other way to save space other than just the size of the structure?

#

(was a script api question because I am using script api to save and load the islands)

green bison
#

How can you test for blocks in a box volume? Like for example
TOP (x = 100, y = 64, z = 120)
BOTTOM (x = 100, y = 40, z = 140)
if all blocks have been destroyed in that box area

Tried looking through documentation but just don't know what to use

neat hound
sleek nexus
#

Anyone had issues with item dynamic properties not being persistent upon world reload?

#

Is this intended behavior?

#

I'll update my game to the latest stable version and try again

#

yesss it's fixed in the current version

I spoke too soon. Testing some things now...

It seems to happen at random on world reload. Not all reloads, but some

green bison
neat hound
sleek nexus
# sleek nexus Anyone had issues with item dynamic properties not being persistent upon world r...

Okay following up on this:

I setup a system where a redstone lamp would turn off only if an item didn't have an expected property. I then restarted my game a couple times, and the lamp was off.
I even kept a copy of this item inside a DATA+ chest inside another chest placed in the world. This "hidden" item also lost its property.
Other items with dynamic properties also lost their properties. It seems like rarely, every single item in the world can lose its dynamic properties.

I am trying to find a way to reproduce this bug purposely, but am yet to find anything. If anyone has experienced this too, please let me know.

sleek nexus
#

...
I believe I have found the issue. Changing the manifest script module uuid breaks item dynamic properties.

#

In the base code it must be that item dps are directly associated with the module uuid. So if the uuid changes, the properties don't exist on the item. Which I guess prevents addons from accidentally overriding other addons item dps

distant tulip
#

also, i believe if you returned the original uuid the properties will be there

sleek nexus
#

I was using regolith and an old version of the gametests filter, where it randomized the uuid on every script change lolll

#

that's why I was so confused and lost

#

I thought I was running into the world's strangest bug

distant tulip
#

yeah, i was concerned when reading your messages

#

i used that everywhere

dim tusk
#

I'm back from sober.

distant tulip
#

what dose that mean bao_foxxo_smug
you are drunk now?

dim tusk
distant tulip
#

oh, i was wandering about that

weak swallow
dim tusk
#

Yes I use prepaid

#

I'm poor asf

distant tulip
dim tusk
#

my prepaid only lasted 7 days and I paid 99 PH pesos

distant tulip
#

i mean there is movable wifi that work without adsl

dim tusk
distant tulip
dim tusk
#

And I'm not studying oof

misty pivot
#

how do i convert the degrees of getRotation into a vector 3? similar to getViewDirection but for the body

weak swallow
#

then you should know

#

which side is x, z, y

#

y is ez rot.x / 90

#

but for x,z you should test

slow walrus
# misty pivot how do i convert the degrees of `getRotation` into a vector 3? similar to `getVi...
x = cos(yaw)*cos(pitch)
y = sin(yaw)*cos(pitch)
z = sin(pitch)

https://stackoverflow.com/questions/1568568/how-to-convert-euler-angles-to-directional-vector

weak swallow
#

idk minecraft follows that rule

misty pivot
#

ah i see thank you, altho is there roll axis?

slow walrus
#

no

#

roll would be like spinning the player's view around

#

clockwise

#

or whatever

#

pretty sure x is pitch and y is yaw

#

could be the other way around though

misty pivot
#

alright, thanks again

chilly fractal
#

Xml is weird fr

remote oyster
wise raft
chilly fractal
meager cargo
#

Can someone help me with that script of detecting if player is on specified block and if so and he has tag, it will teleport him to the closest entity

system.runInterval(() => {
    const players = world.getPlayers();

    for (const player of players) {
        const blockUnder = player.dimension.getBlock(player.location);
        if (!blockUnder) continue;

        const blockBelow = blockUnder.below(1);
        if (!blockBelow) continue;

        if (blockBelow.typeId === "minecraft:lime_stained_glass") {
            const testEntities = Array.from(
                player.dimension.getEntities({
                    type: "test:test",
                    location: player.location,
                    maxDistance: 150,
                })
            ).filter((entity) => entity.location);

            if (testEntities .length > 0) {
                const closestEntity = testEntities .reduce((closest, current) => {
                    const currentDistance = current.location.distanceTo(player.location);
                    const closestDistance = closest.location.distanceTo(player.location);
                    return currentDistance < closestDistance ? current : closest;
                });

                const targetLocation = closestEntity .location;
                player.teleport(targetLocation, { facing: player.location });
            }
        }
    }
}, 1);
dim tusk
#

umm does distanceTo function exist? I mena in scripting API rn. I don't think so right?

meager cargo
#

Yeah... but, it is working in the other my script. Where I detect tag on entity. And there is no error, so it should work either way

#

Here is the working code:

system.runInterval(() => {
    const players = world.getPlayers();

    if (players) {
        for (let player of players) {
            const blockUnder = player.dimension.getBlock(player.location);
            if (!blockUnder) continue;
            const blockBelow = blockUnder.below(1);
            if (!blockBelow) continue;
            if (
                blockBelow.typeId === "minecraft:lime_stained_glass" &&
                player.hasTag("parkour_morph")
            ) {
                const teleportPointEntities = player.dimension.getEntities({
                    tags: ["teleport_point"],
                    location: player.location,
                    maxDistance: 150,
                });
                if (teleportPointEntities.length > 0) {
                    const teleportPoint = teleportPointEntities.reduce(
                        (farthest, current) => {
                            const currentDistance = current.location.distanceTo(
                                player.location
                            );
                            const farthestDistance = farthest.location.distanceTo(
                                player.location
                            );
                            return currentDistance > farthestDistance ? current : farthest;
                        }
                    );

                    const targetLocation = teleportPoint.location;
                    player.teleport(targetLocation, { facing: player.location });
                }
            }
        }
    }
}, 1);
bright dove
#

how do you get the identifier of a block ?

#

typeId ?

warm mason
twilit tartan
#

can someone help me pls?

unique acorn
#

how to detect if an entity is visible on the player's screen?

distant tulip
#

@unique acorn

warm mason
distant tulip
#

edit
if (angle >= -45 && angle <= 45)
for changing the fov

distant tulip
unique acorn
#

alright I'll check that out

distant tulip
twilit tartan
bright dove
#

function loadStructure( blockLocation) {
    const block = world.getBlock(block.location);
    if (block) {
        const treeTypeId = block.typeId ;  
        // Construct the command string
        const command = `structure load ${treeTypeId} ${block.location.x} ${block.location.y} ${block.location.z}`;
        entity.runCommand(command);
    }
}```
#

what is wrong about this ?

twilit tartan
warm mason
warm mason
bright dove
#

thanks thanks

vital halo
#

How do I make an arrow piercing?

wraith basin
#

im trying to make a script that whenever a tnt explodes, ( or on fact any entity ) it spawns it again, multiplied so like 1 2 4 8 16 .......

#

i just cant figute it owt

#

can anyone help

vital halo
warm mason
wraith basin
chilly fractal
#

Muhaha

#

I will help you

#

But actually tho

#

Serty is probably cookin' 🔥

#

So ima let him cook

warm mason
# wraith basin ik i just want to see it
world.beforeEvents.explosion.subscribe(data => {
  if (data.source) {
    let loc = data.source.location
    system.run(() => {
      for (let i = 0; i < 2; i++) {
        data.dimension.spawnEntity(data.source.typeId, loc)
      }
    })
  }
})
chilly fractal
#

Yessirrr

thorn flicker
warm mason
chilly fractal
#

Server will become a pipebomb in exactly 1 explosion, order 1 mc explosion and get 1 free real life explosion! (Completely for free)

chilly fractal
wraith basin
#

:fire;

#

🔥

thorn flicker
warm mason
wraith basin
#

it only spawns it once

#

i mean it does it every time

warm mason
wraith basin
#

but it doesnt multiply

#

oh

#

yeah i noticed the for loop just now

#

mb

celest abyss
#

Is it possible to add a value to a variable? For example, every time a player hits a certain entity, a number is added to the value.

hazy nebula
#

there anyway to make a mob attack any mob?

celest abyss
#

let hit = + 1;

Or something like that?

steady canopy
wary edge
celest abyss
dull shell
#
  world.beforeEvents.entityInteract(data => {
    let player = data.source; 
    if (entity.typeID === "jay:wheat_minion") { 
        system.run(() => main(player)); 
    }

    function main() {
        const form = new ActionFormData()
            .title(title)
            .button(`§c§lClaim Wheat\n§7+0`, "textures/items/wheat")
            .button(`§0§lClose`, "textures/blocks/barrier")
            form.show(player).then(r => {
              if (r.selection == 0) weapons(player)
              if (r.selection == 1) utility(player)
          })}})```
lone thistle
warm mason
dim tusk
#

also it's target if you're wondering

dull shell
#

okay I changed it up but now its just not opening the UI, I dont have any errors in my log

#
import { system, world } from "@minecraft/server"
import { ActionFormData, ModalFormData } from "@minecraft/server-ui";

  system.runInterval(()=>{
    let property = "jay:wheat_minion"
    for (let entity of world.getDimension("overworld").getEntities()) {
      if (entity.typeId === "jay:wheat_minion") {
          let dynamicProperty = entity.getDynamicProperty(property);
          if (dynamicProperty === undefined) {
              entity.setDynamicProperty(property, 60)
          } else 
          if (dynamicProperty > 0) {
              entity.setDynamicProperty(property, dynamicProperty - 1);
          } else 
          if (dynamicProperty <= 0) {
            entity.setDynamicProperty(property, 60);
            entity.runCommandAsync("execute @s ~~~ playanimation @s animation.wheat_minion.finish");
            entity.runCommandAsync("execute @s ~~~ say Produced Wheat");
            entity.runCommandAsync("execute @s ~~~ particle minecraft:totem_particle");
            
          }
  
          entity.nameTag = `§6Wheat Minion\n§7[ §fProduces in: §c${entity.getDynamicProperty(property)}§fs §7]`
      }
    }
  }, 20)

  world.beforeEvents.playerInteractWithEntity.subscribe(data => {
    let entity = "jay:wheat_minion"
    let player = data.source; 
    if (entity.typeID === "jay:wheat_minion") { 
        system.run(() => main(player)); 
    }

    function main() {
        const form = new ActionFormData()
            .title(title)
            .button(`§c§lClaim Wheat\n§7+0`, "textures/items/wheat")
            .button(`§0§lClose`, "textures/blocks/barrier")
            form.show(player).then(r => {
              if (r.selection == 0) { main(player)
                player.runCommandAsync("say claim wheat");
              }
            })
          }
        })```
dim tusk
#

ohh my god

dull shell
#

what 😭

#

it cant be that bad

dim tusk
# dull shell what 😭
world.beforeEvents.playerInteractWithEntity.subscribe(ev => {
   const { target, player, itemStack } = ev;
   if (target.typeId === '<if>') {
      system.run(() => main(player) );
   }
});```
dim tusk
distant tulip
#

sendMessage exists btw

#

playAnimation exists btw

dull shell
#

i just have it like that so ik its working guys

dull shell
#
  world.beforeEvents.playerInteractWithEntity.subscribe(ev => {
    const { target, player, itemStack } = ev;
    if (target.typeId === 'jay:wheat_minion') {
       system.run(() => main(player) );
    }
 })

    function main() {
 //line 35       const form = new ActionFormData()
            .title(title)
            .button(`§c§lClaim Wheat\n§7+0`, "textures/items/wheat")
            .button(`§0§lClose`, "textures/blocks/barrier")
            form.show(player).then(r => {
              if (r.selection == 0) { main(player)
                player.runCommandAsync("say claim wheat");
              }
            })
          }```
#

wait i think thats my fault on my end

#

nvm im not to sure

dim tusk
# dull shell
import { system, world } from "@minecraft/server"
import { ActionFormData, ModalFormData } from "@minecraft/server-ui";

system.runInterval(() => {
  const property = "jay:wheat_minion";
  for (const entity of world.getDimension("overworld").getEntities()) {
    if (entity.typeId === "jay:wheat_minion") {
      let dynamicProperty = entity.getDynamicProperty(property);

      if (dynamicProperty === undefined) entity.setDynamicProperty(property, 60);

      else if (dynamicProperty > 0) entity.setDynamicProperty(property, dynamicProperty - 1);

      else if (dynamicProperty <= 0) {
        entity.setDynamicProperty(property, 60);
 entity.playAnimation("animation.wheat_minion.finish");
        entity.runCommand("say Produced Wheat");
        entity.dimension.spawnParticle("minecraft:totem_particle", entity.location);
      }

      entity.nameTag = `§6Wheat Minion\n§7[ §fProduces in: §c${entity.getDynamicProperty(property)}§fs §7]`;
    }
  }
}, 20);

world.beforeEvents.playerInteractWithEntity.subscribe(data => {
  const { target, player } = data;
  if (target.typeId === "jay:wheat_minion") { 
    system.run(() => main(player)); 
  }

  function main(player) {
    const form = new ActionFormData()
      .title("Wheat Minion")
      .button(`§c§lClaim Wheat\n§7+0`, "textures/items/wheat")
      .button(`§0§lClose`, "textures/blocks/barrier");
      
    form.show(player).then(r => {
      if (r.selection === 0) {
        player.sendMessage("say claim wheat");
        main(player);
      }
    });
  }
});```
dim tusk
distant tulip
dull shell
distant tulip
#

not always

dull shell
#

wdym

gaunt salmonBOT
# dim tusk ```js import { system, world } from "@minecraft/server" import { ActionFormData,...

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 4 errors:

<REPL0>.js:10:16 - error TS2365: Operator '>' cannot be applied to types 'string | number | boolean | Vector3' and 'number'.

10       else if (dynamicProperty > 0) entity.setDynamicProperty(property, dynamicProperty - 1);
                  ~~~~~~~~~~~~~~~~~~~

``````ansi
<REPL0>.js:10:73 - error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.

10       else if (dynamicProperty > 0) entity.setDynamicProperty(property, dynamicProperty - 1);
                                                                           ~~~~~~~~~~~~~~~

``````ansi
<REPL0>.js:11:16 - error TS2365: Operator '<=' cannot be applied to types 'string | number | boolean | Vector3' and 'number'.

11       else if (dynamicProperty <= 0) {
                  ~~~~~~~~~~~~~~~~~~~~

``````ansi
<REPL0>.js:14:16 - error TS2339: Property 'sendMessage' does not exist on type 'Entity'.

14         entity.sendMessage("Produced Wheat");
                  ~~~~~~~~~~~

Lint Result

ESLint results:

<REPL0>.js

2:26 error 'ModalFormData' is defined but never used @typescript-eslint/no-unused-vars

37:9 warning The /say command can be fully replaced with the World.sendMessage api in the @minecraft/server module. See https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/world#sendmessage for more information. minecraft-linting/avoid-unnecessary-command

dim tusk
#

God, don't use the debugger here 😭

dim tusk
#

Ooh, didn't remembered Send message don't work on entities lmfao

dim tusk
warm mason
slow walrus
#

wdym

dull shell
slow walrus
#

the debugger is right about everything there

distant tulip
#

love ts errors

#

nvm there is none related to ts there

dim tusk
#

Yeah.

#

I just copied pasted.

#

Wait lmfao

dull shell
#

okay so I threw in my getScore, from my other script but I get a error.

const getScore = (participant, objective) => {
  try {
      return world.scoreboard.getObjective(objective).getScore(participant) ?? 0;
  } catch {};
  return 0;
};
function metricNumbers(value) {
  const types = ["", "k", "M", "B", "T", "P", "E", "Z", "Y"];
  const exponent = Math.floor(Math.log10(value));
  const selectType = Math.min(Math.floor(exponent / 3), types.length - 1);
  
  return value < 1000 ? value.toString() : `${(value / Math.pow(10, selectType * 3)).toFixed(1)}${types[selectType]}`;
};

world.beforeEvents.playerInteractWithEntity.subscribe(data => {
  const { target, player } = data;
  if (target.typeId === "jay:wheat_minion") { 
    system.run(() => main(player)); 
  }
celest abyss
#

It is possible to remove messages when someone makes an emote?

dim tusk
dim tusk
#

Yeah buddy, I always feel them from my friends.

dull shell
distant tulip
gaunt salmonBOT
# dull shell okay so I threw in my getScore, from my other script but I get a error. ```js co...

Debug result for [code](#1067535608660107284 message)

Compiler Result

Compiler found 2 errors:

<REPL0>.js:18:22 - error TS2304: Cannot find name 'main'.

18     system.run(() => main(player));
                        ~~~~

``````ansi
<REPL0>.js:20:1 - error TS1005: '}' expected.

20 
   

  <REPL0>.js:15:63
    15 world.beforeEvents.playerInteractWithEntity.subscribe(data => {
                                                                     ~
    The parser expected to find a '}' to match the '{' token here.

Lint Result

ESLint results:

<REPL0>.js

20:0 error Parsing error: '}' expected

dim tusk
#

Ohh my god, djnr use the debugger heere

dull shell
#

sorry 😭

dim tusk
#

#debug-playground 🙏

dull shell
#

i used the debugger and it gave me errors that I do not have/need help with 😭

dim tusk
#

Serty already gave you the dev resources

#

C'mon

warm mason
#

|| I don't understand why they don't understand. ||

distant tulip
#

the error is self explanatory anyway

dull shell
#

i figured it out sorry about that I didnt have the objective in yet

#

still learning js 🙏
\

sage sparrow
#

hi there, is it possible to spawn particle on a entity so the particle follows the entity while it is still active?

wary edge
jolly veldt
#

What are the conditions for playerInteractWithEntity

#

Do i need to have like

#

An interaction button or just right click/long tap

#

Or neither

#

Cuz I'm thinking whether i should use that or itemUse and try to get the target entity from that

wary edge
jolly veldt
#

Oh, thank you then

distant tulip
#

it dose not

#

... nvm
i thought i tested this before

wary edge
#

Tada.

distant tulip
#

nvm again lol
beforeEvents work with all entities
afterEvents work as you said

wary edge
#

Ah yep. I commented that in my code.

#

BeforeEvents also works with empty hand but after does not last I checked as well.

distant tulip
#

they do i think?
my fish brain can't remember a test i did two seconds ago

jolly veldt
#

One question

#

Since there seems to be no visible result

#

Do i need to apply setLore to event.itemStack or manually fetch the current item

distant tulip
#

wdym

jolly veldt
#

Which part are you confused about?

distant tulip
#

no visible result of what

jolly veldt
#

So I'm trying to apply setLore to the item that was used on the entity, and there seems to be no lore added

thorn flicker
#

applying the lore.

distant tulip
#

event.itemStack is just a copy of the item

jolly veldt
#

Oh, that explains a lot

distant tulip
#

you need to set the item to the same slot

thorn flicker
#

you need to set the item back in the slot after editing properites

thorn flicker
distant tulip
#

almost the same sentence lol

thorn flicker
#

almosttt

thorn flicker
# jolly veldt Oh, that explains a lot
player.getComponent('equippable').setEquipment('Mainhand', item)
// or...
player.getComponent('inventory').container.setItem(player.selectedSlotIndex, item) 
// if you want to set the item in other slots obviously change player.selectedSlotIndex to the slot you want.
distant tulip
#

i wonder if there any performance different

thorn flicker
#

just do either of these after editing properties

thorn flicker
distant tulip
#

yeah

drowsy scaffold
#

is there a way to stop people from dropping items?

#

like disable the permission from the player

drowsy scaffold
#

ugh

dim tusk
drowsy scaffold
#

For a psuedomethod that could definitely work, yeah

deep yew
#

do structures saved to the world (not loaded, just saved) take up storage? is it minimal, possibly?

#

Like a structure using scripts that uses the player's ID for a template structure like a base, but 100 players have the same structure saved, would it take up a lot of space just sitting as a structure that has been unloaded

wary edge
#

It's saved to the leveldb.

deep yew
#

so it's compressed?

#

a lot

bright dove
#

having a good day ?

celest abyss
#

Just as there is setOnFire, there is something like setOnFrezzing or something to similar the snow effect.

dim tusk
#

you can give the player a freezing damage I guess but not the effect in screen

celest abyss
dull shell
#
     .button("§sSpeed\n§a$§2" + world.scoreboard.getObjective('minionSpeedPrice').getScore(target) + world.scoreboard.getObjective('minionSpeedPrice').getScore(target),  "textures/items/diamond_hoe")```
#

is there anyway to make this so i can have text inbetween the 2 scores?

#

so it looks like this

deep yew
#

You using "+" to concatenate the strings is adding each string directly to the end of the last one

dull shell
#

so remove the "+"?

deep yew
#

So you need to do "$§2" + "1400" + " " + "(" + "1" + ")"

#

no, just add spaces using +

#

replace "1400" and whatever to the code you're using to get those values

dull shell
#

okay 1sec

#

i think I get it

deep yew
#

just take away the quotes or use `` (top left of keyboard with the ~)

#

`${world.scoreboard.....}` is a string version of the code you're trying to use

paper atlas
#

Could someone help me please?? im trying to make my entity deal an area attack using applydamage, but idk what is not working :((

dull shell
dull shell
#

i used that a little while ago for a different project

deep yew
#

It's called "Template Literals" if you want to find the js docs

dull shell
#

yeah i probably will end up

deep yew
#

you can use one string using back ticks (`) and just use ${} for the code, all in one string

dull shell
#

wait fr?

deep yew
#

`Speed\n$${code here} (${code here})`

dull shell
#

oh shit

#

amen for that that actually helps

deep yew
#

it also is useful for converting things to strings

#

like getting a scoreboard value

#

do `${scoreboard value (number)}`

#

and it turns it from type number to type string

#

if you need to use a function or something that can't input numbers

dull shell
#

then I can use it as a astring

#

omg

deep yew
#

yes I just unlocked many things for you

dull shell
#

to many things for me

deep yew
#

let your mind wander

dull shell
#

im about to, again i appericate it thank you! 🙏

solid prawn
#

Is there a way to check how much time does my script takes?

paper atlas
subtle cove
valid ice
solid prawn
#

Thanks

dull shell
#

is it possible to make it so when my entity is placed it spawns a structure?

#

something like this

meager zenith
#

Does anyone know what's wrong with this code var health = player.getComponent("minecraft:health"); health.setCurrentValue(Math.max(health.currentValue+1,health.effectiveMax)); ,it's giving me this error

meager zenith
#

Thank you so much

meager zenith
#

also why let and not var

meager zenith
#

sorry

warm mason
meager zenith
#

oh i see

#

thanks for your help

remote oyster
warm mason
remote oyster
bright dove
#

anyone sees whats wrong w this ?

gaunt salmonBOT
#
Debug Result

There are 29 errors from compiler, and 0 errors from ESLint in this [code](#1067535608660107284 message).
Please read the attached file for the result.

chilly fractal
dim tusk
#

@somber cedar stop doing the debugs here pls?

stark kestrel
#

how would u detect block, not broken by player? or broken by blast or anything else

dawn zealot
#
    world.getDimension('overworld').getEntities().forEach((entity) => {
        if (entity.typeId == "minecraft:item") {
            console.warn(entity.nameTag)
            if (entity.nameTag.startsWith("§cDamage Reduction §7I")) entity.runCommand("say hi")
        }
    })
``` im trying to get this to work but not even the console warn will show
subtle cove
#

entity.nameTag or item.nameTag?

dawn zealot
#

the item is an entity when its dropped right

#

so ima tryna detect the item thats dropped

#

and get its name

dawn zealot
subtle cove
dawn zealot
#

the documentation is in ts i dont use ts