Glue Trap
Get stuck on the trap if you step on it. Break the wool to be set free
← Back to main
World Code:
//Timeout Code by Sulfrox
class MinQueue{constructor(i,t,e){t=e=Uint32Array,this.c=i,this.k=new t(i+1),this.p=new e(i+1),this.h=!1,this.l=0}bbu(i){let t=this.k,e=this.p,r=t[i],h=e[i];for(;i>1;){let s=i>>>1;if(e[s]<=h)break;t[i]=t[s],e[i]=e[s],i=s}t[i]=r,e[i]=h}bbd(i){let t=this.k,e=this.p,r=t[i],h=e[i],s=1+(this.l>>>1),u=this.l+1;for(;i<s;){let n=i<<1,l=e[n],m=t[n],_=n,p=n+1;if(p<u&&e[p]<l&&(l=e[p],m=t[p],_=p),l>=h)break;t[i]=m,e[i]=l,i=_}t[i]=r,e[i]=h}push(i,t){if(this.l===this.c)throw"heap full";if(this.h)this.k[1]=i,this.p[1]=t,this.l++,this.bbd(1),this.h=!1;else{let e=this.l+1;this.k[e]=i,this.p[e]=t,this.l++,this.bbu(e)}}pop(){if(0!==this.l)return this.rpe(),this.l--,this.h=!0,this.k[1]}peekPriority(){if(0!==this.l)return this.rpe(),this.p[1]}peek(){if(0!==this.l)return this.rpe(),this.k[1]}rpe(){this.h&&(this.k[1]=this.k[this.l+1],this.p[1]=this.p[this.l+1],this.bbd(1),this.h=!1)}}let currently_running_timer,TimerQueue=new MinQueue(1024),TimerDictionary=[],TimerNum=0,TickNum=0;function setTimeOut(i,t){let e=TickNum+Math.floor(t/50);TimerDictionary[TimerNum]=i,TimerQueue.push(TimerNum,e),TimerNum++}function tick(){if(TickNum++,currently_running_timer)currently_running_timer(),currently_running_timer=void 0;else if(TimerQueue.peekPriority()<=TickNum){let i=TimerQueue.peek();void 0!==i&&(currently_running_timer=TimerDictionary[i]),TimerQueue.pop(),delete TimerDictionary[i]}}
// Track all placed yellow wool zones and original blocks
const activeWoolAreas = new Map(); // key => array of {x, y, z, originalBlock}
// Place 5x5 Yellow Wool when pebble lands
function onPlayerThrowableHitTerrain(projectileId, itemName, playerId) {
if (itemName === "Pebble") {
const [x, y, z] = api.getPosition(playerId).map(Math.floor);
const minX = x - 2;
const maxX = x + 2;
const minZ = z - 2;
const maxZ = z + 2;
const targetY = y - 1;
const key = `${minX},${targetY},${minZ}`;
const originalBlocks = [];
// Save original blocks
for (let xi = minX; xi <= maxX; xi++) {
for (let zi = minZ; zi <= maxZ; zi++) {
const original = api.getBlock(xi, targetY, zi);
originalBlocks.push({ x: xi, y: targetY, z: zi, block: original });
api.setBlock(xi, targetY, zi, "Yellow Wool");
}
}
activeWoolAreas.set(key, originalBlocks);
}
}
// Make Yellow Wool slow players
function onBlockStand(playerId, x, y, z, blockName) {
if (blockName === "Yellow Wool") {
api.setClientOption(playerId, "speedMultiplier", 0);
api.setClientOption(playerId, "jumpAmount", 0);
} else {
api.setClientOption(playerId, "speedMultiplier", 1);
api.setClientOption(playerId, "jumpAmount", 8);
}
}
// Restore original blocks when wool is broken
onPlayerChangeBlock = (playerId, x, y, z, fromBlock, toBlock) => {
if (fromBlock === "Yellow Wool" && toBlock === "Air") {
for (const [key, originalBlocks] of activeWoolAreas.entries()) {
const [minX, woolY, minZ] = key.split(",").map(Number);
const maxX = minX + 4;
const maxZ = minZ + 4;
if (
y === woolY &&
x >= minX && x <= maxX &&
z >= minZ && z <= maxZ
) {
// Restore saved blocks
for (const block of originalBlocks) {
api.setBlock(block.x, block.y, block.z, block.block);
}
activeWoolAreas.delete(key);
break;
}
}
return "preventDrop";
}
};