/Write and /Setfont

For all mod-related questions and custom code.
Post Reply
Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

/Write and /Setfont

Post by Jonty800 »

Here are two commands that I wrote a couple of months back.

/Write is a command to write text in minecraft blocks. The code has been tested on mono and windows.

/Write is mainly used to decorate your server and can be used as a tool to create cool server logos. /Setfont is a command that controls /Write. It can set the font size and the font for the text.

When someone first uses /Setfont Font, a new folder is created called "fonts". In here, you can add any .ttf font and players can /Write with them

Have some screenshots:

Image
Image
Image

The code is rather lengthy, so I'll pastebin each step for you

Step 1: Place this into buildingcommands.cs
http://pastebin.com/cNWeyArw

Step 2: Create a new class file called FontHandler.cs and paste this
http://pastebin.com/xrXHM5uh

Step 3: Create a new class file called Direction.cs and paste this
http://pastebin.com/Pj8h5d5t

Step 4: Add this into player.cs:

Code: Select all

//at the top
using System.Drawing;

//then

public Font font = new Font("Times New Roman", 14, FontStyle.Regular, GraphicsUnit.Pixel);
        System.Drawing.Text.PrivateFontCollection FontC;
        public FontFamily LoadFontFamily(string fileName)
        {
            FontC = new System.Drawing.Text.PrivateFontCollection();//passing memory space to FontC
            FontC.AddFontFile(fileName);//we add the full path of the ttf file
            return FontC.Families[0];//returns the family object as usual.
        }
fCraft doesn't reference System.Drawing, so you need to do that manually. Users of Visual Studio / Express should already know how.

If you use this code, let me know if I missed out anything. Enjoy!

Edit: Oh and some of the comments are old. Ignore them :P
You cannot use certain BBCodes: [img].

User avatar
OfficerFlake
Offline
Posts: 25
Joined: May 28th, 2012, 12:03 am

Re: /Write and /Setfont

Post by OfficerFlake »

Holy fuck that's awesome. :wink:
=== MeinKraft 24/7 ===
Server Owner & Code Developer

Post Reply