My Very First Mod – Making Better Pickaxing in Terraria

So yesterday I decided to step into the world of modding first-hand for the first time.  I never was the sort to hack and change other people’s work, but I always find something “wrong” with the games I play.  When I say “wrong”, I don’t necessarily mean bad, I mean inadequate for my own selfish desires.  The popularity of Minecraft caused a veritable explosion of mods for that game.  Modding comes about when players want something more out of the games they play.  Because no single developer (or team of developers) can ever truly make the all-encompassing game…inevitably, omissions will arise in the eyes of players.

I first started considering modding after the popularity of Minecraft reached epic proportions.  I lackadaisically explored the possibility of modding:  I didn’t even know where to begin so I just did some light research and some Google’ing (funny that this has become a verb).

Now I’ve always been really good with computers.  I’m a programmer at heart and I’ve written countless programs myself, but I never put any thought into what it would take to actually “mod” something.  I used to think the programs were bullet-proof shells that only the original programmer knew how to work with, tweak, or expand on.  I was so wrong…

Minecraft was programmed in a language called Java.  Its semantics and syntax are similar to (or at least along the same lines as) C++ and C#.  It’s an object-oriented language, which are languages I’m most familiar with and have the most experience in.  I love being able to treat programming concepts in terms of objects…anyway.  Even though Minecraft was made with Java, I’ve never done any serious work in that language, and although it’s in the same neighborhood as C++ and C# (which I’m good at) it still has its own rules and meanings that you have to learn and understand.  The most critical thing about Java is that it’s designed for cross-platform compatibility and works well as a platform for web apps.  Of course, Java can make standalone desktop programs as well.

At any rate, I was still too much of a modding “babby” at the time to do any serious work with Minecraft modding.  Plus, I had gotten tired of the game by that time anyway.

That was about a year and a half ago…fast forward to present day!

With the recent surge in interest of Terraria (with its new 1.2 update coming in July), I decided to play it again.  I immediately started a new character and a new world.  I decided to do hardcore mode (which has nothing to do with the content of this article, but I digress), I played a good 4+ hours before I died.  During my play, I remembered the thing about the game which made me sore (literally).  That thing was the mining.  Mining in Terraria (and by the same token Minecraft) requires holding down the left mouse button on a single block in the world until that block breaks.  As you progress in the game you can get better pickaxes that gradually reduce the time it takes to mine a single block.  But in the early game, you do a lot of holding down the mouse button, which for me strains my index finger.  I don’t know, maybe it’s my mouse, maybe it’s my dainty, weak fingers, but the point is it’s uncomfortable after a while and more to the point, it never made much sense that a pickax could only break one tiny little block at once (especially since the player swings it in a wide arc over its head, giving the impression that you should be doing some serious damage to the surrounding earth).

Sidenote: Minecraft suffers from the same problem, although in Minecraft the blocks visually look much bigger in first person and therefore the effect isn’t as noticeable and thus, isn’t as much a problem (but don’t mistake me, I still consider it uncomfortable in Minecraft as well).

So to address this issue, I did a random search for some Terraria mods just to see what was out there.  It turned out that there were a lot of mods for the game.  This was surprising because I didn’t think Terraria was designed for mod support at all (I was correct about this), however (and what shocked me) was that this didn’t matter at all.

The quintessential thing I learned about modding was this:
* A game doesn’t need to provide mod support in order to be modded *

Of course, I knew through my existing knowledge and experience with computer science and how computers and software worked, that “technically” any program could be cracked open and reverse-engineered.  I’ve seen countless EULA’s which explicitly say not to do so.  My ignorance was in the fact that it actually isn’t as difficult as it seemed.  Back when I was checking out how modding worked for Minecraft, I learned about a program that decompiled Java binaries or object code back into .java source code.  The thing is that even though Notch obfuscated his code (a thing many developers do) before building the executable, one can still decompile and figure out how the code works.  This was the key I was missing.  I gave up trying to mod Minecraft at the time but I kept this knowledge for use when I made this mod I’m about to describe for Terraria.

