#BlockEvents.placed delay

69 messages · Page 1 of 1 (latest)

hollow wave
#

hello, i am trying to make it so nether wart cannot be placed in the overworld. natually i start by making nether wart not placeable at all, and blockevents.placed does this, but even on singleplayer the nether wart still does the placing animation, and is shown as placed very briefly.
is there a faster way to prevent the event (aka nothing happening.)

lavish summitBOT
#

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

stoic spruce
#

you need to place a script in the clientscripts to prevent the block from showing up

#

you can place the same script you made but without any server related part

hollow wave
#

im not sure exactly which is a server-related part, but when i paste the same line into just the client_scripts folder, it doesn't seem to do anything. (added a say hi cmd to make sure it ran and it did)

stoic spruce
#

i don't think the runCommand is ever gonna run, place after the =>

hollow wave
#

the say hi does execute, even when after the blockevent line

#

though i did notice it says server in it so peculiar but doesnt rly matter

stoic spruce
#

did you reload you assets

#

F3 + t

hollow wave
#

yeah, only says hi after asset reload

#

and did /reload etc

stoic spruce
#

does the block still show up?

loud galleon
#

never call server on client side or you will crash when playing on a multiplayer

hollow wave
#

does still show up briefly
like running Utils.server on *singleplayer is nono? got it

loud galleon
#

use event.player.tell("Hi") when testing

hollow wave
#

ok

loud galleon
#

isn't block placed event too late?

#

what are the other options?

hollow wave
#

not sure what you mean, i only have that single line in both the server script and client script and confirm both are running

loud galleon
#

BlockEvents.rightClicked

#

you should try this

#

oh... that is not for inv

hollow wave
#

BlockEvents.rightClicked('minecraft:soul_sand', event => event.cancel()) does make it so that blocks cannot be placed onto soul sand, however still has a visible delay where the block gets deleted

stoic spruce
#

did you place one at client too?

hollow wave
#

i did, and f3+t but i will reboot to be sure

#

doesnt seem to make a difference

stoic spruce
#

weird... is your kubejs updated?

hollow wave
#

i will load same scripts into a 1.20.1 world and see if it does the same thing

loud galleon
#

KubeJS uses Arch events to do that, you may want to try Forge event

hollow wave
#

ok i switched to 1.20.1 FABRIC and it actually works perfectly

#

i haven't heard of those, is there a place on the wiki where it goes over those because i dont see it in any events areas on the wikis

#

unless it isnt a kubejs thing at all

loud galleon
#

it is not, listening to forge events is too specific, let me get you an example

#
ForgeEvents.onEvent("net.minecraftforge.event.level.BlockEvent$EntityPlaceEvent", (event) => {
  if (event.level.isClientSide()){
    // Do client side stuff here
    event.setCanceled(true)
  } else {
    // Do server side stuff here
    event.setCanceled(true)
  }
})

@hollow wave use this on STARTUP_SCRIPTS

#

after listening to this event, you may want to /probejs dump

#

to have auto completion

#

on the event

hollow wave
#

oh boy ok
so do i put my own lines into the if() and else() parts?

loud galleon
#
ForgeEvents.onEvent("net.minecraftforge.event.level.BlockEvent$EntityPlaceEvent", (event) => {
  if (event.placedBlock.block.id == "minecraft:nether_wart"){
    if (event.level.isClientSide()){
      // Do client side stuff here
      event.setCanceled(true)
    } else {
      // Do server side stuff here
      event.setCanceled(true)
    }
  }
})

yes, and put over the IF if what you do is common to client

#

launching my instance to test too

#

rip, didn't work 😐

hollow wave
#

the last one you posted does cancel it but not any quicker than just putting in server script oof

#

but you must be right about something on forgeside because fabric isnt having an issue
or maybe it's 1.19.2 so i will try on forge 1.20.1 real quick

loud galleon
#

i'm on 1.19.2 too here

#

hmmm looks like it is not triggering on client side

hollow wave
#

yeah and 1.20.1 is the same deal so i would assume this is just some kind of oversight but idhk cuz that link you sent makes my head spin

#

appreciate you giving it a try 👍

loud galleon
#

I'm trying other event that triggers on both

#

yes, it worked, now i'm going back to normal kubejs and see if I can not use forge event

hollow wave
#

madman

loud galleon
#
BlockEvents.rightClicked("minecraft:soul_sand", event => {
  console.log("Soul Sand Right Clicked - Server")
  if (event.player.getHeldItem(event.hand).id == "minecraft:nether_wart"){
      console.log("Click cancelled - Server")
      event.cancel()
  }
})
#

this works perfectly, just do at server and client scripts

#

no need for ForgeEvent stuff

#

remember that this does not prevent players from using Create Deployer or other ways to plant nether wart

hollow wave
#

yeah after all this it might be a better idea to just prevent it from growing which i think there are events for, or i can replace a grown version with a non-grown version or something idk but regardless

#

so not to continue to bother you but why does this work, but not the other stuff

#

is this just a way of getting around blockevents.placed which doesnt register on client for some odd reason?

loud galleon
#

placed event only triggers on server side, that is why it flickers

hollow wave
#

cool alright then thank you sir

loud galleon
#

this is not correct anymore

hollow wave
#

i imagine they want it to be clientside too so it's probably just a bug

loud galleon
#

maybe this is a Forge only thing

#

since you tested on Fabric

hollow wave
#

yeah fabric it does work so tis just buggy