예제 #1
0
        public Item[] items;         //Hold all the items this window has inside it.
        public Windows(WindowType type, Point3 pos, World world, Player p)
        {
            try
            {
                id        = FreeId();
                this.type = (byte)type;
                this.p    = p;
                crafting  = new Crafting(p, 9);
                switch (Type)
                {
                case WindowType.Chest:
                    name      = "Chest"; //We change this to "Large Chest" Later if it needs it :3
                    container = world.GetBlockContainer(pos);
                    items     = container.Items;
                    container.AddPlayer(p);
                    break;

                case WindowType.Dispenser:
                    name = "Workbench";
                    //container = world.GetBlockContainer(pos); // We don't have a container for this yet.
                    items = new Item[9];
                    break;

                case WindowType.Furnace:
                    name = "Furnace";
                    //container = world.GetBlockContainer(pos); // We don't have a container for this yet.
                    items = new Item[3];
                    break;

                case WindowType.Workbench:
                    name  = "Dispenser";
                    items = new Item[10];
                    break;

                case WindowType.EnchantmentTable:
                    name  = "Enchant";
                    items = new Item[1];
                    break;

                case WindowType.BrewingStand:
                    name = "Brewing Stand";
                    //container = world.GetBlockContainer(pos); // We don't have a container for this yet.
                    items = new Item[4];
                    break;
                }

                if (Type == WindowType.Workbench || Type == WindowType.EnchantmentTable)
                {
                    for (int i = 0; i < InventorySize; i++)
                    {
                        items[i] = Item.Nothing;
                    }
                }
            }
            catch { Logger.Log("Error making window!"); }
        }
예제 #2
0
        byte type; //This holds type information, used in deciding which kind of window we need to send.

        #endregion Fields

        #region Constructors

        public Windows(WindowType type, Point3 pos, World world, Player p)
        {
            try
            {
                id = FreeId();
                this.type = (byte)type;
                this.p = p;

                switch (Type)
                {
                    case WindowType.Chest:
                        name = "Chest"; //We change this to "Large Chest" Later if it needs it :3
                        container = world.GetBlockContainer(pos);
                        items = container.Items;
                        container.AddPlayer(p);
                        break;
                    case WindowType.Dispenser:
                        name = "Workbench";
                        //container = world.GetBlockContainer(pos); // We don't have a container for this yet.
                        items = new Item[9];
                        break;
                    case WindowType.Furnace:
                        name = "Furnace";
                        //container = world.GetBlockContainer(pos); // We don't have a container for this yet.
                        items = new Item[3];
                        break;
                    case WindowType.Workbench:
                        name = "Dispenser";
                        items = new Item[10];
                        break;
                    case WindowType.EnchantmentTable:
                        name = "Enchant";
                        items = new Item[1];
                        break;
                    case WindowType.BrewingStand:
                        name = "Brewing Stand";
                        //container = world.GetBlockContainer(pos); // We don't have a container for this yet.
                        items = new Item[4];
                        break;
                }

                if (Type == WindowType.Workbench || Type == WindowType.EnchantmentTable)
                {
                    for (int i = 0; i < InventorySize; i++)
                        items[i] = Item.Nothing;
                }
            }
            catch { Logger.Log("Error making window!"); }
        }
예제 #3
0
        public void Update(World w, Player p)
        {
            byte      bType, bMeta;
            ushort    bExtra;
            int       xxx, zzz;
            Container c;

            for (int xx = 0; xx < Width; xx++)
            {
                for (int zz = 0; zz < Depth; zz++)
                {
                    for (int yy = 0; yy < Height; yy++)
                    {
                        xxx   = (x << 4) + xx; zzz = (z << 4) + zz;
                        bType = GetBlock(xx, yy, zz);
                        bMeta = GetMetaData(xx, yy, zz);

                        if (bType == (byte)Blocks.SignPost || bType == (byte)Blocks.SignWall)
                        {
                            p.SendUpdateSign(xxx, (short)yy, zzz, w.GetSign(xxx, yy, zzz));
                        }
                        if (bType == (byte)Blocks.Jukebox)
                        {
                            bExtra = GetExtraData(xx, yy, zz);
                            if (bExtra >= 2256 && bExtra <= 2266)
                            {
                                p.SendSoundEffect(xxx, (byte)yy, zzz, 1005, bExtra);
                            }
                        }
                        if (bType == (byte)Blocks.Chest)
                        {
                            p.SendBlockChange(xxx, (byte)yy, zzz, bType, bMeta);
                            c = w.GetBlockContainer(xxx, yy, zzz);
                            if (c != null)
                            {
                                c.UpdateState();
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
파일: Chunk.cs 프로젝트: Cazzar/ForgeCraft
        public void Update(World w, Player p)
        {
            byte bType, bMeta;
            ushort bExtra;
            int xxx, zzz;
            Container c;
            for (int xx = 0; xx < Width; xx++)
                for (int zz = 0; zz < Depth; zz++)
                    for (int yy = 0; yy < Height; yy++)
                    {
                        xxx = (x << 4) + xx; zzz = (z << 4) + zz;
                        bType = GetBlock(xx, yy, zz);
                        bMeta = GetMetaData(xx, yy, zz);

                        if (bType == (byte)Blocks.SignPost || bType == (byte)Blocks.SignWall)
                            p.SendUpdateSign(xxx, (short)yy, zzz, w.GetSign(xxx, yy, zzz));
                        if (bType == (byte)Blocks.Jukebox)
                        {
                            bExtra = GetExtraData(xx, yy, zz);
                            if (bExtra >= 2256 && bExtra <= 2266)
                                p.SendSoundEffect(xxx, (byte)yy, zzz, 1005, bExtra);
                        }
                        if (bType == (byte)Blocks.Chest)
                        {
                            p.SendBlockChange(xxx, (byte)yy, zzz, bType, bMeta);
                            c = w.GetBlockContainer(xxx, yy, zzz);
                            if (c != null) c.UpdateState();
                        }
                    }
        }