示例#1
0
        public override void OnTick(Level level)
        {
            if (Inventory == null)
            {
                return;
            }

            var furnace = level.GetBlock(Coordinates) as BlastFurnaceBase;

            if (furnace == null)
            {
                return;
            }

            if (!(furnace is LitBlastFurnace))
            {
                Item fuel       = GetFuel();
                Item ingredient = GetIngredient();
                Item smelt      = ingredient.GetSmelt();
                // To light a furnace you need both fuel and proper ingredient.
                if (fuel.Count > 0 && fuel.FuelEfficiency > 0 && smelt != null)
                {
                    var litFurnace = new LitBlastFurnace
                    {
                        Coordinates = furnace.Coordinates,
                    };
                    litFurnace.SetState(furnace.GetState().States);
                    level.SetBlock(litFurnace);
                    furnace = litFurnace;

                    BurnTime       = GetFuelEfficiency(fuel);
                    FuelEfficiency = BurnTime;
                    CookTime       = 0;
                    Inventory.DecreaseSlot(1);
                }
            }

            if (furnace is LitBlastFurnace)
            {
                if (BurnTime > 0)
                {
                    BurnTime--;
                    BurnTick = (short)Math.Ceiling((double)BurnTime / FuelEfficiency * 200d);

                    Item ingredient = GetIngredient();
                    Item smelt      = ingredient.GetSmelt();
                    if (smelt != null)
                    {
                        CookTime++;
                        if (CookTime >= 200)
                        {
                            Inventory.DecreaseSlot(0);
                            Inventory.IncreaseSlot(2, smelt.Id, smelt.Metadata);

                            CookTime = 0;
                        }
                    }
                    else
                    {
                        CookTime = 0;
                    }
                }

                if (BurnTime <= 0)
                {
                    var  fuel       = GetFuel();
                    Item ingredient = GetIngredient();
                    Item smelt      = ingredient.GetSmelt();
                    if (fuel.Count > 0 && fuel.FuelEfficiency > 0 && smelt != null)
                    {
                        Inventory.DecreaseSlot(1);

                        CookTime       = 0;
                        BurnTime       = GetFuelEfficiency(fuel);
                        FuelEfficiency = BurnTime;
                        BurnTick       = (short)Math.Ceiling((double)BurnTime / FuelEfficiency * 200d);
                    }
                    else
                    {
                        // No more fule or nothin more to smelt.
                        var unlitFurnace = new BlastFurnace
                        {
                            Coordinates = furnace.Coordinates,
                        };
                        unlitFurnace.SetState(furnace.GetState().States);
                        level.SetBlock(unlitFurnace);

                        FuelEfficiency = 0;
                        BurnTick       = 0;
                        BurnTime       = 0;
                        CookTime       = 0;
                    }
                }
            }

            foreach (var observer in Inventory.Observers)
            {
                var cookTimeSetData = McpeContainerSetData.CreateObject();
                cookTimeSetData.windowId = Inventory.WindowsId;
                cookTimeSetData.property = 0;
                cookTimeSetData.value    = CookTime;
                observer.SendPacket(cookTimeSetData);

                var burnTimeSetData = McpeContainerSetData.CreateObject();
                burnTimeSetData.windowId = Inventory.WindowsId;
                burnTimeSetData.property = 1;
                burnTimeSetData.value    = BurnTick;
                observer.SendPacket(burnTimeSetData);
            }
        }
示例#2
0
        private List <BlastFurnace> GetDefaultFurnances()
        {
            var f1 = new BlastFurnace()
            {
                FurnanceId                     = 0,
                GasExpenseBasePeriod           = 15000,
                MinGasExpense                  = 10000,
                MaxGasExpense                  = 20000,
                CoxExpenseBasePeriod           = 64.25,
                CoxReplacementEquivalent       = 0.59,
                IronPerformance                = 146.4,
                TheoreticTemperatureBasePeriod = 1938,
                MinTemperature                 = 1900,
                MaxTemperature                 = 2100,
                GasExpenseToReadjust           = 10000,
                DeltaIronPerformanceGasChanged = -0.0007295,
                DeltaIronPerformanceCoxChanged = -0.00297,
                DeltaTemperatureGasChanged     = -0.0265
            };

            var f2 = new BlastFurnace()
            {
                FurnanceId                     = 1,
                GasExpenseBasePeriod           = 17000,
                MinGasExpense                  = 10000,
                MaxGasExpense                  = 20000,
                CoxExpenseBasePeriod           = 66.76,
                CoxReplacementEquivalent       = 0.53,
                IronPerformance                = 136.4,
                TheoreticTemperatureBasePeriod = 1959,
                MinTemperature                 = 1900,
                MaxTemperature                 = 2100,
                GasExpenseToReadjust           = 13039.3258426966,
                DeltaIronPerformanceGasChanged = -0.0006695,
                DeltaIronPerformanceCoxChanged = -0.00297,
                DeltaTemperatureGasChanged     = -0.0356
            };

            var f3 = new BlastFurnace()
            {
                FurnanceId                     = 2,
                GasExpenseBasePeriod           = 11000,
                MinGasExpense                  = 10000,
                MaxGasExpense                  = 20000,
                CoxExpenseBasePeriod           = 56.08,
                CoxReplacementEquivalent       = 0.85,
                IronPerformance                = 134.3,
                TheoreticTemperatureBasePeriod = 2091,
                MinTemperature                 = 1900,
                MaxTemperature                 = 2100,
                GasExpenseToReadjust           = 16026.3157894737,
                DeltaIronPerformanceGasChanged = 0,
                DeltaIronPerformanceCoxChanged = -0.002928,
                DeltaTemperatureGasChanged     = -0.038
            };

            var f4 = new BlastFurnace()
            {
                FurnanceId                     = 3,
                GasExpenseBasePeriod           = 13000,
                MinGasExpense                  = 10000,
                MaxGasExpense                  = 20000,
                CoxExpenseBasePeriod           = 49.78,
                CoxReplacementEquivalent       = 0.59,
                IronPerformance                = 122.3,
                TheoreticTemperatureBasePeriod = 1990,
                MinTemperature                 = 1900,
                MaxTemperature                 = 2100,
                GasExpenseToReadjust           = 125,
                DeltaIronPerformanceGasChanged = -0.00072373,
                DeltaIronPerformanceCoxChanged = -0.002897,
                DeltaTemperatureGasChanged     = -0.0334
            };

            var f5 = new BlastFurnace()
            {
                FurnanceId                     = 4,
                GasExpenseBasePeriod           = 12000,
                MinGasExpense                  = 10000,
                MaxGasExpense                  = 20000,
                CoxExpenseBasePeriod           = 62.92,
                CoxReplacementEquivalent       = 0.75,
                IronPerformance                = 138.2,
                TheoreticTemperatureBasePeriod = 1997,
                MinTemperature                 = 1900,
                MaxTemperature                 = 2100,
                GasExpenseToReadjust           = 2000,
                DeltaIronPerformanceGasChanged = -0.0007724,
                DeltaIronPerformanceCoxChanged = -0.00297,
                DeltaTemperatureGasChanged     = -0.02984
            };

            var f6 = new BlastFurnace()
            {
                FurnanceId                     = 5,
                GasExpenseBasePeriod           = 15000,
                MinGasExpense                  = 10000,
                MaxGasExpense                  = 20000,
                CoxExpenseBasePeriod           = 60.02,
                CoxReplacementEquivalent       = 0.79,
                IronPerformance                = 138.8,
                TheoreticTemperatureBasePeriod = 1925,
                MinTemperature                 = 1900,
                MaxTemperature                 = 2100,
                GasExpenseToReadjust           = 8000,
                DeltaIronPerformanceGasChanged = -0.0006872,
                DeltaIronPerformanceCoxChanged = -0.00297,
                DeltaTemperatureGasChanged     = -0.0314
            };

            var f7 = new BlastFurnace()
            {
                FurnanceId                     = 6,
                GasExpenseBasePeriod           = 17000,
                MinGasExpense                  = 10000,
                MaxGasExpense                  = 20000,
                CoxExpenseBasePeriod           = 81.68,
                CoxReplacementEquivalent       = 0.87,
                IronPerformance                = 191.4,
                TheoreticTemperatureBasePeriod = 1974,
                MinTemperature                 = 1900,
                MaxTemperature                 = 2100,
                GasExpenseToReadjust           = 20000,
                DeltaIronPerformanceGasChanged = -0.0007284,
                DeltaIronPerformanceCoxChanged = -0.003316,
                DeltaTemperatureGasChanged     = -0.0223
            };

            var f8 = new BlastFurnace()
            {
                FurnanceId                     = 7,
                GasExpenseBasePeriod           = 14000,
                MinGasExpense                  = 10000,
                MaxGasExpense                  = 20000,
                CoxExpenseBasePeriod           = 69.7,
                CoxReplacementEquivalent       = 0.77,
                IronPerformance                = 151.6,
                TheoreticTemperatureBasePeriod = 1982,
                MinTemperature                 = 1900,
                MaxTemperature                 = 2100,
                GasExpenseToReadjust           = 15000,
                DeltaIronPerformanceGasChanged = -0.0007305,
                DeltaIronPerformanceCoxChanged = -0.00356,
                DeltaTemperatureGasChanged     = -0.0244
            };

            return(new List <BlastFurnace>()
            {
                f1, f2, f4, f3, f5, f6, f7, f8
            });
        }