Ejemplo n.º 1
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            ItemStack[]   contents   = GetNonEmptyContents(capi.World, itemstack);
            string        recipeCode = itemstack.Attributes.GetString("recipeCode");
            AssetLocation loc        = LabelForContents(recipeCode, contents);

            if (loc == null)
            {
                return;
            }

            Dictionary <string, MeshRef> meshrefs = ObjectCacheUtil.GetOrCreate(capi, "blockcrockGuiMeshRefs", () =>
            {
                return(new Dictionary <string, MeshRef>());
            });

            string  key = Code.ToShortString() + loc.ToShortString();
            MeshRef meshref;

            if (!meshrefs.TryGetValue(key, out meshref))
            {
                MeshData mesh = GenMesh(capi, loc, new Vec3f(0, 270, 0));
                //mesh.Rgba2 = null;
                meshrefs[key] = meshref = capi.Render.UploadMesh(mesh);
            }

            renderinfo.ModelRef = meshref;
        }
Ejemplo n.º 2
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            if (meshCache == null)
            {
                meshCache = capi.ModLoader.GetModSystem <MealMeshCache>();
            }

            CookingRecipe recipe = GetCookingRecipe(capi.World, itemstack);

            ItemStack[] contents = GetNonEmptyContents(capi.World, itemstack);

            MeshRef meshref = meshCache.GetOrCreateMealInContainerMeshRef(this, recipe, contents, new Vec3f(0, yoff / 16f, 0));

            if (meshref != null)
            {
                renderinfo.ModelRef = meshref;
            }
        }
Ejemplo n.º 3
0
 public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
 {
     base.OnBeforeRender(capi, itemstack, target, ref renderinfo);
 }
Ejemplo n.º 4
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            if (meshCache == null)
            {
                meshCache = capi.ModLoader.GetModSystem <MealMeshCache>();
            }

            CookingRecipe recipe = GetCookingRecipe(capi.World, itemstack);

            ItemStack[] contents = GetContents(capi.World, itemstack);

            float yoff = 2.5f; // itemstack.Attributes.GetInt("servings");

            MeshRef meshref = meshCache.GetOrCreateMealMeshRef(this.Shape, recipe, contents, new Vec3f(0, yoff / 16f, 0));

            if (meshref != null)
            {
                renderinfo.ModelRef = meshref;
            }
        }
Ejemplo n.º 5
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            Dictionary <string, MeshRef> meshrefs = ObjectCacheUtil.GetOrCreate(capi, "blockLanternGuiMeshRefs", () =>
            {
                return(new Dictionary <string, MeshRef>());
            });

            string material = itemstack.Attributes.GetString("material");
            string lining   = itemstack.Attributes.GetString("lining");
            string glass    = itemstack.Attributes.GetString("glass", "quartz");

            string  key = material + "-" + lining + "-" + glass;
            MeshRef meshref;

            if (!meshrefs.TryGetValue(key, out meshref))
            {
                AssetLocation shapeloc = Shape.Base.Clone().WithPathPrefix("shapes/").WithPathAppendix(".json");
                Shape         shape    = capi.Assets.TryGet(shapeloc).ToObject <Shape>();

                MeshData mesh = GenMesh(capi, material, lining, glass, shape);
                //mesh.Rgba2 = null;
                meshrefs[key] = meshref = capi.Render.UploadMesh(mesh);
            }

            renderinfo.ModelRef  = meshref;
            renderinfo.CullFaces = false;
        }
Ejemplo n.º 6
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            base.OnBeforeRender(capi, itemstack, target, ref renderinfo);

            /*if (itemstack.Attributes.HasAttribute("hashCode"))
             * {
             *  int hashcode = itemstack.Attributes.GetInt("hashCode");
             *
             *  renderinfo.ModelRef = ObjectCacheUtil.GetOrCreate(capi, "ironbloom-" + hashcode, () =>
             *  {
             *      MeshData mesh = GenMesh(capi, itemstack);
             *      return capi.Render.UploadMesh(mesh);
             *  });
             * }*/
        }
Ejemplo n.º 7
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            base.OnBeforeRender(capi, itemstack, target, ref renderinfo);

            Dictionary <string, MeshRef> tapestryMeshes;

            tapestryMeshes          = ObjectCacheUtil.GetOrCreate(capi, "tapestryMeshesInventory", () => new Dictionary <string, MeshRef>());
            renderinfo.NormalShaded = false;
            MeshRef meshref;

            string type = itemstack.Attributes.GetString("type", "");

            if (!tapestryMeshes.TryGetValue(type, out meshref))
            {
                MeshData mesh = genMesh(false, type, 0, true);
                meshref = capi.Render.UploadMesh(mesh);
                tapestryMeshes[type] = meshref;
            }

            renderinfo.ModelRef = meshref;
        }
Ejemplo n.º 8
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            Dictionary <int, MeshRef> meshrefs = null;

            object obj;

            if (capi.ObjectCache.TryGetValue("bucketMeshRefs", out obj))
            {
                meshrefs = obj as Dictionary <int, MeshRef>;
            }
            else
            {
                capi.ObjectCache["bucketMeshRefs"] = meshrefs = new Dictionary <int, MeshRef>();
            }

            ItemStack contentStack = GetContent(capi.World, itemstack);

            if (contentStack == null)
            {
                return;
            }

            int hashcode = GetBucketHashCode(capi.World, contentStack);

            MeshRef meshRef = null;

            if (!meshrefs.TryGetValue(hashcode, out meshRef))
            {
                MeshData meshdata = GenMesh(capi, contentStack);
                //meshdata.Rgba2 = null;


                meshrefs[hashcode] = meshRef = capi.Render.UploadMesh(meshdata);
            }

            renderinfo.ModelRef = meshRef;
        }
Ejemplo n.º 9
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            base.OnBeforeRender(capi, itemstack, target, ref renderinfo);

            if (itemstack.Attributes.GetInt("pieSize") == 1)
            {
                if (target == EnumItemRenderTarget.Gui)
                {
                    renderinfo.Transform = oneSliceTranformGui;
                }
                if (target == EnumItemRenderTarget.HandTp)
                {
                    renderinfo.Transform = oneSliceTranformTp;
                }
            }

            renderinfo.ModelRef = ms.GetOrCreatePieMeshRef(itemstack);
        }
Ejemplo n.º 10
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            Dictionary <string, MeshRef> meshrefs = new Dictionary <string, MeshRef>();

            object obj;

            if (capi.ObjectCache.TryGetValue("blockLanternGuiMeshRefs", out obj))
            {
                meshrefs = obj as Dictionary <string, MeshRef>;
            }
            else
            {
                Dictionary <string, MeshData> lanternMeshes = GenGuiMeshes(capi);

                foreach (var val in lanternMeshes)
                {
                    meshrefs[val.Key] = capi.Render.UploadMesh(val.Value);
                }

                capi.ObjectCache["blockLanternGuiMeshRefs"] = meshrefs;
            }

            string material = itemstack.Attributes.GetString("material");
            string lining   = itemstack.Attributes.GetString("lining");

            meshrefs.TryGetValue(material + "-" + lining, out renderinfo.ModelRef);
        }
Ejemplo n.º 11
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            base.OnBeforeRender(capi, itemstack, target, ref renderinfo);

            if (isMapleSeed && target == EnumItemRenderTarget.Ground)
            {
                EntityItem ei = (renderinfo.InSlot as EntityItemSlot).Ei;
                if (!ei.Collided && !ei.Swimming)
                {
                    renderinfo.Transform            = renderinfo.Transform.Clone(); // dont override the original transform
                    renderinfo.Transform.Rotation.X = -90;
                    renderinfo.Transform.Rotation.Y = (float)(capi.World.ElapsedMilliseconds % 360.0) * 2f;
                    renderinfo.Transform.Rotation.Z = 0;
                }
            }
        }
Ejemplo n.º 12
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            JsonObject attrObj = itemstack.Collectible.Attributes;

            if (attrObj?["wearableAttachment"].Exists != true)
            {
                return;
            }

            Dictionary <string, MeshRef> armorMeshrefs = ObjectCacheUtil.GetOrCreate(capi, "armorMeshRefs", () => new Dictionary <string, MeshRef>());
            string key = "armorModelRef-" + itemstack.Collectible.Code.ToString();

            if (!armorMeshrefs.TryGetValue(key, out renderinfo.ModelRef))
            {
                renderinfo.ModelRef = armorMeshrefs[key] = genMeshRef(capi, itemstack, renderinfo);
            }
        }
Ejemplo n.º 13
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            if (Code.Path.Contains("clay"))
            {
                return;
            }
            Dictionary <string, MeshRef> meshrefs = null;

            object obj;

            if (capi.ObjectCache.TryGetValue(meshRefsCacheKey, out obj))
            {
                meshrefs = obj as Dictionary <string, MeshRef>;
            }
            else
            {
                capi.ObjectCache[meshRefsCacheKey] = meshrefs = new Dictionary <string, MeshRef>();
            }

            ItemStack contentStack = GetContent(itemstack);

            if (contentStack == null)
            {
                return;
            }

            MeshRef meshRef = null;

            if (!meshrefs.TryGetValue(contentStack.Collectible.Code.Path + Code.Path + contentStack.StackSize, out meshRef))
            {
                MeshData meshdata = GenMesh(capi, contentStack);
                if (meshdata == null)
                {
                    return;
                }

                meshrefs[contentStack.Collectible.Code.Path + Code.Path + contentStack.StackSize] = meshRef = capi.Render.UploadMesh(meshdata);
            }

            renderinfo.ModelRef = meshRef;
        }
Ejemplo n.º 14
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            if (meshCache == null)
            {
                meshCache = capi.ModLoader.GetModSystem <MealMeshCache>();
            }

            MeshRef meshref = meshCache.GetOrCreateMealMeshRef(this, this.Shape, GetCookingRecipe(capi.World, itemstack), GetContents(capi.World, itemstack));

            if (meshref != null)
            {
                renderinfo.ModelRef = meshref;
            }
        }
Ejemplo n.º 15
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            int meshrefId = itemstack.Attributes.GetInt("meshRefId");

            if (!itemstack.Attributes.HasAttribute("meshRefId"))
            {
                meshrefId = ++nextMeshRefId;
            }

            CachedMeshRef cmr = ObjectCacheUtil.GetOrCreate(capi, "" + meshrefId, () =>
            {
                int textureid;
                byte[,,] voxels = GetVoxels(itemstack);
                MeshData mesh   = GenMesh(capi, itemstack, voxels, out textureid);

                return(new CachedMeshRef()
                {
                    meshref = capi.Render.UploadMesh(mesh),
                    TextureId = textureid
                });
            });

            renderinfo.ModelRef  = cmr.meshref;
            renderinfo.TextureId = cmr.TextureId;

            itemstack.Attributes.SetInt("meshRefId", meshrefId);

            base.OnBeforeRender(capi, itemstack, target, ref renderinfo);
        }
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            if (itemstack.Collectible.Variant["type"] == "cutting")
            {
                curTreeType = itemstack.Attributes.GetString("type");

                var dict = ObjectCacheUtil.GetOrCreate(capi, "cuttingMeshRefs", () => new Dictionary <string, MeshRef>());

                if (!dict.TryGetValue(curTreeType, out var meshref))
                {
                    curTessShape = capi.TesselatorManager.GetCachedShape(this.Shape.Base);
                    capi.Tesselator.TesselateShape("fruittreecutting", curTessShape, out var meshdata, this);
                    dict[curTreeType] = renderinfo.ModelRef = capi.Render.UploadMesh(meshdata);
                }
                else
                {
                    renderinfo.ModelRef = meshref;
                }
            }

            base.OnBeforeRender(capi, itemstack, target, ref renderinfo);
        }
Ejemplo n.º 17
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            Dictionary <int, MeshRef> meshrefs;

            object obj;

            if (capi.ObjectCache.TryGetValue("barrelMeshRefs", out obj))
            {
                meshrefs = obj as Dictionary <int, MeshRef>;
            }
            else
            {
                capi.ObjectCache["barrelMeshRefs"] = meshrefs = new Dictionary <int, MeshRef>();
            }

            ItemStack[] contentStacks = GetContents(capi.World, itemstack);
            if (contentStacks == null || contentStacks.Length == 0)
            {
                return;
            }

            bool issealed = itemstack.Attributes.GetBool("sealed");

            int hashcode = GetBarrelHashCode(contentStacks[0], contentStacks.Length > 1 ? contentStacks[1] : null);

            MeshRef meshRef;

            if (!meshrefs.TryGetValue(hashcode, out meshRef))
            {
                MeshData meshdata = GenMesh(contentStacks[0], contentStacks.Length > 1 ? contentStacks[1] : null, issealed);
                meshrefs[hashcode] = meshRef = capi.Render.UploadMesh(meshdata);
            }

            renderinfo.ModelRef = meshRef;
        }
Ejemplo n.º 18
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            JsonObject attrObj = itemstack.Collectible.Attributes;

            if (attrObj?["wearableAttachment"].Exists != true)
            {
                return;
            }

            Dictionary <string, MeshRef> armorMeshrefs = ObjectCacheUtil.GetOrCreate(capi, "armorMeshRefs", () => new Dictionary <string, MeshRef>());
            string key = "armorModelRef-" + itemstack.Collectible.Code.ToString();

            if (!armorMeshrefs.TryGetValue(key, out renderinfo.ModelRef))
            {
                ITexPositionSource texSource = capi.Tesselator.GetTextureSource(itemstack.Item);
                var mesh = genMesh(capi, itemstack, texSource);
                renderinfo.ModelRef = armorMeshrefs[key] = mesh == null ? renderinfo.ModelRef : capi.Render.UploadMesh(mesh);
            }
        }
Ejemplo n.º 19
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            Dictionary <int, MeshRef> meshrefs;

            object obj;

            if (capi.ObjectCache.TryGetValue("cauldMeshRefs", out obj))
            {
                meshrefs = obj as Dictionary <int, MeshRef>;
            }
            else
            {
                capi.ObjectCache["cauldMeshRefs"] = meshrefs = new Dictionary <int, MeshRef>();
            }

            ItemStack[] contentStacks = GetContents(capi.World, itemstack);
            if (contentStacks == null || contentStacks.Length == 0)
            {
                return;
            }

            int hashcode = GetCauldHashCode(contentStacks[5], contentStacks[6]);

            MeshRef meshRef = null;

            if (!meshrefs.TryGetValue(hashcode, out meshRef))
            {
                MeshData meshdata = GenMesh(contentStacks[5], contentStacks[6]);
                meshrefs[hashcode] = meshRef = capi.Render.UploadMesh(meshdata);
            }

            renderinfo.ModelRef = meshRef;
        }
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            Dictionary <string, MeshRef> meshrefs = new Dictionary <string, MeshRef>();

            string key = "genericTypedContainerMeshRefs" + FirstCodePart() + SubtypeInventory;

            meshrefs = ObjectCacheUtil.GetOrCreate(capi, key, () =>
            {
                Dictionary <string, MeshData> meshes = GenGuiMeshes(capi);

                foreach (var val in meshes)
                {
                    val.Value.Rgba2   = null;
                    meshrefs[val.Key] = capi.Render.UploadMesh(val.Value);
                }

                return(meshrefs);
            });


            string type = itemstack.Attributes.GetString("type", defaultType);

            if (!meshrefs.TryGetValue(type, out renderinfo.ModelRef))
            {
                MeshData mesh = GenGuiMesh(capi, type);
                meshrefs[type] = renderinfo.ModelRef = capi.Render.UploadMesh(mesh);
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Called when the collectible is rendered in hands, inventory or on the ground
 /// </summary>
 /// <param name="capi"></param>
 /// <param name="itemstack"></param>
 /// <param name="target"></param>
 /// <param name="renderinfo"></param>
 public virtual void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
 {
 }
Ejemplo n.º 22
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            ChiselBlockModelCache cache = capi.ModLoader.GetModSystem <ChiselBlockModelCache>();

            renderinfo.ModelRef = cache.GetOrCreateMeshRef(itemstack);
        }
Ejemplo n.º 23
0
 public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
 {
     base.OnBeforeRender(capi, itemstack, target, ref renderinfo);
     if (itemstack.Attributes.GetOrAddTreeAttribute("toolparts").Count > 0)
     {
         MeshRef meshRef = MeshManager.GetMesh(api.World as ClientMain, itemstack);
         System.Console.WriteLine("MeshRef exists: {0}", meshRef != null);
         if (meshRef != null)
         {
             renderinfo.ModelRef = meshRef;
         }
     }
 }
