#Right Click With Item

1 messages · Page 1 of 1 (latest)

crude marlin
#

Hello, I am trying to add a datapack in which you right click one item on certain blocks and it will change the block- like bonemeal i guess. Is there an easy way to do this?

jagged gazelle
#

Not necessarily an easy way, but it's not super hard either. You can implement right click detection on any item easily, and have the function that gets run by it so a raycast to find the block that's being looked at

spare zincBOT
jagged gazelle
#

We have guides on both ^

crude marlin
#

Which one would work if I tried to use a wind charge? But not throw it but just right click an item with

jagged gazelle
#

Is there a specific reason you want to use a wind charge?

crude marlin
#

Cuz its like wind, like oxygen for oxidizing copper

jagged gazelle
#

Well that's very different from what you asked, because that's a projectile you throw

crude marlin
#

what would u recommend u think?

#

or is it possible to detect the blocks to be detected by being hit by it?

jagged gazelle
#

Sort of. If you want to use wind charges then you need to make a marker or something ride the wind charge when it gets thrown, and then run a ticking function as and at that marker that checks if it doesn't have a vehicle, then if it doesn't, check the block in front of it to see if it's copper

#

A little more complex

crude marlin
#

Do u have any recommendations on how to learn how to do this?

proper garnet
jagged gazelle
#

Right but I assumed they wanted to use the actual properties of wind charges

jagged gazelle
crude marlin
#

ok ty

crude marlin
#

ok sorry for the stupidity and ignorance but how do i summon 1 marker on the wind charge, cuz i m just thinking putting a summon marker if wind charge is present but i know that would just add hundreds of markers

jagged gazelle
#

Well ideally you're only running the function once via an advancement when the wind charge is consumed/used, and that would run a function as and at all nearby wind charges that don't already have a marker passenger. That function would then summon a marker and use the ride command to make it mount the wind charge

crude marlin
#

ok tysm

crude marlin
#
  "criteria": {
    "thrown_wind": {
      "trigger": "minecraft:consume_item",
      "conditions": {
        "player": [],
        "item": {
          "items": "minecraft:wind_charge"
        }
      }
    }
  },
  "requirements": [
    [
      "thrown_wind"
    ]
  ],
  "rewards": {
    "function": "marker_wind"
  }
}
#

would this work?

jagged gazelle
#

Give it a try

crude marlin
#

ok i am super stumped

#

execute if entity @e[type=wind_charge,nbt=!{Passengers:[{id:"minecraft:iron_golem"}]}] at @e[type=wind_charge,nbt=!{Passengers:[{id:"minecraft:iron_golem"}]}] run summon minecraft:pig ~ ~2 ~ {CustomName:"marker"}

#

i got this running first

#

and then this execute if entity @e[type=wind_charge,nbt=!{Passengers:[{id:"minecraft:marker"}]}] at @e[type=wind_charge,nbt=!{Passengers:[{id:"minecraft:marker"}]}] run summon minecraft:marker ~ ~2 ~ {CustomName:"oxidize_marker"}` i have this function going

jagged gazelle
#
  • Don't check NBT, use a predicate
  • What's the relationship between the first and second command? The first one has an iron Golem passenger, but the second looks for a marker passenger?
  • You don't need to do if entity ... and then an at @e... with the exact same target selectors. Just go straight into the at @e
  • What exactly isn't working?
crude marlin
#

Oh woops, i was using an iron golem to test it out

#

and it just kept summoning iron golems

jagged gazelle
#

Well that's not the command responsible for summoning iron golems, seems like its spawning either a pig or a totally different marker.

crude marlin
#

idk why i messed it up so poorly

#

i just edited and sent it

#

lemme send the actual thing

#

/execute if entity @e[type=wind_charge,nbt=!{Passengers:[{id:"minecraft:marker"}]}] at @e[type=wind_charge,nbt=!{Passengers:[{id:"minecraft:iron_golem"}]}] run summon minecraft:marker ~ ~2 ~

#
  "condition": "minecraft:entity_properties",
  "entity": "this",
  "predicate": {
    "passenger": {
      "type": "minecraft:wind_charge"
    }
  }
}```
#

and how is this for the predicate?

jagged gazelle
#

Well that is checking if the entity has a wind charge for a passenger, not a marker, and you also aren't actually using the predicate. predicate=!<this predicate id> should replace your nbt=!...

#

You also didn't do any of the other things I said

crude marlin
#

sorry for the command i was showing what i was actually using before u said anything

#

so would
/execute at @e[type=wind_charge,predicate=!wind_check_ride] run summon marker work?

jagged gazelle
#

That will summon a marker at the position of every wind charge that doesn't meet the predicate, yes

#

But you need to instead run a new function as and at it, then summons a marker and then makes that marker ride the wind charge (so it no longer meets the predicate, if you fixed it)

crude marlin
jagged gazelle
#

No execute necessary for the summon, but yes

crude marlin
#

Should I add any tags? to either the marker or wind charge?

#

And what do you mean by run a new function as and at it? sorry for my ignorance

jagged gazelle
#

Presumably you'd want them, yes

crude marlin
#

And would that be for summoning the marker?

jagged gazelle
#

That would be how you run the function that summons the marker and makes it ride the wind charge.

