diff --git a/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua b/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua index 8a724be71..d4e4dd9db 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua @@ -31,8 +31,8 @@ if #args == 0 then elseif command ~= "" then --luacheck: globals _ENV local result, reason = sh.execute(_ENV, command) - if not result then - io.stderr:write((reason and tostring(reason) or "unknown error") .. "\n") + if not result and reason then + io.stderr:write(tostring(reason), "\n") end end elseif command == nil then -- false only means the input was interrupted diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/sh.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/sh.lua index f483aee22..877e9b4a3 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/sh.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/sh.lua @@ -198,7 +198,7 @@ function sh.execute(env, command, ...) if type(words) ~= "table" then return words, reason elseif #words == 0 then - return true, 0 + return true end -- MUST be table.pack for non contiguous ... diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala index 7300228f9..0eafd22f0 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala @@ -51,10 +51,14 @@ object ScreenRenderer extends TileEntitySpecialRenderer[Screen] { return } + // y = block.bottom - player.feet + // eye is higher, so the y delta should be more negative + val eye_delta: Double = y - Minecraft.getMinecraft.thePlayer.getEyeHeight + // Crude check whether screen text can be seen by the local player based // on the player's position -> angle relative to screen. val screenFacing = screen.facing.getOpposite - if (screenFacing.getFrontOffsetX * (x + 0.5) + screenFacing.getFrontOffsetY * (y + 0.5) + screenFacing.getFrontOffsetZ * (z + 0.5) < 0) { + if (screenFacing.getFrontOffsetX * (x + 0.5) + screenFacing.getFrontOffsetY * (eye_delta + 0.5) + screenFacing.getFrontOffsetZ * (z + 0.5) < 0) { return } diff --git a/src/main/scala/li/cil/oc/common/Proxy.scala b/src/main/scala/li/cil/oc/common/Proxy.scala index 0ec354f94..72c1b90ab 100644 --- a/src/main/scala/li/cil/oc/common/Proxy.scala +++ b/src/main/scala/li/cil/oc/common/Proxy.scala @@ -77,12 +77,21 @@ class Proxy { api.API.config = Settings.get.config - if (LuaStateFactory.include52) { - api.Machine.add(classOf[NativeLua52Architecture]) - } + // Weird JNLua bug identified + // When loading JNLua (for either 5.2 or 5.3 lua state) there is a static section that the library loads + // being static, it loads once regardless of which lua state is loaded first + // static { REGISTRYINDEX = lua_registryindex(); } + // The problem is that lua_registryindex was removed in 5.3 + // Thus, if we load JNLua from a lua5.3 state first, this static section fails + // We must load 5.2 first, AND we know 5.3 will likely fail to load if 5.2 failed + val include52: Boolean = LuaStateFactory.include52 + // now that JNLua has been initialized from a lua52 state, we are safe to check 5.3 if (LuaStateFactory.include53) { api.Machine.add(classOf[NativeLua53Architecture]) } + if (include52) { + api.Machine.add(classOf[NativeLua52Architecture]) + } if (LuaStateFactory.includeLuaJ) { api.Machine.add(classOf[LuaJLuaArchitecture]) }