Now I knew Terraria was developed in XNA, but of course I didn’t think to look around for C# decompilers back when I first started playing the game a couple years ago.  It turns out though, that there is a nifty little program called ILSpy, which decompiles IL (Intermediate Language) for Microsoft .NET programs.  I read a thread on the Terraria forums talking about it and that’s how I found out about it.

I downloaded ILSpy and gave it a whirl.  I figured I’d just see how far I get.  It turns out that I got pretty far.  :).  Even though the source code I got from the decompiler wasn’t very readable (it has no comments because comments aren’t built into the .exe), it actually still had lots of symbol names to help figure things out.  The textures, tile data, and other useful game objects had meaningful names, which gave me the impression that Re-Logic didn’t obfuscate the code (although I don’t know for sure).  Either way, I personally have never obfuscated my code because I’ve never actually released a commercial title, but I sincerely appreciate Re-Logic for not doing so if this was the case.

After a little refactoring and commenting, I worked out where to put the new code to make my feature a reality.  I added the following code in the PlayerUpdate() routine of the Main class:

Terraria - Microsoft Visual Studio 2010 Express for Windows Phone_2013-06-04_14-55-01

This code implements the 3 block (Terraria calls them Tiles) breaking functionality and also the damage tracking.

Now breaking 3 blocks at a time and having the damage be stored for each block was fun enough, but to really make it look good, I decided to see if I could make the blocks show a damaged overlay on top so that the player could see that he was in fact damaging the blocks.

I added the following code to the DrawTiles() method of the Main class:

Terraria - Microsoft Visual Studio 2010 Express for Windows Phone_2013-06-04_15-04-12

This draws a certain “damage overlay” image on top of any tiles that have the appropriate hit damage.

Also added (but not shown) is code to load these four textures from the disk and store them in the static variables used in the Draw method.

All in all, it was a very rewarding experience.  If you own and play Terraria and would like to try this mod out for yourself, click the download link below.  Instructions for installing are in the zip file.

Download link:

Here’s a video demonstrating the functionality:

Posted in Uncategorized | 4 Comments

Respecting The Freedom of Ideas and Beliefs

I’m going to start embracing my freedom of speech more and I’m going to make an earnest effort to stop myself from getting annoyed when I hear and see other people practice theirs. For the record, I’m not religious and I don’t believe in God. I’m going to stop getting annoyed at others who say they do. So if you have a belief you want to share with the world, SHARE IT! Nobody should ever feel afraid to say what they feel. I’ve said critical things to people who’ve posted their belief’s and opinions in the past. Although I was always respectful with my choice of words, I was still “raining on that person’s parade” and not making them feel any better. I don’t want to be that kind of person.

There needs to be a whole lot more love and respect for our fellow man and woman in this world. We need to treat each other as equals instead of as adversaries.

I don’t believe in God, Jesus, ghosts, spirits, fairies or Santa Clause, but that’s just me and I don’t wish to change that fact about myself. On the same token I also shouldn’t try to change what others believe.

My wish for the future is that everyone can accept each other for their beliefs or lack of beliefs. As long as belief doesn’t turn to violence, I can see no harm in it. So the next time you hear somebody say, “God doesn’t exist” or “Jesus died on a cross for our sins” or “Satan loves pineapples” or even “The deer is a gift of the Earth mother”, just say “ok” and move on.

Accept what people believe and we will all be better off. Thanks for listening and have a wonderful day! 🙂

Posted in Uncategorized | Tagged , , , , , , , , , , , , , , , , , , , | Leave a comment


The person who made the quote in my previous post caught wind of my harsh critique of her language and was offended to say the least.  I often find myself writing words that hurt people’s feelings.

Interestingly, I write more hurtful words than I do speak them.  I tend to be very docile and reserved in person, unless I’m at a party and alcohol is involved (in which case I can loosen up and be more social), but I often times find it more difficult to say harsh or critical words to someone in person then I do online on a blog or on Facebook.  It should come as no surprise, that typing words on a keyboard is a lot easier than saying them to someone’s face.

I believe it’s pretty cowardly of me to hold back my critiques and disagreements in person, but let them loose online.  It’s not difficult to understand why, typing is much easier for me than speaking.  Although I can speak fluently and confidently, it’s just easier for me to type words out than to speak and risk fumbling over the right words.

