2026/07/08(水)ネザーゲートの利用を禁止させる
火打石と打ちがねで、ネザーゲートを開通させることはできる。
しかし、入ろうとするとプレイヤーにデバフがかかりゲートが破壊される。
// ========================================================================
// ネザーゲート禁止
// ========================================================================
let enable_nether_gate_check = true;
system.runInterval(() => {
if (!enable_nether_gate_check) return;
for (const player of world.getPlayers()) {
try {
const dim = player.dimension;
const loc = player.location;
// プレイヤー周囲 ±1 にポータルがあるかチェック
let nearPortal = false;
const searchRange = 1;
outerLoop: for (let dx = -searchRange; dx <= searchRange; dx++) {
for (let dy = -searchRange; dy <= searchRange; dy++) {
for (let dz = -searchRange; dz <= searchRange; dz++) {
const block = dim.getBlock({
x: Math.floor(loc.x) + dx,
y: Math.floor(loc.y) + dy,
z: Math.floor(loc.z) + dz
});
if (block?.typeId === "minecraft:portal") {
nearPortal = true;
break outerLoop;
}
}
}
}
if (!nearPortal) continue;
// 安全な場所を探す(強制TP用、現在未使用だがおいておく)
const offsets = [1];
let safeSpot = null;
for (let attempt = 0; attempt < 10; attempt++) {
const dx = offsets[Math.floor(Math.random() * offsets.length)] * (Math.random() < 0.5 ? -1 : 1);
const dz = offsets[Math.floor(Math.random() * offsets.length)] * (Math.random() < 0.5 ? -1 : 1);
const tx = Math.floor(loc.x) + dx;
const ty = Math.floor(loc.y);
const tz = Math.floor(loc.z) + dz;
const foot = dim.getBlock({ x: tx, y: ty, z: tz });
const under = dim.getBlock({ x: tx, y: ty - 1, z: tz });
if (
foot?.typeId === "minecraft:air" &&
under &&
under.typeId !== "minecraft:air" &&
under.typeId !== "minecraft:portal"
) {
safeSpot = { x: tx + 0.5, y: ty, z: tz + 0.5 };
break;
}
}
if (safeSpot) {
// 効果付与
player.addEffect("wither", 80, { amplifier: 2, showParticles: false });
player.addEffect("darkness", 160, { amplifier: 20, showParticles: false });
player.sendMessage("§c§lネザーゲートは解禁されていません。");
// 周辺のネザーゲート(ポータルブロック)をair置換
const x = Math.floor(loc.x);
const y = Math.floor(loc.y);
const z = Math.floor(loc.z);
const destroyRadius = 3;
player.runCommand(
`fill ${x - destroyRadius} ${y - destroyRadius} ${z - destroyRadius} ` +
`${x + destroyRadius} ${y + destroyRadius} ${z + destroyRadius} ` +
`air replace minecraft:portal`
);
}
} catch (error) {
// ランタイムエラーをキャッチ(プレイヤーが不正な状態の場合など)
console.warn(`ネザーゲート禁止処理でエラーが発生: ${error}`);
}
}
}, 30);