# Minecraft: Hate Basic Math? Use My File!

The Minecraft Building Calculator does the math for you, making construction effortless

**If youâve passed 5th grade, chances are that you know how to find the area of a rectangle. If not, Iâm genuinely concerned.** Perhaps youâve recently tapped into this skill while purchasing property or browsing furniture.

Iâve been playing Minecraft since 2014, and if youâre as avid a fan of the game as I am, then you probably do a lot of multiplication to discern how many blocks you need to build your in-game house. While this is easy, it can also be time-consuming and monotonous to be immediately useful, especially for large structures. This is why I wrote a file to calculate the number of blocks one would need to build theoretical structures, from fortresses to towers.

First, Iâll employ a top-down approach to discuss how my Minecraft Building Calculator works. Then, for those of you who experience technological challenges, Iâll go over how to set up an environment and run the file.

## Parameters

Players might protest that any Minecraft structure worth building isnât reducible to a series of equations. This is *almost* correct. While including creative embellishments in a calculation might be beyond the scope of a little file, using the exact dimensions of each room to calculate a structureâs area is a lot easier.

This file divides Minecraft structures into segments. To calculate the blocks necessary for each segment, the file requests 5 parameters from the user: length, width, height, storeys, and whether the user wants 2 staircases instead of 1.

Geometry establishes what length, width, and height are. Nobody needs Minecraft to discern those factors, but when I say âstoreysâ I refer to** **the number of storeys for which the same length, width, and height persist. If I provide a length of 7, a width of 6, a height of 4, and a storey number of 2, then Iâm talking about a segment that is 7 units long, 6 units wide, and 8 units high to account for 2 storeys instead of 1. When the file completes a segment, it asks the user either to provide parameters for another segment or to complete the structure with a roof.

With roofs, the file takes 3 possible roofs into account, presenting the total number of blocks for all variants. A slanted roof is the least cost-effective roof, a standard roof is a little better, and a pyramidal roof is the most cost-effective, but I had the code present all 3 options. This allows users to stray from the most cost-effective option if they want.

Before diving into minute aspects of the file, I note that the Minecraft Building Calculator accounts for slabs and stairs, as well as blocks. One needs at least 6 blocks to make 4 stairs, so a stair is worth a block and a half. Also, one needs at least 3 blocks to make 6 slabs, which means a slab is a half a block.

Now that Iâve presented an overview of how the code works, Iâll walk you through the individual functions.

## Functions

Upon receiving the userâs first set of parameters, the file calculates the number of blocks the user needs to build the floor. Multiplying the length (L) by the width (W) isnât enough: The file must account for the fact that a floor neednât be beneath the walls, so the file multiplies (L - 2) by (W - 2) instead. Since only slabs are necessary for the floor, the file divides the area by 2. ((L - 2)(W - 2))/2 has to provide a whole number because thereâs no way to have a fraction of a block, so the file employs the round function from Javaâs Math library to round up.

If the file is calculating a 9-by-11 floor that requires 99 slabs, at least 50 blocks are necessary because 49 blocks yield only 98 slabs. Once the segment is complete, the file multiplies the final value of the floor by the number of storeys.

Next, the file calculates the number of blocks necessary for the walls. Subtracting (L - 2)(W - 2) from LW provides the perimeter, and the file multiplies the perimeter by the height (H): (LW - ((L - 2)(W - 2)))H. Again, the file multiplies the final value of the walls by the number of the segmentâs storeys.

Finally, the file calculates the number of stairs. Recall that a stair is worth a block and a half. For each unit of height, there ought to be 1 stair and 1 upside-down stair for aesthetic. This means that the number of blocks necessary to build a staircase is 3H, but another important factor is at play: To build a staircase is to make room for Steve or Alex by creating a hole in the next floor, so the file must subtract enough slabs from the floor for Steve or Alex to fit. A staircase with enough room requires the removal of 5 slabs, but a staircase that needs to turn might require the removal of up to 7, so the final equation to obtain the number of blocks necessary for a staircase is 3H - 3.5.

As with the floor calculation, the file employs the round function to round up, and the file multiplies that ultimate value by the number of storeys. If the user wants 2 staircases, then the file doubles the value.

For each segment, users provide the 5 parameters until the building is complete, after which the file omits a final staircase from the top floor to the ceiling and calculates the number of blocks necessary for the roof.

## The Worst Roof

The slanted roof is as inefficient as its formula suggests: 4LW - 4L - 5W + 8. *Stay with me here!*

No matter the roofâs dimensions, LW provides all the individual spaces the file must address in order to protect the top floor from open air. Apart from a few key spaces that the latter 3 terms address, each of the roofâs horizontal spaces requires 4 blocks: There must be a stair, an upside-down stair, and a block opposite both stairs. 1.5 + 1.5 + 1 = 4, so 4LW is the equationâs first term, but the latter 3 terms correct some false assumptions that 4LW makes.

4LWâs first false assumption is that 2 rows of upside-down stairs exist beneath the stairs that meet the edges of both lengthwise walls. Thus, thereâs an extra 3L to subtract from the total. 4LW assumes that the stairs along the high edge of the roof require corresponding blocks, but those stairs comprise the edge, so the file must subtract another L: 4L in total.

4LW - 4L establishes that upside-down stairs must not be along the lengthwise edges of the roof. Next, neither upside-down stairs nor blocks must be along either widthwise side because the file will fill that space with blocks later. For both widthwise sides, the file subtracts 1 upside-down stair and 1 block. Thus, the file subtracts 2 stairs and 2 blocks for every unit of width: 4LW - 4L - 5W.

