Jump to content

[1.10.2] Spawning structures using Structure Blocks files


JimiIT92

Recommended Posts

On 6/9/2017 at 8:34 PM, myWitch said:

 Here I'll show the final code that definitly works for me:


 //spawn structure  
				if (!worldIn.isRemote) {
					WorldServer worldserver = (WorldServer) worldIn;
					MinecraftServer minecraftserver = worldIn.getMinecraftServer();
					TemplateManager templatemanager = worldserver.getStructureTemplateManager();
					ResourceLocation loc = new ResourceLocation(Reference.MOD_ID,"t1");
					Template template = templatemanager.getTemplate(minecraftserver, loc); 
					Utils.getLogger().info("=======0======="+template);
					if (template != null) {   
						worldIn.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);
						PlacementSettings placementsettings = (new PlacementSettings()).setMirror(Mirror.NONE)
								.setRotation(Rotation.NONE).setIgnoreEntities(false).setChunk((ChunkPos) null)
								.setReplacedBlock((Block) null).setIgnoreStructureBlock(false);
						
						Utils.getLogger().info("=======1======="+loc);
						
						 
						template.addBlocksToWorld(worldIn, pos, placementsettings);
						 
						Utils.getLogger().info("========2======="+pos);
					}
				}

 

Thank you (and to everyone else who helped) when I get back around to modding Ill implement it!

 

edit: It worked first time, excelent.

Edited by Acrogenous
it worked
  • Like 1
Link to comment
Share on other sites

On 6/7/2017 at 0:08 PM, JimiIT92 said:

This class is called from the WorldGenMinable class, in the generateOverworld method (so where you put the code to spawn ores) by doing this


if (world.getBiomeGenForCoords(new BlockPos(x, 60, z)).equals(Biomes.DESERT) && random.nextInt(70) == 1) {
            int randPosX = x + random.nextInt(35);
            int randPosZ = z + random.nextInt(35);
            int randPosY = 60 + random.nextInt(255 - 64);
            BlockPos position = new BlockPos(randPosX, randPosY, randPosZ);
            if (!(world.getBlockState(world.getTopSolidOrLiquidBlock(position)).getBlock().equals(Blocks.WATER)))
                new WorldGenObelisk(world.getTopSolidOrLiquidBlock(position), world);
        }

 

I have tried implementing this into a world generator class (changing all necessary things) I do not think I am doing it right however, what is your full implementation of the working class?

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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