#Detect Client Breaking Blocks

36 messages · Page 1 of 1 (latest)

pseudo agate
#

I cannot see a way to detect in a client script when you just broke a block. There's BlockEvents but that's serverside only for some reason.

modern notchBOT
#

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

uneven meteor
#

show your code

pseudo agate
#
BlockEvents.broken(event => {
    event.player.tell("wow you broke a block")
})
#

nada

flat wing
#

what's your goal? why do you need to detect if the client is breaking a block?

pseudo agate
#

just to trigger something on the client without a bunch of network events

#

alternatively, can I detect a native mc packet with NetworkEvents?

uneven meteor
#

you need to tell us your real problem, listening to real network events looks a bit off

raw scrollBOT
#

The XY problem is when you really want to do X, and you think that Y can achieve X. However, you can't get Y to work, and so ask for help exclusively about Y.

This can lead to a lot of confusion from the people trying to help you, as Y can seem like a very random thing to want to do, and a lot of the time isn't the best way to achieve X anyway.

Its fine to ask about Y, just always include some context about X so you can be put on the right track if Y won't do X well, or there is an easier way to do X.

pseudo agate
#

I want to implement a veinmine system with kjs just for fun

#

but sending a network event to the client every time it breaks a block seems silly

#

when i should just be able to detect it on the client

uneven meteor
#

but what you want to send to client? like messages?

#

or show

#

actually

pseudo agate
#

ok, ignore what i said about netowrk stuff

#

all i want to do is detect, on the client, when i break a block

uneven meteor
#

and do what after?

#

i'm trying to see your end goal

pseudo agate
#

see if the client is using a keybind to know if I should veinmine

uneven meteor
#

if the key is down?

#

or something

pseudo agate
#

yea

#

but thats not the problem

uneven meteor
#

what is?

pseudo agate
#

all i want to do is detect, on the client, when i break a block

uneven meteor
#

i will launch my instance to check that, it should work, if not it is a bug that needs to be fixed

#

so, 1.20.1 and latest Rhino/KubeJS?

pseudo agate
#

yup

#

thank you

uneven meteor
#

yes, it is not working, I think I know what it is, going to try to fix here and PR

meanwhile you can use forge event

ForgeEvents.onEvent("net.minecraftforge.event.level.BlockEvent$BreakEvent", (event) => {
  if (!event.level.clientSide) return
  console.log(`Block: ${event.state.block.id} was broken!`)
  event.player.tell(`Block: ${event.state.block.id} was broken!`)
  Client.isKeyDown(86) && event.player.tell("And was broken holding V key")
})

but this will make players and servers needed to have synced files

uneven meteor
#

yeah it is not that simple fix, it is a problem on Architetury @pseudo agate

#

just use forge event

pseudo agate
#

oh ofc, not sure why I didn't think of that

#

thank you