Jump to content

[1.19.4] updating NbtUtils.readBlockState from 1.19.3 to 1.19.4


Recommended Posts

Posted

I am trying to update my code from 1.19.3 to 1.19.4 but am having trouble adapting the NbtUtils.readBlockState method - this function used to just take one CompoundTag parameter but now it takes the CompoundTag and a HolderGetter<Block> pBlockGetter parameter. Where am I supposed to get pBlockGetter from?

I primarily use this method for reading NBT structure data from my mod's resource files. The player can create structures which are saved into both client and server sides (so this method can run on both sides).

My code for the method is here:

https://github.com/SoLegendary/reignofnether/blob/1.19.4/src/main/java/com/solegendary/reignofnether/building/BuildingBlockData.java#L67-L74

In the future is there a guide for how to update methods like this on a new Minecraft version?

  • 2 weeks later...
Posted

currently i im in the same predicament whit the same function 

the only i can thing of is to somehow get the block name and mod id from paletteNbt.getCompound(i)  and used to get the block from the ForgeRegistries.BLOCKS list 
just to pass it here 

 

 

 

Posted

	// ########## ########## ########## ########## ########## ##########
public ArrayList<BlockState> getBuildingPalette(CompoundTag nbt) {
ArrayList<BlockState> palette = new ArrayList<>();
// load in palette (list of unique blockstates)
ListTag paletteNbt = nbt.getList("palette", 10);
CompoundTag pblk;
Block block = null;
for (int i = 0; i < paletteNbt.size(); i++)
pblk = paletteNbt.getCompound(i);



String name = pblk.getString("Name");
block = ForgeRegistries.BLOCKS. .getValue(name);

//palette.add(NbtUtils.readBlockState( paletteNbt.getCompound(i) ) );


return palette;
}
	

 

Spoiler

				
			
		{ "DataVersion": 3337,
		  "blocks"     : list<TAG_Compound>[3] [
		    { "pos"  : list<TAG_Int>[3] [
		        0,
		        0,
		        0
		      ],
		      "state": 0
		    },
		    { "pos"  : list<TAG_Int>[3] [
		        1,
		        0,
		        0
		      ],
		      "state": 1
		    },
		    { "pos"  : list<TAG_Int>[3] [
		        2,
		        0,
		        0
		      ],
		      "state": 2
		    }
		  ],
		  "entities"   : list<undefined>[0] [],
		  "palette"    : list<TAG_Compound>[3] [
		    { "Name"      : "mercblk:manhole_dirt_path_east_slab",
		      "Properties": {
		        "age"        : "0",
		        "type"       : "top",
		        "waterlogged": "false"
		      }
		    },
		    { "Name"      : "mercblk:stone_bricks_panel",
		      "Properties": {
		        "facing"     : "east",
		        "waterlogged": "false"
		      }
		    },
		    { "Name"      : "mercblk:manhole_dirt_path_west_slab",
		      "Properties": {
		        "age"        : "7",
		        "type"       : "top",
		        "waterlogged": "false"
		      }
		    }
		  ],
		  "size"       : list<TAG_Int>[3] [
		    3,
		    1,
		    1
		  ]
		}				
			

 

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.