Code OF TP PORTAL

 //make by The_Bloxd_Pro___

const PORTAL_DEST = [-925, 119, 20.56];



const PORTAL_BLOCK = "Black Portal";



const TELEPORT_COOLDOWN = 2000;

let lastTeleport = {};



tick = () => {

  const now = api.now();


  

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

  

    if (lastTeleport[playerId] && now - lastTeleport[playerId] < TELEPORT_COOLDOWN) {

      continue;

    }


    // Get the player's position

    const pos = api.getPosition(playerId);

    if (!pos) continue;


    // Get the block the player is currently touching (at body height)

    const blockAt = api.getBlock(Math.floor(pos[0]), Math.floor(pos[1]), Math.floor(pos[2]));


    // Also check head and feet blocks for better detection

    const blockAtFeet = api.getBlock(Math.floor(pos[0]), Math.floor(pos[1] - 1), Math.floor(pos[2]));

    const blockAtHead = api.getBlock(Math.floor(pos[0]), Math.floor(pos[1] + 1), Math.floor(pos[2]));


    // If player is touching the portal block anywhere

    if (blockAt === PORTAL_BLOCK || blockAtFeet === PORTAL_BLOCK || blockAtHead === PORTAL_BLOCK) {

      // Teleport player

      api.setPosition(playerId, PORTAL_DEST[0], PORTAL_DEST[1], PORTAL_DEST[2]);

      api.playSoundAtEntity(playerId, "portal_travel");

      api.playParticleEffect({

        pos1: pos,

        pos2: pos,

        texture: "portal",

        minLifeTime: 1,

        maxLifeTime: 2,

        manualEmitCount: 50,

        colorGradients: [{ timeFraction: 0, minColor: [80, 0, 255, 1], maxColor: [255, 0, 255, 1] }],

      });

      api.sendMessage(playerId, "🌀 You touched the portal and were teleported!", { color: "purple" });


      lastTeleport[playerId] = now;

    }

  }

};

Comments

Popular posts from this blog

APIs that work in code block on bloxd io

Api For Bloxd Look Company to Bloxd io ( Arthur , Tom , Slushie , Oliver , Dirty_Flea_sack , Pixel Baker , Another thing this is 100% functional in Bloxd io