Structure Builder API - 1.1
Works with current minecraft version - 1.2.5
This API is meant to help modders develop WorldGenerators at a faster pace with added support for placing complex blocks such as doors and beds. I originally created this API for myself in developing a mod I'm working on, but it grew so large that I thought I should share my work with others. This API helps take down that complexity of developing structures through code.
Features include:
Methods for generating walls, floors, and cuboids
Automatic placement of other half of door and bed blocks.
Direction support for placement of blocks
Help in placing blocks in the right direction - stairs, doors, beds
Help in placing blocks with specific types of textures - wool, wood, half-steps
Players
Just download and install the file below into your minecraft.jar. Be sure to delete the 'Meta-INF' folder. For other directions, just refer back to the thread in which you came from for installing the rest of the mod.
Modders
You are free to use this API for developing minecraft mods. All I ask is that you leave credit where credit is due. You may add this API to your mod package, but if you feel like it, you may redirect users of your mod to here to download the API.
I have also created an example of a mod you could make with this API. It is a block that when you right-click the block it instantly transforms into a nice wood house. The mod requires Modloader. The source code is included of course. (NOTE: Does not work with latest version of Minecraft. You may use the source code to compile the mod if you wish with the newest version, but don't publish.) Small Wood House Block Mod: DOWNLOAD
How to craft Wood House Block:
Here is the meat of the mod if you wish for a quick view of how the mod works with the API:
package net.minecraft.src;
import java.util.Random;
public class WorldGenSmallWoodHouse extends WorldGenerator {
@Override
public boolean generate(World world, Random random, int i, int j, int k) {
// Clear area
SBAPI.generateCuboid(world, i + 7, j, k - 6, i - 6, j + 7, k + 6, 0);
// Create wood floor base
SBAPI.generateFloor(world, j, i + 5, k - 5, i - 5, k + 5, Block.planks.blockID);
// Generate the four walls
SBAPI.generateWall(world, i + 5, j + 1, k - 5, i + 5, j + 4, k + 5, Block.planks.blockID);
SBAPI.generateWall(world, i - 5, j + 1, k + 5, i - 5, j + 4, k - 5, Block.planks.blockID);
SBAPI.generateWall(world, i - 5, j + 1, k - 5, i + 5, j + 4, k - 5, Block.planks.blockID);
SBAPI.generateWall(world, i + 5, j + 1, k + 5, i - 5, j + 4, k + 5, Block.planks.blockID);
// Generate roof
SBAPI.generateHollowFloor(world, j + 4, i + 6, k - 6, i - 6, k + 6, Block.wood.blockID);
SBAPI.generateHollowFloor(world, j + 5, i + 5, k - 5, i - 5, k + 5, Block.wood.blockID);
SBAPI.generateHollowFloor(world, j + 5, i + 4, k - 4, i - 4, k + 4, Block.wood.blockID);
SBAPI.generateHollowFloor(world, j + 6, i + 4, k - 4, i - 4, k + 4, Block.wood.blockID);
SBAPI.generateHollowFloor(world, j + 6, i + 3, k - 3, i - 3, k + 3, Block.wood.blockID);
SBAPI.generateHollowFloor(world, j + 7, i + 3, k - 3, i - 3, k + 3, Block.wood.blockID);
SBAPI.generateHollowFloor(world, j + 7, i + 2, k - 2, i - 2, k + 2, Block.wood.blockID);
SBAPI.generateFloor(world, j + 7, i + 1, k - 1, i -1, k + 1, Block.glass.blockID);
// Generate corners of house for dark wood detail
SBAPI.generateWall(world, i + 5, j, k - 5, i + 5, j + 4, k - 5, Block.wood.blockID);
SBAPI.generateWall(world, i + 5, j, k + 5, i + 5, j + 4, k + 5, Block.wood.blockID);
SBAPI.generateWall(world, i - 5, j, k + 5, i - 5, j + 4, k + 5, Block.wood.blockID);
SBAPI.generateWall(world, i - 5, j, k - 5, i - 5, j + 4, k - 5, Block.wood.blockID);
// Generate windows
SBAPI.generateWall(world, i + 5, j + 2, k - 3, i + 5, j + 3, k - 2, Block.thinGlass.blockID);
SBAPI.generateWall(world, i + 5, j + 2, k + 2, i + 5, j + 3, k + 3, Block.thinGlass.blockID);
SBAPI.generateWall(world, i - 2, j + 2, k - 5, i - 1, j + 3, k - 5, Block.thinGlass.blockID);
SBAPI.generateWall(world, i + 2, j + 2, k - 5, i + 1, j + 3, k - 5, Block.thinGlass.blockID);
SBAPI.generateWall(world, i - 2, j + 2, k + 5, i - 1, j + 3, k + 5, Block.thinGlass.blockID);
SBAPI.generateWall(world, i + 2, j + 2, k + 5, i + 1, j + 3, k + 5, Block.thinGlass.blockID);
SBAPI.generateWall(world, i - 5, j + 2, k + 2, i - 5, j + 3, k + 1, Block.thinGlass.blockID);
SBAPI.generateWall(world, i - 5, j + 2, k - 2, i - 5, j + 3, k - 1, Block.thinGlass.blockID);
// Add details
SBAPI.generateFloor(world, j, i + 6, k - 1, i + 6, k + 1, Block.planks.blockID);
SBAPI.placeBlock(world, i + 6, j, k - 2, Block.stairSingle.blockID, SBAPI.SlabWood);
SBAPI.placeBlock(world, i + 6, j, k + 2, Block.stairSingle.blockID, SBAPI.SlabWood);
SBAPI.generateFloor(world, j, i + 7, k - 2, i + 7, k + 2, Block.stairSingle.blockID, SBAPI.SlabWood);
SBAPI.placeBlock(world, i + 5, j + 1, k, 0);
SBAPI.placeBlock(world, i + 5, j + 2, k, 0);
SBAPI.placeBlock(world, i + 5, j + 1, k, Block.doorWood.blockID, SBAPI.DoorFaceEast);
SBAPI.placeBlock(world, i + 3, j + 1, k + 4, Block.bed.blockID, SBAPI.PlaceBedEastward);
SBAPI.placeBlock(world, i + 4, j + 1, k - 4, Block.stoneOvenIdle.blockID);
SBAPI.placeBlock(world, i + 3, j + 1, k - 4, Block.workbench.blockID);
SBAPI.placeBlock(world, i - 4, j + 1, k - 4, Block.chest.blockID);
SBAPI.placeBlock(world, i - 4, j + 1, k - 3, Block.chest.blockID);
SBAPI.placeBlock(world, i - 4, j + 1, k + 1, Block.cauldron.blockID);
SBAPI.placeBlock(world, i - 4, j + 1, k + 2, Block.bookShelf.blockID);
SBAPI.placeBlock(world, i - 4, j + 1, k + 3, Block.enchantmentTable.blockID);
SBAPI.placeBlock(world, i - 4, j + 1, k + 4, Block.bookShelf.blockID);
SBAPI.placeBlock(world, i - 4, j + 2, k + 2, Block.brewingStand.blockID);
SBAPI.placeBlock(world, i - 4, j + 2, k + 4, Block.brewingStand.blockID);
SBAPI.placeBlock(world, i + 4, j + 3, k + 1, Block.torchWood.blockID);
SBAPI.placeBlock(world, i + 4, j + 3, k - 1, Block.torchWood.blockID);
SBAPI.placeBlock(world, i, j + 3, k - 4, Block.torchWood.blockID);
SBAPI.placeBlock(world, i, j + 3, k + 4, Block.torchWood.blockID);
SBAPI.placeBlock(world, i - 4, j + 3, k, Block.torchWood.blockID);
return true;
}
}
I hope some people find a use for this API. I don't see many insta-structure mods nowadays and I hope to see a little fruit from this API. If you make a mod from this API. Post a link to it here and I will share with the rest of the world your work.
If you have any questions about the API, feel free to ask me.
Hi!
I will be using this API in my mod but I'm wondering how would I make it so that when you were placing block you were facin some direction and it would generate something in that direction.
There are many static metadata helpers within the API that should help in facing doors, beds, etc in a specific direction. If you want to generate them based off of what direction they are facing, I suggest looking at some of the block placement methods in the BlockBed and BlockDoor classes. That's where I figured out what metadata causes the blocks to face a specific direction. There should be some code in there too that shows how it figures out which direction a player is facing.
From what I understand in Structure generation, StructureComponent.addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox)) should interact with world only through StructureComponent's methods.
AWWWWWWWW YEAHHHHHHHHHHHHHHHHHHH! I can totally see my mods being boosted by a lot! I think the recipe for the example is a bit too expensive. I know it doesn't really matter though.
From what I understand in Structure generation, StructureComponent.addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox)) should interact with world only through StructureComponent's methods.
This is more attuned to generating structures through WorldGenerators. For developing StructureComponents like a village house or something for a Stronghold, that is quite a bit different.
AWWWWWWWW YEAHHHHHHHHHHHHHHHHHHH! I can totally see my mods being boosted by a lot! I think the recipe for the example is a bit too expensive. I know it doesn't really matter though.
I hope you find it useful. This API was made to reduce the number of lines of code needed to make structures like these. I couldn't really think of a recipe that would make the generation of the house equal to what it's worth so I just went with diamonds lol.
I know this is a bit dead but well done! :smile.gif:
I was just browsing around google for structure generators and I found exactly what I needed! Very well done too! Five diamonds for the great work and for the great example!
Made a slight update to it. Not sure if all metadata damage values are still correct, but I fixed a major bug that was caused by a small typo. Basic use of this is still good when it comes to generating cuboids and etc.
Works with current minecraft version - 1.2.5
This API is meant to help modders develop WorldGenerators at a faster pace with added support for placing complex blocks such as doors and beds. I originally created this API for myself in developing a mod I'm working on, but it grew so large that I thought I should share my work with others. This API helps take down that complexity of developing structures through code.
Features include:
Just download and install the file below into your minecraft.jar. Be sure to delete the 'Meta-INF' folder. For other directions, just refer back to the thread in which you came from for installing the rest of the mod.
Players Download this: DOWNLOAD
Modders
You are free to use this API for developing minecraft mods. All I ask is that you leave credit where credit is due. You may add this API to your mod package, but if you feel like it, you may redirect users of your mod to here to download the API.
API: DOWNLOAD
Javadocs: DOWNLOAD
I have also created an example of a mod you could make with this API. It is a block that when you right-click the block it instantly transforms into a nice wood house. The mod requires Modloader. The source code is included of course. (NOTE: Does not work with latest version of Minecraft. You may use the source code to compile the mod if you wish with the newest version, but don't publish.)
Small Wood House Block Mod: DOWNLOAD
How to craft Wood House Block:
Here is the meat of the mod if you wish for a quick view of how the mod works with the API:
I hope some people find a use for this API. I don't see many insta-structure mods nowadays and I hope to see a little fruit from this API. If you make a mod from this API. Post a link to it here and I will share with the rest of the world your work.
If you have any questions about the API, feel free to ask me.
You can create a WorldGenerator which can be used to randomly generate ruins and such, yes.
There are many static metadata helpers within the API that should help in facing doors, beds, etc in a specific direction. If you want to generate them based off of what direction they are facing, I suggest looking at some of the block placement methods in the BlockBed and BlockDoor classes. That's where I figured out what metadata causes the blocks to face a specific direction. There should be some code in there too that shows how it figures out which direction a player is facing.
I left an example mod showing how to use this, but I may write up something later to try and help some more.
From what I understand in Structure generation, StructureComponent.addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox)) should interact with world only through StructureComponent's methods.
This is more attuned to generating structures through WorldGenerators. For developing StructureComponents like a village house or something for a Stronghold, that is quite a bit different.
I hope you find it useful. This API was made to reduce the number of lines of code needed to make structures like these. I couldn't really think of a recipe that would make the generation of the house equal to what it's worth so I just went with diamonds lol.
I was just browsing around google for structure generators and I found exactly what I needed! Very well done too! Five diamonds for the great work and for the great example!