Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new block types #35

Closed
qwindelzorf opened this issue Mar 30, 2012 · 5 comments
Closed

Adding new block types #35

qwindelzorf opened this issue Mar 30, 2012 · 5 comments

Comments

@qwindelzorf
Copy link

With the recent (apparent) demise of c10t, I have switched to pigmap. Now, I run a server running Buildcraft Industrial-Craft 2, and was previously using a custom c10t build that rendered the mod blocks correctly. Now that I have switched to pigmap, I would like them to render.

I'm willing to do the coding to make it all work. Rather than just wandering blindly through the codebase trying to figure out all the places that block rendering code lives, I figured I'd ask on here for a few pointers. Where should I start? I can pull the textures from the mod packages' assets folders, but it is not readily apparent where they should be inserted into the blocks-N.png . Also, the textures would have to undergo the needed transformations to make block images, so I would probably want to extend the system to allow for other texture sources than just terrain.png.

Am I biting off a huge task? Is this going to require a massive refactor of the whole codebase?

Thanks for any input.

@equalpants
Copy link
Owner

All the block image stuff is in blockimages.cpp and .h; it's pretty well isolated. The various functions that turn the terrain tiles into isometric block images could maybe use a little cleanup or a simpler interface, but you should be able to get the hang of it. Towards the top of blockimages.h there's a general explanation of how the isometric conversion is done.

There are basically three steps to adding more block images:

  1. define new IDs ("offsets") for them in blockimages.h
  2. BlockImages::setOffsets defines the mapping from the Minecraft block ID/block data to the block image offsets; add the new block types here
  3. BlockImages::construct is where block images are rendered from the terrain tiles; add the new block images here

Plain old blocks (cubes) are trivial to add, and some of the more common variants are also pretty easy--blocks that only go up to a certain height, items like saplings where two flat images of the terrain tile are drawn in a cross-shape, etc. Anything more complicated can be a bit of a pain. But keep in mind that you can always just skip step 3 and manually draw things directly in your blocks-B.png.

As far as extending to other sources than terrain.png, take a look at how fire.png and endportal.png are handled--it's pretty straightforward.

(I've actually been thinking of adding a plugin system where people would be able to define custom blocks and provide .pngs for them. But that's still probably a while off.)

@pantheis
Copy link

qwindelzorf, if you get a custom pigmap created that works with mod blocks, I would be very interested in seeing the source. I'm running a heavily modified server and would love for my Redpower, IC2, BC2, Forestry, Railcraft and EE blocks to render correctly.

@qwindelzorf
Copy link
Author

I have gotten support for IC2 and BC2 working. I'm not real happy with the rendering of BC Pipes/Frames, but to do it correctly would require me to code up all 64 different pipe configurations for each pipe type, and that is just crazy. Engines are kind of hokey right now as well, but they seem do draw from a number of textures, and were kind of a pain, so I just put in appropriately colored engine-like objects. Results can be seen here: http://qwindelzorf.com/minecraft_map/
To the right of the chunk 0 marker, there is a castle with solar panels on the roof, and a small quarry. Down from the marker, there is a building made from IC2 construction foam, and a large quarry. There are other BC and IC2 elements scattered about the map.
I would be more than willing to push this code back up, should it be valuable to the community.
Also, I have significant interest in re factoring the codebase to support more modularity. I did not go down that road this time, as I did not want to significantly alter the functionality of Pigmap.

@pantheis
Copy link

I would recommend forking pigmap, making the changes you want to make and then issuing pull requests. I would certainly be very interested in the ability to easily define custom blocks and/or plugin modules to support popular mods like RedPower, IC2, etc.

@qwindelzorf
Copy link
Author

I am forking this project to add more extensive block support. The fork can be found here: https://github.com/qwindelzorf/pigmap

Once the code is reasonably stable and usable, I will issue a pull request to try to roll it back into the main Pigmap codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants