#⚒ My ideas in the comments lol ⚒ (Molang Map,Custom Portal ect)

1 messages · Page 1 of 1 (latest)

shadow garden
#

** idea to spin clicks per second with a kick if it exceeds them, poorly optimized and rather poorly built**

const RESET_TIME = 1000
const CPS_LIMIT = 15;
const playerClicks = new Map();

world.afterEvents.entityHitEntity.subscribe(event => {
  const player = event.damagingEntity;
  if (!(player instanceof Player)) return;
  const playerName = player.name;
  const now = Date.now();
  const clickData = playerClicks.get(playerName) || { lastClickTime: now, clicks: 0 };
  const timeDiff = now - clickData.lastClickTime;
  if (timeDiff < RESET_TIME) {
    clickData.clicks++;
  } else {
    clickData.clicks = 1;
    clickData.lastClickTime = now;
  }
  if (clickData.clicks > CPS_LIMIT) {
    player.runCommand(`kick ${playerName} Auto-clicker détecté ${clickData.clicks}`);
    playerClicks.delete(playerName);
    return;
  }
  playerClicks.set(playerName, clickData);
});```
#

checkCooldown exemple

const lastCommandUse = new Map();
export function checkCooldown(joueur, command, cooldown) {
    const now = Date.now();
    const lastUse = lastCommandUse.get(`${joueur.nameTag}-${command}`) || 0;

    if (now - lastUse < cooldown) {
        const timeLeft = ((cooldown - (now - lastUse)) / 1000).toFixed(1);
        joueur.sendMessage(`§cVous devez attendre encore ${timeLeft} secondes avant de pouvoir utiliser cette commande à nouveau.`);
        return false;
    }
    lastCommandUse.set(`${joueur.nameTag}-${command}`, now);
    return true;
}

   if (!checkCooldown(Player, 'Jackie', 10000)) return;

Total Clear Test

export function clear(joueur) {
    const inventory = joueur.getComponent('minecraft:inventory').container;
    inventory.clearAll();
    const equippableComp = joueur.getComponent("equippable");
    const equipmentSlots = ["Chest", "Feet", "Head", "Legs", "Offhand"];
    equipmentSlots.forEach(slot => {
        const item = equippableComp.getEquipment(slot);
        if (item) {
            equippableComp.setEquipment(slot, null);
        }
    });
}
#

** MolangVariableMap color**

⚒️😶‍🌫️
A quick explanation of the colors I tried to bring them closer to reality

function getColorFromString(colorString) {
    const colors = {
        "blue": { red: 0, green: 0, blue: 1 },
        "red": { red: 1, green: 0, blue: 0 },
        "green": { red: 0, green: 1, blue: 0 },
        "gray": { red: 0.5, green: 0.5, blue: 0.5 },
        "black": { red: 0, green: 0, blue: 0 },
        "yellow": { red: 1, green: 0.445, blue: 0 },
        "cyan": { red: 0, green: 1, blue: 1 },
        "magenta": { red: 1, green: 0, blue: 1 },
        "orange": { red: 1, green: 0.26, blue: 0 },
        "purple": { red: 0.5, green: 0, blue: 0.5 },
        "brown": { red: 0.65, green: 0.16, blue: 0.16 }
    };

    return colors[colorString.toLowerCase()] || {
        red: Math.random(),
        green: Math.random(),
        blue: 1
    };
}
 const molang = new MolangVariableMap();
 molang.setColorRGB("variable.color", color);
 overworld.spawnParticle("minecraft:colored_flame_particle", { x, y, z }, molang);

Jayly Api
instructions Jayly
microsoft
instructions microsoft

#

Random function

just to make a function

  export function testnum(min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
      }
#

if you have any questions or information send me a message
I am French
but you can write to me in English,
I need documentation for the materials if possible a complete documentation

#

⚒ My ideas in the comments lol ⚒

shadow garden
#

CREATE a Custom Nether Portal

#
world.beforeEvents.playerInteractWithBlock.subscribe(event => {
  system.run(() => {
    const itemInHand = event.itemStack;
    const contourPortal = 'minecraft:glowstone';
    const portalBlock = 'minecraft:stone';
    const item = 'minecraft:flint_and_steel'
    if (!itemInHand || itemInHand.typeId !== item) return;
    const block = event.block;
    const playerPos = block.location;
    const dimension = world.getDimension('overworld');
    ///Editeur salecraft453 PLease Credit version One 
    const isCorrectContour = (x, y, z, rotation) => {
      const offsets = {
        x: [
          { dx: 0, dz: 1 }, { dx: 0, dz: -2 },
          { dx: 0, dy: 1, dz: 1 }, { dx: 0, dy: 1, dz: -2 },
          { dx: 0, dy: 2, dz: 1 }, { dx: 0, dy: 2, dz: -2 },
          { dx: 0, dy: 3, dz: 1 }, { dx: 0, dy: 3, dz: -2 },
          { dx: 0, dy: 4, dz: 1 }, { dx: 0, dy: 4, dz: -2 },
          { dx: 0, dy: 4, dz: 0 }, { dx: 0, dy: 4, dz: -1 },
          { dx: 0, dz: -1 }
        ],
        z: [
          { dx: 1, dz: 0 }, { dx: -2, dz: 0 },
          { dx: 1, dy: 1, dz: 0 }, { dx: -2, dy: 1, dz: 0 },
          { dx: 1, dy: 2, dz: 0 }, { dx: -2, dy: 2, dz: 0 },
          { dx: 1, dy: 3, dz: 0 }, { dx: -2, dy: 3, dz: 0 },
          { dx: 1, dy: 4, dz: 0 }, { dx: -2, dy: 4, dz: 0 },
          { dx: 0, dy: 4, dz: 0 }, { dx: -1, dy: 4, dz: 0 },
          { dx: -1, dz: 0 }
        ]
      };

#
      return offsets[rotation].every(offset => {
        const blockPos = { x: x + (offset.dx || 0), y: y + (offset.dy || 0), z: z + (offset.dz || 0) };
        return dimension.getBlock(blockPos).typeId === contourPortal;
      });
    };
    const checkAndCreatePortal = (x, y, z) => {
      const useX = dimension.getBlock({ x, y, z: z + 1 }).typeId === contourPortal ||
        dimension.getBlock({ x, y, z: z - 2 }).typeId === contourPortal;
      const rotation = useX ? 'x' : 'z';
      if (isCorrectContour(x, y, z, rotation)) {
        for (let dy = 1; dy <= 3; dy++) {
          for (let dz = -1; dz <= 0; dz++) {
            const portalPos = useX ? { x, y: y + dy, z: z + dz } :
              { x: x + dz, y: y + dy, z };
            dimension.setBlockType(portalPos, portalBlock);
          }
        }
      }
    };
    checkAndCreatePortal(playerPos.x, playerPos.y, playerPos.z);
    checkAndCreatePortal(playerPos.x + 1, playerPos.y, playerPos.z);
    checkAndCreatePortal(playerPos.x - 1, playerPos.y, playerPos.z);
    checkAndCreatePortal(playerPos.x, playerPos.y, playerPos.z + 1);
    checkAndCreatePortal(playerPos.x, playerPos.y, playerPos.z - 1);
  });
});

Please Credit

#

if you need help contact me owo

#

Anti teleport

const baseTeleportThreshold = 10; // Distance de base maximale autorisée en un tick pour ne pas être considéré comme une téléportation
const speedEffectFactor = 1.5; // Facteur d'augmentation de la distance pour chaque niveau de l'effet de vitesse
const tagPrefix = "anticheat:";
const teleportTag = "allowedTeleport";
system.runInterval(() => {
  world.getPlayers().forEach(player => {
    const currentPos = player.location
    let teleportThreshold = baseTeleportThreshold;
    const speedEffect = player.getEffect("minecraft:speed");
    if (speedEffect) {
      teleportThreshold *= (1 + speedEffect.amplifier * speedEffectFactor);
    }
    let prevPosTag = player.getTags().find(tag => tag.startsWith(tagPrefix));
    let prevPos;
    if (prevPosTag) {
      prevPosTag = prevPosTag.replace(tagPrefix, "");
      const [prevX, prevY, prevZ] = prevPosTag.split(",").map(Number);
      prevPos = { x: prevX, y: prevY, z: prevZ };

      const distance = Math.sqrt(
        Math.pow(currentPos.x - prevPos.x, 2) +
        Math.pow(currentPos.y - prevPos.y, 2) +
        Math.pow(currentPos.z - prevPos.z, 2)
      );
      if (distance > teleportThreshold && !player.hasTag(teleportTag)) {

        player.teleport(prevPos, {
          checkForBlocks: false,
          dimension: world.getDimension("overworld")
        });
        player.sendMessage("[NebulaQuest] §cTéléportation détectée et annulée !");
        player.getTags().forEach(tag => {
          if (tag.startsWith(tagPrefix)) {
            player.removeTag(tag);
          }
        });
        player.addTag(`${tagPrefix}${prevPos.x},${prevPos.y},${prevPos.z}`);
        return;
      }
    }
    const newPosTag = `${tagPrefix}${currentPos.x},${currentPos.y},${currentPos.z}`;
    player.getTags().forEach(tag => {
      if (tag.startsWith(tagPrefix)) {
        player.removeTag(tag);
      }
    });
    player.addTag(newPosTag);
    player.removeTag(teleportTag);
  });
}, 1);
#

⚒ My ideas in the comments lol ⚒ (Molang Map,Custom Portal ect)

shadow garden
#

Portal Exemple

#

replace dimension.setBlockType(portalPos, portalBlock); for

 dimension.getBlock(portalPos).setPermutation(BlockPermutation.resolve(portalBlock, {
              "minecraft:cardinal_direction": useX ? 'east' : 'north'```
***you can detect if blocks a and b are next to the portal block otherwise replace the portal part with airs***
4 face exemple detect 
```js
          let positionsAdjacentes 
            if (block.permutation.getState("minecraft:cardinal_direction") === "north") {
                positionsAdjacentes = [
                { x: block.location.x + 1, y: block.location.y, z: block.location.z },
                { x: block.location.x - 1, y: block.location.y, z: block.location.z },
                { x: block.location.x, y: block.location.y + 1, z: block.location.z },
                { x: block.location.x, y: block.location.y - 1, z: block.location.z },

            ];} else {
                positionsAdjacentes = [
                { x: block.location.x , y: block.location.y, z: block.location.z+ 1 },
                { x: block.location.x , y: block.location.y, z: block.location.z- 1 },
                { x: block.location.x, y: block.location.y + 1, z: block.location.z },
                { x: block.location.x, y: block.location.y - 1, z: block.location.z },

            ];}
#

JSON PERMUTATION

        "permutations":[
         {
            "condition":"q.block_state('minecraft:cardinal_direction') == 'north' ",
            "components":{
               "minecraft:transformation":{
                  "rotation":[
                     0,
                     180,
                     0
                  ]
               }
            }
         },
         {
            "condition":"q.block_state('minecraft:cardinal_direction') == 'south' ",
            "components":{
               "minecraft:transformation":{
                  "rotation":[
                     0,
                     0,
                     0
                  ]
               }
            }
         },
         {
            "condition":"q.block_state('minecraft:cardinal_direction') == 'east' ",
            "components":{
               "minecraft:transformation":{
                  "rotation":[
                     0,
                     90,
                     0
                  ]
               }
            }
         },
         {
            "condition":"q.block_state('minecraft:cardinal_direction') == 'west' ",
            "components":{
               "minecraft:transformation":{
                  "rotation":[
                     0,
                     270,
                     0
                  ]
               }
            }
         }
      ]
#

Avoid lines in the portal

      "minecraft:material_instances": {
        "*": {
          "texture": "exemple portal id texture",
            "ambient_occlusion": false,
            "face_dimming": false,
            "render_method": "blend"
        }}
severe breach
#

Maybe a dumb question, but I'm still fairly new to this stuff, where does the portal bring you?

#

just the nether, right?

dusk marlin
#

So it could be any dimension