Magnetic Field Simulation

Build a dynamic magnetic field simulation in vanilla Minecraft using display entities, particle arcs, and opposing polar cores that pull and fling metallic debris.

Java EditionHolograms & Display EntitiesMedium24 commandsTested on a real 26.2 & 26.3 server
Glowing red and blue magnetic cores orbit above a pad with floating iron, copper, and anvil debris. Download the GIF Video & GIF © www.9minecraft.net

Machines & MechanismsTechnologyIndustrialRedBlueOrangeLearningDecorationBlock displaysItem displaysArmor standsBlock building (fill/setblock/clone)Rotation math21+ commands

Two glowing magnetic cores—one North Pole in red and one South Pole in blue—orbit a central pedestal while generating an invisible force field. Metallic debris made of iron, copper, and anvils gets pulled out of the ground, orbits the cores in a figure-eight pattern, and occasionally gets flung across the stage when the magnetic polarity reverses.

This creation uses block_display entities coupled with dynamic vector movement and scoreboard timers to simulate magnetic attraction, orbital velocity, and sudden electromagnetic bursts without any mods.

1. Setup - type these once 8 commands

  1. /scoreboard objectives add c9_mag dummy
  2. /fill ~-4 ~-1 ~-4 ~4 ~-1 ~4 polished_deepslate
  3. /fill ~-2 ~-1 ~-2 ~2 ~-1 ~2 copper_block
  4. /setblock ~ ~-1 ~ lodestone
  5. /summon armor_stand ~ ~4 ~ {Invisible:1b,NoGravity:1b,Marker:1b,Tags:["c9_mag","c9_center"]}
  6. /summon block_display ~ ~4 ~ {Tags:["c9_mag","c9_pole_n"],Glowing:1b,glow_color_override:16724787,block_state:{Name:"minecraft:redstone_block"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[1.3f,1.3f,1.3f],translation:[-0.65f,-0.65f,-0.65f]}}
  7. /summon block_display ~ ~4 ~ {Tags:["c9_mag","c9_pole_s"],Glowing:1b,glow_color_override:3368703,block_state:{Name:"minecraft:lapis_block"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[1.3f,1.3f,1.3f],translation:[-0.65f,-0.65f,-0.65f]}}
  8. /summon item_display ~ ~4 ~ {Tags:["c9_mag","c9_core_ring"],Glowing:1b,glow_color_override:16755200,item:{id:"minecraft:heavy_core",count:1},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[1.8f,1.8f,1.8f],translation:[0f,0f,0f]}}

2. Loop - one repeating command block each (Always Active) 16 commands

  1. /scoreboard players add #tick c9_mag 1
  2. /execute if score #tick c9_mag matches 160.. run scoreboard players set #tick c9_mag 0
  3. /execute as @e[tag=c9_center] at @s run tp @s ~ ~ ~ ~4.5 ~
  4. /execute at @e[tag=c9_center] run tp @e[tag=c9_pole_n] ^4.5 ^ ^
  5. /execute at @e[tag=c9_center] run tp @e[tag=c9_pole_s] ^-4.5 ^ ^
  6. /execute at @e[tag=c9_center] rotated ~ 0 run tp @e[tag=c9_core_ring] ~ ~ ~ ~9 ~
  7. /execute at @e[tag=c9_pole_n] run particle dust{color:[1.0,0.2,0.2],scale:1.6} ~ ~ ~ 0.35 0.35 0.35 0 4 force
  8. /execute at @e[tag=c9_pole_s] run particle dust{color:[0.2,0.5,1.0],scale:1.6} ~ ~ ~ 0.35 0.35 0.35 0 4 force
  9. /execute if score #tick c9_mag matches 1 run summon block_display ~ ~1.5 ~ {Tags:["c9_mag","c9_debris","c9_to_n"],Glowing:1b,glow_color_override:13421772,block_state:{Name:"minecraft:iron_block"},transformation:{left_rotation:[0.3f,0.2f,0.1f,0.9f],right_rotation:[0f,0f,0f,1f],scale:[0.55f,0.55f,0.55f],translation:[-0.27f,-0.27f,-0.27f]}}
  10. /execute if score #tick c9_mag matches 40 run summon block_display ~ ~1.5 ~ {Tags:["c9_mag","c9_debris","c9_to_s"],Glowing:1b,glow_color_override:16744272,block_state:{Name:"minecraft:waxed_copper_block"},transformation:{left_rotation:[0.1f,0.4f,0.2f,0.88f],right_rotation:[0f,0f,0f,1f],scale:[0.5f,0.5f,0.5f],translation:[-0.25f,-0.25f,-0.25f]}}
  11. /execute if score #tick c9_mag matches 80 run summon block_display ~ ~1.5 ~ {Tags:["c9_mag","c9_debris","c9_to_n"],Glowing:1b,glow_color_override:9868950,block_state:{Name:"minecraft:anvil"},transformation:{left_rotation:[0.2f,0.1f,0.4f,0.88f],right_rotation:[0f,0f,0f,1f],scale:[0.6f,0.6f,0.6f],translation:[-0.3f,-0.3f,-0.3f]}}
  12. /execute as @e[tag=c9_debris] at @s run scoreboard players add @s c9_mag 1
  13. /execute as @e[tag=c9_debris,scores={c9_mag=..110}] at @s rotated ~12 0 run tp @s ^0.18 ^0.02 ^0.32 ~14 ~8
  14. /execute as @e[tag=c9_debris,scores={c9_mag=111..}] at @s run tp @s ^ ^0.15 ^0.75 ~25 ~15
  15. /execute as @e[tag=c9_debris] at @s run particle electric_spark ~ ~ ~ 0.1 0.1 0.1 0.05 2 force
  16. /kill @e[tag=c9_debris,scores={c9_mag=145..}]

How it works

Frames from the test run

Magnetic Field Simulation - frame 1Magnetic Field Simulation - frame 2Magnetic Field Simulation - frame 3

Recorded on our own test server: 53 frames at about 8.7 fps. Our image check saw: Glowing red and blue blocks with matching particle trails orbit a central floating block above a tiled pad while smaller glowing iron, copper, and anvil blocks float and move between them.

Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.

Build it in your world

  1. Stand at the center of a flat open area and run each command from the Setup list one by one in chat.
  2. Place a line or stack of 16 Repeating Command Blocks nearby (set them to Repeat, Unconditional, and Always Active).
  3. Copy and paste one command from the Loop list into each repeating command block.
  4. To make sure the coordinates align with the stage center, wrap positional loop commands or place the command blocks directly below the lodestone center and adjust offsets if needed.
  5. Watch the red and blue magnetic cores orbit the heavy core while pulling metallic debris into a swirling vortex before flinging them outward.

Use it with real players

To turn this into a player-controlled magnetic aura, remove the c9_center armor stand and change @e[tag=c9_center] in the loop commands to @p[tag=magnet_user]. Whenever a tagged player walks around, the North and South magnetic cores will orbit their body and pull orbiting metallic debris along with them.

Remove it again 3 commands

  1. /kill @e[tag=c9_mag]
  2. /scoreboard objectives remove c9_mag
  3. /fill ~-4 ~-1 ~-4 ~4 ~-1 ~4 grass_block

FAQ

Will the flying anvils and iron blocks damage my world or build up lag?

No. The debris is made of block_display entities rather than real falling blocks, so they never place blocks on the ground, and every piece is automatically removed after 145 ticks.

How can I make the magnetic field pull actual items dropped on the ground?

You can add a repeating command like /execute as @e[type=item,distance=..10] at @s facing entity @e[tag=c9_center,limit=1] feet run tp @s ^ ^ ^0.2 to slide dropped items toward the center core.

Commands used

/execute/fill/kill/particle/scoreboard/setblock/summon/tp

Similar creations

Join 9Minecraft News & Guides