Jump to content

Recommended Posts

Posted

Been troubleshooting this recipe for a bit. Has to be something basic I'm not seeing:

 

14.12.2025 22:15:01 [Error] [game] An exception was thrown when trying to start the mod:
14.12.2025 22:15:01 [Error] [game] Exception: Object reference not set to an instance of an object.
   at Vintagestory.ServerMods.GridRecipeLoader.LoadRecipe(AssetLocation assetLocation, GridRecipe recipe) in VSEssentials\Loading\GridRecipeLoader.cs:line 60
   at Vintagestory.ServerMods.GridRecipeLoader.LoadGridRecipes() in VSEssentials\Loading\GridRecipeLoader.cs:line 48
   at Vintagestory.ServerMods.GridRecipeLoader.AssetsLoaded(ICoreAPI api) in VSEssentials\Loading\GridRecipeLoader.cs:line 28
   at Vintagestory.Common.ModLoader.TryRunModPhase(Mod mod, ModSystem system, ICoreAPI api, ModRunPhase phase) in VintagestoryLib\Common\API\ModLoader.cs:line 667
14.12.2025 22:15:01 [Error] Failed to run mod phase AssetsLoaded for mod Vintagestory.ServerMods.GridRecipeLoader

recipe:

[
	//apprentice
	{
		ingredientPattern: "HS",
		ingredients: {
			"H": { type: "item", code: "spearhead-sanded-limestone", quantity: 1 },
			"S": { type: "item", code: "spearshaft-redwood", quantity: 1 }
		},
		width: 2,
		height: 1,
		output: { type: "item", code: "spear-apprentice-redwood-limestone"  }
	},
	{
		ingredientPattern: "HS",
		ingredients: {
			"H": { type: "item", code: "spearhead-sanded-limestone", quantity: 1 },
			"S": { type: "item", code: "spearshaft-larch", quantity: 1 }
		},
		width: 2,
		height: 1,
		output: { type: "item", code: "spear-apprentice-larch-limestone"  }
	},
	{
		ingredientPattern: "HS",
		ingredients: {
			"H": { type: "item", code: "spearhead-sanded-slate", quantity: 1 },
			"S": { type: "item", code: "spearshaft-redwood", quantity: 1 }
		},
		width: 2,
		height: 1,
		output: { type: "item", code: "spear-apprentice-redwood-slate"  }
	},
	{
		ingredientPattern: "HS",
		ingredients: {
			"H": { type: "item", code: "spearhead-sanded-slate", quantity: 1 },
			"S": { type: "item", code: "spearshaft-larch", quantity: 1 }
		},
		width: 2,
		height: 1,
		output: { type: "item", code: "spear-apprentice-larch-slate"  }
	},
	//journeyman
	{
		ingredientPattern: "HS",
		ingredients: {
			"H": { type: "item", code: "spearhead-polished-limestone", quantity: 1 },
			"S": { type: "item", code: "spearshaft-redwood", quantity: 1 }
		},
		width: 2,
		height: 1,
		output: { type: "item", code: "spear-journeyman-redwood-limestone"  }
	},
	{
		ingredientPattern: "HS",
		ingredients: {
			"H": { type: "item", code: "spearhead-polished-limestone", quantity: 1 },
			"S": { type: "item", code: "spearshaft-larch", quantity: 1 }
		},
		width: 2,
		height: 1,
		output: { type: "item", code: "spear-journeyman-larch-limestone"  }
	},
	{
		ingredientPattern: "HS",
		ingredients: {
			"H": { type: "item", code: "spearhead-polished-slate", quantity: 1 },
			"S": { type: "item", code: "spearshaft-redwood", quantity: 1 }
		},
		width: 2,
		height: 1,
		output: { type: "item", code: "spear-journeyman-redwood-slate"  }
	},
	{
		ingredientPattern: "HS",
		ingredients: {
			"H": { type: "item", code: "spearhead-polished-slate", quantity: 1 },
			"S": { type: "item", code: "spearshaft-larch", quantity: 1 }
		},
		width: 2,
		height: 1,
		output: { type: "item", code: "spear-journeyman-larch-slate"  }
	}
]

Spears:

{
	code: "spear",
	class: "ItemSpear",
	tags: ["weapon", "weapon-melee"],
	damagedby: ["attacking"],
	tool: "spear",
	behaviors: [
		{ name: "GroundStorable", properties: { layout: 'WallHalves', wallOffYByType:{ "@spear-generic-(chert|granite|andesite|basalt|obsidian|peridotite|flint)": 2, "*": 3 }, ctrlKey: true, selectionBox: { x1: 0, y1: 0, z1: 0, x2: 1, y2: 0.1, z2: 1 }, collisionBox: { x1: 0, y1: 0, z1: 0, x2: 0, y2: 0, z2: 0 } } },
		{ name: "AnimationAuthoritative" }
	],
	variantgroups: [
		{ code: "type", states: ["apprentice", "journeyman" ] },
		{ code: "wood", states: [ "redwood", "larch" ] },
		{ code: "material", states: ["limestone", "slate" ] }
	],
	shapeByType: { "*": { base: "game:item/tool/spear/stone" } },
	heldTpIdleAnimation: "spearidle",
	heldRightReadyAnimation: "spearidle",
	heldTpHitAnimation: "spearhit",
	texturesByType: {
		"spear-apprentice-*-limestone": {
			"string": { "base": "bow-string/bowstring-hide" },
            "handle": { "base": "debarked/{wood}" },
            "material": { "base": "polished/{material}1" }
		},
		"spear-journeyman-*-limestone": {
			"string": { "base": "bow-string/bowstring-hide" },
            "handle": { "base": "debarked/{wood}" },
            "material": { "base": "polished/{material}1" }
		},
		"spear-apprentice-*-slate": {
			"string": { "base": "bow-string/bowstring-hide" },
            "handle": { "base": "debarked/{wood}" },
            "material": { "base": "polished/{material}1" }
		},
		"spear-journeyman-*-slate": {
			"string": { "base": "bow-string/bowstring-hide" },
            "handle": { "base": "debarked/{wood}" },
            "material": { "base": "polished/{material}1" }
		}   
	},
	attackRange: 3.5,
	attackpowerbytype: {
		"spear-apprentice-*-limestone": 1.35,
		"spear-journeyman-*-limestone": 1.5,
		"spear-apprentice-*-slate": 1.45,
		"spear-journeyman-*-slate": 1.65
	},
	attributes: {
		heldItemPitchFollow: 1,
		groundStorageTransformByType: {
			"*": {
				translation: { x: 0, y: 0.26, z: 0.596 },
				rotation: { x: 16, y: 90, z: 90 },
				scale: 0.85
			}
		},
		// Thrown damage
		damageByType: {
		"spear-apprentice-*-limestone": 3.45,
		"spear-journeyman-*-limestone": 3.7,
		"spear-apprentice-*-slate": 3.62,
		"spear-journeyman-*-slate": 3.89
		},
		damageTierByType: {
		"spear-apprentice-*-limestone": 0,
		"spear-journeyman-*-limestone": 0,
		"spear-apprentice-*-slate": 0,
		"spear-journeyman-*-slate": 0
		},
		spearEntityCodeByType: {
			"*": "erelprojectile-large-usable"
			//"*": "spear-{type}-{wood}-{material}"
		},
		handbook: {
			groupBy: ["spear-*"]
		},
		toolrackTransformByType: {
			"*": {
				rotation: { y: 1, z: -1 },
				translation: { x: -0.23, y: 0.66 },
				scale: 1.36
			}
		}
	},
	durabilitybytype: {
		"spear-apprentice-*-limestone": 80,
		"spear-journeyman-*-limestone": 140,
		"spear-apprentice-*-slate": 110,
		"spear-journeyman-*-slate": 190
	},
	creativeinventory: { "general": ["*"], "items": ["*"], "tools": ["*"] },
	guiTransformByType: {
		"*": {
			translation: { x: 0, y: 0, z: 0 },
			rotation: { x: -60, y: 124, z: 6 },
			origin: { x: 1.19, y: 0, z: 0.5 },
			scale: 2.26
		}
	},
	fpHandTransformByType: {
		"*": {
			translation: { x: 0.1, y: 0.4, z: 0.16 },
			rotation: { x: -82, y: 180, z: 96 },
			origin: { x: 0.5, y: 0, z: 0.5 },
			scale: 2.45
		}
	},
	groundTransformByType: {
		"*": {
			translation: { x: 0, y: 0.05, z: 0 },
			rotation: { x: 90, y: 0, z: 0 },
			origin: { x: 0.5, y: 0, z: 0.5 },
			scale: 3.4
		}
	},
	tpHandTransformByType: {
		"*": {
			translation: { x: -1.29, y: 0.02, z: -0.57 },
			rotation: { x: -90, y: 0, z: 0 },
			origin: { x: 0.5, y: 0, z: 0.5 },
			scale: 0.8
		}
	}
}

 

 

