Skip to Content

                              Scroll down for more codes of previous  videos

Snow Golem Code :

//=================== MADE BY KIDDING_MC_VN =============
// ================== GLOBAL VARIABLES ==================
var s = null
var sj = 0
var clearPos = null // store block position to be removed
var lastSkinUpdate = 0 // last skin update time (ms)

// ================== HELPER FUNCTION ==================
function v(i){
try { api.getPosition(i); return true }
catch(e){ return false }
}

// ================== MOB SUMMON ==================
function onPlayerChangeBlock(p,x,y,z,f,t){
if (
t.includes("Carved Pumpkin") &&
api.getBlock([x,y-1,z]) == "Snow" &&
api.getBlock([x,y-2,z]) == "Snow"
){
// spawn mob (base AI)
s = api.attemptSpawnMob(
"Draugr Skeleton",
x, y-1, z,
{ name: "Snow Golem" }
)

api.setTargetedPlayerSettingForEveryone(s,"canSee",true,true)
sj = api.now()

// mark blocks to be removed in tick()
clearPos = [x,y,z]
lastSkinUpdate = 0
}
}

// ================== TICK ==================
function tick(){

// ---- remove summon blocks (once) ----
if (clearPos){
let x = clearPos[0]
let y = clearPos[1]
let z = clearPos[2]

api.setBlock([x,y,z],"Air")
api.setBlock([x,y-1,z],"Air")
api.setBlock([x,y-2,z],"Air")

clearPos = null
}

if (!v(s)) return

// ---- adjust mob visuals (no movement changes) ----
if (sj !== "c" && api.now() - sj > 250){
api.setTargetedPlayerSettingForEveryone(s,"canSee",true,true)
api.setTargetedPlayerSettingForEveryone(s,"killfeedColour","white",true)
api.setTargetedPlayerSettingForEveryone(
s,
"nameTagInfo",
{ backgroundColor:"rgba(0,0,0,0)", content:[] },
true
)

// if you want the mob to attack normally β†’ REMOVE the line below
api.setMobSetting(s,"attackDamage",4)

sj = "c"
}

// ================== UPDATE MOB SKIN EVERY 1 SECONDS ==================
if (api.now() - lastSkinUpdate > 1000){ // 1 seconds
api.setMobSetting(s, "heldItemName", "Air");
api.setMobSetting(s, "name", "Snow Golem")
api.setMobSetting(s, "attackItemName", "Snowball");
api.setMobSetting(s, "onDeathItemDrops", [
{
itemName: "Snowball",
probabilityOfDrop: 1,
dropMinAmount: 0,
dropMaxAmount: 15,
},
{
itemName: "Carved Pumpkin",
probabilityOfDrop: 1,
dropMinAmount: 1,
dropMaxAmount: 1,
},
])

// Pumpkin head attached closely above the body
api.updateEntityNodeMeshAttachment(s, "HeadMesh", "BloxdBlock",
{blockName:"Carved Pumpkin", size:0.8, meshOffset:[0,0,0]},
[0,0.25,0], [3.14159,3.14159,3.14159]
)

// Extended Snow body
api.updateEntityNodeMeshAttachment(s, "TorsoNode", "BloxdBlock",
{blockName:"Snow", size:1.1, meshOffset:[0,0,0]},
[0,0,0], [0,0,0]
)

lastSkinUpdate = api.now()
}

// ================== CREATE BLOCK UNDER MOB FEET ==================
let pos = api.getPosition(s)
let bx = Math.floor(pos[0])
let by = Math.floor(pos[1] - 0.5)
let bz = Math.floor(pos[2])

if (api.getBlock([bx,by,bz]) == "Air"){
api.setBlock([bx,by,bz], "Snow")
}
}




Pink Sheep code :

//coded by Sousu 

const mobId =api.attemptSpawnMob("Sheep", -37, 1, 98,{variation:"pink"})

//other colors: "default", "black", "red", "orange", "pink", "purple", "yellow", "blue", "brown", "cyan", "gray", "green", "lightBlue", "lightGray", "lime", "magenta"



Mace Code for Bloxd.io :

let playerPositions = {};
SPAWN = [[-45, 1, -1], [-37, 10, 12]];

function onPlayerDamagingOtherPlayer(attacker, victim) {
  try {
    if (api.isInsideRect(api.getPosition(victim), ...SPAWN)) {
        return "preventDamage";
    }
    const weapon = api.getHeldItem(attacker);
    if (weapon?.attributes?.customDisplayName) {
      const name = weapon.attributes.customDisplayName;
      if (name === "Mace") {
        const [x1, y1, z1] = api.getPosition(attacker);

        let fallHeight = 0;
        if (playerPositions[attacker]) {
          const lastY = playerPositions[attacker].y;
          fallHeight = Math.max(0, lastY - y1);
        }

        const baseDamage = 20;
        const fallDamageBonus = Math.min(60, fallHeight * 5);
        const totalDamage = Math.floor(baseDamage + fallDamageBonus);

        api.applyHealthChange(victim, -totalDamage, attacker);

        const slownessDuration = Math.min(10000, 5000 + fallDamageBonus * 50);
        const slownessLevel = Math.min(5, 2 + Math.floor(fallHeight / 3));

        api.applyEffect(victim, "Slowness", slownessDuration, {
          icon: "Slowness",
          displayName: fallHeight > 3 ? "Devastated" : "Slammed",
          inbuiltLevel: slownessLevel,
        });

        const [x2, y2, z2] = api.getPosition(victim);
        api.setVelocity(attacker, 0, 20, 0);

        const particleIntensity = Math.min(3, 1 + fallHeight / 5);
        const particleCount = Math.min(200, 100 + fallDamageBonus * 2);

        api.playParticleEffect({
          dir1: [
            -3 * particleIntensity,
            -3 * particleIntensity,
            -3 * particleIntensity,
          ],
          dir2: [
            3 * particleIntensity,
            3 * particleIntensity,
            3 * particleIntensity,
          ],
          pos1: [x2 - 3, y2, z2 - 3],
          pos2: [x2 + 3, y2 + 3, z2 + 3],
          texture: "glint",
          minLifeTime: 0.3,
          maxLifeTime: 1 + fallHeight * 0.1,
          minEmitPower: 3,
          maxEmitPower: 5 + fallHeight,
          minSize: 0.3,
          maxSize: 0.7 + fallHeight * 0.05,
          manualEmitCount: particleCount,
          gravity: [0, -5, 0],
          colorGradients: [
            {
              timeFraction: 0,
              minColor:
                fallHeight > 5 ? [255, 100, 100, 1] : [180, 180, 180, 1],
              maxColor:
                fallHeight > 5 ? [255, 200, 100, 1] : [255, 255, 255, 1],
            },
          ],
          velocityGradients: [{ timeFraction: 0, factor: 1, factor2: 1 }],
          blendMode: 1,
        });

        if (fallHeight > 0) {
          api.sendMessage(
            attacker,
            `Mace Strike! Fall damage bonus: ${fallDamageBonus} (${fallHeight.toFixed(
              1
            )}m fall)`
          );
        }

        return "preventDamage";
      }
    }
  } catch {}
}



onPlayerJoin = (pid) => {
  api.setClientOption(pid, "airJumpCount", 3);

  if (["BloxdDevsAreTheBest"].includes(api.getEntityName(pid))) {
    api.setClientOption(pid, "canEditCode", true);
  }

  playerPositions[pid] = { y: 0, lastUpdate: api.now() };
};

tick = (ms) => {
  const playerIds = api.getPlayerIds();
  const currentTime = api.now();

  for (const playerId of playerIds) {
    if (api.playerIsInGame(playerId)) {
      const y = api.getPosition(playerId)[1];

      if (!playerPositions[playerId]) {
        playerPositions[playerId] = { y: y, lastUpdate: currentTime };
      } else {
        if (
          y > playerPositions[playerId].y ||
          currentTime - playerPositions[playerId].lastUpdate > 1000
        ) {
          playerPositions[playerId].y = y;
          playerPositions[playerId].lastUpdate = currentTime;
        }
      }
    }
  }

  for (const playerId in playerPositions) {
    if (!api.playerIsInGame(playerId)) {
      delete playerPositions[playerId];
    }
  }
};





Woodoo dolls world code :

let voodooMap = {};

function hasJoinedBefore(playerId) {
    let item = api.getMoonstoneChestItemSlot(playerId, 0);
    return item && item.name === "Dirt" && item.attributes?.customDescription === "JoinedBefore";
}

function markAsJoined(playerId) {
    api.setMoonstoneChestItemSlot(playerId, 0, "Dirt", 1, {
        customDescription: "JoinedBefore"
    });
}

function setVoodooPos(p, pos) {
    api.setMoonstoneChestItemSlot(p, 1, "Dirt", 1, {
        customDescription: JSON.stringify(pos)
    });
}

function getVoodooPos(p) {
    let it = api.getMoonstoneChestItemSlot(p, 1);
    if (!it || !it.attributes?.customDescription) return null;
    try { return JSON.parse(it.attributes.customDescription); } catch { return null; }
}

function spawnVoodoo(ownerName, pos) {
    if (!pos || !Array.isArray(pos)) return null;
    let mobId = api.attemptSpawnMob("Draugr Zombie", pos[0], pos[1], pos[2], { name: ownerName });
    if (!mobId) return null;

    // Configure voodoo mob
    api.setMobSetting(mobId, "maxHealth", 1e9);
    api.setMobSetting(mobId, "initialHealth", 1e9);
    api.setMobSetting(mobId, "hostilityRadius", 0);
    api.setMobSetting(mobId, "attackRadius", 0)
    api.setMobSetting(mobId, "attackDamage", 0);
    api.setMobSetting(mobId, "runAwayRadius", 0)
    api.setMobSetting(mobId, "chaseRadius", 0);
    api.setMobSetting(mobId, "baseWalkingSpeed", 0)
    api.setMobSetting(mobId, "baseRunningSpeed", 0);
    api.setMobSetting(mobId, "walkingSpeedMultiplier", 0)
    api.setMobSetting(mobId, "runningSpeedMultiplier", 0);
    api.setMobSetting(mobId, "onDeathItemDrops", []);

    voodooMap[ownerName] = mobId;
    let ownerId = api.getPlayerId(ownerName);
    if (ownerId) setVoodooPos(ownerId, pos);

    return mobId;
}

function despawnVoodoo(ownerName) {
    let mobId = voodooMap[ownerName];
    if (mobId) {
        api.despawnMob(mobId);
        delete voodooMap[ownerName];
    }
}

onPlayerJoin = (p) => {
    let name = api.getEntityName(p);
    let pos = getVoodooPos(p);

    // Only respawn if there is a stored position
    if (pos && Array.isArray(pos)) {
        spawnVoodoo(name, pos);
    }

    if (!hasJoinedBefore(p)) {
        api.giveItem(p, "Black Paintball", 1, { customDisplayName: name + "'s Voodoo" });
        markAsJoined(p);
        api.sendMessage(p, "You have been bound to your voodoo doll...");
    }
};

onPlayerLeave = (p) => {
    let n = api.getEntityName(p);
    let hasVoodooItem = false;

    // Check all inventory slots (0–50) for the voodoo item
    for (let i = 0; i <= 50; i++) {
        let item = api.getItemSlot(p, i);
        if (item && item.name === "Black Paintball" &&
            item.attributes?.customDisplayName === n + "'s Voodoo") {
            hasVoodooItem = true;
            break;
        }
    }

    // If the player doesn’t have the voodoo item, save mob pos
    if (!hasVoodooItem) {
        let mobId = voodooMap[n];
        if (mobId) {
            let pos = api.getPosition(mobId);
            setVoodooPos(p, pos);
            api.despawnMob(mobId);
        }
    } else {
        // If they have it in inventory, mark as "false"
        setVoodooPos(p, false);
    }
};

onPlayerAltAction = (id, x, y, z, block, eId) => {
    let held = api.getHeldItem(id);
    if (!held || held.name !== 'Black Paintball' || !held.attributes?.customDisplayName.endsWith("'s Voodoo")) return;

    let ownerName = held.attributes.customDisplayName.slice(0, -9);
    let ownerId = api.getPlayerId(ownerName);
    if (!ownerId) return;

    // Remove the held item
    api.setItemSlot(id, api.getSelectedInventorySlotI(id), 'Air');

    const pos = [x, y + 1, z];
    api.sendMessage(ownerId, `Your Voodoo has been placed at ${pos[0]} ${pos[1]} ${pos[2]}!`);
    setVoodooPos(ownerId, pos);

    // Spawn the voodoo mob
    const mobId = spawnVoodoo(ownerName, pos);
    if (!mobId) return;

    voodooMap[ownerName] = mobId;
};



