Jump to content

Recommended Posts

Posted

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 :-*

 

 

 

 

 

Posted

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.

width=700 height=200http://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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
    • Maybe you need to create file in assets/<modid>/items/<itemname>.json with content like this:   { "model": { "type": "minecraft:model", "model": "modname:item/itemname" } }  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.