Fixed NPE crash when trying to transport into orbit from hyperspace
Improved usability in transporter jammed status report
This commit is contained in:
parent
084b03c935
commit
ffb6472051
5 changed files with 29 additions and 6 deletions
|
@ -731,14 +731,16 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyCoreOrCon
|
||||||
if (vRequest.y < 0) {
|
if (vRequest.y < 0) {
|
||||||
final CelestialObject celestialObjectChild = CelestialObjectManager.getClosestChild(world, pos.getX(), pos.getZ());
|
final CelestialObject celestialObjectChild = CelestialObjectManager.getClosestChild(world, pos.getX(), pos.getZ());
|
||||||
if (celestialObjectChild == null) {
|
if (celestialObjectChild == null) {
|
||||||
reasonJammed = "Not in orbit of a planet";
|
reasonJammed = "Not in orbit of a planet!\nIncrease target Y coordinate.";
|
||||||
} else {
|
} else {
|
||||||
vRequest.translate(celestialObjectChild.getEntryOffset());
|
vRequest.translate(celestialObjectChild.getEntryOffset());
|
||||||
globalPositionRemoteNew = new GlobalPosition(celestialObjectChild.dimensionId, vRequest.x, (vRequest.y + 1024) % 256, vRequest.z);
|
globalPositionRemoteNew = new GlobalPosition(celestialObjectChild.dimensionId, vRequest.x, (vRequest.y + 1024) % 256, vRequest.z);
|
||||||
}
|
}
|
||||||
} else if (vRequest.y > 256) {
|
} else if (vRequest.y > 256) {
|
||||||
if (celestialObjectLocal == null) {
|
if (celestialObjectLocal == null) {
|
||||||
reasonJammed = "Unknown dimension, no reachable orbit";
|
reasonJammed = "Unknown local celestial object!\nThere's no orbit to reach from here.\nReduce target Y coordinate.";
|
||||||
|
} else if (celestialObjectLocal.parent == null) {
|
||||||
|
reasonJammed = "No parent dimension!\nThere's no orbit to reach from here.\nReduce target Y coordinate.";
|
||||||
} else {
|
} else {
|
||||||
vRequest.translateBack(celestialObjectLocal.getEntryOffset());
|
vRequest.translateBack(celestialObjectLocal.getEntryOffset());
|
||||||
globalPositionRemoteNew = new GlobalPosition(celestialObjectLocal.parent.dimensionId, vRequest.x, vRequest.y % 256, vRequest.z);
|
globalPositionRemoteNew = new GlobalPosition(celestialObjectLocal.parent.dimensionId, vRequest.x, vRequest.y % 256, vRequest.z);
|
||||||
|
@ -806,7 +808,7 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyCoreOrCon
|
||||||
&& celestialObjectLocal.isHyperspace() )
|
&& celestialObjectLocal.isHyperspace() )
|
||||||
|| celestialObjectRemote.isHyperspace() ) {
|
|| celestialObjectRemote.isHyperspace() ) {
|
||||||
isJammed = true;
|
isJammed = true;
|
||||||
reasonJammed = "Blocked by warp field barrier";
|
reasonJammed = "Blocked by warp field barrier!\nExit hyperspace to use transporter room.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -827,7 +829,8 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyCoreOrCon
|
||||||
celestialObjectRemote.dimensionId,
|
celestialObjectRemote.dimensionId,
|
||||||
this));
|
this));
|
||||||
isJammed = true;
|
isJammed = true;
|
||||||
reasonJammed = String.format("Unable to initialize dimension %d", celestialObjectRemote.dimensionId);
|
reasonJammed = String.format("Unable to initialize dimension %d",
|
||||||
|
celestialObjectRemote.dimensionId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -161,6 +161,15 @@ local function writeLn(text)
|
||||||
w.setCursorPos(1, y + 1)
|
w.setCursorPos(1, y + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function writeMultiLine(text)
|
||||||
|
local textToParse = text or ""
|
||||||
|
for line in string.gmatch(textToParse, "[^\n]+") do
|
||||||
|
if line ~= "" then
|
||||||
|
w.writeLn(line)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function writeCentered(y, text)
|
local function writeCentered(y, text)
|
||||||
local unused
|
local unused
|
||||||
if text == nil then
|
if text == nil then
|
||||||
|
@ -1270,6 +1279,7 @@ w = {
|
||||||
clear = clear,
|
clear = clear,
|
||||||
clearLine = clearLine,
|
clearLine = clearLine,
|
||||||
writeLn = writeLn,
|
writeLn = writeLn,
|
||||||
|
writeMultiLine = writeMultiLine,
|
||||||
writeCentered = writeCentered,
|
writeCentered = writeCentered,
|
||||||
writeFullLine = writeFullLine,
|
writeFullLine = writeFullLine,
|
||||||
page_begin = page_begin,
|
page_begin = page_begin,
|
||||||
|
|
|
@ -153,7 +153,7 @@ function transporter_page()
|
||||||
if isJammed then
|
if isJammed then
|
||||||
w.setColorBad()
|
w.setColorBad()
|
||||||
end
|
end
|
||||||
w.write(state)
|
w.writeMultiLine(state)
|
||||||
w.setColorNormal()
|
w.setColorNormal()
|
||||||
w.write(".")
|
w.write(".")
|
||||||
end
|
end
|
||||||
|
|
|
@ -172,6 +172,15 @@ local function writeLn(text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function writeMultiLine(text)
|
||||||
|
local textToParse = text or ""
|
||||||
|
for line in string.gmatch(textToParse, "[^\n]+") do
|
||||||
|
if line ~= "" then
|
||||||
|
w.writeLn(line)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function writeCentered(y, text)
|
local function writeCentered(y, text)
|
||||||
local unused
|
local unused
|
||||||
if text == nil then
|
if text == nil then
|
||||||
|
@ -1251,6 +1260,7 @@ w = {
|
||||||
clear = clear,
|
clear = clear,
|
||||||
clearLine = clearLine,
|
clearLine = clearLine,
|
||||||
writeLn = writeLn,
|
writeLn = writeLn,
|
||||||
|
writeMultiLine = writeMultiLine,
|
||||||
writeCentered = writeCentered,
|
writeCentered = writeCentered,
|
||||||
writeFullLine = writeFullLine,
|
writeFullLine = writeFullLine,
|
||||||
page_begin = page_begin,
|
page_begin = page_begin,
|
||||||
|
|
|
@ -152,7 +152,7 @@ function transporter_page()
|
||||||
if isJammed then
|
if isJammed then
|
||||||
w.setColorBad()
|
w.setColorBad()
|
||||||
end
|
end
|
||||||
w.write(state)
|
w.writeMultiLine(state)
|
||||||
w.setColorNormal()
|
w.setColorNormal()
|
||||||
w.write(".")
|
w.write(".")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue