Skip to content

Instantly share code, notes, and snippets.

@duongddinh
Last active May 13, 2019 22:32
Show Gist options
  • Save duongddinh/4e108bb8804e88c2c93ec17163289922 to your computer and use it in GitHub Desktop.
Save duongddinh/4e108bb8804e88c2c93ec17163289922 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
import java.lang.Math.*;
class Calc_Mine {
public static void main(String[] args){
boolean c=true;
while (c){
Scanner scn = new Scanner(System.in);
System.out.println("Use loaded data or enter data yourself? (l/m)");
String inp = scn.nextLine();
if (inp.equals("l")){
c = false;
Funme f = new Funme();
f.sta(50,2.20);
}
else if (inp.equals("m")){
c=false;
Funme f = new Funme();
f.sta();
}
else {c=true; System.out.println("Not found");}
}
}
}
class Funme {
public void sta(double h, double t){
conti(h,t);
}
public void sta(){
double t;
double h;
double[] time = new double[5];
System.out.println("Enter time 5 times");
for (int i =0; i<time.length; i++){
Scanner scn = new Scanner(System.in);
System.out.print("Enter time (s) #" + (i+1) +": ");
time[i] = scn.nextDouble();
}
double sum=0;
for (int a=0; a<time.length; a++){
sum += time[a];
}
t = sum / time.length;
Scanner scan = new Scanner(System.in);
System.out.println("Enter height (each block is 1m) (m) :");
h = scan.nextDouble();
conti(h,t);
}
public void conti(double h, double t){
//h = 1/2*g*t^2
double g;
g = (2*h)/(t*t);
double gM = (double) Math.round(g*100)/100;
double rM = 6371000*(double) Math.round (Math.sqrt(1/(g/9.8))*100)/100;
System.out.println("The acceleration of Minecraft world is: "+ (double) Math.round(g*100)/100 + " and on earth is nearly 9.8; " + " gM = "+ (double) Math.round((g/9.8)*100)/100 + "*gE");
// g = (G*M)/r^2
System.out.println ("So either the mass of Minecraft world is "+ (double) Math.round((g/9.8)*100)/100 + "*gE" + " or the radius is "+ (double) Math.round (Math.sqrt(1/(g/9.8))*100)/100 + "*rE. Which means the radius is: "+ 6371000*(double) Math.round (Math.sqrt(1/(g/9.8))*100)/100 + " Or the mass is: "+ 5.972*(double) Math.round((g/9.8)*100)/100 + " x 10^24" );
System.out.println("Using t = " +t+ " (s) with the g= 9.8 m/s^2, the height on earth is: "+ ((double)Math.round(((9.8*t*t)/2)*100)/100) +" m");
System.out.println();
boolean a = true;
while(a){
Scanner scna = new Scanner(System.in);
System.out.println("Do you want to continue with additional calculations? (yes - manually enter; n - no; yl - yes but loaded): (y/n/yl) ");
String opt = scna.nextLine();
if (opt.equals("y")){
a= false;
Addi ad = new Addi();
ad.additi(rM);
}
else if (opt.equals("yl")){
a=false;
Addi ad = new Addi();
ad.additi(rM, 0.87 , 10);
}
else if (opt.equals("n")){
System.exit(2);
}
else {a = true; System.out.println("Try again!");}
}
}
}
class Addi{
public void additi(double rM){
double[] time2 = new double[5];
for (int i =0; i<time2.length; i++){
Scanner scan2 = new Scanner(System.in);
System.out.println("Enter time for flying (" +(5-i)+" more time(s)): ");
time2[i] = scan2.nextDouble();
}
double sum2=0;
for (int a=0; a<time2.length; a++){
sum2 += time2[a];
}
double fly_time = sum2 / time2.length;
Scanner scan3 = new Scanner(System.in);
System.out.println("Enter blocks (m)");
double fly_block = scan3.nextDouble();
fia(rM ,fly_time,fly_block );
}
public void additi(double rM, double fly_time, double fly_block){
fia(rM, fly_time, fly_block);
}
public void fia(double rM, double fly_time, double fly_block){
double volumn = (4*rM*rM*rM*Math.PI)/3;
double perimeter=Math.PI*rM*2;
double total_blocks = volumn/1;
double total_chunk = total_blocks / 65536;
double total_diamond = total_chunk*3.097;
double total_emerald = total_chunk*0.2;
double speed_fly = fly_block / fly_time;
double time_around_sec = perimeter/speed_fly;
double time_around_mi = time_around_sec/60;
double time_around_hour = time_around_mi/60;
double time_around_day = time_around_hour/24;
double time_around_week = time_around_day/7;
double time_around_month = time_around_day/30;
double time_around_year = time_around_day/365;
System.out.println("The volume of that world is: "+volumn);
System.out.println("The perimeter of the world is: "+(double) Math.round(perimeter*100)/100+ " which means there are total: "+ (double) Math.round(total_blocks*100)/100 + " blocks in Minecraft and there are "+(double) Math.round(total_diamond*100)/100+ " blocks of diamond and "+ total_emerald + " blocks of emerald" );
System.out.println("It takes "+ (double) Math.round(time_around_sec*100)/100 + " second(s) or " + (double) Math.round(time_around_mi*100)/100 +" minute(s) or "+ (double) Math.round(time_around_hour*100)/100+ " hour(s) or "+ (double) Math.round(time_around_day*100)/100 +" day(s) or "+ (double) Math.round(time_around_week*100)/100 +" week(s) or "+(double) Math.round(time_around_month*100)/100+" month(s) or "+(double) Math.round(time_around_year*100)/100+" year(s)"+" to go one circle around Minecraft world");
}
// 5E11 = 5 x 10^11
}

