This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TomyLobo's profile picture

monitor_touch event inaccurate in SMP

Started by TomyLobo, 15 March 2013 - 01:18 PM
TomyLobo #1
Posted 15 March 2013 - 02:18 PM
The monitor_touch event reports inaccurate coordinates in multi-player mode. Single-player mode is fine.

This program, when invoked with the monitor tool, showcases the bug:

peripheral.call("top", "setTextScale",0.5)

term.clear()

while true do
	local _,_,x,y = os.pullEvent("mouse_click")
	term.setCursorPos(x,y)
	term.write("X")
	term.setCursorPos(1,1)
	term.write(string.format("%s/%s	   ",x,y))
end
Place a computer with an advanced monitor on top of it, put this program on the computer and Invoke it with "monitor top <program name>"
Then try to make it draw an X in the 2nd column or any (column%4==2).

If I either remove the monitor scale or go to single-player mode, the problem vanishes.
SimssmiS #2
Posted 03 May 2013 - 06:42 PM
I have the same problem in much of my programs.
But also not using scale dose not help me.
I would be very happy if anyone could help.
I have access to the server so if i have to change anything in the properties i can.
Cloudy #3
Posted 03 May 2013 - 06:45 PM
I cannot reproduce this.
SimssmiS #4
Posted 03 May 2013 - 06:49 PM
I cannot reproduce this.

I use a Tekkit Lite Server
my code is:
http://pastebin.com/h0CC61RV

i use the programm as
monitor <side> <program>

its not a big problem for this program as you see what happens but for my doorLock with censored input (dont have the code here) its a problem which causes traps to be triggered :D/>
Dlcruz129 #5
Posted 03 May 2013 - 07:44 PM
Dan and Cloudy don't support Bukkit versions, so you're on you're own.
KaoS #6
Posted 25 May 2013 - 05:29 AM
In multiplayer there are many mods that become hard to use if your connection is slow. You right click and have to wait a sec or two for the change to reflect, if you move your cursor it uses the new co-ords as the right click location in many cases. During a particularly bad lag-spike as a result of exploits on a SMP server I once placed a block, ran over 10 blocks over and had it suddenly appear in front of me…

TLDR: try keeping the cursor still after clicking

ALSO: apologies for slight necro, bug thread was still open so I guessed maybe someone was still trying to figure this out
immibis #7
Posted 26 May 2013 - 08:39 AM
Or it could also be caused by doing ray traces on the server.
Rybec #8
Posted 31 January 2014 - 12:56 AM
This bug also exists under 1.6.4 running FTB Direwolf20 pack v1.0.12. Have only been able to test on one server, unsure what additional plugins they are running.
Not only are coordinates inaccurate, but some columns become completely inaccessible. Which columns are inaccessible depends on the monitor's orientation; pixels near the center are much more accurate than pixels near the edge of the screen. Player positioning and angle to screen does not seem to affect results.
As a result I am now forced to label my elevator stops in leetspeak via the on-screen keyboard…..
Lyqyd #9
Posted 31 January 2014 - 01:31 AM
Do you have optifine installed?
oeed #10
Posted 31 January 2014 - 01:39 AM
I have found that if the resizing of your Minecraft window glitches out (it doesn't cover the entire window or is too big) the hit detection completely breaks. However, this is universal to buttons, monitors and blocks.
MKlegoman357 #11
Posted 31 January 2014 - 08:55 AM
I've dealt with this problem on Mack's server (1.5.2) and on other servers too (1.6.4). My guess was inaccuracity between server and client.

The problem I think is: when client sends player information it is not very accurate. At the server's end the player is lets say 1 degree rotated more to the left. When a player clicks on monitor the info that a player clicked a block is sent to the server but the actual click (the pixel the player clicked) is counted on the server's end thus the click is inaccurate.

The solution i think would be: count the pixel the player clicked on the client side and send information to the server with the exact pixel coordinates.
Rybec #12
Posted 31 January 2014 - 07:52 PM
Do you have optifine installed?
I do not. The server may be running Bukkit though, I am awaiting a reply from their end. If so I will attempt to reproduce in a clean environment.
I find it interesting that while the click detection is not accurate, it IS consistent. With practice I can learn where to click to hit the pixel I really want, except for certain columns which will not register no matter where I click.


EDIT: Just tested on a locally hosted server; both client and server running only Forge and Computercraft. Inaccuracy is present and consistent with observed behavior on my regular server. I.E. if I am facing west, I cannot click the same columns as in my MP base. Errors match up for other directions as well. Singleplayer continues to function normally. At first I was thinking perhaps player view angles were being truncated or rounded, but that would imply that if I cram my face into the monitor, face exactly perpendicular to it and move the cross hair with my position I should be able to get full access to all pixels. This is not the case. If I am facing south, no combination of position or angle will let me click columns 2, 6 or 10. All Y coordinates are click able, but do not match what the user sees.
Edited on 31 January 2014 - 07:34 PM
Cloudy #13
Posted 02 February 2014 - 02:17 PM
Can not confirm. I have never ever experienced this issue despite multiple setups. Can you set up a world download?
Sangar #14
Posted 03 February 2014 - 03:02 PM
If it's the same issue I was having (and I'm assuming it is, because it very much looks like it - I can reproduce it), then the problem is probably that Minecraft's 'Packet15Place' is weird and transmits the hit offsets as integer values truncated to a [0,16] value range (see the read/write methods in that class). Assuming you use the hitX/Y/Z floats passed to onBlockActivated on the server, you'll get the reported loss of precision. In single player there's always full precision because the packet is never written to a data stream, the very instance created by the client is directly used by the integrated server. You'll only get full precision on a dedicated server by using a custom packet for touch events. The question is whether that's worth it in this case, since it's borderline unnoticeable.
Cloudy #15
Posted 04 February 2014 - 01:27 PM
That is exactly how it is done. Thank you for the information! Very helpful. Dan should either now be able to fix this, or not fix it.