"make player see block as" left click makes it disappear

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

MiiTsY

Member
May 27, 2022
41
1
8
26
skript 2.6.2
mc : 1.17.1

Code:
on join:
    wait 10 tick
    loop all players:
        make loop-player see block at location(-19.5, 43.5, 360.5) as stone
        make loop-player see block at location(-18.5, 43.5, 360.5) as stone
        make loop-player see block at location(-17.5, 43.5, 360.5) as stone
        make loop-player see block at location(-16.5, 43.5, 360.5) as stone
        make loop-player see block at location(-15.5, 43.5, 360.5) as stone
        make loop-player see block at location(-14.5, 43.5, 360.5) as stone
        make loop-player see block at location(-13.5, 43.5, 360.5) as stone

I was testing stuff out but noticed that on left click, client blocks becomes back to air, in my case.
Is there a way to prevent that from happening?
 
I'm not an expert in "make %player% see block at %location% as %itemstack%", but I do think they are a type of ghost blocks, since technically only you can see it, the server can't.

I really hope I didn't say anything stupid xdd.
 
I'm not an expert in "make %player% see block at %location% as %itemstack%", but I do think they are a type of ghost blocks, since technically only you can see it, the server can't.

I really hope I didn't say anything stupid xdd.

Yeah I know that, and by left clicking, the server updates the block, so it becomes air. That is why im asking if anyknow know how to prevent that!
 
Yeah I know that, and by left clicking, the server updates the block, so it becomes air. That is why im asking if anyknow know how to prevent that!

I would like to help but i really don't know, the only thing I can think of is doing it every tick or second
 
You can not prevent a client-side block to be removed on an easy way. You could go the complicated route via packets though.

The easiest way would probably be to set this block every 5 ticks, when the player is able to see the block.
 
You can not prevent a client-side block to be removed on an easy way. You could go the complicated route via packets though.

The easiest way would probably be to set this block every 5 ticks, when the player is able to see the block.

is there a condition that could work like
"if player see event-block as air"
or something like that ?
Otherwise I will just go with a "while player is online" i guess


edit:
I doesnt seem like it exist so I went for this:

Code:
on right click:
    wait 1 tick
    if event-block is air:
        make player see event-block as stone

on left click:
    if event-block is air:
        set event-block to stone
        wait 4 tick
        set event-block to air
        wait 1 tick
        make player see event-block as stone

for some reason 1 tick is enough for the right click but left click needs about 5 ticks to not disappear still time to time by left clicking so then in between the 5 ticks player can slip thru so had to set it to stone then air, will kinda look weird on other players perspective tho

edit:edit: Ok so client blocks seems to be affected by game performance which means the 5 ticks from left click or 1 tick from right click will not work if the client game freeze :/

I will just go with a loop LOL
 
Last edited:
I'm unsure if the server will send the chunk to the user every time the block is updated so I'd suggest something like the following:
Code:
options:
    location: location at (-19.5, 43.5, 360.5) in world "world"
    block: stone

on join:
    wait 10 ticks
    make player see block at {@location} as {@block}

every tick:
    loop all players within 10 meters of {@location}:
        make loop-player see block at {@location} as {@block}
 
Didnt think of "within 10 meters"!

Thank you, that will save me from some server lag xD


--------------------
final code
Code:
every tick:
    loop all players within 128 meters of location(-16.5, 43.5, 360.5):  #server view distance
        if {route1.%loop-player's uuid%} is not set:  #event to unlock
            set {_i} to -19.5
            loop 7 times:
                make loop-player see block at location({_i}, 43.5, 360.5) as stone
                add 1 to {_i}


on right click:
    if event-block is air:
        set {route1.%player's uuid%} to true #condition fullfilled
        play sound "entity.zombie.break_wooden_door" with volume 2 at event-block for player
        
on quit:
    if {route1.%player's uuid%}: #to retest
        delete {route1.%player's uuid%}
 
Last edited:
Status
Not open for further replies.