#(Yamie) How to find the block state of the block the player breaks

134 messages · Page 1 of 1 (latest)

muted galleon
#

I am trying to find the note blockstate of a noteblock a player breaks

stone shuttleBOT
candid hullBOT
#

(Yamie) How to find the block state of the block the player breaks

#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

neon cove
#

there are several tags for note blocks depending on what specifically you want

minor vector
#

You dont have to make a thread for any question to the same problem.

muted galleon
#

how is this the same problem

neon cove
#

oh it's just a duplicate

minor vector
#

The last 5ish threads are about making custom blocks with note blocks

#

You can have one thread for that :D

muted galleon
#

if i have 1 thread for it after about a day it will never be seen again

minor vector
#

that's not true

neon cove
#

no

#

we routinely go through older threads

muted galleon
#

oh

#

mb

neon cove
#

and threads with active discussion aren't even hidden for us to begin with

minor vector
#

And if you resolve a thread to early, it's technically gone for us.

neon cove
#

we do lose it when you mark it as resolved

#

which you seem to do before your actual issue is solved

muted galleon
#

because alot of the time you guys reference me to tags and stuff that i usually put together myself and figure out how to do it

neon cove
#

that's fine, i just wanted to be clear

muted galleon
#

ig after this thread next time i have a question ill just make 1 thread called "Custom Blocks With Note Block Blockstates" and leave it open

neon cove
#

after you mark a thread as resolved, it's highly unlikely that anybody will see it again

muted galleon
#

is there any way to mark a thread as like currently unused

#

and then un mark it when i need it again?

minor vector
#

You can reopen closed threads at any time yes

neon cove
#

use /helpthread to do so

muted galleon
#

so just have 1 thread and do resolved and then reopen it when i need it

minor vector
#

for one specific project, yes, totally fine

#

(project would be your note block thing)

muted galleon
#

im probs gonna be working on this 1 project for a long time

#

anyway i will do that

#

how am i able to replace the note block drop when i break it in survival depending on what blockstate the note block has?

minor vector
#

!e breaks block

wooden lilyBOT
# minor vector !e breaks block
Group

Player

Event Lines

player breaks block player breaks <material>

Switches

with:<item> to only process the event when the player is breaking the block with a specified item.

Triggers

when a player breaks a block.

Has Player

Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Context

<context.location> returns the LocationTag the block was broken at.
<context.material> returns the MaterialTag of the block that was broken.
<context.xp> returns how much XP will be dropped.
<context.should_drop_items> returns whether the event will drop items.

Determine

"NOTHING" to make the block drop no items.
ListTag(ItemTag) to make the block drop a specified list of items.
ElementTag(Number) to set the amount of xp to drop.

Has Known Location

True - this adds switches in:<area> + location_flagged:<flag name>.

Cancellable

True - this adds <context.cancelled> and determines cancelled + cancelled:false.

muted galleon
#

so far i have tried to detect what the block state is and use - drop

minor vector
#

determinations ^

#

check the block and depending on what it is determine a different drop

#

!guide first world script

muted galleon
#

checking through now

#

im confused on how i use a <> statement to set a variable

#
  • determine <context.should_drop_items> false?
minor vector
#

The guide explains how it works

#

context.tags are just additional tags you can pull information with, from an event

#

determinations set the outcome of an event, each determination is described in meta

#

if you - determine nothing the block will drop no items

#

if you provide a list of items, or a item tag the block will drop that

#

if you provide a number, the block will drop xp

muted galleon
#

in an item am i able to define a blockstate?

#

in one of these

block_drop:
    type: item
    material: note_block
    display name: <&r>Block
#

cause i know how to define custom model data but cant figure out how to define the note and instrument

cosmic condorBOT
#
Changed to Help/Support

Thread is now a Help/Support thread. A helper will check your thread when available.

muted galleon
#

how would i make a sound play based on what block the player is holding

#

e.g. they are holding stone and i want the sound to be stone place

#

or e.g. they are holding a door and i want it to play wood.place

wooden lilyBOT
#
Cannot Specify Searched Command

Multiple possible commands: PlaySound, PlayEffect, DisplayItem, playerpoints.

#
Possible Confusion

Did you mean to search for mechanism flag?

lone pendant
#

!c playsound

wooden lilyBOT
# lone pendant !c playsound
Group

world

Syntax

