MightyPirates / OpenComputers

Home of the OpenComputers mod for Minecraft.
https://oc.cil.li
Other
1.59k stars 430 forks source link

`tablet_use` event not sent when analyzer installed beside other upgrades #3474

Closed aiverson closed 3 years ago

aiverson commented 3 years ago

The tablet_use event will be dispatched correctly when just a geolyzer is installed, but not when both a geolyzer and an analyzer are installed.

This bug found on minecraft 1.12 with the latest released version of the mod.

For all upgrades that add data to tablet_use except the Analyzer, if the upgrade isn't applicable to the block scanned, it will simply not provide data on the block. For the Analyzer, it will instead block the tablet_use event altogether, even if other upgrades would ordinarily provide data.

Test setup: two creative tablets: common components:

OpenOS installed on both tablets. The following program analyzer.lua installed on both tablets:

local computer = require 'computer'
local term = require 'term'

local function dumpinfo(obj, level)
  if type(obj) == 'table' then
    term.write(tostring(obj).."\n")
    for k, v in pairs(obj) do
      term.write(('  '):rep(level) .. tostring(k).." : ")
      dumpinfo(v, level + 1)
    end
  else
    term.write(tostring(obj).."\n")
  end
end

while true do
  local evt = {computer.pullSignal()}
  if evt[1] == "interrupted" then break end
  if evt[1] == "tablet_use" then
    term.clear()
    dumpinfo(evt, 0)
  end
end

Test blocks:

Procedure: While analyzer.lua is running, right click and hold for one second on each block with each tablet.

Expectation: The Experimental tablet will provide the same data as the Control tablet when used on a dirt block.

Observations: The Control tablet provides color, metadata, hardness, and harvestLevel information about both blocks, but also harvestTool on the dirt block. The Experimental tablet provides color, metadata, hardness, harvestLevel information only about the screen. It also provides an "analyzed" table containing a list of one element giving a type and address for the screen component. It provides no data about the dirt block, and no tablet_use event is fired. However, it does log an error to the console when used on the dirt block.

[04:03:19] [Server thread/WARN] [opencomputers]: Block analysis on tablet right click failed gloriously!
scala.MatchError: null
    at li.cil.oc.server.component.UpgradeBarcodeReader.onMessage(UpgradeBarcodeReader.scala:44) ~[UpgradeBarcodeReader.class:?]
    at li.cil.oc.server.network.Network$$anonfun$send$1.apply(Network.scala:371) ~[Network$$anonfun$send$1.class:?]
    at li.cil.oc.server.network.Network$$anonfun$send$1.apply(Network.scala:371) ~[Network$$anonfun$send$1.class:?]
    at scala.collection.immutable.List.foreach(List.scala:383) ~[List.class:?]
    at li.cil.oc.server.network.Network.send(Network.scala:371) ~[Network.class:?]
    at li.cil.oc.server.network.Network.sendToReachable(Network.scala:205) ~[Network.class:?]
    at li.cil.oc.server.network.Network$Wrapper.sendToReachable(Network.scala:773) ~[Network$Wrapper.class:?]
    at li.cil.oc.server.network.Network$Wrapper.sendToReachable(Network.scala:749) ~[Network$Wrapper.class:?]
    at li.cil.oc.server.network.NodeVarargPart$class.sendToReachable(Node.scala:104) ~[NodeVarargPart$class.class:?]
    at li.cil.oc.server.network.Network$ComponentConnectorBuilder$$anon$1.sendToReachable(Network.scala:636) ~[Network$ComponentConnectorBuilder$$anon$1.class:?]
    at li.cil.oc.server.network.Network$ComponentConnectorBuilder$$anon$1.sendToReachable(Network.scala:636) ~[Network$ComponentConnectorBuilder$$anon$1.class:?]
    at li.cil.oc.common.item.Tablet.onPlayerStoppedUsing(Tablet.scala:184) [Tablet.class:?]
    at li.cil.oc.common.item.Delegator.onPlayerStoppedUsing(Delegator.scala:177) [Delegator.class:?]
    at net.minecraft.item.ItemStack.onPlayerStoppedUsing(ItemStack.java:548) [aip.class:?]
    at net.minecraft.entity.EntityLivingBase.stopActiveHand(EntityLivingBase.java:2816) [vp.class:?]
    at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:666) [pa.class:?]
    at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(SourceFile:40) [lp.class:?]
    at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(SourceFile:10) [lp.class:?]
    at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) [hv$1.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_272]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_272]
    at net.minecraft.util.Util.runTask(SourceFile:529) [h.class:?]
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:723) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668) [MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:185) [chd.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_272]
aiverson commented 3 years ago

While attempting to research and fix this, I found that the latest dev build has a fix, and there just hasn't been an updated version released in a long time. Closing.