Speaking in person to be convincing in an argument is much tougher than in formal writing.  When you speak in person, you are perpetually “on the spot” as you speak and people are waiting for your words to come out.  If you slip up, stumble, or slur, or lose your train of thought; you immediately lose nearly all credibility you had in trying to explain your position.  However, in writing, you have much more time to compose your thoughts and choose just the right words in just the right order to sound as convincing as you wish to be.

So back to feelings…I don’t care for them and I wish we didn’t have them.  They make life so much more complicated than it needs to be.  Of course, some feelings are beneficial or enjoyable…like the feeling you get after relieving your bladder when you’ve been holding it for so long.  Or the feeling of excitement after seeing something exciting or the feeling of accomplishment after accomplishing something.  But the sad and miserable feelings we get when someone does or says something hurtful to us should be surgically removed at birth.  We might have a lot less conflict in the world if we can do that.

Posted in Uncategorized | Tagged , , , , , , , , , , | Leave a comment

A Culture of Distrust and Unkindess

We live in a world with increasing competition for resources. It’s sad that we’ve been driven to such a strong culture of distrust and unkindness toward “other people.”  I recently read a rather disturbing post on Facebook which read as follows:

Stupid drunk bum, made the mistake of asking me for money in a dark parking lot tonight… he was in between my car and another car…. popped up out of nowhere. I pushed his sorry ass to the pavement. scared me pretty bad.. he got up n ran away. be careful girls!!

The post uses prejudicial and hostile words (which I’ve bolded) to describe the man, when the only discernible offense committed was asking for money and popping up out of nowhere in the dark.  The replies that followed were full of praise and kudos.  One particular reply stood out for me:

You are my BAS ASS HERO, [Name]! ‘SECURE’ Queen! How dare that idiot think it was ok to approach you like that!

Yes, indeed.  How dare he.  How dare a person ask for help in this country.  If the man was hostile or threatening or demanding during the exchange, I could understand…but no such evidence of that was given and I’m not going to assume that he was.

So now I pose a couple of questions to anyone reading this:

1. If a strange looking man with dirty clothes came up to you and asked you for money, what would be your first assessment of him?

A) He’s a drunk and homeless bum.
B) He’s possibly a drunk and homeless bum.
C) He may be drunk or homeless, but he’s not necessarily a bum.
D) He’s a bum, but he may not necessarily be drunk or homeless.
E) He’s a bum just trying to leech money off me.
F) He’s a person asking for help.

2. After your initial assessment, what would you do?

A) Ignore him and walk away.
B) Tell him to leave you alone.
C) Tell him you don’t have any cash or change on you (even if you do).
D) Give him spare change.
E) Ask him why he needs the money (even if you’re pressed for time) and be willing to have a normal conversation with him.

Now repeat the previous two questions for a stranger who happened to be a woman. What if it was a child? Really think about the questions and be as honest as possible with yourself. Now try to ask yourself why you answered the way you did.

Posted in Uncategorized | Tagged , , , , , , , , , | Leave a comment

Looking Back on My Life

I was recently going through some old emails that were exchanged between myself and one of my greatest friends.  It was 2006 and we were both deployed to the middle east.  I was in Afghanistan and he was in Iraq.  We kept each other informed of what was going on in our own little worlds.  We talked about the things we were going to do when we got back home.  We were going to go to Vegas, hit the town, pick up chicks, live it up…we were going to treat ourselves after working so hard in the desert.

Sadly, Vegas never came to pass.  As time went on during our deployments, our priorities changed.  Suddenly, our financial situations became more important and our feelings and sentiments changed.  Looking back on it now I can’t think about what exactly it was that changed our priorities and why we lost our will to go and take life by the horns.  I just remember getting back home and falling back into the same routine we had before we left.  In reality, nothing had really changed.  Sure we came back new men–I had slightly more confidence and he had more wisdom–but it wasn’t enough to force us to go out and take action like we talked about over email.

Perhaps it’s simply easier to say something then to actually do it.  We talked a lot about what we wanted to do, but when the time finally came, we instead did nothing.

