#Script API General
1 messages Β· Page 30 of 1
Yes it's a custom frying pan
Your script is beta or nah?
Btw is custom components still beta?
does anyone know why this doesnt work?
const Block = data.block
const player = data.player
console.warn(`erherhedhewse`)
})```
Mmh I don't know
What block are you using to interact?
grass block
Grass block is not interactable
Try using crafting table
What i mean by interactable your arms swings whn you right click a block
I've seen someone do it with non interactable blocks like a diamond block
They used beforeEvents
Btw it spams the console warn
yeah it works but it spams
Does a setTimeout work ?
runTimeout
I have that fix before, ill find it on my old scripts brb
Do you have an example ?
world.beforeEvents.playerInteractWithBlock.subscribe(({ block, player }) => {
if ((player['cooldown'] ?? 0) > Date.now()) return;
player['cooldown'] = Date.now() + 50;
console.warn("block");
});
system.runTimeout(() => {
//codes
}, 20 * 3); //1 second is 20 ticks, we multiplied by 3 so 3 seconds or 60 ticks```
Thats all I remembered, idkk if that still works but just try it lol
Ik it's like the 5th time I've asked this but is their anyway to randomize setblock using an array?
Probably?
const blockTypes = [
"minecraft:stone",
"minecraft:grass",
"minecraft:dirt",
"minecraft:log",
"minecraft:planks",
// more block as needed
];
system.runInterval(() => {
const randomBlock = blockTypes[Math.floor(Math.random() * blockTypes.length)];
world.getDimension('overworld').runCommandAsync(`setblock ${x} ${y} ${z} ${randomBlock}`);
});
Just define the xyz
hi there, I used to have this code where it simulates a security camera but it get updated with a new location every X seconds always facing the player and it keeps tracking the player until next update.
after some past update it stopped to work and now I m trying to tshoot it, and looks like the easeOptions is causing a issue where the camera will not get update and always remains on the first position it was set at begining of the loop ```javascript
tv.camera.setCamera("minecraft:free", { easeOptions: { easeTime: 0.80, easeType: "OutCubic" }, facingEntity: target, location: { x: target.location.x, y: target.location.y+5, z: target.location.z+3 } })
do someone know what can be causing it?
if I remove the easeOptions it work and the camera get updated to the new location, but with ease it dont.
No one help me on how to do item lore for a item yet
can I please get some help, it would be very appreciated
And also please stop with the ItemStack thing because I want it set for a specific item to have lore, Example: a stick, where you can hover over it in the creative, or normal inventory and the lore appears for only the stick
That's how you do it. You create a new ItemStack -> SetLore -> Set to Inventory.
But to a specific item, it not clarifying what item it's adding lore to
Ik it's possible, i seen people done it
I just don't know how
That's what ItemStack does.
But how do I set it to what item, i want to have lore on it?
const item = new ItemStack('minecraft:stick');
item.setLore(['Lore']);
// Code to set Item in inventory
A lot of people have been tell me to do this:
ItemStack.addLore(["line1","line2","line3"])
This is what i was looking for
Idk how to set to inventory, i don't do scripting. Could you please help with that?
You should try learning Scripting.
Its pretty confusing
Essentially: https://stirante.com/script/server/1.15.0/classes/Container.html#setItem
Grab the entity -> grab the inventory component -> grab the container -> set the item.
Documentation for @minecraft/server
I'm looking at it, and I don't get it? I see getItem but how do I grab the entity?
Just from the creative inventory/a mob loot/recipe/ basically anyway you can get a item the lore will be there
Yeah that's not really feasible. You can only do it when it's in the world and not just UI.
For loot you can use loot table's functions. As for the rest, you probably want to do a system.run then loop through the inventory and if there isn't lore add the lore. Or alternatively if it's a custom item just use \n in the display_name.
How did others do it then?
Such as?
They likely used the methods I mentioned.
But the lore appears in the creative inventory when you hover or it
Then they used the second method I described.
Or alternatively if it's a custom item just use
\nin thedisplay_name.
One question, why do I need the code to set item in inventory?
That's just how it is.
What does it do? Does it make it work or something else?
Sorry if I'm bothering you a lot
I'm just a bit confused
Yeah it sets the Item into the inventory. That's just how it is.
So it adds a item in there with the lore or just makes the item in there have the lore
scripting isn't that confusing once you realize that it is just javascript
Depends on how the ItemStack instance is prepared. It is possible to do both:
- Adding an item involves creating an ItemStack instance out of thin air, via the
newkeyword (like Smokey described earlier). Then the lore is set, and later is added into the inventory. - Changing an item requires first grabbing an ItemStack instance from within the inventory first. Then the lore is set, and later can be set back to the slot in which it came.
anyone help
The only instances where an ItemStack does not have to be set back is for beforeEvents if I recall. Specfiically for the Custom Components one.
It can be. There are some hoops you need to jump through to grab the data you wantβin this case, grabbing an item off the player involves:
- Grabbing the player
- Grabbing the "inventory" component
- Grabbing the container
- Grabbing the slot
- Grabbing the item
here are some pages that will help you learn it:
https://www.w3schools.com/js/default.asp
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
https://wiki.bedrock.dev/scripting/starting-scripts.html
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/?view=minecraft-bedrock-experimental
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
The JavaScript reference serves as a repository of facts about the JavaScript language. The entire language is described here in detail. As you write JavaScript code, you'll refer to these pages often (thus the title "JavaScript reference").
As the Script API is a framework built on JavaScript code, having an understanding of JavaScript is key.
If you are being shown this, then you most likely are a beginner with JS and could use a little guidance.
Videos on Learning JavaScript
Javascript in 1 hour
Javascript Classes in 1 hour
Web Guide:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
Reference Sites:
https://www.w3schools.com/jsref/default.asp
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
https://javascript.info
oh lol I didn't realize there was a command for it, I was just listing the websites I used to teach myself javascript and the minecraft scripting api
Where it being JavaScript becomes relevant is understanding how data in the API is exposed. All data in the API, except of the most atomic kind like primitives (numbers, strings of text) and interfaces (a la objects), are classes of some kind. A function in one class may return another kind of class; the Player class' getComponent("inventory") method returns an EntityInventoryComponent class, which happens to be an extension of a more general EntityComponent class, and so on up the chain.
Anyone know how I could constantly update a scoreboard in scripts..
I thought about just constantly deleting and re adding the scoreboard but idk
is their any way to simulate a warped or crimson tree using the tree feature?
no one can help you beacuse they have no clue what you're asking for. All you've showed is two screenshots with zero code, and said you can't do something.
system.runTimeout doesnt work, does someone have another solution ?
import { BlockPermutation, ItemStack } from "@minecraft/server";
import { addItemOrSpawn } from '../util/utils';
export class FryingPan {
onPlayerInteract(e) {
const { player, block, dimension } = e;
const itemInHand = player.getComponent("inventory").container.getItem(player.selectedSlotIndex);
const detailBlock = block.typeId.split("_fryingpan_")[0];
const typeBlock = detailBlock.split(":")[1];
const stateBlockId = block.typeId.split("_fryingpan_")[1];
const stateBlock = Number(stateBlockId);
player.sendMessage(`Entered`);
player.sendMessage(`${typeBlock}`);
player.sendMessage(`${stateBlock}`);
switch (typeBlock) {
case "empty":
const newItem = itemInHand.typeId.split(":")[1];
player.sendMessage(`Entered empty`);
player.sendMessage(`${newItem}`);
block.setPermutation(BlockPermutation.resolve(`custom:${newItem}_fryingpan_1`));
player.sendMessage(`Entered empty check`);
player.runCommandAsync('playsound random.pop @s ~ ~ ~ 0.2');
if (!isCreative(player)) decrementItemInHand(player);
timeout1 = system.runTimeout(() => {
block.setPermutation(BlockPermutation.resolve(`custom:${newItem}_fryingpan_2`));
}, 20 * 3);
timeout2 = system.runTimeout(() => {
block.setPermutation(BlockPermutation.resolve(`custom:burn_fryingpan_3`));
}, 20 * 3);
break;
case "sliced_beef":
if(stateBlock === 2) {
addItemOrSpawn(player, new ItemStack("custom:cooked_sliced_beef", 1));
block.setPermutation(BlockPermutation.resolve(`custom:empty_fryingpan_0`));
}
case "burn":
if(stateBlock === 3) {
addItemOrSpawn(player, new ItemStack("custom:burned", 1));
block.setPermutation(BlockPermutation.resolve(`custom:empty_fryingpan_0`));
}
}
}
}
doesn't work for what?
I want to do a permutation after 3 seconds
you haven't import system
Mmmh indeed x)
Does it come from minecraft/server ?
yup
ok thanks
Also, is it possible to cancel a runTimeout with a second click of the player ? Like I click one time, it triggers the runTimeout, and then, I click a second time and it triggers a clearRun
If you successfully start an interval by clicking, then you can also clear it by clicking it again. Just grab the return value from runTimeout and pass it to the clearRun method to stop it.
I've done this but it doesnt work
Show an example
import { BlockPermutation, ItemStack, system } from "@minecraft/server";
import { addItemOrSpawn, isCreative } from '../util/utils';
export class FryingPan {
onPlayerInteract(e) {
const { player, block, dimension } = e;
const itemInHand = player.getComponent("inventory").container.getItem(player.selectedSlotIndex);
const detailBlock = block.typeId.split("_fryingpan_")[0];
const typeBlock = detailBlock.split(":")[1];
const stateBlockId = block.typeId.split("_fryingpan_")[1];
const stateBlock = Number(stateBlockId);
switch (typeBlock) {
case "empty":
const newItem = itemInHand.typeId.split(":")[1];
block.setPermutation(BlockPermutation.resolve(`custom:${newItem}_fryingpan_1`));
player.runCommandAsync('playsound random.pop @s ~ ~ ~ 0.2');
if (!isCreative(player)) decrementItemInHand(player);
system.runTimeout(() => {
block.setPermutation(BlockPermutation.resolve(`custom:${newItem}_fryingpan_2`));
}, 20 * 10);
const burning = system.runTimeout(() => {
block.setPermutation(BlockPermutation.resolve(`custom:burn_fryingpan_3`));
}, 20 * 20);
break;
case "sliced_beef":
if(stateBlock === 2) {
system.clearRun(burning);
addItemOrSpawn(player, new ItemStack("custom:sliced_beef", 1));
block.setPermutation(BlockPermutation.resolve(`custom:empty_fryingpan_0`));
}
case "burn":
if(stateBlock === 3) {
addItemOrSpawn(player, new ItemStack("custom:burned", 1));
block.setPermutation(BlockPermutation.resolve(`custom:empty_fryingpan_0`));
}
}
}
}
when my block is "empty", it starts the runTimeout. Then, when the block becomes "sliced_beef", I want to clearRun the second runTimeout by clicking on the block
The issue you're encountering is that the burning variable is defined within a specific scope, meaning it is lost once that scope ends. As a result, when you click again for "sliced_beef", burning is undefined, and nothing happens. To resolve this, you have a couple of options: you can either make burning a global variable, allowing it to persist across different invocations in your script, or you can modify your class to add burning as a property. The second approach is generally recommended, as it keeps your code organized and avoids potential conflicts with global variables, allowing each instance of the class to maintain its own state.
thanks ! How do I define burning as a property ?
import { BlockPermutation, ItemStack, system } from "@minecraft/server";
import { addItemOrSpawn, isCreative } from '../util/utils';
export class FryingPan {
constructor() {
this.burning = null; // Initialize burning as a property
}
onPlayerInteract(e) {
const { player, block } = e;
const itemInHand = player.getComponent("inventory").container.getItem(player.selectedSlotIndex);
const detailBlock = block.typeId.split("_fryingpan_")[0];
const typeBlock = detailBlock.split(":")[1];
const stateBlockId = block.typeId.split("_fryingpan_")[1];
const stateBlock = Number(stateBlockId);
switch (typeBlock) {
case "empty":
const newItem = itemInHand.typeId.split(":")[1];
block.setPermutation(BlockPermutation.resolve(`custom:${newItem}_fryingpan_1`));
player.runCommandAsync('playsound random.pop @s ~ ~ ~ 0.2');
if (!isCreative(player)) decrementItemInHand(player);
system.runTimeout(() => {
block.setPermutation(BlockPermutation.resolve(`custom:${newItem}_fryingpan_2`));
}, 20 * 10);
this.burning = system.runTimeout(() => {
block.setPermutation(BlockPermutation.resolve(`custom:burn_fryingpan_3`));
}, 20 * 20);
break;
case "sliced_beef":
if (stateBlock === 2) {
if (this.burning) {
system.clearRun(this.burning); // Clear the previous timeout
this.burning = null; // Reset burning after clearing
}
addItemOrSpawn(player, new ItemStack("custom:sliced_beef", 1));
block.setPermutation(BlockPermutation.resolve(`custom:empty_fryingpan_0`));
}
break;
case "burn":
if (stateBlock === 3) {
addItemOrSpawn(player, new ItemStack("custom:burned", 1));
block.setPermutation(BlockPermutation.resolve(`custom:empty_fryingpan_0`));
}
break;
}
}
}
To create a property for burning in the FryingPan class, you start by adding this.burning = null; in the constructor. This way, you're setting up burning as a property that belongs to the class. Then, when you get to the "sliced_beef" case, you check if this.burning is still active before trying to clear it. This makes sure you don't run into any issues. After clearing the timeout, you reset this.burning to null to show that there's no active burning state anymore. This approach helps keep everything organized and makes sure each instance of FryingPan can manage its own burning status without stepping on each other's toes.
Okay okay, thanks ! I'll try this
I'll be at church for a little bit so if there's still some issues then I won't be able to respond in a timely manner, but I'm pretty confident you should be good to go with that information.
no problem, thanks for your help π
what's the best way to store scores that I'm gonna be accessing every ~3-4 ticks?
all of my "scores" are dynamic properties, if that helps
I imagine dynamic properties are optimized to be accessed, yet it's still an API call. Personally I would only be updating their values when I know I need them stored, like when a player logs out or when the world closes.
waht if the game crashes?
The world state will probably not be saved anyway. You notice how you might lose some progress when the game crashes?
yeah but thats becouse world has auto save that has a ~1 minute inteval
That may be how often you feel comfortable saving your dynamic properties, then π
where can I find that sample for itemUse?
found it
it's in wolrdafterevents
why can't I use "if" in itemuse afterEvent
I forgot I have to do the prefix "minecraft"....
Is it possible to create an entity that is completely invisible (cannot be hit and doesn't get in the way of placing blocks)
can this listen to messages event on the server without need to create bedrock client?
any way to teleport an entity to player so fast that it's not being late? (so it accurately depicts player position)
The break block event has a block property
The block has .x, .y, and .z
As well as a .location
Hey, is there an event that detects when a block is placed but not by a player ?
Something like
- enderman placing block
- cobblestone generating from lava and water
etc ?

Is there a good reliable way to detect when a dispenser dispenses an item?
just execute at the location and then run your positional commands
execute positioned x y z run ...
no event for that yet, your best bet is just looking for items near dispensers with horizontal velocity
what is your goal?
some stuff don't need commands
InputPermissionCategory ? Movement: 2 ?
is that a question or what?
Stop all animation ?
Is it something that's planned?
π
I highly doubt it
I think the focus is on the input apis now
(which is awesome)
they should add these to platform information:
device's current fps
ip address (only available if you were using the server-net module)
max storage (not ram. the actual storage like ssd, hdd, sd card)
ping
but the current stuff is already awesome
Ping would be great
FPS would be nice to for on the fly adjustment
yeah
they will not do ip address.
lmao
probably not, but i think it'd go great with server-net
i do
InputPermission is for player controls not animations (stop movement and actions)
I hope that we can get left click detection for this
i want key control detection, like wasd, or controller sticks
left click detection would complete addons
even right click detection would be nice
its not that needed since we have item, block, and entity click events
but its nice to click on nothing
im aware
i know.
I know that you know.
i know that you know that i know
fair.
yeah
you never know when you will need it for an addon idea/feature
like a dash ability, idk
that would probably be better if we can detect other keys
doing that while supporting multiple platforms is a challenge
π€·ββοΈ
there's a concern for keyloggers too
yeah
unnecessary concern (i think?)
which I kinda understand why there is but it still makes me sad.
I hope they add it regardless.
You better get off the Internet lol. Public IPs aren't a secret. Think of it as a mailing address for your network (modem/router).
I know
I just, still dont want addons grabbing my ip? lol
fr
not really
Mojang
ah, tbf microsoft doesn't need to use minecraft if they can just take a screenshot of your computer every 5 seconds for AI (thank god that was canceled lmao)
execs smoking some shit fr
lolll
const invalidItemNames = [
"bricks", "slab", "chest", "table", "log", "block", "snow", "head", "skull", "carpet", "door", "stair", "chair", "anvil", "brew", "wall", "sign", "cracked", "slate", "gate", "egg", "bell", "wool", "glazed", "banner", "ore", "cobblestone", "stone", "box", "cake", "vine", "skulk", "clay", "cobbled", "copper", "heart", "crafter", "dispenser", "dropper", "rail", "lamp", "lectern", "path", "obsidian", "frame", "eye", "splash", "charge", "steel", "beacon", "furnace", "smoker", "moss", "pot", "candle", "boat", "spawn", "vault", "banner", "carpet", "button", "torch", "hook", "tnt", "redstone", "planks", "fence", "plate", "stripped", "camp", "lava", "water", "ice", "magma", "coral", "bucket", "wrench", "debug", "light", "sand", "glass", "stem", "end", "button", "piston", "carpet", "wax", "amethyst"
];```
Using playerInteractWithBlock, I'm trying to filter out any click event where the player is holding a block or something that naturally interacts with stairs or slabs ingame. This use typeID includes.
Any suggestions on what I should add to it?
is there a way to cancel the damage done on player durability during a break or hit event
Custom item?
i meant durability in general, like if i break a block with a vanilla shovel, can i cancel the damage done on the durability
Not vanilla.
how can i make tamed wolves to target an entity the player attacks? wolves somehow wont track targets if the player's attack wasnt direct
applyDamage also doesnt work for targeting
https://stirante.com/script/server/1.15.0/interfaces/EntityApplyDamageOptions.html
Do these options not work?
Documentation for @minecraft/server
no, for some reason
to put it short, it disables direct damage from player and replace it with applyDamage
How does it disable?
by putting a huge negative number in player entity's attack component
(it works somehow lmao)
Ok now I'm curious, does doing /damage work? Vanilla.
let me check
Intriguing.
because its a tablet
how do you format your code in quick edit
i just do it 
enter and tab keys
perfect
you could always switch to code editor, its the exact same thing but it has a format button
fair
it was 2 different questions, for the inputpermission I found but impossible to find how to stop all the animations
playAnimation(animationName: string, options?: PlayAnimationOptions): void
Stop animation ??
stopExpression is used to stop the animation that I am launching and not an animation already launched or am I making mistakes?
No
function addench(player) {
const i = player.selectedSlotIndex;
const inv = player.getComponent("inventory").container;
const item = inv.getItem(i);
const enc = item.getComponent("enchantable").getEnchantments();
for (let i = 0; i < enc.length; i++) {
console.warn(enc.type.id)
}
}
Not work , why?
The former. When the stopExpression evaluates to true, animationName stops playing and transitions to the nextState (which can be another animation)
enc is an array and at console.warn() you re getting a type from the array
you should do
console.warn(enc[i].type.id)
Helloo,
what is better or efficient, making the more scripting files with tiny codes, or putting all the codes in one big single file?
Multiple files.
thanks!
Can someone help me? How do I get the device the player is playing on and add a tag with the device name?
#1288452153584648265
Thank you very much, it will help me a lot.
π
i like to limit myself to 2000 lines of code, then make a new file and repeat.
it also helps me sort things out based on what i wanna work on
[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'beforeItemUseOn' of undefined
[Scripting][error]-Plugin [test_blaster BP - 1.0.0] - [index.js] ran with error: [TypeError: cannot read property 'beforeItemUseOn' of undefined at <anonymous> (test.js:17)
]```Why am i getting this error?
did i not import or is my manifest for minecraft/servers needs to be a specfic version?
manifest verion issue?
{
"format_version": 2,
"header": {
"description": "test_pack",
"name": "test_blaster BP",
"uuid": "ecb74745-bfc1-483f-8904-2423a755ea56",
"version": [
1,
1,
1
],
"min_engine_version": [
1,
21,
1
]
},
"modules": [
{
"description": "pack.description",
"type": "data",
"uuid": "96d8494a-2431-4e8b-a08e-3978ee2ec57b",
"version": [
1,
1,
1
]
},
{
"entry": "scripts/index.js",
"type": "script",
"uuid": "b4744624-8a95-4699-a65e-f95fce5be59b",
"version": [
1,
0,
0
]
}
],
"capabilities": [ "script_eval" ],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.15.0"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.3.0"
}
],
"metadata": {
"generated_with": {
"bridge": [
"1.8.5"
]
}
}
}
this it
it is up to date to my knowledge
What's your code?
const BLOCK_IDENTIFIER = "JCTbuild:coppercornerangle";
const MAX_SPIN = 15;
function rotateBlock(block) {
let spinValue = block.getBlockData().getProperty("JCTbuild:spin");
let newSpin = (spinValue + 1) % (MAX_SPIN + 1);
let permutation = BlockPermutation.create(block.type, { "JCTbuild:spin": newSpin });
block.setPermutation(permutation);
}
world.events.beforeItemUseOn.subscribe((event) => {
const { source: player, block } = event;
if (block.typeId === BLOCK_IDENTIFIER && player.isSneaking) {
rotateBlock(block);
}
});
ah, world.events is not a thing anymore
replacement?
world.afterEvents or world.beforeEvents
world.events hasn't been a thing since like, 1.19
don't use AI
don't always assume it's ai
it is AI
people can code a certain way similar to ai and it not be ai
you never know if he knew world.events didn't exist anymore
yeah, but my point is: dont assume every time
I'm not assuming every time
you did this time
is this time every time?
it's part of every time
but it's not every time is it
there's no removeItem function?
no, you have to setItem an itemStack of air
no. but ive seen you assume
use setItem, but leave the itemstack undefined
the problem its that i wanted to decrease the quantity of items
you don't need to do air
get the itemstack, decrement the itemstack's amount, then set the itemstack
really? last time I mentioned someone using AI was 8 months ago
did i say you directly said "AI"?
show me then
To be fair, the conversation was about the discussion of AI and whether or not it was used.
you were the one who claimed, you have to back it up
As others mentioned, setItem(undefined) will work.
i did claim, but there's no point in backing it up.
then your claim is invalid
no
no
does it?
if you can't show evidence, you can't say it's the truth
if you can't show evidence that the person used ai to generate their code, you can't say it's the truth either.
there is evidence though
it's right there in the code
Both of you cut it out, it legitimately does not matter
even if it's not enough evidence, I didn't explicitly state they used AI anyway, I simply said "don't use AI".
I could say "dont use AI" to anyone
not enough to support your claim
2 - 3 sentences on why they could be using AI, and why they shouldn't
ok, give me a second
If the code references outdated methods like world.events that are no longer valid in the current API, it could indicate a lack of understanding of the latest standards. This is a common issue with AI-generated code, as it might not always be up-to-date with recent changes in libraries or frameworks. Such inaccuracies can further support the argument that the code may have been generated rather than written by someone familiar with the current environment.
Please note "may have".
-
let spinValue = block.getBlockData().getProperty("JCTbuild:spin");
Block.getBlockData doesn't exist, never has existed. Obviously an AI hallucination. Likewise getProperty on whatever that should return also doesn't exist. -
let permutation = BlockPermutation.create(block.type, { "JCTbuild:spin": newSpin });
BlockPermutation.create() also doesn't exist. AI hallucination -
world.events.beforeItemUseOn.subscribe
hasn't existed for a long time, so they've used an AI with old training data
haha actually yk what
block.getBlockData is a spigot function
declaration: package: org.bukkit.block, interface: Block
sure the world.events is outdated, but you cant underestimate people. he might've not scripted for a while, and still thought that events were still used like that after coming back. AI makes mistakes like the ones you pointed out, but anyone could accidentally make that mistake. ive seen people used methods that don't exist, and their code wasn't AI at all.
you shouldn't almost automatically assume that their code is AI generated, they may be a Java player who works with spigot or some other server tool. some of this code probably was AI generated, but probably not all.
sorry if im a little slower at typing, im on a mobile device after all.
you are correct about these, but he could always be a java player and it could be a coincidence.
I highly doubt that
Ngl, I do think the code was AI generated
Occam's Razor
MOVE ON FOLKS
or is it? just wait till i type on a keyboard
i use ai to get familar with topics, they are wrong but now ik what to look for
[Scripting][error]-ReferenceError: Native function [Block::setPermutation] does not have required privileges. at rotateBlock (test.js:16)
at <anonymous> (test.js:25)```
```import { world, BlockPermutation, EquipmentSlot } from '@minecraft/server';
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") {
rotateBlock(block);
} else {
console.log("Rip.");
}
});
```Anyone knows what this error means?
beforeEvents puts the code in read-only mode, and some functions cant be used in read-only mode
afterEvents?
wrapping the function with system.run() will make the code to run
ah ok thank you
system.run(() => rotateBlock(block))```
or
```js
system.run(() => {
rotateBlock(block)
})```
how could i loop whats in here 20 times?
js if(player.hasTag('rabbit_escape_tamed')){ const entity = player.dimension.spawnEntity('jjk:shikigami_projectile_dummy' , player.getHeadLocation()); const projectile = entity.getComponent('projectile'); projectile.owner = player; projectile.shoot(player.getViewDirection()) entity.runCommandAsync("event entity @s rabbit_escape") cooldown.startCooldown(player) }
I forgot and don't wanna type it 20 times with different constant names π
like looping for x amount of times basically
π₯Ί
for (let i=0; i<20; i++) {
//code
}
it'll shoot all of it in the same tick tho
works for me
you want to spawn 20 projectiles?
wait nvm saw it's already been answered
Super cell.
entityDie
event
after event iirc
Yeah cause there's no before event π
I know seems impossible I want to be able cancel damage using SCRIPTS only
Not possible indeed
psst
not sure if you know it but
putting a huge negative value in attack component can cancel the damage
it does use player.json but just saying
can't that be done with script?
-# no, there is no attack component
letterally there are auto completions and jsdoc, its impossible to use methods that dont exist
If one chooses to use an IDE that provides those suggestions, then sure.
Not everyone does though, so oftentimes it looks like people engage in guesswork. That does not often work
outdated packages do suggest outdated stuff
-# anyway don't start that conversation again
remove collision box and make it immune from all damage
An entity will always occupy blocks. The only way to make it completely intangible is to make it an AOE cloud.
Guys can I ask, what code to fill with this.
Const tool = (the item that was in the mainland of the player)
*mainhand
player.getComponent('equippable').getEquipment('Mainhand')
Documentation for @minecraft/server
When I put it switch ,should it be like 'minecraft:stick' or just 'stick'
im not sure that if it matters or not when it comes to vanilla stuff, but custom items need the prefix.
Ohh thanks
I would just put minecraft: anyway
Mojang moment
tyring! why tyring instead of trying π
on the error log see after enchantment instance - Tyring to set enchantment level to 2,
Actually funny.. An official error is issued after checking whether it is possible to add an enchantment and says that she is tired of adding enchantments.
Is there a way to make an entity load the chunk its in
Ticking component in entity behavior
Do if (!initialSpawn) detect player first spawn or spawn after he died?
after he died
the property returns true if a player spawns by joining.
Checking if it's false would mean spawning after death.
someone who has a point
if omniac up for it, ill be glad to argue again
Is there a way to get query.time_of_day data in scripting?
I want to make clock block.
Thank you
guys why my custom component for updating block_states doesnt work, i just want to make it that if the player is holding a stick on the mainhand and click the block. The block state will be updated
I tried 'minecraft:stick' and still no changes
Try tool.typeId in your switch argument
I'll argue, If we're assuming they are using some old npm packages with autocomplete, they would've never done BlockPermutation.create or block.getBlockData, since they have never existed, they would've been error'd out
even tho they didnt exist, you can still code without autocomplete. meaning you could make some mistake thinking those methods may exist even tho they dont. i know it looks pretty ai, but it happens.
then your npm package argument is irrelevant, because that means they weren't using it anyway
no it's not, they could be using an outdated npm as well as non existent methods. the non existent methods could've been typed by accident even if they weren't part of the npm package.
i know the method names seem specific like how ai would use them, but really anyone can make the mistake of using a fake method
I'm not convinced that someone who uses auto completion, whether their packages are outdated or not, would use a non existing method since there would be no auto completion for it. Would be an illogical thing to do even for someone who is limited on what the API may offer, since this conversation established they are dependent on auto completion to assist them as they write the code. Besides, assuming they do not use auto completion, they wouldn't have been able to write a portion of their code without some knowledge and references to the API, therefore demonstrating their ability to read and understand it to some degree, and thereby determining if such methods did in fact exist since their code showed evidence that they would have used a reference for the API. Omniac is correct that the errors would have been sufficient in the initial tests to show they were incompatible.
Whether they understood what the errors meant or not is an entirely different discussion.
im not convinced either, but that wasn't the point of the conversation. it was that people can make mistakes, and not everything is ai. in this case the code probably was generated with some ai software. but i started the argument because people dont always use ai. i personally dont think the old npm package auto completion used the methods that were non existent as proven. but im saying anyone can make a simple mistake of using a non existent method. i would type a lot more, but i dont have the time right now. omniac was indeed correct at some parts, but not all. i too have seen ai code and know what it looks like.
@hot gust
??
Pinged them to see it.
If they had the old npm packages, and they were using autocomplete, then,
- They would have used the old event syntax
- But they wouldn't have used the non-existent methods (because they'd be errored out)
OR, if they didn't have the packages, and they were using the correct packages,
- They wouldn't have used the old syntax
- They also wouldn't have used the non-existent methods, (again they'd have errors)
OR, if they weren't using any packages at all,
- They would have had to look at the docs to see what they needed, in which case they would've used the correct syntax, since the official docs are always on the latest version
- They wouldn't have used the non-existent methods, since they aren't in the docs
SO in conclusion the only way that they would have done this, is either,
- If they were high on the zaza and imagining things
- Or if it's simply just an AI, which has had it's training data mashed together from scraped data from the web, so it mixed up the old syntax, with methods from spigot, probably because the user prompted something like "write a script to get the block data for minecraft", without specifiying versions, or APIs. And that's assuming that the AI still wouldn't hallucinate with the correct specifications, which it usually does.
Anyone who have the chest Gui addons?
didnt you get one yesterday
Wdym
I don't want this
What I need is a real container gui
Not a Gui that mimic the chest
Then use server plugins. U can't do that with Script
not yet
Actual chest UIs are awful to work with, just a fair warning.
Not multiplayer friendly, and very annoying to edit
HEY EVERYONE JAYLY BOT BACK
looks like I should have double tapped
uh cant i add tags to itemStack?
i dont see the addTag method
Theyβre a static thing
Not editable outside of the json
bruhhhhhhhhh
Use dynamic properties, itβs what theyβre for
how can i get the list of tags the item has?
getTags or something, idk
as an array
ill see
How to detect when a player is in a moving minecart?
Ok
is_axe
detect if player is in minecart and detect if player is moving
to detect if player moving you can do:
if (player.getVelocity() != 0) {
//returns true/false
}
there might be molang for if player is in minecart
@prisma shard
// <player> implements a player
const ridingOnEntity = <player>.getComponent('riding').entityRidingOn // Entity
if (ridingOnEntity.typeId === 'minecraft:minecart') { ... };
import { EquipmentSlot, system, world } from "@minecraft/server";
// List of the animals that will recieve double damage
const Animals_List = [
"minecraft:pig"
];
// A function to make the animale recieve double damage
function doubleDamage(damage) {
return damage * 2
}
world.afterEvents.entityHurt.subscribe(({ damageSource, hurtEntity, damage }) => {
// Get the item
const itemStack = damageSource.damagingEntity.getComponent("minecraft:equippable").getEquipment(EquipmentSlot.Mainhand);
// Check if the weapon has the tag "axe"
if (itemStack && itemStack.hasTag("minecraft:is_axe")) {
// Check if the hitted animale is in the list
if (Animals_List.includes(hurtEntity.typeId)) {
// Get the applied damage and double it using the function
const newDamage = doubleDamage(damage);
// and then apply it
hurtEntity.applyDamage(newDamage);
}
}
})```
help
my script is not working
whyy
what isnt woring
okay ill take a look over it
it recieves normal damage
i multiplied the damage with 2 but it doesnt apply it
lets dm
yes that i want
the damage i apllied and along with the doubel damage
ok
.
its fine to me
Most likely it doesnβt work because when you deal damage, a certain cooldown begins and while it lasts you cannot deal damage. That is, you need to wait a while for it to deal damage again
what if they were using old npm packaged but didn't know how methods worked? they could've used non existent methods whether or not they had auto completions. they could've not known about the docs, and they may have seen past code that doesnt work using old npm package autocompletion. they used non existent methods thinking they might work combined with old code.
You didn't change at all...
You still love pinging people π
I'd honestly be impressed if they were able to find such outdated code naturally
anyway you can't just slap random stuff together from nowhere, they would've had to have some sort of knowledge about the methods etc to even start writing, if it were the case that they didn't have autocompletions
im not lmao, this isn't random stuff. they indeed should've had some knowledge to start writing, but anyone can make the mistake of using a fake method. even if they've already seen the docs or it's not in their outdated autocompletion. they could still by choice use a fake method.
sure they could intentionally do that, to fuck with someone, but no one would ever do that unintentionally while just writing code. Why would they have correct syntax usage here and there but specfically not those two things? and why would they use spigot methods?
btw I was talking about them slapping random code together
the spigot method use is a big sign of ai. but void is right about people guessing methods, ive seen them do it with an outdated/normal syntax.
ok be more specific then, it looked as if you were referring to me.
eh it was more just a general term, "you" as in anyone
he was saying "you" as in people in general
Hello everyone. I'm struggling with implementing 3 riding anims for my jane mob. Any help is appreciated.
I'll just send the scripting parts
Wait
doesnt really sound like a scripting thing
animations?
No like
i know. i saw what he said.
I sent that as soon as he sent his message.
i read faster than you typed that
"addon:riding": {
"client_sync": true,
"default": 0,
"type": "int",
"range": [
0,
2
]
}
}
},```
Here
So far, I can only execute the anims using the event command
okay, so based in the property, you want the animation to change when its riding
Exactly
still wondering how this is related to scripting though
Because of this
I want them to work.
But I got no idea how to
you shouldnt use scripting
you just need animation controllers lmao
guys, how can i use InputButton thing?
also is it possible to open the entity inventory using it??
I'm just curious, is there any way to open the entity inventory without interacting with it?
For input events
Jump, sneak, etc
Yes but i think you can detect WASD or joystic using getMovementVector or player velocity
Ok
it says cannot read property registerCustomComponent of undefined
world.beforeEvents.worldInitialize.subscribe(event => {
event.blockTypeRegistry.registerCustomComponent("vm:potato_pie", new PotatoPie())
})```
Youw wassup
try changing blockTypeRegistry to blockComponentRegistry
alright, i got this from the microsoft docs
ow
oh that part is already working, since it's a class with the thingie in the constructor cant really explain
but this made it work now
._.
yeah sorry π
Ok np
but is this how you check if a block has a specific permutation?
if (block.permutation.getState("example:test")) {
...
}```
he is pingable ??
sooo, there's no way to open the entity inventory without interacting with the entity itself,,, right?
yo whats the command to see whats wrong with a script
Debug on #debug-playground
i just wanna see someone say no it's not possible
No it's not possible
@valid ice I have a question, is it possible to write items and lore in the creative inventory?
Nop
Hey guys
return new ModalFormData()
// likes: number
.slider('Β§f\nΒ§8[Β§2LikesΒ§8] Β§eΒ§l ', likes, likes, likes, likes);
How can i like make that the slider can't be moved? i want it like that he stays at the start and just don't move, is that possible?
// implement this as a slider
[Likes] : 23
// Cant be moved, its constant on the edge
[x]=====================================
(Nervermind, i figured it out)
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]
._. just remove != Undefined
it is necessary
in case the state is 0 or false
Any scripters here do commissions?
Commissions ?
i found a weird bug
All I said was "you still ping people like you used to before"
Yeah.
What the hell is this?
(0 <= world.getTimeOfDay() < 6000)
Didn't thought this was possible
Supposed to look like this, world.getTimeOfDay() >= 0 && world.getTimeOfDay() < 12000 right?
that is not in the code?
if ((0 <= world.getTimeOfDay() < 6000) || (18000 <= world.getTimeOfDay() < 0)) {}
?
Also that's the reason I said didn't thought it was possible cause I'm not sure either lmao
I've uploaded a better version.
line 65
replace it with
if ((0 <= timeOfDay && timeOfDay < 6000) || (18000 <= timeOfDay && timeOfDay < 24000)) {
yeah it is not
1 < 2 <3
will just turn into
true < 3
Here @alpine nebula
That worked, thank you guys.
np
Goofy ahh pfp
no it say not a function in line 6 πΏ
line 6 is a return
Not script related but I found a way to increase the NPCs button
Yeah, I did it last year I just don't share it cause I know people don't use npc_interact screen anymore lmfao
is there a limit somewhere in the json of npc_interact?
You can only have 6 buttons
yeah
But I used an editor that lets you add almost infinite amounts of button by editing it's data.
ah
So fun to use lmao... I love that it doesn't flickers when you change forms...
wouldnt that affect performance
Probably for really low end devices
But I don't lag and I only added 10-15 buttons yet
When transferring items to the player's inventory, is there a way to prevent the items from showing up as invisible?
?
they shouldnt be invisible
thats likely a problem with the item itself (like the resource pack)
I'm not using any resource packs, its weird
const time = world.getTimeOfDay();
if (time <= 12000) β will work only in daytime
i already tested it out
Yeah I know... What I'm trying to say he should have used &&
he doesn't even have to use it
@untold magnet
Backread first lmao
he doesn't have to do all of that stuff, if he wanna make it work only in daytime
He already said it's "AM" and "PM"... Backread gosh
@untold magnet
I hate MS docs https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/timeofday?view=minecraft-bedrock-experimental
he kinda right
there is not negative timeOfDay
0 <= timeOfDay this is not needed
I've fixed my clock
I hate light mode
That's why I use jaylys website
return (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
def get_days_in_month(month, year):
if month == 1: # January
return 31
elif month == 2: # February
return 29 if is_leap_year(year) else 28
elif month == 3: # March
return 31
elif month == 4: # April
return 30
elif month == 5: # May
return 31
elif month == 6: # June
return 30
elif month == 7: # July
return 31
elif month == 8: # August
return 31
elif month == 9: # September
return 30
elif month == 10: # October
return 31
elif month == 11: # November
return 30
elif month == 12: # December
return 31
else:
return "Invalid month number."
def main():
user_input = input("Type 'yes' to continue: ").strip().lower()
if user_input == "yes":
try:
year = int(input("Enter the year: "))
month = int(input("Enter the month number (1-12): "))
days = get_days_in_month(month, year)
if isinstance(days, int):
print(f"The number of days in month {month} of year {year} is: {days}")
else:
print(days)
except ValueError:
print("Please enter a valid year and month number.")
else:
print("Exiting the program.")
if __name__ == "__main__":
main()
My friend is so stupid in python he needs help with this
-# Not related to script
Their teacher asked them to create a program that you can put the number of the exam 1 for January and shows the days of that month
I have this script that would show my inventory and its showing all the slots filled, but it shows as empty. Then, if I interact, they all appear
Anyways, I'm creating clipboard hahahaha.. I''ll be back next week
why hotbar? u still able to see it anyway
anyways
Since the items also show as invisible on the hotbar
I feel like its a bedrock thing
im so stupid in python i dont understand any of this except the functions
thanks it work
It's okay.. python is pretty much like JavaScript but with much more unnecessary things β οΈ
Bro said
Wth
Man , didn't see c++ yet
I saw that, I don't like it
β οΈ just don't try to learn it , u r had gonna shut down
That's what I said I don't like it... I prefer, python, html, JavaScript a lil bit of java and json
I won't learn new language from now. Unless I got time...
I need help for json UI lmao... I'll finish the modal form then problem the UI next and bg
Wait in the text field you can't put limit that like it's 10 characters only? Nope I'm not talking about hiding it like you can't realize type it
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]
I'm trying to create a custom form for Minecraft via main.js. However, when I try to use the listed items to activate it, it doesn't work. Does anyone know where the error is?
replace the customUI Β° with =
and change the tipeId in your event to typeId
Ok here I have changed it but it still doesn't work
any errors?
import { world } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"
world.afterEvents.itemUse.subscribe((data) => {
const player = data.source;
if (player && data.itemStack.typeId === "minecraft:compass") {
ui(player);
}
if (player && data.itemStack.typeId === "minecraft:clock") {
customUi(player);
}
});
function ui(player) {
const form = new ActionFormData()
.title("title Ui")
.body("Body Ui")
.button("button.1")
.button("button.2")
.button("button.3")
form.show(player).then(r => {
if (r.selection == 0) {
player.sendMessage("Button Ui 1")
}
if (r.selection == 1) {
player.sendMessage("Button Ui 2")
}
if (r.selection == 2) {
player.sendMessage("Button Ui 3")
}
})
}
function customUi(player) {
const form = new ActionFormData()
.title("title customUi")
.body("Body customUi")
.button("button.1")
.button("button.2")
.button("button.3")
form.show(player).then(r => {
if (r.selection == 0) {
player.sendMessage("Button customUi 1")
}
if (r.selection == 1) {
player.sendMessage("Button customUi 2")
}
if (r.selection == 2) {
player.sendMessage("Button customUi 3")
}
})
}
@hardy moat
Okay, I'll try to add it.
Unfortunately this still doesn't work. Maybe someone knows what the error is in the script placement?
do you have content logs on
itll tell you errors
(alternatively, try deleting the pack from the world and activate it back)
I don't have it. How do I do it?
I'm a newbie here
open settings, and check the tab with command block icon
and then turn on content logs GUI
dont forget to do this too, the pack couldve cached in your world
and dont turn on 'files' one, itll bloat your storage
Ok I will try it
I have tried all those ways but still not working and this came out
show your manifest
add the server-ui module to your dependencies
π
How to close only player current form not all?
Open another form after you close it
it will look strange tho
I want to open another form first and close current form
Nah, take the ugly sliding animation or leave it. (or use json ui to remove the animation)
can't dynamically update server form without the animation
Guys, I'm still correct that you can't access the form values if you close the form right? Using the ModalFormData
Looks I really need to edit the json UI of it so when player closed the form it will click the submit button
I didnβt ask you tho
yes. hehe
im always leik that xd
Hail9
Yes if I remember correctly
is it fine if I ask about MBE here?
you mean this? https://wiki.bedrock.dev/commands/block-entities
how do I check if an entity is alive. example:
I spawn an entity and use runTimeout and check if the entity if still alive.
get the health component, and the currentValue property
check if its greater than 0
alright thanks
alright
'player' is the specific player u want,
u can use it after a form has been shown
I meant how to close only 1 form that player is opened like
form(player);
system.runTimeout(() => {
uiManager.closeAllForms(player);
}, 2);
Is there a way to close only 1 form not all forms?
well, there's only that method rn, so no other method
u can prevent a form being shown multi times using time/tick
I just found out that inside an event after getting an entity's health component and do a runTimeout the health component is still updated, so basically when an entity dies and that runTimeout triggers it gets the updated value not the past
cus the property is a getter bound to the health component of specific entity
thats the nature of getter property
u can cache such components actually
how do I get the past? do I assign it outside the event block?
use entitytHealthChange event
what are other options?
const hp0 = health.currentValue
system.runTimeout(() => {
const hp1 = health.currentValue
}, 10)```
I check for hp0 and still the same
adjust the tick time
define the number before the runTimeout
the number?
mc.world.afterEvents.itemUse.subscribe((e) =>{
const entityHealth = entity.getComponent("health");
mc.system.runTimeout(() =>{
let durability = itemUsed.getComponent("durability");
inventory.addItem(itemUsed);
if (entity.isValid()) {
mc.world.sendMessage("1")
durability.damage = durability.damage - ( entityHealth.currentValue - entityHealth.defaultValue );
entity.remove();
}
else {
mc.world.sendMessage("2")
durability.damage = durability.damage - entityHealth.defaultValue;
};
},200);
)};
basically this is what I was doing
the 2 doesn't get to check the defaultValue
Have anyone of you ever used Proxy or Reflect in a minecraft script?
search it up
here...
the Reflect one isn't visible, but ive seen it been used here
Okay cool, btw:
Sometimes some functions arent available in mnicraft like bigInt or eval, you know how i can use them?
do i need to add a module or what?
MS Docs.
Thanks you both
;-; vscode ext
What is "pbr"?
wanted to ask the same
@honest spear help ;-;
No, you got this M9
rare M9 moment
nah, haent touched that pbr thing tho
manifest capabilities like pbr
What is pbr for a capabilities in the minecraft manifest
its for deferend rendering resource packs
okay thanks, is it possible to use bigInt somehow?
BigInt doesn't require any of the capabilities
huh, i tought because sometime (in the past) i got an error while using it, probably my skill issue
they added support to it sometime ago
Nice
you can not use arithmetic operation with BigInt and normal Number
Yes i know
Yep
Hmm, i dont really remember the reason for the usecase, i dont even know if anyone ever have used it in a minecraft script
can someone try this to confirm it? i need to make a bug report (tabbing out of the game is what trigger it in my case)
Use it for long distance between world's maxX and minX
Or if u wanna count the total number of blocks in your world β οΈ
you don't have to count it you just multiply number of chunks with 16x16 height of the chunk
thats still not great usecase
well Number is big enought
also MC would crash if you try to spawn too big structures
Number is good enought trust me
i couldn't replicate it
yeah nvm
json ui bug
Is the Buffer (class) useable? (i cant test it at)
Script-API is based on QuickJS, from online search I found that Buffer class is mostly associated with NodeJS
Ohh okay, Thanks Gega
yo chat
yo Woods
Dosen't support binary
Guys question
Is there something in server module , that divides blocks into categories
Like
Redstone blocks
Ticking blocks
Farm blocks
Decoration blocks
Or something like that
@amber granite idk but maybe you can do some thing with that:
block.getComponent
block.getTags
block.hasTag
block.permutation.type.canBeWaterlogged
block.permutation.getState
block.permutation.getAllStates
block.permutation.hasTag
block.permutation.getTags
are vanilla blocks categorised?
Elaborate.
For reference ^
They're in the creative menu?
Yeah can i get it in script api
no
however there's item tags for swords, pickaxes, axes and hoes.
if that's useful
What about
Maybe becazse you have changed the UUID of the addon
this.#player.camera.setCamera("GameCamera", {
rotation: rotation, // Vector2
location: location, // Vector3
easeOptions: {
easeTime: easeTime, // number
easeType: easingType // keyof typeof EasingType
}
});
help?
@valid ice
What is "GameCamera"? Is that some camera preset you have created? I'm pretty sure cameras need to be namespaced IDs
I have gameCamera (class) added to the player so i can call it whe i need to
i can try to
Mm, the camera preset there is something like "minecraft:free". It is a camera definition within your behavior pack
tried camera:gameDefault, it still throwed an error
ohh you meant this
I completely forgot about that
thanks!
Thanks Sprunkles
yes its working
Hey everyone who can help me fix the code
#1301464443162460221 message
See the latest massage
Guys i want explanation
Sure
QR CODE builder?
What should i explain there?
No
So i used getEntities({maxDistancr : 40 } )
And i got this
The pink frames are the chunks that getEntities method didn't detect them
@distant gulch
How can i make it detects those 4 chunks
Probably because that chunk didn't load properly?
They are loaded
location, where
The red dot in the middle
should it be radius or box?
What
if u moved on the corner, does it detect the entities in pink?
const location = entity.location;
location.x -= 40
location.z -= 40
entity.dimension.getEntities({location, volume:{ x:40*2 ,y:20 ,z:40*2 }})
Nice
Is there more optimized way to do it
dunno
I need the most effecient way
perhaps that's just the range of chunks the entity, alone, can simulate...
Ok
more like touched by the radius
ah,
const block = entity.dimension.getBlock(entity.location);
const { x, y, z } = block?.center();
unloaded chunks ^^
Use ticking area or use entity
if (block?.isValid() === true) continue; should do it?
fixed
guys
How to detect and kill specific item
const itemNametag = 'diamond';
system.runInterval(() => {
for (const entity of world.getDimension('overworld').getEntities())
if (entity.typeId === "minecraft:item" && entity.nameTag === itemNametag) {
entity.kill();
});
I do this but not working
Code is correct but I drop the item the. Not happened anything
Guys
dont use nameTag
lemme make u one
just wait
item entity doesn't have name tags
im making him/her a script rn
No wonder
But the compiler doesn't said code has bug
Compiler only checks for syntax error, not logic error. It doesn't understand what you're trying to achieve.
How U made the compiler bot?
@quick shoal
import { system } from '@minecraft/server';
const eItems = ['minecraft:diamond'] // add the items ID's here
system.runInterval(() => {
const dimension = ['overworld', 'nether', 'the_end'].map(dim => {
for (const entity of world.getDimension(dim).getEntities()) {
const rItems = entity.getComponent('minecraft:item');
if (eItems?.includes(rItems.itemStack.typeId)) entity.remove()
}
})
})```
np,
Debug result for [code](#1067535608660107284 message)
Compiler found 1 errors:
[36m<REPL0>.js[0m:[33m6[0m:[33m26[0m - [31merror[0m[30m TS2304: [0mCannot find name 'world'.
[7m6[0m for (const entity of world.getDimension(dim).getEntities()) {
[7m [0m [31m ~~~~~[0m
ESLint results:
<REPL0>.js
5:9 error 'dimension' is assigned a value but never used @typescript-eslint/no-unused-vars
What are U doing
Code :
e.dimension.getEntities({location : e.entity.location , volume : { x : 80 , y : 80 , z :80 } } )
I want this
U see the middle red block
Is the entity
I want the entities around 2 chunks of it in radius
Including pink frames
I used that but i got weird result
subtract the location's x and z coords by radius
How
.
its like x,y,z,dx,dy,dz
hm,mm,mmm does the tickingarea have limitations of how many areas are loaded?
Why ?
10
Oh i see
So location is like
X1 , y 1 , z1
And volume is
X2 , y2 , z2 ?
@subtle cove
ye
Tank u
alright!, I'll make my addon use a custom advanced block that will load chunks around it using the tickingarea command
is there any better way to do it?
like entities that will load chunks around it, i think its possible
But...
Tick_world
Works chunk radius not block radius
And maximum radius is 6 and minimum is 2
So if u wanna load 1 block... As example
U will load other 24 chunks
i will load blocks in a huge radius, not one or two blocks
Yep use what i told u
More heat
for what purpose...
my addon isn't allowed for phones that aren't 15+
And that needs : time , math , bugs
they will explode
its for everything, phones pcs xbox ps7
wait, 10 chunks only but there's no limitations of how many tickingareas i add???
@subtle cove ^
perhaps /tickingarea cmd
So 100 chunks limit
Now chose between two
uhm, tickingarea is limited per dimension, its in /tickingarea list
entity tick_world component, u can use more
Tick_world cons :
1 entity that has tick_world component, can cause lag as hell
Because minimum is 25 chunks per entity
TickArea command cons :
More devices friendly , limited
Hey
@untold magnet can U help me again the code U given is bugging
[Scripting][error]-TypeError: cannot read property 'itemStack' of undefined at <anonymous> (main.js:53)
at map (native)
at <anonymous> (main.js:55)
Send code
use runInterval as timer
What
system.runInterval(() => {
const eItems = ['minecraft:diamond']
const dimension = ['overworld', 'nether', 'the_end'].map(dim => {
for (const entity of world.getDimension(dim).getEntities()) {
const rItems = entity.getComponent('minecraft:item');
if (eItems?.includes(rItems.itemStack.typeId)) entity.remove()
}
})
});
How
system.runInterval(() => {
const eItems = ['minecraft:diamond']
const dimension = ['overworld', 'nether', 'the_end'].map(dim => {
for (const entity of world.getDimension(dim).getEntities()) {
const rItems = entity.getComponent('minecraft:item');
if (eItems?.includes(rItems.itemStack.typeId)) entity.remove()
}
})
});
[Scripting][error]-TypeError: cannot read property 'itemStack' of undefined at <anonymous> (main.js:53)
at map (native)
at <anonymous> (main.js:55)
Plz fix it
rItems is not defined
Just Verify if itemstack exists
, use container then get inventory
item entity should be removed instantly?
That not how it works
perhaps the entity isn't an item entity
^
Just Check if not an item entity
Use the entity filter of getEntities()
How
Bruh
entities.filter(e => e.typeId == "minecart:item" )
No
getEntities({type:'item'})
?
Its will normally remove the item but also broke my chest Gui code
my internet went off
sigh
or that ^