june 06, 2018 by @frychicken


How big is the minecraft world and how long will it take to travel around the world?

Imgur

Using classical physics technique

First, starts with gravity.

h = 1/2gt^2 
g = 2*h/t^2

where "g" is gravitational acceleration (m/s^2); "h" is height (m), and "t" is time (t).

Imgur

Each block in minecraft is 1x1x1 (m^3), so we can build to a certain height and count the jump down, image above, time in second (Do this multiple times).

I found that the time for 50m-jump is 2.20 seconds so g is ~20.66 m/s^2 whereas on earth is ~9.8 m/s^2

Second, calculate the radius/mass.

using the universal gravitation equation:

mg = (G*M*m)/r^2
g = G*M/r^2

where "g" is gravitational acceleration (m/s^2); "r" is radius (m); "M" is mass of the planet(kg); "m" is mass of the object (kg), "G" is Universal constant - 6.674×10^−11 - (N·kg^–2·m^2).

gMinecraft is 20.66 and gEarth is 9.8 -> gMinecraft = 2.11 * gEarth

2.11*gEarth = gMinecraft

2.11 * (G*Mass_earth/radius_earth^2) = gMinecraft

-> either Mass of Minecraft world is 2.11 times bigger than the mass of earth or the radius of the planet is 0.69 (1/square root of 2.11) times bigger than that of earth.

The mass of minecraft world is 2.11* 5.972 × 10^24 = 12.60092 x 10^24 kg or the radius of minecraft world is 0.69* 6371000 = 4395990.0 m.

With everything above, we can find how many diamonds/emeralds/blocks; how long will it take to travel around the world

(If minecraft world is NOT flat)

First, we need to find the volume
(4*rMinecraft*rMinecraft*rMinecraft*Math.PI)/3;

the volume is 3.558432210460817E20 or 3.56x10^20 m^3

the volume of a block in minecraft is 1x1x1 = 1 m^3

so, there are 3.56x10^20 / 1 = 3.558432210460817E20 or 3.56x10^20 blocks in minecraft.

There are 3.097 blocks on diamond in a chunk and 0.2 blocks of emerald in a chunk-a chunk is 65536 blocks.

Using the information above, we can find how many chunks in minecraft using 3.56x10^20 / 65536. As a result, there are total total_chunk * 3.097 = 1.6815894402766646E16 / 1.7 x 10^16 blocks of diamonds and total_chunk * 0.2 = 1.0859473298525442E15 or 1.1 x 10^15 blocks of emerald.

how long it takes to travel around minecraft world?

Thinking it as a circle with radius = 4395990.0, we can find the perimeter of a minecraft world

Math.PI*rMinecraft*2;

-> the perimeter is 2.762081978E7 or 2.8x10^7 m

Now, we need to calculate the speed by using how many blocks per time (do this multiple times).

I found that the time to fly (I fly because it is the fastest way to travel) 10 blocks is 0.87 seconds, so the speed is ~ 11m/s

S = v*t

-> t = S/v = 2.8x10^7 / 11 = 2403011.32 seconds or 40050.19 minutes or 667.5 hours or 27.81 days or 3.97 weeks or 0.93 months or 0.08 years to go one circle around Minecraft world

Conclusion

nearly 4 weeks to go one circle around Minecraft world?! With that said, I think the mass of minecraft world is 2.11 times bigger than that of earth. In addition, the minecraft world is flat - if you dig down, you will see the end but not the other half of the world (image below).

Imgur

This is the program I wrote for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment