Jump to content

[1.19.2] capture some blocks get the data, convert that data to nbt, then save the nbt as a textfile.nbt


Recommended Posts

this one 

i want to remake structure's of mi mod but its complex to explain and don't speak naively English 

using code someones lend me for minecraft 1.16.5 i made a class that read the nbt files

this class read those nbt files and recreate the structures contained, also apply rotation based on the facing of the player 

and that works fine 



now i need to make the class to detect structures read those blocks an covert it to nbt data and save it to a text file 

i don't have access to the nbt rules so im guessing my way through and there is some knowledge holes  soo in need of help all the way here 

Spoiler

				
			// ########## ########## ########## ########## ########## ##########				
			public void addBlock_to_NBT(CompoundTag nbt, BlockPos pos, BlockState blkstate) {				
			//CompoundTag nbt = getBuildingNbt(structureName);				
			if (nbt == null) {				
			// load in blocks (list of blockPos and their palette index)				
			ListTag blocksNbt = nbt.getList("blocks", 10);				
			ListTag blockdata = new ListTag();				
			CompoundTag dx = new CompoundTag();				
			CompoundTag dy = new CompoundTag();				
			CompoundTag dz = new CompoundTag();				
			dx.putInt("x", pos.getX() );				
			dy.putInt("y", pos.getX() );				
			dz.putInt("z", pos.getX() );				
			ListTag NbtPosValues = new ListTag();				
			NbtPosValues.add(dx);				
			NbtPosValues.add(dy);				
			NbtPosValues.add(dz);				
			CompoundTag NbtPos = new CompoundTag();				
			NbtPos.put("pos", NbtPosValues);				
			blockdata.add(NbtPos);				
			

for why i interpetrate every block i wanna store must be represented as an nbt tag 
i call this blockdata 

and that block data must contain a tag named pos containing a list of int values for [x,y,z]

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

anyway i see the block states are stored and returned by something called pallete 

ArrayList<BlockState> palette = getBuildingPalette(nbt);//¿some class to convert nbt data to blockstates i suppose it respect order

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

i need to make the opposite having a list of blockstates convert then to a nbt pallete and add that to the nbt data 

 

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

also and later whit an nbt data i need to save it to a fisical txt.nbt file 

this code uses

CompoundTag nbt = getBuildingNbt(structureName); to read the fisical txt file 

so some where must be an equivalent function 

setBuildingNbt(structureName, CompoundTag nbt);

 

do you can point me this things 

or best a link to working code  saving nbt to fisical files ??

 

 

Spoiler

				
			package mercblk.util;				
			import java.util.ArrayList;				
			import java.util.Optional;				
			import net.minecraft.client.Minecraft;				
			import net.minecraft.core.BlockPos;				
			import net.minecraft.core.Direction;				
			import net.minecraft.nbt.CompoundTag;				
			import net.minecraft.nbt.ListTag;				
			import net.minecraft.nbt.NbtIo;				
			import net.minecraft.nbt.NbtUtils;				
			import net.minecraft.resources.ResourceLocation;				
			import net.minecraft.server.packs.resources.Resource;				
			import net.minecraft.server.packs.resources.ResourceManager;				
			import net.minecraft.world.level.Level;				
			import net.minecraft.world.level.LevelAccessor;				
			import net.minecraft.world.level.block.Rotation;				
			import net.minecraft.world.level.block.state.BlockState;				
			import net.minecraft.world.level.block.state.properties.BlockStateProperties;				
			public class NbtStructure {				
			public LevelAccessor warudo = null;				
			public LevelAccessor getWarudo() {				
			return warudo;				
			}				
			public void setWarudo(LevelAccessor warudo) {				
			this.warudo = warudo;				
			}				
			public String modname = "mercblk";				
			public String structureName = "";				
			public Rotation rot = Rotation.NONE;				
			private int ci_x = 0;				
			private int ci_y = 0;				
			private int ci_z = 0;				
			// ########## ########## ########## ########## ########## ##########				
			// BlockMap part				
			// ########## ########## ########## ########## ########## ##########				
			private BlockState blkstate = null;				
			private BlockPos blkpos = null;				
			private ResourceManager resourceManager = null;				
			private BlockMap bm = null;				
			// ########## ########## ########## ########## ########## ##########				
			// main constructor				
			// NBT part				
			// ########## ########## ########## ########## ########## ##########				
			public NbtStructure(Level warudo, String structureName) {				
			this.warudo = warudo;				
			this.getResourceManager();				
			this.structureName = structureName;				
			getBuildingBlocks(this.structureName);				
			}				
			public NbtStructure(Level warudo, String structureName, BlockPos cornerstone, Rotation rot) {				
			this.warudo = warudo;				
			this.getResourceManager();				
			this.ci_x = cornerstone.getX();				
			this.ci_y = cornerstone.getY();				
			this.ci_z = cornerstone.getZ();				
			this.rot = rot;				
			this.structureName = structureName;				
			getBuildingBlocks(this.structureName);				
			}				
			//########## ########## ########## ########## ########## ##########				
			//########## ########## ########## ########## ########## ##########				
			public NbtStructure(Level warudo, String structureName, BlockPos cornerstone, Direction facing) {				
			switch (facing) {				
			default:				
			case UP:				
			case DOWN:				
			case SOUTH:				
			this.rot = Rotation.NONE;				
			break;				
			case NORTH:				
			this.rot = Rotation.CLOCKWISE_180;				
			break;				
			case EAST:				
			this.rot = Rotation.COUNTERCLOCKWISE_90;				
			break;				
			case WEST:				
			this.rot = Rotation.CLOCKWISE_90;				
			break;				
			}				
			this.warudo = warudo;				
			this.bm = new BlockMap(warudo);				
			this.getResourceManager();				
			this.ci_x = cornerstone.getX();				
			this.ci_y = cornerstone.getY();				
			this.ci_z = cornerstone.getZ();				
			this.structureName = structureName;				
			getBuildingBlocks(this.structureName);				
			}				
			//########## ########## ########## ##########				
			public NbtStructure(BlockMap bm, String structureName, BlockPos cornerstone, Direction facing) {				
			switch (facing) {				
			default:				
			case UP:				
			case DOWN:				
			case SOUTH:				
			this.rot = Rotation.NONE;				
			break;				
			case NORTH:				
			this.rot = Rotation.CLOCKWISE_180;				
			break;				
			case EAST:				
			this.rot = Rotation.COUNTERCLOCKWISE_90;				
			break;				
			case WEST:				
			this.rot = Rotation.CLOCKWISE_90;				
			break;				
			}				
			this.bm = bm;				
			this.warudo = bm.level();				
			this.getResourceManager();				
			this.ci_x = cornerstone.getX();				
			this.ci_y = cornerstone.getY();				
			this.ci_z = cornerstone.getZ();				
			this.structureName = structureName;				
			getBuildingBlocks(this.structureName);				
			}				
			//########## ########## ########## ##########				
			public NbtStructure(BlockMap bm, String structureName) {				
			this.bm = bm;				
			this.warudo = bm.level();				
			this.getResourceManager();				
			this.structureName = structureName;				
			}				
			//########## ########## ########## ##########				
			public void spawnStructureAt(BlockPos cornerstone, Direction facing) {				
			switch (facing) {				
			default:				
			case UP:				
			case DOWN:				
			case SOUTH:				
			this.rot = Rotation.NONE;				
			break;				
			case NORTH:				
			this.rot = Rotation.CLOCKWISE_180;				
			break;				
			case EAST:				
			this.rot = Rotation.COUNTERCLOCKWISE_90;				
			break;				
			case WEST:				
			this.rot = Rotation.CLOCKWISE_90;				
			break;				
			}				
			this.ci_x = cornerstone.getX();				
			this.ci_y = cornerstone.getY();				
			this.ci_z = cornerstone.getZ();				
			getBuildingBlocks(this.structureName);				
			}				
			//########## ########## ########## ##########				
			public ResourceManager getResourceManager() {				
			if (resourceManager == null)				
			if (this.warudo.isClientSide())				
			this.resourceManager = Minecraft.getInstance().getResourceManager();				
			else				
			this.resourceManager = this.warudo.getServer().getResourceManager();				
			return resourceManager;				
			}				
			// ########## ########## ########## ########## ########## ##########				
			// load blocks from nbt.file to the blockmap				
			// ########## ########## ########## ########## ########## ##########				
			public void getBuildingBlocks(String structureName) {				
			CompoundTag nbt = getBuildingNbt(structureName);				
			if (nbt == null) {				
			System.out.println(" Structure not find [" + structureName + "]");				
			return;				
			}				
			// load in blocks (list of blockPos and their palette index)				
			ListTag blocksNbt = nbt.getList("blocks", 10);				
			ArrayList<BlockState> palette = getBuildingPalette(nbt);//¿some class to convert blockstate to nbt data				
			for (int i = 0; i < blocksNbt.size(); i++) {				
			CompoundTag blockdata = blocksNbt.getCompound(i);				
			ListTag blockPosNbt = blockdata.getList("pos", 3);				
			blkstate = palette.get(blockdata.getInt("state"));				
			blkpos = new BlockPos(blockPosNbt.getInt(0), blockPosNbt.getInt(1), blockPosNbt.getInt(2));				
			// rotate				
			blkstate = rotate_blockstate(blkstate, this.rot);				
			blkpos = rotate_blockpos(blkpos, this.rot);				
			// fit to corner stone block				
			blkpos = (new BlockPos((blkpos.getX() + this.ci_x), (blkpos.getY() + this.ci_y),				
			(blkpos.getZ() + this.ci_z)));				
			// save to the hash map				
			System.out.println("NBT add to BM " + blkpos );				
			this.bm.setBlockState(blkpos, blkstate);				
			// warudo.setBlock(blkpos, blkstate, 10);				
			}				
			}				
			// ########## ########## ########## ########## ########## ##########				
			public void addBlock_to_NBT(CompoundTag nbt, BlockPos pos, BlockState blkstate) {				
			//CompoundTag nbt = getBuildingNbt(structureName);				
			if (nbt == null) {				
			// load in blocks (list of blockPos and their palette index)				
			ListTag blocksNbt = nbt.getList("blocks", 10);				
			ListTag blockdata = new ListTag();				
			CompoundTag dx = new CompoundTag();				
			CompoundTag dy = new CompoundTag();				
			CompoundTag dz = new CompoundTag();				
			dx.putInt("x", pos.getX() );				
			dy.putInt("y", pos.getX() );				
			dz.putInt("z", pos.getX() );				
			ListTag NbtPosValues = new ListTag();				
			NbtPosValues.add(dx);				
			NbtPosValues.add(dy);				
			NbtPosValues.add(dz);				
			CompoundTag NbtPos = new CompoundTag();				
			NbtPos.put("pos", NbtPosValues);				
			blockdata.add(NbtPos);				
			//blkstate = palette.get(blockNbt.getInt("state"));				
			/*				
			blockNbt.addTag(0, pos.getX());				
			itemstacktag = new CompoundTag();				
			blockdata.put("pos", 3);				
			ListTag blockPosNbt = blockNbt.getList("pos", 3);				
			blkstate = palette.get(blockNbt.getInt("state"));				
			blkpos = new BlockPos(blockPosNbt.getInt(0), blockPosNbt.getInt(1), blockPosNbt.getInt(2));				
			ArrayList<BlockState> palette = getBuildingPalette(nbt);//¿some class to convert blockstate to nbt data				
			for (int i = 0; i < blocksNbt.size(); i++) {				
			CompoundTag blockNbt = blocksNbt.getCompound(i);				
			ListTag blockPosNbt = blockNbt.getList("pos", 3);				
			blkstate = palette.get(blockNbt.getInt("state"));				
			blkpos = new BlockPos(blockPosNbt.getInt(0), blockPosNbt.getInt(1), blockPosNbt.getInt(2));				
			// rotate				
			blkstate = rotate_blockstate(blkstate, this.rot);				
			blkpos = rotate_blockpos(blkpos, this.rot);				
			// fit to corner stone block				
			blkpos = (new BlockPos((blkpos.getX() + this.ci_x), (blkpos.getY() + this.ci_y),				
			(blkpos.getZ() + this.ci_z)));				
			// save to the hash map				
			System.out.println("NBT add to BM " + blkpos );				
			this.bm.setBlockState(blkpos, blkstate);				
			// warudo.setBlock(blkpos, blkstate, 10);				
			}				
			*/				
			}				
			}				
			// ########## ########## ########## ########## ########## ##########				
			// ########## ########## ########## ########## ########## ##########				
			public CompoundTag getBuildingNbt(String structureName) {				
			try {				
			ResourceLocation rl = new ResourceLocation(this.modname, "structures/" + structureName + ".nbt");				
			Optional<Resource> rs = this.resourceManager.getResource(rl);				
			return NbtIo.readCompressed(rs.get().open());				
			} catch (Exception e) {				
			// System.out.println(e);				
			return null;				
			}				
			}				
			// ########## ########## ########## ########## ########## ##########				
			public ArrayList<BlockState> getBuildingPalette(CompoundTag nbt) {				
			ArrayList<BlockState> palette = new ArrayList<>();				
			// load in palette (list of unique blockstates)				
			ListTag paletteNbt = nbt.getList("palette", 10);				
			for (int i = 0; i < paletteNbt.size(); i++)				
			palette.add(NbtUtils.readBlockState(paletteNbt.getCompound(i)));				
			return palette;				
			}				
			// ########## ########## ########## ##########				
			public BlockState rotate_blockstate(BlockState blkstate, Rotation rot) {				
			// Direccion				
			Direction facing = null;				
			if (blkstate.hasProperty(BlockStateProperties.FACING)) {				
			facing = blkstate.getValue(BlockStateProperties.FACING);				
			}				
			if (blkstate.hasProperty(BlockStateProperties.HORIZONTAL_FACING)) {				
			facing = blkstate.getValue(BlockStateProperties.HORIZONTAL_FACING);				
			}				
			Direction.Axis axix = null;				
			if (blkstate.hasProperty(BlockStateProperties.AXIS)) {				
			axix = blkstate.getValue(BlockStateProperties.AXIS);				
			}				
			if (blkstate.hasProperty(BlockStateProperties.HORIZONTAL_AXIS)) {				
			axix = blkstate.getValue(BlockStateProperties.HORIZONTAL_AXIS);				
			}				
			if (facing != null && facing != Direction.UP && facing != Direction.DOWN) {				
			switch (rot) {				
			default:				
			// du nothing				
			break;				
			case CLOCKWISE_180:				
			facing = facing.getOpposite();				
			break;				
			case CLOCKWISE_90:				
			facing = facing.getClockWise();				
			break;				
			case COUNTERCLOCKWISE_90:				
			facing = facing.getCounterClockWise();				
			break;				
			}				
			if (blkstate.hasProperty(BlockStateProperties.FACING)) {				
			blkstate = blkstate.setValue(BlockStateProperties.FACING, facing);				
			}				
			if (blkstate.hasProperty(BlockStateProperties.HORIZONTAL_FACING)) {				
			blkstate = blkstate.setValue(BlockStateProperties.HORIZONTAL_FACING, facing);				
			}				
			}				
			// axis				
			// Direction.Axis.valueOf(value.toUpperCase())				
			if (axix != null) {				
			switch (axix) {				
			default:				
			case Y:				
			// du nuthing				
			break;				
			case X:				
			axix = Direction.Axis.Z;				
			break;				
			case Z:				
			axix = Direction.Axis.X;				
			break;				
			}				
			if (blkstate.hasProperty(BlockStateProperties.AXIS)) {				
			blkstate = blkstate.setValue(BlockStateProperties.AXIS, axix);				
			}				
			if (blkstate.hasProperty(BlockStateProperties.HORIZONTAL_AXIS)) {				
			blkstate = blkstate.setValue(BlockStateProperties.HORIZONTAL_AXIS, axix);				
			}				
			}				
			// this thing dont works on mod made blocks				
			if (axix == null && facing == null) {				
			blkstate.rotate(rot);				
			}				
			return blkstate;				
			}				
			// ########## ########## ########## ##########				
			public BlockPos rotate_blockpos(BlockPos cursor, Rotation rot) {				
			switch (rot) {				
			default:				
			// case NORTH:				
			// du nuthing				
			break;				
			case CLOCKWISE_90:				
			cursor = new BlockPos(cursor.getZ() * -1, cursor.getY(), cursor.getX());				
			break;				
			case CLOCKWISE_180:				
			cursor = new BlockPos(cursor.getX() * -1, cursor.getY(), cursor.getZ() * -1);				
			break;				
			case COUNTERCLOCKWISE_90:				
			cursor = new BlockPos(cursor.getZ(), cursor.getY(), cursor.getX() * -1);				
			break;				
			}				
			return cursor;				
			}				
			// ########## ########## ########## ########## ########## ##########				
			// ########## ########## ########## ########## ########## ##########				
			//				
			public static String get_blkfullname(BlockState blkstate) {				
			if (blkstate == null) {				
			return "NULL";				
			}				
			String nnn = "" + blkstate.getBlock().getName().getString().toLowerCase();				
			return fix_blkfullname(nnn);				
			}				
			// ########## ########## ########## ########## ########## ##########				
			//				
			public static String fix_blkfullname(String blkfullname) {				
			if (blkfullname.contains(".")) {				
			String[] split1 = blkfullname.split("\\."); // "\\."				
			if (split1.length > 1) {				
			blkfullname = split1[split1.length - 1].replaceAll("_", " ");				
			}				
			}				
			return blkfullname.toLowerCase();				
			}				
			// ########## ########## ########## ##########				
			// ########## ########## ########## ##########				
			public static BlockPos chunk_northwest_corner(Level warudo, BlockPos pos) {				
			BlockPos min = null;				
			int subx = 0;				
			int subz = 0;				
			int abs = 0;				
			int factox = 0;				
			int factoz = 0;				
			// si el valor es negativo				
			if (pos.getX() < 0) {				
			abs = Math.abs(pos.getX());				
			factox = (abs / 16);				
			factox = ((abs % 16) > 0) ? factox + 1 : factox;				
			subx = -16 * factox;				
			} else {				
			subx = pos.getX() - (pos.getX() % 16);				
			}				
			// si el valor es negativo				
			if (pos.getZ() < 0) {				
			abs = Math.abs(pos.getZ());				
			factoz = (abs / 16);				
			factoz = ((abs % 16) > 0) ? factoz + 1 : factoz;				
			subz = -16 * factoz;				
			} else {				
			subz = pos.getZ() - (pos.getZ() % 16);				
			}				
			min = new BlockPos(subx, pos.getY(), subz);				
			return min;				
			}				
			// ########## ########## ########## ##########				
			public void setBlocks(){				
			bm.find_liquids();				
			bm.setBlocks();				
			}				
			// ########## ########## ########## ########## ########## ##########				
			public BlockMap getBm() {				
			return bm;				
			}				
			public void setBm(BlockMap bm) {				
			this.bm = bm;				
			}				
			// ########## ########## ########## ########## ########## ##########				
			// ########## ########## ########## ########## ########## ##########				
			// ########## ########## ########## ########## ########## ##########				
			// ########## ########## ########## ########## ########## ##########				
			}				
			 				
			

 

 

 

 


 

 

 

 

 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

Link to comment
Share on other sites

This is why you shouldn't just copy code/paste and instead try to understand what you are doing.

The code for this can be found in:

net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager
net.minecraft.nbt.NbtIo
net.minecraft.nbt.NbtUtils

You are already using some of these for reading the data. The writes are in the same place.

BTW: What you are trying to do sounds similar to what the JigsawBlock does?

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Posted (edited)

yap kinda like jigsaw
but never find a compressive guide just the one spawning the tower 
also i have an obsession for levering the terrain and set random structure's based in the resulting highs of the levered terrain and at the end i want those random structure's to surrounding whit a fence or a wall and also sewers 

an there is this thing where house variants can have or not attics and basements i do that just by swapping random assigned parts up an down 

2023-03-19-07-12-29.png

 

 

still a good guide of jiwsaw would come in handly 

 

Edited by perromercenary00
Link to comment
Share on other sites

i quite advance here i successfully made the function to read the blocks sort them into a map and use that  map to create the nbt tags and find the method to convert that to a fisical text file 

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

Spoiler

				
			// ########## ########## ########## ########## ########## ##########				
			public void setBuildingNbt(String structureName, CompoundTag nbt) {				
			try {				
			ResourceLocation rl = new ResourceLocation(this.modname, "structures/" + structureName + ".nbt");				
			Optional<Resource> rs = this.resourceManager.getResource(rl);				
			File file = new File( rl.getNamespace() + "/structures/" + structureName + ".nbt" ); //				
			if (file.exists()) {				
			file.delete();				
			}				
			file.createNewFile();				
			System.out.println("\n########## absolute pad >" + file.getAbsolutePath() + "<");				
			NbtIo.writeCompressed(nbt, file );				
			} catch (Exception e) {				
			System.out.println(e);				
			}				
			}				
			

this works it creates the file in 

file:///home/usuario/workspace/block/forge-1.19.2-43.2.1-mdk/run/mercblk/structures/xxxxxxxxxx.nbt

 

but i want it to drop the file into mi mod structure folder 

file:///home/usuario/workspace/block/forge-1.19.2-43.2.1-mdk/src/main/resources/data/mercblk/structures/

 

or at least drop it into the same folder the minecrafts vainilla   structure_block saves it files that would be the saves folder for the current world 

file:///home/usuario/workspace/block/forge-1.19.2-43.2.1-mdk/run/saves/New_World/generated/minecraft/structures/

 

this thing here 

	File file = new File( rl.getNamespace() + "/structures/" + structureName + ".nbt" ); //
	

how do i made to get the route to mi mod data folder ? 
or to the current world saves folder 

 

the full NbtStructure class

Spoiler

				
			package mercblk.util;				
			import java.io.File;
		import java.util.ArrayList;
		import java.util.HashMap;
		import java.util.HashSet;
		import java.util.Iterator;
		import java.util.Map;
		import java.util.Optional;
		import java.util.Set;				
			import net.minecraft.client.Minecraft;
		import net.minecraft.core.BlockPos;
		import net.minecraft.core.Direction;
		import net.minecraft.nbt.CompoundTag;
		import net.minecraft.nbt.ListTag;
		import net.minecraft.nbt.NbtIo;
		import net.minecraft.nbt.NbtUtils;
		import net.minecraft.resources.ResourceLocation;
		import net.minecraft.server.packs.resources.Resource;
		import net.minecraft.server.packs.resources.ResourceManager;
		import net.minecraft.world.level.Level;
		import net.minecraft.world.level.LevelAccessor;
		import net.minecraft.world.level.block.Block;
		import net.minecraft.world.level.block.Blocks;
		import net.minecraft.world.level.block.Rotation;
		import net.minecraft.world.level.block.state.BlockState;
		import net.minecraft.world.level.block.state.properties.BlockStateProperties;
		import net.minecraft.world.level.block.state.properties.Property;				
			public class NbtStructure {				
			    public Level warudo = null;				
			    public Level getWarudo() {
		        return warudo;
		    }				
			    public void setWarudo(Level warudo) {
		        this.warudo = warudo;
		    }				
			    public String modname = "mercblk";
		    public String structureName = "";
		    public Rotation rot = Rotation.NONE;				
			    private int ci_x = 0;
		    private int ci_y = 0;
		    private int ci_z = 0;
		    
		    //########## ########## ########## ##########    
		    private Map<BlockState, ArrayList<BlockPos>> mapa = new HashMap<BlockState, ArrayList<BlockPos>>();
		    
		    //########## ##########
		    public void  add_to_mapa(Postate pstate) {
		        
		        BlockState blkstate = pstate.getBlockState();
		        BlockPos position = pstate.get_blockpos();
		        ArrayList<BlockPos> sublista;
		        
		        if( this.mapa.containsKey(blkstate) ) {
		            sublista = mapa.get(blkstate);
		            
		            if(!sublista.contains(position)) {
		                sublista.add( position );    
		            }
		        }
		        else {
		            sublista = new ArrayList<BlockPos>();
		            sublista.add(position);
		            mapa.put(blkstate, sublista);
		        }
		    }    
		        
		    //########## ##########
		    public void  print_mapa() {
		        
		        Iterator<BlockState> mapi = mapa.keySet().iterator(); // keyset is a method
		        BlockState blkstate;
		        BlockPos position;
		        ArrayList<BlockPos> sublista;				
			        while (mapi.hasNext()) {
		            blkstate = mapi.next();
		            sublista = mapa.get(blkstate);
		            
		            System.out.println("\n----- - -----");
		            System.out.println( blkstate.getBlock().getName().getString() );
		            
		            String propiedades = "";
		            for (Property<?> porp : blkstate.getProperties()) {
		                System.out.println(porp.getName() + " -> " + blkstate.getValue(porp));
		                //propiedades += String.format(",\"%1$s\":\"%2$s\"", porp.getName(), blkstate.getValue(porp));
		            }
		            
		            for( BlockPos cursor : sublista ) {
		                System.out.println( "[" + cursor.getX() + ", " + cursor.getY() + ", " + cursor.getZ() + "]");
		            }
		            System.out.println(" ");
		        }
		        
		    }
		    
		    				
			
		    // ########## ########## ########## ########## ########## ##########
		    // BlockMap part
		    // ########## ########## ########## ########## ########## ##########				
			    private BlockState blkstate = null;
		    private BlockPos blkpos = null;
		    private ResourceManager resourceManager = null;
		    private BlockMap bm = null;				
			    // ########## ########## ########## ########## ########## ##########
		    // main constructor
		    // NBT part
		    // ########## ########## ########## ########## ########## ##########
		    
		    public NbtStructure(Level warudo) {
		        this.warudo = warudo;
		        this.getResourceManager();
		        
		    }
		    
		    
		    public NbtStructure(Level warudo, String structureName) {
		        this.warudo = warudo;
		        this.getResourceManager();				
			        this.structureName = structureName;
		        getBuildingBlocks(this.structureName);
		    }				
			    public NbtStructure(Level warudo, String structureName, BlockPos cornerstone, Rotation rot) {				
			        this.warudo = warudo;
		        this.getResourceManager();				
			        this.ci_x = cornerstone.getX();
		        this.ci_y = cornerstone.getY();
		        this.ci_z = cornerstone.getZ();				
			        this.rot = rot;				
			        this.structureName = structureName;
		        getBuildingBlocks(this.structureName);
		        
		    }				
			    //########## ########## ########## ########## ########## ##########
		    //########## ########## ########## ########## ########## ##########     
		    public NbtStructure(Level warudo, String structureName, BlockPos cornerstone, Direction facing) {				
			        switch (facing) {
		        default:
		        case UP:
		        case DOWN:
		        case SOUTH:
		            this.rot = Rotation.NONE;
		            break;
		        case NORTH:
		            this.rot = Rotation.CLOCKWISE_180;
		            break;
		        case EAST:
		            this.rot = Rotation.COUNTERCLOCKWISE_90;
		            break;
		        case WEST:
		            this.rot = Rotation.CLOCKWISE_90;
		            break;
		        }				
			        this.warudo = warudo;
		        this.bm = new BlockMap(warudo);
		        this.getResourceManager();				
			        this.ci_x = cornerstone.getX();
		        this.ci_y = cornerstone.getY();
		        this.ci_z = cornerstone.getZ();				
			        this.structureName = structureName;
		        getBuildingBlocks(this.structureName);
		    }				
			    //########## ########## ########## ##########    
		    public NbtStructure(BlockMap bm, String structureName, BlockPos cornerstone, Direction facing) {
		                
		        switch (facing) {
		        default:
		        case UP:
		        case DOWN:
		        case SOUTH:
		            this.rot = Rotation.NONE;
		            break;
		        case NORTH:
		            this.rot = Rotation.CLOCKWISE_180;
		            break;
		        case EAST:
		            this.rot = Rotation.COUNTERCLOCKWISE_90;
		            break;
		        case WEST:
		            this.rot = Rotation.CLOCKWISE_90;
		            break;
		        }				
			        this.bm = bm;        
		        this.warudo = bm.level();
		        this.getResourceManager();				
			        this.ci_x = cornerstone.getX();
		        this.ci_y = cornerstone.getY();
		        this.ci_z = cornerstone.getZ();				
			        this.structureName = structureName;
		        getBuildingBlocks(this.structureName);
		    }
		    
		    //########## ########## ########## ##########    
		    public NbtStructure(BlockMap bm, String structureName) {
		        this.bm = bm;        
		        this.warudo = bm.level();
		        this.getResourceManager();
		        this.structureName = structureName;
		    }    
		    
		    //########## ########## ########## ##########    
		    public void spawnStructureAt(BlockPos cornerstone, Direction facing) {
		        
		        switch (facing) {
		        default:
		        case UP:
		        case DOWN:
		        case SOUTH:
		            this.rot = Rotation.NONE;
		            break;
		        case NORTH:
		            this.rot = Rotation.CLOCKWISE_180;
		            break;
		        case EAST:
		            this.rot = Rotation.COUNTERCLOCKWISE_90;
		            break;
		        case WEST:
		            this.rot = Rotation.CLOCKWISE_90;
		            break;
		        }				
			        this.ci_x = cornerstone.getX();
		        this.ci_y = cornerstone.getY();
		        this.ci_z = cornerstone.getZ();				
			        getBuildingBlocks(this.structureName);
		    }
		    
		    //########## ########## ########## ##########
		    public ResourceManager getResourceManager() {				
			        if (resourceManager == null)
		            if (this.warudo.isClientSide())
		                this.resourceManager = Minecraft.getInstance().getResourceManager();
		            else
		                this.resourceManager = this.warudo.getServer().getResourceManager();				
			        return resourceManager;
		    }				
			    // ########## ########## ########## ########## ########## ##########
		    // load blocks from nbt.file to the blockmap
		    // ########## ########## ########## ########## ########## ##########
		    public void getBuildingBlocks(String structureName) {
		        CompoundTag nbt = getBuildingNbt(structureName);				
			        if (nbt == null) {
		            System.out.println(" Structure not find [" + structureName + "]");
		            return;
		        }
		        
		        System.out.println( NbtUtils.prettyPrint(nbt) );
		        				
			        // load in blocks (list of blockPos and their palette index)
		        ListTag blocksNbt = nbt.getList("blocks", 10);				
			        ArrayList<BlockState> palette = getBuildingPalette(nbt);//¿some class to convert blockstate to nbt data 				
			        for (int i = 0; i < blocksNbt.size(); i++) {
		            
		            
		            CompoundTag blockdata = blocksNbt.getCompound(i);//i from  "blocks" tag
		            ListTag blockPosNbt = blockdata.getList("pos", 3);//blockdata contains pos 				
			            blkstate = palette.get(blockdata.getInt("state"));//blockdata contains state and thats the index of the block 
		            
		            
		            
		            blkpos = new BlockPos(blockPosNbt.getInt(0), blockPosNbt.getInt(1), blockPosNbt.getInt(2));				
			            // rotate
		            blkstate = rotate_blockstate(blkstate, this.rot);
		            blkpos = rotate_blockpos(blkpos, this.rot);				
			            // fit to corner stone block
		            blkpos = (new BlockPos((blkpos.getX() + this.ci_x), (blkpos.getY() + this.ci_y),
		                    (blkpos.getZ() + this.ci_z)));				
			            // save to the hash map
		            //System.out.println("NBT add to BM "  + blkpos );
		            this.bm.setBlockState(blkpos, blkstate);
		            // warudo.setBlock(blkpos, blkstate, 10);
		        }
		    }				
			    // ########## ########## ########## ########## ########## ##########
		    public void capture_blocks(BlockPos pos) {				
			        //CompoundTag nbt = getBuildingNbt(structureName);
		            Postate startpoint = new Postate(this.warudo , pos);
		            //check all non air blocks in direct contact to this
		            
		            mapa.clear();
		            ArrayList<Postate> lista = check_surroundings(startpoint);
		            
		            for(Postate pstate : lista) {
		            add_to_mapa(pstate);
		            }				
			            //##########
		            //print_mapa();
		            
		            
		            
		            //xxxxx
		            CompoundTag nbt = new CompoundTag();
		            
		            //ListTag blocksNbt = nbt.getList("blocks", 10);
		            ListTag blocksNbt;
		            if( nbt.contains("blocks") ) {
		                blocksNbt = nbt.getList("blocks", 10);
		            }else {
		                blocksNbt = new ListTag();
		            }    
		            
		            
		            //ListTag paletteNbt = nbt.getList("palette", 10);
		            ListTag paletteNbt;
		            if( nbt.contains("palette") ) {
		                paletteNbt = nbt.getList("palette", 10);
		            }else {
		                paletteNbt = new ListTag();
		            }            
		            
		                        
		            
		            Iterator<BlockState> mapi = mapa.keySet().iterator(); // keyset is a method
		            BlockState blkstate;
		            BlockPos position;
		            ArrayList<BlockPos> sublista;
		            
		            CompoundTag nbtstate;// = NbtUtils.writeBlockState(blkstate);
		            CompoundTag nbtpos;// = NbtUtils.writeBlockPos(pos);
		            CompoundTag stateindex;//
		            
		            CompoundTag blockdata;//
		            
		            int state = 0;
		            while (mapi.hasNext()) {
		                blkstate = mapi.next();
		                sublista = mapa.get(blkstate);
		                
		                nbtstate = NbtUtils.writeBlockState(blkstate);
		                paletteNbt.add(nbtstate);
		                
		                
		                
		                for( BlockPos cursor : sublista ) {
		                    blockdata = new CompoundTag();
		                    
		                    blockdata.putInt("state", state);
		                                        
		                    nbtpos = NbtUtils.writeBlockPos(cursor);
		                    
		                    blockdata.put("pos", nbtpos);
		                    
		                    
		                    //int [] p = {cursor.getX(),cursor.getY(),cursor.getZ()}  ;
		                    
		                    //blockdata.putIntArray("pos", p );
		                    
		                    blocksNbt.add(blockdata);				
			                }
		                
		                state ++;
		            }
		            
		            nbt.put("blocks", blocksNbt);
		            nbt.put("palette", paletteNbt);
		            
		            
		            System.out.println( NbtUtils.prettyPrint(nbt) );
		            
		            
		            setBuildingNbt("xxxxxxxxxx", nbt);
		            
		            
		            
		            
		            
		/*
		        // load in blocks (list of blockPos and their palette index)
		        
		        //ListTag blocksNbt = nbt.getList("blocks", 10);
		        ListTag blocksNbt;
		        if( nbt.contains("blocks") ) {
		            blocksNbt = nbt.getList("blocks", 10);
		        }else {
		            blocksNbt = new ListTag();
		        }    
		        
		        
		        //ListTag paletteNbt = nbt.getList("palette", 10);
		        ListTag paletteNbt;
		        if( nbt.contains("palette") ) {
		            paletteNbt = nbt.getList("palette", 10);
		        }else {
		            paletteNbt = new ListTag();
		        }    
		        
		        
		        CompoundTag nbtstate = NbtUtils.writeBlockState(blkstate);
		        CompoundTag nbtpos = NbtUtils.writeBlockPos(pos);
		        
		        CompoundTag nbtstateindex = new CompoundTag();
		        nbtstateindex.putInt("state", 0);
		        
		        */
		        
		        /*				
			        ListTag blockdata = new ListTag();
		        
		        CompoundTag dx = new CompoundTag();
		        CompoundTag dy = new CompoundTag();
		        CompoundTag dz = new CompoundTag();
		        
		        dx.putInt("x", pos.getX() );
		        dy.putInt("y", pos.getX() );
		        dz.putInt("z", pos.getX() );
		        
		        ListTag NbtPosValues = new ListTag();
		        
		        NbtPosValues.add(dx);
		        NbtPosValues.add(dy);
		        NbtPosValues.add(dz);
		        
		        CompoundTag NbtPos = new CompoundTag();
		        NbtPos.put("pos", NbtPosValues);
		        
		        blockdata.add(NbtPos);
		        
		        */
		        
		                //.readBlockState(
		        
		        
		        //blkstate = palette.get(blockNbt.getInt("state"));
		        
		        
		        
		        
		        /*
		        blockNbt.addTag(0, pos.getX());
		        
		        
		        
		        itemstacktag = new CompoundTag();
		        
		        blockdata.put("pos", 3);
		        
		        
		        
		        ListTag blockPosNbt = blockNbt.getList("pos", 3);				
			        blkstate = palette.get(blockNbt.getInt("state"));
		        blkpos = new BlockPos(blockPosNbt.getInt(0), blockPosNbt.getInt(1), blockPosNbt.getInt(2));				
			        
		        
		        
		        				
			        ArrayList<BlockState> palette = getBuildingPalette(nbt);//¿some class to convert blockstate to nbt data 				
			        for (int i = 0; i < blocksNbt.size(); i++) {
		            
		            
		            CompoundTag blockNbt = blocksNbt.getCompound(i);
		            ListTag blockPosNbt = blockNbt.getList("pos", 3);				
			            blkstate = palette.get(blockNbt.getInt("state"));
		            blkpos = new BlockPos(blockPosNbt.getInt(0), blockPosNbt.getInt(1), blockPosNbt.getInt(2));				
			            // rotate
		            blkstate = rotate_blockstate(blkstate, this.rot);
		            blkpos = rotate_blockpos(blkpos, this.rot);				
			            // fit to corner stone block
		            blkpos = (new BlockPos((blkpos.getX() + this.ci_x), (blkpos.getY() + this.ci_y),
		                    (blkpos.getZ() + this.ci_z)));				
			            // save to the hash map
		            System.out.println("NBT add to BM "  + blkpos );
		            this.bm.setBlockState(blkpos, blkstate);
		            // warudo.setBlock(blkpos, blkstate, 10);
		        }
		        */
		        
		    }				
			    
		    // ########## ########## ########## ##########
		    public ArrayList<Postate> check_surroundings(Postate startpoint) {
		        int maxblocks = 8192;//like two chunks 				
			        ArrayList<Postate> lista = new ArrayList<Postate>();				
			        Set<BlockPos> sub_pos_list_A = new HashSet<BlockPos>();
		        Set<BlockPos> sub_pos_list_B = new HashSet<BlockPos>();
		        Set<BlockPos> cheked_blocks = new HashSet<BlockPos>();				
			        if (check_if_valid(this.warudo, startpoint.get_blockpos()) != null) {
		            lista.add(startpoint);
		        }
		        cheked_blocks.add(startpoint.get_blockpos());
		        sub_pos_list_A.add(startpoint.get_blockpos());
		        // sub_pos_list_B.add(center.pos);				
			        while (sub_pos_list_A.size() > 0) {
		            // System.out.println(String.format("revizar %1$s blockes",
		            // sub_pos_list_A.size()));				
			            for (BlockPos cursor : sub_pos_list_A) {
		                sub_pos_list_B.addAll(check_surroundings_pos_6(cursor));
		            }				
			            sub_pos_list_A.clear();
		            for (BlockPos cursor : sub_pos_list_B) {				
			                if (cheked_blocks.add(cursor)) {// si ya fue revizado antes ignorelo
		                    Postate sub_postate = check_if_valid(warudo, cursor);
		                    if (sub_postate != null) {
		                        lista.add(sub_postate);
		                        sub_pos_list_A.add(cursor);
		                    }
		                }
		            }
		            sub_pos_list_B.clear();				
			            if (lista.size() > maxblocks) {
		                break;
		            }				
			        }				
			        return lista;
		    }				
			    // ########## ########## ########## ##########
		    public Postate check_if_valid(Level warudo, BlockPos pos) {				
			        Postate postate = new Postate(warudo, pos);
		        // BlockState blkstate = postate.getBlockState();
		        Block bloque = postate.getBlockState().getBlock();				
			        if (bloque == Blocks.AIR) {
		            return null;
		        }				
			        /*
		        if (bloque == Blocks.DIRT) {
		            System.out.println("Es tierra");
		            //return null;
		        }				
			
		        if (bloque == Blocks.GRASS_BLOCK) {
		            System.out.println("Es pasto ");
		            //return null;
		        }				
			        if (bloque == Blocks.GRASS) {
		            System.out.println("Es pasto ");
		            //return null;
		        }
		        */				
			        return postate;
		    }				
			    // ########## ########## ########## ##########
		    public ArrayList<BlockPos> check_surroundings_pos_6(BlockPos center) {
		        ArrayList<BlockPos> sub_lista = new ArrayList<BlockPos>();				
			        sub_lista.add(center.above());
		        sub_lista.add(center.below());
		        sub_lista.add(center.east());
		        sub_lista.add(center.west());
		        sub_lista.add(center.north());
		        sub_lista.add(center.south());				
			        return sub_lista;
		    }
		    
		    
		    
		    
		    
		    
		    
		    
		    
		    
		    
		    // ########## ########## ########## ########## ########## ##########
		    // ########## ########## ########## ########## ########## ##########
		    public CompoundTag getBuildingNbt(String structureName) {
		        try {
		            ResourceLocation rl = new ResourceLocation(this.modname, "structures/" + structureName + ".nbt");
		            Optional<Resource> rs = this.resourceManager.getResource(rl);
		            return NbtIo.readCompressed(rs.get().open());
		        } catch (Exception e) {
		            // System.out.println(e);
		            return null;
		        }
		    }				
			    // ########## ########## ########## ########## ########## ##########
		    public void setBuildingNbt(String structureName, CompoundTag nbt) {
		        try {
		            ResourceLocation rl = new ResourceLocation(this.modname, "structures/" + structureName + ".nbt");
		            Optional<Resource> rs = this.resourceManager.getResource(rl);
		        
		            File file = new File( rl.getNamespace() + "/structures/" + structureName + ".nbt"   ); //  
		                        
		            if (file.exists()) {
		                file.delete();
		            }
		            file.createNewFile();
		            
		            System.out.println("\n########## absolute pad >" + file.getAbsolutePath() + "<");
		            
		            NbtIo.writeCompressed(nbt, file );
		            
		        } catch (Exception e) {
		            System.out.println(e);
		        }
		    }    
		    
		    
		    // ########## ########## ########## ########## ########## ##########
		    public ArrayList<BlockState> getBuildingPalette(CompoundTag nbt) {
		        ArrayList<BlockState> palette = new ArrayList<>();
		        // load in palette (list of unique blockstates)
		        ListTag paletteNbt = nbt.getList("palette", 10);
		        for (int i = 0; i < paletteNbt.size(); i++)
		            palette.add(NbtUtils.readBlockState(paletteNbt.getCompound(i)));
		        return palette;
		    }				
			    // ########## ########## ########## ##########
		    public BlockState rotate_blockstate(BlockState blkstate, Rotation rot) {				
			        // Direccion
		        Direction facing = null;				
			        if (blkstate.hasProperty(BlockStateProperties.FACING)) {
		            facing = blkstate.getValue(BlockStateProperties.FACING);
		        }				
			        if (blkstate.hasProperty(BlockStateProperties.HORIZONTAL_FACING)) {
		            facing = blkstate.getValue(BlockStateProperties.HORIZONTAL_FACING);
		        }				
			        Direction.Axis axix = null;
		        if (blkstate.hasProperty(BlockStateProperties.AXIS)) {
		            axix = blkstate.getValue(BlockStateProperties.AXIS);
		        }				
			        if (blkstate.hasProperty(BlockStateProperties.HORIZONTAL_AXIS)) {
		            axix = blkstate.getValue(BlockStateProperties.HORIZONTAL_AXIS);
		        }				
			        if (facing != null && facing != Direction.UP && facing != Direction.DOWN) {
		            switch (rot) {
		            default:
		                // du nothing
		                break;
		            case CLOCKWISE_180:
		                facing = facing.getOpposite();
		                break;
		            case CLOCKWISE_90:
		                facing = facing.getClockWise();
		                break;
		            case COUNTERCLOCKWISE_90:
		                facing = facing.getCounterClockWise();
		                break;
		            }				
			            if (blkstate.hasProperty(BlockStateProperties.FACING)) {
		                blkstate = blkstate.setValue(BlockStateProperties.FACING, facing);
		            }				
			            if (blkstate.hasProperty(BlockStateProperties.HORIZONTAL_FACING)) {
		                blkstate = blkstate.setValue(BlockStateProperties.HORIZONTAL_FACING, facing);
		            }
		        }				
			        // axis
		        // Direction.Axis.valueOf(value.toUpperCase())				
			        if (axix != null) {				
			            switch (axix) {
		            default:
		            case Y:
		                // du nuthing
		                break;
		            case X:
		                axix = Direction.Axis.Z;
		                break;
		            case Z:
		                axix = Direction.Axis.X;
		                break;
		            }				
			            if (blkstate.hasProperty(BlockStateProperties.AXIS)) {
		                blkstate = blkstate.setValue(BlockStateProperties.AXIS, axix);
		            }				
			            if (blkstate.hasProperty(BlockStateProperties.HORIZONTAL_AXIS)) {
		                blkstate = blkstate.setValue(BlockStateProperties.HORIZONTAL_AXIS, axix);
		            }
		        }				
			        // this thing dont works on mod made blocks
		        if (axix == null && facing == null) {
		            blkstate.rotate(rot);
		        }				
			        return blkstate;
		    }				
			    // ########## ########## ########## ##########
		    public BlockPos rotate_blockpos(BlockPos cursor, Rotation rot) {
		        switch (rot) {
		        default:
		            // case NORTH:
		            // du nuthing
		            break;				
			        case CLOCKWISE_90:
		            cursor = new BlockPos(cursor.getZ() * -1, cursor.getY(), cursor.getX());
		            break;				
			        case CLOCKWISE_180:
		            cursor = new BlockPos(cursor.getX() * -1, cursor.getY(), cursor.getZ() * -1);
		            break;				
			        case COUNTERCLOCKWISE_90:
		            cursor = new BlockPos(cursor.getZ(), cursor.getY(), cursor.getX() * -1);
		            break;
		        }				
			        return cursor;
		    }				
			    // ########## ########## ########## ########## ########## ##########
		    // ########## ########## ########## ########## ########## ##########
		    //
		    public static String get_blkfullname(BlockState blkstate) {
		        if (blkstate == null) {
		            return "NULL";
		        }				
			        String nnn = "" + blkstate.getBlock().getName().getString().toLowerCase();				
			        return fix_blkfullname(nnn);
		    }				
			    // ########## ########## ########## ########## ########## ##########
		    //
		    public static String fix_blkfullname(String blkfullname) {
		        if (blkfullname.contains(".")) {
		            String[] split1 = blkfullname.split("\\."); // "\\."				
			            if (split1.length > 1) {
		                blkfullname = split1[split1.length - 1].replaceAll("_", " ");
		            }
		        }				
			        return blkfullname.toLowerCase();
		    }				
			    // ########## ########## ########## ##########
		    // ########## ########## ########## ##########
		    public static BlockPos chunk_northwest_corner(Level warudo, BlockPos pos) {
		        BlockPos min = null;				
			        int subx = 0;
		        int subz = 0;
		        int abs = 0;				
			        int factox = 0;
		        int factoz = 0;				
			        // si el valor es negativo
		        if (pos.getX() < 0) {
		            abs = Math.abs(pos.getX());				
			            factox = (abs / 16);
		            factox = ((abs % 16) > 0) ? factox + 1 : factox;
		            subx = -16 * factox;				
			        } else {
		            subx = pos.getX() - (pos.getX() % 16);
		        }				
			        // si el valor es negativo
		        if (pos.getZ() < 0) {
		            abs = Math.abs(pos.getZ());				
			            factoz = (abs / 16);
		            factoz = ((abs % 16) > 0) ? factoz + 1 : factoz;
		            subz = -16 * factoz;				
			        } else {
		            subz = pos.getZ() - (pos.getZ() % 16);
		        }				
			        min = new BlockPos(subx, pos.getY(), subz);
		        return min;
		    }				
			    
		    // ########## ########## ########## ##########
		    public void setBlocks(){
		        bm.find_liquids();
		        bm.setBlocks();    
		    }
		    
		    // ########## ########## ########## ########## ########## ##########
		    public BlockMap getBm() {
		        return bm;
		    }				
			    public void setBm(BlockMap bm) {
		        this.bm = bm;
		    }				
			    
		    // ########## ########## ########## ########## ########## ##########
		    // ########## ########## ########## ########## ########## ##########
		    // ########## ########## ########## ########## ########## ##########
		    // ########## ########## ########## ########## ########## ##########
		}
		 				
			

 

the testing item 

Spoiler

				
			
		package mercblk.item.rod;				
			import java.util.ArrayList;
		import java.util.Collections;
		import java.util.HashSet;
		import java.util.List;
		import java.util.Optional;
		import java.util.Set;				
			import mercblk.util.NbtStructure;
		import mercblk.util.Target;				
			import java.util.Map.Entry;
		import java.util.function.Predicate;				
			import net.minecraft.advancements.critereon.EntityPredicate;
		import net.minecraft.core.BlockPos;
		import net.minecraft.core.Direction;
		import net.minecraft.core.particles.ParticleTypes;
		import net.minecraft.network.chat.Component;
		import net.minecraft.resources.ResourceKey;
		import net.minecraft.server.level.ServerLevel;
		import net.minecraft.sounds.SoundEvents;
		import net.minecraft.world.InteractionHand;
		import net.minecraft.world.InteractionResultHolder;
		import net.minecraft.world.entity.Entity;
		import net.minecraft.world.entity.LivingEntity;
		import net.minecraft.world.entity.Pose;
		import net.minecraft.world.entity.ai.targeting.TargetingConditions;
		import net.minecraft.world.entity.player.Player;
		import net.minecraft.world.item.Item;
		import net.minecraft.world.item.ItemStack;
		import net.minecraft.world.item.Items;
		import net.minecraft.world.level.Level;
		import net.minecraft.world.level.block.Block;
		import net.minecraft.world.level.block.Blocks;
		import net.minecraft.world.level.block.state.BlockState;
		import net.minecraft.world.phys.AABB;
		import net.minecraft.world.phys.Vec2;
		import net.minecraft.world.phys.Vec3;
		import net.minecraftforge.registries.ForgeRegistries;				
			public class just_aButton extends Item {				
			    // ########## ########## ########## ##########
		    public just_aButton(Properties propiedad) {
		        super(propiedad);
		        // TODO Auto-generated constructor stub
		    }				
			    // ########## ########## ########## ##########
		    @Override
		    public InteractionResultHolder<ItemStack> use(Level warudo, Player pe, InteractionHand hand) {				
			        if (! warudo.isClientSide )
		        { 
		            
		            BlockPos p0 = new BlockPos( 0, 76, 5283 );
		            
		            NbtStructure nstr = new NbtStructure(warudo);
		            
		            nstr.capture_blocks(p0);
		        }				
			        return InteractionResultHolder.pass(pe.getItemInHand(hand));
		    }				
			    // ########## ########## ########## ##########
		    // ########## ########## ########## ##########
		    // ########## ########## ########## ##########
		    // ########## ########## ########## ##########				
			}				
			

some blocks i set floating in the air to capture this methods reads everything around the starting point ignoring air so  it will also reads water and crops also you must separate the extructure from the soil ol youll get 4096 blocks of dirt and stone whit the structure 
bloques-edit.gif
 

Link to comment
Share on other sites

Path worldSaveDirectory = minecraftServer.getWorldPath(LevelResource.ROOT);

Should get you the current save?

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.



×
×
  • Create New...

Important Information

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