Skip to content

Commit 3c31858

Browse files
committed
Fixed Ship API being broken, gotta love silent failure
1 parent 88bd114 commit 3c31858

File tree

2 files changed

+77
-74
lines changed

2 files changed

+77
-74
lines changed

common/src/main/resources/data/computercraft/lua/rom/apis/ship.lua

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -284,86 +284,59 @@ local deprecatedQuat = {
284284

285285
local env = _ENV
286286

287-
-- Add outdated methods to prompt transition
288-
for _, funct in pairs(deprecatedQuat) do
289-
env[funct] = function(...)
290-
error("This method no longer exists! Please utilize the new quaternion API!")
291-
end
292-
end
293-
env.getRotationMatrix = function(...) error("This method no longer exists! Use getTransformationMatrix instead!") end
294-
295-
env.pullPhysicsTicks = function(...)
296-
local _, err = native.pullPhysicsTicks(...)
297-
if err then
298-
error(err)
299-
end
300-
local event = table.pack(os.pullEvent("physics_ticks"))
301-
for k,v in pairs(event) do
302-
if type(v) == "table" then
303-
local result, _ = v.getPoseVel()
304-
v.getPoseVel = function()
305-
result.vel = vector.new(result.vel.x, result.vel.y, result.vel.z)
306-
result.omega = vector.new(result.omega.x, result.omega.y, result.omega.z)
307-
result.pos = vector.new(result.pos.x, result.pos.y, result.pos.z)
308-
result.rot = quaternion.fromComponents(result.rot.x, result.rot.y, result.rot.z, result.rot.w)
309-
return result
310-
end
311-
end
312-
end
313-
return table.unpack(event)
314-
end
315-
316287
for k,v in pairs(native) do
317288
-- Convert functions with vector outputs to actual vectors
318-
if k == 'getOmega' or k == 'getScale' or k == 'getShipyardPosition' or k == 'getVelocity' or k == 'getWorldspacePosition' or k == 'transformPositionToWorld' then
289+
if k == "getOmega" or k == "getScale" or k == "getShipyardPosition" or k == "getVelocity" or k == "getWorldspacePosition" or k == "transformPositionToWorld" then
319290
env[k] = function(...)
320291
local result, err = v(...)
321292
if err then
322293
error(err)
323294
end
324295
return vector.new(result.x, result.y, result.z)
325296
end
326-
elseif k == 'getQuaternion' then
297+
elseif k == "getQuaternion" then
327298
env[k] = function(...)
328299
local result, err = v(...)
329300
if err then
330301
error(err)
331302
end
332303
return quaternion.fromComponents(result.x, result.y, result.z, result.w)
333304
end
334-
elseif k == 'getTransformationMatrix' then
305+
elseif k == "getTransformationMatrix" then
335306
env[k] = function(...)
336307
local result, err = v(...)
337308
if err then
338309
error(err)
339310
end
340311
return matrix.from2DArray(result)
341312
end
342-
elseif k == 'getConstraints' then
343-
local result, err = native.getTransformationMatrix(...)
344-
if err then
345-
error(err)
346-
end
347-
for id, constraint in pairs(result) do
348-
if constraint.localPos0 then
349-
constraint.localPos0 = vector.new(constraint.localPos0.x, constraint.localPos0.y, constraint.localPos0.z)
350-
end
351-
if constraint.localPos1 then
352-
constraint.localPos1 = vector.new(constraint.localPos1.x, constraint.localPos1.y, constraint.localPos1.z)
353-
end
354-
if constraint.localRot0 then
355-
constraint.localRot0 = quaternion.fromComponents(constraint.localRot0.x, constraint.localRot0.y, constraint.localRot0.z, constraint.localRot0.w)
356-
end
357-
if constraint.localRot1 then
358-
constraint.localRot1 = quaternion.fromComponents(constraint.localRot1.x, constraint.localRot1.y, constraint.localRot1.z, constraint.localRot1.w)
313+
elseif k == "getConstraints" then
314+
env[k] = function(...)
315+
local result, err = native.getTransformationMatrix(...)
316+
if err then
317+
error(err)
359318
end
360-
if constraint.localSlideAxis0 then
361-
constraint.localSlideAxis0 = vector.new(constraint.localSlideAxis0.x, constraint.localSlideAxis0.y, constraint.localSlideAxis0.z)
319+
for id, constraint in pairs(result) do
320+
if constraint.localPos0 then
321+
constraint.localPos0 = vector.new(constraint.localPos0.x, constraint.localPos0.y, constraint.localPos0.z)
322+
end
323+
if constraint.localPos1 then
324+
constraint.localPos1 = vector.new(constraint.localPos1.x, constraint.localPos1.y, constraint.localPos1.z)
325+
end
326+
if constraint.localRot0 then
327+
constraint.localRot0 = quaternion.fromComponents(constraint.localRot0.x, constraint.localRot0.y, constraint.localRot0.z, constraint.localRot0.w)
328+
end
329+
if constraint.localRot1 then
330+
constraint.localRot1 = quaternion.fromComponents(constraint.localRot1.x, constraint.localRot1.y, constraint.localRot1.z, constraint.localRot1.w)
331+
end
332+
if constraint.localSlideAxis0 then
333+
constraint.localSlideAxis0 = vector.new(constraint.localSlideAxis0.x, constraint.localSlideAxis0.y, constraint.localSlideAxis0.z)
334+
end
335+
result[id] = constraint
362336
end
363-
result[id] = constraint
337+
return result
364338
end
365-
return result
366-
elseif k == 'applyInvariantForce' or k == 'applyInvariantTorque' or k == 'applyRotDependentForce' or k == 'applyRotDependentTorque' then
339+
elseif k == "applyInvariantForce" or k == "applyInvariantTorque" or k == "applyRotDependentForce" or k == "applyRotDependentTorque" then
367340
env[k] = function(...)
368341
local args = {...}
369342
local vec = args[1]
@@ -381,7 +354,7 @@ for k,v in pairs(native) do
381354
error(err)
382355
end
383356
end
384-
elseif k == 'applyInvariantForceToPos' or k == 'applyRotDependentForceToPos' then
357+
elseif k == "applyInvariantForceToPos" or k == "applyRotDependentForceToPos" then
385358
env[k] = function(...)
386359
local args = {...}
387360
expect(1, args[1], "table", "number")
@@ -424,4 +397,32 @@ for k,v in pairs(native) do
424397
else
425398
env[k] = v
426399
end
400+
end
401+
402+
for _, funct in pairs(deprecatedQuat) do
403+
env[funct] = function(...)
404+
error("This method no longer exists! Please utilize the new quaternion API!")
405+
end
406+
end
407+
env.getRotationMatrix = function(...) error("This method no longer exists! Use getTransformationMatrix instead!") end
408+
409+
env.pullPhysicsTicks = function(...)
410+
local _, err = native.pullPhysicsTicks(...)
411+
if err then
412+
error(err)
413+
end
414+
local event = table.pack(os.pullEvent("physics_ticks"))
415+
for k,v in pairs(event) do
416+
if type(v) == "table" then
417+
local result, _ = v.getPoseVel()
418+
v.getPoseVel = function()
419+
result.vel = vector.new(result.vel.x, result.vel.y, result.vel.z)
420+
result.omega = vector.new(result.omega.x, result.omega.y, result.omega.z)
421+
result.pos = vector.new(result.pos.x, result.pos.y, result.pos.z)
422+
result.rot = quaternion.fromComponents(result.rot.x, result.rot.y, result.rot.z, result.rot.w)
423+
return result
424+
end
425+
end
426+
end
427+
return table.unpack(event)
427428
end

gradle-scripts/publish-curseforge.gradle

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
// Publish to CurseForge
22
curseforge {
3-
apiKey = System.getenv("CURSEFORGE_TOKEN")
4-
project {
5-
id = project.curse_project_id
6-
releaseType = 'release'
7-
changelogType = 'markdown'
8-
changelog = rootProject.file("changelog.md").text
9-
addGameVersion project.minecraft_version
10-
addGameVersion project.loader_platform
3+
if (System.getenv("CURSEFORGE_TOKEN") != null) {
4+
apiKey = System.getenv("CURSEFORGE_TOKEN")
5+
project {
6+
id = project.curse_project_id
7+
releaseType = 'release'
8+
changelogType = 'markdown'
9+
changelog = rootProject.file("changelog.md").text
10+
addGameVersion project.minecraft_version
11+
addGameVersion project.loader_platform
1112

12-
mainArtifact(remapJar.archiveFile.get().asFile) {
13-
relations {
14-
requiredDependency 'valkyrien-skies'
15-
requiredDependency 'cc-tweaked'
16-
if (project.loader_platform == "Forge")
17-
requiredDependency 'kotlin-for-forge'
13+
mainArtifact(remapJar.archiveFile.get().asFile) {
14+
relations {
15+
requiredDependency 'valkyrien-skies'
16+
requiredDependency 'cc-tweaked'
17+
if (project.loader_platform == "Forge")
18+
requiredDependency 'kotlin-for-forge'
19+
}
20+
displayName = 'CC: VS ' + project.minecraft_version + ' ' + project.loader_platform + ' ' + project.mod_version
1821
}
19-
displayName = 'CC: VS ' + project.minecraft_version + ' ' + project.loader_platform + ' ' + project.mod_version
2022
}
21-
}
22-
options {
23-
forgeGradleIntegration = false
24-
javaVersionAutoDetect = false
23+
options {
24+
forgeGradleIntegration = false
25+
javaVersionAutoDetect = false
26+
}
2527
}
2628
}
2729

0 commit comments

Comments
 (0)