onWorldAttemptDespawnMob = (mobId) => {
    for (let ownerName in voodooMap) {
        if (voodooMap[ownerName] === mobId) {
            return "preventDespawn";
        }
    }
};

onPlayerDropItem = (playerId, x, y, z, itemName, itemAmount, fromIdx) => {
    if (itemName === "Black Paintball") {
            api.sendMessage(playerId, "You cannot drop your Voodoo!");
            return "preventDrop"
      }
};

playerCommand = (id, cmd) => {
    if (cmd !== 'voodoo') return

    let voodooOwnerName = api.getEntityName(id);
    let found = null;

    for (let mId of api.getMobIds()) {
        if (api.getEntityName(mId) === voodooOwnerName) {
            found = api.getPosition(mId)
            break;
        }
    }

    if (!found && api.hasItem(id, "Black Paintball")) {
          api.sendMessage(id, "Your Voodoo is in your inventory")
          return true
    }

    api.setMoonstoneChestItemSlot(id, 1, 'Dirt', 1, { customAttributes: { pos: found } });

    if (Array.isArray(found)) {
        api.sendMessage(id, `Your Voodoo is at ${found[0]} ${found[1]} ${found[2]}`);
        return true

    }
};


onPlayerDamagingMob = (playerId, mobId, damageDealt, withItem) => {
    for (let pId in voodooMap) {
        if (voodooMap[pId] !== mobId) continue;

        let dollName = api.getMobSetting(mobId, "name");
        let realId = api.getPlayerId(dollName);

        // Pick up your own voodoo if empty-handed
        if (api.getHeldItem(playerId) == null && dollName === api.getEntityName(playerId)) {
            api.despawnMob(mobId);
            api.giveItem(playerId, "Black Paintball", 1, {
                customDisplayName: dollName + "'s Voodoo"
            });
            setVoodooPos(playerId, "false");
            delete voodooMap[pId];
            return;
        }

        // Deal mirrored damage to the real player
        if (realId && dollName !== api.getEntityName(playerId)) {
            let dir = api.getPlayerFacingInfo(playerId).dir;
            api.applyMeleeHit(playerId, realId, dir, null, { damage: damageDealt });
            api.applyHealthChange(mobId, 1e9); // instantly kills the doll, prevents repeat hits
        }
    }
};


onMobDamagingOtherMob = (attackingMob, damagedMob, damageDealt, withItem) => {
    let name = api.getMobSetting(damagedMob, "name");
    if (!name) return;
    let playerId = api.getPlayerId(name)
    if (playerId) {
        let dir = [0, 0, 0]
        api.applyMeleeHit(attackingMob, playerId, dir, null, { damage: damageDealt });
                api.applyHealthChange(damagedMob, 1e+9)
    }
};

onItemDropCreated = (itemEId, itemName, itemAmount, x, y, z) => {
if (itemName == "Black Paintball") {
   api.deleteItemDrop(itemEId)
  }
}

onPlayerKilledOtherPlayer = (attackingPlayer, killedPlayer, damageDealt, withItem) => {
if (api.hasItem(killedPlayer, "Black Paintball")) {
    spawnVoodoo(api.getEntityName(killedPlayer), api.getPosition(killedPlayer))
  }
  else {
    for (let mId of api.getMobIds()) {
        if (api.getEntityName(mId) === api.getEntityName(killedPlayer)) {
            found = api.getPosition(mId)
            break
        }
    }
   api.sendMessage(attackingPlayer, api.getEntityName(killedPlayer) + `'s Voodoo is at ${found[0]} ${found[1]} ${found[2]}`)
  }
}

onMobKilledPlayer = (attackingMob, killedPlayer, damageDealt, withItem) => {
if (api.hasItem(killedPlayer, "Black Paintball")) {
    spawnVoodoo(api.getEntityName(killedPlayer), api.getPosition(killedPlayer))
  }
}

Woodoo dolls normal code :

api.giveItem(myId, "Black Paintball", 1, { customDisplayName: "x__snehaa__x" + "'s Voodoo" });





AI BOTS CHAT CODE :

// Ocelote 2025 ALL RIGHTS RESERVED
// DO NOT COPY CODE
// Subscribe to Pika gaming 2 on yt // if you do decide to copy for testing, please give credit in the world // DO NOT use this code in a world or video without permission from Ocelote // still under development let botsCanInventTrends = true let chatLevel = 0.02 const ownerName = "Ocelote" let lastMsg = "" g=(e={})=>{let a=e.w||10,o=e.l||22,r=e.p||60000,i=e.o||0,l=["Awesome","Exalted","Frantic","Merry","Alert","Amusing","Bored","Brave","Calm","Chilly","Clever","Clumsy","Cranky","Crazy","Excited","Foolish","Fussy","Fuzzy","Glowing","Crafty","Lumpy","Messy","Mighty","Peppy","Nimble","Polite","Proud","Quick","Quiet","Rusty","Shining","Silly","Sleepy","Slimy","Sloppy","Smooth","Speedy","Stinky","Strict","Tough","Tricky","Wild","Wise","Worried","Haunted","Fierce","Opulent","Saucy","Irksome","Famous","Feral","Fresh","Spoony","Noisy","Amazing","Gangly","Juicy","Ancient","Frosty","Savage","Fiery","Enraged","Surly","Helpful","Simple","Feisty","Toasty","Joyful","Humble","Extreme","Grumpy","Snoozy","Sneaky","Cheeky","Shrewd","Cunning","Motley","Primal","Harsh","Sandy","Funny","Gentle","Elegant","Fancy","Scruffy","Eager","Jolly","Witty","Nervous","Careful","Gifted","Melodic","Raspy","Modern","Fluffy","Prickly","Shaggy","Ghastly","Exotic","Spicy","Salty","Elusive","Magical","Beloved","Squeaky","Shiny","Singing","Pink","Raging","Unruly","Scary","Flappy","Tiny","Haughty"],n=["Turtle","Fox","Hawk","Falcon","Eagle","Jester","Joker","Potato","Ace","Flyer","Driver","Turkey","Chicken","Donkey","Goat","Llama","Weasel","Koala","Wolf","Cook","Hippie","Boss","Goose","Crawdad","Toaster","HotDog","Wizard","Unicorn","Ninja","Samurai","Cowboy","Vampire","Pirate","Ogre","Mentor","Narwhal","Cactus","Bigfoot","Farmer","Knight","Ghost","BLT","Baby","Eyeball","Hamster","Toad","Wombat","Worm","Hare","Zombie","Mutant","Mime","Sheriff","Toast","Pancake","Plumber","Penguin","Hammer","Panda","Octopus","Wallaby","Lemur","Burrito","Avenger","Bobcat","Donut","Cobra","Yodeler","Diva","Coconut","Moose","Tiger","Walrus","Coyote","Lion","Puma","Mango","Cake","Ostrich","Caveman","Ukulele","Furball","Manatee","Buffalo","Paladin","Shaman","Warrior","Rogue","Warlock","Druid","Scout","Banshee","Artisan","Citizen","Badger","Bear","Beast","Centaur","Coward","Cyclops","Hominid","Goblin","Kobold","Gremlin","Gryphon","Kraken","Mystic","Nomad","Peasant","Pegasus","Rhino","Sapling","Yeti","Sphinx","Villain","Warthog","Squire","Cheese","Spider","Lemon","Truck","Banana","Elf","Alpaca","Dragon","Raccoon","Taco","Witch"],t=[],y=~~((Date.now()+i)/r);for(let e=0;e<a;e++){let a,r=(a=1779033703^y-e,a=Math.imul(a^a>>>16,2246822507),a=Math.imul(a^a>>>13,3266489909),(a^a>>>16)>>>0),i=()=>Math.abs(r=1664525*r+1013904223|0),u=l[i()%l.length]+n[i()%n.length],s="";for(let e=0,a=o-u.length;e<a;e++)s+=i()%10;t.push(u+s)}return t}; guestNames = g() function typo(originalString, typoChance) { if (typoChance < 0 || typoChance > 1) { return originalString; } let newString = ""; let i = 0; while (i < originalString.length) { if (Math.random() < typoChance) { const typoType = Math.floor(Math.random() * 4); switch (typoType) { case 0: i++; break; case 1: const repeatChar = Math.random() < 0.5 && i > 0 ? originalString[i - 1] : originalString[i + 1]; newString += repeatChar??""; newString += originalString[i]??""; i++; break; case 2: const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; const randomReplacement = chars.charAt(Math.floor(Math.random() * chars.length)); newString += randomReplacement; i++; break; case 3: if (i + 1 < originalString.length) { newString += originalString[i + 1]??""; newString += originalString[i]??""; i += 2; } else { newString += originalString[i]; i++; } break; } } else { newString += originalString[i]; i++; } } return newString; } function seval(str){if(typeof str !== 'string'||str.trim()===''){return undefined} if(str.includes('//')||str.includes('**')){return undefined} let processedStr=str.replace(/([0-9.)])\s*\(/g,'$1*(').replace(/x|X/g,'*'); let sanitizedStr=processedStr.replace(/[^0-9.+\-*/^()]/g,''); let evalStr=sanitizedStr.replace(/\^/g,'**'); try{if(evalStr===''||!/[0-9]/.test(evalStr)){return undefined} return eval(evalStr)}catch(e){return undefined}} function randIP() {return Math.floor(Math.random()*256)+"."+Math.floor(Math.random()*256)+"."+Math.floor(Math.random()*256)+"."+Math.floor(Math.random()*256)} let botNames = [ "log", "fof", "sos", "pug", "nod", "rek", "mov", "tag", "tee", "vok", ] chatEvents = { join:{player:null,talk:0}, chat:{player:null,talk:0,msg:""}, leave:{player:null,talk:0}, } let msgs = { gen:[ "yo anyone can help me code pls", "CREATIVE PLS I BEG OR CO OWNER IS ALSO FINE", "who owner", "anyone espanol???", "wdym", "I mean like I want to know yes or no", "1v1 anyone??", "Ye", "No", "OFC NOT", "bruh, like, wdym", "what...?", "that was so abrupt", "anyone pick a number between 1 and 10 and i will guess", "bro what is going on in chat", "BRO THAT GUY WAS A HACKER! REPORTED!", "yo how am i in creative", "jk", "guys pls join my party", "anyone?", "yep exactly.", "hash tables can work", "how am I meant to work with this", "bro what is this world", "owner this world is very nice, can you please friend me, I want co owner.", "jkjk", "Timothy said he will make world code limit higher soon", "Yo I have yet another anti-interrupt framework", "just use my os lol, like, it supports literal file loading and saving", "that's all it does tho isnt it", "I hate how snowdashes go sideways and not forwards", "Releasing a new implementation of of setTimeOut!!!", "it's interruption safe", "nothing in bloxd is interruption safe", "no wdym", "yep, he is.", "someone gift me super pls", "I am a bloxd dev.", "Hello, how may I assist you?", "kk", "pls admin", "gimme admin or i ban u", "you have a few more seconds", "donating super, who wants?", "me", "ye ofc it does", "did it work", "onPlayerMove callback has been released!!!", "tp for shop", "tp for pvp", "OMG I GOT 2 DIRT", "gimme creative plzzz", "abc to adopt me", ], join: [ ["hi "], ["hello "], ["yo wsp "], ["yo wsg "], ["sup "], ["wsp "], ["wsg "], ["yo "], ["look who we have here. it is our very own "], ["yo big fan "], ["WAIT "," JOINED???"], ["OMG HI ","!!"], ["yo "," wsp"], ["YO GUYS "," joined, do you know who that is?"], ["wait is this the real ","?"], ["Is that who I think it is? Is that ","?"], ["seriously? ","?"], ], chat: [ ["wdym \"",false,"\""], ["lol ",true," is crashing out"], ["wait ru sure ",true,"??"], ["NO. WAY. ",false,"..."], ["so like '",false,"' u mean now there is?"], ["wdym ",true,""], ["ok ",true,". whatever u say."], ["no way ",true," is for real"], ["bro ru kidding me ",true,""], ["",true," is correct"], ["Exactly. ",false,"..."], ["YEA IKR! ",false," FR!!!"], ["bro rlly said \"",false,"\""], ["nahh ",true," is autoclicking"], ["BRO ",true," IS HACKING"], ["Wow! You are the best ",true,"! and please don't say that again!"], ["yeah ",false," ikr so true"], ["",false,"... WAIT THATS GENIUS"], ["wait so ",false," now? ok ig"], ["lol ",true," is actually cooking"], ["so ",true,", how exactly does that work"], ["wait, ",true," IS ON???"], ["OMG HI ",true,"!!"], ["yo, ",true,"? big fan"], ["hey ",true," can u accept my friend req pls :D"], ["yo ",true," send me a req"], ["hi ",true," pls friend me"], ["wanna join me ",true,"?"], ] } chatMsgCache = [ "Hi there", "Yup", "Nup", "Nope", "Les gooooo", "Les goooo", "Les gooo", "are you there", "done", "ooh interesting...", "yes", "No", "Yes", "no", "super", "brain", "mind", "you forgot a comma", "*exclamation mark*", "!!!! WARNING !!!!", "Hi what's up", "guys im new", "how do I play bloxd", "TWO dirt? really? no way...", "that's what i said", "WHAT DID I SAY", "you deserved it", "hello hi", "hi hello", "im a real human bro", "BRO IM NOT A BOT", "ok ig ur right", "hmmm... really?", "that feels wrong", ] responses = {} let botsNum = 10 broadcasts = [] tick=()=>{ if(broadcasts.length>0){ api.broadcastMessage(broadcasts.shift()) } if(Math.random()<0.005){ api.broadcastMessage(guestNames[(guestNames.length*Math.random())>>0]+((Math.random()>0.2)?" joined":" left"),{color:"#cef3ff"}) } if(Math.random()<chatLevel){ let num = Math.floor(Math.random()*botsNum) let name = (Math.random()<0.5)?(botNames[num]):(guestNames[num]) let nameRefs = botNames.filter(name=>lastMsg.toLowerCase().includes(name)) if((nameRefs[0])&&(Math.random()>0.2)){ name = nameRefs[Math.floor(Math.random()*nameRefs.length)] } let msg = '' if((responses[lastMsg]!==undefined)&&(Math.random()>0.65)){ msg = responses[lastMsg] } else { if(chatEvents.join.talk>0){ let joinmsg = msgs.join[Math.floor(Math.random()*msgs.join.length)] msg = (joinmsg[0]??'')+chatEvents.join.player+(joinmsg[1]??'') chatEvents.join.talk-- } else if(chatEvents.chat.talk>0 && chatEvents.chat.player) { chatEvents.chat.talk-- let m = chatEvents.chat.msg let ml = m.toLowerCase() let sw = ml.startsWith let ans = seval(m) if((Math.random()>0.2)&&(ans!==undefined)){ msg = ans+"" } else if((ml.includes("what")||ml.includes("wut")||ml.includes("wat"))&&ml.includes("ip")) { msg = "The ip adress is: "+randIP() chatEvents.chat.talk=0 } else if(["is","are","was","were","do","does","will","were","was"].some(pre=>ml.startsWith(pre))&&(Math.random()>0.2)){ msg = (Math.random()>0.5)?"yes":"no" } else { let style = msgs.chat[Math.floor(Math.random()*msgs.chat.length)] msg = style[0]+((style[1])?(chatEvents.chat.player):(chatEvents.chat.msg))+style[2] } } else { if (Math.random() < 0.6) { let part1 = ["bro","wait","omg","obviously","for real","nah","I think","honestly","have you realized that","did you know that","did yk","ok so just I realized","no wait,","in my opinion","bruh","how come","are you sure that","you literally just said that","what about when you said","guys I just found out that"] let part2 = ["the code","my wifi","the chat","my pet","your bro","the owner","your pet","having a chat","being honest","that spider","my life","your effort","your username","my house","my big bro","that one guy","that dude from earlier","this chest","that one youtuber","your coder","your brain","this universe","the past"] let part3 = ["is wild","is a scam","is cringe","is fire","sux","is fake","is so good","doesn't even make sense","is honest","is a lie","is unrealistic","is a GOD","makes a lot of sense","came out of nowhere","is ai generated","doesn't actually exist","still exists"] let usePName = (Math.random()>0.7) let pt2 if(usePName){ let pids = api.getPlayerIds() let randId = pids[(Math.random()*pids.length)>>0] pt2 = api.getEntityName(randId) } else { pt2 = part2[Math.floor(Math.random()*part2.length)] } msg = `${part1[Math.floor(Math.random()*part1.length)]} ${pt2} ${part3[Math.floor(Math.random()*part3.length)]}` } else if(Math.random()<0.35){ msg=lastMsg } else if(Math.random()>0.5){ msg = msgs.gen[Math.floor(Math.random()*msgs.gen.length)] } else { msg = chatMsgCache[Math.floor(Math.random()*chatMsgCache.length)] } } } let lastMsgCoherent = msg.toLowerCase() msg = typo(msg,Math.random()*0.03) if(botsCanInventTrends){ responses[lastMsg] = msg.toLowerCase() let i = Math.floor(Math.random()*chatMsgCache.length) chatMsgCache[i]=msg } lastMsg = lastMsgCoherent if(Math.random()>0.75)msg=msg.toUpperCase() if(Math.random()>0.75)msg=msg.toLowerCase() api.broadcastMessage([ {str:name+": ",style:{color:"#dff8ff"}}, {str:msg,style:{color:"#fff"}} ]) } } onPlayerJoin=(pid)=>{ let name = api.getEntityName(pid) if(name==="Ocelote")api.setClientOption(pid,"canEditCode",true) chatEvents.join.player=((Math.random()<0.5)?(name.replace(/[^a-zA-Z]/g,'')):name).toLowerCase() chatEvents.join.talk=3 guestNames = g() } onPlayerChat=(pid,msg,loc)=>{ if(loc==="Tribe")return let name = api.getEntityName(pid) if(!msg.includes("**")){ let i = Math.floor(Math.random()*chatMsgCache.length) chatMsgCache[i]=msg chatEvents.chat.player=((Math.random()<0.5)?(name.replace(/[^a-zA-Z]/g,'')):name).toLowerCase() chatEvents.chat.talk=Math.floor(Math.random()*Math.random()*16+1) chatEvents.chat.msg=msg chatEvents.chat.lasttime=api.now() let lom = msg.toLowerCase() responses[lastMsg] = lom lastMsg = lom } //* broadcasts.push([ {str:name+": ",style:{color:"#cef3ff"}}, {str:msg,style:{color:"#fff"}} ]) return false /**/ } playerCommand=(pid,cmd)=>{ if(api.getEntityName(pid)!==ownerName)return let args = cmd.split(" ") switch(args[0]){ case "level": chatLevel = +args[1] return true } }







  1.  Rainbow Sky
