예제 #1
0
 public Physics(World w, PSetting setting, int speed)
 {
     this.w = w;
     this.setting = setting;
     this.speed = speed;
     this.random = new Random();
 }
예제 #2
0
        public Server()
        {
            Log("Starting Server");
            s = this;
            consolePlayer = new ConsolePlayer(s);
            consolePlayer.SetUsername(ConsoleName);
            //Group.DefaultGroup = new DefaultGroup(); //debugging
            mainlevel = new World(0, 127, 0, "main", new Random().Next());
            World.worlds.Add(mainlevel);
            ml = new MainLoop("server");
            #region updatetimer
            ml.Queue(delegate
            {
                updateTimer.Elapsed += delegate
                {
                Player.GlobalUpdate();
                }; updateTimer.Start();
            });
            #endregion
            //TODO AI Update Timer

            //Setup();

            Log("Server Started");

            //new Creeper(new Point3(0, 0, 0), mainlevel);
        }
예제 #3
0
 public Item(Items item, World l, bool inv = false)
 {
     isInventory = inv;
     e = new Entity(this, l);
     this.id = (short)item;
     OnGround = false;
 }
예제 #4
0
 public override void Use(Player p, params string[] args)
 {
     if (args.Length == 0) { Help(p); return; }
     else if (args.Length == 1)
     {
         Random rand = new Random();
         int seed = new Random().Next();
         p.SendMessage("Creating world with seed: " + seed);
         double x = 0; double y = 127; double z = 0;
         World temp = new World(x, y, z, args[0], seed);
         //while (Chunk.GetChunk((int)x, (int)z, temp).GetBlock((int)x, (int)(y - 1), (int)z) == 0)
         //	y--;
         temp.SpawnY = y;
         World.worlds.Add(temp);
         p.SendMessage("World " + args[0] + " MADE!");
     }
     else if (args.Length == 2 || args.Length == 3)
     {
         int seed = Convert.ToInt32(args[1]);
         p.SendMessage("Creating world with seed: " + seed);
         double x = 0; double y = 127; double z = 0;
         World temp = new World(x, y, z, args[0], seed);
         if (args.Length == 3)
         {
             int limit = Convert.ToInt32(args[2]);
             if (limit > 2)
                 temp.ChunkLimit = limit;
             else { p.SendMessage("maxchunks cannot be less than 3. creating with maxchunks 3."); temp.ChunkLimit = 3; }
         }
         World.worlds.Add(temp);
         p.SendMessage("World " + args[0] + " MADE!");
     }
 }
예제 #5
0
 public ChunkLoadQueue(int x, int z, bool unload, World world)
 {
     this.x = x;
     this.z = z;
     this.unload = unload;
     this.world = world;
 }
예제 #6
0
        public Creeper(Point3 pos, World level)
        {
            mye = new Entity(this, level);
            mylevel = level;
            e.pos = pos;

            e.UpdateChunks(false, false);
        }
예제 #7
0
 public ChunkGenQueue(int x, int z, World world, bool generate = true, bool populate = true)
 {
     this.generate = generate;
     this.populate = populate;
     this.x = x;
     this.z = z;
     this.world = world;
 }
 public ContainerChest(World level, Point3 point)
 {
     this.level = level;
     this.point = point;
     items = new Item[Size];
     for (int i = 0; i < Size; i++)
         items[i] = Item.Nothing;
 }
예제 #9
0
 public Item(short item, byte count, short meta, World l)
 {
     this.item = (short)item;
     this.meta = meta;
     this.count = count;
     OnGround = false;
     e = new Entity(this, l);
 }
예제 #10
0
        public Entity(AI ai, World l)
        {
            this.ai = ai;
            id = FreeId();
            isAI = true;
            level = l;

            Entities.Add(id, this);
        }
예제 #11
0
 public Item(short item, byte count, short meta, World l, bool inv = false)
 {
     isInventory = inv;
     e = new Entity(this, l);
     this.id = (short)item;
     this.meta = meta;
     this.count = count;
     OnGround = false;
 }
예제 #12
0
 public WorldChunkManager(World world)
     : this()
 {
     GenLayer[] agenlayer = GenLayer.func_35019_a(world.seed);
     field_34907_a = agenlayer[0];
     field_34906_b = agenlayer[1];
     temperatureLayer = agenlayer[2];
     rainfallLayer = agenlayer[3];
 }
예제 #13
0
파일: Entity.cs 프로젝트: Cazzar/ForgeCraft
        public Entity(Player pl, World l)
            : this(l)
        {
            p = pl;
            isPlayer = true;

            UpdateChunks(false, false);

            Entities.Add(id, this);
        }
