Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Commit

Permalink
Hehe.. #120 (My magical RIG)
Browse files Browse the repository at this point in the history
  • Loading branch information
sameer committed Feb 17, 2016
1 parent 17d71ed commit 90e34df
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 16 deletions.
44 changes: 28 additions & 16 deletions patches/net/minecraft/server/MinecraftServer.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,19 @@
FMLCommonHandler.instance().handleServerStopped();
this.serverStopped = true;
this.systemExitNow();
@@ -532,8 +799,11 @@
@@ -497,6 +764,11 @@
{
File file1 = this.getFile("server-icon.png");

+ if (!file1.isFile())
+ {
+ try {thermos.SIGen.gen(this,file1);} catch(Exception e){}
+ }
+
if (file1.isFile())
{
ByteBuf bytebuf = Unpooled.buffer();
@@ -532,8 +804,11 @@

public void tick()
{
Expand All @@ -595,7 +607,7 @@
++this.tickCounter;

if (this.startProfiling)
@@ -562,12 +832,21 @@
@@ -562,12 +837,21 @@
this.field_147147_p.func_151318_b().func_151330_a(agameprofile);
}

Expand All @@ -619,7 +631,7 @@
}

this.theProfiler.startSection("tallying");
@@ -575,25 +854,57 @@
@@ -575,25 +859,57 @@
this.theProfiler.endSection();
this.theProfiler.startSection("snooper");

Expand Down Expand Up @@ -679,7 +691,7 @@
int i;

Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0);
@@ -602,19 +913,21 @@
@@ -602,19 +918,21 @@
int id = ids[x];
long j = System.nanoTime();

Expand All @@ -704,7 +716,7 @@

this.theProfiler.startSection("tick");
FMLCommonHandler.instance().onPreWorldTick(worldserver);
@@ -622,22 +935,46 @@
@@ -622,22 +940,46 @@

try
{
Expand Down Expand Up @@ -753,7 +765,7 @@
worldserver.addWorldInfoToCrashReport(crashreport);
throw new ReportedException(crashreport);
}
@@ -645,10 +982,12 @@
@@ -645,10 +987,12 @@
FMLCommonHandler.instance().onPostWorldTick(worldserver);
this.theProfiler.endSection();
this.theProfiler.startSection("tracker");
Expand All @@ -767,7 +779,7 @@

worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j;
}
@@ -656,15 +995,21 @@
@@ -656,15 +1000,21 @@
this.theProfiler.endStartSection("dim_unloading");
DimensionManager.unloadWorlds(worldTickTimes);
this.theProfiler.endStartSection("connection");
Expand All @@ -789,7 +801,7 @@

this.theProfiler.endSection();
}
@@ -699,6 +1044,13 @@
@@ -699,6 +1049,13 @@

