I'm looking for a barrier setup that would conditionally block entities from passing over the block, to create impassable rivers or lava, for example, unless they have a certain tag state, etc. Flying and projectile entities should be able to pass, but not mobs nor players unless they have the correct item, for example. The system needs to work for very large areas of "coastline." I've tried the following, with various setbacks:
1. Armor stand detection with conditional barrier block placement: Works to block players/mobs but projectiles are too fast to trigger the system, and if an allowed entity triggers the system a disallowed entity can also get through. Also requires a ton of armor stands, which may reduce performance.
2. Auto /tp system: One benefit is that I can use either block or entity detection, which allows for scalability. However, I am not a great command coder and I have had significant difficulty getting the syntax worked out; I tried using player orientation/rotation to direct the tp coordinates but that allowed the player to simply walk backwards to bypass the barrier. Unsure if I can use player/entity motion data to guide /tp command. Also, tended to be very jerky movement. An example of the code I've experimented with:
execute as @a at @s if block ~ ~-1 ~ minecraft:water rotated ~ 0 run tp @s ^ ^ ^-0.3
3. Resource pack to create invisible fences/gates: Looks like you can't place a transparent texture on a fence or gate. Maybe I could change the model directly? If so, does that affect the hitbox size? Could I set up a system to open gates when approaching, conditionally, or maybe allow them to pass the fence by changing entity jump height? One additional aesthetic issue is that projectiles will still hit the fence/closed gate.
Has anyone developed a working system that would work for my needs? Thanks!
Been a while personally since i did conmand block stuff, but this takes a lot of checking and if you ask me, i think you need to step away from a teleport mechanic and should instead just place your armor stands near the liquids and the detect for a player coming close to it, if so, spawn a creeper (ofc mobgriefing off) with instant fuse to knock the player back, paired with 1 second of resistance.
Maybe this could do the trick instead of placingand replacing blocks every tick or having unsmooth teleportation
Rollback Post to RevisionRollBack
Ex-minecraft map maker
Somewhat of a datapack/command block engineer at your service...?
I ended up trying a system using fences with the model removed in a resource pack to make them invisible, and self-deleting armor stands as "sensors" placed a 1/2 block away in each of the eight compass directions. The "sensor" armor stands replace the fences with air if the player is holding a ladder. It's basically the NES LoZ mechanic. It works surprisingly well, though blocked projectiles remain an issue. The system also doesn't work over real water (weird displacement effects), and I'm going to have to find a way to put the animated water texture on a glass or other transparent block if possible (if anyone knows that process, feel free to chime in). The code is posted below if anyone can find it useful.
That's a unique mechanic, Superfool2000. I'll try it out and see how it goes.
execute as @a[nbt={Inventory:[{id:"minecraft:ladder"}]}] at @s if block ~.5 ~ ~ minecraft:acacia_fence unless entity @e[name=water,distance=..0.1] run summon minecraft:armor_stand ~.5 ~ ~ {CustomName:"\"water\"",Invisible:1}
execute as @a[nbt={Inventory:[{id:"minecraft:ladder"}]}] at @s if block ~-.5 ~ ~ minecraft:acacia_fence unless entity @e[name=water,distance=..0.1] run summon minecraft:armor_stand ~-.5 ~ ~ {CustomName:"\"water\"",Invisible:1}
execute as @a[nbt={Inventory:[{id:"minecraft:ladder"}]}] at @s if block ~ ~ ~.5 minecraft:acacia_fence unless entity @e[name=water,distance=..0.1] run summon minecraft:armor_stand ~ ~ ~.5 {CustomName:"\"water\"",Invisible:1}
execute as @a[nbt={Inventory:[{id:"minecraft:ladder"}]}] at @s if block ~ ~ ~-.5 minecraft:acacia_fence unless entity @e[name=water,distance=..0.1] run summon minecraft:armor_stand ~ ~ ~-.5 {CustomName:"\"water\"",Invisible:1}
execute as @a[nbt={Inventory:[{id:"minecraft:ladder"}]}] at @s if block ~.5 ~ ~.5 minecraft:acacia_fence unless entity @e[name=water,distance=..0.1] run summon minecraft:armor_stand ~.5 ~ ~.5 {CustomName:"\"water\"",Invisible:1}
execute as @a[nbt={Inventory:[{id:"minecraft:ladder"}]}] at @s if block ~-.5 ~ ~-.5 minecraft:acacia_fence unless entity @e[name=water,distance=..0.1] run summon minecraft:armor_stand ~-.5 ~ ~-.5 {CustomName:"\"water\"",Invisible:1}
execute as @a[nbt={Inventory:[{id:"minecraft:ladder"}]}] at @s if block ~-.5 ~ ~.5 minecraft:acacia_fence unless entity @e[name=water,distance=..0.1] run summon minecraft:armor_stand ~-.5 ~ ~.5 {CustomName:"\"water\"",Invisible:1}
execute as @a[nbt={Inventory:[{id:"minecraft:ladder"}]}] at @s if block ~.5 ~ ~-.5 minecraft:acacia_fence unless entity @e[name=water,distance=..0.1] run summon minecraft:armor_stand ~.5 ~ ~-.5 {CustomName:"\"water\"",Invisible:1}
execute as @e[name=water] at @s run setblock ~ ~ ~ minecraft:air
execute as @e[name=water] at @s if block ~ ~ ~ minecraft:air unless entity @p[distance=..1] run tag @s add kill
execute as @e[name=water,tag=kill] at @s run setblock ~ ~ ~ minecraft:acacia_fence
kill @e[name=water,tag=kill]
I just realized I should be able to switch the above system around, using the sensor system to detect water and placing invisible fences when an entity should be blocked, rather than removing them. This would allow open projectile paths and prevent mobs from sneaking by unintentionally. The downside is the need for a constant halo of armor stands around all moving ground/water entities, which might cause performance issues.
I'm looking for a barrier setup that would conditionally block entities from passing over the block, to create impassable rivers or lava, for example, unless they have a certain tag state, etc. Flying and projectile entities should be able to pass, but not mobs nor players unless they have the correct item, for example. The system needs to work for very large areas of "coastline." I've tried the following, with various setbacks:
1. Armor stand detection with conditional barrier block placement: Works to block players/mobs but projectiles are too fast to trigger the system, and if an allowed entity triggers the system a disallowed entity can also get through. Also requires a ton of armor stands, which may reduce performance.
2. Auto /tp system: One benefit is that I can use either block or entity detection, which allows for scalability. However, I am not a great command coder and I have had significant difficulty getting the syntax worked out; I tried using player orientation/rotation to direct the tp coordinates but that allowed the player to simply walk backwards to bypass the barrier. Unsure if I can use player/entity motion data to guide /tp command. Also, tended to be very jerky movement. An example of the code I've experimented with:
3. Resource pack to create invisible fences/gates: Looks like you can't place a transparent texture on a fence or gate. Maybe I could change the model directly? If so, does that affect the hitbox size? Could I set up a system to open gates when approaching, conditionally, or maybe allow them to pass the fence by changing entity jump height? One additional aesthetic issue is that projectiles will still hit the fence/closed gate.
Has anyone developed a working system that would work for my needs? Thanks!
Been a while personally since i did conmand block stuff, but this takes a lot of checking and if you ask me, i think you need to step away from a teleport mechanic and should instead just place your armor stands near the liquids and the detect for a player coming close to it, if so, spawn a creeper (ofc mobgriefing off) with instant fuse to knock the player back, paired with 1 second of resistance.
Maybe this could do the trick instead of placingand replacing blocks every tick or having unsmooth teleportation
Ex-minecraft map maker
Somewhat of a datapack/command block engineer at your service...?
I ended up trying a system using fences with the model removed in a resource pack to make them invisible, and self-deleting armor stands as "sensors" placed a 1/2 block away in each of the eight compass directions. The "sensor" armor stands replace the fences with air if the player is holding a ladder. It's basically the NES LoZ mechanic. It works surprisingly well, though blocked projectiles remain an issue. The system also doesn't work over real water (weird displacement effects), and I'm going to have to find a way to put the animated water texture on a glass or other transparent block if possible (if anyone knows that process, feel free to chime in). The code is posted below if anyone can find it useful.
That's a unique mechanic, Superfool2000. I'll try it out and see how it goes.
I just realized I should be able to switch the above system around, using the sensor system to detect water and placing invisible fences when an entity should be blocked, rather than removing them. This would allow open projectile paths and prevent mobs from sneaking by unintentionally. The downside is the need for a constant halo of armor stands around all moving ground/water entities, which might cause performance issues.