Skip to content

Commit 99a2e71

Browse files
committed
fix: fix mc.explode #111
1 parent cfc837e commit 99a2e71

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

docs/apis/GameAPI/Entity.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -657,17 +657,17 @@ The following APIs provide APIs for interacting with entities at specified locat
657657

658658
#### Create an Explosion at the Specified Location
659659

660-
`mc.explode(pos,source,power,range,isDestroy,isFire)`
661-
`mc.explode(x,y,z,dimid,source,power,range,isDestroy,isFire)`
660+
`mc.explode(pos,source,maxResistance,radius,isDestroy,isFire)`
661+
`mc.explode(x,y,z,dimid,source,maxResistance,radius,isDestroy,isFire)`
662662

663663
- Parameters:
664664
- pos : `IntPos `/ `FloatPos`
665665
The coordinates of the location where the explosion occurred (or use x, y, z, dimid to determine entity location).
666666
- source : `Entity`
667667
Set the entity object of the explosion source, which can be `Null`.
668-
- power : `Float`
669-
The power value of the explosion, which affects the damage and damage range of the explosion.
670-
- range : `Float`
668+
- maxResistance : `Float`
669+
The maximum explosion resistance of the block. Blocks lower than this value will be destroyed.
670+
- radius : `Float`
671671
The radius of the explosion, which affects the scope of the explosion.
672672
- isDestroy : `Boolean`
673673
Does the explosion destroy blocks.

docs/apis/GameAPI/Entity.zh.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -692,17 +692,17 @@
692692

693693
#### 在指定位置制造一次爆炸
694694

695-
`mc.explode(pos,source,power,range,isDestroy,isFire)`
696-
`mc.explode(x,y,z,dimid,source,power,range,isDestroy,isFire)`
695+
`mc.explode(pos,source,maxResistance,radius,isDestroy,isFire)`
696+
`mc.explode(x,y,z,dimid,source,maxResistance,radius,isDestroy,isFire)`
697697

698698
- 参数:
699699
- pos : `IntPos `/ `FloatPos`
700700
引发爆炸的位置坐标(或者使用x, y, z, dimid来确定实体位置)
701701
- source : `Entity`
702702
设置爆炸来源的实体对象,可以为`Null`
703-
- power : `Float`
704-
爆炸的威力值,影响爆炸的伤害大小和破坏范围
705-
- range : `Float`
703+
- maxResistance : `Float`
704+
方块最大爆炸抗性,低于此值的方块会被破坏
705+
- radius : `Float`
706706
爆炸的范围半径,影响爆炸的波及范围
707707
- isDestroy : `Boolean`
708708
爆炸是否破坏方块

src/legacy/api/EntityAPI.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -1756,12 +1756,12 @@ Local<Value> McClass::spawnMob(const Arguments& args) {
17561756
}
17571757

17581758
Local<Value> McClass::explode(const Arguments& args) {
1759-
CHECK_ARGS_COUNT(args, 5);
1759+
CHECK_ARGS_COUNT(args, 6);
17601760

17611761
try {
17621762
FloatVec4 pos;
17631763
int beginIndex;
1764-
if (args.size() == 5) {
1764+
if (args.size() == 6) {
17651765
// PosObj
17661766
beginIndex = 1;
17671767

@@ -1786,7 +1786,7 @@ Local<Value> McClass::explode(const Arguments& args) {
17861786
LOG_WRONG_ARG_TYPE();
17871787
return Local<Value>();
17881788
}
1789-
} else if (args.size() == 8) {
1789+
} else if (args.size() == 9) {
17901790
// Number Pos
17911791
beginIndex = 4;
17921792
CHECK_ARG_TYPE(args[0], ValueKind::kNumber);
@@ -1807,21 +1807,23 @@ Local<Value> McClass::explode(const Arguments& args) {
18071807
auto source = EntityClass::extract(args[beginIndex + 0]); // Can be nullptr
18081808

18091809
CHECK_ARG_TYPE(args[beginIndex + 1], ValueKind::kNumber);
1810-
CHECK_ARG_TYPE(args[beginIndex + 2], ValueKind::kBoolean);
1810+
CHECK_ARG_TYPE(args[beginIndex + 2], ValueKind::kNumber);
18111811
CHECK_ARG_TYPE(args[beginIndex + 3], ValueKind::kBoolean);
1812+
CHECK_ARG_TYPE(args[beginIndex + 4], ValueKind::kBoolean);
18121813

1813-
float power = args[beginIndex + 1].asNumber().toFloat();
1814-
bool isDestroy = args[beginIndex + 2].asBoolean().value();
1815-
bool isFire = args[beginIndex + 3].asBoolean().value();
1814+
float maxResistance = args[beginIndex + 1].asNumber().toFloat();
1815+
float radius = args[beginIndex + 2].asNumber().toFloat();
1816+
bool isDestroy = args[beginIndex + 3].asBoolean().value();
1817+
bool isFire = args[beginIndex + 4].asBoolean().value();
18161818

18171819
ll::service::getLevel()->explode(
18181820
ll::service::getLevel()->getDimension(pos.dim)->getBlockSourceFromMainChunkSource(),
18191821
source,
18201822
pos.getVec3(),
1821-
power,
1823+
radius,
18221824
isFire,
18231825
isDestroy,
1824-
3.40282347e+38,
1826+
maxResistance,
18251827
false
18261828
);
18271829
return Boolean::newBoolean(true);

0 commit comments

Comments
 (0)