crude marlin
jagged gazelle
#

That runs the reward function as the player.

#

Advancement runs function as and at player -> Function includes command that executes as and at the nearest wind charge without a passenger -> Function summons a marker and makes it ride the wind charge

#

I cannot be any more plain than that

crude marlin
#

im so sorry for my ignorance

#

idk why this sometimes takes so long for me to understand, im sorry

#

I think i messed up somehow, i did it so it runs a function that says test when i throw a windcharge and nothing comes out

#
{
  "criteria": {
    "thrown_wind": {
      "trigger": "minecraft:consume_item",
      "conditions": {
        "item": {
          "items": "minecraft:wind_charge"
        }
      }
    }
  },
  "requirements": [
    [
      "thrown_wind"
    ]
  ],
  "rewards": {
    "function": "oxidize:marker_wind"
  }
}```
#

then oxidize:marker_wind function just has say test, but nothing

#

ty for the help btw

jagged gazelle
#

Are you able to grant the advancement in chat?

crude marlin
#

sorry for the delay, but yes i am

#

that makes it say test in chat

crude marlin
#

if there is no detection for checking a wind charge being used, would it be easier for it to be any wind charge?

jagged gazelle
#

Technically, but do you want it to apply to every wind charge?

crude marlin
#

it can be, regardless i figured it out u cant detect wind charge consumed via advancements only statistics- so i used that with a scoreboard function

#

my problem is now trying to figure out how to make it so when it "explodes", it detects that it does and changes the copper blocks to an age later (copper>exposed>weathered>oxidized)

#

would it be an execute command checking if a marker has no "ride" that it will run a function?

jagged gazelle
#

Correct

crude marlin
jagged gazelle
#

I'd recommend placing a configured feature with the /place command

#

Probably a disk, maybe a random patch

crude marlin
#

sorry never used the place command, sorry again about ignorance, would this be a structure i make on my own?

#

Im looking at the configured feature generator and i am def confused sorry

#

idk how to achieve this to this

jagged gazelle
#

Not a structure, just a JSON file

#

Nevermind, it's gonna be too complex for you

crude marlin
#

sorry

jagged gazelle
#

Just have the marker check nearby blocks to see if they're each of the various copper block states, and if they are, have a chance to change them to the next oxidation level

#

execute if blocks a bunch of times

crude marlin
#

so it would be simpler to do a box then like a cricular radius?

jagged gazelle
#

Not necessarily

#

With this method you can do either, the shape is irrelevant

crude marlin
#

so when u mean a bunch of times do u mean for every variant of copper?

jagged gazelle
#

Yep

crude marlin
#

how would i do the chance, sorry again

jagged gazelle
#

A random_chance predicate

crude marlin
jagged gazelle
#

The use of the predicate looks fine

#

But you never ever need to write run execute. The command runs exactly the same without it, but including it is worse for performance

#

You probably also need the at @e[...] before the if blocks ...

crude marlin
jagged gazelle
#

Also what is the armor stand for?

crude marlin
#

oh sorry i changed it so i could see it

#

there

#

/execute at @e[type=marker,tag=throwncharge] if predicate oxidize:random75 if blocks ~2 ~2 ~2 ~-2 ~-2 ~-2 106 -58 20 masked at @e[type=marker,tag=throwncharge] run fill ~2 ~2 ~2 ~-2 ~-2 ~-2 minecraft:exposed_copper replace minecraft:copper_block

#

i changed it to this and it kinda works execute at @e[type=marker,tag=throwncharge] if predicate oxidize:random75 at @e[type=marker,tag=throwncharge] run fill ~2 ~2 ~2 ~-2 ~-2 ~-2 minecraft:exposed_copper replace minecraft:copper_block

jagged gazelle
#

great

crude marlin
#

But idk if it’s the chance or not but sometimes it just doesn’t do it, after I threw it like 10 times

jagged gazelle
#

You're sure you're testing on exposed_copper blocks and not waxed_exposed_copper blocks, or some other exposed copper block variant?

crude marlin
#

Yea def regular blocks

#

No wax

jagged gazelle
#

Then you have some logic error somewhere

crude marlin
#

im guessing tho there is no way to have each individual block go thru the random chance predicate

jagged gazelle
#

There is, just means more commands that just replace a single block position

jagged gazelle
#

They would still be fill commands so you can use replace I believe

crude marlin
#

How would I do that then for 75% for every block?

jagged gazelle
#

By having a command for every block that also includes the predicate

crude marlin
#

like this? /execute at @e[type=marker,tag=throwncharge] if predicate oxidize:random75 run fill ~ ~ ~ ~ ~ ~ minecraft:exposed_copper replace minecraft:copper_block

jagged gazelle
#

Yep

crude marlin
#

this is correct for 75% chance btw right?

{
  "condition": "minecraft:random_chance",
  "chance": 0.75
}
jagged gazelle
#

Yep

crude marlin
# jagged gazelle Yep

for some reason this command only really works if i throw the windcharge below me while i stand on the copper
execute at @e[type=marker,tag=throwncharge] if predicate oxidize:random75 run fill ~-2 ~-2 ~-2 ~2 ~2 ~2 exposed_copper replace copper_block

crude marlin
#

bump