If I remove the recipe, works fine no issues. Gives error with no helpful info when i load:

14.12.2025 22:15:01 [Error] [game] An exception was thrown when trying to start the mod:
14.12.2025 22:15:01 [Error] [game] Exception: Object reference not set to an instance of an object.
   at Vintagestory.ServerMods.GridRecipeLoader.LoadRecipe(AssetLocation assetLocation, GridRecipe recipe) in VSEssentials\Loading\GridRecipeLoader.cs:line 60
   at Vintagestory.ServerMods.GridRecipeLoader.LoadGridRecipes() in VSEssentials\Loading\GridRecipeLoader.cs:line 48
   at Vintagestory.ServerMods.GridRecipeLoader.AssetsLoaded(ICoreAPI api) in VSEssentials\Loading\GridRecipeLoader.cs:line 28
   at Vintagestory.Common.ModLoader.TryRunModPhase(Mod mod, ModSystem system, ICoreAPI api, ModRunPhase phase) in VintagestoryLib\Common\API\ModLoader.cs:line 667
14.12.2025 22:15:01 [Error] Failed to run mod phase AssetsLoaded for mod Vintagestory.ServerMods.GridRecipeLoader

how I read it is the recipe reader crapped out but its not saying why or whats wrong with my recipe. 

 

Posted
25 minutes ago, Brady_The said:

Recipe files don't like comments.

You sure? I comment out stuff in my files (including recipes) all the time during development and I never noticed any issue with that.

Was under the impression that comments are ignored by Newtonsoft.JSON (the library responsible for parsing JSON)

Posted (edited)
3 hours ago, The Insanity God said:

You sure? I comment out stuff in my files (including recipes) all the time during development and I never noticed any issue with that.

Was under the impression that comments are ignored by Newtonsoft.JSON (the library responsible for parsing JSON)

I specified above. Comments inside curly brackets are okay, comments outside curly brackets trigger this error.

Spoiler

image.thumb.png.6433c9bf17cca4ca5f70e9c37e95b491.png

image.thumb.png.fdaf44a52cd36faac27afa9040ff3e89.png

Edited by Brady_The
Posted (edited)
1 hour ago, Brady_The said:

Comments inside curly brackets are okay, comments outside curly brackets trigger this error.

 

Hmm how interesting, it seems that when you have a comment in an array it actually is read as an item in the array (of ValueType "comment") and because the game is manually grabbing each entry and trying to parse it to a GridRecipe, it ends up failing and crashes.
image.thumb.png.3075b5805a8cbb42f6f266f28dac5656.png


As someone who likes to put down comments this is good to know.

Edited by The Insanity God
  • Like 1
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.