#Is it possible to prevent a specific block from being placed on another specific block?

32 messages · Page 1 of 1 (latest)

hearty gyro
#

I'm trying to prevent a specific flower being placed on a specific soil block. I know there is the BlockEvents.placed event that is cancellable, but how do I identify the block the flower is being placed on in order to see whether the place should be cancelled?

gentle mauveBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

north torrent
#

event.block.down will give you the block below the one you placed

#

you can check the ID of the block + block below and cancel the event

hearty gyro
#

Thank you, that sounds like what I need! I'll give that a try later catheart

hearty gyro
#

I finally had time to sit down and test this, it worked! Now I just need to figure out why there is a desync issue even with the script being on both client and server hmmm

#

The flower is indeed prevented from being placed and is returned to the inventory, but it looks like it just disappeared from your inventory until you click the slot it was in.

north torrent
#

try player.sendInventoryUpdate()

hearty gyro
#

I tried adding that in on both sides, but it didn't change anything. I thought maybe I needed to do a full reboot of the game and now its rolled my script back to a non-working version... wtf??

#

Ok gonna shut everything down and try saving without the game open, bizarre hmmm

north torrent
#

=.=

hearty gyro
#

So... I booted the game back up after fixing the script. It was no longer working as intended in game until I did a /reload, even though I didn't change anything

#

I'm not sure what is going on, I've never seen this before

north torrent
#

event.player

hearty gyro
#

Ahh

#

Its still not preventing the desync

north torrent
#

hmmm

hearty gyro
#

also tried event.player.inventory.markDirty() hmmm

north torrent
#

try putting the update before and after the cancel
not sure if the cancel stops execution in 1.20

hearty gyro
#

Tried putting it before and after, both server and client side, no difference

north torrent
#

._.

hearty gyro
#

edit: nevermind I am silly, its still broke but whatever it semi works

#

Thank you for your help!

north torrent
#

i dont know why its not fixed very_sad_kitty_lex

#

one last try
see if this works, or throws errors

event.player.inventoryMenu.broadcastFullState()
#

thats from an older version

hearty gyro
#

Putting that before the cancel seems to have worked 🥳

#

The script doesn't always work on game start but uh... it does work after a /reload

#

Maybe I need to mess with priority

#

But the desync is fixed, thank you!

north torrent
#

oooh