BlockDispenseEvent is called twice since 26.3 for most blocks
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start in DispenserBlock around line 121 and trace SulfurCubeBlockDispenseItemBehavior.execute into dispenseBlock and CraftEventFactory.handleBlockDispenseEvent. Check how the fallback through DefaultDispenseItemBehavior triggers the event, then reproduce with an event listener that logs each dispense. Done means one BlockDispenseEvent per dispense, with the sulfur cube behavior and fallback still working.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Expected behavior
BlockDispenseEvent is only called once when a dispenser throws out a block
Observed/Actual behavior
When a block is dispensed from a dispenser, it used to go through the usual DefaultDispenseItemBehavior.
With the Sulfur Cubes that changed for most blocks (DispenserBlock line 121):
} else if (itemStack.is(ItemTags.SULFUR_CUBE_SWALLOWABLE)) {
return SulfurCubeBlockDispenseItemBehavior.INSTANCE;
}
SulfurCubeBlockDispenseItemBehavior#execute (vanilla) falls back to super.execute if no Sulfur Cube took the item:
@Override
protected ItemStack execute(final BlockSource source, final ItemStack dispensed) {
return dispenseBlock(source.level(), source.pos().relative(source.state().getValue(DispenserBlock.FACING)), dispensed, source, this) // Paper - Call BlockDispenseEvent
? dispensed
: super.execute(source, dispensed);
}
Paper calls handleBlockDispenseEvent at the start of dispenseBlock, before it checks whether a Sulfur Cube is in front:
ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(source, pos, dispensed, currentBehavior);
If there is none, dispenseBlock returns false and vanilla falls back to super.execute, which fires the event again in DefaultDispenseItemBehavior.spawnItem.
The same applies to TNT: the TNT behavior also calls SulfurCubeBlockDispenseItemBehavior.dispenseBlock first and then fires its own BlockDispenseEvent. The TNT is only primed once, but the event is called twice for a single dispense.
sequenceDiagram
autonumber
participant D as DispenserBlock
participant S as SulfurCubeBlockDispenseItemBehavior
participant DD as DefaultDispenseItemBehavior (super)
participant F as CraftEventFactory
participant L as Plugin Listener
D->>D: getDefaultDispenseMethod(itemStack)
Note over D: itemStack.is(SULFUR_CUBE_SWALLOWABLE)<br/>→ SulfurCubeBlockDispenseItemBehavior.INSTANCE
D->>S: dispense(source, stack)
S->>S: execute(source, stack)
S->>S: dispenseBlock(level, pos, stack, source, this)
S->>F: handleBlockDispenseEvent(source, pos, stack, this)
F->>L: BlockDispenseEvent (1st call)
L-->>F: not cancelled
F-->>S: null
S->>S: getEntitiesOfClass(SulfurCube, AABB(pos))
Note over S: no Sulfur Cube in front<br/>→ dispenseBlock returns false
S->>DD: super.execute(source, stack)
DD->>DD: spawnItem(level, stack, 6, direction, position, source)
DD->>L: BlockDispenseEvent (2nd call)
L-->>DD: not cancelled
DD->>DD: level.addFreshEntity(itemEntity)
Steps/models to reproduce
Watch the BlockDispenseEvent with a event listener and see two logs for the same dispense.
Plugin and Datapack List
Paper version
This server is running Paper version 26.3-209-main@03af8b4 (2026-10-20T21:49:44Z) (Implementing API version 26.3.build.209-stable)
Other
No response
- Ngôn ngữ chính
- Java
- Star
- 12.8k
- Fork
- 3.6k
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 33
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PaperMC/Paper
-
Add .getIgniter() to ExplosiveMinecartCó thể đã có người làm @WouterGritter đã nhận 51 ngày trước. Đang mởstatus: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
PaperMC/Paper#14097 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
BlockType#isOccluding is incorrectly handledCó thể đã có người làm @ryoji-ikeda đã nhận 195 ngày trước. Đang mởstatus: accepted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
PaperMC/Paper#13790 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
status: needs triage version: 26.3
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
-
status: needs triage version: 26.3
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
status: needs triage version: 26.3
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của PaperMC/Paper
Issue tương tự
-
Marketplace time-zone issueĐang mởbug main ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openhab/openhab-webui#4671 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
NearVanilla/IceCream#109 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
getRawTextContent() returns the lines of every page in reverse order (bottom to top) since 4.0.3Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
bancolombia/bin-stash#79 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày