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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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