5

I am building a game where players can wall cling, and I am doing this by teleporting invisible, invulnerable, AI-less happy ghasts beneath them. This is working great for me, except for one issue.

When a player shoots one, the arrow bounces off.

I would like the arrow to go straight through the ghast and hit anything beyond. How do I achieve this without making the player fall through?

3
  • Have you tried making the ghasts really small using the Scale attribute? Commented yesterday
  • 2
    Related question (but not duplicate, I would say it is a "conjugate" question): Can mobs be "glued" together in Minecraft? Commented yesterday
  • Tried the scale, they need to be at least .6 for you to run on them Commented 19 hours ago

1 Answer 1

6

As many pointed out, the previous solution I wrote does not work. The solution allows mob entities to phase through each-other, but arrows follow different rules. Instead, we can exploit the fact that arrows can be piercing, and force all arrows to have a piercing level. Let's go ham and max that stat out.

In a repeating command block, run:

execute as @e[type=arrow] run data modify entity @s PierceLevel set value 127b

I verified in-game that with this command on, all arrows will pierce through the entities they encounter. You might want to heal your happy ghasts now though


I am keeping the old solution in the answer since people might find this useful for other entity interactions.

Old solution:

I think the best solution especially since you are using happy ghasts as technical entities, is to add a team for the players and their happy ghasts, and set the collision rule such that they cannot be pushed by entities from other teams (like spawned arrows).

In an impulse chain:

team add no_push
# ensures entities in this team can ONLY be pushed by other entities in the team, contrary to the name of the rule
team modify no_push collisionRule pushOtherTeams
# join the no_push team (modify these to suit your needs)
team join no_push @a
team join no_push @e[type=happy_ghast]

More info on /team collision rules

5
  • 1
    pushOtherTeams naming confusion will never not be hilarious Commented 23 hours ago
  • actually thinking about it a bit more, wouldn't this have the effect of having the arrow also pass through the player? Commented 23 hours ago
  • @NODO55, it didn't work; the arrow still bounces off. This does help another part of the project, though! Commented 19 hours ago
  • I tried this yesterday and it didn't work for me either. Despite being on the same team as the ghast, my arrows bounced off. Even running a command to make the arrows join the team too also didn't work. This could be a bug and not a feature though. Commented 17 hours ago
  • That's what I get for not verifying first... I edited with a proper, working solution. I am keeping the old "solution" since it is still helpful for non-arrows Commented 15 hours ago

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.