#Placable end portals with item
1 messages · Page 1 of 1 (latest)
What
for example when Im testing nether linking in creative I like to have command block with:
setblock ~ ~ ~ nether_portal set to always active in my hotbar
so I dont have to scroll for a command
but I cant place command blocks in survival
Right
Make a spawn egg that summons a marker with a tag, and have a ticking function or an advancement to execute as and at markers with that tag, to setblock a portal and kill the marker
I was wondering if it's possible without tick function or without a datapack
just a stand alone item
Repeating Command Block executing as the markers will work fine too
I meant all the logic is handeled from the item
No
could minecart with command block be powered upon spawning?
Not that I'm aware of.
ok I think im gonna try the advancement
this advancement doesnt works but function works triggered manually
{
"criteria": {
"set_portal": {
"trigger": "minecraft:using_item",
"conditions": {
"item": {
"items": "minecraft:endermite_spawn_egg",
"components": {
"minecraft:entity_data": {
"id": "minecraft:marker",
"Tags": [
"set_portal"
]
}
}
}
}
}
},
"rewards": {
"function": "blockendm:set_portal"
}
}
Which trigger should I use?
Using item should be correct
It won't work unless the item has a use interaction with the block already.
Besides, advancements trigger as and at the player, never at the location of the advancement.
That shouldn't be an issue, they're going to do an execute at @e/@n anyways
Big misconception here, advancements never run their reward function at the player
The function I wrote works
I just can't get the advancement to trigger
I don't have all context here but you can use the trigger item_used_on_block or any_block_use one of these (i don't remember exactly just try which one works) will always trigger when you interact with a block and your hand swings. So placing spawn eggs can be detected with this. Alternatively you can make a scoreboard objective that tracks when you've used a spawnegg and then run your function
@bronze briar Debug.
Does the spawn egg work? Does the marker spawn ? With the correct tags?
Could it be that you have the advancement granted already?
How do you know the reward command works? Does it give you any feedback, like a /say command?
The egg spawns the marker with a tag
A/function sets the portal and kills it
Lemmie get on computer and check if its already granted
andvancement is not granted and upon manually giving it the function runs correctly
item_used_on_block worked
sorry but my reward function ALWAYS runs as and at the player. I can do a predicate in the advancement on the origin which can be different context but in my reward function any command is run at the location of the player receiving the advancemnt.
I run a summon command and it will always be at my feet, not at the origin of the advancement or the world.
e.g. execution context definitely does use player position, maybe not rotation.
[35mexecute [34msummon [0minteraction [34mrun [35mtellraw [36m@a [33m[[35m{[37mtranslate[34m:[32m"Position of %s: "[34m,[37mwith[34m:[[33m{[37mselector[34m:[32m"@s"[33m}[34m][35m}[34m,[35m{[37mnbt[34m:[32m"Pos"[34m,[37mentity[34m:[32m"@s"[35m}[33m]
[35mtellraw [36m@a [33m[[35m{[37mtranslate[34m:[32m"Position of %s: "[34m,[37mwith[34m:[[33m{[37mselector[34m:[32m"@s"[33m}[34m][35m}[34m,[35m{[37mnbt[34m:[32m"Pos"[34m,[37mentity[34m:[32m"@s"[35m}[33m]
see for yourself
which trigger are you using? It heavily depends on the trigger
any_block_use, but i have never found a trigger where this was different for advancements
entity interaction same story
as in, if there are any that don't behave like this they are very rare
this ended up working for me
i recently found out about the command generator that can generate spawn egg that can run any command when placed.. i tried it and this works.. give @p cat_spawn_egg[entity_data={id:"minecraft:falling_block",DropItem:0,BlockState:{Name:"minecraft:command_block"},TileEntityData:{Command:"summon falling_block ~ ~1 ~ {BlockState:{Name:redstone_block},Passengers:[{id:falling_block,BlockState:{Name:activator_rail}},{id:command_block_minecart,Command:\"summon minecraft:falling_block ~ ~-2 ~ {BlockState:{Name:\\\"nether_portal\\\"}}\"},{id:command_block_minecart,Command:\"setblock ~ ~1 ~ command_block{Command:\\\"fill ~ ~ ~ ~ ~-3 ~ air\\\",auto:1}\"},{id:command_block_minecart,Command:\"execute align xyz run kill @e[type=command_block_minecart,dy=0]\"}]}",auto:1}}]
this places the nether portal where the spawn egg is used
and it san be modified for any other portal
i used the falling block because the /setblock is imidietly deleted by /fill air that clears the command blocks
if you dont care abouth the block falling cant you just do this?
/give @p endermite_spawn_egg[entity_data={id:"minecraft:falling_block",BlockState:{Name:"minecraft:nether_portal"},Time:1,Tags:["set_portal"]}] 1
yeah but it falls
yap
you maybe can modify the commads so it does not fill the lowes block so it uses /setblock to place it
yap.. this also works XD
it palces mid air?
give @p cat_spawn_egg[entity_data={id:"minecraft:falling_block",DropItem:0,BlockState:{Name:"minecraft:command_block"},TileEntityData:{Command:"summon falling_block ~ ~1 ~ {BlockState:{Name:redstone_block},Passengers:[{id:falling_block,BlockState:{Name:activator_rail}},{id:command_block_minecart,Command:\"setblock ~ ~-2 ~ end_portal\"},{id:command_block_minecart,Command:\"setblock ~ ~1 ~ command_block{Command:\\\"fill ~ ~ ~ ~ ~-2 ~ air\\\",auto:1}\"},{id:command_block_minecart,Command:\"execute align xyz run kill @e[type=command_block_minecart,dy=0]\"}]}",auto:1}}]
it places it on the block where the mob would spawn from the spawn egg
nvm.. it falls down
yeah
I don't see any advantages of this to just summoning falling block of choice directly
this can run any command..
i wasnt sure if it would work.. i just shared it in case it can be useful
anyway how does execute store result storage works
im using setblock keep and want to refund the spawn egg if someone placed it on grass and such
each command when its run it has some number it returns on success.. this command just saves that number to the storage so it can be used.. for example /fill returns the number of blocks that it filled and /scoreboard returns the final score after the operation
is the storage temporary?
where is it located
you determine where it is located and the storage exists until its overwritten or deleted
when I reloaded the world it disapeared
it shouldnt.. it is saved in world files so it is per-world storage.. it would disapear if you deleted the world and tried to make a new one
in folder of the world you have folder called data in there each storeage is saved as .dat file
sry i gtg i have to restart the comp cus of windows update
nvm its there
k
but I still dont get it
I used this:
/execute store result storage test test1 int 1 run fill -12 0 -12 -12 0 -12 air replace dirt
and regardless of success or failure this command always executes
/execute if data storage minecraft:test test1 run give @p minecraft:apple
damn this updated fast.. xd
yap.. when you runed the first ocmmand you created the storage and when you run the seccond command you are testing the condition if the storage location exists.. and it always exists untill you delete it.. even if the stored value is 0
run command /data get storage...
and youll see tha value stoared on that location
how can I execute base on the value
execute if data storage minecraft:test {test1 :0}... this will run only if the stoared value is 0
is it only for storing numbers?
and this worked
you can store ints, floats, strings, components..
what are the 'long' and 'short' suppose to repersent?
Different ways to store data
You can check the wiki ofr it:
https://minecraft.wiki/w/NBT_format#Data_types
no, you can just store a string {string:"something"}
I couldnt with execute
yea that's the limitation, execute can only get numbers
lists, strings, and such can only be accessed doing /data modify ... from ...
so for example how would I read item from component and give it to a player
if thats how you're suppose to use it
You might be complicating it unnecessarily. Your objective is to refund the portal item to the player if it has placed it on non-air blocks?
It would also depend on which placing method you decided to go for
this is the function that triggers from advancement:
execute at @e[tag=set_portal] as @s run setblock ~ ~ ~ minecraft:nether_portal keep
execute as @e[tag=set_portal] run kill @s
playsound minecraft:block.stone.place block @a ~ ~ ~ 1 0.8
advancement revoke @a only blockendm:set_portal
Alright, to start, if you change execute at @e[tag=set_portal] as @sto execute as @e[tag=set_portal] at @s you can check multiple marker entities at the same time
then
is that what you want? a way to interrupt placing?
yes
so if you place it on the ches it stays save and you cant dispense it into bedrock to break it
if you want to avoid dispensers using it, use an item_frame as base entity instead
now gimme a sec
Here's what would work for you.
Main:
advancement revoke @s only ...
# check if it has air
execute as @e[tag=set_portal] at @s unless block ~ ~ ~ air run function blockendm:items/example/interrupt
# else
execute as @e[tag=set_portal] at @s run setblock ~ ~ ~ nether_portal
kill @e[tag=set_portal]
# other effects below```
Interrupt.mcfunction:
```# kill portal
kill @e[tag=set_portal]
# give item to the player (/give or /loot)
give @p ...```
is it gonna give the egg to the placer or closest player?
in this case, to the closest player
hm
you can tag the player as placer and then remove the tag though
tag @s add portal_placer
execute as @e[tag=set_portal] at @s unless block ~ ~ ~ air run function siscu:items/example_egg/interrupt
tag @s remove portal_placer```
then give @p[tag=portal_placer] ...
it doesnt work if only one item is held
I think it might have not worked before that
I think using last item in a stack doesnt work with this
I think I will use falling sand spawn egg as it doesn't require datapack and is good enough