Beispiel #1
0
        public virtual void Spawn(Level level)
        {
            McpeLevelEvent levelEvent = McpeLevelEvent.CreateObject();
            levelEvent.eventId = Id;
            levelEvent.data = Pitch;
            levelEvent.x = (float) Position.X;
            levelEvent.y = (float) Position.Y;
            levelEvent.z = (float) Position.Z;

            level.RelayBroadcast(levelEvent);
        }
Beispiel #2
0
        public override void OnTick(Level level)
        {
            if (Inventory == null) return;

            Furnace furnace = level.GetBlock(Coordinates) as Furnace;
            if (furnace == null) return;

            if (!(furnace is LitFurnace))
            {
                if (GetFuel().Id != 0)
                {
                    LitFurnace litFurnace = new LitFurnace
                    {
                        Coordinates = furnace.Coordinates,
                        Metadata = furnace.Metadata
                    };

                    level.SetBlock(litFurnace);
                    furnace = litFurnace;

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

            if (!(furnace is LitFurnace)) return;

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

                if (GetIngredient().Id != 0)
                {
                    CookTime++;
                    if (CookTime >= 200)
                    {
                        Item result = GetResult(GetIngredient());
                        if (result != null)
                        {
                            Inventory.DecreaseSlot(0);
                            Inventory.IncreaseSlot(2, result.Id, result.Metadata);
                        }

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

            if (BurnTime <= 0)
            {
                if (!Inventory.DecreaseSlot(1))
                {
                    //CookTime = 0;
                    BurnTime = GetFuelEfficiency(GetFuel());
                    FuelEfficiency = BurnTime;
                    BurnTick = (short) Math.Ceiling((double) BurnTime/FuelEfficiency*200d);
                }
                else
                {
                    // No more fule
                    Furnace unlitFurnace = new Furnace
                    {
                        Coordinates = furnace.Coordinates,
                        Metadata = furnace.Metadata
                    };

                    level.SetBlock(unlitFurnace);
                    FuelEfficiency = 0;
                    BurnTick = 0;
                    BurnTime = 0;
                    CookTime = 0;
                }
            }

            level.RelayBroadcast(new McpeContainerSetData
            {
                windowId = Inventory.WindowsId,
                property = 0,
                value = CookTime
            });

            level.RelayBroadcast(new McpeContainerSetData
            {
                windowId = Inventory.WindowsId,
                property = 1,
                value = BurnTick
            });
        }
Beispiel #3
0
        private void GenerateParticles(Random random, Level level, PlayerLocation point, float yoffset, Vector3 multiplier, double d)
        {
            float vx = (float) random.NextDouble();
            vx *= random.Next(2) == 0 ? 1 : -1;
            vx *= (float) multiplier.X;

            float vy = (float) random.NextDouble();
            //vy *= random.Next(2) == 0 ? 1 : -1;
            vy *= (float) multiplier.Y;

            float vz = (float) random.NextDouble();
            vz *= random.Next(2) == 0 ? 1 : -1;
            vz *= (float) multiplier.Z;

            McpeLevelEvent mobParticles = McpeLevelEvent.CreateObject();
            mobParticles.eventId = (short) (0x4000 | GetParticle(random.Next(0, m < 1 ? 2 : 5)));
            mobParticles.x = point.X + vx;
            mobParticles.y = (point.Y - 2) + yoffset + vy;
            mobParticles.z = point.Z + vz;
            level.RelayBroadcast(mobParticles);
        }