Finally, the file adds 8 blocks. The spatial modifications suggested by -4L and -5W ** overlap** such that the file has subtracted too many blocks from the corners. If you can visualize any of this, to subtract 4L and 5W from 4LW is to subtract both 4 stairs (6 blocks) and 2 blocks twice, so the file must return 8 blocks to the structure. While this final term completes the equation, the triangular widthwise sides of the roof are incomplete. To fill the widthwise sides with blocks, the file employs a for loop: For W - 1 iterations, the file adds twice the current iteration to the total and subtracts 1 from the iteration.

## The Conventional Roof

When I write âStandard Roofâ in the code, I refer to the roof that comes together in the middle only along the length of the structure, while blocks along the width climb the height of the building to reach the roof. The formula for this is: 3LW - 3L - 3W + 6.

3LW references the fact that 2 stairs occupy 1 unit in the roofâs horizontal area. 1.5 + 1.5 = 3, but this term presents too many blocks. The file subtracts 3L and 3W to omit upside-down stairs along the edges of the roof. Finally, the file adds 6 because it has subtracted a stair from each corner twice. Since there are 4 corners, we add 1.5 * 4 blocks (6 blocks).

Still, the file hasnât accounted for the triangular sides of the roof leading up to the middle: For W - 2 iterations, the file adds twice the current iteration to the total and subtracts 2 from the iteration until the iteration reaches 0.

In combination with a for loop, 3LW - 3L - 3W + 6 presents a full evaluation of a conventional roof whose *width is even*. Roofs whose widths are odd present an extra step because they require 2 blocks and several slabs to cover the middle. To adjust for this need, the file adds 2 and subtracts 2.5L from the total: To remove the stairs and upside-down stairs from the middle of the roof, the file subtracts 3L, but a slab must replace each pair of stairs, so the file adds 0.5L. 3L - 0.5L = 2.5L. Adding 2 - 2.5L allows the file to compensate for a roof whose width is odd. Again, the file employs the round function to round up to the nearest whole number.

## The Cost-Effective Roof

Curiously, a pyramidal roof is also the easiest to explain. LW accounts for all the stairs on top of the roof. To calculate the upside-down stairs on the inside of the roof, the file adds (L-2)(W-2). If the width is even, the file need only multiply the final value by 1.5 to convert the spaces into stairs.

If the width is odd, the file replaces the roofâs most central stairs with slabs. The necessary number of slabs is equal to ((L - 2) - (W - 2)) + 1. Once the file discerns this value, the number of stairs decreases, becoming equal to the total minus twice the number of slabs because the file subtracts a pair of stairs for every slab it introduces. Then, the file divides the number of slabs by 2 since 1 block yields 2 slabs. Finally, the file multiplies the remaining number of stairs by 1.5. Adding the number of slabs to the number of stairs, the file presents the final number of blocks necessary for the roof.

## Finishing Touches

For courtesyâs sake, since the file doesnât account for doors and windows, it states how many blocks are necessary to build 75% of the structure. Still, it recommends that you acquire 100% of the blocks for embellishments. Finally, if a higher segmentâs dimensions differ from a lower segmentâs, the file builds an intermediate roof of slabs between the 2 segments. This is a simple matter of differentiating between 2 floor areas and converting slabs to blocks.

Iâve certainly used this file for my in-game projects, and it works! Its minute estimates have streamlined the construction of two whole fortresses in my current local world, both of which turned out to be pretty cool and pretty tall. I ultimately hope that many will find this tool hopeful, but especially gamers for whom Minecraft is a bit too laissez-faire and byzantine (understandable), architects who struggle to create or maintain their structures in survival mode, and math or computer science nerds who might be interested in seeing what all the fuss is about. While I know my file inside-and-out, I encourage this latter group to one-up me, if possible. Iâm paranoid about missing something somewhere.

While this might be a stretch, users who struggle with dyscalculia may employ my file against the monotony of calculating area after area. Not everyone is a math person, and thatâs perfectly fine as long as we understand that math is our friend. Itâs something that we can use every day for lots of things, from what we need to what we enjoy.

I usually overshot blocks because I like to add lots of embellishments to my home, but when I use this file to estimate my needs, I never deplete my materials in the middle of construction. Some blocks cost 4 bricks or blocks of something else to make. If you like Nether Bricks, remember to quadruple the value before collecting Netherrack. *That*, I think you can do by yourself.

### Setup

- Visit my repository to download the .zip file.
- Extract to your favorite folder. I recommend the Downloads folder.
- Open Command Prompt, Powershell, Terminal, or another navigation tool that smart people use to access files. Powershell is what I use most, so Iâll walk you through that one.
- In Powershell, use âlsâ and âcdâ to navigate to the file, Minecraft-Building-Calculator.java. The command, âls,â shows you what folders or files you can access from your current directory, while âcdâ allows you to navigate to available subfolders. Remember to put the folder name after âcdâ before hitting âReturn.â
- Once youâve reached the file, use the command for compiling a Java file, âjavac.â The full line should be âjavac Minecraft-Building-Calculator.javaâ
***** - Now that your computer has compiled the file, run it by using the command, âjava.â The full line should be âjava Minecraft-Building-Calculatorâ
- Follow the on-screen instructions to calculate the number of blocks.

*, you need either to install Java or to troubleshoot with your favorite search engine because I donât remember.*

*****If this doesnât work**Thanks for checking out my project!

## Comments

Sign in or become a SUPERJUMP member to join the conversation.