Frost Walker

World Code

Tags:

None

Creator:

blox_duo_pro

Code:


/* --- CREATIVE STARTUP ANNOUNCEMENT --- */
api.broadcastMessage("❄️ --- FROST WALKER MOD LOADED --- ❄️", { color: "yellow", fontWeight: "bold" });
api.broadcastMessage("Type !frost walker in chat to get your special boots!", { color: "aqua" });
api.broadcastMessage("⚠️ Note: You must HOLD the boots in your hand to freeze water.", { color: "white" });

/* --- GLOBAL DATA --- */
frostIceList = [];

onPlayerChat = (pId, msg) => {
    if (msg === "!frost walker") {
        api.giveItem(pId, "Diamond Boots", 1, { customDisplayName: "Frost Walker" });
        api.sendMessage(pId, "✨ Frost Walker Boots received!", { color: "yellow" });
        return false;
    }
    return true;
};

tick = (ms) => {
    var now = Date.now();
    var players = api.getPlayerIds();

    for (var i = 0; i < players.length; i++) {
        var pId = players[i];
        if (!api.checkValid(pId)) continue;

        var held = api.getHeldItem(pId);
        if (held && held.attributes && held.attributes.customDisplayName === "Frost Walker") {
            
            var pPos = api.getPosition(pId);
            var vel = api.getVelocity(pId); 
            if (!pPos || !vel) continue;

            var centerX = Math.floor(pPos[0] + (vel[0] * 0.2));
            var centerZ = Math.floor(pPos[2] + (vel[2] * 0.2));
            var startY = Math.floor(pPos[1]);

            var scanDepth = 6;
            if (vel[1] < -1) { scanDepth = 15; }

            var lockedY = null;
            for (var d = 0; d <= scanDepth; d++) {
                var testY = startY - d;
                var block = api.getBlock(centerX, testY, centerZ);
                
                if (block === "Water") {
                    lockedY = testY;
                    break; 
                }
                if (block === "Ice") {
                    lockedY = testY;
                    break;
                }
            }

            if (lockedY !== null) {
                for (var ox = -2; ox <= 2; ox++) {
                    for (var oz = -2; oz <= 2; oz++) {
                        var tx = centerX + ox;
                        var tz = centerZ + oz;

                        if (api.getBlock(tx, lockedY, tz) === "Water") {
                            api.setBlock(tx, lockedY, tz, "Ice");
                            frostIceList.push({ x: tx, y: lockedY, z: tz, meltTime: now + 3000 });
                        }
                    }
                }

                if (pPos[1] < lockedY + 1.8 && vel[1] < 0) {
                    api.setVelocity(pId, vel[0], 0, vel[2]);
                }
            }
        }
    }

    for (var j = frostIceList.length - 1; j >= 0; j--) {
        var ice = frostIceList[j];
        if (now >= ice.meltTime) {
            var playerStillThereAndHolding = false;

            for (var k = 0; k < players.length; k++) {
                var pId2 = players[k];
                var pPos2 = api.getPosition(pId2);
                var held2 = api.getHeldItem(pId2);
                if (!pPos2) continue;

                var dx = Math.abs(pPos2[0] - ice.x);
                var dz = Math.abs(pPos2[2] - ice.z);
                var dy = Math.abs(pPos2[1] - (ice.y + 1));

                if (dx <= 2.8 && dz <= 2.8 && dy < 1.5) {
                    if (held2 && held2.attributes && held2.attributes.customDisplayName === "Frost Walker") {
                        playerStillThereAndHolding = true;
                        break;
                    }
                }
            }

            if (playerStillThereAndHolding) {
                ice.meltTime = now + 1000;
            } else {
                if (api.getBlock(ice.x, ice.y, ice.z) === "Ice") {
                    api.setBlock(ice.x, ice.y, ice.z, "Water");
                }
                frostIceList.splice(j, 1);
            }
        }
    }
};

Instructions:

u dont need diamond boots u need to type !frost walker plz enjoy i didnt had a good photo so i added this