Skip to content

메가 스택 뭉침 메커니즘 (MC 26.1.2)

이 문서는 Minecraft 26.1.2 버전의 Item Clumps에 대한 바닥 아이템 집약, 탐색 반경 연산 및 엔티티 병합에 대한 기술적/수학적 분석을 제공합니다.


📊 기능 정보 상자

속성세부 정보
시스템 이름바닥 아이템 메가 스택 집약기
대상 클래스net.minecraft.world.entity.item.ItemEntity
기본 뭉침 한도9,999개 (최대 $2,147,483,647$개까지 설정 가능)
탐색 반경 ($r$)수평 $1$ ~ $10$ 블록 (기본값: $1$ 블록)
반경 주입AABB.inflate(DDD) 대상 @ModifyArgs
제어 게임 규칙item_clumps:enable_clumping, item_clumps:max_clump_size, item_clumps:merge_radius

⚙️ 메가 스택 뭉침 작동 원리

바닐라 Minecraft에서는 바닥에 떨어진 아이템이 틱 주기 동안 mergeWithNeighbours()를 호출하지만, 아이템 수량이 itemStack.getMaxStackSize()(일반적으로 64개)를 초과하면 병합을 금지합니다.

Item Clumps는 ItemEntityMixin.java를 통해 이 제약을 해제하며 데이터 컴포넌트의 안전성을 엄격히 보존합니다.

                  ┌──────────────────────────────┐
                  │    ItemEntity A Ticks In     │
                  └──────────────┬───────────────┘


                  ┌──────────────────────────────┐
                  │     Feasibility Check        │
                  │  - Matching player target?   │
                  │  - Identical DataComponents? │
                  └──────────────┬───────────────┘
                                 │ (Pass)

                  ┌──────────────────────────────┐
                  │   Combine Stacks Math Check  │
                  └──────────────┬───────────────┘

                 ┌───────────────┴───────────────┐
                 │                               │
    thisCount + otherCount <= maxClump    thisCount + otherCount > maxClump
                 │                               │
                 ▼                               ▼
       ┌───────────────────┐           ┌───────────────────┐
       │   Complete Merge  │           │   Partial Merge   │
       │ Larger absorbs    │           │ Fill entity A to  │
       │ smaller entity;   │           │ maxClumpSize;     │
       │ Younger age kept. │           │ B keeps remainder.│
       └───────────────────┘           └───────────────────┘

📐 수학 공식 및 정밀 연산

1. 수평 히트박스 확장 (@ModifyArgs)

$$\text{args.set}(0, r), \quad \text{args.set}(2, r)$$

여기서:

  • $r = \text{DynamicGameRuleManager}.\text{getInt}(\text{level}, \text{MERGE_RADIUS}) \in [1, 10]$ 블록.
  • 수직 높이 인덱스($1$)는 변경되지 않으므로 서로 다른 층 간의 수직 분리가 엄격히 유지됩니다.

2. 아이템 수량 이동 연산

  • 완전 흡수 ($S \le \text{maxClumpSize}$): $$\text{count}_{\text{merged}} = \text{thisCount} + \text{otherCount}$$
  • 부분 흡수 ($S > \text{maxClumpSize}$): $$\Delta = \text{maxClumpSize} - \text{thisCount}$$ $$\text{thisCount}' = \text{maxClumpSize}, \quad \text{otherCount}' = \text{otherCount} - \Delta$$

💻 실제 Java 소스 코드 구현

Minecraft 26.1.2의 ItemEntityMixin.java 출처:

java
@ModifyArgs(method = "mergeWithNeighbours", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;inflate(DDD)Lnet/minecraft/world/phys/AABB;"))
private void item_clumps$modifySearchRadius(Args args) {
    if (DynamicGameRuleManager.getBoolean(this.level(), ItemClumpsFabric.ENABLE_CLUMPING)) {
        double radius = DynamicGameRuleManager.getInt(this.level(), ItemClumpsFabric.MERGE_RADIUS);
        args.set(0, radius);
        args.set(2, radius);
    }
}

@Inject(method = "tryToMerge", at = @At("HEAD"), cancellable = true)
private void item_clumps$customMerge(ItemEntity other, CallbackInfo ci) {
    if (!DynamicGameRuleManager.getBoolean(this.level(), ItemClumpsFabric.ENABLE_CLUMPING)) return;

    ItemStack thisStack = this.getItem();
    ItemStack otherStack = other.getItem();

    if (!Objects.equals(this.target, ((ItemEntityMixin)(Object)other).target) || 
        !ItemStack.isSameItemSameComponents(thisStack, otherStack)) {
        return;
    }

    int thisCount = thisStack.getCount();
    int otherCount = otherStack.getCount();
    int maxClump = DynamicGameRuleManager.getInt(this.level(), ItemClumpsFabric.MAX_CLUMP_SIZE);

    if (thisCount + otherCount > maxClump) {
        int spaceLeft = maxClump - thisCount;
        if (spaceLeft > 0) {
            thisStack.setCount(maxClump);
            this.setItem(thisStack);
            otherStack.setCount(otherCount - spaceLeft);
            other.setItem(otherStack);
        }
        ci.cancel();
        return;
    }

    // Full Merge: larger stack absorbs the smaller stack
    if (otherCount < thisCount) {
        thisStack.setCount(thisCount + otherCount);
        this.setItem(thisStack);
        this.pickupDelay = Math.max(this.pickupDelay, ((ItemEntityMixin)(Object)other).pickupDelay);
        this.age = Math.min(this.age, ((ItemEntityMixin)(Object)other).age);
        other.discard();
    } else {
        otherStack.setCount(thisCount + otherCount);
        other.setItem(otherStack);
        ((ItemEntityMixin)(Object)other).pickupDelay = Math.max(((ItemEntityMixin)(Object)other).pickupDelay, this.pickupDelay);
        ((ItemEntityMixin)(Object)other).age = Math.min(((ItemEntityMixin)(Object)other).age, this.age);
        this.discard();
    }
    ci.cancel();
}

🔗 관련 문서 (MC 26.1.2)

Official documentation & web portal for Dasik Igaijinn mods.