Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

physic addons

Open
#160 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Active
Tech stack
javascript
Domain
game-dev

Research direction

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.

Written by the indexing model from the issue text.

Description

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
});

}

Dominant language
TypeScript
Stars
433
Forks
247
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/minecraft-samples

All issues in microsoft/minecraft-samples

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.