Can Minecraft BE commands be converted to JE commands?

I'm trying to remake/translate a Bedrock Edition command into Java Edition, but it's not working:

/execute @e[type=!armor_stand] ~ ~ ~ tp ^ ^ ^0.10 facing @e[name=blackhole,r=10]

What am I doing wrong?


TL;DR: The short answer: yes and no. Jump to the Your Use-Case section for the translated version of your command.


Direct Translation

I'd like to start with the shortest explanation that there are some commands that cannot be directly converted to Java edition, per the documentation on commands. Here is a sample of the command table that shows a few of the first commands that cannot be directly used in Java edition:

Command Description BE JE
/ability Grants or revokes a player ability. Yes No
/alwaysday An alias of /daylock. Locks and unlocks the day-night cycle. Yes No
/camerashake Used to enable a camera shaking effect. Yes No

Note: Please refer to the aforementioned documentation for the complete table.

However, there are some commands that have very, very similar syntax in both Bedrock edition and Java edition. For example, the fill command is one such candidate for nearly direct translation:

Java Edition

fill <from> <to> <block> [destroy|hollow|keep|outline|replace]

Bedrock Edition

fill <from: x y z> <to: x y z> <tileName: Block> [tileData: int] [oldBlockHandling: FillMode]

As a result, the following command should execute successfully in currently released versions of Bedrock and Java editions:

fill ~ ~ ~ ~5 ~5 ~5 concrete

Indirect Translation (Your Use-Case)

The execute command is one of those commands that is incredibly powerful in Java edition, but limited in Bedrock edition. Based on the command you provided:

/execute @e[type=!armor_stand] ~ ~ ~ tp ^ ^ ^0.10 facing @e[name=blackhole,r=10]

I can infer some guidelines for translation:

All entities that are not of type armor_stand, from their current location, execute a teleport command to their local coordinates plus 0.10 on the z-axis, facing all entities named blackhole within a radius of 10.

In Java edition, your command is a bit more complicated than it seems, and Bedrock edition is notorious for hiding this from us. To get your command to work, you'll need to run the command as the entity, at the entity's location, facing the target:

/execute as x at x facing entity x eyes run tp...

Subsequently, your full command in Java edition is:

/execute as @e[type=!armor_stand] at @s facing entity @e[name=blackhole,r=10] eyes run tp ^ ^ ^0.10

Note: The use of @s after the at is enabled by the fact that the as has already established the entity we need and since we are executing the command as the entity, we can use the self target.