Jump to content

Recommended Posts

Posted

I have rebuilt my cabinet code 3 times now. It works for awhile then starts to crash. I have two identical files one works and other crashes:

Working version:

{
  code: "b1cabinet",
  class: "BlockGenericTypedContainer",
  entityclass: "GenericTypedContainer",
  behaviors: [
    { "name": "Lockable" },
    { "name": "Container" },
    { "name": "BoatableGenericTypedContainer" }
  ],
  creativeinventory: { "general": [ "b1cabinet" ],  "decorative": [ "b1cabinet" ] },
  attributes: {
    inventoryClassName: "chest",
    defaultType: "acacia",
    types: [ "acacia" ],
    handbook: {
      groupBy: [ "cabinet" ]
    },
    rotatatableInterval: { "acacia": "22.5degnot45deg" },
    storageType: { "acacia": 189 },
    retrieveOnly: { "acacia": false },
    quantitySlots: { "acacia": 20 },
    shape: { "acacia": "cabinet" },
    typedOpenSound: { "acacia": "game:sounds/block/largechestopen" },
    typedCloseSound: { "acacia": "game:sounds/block/largechestclose" },
    variantByGroup: "side",
    variantByGroupInventory: null
  },
  shapeInventory: {
    "base": "cabinet",
    "rotateY": 270
  },
  //Texture identifiers are prefixed with the type
  textures: {
   "acacia-top": { "base": "polished/obsidian2" },
    "acacia-handle": { "base": "polished/obsidian2" },
    "acacia-bottom": { "base": "debarked/acacia" },
    "acacia-fdoor": { "base": "debarked/acacia" },
    "acacia-back": { "base": "debarked/acacia" },
    "acacia-sideleft": { "base": "debarked/acacia" },
    "acacia-sideright": { "base": "debarked/acacia" }
  },
  replaceable: 500,
  resistance: 1.5,
  lightAbsorption: 99,
  sidesolid: { "all": false },
  sideopaque: { "all": false },
  heldTpIdleAnimation: "holdbothhandslarge",
  heldRightReadyAnimation: "heldblockready",
  heldTpUseAnimation: "twohandplaceblock",
  tpHandTransform: {
    translation: {
      "x": -1.23,
      "y": -0.91,
      "z": -0.8
    },
    rotation: {
      "x": -2,
      "y": 25,
      "z": -78
    },
    scale: 0.4
  }
}

Crashing version:

{
  code: "cabinet-1",
  class: "BlockGenericTypedContainer",
  entityclass: "GenericTypedContainer",
  behaviors: [
    { "name": "Lockable" },
    { "name": "Container" },
    { "name": "BoatableGenericTypedContainer" }
  ],
  creativeinventory: { "general": [ "cabinet-1" ],  "decorative": [ "cabinet-1" ] },
  attributes: {
    inventoryClassName: "chest",
    defaultType: "acacia",
    types: [ "acacia" ],
    handbook: {
      groupBy: [ "cabinet" ]
    },
    rotatatableInterval: { "acacia": "22.5degnot45deg" },
    storageType: { "acacia": 189 },
    retrieveOnly: { "acacia": false },
    quantitySlots: { "acacia": 20 },
    shape: { "acacia": "cabinet" },
    typedOpenSound: { "acacia": "game:sounds/block/largechestopen" },
    typedCloseSound: { "acacia": "game:sounds/block/largechestclose" },
    variantByGroup: "side",
    variantByGroupInventory: null
  },
  shapeInventory: {
    "base": "cabinet",
    "rotateY": 270
  },
  //Texture identifiers are prefixed with the type
  textures: {
   "acacia-top": { "base": "polished/obsidian2" },
    "acacia-handle": { "base": "polished/obsidian2" },
    "acacia-bottom": { "base": "debarked/acacia" },
    "acacia-fdoor": { "base": "debarked/acacia" },
    "acacia-back": { "base": "debarked/acacia" },
    "acacia-sideleft": { "base": "debarked/acacia" },
    "acacia-sideright": { "base": "debarked/acacia" }
  },
  replaceable: 500,
  resistance: 1.5,
  lightAbsorption: 99,
  sidesolid: { "all": false },
  sideopaque: { "all": false },
  heldTpIdleAnimation: "holdbothhandslarge",
  heldRightReadyAnimation: "heldblockready",
  heldTpUseAnimation: "twohandplaceblock",
  tpHandTransform: {
    translation: {
      "x": -1.23,
      "y": -0.91,
      "z": -0.8
    },
    rotation: {
      "x": -2,
      "y": 25,
      "z": -78
    },
    scale: 0.4
  }
}

