Example #1
0
        /// <summary> Resets the properties for the given block to their defaults. </summary>
        public void ResetBlockProps(BlockID id)
        {
            BlocksLight[id]     = DefaultSet.BlocksLight(id);
            FullBright[id]      = DefaultSet.FullBright(id);
            FogColour[id]       = DefaultSet.FogColour(id);
            FogDensity[id]      = DefaultSet.FogDensity(id);
            Collide[id]         = DefaultSet.Collide(id);
            DigSounds[id]       = DefaultSet.DigSound(id);
            StepSounds[id]      = DefaultSet.StepSound(id);
            SpeedMultiplier[id] = 1;
            Name[id]            = DefaultName(id);
            Tinted[id]          = false;

            Draw[id] = DefaultSet.Draw(id);
            if (Draw[id] == DrawType.Sprite)
            {
                MinBB[id] = new Vector3(2.50f / 16f, 0, 2.50f / 16f);
                MaxBB[id] = new Vector3(13.5f / 16f, 1, 13.5f / 16f);
            }
            else
            {
                MinBB[id]   = Vector3.Zero;
                MaxBB[id]   = Vector3.One;
                MaxBB[id].Y = DefaultSet.Height(id);
                MaxBB[id].X = DefaultSet.WidthX(id);
                MaxBB[id].Z = DefaultSet.WidthZ(id);
            }

            SetBlockDraw(id, Draw[id]);
            CalcRenderBounds(id);
            LightOffset[id] = CalcLightOffset(id);

            if (id >= Block.CpeCount)
            {
#if USE16_BIT
                // give some random texture ids
                SetTex((id * 10 + (id % 7) + 20) % 80, Side.Top, id);
                SetTex((id * 8 + (id & 5) + 5) % 80, Side.Bottom, id);
                SetSide((id * 4 + (id / 4) + 4) % 80, id);
#else
                SetTex(0, Side.Top, id);
                SetTex(0, Side.Bottom, id);
                SetSide(0, id);
#endif
            }
            else
            {
                SetTex(topTex[id], Side.Top, id);
                SetTex(bottomTex[id], Side.Bottom, id);
                SetSide(sideTex[id], id);

                if (id == Block.Chest1)
                {
                    SetTex(125, Side.Back, id);
                }
                if (id == Block.Chest2)
                {
                    SetTex(125, Side.Front, id);
                }
                if (id == Block.Chest3)
                {
                    SetTex(125, Side.Right, id);
                }
                if (id == Block.Chest4)
                {
                    SetTex(125, Side.Left, id);
                }
            }
        }