This brings credence to the sayings: talk is cheap and actions speak louder than words.

Here’s to doing more of what we say we’re going to do.

Posted in Uncategorized | Leave a comment

A Roadblock to Animating the Xbox 360 Avatar Gadget

I really didn’t want to get the hopes up of any of the users of the Xbox 360 Avatar gadget, only to bring them back down again; but unfortunately I feel I may have done just that.

Sadly, animating the gadget (by leveraging the Xbox Live Avatar’s 3D API from within XNA) is not possible on Windows.  This feature is reserved for Xbox 360.  Microsoft apparently uses an in-house solution to present your avatar’s 3D model on the Xbox Live website and doesn’t provide a publicly accessible means for 3rd-party developers to present it.

I’ve been checking out a multitude of resources on the web, trying to see if I there would be any way of animating the gadget using workarounds and came up empty-handed.  The newest version of Silverlight (version 5) shows promise for the future by allowing developers to utilize the fundamental XNA 3D libraries from within a browser, but the cold, hard fact remains:  Until the libraries which provide avatar functionality are made available to 3rd-party developers on the Windows platform, the Xbox 360 Avatar gadget will have to remain motionless.

Perhaps when Windows 8 ships, other avenues will open up to allow the development of a start screen app that can display the actual 3D model of our avatars.  Keep your eyes on the future…

Posted in Notifications, Xbox 360 Avatar Gadget | Tagged , , , | 8 Comments

Animating the Xbox 360 Avatar Gadget

Thanks to a very helpful user of the gadget (goes by the name of Dave), I have been informed that animating the avatar within the gadget may be possible.  Apparently, the Xbox Live site currently hosts the animated version of the avatar in a Silverlight plugin and since gadgets are merely glorified, miniature web apps that live on the desktop, using Silverlight in a gadget is completely possible and opens up a whole new world of possibilities for the gadget.  However, since gadgets are slowly being fazed out with Windows 8’s new “metro app framework”, this gadget will likely not see any significant revamping other than to add animation to the avatar.

On the bright side though, if there is enough support, I will consider writing a new Windows 8 dockable app that may be able to serve as a logical evolution of the Xbox 360 Avatar Gadget.  I’ll have to see what the final version of Windows 8 holds and how the new app ecosystem develops.  I’m curious to see how the current Windows 7 Gadget Platform will change (or if it doesn’t) for Windows 8 and what the usefulness will be for having gadgets live on the “old” desktop that will be overshadowed by Windows 8’s new Start/Home Screen.

Anyway, I’m currently working on writing a new version of the Xbox 360 Avatar Gadget that will utilize Silverlight (which can leverage XNA libraries to animate and control the avatar in many useful ways).  The new version of the gadget will likely be remarkably different so I will not simply replace the current unanimated one with the new animated one, just in case some people have problems with the animated version.

Stay tuned!

Posted in Notifications, Xbox 360, Xbox 360 Avatar Gadget | Tagged , , , , , , , , , | 10 Comments

I’m currently tracking the development of this project called Species. I like the concept of it and it looks like it could be really fun to play. If you like checking out fun and interesting up-and-coming programming projects as much as I do, you should check out this person’s blog!

Edit:  For the record, I don’t think render targets are evil.  🙂

Species Development Blog

aka. Misadventures In Implementing a Real Time Tree of Life Graph. Note: this post is a logical sequel to the previous post, though it also doubles as a what-not-to-do tutorial of sorts when it comes to implementing real time graphs and render targets in XNA. Fair warning: It’ll probably be a bit incomprehensible if you’re not a programmer.

/tangential progress report: we’re about 40% of the way to the alpha release deadline and about 50% of the way through the “list of crap to do”. So we’re ahead of schedule, but not by much.

It’s probably worth noting that part of the reason I’m cutting it so fine is micro-feature-creep. A major advantage of programming on your own is the ability to indulge your inner ADHD-sufferer: getting distracted by something that sounds like fun and wandering off to code it. Some of my favorite features in Species have…

View original post 1,734 more words

Posted in Uncategorized | Leave a comment

FlexNA Beta 1.0 and New Site Design

