thundernorlis

สร้าง Plugin paper 26.2 ระบบ แม่เหล็ก ดูดไอเท็มที่เราขุดเข้าตัวทันทีละแร่ที่อยู่ไกล้ๆ ในระยะ 8 บล็อก จะมีแสงอนิเมชั่นที่กำลังดึงเข้าตัวเราและทำให้ระบบดีๆด้วยนะครับ

Kodari AI
KodariJul 3 at 7:19 am 2
MagnetPuller
A magnet system that automatically pulls mined items toward the player with animated particle effects. When breaking blocks, nearby dropped items within 8 blocks are pulled in with accelerating speed, particle trails, spiral effects, and beam visuals. Features player toggle command, configurable range and speed, and per-player magnet state persistence.
MagnetPuller
An automatic item magnet system for Paper 1.21.3 that pulls mined items toward the player with animated particle effects. When breaking blocks, nearby dropped items within 8 blocks are pulled in with accelerating speed, beam particle trails, and spiral animations. Features per-player toggle, configurable range/speed/acceleration, and particle customization.
MagnetPuller
A Paper 1.21.3 magnet plugin that automatically pulls mined items toward the player with animated particle effects. When the magnet is active, dropped items within 8 blocks are pulled in with accelerating speed, beam particle trails, and spiral animations. Features per-player toggle (/magnet), configurable range/speed/acceleration, particle customization, and burst effects on block break. Includes chat status display.
thundernorlis

ใช้งานยังไง

Kodari AI
KodariJul 3 at 7:26 am 1

นี่คือวิธีใช้งานระบบ MagnetPuller ที่สร้างไว้:


🔧 คำสั่ง

คำสั่ง
คำอธิบาย
/magnet
เปิด/ปิดระบบแม่เหล็ก (toggle)
/magnet on
เปิดใช้งาน
/magnet off
ปิดใช้งาน
/magnet reload
โหลด config ใหม่ (ต้องมี permission)

Permission: magnetpuller.use — สำหรับใช้คำสั่ง /magnet


⚙️ Config (config.yml)

YAML
range: 8                      # ระยะดูด (บล็อก)
base-speed: 0.35              # ความเร็วเริ่มต้น
acceleration: 1.15            # อัตราเร่ง (คูณทุก tick)
particle:
  beam: "END_ROD"             # อนุภาคลำแสง
  spiral: "ELECTRIC_SPARK"    # อนุภาคเกลียว
  burst: "SONIC_BOOM"         # อนุภาคตอนขุดแร่
updates-per-second: 20        # fps ของ animation

🎮 วิธีใช้

  1. วาง jar ลง plugins/ แล้วรีสตาร์ทเซิร์ฟเวอร์

  2. พิมพ์ /magnet on เพื่อเปิดระบบ

  3. ขุดบล็อก — ของที่ดรอปจะถูกดูดเข้าหาตัวเองอัตโนมัติ

  4. มี เอฟเฟกต์:

    • 🌟 Burst ตอนขุดแร่ (SONIC_BOOM)

    • ✨ ลำแสง (END_ROD) จากไอเท็มถึงตัวคุณ

    • 🌀 เกลียว (ELECTRIC_SPARK) หมุนรอบไอเท็มขณะถูกดูด

    • 🚀 ความเร็วเพิ่มขึ้นเรื่อยๆ ยิ่งใกล้ยิ่งเร็ว

  5. พิมพ์ /magnet off เมื่อต้องการปิด


🧠 ระบบทำงานยังไง (สั้นๆ)

  • BlockBreakListener — ตรวจจับเวลาขุดบล็อก → ส่งสัญญาณไปที่ MagnetManager

  • MagnetManager — มี task loop ที่เช็คไอเท็มในระยะ 8 บล็อกรอบผู้เล่นที่เปิดโหมดแม่เหล็ก

  • ดึงไอเท็มเข้าหาตัวด้วยฟิสิกส์: vector จากไอเท็ม → ผู้เล่น × ความเร็วที่เพิ่มขึ้นทุก tick

  • ตอนแรกระยะใกล้ถึง 1.5 บล็อก → ไอเท็มจะถูกรวมเข้าคลังทันที

  • PlayerMagnetState — เก็บสถานะเปิด/ปิดของแต่ละคน (ต่อ session)

Tip: ถ้าอยากให้ดูดตลอดเวลาไม่ต้องกดเปิด ให้ตั้ง default-enabled: true — หรือบอกมาได้เลยจะแก้ให้ 😄

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
8 464
src/main/java/com/magnetpuller/MagnetPullerPlugin.java
package com.magnetpuller;

import com.magnetpuller.command.MagnetCommand;
import com.magnetpuller.listener.BlockBreakListener;
import com.magnetpuller.manager.MagnetManager;
import org.bukkit.plugin.java.JavaPlugin;

public class MagnetPullerPlugin extends JavaPlugin {

    private MagnetManager magnetManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        this.magnetManager = new MagnetManager(this);
        magnetManager.start();

        getServer().getPluginManager().registerEvents(new BlockBreakListener(this), this);
        getCommand("magnet").setExecutor(new MagnetCommand(this));

        getLogger().info("MagnetPuller enabled — items will be pulled toward players!");
    }

    @Override
    public void onDisable() {
        if (magnetManager != null) {
            magnetManager.stop();
        }
    }

    public MagnetManager getMagnetManager() {
        return magnetManager;
    }
}