api.setClientOption(myId, "skyBox", {
        type: "earth",           // Use realistic sky model
        inclination: -6.486,        // Sun higher in the sky
        azimuth: -175.57672,            // Direction of the sun
        turbidity: 154,            // Clear sky with soft clouds
        luminance: 2.00,          // Brighter lighting
        vertexTint: [-100, -100, -100] // Cool blue tint (crystal morning)
    })

2. Mega Black Hole Sky

api.setClientOption(myId, "skyBox", {
        type: "earth",           // Use realistic sky model
        inclination: -6.486,        // Sun higher in the sky
        azimuth: -175.57672,            // Direction of the sun
        turbidity: 13702,            // Clear sky with soft clouds
        luminance: 1000000.00,          // Brighter lighting
        vertexTint: [-100, -100, -100] // Cool blue tint (crystal morning)
    })

3. Alien Sky

api.setClientOption(myId, "skyBox", {
        type: "earth",           // Use realistic sky model
        inclination: 4.42,        // Sun higher in the sky
        azimuth: 1.52,            // Direction of the sun
        turbidity: -132,            // Clear sky with soft clouds
        luminance: 2.0,          // Brighter lighting
        vertexTint: [100000, 100, 100] // Cool blue tint (crystal morning)
    })

4. illusion Sky

api.setClientOption(myId, "skyBox", {
        type: "earth",           // Use realistic sky model
        inclination: 4.42,        // Sun higher in the sky
        azimuth: 1.52,            // Direction of the sun
        turbidity: 132,            // Clear sky with soft clouds
        luminance: 100.0,          // Brighter lighting
        vertexTint: [-10, -10, -10] // Cool blue tint (crystal morning)
    })

5. Double Theme sky

api.setClientOption(myId, "skyBox", {
        type: "earth",           // Use realistic sky model
        inclination:4.42434,        // Sun higher in the sky
        azimuth: 1.5542,            // Direction of the sun
        turbidity: 14352,            // Clear sky with soft clouds
        luminance: 2.0,          // Brighter lighting
        vertexTint: [-100000, -100, -10000] // Cool blue tint (crystal morning)
    })

6. Colourful Sky

api.setClientOption(myId, "skyBox", {
        type: "earth",           // Use realistic sky model
        inclination: 1.426,        // Sun higher in the sky
        azimuth: 6.52,            // Direction of the sun
        turbidity: 132,            // Clear sky with soft clouds
        luminance: 10000000.100,          // Brighter lighting
        vertexTint: [100000, 100, 100] // Cool blue tint (crystal morning)
    })

7. Crystal Morning Sky

api.setClientOption(myId, "skyBox", {
        type: "earth",           // Use realistic sky model
        inclination: 4.42,        // Sun higher in the sky
        azimuth: 4.52,            // Direction of the sun
        turbidity: 132,            // Clear sky with soft clouds
        luminance: 10000.0,          // Brighter lighting
        vertexTint: [-533336, 100, 100] // Cool blue tint (crystal morning)
    })

8. Black Crystal Sky

api.setClientOption(myId, "skyBox", {
        type: "earth",           // Use realistic sky model
        inclination: 4.42,        // Sun higher in the sky
        azimuth: 1.52,            // Direction of the sun
        turbidity: 1302,            // Clear sky with soft clouds
        luminance: 2.0,          // Brighter lighting
        vertexTint: [-10, -10, -10] // Cool blue tint (crystal morning)
    })

9. Normal Sky Code

api.setClientOptionToDefault(myId, "skyBox")




  1. Arthur Name Code
api.setTargetedPlayerSettingForEveryone(myId, "nameTagInfo", {
   content: [{str:"πŸ”§", style:{color:"#CEF3FF"}  }, {str: "Arthur", style: {color: "orange"}}],
   backgroundColor: "black",
}, true)

2. Custom Role Code 

api.setTargetedPlayerSettingForEveryone(myId, "nameTagInfo", {
    content: [{str:api.getEntityName(myId),style:{color:"white"}}],
    subtitle: [{str:"player",style:{color:"white"}}],
backgroundColor: "black",
}, true)

3. Bomber Code

function dCA(a,b){
return (Math.abs(a[0]-b[0]) + Math.abs(a[1]-b[1]) + Math.abs(a[2]-b[2]) )/3
}
function onPlayerThrowableHitTerrain(c,b,a){if(b=="Reinforced Pebble"){api.getPosition(a);api.setBlockRect([api.getPosition(a)[0]-3,api.getPosition(a)[1]+1,api.getPosition(a)[2]-3],[api.getPosition(a)[0]+3,api.getPosition(a)[1]-5,api.getPosition(a)[2]+3],"Air");for (let sg=0;sg<api.getPlayerIds().length;sg++){if (api.isInsideRect(api.getPosition(api.getPlayerIds()[sg]),[api.getPosition(a)[0]-6,api.getPosition(a)[1]+1,api.getPosition(a)[2]-6],[api.getPosition(a)[0]+6,api.getPosition(a)[1]-5,api.getPosition(a)[2]+6],false)){
try{
api.applyHealthChange(api.getPlayerIds()[sg],Math.round(-90 / dCA(api.getPosition(api.getPlayerIds()[sg]),api.getPosition(a))),{lifeformId:c,withItem:"Moonstone Explosive"},true)} catch(err){}}}
api.broadcastSound("cannonFire1",1,1);api.playParticleEffect({dir1: [0, 0, 0],dir2: [0, 0, 0],pos1: api.getPosition(a),pos2: api.getPosition(a),texture: "square_particle",minLifeTime: 0.13,maxLifeTime: 0.13,minEmitPower: 1,maxEmitPower: 1,minSize: 5,maxSize: 5,manualEmitCount: 1,gravity: [0, 0, 0],colorGradients: [{timeFraction: 0,minColor: [255, 0, 0, 1],maxColor: [255, 0, 0, 1]}],velocityGradients: [{timeFraction: 0,factor: 1,factor2: 1}],blendMode: 1},null);api.playParticleEffect({dir1: [0, 0, 0],dir2: [0, 0, 0],pos1: api.getPosition(a),pos2: api.getPosition(a),texture: "square_particle",minLifeTime: 0.13,maxLifeTime: 0.13,minEmitPower: 1,maxEmitPower: 1,minSize: 3.5,maxSize: 3.5,manualEmitCount: 1,gravity: [0, 0, 0],colorGradients: [{timeFraction: 0,minColor: [250, 100, 0, 1],maxColor: [250, 100, 0, 1]}],velocityGradients: [{timeFraction: 0,factor: 1,factor2: 1}],blendMode: 1},null);api.playParticleEffect({dir1: [0, 0, 0],dir2: [0, 0, 0],pos1: api.getPosition(a),pos2: api.getPosition(a),texture: "square_particle",minLifeTime: 0.13,maxLifeTime: 0.13,minEmitPower: 1,maxEmitPower: 1,minSize: 2.5,maxSize: 2.5,manualEmitCount: 1,gravity: [0, 0, 0],colorGradients: [{timeFraction: 0,minColor: [250, 250, 0, 1],maxColor: [250, 250, 0, 1]}],velocityGradients: [{timeFraction: 0,factor: 1,factor2: 1}],blendMode: 1},null)}}

 4. Arthur Chat Code