playsound (<location>|...) (<player>|...) [sound:<name>] (volume:<#.#>) (pitch:<#.#>) (custom) (sound_category:<category_name>)

Short Description

Plays a sound at the location or to a list of players.

Description

Plays a sound to a player or nearby players at a location.
The sound is played through the player's client just like any other sounds in Minecraft.

For a list of all sounds, check https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html

Sounds are by default played under their normal sound type (eg zombie sounds are under the type Mobs/Animals).
You can optionally instead specify an alternate sound category to use.
For a list of all valid sound categories, check <@link url ht...

lone pendant
#

@muted galleon

#

And

#

!e player holds item

wooden lilyBOT
# lone pendant !e player holds item
Group

Player

Event Lines

player scrolls their hotbar player holds item

Switches

item:<item> to only process the event when the player is going to hold a specified item.

Triggers

when a player scrolls through their hotbar.

Has Player

Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Context

<context.new_slot> returns the number of the new inventory slot.
<context.previous_slot> returns the number of the old inventory slot.

Has Known Location

True - this adds switches in:<area> + location_flagged:<flag name>.

Cancellable

True - this adds <context.cancelled> and determines cancelled + cancelled:false.

muted galleon
#

okie dokie ill try it now

muted galleon
#

im looking to cancel the sound of a note block breaking not play a sound

vernal bluff
#

!m stop_sound

wooden lilyBOT
# vernal bluff !m stop_sound

Stops all sounds of the specified type for the player.
Valid types are AMBIENT, BLOCKS, HOSTILE, MASTER, MUSIC, NEUTRAL, PLAYERS, RECORDS, VOICE, and WEATHER
Instead of a type, you can specify a full sound key, which usually has the 'minecraft:' prefix.
If no sound type is specified, all types will be stopped.

Object

PlayerTag

Input

ElementTag

vernal bluff
#

Try this ^

#

that's a mechanism, should be used with adjust

muted galleon
#

i have this but how do i format it correctly

#
  • adjust <player> stop_sound minecraft:block_wood_break
vernal bluff
#

If that's an existing minecraft sound key then yep, it should work

#

just try it

muted galleon
#

its underlined but ill try

vernal bluff
#

stop_sound:minecraft:block_wood_break
"stop_sound:minecraft:block_wood_break"

#

One of these should work fine

muted galleon
#

it does not work :p

vernal bluff
dim pendant
#

You don't need quotes there

muted galleon
#

what im trying to do is when the player breaks a note block it cancells the original sound and plays a new one, i would just remove the note block break sound as a work around but it just uses the wood break sound

dim pendant
#

on runs before the block break happens, so the sound hasn't played yet

#

!l on vs after

wooden lilyBOT
#
Possible Confusion

Did you mean to search for script event after vs on?

wooden lilyBOT
# dim pendant !l on vs after

Modern ScriptEvents let you choose between "on" and "after".
An "on" event looks like "on player breaks block:" while an "after" event looks like "after player breaks block:".

An "on" event fires *before* the event actually happens in the world. This means some relevant data won't be updated
(for example, "<context.location.material>" would still show the block type that is going to be broken)
and the result of the event can be changed (eg the event can be cancelled to stop it from actually going through).

An "after" event, as the name implies, fires *after* the event actually happens. This means data will be already updated to the new state
(so "<context.location.material>" would now show air) but could potentially contain an arbitrary new state from unrelated changes
(for example "<con...

Group

Script Events

muted galleon
#

so put it in a after player breaks note_block: section

#

i have this but it dosent seem to work

vernal bluff
#

There was a thread with cancelling portal sounds and there was a point that some of the sounds are client-side and you can't really cancel them. If everything okay, that can probably be the case?

muted galleon
#

damn

#

gues it will just sound a little weird

#

thats fine

vernal bluff
#

Did you tried to stop all the sounds instead of just one?

muted galleon
#

ive tried on player hears sound:

  • determine cancelled
    and that didnt work either
vernal bluff
#

Just tried it - enabled rain in the world, stop_sound stopped rain sound for a moment but not a block breaking one. The same will be with the portal, opening a chest and etc, that comes from a server

muted galleon
#

damn

#

do you happen to know if there is a way to detect what face of a block the player places a note_block on

vernal bluff
#

It is something about .relative tag, as I remember, but I'm not sure. It'll be better to wait for someone else's answer

muted galleon
#

ive had icecapade help me but we couldnt rlly figure at a way to do it other than player.direction & player.eye_location.ray_trace[return=normal] which is the old method of directional block placement

#

im looking to replicate how logs are placed, which is based on what block face you right click on it chages the direction

vernal bluff
#

Actually... I found one thing, but it could not be that helpful as we want... Let me show you

#

!e player clicks block

wooden lilyBOT
# vernal bluff !e player clicks block
Group

Player

**WARNING**

this event may in some cases double-fire, requiring usage of the 'ratelimit' command (like 'ratelimit <player> 1t') to prevent doubling actions.

Event Lines

player (right|left) clicks <block>

Switches

with:<item> to only process the event if a specified item was held.
using:hand/off_hand/either_hand to only process the event if the specified hand was used to click.
type:<material> to only run if the block clicked matches the material input.

Triggers

when a player clicks on a block or in the air.

Has Player

Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Context

<context.item> returns the ItemTag the player is clicking with.
<context.location> returns the LocationTag the player is clicking on.
<context.relative> returns a LocationTag of the air block in front of the clicked block.
<context.click_type> returns an ElementTag of the Spigot API click type <@link url https://hub.spi...
<context.hand> returns an ElementTag of the used hand.

Has Known Location

True - this adds switches in:<area> + location_flagged:<flag name>.

Cancellable

True - this adds <context.cancelled> and determines cancelled + cancelled:false.

vernal bluff
#

<context.relative>

#

but it seems like you're seeking for an action inside the block placement event

muted galleon
#

what im doing is when the player right clicks the side of a note_block it removes the note update and sets the side of the block that the player clicked on to the block in the players hand as well as removing 1 item from the players hand the only problem is that when its a directional block like a log it just places it vertically, so what i think i could do is:
compare
<context.location.block>
and
<context.relative.location.block>
and get the value it provides to detect where the block was placed as this will fix it for vanilla blocks as well as i could apply this same logic to when a player clicks a vanilla block which should in theory provide my expected outcome

#

sorry for the paragraph

#
- if <context.location> -= <context.relative> == 0,0,1:
#

how would i compare these 2 numbers

#

im trying to subtract the second 1 from the first 1 which should result in a 1 block ofset

amber yew
#

!t location.sub

wooden lilyBOT
amber yew
#

first, if you are subtracting locations you need to use the tag. bare math symbols arent supported

#

2nd, a location wont ever just equal 0,0,1 or anything like that. you can compare each of the parts though

#

!t location.x

wooden lilyBOT
amber yew
#

ie with that

muted galleon
#

thank you, i will have to try it when i get home

cosmic condorBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@muted galleon