Skip to content

Commit 9c81c2d

Browse files
VinkyVShrBox
authored andcommitted
fix: make onPlaceBlock returning placing face and removing truePos pre calculation
fix: make onPlaceBlock returning place block face & edited docs chore: update PlayerEvents.zh.md fix: fix truePos
1 parent 4582414 commit 9c81c2d

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

docs/apis/EventAPI/PlayerEvents.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,14 @@ Note: The player may trigger this event on the server multiple times in a row.
396396
#### `"onPlaceBlock"` - Player Try Places Block Event
397397

398398
- Listener function prototype
399-
`function(player,block)`
399+
`function(player,block,face)`
400400
- Parameters:
401401
- player : `Player`
402402
The player that placed the block.
403403
- block : `Block`
404-
The block that was placed.
404+
The block that was placed on.
405+
- face : `Integer`
406+
The face that was placed on.
405407

406408
- Intercept events: function returns `false`
407409

docs/apis/EventAPI/PlayerEvents.zh.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -407,20 +407,20 @@
407407
#### `"onPlaceBlock"` - 玩家尝试放置方块
408408

409409
- 监听函数原型
410-
`function(player,block)`
410+
`function(player,block,face)`
411411
- 参数:
412412
- player : `Player`
413413
放置方块的玩家对象
414414

415415
- block : `Block`
416416
将要放置的方块对象
417417

418+
- face : `Integer`
419+
被放置的方块的朝向。
420+
418421
- 拦截事件:函数返回`false`
419422

420-
> **存在问题**
421-
>
422-
> 1. 当玩家尝试放置方块时,该事件将持续被触发。
423-
> 2. 方块对象为准星对准的方块,并非将放置方块对象。
423+
> **存在问题** 当玩家尝试放置方块时,该事件将持续被触发。
424424
425425

426426

src/legacy/api/EventAPI.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ void EnableEventListener(int eventId) {
276276
CallEvent(
277277
EVENT_TYPES::onPlaceBlock,
278278
PlayerClass::newPlayer(&ev.self()),
279-
BlockClass::newBlock(ev.pos(), ev.self().getDimensionId())
279+
BlockClass::newBlock(truePos, ev.self().getDimensionId()),
280+
Number::newNumber((schar)ev.face())
280281
);
281282
}
282283
IF_LISTENED_END(EVENT_TYPES::onPlaceBlock);

0 commit comments

Comments
 (0)