function onPlayerChat(id,msg){
let name = api.getEntityName(id)
if(name === "Itz_Pika_YT"){
        api.broadcastMessage([
{str:"[⚑SUPER]",style:{color:"yellow"}},
{str:"[πŸ”§Dev]",style:{color:"gray"}},
{str:"Slushie", style:{color:"orange"}},
{str:" "+msg, style:{color:"white"}},
])
return false;}}




Mob Taming Code :

const mobName = "Draugr Zombie"
const playerName = "Itz_Pika_YT"
const playerDbId = api.getPlayerDbId(api.getPlayerId(playerName))
let mobId = api.attemptSpawnMob(mobName, thisPos[0], thisPos[1], thisPos[2], {name: "My Pet"})
api.setMobSetting(mobId, "ownerDbId", playerDbId)



Amputation Shears Code :

//License has been moved to the Wall Of Shame
dicss=["TorsoNode", "HeadMesh", "ArmRightMesh", "ArmLeftMesh","LegLeftMesh", "LegRightMesh"]
scl={}
s=4
function onPlayerDamagingOtherPlayer(
    attackingPlayer,
    damagedPlayer,
    damageDealt,
    withItem,
    bodyPartHit,
    damagerDbId,
){
iddx=api.getSelectedInventorySlotI(attackingPlayer)
itm = api.getItemSlot(attackingPlayer,iddx)
if (itm.attributes.customDescription === "Attack to amputate other players!"){

if (bodyPartHit==="Torso"){
bodyPartHit="TorsoNode"
}else{
bodyPartHit+="Mesh"
scl[damagedPlayer][bodyPartHit]=[0,0,0]
api.scalePlayerMeshNodes(damagedPlayer, scl[damagedPlayer])
}


api.applyHealthChange(damagedPlayer, damageDealt)
}
}
function onPlayerJoin(id){
scl[id]={}
for (const dic of dicss){
scl[id][dic]=[1,1,1]
}
api.scalePlayerMeshNodes(id, scl[id])
api.setItemSlot(id, 0, "Artisan Shears", null, {customDescription: "Attack to amputate other players!", customDisplayName:"Amputation Shear"})
}





  1. Hunger Bar Code :
/*    Hunger System – v4.5  (Slowness + slower tick + reduced jump cost) */

const MAX_HUNGER       = 20;
const DECAY_EVERY_TICK = 60 * 60;     // once per 60 seconds β‡’ 20 min total
const JUMP_COST        = 0.1;         // reduced jump drain
const STARVE_THRESH    = 4;

const FOOD_VALUES = {
  "Steak": 8, "Cooked Pork chop": 8, "Cooked Mutton": 6,
  "Apple": 4, "Bread": 5,
  "Watermelon Slice": 2, "Melon Slice": 2,
  "Cooked Venison": 8,
  "Plum": 3, "Pear": 3, "Cracked Coconut": 5,
  "Bowl of Rice": 6, "Bowl of Cranberries": 4,
  "Chili Pepper": 2, "Corn": 3, "Cherry": 2,
  "Pumpkin Pie": 8,
};

/* ── shared state ─────────────────────────────── */
globalThis.data ??= {};   // { hunger, t, slow, pendingHungerGain }

function updatePlayerHunger(id, newH) {
  const d = data[id]; if (!d) return;

  d.hunger = Math.max(0, Math.min(MAX_HUNGER, newH));
  api.progressBarUpdate(id, d.hunger / MAX_HUNGER, 200);

  if (d.hunger <= STARVE_THRESH) {
    if (!d.slow) {
      api.applyEffect(id, "Slowness", null, {});
      d.slow = true;
    }
  } else if (d.slow) {
    api.removeEffect(id, "Slowness");
    d.slow = false;
  }
}

/* ── callbacks ─────────────────────────────── */
onPlayerJoin = id => {
  data[id] = { hunger: MAX_HUNGER, t: 0, slow: false };
  api.progressBarUpdate(id, 1, 0);
};

onPlayerLeave = id => delete data[id];

tick = () => {
  for (const id of api.getPlayerIds()) {
    const d = data[id]; if (!d) continue;

    if (d.pendingHungerGain) {
      updatePlayerHunger(id, d.hunger + d.pendingHungerGain);
      delete d.pendingHungerGain;
    }

    if (++d.t >= DECAY_EVERY_TICK) {
      d.t = 0;
      updatePlayerHunger(id, d.hunger - 1);
    }
  }
};

onPlayerJump = id => updatePlayerHunger(id, data[id].hunger - JUMP_COST);

onPlayerAttemptAltAction = id => {
  const held = api.getHeldItem(id);
  const gain = FOOD_VALUES[held?.name];
  if (!gain) return;

  const d = data[id];
  if (!d || d.hunger >= MAX_HUNGER) return;

  const slot = api.getSelectedInventorySlotI(id);
  const left = held.amount - 1;

  if (left <= 0) { api.setItemSlot(id, slot, "Air"); }
  else            { api.setItemSlot(id, slot, held.name, left); }

  d.pendingHungerGain = (d.pendingHungerGain || 0) + gain;
};







  1. bank generate code :
function createRandomBankAccount() {
    let requiredGold = 50; // Amount of Gold Coins to generate a bank
                           // *set to 0 for free generate* 
    let Items = "Gold Coin"; // item to buy the bank change it to any item that
                             // you want to buy with like Diamond for example




function getRandomCoordinates() {
    const x = Math.floor(Math.random() * 3000) - 3000;
    const y = 300;
    const z = Math.floor(Math.random() * 3000) - 3000;
    return [x, y, z];
  }

  function generatePassword(length = 10) {
    const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    return [...Array(length)].map(() =>
      chars.charAt(Math.floor(Math.random() * chars.length))
    ).join('');
  }


  let playerGold = api.getInventoryItemAmount(myId, Items);

  if (playerGold >= requiredGold) {
    let position;
    let isAir = false;

    while (!isAir) {
      position = getRandomCoordinates();
      isAir = api.getBlock(position) === 'Air';

      if (!isAir) {
        console.log("Position " + position.join(" ") + " is not Air. Trying again...");
      }
    }

    const password = generatePassword(10);

    api.setBlock(position, 'Chest');

    // Only remove coins after success
    api.removeItemName(myId, Items, requiredGold);

    api.giveItem(myId, "Book", 1, {
      customDisplayName: "Bank Account",
      customDescription: "To Access this Bank Account",
      customAttributes: {
        pages: [
          `Coordinates:\n${position.join(' ')}\n\nPassword:\n"${password}"\n\n*Do not share this\nor drop it, people\nmay access this bank\naccount*`
        ]
      }
    });

    api.giveStandardChestItem(position, "Book", 1, undefined, {
      customDisplayName: "Bank Account",
      customDescription: "Password Only",
      customAttributes: {
        pages: [password]
      }
    });

    for (let i = 0; i < 35; i++) {
      api.giveStandardChestItem(position, "Book", 1, undefined, {
        customDisplayName: `Bank Account Book ${i + 1}`,
        customDescription: `Bank Account Book ${i + 1} (Page 0: "0")`,
        customAttributes: {
          pages: ["0"]
        }
      });
    }

    console.log("Bank account created at:", position);
    return true;
  } else {
    let goldNeeded = requiredGold - playerGold;
    api.sendMessage(myId, `You need ${goldNeeded} more ` + Items + `s` + ` to create a bank account.`, { color: "red" });
    return false;
  }
}

createRandomBankAccount();



2. Deposit Code :

(function () {

    // === Configuration ===

    const DEPOSIT_ITEM_NAME = "Gold Coin"; /* Item name to deposit ( u can change

                                     change it to item u want to deposit

                                     */

    const DEPOSIT_AMOUNT = 50;             // Amount to deposit (change it if u want)


    const CHEST_BOOK_SLOT = 1; /*              Important!! if u do want to add

                                              more item to deposit or withdraw

                                              u have to make the number diffrent

                                              for each diffrent item names

                                              maximum is 1 - 36

                                           

*/






    const BOOK_SLOT = 0;                    // password bank book

    // === Logic ===

    let inventoryBook = api.getItemSlot(myId, BOOK_SLOT);


    if (inventoryBook?.name === "Book") {

        let page0 = inventoryBook.attributes?.customAttributes?.pages?.[0];


        if (page0 !== undefined) {

            let coordsStart = page0.indexOf("Coordinates:");

            let passwordStart = page0.indexOf("Password:");


            if (coordsStart !== -1 && passwordStart !== -1) {

                let coordsText = page0.substring(coordsStart + "Coordinates:".length, passwordStart).trim();

                let coordsArray = coordsText.split(/\s+/);


                let passwordLine = page0.substring(passwordStart);

                let quoteStart = passwordLine.indexOf('"');

                let quoteEnd = passwordLine.indexOf('"', quoteStart + 1);


                if (quoteStart !== -1 && quoteEnd !== -1 && coordsArray.length >= 3) {

                    let password = passwordLine.substring(quoteStart + 1, quoteEnd);

                    let x = parseInt(coordsArray[0]);

                    let y = parseInt(coordsArray[1]);

                    let z = parseInt(coordsArray[2]);


                    api.sendMessage(myId, `Found coordinates: ${x} ${y} ${z}`);

                    api.sendMessage(myId, `Password obtained.`);


                    if (y !== 300) {

                        api.sendMessage(myId, "Invalid height detected! Teleportation restricted to y=300 only.");

                    } else if (x > 3000 || x < -3000 || z > 3000 || z < -3000) {

                        api.sendMessage(myId, "Invalid coordinates! Teleportation restricted to x/z range of -3000 to 3000.");

                    } else {

                        if (api.isBlockInLoadedChunk(x, y, z)) {

                            const chestPos = [x, y, z];


                            try {

                                const chestItem = api.getStandardChestItemSlot(chestPos, 0);


                                if (chestItem?.attributes?.customAttributes) {

                                    const pages = chestItem.attributes.customAttributes.pages;


                                    if (Array.isArray(pages) && pages.length > 0) {

                                        const chestPage = pages[0];

                                        const lines = chestPage.split("\n");


                                        let chestPassword = null;

                                        for (const line of lines) {

                                            const trimmedLine = line.trim();

                                            if (trimmedLine && !trimmedLine.includes(" ")) {

                                                chestPassword = trimmedLine;

                                                break;

                                            }

                                        }


                                        if (!chestPassword) chestPassword = chestPage.trim();


                                        if (password === chestPassword) {

                                            api.sendMessage(myId, "Correct password!");


                                            const itemCount = api.getInventoryItemAmount(myId, DEPOSIT_ITEM_NAME);

                                            if (itemCount >= DEPOSIT_AMOUNT) {

                                                try {

                                                    const bookItem = api.getStandardChestItemSlot(chestPos, CHEST_BOOK_SLOT);

                                                    let currentNumber = 0;


                                                    if (bookItem?.attributes?.customAttributes?.pages?.[0]) {

                                                        const numberText = bookItem.attributes.customAttributes.pages[0].trim();

                                                        currentNumber = parseInt(numberText) || 0;

                                                    }


                                                    api.removeItemName(myId, DEPOSIT_ITEM_NAME, DEPOSIT_AMOUNT);

                                                    api.sendMessage(myId, `${DEPOSIT_AMOUNT} ${DEPOSIT_ITEM_NAME}(s) have been deducted from your inventory.`);


                                                    api.setStandardChestItemSlot(chestPos, CHEST_BOOK_SLOT, "Air", null, myId);


                                                    const newNumber = currentNumber + DEPOSIT_AMOUNT;

                                                    const newBookAttributes = {

                                                        customAttributes: {

                                                            pages: [String(newNumber)]

                                                        }

                                                    };


                                                    api.setStandardChestItemSlot(chestPos, CHEST_BOOK_SLOT, "Book", 1, myId, newBookAttributes);

                                                    api.sendMessage(myId, `Transaction successful! Your balance is now ${newNumber}.`);

                                                } catch (error) {

                                                    api.sendMessage(myId, "Error processing transaction: " + error);

                                                }

                                            } else {

                                                const shortage = DEPOSIT_AMOUNT - itemCount;

                                                api.sendMessage(myId, `You need ${shortage} more ${DEPOSIT_ITEM_NAME}${shortage !== 1 ? 's' : ''} to complete this transaction.`);

                                            }

                                        } else {

                                            api.sendMessage(myId, "Access denied: Incorrect password.");

                                        }

                                    } else {

                                        api.sendMessage(myId, "No pages found in chest book!");

                                    }

                                } else {

                                    api.sendMessage(myId, "Could not find book in chest!");

                                }

                            } catch (error) {

                                api.sendMessage(myId, "Error accessing chest: " + error);

                            }

                        } else {

                            try {

                                api.setBlock([x, y, z], 'Stone');

                                api.sendMessage(myId, "Loading Chunk.");

                                api.sendTopRightHelper(myId, "wrench", "The Chunk of the bank is being loaded. Please press the code again.", {

                                    duration: 7,

                                    width: 250,

                                    height: 80,

                                    color: "white",

                                    iconSizeMult: 2,

                                    fontSize: "14px"

                                });

                            } catch (error) {

                                api.sendMessage(myId, `Failed to teleport: ${error}. Please go to coordinates ${x} ${y} ${z} manually.`);

                            }

                        }

                    }

                }

            }

        }

    } else {

        api.sendMessage(myId, "Please make sure you put the bank account book on the correct slot.");

    }

})();



