#Placable end portals with item

1 messages · Page 1 of 1 (latest)

bronze briar
#

If I'm in creative I can just place command bock with setblock and always active
But how can I do this in survival

heavy narwhal
#

What

bronze briar
# heavy narwhal 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

heavy narwhal
#

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

bronze briar
heavy narwhal
#

Repeating Command Block executing as the markers will work fine too

bronze briar
#

I meant all the logic is handeled from the item

heavy narwhal
#

No

bronze briar
#

could minecart with command block be powered upon spawning?

heavy narwhal
#

Not that I'm aware of.

bronze briar
bronze briar
#

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"
}
}

bronze briar
#

Which trigger should I use?

flat hinge
#

Using item should be correct

rare mural
#

I use "item_used_on_block" instead

#

dunno how much it differs

pale shadow
#

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.

rare mural
#

That shouldn't be an issue, they're going to do an execute at @e/@n anyways

somber siren
bronze briar
#

The function I wrote works
I just can't get the advancement to trigger

somber siren
#

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

rare mural
#

@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?

bronze briar
bronze briar
bronze briar
#

item_used_on_block worked

pale shadow
somber siren
pale shadow
#

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.

noble nimbusBOT
#
execute summon interaction run tellraw @a [{translate:"Position of %s: ",with:[{selector:"@s"}]},{nbt:"Pos",entity:"@s"}]
tellraw @a [{translate:"Position of %s: ",with:[{selector:"@s"}]},{nbt:"Pos",entity:"@s"}]

see for yourself

somber siren
#

which trigger are you using? It heavily depends on the trigger

pale shadow
#

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

bronze briar
kind musk
#

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

bronze briar
kind musk
#

ill test it.. im not sure

#

it looks like its working

bronze briar
#

yeah but it falls

kind musk
#

yap

kind musk
bronze briar
kind musk
#

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}}]

kind musk
#

nvm.. it falls down

bronze briar
#

yeah

kind musk
#

i didnt test it in the air

#

maybe if all of that was on something like text display

bronze briar
#

I don't see any advantages of this to just summoning falling block of choice directly

bronze briar
#

true

#

but I mean for this use case

kind musk
#

i wasnt sure if it would work.. i just shared it in case it can be useful

bronze briar
#

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

kind musk
bronze briar
#

is the storage temporary?
where is it located

kind musk
bronze briar
kind musk
#

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

bronze briar
#

nvm its there

bronze briar
#

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

kind musk
kind musk
#

run command /data get storage...

#

and youll see tha value stoared on that location

bronze briar
kind musk
#

execute if data storage minecraft:test {test1 :0}... this will run only if the stoared value is 0

bronze briar
#

is it only for storing numbers?

kind musk
bronze briar
#

what are the 'long' and 'short' suppose to repersent?

rare mural
#

Different ways to store data

bronze briar
#

wait so it is all numbers

#

how do I store components and strings

rare mural
#

no, you can just store a string {string:"something"}

bronze briar
#

I couldnt with execute

rare mural
#

yea that's the limitation, execute can only get numbers

#

lists, strings, and such can only be accessed doing /data modify ... from ...

bronze briar
#

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

rare mural
#

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

bronze briar
rare mural
#

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

rare mural
bronze briar
rare mural
#

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 ...```
bronze briar
#

is it gonna give the egg to the placer or closest player?

rare mural
#

in this case, to the closest player

bronze briar
#

hm

rare mural
#

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] ...

bronze briar
#

it doesnt work if only one item is held

#

I think it might have not worked before that

bronze briar
bronze briar
#

I think I will use falling sand spawn egg as it doesn't require datapack and is good enough