Carpet

Carpet

2M Downloads

fake player can not activate the lever when i use player command

PunChen opened this issue ยท 6 comments

commented

when i use command player Alex spawn , i drop a lever to alex , then i use command player alex use , he place the lever on the block as expected ,but when i use command player alex use again ,he didn't activate the lever as i thought ,why , is this a bug?
ps: i am using carpet for 1.16.1 file name is fabric-carpet-1.16.1-1.4.0+v200623_build2.jar

commented

I'm noticing this same issue in carpet 1.4.7+v200806 using fabric 0.9.0+build.204 and minecraft 1.16.2-pre3, it's working fine with buttons also, and i can confirm it's not an issue with just looking at the wrong location, because using F3+B i can see that the fake player's line of sight directly intersects with the lever's hitbox

However placing a lamp right next to the lever reveals that he is indeed pressing the lever, but just at such a high speed that it turns off again before /player .. use once will actually stop him using, i'm assuming then (haven't looked at code maybe should) that /player .. use once uses the same logic as continuous, but terminates it very quickly, but not quick enough to toggle a lever only once, rather it's toggled back to the original state because it toggles twice

It appears it emits a proper (albeit very short) redstone signal server-side, but it just happens so fast that the client is never sent that event for whatever reason?

I've recorded a video showing this issue, and uploaded it to youtube: https://youtu.be/K_PhqJKYaBE

commented

Additionally, the signal is not long enough to interact with redstone torches, or to interact with pistons, and it is not enough to deactivate a redstone lamp or a repeater that is set to one tick, and it also does not cause a block update when it doesn't deactivate a redstone lamp (tested with an observer, which emits a signal when a lamp is toggled on, but not when it is not toggled off), observers can however detect the lever itself being pressed, even if another observer pointing to a lamp under it cannot detect that

commented

I have checked the code ,but i didn't find any clue to edit the code,do you have any idea for this ?

commented

Potential fix: Edit the code so that the fake player only flips the lever once, rather than twice in the same game tick. When /player .. use once gets executed, the lever is intended to change state once per execution, not twice.

commented

Buttons work as intended since it triggers the first time it is pressed. It stays on for 20 game ticks (stone and blackstone) or 30 game ticks (any type of wood) regardless if it is pressed again during the delay. In other words, if the button is already on and the delay is still running, the button will not accept any more presses until the delay is over.

commented

fixed