3. Withdraw Code:

(function() {

    let item = "Gold Coin" /* Item name to deposit ( u can change 

                                     change it to item u want to deposit

*/

    let number = 50; // Amount to deposit (change it if u want)


    let slotitem = 1; /* Important!! if u do want to add

                                              more item to deposit or withdraw

                                              u have to make the number diffrent

                                              for each diffrent item names

                                              maximum is 1 - 36


*/





    let slot = 0;

    let inventoryBook = api.getItemSlot(myId, slot);


    if (inventoryBook?.name === "Book") {

        let page0 = inventoryBook.attributes?.customAttributes?.pages?.[0];

        

        if (page0 !== undefined) {

            let coordsStart = page0.indexOf("Coordinates:");

            let passwordStart = page0.indexOf("Password:");

            

            if (coordsStart !== -1 && passwordStart !== -1) {

                let coordsText = page0.substring(coordsStart + "Coordinates:".length, passwordStart).trim();

                let coordsArray = coordsText.split(/\s+/);


                let passwordLine = page0.substring(passwordStart);

                let quoteStart = passwordLine.indexOf('"');

                let quoteEnd = passwordLine.indexOf('"', quoteStart + 1);


                if (quoteStart !== -1 && quoteEnd !== -1 && coordsArray.length >= 3) {

                    let password = passwordLine.substring(quoteStart + 1, quoteEnd);

                    let x = parseInt(coordsArray[0]);

                    let y = parseInt(coordsArray[1]);

                    let z = parseInt(coordsArray[2]);


                    api.sendMessage(myId, `Found coordinates: ${x} ${y} ${z}`);

                    api.sendMessage(myId, `Password obtained.`);


                    if (y !== 300) {

                        api.sendMessage(myId, "Invalid height detected! Teleportation restricted to y=300 only.");

                    } else if (x > 3000 || x < -3000 || z > 3000 || z < -3000) {

                        api.sendMessage(myId, "Invalid coordinates! Teleportation restricted to x/z range of -3000 to 3000.");

                    } else {

                        if (api.isBlockInLoadedChunk(x, y, z)) {

                            const chestPos = [x, y, z];

                            const chestSlot = 0;


                            try {

                                const chestItem = api.getStandardChestItemSlot(chestPos, chestSlot);


                                if (chestItem?.attributes?.customAttributes) {

                                    const pages = chestItem.attributes.customAttributes.pages;


                                    if (Array.isArray(pages) && pages.length > 0) {

                                        const chestPage = pages[0];


                                        if (chestPage) {

                                            const lines = chestPage.split("\n");

                                            let chestPassword = null;


                                            for (const line of lines) {

                                                const trimmedLine = line.trim();

                                                if (trimmedLine && !trimmedLine.includes(" ")) {

                                                    chestPassword = trimmedLine;

                                                    break;

                                                }

                                            }


                                            if (!chestPassword) {

                                                chestPassword = chestPage.trim();

                                            }


                                            if (password === chestPassword) {

                                                api.sendMessage(myId, "Correct password!");

                                                

                                                // Check if player has free inventory slots

                                                const freeSlots = api.getInventoryFreeSlotCount(myId);

                                                

                                                if (freeSlots > 0) {

                                                    // Get the current number from chest slot 1

                                                    try {

                                                        const bookItem = api.getStandardChestItemSlot(chestPos, slotitem);

                                                        let currentNumber = 0;

                                                        

                                                        if (bookItem?.attributes?.customAttributes?.pages?.[0]) {

                                                            const numberText = bookItem.attributes.customAttributes.pages[0].trim();

                                                            currentNumber = parseInt(numberText) || 0;

                                                        }

                                                        


                                                        if (currentNumber < number) {

                                                            api.sendMessage(myId, `Error: Your balance is ${currentNumber}. You need at least ` + number + ` to withdraw.`);

                                                            return;

                                                        }

                                                        

                                                        const newNumber = currentNumber - number;

                                                        

                                                        // Delete the book in slot 1

                                                        api.setStandardChestItemSlot(chestPos, slotitem, "Air", null, myId);

                                                        

                                                        // Create a new book with updated number

                                                        const newBookAttributes = {

                                                            customAttributes: {

                                                                pages: [String(newNumber)]

                                                            }

                                                        };

                                                        

                                                        api.setStandardChestItemSlot(chestPos, slotitem, "Book", 1, myId, newBookAttributes);

                                                        


                                                        api.giveItem(myId, item, number);

                                                        api.sendMessage(myId, number + " Gold Coins have been added to your inventory.");

                                                        api.sendMessage(myId, `Withdrawal successful! Your ${item}s balance is now ${newNumber}.`);

                                                        

                                                    } catch (error) {

                                                        api.sendMessage(myId, `Error processing withdrawal: ${error}`);

                                                    }

                                                } else {

                                                    api.sendMessage(myId, `Error: You need at least one free inventory slot to withdraw ${item}`);

                                                }

                                            } else {

                                                api.sendMessage(myId, "Access denied: Incorrect password.");

                                            }

                                        } else {

                                            api.sendMessage(myId, "Chest book page is empty!");

                                        }

                                    } else {

                                        api.sendMessage(myId, "No pages found in chest book!");

                                    }

                                } else {

                                    api.sendMessage(myId, "Could not find book in chest!");

                                }

                            } catch (error) {

                                api.sendMessage(myId, `Error accessing chest: ${error}`);

                            }

                        } else {

                            try {

                                api.setBlock([x, y, z], 'Stone');

                                api.sendMessage(myId, "Loading Chunk.");

                                api.sendTopRightHelper(myId, "wrench", "The Chunk of the bank is being loaded. Please press the code again.", { 

                                    duration: 7,

                                    width: 250,

                                    height: 80,

                                    color: "white",

                                    iconSizeMult: 2,

                                    fontSize: "14px"

                                });

                            } catch (error) {

                                api.sendMessage(myId, `Failed to teleport: ${error}. Please go to coordinates ${x} ${y} ${z} manually.`);

                            }

                        }

                    }

                }

            }

        }

    } else {

        api.sendMessage(myId, "Please make sure you put the bank account book on the first slot.");

    }

})();       





Night & Day cycle code :

