Esempio n. 1
0
 InKilnProps GetRenderProps(ItemStack contentStack)
 {
     if (contentStack?.ItemAttributes?.KeyExists("inKilnProps") == true)
     {
         InKilnProps props = contentStack.ItemAttributes["inKilnProps"].AsObject <InKilnProps>();
         props.Transform.EnsureDefaultValues();
         return(props);
     }
     return(null);
 }
Esempio n. 2
0
        private MeshData getContentMesh(ItemStack contentStack, ITesselatorAPI tesselator)
        {
            CurrentModel = EnumKilnModel.Normal;

            if (contentStack == null)
            {
                return(null);
            }

            if (contentStack.Collectible is IInKilnMeshSupplier)
            {
                EnumKilnModel model = EnumKilnModel.Normal;
                MeshData      mesh  = (contentStack.Collectible as IInKilnMeshSupplier).GetMeshWhenInKiln(contentStack, Api.World, Pos, ref model);
                this.CurrentModel = model;

                if (mesh != null)
                {
                    return(mesh);
                }
            }

            if (contentStack.Collectible is IInKilnRendererSupplier)
            {
                EnumKilnModel model = (contentStack.Collectible as IInKilnRendererSupplier).GetDesiredKilnModel(contentStack, this, contentStack == outputStack);
                this.CurrentModel = model;
                return(null);
            }


            InKilnProps renderProps = GetRenderProps(contentStack);

            if (renderProps != null)
            {
                this.CurrentModel = renderProps.UseKilnModel;

                if (contentStack.Class != EnumItemClass.Item)
                {
                    MeshData ObjMesh;
                    tesselator.TesselateBlock(contentStack.Block, out ObjMesh);

                    ObjMesh.ModelTransform(renderProps.Transform);

                    return(ObjMesh);
                }

                return(null);
            }
            return(null);
        }
Esempio n. 3
0
        void UpdateRenderer()
        {
            if (renderer == null)
            {
                return;
            }

            ItemStack contentStack = inputStack == null ? outputStack : inputStack;

            bool useOldRenderer =
                renderer.ContentStack != null &&
                renderer.contentStackRenderer != null &&
                contentStack?.Collectible is IInKilnRendererSupplier &&
                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 IInKilnRendererSupplier)
            {
                IInKilnRenderer childrenderer = (contentStack?.Collectible as IInKilnRendererSupplier).GetRendererWhenInKiln(contentStack, this, contentStack == outputStack);
                if (childrenderer != null)
                {
                    renderer.SetChildRenderer(contentStack, childrenderer);
                    return;
                }
            }

            InKilnProps props = GetRenderProps(contentStack);

            if (contentStack?.Collectible != null && !(contentStack?.Collectible is IInKilnMeshSupplier) && props != null)
            {
                renderer.SetContents(contentStack, props.Transform);
            }
            else
            {
                renderer.SetContents(null, null);
            }
        }