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

physic addons

Open
#161 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with the proposed scripts/main.js entry point and the manifest dependency on @minecraft/server. Clarify which of the block-break particles, item impulses, and death impulses are intended, then verify the relevant event and entity APIs against the stated Minecraft version. Done should be defined as the selected physics effects working in-game without errors.

Written by the indexing model from the issue text.

Description

import { world, system } from "@minecraft/server";

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

// Tọa độ tâm khối bị phá
const centerX = loc.x + 0.5;
const centerY = loc.y + 0.5;
const centerZ = loc.z + 0.5;

// 1. TẠO HIỆU ỨNG MẢNH VỠ 3D (BLOCK FRACTURE PARTICLES)
// Dùng hệ thống Particle có sẵn của Bedrock để mô phỏng mảnh vỡ vật lý văng ra
for (let i = 0; i < 12; i++) {
    // Tạo vận tốc ngẫu nhiên văng ra mọi hướng
    const offsetX = (Math.random() - 0.5) * 0.6;
    const offsetY = (Math.random() - 0.5) * 0.6;
    const offsetZ = (Math.random() - 0.5) * 0.6;

    try {
        // Bắn các hạt mảnh vỡ tương ứng với loại khối vừa đập
        dimension.spawnParticle(
            "minecraft:block_destruct", 
            { x: centerX + offsetX, y: centerY + offsetY, z: centerZ + offsetZ },
            brokenBlockPermutation
        );
    } catch (e) {}
}

// 2. VẬT LÝ VĂNG ITEM (Physics Item Drop)
// Làm cho vật phẩm rớt ra văng ngẫu nhiên giống Java Physics Mod
system.run(() => {
    // Tìm các item entity vừa xuất hiện gần đó
    const nearbyEntities = dimension.getEntities({
        location: { x: centerX, y: centerY, z: centerZ },
        maxDistance: 1.5,
        type: "minecraft:item"
    });

    for (const itemEntity of nearbyEntities) {
        // Áp dụng lực văng (Impulse) ngẫu nhiên cho Item
        const forceX = (Math.random() - 0.5) * 0.25;
        const forceY = Math.random() * 0.2 + 0.15; // Đẩy nảy nhẹ lên trên
        const forceZ = (Math.random() - 0.5) * 0.25;

        try {
            itemEntity.applyImpulse({ x: forceX, y: forceY, z: forceZ });
        } catch (e) {}
    }
});

});

// ==========================================================
// 3. VẬT LÝ QUÁI VĂNG KHI CHẾT (Mob Ragdoll Knockback Impulse)
// ==========================================================
world.afterEvents.entityDie.subscribe((event) => {
const deadEntity = event.deadEntity;
const damageSource = event.damageSource;

// Nếu quái chết do người chơi hoặc vụ nổ
if (deadEntity && damageSource.damagingEntity) {
    const attacker = damageSource.damagingEntity;
    const loc = deadEntity.location;

    // Tính hướng văng từ người tấn công đến quái
    const dx = loc.x - attacker.location.x;
    const dz = loc.z - attacker.location.z;
    const distance = Math.sqrt(dx * dx + dz * dz) || 1;

    // Tạo lực đẩy nảy xác quái ra xa (Mô phỏng Ragdoll)
    const pushX = (dx / distance) * 0.6;
    const pushZ = (dz / distance) * 0.6;

    try {
        deadEntity.applyImpulse({ x: pushX, y: 0.35, z: pushZ });
    } catch (e) {}
}

});
{
"format_version": 2,
"header": {
"name": "Java-Style Physics Addon",
"description": "Mo phong hieu ung vat ly Java Physics Mod cho Bedrock",
"uuid": "7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d",
"version": [1, 0, 0],
"min_engine_version": [1, 20, 50]
},
"modules": [
{
"type": "script",
"language": "javascript",
"uuid": "8b9c0d1e-2f3a-4b5c-6d7e-8f9a0b1c2d3e",
"version": [1, 0, 0],
"entry": "scripts/main.js"
}
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.9.0"
}
]
}

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.