Posted August 30, 201510 yr Hello, I made a tower.schematic file with MC Edit so now i want to generate this in my world so first of all i created a BlockObject class wich represent a single block in the schematic public class BlockObject { private BlockPos pos; private IBlockState state; public BlockObject(BlockPos pos, IBlockState state) { this.pos = pos; this.state = state; } public BlockPos getPos() { return pos; } public IBlockState getState() { return state; } public BlockPos getPositonWithOffset(int x, int y, int z){ return new BlockPos(x + pos.getX(), y + pos.getY(), z + pos.getZ()); } } next i created a .schematic reader that makes a array of block objects: private short width; private short length; private short heigth; private int size; private BlockObject[] blockObjects; public Schematic(String name) { try{ InputStream is = Schematic.class.getResourceAsStream("/assets/zaubermod/schematics/" + name); NBTTagCompound nbtdata = CompressedStreamTools.readCompressed(is); is.close(); width = nbtdata.getShort("Width"); length = nbtdata.getShort("Length"); heigth = nbtdata.getShort("Heigth"); size = width * length * heigth; blockObjects = new BlockObject[size]; byte[] blockids = nbtdata.getByteArray("Blocks"); byte[] metadata = nbtdata.getByteArray("Data"); int counter = 0; for(int i = 0; i < heigth; i++){ for(int j = 0; j < length; j++){ for(int k = 0; k < width; k++){ BlockPos pos = new BlockPos(k, i, j); IBlockState state = Block.getBlockById(blockids[counter]).getStateFromMeta(metadata[counter]); blockObjects[counter] = new BlockObject(pos, state); counter++; } } } }catch(Exception e){ e.printStackTrace(); } } public void generate(World world, int x, int y, int z){ for(BlockObject obj : blockObjects){ world.setBlockState(obj.getPositonWithOffset(x, y, z), obj.getState()); } } } So now i create a object of the schematic class in the main class: @Mod(modid = ZauberMod.MODID) public class ZauberMod { public static final String MODID = "zaubermod"; public static final Schematic TOWER_SCHEMATIC = new Schematic("tower.schematic"); @Instance public ZauberMod instance; @EventHandler public void preInit(FMLPreInitializationEvent event){ } @EventHandler public void Init(FMLInitializationEvent event){ GameRegistry.registerWorldGenerator(new SchematicGenereator(TOWER_SCHEMATIC), 0); } @EventHandler public void postInit(FMLPostInitializationEvent event){ } at the end i created a world generator that should create this structure every chunk: public class SchematicGenereator implements IWorldGenerator{ private Schematic schematic; public SchematicGenereator(Schematic schematic) { this.schematic = schematic; } @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { int x = chunkX * 16 + random.nextInt(16); int z = chunkZ * 16 + random.nextInt(16); int y = getWorldHeightAt(world, x, z); schematic.generate(world, x, y, z); } private static int getWorldHeightAt(World worldIn, int x, int z){ int heigth = 0; for(int i = 0; i < 255; i++){ if(worldIn.getBlockState(new BlockPos(x, i, z)).getBlock().isSolidFullCube()){ heigth = i; } } return heigth; } } now my problem: it just doesnt create i can fly every where in the world but the Structure doesnt create thank you for your answers
August 30, 201510 yr First off you misspelled "Height" in your schematic reader. Other than that I'm not in a position to answer, seeing as I don't know anything about worldgen, just thought I'd point that out as that might be related. Who are you? Why have you brought me here? And why are there so many PewDiePie fanboys surrounding meeeeeeeee....... *falls into pit and dies*. Also this. Check it out. http://i.imgur.com/J4rrGt6.png[/img]
August 30, 201510 yr Author Thank you very much now it works so a very silly Mistake but i'm from germany
August 30, 201510 yr No problem. Who are you? Why have you brought me here? And why are there so many PewDiePie fanboys surrounding meeeeeeeee....... *falls into pit and dies*. Also this. Check it out. http://i.imgur.com/J4rrGt6.png[/img]
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.