#Redstone ore detection

1 messages · Page 1 of 1 (latest)

low briar
#

Is there a way to detect block state changes and run a command to the player who activated said block state change?

More specifically, I want players who interact with redstone ore (right click or step on), to trigger a /loot give command

grave breachBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 After a while, hit the Summon Helpers button to ping the helper team. They'll be happy to help you

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

vestal zealot
#

You can use an advancement withe an item_used_on_block trigger or a step_on condition

low briar
vestal zealot
#

Powerd and unpowere redstone ore are two different block states. You can make the check more specific and make it only trigger if it has one specific block state

low briar
#

how would it detect the player, and not just the nearest entity?

#

I'm new to datapacks

vestal zealot
#

Advancements are a player only thing.

#

They also execute a reward function from and as the player

low briar
#

Would it look something like this?

{
"criteria": {
"interact_with_redstone_ore": {
"trigger": "minecraft:player_interacted_with_block",
"conditions": {
"block": "minecraft:redstone_ore"
}
}
},
"rewards": {
"function": "namespace:your_function_name"
}
}

#

Would that detect the interaction with redstone ore?

low briar
vestal zealot
#

I suggest using misode to make the advancement, it is much easier

sonic plazaBOT
#
**📖 Misode**

Awesome website with generators for almost everything. Also contains a technical changelog for new versions, guides on how to use some features, a performance report inspector and more!

Full list of generators: Loot Tables, Predicates, Item Modifiers, Advancements, Recipes, Text Components, Damage Types, Chat Types, Trim Materials, Trim Patterns, pack.mcmetas, Dimensions, Dimension Types, Biomes, Configured Carvers, Configured Features, Placed Features, Density Functions, Noise, Noise Settings, Structures, Structure Sets, Processor Lists, Template Pools, World Presets, Flat World Presets, World Settings, Block Tags, Entity Type Tags, Fluid Tags, Game Event Tags, Item Tags, Biome Tags, Structure Tags, Blockstates, Models, Fonts, Atlases

Link: https://misode.github.io/

vestal zealot
#

There is a field called Blockstate, look ingame with f3 what that Blockstate is called exactly and then put that in there, press the plus button and then select boolean.

low briar
#

what would the criteria be?

vestal zealot
#

Item used on block

low briar
#

Would that mean an item would be necessary to activate the advancement?

vestal zealot
#

No

#

If you don't specify one, it won't need one.

low briar
#

I'm confused with the requirements tab

low briar
#

In misode

vestal zealot
#

One minute, I'm on my pc in just a moment, then I can show you better

low briar
#

okay 🙂

vestal zealot
#

the block state is called lit btw

low briar
#

[lit=true]
or just
lit

#

Also, I'm using 1.16.5, if that changes anything

vestal zealot
#

that changes a little bit

low briar
#

I still found where I need to be

vestal zealot
#

only write lit in the field an then press the green plus

low briar
#

The only difference is location is not a condition anymore

vestal zealot
#

it will look like this

low briar
#

yes

vestal zealot
#

click on string and select boolean

#

then, make it true or false, depending on what you want

low briar
#

So true would mean the redstone ore that is lit would activate the datapack reward to the player?

vestal zealot
#

yes, true means only lit ores can activate it

low briar
#

I want players who activate the redstone ore to recieve a reward

vestal zealot
#

then set it to false

low briar
#

ah ok

#

and for the reward, would a /give loot pouch
function work?

#

a loot table also could work

vestal zealot
#

if the player is supposed to get an item and nothing else should happen, then a loot table is enough

low briar
#

sure

#

so the modded loot table is
{LootTable:"mineminenomi:chests/marine_large_base/captain"}

#

would I simply paste that into loot tables?

vestal zealot
#

no, only the path

low briar
#

Yea I figured that out

#

I see

#

And a display wouldn't be necessary

#

I would now download this and paste this into the datapacks folder?

#

Oh this is a json

vestal zealot
#

that or just copy the code

low briar
#

neat

#

advancement.json

vestal zealot
#

I was testing around but it seems you can't detect if the player r-clicks an unlit redstone ore

#

the advancements is apparently later in the tick list than the block state change

low briar
#

is there any workaround?

vestal zealot
#

raycast

low briar
#

raycast?

vestal zealot
#

maybe

#

wouldn't work, forget it

low briar
#

so this is a minecraft limitation?

#

damn

vestal zealot
#

yeah, it has something to do in which order the events are processed internally

low briar
#

i'm probably asking the wrong question, but did you forget to set the block id?

#

maybe double check if everything is there

vestal zealot
#

I did forget it

low briar
#

ah thank god

vestal zealot
#

but it doesn't seem to change anything

low briar
#

maybe dimension?

#

i'll try true and false to maybe see if that changes anything

vestal zealot
#

it detects the click, the only thing that doesn't work is checking for a click on an unlit ore

low briar
#

so the block state itself doesn't work

#

damn

vestal zealot
#

the block state changes from unlit to lit before the advancement checks it, that's why you can't check for unlit

low briar
#

awww

#

would a mod possibly change this?

#

instead of using a datapack?

vestal zealot
#

could be a possibility

low briar
#

I've got no modded coding experience 😂

thats gonna be fun

vestal zealot
#

what works though is the step on ccheck

low briar
#

step on?

#

even with the block state?

vestal zealot
#

stepping on unlit redstone

#

yes

low briar
#

That works for me

#

!!!!

#

Bro thank you 🙂

#

how can I repay you

vestal zealot
#

This is a 2 step process, making a predicate and an advanccement

vestal zealot
low briar
#

i can't afford that even selling my organs -_-

vestal zealot
#

The predicate is a simple location check with a y offset of -1, the block and block state is the same as before

#

predicates need to be in a separate predicates folder in your datapack

low briar
#

is it exact or range?

vestal zealot
#

are you in the advancement or predicate generator?

low briar
#

oh advancement generator my bad

#

i'll switch to predicate

#

how would i reward?

vestal zealot
#

the reward comes in the advancement part

#

we only need the predicate because with and advancement location check, we can't have an offset

low briar
#

since you have it working, wouldn't it be easier to send me the datapack you got working?

#

I'm a little new on the whole datapack fomatting

vestal zealot
#

I don't have a full data pack, I was just testing the other stuff earlier.

low briar
#

the predicate is the location check?

vestal zealot
#

the predicate is the location check and we need to change the advancement to a tick advancement that references the predicacte.

low briar
#

invalid characters?

#

there is an error message

vestal zealot
#

everything in betweenn <> is just a placeholder

