#Non-depreciated way to check if PlayerInteractEvent is cancelled?

1 messages · Page 1 of 1 (latest)

wise fox
#

Hey guys!

Title says it all :)

signal crater
#

isCancelled();?

ebon mason
wise fox
ebon mason
#

it shows you in the description

proud echo
#

it tells u how to check it then

warm mortar
#

Pro tip if something in the api is deprecated there's always an explaination in the javadocs as to why and what to do instead

ebon mason
#

Event.Result

wise fox
#

Yeah I read the description, and was able to get the results... but I couldn't figure out how to check if those results are cancelled? Perhaps I'm missing something obvious here :P

ebon mason
#

if they are allowed then its not cancelled

#

if denied then cancelled

#

if default then they are not modified

#

p sure

#

and to set cancelled you use setUseInteractedBlock or useItemInHand and pass in the Result

wise fox
#

what do I pass the result to? 😅

ebon mason
#

what

wise fox
#

as in, how do I check if it is allowed, denied, or default

ebon mason
#

if (useItemInHand == Event.Result.Allow)

warm mortar
#

Same goes for useInteractedBlock

wise fox
#

oooooooooooh

#

man I feel kinda stupid for not trying that myself

#

tysm :)