Jump to content

[KindaSolved][1.19.4] how to use forge alredy existing tools to spawn structures from code


perromercenary00

Recommended Posts

hi well i dont have idea of have to do it 

i was googling and cannot figure it out by myself

 

i want this item to spawn a village whit an small wall adapting the shape to the terrain variables
step one already have made code to fix the land to slabs and remove trees 


 

 

 

step two) made the paths and the sewers 
i have made this two nbt structures 

/home/usuario/workspace/1.19.4/mercblk-mdk/run/saves/Mundo Juego/generated/minecraft/structures/tunel00.nbt

/home/usuario/workspace/1.19.4/mercblk-mdk/run/saves/Mundo Juego/generated/minecraft/structures/tunel01.nbt

 

 

the plan is to loop spawn  this two structures next each other until it forms a grass path whit a sewer tunnel below having in count the terrain heighs 
there must be a forge class already existing to spawn nbt structures in to the world

something like :

ForgeUtils.something.spawnStructureAt( "run/saves/Mundo Juego/generated/minecraft/structures/tunel00.nbt" , position, rotation );

but i dont know what it is and cannot figure it out form the structure block code

for step tree i need to spawn some houses 
step four is the wall itself 

########################################################

more exactly i need an example of how to spawn an structure in the world so i can use it whit a custome rod 

	// ########## ########## ########## ##########
@Override
public InteractionResultHolder<ItemStack> use(Level warudo, Player pe, InteractionHand hand) {


//System.out.println("public InteractionResultHolder<ItemStack> use ");

//if (!warudo.isClientSide)
{ // && !warudo.isClientSide

Target target = new Target(warudo, pe, 10);
Postate rp = target.get_postate();

if (rp != null ) {
lever_this_land ltl = new lever_this_land(warudo, rp.get_blockpos(), 32 );

High_Map hm = ltl.getHm();
hm.print();
Block_Map bm = ltl.getBm();
bm.setBlocks();

}
}
return InteractionResultHolder.pass(pe.getItemInHand(hand));
}
	


 

thanks for your attention 

 

 

 

 


 

 

 

 



 

 

 

 

 

 


 

 

 

 

Edited by perromercenary00
Link to comment
Share on other sites

currently trying this from a custome stick 
dont works but also dont return error 

	// ########## ########## ########## ##########
@Override
public InteractionResultHolder<ItemStack> use(Level warudo, Player pe, InteractionHand hand) {


System.out.println("public InteractionResultHolder<ItemStack> use " + warudo.isClientSide() );

if (!warudo.isClientSide) { // && !warudo.isClientSide

Target target = new Target(warudo, pe, 10);
Postate rp = target.get_postate();
String Name = "test2";
// /home/usuario/workspace/1.19.4/mercblk-mdk/src/main/resources/data/mercblk/structures/test2.nbt
//ResourceLocation structureName;


if (rp != null) {
BlockPos blockpos1 = rp.get_blockpos();//blockpos.offset(this.structurePos);

// /home/usuario/workspace/1.19.4/mercblk-mdk/src/main/resources/data/mercblk/structures/house00.nbt
StructureBlockEntity sbe = (StructureBlockEntity)newBlockEntity(blockpos1, Blocks.STRUCTURE_BLOCK.defaultBlockState() );
sbe.setStructureName("mercblk:tunel01");
sbe.setIgnoreEntities(false);
sbe.setStructurePos( blockpos1 );
sbe.loadStructure( ((ServerLevel)warudo) );

System.out.println( sbe.getStructurePos() );
System.out.println( sbe.getStructureName() );
	 
	}
	}
	}
	 
	

Link to comment
Share on other sites

just updathing 
kinda make it works but don't like the way it works 
if i manually create the tileentity and cast it into the world it don't works 
you have to create an structure block or you have to create an structure block 
then get the tile entity form it and set the values 

the other weird thing its you have to call two times 

sbe.loadStructure( ((ServerLevel)warudo) );
sbe.loadStructure( ((ServerLevel)warudo) );

other way it only highlights the area where the structure gonna appear 

for the other side looks like i can reuse the StructureBlockEntity manytimes 

 

now the other thing is how i get a list of the minecraft nbt structures included on minecraft ?? 

 

 

	// ########## ########## ########## ##########
@Override
public InteractionResultHolder<ItemStack> use(Level warudo, Player pe, InteractionHand hand) {
System.out.println("public InteractionResultHolder<ItemStack> use " + warudo.isClientSide() );

if (!warudo.isClientSide) { // && !warudo.isClientSide

Target target = new Target(warudo, pe, 10);
Postate rp = target.get_postate();
String Name = "tunel00";
// /home/usuario/workspace/1.19.4/mercblk-mdk/src/main/resources/data/mercblk/structures/test2.nbt
//ResourceLocation structureName;

if (rp != null) {
BlockPos blockpos1 = rp.get_blockpos();//blockpos.offset(this.structurePos);
rp.setBlockState( Blocks.STRUCTURE_BLOCK );
rp.setBlock(2);

//warudo.setBlockEntity( new StructureBlockEntity(blockpos1, Blocks.STRUCTURE_BLOCK.defaultBlockState() ) );
BlockEntity be = warudo.getBlockEntity(blockpos1);
StructureBlockEntity sbe = (StructureBlockEntity)be;

//"structures/" +
ResourceLocation structureName = new ResourceLocation(mercblk.MOD_ID, Name );
// /home/usuario/workspace/1.19.4/mercblk-mdk/src/main/resources/data/mercblk/structures/house00.nbt

sbe.setStructureName(structureName);
sbe.setIgnoreEntities(false);
sbe.setStructurePos( new BlockPos(0, -4, 0) );

sbe.loadStructure( ((ServerLevel)warudo) );

sbe.loadStructure( ((ServerLevel)warudo) );


System.out.println( sbe.getStructurePos() );
System.out.println( sbe.getStructureName() );

warudo.removeBlockEntity(blockpos1);

//structure_void
//structure_block

}
}
return InteractionResultHolder.pass(pe.getItemInHand(hand));
}
	

 

 

 

 

 

 

Link to comment
Share on other sites

  • perromercenary00 changed the title to [KindaSolved][1.19.4] how to use forge alredy existing tools to spawn structures from code

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.



×
×
  • Create New...

Important Information

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