sonic plazaBOT
#
📂 Datapack Folderstructure
                .
                ├── pack.mcmeta
                ├── pack.png
                └── data
                    └── <namespace>
                        ├── advancements
                        ├── functions
                        ├── item_modifiers
                        ├── loot_tables
                        ├── predicates
                        ├── recipes
                        ├── structures
                        ├── chat_type
                        ├── damage_type
                        ├── tags 
                        │   ├── blocks
                        │   ├── entity_types
                        │   ├── fluids
                        │   ├── functions
                        │   ├── game_events
                        │   ├── items
                        │   ├── chat_type
                        │   └── damage_type
                        ├── dimension
                        ├── dimension_type
                        └── worldgen
                            ├── biome
                            ├── configured_carver
                            ├── configured_feature
                            ├── density_function
                            ├── noise
                            ├── noise_settings
                            ├── placed_feature
                            ├── processor_list
                            ├── structure
                            ├── structure_set
                            ├── template_pool
                            ├── world_preset
                            └── flat_level_generator_preset
                        ```
low briar
#

removed <>, now it works

#

i think I got the datapack formatted, i'll try running it

#

my game crashes?

vestal zealot
#

what?

#

that can't happen because of the data pack

#

what does the log say?

low briar
#

i'll try another instance without mods

sonic plazaBOT
#
:information_source: Default Launcher Logs

The logs are where Minecraft displays errors when something goes wrong and can thus help you gain information about why something isn't working for you!
To open the logs:

  1. Enable logs in the Minecraft Launcher
  2. Start your game (or restart it if you already have an open instance)
  3. Enjoy spotting errors getting much easier!
low briar
#

i'm using ATlauncher, but I think I found it

#

i'll try a new instance before I send the crash log

#

yea its the datapack

#

for the predicate, do I need to set an X and Z offset as ~?

vestal zealot
#

no

low briar
#

I can send a full crash log if that helps

vestal zealot
#

yeah

low briar
vestal zealot
#

Those logs don't really help

#

It definitely has something to do with the launcher

low briar
#

I'll try it in vanilla launcher

vestal zealot
#

could you send your pack, just to confirm it's right?

low briar
#

the previous file was a .7 zip

#

sent another incase you don't have 7zip

grave breachBOT
#
Result of analysis

I found 3 issues with the structure of your datapack.

  • I couldn't find pack.mcmeta. Make sure that it exists in the root of the zip.
  • I couldn't find the folder data. Make sure that it exists in the root of the zip.
  • I couldn't find the namespace minecraft. It isn't required, but 90% of datpacks do need to have it. If you don't use tick/load functions or you don't need to change vanilla data, then disregard this.
vestal zealot
#

you zipped a folder

#

ou need to zip this

low briar
#

i can't send unzipped files onto disocrd

#

discord

#

oh

vestal zealot
#

apart from that it looks ok

grave breachBOT
#
Result of analysis

I found 1 issues with the structure of your datapack.

  • I couldn't find pack.mcmeta. Make sure that it exists in the root of the zip.
low briar
#

wait

#

would pack format 6 be the issue?

vestal zealot
#

no

low briar
#

i'll try 5

vestal zealot
#

it just for a message ingame telling you that it's from an older version

sonic plazaBOT
#
📦 Datapack Pack Format History

Format: 4 Version(s): 17w48a–19w46b
Format: 5 Version(s): 1.15-pre1–1.16.2-pre3
Format: 6 Version(s): 1.16.2-rc1–1.16.5
Format: 7 Version(s): 20w46a–1.17.1
Format: 8 Version(s): 21w37a–22w07a
Format: 9 Version(s): 1.18.2-pre1–1.18.2
Format: 10 Version(s): 22w11a–1.19.3
Format: 11 Version(s): 23w03a–23w05a
Format: 12 Version(s): 23w06a–1.19.4
Format: 13 Version(s): 23w12a–23w14a
Format: 14 Version(s): 23w16a–23w17a
Format: 15 Version(s): 23w18a–1.20.1
Format: 16 Version(s): 23w31a
Format: 17 Version(s): 23w32a–23w35a
Format: 18 Version(s): 1.20.2-pre1–1.20.2
Format: 19 Version(s): 23w40a
Format: 20 Version(s): 23w41a
Format: 21 Version(s): 23w42a
Format: 22 Version(s): 23w43a–23w43b
Format: 23 Version(s): 23w44a
Format: 24 Version(s): 23w45a
Format: 25 Version(s): 23w46a
Format: 26 Version(s): 1.20.3-pre1–1.20.4
Format: 27 Version(s): 23w51a–23w51b
Format: 28 Version(s): 24w03a
Format: 29 Version(s): 24w04a
Format: 30 Version(s): 24w05a–24w05b
Format: 31 Version(s): 24w06a

low briar
#

ah ok

vestal zealot
low briar
grave breachBOT
#
Result of analysis

I found no issues with the structure of your datapack.

low briar
#

i'll try sending you a crash log with vanilla minecraft launcher

#

There's the crash report, and the launcher log

#

I'll try changing it to "predicates.json" instead of "predicate.json"

#

@signal chasm

signal chasm
low briar
#

would you be able to help?

#

sorry to bother you

signal chasm
#

What's the question

low briar
#

the datapack I have, is currently crashing

signal chasm
#

What were you doing in the datapack?

low briar
#

We were trying to run a step on predicate alongisde an advancement.json that would detect a player walking ontop of a redstone ore

#

the block state of the redstone ore would go from unlit to lit, thereby activating the reward

#

To put it simply, I'm trying to reward players for walking ontop of redstone ore (to light it up)

#

For some reason the datapack simply crashes upon load

#

Should I wait for HeDeAn if he may be of better help?

signal chasm
#

you have an incorrect datapack, you only have the namespace "maincraft", there is no namespace "namespace" and "mineminenomi"

low briar
#

how would i go about fixing this?

signal chasm
#

you can immediately put the predicate in the advancement.
and also, what kind of loot should be on the "mineminenomi:chests/marine_large_base/captain" path?

low briar
#

"mineminenomi:chests/marine_large_base/captain" is the loot table

#

it's from the mod

low briar
#

it doesn't crash anymore, but it simply doesn't work

signal chasm
#

give the datapack again

low briar
#

shall i try changing the loot table reward to a vanilla one?

#

still does not work with "minecraft:chests/simple_dungeon"

signal chasm
low briar
#

1.16.5

signal chasm
#

oh

#

then idk

low briar
#

I think I have a solution, but I'll have to test it. I simply set a repeating always active command block that detects players standing upon a redstone ore[unlit]

low briar
#

I slept. Timezone different here. I'll get back to you guys soon

low briar
#

execute as @a at @s if block ~ ~-1 ~ minecraft:redstone_ore[lit=false] run loot give @s loot mineminenomi:chests/marine_large_base/captain

low briar
#

Block detection isn't precise though, and players who fall or jump onto the redstone ore trigger the command block multiple times

low briar
#

So the problem isn't really solved...

low briar
low briar
#

I think I'll try and write a mod from the ground up for this task

celest anvil
low briar
#

The command block workaround works, but triggers the reward too many times if players were to fall or hover over the redstone ore

celest anvil
#

what's the point of the datapack

#

what does it do

low briar
#

It's meant to detect and give a loot table whenever a player would step on a redstone ore (that is unlit)

celest anvil
#

whaaaat

#

but that sounds soooooo easy

#

is there a blockstate for redstone ore being lit or not?

low briar
#

Yes, we have already tried that

celest anvil
twin pilot
low briar
#

I have got a mod working for what I want

#

I can upload it to the public

grave breachBOT
# low briar I can upload it to the public
🎗️ Is your question resolved?

If your question is resolved, that's great to hear! Make sure to run /resolve or click the Resolve Question button. Otherwise, feel free to continue asking for help! :D