Minecraft – What are the rules of spawning zombie pigmen from nether portals

minecraft-java-edition

Is zombie pigmen spawning (in overworld) affected by light? Do they need to be a specific distance from the player? Do they need some clearance around the portal? Any other influences?

Best Answer

Exactly nothing changes whether Zombie Pigman spawn from Nether portals.

(Well, apart from turning on Peaceful, of course.)

Looking at the code for 1.6.2 in MCP, the code for spawning Zombie Pigmen in portals is dead simple, being only 6 lines of code. If the portal block receives a tick, it checks the difficulty against a random number and if successful, tries to spawn a Zombie Pigman with its feet inside the portal block. It does a check to make sure there is headroom and a solid block under the Pigman's feet, which is why they only spawn with their feet inside the two lower portal blocks inside the frame.

That's it. Light level, player location, and the number of Zombie Pigmen nearby aren't consulted at all.

That means that, so long as the portal is active and in a loaded chunk, it will spawn Zombie Pigmen. By implication, the only way to stop them from spawning is to to deactivate the portal so there are no portal blocks to receive ticks, or to go far away from the portal so the game unloads the chunk it's in.

Further implications:

  • Lowering the difficulty level will decrease Zombie Pigmen spawns from portals. The chance of spawning in a given tick is proportional to the difficulty level d: d/2000, or 1/2000 on Easy, 1/1000 on Normal, and 1/666.6 (repeating) on Hard.
  • Since they always spawn within the portal blocks you can easily fence them in.

One method of Zombie Pigmen control that leverages the limited spawning area would be to put doors or fence gates flush against one side of the portal where you normally enter it, and a waterfall at the level of the bottom frame on the other side. This will transport Zombie Pigmen into a holding area where you can dispose of them at your leisure, leaving your portal free for use. If there are any Zombie Pigmen standing in the portal when you want to use it because they haven't gone for a swim yet, you can just gently nudge them into the water flow as you pass through.