Exemple #1
0
        public async Task <bool> FinishedDigging(IEntity entity, IGrainFactory grainFactory, IWorld world, BlockWorldPos position, BlockState blockState, long usedTick, GameMode gameMode)
        {
            if (!blockState.IsSameId(BlockStates.Bedrock()))
            {
                var newState = BlockStates.Air();
                await world.SetBlockState(grainFactory, position, newState);

                // 产生 Pickup
                if (gameMode.ModeClass != GameMode.Class.Creative)
                {
                    var chunk        = position.ToChunkWorldPos();
                    var finder       = grainFactory.GetGrain <ICollectableFinder>(world.MakeAddressByPartitionKey(chunk));
                    var blockHandler = BlockHandler.Create((BlockId)blockState.Id);
                    var droppedSlot  = blockHandler.DropBlock(ItemId, blockState);
                    if (!droppedSlot.IsEmpty)
                    {
                        await finder.SpawnPickup(position + new Vector3(0.5f, 0.5f, 0.5f), new[] { droppedSlot }.AsImmutable());
                    }
                }

                return(true);
            }

            return(false);
        }
Exemple #2
0
 public static Block FromBlockState(BlockState blockState)
 {
     if (blockState == BlockStates.Air())
     {
         return(new BlockAir());
     }
     else if (blockState.IsId(BlockId.Stone))
     {
         var stone = new BlockStone();
         stone.BlockState = blockState;
         return(stone);
     }
     else if (blockState == BlockStates.GrassBlock())
     {
         return(new BlockGrassBlock());
     }
     else if (blockState == BlockStates.Dirt())
     {
         return(new BlockDirt());
     }
     else if (blockState == BlockStates.Cobblestone())
     {
         return(new BlockCobblestone());
     }
     else if (blockState.IsId(BlockId.WoodPlanks))
     {
         var planks = new BlockWoodPlanks();
         planks.BlockState = blockState;
         return(planks);
     }
     else if (blockState.IsId(BlockId.Sapling))
     {
         var planks = new BlockSapling();
         planks.BlockState = blockState;
         return(planks);
     }
     else if (blockState == BlockStates.Bedrock())
     {
         return(new BlockBedrock());
     }
     else if (blockState == BlockStates.Water())
     {
         return(new BlockWater());
     }
     else
     {
         return(new BlockAir());
     }
 }
Exemple #3
0
 public BlockBedrock()
 {
     FullBlock             = true;
     LightOpacity          = 255;
     Translucent           = false;
     LightValue            = 0;
     UseNeighborBrightness = false;
     BlockHardness         = 60000.0f;
     BlockResistance       = 60000.0f;
     EnableStats           = false;
     NeedsRandomTick       = true;
     IsBlockContainer      = false;
     BlockSoundType        = null;
     BlockParticleGravity  = 1.0f;
     BlockState            = BlockStates.Bedrock();
     UnlocalizedName       = "bedrock";
 }
Exemple #4
0
        // ��������Ⱥϵ���еķ���
        public virtual void GenerateBiomeTerrain(int seaLevel, Random rand, ChunkColumnStorage chunk, int chunk_x, int chunk_z, int x_in_chunk, int z_in_chunk, double noiseVal)
        {
            BlockState topBlockstate    = _topBlock;
            BlockState fillerBlockstate = _fillerBlock;
            int        surfaceFlag      = -1;
            int        surfaceDepth     = (int)(noiseVal / 3.0D + 3.0D + rand.NextDouble() * 0.25D);

            for (int y = 255; y >= 0; --y)
            {
                if (y <= rand.Next(5))
                {
                    chunk[x_in_chunk, y, z_in_chunk] = BlockStates.Bedrock();
                }
                else
                {
                    BlockState iblockstate = chunk[x_in_chunk, y, z_in_chunk];

                    if (iblockstate.IsAir())
                    {
                        surfaceFlag = -1;
                    }
                    else if (iblockstate == BlockStates.Stone())
                    {
                        // ������ʯͷ��������Ⱥϵ�滻
                        if (surfaceFlag == -1)
                        {
                            if (surfaceDepth <= 0)
                            {
                                topBlockstate    = BlockStates.Air();
                                fillerBlockstate = BlockStates.Stone();
                            }
                            else if (y >= seaLevel - 4 && y <= seaLevel + 1)
                            {
                                topBlockstate    = _topBlock;
                                fillerBlockstate = _fillerBlock;
                            }

                            // TODO �����¶ȱ仯����ˮ��״̬
                            surfaceFlag = surfaceDepth;

                            if (y >= seaLevel - 1)
                            {
                                chunk[x_in_chunk, y, z_in_chunk] = topBlockstate;
                            }
                            else if (y < seaLevel - 7 - surfaceDepth)
                            {
                                topBlockstate    = BlockStates.Air();
                                fillerBlockstate = BlockStates.Stone();
                                chunk[x_in_chunk, y, z_in_chunk] = BlockStates.Gravel();
                            }
                            else
                            {
                                chunk[x_in_chunk, y, z_in_chunk] = fillerBlockstate;
                            }
                        }
                        else if (surfaceFlag > 0)
                        {
                            --surfaceFlag;
                            chunk[x_in_chunk, y, z_in_chunk] = fillerBlockstate;
                        }
                    }
                }
            }
        }