I Built a Tiny Browser Extension to Stop Messing Up Nether Portals in Minecraft
If you've played Minecraft Survival for a while, you've probably done this: built a Nether portal, walked through, built the return portal "roughly in the right place"… and ended up 400 blocks away from your base. The rule is simple: 1 block in the Nether = 8 blocks in the Overworld . Doing that maths in your head while a ghast is shooting at you is not. So I built Portal Calc , a small browser…
If you've spent time playing Minecraft in Survival mode, you may have experienced this situation: constructed a Nether portal, ventured through, and then found yourself inadvertently 400 blocks away from your base. The underlying principle is straightforward: one block in the Nether corresponds to eight blocks in the Overworld. Mentally calculating this ratio while under attack from a ghast is challenging.
To address this issue, I developed Portal Calc, a compact browser extension that automates the conversion process for you.
What Portal Calc does:
- Overworld ↔ Nether converter: input X, Y, Z coordinates and receive the corresponding coordinates in the opposite dimension, allowing for easy copying.
- Distance calculator: calculates the straight-line distance and horizontal distance between two points. It also estimates the trip length when traveling through the Nether.
- Waypoints: enables saving of bases, portals, and villages in both dimensions for quick access.
How Portal Calc was created:
- The extension follows a minimalist approach, employing only Manifest V3, a single popup interface, and no background scripts.
- The codebase consists of plain HTML, CSS, and vanilla JavaScript, with a total size under 10 KB when zipped.
- The only permission requested is "storage", which is utilized to store waypoints using chrome.storage.local.
- No network requests or analytics are involved, keeping the extension lightweight.
- The conversion formula is succinct: const factor = direction === "o2n" ? 1 / 8 : 8 ; const nx = Math.floor(x * factor); const nz = Math.floor(z * factor); Math.floor is crucial here, as Minecraft block coordinates round down. Relying on Math.round for negative values could lead to incorrect block placement.
For the distance tab, three values are displayed to cater to varying travel needs:
- flat: straight-line distance (walking distance)
- full: three-dimensional distance
- viaNether: distance calculated via Nether shortcut
An initial hurdle encountered during the extension's creation was a warning from Mozilla's add-on validator regarding "Unsafe assignment to innerHTML". Despite the fact that the code only inserted numbers, the validator flagged the issue. To resolve this, I rewrote the result rendering to use textContent and createElement, which eliminated the warning. This experience serves as a reminder for developers to adhere to best practices from the outset to avoid unnecessary re-submissions.
For those interested in exploring or contributing to Portal Calc, the source code is available under the MIT license at: https://github.com/nimipakao/portal-calc. The tool was inspired by my Minecraft guides, which can be found at theminecrftapkdl.com. If you're a Minecraft player and have suggestions for potential future features, such as stronghold triangulation or slime chunk finder, please share your ideas in the comments section.
Rewritten by urgent.news; may contain errors — check the original. How we use AI.
Source: dev.to