public WorldServer worldServerForDimension(int p_71218_1_)
{
Expand All @@ -803,7 +815,7 @@
WorldServer ret = DimensionManager.getWorld(p_71218_1_);
if (ret == null)
{
@@ -784,13 +1136,14 @@
@@ -784,13 +1141,14 @@

public List getPossibleCompletions(ICommandSender p_71248_1_, String p_71248_2_)
{
Expand All @@ -822,7 +834,7 @@

if (list != null)
{
@@ -798,40 +1151,25 @@
@@ -798,40 +1156,25 @@

while (iterator.hasNext())
{
Expand Down Expand Up @@ -871,7 +883,7 @@
}

public static MinecraftServer getServer()
@@ -1034,7 +1372,7 @@
@@ -1034,7 +1377,7 @@

public boolean isServerInOnlineMode()
{
Expand All @@ -880,7 +892,7 @@
}

public void setOnlineMode(boolean p_71229_1_)
@@ -1124,7 +1462,7 @@
@@ -1124,7 +1467,7 @@

public NetworkSystem func_147137_ag()
{
Expand All @@ -889,7 +901,7 @@
}

@SideOnly(Side.CLIENT)
@@ -1259,8 +1597,11 @@
@@ -1259,8 +1602,11 @@
{
Bootstrap.func_151354_b();

Expand All @@ -901,7 +913,7 @@
boolean flag = true;
String s = null;
String s1 = ".";
@@ -1356,16 +1697,34 @@
@@ -1356,16 +1702,34 @@
{
dedicatedserver.setGuiEnabled();
}
Expand Down Expand Up @@ -942,7 +954,7 @@
}
catch (Exception exception)
{
@@ -1400,15 +1759,70 @@
@@ -1400,15 +1764,70 @@
@SideOnly(Side.SERVER)
public String getPlugins()
{
Expand Down Expand Up @@ -1018,7 +1030,7 @@
}

@SideOnly(Side.SERVER)
@@ -1455,9 +1869,213 @@
@@ -1455,9 +1874,213 @@
return this.serverStopped;
}

Expand Down
128 changes: 128 additions & 0 deletions src/main/java/thermos/SIGen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package thermos;

import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class SIGen
{

//Initialize a random number generator
public static final Random r = new Random();

//Image Size
public static final int width = 64, height = 64;


public static void gen(net.minecraft.server.MinecraftServer MS, File file1) throws Exception
{

//Create the image
BufferedImage bi = new BufferedImage(width,
height,
BufferedImage.TYPE_INT_RGB
);

//Initialize Graphics2D for drawing on the image
Graphics2D g = bi.createGraphics();

//Some renderer hints that make the output image sharper
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
g.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);

//Randomly decide how many points to use as start points
int num_nodes = r.nextInt(9) + 3;
for (int i = 0; i < num_nodes; i++)
{
//Randomly select start point coordinates
int centerx = r.nextInt(width);
int centery = r.nextInt(height);

//Randomly decide how many node branches to create
int num_branches = r.nextInt(16) + 5;
//Choose a random color
Color c = null;
switch (r.nextInt(6))
{
case 0:
c = Color.BLUE;
break;
case 1:
c = Color.RED;
break;
case 2:
c = Color.GREEN;
break;
case 3:
c = Color.ORANGE;
break;
case 4:
c = Color.YELLOW;
break;
case 5:
c = Color.WHITE;
break;
}
//Create the branches
for (int a = 0; a < num_branches; a++)
{
//"Transform" the graphics object so that drawn branches will originate for the start point at a specified angle
AffineTransform aft = AffineTransform.getRotateInstance(Math.toRadians(360 * ((double) a / num_branches)), centerx, centery);
g.setTransform(aft);

//Recursively create the branch
branch(g, bi, centerx, centery, 2, 8, 50, 50, 20, 20, c);
}
}
ImageIO.write(bi, "png", file1);

//Display image
JFrame f = new JFrame();
f.getContentPane().setLayout(new FlowLayout());
f.getContentPane().add(new JLabel(new ImageIcon(bi)));
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);

}

public static void branch(Graphics2D g, BufferedImage bi, int lastx, int lasty, int node, int maxdepth, int ydv, int xdv, int ydm, int xdm, Color c)
{
//Choose the next branch 1 and 2 endpoints
int b1x = lastx + r.nextInt(xdv) + xdm, b1y = lasty + r.nextInt(ydv) + ydm;
int b2x = lastx - r.nextInt(xdv) - xdm, b2y = lasty + r.nextInt(ydv) + ydm;
if (node == maxdepth)
{
//Stop recursive call so that we dont create branches forever
return;
}
//Set the current branch color
g.setPaint(c);
//Draw branch lines
g.drawLine(lastx, lasty, b2x, b2y);
g.drawLine(lastx, lasty, b1x, b1y);

//Call the branch again, incrementing the node number and reducing the branch variation and making the color darker
//Divide into *two* new branch calls
branch(g, bi, b1x, b1y, ++node, maxdepth, (int) (ydv / 1.1), (int) (xdv / 1.1), ydm, xdm, c.darker());
branch(g, bi, b2x, b2y, node, maxdepth, (int) (ydv / 1.1), (int) (xdv / 1.1), ydm, xdm, c.darker());
}

public static int RGBTransform(int R, int G, int B)
{
R = (R << 16) & 0x00FF0000;
G = (G << 8) & 0x0000FF00;
B = B & 0x000000FF;
return 0xFF000000 | R | G | B;
}
}

4 comments on commit 90e34df

@Yive
Copy link
Contributor

@Yive Yive commented on 90e34df Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting is something that doesn't exist in your dictionary 😆

@sameer
Copy link
Member Author

@sameer sameer commented on 90e34df Feb 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy+paste from my files does!

@sameer
Copy link
Member Author

@sameer sameer commented on 90e34df Feb 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KasperFranz discord?

@sameer
Copy link
Member Author

@sameer sameer commented on 90e34df Feb 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And he is a friend of mine, gave me permission to use his gens for the server icons. He doesn't have a github though :/

Check out his blog here: https://c0dart.wordpress.com

Please sign in to comment.