Exemplo n.º 1
0
 public static bool IsMobCollided(this BlockState state)
 {
     return(!state.IsSameId(BlockStates.Air()) &&
            !state.IsSameId(BlockStates.Grass()) &&
            !state.IsSameId(BlockStates.LargeFlowers()) &&
            !state.IsSameId(BlockStates.Poppy()) &&
            !state.IsSameId(BlockStates.Dandelion()));
 }
Exemplo n.º 2
0
 public static bool CanMobStand(this BlockState state)
 {
     return(!state.IsSameId(BlockStates.Air()) &&
            !state.IsSameId(BlockStates.Grass()) &&
            !state.IsSameId(BlockStates.Water()) &&
            !state.IsSameId(BlockStates.LargeFlowers()) &&
            !state.IsSameId(BlockStates.Poppy()) &&
            !state.IsSameId(BlockStates.Dandelion()));
 }
Exemplo n.º 3
0
        // 一些特性
        public static int IsLightOpacity(this BlockState state)
        {
            if (state.IsSameId(BlockStates.Air()))
            {
                return(255);
            }
            else if (state.IsSameId(BlockStates.Water()))
            {
                return(255);
            }
            else if (state.IsSameId(BlockStates.Lava()))
            {
                return(255);
            }
            else if (state.IsSameId(BlockStates.Glass()))
            {
                return(255);
            }
            else if (state.IsSameId(BlockStates.Grass()))
            {
                return(255);
            }
            else if (state.IsSameId(BlockStates.Poppy()))
            {
                return(255);
            }
            else if (state.IsSameId(BlockStates.Dandelion()))
            {
                return(255);
            }

            /*
             * else if (state.IsSameId(BlockStates.LargeFlowers()))
             * {
             *  return 255;
             * }
             */
            else
            {
                return(0);
            }
        }
Exemplo n.º 4
0
        public override async Task GenerateSingle(IWorld world, ChunkWorldPos chunkWorldPos, BlockWorldPos pos)
        {
            var curBlock = await GetBlock(world, chunkWorldPos, pos);

            var downBlock = await GetBlock(world, chunkWorldPos, new BlockWorldPos { X = pos.X, Y = pos.Y - 1, Z = pos.Z });

            if (curBlock.IsAir() &&
                downBlock == BlockStates.GrassBlock())
            {
                switch (_flowerType)
                {
                case PlantsType.Poppy:
                    await SetBlock(world, chunkWorldPos, pos, BlockStates.Poppy());

                    break;

                case PlantsType.Dandelion:
                    await SetBlock(world, chunkWorldPos, pos, BlockStates.Dandelion());

                    break;
                }
            }
        }
Exemplo n.º 5
0
        public override void Generate(IWorld world, IGrainFactory grainFactory, ChunkColumnCompactStorage chunk, Biome biome, Random random, BlockWorldPos pos)
        {
            BlockChunkPos chunkPos = pos.ToBlockChunkPos();
            int           x        = chunkPos.X;
            int           y        = chunkPos.Y;
            int           z        = chunkPos.Z;

            // TODO use block accessor
            if (chunk[x, y, z].IsAir() &&
                chunk[x, y - 1, z] == BlockStates.GrassBlock())
            {
                var flowerType = biome.GetRandomFlower(random);
                switch (flowerType)
                {
                case PlantsType.Poppy:
                    chunk[x, y, z] = BlockStates.Poppy();
                    break;

                case PlantsType.Dandelion:
                    chunk[x, y, z] = BlockStates.Dandelion();
                    break;
                }
            }
        }