예제 #14
0
        public Player p; //Only set if this entity is a player, and it referances the player it is

        #endregion Fields

        #region Constructors

        public Entity(Player pl, World l)
        {
            p = pl;
            id = FreeId();
            isPlayer = true;
            level = l;

            UpdateChunks(false, false);

            Entities.Add(id, this);
        }
예제 #15
0
파일: Item.cs 프로젝트: ProLoks/ForgeCraft
 public Item(short item, byte count, short meta, World l, double[] pos, byte[] rot)
 {
     this.item = item;
     this.count = count;
     this.meta = meta;
     this.level = l;
     this.pos = pos;
     this.rot = rot;
     OnGround = true;
     e = new Entity(this, l);
     e.UpdateChunks(false, false);
 }
예제 #16
0
 public Explosion(World world, /*Entity entity,*/ double d, double d1, double d2, float f)
 {
     isFlaming = false;
     ExplosionRNG = new Random();
     destroyedBlockPositions = new HashSet<Point3>();
     worldObj = world;
     //exploder = entity; // Not needed right now
     explosionSize = f;
     explosionX = d;
     explosionY = d1;
     explosionZ = d2;
 }
예제 #17
0
        public Entity(Item i, World l)
        {
            I = i;
            id = FreeId();
            isItem = true;
            level = l;

            if (I.OnGround)
                UpdateChunks(false, false);

            Entities.Add(id, this);
        }
예제 #18
0
        public Entity(Item i, World l)
        {
            I = i;
            if (!I.isInventory) id = FreeId();
            isItem = true;
            level = l;

            if (!I.isInventory)
            {
                UpdateChunks(false, false);
                Entities.Add(id, this);
            }
        }
예제 #19
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!"); }
        }
예제 #20
0
 /// <summary>
 /// Cancel a World Event
 /// </summary>
 /// <param name="e">The event to cancel</param>
 /// <param name="w">The world</param>
 public static void CancelEvent(LevelEvent e, World w)
 {
     switch (e)
     {
         case LevelEvent.PhysicsUpdate:
             w.physics.cancelphysics = true;
             break;
         case LevelEvent.Save:
             World.cancelsave = true;
             break;
         case LevelEvent.ChunkGenerated:
             w.cancelchunk = true;
             break;
     }
 }
예제 #21
0
 public override void Use(Player p, params string[] args)
 {
     if (args.Length == 0) { Help(p); return; }
     else if (args.Length == 1)
     {
         Random rand = new Random();
         long seed = new Random().Next();
         p.SendMessage("Creating world with seed: " + seed);
         double x = rand.Next(50); double y = 64; double z = rand.Next(50);
         World temp = new World(x, y, z, args[0]);
         //while (Chunk.GetChunk((int)x, (int)z, temp).GetBlock((int)x, (int)(y - 1), (int)z) == 0)
         //	y--;
         temp.SpawnY = y;
         World.worlds.Add(temp);
         p.SendMessage("World " + args[0] + " MADE!");
     }
 }
예제 #22
0
 public static Container CreateInstance(ContainerType type, World level, Point3 point)
 {
     switch (type)
     {
         case ContainerType.Chest:
             return new ContainerChest(level, point);
         case ContainerType.Furnace:
             // TODO
             break;
         case ContainerType.Dispenser:
             // TODO
             break;
         case ContainerType.BrewingStand:
             // TODO
             break;
     }
     return null;
 }
예제 #23
0
        public virtual void generate(World world, int i, int j, byte[] abyte0)
        {
            int k = field_947_a;
            field_35530_d = world;
            rand = new java.util.Random(world.seed);
            long l = rand.nextLong();
            long l1 = rand.nextLong();
            for(int i1 = i - k; i1 <= i + k; i1++)
            {
                for(int j1 = j - k; j1 <= j + k; j1++)
                {
                    long l2 = (long)i1 * l;
                    long l3 = (long)j1 * l1;
                    rand = new java.util.Random(l2 ^ l3 ^ world.seed);
                    recursiveGenerate(world, i1, j1, i, j, abyte0);
                }

            }
        }
