示例#1
0
    /**
     * This happens when the block is placed in the world.
     */

    public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
    {
        Block block = Block.list[_result.blockValue.type];

        if (block.shape.IsTerrain())
        {
            _world.SetBlockRPC(_result.clrIdx, _result.blockPos, _result.blockValue, this.Density);
        }
        else if (!block.IsTerrainDecoration)
        {
            _world.SetBlockRPC(_result.clrIdx, _result.blockPos, _result.blockValue, MarchingCubes.DensityAir);
        }
        else
        {
            _world.SetBlockRPC(_result.clrIdx, _result.blockPos, _result.blockValue);
        }

        TileEntityBlockTransformer tileEntityBlockTransformer = _world.GetTileEntity(_result.clrIdx, _result.blockPos) as TileEntityBlockTransformer;

        if (tileEntityBlockTransformer == null)
        {
            Log.Warning("Failed to create tile entity");
            return;
        }
        if (_ea != null && _ea.entityType == EntityType.Player)
        {
            tileEntityBlockTransformer.bPlayerStorage   = true;
            tileEntityBlockTransformer.worldTimeTouched = _world.GetWorldTime();
            tileEntityBlockTransformer.SetEmpty();
        }
        Log.Out("Created successfullly.");
    }