Jump to content

[1.19.4] updating NbtUtils.readBlockState from 1.19.3 to 1.19.4


SoLegendary

Recommended Posts

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?

Link to comment
Share on other sites

  • 2 weeks later...

	// ########## ########## ########## ########## ########## ##########
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
		  ]
		}				
			

 

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.