#detecting double sneak while on 8th hotbar slot✅
1 messages · Page 1 of 1 (latest)
yep
import {
system,
world
} from "@minecraft/server";
const playerMemory = {};
system.runInterval(() => {
world.getPlayers().forEach((player) => {
const SlotIndex = player.selectedSlotIndex;
const {
isSneaking
} = player;
playerMemory[player.id] ??= {};
if (isSneaking) {
if (!playerMemory[player.id].wasSneaking) {
playerMemory[player.id].wasSneaking = true;
playerMemory[player.id].sneaks ??= 0;
playerMemory[player.id].ticks = 0;
playerMemory[player.id].sneaks++;
}
} else {
playerMemory[player.id].wasSneaking = false;
playerMemory[player.id].ticks ??= 0;
// change the detection speed here
if (playerMemory[player.id].ticks++ > 4) {
// here executes when double sneak && 8 slot
if (playerMemory[player.id].sneaks === 2 && SlotIndex === 7) {
playerMemory[player.id].sneaks = 0;
console.warn(`You Double Sneak and won the "maxed" tag!`);
player.addTag("maxed");
}
playerMemory[player.id].ticks = 0;
playerMemory[player.id].sneaks = 0;
}
}
});
});```
@shy dome
Thanks! I‘ll test it
so i just pasted this into a new script but it doesn't seem to work...
am i doing something wrong?
Probably, I tested it and it is working
What are you doing? Have you correctly defined the classes? How did you put the script together? What's your version? Console log errors? Did you put it in the right folder?
oh, and also make sure you are in the right slot when you run it lol, I made it so that the code would only run if you were in the penultimate slot (8th)
@shy dome
What do you mean by „correctly defined the classes“?(sry I’m new to scripting)
I don't even know if it's called that lmao, but it's to define @minecraft/server in the manifest
anyway, are your scripts defined in your manifest?
my min engine version:
"min_engine_version": [
1,
21,
0
],
"capabilities": [
"script_eval"
],
"dependencies": [
{
"uuid": "6b49b646-4ad6-4337-988a-3ef6c6dfb92c",
"version": [
1,
0,
0
]
},
{
"module_name": "@minecraft/server",
"version": "1.14.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.3.0-beta"
}
]
}
this is in my manifest aswell
"description": "Script that implements basic starter tests.",
"type": "script",
"language": "javascript",
"uuid": "1A1B53FC-5653-4A75-91B7-9CDF027674AE",
"version": [
1,
0,
0
],
"entry": "scripts/StarterTests.js"
}
],
@chilly iron
scripts/StarterTests.js is also the script where i put your code in
Latest NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Beta APIs NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Preview Latest NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Preview Beta APIs NPM Types
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
npm i @minecraft/[email protected]
Try changing 1.14.0-beta to 1.12.0-beta | and | 1.3.0-beta to 1.2.0-beta
This version is in beta preview, unless you are in the beta version
If you are on Stable, switch versions to this to try
i did
still doesn't work for me
hmm
Can you send me your manifest file and the file where you put my code?
@shy dome
sorry for the delay
heres my manifest:
{
"format_version": 2,
"metadata": {
"authors": [
"Me"
],
"generated_with": {
"bridge": [
"2.7.24"
],
"dash": [
"github:bridge-core/dash-compiler#8fa35c73292f6382747d0f411fca26431a6d2c8e"
]
}
},
"header": {
"name": "MyAddon",
"description": "Addon",
"min_engine_version": [
1,
21,
0
],
"uuid": " some code ",
"version": [
1,
0,
0
]
},
"modules": [
{
"type": "data",
"uuid": " some code ",
"version": [
1,
0,
0
]
},
{
"description": "Script that implements basic starter tests.",
"type": "script",
"language": "javascript",
"uuid": "1A1B53FC-5653-4A75-91B7-9CDF027674AE",
"version": [
1,
0,
0
],
"entry": "scripts/StarterTests.js"
}
],
"capabilities": [
"script_eval"
],
"dependencies": [
{
"uuid": "6b49b646-4ad6-4337-988a-3ef6c6dfb92c",
"version": [
1,
0,
0
]
},
{
"module_name": "@minecraft/server",
"version": "1.12.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.2.0-beta"
}
]
}
edited some stuff out
and inside my scripts folder inside my bridge is:
import {
system,
world
} from "@minecraft/server";
const playerMemory = {};
system.runInterval(() => {
world.getPlayers().forEach((player) => {
const SlotIndex = player.selectedSlotIndex;
const {
isSneaking
} = player;
playerMemory[player.id] ??= {};
if (isSneaking) {
if (!playerMemory[player.id].wasSneaking) {
playerMemory[player.id].wasSneaking = true;
playerMemory[player.id].sneaks ??= 0;
playerMemory[player.id].ticks = 0;
playerMemory[player.id].sneaks++;
}
} else {
playerMemory[player.id].wasSneaking = false;
playerMemory[player.id].ticks ??= 0;
// change the detection speed here
if (playerMemory[player.id].ticks++ > 4) {
// here executes when double sneak && 8 slot
if (playerMemory[player.id].sneaks === 2 && SlotIndex === 7) {
playerMemory[player.id].sneaks = 0;
console.warn(`You Double Sneak and won the "maxed" tag!`);
player.addTag("maxed");
}
playerMemory[player.id].ticks = 0;
playerMemory[player.id].sneaks = 0;
}
}
});
});
the script is called StarterTests.js
@chilly iron ik not a file but what is inside the files
np but both looks fine
no errors in the console log?
try adding
console.warn(`Test`);```
at the begin, if this message appears then the problem is my code
Where is the console, like in the game or in bridge?
pls excuse if this sounds ridiculous
its in-game
You activate it in the settings, in the creator option
theres a command block as a icon
Did this end up working for you?
No, but I need to test it with the console warn
Dang
yes it appeared..
wait wtf
for some reason now it still worked
but for some reason it only worked once
@chilly iron
yeah seems like it only worked for that one single time,
which is really really weird
fr
idk, maybe you need a new manifest or it's something i'm not realizing
what the f does this mean ? @chilly iron
It's normal, the script is loading, this message is only bad when it appears while you are playing-
cuz it means that the script is slow
anyways ill make a new manifest for ya
@shy dome
{
"format_version": 2,
"header": {
"name": "§lAddon",
"description": "try this with the scripts",
"uuid": "0ae2622b-ba91-472a-999c-eb56f7c26a81",
"version": [1, 0, 0],
"min_engine_version": [1, 21, 0]
},
"modules": [
{
"type": "data",
"uuid": "8a1a4c02-5a62-4a3a-b13e-437a06745b79",
"version": [1, 0, 0]
},
{
"type": "script",
"language": "javascript",
"uuid": "032ebfac-6030-408d-bd3e-9c8fcc15d6ba",
"version": [1, 0, 0],
"entry": "StarterTests.js"
}
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.12.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.2.0-beta"
}
]
}```
why does it look so much shorter?
i optimized it lmao
and wrote more directly
and nothing bad will happen if i change it right?
hold on
it looks like you have a dependence uuid in the rp
if so, you'll just change it
But try using mine to see if it works, but don't discard yours, just replace it temporarily
well tbh, it wasn't even my own manifest in the first place, just copy pasted it from someones addon bc i didn't know how to make one, lmao
😀
@chilly iron
okay, okay
no
something is severely wrong here
"this pack is missing 1 or more dependencies"
and the Test came up again 😃
did you try sneaking?
I even forgot to say, it has to be very quick
not that much, but anyways
i did, almost broke my fingers(not really)
wdym? This stuff always comes up as soon as i enter the game 🥲
I'm doubting my own script, Can you tell me exactly how you put it in StarterTests.js
actually send me, if you have just it in the file
deleted my initial text of the script, pasted your stuff in
It works fine for me 😭
btw i got jumpscared by an armor stand
i dont think so
but maybe, who knows
then it must be a maniferst issue?
PC and PE is same
no way it would show different results
what the actual f.,..
earlier today i reverted my manifest to the old one and now the script works?!
have tested multiple times in multiple worlds and it seems to work..
the only thing i need now really is to set the scoreboard hotbar to whichever hotbar slot i'm on and a script that removes maxed when dsneaking while having maxed tag
but thank you really much @chilly iron , even if it hadn't worked the fact that you gave so much of your time and attention to this makes me really greatful and i hope i can help you someday too
🥹
lmao, I suggest taking your Minecraft to a priest bc its cursed 😭
no problem! i'm glad I helped
Really, thanks a lot!
i can help with that too if ya want
Sure
I already had a few ideas but can’t really code
but dm me, this forum is already full of messages and the main problem has already been resolved
its really ez dw, i like to help cuz i learn a lot too
detecting double sneak while on 8th hotbar slot✅
Which old manifest version?