FlexNA has reached a milestone release:  Beta 1.0.  You can get it over at the newly redesigned homepage:  All the information you need to know about the 1.0 release is on the website.  Go there and check it out!

Posted in Notifications | Leave a comment

Extending the Microsoft XNA Framework

I’ve been working on a space colonization/exploration/conquest/adventure/arcade/action game for the past eight years or so and I’ve never been able to finish it.  The development tools I use keep evolving and I keep wanting to apply new features.  Unfortunately, this resulted in a perpetual development cycle with no foreseeable end.


The most recent development tool I’ve been using to develop my game has been Microsoft’s XNA Game Studio; which, while sounding fancy, is really just an API built on top of the .NET framework.  XNA provides a .NET friendly layer on top of the DirectX 9 API, which can be easier than accessing the DirectX 9 API directly using C++.  While I can program in C++, I’ve found C# and the .NET framework to be easier and quicker to use.  The .NET framework handles many of the minutia that programming in C++ requires and this cuts down on development time.  Since my time is limited:  C#, the .NET framework, and XNA are practical alternatives for me.

Throughout my time developing my game using XNA Game Studio, I’ve found that there are many features that I want in my game that aren’t available “out of the box” in the XNA framework.  In other words, there aren’t certain classes available to do what I want and so I have to make them myself.  This is understandable given that XNA is designed to be a general framework to start a game project from.  As I wrote the classes that I needed to be part of my game (such as an intro screen, main menu, hit detection, buttons, dialogs, popups, etc.) I found that these were features that many, if not all, games use.  I started building my own game framework on top of XNA, which in some circles could be referred to as a “game engine.”  However, a game engine is usually designed for a specific game and many games use their own game engine.  However, I found that the features I need are more general and can be used for a wide variety of games that I may plan to make in the future.  An intro screen, main menu, windows, popups, buttons, hit detection, etc. are all things that virtually any game would need and curiously, they are not provided as built-in features of the XNA framework.  So I decided to write my own.

The Beginnings of a new Framework

What started as a simple set of classes to handle the core functionality for my space colonization/exploration/conquest/adventure/arcade/action game (which I’ll simply refer to as my “space game” from now on), grew into an actual framework that can provide functionality to all types of games.  Primarily, I wanted a framework to give me everything I needed to start right into writing the actual meat of a game whenever I wanted to start a new game project.  Every game I plan on making needs to have a main menu, intro screen, etc., so I want those to be available from the start, requiring only a little tweaking.

When I was developing my space game in XNA, I kept coming up with new features that were useful as a generic feature for all my games, so they went into the “Framework” folder of the code library for the game.  Eventually, as the “Framework” folder got big enough, I decided it needed to be its own entity, and so the FlexNA framework was born.

Enter FlexNA

“FlexNA” is a name I came up with to distinguish my core game library from my space game.  FlexNA started as a folder within my game’s overall solution in Visual Studio.  I then separated it out as its own “Game Library” solution and kept my space game as its own solution.  However, this posed problems when developing my space game and FlexNA at the same time.  Really, they weren’t problems per se, just annoyances and inconveniences associated with syncing and moving between two projects all the time.  Because of these quirks, I moved FlexNA back into the space game’s solution and kept it as a separate project within the solution.  This allowed me to develop both my space game and FlexNA side-by-side without any inconveniences.

As I continued work on the space game, I noticed that most of the work was going to FlexNA.  Also, the FlexNA code was starting to become patch worked and messy as I added the new, removed the old, and tweaked the existing code.  This led me to the conclusion that I needed to start FlexNA off right and rebuild it from the ground up as the standalone game library it was meant to be.

FlexNA has once again been put into its own solution and FlexNA 0.1 is now in development.  If I can get it to version 1.0, then it will be a complete framework ready to be used in other games.  It can then be extended later on to add more features, at which point games can use updated versions of FlexNA as necessary or keep with 1.0.


If you are interested in what FlexNA can do for your game projects, let me know.  As I develop the framework, I will post more on what it can do and what I plan for it to do.

Posted in Computers and Internet, Game Development | Tagged , , , , , , , | Leave a comment