Crash report:

Running on 64 bit Linux (Linux Mint 22.1) [Kernel 6.8.0.90] with 31965 MB RAM
Game Version: v1.21.6 (Stable)
12/29/2025 10:37:10AM: Critical error occurred
Loaded Mods: mudmod@1.0.0, plantsexpandedmod@1.0.4, game@1.21.6, woodworking@1.0.0, creative@1.21.6, survival@1.21.6
System.Exception: Can't create itemstack without block!
   at Vintagestory.API.Common.ItemStack..ctor(Block block, Int32 stacksize) in VintagestoryApi\Common\Collectible\ItemStack.cs:line 244
   at Vintagestory.GameContent.BlockGenericTypedContainer.OnPickBlock(IWorldAccessor world, BlockPos pos) in VSSurvivalMod\Block\BlockGenericTypedContainer.cs:line 374
   at Vintagestory.API.Common.Block.GetPlacedBlockName(IWorldAccessor world, BlockPos pos) in VintagestoryApi\Common\Collectible\Block\Block.cs:line 2199
   at Vintagestory.Client.NoObf.HudElementBlockAndEntityInfo.ComposeBlockInfoHud() in VintagestoryLib\Client\Systems\Gui\Huds\HudElementBlockAndEntityInfo.cs:line 44
   at Vintagestory.Common.GameTickListener.OnTriggered(Int64 ellapsedMilliseconds) in VintagestoryLib\Common\Model\GameTickListener.cs:line 25
   at Vintagestory.Common.EventManager.TriggerGameTick(Int64 ellapsedMilliseconds, IWorldAccessor world) in VintagestoryLib\Common\EventManager.cs:line 102
   at Vintagestory.Client.NoObf.ClientMain.MainRenderLoop(Single dt) in VintagestoryLib\Client\ClientMain.cs:line 836
   at Vintagestory.Client.GuiScreenRunningGame.RenderToPrimary(Single dt) in VintagestoryLib\Client\MainMenu\Screens\GuiScreenRunningGame.cs:line 172
   at Vintagestory.Client.ScreenManager.Render(Single dt) in VintagestoryLib\Client\ScreenManager.cs:line 719
   at Vintagestory.Client.ScreenManager.OnNewFrame(Single dt) in VintagestoryLib\Client\ScreenManager.cs:line 663
   at Vintagestory.Client.NoObf.ClientPlatformWindows.window_RenderFrame(FrameEventArgs e) in VintagestoryLib\Client\ClientPlatform\GameWindow.cs:line 112
   at OpenTK.Windowing.Desktop.GameWindow.Run()
   at Vintagestory.Client.ClientProgram.Start(ClientProgramArgs args, String[] rawArgs) in VintagestoryLib\Client\ClientProgram.cs:line 347
   at Vintagestory.Client.ClientProgram.<>c__DisplayClass10_0.<.ctor>b__1() in VintagestoryLib\Client\ClientProgram.cs:line 131
   at Vintagestory.ClientNative.CrashReporter.Start(ThreadStart start) in VintagestoryLib\Client\ClientPlatform\ClientNative\CrashReporter.cs:line 95

 

  • Solution
Posted (edited)

They are not identical, the code is different.

On 12/29/2025 at 5:37 PM, Micah Holmes said:
  code: "cabinet-1",

The code of the crashing version has a `-` in it, which is a big no no as it this symbol is used to separate variants. This means that whenever the game attempts to do any kind of logic for looking up variants it will think that your base code is "cabinet" (because it discards everything after the first variant separator) which generally results in it being unable to find the block or item.

The method that is crashing does exactly that:
image.png.a266d88f8dda0c173f55790f188d7522.png

`CodeWithVariant` attempts to take your code and replace the "side" variant with the value "east" (if present) but in the process it removes the `-1` and thus becomes unable to find it.

Edited by The Insanity God
×
×
  • 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.