예제 #24
0
        public void Normal(World w, int x, int y, int z, byte type)
        {
            byte dist, tile;
            byte height = (byte)(rand.nextInt(4) + 3);
            byte top = (byte)(height - 2);
            short xx, yy, zz;
            int xxx, yyy, zzz;
            for (yy = 0; yy <= height; yy++)
            {
                yyy = y + yy;
                tile = tile = w.GetBlock(x, yyy, z);
                if (tile == (byte)Blocks.Air || (yyy == y && tile == (byte)Blocks.Sapling))
                    w.BlockChange(x, yyy, z, (byte)Blocks.Wood, type);
            }

            for (yy = top; yy <= height + 1; yy++)
            {
                dist = yy > height - 1 ? (byte)1 : (byte)2;
                for (xx = (short)-dist; xx <= dist; xx++)
                {
                    for (zz = (short)-dist; zz <= dist; zz++)
                    {
                        xxx = x + xx;
                        yyy = y + yy;
                        zzz = z + zz;
                        tile = w.GetBlock(xxx, yyy, zzz);
                        //Server.s.Log(String.Format("{0} {1} {2}", xxx, yyy, zzz));

                        if ((xxx == x && zzz == z && yy <= height) || tile != (byte)Blocks.Air)
                            continue;

                        if (Math.Abs(xx) == dist && Math.Abs(zz) == dist)
                        {
                            if (yy > height) continue;
                            if (rand.nextInt(2) == 0)
                                w.BlockChange(xxx, yyy, zzz, (byte)Blocks.Leaves, type);
                        }
                        else
                            w.BlockChange(xxx, yyy, zzz, (byte)Blocks.Leaves, type);
                    }
                }
            }
        }
예제 #25
0
 public GenStandard(World w, bool flag)
 {
     worldObj = w;
     random = new java.util.Random(w.seed);
     field_35562_v = new double[256];
     caveGenerator = new GenCaves();
     //field_35559_d = new MapGenStronghold();
     //field_35560_e = new MapGenVillage();
     //field_35558_f = new MapGenMineshaft();
     field_35564_x = new GenRavine();
     //unusedIntArray32x32 = new int[32][32];
     field_35563_t = flag;
     field_705_k = new NoiseOctaves(random, 16);
     field_704_l = new NoiseOctaves(random, 16);
     field_703_m = new NoiseOctaves(random, 8);
     field_702_n = new NoiseOctaves(random, 4);
     field_715_a = new NoiseOctaves(random, 10);
     field_714_b = new NoiseOctaves(random, 16);
     mobSpawnerNoise = new NoiseOctaves(random, 8);
 }
예제 #26
0
        public Server()
        {
            Log("Starting Server");
            s = this;
            mainlevel = new World(0, 127, 0, "main");
            World.worlds.Add(mainlevel);
            ml = new MainLoop("server");
            #region updatetimer
            ml.Queue(delegate
            {
                updateTimer.Elapsed += delegate
                {
                    Player.GlobalUpdate();
                }; updateTimer.Start();
            });
            #endregion

            Setup();

            Log("Server Started");
        }
예제 #27
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 Level)
        {
            Server.Log("Window Creating.");

            id = FreeId();
            type = (byte)Type;
            pos = Pos;
            level = Level;

            switch (Type)
            {
                case WindowType.Chest:
                    name = "Chest"; //We change this to "Large Chest" Later if it needs it :3
                    items = new Item[27];
                    break;
                case WindowType.Dispenser:
                    name = "Workbench";
                    items = new Item[9];
                    break;
                case WindowType.Furnace:
                    name = "Furnace";
                    items = new Item[3];
                    break;
                case WindowType.Workbench:
                    name = "Dispenser";
                    items = new Item[9];
                    break;
                case WindowType.EnchantmentTable:
                    name = "Enchant";
                    items = new Item[1];
                    break;
                case WindowType.BrewingStand:
                    name = "Brewing Stand";
                    items = new Item[4];
                    break;
            }
            Server.Log("Window adding.");
            level.windows.Add(pos, this);
            Server.Log("Window done.");
        }
예제 #28
0
 public static void GlobalUpdateSign(World wld, int x, short y, int z, params string[] text)
 {
     Player.players.ForEach(delegate(Player pl)
         {
             if (pl.MapLoaded && pl.level == wld && pl.VisibleChunks.Contains(Chunk.GetChunk(x >> 4, z >> 4, pl.level).point))
                 pl.SendUpdateSign(x, y, z, text);
         });
 }
예제 #29
0
 public static void GlobalSoundEffect(Point3 a, int type, World wld, Player exclude = null)
 {
     GlobalSoundEffect(a, type, 0, wld, exclude);
 }
예제 #30
0
 public static void GlobalSoundEffect(Point3 a, int type, int data, World wld, Player exclude = null)
 {
     GlobalSoundEffect((int)a.x, (byte)a.y, (int)a.z, type, data, wld, exclude);
 }
예제 #31
0
 public ContainerChest(World level, Point3 point, Item[] items)
     : base(level)
 {
     this.point = point;
     this.items = items;
 }