Spring Cleaning

I’ve decided to have a spring clean of my social media presence. I run four different blogs about four different aspects of my life and I am now feeling that I’d like to draw the threads closer together. This is probably a good time to apologise – if you’re an avid follower of all things Graham H Miller, then you’ll be seeing this message several times!

I’ve decided to make http://grahamhmiller.com my main hub across the web. It’s the only WordPress site I’ve got a custom URL for and it also makes the most sense. I’d like to be able to import all my blogs to here, but I don’t think I can. This is quite reasonable as I’ve got different follower lists and there no reason, for example, why my Penguin’s Knee followers would want to know about Minecraft.

So, for the minute, until I can figure out something more elegant, I’ll put links to everything over here on one page: http://grahamhmiller.com/otherblogs. So, whichever blog you read this post on, you can head over there to see what else I do. It’s probably worth pointing out that I write both fiction and non fiction, and grahamhmiller.com is my main blog for all things about writing.

What do you, my followers, want me to do? Keep it all separate or try to merge it? Likewise, if you know more about WordPress than me and feel like being helpful, please do get in touch!

Thank you!


Entity or Mob Tutorial

For this tutorial I’m assuming that you have Minecraft 1.7.2 and Forge 1060. Also that you have Eclipse installed, with separate projects for your mod and for the decompiled Minecraft code. (If you haven’t got that far yet, then go and Google for some tutorials!) In order to keep the whole tutorial quite clean looking, I’ve put the code for the main classes up on Dropbox – you can find them here:


  1. For an entity or mob on Minecraft, there are several different classes that you’ll need. I’m adding a bear to my mod, so as I go through, I’ll type it up here. To define the animal itself, you need an entity class, a model class, and a render class. Then you need a class to load it into Minecraft, which is the main mod, along with a proxy class to tell Minecraft where to find the render and model files. And finally you’ll need a language file and a texture for it, all in the right locations in your file structure.
  2. I use Techne to make the basic models. As it’s a graphical tool I tried to make a vide of me using it. But Bandicam only captures OpenGL or DirectX directly. I set it to screen capture but it came out as nearly 1GB for a five min video that made YouTube timeout on the upload. I might fix it but in the meantime I know there are Techne video tutorials out there.  Once you’ve finished your model with Techne, you export two files, a .png texture map and a .java code file.
  3. The first class I added I called EntityBear. I’m a great believer in not writing more original code than you need to. So I looked for similar classes in the source to copy code from. Based on what I found, I decided to extend EntityAnimal and copy all the code from EntityWolf that doesn’t have anything to do with taming. This will be a first pass through to get it running. When that’s done I’ll change it to make it more personal. Obviously depending on what you’re writing you can extend whatever you want.
  4. Once I typed ‘extends EntityAnimal’ a whole host of errors popped up so I followed the suggested fixes to put in the function stubs and add the imports.
  5. Then I copied over the variables and AI code from the wolf code and edited out all the tameable stuff. I also did a general tidy up to rename variables and functions to reference bear not wolf.
  6. Next I added a ModelBear class that extends ModelBase. I copied in the body of the code from the Techne .java file, from the first ModelRenderer definition down to the SetRotation Function.
  7. This step took me ages to find. In the constructor, add super.textureHeight=64 and super.textureWidth=128. Or whatever size your texture map is, if it isn’t 64×32. Without this all sorts of weird and unpleasant things happen! Also note that your map size has to be in binary number steps, 32, 64, 128, 256 etc and must be twice as wide as it’s high.
  8. Just after the head.addbox, I copied the code from the nose and added a head.setTexture(co-ordinates from the nose render constructor).addbox(parameters from the nose.addbox) This will make the nose move with the head. It can also be used for horns, ears, and other bits attached to boxes. Doing this step I realised that you must set the Position of the nose (which is where the blue ball is on Techne) to the same as the head, otherwise all sorts of odd things happen. For a moment I had a bear with a nose that floated in front of its face.
  9. Then I tidied up the setRotation function by adding an Entity parameter. And I copied over some Render code to make it actually walk and turn its head.
  10. Next class to create is RenderBear which extends RenderLiving and contains all the detail about where to find the texture map. Looking at the wolf code, you can put clever stuff in here if you want the appearance of your animal to change depending on variables.
  11. You need to create a directory called textures at the same level as lang and set-up your own structure beneath there. Personally, I just have sub-directory called entity and put all of my files in there as they’re named one for each animal. Then you have to update the  texture location variable and it *should* work. I must admit this part took an awful lot of fiddling around with. Another handy hint is to refresh the folder structure each time you make a change. And you need to add the folder structure into your project as well. While we’re on the subject of text files, you can add a line to the en_US.lang file (or whatever language you’re in) to make your spawn egg have a proper name, like Bear instead of entity.Bear.name.
  12. The texture file from Techne should be quite self-explanatory. Each box, head, leg, etc. has a multicoloured zone that is a flattened cuboid. It is roughly marked F, B, R, L, T and B for Front, Right, Left, Bottom, Top and Back. And they’re colour coded. Load up your favourite graphics editor and make it beautiful!
  13. So, now we have an Entity class, a Render class and a Model class. Now we need to tell Minecraft what to do with it. In my main mod class, AnimalLoader I have three lines. In my code, I’ve wrapped these up in a function that I can call for each animal I want to add. In order, they add it to the registry of Entities, make it spawn in the world and give it an egg for creative mode.
    EntityRegistry.registerModEntity(entity, name, entID, this, 64, 1, true);
     EntityRegistry.addSpawn(entity, 200, 1, 8, creature);
     EntityList.addMapping(entity, name, entID, eggColour1, eggColour2);
  14. In theory you can use getUniqueID to get a unique ID but I can’t make it work. So I just started at 255 and count down. Also, in the addSpawn, you can either add a list of biomes or even use some fancy code with a loop and an array but again, that’s for the future. For the minute I’ve left it blank which means it spawns in all biomes.
  15. Nearly there now – one more file to modify. ClientProxy which should live in the proxy package. We need to add line to the registerRenderers() function:
    RenderingRegistry.registerEntityRenderingHandler(EntityBear.class, new RenderBear(new ModelBear(), 0.8F));

I think that’s about it. Once you’ve got all of those classes with no errors, it’s time to fire it up and see how it goes. As I said this is a fairly bare-bones mod for people who’re already writing mods. I do apologise for the state of the code – it’s all pasted in from the Minecraft source and changed. But I know there’s a bit more work to do to make it uniquely my bear and not just a bigger wolf!

Please comment and let me know if you want me to expand on anything.