Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

physic addons

未关闭
#160 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
活跃
技术栈
javascript
领域
game-dev

调研方向

Start with physics_addon_bp/manifest.json to confirm the Bedrock add-on configuration, then read scripts/index.js and verify the entry point and Minecraft API usage. Test the add-on in Minecraft Bedrock with supported log types; done means the sample is integrated and its described tree-breaking behavior works without errors.

由索引模型根据 Issue 内容生成。

描述

physics_addon_bp/
├── manifest.json
└── scripts/
└── index.js
{
"format_version": 2,
"header": {
"name": "Physics Addon",
"description": "Thêm hiệu ứng vật lý chân thực cho Minecraft!",
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"version": [1, 0, 0],
"min_engine_version": [1, 20, 50]
},
"modules": [
{
"type": "script",
"language": "javascript",
"uuid": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
"version": [1, 0, 0],
"entry": "scripts/index.js"
}
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.9.0"
}
]
}
import { world, system, BlockPermutation } from "@minecraft/server";

// Danh sách các loại gỗ hỗ trợ
const LOG_BLOCKS = [
"minecraft:oak_log",
"minecraft:spruce_log",
"minecraft:birch_log",
"minecraft:jungle_log",
"minecraft:acacia_log",
"minecraft:dark_oak_log",
"minecraft:mangrove_log",
"minecraft:cherry_log"
];

// Lắng nghe sự kiện người chơi phá khối
world.beforeEvents.playerBreakBlock.subscribe((event) => {
const block = event.block;
const dimension = event.dimension;

// Kiểm tra xem khối bị phá có phải gỗ không
if (LOG_BLOCKS.includes(block.typeId)) {
    // Chạy thuật toán rơi vật lý sau 1 tick
    system.run(() => {
        breakTreePhysics(block.location, dimension);
    });
}

});

function breakTreePhysics(startLocation, dimension) {
let currentY = startLocation.y + 1;
const logsToBreak = [];

// Tìm toàn bộ khối gỗ nối tiếp thẳng đứng
while (currentY < startLocation.y + 30) {
    const checkLocation = { x: startLocation.x, y: currentY, z: startLocation.z };
    const block = dimension.getBlock(checkLocation);

    if (block && LOG_BLOCKS.includes(block.typeId)) {
        logsToBreak.push({ location: checkLocation, typeId: block.typeId });
        currentY++;
    } else {
        break; // Dừng lại nếu hết khối gỗ
    }
}

// Làm rơi từng khối gỗ theo hiệu ứng thời gian
logsToBreak.forEach((logData, index) => {
    system.runTimeout(() => {
        const block = dimension.getBlock(logData.location);
        if (block && LOG_BLOCKS.includes(block.typeId)) {
            // Đổi khối thành không khí và thả rơi item
            dimension.runCommand(`setblock ${logData.location.x} ${logData.location.y} ${logData.location.z} air destroy`);
        }
    }, index * 2); // Trễ 2 tick giữa mỗi khối để tạo hiệu ứng rơi mượt
});

}

主要语言
TypeScript
星标
433
派生
247
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/minecraft-samples 的其他 Issue

查看 microsoft/minecraft-samples 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。