Exemple #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()));
 }
        private async Task PlaceAt(IWorld world, BlockWorldPos pos, PlantsType type)
        {
            if (type == PlantsType.DoubleTallgrass)
            {
                await world.SetBlockStateUnsafe(this.GrainFactory, pos, BlockStates.Grass(GrassType.TallGrass));

                await world.SetBlockStateUnsafe(this.GrainFactory, pos.Up(), BlockStates.Grass(GrassType.TallGrass));
            }
        }
Exemple #3
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()));
 }
        public override async Task GenerateSingle(IWorld world, ChunkWorldPos chunkWorldPos, BlockWorldPos pos)
        {
            // TODO use block accessor
            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())
            {
                await SetBlock(world, chunkWorldPos, pos, BlockStates.Grass());
            }
        }
        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())
            {
                chunk[x, y, z] = BlockStates.Grass(GrassType.TallGrass);
            }
        }
        // 一些特性
        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);
            }
        }
        public static async Task <bool> CanBlockStay(this BlockState state, IWorld world, IGrainFactory grainFactory, int x, int y, int z)
        {
            if (state.IsSameId(BlockStates.Grass()))
            {
                if (y > 0)
                {
                    var downState = await world.GetBlockState(grainFactory, x, y - 1, z);

                    if (downState == BlockStates.Dirt() ||
                        downState == BlockStates.Grass())
                    {
                        return(true);
                    }
                }

                return(false);
            }
            else
            {
                return(true);
            }
        }