Beispiel #1
0
        protected void SetDoubleSlab(Level world, BlockCoordinates coordinates)
        {
            Block slab = BlockFactory.GetBlockById(_doubleSlabId);

            slab.Coordinates = coordinates;
            slab.SetState(GetState().States);
            world.SetBlock(slab);
        }
Beispiel #2
0
        private void SetDoubleSlab(Level world, BlockCoordinates coordinates)
        {
            Block slab = BlockFactory.GetBlockById((byte)(Id - 1));

            slab.Coordinates = coordinates;
            slab.Metadata    = (byte)Metadata;
            world.SetBlock(slab);
        }
Beispiel #3
0
        private void SetToFlowing(Level world)
        {
            Block flowingBlock = BlockFactory.GetBlockById((byte)(Id - 1));

            flowingBlock.Metadata    = Metadata;
            flowingBlock.Coordinates = Coordinates;
            world.SetBlock(flowingBlock, applyPhysics: false);
            world.ScheduleBlockTick(flowingBlock, 5);
        }
Beispiel #4
0
        private void SetToFlowing(Level world)
        {
            var flowingBlock = (Flowing)BlockFactory.GetBlockById((byte)(Id - 1));

            flowingBlock.LiquidDepth = LiquidDepth;
            flowingBlock.Coordinates = Coordinates;
            world.SetBlock(flowingBlock, applyPhysics: false);
            world.ScheduleBlockTick(flowingBlock, 5);
        }
Beispiel #5
0
 public override void DoPhysics(Level level)
 {
     if (level.GetSubtractedLight(Coordinates + BlockCoordinates.Up) < 4)
     {
         Block dirt = BlockFactory.GetBlockById(3);
         dirt.Coordinates = Coordinates;
         level.SetBlock(dirt, true, false, false);
     }
 }
Beispiel #6
0
        private void SetToStill(Level world, int x, int y, int z)
        {
            byte meta = world.GetBlock(x, y, z).Metadata;

            Block stillBlock = BlockFactory.GetBlockById((byte)(Id + 1));

            stillBlock.Metadata    = meta;
            stillBlock.Coordinates = new BlockCoordinates(x, y, z);
            world.SetBlock(stillBlock, applyPhysics: false);
        }
Beispiel #7
0
        public override void DoPhysics(Level level)
        {
            if (level.GameMode == GameMode.Creative)
            {
                return;
            }

            if (level.GetSubtractedLight(Coordinates.BlockUp()) < 4)
            {
                Block dirt = BlockFactory.GetBlockById(3);
                dirt.Coordinates = Coordinates;
                level.SetBlock(dirt, true, false, false);
            }
        }
Beispiel #8
0
        public override void OnTick(Level level, bool isRandom)
        {
            if (!isRandom)
            {
                return;
            }

            if (!level.IsTransparent(Coordinates + BlockCoordinates.Up))
            {
                Block dirt = BlockFactory.GetBlockById(3);
                dirt.Coordinates = Coordinates;
                level.SetBlock(dirt, true, false, false);
            }

            //TODO: Do grass spreading here
        }
Beispiel #9
0
        public override void OnTick(Level level, bool isRandom)
        {
            if (level.GameMode == GameMode.Creative)
            {
                return;
            }
            if (!isRandom)
            {
                return;
            }

            var lightLevel = level.GetSubtractedLight(Coordinates.BlockUp());

            if (lightLevel < 4 /* && check opacity */)
            {
                Block dirt = BlockFactory.GetBlockById(3);
                dirt.Coordinates = Coordinates;
                level.SetBlock(dirt, true, false, false);
            }
            else
            {
                if (lightLevel >= 9)
                {
                    Random random = new Random();
                    for (int i = 0; i < 4; i++)
                    {
                        var   coordinates = Coordinates + new BlockCoordinates(random.Next(3) - 1, random.Next(5) - 3, random.Next(3) - 1);
                        Block next        = level.GetBlock(coordinates);
                        if (next is Dirt && next.Metadata == 0)
                        {
                            Block nextUp = level.GetBlock(coordinates.BlockUp());
                            if (nextUp.IsTransparent && (nextUp.BlockLight >= 4 || nextUp.SkyLight >= 4))
                            {
                                level.SetBlock(new Grass {
                                    Coordinates = coordinates
                                });
                            }
                        }
                    }
                }
            }
        }
Beispiel #10
0
        public override bool PlaceBlock(Level world, Player player, BlockCoordinates targetCoordinates, BlockFace face, Vector3 faceCoords)
        {
            if (world.GetBlock(Coordinates) is SnowLayer current)
            {
                if (current.Height < 6)
                {
                    Height = current.Height + 1;
                }
                else
                {
                    if (BlockFactory.GetBlockById(80) is Snow snow)
                    {
                        snow.Coordinates = Coordinates;
                        world.SetBlock(snow);
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #11
0
        public override bool PlaceBlock(Level world, Player player, BlockCoordinates targetCoordinates, BlockFace face, Vector3 faceCoords)
        {
            if (world.GetBlock(Coordinates.BlockDown()) is SnowLayer current)
            {
                if (current.Metadata < 7)
                {
                    Coordinates += BlockCoordinates.Down;
                    Metadata     = (byte)(current.Metadata + 1);
                }
                else
                {
                    if (BlockFactory.GetBlockById(80) is Snow snow)
                    {
                        snow.Coordinates = Coordinates.BlockDown();
                        world.SetBlock(snow);
                    }
                }
            }

            return(false);
        }
Beispiel #12
0
        private void Flow(Level world, int x, int y, int z, int decay)
        {
            if (CanBeFlownInto(world, x, y, z))
            {
                //Block block = world.GetBlock(x, y, z);

                //if (this is FlowingLava)
                //{
                //	this.fizz(world, i, j, k);
                //}
                //else
                //{
                //	block.DoDrop(world, i, j, k, world.getData(i, j, k), 0);
                //}

                Block newBlock = BlockFactory.GetBlockById(Id);
                newBlock.Coordinates = new BlockCoordinates(x, y, z);
                newBlock.Metadata    = (byte)decay;
                world.SetBlock(newBlock, applyPhysics: true);
                world.ScheduleBlockTick(newBlock, TickRate());
            }
        }
Beispiel #13
0
        protected void SetDoubleSlab(Level world, BlockCoordinates coordinates)
        {
            Block slab = _doubleSlabId == -1 ? BlockFactory.GetBlockByName(GetType().Name.Replace("Slab", "DoubleSlab")) : BlockFactory.GetBlockById(_doubleSlabId);

            slab.Coordinates = coordinates;
            slab.SetState(GetState().States);
            world.SetBlock(slab);
        }