internal void SetChildRenderer(ItemStack contentStack, IInCampFireRenderer renderer) { this.ContentStack = contentStack; meshref?.Dispose(); meshref = null; contentStackRenderer = renderer; }
void UpdateRenderer() { if (renderer == null) { return; } ItemStack contentStack = inputStack == null ? outputStack : inputStack; bool useOldRenderer = renderer.ContentStack != null && renderer.contentStackRenderer != null && contentStack?.Collectible is IInFirepitRendererSupplier && renderer.ContentStack.Equals(Api.World, contentStack, GlobalConstants.IgnoredStackAttributes) ; if (useOldRenderer) { return; // Otherwise the cooking sounds restarts all the time } renderer.contentStackRenderer?.Dispose(); renderer.contentStackRenderer = null; if (contentStack?.Collectible is IInCampFireRendererSupplier) { IInCampFireRenderer childrenderer = (contentStack?.Collectible as IInCampFireRendererSupplier).GetRendererWhenInCampfire(contentStack, this, contentStack == outputStack); if (childrenderer != null) { renderer.SetChildRenderer(contentStack, childrenderer); return; } } InCampFireProps props = GetRenderProps(contentStack); if (contentStack?.Collectible != null && !(contentStack?.Collectible is IInCampFireMeshSupplier) && props != null) { renderer.SetContents(contentStack, props.Transform); } else { renderer.SetContents(null, null); } }
public void SetContents(ItemStack newContentStack, ModelTransform transform) { contentStackRenderer?.Dispose(); contentStackRenderer = null; this.transform = transform; if (transform == null) { this.transform = defaultTransform; } this.transform.EnsureDefaultValues(); meshref?.Dispose(); meshref = null; if (newContentStack == null || newContentStack.Class == EnumItemClass.Block) { this.ContentStack = null; return; } MeshData ingredientMesh; if (newContentStack.Class == EnumItemClass.Item) { api.Tesselator.TesselateItem(newContentStack.Item, out ingredientMesh); textureId = api.ItemTextureAtlas.Positions[newContentStack.Item.FirstTexture.Baked.TextureSubId].atlasTextureId; } else { api.Tesselator.TesselateBlock(newContentStack.Block, out ingredientMesh); textureId = api.ItemTextureAtlas.Positions[newContentStack.Block.Textures.FirstOrDefault().Value.Baked.TextureSubId].atlasTextureId; } meshref = api.Render.UploadMesh(ingredientMesh); this.ContentStack = newContentStack; }