Skip to content

Commit 4e5d372

Browse files
committed
fix: fix onEntityExplode #225
1 parent 102da3c commit 4e5d372

File tree

3 files changed

+39
-40
lines changed

3 files changed

+39
-40
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ jobs:
4040
4141
- run: |
4242
xmake -y
43-
sed -i 's/\"name\": \"legacy-script-engine\"/\"name\": \"legacy-script-engine-${{ matrix.backend }}\"/g' bin/legacy-script-engine/manifest.json
44-
mv bin/legacy-script-engine bin/legacy-script-engine-${{ matrix.backend }}
4543
4644
- run: |
4745
sentry-cli debug-files upload --include-sources bin/legacy-script-engine-${{ matrix.backend }}

src/lse/events/BlockEvents.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,17 @@ LL_TYPE_INSTANCE_HOOK(
173173
return shouldPush;
174174
}
175175

176-
LL_TYPE_INSTANCE_HOOK(ExplodeHook, HookPriority::Normal, Level, &Level::$explode, bool, ::Explosion& explosion) {
176+
LL_TYPE_INSTANCE_HOOK(ExplodeHook, HookPriority::Normal, Explosion, &Explosion::explode, bool) {
177177
IF_LISTENED(EVENT_TYPES::onEntityExplode) {
178-
if (explosion.mSourceID->rawID != ActorUniqueID::INVALID_ID().rawID) {
178+
if (mSourceID->rawID != ActorUniqueID::INVALID_ID().rawID) {
179179
if (!CallEvent(
180180
EVENT_TYPES::onEntityExplode,
181-
EntityClass::newEntity(ll::service::getLevel()->fetchEntity(explosion.mSourceID, false)),
182-
FloatPos::newPos(explosion.mPos, explosion.mRegion.getDimensionId()),
183-
Number::newNumber(explosion.mRadius),
184-
Number::newNumber(explosion.mMaxResistance),
185-
Boolean::newBoolean(explosion.mBreaking),
186-
Boolean::newBoolean(explosion.mFire)
181+
EntityClass::newEntity(ll::service::getLevel()->fetchEntity(mSourceID, false)),
182+
FloatPos::newPos(mPos, mRegion.getDimensionId()),
183+
Number::newNumber(mRadius),
184+
Number::newNumber(mMaxResistance),
185+
Boolean::newBoolean(mBreaking),
186+
Boolean::newBoolean(mFire)
187187
)) {
188188
return false;
189189
}
@@ -194,18 +194,18 @@ LL_TYPE_INSTANCE_HOOK(ExplodeHook, HookPriority::Normal, Level, &Level::$explode
194194
IF_LISTENED(EVENT_TYPES::onBlockExplode) {
195195
if (!CallEvent(
196196
EVENT_TYPES::onBlockExplode,
197-
BlockClass::newBlock(*explosion.mPos, explosion.mRegion.getDimensionId()),
198-
FloatPos::newPos(explosion.mPos, explosion.mRegion.getDimensionId()),
199-
Number::newNumber(explosion.mRadius),
200-
Number::newNumber(explosion.mMaxResistance),
201-
Boolean::newBoolean(explosion.mBreaking),
202-
Boolean::newBoolean(explosion.mFire)
197+
BlockClass::newBlock(*mPos, mRegion.getDimensionId()),
198+
FloatPos::newPos(mPos, mRegion.getDimensionId()),
199+
Number::newNumber(mRadius),
200+
Number::newNumber(mMaxResistance),
201+
Boolean::newBoolean(mBreaking),
202+
Boolean::newBoolean(mFire)
203203
)) {
204204
return false;
205205
}
206206
}
207207
IF_LISTENED_END(EVENT_TYPES::onBlockExplode);
208-
return origin(explosion);
208+
return origin();
209209
}
210210

211211
LL_TYPE_STATIC_HOOK(

xmake.lua

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,29 @@ target("legacy-script-engine")
9595
"src/legacy"
9696
)
9797
on_load(function (target)
98-
local tag = os.iorun("git describe --tags --abbrev=0 --always")
99-
local major, minor, patch, suffix = tag:match("v(%d+)%.(%d+)%.(%d+)(.*)")
100-
if not major then
101-
print("Failed to parse version tag, using 0.0.0")
102-
major, minor, patch = 0, 0, 0
103-
end
104-
local versionStr = major.."."..minor.."."..patch
105-
if suffix then
106-
prerelease = suffix:match("-(.*)")
107-
if prerelease then
108-
prerelease = prerelease:gsub("\n", "")
109-
end
98+
local tag = os.iorun("git describe --tags --abbrev=0 --always")
99+
local major, minor, patch, suffix = tag:match("v(%d+)%.(%d+)%.(%d+)(.*)")
100+
if not major then
101+
print("Failed to parse version tag, using 0.0.0")
102+
major, minor, patch = 0, 0, 0
103+
end
104+
local versionStr = major.."."..minor.."."..patch
105+
if suffix then
106+
prerelease = suffix:match("-(.*)")
107+
if prerelease then
108+
prerelease = prerelease:gsub("\n", "")
110109
end
110+
end
111111

112-
if not has_config("publish") then
113-
local hash = os.iorun("git rev-parse --short HEAD")
114-
versionStr = versionStr.."+"..hash:gsub("\n", "")
115-
end
112+
if not has_config("publish") then
113+
local hash = os.iorun("git rev-parse --short HEAD")
114+
versionStr = versionStr.."+"..hash:gsub("\n", "")
115+
end
116116

117-
target:add("rules", "@levibuildscript/modpacker",{
118-
modVersion = versionStr
119-
})
117+
target:add("rules", "@levibuildscript/modpacker",{
118+
modName = target:basename(),
119+
modVersion = versionStr
120+
})
120121
end)
121122

122123
if is_config("backend", "lua") then
@@ -129,7 +130,7 @@ target("legacy-script-engine")
129130
after_build(function(target)
130131
local baselibPath = path.join(os.projectdir(), "src/baselib/BaseLib.lua")
131132
local langPath = path.join(os.projectdir(), "src/lang/")
132-
local outputPath = path.join(os.projectdir(), "bin/" .. target:name())
133+
local outputPath = path.join(os.projectdir(), "bin/" .. target:basename())
133134
local baselibOutputPath = path.join(outputPath, "baselib")
134135
os.mkdir(baselibOutputPath)
135136
os.cp(baselibPath, baselibOutputPath)
@@ -146,7 +147,7 @@ target("legacy-script-engine")
146147
after_build(function(target)
147148
local baselibPath = path.join(os.projectdir(), "src/baselib/BaseLib.js")
148149
local langPath = path.join(os.projectdir(), "src/lang/")
149-
local outputPath = path.join(os.projectdir(), "bin/" .. target:name())
150+
local outputPath = path.join(os.projectdir(), "bin/" .. target:basename())
150151
local baselibOutputPath = path.join(outputPath, "baselib")
151152
os.mkdir(baselibOutputPath)
152153
os.cp(baselibPath, baselibOutputPath)
@@ -162,7 +163,7 @@ target("legacy-script-engine")
162163
after_build(function(target)
163164
local baselibPath = path.join(os.projectdir(), "src/baselib/BaseLib.py")
164165
local langPath = path.join(os.projectdir(), "src/lang/")
165-
local outputPath = path.join(os.projectdir(), "bin/" .. target:name())
166+
local outputPath = path.join(os.projectdir(), "bin/" .. target:basename())
166167
local baselibOutputPath = path.join(outputPath, "baselib")
167168
os.mkdir(baselibOutputPath)
168169
os.cp(baselibPath, baselibOutputPath)
@@ -178,7 +179,7 @@ target("legacy-script-engine")
178179
set_basename("legacy-script-engine-nodejs")
179180
after_build(function(target)
180181
local langPath = path.join(os.projectdir(), "src/lang/")
181-
local outputPath = path.join(os.projectdir(), "bin/" .. target:name())
182+
local outputPath = path.join(os.projectdir(), "bin/" .. target:basename())
182183
os.mkdir(outputPath)
183184
os.cp(langPath, outputPath)
184185
end)

0 commit comments

Comments
 (0)