Ejemplo n.º 24
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            MeshRef meshref = meshCache.GetOrCreateMealInContainerMeshRef(this, GetCookingRecipe(capi.World, itemstack), GetNonEmptyContents(capi.World, itemstack));

            if (meshref != null)
            {
                renderinfo.ModelRef = meshref;
            }
        }
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            Dictionary <string, MeshRef> meshrefs = new Dictionary <string, MeshRef>();

            object obj;

            if (capi.ObjectCache.TryGetValue("genericTypedContainerMeshRefs" + FirstCodePart(), out obj))
            {
                meshrefs = obj as Dictionary <string, MeshRef>;
            }
            else
            {
                Dictionary <string, MeshData> meshes = GenGuiMeshes(capi);

                foreach (var val in meshes)
                {
                    meshrefs[val.Key] = capi.Render.UploadMesh(val.Value);
                }

                capi.ObjectCache["genericTypedContainerMeshRefs" + FirstCodePart()] = meshrefs;
            }

            string type = itemstack.Attributes.GetString("type", defaultType);

            meshrefs.TryGetValue(type, out renderinfo.ModelRef);
        }
Ejemplo n.º 26
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            if (target == EnumItemRenderTarget.HandFp)
            {
                bool sneak = capi.World.Player.Entity.Controls.Sneak;

                curOffY += ((sneak ? 0.4f : offY) - curOffY) * renderinfo.dt * 8;

                renderinfo.Transform.Translation.X = curOffY;
                renderinfo.Transform.Translation.Y = curOffY * 1.2f;
                renderinfo.Transform.Translation.Z = curOffY * 1.2f;
            }

            base.OnBeforeRender(capi, itemstack, target, ref renderinfo);
        }
Ejemplo n.º 27
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            string blockMaterialCode = GetBlockMaterialCode(itemstack);

            if (blockMaterialCode == null)
            {
                return;
            }

            string key = "pan-filled-" + blockMaterialCode;

            renderinfo.ModelRef = ObjectCacheUtil.GetOrCreate <MeshRef>(capi, key, () =>
            {
                AssetLocation shapeloc = new AssetLocation("shapes/block/wood/pan/filled.json");
                Shape shape            = capi.Assets.TryGet(shapeloc).ToObject <Shape>();
                MeshData meshdata;

                Block block      = capi.World.GetBlock(new AssetLocation(blockMaterialCode));
                AtlasSize        = capi.BlockTextureAtlas.Size;
                matTexPosition   = capi.BlockTextureAtlas.GetPosition(block, "up");
                ownTextureSource = capi.Tesselator.GetTexSource(this);

                capi.Tesselator.TesselateShape("filledpan", shape, out meshdata, this);

                return(capi.Render.UploadMesh(meshdata));
            });
        }
Ejemplo n.º 28
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            EnumSlabPlaceMode mode = (EnumSlabPlaceMode)itemstack.Attributes.GetInt("slabPlaceMode", 0);

            if (mode == EnumSlabPlaceMode.Vertical)
            {
                renderinfo.Transform            = renderinfo.Transform.Clone();
                renderinfo.Transform.Rotation.X = -80;
                renderinfo.Transform.Rotation.Y = 0;
                renderinfo.Transform.Rotation.Z = -22.5f;
            }
            if (mode == EnumSlabPlaceMode.Horizontal)
            {
                renderinfo.Transform            = renderinfo.Transform.Clone();
                renderinfo.Transform.Rotation.X = 5;
            }

            base.OnBeforeRender(capi, itemstack, target, ref renderinfo);
        }
Ejemplo n.º 29
0
        public override void OnBeforeRender(ICoreClientAPI capi, ItemStack itemstack, EnumItemRenderTarget target, ref ItemRenderInfo renderinfo)
        {
            string cacheKey = "crateMeshRefs" + FirstCodePart() + SubtypeInventory;
            var    meshrefs = ObjectCacheUtil.GetOrCreate(capi, cacheKey, () => new Dictionary <string, MeshRef>());

            string type     = itemstack.Attributes.GetString("type", Props.DefaultType);
            string label    = itemstack.Attributes.GetString("label");
            string lidState = itemstack.Attributes.GetString("lidState", "closed");

            string key = type + "-" + label + "-" + lidState;

            if (!meshrefs.TryGetValue(key, out renderinfo.ModelRef))
            {
                CompositeShape cshape = Props[type].Shape;
                var            rot    = ShapeInventory == null ? null : new Vec3f(ShapeInventory.rotateX, ShapeInventory.rotateY, ShapeInventory.rotateZ);

                var contentStacks = GetNonEmptyContents(capi.World, itemstack);
                var contentStack  = contentStacks == null || contentStacks.Length == 0 ? null : contentStacks[0];

                var mesh = GenMesh(capi, contentStack, type, label, lidState, cshape, rot);
                meshrefs[key] = renderinfo.ModelRef = capi.Render.UploadMesh(mesh);
            }
        }