let skySpeed = 100; let inclinationList = [ -0.6, -0.575, -0.55, -0.525, -0.5, -0.45, -0.4, -0.35, -0.3, -0.25, -0.2, -0.15, -0.05, 0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.475, 0.5 ]; let intervals = [ 15000, 15000, 15000, 15000, 15000, // night 15000, 15000, 15000, 15000, 15000, // dawn skySpeed / 10, skySpeed / 10, skySpeed / 10, skySpeed / 10, skySpeed / 10, // morning skySpeed / 10, skySpeed / 10, skySpeed / 10, skySpeed / 10, skySpeed / 10, // afternoon 15000, 15000, 15000, 15000, 15000 // sunset ]; let skyTime = 0; let skyIndex = 0; tick = (dt) => { skyTime += dt; while (skyTime >= intervals[skyIndex]) { skyTime -= intervals[skyIndex]; skyIndex++; if (skyIndex >= intervals.length - 1) { skyIndex = 0; skyTime = 0; } } let t = skyTime / intervals[skyIndex]; let startIncl = inclinationList[skyIndex]; let endIncl = inclinationList[skyIndex + 1]; let currentIncl = startIncl + (endIncl - startIncl) * t; api.getPlayerIds().forEach(id => { api.setClientOption(id, "skyBox", { type: "earth", inclination: currentIncl, turbidity: 1, luminance: 0.75, azimuth: 0, infiniteDistance: 3, vertexTint: [255, 255, 255], }); }); };






  1. Shield Code :

let times = {}

let sheild = false

let sheildUp = false


function onPlayerAttemptAltAction(playerId, x, y, z, block, targetEId){


let getitem = api.getHeldItem(playerId)

let time = Date.now()


    if (getitem?.name == "Pine Door" && sheild == false){

api.updateEntityNodeMeshAttachment(playerId, "TorsoNode", "BloxdBlock",{ blockName: "Pine Door", size: 0.7, meshOffset: [0, 0, 0] },[0.5, 0.2, 0], [0, 1.5, 0])

        api.applyEffect(playerId, "shed", null, {'displayName': "Sheild",'icon': "Pine Door"})

        api.removeItemName(playerId, "Pine Door", 1)}


if (api.getEffects(playerId)  == "shed"){

    times[playerId] = time

sheildUp = true

api.updateEntityNodeMeshAttachment(playerId, "TorsoNode", "BloxdBlock",{ blockName: "Pine Door", size: 0.7, meshOffset: [0, 0, 0] },[0.3, 0.3, 0.3], [0, 3.1, 0])

api.setClientOption(playerId, "speedMultiplier", 0.5)}

}



function tick(){

for (const [playerId, time] of Object.entries(times)) {

if(Date.now() - time > 300){

sheildUp = false

api.setClientOptionToDefault(playerId, "speedMultiplier")

api.updateEntityNodeMeshAttachment(playerId, "TorsoNode", "BloxdBlock",{ blockName: "Pine Door", size: 0.7, meshOffset: [0, 0, 0] },[0.5, 0.2, 0], [0, 1.5, 0])

delete times[playerId];

}

  }

}


function onPlayerDamagingOtherPlayer (attackingPlayer, damagedPlayer,damageDealt, withItem, bodyPartHit){

if (sheildUp == true){

if (withItem == "Diamond Axe"){

api.applyEffect(damagedPlayer, "stun", 5000, {'displayName': "Stunned", 'icon': "Cobweb"})}

else if (bodyPartHit == "Torso"){

return "preventDamage"}

else if (bodyPartHit == "LegLeft"){

return "preventDamage"}

else if (bodyPartHit == "ArmRight"){

return "preventDamage"}

else if (bodyPartHit == "ArmLeft"){

return "preventDamage"}

}

}











  1. Enderman Bow code :

function onPlayerThrowableHitTerrain (playerId, throwableName, thrownEntityId){

k = api.getPosition(thrownEntityId)

    api.setPosition (playerId, k)

}








Teleporting with Mobs Code :

let spawn = [159, 334, -298] let mobspawn1 = [spawn[0]-1, spawn[1], spawn[2]+1] let mobspawn = [spawn[0]+1, spawn[1]+2, spawn[2]-1] api.log(mobspawn) api.log(mobspawn1) let position = [spawn[0]+0.50, spawn[1], spawn[2]+0.50] var mobid var mob var coords var target function onPlayerJoin(playerId){ if (api.getEntitiesInRect(mobspawn1, mobspawn) == 0 ){ api.attemptSpawnMob("Draugr Zombie", position[0], position[1], position[2], {name:"Tp Spawn"}) } else {} } function onPlayerAttemptAltAction (playerId, x, y, z, block, targetEId){ target = targetEId if (targetEId == mobid){ api.setPosition(playerId, 148, 334, -286)} //tp else {} } function onMobDamagingPlayer (attackingMob){ return "preventDamage" } function onPlayerDamagingMob (playerId, mobId, damageDealt, withItem){ if (mobId == mobid){ return "preventDamage" } } function onWorldSpawnMob(mobId, mobType, x, y, z){ if (mobType == "Draugr Zombie"){ mobid = mobId mob = mobType coords = [x, y, z] api.setMobSetting(mobId,"baseWalkingSpeed", 0) api.setMobSetting(mobId,"baseRunningSpeed", 0) } } function tick(){ if (api.getEntityType(mobid) == "Draugr Zombie"){ if (coords == !position[0], position[1], position[2]){ api.setPosition(mobid, position[0], position[1], position[2])} } }







  1. Eye of ender and invis solid code :

api.giveItem(myId, "Moonstone", 12, {customDisplayName: "Eye of Ender", customDescription: "Track the end portal and enter the end"}) api.giveItem(myId, "Invisible Solid")


2. End Portal Code :

//by x_drxth and help from tim128 and Itz_Pika_YT



//phase thru

function onPlayerJoin (playerId){

api.sendTopRightHelper(playerId, "crown", "Subscribe to Pika Gaming 2!", {duration:       

5, height:85, width:300, color:"#bf0f02", iconSizeMult:1, textAndIconColor:

"#FFFFFF", fontSize:"18px"})

api.setWalkThroughType(playerId, "Invisible Solid")

api.setWalkThroughType(playerId, "Obby Absorb Block")

api.setCantChangeBlockRect(playerId, save, save2)

}


//end portal

function onPlayerAttemptAltAction(playerId, x, y, z, blockName, entityId){


if (blockName == "Yellowstone" && api.getHeldItem(playerId).attributes.customDisplayName == "Eye of Ender"){



let Slot = api.getSelectedInventorySlotI(playerId)


    if (api.getBlock(x, y+1, z) == "Green Carpet" && api.getHeldItem(playerId).attributes.customDisplayName == "Eye of Ender"){

     api.giveItem(playerId, "Moonstone", 1, {customDisplayName: "Eye of Ender", 

     customDescription: "Track the end portal and enter the end"})

}

   

   if (api.getHeldItem(playerId).attributes.customDisplayName == "Eye of Ender"){

      api.setBlock (x, y+1, z, "Green Carpet")

      api.playSound(playerId,"caveGolem1" ,1, 10)

      api.removeItemName(playerId, "Moonstone", 1)     

      api.broadcastSound("headshot_04", 1, 2)}

//check

if (api.getBlock(centerp[0]+2, centerp[1]+1, centerp[2])== "Green Carpet"&&

       api.getBlock(centerp[0]-2, centerp[1]+1, centerp[2])== "Green Carpet"&&

       api.getBlock(centerp[0], centerp[1]+1, centerp[2]+2)== "Green Carpet"&&

       api.getBlock(centerp[0], centerp[1]+1, centerp[2]-2)== "Green Carpet"&&

       api.getBlock(centerp[0]+1, centerp[1]+1, centerp[2]+2)== "Green Carpet"&&

       api.getBlock(centerp[0]+2, centerp[1]+1, centerp[2]-1)== "Green Carpet"&&

       api.getBlock(centerp[0]-1, centerp[1]+1, centerp[2]+2)== "Green Carpet"&&

       api.getBlock(centerp[0]+2, centerp[1]+1, centerp[2]-1)== "Green Carpet"&&

       api.getBlock(centerp[0]-2, centerp[1]+1, centerp[2]+1)== "Green Carpet"&&

       api.getBlock(centerp[0]+1, centerp[1]+1, centerp[2]-2)== "Green Carpet"&&

       api.getBlock(centerp[0]+2, centerp[1]+1, centerp[2]+1)== "Green Carpet"&&

       api.getBlock(centerp[0]-2, centerp[1]+1, centerp[2]-1)== "Green Carpet"&&

       api.getBlock(centerp[0]-1, centerp[1]+1, centerp[2]-2)== "Green Carpet"){

api.broadcastSound("ZombieGrunt3", 1, 1)

api.setClientOption(playerId, "canAltAction", true)


api.setBlock(centerp[0]+1, centerp[1], centerp[2]+1, "Obby Absorb Block")

     api.setBlock(centerp[0]+1, centerp[1], centerp[2]-1, "Obby Absorb Block")

     api.setBlock(centerp[0]-1, centerp[1], centerp[2]+1, "Obby Absorb Block")

     api.setBlock(centerp[0]-1, centerp[1], centerp[2]-1, "Obby Absorb Block")

     api.setBlock(centerp[0]+1, centerp[1], centerp[2], "Obby Absorb Block")

     api.setBlock(centerp[0]-1, centerp[1], centerp[2], "Obby Absorb Block")

     api.setBlock(centerp[0], centerp[1], centerp[2]+1, "Obby Absorb Block")

     api.setBlock(centerp[0], centerp[1], centerp[2]-1, "Obby Absorb Block")

     api.setBlock(centerp[0], centerp[1], centerp[2], "Obby Absorb Block")}

  }

}


//spawn end portal

function onPlayerChangeBlock(playerId, x, y, z, toBlock, fromBlock){

if(fromBlock == "Invisible Solid"){

    centerp = [x, y, z]

    corner1 = [x-1, y, z-1]

    corner2 = [x+1, y, z+1]

    cantchange1 = [x-2, y, z-2]

    cantchange2 = [x+2, y+1, z+2]

    save = cantchange1

    save2 = cantchange2

    api.setCantChangeBlockRect(playerId, cantchange1, cantchange2)


     api.setBlock(x+2, y, z, "Yellowstone")

     api.setBlock(x-2, y, z, "Yellowstone")

     api.setBlock(x, y, z+2, "Yellowstone")

     api.setBlock(x, y, z-2, "Yellowstone")

     api.setBlock(x+1, y, z+2, "Yellowstone")

     api.setBlock(x+2, y, z-1, "Yellowstone")

     api.setBlock(x-1, y, z+2, "Yellowstone")

     api.setBlock(x+2, y, z-1, "Yellowstone")

     api.setBlock(x-2, y, z+1, "Yellowstone")

     api.setBlock(x+1, y, z-2, "Yellowstone")

     api.setBlock(x+2, y, z+1, "Yellowstone")

     api.setBlock(x-2, y, z-1, "Yellowstone")

     api.setBlock(x-1, y, z-2, "Yellowstone")

  }

}     


//tp (by tim128)

function p(a){

return api.getBlock(api.getPosition(a)) == 'Obby Absorb Block'};

function tick(){

if(api.getPlayerIds().find(p) != undefined){

api.setPosition(api.getPlayerIds().find(p),[0,1,0])

   }

}



/*

tick onClose onPlayerJoin onPlayerLeave onPlayerJump onRespawnRequest

playerCommand onPlayerChat onPlayerChangeBlock onPlayerDropItem

onPlayerPickedUpItem onPlayerSelectInventorySlot onBlockStand

onPlayerAttemptCraft onPlayerCraft onPlayerAttemptOpenChest

onPlayerOpenedChest onPlayerMoveItemOutOfInventory onPlayerMoveInvenItem

onPlayerMoveItemIntoIdxs onPlayerSwapInvenSlots onPlayerMoveInvenItemWithAmt

onPlayerAttemptAltAction onPlayerAltAction onPlayerClick

onClientOptionUpdated onInventoryUpdated onChestUpdated onWorldChangeBlock

onCreateBloxdMeshEntity onEntityCollision onPlayerAttemptSpawnMob

onWorldAttemptSpawnMob onPlayerSpawnMob onWorldSpawnMob onMobDespawned

onPlayerAttack onPlayerDamagingOtherPlayer onPlayerDamagingMob

onMobDamagingPlayer onMobDamagingOtherMob onPlayerKilledOtherPlayer

onMobKilledPlayer onPlayerKilledMob onMobKilledOtherMob onPlayerPotionEffect

onPlayerDamagingMeshEntity onPlayerBreakMeshEntity onPlayerUsedThrowable

onPlayerThrowableHitTerrain onTouchscreenActionButton onTaskClaimed

onChunkLoaded onPlayerRequestChunk onItemDropCreated

onPlayerStartChargingItem onPlayerFinishChargingItem doPeriodicSave


To use a callback, just assign a function to it in the world code!

tick = () => {} or function tick() {}

*/











1.yellow Sky

api.getPlayerIds().forEach(pid=>api.setClientOption(pid,"skyBox",{ type: "earth", vertexTint:[255,255,0]}));


2.Red sky

api.getPlayerIds().forEach(pid=>api.setClientOption(pid,"skyBox",{ type: "earth", vertexTint:[255,0,0]})); 

3. Night time

api.getPlayerIds().forEach(pid=>api.setClientOption(pid,"skyBox",{ type: "earth",turbidity:-10000000})); 

4. Colorful Nametags

api.setEveryoneSettingForPlayer(myId, "nameColour", "red", true)  





































1.Spawn mob code :

api.attemptSpawnMob("Cow",20055.5, 34, 20324.5, {name:"Bob"})


2. Transform/Morph into Mob Code :

api.addFollowingEntityToPlayer(myId,"-2") api.setPlayerOpacity(myId,0)








































1.something bad happened screen message code :

const customEffectInfo = {

  icon: "Invisible_potion",

};

api.applyEffect(myId, "Invisible Boost II ", 600000000000000, customEffectInfo);


2. Minecart Code :

Currentdirection = 0;

Minecart = "Block of Diamond";

Rail = "Block of Iron";

let isPlayerOnCart = false;

let cartPosition = {};

let moveSpeed = 1;


function CartMove(playerId) {

    if (!cartPosition[playerId]) return;

    let [x, y, z] = cartPosition[playerId];

    api.setBlock(Math.floor(x), Math.floor(y), Math.floor(z), "Air");


    let nextX = x;

    let nextY = y;

    let nextZ = z;


    let canMove = false;

    let nextRailY = y - 1;


    if (Currentdirection === 5) {

        nextY += moveSpeed;

        nextRailY = y;

        if (api.getBlock(Math.floor(x), Math.floor(nextY), Math.floor(z)) === Rail) canMove = true;

    } else if (Currentdirection === 6) {

        nextY -= moveSpeed;

        if (api.getBlock(Math.floor(x), Math.floor(nextY - 1), Math.floor(z)) === Rail) canMove = true;

    } else if (Currentdirection === 1) {

        nextX += moveSpeed;

        if (api.getBlock(Math.floor(nextX), nextRailY, Math.floor(z)) === Rail) canMove = true;

    } else if (Currentdirection === 2) {

        nextZ += moveSpeed;

        if (api.getBlock(Math.floor(x), nextRailY, Math.floor(nextZ)) === Rail) canMove = true;

    } else if (Currentdirection === 3) {

        nextX -= moveSpeed;

        if (api.getBlock(Math.floor(nextX), nextRailY, Math.floor(z)) === Rail) canMove = true;

    } else if (Currentdirection === 4) {

        nextZ -= moveSpeed;

        if (api.getBlock(Math.floor(x), nextRailY, Math.floor(nextZ)) === Rail) canMove = true;

    }


    if (canMove) {

        api.setBlock(Math.floor(nextX), Math.floor(nextY), Math.floor(nextZ), Minecart);

        api.setPosition(playerId, nextX + 0.5, nextY + 1, nextZ + 0.5);

        cartPosition[playerId] = [nextX, nextY, nextZ];

       

        if (api.getBlock(Math.floor(nextX), Math.floor(nextY - 1), Math.floor(nextZ)) !== Rail && Currentdirection < 5) {

            Currentdirection = 0;

            isPlayerOnCart = false;

            delete cartPosition[playerId];

        } else if (api.getBlock(Math.floor(nextX), Math.floor(nextY), Math.floor(nextZ)) !== Rail && Currentdirection >= 5) {

            Currentdirection = 0;

            isPlayerOnCart = false;

            delete cartPosition[playerId];

        }

    } else {

        Currentdirection = 0;

        isPlayerOnCart = false;

        delete cartPosition[playerId];

    }

}


tick = (dt) => {

    for (const playerId in cartPosition) {

        if (isPlayerOnCart && Currentdirection !== 0) {

            CartMove(playerId);

        }

    }

};


onBlockStand = (playerId, x, y, z, blockName) => {

    blockBelow = api.getBlock(x, y - 1, z);

    if (blockName === Minecart && blockBelow === Rail && !isPlayerOnCart) {

        isPlayerOnCart = true;

        cartPosition[playerId] = [x, y, z];

        Currentdirection = findInitialDirection(playerId, x, y, z);

    } else if (isPlayerOnCart && blockName !== Minecart) {

        isPlayerOnCart = false;

        Currentdirection = 0;

        delete cartPosition[playerId];

    } else if (isPlayerOnCart && blockName === Minecart) {

        handleCornersAndVertical(playerId, x, y, z);

    }

};


function findInitialDirection(playerId, x, y, z) {

    if (api.getBlock(x + 1, y - 1, z) === Rail) return 1;

    if (api.getBlock(x, y - 1, z + 1) === Rail) return 2;

    if (api.getBlock(x - 1, y - 1, z) === Rail) return 3;

    if (api.getBlock(x, y - 1, z - 1) === Rail) return 4;

    if (api.getBlock(x, y + 1, z) === Rail) return 5;

    if (api.getBlock(x, y - 1, z) === Rail) return 6;

    return 0;

}


function checkRailWithOffset(x, y, z, offsetX, offsetY, offsetZ) {

    return api.getBlock(x + offsetX, y + offsetY, z + offsetZ) === Rail;

}


function handleCornersAndVertical(playerId, x, y, z) {

    if (Currentdirection === 1) {

        if (checkRailWithOffset(x, y - 1, z, 0, 0, 1)) Currentdirection = 2;

        else if (checkRailWithOffset(x, y - 1, z, 0, 0, -1)) Currentdirection = 4;

        else if (checkRailWithOffset(x, y - 1, z, 0, 1, 0)) Currentdirection = 5;

        else if (checkRailWithOffset(x, y - 1, z, 0, -1, 0)) Currentdirection = 6;

    } else if (Currentdirection === 2) {

        if (checkRailWithOffset(x, y - 1, z, 1, 0, 0)) Currentdirection = 1;

        else if (checkRailWithOffset(x, y - 1, z, -1, 0, 0)) Currentdirection = 3;

        else if (checkRailWithOffset(x, y - 1, z, 0, 1, 0)) Currentdirection = 5;

        else if (checkRailWithOffset(x, y - 1, z, 0, -1, 0)) Currentdirection = 6;

    } else if (Currentdirection === 3) {

        if (checkRailWithOffset(x, y - 1, z, 0, 0, 1)) Currentdirection = 2;

        else if (checkRailWithOffset(x, y - 1, z, 0, 0, -1)) Currentdirection = 4;

        else if (checkRailWithOffset(x, y - 1, z, 0, 1, 0)) Currentdirection = 5;

        else if (checkRailWithOffset(x, y - 1, z, 0, -1, 0)) Currentdirection = 6;

    } else if (Currentdirection === 4) {

        if (checkRailWithOffset(x, y - 1, z, 1, 0, 0)) Currentdirection = 1;

        else if (checkRailWithOffset(x, y - 1, z, -1, 0, 0)) Currentdirection = 3;

        else if (checkRailWithOffset(x, y - 1, z, 0, 1, 0)) Currentdirection = 5;

        else if (checkRailWithOffset(x, y - 1, z, 0, -1, 0)) Currentdirection = 6;

    } else if (Currentdirection === 5) {

        if (checkRailWithOffset(x, y + 1, z, 1, 0, 0)) Currentdirection = 1;

        else if (checkRailWithOffset(x, y + 1, z, -1, 0, 0)) Currentdirection = 3;

        else if (checkRailWithOffset(x, y + 1, z, 0, 0, 1)) Currentdirection = 2;

        else if (checkRailWithOffset(x, y + 1, z, 0, 0, -1)) Currentdirection = 4;

    } else if (Currentdirection === 6) {

        if (checkRailWithOffset(x, y - 1, z, 1, 0, 0)) Currentdirection = 1;

        else if (checkRailWithOffset(x, y - 1, z, -1, 0, 0)) Currentdirection = 3;

        else if (checkRailWithOffset(x, y - 1, z, 0, 0, 1)) Currentdirection = 2;

        else if (checkRailWithOffset(x, y - 1, z, 0, 0, -1)) Currentdirection = 4;

    } else {

       

        Currentdirection = findInitialDirection(playerId, x, y, z);

        if (Currentdirection === 0) {

         

            if (checkRailWithOffset(x, y - 1, z, 1, -1, 0)) Currentdirection = 1;

            else if (checkRailWithOffset(x, y - 1, z, -1, -1, 0)) Currentdirection = 3;

            else if (checkRailWithOffset(x, y - 1, z, 0, -1, 1)) Currentdirection = 2;

            else if (checkRailWithOffset(x, y - 1, z, 0, -1, -1)) Currentdirection = 4;

            else if (checkRailWithOffset(x, y + 1, z, 1, 1, 0)) Currentdirection = 1;

            else if (checkRailWithOffset(x, y + 1, z, -1, 1, 0)) Currentdirection = 3;

            else if (checkRailWithOffset(x, y + 1, z, 0, 1, 1)) Currentdirection = 2;

            else if (checkRailWithOffset(x, y + 1, z, 0, 1, -1)) Currentdirection = 4;

            else if (checkRailWithOffset(x, y - 1, z, 0, -1, 0)) Currentdirection = 6;

            else if (checkRailWithOffset(x, y + 1, z, 0, 1, 0)) Currentdirection = 5;

        }

    }

};


onPlayerJoin = (playerId) => {

api.editItemCraftingRecipes(playerId, Minecart,

[{requires:[{items:["Stick"],amt: 1}],

produces: 2,

station:"Workbench"}])

}




















































Admin commands code :

onPlayerChat = (id, msg) => {

    // Only process commands that start with !

    if (!msg.startsWith('!')) {

        // Regular chat message, not a command - don't log it

        return;

    }


    const allowedUsers = ["Stop_Da_Auto_K1ng", "Itz_Pika_YT"]; /* Change it to ur Username or people that u want to be allowed to use

the command */


    const executorName = api.getEntityName(id);


    if (!allowedUsers.includes(executorName)) {

        api.sendMessage(id, "You are not allowed to use this command.", { color: "red" });

        return;

    }


    const lowerMsg = msg.toLowerCase();

    const args = msg.split(" "); // Keep original casing for item names

    const lowerCommand = args[0].toLowerCase();


    // Command List (case-insensitive)

    if (["!cmds", "!commands", "!command"].includes(lowerCommand)) {

        const commandList = `

Available Commands:

- !tp / !teleport <player>: Teleport to a specific player

- !kill <all/others/player>: Kill players

  * !kill all: Kill everyone

  * !kill others: Kill all except yourself

  * !kill <player>: Kill specific player

- !forcerespawn / !respawn <all/others/player>: Respawn players

  * !forcerespawn all: Respawn everyone

  * !forcerespawn others: Respawn all except yourself

  * !forcerespawn <player>: Respawn specific player

- !giveitem <all/others/player>: Give items to players

  * !giveitem all <item> <amount>: Give item to everyone

  * !giveitem others <item> <amount>: Give item to all except yourself

  * !giveitem <player> <item> <amount>: Give item to specific player

- !health / !hp / !sethp <all/others/player> <amount>: Set player health

  * !health all 100: Set everyone's health

  * !health others 100: Set others' health

  * !health <player> 100: Set specific player's health

- !bring <all/player>: Bring players to your location

  * !bring all: Bring everyone

  * !bring <player>: Bring specific player


Tips:

- Use partial names (e.g., !tp dra)

- If multiple players match, a list will be shown

        `;

       

        api.sendMessage(id, commandList, { color: "aqua" });

        // Log valid command usage

        console.log(`[COMMAND] ${executorName} used: ${msg}`);

        return;

    }


    // List of valid commands with their alternatives

    const validCommands = {

        "!tp": ["!teleport"],

        "!kill": [],

        "!forcerespawn": ["!respawn"],

        "!health": ["!hp", "!sethp"],

        "!giveitem": [],

        "!bring": []

    };


    // Check if the command starts with ! but is not a valid command

    const isValidCommand = Object.keys(validCommands).some(cmd =>

        lowerCommand === cmd || validCommands[cmd].includes(lowerCommand)

    );


    if (!isValidCommand) {

        // Find similar commands

        const similarCommands = Object.entries(validCommands).filter(([cmd, alts]) =>

            cmd.includes(lowerCommand.slice(1)) ||

            alts.some(alt => alt.includes(lowerCommand.slice(1)))

        );


        let errorMessage = `Unknown command "${args[0]}". Type !cmds to see available commands.`;

       

        if (similarCommands.length > 0) {

            errorMessage += "\n\nDid you mean:";

            similarCommands.forEach(([cmd, alts]) => {

                errorMessage += `\n- ${cmd}${alts.length > 0 ? ` (alternatives: ${alts.join(", ")})` : ''}`;

            });

        }


        api.sendMessage(id, errorMessage, { color: "red" });

        console.log(`[UNKNOWN COMMAND] ${executorName} attempted: ${msg}`);

        return;

    }


    // Normalize the command to its primary form

    const primaryCommand = Object.entries(validCommands).reduce((acc, [cmd, alts]) => {

        return lowerCommand === cmd || alts.includes(lowerCommand) ? cmd : acc;

    }, lowerCommand);


    // Logging system for valid command usage

    console.log(`[COMMAND] ${executorName} used: ${msg}`);


    // Helper function to find player ID by partial name

    const findPlayerIdByPartialName = (partialName) => {

        const lowerPartialName = partialName.toLowerCase();

        const matchedPlayers = api.getPlayerIds().filter(playerId =>

            api.getEntityName(playerId).toLowerCase().includes(lowerPartialName)

        );


        if (matchedPlayers.length === 0) {

            return null;

        }


        if (matchedPlayers.length > 1) {

            return {

                error: true,

                matches: matchedPlayers.map(pId => api.getEntityName(pId))

            };

        }


        return matchedPlayers[0];

    };


    // Teleport to Player Command

    if (primaryCommand === "!tp") {

        if (args.length < 2) {

            api.sendMessage(id, "Usage: !tp <player>", { color: "red" });

            return;

        }


        const targetName = args.slice(1).join(" ");

        const targetResult = findPlayerIdByPartialName(targetName);


        if (targetResult === null) {

            api.sendMessage(id, `No player found matching "${targetName}".`, { color: "red" });

            return;

        }


        if (targetResult.error) {

            api.sendMessage(id, `Multiple players found matching "${targetName}":

${targetResult.matches.join(", ")}`, { color: "red" });

            return;

        }


        const targetPos = api.getPosition(targetResult);

        api.setPosition(id, ...targetPos);

        api.sendMessage(id, `Teleported to ${api.getEntityName(targetResult)}.`, { color: "lime" });

    }


    // Kill Command

    if (primaryCommand === "!kill") {

        if (args.length === 1 || args[1].toLowerCase() === "all") {

            // Kill all

            for (const playerId of api.getPlayerIds()) {

                api.setHealth(playerId, 0, undefined, true);

                api.sendMessage(playerId, `You got killed by ${executorName}.`, { color: "red" });


                if (playerId !== id) {

                    api.sendMessage(id, `You killed: ${api.getEntityName(playerId)}.`, { color: "lime" });

                }

            }

        } else if (args[1].toLowerCase() === "others") {

            // Kill others

            for (const playerId of api.getPlayerIds()) {

                if (playerId !== id) {

                    api.setHealth(playerId, 0, undefined, true);

                    api.sendMessage(playerId, `You got killed by ${executorName}.`, { color: "red" });

                    api.sendMessage(id, `You killed: ${api.getEntityName(playerId)}.`, { color: "lime" });

                }

            }

        } else {

            // Kill specific player

            const targetName = args.slice(1).join(" ");

            const targetResult = findPlayerIdByPartialName(targetName);

           

            if (targetResult === null) {

                api.sendMessage(id, `No player found matching "${targetName}".`, { color: "red" });

                return;

            }


            if (targetResult.error) {

                api.sendMessage(id, `Multiple players found matching "${targetName}":

${targetResult.matches.join(", ")}`, { color: "red" });

                return;

            }


            api.setHealth(targetResult, 0, undefined, true);

            api.sendMessage(targetResult, `You got killed by ${executorName}.`, { color: "red" });

            api.sendMessage(id, `You killed: ${api.getEntityName(targetResult)}.`, { color: "lime" });

        }

    }


    // Force Respawn Command

    if (primaryCommand === "!forcerespawn") {

        if (args.length === 1 || args[1].toLowerCase() === "all") {

            // Respawn all

            for (const playerId of api.getPlayerIds()) {

                api.forceRespawn(playerId);

            }

            api.sendMessage(id, "You have respawned all players.", { color: "lime" });

        } else if (args[1].toLowerCase() === "others") {

            // Respawn others

            for (const playerId of api.getPlayerIds()) {

                if (playerId !== id) {

                    api.forceRespawn(playerId);

                }

            }

            api.sendMessage(id, "You have respawned all players except yourself.", { color: "lime" });

        } else {

            // Respawn specific player

            const targetName = args.slice(1).join(" ");

            const targetResult = findPlayerIdByPartialName(targetName);

           

            if (targetResult === null) {

                api.sendMessage(id, `No player found matching "${targetName}".`, { color: "red" });

                return;

            }


            if (targetResult.error) {

                api.sendMessage(id, `Multiple players found matching "${targetName}":

${targetResult.matches.join(", ")}`, { color: "red" });

                return;

            }


            api.forceRespawn(targetResult);

            api.sendMessage(id, `You have respawned: ${api.getEntityName(targetResult)}.`, { color: "lime" });

        }

    }


    // Set Health Command

    if (primaryCommand === "!health") {

        const healthAmount = parseInt(args[args.length - 1]);


        if (!isNaN(healthAmount) && healthAmount > 0 && healthAmount.toString().length <= 10) {

            if (args.length === 2 && (args[1].toLowerCase() === "all" || args[1].toLowerCase() === "others")) {

                // Set health for all or others

                const targetPlayers = args[1].toLowerCase() === "all"

                    ? api.getPlayerIds()

                    : api.getPlayerIds().filter(playerId => playerId !== id);


                for (const playerId of targetPlayers) {

                    api.setHealth(playerId, healthAmount, undefined, true);

                    api.sendMessage(playerId, `Your health has been set to ${healthAmount}.`, { color: "lime" });

                }

                api.sendMessage(id, `Health set to ${healthAmount} for ${args[1].toLowerCase()} players.`, { color: "lime" });

            } else if (args.length > 2) {

                // Set health for specific player

                const targetName = args.slice(1, -1).join(" ");

                const targetResult = findPlayerIdByPartialName(targetName);

               

                if (targetResult === null) {

                    api.sendMessage(id, `No player found matching "${targetName}".`, { color: "red" });

                    return;

                }


                if (targetResult.error) {

                    api.sendMessage(id, `Multiple players found matching "${targetName}":

${targetResult.matches.join(", ")}`, { color: "red" });

                    return;

                }


                api.setHealth(targetResult, healthAmount, undefined, true);

                api.sendMessage(targetResult, `Your health has been set to ${healthAmount}.`, { color: "lime" });

                api.sendMessage(id, `Health set to ${healthAmount} for ${api.getEntityName(targetResult)}.`, { color: "lime" });

            } else {

                // Set health for self

                api.setHealth(id, healthAmount, undefined, true);

                api.sendMessage(id, `Your health has been set to ${healthAmount}.`, { color: "lime" });

            }

        } else {

            api.sendMessage(id, "Invalid health value. Please enter a positive number (max 10 digits).", { color: "red" });

        }

    }


    // Give Item Command

    if (primaryCommand === "!giveitem") {

        if (args.length < 4) {

            api.sendMessage(id, "Usage: !giveitem <player> <item name> <amount>", { color: "red" });

            return;

        }


        const itemAmount = parseInt(args[args.length - 1]);

        const itemName = args.slice(2, -1).join(" ");

        const targetName = args[1];

        const maxStackSize = 999;


        const targetResult = findPlayerIdByPartialName(targetName);

       

        if (targetResult === null) {

            api.sendMessage(id, `No player found matching "${targetName}".`, { color: "red" });

            return;

        }


        if (targetResult.error) {

            api.sendMessage(id, `Multiple players found matching "${targetName}":

${targetResult.matches.join(", ")}`, { color: "red" });

            return;

        }


        if (!isNaN(itemAmount) && itemAmount > 0) {

            const freeSlots = api.getInventoryFreeSlotCount(targetResult);

            let stacksNeeded = Math.ceil(itemAmount / maxStackSize);


            if (stacksNeeded <= freeSlots) {

                for (let i = 0; i < stacksNeeded; i++) {

                    let amountToGive = i === stacksNeeded - 1 ? itemAmount % maxStackSize || maxStackSize : maxStackSize;

                    api.giveItem(targetResult, itemName, amountToGive);

                }

                api.sendMessage(id, `Gave ${itemAmount}x ${itemName} to ${api.getEntityName(targetResult)}.`, { color: "lime" });

                api.sendMessage(targetResult, `You received ${itemAmount}x ${itemName} from ${executorName}.`, { color: "lime" });

            } else {

                api.sendMessage(id, `Not enough inventory space for ${api.getEntityName(targetResult)}! They need ${stacksNeeded - freeSlots} more empty slots.`, { color: "red" });

            }

        } else {

            api.sendMessage(id, "Invalid item amount. Please enter a valid number.", { color: "red" });

        }

    }


    // Bring Command

    if (primaryCommand === "!bring") {

        if (args.length < 2) {

            api.sendMessage(id, "Usage: !bring <player>", { color: "red" });

            return;

        }


        const executorPos = api.getPosition(id);


        if (args[1].toLowerCase() === "all") {

            // Bring ALL players to the executor (except the executor)

            for (const playerId of api.getPlayerIds()) {

                if (playerId !== id) {

                    api.setPosition(playerId, ...executorPos);

                    api.sendMessage(playerId, `You have been teleported to ${executorName}.`, { color: "lime" });

                }

            }

            api.sendMessage(id, "You have teleported all players to your location.", { color: "lime" });

            return;

        }


        const targetName = args.slice(1).join(" ");

        const targetResult = findPlayerIdByPartialName(targetName);


        if (targetResult === null) {

            api.sendMessage(id, `No player found matching "${targetName}".`, { color: "red" });

            return;

        }


        if (targetResult.error) {

            api.sendMessage(id, `Multiple players found matching "${targetName}":

${targetResult.matches.join(", ")}`, { color: "red" });

            return;

        }


        api.setPosition(targetResult, ...executorPos);

        api.sendMessage(targetResult, `You have been teleported to ${executorName}.`, { color: "lime" });

        api.sendMessage(id, `You teleported ${api.getEntityName(targetResult)} to your location.`, { color: "lime" });

    }

};

 



















    Here are new codes of today :

  1. Poison Gas code :

let get_distance=([a,b,c],[x,y,z])=>{

    return Math.sqrt( (a-x)*(a-x) + (b-y)*(b-y) + (c-z)*(c-z) );

}


tick=()=>{

    let players = api.getPlayerIds();

    if(players.length===0)return;

    let pid = players[Math.floor(players.length*Math.random())];

    let p2id = players[Math.floor(players.length*Math.random())];

    if(pid!==p2id && get_distance(api.getPosition(pid), api.getPosition(p2id))<5 && api.getHeldItem(p2id)?.name!=="Allium" && !api.getEffects(p2id).includes("Poisoned"))api.applyEffect(p2id, "Poisoned", 5000, {inbuiltLevel:1});}

   


function onBlockStand(playerId, x, y, z, block, targetEId) {

  const heldItem = api.getHeldItem(playerId);

  const pos = api.getPosition(playerId);

  if (!heldItem) return;


  if (heldItem.name === "Allium") {

   

   


    api.playParticleEffect({

      texture: "effect_5",

      minLifeTime: 0.2,

      maxLifeTime: 0.6,

      minEmitPower: 2,

      maxEmitPower: 2,

      minSize: 0.25,

      maxSize: 0.35,

      gravity: [0, -10, 0],

      velocityGradients: [{ timeFraction: 0, factor: 1, factor2: 1 }],

      colorGradients: [{

        timeFraction: 0,

        minColor: [2, 245, 2, 1],

        maxColor: [2, 255, 0, 1],

      }],

      blendMode: 1,

      dir1: [-12, 0, -12],

      dir2: [12, 0, 12],

      pos1: [pos[0], pos[1] + 1, pos[2]],

      pos2: [pos[0] + 1, pos[1] + 1, pos[2] + 1],

      manualEmitCount: 20,

    });

  }}



2. Landmine Code :

let landmines = []; onPlayerChangeBlock = (playerId, x, y, z, fromBlock, toBlock) => { if (toBlock === "Block of Iron") { //api.log(`Landmine armed at [${x}, ${y}, ${z}] by player ${playerId}`); landmines.push([x, y, z]); // Store the mine position api.setBlock(x, y, z, "Air"); api.sendMessage(playerId, "Mine in place.", { color: "red" }) } }; // Check for landmine explosion on each tick tick = (dt) => { let len = landmines.length; for (let i = 0; i < len; i++) { const [lx, ly, lz] = landmines[i]; api.getPlayerIds().forEach((playerId) => { const playerPosRaw = api.getPosition(playerId); const playerPos = [ Math.floor(playerPosRaw[0]), Math.floor(playerPosRaw[1]), Math.floor(playerPosRaw[2]) ]; // Check if the player is within 3 blocks above the landmine if ( playerPos[0] === lx && playerPos[1] >= ly && playerPos[1] <= ly + 3 && playerPos[2] === lz ) { api.setBlock(lx, ly, lz, "Air"); api.broadcastSound("beep",1,4,{ playerIdOrPos: playerId, maxHearDist: 15 }); api.broadcastSound("cannonFire2",1,1,{ playerIdOrPos: playerId, maxHearDist: 45 }); api.playParticleEffect({ dir1: [1, 1, -1], dir2: [-1, 1, 1], dir3: [1, 1, 1], dir4: [-1, 1, -1], pos1: [lx, ly, lz], pos2: [lx+1, ly, lz+1], texture: "square_particle", minLifeTime: .5, maxLifeTime: 3, minEmitPower: 1, maxEmitPower: 5, minSize: 0.1, maxSize: .25, manualEmitCount: 512, gravity: [0, 0, 0], colorGradients: [ { timeFraction: 10, minColor: [256, 85, 1, .8], maxColor: [0, 0, 0, .3], }, ], velocityGradients: [ { timeFraction: .1000, factor: 5, factor2: .10000, }, ], blendMode: 0, }); api.playParticleEffect({ dir1: [1, 1, -1], dir2: [-1, 1, 1], dir3: [1, 1, 1], dir4: [-1, 1, -1], pos1: [lx, ly, lz], pos2: [lx+1, ly+4, lz+1], texture: "square_particle", minLifeTime: 1, maxLifeTime: 8, minEmitPower: 1, maxEmitPower: 5, minSize: 0.1, maxSize: .25, manualEmitCount: 1024, gravity: [0, 0, 0], colorGradients: [ { timeFraction: 10, minColor: [50, 50, 50, .8], maxColor: [0, 0, 0, .3], }, ], velocityGradients: [ { timeFraction: 10, factor: 5, factor2: 10, }, ], blendMode: 1, }); // Damage api.attemptApplyDamage({ eId: playerId, hitEId: playerId, attemptedDmgAmt: 10000, withItem: "Block of Iron", attackDir: [(Math.random()*2)-(Math.random()*2), 15, (Math.random()*2)-(Math.random()*2)], showCritParticles: true, reduceVerticalKbVelocity: false, }); // Cleanup landmines.splice(i, 1); api.setBlock(lx, ly, lz, "Air"); const r = 3; for (let dx = -r; dx <= r; dx++) { for (let dy = -r; dy <= 4; dy++) { // extends upward for (let dz = -r; dz <= r; dz++) { const dist = Math.sqrt(dx * dx + dy * dy + dz * dz); if (dist <= r || (dy > 0 && dist <= r + 1)) { api.setBlock(lx + dx, ly + dy, lz + dz, "Air"); } } } } //api.log(`Landmine at [${lx}, ${ly}, ${lz}] exploded!`); return; // Exit early after explosion } }); } };